Tracking de l'application VApp (IHM du jeu)

This commit is contained in:
2025-05-11 18:04:12 +02:00
commit 89e9db9b62
17763 changed files with 3718499 additions and 0 deletions

21
VApp/node_modules/worker-timers-broker/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Christoph Guttandin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

5
VApp/node_modules/worker-timers-broker/README.md generated vendored Normal file
View File

@ -0,0 +1,5 @@
# worker-timers-broker
**The broker which is used by the worker-timers package.**
[![version](https://img.shields.io/npm/v/worker-timers-broker.svg?style=flat-square)](https://www.npmjs.com/package/worker-timers-broker)

View File

@ -0,0 +1,3 @@
import { ICallNotification, TWorkerMessage } from 'worker-timers-worker';
export declare const isCallNotification: (message: TWorkerMessage) => message is ICallNotification;
//# sourceMappingURL=call-notification.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"call-notification.d.ts","sourceRoot":"","sources":["../../../src/guards/call-notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEzE,eAAO,MAAM,kBAAkB,YAAa,cAAc,iCAEzD,CAAC"}

View File

@ -0,0 +1,4 @@
export const isCallNotification = (message) => {
return message.method !== undefined && message.method === 'call';
};
//# sourceMappingURL=call-notification.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"call-notification.js","sourceRoot":"","sources":["../../../src/guards/call-notification.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAuB,EAAgC,EAAE;IACxF,OAA2B,OAAQ,CAAC,MAAM,KAAK,SAAS,IAAwB,OAAQ,CAAC,MAAM,KAAK,MAAM,CAAC;AAC/G,CAAC,CAAC"}

View File

@ -0,0 +1,3 @@
import { IClearResponse, TWorkerMessage } from 'worker-timers-worker';
export declare const isClearResponse: (message: TWorkerMessage) => message is IClearResponse;
//# sourceMappingURL=clear-response.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"clear-response.d.ts","sourceRoot":"","sources":["../../../src/guards/clear-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtE,eAAO,MAAM,eAAe,YAAa,cAAc,8BAEtD,CAAC"}

View File

@ -0,0 +1,4 @@
export const isClearResponse = (message) => {
return message.error === null && typeof message.id === 'number';
};
//# sourceMappingURL=clear-response.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"clear-response.js","sourceRoot":"","sources":["../../../src/guards/clear-response.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAuB,EAA6B,EAAE;IAClF,OAAwB,OAAQ,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,OAAO,CAAC,EAAE,KAAK,QAAQ,CAAC;AACtF,CAAC,CAAC"}

View File

@ -0,0 +1,7 @@
export declare const load: (url: string) => {
clearInterval: (timerId: number) => void;
clearTimeout: (timerId: number) => void;
setInterval: (func: Function, delay?: number) => number;
setTimeout: (func: Function, delay?: number) => number;
};
//# sourceMappingURL=module.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI,QAAS,MAAM;6BAiFI,MAAM;4BAaP,MAAM;wBAaV,QAAQ;uBAmCT,QAAQ;CAyBrC,CAAC"}

View File

@ -0,0 +1,142 @@
import { generateUniqueNumber } from 'fast-unique-numbers';
import { isCallNotification } from './guards/call-notification';
import { isClearResponse } from './guards/clear-response';
export const load = (url) => {
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
const scheduledIntervalFunctions = new Map([[0, () => { }]]); // tslint:disable-line no-empty
const scheduledTimeoutFunctions = new Map([[0, () => { }]]); // tslint:disable-line no-empty
const unrespondedRequests = new Map();
const worker = new Worker(url);
worker.addEventListener('message', ({ data }) => {
if (isCallNotification(data)) {
const { params: { timerId, timerType } } = data;
if (timerType === 'interval') {
const idOrFunc = scheduledIntervalFunctions.get(timerId);
if (typeof idOrFunc === 'number') {
const timerIdAndTimerType = unrespondedRequests.get(idOrFunc);
if (timerIdAndTimerType === undefined ||
timerIdAndTimerType.timerId !== timerId ||
timerIdAndTimerType.timerType !== timerType) {
throw new Error('The timer is in an undefined state.');
}
}
else if (typeof idOrFunc !== 'undefined') {
idOrFunc();
}
else {
throw new Error('The timer is in an undefined state.');
}
}
else if (timerType === 'timeout') {
const idOrFunc = scheduledTimeoutFunctions.get(timerId);
if (typeof idOrFunc === 'number') {
const timerIdAndTimerType = unrespondedRequests.get(idOrFunc);
if (timerIdAndTimerType === undefined ||
timerIdAndTimerType.timerId !== timerId ||
timerIdAndTimerType.timerType !== timerType) {
throw new Error('The timer is in an undefined state.');
}
}
else if (typeof idOrFunc !== 'undefined') {
idOrFunc();
// A timeout can be savely deleted because it is only called once.
scheduledTimeoutFunctions.delete(timerId);
}
else {
throw new Error('The timer is in an undefined state.');
}
}
}
else if (isClearResponse(data)) {
const { id } = data;
const timerIdAndTimerType = unrespondedRequests.get(id);
if (timerIdAndTimerType === undefined) {
throw new Error('The timer is in an undefined state.');
}
const { timerId, timerType } = timerIdAndTimerType;
unrespondedRequests.delete(id);
if (timerType === 'interval') {
scheduledIntervalFunctions.delete(timerId);
}
else {
scheduledTimeoutFunctions.delete(timerId);
}
}
else {
const { error: { message } } = data;
throw new Error(message);
}
});
const clearInterval = (timerId) => {
const id = generateUniqueNumber(unrespondedRequests);
unrespondedRequests.set(id, { timerId, timerType: 'interval' });
scheduledIntervalFunctions.set(timerId, id);
worker.postMessage({
id,
method: 'clear',
params: { timerId, timerType: 'interval' }
});
};
const clearTimeout = (timerId) => {
const id = generateUniqueNumber(unrespondedRequests);
unrespondedRequests.set(id, { timerId, timerType: 'timeout' });
scheduledTimeoutFunctions.set(timerId, id);
worker.postMessage({
id,
method: 'clear',
params: { timerId, timerType: 'timeout' }
});
};
const setInterval = (func, delay = 0) => {
const timerId = generateUniqueNumber(scheduledIntervalFunctions);
scheduledIntervalFunctions.set(timerId, () => {
func();
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
if (typeof scheduledIntervalFunctions.get(timerId) === 'function') {
worker.postMessage({
id: null,
method: 'set',
params: {
delay,
now: performance.now(),
timerId,
timerType: 'interval'
}
});
}
});
worker.postMessage({
id: null,
method: 'set',
params: {
delay,
now: performance.now(),
timerId,
timerType: 'interval'
}
});
return timerId;
};
const setTimeout = (func, delay = 0) => {
const timerId = generateUniqueNumber(scheduledTimeoutFunctions);
scheduledTimeoutFunctions.set(timerId, func);
worker.postMessage({
id: null,
method: 'set',
params: {
delay,
now: performance.now(),
timerId,
timerType: 'timeout'
}
});
return timerId;
};
return {
clearInterval,
clearTimeout,
setInterval,
setTimeout
};
};
//# sourceMappingURL=module.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE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AC,CAAC;QAEH,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO;QACH,aAAa;QACb,YAAY;QACZ,WAAW;QACX,UAAU;KACb,CAAC;AACN,CAAC,CAAC"}

View File

@ -0,0 +1,162 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fast-unique-numbers')) :
typeof define === 'function' && define.amd ? define(['exports', 'fast-unique-numbers'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.workerTimersBroker = {}, global.fastUniqueNumbers));
})(this, (function (exports, fastUniqueNumbers) { 'use strict';
var isCallNotification = function isCallNotification(message) {
return message.method !== undefined && message.method === 'call';
};
var isClearResponse = function isClearResponse(message) {
return message.error === null && typeof message.id === 'number';
};
var load = function load(url) {
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
var scheduledIntervalFunctions = new Map([[0, function () {}]]); // tslint:disable-line no-empty
var scheduledTimeoutFunctions = new Map([[0, function () {}]]); // tslint:disable-line no-empty
var unrespondedRequests = new Map();
var worker = new Worker(url);
worker.addEventListener('message', function (_ref) {
var data = _ref.data;
if (isCallNotification(data)) {
var _data$params = data.params,
timerId = _data$params.timerId,
timerType = _data$params.timerType;
if (timerType === 'interval') {
var idOrFunc = scheduledIntervalFunctions.get(timerId);
if (typeof idOrFunc === 'number') {
var timerIdAndTimerType = unrespondedRequests.get(idOrFunc);
if (timerIdAndTimerType === undefined || timerIdAndTimerType.timerId !== timerId || timerIdAndTimerType.timerType !== timerType) {
throw new Error('The timer is in an undefined state.');
}
} else if (typeof idOrFunc !== 'undefined') {
idOrFunc();
} else {
throw new Error('The timer is in an undefined state.');
}
} else if (timerType === 'timeout') {
var _idOrFunc = scheduledTimeoutFunctions.get(timerId);
if (typeof _idOrFunc === 'number') {
var _timerIdAndTimerType = unrespondedRequests.get(_idOrFunc);
if (_timerIdAndTimerType === undefined || _timerIdAndTimerType.timerId !== timerId || _timerIdAndTimerType.timerType !== timerType) {
throw new Error('The timer is in an undefined state.');
}
} else if (typeof _idOrFunc !== 'undefined') {
_idOrFunc();
// A timeout can be savely deleted because it is only called once.
scheduledTimeoutFunctions["delete"](timerId);
} else {
throw new Error('The timer is in an undefined state.');
}
}
} else if (isClearResponse(data)) {
var id = data.id;
var _timerIdAndTimerType2 = unrespondedRequests.get(id);
if (_timerIdAndTimerType2 === undefined) {
throw new Error('The timer is in an undefined state.');
}
var _timerId = _timerIdAndTimerType2.timerId,
_timerType = _timerIdAndTimerType2.timerType;
unrespondedRequests["delete"](id);
if (_timerType === 'interval') {
scheduledIntervalFunctions["delete"](_timerId);
} else {
scheduledTimeoutFunctions["delete"](_timerId);
}
} else {
var message = data.error.message;
throw new Error(message);
}
});
var clearInterval = function clearInterval(timerId) {
var id = fastUniqueNumbers.generateUniqueNumber(unrespondedRequests);
unrespondedRequests.set(id, {
timerId: timerId,
timerType: 'interval'
});
scheduledIntervalFunctions.set(timerId, id);
worker.postMessage({
id: id,
method: 'clear',
params: {
timerId: timerId,
timerType: 'interval'
}
});
};
var clearTimeout = function clearTimeout(timerId) {
var id = fastUniqueNumbers.generateUniqueNumber(unrespondedRequests);
unrespondedRequests.set(id, {
timerId: timerId,
timerType: 'timeout'
});
scheduledTimeoutFunctions.set(timerId, id);
worker.postMessage({
id: id,
method: 'clear',
params: {
timerId: timerId,
timerType: 'timeout'
}
});
};
var setInterval = function setInterval(func) {
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var timerId = fastUniqueNumbers.generateUniqueNumber(scheduledIntervalFunctions);
scheduledIntervalFunctions.set(timerId, function () {
func();
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
if (typeof scheduledIntervalFunctions.get(timerId) === 'function') {
worker.postMessage({
id: null,
method: 'set',
params: {
delay: delay,
now: performance.now(),
timerId: timerId,
timerType: 'interval'
}
});
}
});
worker.postMessage({
id: null,
method: 'set',
params: {
delay: delay,
now: performance.now(),
timerId: timerId,
timerType: 'interval'
}
});
return timerId;
};
var setTimeout = function setTimeout(func) {
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var timerId = fastUniqueNumbers.generateUniqueNumber(scheduledTimeoutFunctions);
scheduledTimeoutFunctions.set(timerId, func);
worker.postMessage({
id: null,
method: 'set',
params: {
delay: delay,
now: performance.now(),
timerId: timerId,
timerType: 'timeout'
}
});
return timerId;
};
return {
clearInterval: clearInterval,
clearTimeout: clearTimeout,
setInterval: setInterval,
setTimeout: setTimeout
};
};
exports.load = load;
}));

