first commit
This commit is contained in:
21
node_modules/worker-timers/LICENSE
generated
vendored
Normal file
21
node_modules/worker-timers/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 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.
|
79
node_modules/worker-timers/README.md
generated
vendored
Normal file
79
node_modules/worker-timers/README.md
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||

|
||||
|
||||
# worker-timers
|
||||
|
||||
**A replacement for setInterval() and setTimeout() which works in unfocused windows.**
|
||||
|
||||
[](https://www.npmjs.com/package/worker-timers)
|
||||
|
||||
## Motivation
|
||||
|
||||
For scripts that rely on [WindowTimers](http://www.w3.org/TR/html5/webappapis.html#timers) like `setInterval()` or `setTimeout()` things get confusing when the site which the script is running on loses focus. Chrome, Firefox and maybe others throttle the frequency at which they invoke those timers to a maximum of once per second in such a situation. However this is only true for the main thread and does not affect the behavior of [Web Workers](http://www.w3.org/TR/workers/). Therefore it is possible to avoid the throttling by using a worker to do the actual scheduling. This is exactly what `worker-timers` does.
|
||||
|
||||
## Getting Started
|
||||
|
||||
`worker-timers` is available as a package on [npm](https://www.npmjs.org/package/worker-timers). Run the following command to install it:
|
||||
|
||||
```shell
|
||||
npm install worker-timers
|
||||
```
|
||||
|
||||
You can then import the exported functions in your code like this:
|
||||
|
||||
```js
|
||||
import { clearInterval, clearTimeout, setInterval, setTimeout } from 'worker-timers';
|
||||
```
|
||||
|
||||
The usage is exactly the same (despite of the [error handling](#error-handling) and the
|
||||
[differentiation between intervals and timeouts](#differentiation-between-intervals-and-timeouts))
|
||||
as with the corresponding functions on the global scope.
|
||||
|
||||
```js
|
||||
var intervalId = setInterval(() => {
|
||||
// do something many times
|
||||
}, 100);
|
||||
|
||||
clearInterval(intervalId);
|
||||
|
||||
var timeoutId = setTimeout(() => {
|
||||
// do something once
|
||||
}, 100);
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
The native WindowTimers are very forgiving. Calling `clearInterval()` or `clearTimeout()` without a value or with an id which doesn't exist will get ignored. In contrast to that `worker-timers` will throw an error when doing so.
|
||||
|
||||
```js
|
||||
// This will return undefined.
|
||||
window.clearTimeout('not-a-timeout-id');
|
||||
|
||||
// This will throw an error.
|
||||
clearTimeout('not-a-timeout-id');
|
||||
```
|
||||
|
||||
## Differentiation between Intervals and Timeouts
|
||||
|
||||
Another difference between `worker-timers` and WindowTimers is that this package maintains two separate lists to store the ids of intervals and timeouts internally. WindowTimers do only have one list which allows intervals to be cancelled by calling `clearTimeout()` and the other way round. This is not possible with `worker-timers`. As mentioned above `worker-timers` will throw an error when provided with an unknown id.
|
||||
|
||||
```js
|
||||
const periodicWork = () => {};
|
||||
|
||||
// This will stop the interval.
|
||||
const windowId = window.setInterval(periodicWork, 100);
|
||||
window.clearTimeout(windowId);
|
||||
|
||||
// This will throw an error.
|
||||
const workerId = setInterval(periodicWork, 100);
|
||||
clearTimeout(workerId);
|
||||
```
|
||||
|
||||
## Server-Side Rendering
|
||||
|
||||
This package is intended to be used in the browser and requires the browser to have [support for Web Workers](https://caniuse.com/#feat=webworkers). It does not contain any fallback which would allow it to run in another environment like Node.js which doesn't know about Web Workers. This is to prevent this package from silently failing in an unsupported browser. But it also means that it needs to be replaced when used in a web project which also supports server-side rendering. The replacement should be straightforward, at least in theory, because each function has the exact same signature as its corresponding builtin function. But the configuration of a real-life project can be tricky. For a concrete example, please have a look at the [worker-timers-ssr-example](https://github.com/newyork-anthonyng/worker-timers-ssr-example) provided by [@newyork-anthonyng](https://github.com/newyork-anthonyng). It shows the usage inside of a server-side rendered React app.
|
||||
|
||||
## Angular (& Zone.js)
|
||||
|
||||
If `worker-timers` is used inside of an Angular app and Zone.js (which is the default) is used to detect changes, the behavior of `worker-timers` can be confusing. Angular is using Zone.js which is patching the native `setInterval()` and `setTimeout()` functions to get notified about the invocation of their callback functions. But Angular (more specifically Zone.js) is not aware of `worker-timers` and doesn't get notified about any callback invocations. Therefore Angular needs to be notified manually about state changes that occur inside of a callback function which was scheduled with the help of `worker-timers`.
|
2
node_modules/worker-timers/build/es2019/factories/load-or-return-broker.d.ts
generated
vendored
Normal file
2
node_modules/worker-timers/build/es2019/factories/load-or-return-broker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare const createLoadOrReturnBroker: <Broker>(loadBroker: (url: string) => Broker, worker: string) => () => Broker;
|
||||
//# sourceMappingURL=load-or-return-broker.d.ts.map
|
1
node_modules/worker-timers/build/es2019/factories/load-or-return-broker.d.ts.map
generated
vendored
Normal file
1
node_modules/worker-timers/build/es2019/factories/load-or-return-broker.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"load-or-return-broker.d.ts","sourceRoot":"","sources":["../../../src/factories/load-or-return-broker.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,uBAAwB,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,UAAU,MAAM,iBAkBnG,CAAC"}
|
15
node_modules/worker-timers/build/es2019/factories/load-or-return-broker.js
generated
vendored
Normal file
15
node_modules/worker-timers/build/es2019/factories/load-or-return-broker.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export const createLoadOrReturnBroker = (loadBroker, worker) => {
|
||||
let broker = null;
|
||||
return () => {
|
||||
if (broker !== null) {
|
||||
return broker;
|
||||
}
|
||||
const blob = new Blob([worker], { type: 'application/javascript; charset=utf-8' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
broker = loadBroker(url);
|
||||
// Bug #1: Edge up until v18 didn't like the URL to be revoked directly.
|
||||
setTimeout(() => URL.revokeObjectURL(url));
|
||||
return broker;
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=load-or-return-broker.js.map
|
1
node_modules/worker-timers/build/es2019/factories/load-or-return-broker.js.map
generated
vendored
Normal file
1
node_modules/worker-timers/build/es2019/factories/load-or-return-broker.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"load-or-return-broker.js","sourceRoot":"","sources":["../../../src/factories/load-or-return-broker.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAS,UAAmC,EAAE,MAAc,EAAE,EAAE;IACpG,IAAI,MAAM,GAAkB,IAAI,CAAC;IAEjC,OAAO,GAAG,EAAE;QACR,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAClB,OAAO,MAAM,CAAC;QAClB,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,uCAAuC,EAAE,CAAC,CAAC;QACnF,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAEtC,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QAEzB,wEAAwE;QACxE,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;QAE3C,OAAO,MAAM,CAAC;IAClB,CAAC,CAAC;AACN,CAAC,CAAC"}
|
6
node_modules/worker-timers/build/es2019/module.d.ts
generated
vendored
Normal file
6
node_modules/worker-timers/build/es2019/module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { load } from 'worker-timers-broker';
|
||||
export declare const clearInterval: ReturnType<typeof load>['clearInterval'];
|
||||
export declare const clearTimeout: ReturnType<typeof load>['clearTimeout'];
|
||||
export declare const setInterval: ReturnType<typeof load>['setInterval'];
|
||||
export declare const setTimeout: ReturnType<typeof load>['setTimeout'];
|
||||
//# sourceMappingURL=module.d.ts.map
|
1
node_modules/worker-timers/build/es2019/module.d.ts.map
generated
vendored
Normal file
1
node_modules/worker-timers/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":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAM5C,eAAO,MAAM,aAAa,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,eAAe,CAA4D,CAAC;AAEhI,eAAO,MAAM,YAAY,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,cAAc,CAA2D,CAAC;AAE7H,eAAO,MAAM,WAAW,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,aAAa,CAA0D,CAAC;AAE1H,eAAO,MAAM,UAAU,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,YAAY,CAAyD,CAAC"}
|
9
node_modules/worker-timers/build/es2019/module.js
generated
vendored
Normal file
9
node_modules/worker-timers/build/es2019/module.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { load } from 'worker-timers-broker';
|
||||
import { createLoadOrReturnBroker } from './factories/load-or-return-broker';
|
||||
import { worker } from './worker/worker';
|
||||
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
||||
export const clearInterval = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
||||
export const clearTimeout = (timerId) => loadOrReturnBroker().clearTimeout(timerId);
|
||||
export const setInterval = (...args) => loadOrReturnBroker().setInterval(...args);
|
||||
export const setTimeout = (...args) => loadOrReturnBroker().setTimeout(...args);
|
||||
//# sourceMappingURL=module.js.map
|
1
node_modules/worker-timers/build/es2019/module.js.map
generated
vendored
Normal file
1
node_modules/worker-timers/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,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,aAAa,GAA6C,CAAC,OAAO,EAAE,EAAE,CAAC,kBAAkB,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAEhI,MAAM,CAAC,MAAM,YAAY,GAA4C,CAAC,OAAO,EAAE,EAAE,CAAC,kBAAkB,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAE7H,MAAM,CAAC,MAAM,WAAW,GAA2C,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,kBAAkB,EAAE,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;AAE1H,MAAM,CAAC,MAAM,UAAU,GAA0C,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,kBAAkB,EAAE,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC"}
|
2
node_modules/worker-timers/build/es2019/worker/worker.d.ts
generated
vendored
Normal file
2
node_modules/worker-timers/build/es2019/worker/worker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare const worker = "(()=>{\"use strict\";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:\"call\",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener(\"message\",(i=>{let{data:s}=i;try{if(\"clear\"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if(\"interval\"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id \"'.concat(t,'\".'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if(\"timeout\"!==i)throw new Error('The given type \"'.concat(i,'\" is not supported'));(e=>{const r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id \"'.concat(e,'\".'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if(\"set\"!==s.method)throw new Error('The given method \"'.concat(s.method,'\" is not supported'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if(\"interval\"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,\"interval\"))})(i,a,n);else{if(\"timeout\"!==d)throw new Error('The given type \"'.concat(d,'\" is not supported'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,\"timeout\"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();";
|
||||
//# sourceMappingURL=worker.d.ts.map
|
1
node_modules/worker-timers/build/es2019/worker/worker.d.ts.map
generated
vendored
Normal file
1
node_modules/worker-timers/build/es2019/worker/worker.d.ts.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../src/worker/worker.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,MAAM,28CAA26C,CAAC"}
|
3
node_modules/worker-timers/build/es2019/worker/worker.js
generated
vendored
Normal file
3
node_modules/worker-timers/build/es2019/worker/worker.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
// This is the minified and stringified code of the worker-timers-worker package.
|
||||
export const worker = `(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id "'.concat(t,'".'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error('The given type "'.concat(i,'" is not supported'));(e=>{const r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error('The given method "'.concat(s.method,'" is not supported'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error('The given type "'.concat(d,'" is not supported'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();`; // tslint:disable-line:max-line-length
|
||||
//# sourceMappingURL=worker.js.map
|
1
node_modules/worker-timers/build/es2019/worker/worker.js.map
generated
vendored
Normal file
1
node_modules/worker-timers/build/es2019/worker/worker.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/worker/worker.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,CAAC,MAAM,MAAM,GAAG,w6CAAw6C,CAAC,CAAC,sCAAsC"}
|
50
node_modules/worker-timers/build/es5/bundle.js
generated
vendored
Normal file
50
node_modules/worker-timers/build/es5/bundle.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('worker-timers-broker')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', 'worker-timers-broker'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.workerTimers = {}, global.workerTimersBroker));
|
||||
})(this, (function (exports, workerTimersBroker) { 'use strict';
|
||||
|
||||
var createLoadOrReturnBroker = function createLoadOrReturnBroker(loadBroker, worker) {
|
||||
var broker = null;
|
||||
return function () {
|
||||
if (broker !== null) {
|
||||
return broker;
|
||||
}
|
||||
var blob = new Blob([worker], {
|
||||
type: 'application/javascript; charset=utf-8'
|
||||
});
|
||||
var url = URL.createObjectURL(blob);
|
||||
broker = loadBroker(url);
|
||||
// Bug #1: Edge up until v18 didn't like the URL to be revoked directly.
|
||||
setTimeout(function () {
|
||||
return URL.revokeObjectURL(url);
|
||||
});
|
||||
return broker;
|
||||
};
|
||||
};
|
||||
|
||||
// This is the minified and stringified code of the worker-timers-worker package.
|
||||
var worker = "(()=>{var e={472:(e,t,r)=>{var o,i;void 0===(i=\"function\"==typeof(o=function(){\"use strict\";var e=new Map,t=new Map,r=function(t){var r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id \"'.concat(t,'\".'));clearTimeout(r),e.delete(t)},o=function(e){var r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id \"'.concat(e,'\".'));clearTimeout(r),t.delete(e)},i=function(e,t){var r,o=performance.now();return{expected:o+(r=e-Math.max(0,o-t)),remainingDelay:r}},n=function e(t,r,o,i){var n=performance.now();n>o?postMessage({id:null,method:\"call\",params:{timerId:r,timerType:i}}):t.set(r,setTimeout(e,o-n,t,r,o,i))},a=function(t,r,o){var a=i(t,o),s=a.expected,d=a.remainingDelay;e.set(r,setTimeout(n,d,e,r,s,\"interval\"))},s=function(e,r,o){var a=i(e,o),s=a.expected,d=a.remainingDelay;t.set(r,setTimeout(n,d,t,r,s,\"timeout\"))};addEventListener(\"message\",(function(e){var t=e.data;try{if(\"clear\"===t.method){var i=t.id,n=t.params,d=n.timerId,c=n.timerType;if(\"interval\"===c)r(d),postMessage({error:null,id:i});else{if(\"timeout\"!==c)throw new Error('The given type \"'.concat(c,'\" is not supported'));o(d),postMessage({error:null,id:i})}}else{if(\"set\"!==t.method)throw new Error('The given method \"'.concat(t.method,'\" is not supported'));var u=t.params,l=u.delay,p=u.now,m=u.timerId,v=u.timerType;if(\"interval\"===v)a(l,m,p);else{if(\"timeout\"!==v)throw new Error('The given type \"'.concat(v,'\" is not supported'));s(l,m,p)}}}catch(e){postMessage({error:{message:e.message},id:t.id,result:null})}}))})?o.call(t,r,t,e):o)||(e.exports=i)}},t={};function r(o){var i=t[o];if(void 0!==i)return i.exports;var n=t[o]={exports:{}};return e[o](n,n.exports,r),n.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{\"use strict\";r(472)})()})();"; // tslint:disable-line:max-line-length
|
||||
|
||||
var loadOrReturnBroker = createLoadOrReturnBroker(workerTimersBroker.load, worker);
|
||||
var clearInterval = function clearInterval(timerId) {
|
||||
return loadOrReturnBroker().clearInterval(timerId);
|
||||
};
|
||||
var clearTimeout = function clearTimeout(timerId) {
|
||||
return loadOrReturnBroker().clearTimeout(timerId);
|
||||
};
|
||||
var setInterval = function setInterval() {
|
||||
var _loadOrReturnBroker;
|
||||
return (_loadOrReturnBroker = loadOrReturnBroker()).setInterval.apply(_loadOrReturnBroker, arguments);
|
||||
};
|
||||
var setTimeout$1 = function setTimeout() {
|
||||
var _loadOrReturnBroker2;
|
||||
return (_loadOrReturnBroker2 = loadOrReturnBroker()).setTimeout.apply(_loadOrReturnBroker2, arguments);
|
||||
};
|
||||
|
||||
exports.clearInterval = clearInterval;
|
||||
exports.clearTimeout = clearTimeout;
|
||||
exports.setInterval = setInterval;
|
||||
exports.setTimeout = setTimeout$1;
|
||||
|
||||
}));
|
106
node_modules/worker-timers/package.json
generated
vendored
Normal file
106
node_modules/worker-timers/package.json
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"author": "Christoph Guttandin",
|
||||
"bugs": {
|
||||
"url": "https://github.com/chrisguttandin/worker-timers/issues"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "cz-conventional-changelog"
|
||||
}
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"email": "a-anng@expedia.com",
|
||||
"name": "Anthony Ng"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.24.5",
|
||||
"tslib": "^2.6.2",
|
||||
"worker-timers-broker": "^6.1.8",
|
||||
"worker-timers-worker": "^7.0.71"
|
||||
},
|
||||
"description": "A replacement for setInterval() and setTimeout() which works in unfocused windows.",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.24.5",
|
||||
"@babel/core": "^7.24.5",
|
||||
"@babel/plugin-external-helpers": "^7.24.1",
|
||||
"@babel/plugin-transform-runtime": "^7.24.3",
|
||||
"@babel/preset-env": "^7.24.5",
|
||||
"@babel/register": "^7.23.7",
|
||||
"@commitlint/cli": "^19.3.0",
|
||||
"@commitlint/config-angular": "^19.3.0",
|
||||
"@rollup/plugin-babel": "^6.0.4",
|
||||
"@rollup/plugin-replace": "^5.0.5",
|
||||
"babel-loader": "^9.1.3",
|
||||
"chai": "^4.3.10",
|
||||
"commitizen": "^4.3.0",
|
||||
"cz-conventional-changelog": "^3.3.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-holy-grail": "^59.0.8",
|
||||
"grunt": "^1.6.1",
|
||||
"grunt-cli": "^1.4.3",
|
||||
"grunt-sh": "^0.2.1",
|
||||
"husky": "^8.0.3",
|
||||
"karma": "^6.4.3",
|
||||
"karma-chrome-launcher": "^3.2.0",
|
||||
"karma-firefox-launcher": "^2.1.3",
|
||||
"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",
|
||||
"memfs": "^4.9.2",
|
||||
"mocha": "^10.4.0",
|
||||
"prettier": "^3.2.5",
|
||||
"rimraf": "^5.0.5",
|
||||
"rollup": "^4.17.2",
|
||||
"sinon": "^17.0.1",
|
||||
"sinon-chai": "^3.7.0",
|
||||
"terser-webpack-plugin": "^5.3.10",
|
||||
"ts-loader": "^9.5.1",
|
||||
"tsconfig-holy-grail": "^15.0.1",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-holy-grail": "^56.0.1",
|
||||
"typescript": "^5.4.5",
|
||||
"webpack": "^5.91.0",
|
||||
"webpack-cli": "^5.1.4"
|
||||
},
|
||||
"files": [
|
||||
"build/es2019/",
|
||||
"build/es5/",
|
||||
"src/"
|
||||
],
|
||||
"homepage": "https://github.com/chrisguttandin/worker-timers",
|
||||
"keywords": [
|
||||
"Web Workers",
|
||||
"WindowTimers",
|
||||
"clearInterval",
|
||||
"clearTimeout",
|
||||
"interval",
|
||||
"setInterval",
|
||||
"setTimeout"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "build/es5/bundle.js",
|
||||
"module": "build/es2019/module.js",
|
||||
"name": "worker-timers",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/chrisguttandin/worker-timers.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rimraf build/* && webpack --config config/webpack/worker-es2019.js && tsc --project src/tsconfig.json && rollup --config config/rollup/bundle.mjs && babel ./build/es2019 --config-file ./config/babel/build.json --out-dir ./build/node",
|
||||
"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": "7.1.8"
|
||||
}
|
19
node_modules/worker-timers/src/factories/load-or-return-broker.ts
generated
vendored
Normal file
19
node_modules/worker-timers/src/factories/load-or-return-broker.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export const createLoadOrReturnBroker = <Broker>(loadBroker: (url: string) => Broker, worker: string) => {
|
||||
let broker: null | Broker = null;
|
||||
|
||||
return () => {
|
||||
if (broker !== null) {
|
||||
return broker;
|
||||
}
|
||||
|
||||
const blob = new Blob([worker], { type: 'application/javascript; charset=utf-8' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
broker = loadBroker(url);
|
||||
|
||||
// Bug #1: Edge up until v18 didn't like the URL to be revoked directly.
|
||||
setTimeout(() => URL.revokeObjectURL(url));
|
||||
|
||||
return broker;
|
||||
};
|
||||
};
|
13
node_modules/worker-timers/src/module.ts
generated
vendored
Normal file
13
node_modules/worker-timers/src/module.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import { load } from 'worker-timers-broker';
|
||||
import { createLoadOrReturnBroker } from './factories/load-or-return-broker';
|
||||
import { worker } from './worker/worker';
|
||||
|
||||
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
||||
|
||||
export const clearInterval: ReturnType<typeof load>['clearInterval'] = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
||||
|
||||
export const clearTimeout: ReturnType<typeof load>['clearTimeout'] = (timerId) => loadOrReturnBroker().clearTimeout(timerId);
|
||||
|
||||
export const setInterval: ReturnType<typeof load>['setInterval'] = (...args) => loadOrReturnBroker().setInterval(...args);
|
||||
|
||||
export const setTimeout: ReturnType<typeof load>['setTimeout'] = (...args) => loadOrReturnBroker().setTimeout(...args);
|
6
node_modules/worker-timers/src/tsconfig.json
generated
vendored
Normal file
6
node_modules/worker-timers/src/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"isolatedModules": true
|
||||
},
|
||||
"extends": "tsconfig-holy-grail/src/tsconfig-browser"
|
||||
}
|
2
node_modules/worker-timers/src/worker/worker.ts
generated
vendored
Normal file
2
node_modules/worker-timers/src/worker/worker.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// This is the minified and stringified code of the worker-timers-worker package.
|
||||
export const worker = `(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id "'.concat(t,'".'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error('The given type "'.concat(i,'" is not supported'));(e=>{const r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error('The given method "'.concat(s.method,'" is not supported'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error('The given type "'.concat(d,'" is not supported'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();`; // tslint:disable-line:max-line-length
|
Reference in New Issue
Block a user