Tracking de l'application VApp (IHM du jeu)
This commit is contained in:
3
VApp/node_modules/worker-timers-broker/build/es2019/guards/call-notification.d.ts
generated
vendored
Normal file
3
VApp/node_modules/worker-timers-broker/build/es2019/guards/call-notification.d.ts
generated
vendored
Normal 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
|
1
VApp/node_modules/worker-timers-broker/build/es2019/guards/call-notification.d.ts.map
generated
vendored
Normal file
1
VApp/node_modules/worker-timers-broker/build/es2019/guards/call-notification.d.ts.map
generated
vendored
Normal 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"}
|
4
VApp/node_modules/worker-timers-broker/build/es2019/guards/call-notification.js
generated
vendored
Normal file
4
VApp/node_modules/worker-timers-broker/build/es2019/guards/call-notification.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export const isCallNotification = (message) => {
|
||||
return message.method !== undefined && message.method === 'call';
|
||||
};
|
||||
//# sourceMappingURL=call-notification.js.map
|
1
VApp/node_modules/worker-timers-broker/build/es2019/guards/call-notification.js.map
generated
vendored
Normal file
1
VApp/node_modules/worker-timers-broker/build/es2019/guards/call-notification.js.map
generated
vendored
Normal 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"}
|
3
VApp/node_modules/worker-timers-broker/build/es2019/guards/clear-response.d.ts
generated
vendored
Normal file
3
VApp/node_modules/worker-timers-broker/build/es2019/guards/clear-response.d.ts
generated
vendored
Normal 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
|
1
VApp/node_modules/worker-timers-broker/build/es2019/guards/clear-response.d.ts.map
generated
vendored
Normal file
1
VApp/node_modules/worker-timers-broker/build/es2019/guards/clear-response.d.ts.map
generated
vendored
Normal 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"}
|
4
VApp/node_modules/worker-timers-broker/build/es2019/guards/clear-response.js
generated
vendored
Normal file
4
VApp/node_modules/worker-timers-broker/build/es2019/guards/clear-response.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export const isClearResponse = (message) => {
|
||||
return message.error === null && typeof message.id === 'number';
|
||||
};
|
||||
//# sourceMappingURL=clear-response.js.map
|
1
VApp/node_modules/worker-timers-broker/build/es2019/guards/clear-response.js.map
generated
vendored
Normal file
1
VApp/node_modules/worker-timers-broker/build/es2019/guards/clear-response.js.map
generated
vendored
Normal 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"}
|
7
VApp/node_modules/worker-timers-broker/build/es2019/module.d.ts
generated
vendored
Normal file
7
VApp/node_modules/worker-timers-broker/build/es2019/module.d.ts
generated
vendored
Normal 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
|
1
VApp/node_modules/worker-timers-broker/build/es2019/module.d.ts.map
generated
vendored
Normal file
1
VApp/node_modules/worker-timers-broker/build/es2019/module.d.ts.map
generated
vendored
Normal 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"}
|
142
VApp/node_modules/worker-timers-broker/build/es2019/module.js
generated
vendored
Normal file
142
VApp/node_modules/worker-timers-broker/build/es2019/module.js
generated
vendored
Normal 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
|
1
VApp/node_modules/worker-timers-broker/build/es2019/module.js.map
generated
vendored
Normal file
1
VApp/node_modules/worker-timers-broker/build/es2019/module.js.map
generated
vendored
Normal 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,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,EAAE;IAChC,2GAA2G;IAC3G,MAAM,0BAA0B,GAAmC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,+BAA+B;IAC5H,MAAM,yBAAyB,GAAmC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,+BAA+B;IAC3H,MAAM,mBAAmB,GAA4D,IAAI,GAAG,EAAE,CAAC;IAE/F,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;IAE/B,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,EAAgB,EAAE,EAAE;QAC1D,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,EACF,MAAM,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EACjC,GAAG,IAAI,CAAC;YAET,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;gBAC3B,MAAM,QAAQ,GAAG,0BAA0B,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAEzD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;oBAC/B,MAAM,mBAAmB,GAAG,mBAAmB,CAAC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,yBAAyB,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAE7C,MAAM,CAAC,WAAW,CAAmB;YACjC,EAAE,EAAE,IAAI;YACR,MAAM,EAAE,KAAK;YACb,MAAM,EAAE;gBACJ,KAAK;gBACL,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE;gBACtB,OAAO;gBACP,SAAS,EAAE,SAAS;aACvB;SACJ,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO;QACH,aAAa;QACb,YAAY;QACZ,WAAW;QACX,UAAU;KACb,CAAC;AACN,CAAC,CAAC"}
|
162
VApp/node_modules/worker-timers-broker/build/es5/bundle.js
generated
vendored
Normal file
162
VApp/node_modules/worker-timers-broker/build/es5/bundle.js
generated
vendored
Normal 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;
|
||||
|
||||
}));
|
Reference in New Issue
Block a user