84
VApp/node_modules/worker-timers-broker/package.json generated vendored Normal file
View File

@ -0,0 +1,84 @@
{
"author": "Christoph Guttandin",
"bugs": {
"url": "https://github.com/chrisguttandin/worker-timers-broker/issues"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"dependencies": {
"@babel/runtime": "^7.23.9",
"fast-unique-numbers": "^9.0.0",
"tslib": "^2.6.2",
"worker-timers-worker": "^7.0.66"
},
"description": "The broker which is used by the worker-timers package.",
"devDependencies": {
"@babel/core": "^7.23.9",
"@babel/plugin-external-helpers": "^7.23.3",
"@babel/plugin-transform-runtime": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@commitlint/cli": "^18.6.0",
"@commitlint/config-angular": "^18.6.0",
"@rollup/plugin-babel": "^6.0.4",
"chai": "^4.3.10",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.56.0",
"eslint-config-holy-grail": "^58.0.2",
"grunt": "^1.6.1",
"grunt-cli": "^1.4.3",
"grunt-sh": "^0.2.1",
"husky": "^8.0.3",
"karma": "^6.4.2",
"karma-chrome-launcher": "^3.2.0",
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-sauce-launcher": "^4.3.6",
"karma-sinon-chai": "^2.0.2",
"karma-webkit-launcher": "^2.4.0",
"karma-webpack": "^5.0.1",
"lint-staged": "^15.2.2",
"load-grunt-config": "^4.0.1",
"mocha": "^10.2.0",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"rollup": "^4.9.6",
"sinon": "^17.0.1",
"sinon-chai": "^3.7.0",
"ts-loader": "^9.5.1",
"tsconfig-holy-grail": "^15.0.0",
"tslint": "^6.1.3",
"tslint-config-holy-grail": "^56.0.0",
"typescript": "^5.3.3",
"webpack": "^5.90.1"
},
"files": [
"build/es2019/",
"build/es5/",
"src/"
],
"homepage": "https://github.com/chrisguttandin/worker-timers-broker",
"license": "MIT",
"main": "build/es5/bundle.js",
"module": "build/es2019/module.js",
"name": "worker-timers-broker",
"repository": {
"type": "git",
"url": "https://github.com/chrisguttandin/worker-timers-broker.git"
},
"scripts": {
"build": "rimraf build/* && tsc --project src/tsconfig.json && rollup --config config/rollup/bundle.mjs",
"lint": "npm run lint:config && npm run lint:src && npm run lint:test",
"lint:config": "eslint --config config/eslint/config.json --ext .js --report-unused-disable-directives config/",
"lint:src": "tslint --config config/tslint/src.json --project src/tsconfig.json src/*.ts src/**/*.ts",
"lint:test": "eslint --config config/eslint/test.json --ext .js --report-unused-disable-directives test/",
"prepare": "husky install",
"prepublishOnly": "npm run build",
"test": "grunt lint && grunt test"
},
"types": "build/es2019/module.d.ts",
"version": "6.1.2"
}

View File

@ -0,0 +1,5 @@
import { ICallNotification, TWorkerMessage } from 'worker-timers-worker';
export const isCallNotification = (message: TWorkerMessage): message is ICallNotification => {
return (<ICallNotification>message).method !== undefined && (<ICallNotification>message).method === 'call';
};

View File

@ -0,0 +1,5 @@
import { IClearResponse, TWorkerMessage } from 'worker-timers-worker';
export const isClearResponse = (message: TWorkerMessage): message is IClearResponse => {
return (<IClearResponse>message).error === null && typeof message.id === 'number';
};

173
VApp/node_modules/worker-timers-broker/src/module.ts generated vendored Normal file
View File

@ -0,0 +1,173 @@
import { generateUniqueNumber } from 'fast-unique-numbers';
import { IClearRequest, ISetNotification, IWorkerEvent, TTimerType } from 'worker-timers-worker';
import { isCallNotification } from './guards/call-notification';
import { isClearResponse } from './guards/clear-response';
export const load = (url: string) => {
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
const scheduledIntervalFunctions: Map<number, number | Function> = new Map([[0, () => {}]]); // tslint:disable-line no-empty
const scheduledTimeoutFunctions: Map<number, number | Function> = new Map([[0, () => {}]]); // tslint:disable-line no-empty
const unrespondedRequests: Map<number, { timerId: number; timerType: TTimerType }> = new Map();
const worker = new Worker(url);
worker.addEventListener('message', ({ data }: IWorkerEvent) => {
if (isCallNotification(data)) {
const {
params: { timerId, timerType }
} = data;
if (timerType === 'interval') {
const idOrFunc = scheduledIntervalFunctions.get(timerId);
if (typeof idOrFunc === 'number') {
const timerIdAndTimerType = unrespondedRequests.get(idOrFunc);
if (
timerIdAndTimerType === undefined ||
timerIdAndTimerType.timerId !== timerId ||
timerIdAndTimerType.timerType !== timerType
) {
throw new Error('The timer is in an undefined state.');
}
} else if (typeof idOrFunc !== 'undefined') {
idOrFunc();
} else {
throw new Error('The timer is in an undefined state.');
}
} else if (timerType === 'timeout') {
const idOrFunc = scheduledTimeoutFunctions.get(timerId);
if (typeof idOrFunc === 'number') {
const timerIdAndTimerType = unrespondedRequests.get(idOrFunc);
if (
timerIdAndTimerType === undefined ||
timerIdAndTimerType.timerId !== timerId ||
timerIdAndTimerType.timerType !== timerType
) {
throw new Error('The timer is in an undefined state.');
}
} else if (typeof idOrFunc !== 'undefined') {
idOrFunc();
// A timeout can be savely deleted because it is only called once.
scheduledTimeoutFunctions.delete(timerId);
} else {
throw new Error('The timer is in an undefined state.');
}
}
} else if (isClearResponse(data)) {
const { id } = data;
const timerIdAndTimerType = unrespondedRequests.get(id);
if (timerIdAndTimerType === undefined) {
throw new Error('The timer is in an undefined state.');
}
const { timerId, timerType } = timerIdAndTimerType;
unrespondedRequests.delete(id);
if (timerType === 'interval') {
scheduledIntervalFunctions.delete(timerId);
} else {
scheduledTimeoutFunctions.delete(timerId);
}
} else {
const {
error: { message }
} = data;
throw new Error(message);
}
});
const clearInterval = (timerId: number) => {
const id = generateUniqueNumber(unrespondedRequests);
unrespondedRequests.set(id, { timerId, timerType: 'interval' });
scheduledIntervalFunctions.set(timerId, id);
worker.postMessage(<IClearRequest>{
id,
method: 'clear',
params: { timerId, timerType: 'interval' }
});
};
const clearTimeout = (timerId: number) => {
const id = generateUniqueNumber(unrespondedRequests);
unrespondedRequests.set(id, { timerId, timerType: 'timeout' });
scheduledTimeoutFunctions.set(timerId, id);
worker.postMessage(<IClearRequest>{
id,
method: 'clear',
params: { timerId, timerType: 'timeout' }
});
};
const setInterval = (func: Function, delay = 0) => {
const timerId = generateUniqueNumber(scheduledIntervalFunctions);
scheduledIntervalFunctions.set(timerId, () => {
func();
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
if (typeof scheduledIntervalFunctions.get(timerId) === 'function') {
worker.postMessage(<ISetNotification>{
id: null,
method: 'set',
params: {
delay,
now: performance.now(),
timerId,
timerType: 'interval'
}
});
}
});
worker.postMessage(<ISetNotification>{
id: null,
method: 'set',
params: {
delay,
now: performance.now(),
timerId,
timerType: 'interval'
}
});
return timerId;
};
const setTimeout = (func: Function, delay = 0) => {
const timerId = generateUniqueNumber(scheduledTimeoutFunctions);
scheduledTimeoutFunctions.set(timerId, func);
worker.postMessage(<ISetNotification>{
id: null,
method: 'set',
params: {
delay,
now: performance.now(),
timerId,
timerType: 'timeout'
}
});
return timerId;
};
return {
clearInterval,
clearTimeout,
setInterval,
setTimeout
};
};

View File

@ -0,0 +1,6 @@
{
"compilerOptions": {
"isolatedModules": true
},
"extends": "tsconfig-holy-grail/src/tsconfig-browser"
}