uawdijnntqw1x1x1
IP : 216.73.216.110
Hostname : 6.87.74.97.host.secureserver.net
Kernel : Linux 6.87.74.97.host.secureserver.net 4.18.0-553.83.1.el8_10.x86_64 #1 SMP Mon Nov 10 04:22:44 EST 2025 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
home
/
emeraadmin
/
.cpanel
/
..
/
public_html
/
.
/
node_modules
/
make-iterator
/
..
/
..
/
4d695
/
asap.tar
/
/
src/AsapQueue.ts000064400000015575151677317570007634 0ustar00/* eslint-disable no-restricted-globals, @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-vars, @typescript-eslint/no-non-null-assertion */ import type { Task } from './types.js' import { makeRequestCall, makeRequestCallFromTimer } from './makeRequestCall.js' export class AsapQueue { private queue: Task[] = [] // We queue errors to ensure they are thrown in right order (FIFO). // Array-as-queue is good enough here, since we are just dealing with exceptions. private pendingErrors: any[] = [] // Once a flush has been requested, no further calls to `requestFlush` are // necessary until the next `flush` completes. // @ts-ignore private flushing = false // `requestFlush` is an implementation-specific method that attempts to kick // off a `flush` event as quickly as possible. `flush` will attempt to exhaust // the event queue before yielding to the browser's own event loop. private requestFlush: () => void private requestErrorThrow: () => void // The position of the next task to execute in the task queue. This is // preserved between calls to `flush` so that it can be resumed if // a task throws an exception. private index = 0 // If a task schedules additional tasks recursively, the task queue can grow // unbounded. To prevent memory exhaustion, the task queue will periodically // truncate already-completed tasks. private capacity = 1024 public constructor() { // `requestFlush` requests that the high priority event queue be flushed as // soon as possible. // This is useful to prevent an error thrown in a task from stalling the event // queue if the exception handled by Node.js’s // `process.on("uncaughtException")` or by a domain. // `requestFlush` is implemented using a strategy based on data collected from // every available SauceLabs Selenium web driver worker at time of writing. // https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593 this.requestFlush = makeRequestCall(this.flush) this.requestErrorThrow = makeRequestCallFromTimer(() => { // Throw first error if (this.pendingErrors.length) { throw this.pendingErrors.shift() } }) } // Use the fastest means possible to execute a task in its own turn, with // priority over other events including IO, animation, reflow, and redraw // events in browsers. // // An exception thrown by a task will permanently interrupt the processing of // subsequent tasks. The higher level `asap` function ensures that if an // exception is thrown by a task, that the task queue will continue flushing as // soon as possible, but if you use `rawAsap` directly, you are responsible to // either ensure that no exceptions are thrown from your task, or to manually // call `rawAsap.requestFlush` if an exception is thrown. public enqueueTask(task: Task): void { const { queue: q, requestFlush } = this if (!q.length) { requestFlush() this.flushing = true } // Equivalent to push, but avoids a function call. q[q.length] = task } // The flush function processes all tasks that have been scheduled with // `rawAsap` unless and until one of those tasks throws an exception. // If a task throws an exception, `flush` ensures that its state will remain // consistent and will resume where it left off when called again. // However, `flush` does not make any arrangements to be called again if an // exception is thrown. private flush = () => { const { queue: q } = this while (this.index < q.length) { const currentIndex = this.index // Advance the index before calling the task. This ensures that we will // begin flushing on the next task the task throws an error. this.index++ q[currentIndex]!.call() // Prevent leaking memory for long chains of recursive calls to `asap`. // If we call `asap` within tasks scheduled by `asap`, the queue will // grow, but to avoid an O(n) walk for every task we execute, we don't // shift tasks off the queue after they have been executed. // Instead, we periodically shift 1024 tasks off the queue. if (this.index > this.capacity) { // Manually shift all values starting at the index back to the // beginning of the queue. for ( let scan = 0, newLength = q.length - this.index; scan < newLength; scan++ ) { q[scan] = q[scan + this.index]! } q.length -= this.index this.index = 0 } } q.length = 0 this.index = 0 this.flushing = false } // In a web browser, exceptions are not fatal. However, to avoid // slowing down the queue of pending tasks, we rethrow the error in a // lower priority turn. public registerPendingError = (err: any) => { this.pendingErrors.push(err) this.requestErrorThrow() } } // The message channel technique was discovered by Malte Ubl and was the // original foundation for this library. // http://www.nonblocking.io/2011/06/windownexttick.html // Safari 6.0.5 (at least) intermittently fails to create message ports on a // page's first load. Thankfully, this version of Safari supports // MutationObservers, so we don't need to fall back in that case. // function makeRequestCallFromMessageChannel(callback) { // var channel = new MessageChannel(); // channel.port1.onmessage = callback; // return function requestCall() { // channel.port2.postMessage(0); // }; // } // For reasons explained above, we are also unable to use `setImmediate` // under any circumstances. // Even if we were, there is another bug in Internet Explorer 10. // It is not sufficient to assign `setImmediate` to `requestFlush` because // `setImmediate` must be called *by name* and therefore must be wrapped in a // closure. // Never forget. // function makeRequestCallFromSetImmediate(callback) { // return function requestCall() { // setImmediate(callback); // }; // } // Safari 6.0 has a problem where timers will get lost while the user is // scrolling. This problem does not impact ASAP because Safari 6.0 supports // mutation observers, so that implementation is used instead. // However, if we ever elect to use timers in Safari, the prevalent work-around // is to add a scroll event listener that calls for a flush. // `setTimeout` does not call the passed callback if the delay is less than // approximately 7 in web workers in Firefox 8 through 18, and sometimes not // even then. // This is for `asap.js` only. // Its name will be periodically randomized to break any code that depends on // // its existence. // rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer // ASAP was originally a nextTick shim included in Q. This was factored out // into this ASAP package. It was later adapted to RSVP which made further // amendments. These decisions, particularly to marginalize MessageChannel and // to capture the MutationObserver implementation in a closure, were integrated // back into ASAP proper. // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js src/types.ts000064400000000110151677317570007062 0ustar00export interface Task { call(): void } export type TaskFn = () => void src/TaskFactory.ts000064400000000653151677317570010164 0ustar00import type { Task } from './types.js' import { RawTask } from './RawTask.js' export class TaskFactory { private freeTasks: RawTask[] = [] public constructor(private onError: (err: any) => void) {} public create(task: () => void): Task { const tasks = this.freeTasks const t = tasks.length ? (tasks.pop() as RawTask) : new RawTask(this.onError, (t) => (tasks[tasks.length] = t)) t.task = task return t } } src/RawTask.ts000064400000000756151677317570007312 0ustar00// We wrap tasks with recyclable task objects. A task object implements import type { TaskFn, Task } from 'types' // `call`, just like a function. export class RawTask implements Task { public task: TaskFn | null = null public constructor( private onError: (err: any) => void, private release: (t: RawTask) => void, ) {} public call() { try { this.task && this.task() } catch (error) { this.onError(error) } finally { this.task = null this.release(this) } } } src/index.ts000064400000000165151677317570007037 0ustar00export * from './asap.js' export * from './types.js' export * from './AsapQueue.js' export * from './TaskFactory.js' src/asap.ts000064400000001347151677317570006657 0ustar00import { AsapQueue } from './AsapQueue.js' import { TaskFactory } from './TaskFactory.js' import type { TaskFn } from './types.js' const asapQueue = new AsapQueue() const taskFactory = new TaskFactory(asapQueue.registerPendingError) /** * Calls a task as soon as possible after returning, in its own event, with priority * over other events like animation, reflow, and repaint. An error thrown from an * event will not interrupt, nor even substantially slow down the processing of * other events, but will be rather postponed to a lower priority event. * @param {{call}} task A callable object, typically a function that takes no * arguments. */ export function asap(task: TaskFn) { asapQueue.enqueueTask(taskFactory.create(task)) } src/makeRequestCall.ts000064400000007075151677317600011013 0ustar00// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that // have WebKitMutationObserver but not un-prefixed MutationObserver. // Must use `global` or `self` instead of `window` to work in both frames and web // workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. /* globals self */ const scope = typeof global !== 'undefined' ? global : self const BrowserMutationObserver = (scope as any).MutationObserver || (scope as any).WebKitMutationObserver export function makeRequestCallFromTimer(callback: () => void) { return function requestCall() { // We dispatch a timeout with a specified delay of 0 for engines that // can reliably accommodate that request. This will usually be snapped // to a 4 milisecond delay, but once we're flushing, there's no delay // between events. const timeoutHandle = setTimeout(handleTimer, 0) // However, since this timer gets frequently dropped in Firefox // workers, we enlist an interval handle that will try to fire // an event 20 times per second until it succeeds. const intervalHandle = setInterval(handleTimer, 50) function handleTimer() { // Whichever timer succeeds will cancel both timers and // execute the callback. clearTimeout(timeoutHandle) clearInterval(intervalHandle) callback() } } } // To request a high priority event, we induce a mutation observer by toggling // the text of a text node between "1" and "-1". export function makeRequestCallFromMutationObserver(callback: () => void) { let toggle = 1 const observer = new BrowserMutationObserver(callback) const node = document.createTextNode('') observer.observe(node, { characterData: true }) return function requestCall() { toggle = -toggle ;(node as any).data = toggle } } export const makeRequestCall = typeof BrowserMutationObserver === 'function' ? // MutationObservers are desirable because they have high priority and work // reliably everywhere they are implemented. // They are implemented in all modern browsers. // // - Android 4-4.3 // - Chrome 26-34 // - Firefox 14-29 // - Internet Explorer 11 // - iPad Safari 6-7.1 // - iPhone Safari 7-7.1 // - Safari 6-7 makeRequestCallFromMutationObserver : // MessageChannels are desirable because they give direct access to the HTML // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera // 11-12, and in web workers in many engines. // Although message channels yield to any queued rendering and IO tasks, they // would be better than imposing the 4ms delay of timers. // However, they do not work reliably in Internet Explorer or Safari. // Internet Explorer 10 is the only browser that has setImmediate but does // not have MutationObservers. // Although setImmediate yields to the browser's renderer, it would be // preferrable to falling back to setTimeout since it does not have // the minimum 4ms penalty. // Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and // Desktop to a lesser extent) that renders both setImmediate and // MessageChannel useless for the purposes of ASAP. // https://github.com/kriskowal/q/issues/396 // Timers are implemented universally. // We fall back to timers in workers in most engines, and in foreground // contexts in the following browsers. // However, note that even this simple case requires nuances to operate in a // broad spectrum of browsers. // // - Firefox 3-13 // - Internet Explorer 6-9 // - iPad Safari 4.3 // - Lynx 2.8.7 makeRequestCallFromTimer package.json000064400000004017151677317600007051 0ustar00{ "_from": "@react-dnd/asap@^4.0.0", "_id": "@react-dnd/asap@4.0.1", "_inBundle": false, "_integrity": "sha512-kLy0PJDDwvwwTXxqTFNAAllPHD73AycE9ypWeln/IguoGBEbvFcPDbCV03G52bEcC5E+YgupBE0VzHGdC8SIXg==", "_location": "/@react-dnd/asap", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, "raw": "@react-dnd/asap@^4.0.0", "name": "@react-dnd/asap", "escapedName": "@react-dnd%2fasap", "scope": "@react-dnd", "rawSpec": "^4.0.0", "saveSpec": null, "fetchSpec": "^4.0.0" }, "_requiredBy": [ "/dnd-core" ], "_resolved": "https://registry.npmjs.org/@react-dnd/asap/-/asap-4.0.1.tgz", "_shasum": "5291850a6b58ce6f2da25352a64f1b0674871aab", "_spec": "@react-dnd/asap@^4.0.0", "_where": "C:\\xampp\\htdocs\\emeraltd\\node_modules\\dnd-core", "bugs": { "url": "https://github.com/react-dnd/react-dnd/issues" }, "bundleDependencies": false, "deprecated": false, "description": "High-priority task queue for Node.js and browsers", "devDependencies": { "@swc/cli": "^0.1.57", "@swc/core": "^1.2.161", "@types/jest": "^24.9.1", "@types/node": "^17.0.23", "npm-run-all": "^4.1.5", "shx": "^0.3.4", "typescript": "^4.6.3" }, "exports": { "import": "./dist/esm/index.mjs", "require": "./dist/cjs/index.js", "types": "./dist/types/index.d.ts" }, "homepage": "https://github.com/react-dnd/react-dnd#readme", "keywords": [ "event", "task", "queue" ], "license": "MIT", "main": "dist/cjs/index.js", "name": "@react-dnd/asap", "repository": { "type": "git", "url": "git+https://github.com/react-dnd/react-dnd.git" }, "scripts": { "build": "run-s build_types build_esm build_cjs esm_hack", "build_cjs": "swc -C module.type=commonjs -d dist/cjs src/", "build_esm": "swc -C module.type=es6 -d dist/esm src/", "build_types": "tsc -b .", "clean": "shx rm -rf dist/", "esm_hack": "node ../../scripts/esmify.mjs" }, "types": "dist/types/index.d.ts", "version": "4.0.1" } CHANGES.md000064400000005520151677317600006155 0ustar00## 2.0.6 Version 2.0.4 adds support for React Native by clarifying in package.json that the browser environment does not support Node.js domains. Why this is necessary, we leave as an exercise for the user. ## 2.0.3 Version 2.0.3 fixes a bug when adjusting the capacity of the task queue. ## 2.0.1-2.02 Version 2.0.1 fixes a bug in the way redirects were expressed that affected the function of Browserify, but which Mr would tolerate. ## 2.0.0 Version 2 of ASAP is a full rewrite with a few salient changes. First, the ASAP source is CommonJS only and designed with [Browserify][] and [Browserify-compatible][mr] module loaders in mind. [browserify]: https://github.com/substack/node-browserify [mr]: https://github.com/montagejs/mr The new version has been refactored in two dimensions. Support for Node.js and browsers have been separated, using Browserify redirects and ASAP has been divided into two modules. The "raw" layer depends on the tasks to catch thrown exceptions and unravel Node.js domains. The full implementation of ASAP is loadable as `require("asap")` in both Node.js and browsers. The raw layer that lacks exception handling overhead is loadable as `require("asap/raw")`. The interface is the same for both layers. Tasks are no longer required to be functions, but can rather be any object that implements `task.call()`. With this feature you can recycle task objects to avoid garbage collector churn and avoid closures in general. The implementation has been rigorously documented so that our successors can understand the scope of the problem that this module solves and all of its nuances, ensuring that the next generation of implementations know what details are essential. - [asap.js](https://github.com/kriskowal/asap/blob/master/asap.js) - [raw.js](https://github.com/kriskowal/asap/blob/master/raw.js) - [browser-asap.js](https://github.com/kriskowal/asap/blob/master/browser-asap.js) - [browser-raw.js](https://github.com/kriskowal/asap/blob/master/browser-raw.js) The new version has also been rigorously tested across a broad spectrum of browsers, in both the window and worker context. The following charts capture the browser test results for the most recent release. The first chart shows test results for ASAP running in the main window context. The second chart shows test results for ASAP running in a web worker context. Test results are inconclusive (grey) on browsers that do not support web workers. These data are captured automatically by [Continuous Integration][].   [continuous integration]: https://github.com/kriskowal/asap/blob/master/CONTRIBUTING.md dist/types/makeRequestCall.d.ts000064400000000405151677317600012543 0ustar00export declare function makeRequestCallFromTimer(callback: () => void): () => void; export declare function makeRequestCallFromMutationObserver(callback: () => void): () => void; export declare const makeRequestCall: typeof makeRequestCallFromMutationObserver; dist/types/asap.d.ts000064400000001000151677317600010375 0ustar00import type { TaskFn } from './types.js'; /** * Calls a task as soon as possible after returning, in its own event, with priority * over other events like animation, reflow, and repaint. An error thrown from an * event will not interrupt, nor even substantially slow down the processing of * other events, but will be rather postponed to a lower priority event. * @param {{call}} task A callable object, typically a function that takes no * arguments. */ export declare function asap(task: TaskFn): void; dist/types/RawTask.d.ts000064400000000376151677317600011044 0ustar00import type { TaskFn, Task } from 'types'; export declare class RawTask implements Task { private onError; private release; task: TaskFn | null; constructor(onError: (err: any) => void, release: (t: RawTask) => void); call(): void; } dist/types/AsapQueue.d.ts000064400000000550151677317600011353 0ustar00import type { Task } from './types.js'; export declare class AsapQueue { private queue; private pendingErrors; private flushing; private requestFlush; private requestErrorThrow; private index; private capacity; constructor(); enqueueTask(task: Task): void; private flush; registerPendingError: (err: any) => void; } dist/types/TaskFactory.d.ts000064400000000313151677317600011711 0ustar00import type { Task } from './types.js'; export declare class TaskFactory { private onError; private freeTasks; constructor(onError: (err: any) => void); create(task: () => void): Task; } dist/types/index.d.ts000064400000000171151677317600010570 0ustar00export * from './asap.js'; export * from './types.js'; export * from './AsapQueue.js'; export * from './TaskFactory.js'; dist/types/types.d.ts000064400000000125151677317600010624 0ustar00export interface Task { call(): void; } export declare type TaskFn = () => void; dist/cjs/AsapQueue.js.map000064400000024615151677317600011316 0ustar00{"version":3,"sources":["../../src/AsapQueue.ts"],"sourcesContent":["/* eslint-disable no-restricted-globals, @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-vars, @typescript-eslint/no-non-null-assertion */\nimport type { Task } from './types.js'\nimport { makeRequestCall, makeRequestCallFromTimer } from './makeRequestCall.js'\n\nexport class AsapQueue {\n\tprivate queue: Task[] = []\n\t// We queue errors to ensure they are thrown in right order (FIFO).\n\t// Array-as-queue is good enough here, since we are just dealing with exceptions.\n\tprivate pendingErrors: any[] = []\n\t// Once a flush has been requested, no further calls to `requestFlush` are\n\t// necessary until the next `flush` completes.\n\t// @ts-ignore\n\tprivate flushing = false\n\t// `requestFlush` is an implementation-specific method that attempts to kick\n\t// off a `flush` event as quickly as possible. `flush` will attempt to exhaust\n\t// the event queue before yielding to the browser's own event loop.\n\tprivate requestFlush: () => void\n\n\tprivate requestErrorThrow: () => void\n\t// The position of the next task to execute in the task queue. This is\n\t// preserved between calls to `flush` so that it can be resumed if\n\t// a task throws an exception.\n\tprivate index = 0\n\t// If a task schedules additional tasks recursively, the task queue can grow\n\t// unbounded. To prevent memory exhaustion, the task queue will periodically\n\t// truncate already-completed tasks.\n\tprivate capacity = 1024\n\n\tpublic constructor() {\n\t\t// `requestFlush` requests that the high priority event queue be flushed as\n\t\t// soon as possible.\n\t\t// This is useful to prevent an error thrown in a task from stalling the event\n\t\t// queue if the exception handled by Node.js’s\n\t\t// `process.on(\"uncaughtException\")` or by a domain.\n\n\t\t// `requestFlush` is implemented using a strategy based on data collected from\n\t\t// every available SauceLabs Selenium web driver worker at time of writing.\n\t\t// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593\n\t\tthis.requestFlush = makeRequestCall(this.flush)\n\t\tthis.requestErrorThrow = makeRequestCallFromTimer(() => {\n\t\t\t// Throw first error\n\t\t\tif (this.pendingErrors.length) {\n\t\t\t\tthrow this.pendingErrors.shift()\n\t\t\t}\n\t\t})\n\t}\n\n\t// Use the fastest means possible to execute a task in its own turn, with\n\t// priority over other events including IO, animation, reflow, and redraw\n\t// events in browsers.\n\t//\n\t// An exception thrown by a task will permanently interrupt the processing of\n\t// subsequent tasks. The higher level `asap` function ensures that if an\n\t// exception is thrown by a task, that the task queue will continue flushing as\n\t// soon as possible, but if you use `rawAsap` directly, you are responsible to\n\t// either ensure that no exceptions are thrown from your task, or to manually\n\t// call `rawAsap.requestFlush` if an exception is thrown.\n\tpublic enqueueTask(task: Task): void {\n\t\tconst { queue: q, requestFlush } = this\n\t\tif (!q.length) {\n\t\t\trequestFlush()\n\t\t\tthis.flushing = true\n\t\t}\n\t\t// Equivalent to push, but avoids a function call.\n\t\tq[q.length] = task\n\t}\n\n\t// The flush function processes all tasks that have been scheduled with\n\t// `rawAsap` unless and until one of those tasks throws an exception.\n\t// If a task throws an exception, `flush` ensures that its state will remain\n\t// consistent and will resume where it left off when called again.\n\t// However, `flush` does not make any arrangements to be called again if an\n\t// exception is thrown.\n\tprivate flush = () => {\n\t\tconst { queue: q } = this\n\t\twhile (this.index < q.length) {\n\t\t\tconst currentIndex = this.index\n\t\t\t// Advance the index before calling the task. This ensures that we will\n\t\t\t// begin flushing on the next task the task throws an error.\n\t\t\tthis.index++\n\t\t\tq[currentIndex]!.call()\n\t\t\t// Prevent leaking memory for long chains of recursive calls to `asap`.\n\t\t\t// If we call `asap` within tasks scheduled by `asap`, the queue will\n\t\t\t// grow, but to avoid an O(n) walk for every task we execute, we don't\n\t\t\t// shift tasks off the queue after they have been executed.\n\t\t\t// Instead, we periodically shift 1024 tasks off the queue.\n\t\t\tif (this.index > this.capacity) {\n\t\t\t\t// Manually shift all values starting at the index back to the\n\t\t\t\t// beginning of the queue.\n\t\t\t\tfor (\n\t\t\t\t\tlet scan = 0, newLength = q.length - this.index;\n\t\t\t\t\tscan < newLength;\n\t\t\t\t\tscan++\n\t\t\t\t) {\n\t\t\t\t\tq[scan] = q[scan + this.index]!\n\t\t\t\t}\n\t\t\t\tq.length -= this.index\n\t\t\t\tthis.index = 0\n\t\t\t}\n\t\t}\n\t\tq.length = 0\n\t\tthis.index = 0\n\t\tthis.flushing = false\n\t}\n\n\t// In a web browser, exceptions are not fatal. However, to avoid\n\t// slowing down the queue of pending tasks, we rethrow the error in a\n\t// lower priority turn.\n\tpublic registerPendingError = (err: any) => {\n\t\tthis.pendingErrors.push(err)\n\t\tthis.requestErrorThrow()\n\t}\n}\n\n// The message channel technique was discovered by Malte Ubl and was the\n// original foundation for this library.\n// http://www.nonblocking.io/2011/06/windownexttick.html\n\n// Safari 6.0.5 (at least) intermittently fails to create message ports on a\n// page's first load. Thankfully, this version of Safari supports\n// MutationObservers, so we don't need to fall back in that case.\n\n// function makeRequestCallFromMessageChannel(callback) {\n// var channel = new MessageChannel();\n// channel.port1.onmessage = callback;\n// return function requestCall() {\n// channel.port2.postMessage(0);\n// };\n// }\n\n// For reasons explained above, we are also unable to use `setImmediate`\n// under any circumstances.\n// Even if we were, there is another bug in Internet Explorer 10.\n// It is not sufficient to assign `setImmediate` to `requestFlush` because\n// `setImmediate` must be called *by name* and therefore must be wrapped in a\n// closure.\n// Never forget.\n\n// function makeRequestCallFromSetImmediate(callback) {\n// return function requestCall() {\n// setImmediate(callback);\n// };\n// }\n\n// Safari 6.0 has a problem where timers will get lost while the user is\n// scrolling. This problem does not impact ASAP because Safari 6.0 supports\n// mutation observers, so that implementation is used instead.\n// However, if we ever elect to use timers in Safari, the prevalent work-around\n// is to add a scroll event listener that calls for a flush.\n\n// `setTimeout` does not call the passed callback if the delay is less than\n// approximately 7 in web workers in Firefox 8 through 18, and sometimes not\n// even then.\n\n// This is for `asap.js` only.\n// Its name will be periodically randomized to break any code that depends on\n// // its existence.\n// rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer\n\n// ASAP was originally a nextTick shim included in Q. This was factored out\n// into this ASAP package. It was later adapted to RSVP which made further\n// amendments. These decisions, particularly to marginalize MessageChannel and\n// to capture the MutationObserver implementation in a closure, were integrated\n// back into ASAP proper.\n// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js\n"],"names":["AsapQueue","enqueueTask","task","queue","q","requestFlush","length","flushing","pendingErrors","index","capacity","flush","currentIndex","call","scan","newLength","registerPendingError","err","push","requestErrorThrow","makeRequestCall","makeRequestCallFromTimer","shift"],"mappings":"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"}dist/cjs/asap.js.map000064400000002376151677317600010351 0ustar00{"version":3,"sources":["../../src/asap.ts"],"sourcesContent":["import { AsapQueue } from './AsapQueue.js'\nimport { TaskFactory } from './TaskFactory.js'\nimport type { TaskFn } from './types.js'\n\nconst asapQueue = new AsapQueue()\nconst taskFactory = new TaskFactory(asapQueue.registerPendingError)\n\n/**\n * Calls a task as soon as possible after returning, in its own event, with priority\n * over other events like animation, reflow, and repaint. An error thrown from an\n * event will not interrupt, nor even substantially slow down the processing of\n * other events, but will be rather postponed to a lower priority event.\n * @param {{call}} task A callable object, typically a function that takes no\n * arguments.\n */\nexport function asap(task: TaskFn) {\n\tasapQueue.enqueueTask(taskFactory.create(task))\n}\n"],"names":["asap","asapQueue","AsapQueue","taskFactory","TaskFactory","registerPendingError","task","enqueueTask","create"],"mappings":"AAAA;;;;QAegBA,IAAI,GAAJA,IAAI;AAfM,IAAA,YAAgB,WAAhB,gBAAgB,CAAA;AACd,IAAA,cAAkB,WAAlB,kBAAkB,CAAA;AAG9C,MAAMC,SAAS,GAAG,IAAIC,YAAS,UAAA,EAAE;AACjC,MAAMC,WAAW,GAAG,IAAIC,cAAW,YAAA,CAACH,SAAS,CAACI,oBAAoB,CAAC;AAU5D,SAASL,IAAI,CAACM,IAAY,EAAE;IAClCL,SAAS,CAACM,WAAW,CAACJ,WAAW,CAACK,MAAM,CAACF,IAAI,CAAC,CAAC;CAC/C"}dist/cjs/types.js.map000064400000000256151677317600010564 0ustar00{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["export interface Task {\n\tcall(): void\n}\nexport type TaskFn = () => void\n"],"names":[],"mappings":"AAAA"}dist/cjs/types.js000064400000000163151677317600010005 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); //# sourceMappingURL=types.js.mapdist/cjs/makeRequestCall.js000064400000007107151677317600011730 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.makeRequestCallFromTimer = makeRequestCallFromTimer; exports.makeRequestCallFromMutationObserver = makeRequestCallFromMutationObserver; exports.makeRequestCall = void 0; // Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that // have WebKitMutationObserver but not un-prefixed MutationObserver. // Must use `global` or `self` instead of `window` to work in both frames and web // workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. /* globals self */ const scope = typeof global !== 'undefined' ? global : self; const BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver; function makeRequestCallFromTimer(callback) { return function requestCall() { // We dispatch a timeout with a specified delay of 0 for engines that // can reliably accommodate that request. This will usually be snapped // to a 4 milisecond delay, but once we're flushing, there's no delay // between events. const timeoutHandle = setTimeout(handleTimer, 0); // However, since this timer gets frequently dropped in Firefox // workers, we enlist an interval handle that will try to fire // an event 20 times per second until it succeeds. const intervalHandle = setInterval(handleTimer, 50); function handleTimer() { // Whichever timer succeeds will cancel both timers and // execute the callback. clearTimeout(timeoutHandle); clearInterval(intervalHandle); callback(); } }; } function makeRequestCallFromMutationObserver(callback) { let toggle = 1; const observer = new BrowserMutationObserver(callback); const node = document.createTextNode(''); observer.observe(node, { characterData: true }); return function requestCall() { toggle = -toggle; node.data = toggle; }; } const makeRequestCall = typeof BrowserMutationObserver === 'function' ? // reliably everywhere they are implemented. // They are implemented in all modern browsers. // // - Android 4-4.3 // - Chrome 26-34 // - Firefox 14-29 // - Internet Explorer 11 // - iPad Safari 6-7.1 // - iPhone Safari 7-7.1 // - Safari 6-7 makeRequestCallFromMutationObserver : // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera // 11-12, and in web workers in many engines. // Although message channels yield to any queued rendering and IO tasks, they // would be better than imposing the 4ms delay of timers. // However, they do not work reliably in Internet Explorer or Safari. // Internet Explorer 10 is the only browser that has setImmediate but does // not have MutationObservers. // Although setImmediate yields to the browser's renderer, it would be // preferrable to falling back to setTimeout since it does not have // the minimum 4ms penalty. // Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and // Desktop to a lesser extent) that renders both setImmediate and // MessageChannel useless for the purposes of ASAP. // https://github.com/kriskowal/q/issues/396 // Timers are implemented universally. // We fall back to timers in workers in most engines, and in foreground // contexts in the following browsers. // However, note that even this simple case requires nuances to operate in a // broad spectrum of browsers. // // - Firefox 3-13 // - Internet Explorer 6-9 // - iPad Safari 4.3 // - Lynx 2.8.7 makeRequestCallFromTimer; exports.makeRequestCall = makeRequestCall; //# sourceMappingURL=makeRequestCall.js.mapdist/cjs/TaskFactory.js000064400000001040151677317600011066 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _rawTaskJs = require("./RawTask.js"); class TaskFactory { create(task) { const tasks = this.freeTasks; const t1 = tasks.length ? tasks.pop() : new _rawTaskJs.RawTask(this.onError, (t)=>tasks[tasks.length] = t ); t1.task = task; return t1; } constructor(onError){ this.onError = onError; this.freeTasks = []; } } exports.TaskFactory = TaskFactory; //# sourceMappingURL=TaskFactory.js.mapdist/cjs/makeRequestCall.js.map000064400000013433151677317600012503 0ustar00{"version":3,"sources":["../../src/makeRequestCall.ts"],"sourcesContent":["// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that\n// have WebKitMutationObserver but not un-prefixed MutationObserver.\n// Must use `global` or `self` instead of `window` to work in both frames and web\n// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.\n\n/* globals self */\nconst scope = typeof global !== 'undefined' ? global : self\nconst BrowserMutationObserver =\n\t(scope as any).MutationObserver || (scope as any).WebKitMutationObserver\n\nexport function makeRequestCallFromTimer(callback: () => void) {\n\treturn function requestCall() {\n\t\t// We dispatch a timeout with a specified delay of 0 for engines that\n\t\t// can reliably accommodate that request. This will usually be snapped\n\t\t// to a 4 milisecond delay, but once we're flushing, there's no delay\n\t\t// between events.\n\t\tconst timeoutHandle = setTimeout(handleTimer, 0)\n\t\t// However, since this timer gets frequently dropped in Firefox\n\t\t// workers, we enlist an interval handle that will try to fire\n\t\t// an event 20 times per second until it succeeds.\n\t\tconst intervalHandle = setInterval(handleTimer, 50)\n\n\t\tfunction handleTimer() {\n\t\t\t// Whichever timer succeeds will cancel both timers and\n\t\t\t// execute the callback.\n\t\t\tclearTimeout(timeoutHandle)\n\t\t\tclearInterval(intervalHandle)\n\t\t\tcallback()\n\t\t}\n\t}\n}\n\n// To request a high priority event, we induce a mutation observer by toggling\n// the text of a text node between \"1\" and \"-1\".\nexport function makeRequestCallFromMutationObserver(callback: () => void) {\n\tlet toggle = 1\n\tconst observer = new BrowserMutationObserver(callback)\n\tconst node = document.createTextNode('')\n\tobserver.observe(node, { characterData: true })\n\treturn function requestCall() {\n\t\ttoggle = -toggle\n\t\t;(node as any).data = toggle\n\t}\n}\n\nexport const makeRequestCall =\n\ttypeof BrowserMutationObserver === 'function'\n\t\t? // MutationObservers are desirable because they have high priority and work\n\t\t // reliably everywhere they are implemented.\n\t\t // They are implemented in all modern browsers.\n\t\t //\n\t\t // - Android 4-4.3\n\t\t // - Chrome 26-34\n\t\t // - Firefox 14-29\n\t\t // - Internet Explorer 11\n\t\t // - iPad Safari 6-7.1\n\t\t // - iPhone Safari 7-7.1\n\t\t // - Safari 6-7\n\t\t makeRequestCallFromMutationObserver\n\t\t: // MessageChannels are desirable because they give direct access to the HTML\n\t\t // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera\n\t\t // 11-12, and in web workers in many engines.\n\t\t // Although message channels yield to any queued rendering and IO tasks, they\n\t\t // would be better than imposing the 4ms delay of timers.\n\t\t // However, they do not work reliably in Internet Explorer or Safari.\n\n\t\t // Internet Explorer 10 is the only browser that has setImmediate but does\n\t\t // not have MutationObservers.\n\t\t // Although setImmediate yields to the browser's renderer, it would be\n\t\t // preferrable to falling back to setTimeout since it does not have\n\t\t // the minimum 4ms penalty.\n\t\t // Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and\n\t\t // Desktop to a lesser extent) that renders both setImmediate and\n\t\t // MessageChannel useless for the purposes of ASAP.\n\t\t // https://github.com/kriskowal/q/issues/396\n\n\t\t // Timers are implemented universally.\n\t\t // We fall back to timers in workers in most engines, and in foreground\n\t\t // contexts in the following browsers.\n\t\t // However, note that even this simple case requires nuances to operate in a\n\t\t // broad spectrum of browsers.\n\t\t //\n\t\t // - Firefox 3-13\n\t\t // - Internet Explorer 6-9\n\t\t // - iPad Safari 4.3\n\t\t // - Lynx 2.8.7\n\t\t makeRequestCallFromTimer\n"],"names":["makeRequestCallFromTimer","makeRequestCallFromMutationObserver","scope","global","self","BrowserMutationObserver","MutationObserver","WebKitMutationObserver","callback","requestCall","timeoutHandle","setTimeout","handleTimer","intervalHandle","setInterval","clearTimeout","clearInterval","toggle","observer","node","document","createTextNode","observe","characterData","data","makeRequestCall"],"mappings":"AAMA;;;;QAIgBA,wBAAwB,GAAxBA,wBAAwB;QAwBxBC,mCAAmC,GAAnCA,mCAAmC;;AAlCnD,4EAA4E;AAC5E,oEAAoE;AACpE,iFAAiF;AACjF,mEAAmE;AAEnE,kBAAkB,CAClB,MAAMC,KAAK,GAAG,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAGC,IAAI;AAC3D,MAAMC,uBAAuB,GAC5B,AAACH,KAAK,CAASI,gBAAgB,IAAI,AAACJ,KAAK,CAASK,sBAAsB;AAElE,SAASP,wBAAwB,CAACQ,QAAoB,EAAE;IAC9D,OAAO,SAASC,WAAW,GAAG;QAC7B,qEAAqE;QACrE,sEAAsE;QACtE,qEAAqE;QACrE,kBAAkB;QAClB,MAAMC,aAAa,GAAGC,UAAU,CAACC,WAAW,EAAE,CAAC,CAAC;QAChD,+DAA+D;QAC/D,8DAA8D;QAC9D,kDAAkD;QAClD,MAAMC,cAAc,GAAGC,WAAW,CAACF,WAAW,EAAE,EAAE,CAAC;QAEnD,SAASA,WAAW,GAAG;YACtB,uDAAuD;YACvD,wBAAwB;YACxBG,YAAY,CAACL,aAAa,CAAC;YAC3BM,aAAa,CAACH,cAAc,CAAC;YAC7BL,QAAQ,EAAE;SACV;KACD,CAAA;CACD;AAIM,SAASP,mCAAmC,CAACO,QAAoB,EAAE;IACzE,IAAIS,MAAM,GAAG,CAAC;IACd,MAAMC,QAAQ,GAAG,IAAIb,uBAAuB,CAACG,QAAQ,CAAC;IACtD,MAAMW,IAAI,GAAGC,QAAQ,CAACC,cAAc,CAAC,EAAE,CAAC;IACxCH,QAAQ,CAACI,OAAO,CAACH,IAAI,EAAE;QAAEI,aAAa,EAAE,IAAI;KAAE,CAAC;IAC/C,OAAO,SAASd,WAAW,GAAG;QAC7BQ,MAAM,GAAG,CAACA,MAAM,CACf;QAAA,AAACE,IAAI,CAASK,IAAI,GAAGP,MAAM;KAC5B,CAAA;CACD;AAEM,MAAMQ,eAAe,GAC3B,OAAOpB,uBAAuB,KAAK,UAAU,GAE1C,4CAA4C;AAC5C,+CAA+C;AAC/C,EAAE;AACF,kBAAkB;AAClB,iBAAiB;AACjB,kBAAkB;AAClB,yBAAyB;AACzB,sBAAsB;AACtB,wBAAwB;AACxB,eAAe;AACfJ,mCAAmC,GAEnC,+EAA+E;AAC/E,6CAA6C;AAC7C,6EAA6E;AAC7E,yDAAyD;AACzD,qEAAqE;AAErE,0EAA0E;AAC1E,8BAA8B;AAC9B,sEAAsE;AACtE,mEAAmE;AACnE,2BAA2B;AAC3B,8EAA8E;AAC9E,iEAAiE;AACjE,mDAAmD;AACnD,4CAA4C;AAE5C,sCAAsC;AACtC,uEAAuE;AACvE,sCAAsC;AACtC,4EAA4E;AAC5E,8BAA8B;AAC9B,EAAE;AACF,iBAAiB;AACjB,0BAA0B;AAC1B,oBAAoB;AACpB,eAAe;AACfD,wBAAwB;QAzCfyB,eAAe,GAAfA,eAAe"}dist/cjs/index.js000064400000005246151677317600007757 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _exportNames = {}; var _asapJs = _interopRequireWildcard(require("./asap.js")); Object.keys(_asapJs).forEach(function(key) { if (key === "default" || key === "__esModule") return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; if (key in exports && exports[key] === _asapJs[key]) return; Object.defineProperty(exports, key, { enumerable: true, get: function() { return _asapJs[key]; } }); }); var _typesJs = _interopRequireWildcard(require("./types.js")); Object.keys(_typesJs).forEach(function(key) { if (key === "default" || key === "__esModule") return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; if (key in exports && exports[key] === _typesJs[key]) return; Object.defineProperty(exports, key, { enumerable: true, get: function() { return _typesJs[key]; } }); }); var _asapQueueJs = _interopRequireWildcard(require("./AsapQueue.js")); Object.keys(_asapQueueJs).forEach(function(key) { if (key === "default" || key === "__esModule") return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; if (key in exports && exports[key] === _asapQueueJs[key]) return; Object.defineProperty(exports, key, { enumerable: true, get: function() { return _asapQueueJs[key]; } }); }); var _taskFactoryJs = _interopRequireWildcard(require("./TaskFactory.js")); Object.keys(_taskFactoryJs).forEach(function(key) { if (key === "default" || key === "__esModule") return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; if (key in exports && exports[key] === _taskFactoryJs[key]) return; Object.defineProperty(exports, key, { enumerable: true, get: function() { return _taskFactoryJs[key]; } }); }); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for(var key in obj){ if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } //# sourceMappingURL=index.js.mapdist/cjs/asap.js000064400000000670151677317600007570 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.asap = asap; var _asapQueueJs = require("./AsapQueue.js"); var _taskFactoryJs = require("./TaskFactory.js"); const asapQueue = new _asapQueueJs.AsapQueue(); const taskFactory = new _taskFactoryJs.TaskFactory(asapQueue.registerPendingError); function asap(task) { asapQueue.enqueueTask(taskFactory.create(task)); } //# sourceMappingURL=asap.js.mapdist/cjs/RawTask.js.map000064400000002105151677317600010767 0ustar00{"version":3,"sources":["../../src/RawTask.ts"],"sourcesContent":["// We wrap tasks with recyclable task objects. A task object implements\n\nimport type { TaskFn, Task } from 'types'\n\n// `call`, just like a function.\nexport class RawTask implements Task {\n\tpublic task: TaskFn | null = null\n\n\tpublic constructor(\n\t\tprivate onError: (err: any) => void,\n\t\tprivate release: (t: RawTask) => void,\n\t) {}\n\n\tpublic call() {\n\t\ttry {\n\t\t\tthis.task && this.task()\n\t\t} catch (error) {\n\t\t\tthis.onError(error)\n\t\t} finally {\n\t\t\tthis.task = null\n\t\t\tthis.release(this)\n\t\t}\n\t}\n}\n"],"names":["RawTask","call","task","error","onError","release"],"mappings":"AAEA;;;;AAGO,MAAMA,OAAO;IAQnB,AAAOC,IAAI,GAAG;QACb,IAAI;YACH,IAAI,CAACC,IAAI,IAAI,IAAI,CAACA,IAAI,EAAE;SACxB,CAAC,OAAOC,KAAK,EAAE;YACf,IAAI,CAACC,OAAO,CAACD,KAAK,CAAC;SACnB,QAAS;YACT,IAAI,CAACD,IAAI,GAAG,IAAI;YAChB,IAAI,CAACG,OAAO,CAAC,IAAI,CAAC;SAClB;KACD;IAdD,YACSD,OAA2B,EAC3BC,OAA6B,CACpC;aAFOD,OAA2B,GAA3BA,OAA2B;aAC3BC,OAA6B,GAA7BA,OAA6B;aAJ/BH,IAAI,GAAkB,IAAI;KAK7B;CAYJ;QAlBYF,OAAO,GAAPA,OAAO"}dist/cjs/TaskFactory.js.map000064400000002145151677317600011651 0ustar00{"version":3,"sources":["../../src/TaskFactory.ts"],"sourcesContent":["import type { Task } from './types.js'\nimport { RawTask } from './RawTask.js'\n\nexport class TaskFactory {\n\tprivate freeTasks: RawTask[] = []\n\n\tpublic constructor(private onError: (err: any) => void) {}\n\n\tpublic create(task: () => void): Task {\n\t\tconst tasks = this.freeTasks\n\t\tconst t = tasks.length\n\t\t\t? (tasks.pop() as RawTask)\n\t\t\t: new RawTask(this.onError, (t) => (tasks[tasks.length] = t))\n\t\tt.task = task\n\t\treturn t\n\t}\n}\n"],"names":["TaskFactory","create","task","tasks","freeTasks","t","length","pop","RawTask","onError"],"mappings":"AAAA;;;;AACwB,IAAA,UAAc,WAAd,cAAc,CAAA;AAE/B,MAAMA,WAAW;IAKvB,AAAOC,MAAM,CAACC,IAAgB,EAAQ;QACrC,MAAMC,KAAK,GAAG,IAAI,CAACC,SAAS;QAC5B,MAAMC,EAAC,GAAGF,KAAK,CAACG,MAAM,GAClBH,KAAK,CAACI,GAAG,EAAE,GACZ,IAAIC,UAAO,QAAA,CAAC,IAAI,CAACC,OAAO,EAAE,CAACJ,CAAC,GAAMF,KAAK,CAACA,KAAK,CAACG,MAAM,CAAC,GAAGD,CAAC;QAAC,CAAC;QAC9DA,EAAC,CAACH,IAAI,GAAGA,IAAI;QACb,OAAOG,EAAC,CAAA;KACR;IATD,YAA2BI,OAA2B,CAAE;aAA7BA,OAA2B,GAA3BA,OAA2B;aAF9CL,SAAS,GAAc,EAAE;KAEyB;CAU1D;QAbYJ,WAAW,GAAXA,WAAW"}dist/cjs/RawTask.js000064400000001002151677317600010206 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class RawTask { call() { try { this.task && this.task(); } catch (error) { this.onError(error); } finally{ this.task = null; this.release(this); } } constructor(onError, release){ this.onError = onError; this.release = release; this.task = null; } } exports.RawTask = RawTask; //# sourceMappingURL=RawTask.js.mapdist/cjs/index.js.map000064400000000753151677317600010531 0ustar00{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './asap.js'\nexport * from './types.js'\nexport * from './AsapQueue.js'\nexport * from './TaskFactory.js'\n"],"names":[],"mappings":"AAAA;;;;;8CAAc,WAAW;AAAzB,YAAA,OAAyB;;;2CAAzB,OAAyB;;;;mBAAzB,OAAyB;;;EAAA;+CACX,YAAY;AAA1B,YAAA,QAA0B;;;2CAA1B,QAA0B;;;;mBAA1B,QAA0B;;;EAAA;mDACZ,gBAAgB;AAA9B,YAAA,YAA8B;;;2CAA9B,YAA8B;;;;mBAA9B,YAA8B;;;EAAA;qDAChB,kBAAkB;AAAhC,YAAA,cAAgC;;;2CAAhC,cAAgC;;;;mBAAhC,cAAgC;;;EAAA"}dist/cjs/AsapQueue.js000064400000016367151677317600010547 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _makeRequestCallJs = require("./makeRequestCall.js"); class AsapQueue { // Use the fastest means possible to execute a task in its own turn, with // priority over other events including IO, animation, reflow, and redraw // events in browsers. // // An exception thrown by a task will permanently interrupt the processing of // subsequent tasks. The higher level `asap` function ensures that if an // exception is thrown by a task, that the task queue will continue flushing as // soon as possible, but if you use `rawAsap` directly, you are responsible to // either ensure that no exceptions are thrown from your task, or to manually // call `rawAsap.requestFlush` if an exception is thrown. enqueueTask(task) { const { queue: q , requestFlush } = this; if (!q.length) { requestFlush(); this.flushing = true; } // Equivalent to push, but avoids a function call. q[q.length] = task; } constructor(){ this.queue = []; // We queue errors to ensure they are thrown in right order (FIFO). // Array-as-queue is good enough here, since we are just dealing with exceptions. this.pendingErrors = []; // Once a flush has been requested, no further calls to `requestFlush` are // necessary until the next `flush` completes. // @ts-ignore this.flushing = false; // The position of the next task to execute in the task queue. This is // preserved between calls to `flush` so that it can be resumed if // a task throws an exception. this.index = 0; // If a task schedules additional tasks recursively, the task queue can grow // unbounded. To prevent memory exhaustion, the task queue will periodically // truncate already-completed tasks. this.capacity = 1024; // The flush function processes all tasks that have been scheduled with // `rawAsap` unless and until one of those tasks throws an exception. // If a task throws an exception, `flush` ensures that its state will remain // consistent and will resume where it left off when called again. // However, `flush` does not make any arrangements to be called again if an // exception is thrown. this.flush = ()=>{ const { queue: q } = this; while(this.index < q.length){ const currentIndex = this.index; // Advance the index before calling the task. This ensures that we will // begin flushing on the next task the task throws an error. this.index++; q[currentIndex].call(); // Prevent leaking memory for long chains of recursive calls to `asap`. // If we call `asap` within tasks scheduled by `asap`, the queue will // grow, but to avoid an O(n) walk for every task we execute, we don't // shift tasks off the queue after they have been executed. // Instead, we periodically shift 1024 tasks off the queue. if (this.index > this.capacity) { // Manually shift all values starting at the index back to the // beginning of the queue. for(let scan = 0, newLength = q.length - this.index; scan < newLength; scan++){ q[scan] = q[scan + this.index]; } q.length -= this.index; this.index = 0; } } q.length = 0; this.index = 0; this.flushing = false; }; // In a web browser, exceptions are not fatal. However, to avoid // slowing down the queue of pending tasks, we rethrow the error in a // lower priority turn. this.registerPendingError = (err)=>{ this.pendingErrors.push(err); this.requestErrorThrow(); }; // `requestFlush` requests that the high priority event queue be flushed as // soon as possible. // This is useful to prevent an error thrown in a task from stalling the event // queue if the exception handled by Node.js’s // `process.on("uncaughtException")` or by a domain. // `requestFlush` is implemented using a strategy based on data collected from // every available SauceLabs Selenium web driver worker at time of writing. // https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593 this.requestFlush = (0, _makeRequestCallJs).makeRequestCall(this.flush); this.requestErrorThrow = (0, _makeRequestCallJs).makeRequestCallFromTimer(()=>{ // Throw first error if (this.pendingErrors.length) { throw this.pendingErrors.shift(); } }); } } // The message channel technique was discovered by Malte Ubl and was the // original foundation for this library. // http://www.nonblocking.io/2011/06/windownexttick.html // Safari 6.0.5 (at least) intermittently fails to create message ports on a // page's first load. Thankfully, this version of Safari supports // MutationObservers, so we don't need to fall back in that case. // function makeRequestCallFromMessageChannel(callback) { // var channel = new MessageChannel(); // channel.port1.onmessage = callback; // return function requestCall() { // channel.port2.postMessage(0); // }; // } // For reasons explained above, we are also unable to use `setImmediate` // under any circumstances. // Even if we were, there is another bug in Internet Explorer 10. // It is not sufficient to assign `setImmediate` to `requestFlush` because // `setImmediate` must be called *by name* and therefore must be wrapped in a // closure. // Never forget. // function makeRequestCallFromSetImmediate(callback) { // return function requestCall() { // setImmediate(callback); // }; // } // Safari 6.0 has a problem where timers will get lost while the user is // scrolling. This problem does not impact ASAP because Safari 6.0 supports // mutation observers, so that implementation is used instead. // However, if we ever elect to use timers in Safari, the prevalent work-around // is to add a scroll event listener that calls for a flush. // `setTimeout` does not call the passed callback if the delay is less than // approximately 7 in web workers in Firefox 8 through 18, and sometimes not // even then. // This is for `asap.js` only. // Its name will be periodically randomized to break any code that depends on // // its existence. // rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer // ASAP was originally a nextTick shim included in Q. This was factored out // into this ASAP package. It was later adapted to RSVP which made further // amendments. These decisions, particularly to marginalize MessageChannel and // to capture the MutationObserver implementation in a closure, were integrated // back into ASAP proper. // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js exports.AsapQueue = AsapQueue; //# sourceMappingURL=AsapQueue.js.mapdist/esm/index.mjs.map000064400000000454151677317600010711 0ustar00{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './asap.js'\nexport * from './types.js'\nexport * from './AsapQueue.js'\nexport * from './TaskFactory.js'\n"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA"}dist/esm/TaskFactory.mjs.map000064400000002107151677317600012031 0ustar00{"version":3,"sources":["../../src/TaskFactory.ts"],"sourcesContent":["import type { Task } from './types.js'\nimport { RawTask } from './RawTask.js'\n\nexport class TaskFactory {\n\tprivate freeTasks: RawTask[] = []\n\n\tpublic constructor(private onError: (err: any) => void) {}\n\n\tpublic create(task: () => void): Task {\n\t\tconst tasks = this.freeTasks\n\t\tconst t = tasks.length\n\t\t\t? (tasks.pop() as RawTask)\n\t\t\t: new RawTask(this.onError, (t) => (tasks[tasks.length] = t))\n\t\tt.task = task\n\t\treturn t\n\t}\n}\n"],"names":["RawTask","TaskFactory","create","task","tasks","freeTasks","t","length","pop","onError"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc,CAAA;AAEtC,OAAO,MAAMC,WAAW;IAKvB,AAAOC,MAAM,CAACC,IAAgB,EAAQ;QACrC,MAAMC,KAAK,GAAG,IAAI,CAACC,SAAS;QAC5B,MAAMC,EAAC,GAAGF,KAAK,CAACG,MAAM,GAClBH,KAAK,CAACI,GAAG,EAAE,GACZ,IAAIR,OAAO,CAAC,IAAI,CAACS,OAAO,EAAE,CAACH,CAAC,GAAMF,KAAK,CAACA,KAAK,CAACG,MAAM,CAAC,GAAGD,CAAC;QAAC,CAAC;QAC9DA,EAAC,CAACH,IAAI,GAAGA,IAAI;QACb,OAAOG,EAAC,CAAA;KACR;IATD,YAA2BG,OAA2B,CAAE;aAA7BA,OAA2B,GAA3BA,OAA2B;aAF9CJ,SAAS,GAAc,EAAE;KAEyB;CAU1D"}dist/esm/types.mjs000064400000000057151677317600010171 0ustar00export { }; //# sourceMappingURL=types.mjs.mapdist/esm/makeRequestCall.mjs.map000064400000013355151677317600012670 0ustar00{"version":3,"sources":["../../src/makeRequestCall.ts"],"sourcesContent":["// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that\n// have WebKitMutationObserver but not un-prefixed MutationObserver.\n// Must use `global` or `self` instead of `window` to work in both frames and web\n// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.\n\n/* globals self */\nconst scope = typeof global !== 'undefined' ? global : self\nconst BrowserMutationObserver =\n\t(scope as any).MutationObserver || (scope as any).WebKitMutationObserver\n\nexport function makeRequestCallFromTimer(callback: () => void) {\n\treturn function requestCall() {\n\t\t// We dispatch a timeout with a specified delay of 0 for engines that\n\t\t// can reliably accommodate that request. This will usually be snapped\n\t\t// to a 4 milisecond delay, but once we're flushing, there's no delay\n\t\t// between events.\n\t\tconst timeoutHandle = setTimeout(handleTimer, 0)\n\t\t// However, since this timer gets frequently dropped in Firefox\n\t\t// workers, we enlist an interval handle that will try to fire\n\t\t// an event 20 times per second until it succeeds.\n\t\tconst intervalHandle = setInterval(handleTimer, 50)\n\n\t\tfunction handleTimer() {\n\t\t\t// Whichever timer succeeds will cancel both timers and\n\t\t\t// execute the callback.\n\t\t\tclearTimeout(timeoutHandle)\n\t\t\tclearInterval(intervalHandle)\n\t\t\tcallback()\n\t\t}\n\t}\n}\n\n// To request a high priority event, we induce a mutation observer by toggling\n// the text of a text node between \"1\" and \"-1\".\nexport function makeRequestCallFromMutationObserver(callback: () => void) {\n\tlet toggle = 1\n\tconst observer = new BrowserMutationObserver(callback)\n\tconst node = document.createTextNode('')\n\tobserver.observe(node, { characterData: true })\n\treturn function requestCall() {\n\t\ttoggle = -toggle\n\t\t;(node as any).data = toggle\n\t}\n}\n\nexport const makeRequestCall =\n\ttypeof BrowserMutationObserver === 'function'\n\t\t? // MutationObservers are desirable because they have high priority and work\n\t\t // reliably everywhere they are implemented.\n\t\t // They are implemented in all modern browsers.\n\t\t //\n\t\t // - Android 4-4.3\n\t\t // - Chrome 26-34\n\t\t // - Firefox 14-29\n\t\t // - Internet Explorer 11\n\t\t // - iPad Safari 6-7.1\n\t\t // - iPhone Safari 7-7.1\n\t\t // - Safari 6-7\n\t\t makeRequestCallFromMutationObserver\n\t\t: // MessageChannels are desirable because they give direct access to the HTML\n\t\t // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera\n\t\t // 11-12, and in web workers in many engines.\n\t\t // Although message channels yield to any queued rendering and IO tasks, they\n\t\t // would be better than imposing the 4ms delay of timers.\n\t\t // However, they do not work reliably in Internet Explorer or Safari.\n\n\t\t // Internet Explorer 10 is the only browser that has setImmediate but does\n\t\t // not have MutationObservers.\n\t\t // Although setImmediate yields to the browser's renderer, it would be\n\t\t // preferrable to falling back to setTimeout since it does not have\n\t\t // the minimum 4ms penalty.\n\t\t // Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and\n\t\t // Desktop to a lesser extent) that renders both setImmediate and\n\t\t // MessageChannel useless for the purposes of ASAP.\n\t\t // https://github.com/kriskowal/q/issues/396\n\n\t\t // Timers are implemented universally.\n\t\t // We fall back to timers in workers in most engines, and in foreground\n\t\t // contexts in the following browsers.\n\t\t // However, note that even this simple case requires nuances to operate in a\n\t\t // broad spectrum of browsers.\n\t\t //\n\t\t // - Firefox 3-13\n\t\t // - Internet Explorer 6-9\n\t\t // - iPad Safari 4.3\n\t\t // - Lynx 2.8.7\n\t\t makeRequestCallFromTimer\n"],"names":["scope","global","self","BrowserMutationObserver","MutationObserver","WebKitMutationObserver","makeRequestCallFromTimer","callback","requestCall","timeoutHandle","setTimeout","handleTimer","intervalHandle","setInterval","clearTimeout","clearInterval","makeRequestCallFromMutationObserver","toggle","observer","node","document","createTextNode","observe","characterData","data","makeRequestCall"],"mappings":"AAAA,4EAA4E;AAC5E,oEAAoE;AACpE,iFAAiF;AACjF,mEAAmE;AAEnE,kBAAkB,CAClB,MAAMA,KAAK,GAAG,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAGC,IAAI;AAC3D,MAAMC,uBAAuB,GAC5B,AAACH,KAAK,CAASI,gBAAgB,IAAI,AAACJ,KAAK,CAASK,sBAAsB;AAEzE,OAAO,SAASC,wBAAwB,CAACC,QAAoB,EAAE;IAC9D,OAAO,SAASC,WAAW,GAAG;QAC7B,qEAAqE;QACrE,sEAAsE;QACtE,qEAAqE;QACrE,kBAAkB;QAClB,MAAMC,aAAa,GAAGC,UAAU,CAACC,WAAW,EAAE,CAAC,CAAC;QAChD,+DAA+D;QAC/D,8DAA8D;QAC9D,kDAAkD;QAClD,MAAMC,cAAc,GAAGC,WAAW,CAACF,WAAW,EAAE,EAAE,CAAC;QAEnD,SAASA,WAAW,GAAG;YACtB,uDAAuD;YACvD,wBAAwB;YACxBG,YAAY,CAACL,aAAa,CAAC;YAC3BM,aAAa,CAACH,cAAc,CAAC;YAC7BL,QAAQ,EAAE;SACV;KACD,CAAA;CACD;AAED,8EAA8E;AAC9E,gDAAgD;AAChD,OAAO,SAASS,mCAAmC,CAACT,QAAoB,EAAE;IACzE,IAAIU,MAAM,GAAG,CAAC;IACd,MAAMC,QAAQ,GAAG,IAAIf,uBAAuB,CAACI,QAAQ,CAAC;IACtD,MAAMY,IAAI,GAAGC,QAAQ,CAACC,cAAc,CAAC,EAAE,CAAC;IACxCH,QAAQ,CAACI,OAAO,CAACH,IAAI,EAAE;QAAEI,aAAa,EAAE,IAAI;KAAE,CAAC;IAC/C,OAAO,SAASf,WAAW,GAAG;QAC7BS,MAAM,GAAG,CAACA,MAAM,CACf;QAAA,AAACE,IAAI,CAASK,IAAI,GAAGP,MAAM;KAC5B,CAAA;CACD;AAED,OAAO,MAAMQ,eAAe,GAC3B,OAAOtB,uBAAuB,KAAK,UAAU,GAE1C,4CAA4C;AAC5C,+CAA+C;AAC/C,EAAE;AACF,kBAAkB;AAClB,iBAAiB;AACjB,kBAAkB;AAClB,yBAAyB;AACzB,sBAAsB;AACtB,wBAAwB;AACxB,eAAe;AACfa,mCAAmC,GAEnC,+EAA+E;AAC/E,6CAA6C;AAC7C,6EAA6E;AAC7E,yDAAyD;AACzD,qEAAqE;AAErE,0EAA0E;AAC1E,8BAA8B;AAC9B,sEAAsE;AACtE,mEAAmE;AACnE,2BAA2B;AAC3B,8EAA8E;AAC9E,iEAAiE;AACjE,mDAAmD;AACnD,4CAA4C;AAE5C,sCAAsC;AACtC,uEAAuE;AACvE,sCAAsC;AACtC,4EAA4E;AAC5E,8BAA8B;AAC9B,EAAE;AACF,iBAAiB;AACjB,0BAA0B;AAC1B,oBAAoB;AACpB,eAAe;AACfV,wBAAwB,CAAA"}dist/esm/asap.mjs.map000064400000002351151677317600010524 0ustar00{"version":3,"sources":["../../src/asap.ts"],"sourcesContent":["import { AsapQueue } from './AsapQueue.js'\nimport { TaskFactory } from './TaskFactory.js'\nimport type { TaskFn } from './types.js'\n\nconst asapQueue = new AsapQueue()\nconst taskFactory = new TaskFactory(asapQueue.registerPendingError)\n\n/**\n * Calls a task as soon as possible after returning, in its own event, with priority\n * over other events like animation, reflow, and repaint. An error thrown from an\n * event will not interrupt, nor even substantially slow down the processing of\n * other events, but will be rather postponed to a lower priority event.\n * @param {{call}} task A callable object, typically a function that takes no\n * arguments.\n */\nexport function asap(task: TaskFn) {\n\tasapQueue.enqueueTask(taskFactory.create(task))\n}\n"],"names":["AsapQueue","TaskFactory","asapQueue","taskFactory","registerPendingError","asap","task","enqueueTask","create"],"mappings":"AAAA,SAASA,SAAS,QAAQ,gBAAgB,CAAA;AAC1C,SAASC,WAAW,QAAQ,kBAAkB,CAAA;AAG9C,MAAMC,SAAS,GAAG,IAAIF,SAAS,EAAE;AACjC,MAAMG,WAAW,GAAG,IAAIF,WAAW,CAACC,SAAS,CAACE,oBAAoB,CAAC;AAEnE;;;;;;;GAOG,CACH,OAAO,SAASC,IAAI,CAACC,IAAY,EAAE;IAClCJ,SAAS,CAACK,WAAW,CAACJ,WAAW,CAACK,MAAM,CAACF,IAAI,CAAC,CAAC;CAC/C"}dist/esm/AsapQueue.mjs000064400000016170151677317600010721 0ustar00import { makeRequestCall, makeRequestCallFromTimer } from './makeRequestCall.mjs'; export class AsapQueue { // Use the fastest means possible to execute a task in its own turn, with // priority over other events including IO, animation, reflow, and redraw // events in browsers. // // An exception thrown by a task will permanently interrupt the processing of // subsequent tasks. The higher level `asap` function ensures that if an // exception is thrown by a task, that the task queue will continue flushing as // soon as possible, but if you use `rawAsap` directly, you are responsible to // either ensure that no exceptions are thrown from your task, or to manually // call `rawAsap.requestFlush` if an exception is thrown. enqueueTask(task) { const { queue: q , requestFlush } = this; if (!q.length) { requestFlush(); this.flushing = true; } // Equivalent to push, but avoids a function call. q[q.length] = task; } constructor(){ this.queue = []; // We queue errors to ensure they are thrown in right order (FIFO). // Array-as-queue is good enough here, since we are just dealing with exceptions. this.pendingErrors = []; // Once a flush has been requested, no further calls to `requestFlush` are // necessary until the next `flush` completes. // @ts-ignore this.flushing = false; // The position of the next task to execute in the task queue. This is // preserved between calls to `flush` so that it can be resumed if // a task throws an exception. this.index = 0; // If a task schedules additional tasks recursively, the task queue can grow // unbounded. To prevent memory exhaustion, the task queue will periodically // truncate already-completed tasks. this.capacity = 1024; // The flush function processes all tasks that have been scheduled with // `rawAsap` unless and until one of those tasks throws an exception. // If a task throws an exception, `flush` ensures that its state will remain // consistent and will resume where it left off when called again. // However, `flush` does not make any arrangements to be called again if an // exception is thrown. this.flush = ()=>{ const { queue: q } = this; while(this.index < q.length){ const currentIndex = this.index; // Advance the index before calling the task. This ensures that we will // begin flushing on the next task the task throws an error. this.index++; q[currentIndex].call(); // Prevent leaking memory for long chains of recursive calls to `asap`. // If we call `asap` within tasks scheduled by `asap`, the queue will // grow, but to avoid an O(n) walk for every task we execute, we don't // shift tasks off the queue after they have been executed. // Instead, we periodically shift 1024 tasks off the queue. if (this.index > this.capacity) { // Manually shift all values starting at the index back to the // beginning of the queue. for(let scan = 0, newLength = q.length - this.index; scan < newLength; scan++){ q[scan] = q[scan + this.index]; } q.length -= this.index; this.index = 0; } } q.length = 0; this.index = 0; this.flushing = false; }; // In a web browser, exceptions are not fatal. However, to avoid // slowing down the queue of pending tasks, we rethrow the error in a // lower priority turn. this.registerPendingError = (err)=>{ this.pendingErrors.push(err); this.requestErrorThrow(); }; // `requestFlush` requests that the high priority event queue be flushed as // soon as possible. // This is useful to prevent an error thrown in a task from stalling the event // queue if the exception handled by Node.js’s // `process.on("uncaughtException")` or by a domain. // `requestFlush` is implemented using a strategy based on data collected from // every available SauceLabs Selenium web driver worker at time of writing. // https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593 this.requestFlush = makeRequestCall(this.flush); this.requestErrorThrow = makeRequestCallFromTimer(()=>{ // Throw first error if (this.pendingErrors.length) { throw this.pendingErrors.shift(); } }); } } // The message channel technique was discovered by Malte Ubl and was the // original foundation for this library. // http://www.nonblocking.io/2011/06/windownexttick.html // Safari 6.0.5 (at least) intermittently fails to create message ports on a // page's first load. Thankfully, this version of Safari supports // MutationObservers, so we don't need to fall back in that case. // function makeRequestCallFromMessageChannel(callback) { // var channel = new MessageChannel(); // channel.port1.onmessage = callback; // return function requestCall() { // channel.port2.postMessage(0); // }; // } // For reasons explained above, we are also unable to use `setImmediate` // under any circumstances. // Even if we were, there is another bug in Internet Explorer 10. // It is not sufficient to assign `setImmediate` to `requestFlush` because // `setImmediate` must be called *by name* and therefore must be wrapped in a // closure. // Never forget. // function makeRequestCallFromSetImmediate(callback) { // return function requestCall() { // setImmediate(callback); // }; // } // Safari 6.0 has a problem where timers will get lost while the user is // scrolling. This problem does not impact ASAP because Safari 6.0 supports // mutation observers, so that implementation is used instead. // However, if we ever elect to use timers in Safari, the prevalent work-around // is to add a scroll event listener that calls for a flush. // `setTimeout` does not call the passed callback if the delay is less than // approximately 7 in web workers in Firefox 8 through 18, and sometimes not // even then. // This is for `asap.js` only. // Its name will be periodically randomized to break any code that depends on // // its existence. // rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer // ASAP was originally a nextTick shim included in Q. This was factored out // into this ASAP package. It was later adapted to RSVP which made further // amendments. These decisions, particularly to marginalize MessageChannel and // to capture the MutationObserver implementation in a closure, were integrated // back into ASAP proper. // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js //# sourceMappingURL=AsapQueue.mjs.mapdist/esm/index.mjs000064400000000240151677317600010126 0ustar00export * from './asap.mjs'; export * from './types.mjs'; export * from './AsapQueue.mjs'; export * from './TaskFactory.mjs'; //# sourceMappingURL=index.mjs.mapdist/esm/RawTask.mjs000064400000000677151677317600010411 0ustar00// `call`, just like a function. export class RawTask { call() { try { this.task && this.task(); } catch (error) { this.onError(error); } finally{ this.task = null; this.release(this); } } constructor(onError, release){ this.onError = onError; this.release = release; this.task = null; } } //# sourceMappingURL=RawTask.mjs.mapdist/esm/makeRequestCall.mjs000064400000006657151677317600012123 0ustar00// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that // have WebKitMutationObserver but not un-prefixed MutationObserver. // Must use `global` or `self` instead of `window` to work in both frames and web // workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. /* globals self */ const scope = typeof global !== 'undefined' ? global : self; const BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver; export function makeRequestCallFromTimer(callback) { return function requestCall() { // We dispatch a timeout with a specified delay of 0 for engines that // can reliably accommodate that request. This will usually be snapped // to a 4 milisecond delay, but once we're flushing, there's no delay // between events. const timeoutHandle = setTimeout(handleTimer, 0); // However, since this timer gets frequently dropped in Firefox // workers, we enlist an interval handle that will try to fire // an event 20 times per second until it succeeds. const intervalHandle = setInterval(handleTimer, 50); function handleTimer() { // Whichever timer succeeds will cancel both timers and // execute the callback. clearTimeout(timeoutHandle); clearInterval(intervalHandle); callback(); } }; } // To request a high priority event, we induce a mutation observer by toggling // the text of a text node between "1" and "-1". export function makeRequestCallFromMutationObserver(callback) { let toggle = 1; const observer = new BrowserMutationObserver(callback); const node = document.createTextNode(''); observer.observe(node, { characterData: true }); return function requestCall() { toggle = -toggle; node.data = toggle; }; } export const makeRequestCall = typeof BrowserMutationObserver === 'function' ? // reliably everywhere they are implemented. // They are implemented in all modern browsers. // // - Android 4-4.3 // - Chrome 26-34 // - Firefox 14-29 // - Internet Explorer 11 // - iPad Safari 6-7.1 // - iPhone Safari 7-7.1 // - Safari 6-7 makeRequestCallFromMutationObserver : // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera // 11-12, and in web workers in many engines. // Although message channels yield to any queued rendering and IO tasks, they // would be better than imposing the 4ms delay of timers. // However, they do not work reliably in Internet Explorer or Safari. // Internet Explorer 10 is the only browser that has setImmediate but does // not have MutationObservers. // Although setImmediate yields to the browser's renderer, it would be // preferrable to falling back to setTimeout since it does not have // the minimum 4ms penalty. // Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and // Desktop to a lesser extent) that renders both setImmediate and // MessageChannel useless for the purposes of ASAP. // https://github.com/kriskowal/q/issues/396 // Timers are implemented universally. // We fall back to timers in workers in most engines, and in foreground // contexts in the following browsers. // However, note that even this simple case requires nuances to operate in a // broad spectrum of browsers. // // - Firefox 3-13 // - Internet Explorer 6-9 // - iPad Safari 4.3 // - Lynx 2.8.7 makeRequestCallFromTimer; //# sourceMappingURL=makeRequestCall.mjs.mapdist/esm/TaskFactory.mjs000064400000000650151677317600011256 0ustar00import { RawTask } from './RawTask.mjs'; export class TaskFactory { create(task) { const tasks = this.freeTasks; const t1 = tasks.length ? tasks.pop() : new RawTask(this.onError, (t)=>tasks[tasks.length] = t ); t1.task = task; return t1; } constructor(onError){ this.onError = onError; this.freeTasks = []; } } //# sourceMappingURL=TaskFactory.mjs.mapdist/esm/RawTask.mjs.map000064400000002070151677317600011152 0ustar00{"version":3,"sources":["../../src/RawTask.ts"],"sourcesContent":["// We wrap tasks with recyclable task objects. A task object implements\n\nimport type { TaskFn, Task } from 'types'\n\n// `call`, just like a function.\nexport class RawTask implements Task {\n\tpublic task: TaskFn | null = null\n\n\tpublic constructor(\n\t\tprivate onError: (err: any) => void,\n\t\tprivate release: (t: RawTask) => void,\n\t) {}\n\n\tpublic call() {\n\t\ttry {\n\t\t\tthis.task && this.task()\n\t\t} catch (error) {\n\t\t\tthis.onError(error)\n\t\t} finally {\n\t\t\tthis.task = null\n\t\t\tthis.release(this)\n\t\t}\n\t}\n}\n"],"names":["RawTask","call","task","error","onError","release"],"mappings":"AAIA,gCAAgC;AAChC,OAAO,MAAMA,OAAO;IAQnB,AAAOC,IAAI,GAAG;QACb,IAAI;YACH,IAAI,CAACC,IAAI,IAAI,IAAI,CAACA,IAAI,EAAE;SACxB,CAAC,OAAOC,KAAK,EAAE;YACf,IAAI,CAACC,OAAO,CAACD,KAAK,CAAC;SACnB,QAAS;YACT,IAAI,CAACD,IAAI,GAAG,IAAI;YAChB,IAAI,CAACG,OAAO,CAAC,IAAI,CAAC;SAClB;KACD;IAdD,YACSD,OAA2B,EAC3BC,OAA6B,CACpC;aAFOD,OAA2B,GAA3BA,OAA2B;aAC3BC,OAA6B,GAA7BA,OAA6B;aAJ/BH,IAAI,GAAkB,IAAI;KAK7B;CAYJ"}dist/esm/AsapQueue.mjs.map000064400000024501151677317600011472 0ustar00{"version":3,"sources":["../../src/AsapQueue.ts"],"sourcesContent":["/* eslint-disable no-restricted-globals, @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-vars, @typescript-eslint/no-non-null-assertion */\nimport type { Task } from './types.js'\nimport { makeRequestCall, makeRequestCallFromTimer } from './makeRequestCall.js'\n\nexport class AsapQueue {\n\tprivate queue: Task[] = []\n\t// We queue errors to ensure they are thrown in right order (FIFO).\n\t// Array-as-queue is good enough here, since we are just dealing with exceptions.\n\tprivate pendingErrors: any[] = []\n\t// Once a flush has been requested, no further calls to `requestFlush` are\n\t// necessary until the next `flush` completes.\n\t// @ts-ignore\n\tprivate flushing = false\n\t// `requestFlush` is an implementation-specific method that attempts to kick\n\t// off a `flush` event as quickly as possible. `flush` will attempt to exhaust\n\t// the event queue before yielding to the browser's own event loop.\n\tprivate requestFlush: () => void\n\n\tprivate requestErrorThrow: () => void\n\t// The position of the next task to execute in the task queue. This is\n\t// preserved between calls to `flush` so that it can be resumed if\n\t// a task throws an exception.\n\tprivate index = 0\n\t// If a task schedules additional tasks recursively, the task queue can grow\n\t// unbounded. To prevent memory exhaustion, the task queue will periodically\n\t// truncate already-completed tasks.\n\tprivate capacity = 1024\n\n\tpublic constructor() {\n\t\t// `requestFlush` requests that the high priority event queue be flushed as\n\t\t// soon as possible.\n\t\t// This is useful to prevent an error thrown in a task from stalling the event\n\t\t// queue if the exception handled by Node.js’s\n\t\t// `process.on(\"uncaughtException\")` or by a domain.\n\n\t\t// `requestFlush` is implemented using a strategy based on data collected from\n\t\t// every available SauceLabs Selenium web driver worker at time of writing.\n\t\t// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593\n\t\tthis.requestFlush = makeRequestCall(this.flush)\n\t\tthis.requestErrorThrow = makeRequestCallFromTimer(() => {\n\t\t\t// Throw first error\n\t\t\tif (this.pendingErrors.length) {\n\t\t\t\tthrow this.pendingErrors.shift()\n\t\t\t}\n\t\t})\n\t}\n\n\t// Use the fastest means possible to execute a task in its own turn, with\n\t// priority over other events including IO, animation, reflow, and redraw\n\t// events in browsers.\n\t//\n\t// An exception thrown by a task will permanently interrupt the processing of\n\t// subsequent tasks. The higher level `asap` function ensures that if an\n\t// exception is thrown by a task, that the task queue will continue flushing as\n\t// soon as possible, but if you use `rawAsap` directly, you are responsible to\n\t// either ensure that no exceptions are thrown from your task, or to manually\n\t// call `rawAsap.requestFlush` if an exception is thrown.\n\tpublic enqueueTask(task: Task): void {\n\t\tconst { queue: q, requestFlush } = this\n\t\tif (!q.length) {\n\t\t\trequestFlush()\n\t\t\tthis.flushing = true\n\t\t}\n\t\t// Equivalent to push, but avoids a function call.\n\t\tq[q.length] = task\n\t}\n\n\t// The flush function processes all tasks that have been scheduled with\n\t// `rawAsap` unless and until one of those tasks throws an exception.\n\t// If a task throws an exception, `flush` ensures that its state will remain\n\t// consistent and will resume where it left off when called again.\n\t// However, `flush` does not make any arrangements to be called again if an\n\t// exception is thrown.\n\tprivate flush = () => {\n\t\tconst { queue: q } = this\n\t\twhile (this.index < q.length) {\n\t\t\tconst currentIndex = this.index\n\t\t\t// Advance the index before calling the task. This ensures that we will\n\t\t\t// begin flushing on the next task the task throws an error.\n\t\t\tthis.index++\n\t\t\tq[currentIndex]!.call()\n\t\t\t// Prevent leaking memory for long chains of recursive calls to `asap`.\n\t\t\t// If we call `asap` within tasks scheduled by `asap`, the queue will\n\t\t\t// grow, but to avoid an O(n) walk for every task we execute, we don't\n\t\t\t// shift tasks off the queue after they have been executed.\n\t\t\t// Instead, we periodically shift 1024 tasks off the queue.\n\t\t\tif (this.index > this.capacity) {\n\t\t\t\t// Manually shift all values starting at the index back to the\n\t\t\t\t// beginning of the queue.\n\t\t\t\tfor (\n\t\t\t\t\tlet scan = 0, newLength = q.length - this.index;\n\t\t\t\t\tscan < newLength;\n\t\t\t\t\tscan++\n\t\t\t\t) {\n\t\t\t\t\tq[scan] = q[scan + this.index]!\n\t\t\t\t}\n\t\t\t\tq.length -= this.index\n\t\t\t\tthis.index = 0\n\t\t\t}\n\t\t}\n\t\tq.length = 0\n\t\tthis.index = 0\n\t\tthis.flushing = false\n\t}\n\n\t// In a web browser, exceptions are not fatal. However, to avoid\n\t// slowing down the queue of pending tasks, we rethrow the error in a\n\t// lower priority turn.\n\tpublic registerPendingError = (err: any) => {\n\t\tthis.pendingErrors.push(err)\n\t\tthis.requestErrorThrow()\n\t}\n}\n\n// The message channel technique was discovered by Malte Ubl and was the\n// original foundation for this library.\n// http://www.nonblocking.io/2011/06/windownexttick.html\n\n// Safari 6.0.5 (at least) intermittently fails to create message ports on a\n// page's first load. Thankfully, this version of Safari supports\n// MutationObservers, so we don't need to fall back in that case.\n\n// function makeRequestCallFromMessageChannel(callback) {\n// var channel = new MessageChannel();\n// channel.port1.onmessage = callback;\n// return function requestCall() {\n// channel.port2.postMessage(0);\n// };\n// }\n\n// For reasons explained above, we are also unable to use `setImmediate`\n// under any circumstances.\n// Even if we were, there is another bug in Internet Explorer 10.\n// It is not sufficient to assign `setImmediate` to `requestFlush` because\n// `setImmediate` must be called *by name* and therefore must be wrapped in a\n// closure.\n// Never forget.\n\n// function makeRequestCallFromSetImmediate(callback) {\n// return function requestCall() {\n// setImmediate(callback);\n// };\n// }\n\n// Safari 6.0 has a problem where timers will get lost while the user is\n// scrolling. This problem does not impact ASAP because Safari 6.0 supports\n// mutation observers, so that implementation is used instead.\n// However, if we ever elect to use timers in Safari, the prevalent work-around\n// is to add a scroll event listener that calls for a flush.\n\n// `setTimeout` does not call the passed callback if the delay is less than\n// approximately 7 in web workers in Firefox 8 through 18, and sometimes not\n// even then.\n\n// This is for `asap.js` only.\n// Its name will be periodically randomized to break any code that depends on\n// // its existence.\n// rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer\n\n// ASAP was originally a nextTick shim included in Q. This was factored out\n// into this ASAP package. It was later adapted to RSVP which made further\n// amendments. These decisions, particularly to marginalize MessageChannel and\n// to capture the MutationObserver implementation in a closure, were integrated\n// back into ASAP proper.\n// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js\n"],"names":["makeRequestCall","makeRequestCallFromTimer","AsapQueue","enqueueTask","task","queue","q","requestFlush","length","flushing","pendingErrors","index","capacity","flush","currentIndex","call","scan","newLength","registerPendingError","err","push","requestErrorThrow","shift"],"mappings":"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"}dist/esm/types.mjs.map000064400000000264151677317600010745 0ustar00{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["export interface Task {\n\tcall(): void\n}\nexport type TaskFn = () => void\n"],"names":[],"mappings":"AAAA,WAG+B"}dist/esm/asap.mjs000064400000001340151677317600007745 0ustar00import { AsapQueue } from './AsapQueue.mjs'; import { TaskFactory } from './TaskFactory.mjs'; const asapQueue = new AsapQueue(); const taskFactory = new TaskFactory(asapQueue.registerPendingError); /** * Calls a task as soon as possible after returning, in its own event, with priority * over other events like animation, reflow, and repaint. An error thrown from an * event will not interrupt, nor even substantially slow down the processing of * other events, but will be rather postponed to a lower priority event. * @param {{call}} task A callable object, typically a function that takes no * arguments. */ export function asap(task) { asapQueue.enqueueTask(taskFactory.create(task)); } //# sourceMappingURL=asap.mjs.mapREADME.md000064400000023504151677317600006044 0ustar00# ASAP [](https://travis-ci.org/kriskowal/asap) Promise and asynchronous observer libraries, as well as hand-rolled callback programs and libraries, often need a mechanism to postpone the running of a callback until the next available event. (See [Designing API’s for Asynchrony][zalgo].) The `asap` function runs a task **as soon as possible** but not before it returns, waiting only for the completion of the current event and previously scheduled tasks. ```javascript asap(function () { // ... }) ``` [zalgo]: http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony This CommonJS package provides an `asap` module that exports a function that ruts a task function _as soon as possible_. ASAP strives to schedule events to occur before yielding for IO, reflow, or redrawing. Each event receives an independent stack, with only platform code in parent frames and the events run in the order they are scheduled. ASAP provides a fast event queue that will run tasks until it is empty before yielding to the JavaScript engine's underlying event-loop. When a task gets added to a previously empty event queue, ASAP schedules a flush event, preferring for that event to occur before the JavaScript engine has an opportunity to perform IO tasks or rendering, thus making the first task and subsequent tasks semantically indistinguishable. ASAP uses a variety of techniques to preserve this invariant on different versions of browsers and Node.js. By design, ASAP prevents input events from being handled until the task queue is empty. If the process is busy enough, this may cause incoming connection requests to be dropped, and may cause existing connections to inform the sender to reduce the transmission rate or stall. ASAP allows this on the theory that, if there is enough work to do, there is no sense in looking for trouble. As a consequence, ASAP can interfere with smooth animation. If your task should be tied to the rendering loop, consider using `requestAnimationFrame` instead. A long sequence of tasks can also effect the long running script dialog. If this is a problem, you may be able to use ASAP’s cousin `setImmediate` to break long processes into shorter intervals and periodically allow the browser to breathe. `setImmediate` will yield for IO, reflow, and repaint events. It also returns a handler and can be canceled. For a `setImmediate` shim, consider [YuzuJS setImmediate][setimmediate]. [setimmediate]: https://github.com/YuzuJS/setImmediate Take care. ASAP can sustain infinite recursive calls without warning. It will not halt from a stack overflow, and it will not consume unbounded memory. This is behaviorally equivalent to an infinite loop. As with infinite loops, you can monitor a Node.js process for this behavior with a heart-beat signal. As with infinite loops, a very small amount of caution goes a long way to avoiding problems. ```javascript function loop() { asap(loop) } loop() ``` In browsers, if a task throws an exception, it will not interrupt the flushing of high-priority tasks. The exception will be postponed to a later, low-priority event to avoid slow-downs. In Node.js, if a task throws an exception, ASAP will resume flushing only if—and only after—the error is handled by `domain.on("error")` or `process.on("uncaughtException")`. ## Raw ASAP Checking for exceptions comes at a cost. The package also provides an `asap/raw` module that exports the underlying implementation which is faster but stalls if a task throws an exception. This internal version of the ASAP function does not check for errors. If a task does throw an error, it will stall the event queue unless you manually call `rawAsap.requestFlush()` before throwing the error, or any time after. In Node.js, `asap/raw` also runs all tasks outside any domain. If you need a task to be bound to your domain, you will have to do it manually. ```js if (process.domain) { task = process.domain.bind(task) } rawAsap(task) ``` ## Tasks A task may be any object that implements `call()`. A function will suffice, but closures tend not to be reusable and can cause garbage collector churn. Both `asap` and `rawAsap` accept task objects to give you the option of recycling task objects or using higher callable object abstractions. See the `asap` source for an illustration. ## Compatibility ASAP is tested on Node.js v0.10 and in a broad spectrum of web browsers. The following charts capture the browser test results for the most recent release. The first chart shows test results for ASAP running in the main window context. The second chart shows test results for ASAP running in a web worker context. Test results are inconclusive (grey) on browsers that do not support web workers. These data are captured automatically by [Continuous Integration][]. [continuous integration]: https://github.com/kriskowal/asap/blob/master/CONTRIBUTING.md   ## Caveats When a task is added to an empty event queue, it is not always possible to guarantee that the task queue will begin flushing immediately after the current event. However, once the task queue begins flushing, it will not yield until the queue is empty, even if the queue grows while running tasks. The following browsers allow the use of [DOM mutation observers][] to access the HTML [microtask queue][], and thus begin flushing ASAP's task queue immediately at the end of the current event loop turn, before any rendering or IO: [microtask queue]: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#microtask-queue [dom mutation observers]: http://dom.spec.whatwg.org/#mutation-observers - Android 4–4.3 - Chrome 26–34 - Firefox 14–29 - Internet Explorer 11 - iPad Safari 6–7.1 - iPhone Safari 7–7.1 - Safari 6–7 In the absense of mutation observers, there are a few browsers, and situations like web workers in some of the above browsers, where [message channels][] would be a useful way to avoid falling back to timers. Message channels give direct access to the HTML [task queue][], so the ASAP task queue would flush after any already queued rendering and IO tasks, but without having the minimum delay imposed by timers. However, among these browsers, Internet Explorer 10 and Safari do not reliably dispatch messages, so they are not worth the trouble to implement. [message channels]: http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#message-channels [task queue]: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#concept-task - Internet Explorer 10 - Safair 5.0-1 - Opera 11-12 In the absense of mutation observers, these browsers and the following browsers all fall back to using `setTimeout` and `setInterval` to ensure that a `flush` occurs. The implementation uses both and cancels whatever handler loses the race, since `setTimeout` tends to occasionally skip tasks in unisolated circumstances. Timers generally delay the flushing of ASAP's task queue for four milliseconds. - Firefox 3–13 - Internet Explorer 6–10 - iPad Safari 4.3 - Lynx 2.8.7 ## Heritage ASAP has been factored out of the [Q][] asynchronous promise library. It originally had a naïve implementation in terms of `setTimeout`, but [Malte Ubl][nonblocking] provided an insight that `postMessage` might be useful for creating a high-priority, no-delay event dispatch hack. Since then, Internet Explorer proposed and implemented `setImmediate`. Robert Katić began contributing to Q by measuring the performance of the internal implementation of `asap`, paying particular attention to error recovery. Domenic, Robert, and Kris Kowal collectively settled on the current strategy of unrolling the high-priority event queue internally regardless of what strategy we used to dispatch the potentially lower-priority flush event. Domenic went on to make ASAP cooperate with Node.js domains. [q]: https://github.com/kriskowal/q [nonblocking]: http://www.nonblocking.io/2011/06/windownexttick.html For further reading, Nicholas Zakas provided a thorough article on [The Case for setImmediate][ncz]. [ncz]: http://www.nczonline.net/blog/2013/07/09/the-case-for-setimmediate/ Ember’s RSVP promise implementation later [adopted][rsvp asap] the name ASAP but further developed the implentation. Particularly, The `MessagePort` implementation was abandoned due to interaction [problems with Mobile Internet Explorer][ie problems] in favor of an implementation backed on the newer and more reliable DOM `MutationObserver` interface. These changes were back-ported into this library. [ie problems]: https://github.com/cujojs/when/issues/197 [rsvp asap]: https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js In addition, ASAP factored into `asap` and `asap/raw`, such that `asap` remained exception-safe, but `asap/raw` provided a tight kernel that could be used for tasks that guaranteed that they would not throw exceptions. This core is useful for promise implementations that capture thrown errors in rejected promises and do not need a second safety net. At the same time, the exception handling in `asap` was factored into separate implementations for Node.js and browsers, using the the [Browserify][browser config] `browser` property in `package.json` to instruct browser module loaders and bundlers, including [Browserify][], [Mr][], and [Mop][], to use the browser-only implementation. [browser config]: https://gist.github.com/defunctzombie/4339901 [browserify]: https://github.com/substack/node-browserify [mr]: https://github.com/montagejs/mr [mop]: https://github.com/montagejs/mop ## License Copyright 2009-2014 by Contributors MIT License (enclosed) LICENSE.md000064400000002071151677317600006165 0ustar00Copyright 2009–2014 Contributors. All rights reserved. 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. .swcrc000064400000000312151677317600005677 0ustar00{ "sourceMaps": true, "jsc": { "target": "es2017", "parser": { "syntax": "typescript", "tsx": true }, "transform": { "react": { "runtime": "automatic", "useBuiltins": true } } } } tsconfig.json000064400000000323151677317600007266 0ustar00{ "extends": "../../tsconfig.base.json", "compilerOptions": { "baseUrl": "./src", "emitDeclarationOnly": true, "outDir": "dist/types", "types": ["node", "jest"] }, "include": ["./src"] }
/home/emeraadmin/.cpanel/../public_html/./node_modules/make-iterator/../../4d695/asap.tar