@wordpress/priority-queue 2.10.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.13.0 (2022-07-13)
6
+
7
+ ## 2.12.0 (2022-06-29)
8
+
9
+ ## 2.11.0 (2022-06-15)
10
+
5
11
  ## 2.10.0 (2022-06-01)
6
12
 
7
13
  ## 2.9.0 (2022-05-18)
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/priority-queue/src/index.js"],"names":["createQueue","waitingList","elementsMap","WeakMap","isRunning","runWaitingList","deadline","hasTimeRemaining","timeRemaining","length","nextElement","shift","callback","get","delete","add","element","item","has","push","set","flush","index","indexOf","splice","cancel","reset"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,MAAM;AAChC;AACA,MAAIC,WAAW,GAAG,EAAlB;AAEA;;AACA,MAAIC,WAAW,GAAG,IAAIC,OAAJ,EAAlB;AAEA,MAAIC,SAAS,GAAG,KAAhB;AAEA;AACD;AACA;AACA;AACA;AACA;;AACC,QAAMC,cAAc,GAAKC,QAAF,IAAgB;AACtC,UAAMC,gBAAgB,GACrB,OAAOD,QAAP,KAAoB,QAApB,GACG,MAAM,KADT,GAEG,MAAMA,QAAQ,CAACE,aAAT,KAA2B,CAHrC;;AAKA,OAAG;AACF,UAAKP,WAAW,CAAC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AAA,QAAQ;AAER,WAAO,IAAP;AACA,GAdD;AAgBA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMa,MAAM,GAAKT,OAAF,IAAe;AAC7B,QAAK,CAAEd,WAAW,CAACgB,GAAZ,CAAiBF,OAAjB,CAAP,EAAoC;AACnC,aAAO,KAAP;AACA;;AAED,UAAMM,KAAK,GAAGrB,WAAW,CAACsB,OAAZ,CAAqBP,OAArB,CAAd;AACAf,IAAAA,WAAW,CAACuB,MAAZ,CAAoBF,KAApB,EAA2B,CAA3B;AACApB,IAAAA,WAAW,CAACY,MAAZ,CAAoBE,OAApB;AAEA,WAAO,IAAP;AACA,GAVD;AAYA;AACD;AACA;AACA;AACA;;;AACC,QAAMU,KAAK,GAAG,MAAM;AACnBzB,IAAAA,WAAW,GAAG,EAAd;AACAC,IAAAA,WAAW,GAAG,IAAIC,OAAJ,EAAd;AACAC,IAAAA,SAAS,GAAG,KAAZ;AACA,GAJD;;AAMA,SAAO;AACNW,IAAAA,GADM;AAENM,IAAAA,KAFM;AAGNI,IAAAA,MAHM;AAINC,IAAAA;AAJM,GAAP;AAMA,CA9HM","sourcesContent":["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n *\n * @typedef {()=>void} WPPriorityQueueCallback\n */\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n *\n * @typedef {{}} WPPriorityQueueContext\n */\n\n/**\n * Function to add callback to priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd\n */\n\n/**\n * Function to flush callbacks from priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush\n */\n\n/**\n * Reset the queue.\n *\n * @typedef {()=>void} WPPriorityQueueReset\n */\n\n/**\n * Priority queue instance.\n *\n * @typedef {Object} WPPriorityQueue\n *\n * @property {WPPriorityQueueAdd} add Add callback to queue for context.\n * @property {WPPriorityQueueFlush} flush Flush queue for context.\n * @property {WPPriorityQueueFlush} cancel Clear queue for context.\n * @property {WPPriorityQueueReset} reset Reset queue.\n */\n\n/**\n * Creates a context-aware queue that only executes\n * the last task of a given context.\n *\n * @example\n *```js\n * import { createQueue } from '@wordpress/priority-queue';\n *\n * const queue = createQueue();\n *\n * // Context objects.\n * const ctx1 = {};\n * const ctx2 = {};\n *\n * // For a given context in the queue, only the last callback is executed.\n * queue.add( ctx1, () => console.log( 'This will be printed first' ) );\n * queue.add( ctx2, () => console.log( 'This won\\'t be printed' ) );\n * queue.add( ctx2, () => console.log( 'This will be printed second' ) );\n *```\n *\n * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.\n */\nexport const createQueue = () => {\n\t/** @type {WPPriorityQueueContext[]} */\n\tlet waitingList = [];\n\n\t/** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */\n\tlet elementsMap = new WeakMap();\n\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline ) => {\n\t\tconst hasTimeRemaining =\n\t\t\ttypeof deadline === 'number'\n\t\t\t\t? () => false\n\t\t\t\t: () => deadline.timeRemaining() > 0;\n\n\t\tdo {\n\t\t\tif ( waitingList.length === 0 ) {\n\t\t\t\tisRunning = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextElement = /** @type {WPPriorityQueueContext} */ ( waitingList.shift() );\n\t\t\tconst callback = /** @type {WPPriorityQueueCallback} */ ( elementsMap.get(\n\t\t\t\tnextElement\n\t\t\t) );\n\t\t\t// If errors with undefined callbacks are encountered double check that all of your useSelect calls\n\t\t\t// have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected\n\t\t\t// loops and race conditions in the queue.\n\t\t\tcallback();\n\t\t\telementsMap.delete( nextElement );\n\t\t} while ( hasTimeRemaining() );\n\n\t\trequestIdleCallback( runWaitingList );\n\t};\n\n\t/**\n\t * Add a callback to the queue for a given context.\n\t *\n\t * @type {WPPriorityQueueAdd}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add = ( element, item ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\twaitingList.push( element );\n\t\t}\n\t\telementsMap.set( element, item );\n\t\tif ( ! isRunning ) {\n\t\t\tisRunning = true;\n\t\t\trequestIdleCallback( runWaitingList );\n\t\t}\n\t};\n\n\t/**\n\t * Flushes queue for a given context, returning true if the flush was\n\t * performed, or false if there is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\tconst callback = /** @type {WPPriorityQueueCallback} */ ( elementsMap.get(\n\t\t\telement\n\t\t) );\n\t\telementsMap.delete( element );\n\t\tcallback();\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Clears the queue for a given context, cancelling the callbacks without\n\t * executing them. Returns `true` if there were scheduled callbacks to cancel,\n\t * or `false` if there was is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\telementsMap.delete( element );\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t *\n\t * @type {WPPriorityQueueReset}\n\t */\n\tconst reset = () => {\n\t\twaitingList = [];\n\t\telementsMap = new WeakMap();\n\t\tisRunning = false;\n\t};\n\n\treturn {\n\t\tadd,\n\t\tflush,\n\t\tcancel,\n\t\treset,\n\t};\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/priority-queue/src/index.js"],"names":["createQueue","waitingList","elementsMap","WeakMap","isRunning","runWaitingList","deadline","hasTimeRemaining","timeRemaining","length","nextElement","shift","callback","get","delete","add","element","item","has","push","set","flush","index","indexOf","splice","cancel","reset"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,MAAM;AAChC;AACA,MAAIC,WAAW,GAAG,EAAlB;AAEA;;AACA,MAAIC,WAAW,GAAG,IAAIC,OAAJ,EAAlB;AAEA,MAAIC,SAAS,GAAG,KAAhB;AAEA;AACD;AACA;AACA;AACA;AACA;;AACC,QAAMC,cAAc,GAAKC,QAAF,IAAgB;AACtC,UAAMC,gBAAgB,GACrB,OAAOD,QAAP,KAAoB,QAApB,GACG,MAAM,KADT,GAEG,MAAMA,QAAQ,CAACE,aAAT,KAA2B,CAHrC;;AAKA,OAAG;AACF,UAAKP,WAAW,CAACQ,MAAZ,KAAuB,CAA5B,EAAgC;AAC/BL,QAAAA,SAAS,GAAG,KAAZ;AACA;AACA;;AAED,YAAMM,WAAW;AAAG;AACnBT,MAAAA,WAAW,CAACU,KAAZ,EADD;AAGA,YAAMC,QAAQ;AAAG;AAChBV,MAAAA,WAAW,CAACW,GAAZ,CA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ACnC,aAAO,KAAP;AACA;;AAED,UAAMM,KAAK,GAAGrB,WAAW,CAACsB,OAAZ,CAAqBP,OAArB,CAAd;AACAf,IAAAA,WAAW,CAACuB,MAAZ,CAAoBF,KAApB,EAA2B,CAA3B;AACApB,IAAAA,WAAW,CAACY,MAAZ,CAAoBE,OAApB;AAEA,WAAO,IAAP;AACA,GAVD;AAYA;AACD;AACA;AACA;AACA;;;AACC,QAAMU,KAAK,GAAG,MAAM;AACnBzB,IAAAA,WAAW,GAAG,EAAd;AACAC,IAAAA,WAAW,GAAG,IAAIC,OAAJ,EAAd;AACAC,IAAAA,SAAS,GAAG,KAAZ;AACA,GAJD;;AAMA,SAAO;AACNW,IAAAA,GADM;AAENM,IAAAA,KAFM;AAGNI,IAAAA,MAHM;AAINC,IAAAA;AAJM,GAAP;AAMA,CAhIM","sourcesContent":["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n *\n * @typedef {()=>void} WPPriorityQueueCallback\n */\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n *\n * @typedef {{}} WPPriorityQueueContext\n */\n\n/**\n * Function to add callback to priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd\n */\n\n/**\n * Function to flush callbacks from priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush\n */\n\n/**\n * Reset the queue.\n *\n * @typedef {()=>void} WPPriorityQueueReset\n */\n\n/**\n * Priority queue instance.\n *\n * @typedef {Object} WPPriorityQueue\n *\n * @property {WPPriorityQueueAdd} add Add callback to queue for context.\n * @property {WPPriorityQueueFlush} flush Flush queue for context.\n * @property {WPPriorityQueueFlush} cancel Clear queue for context.\n * @property {WPPriorityQueueReset} reset Reset queue.\n */\n\n/**\n * Creates a context-aware queue that only executes\n * the last task of a given context.\n *\n * @example\n *```js\n * import { createQueue } from '@wordpress/priority-queue';\n *\n * const queue = createQueue();\n *\n * // Context objects.\n * const ctx1 = {};\n * const ctx2 = {};\n *\n * // For a given context in the queue, only the last callback is executed.\n * queue.add( ctx1, () => console.log( 'This will be printed first' ) );\n * queue.add( ctx2, () => console.log( 'This won\\'t be printed' ) );\n * queue.add( ctx2, () => console.log( 'This will be printed second' ) );\n *```\n *\n * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.\n */\nexport const createQueue = () => {\n\t/** @type {WPPriorityQueueContext[]} */\n\tlet waitingList = [];\n\n\t/** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */\n\tlet elementsMap = new WeakMap();\n\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline ) => {\n\t\tconst hasTimeRemaining =\n\t\t\ttypeof deadline === 'number'\n\t\t\t\t? () => false\n\t\t\t\t: () => deadline.timeRemaining() > 0;\n\n\t\tdo {\n\t\t\tif ( waitingList.length === 0 ) {\n\t\t\t\tisRunning = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextElement = /** @type {WPPriorityQueueContext} */ (\n\t\t\t\twaitingList.shift()\n\t\t\t);\n\t\t\tconst callback = /** @type {WPPriorityQueueCallback} */ (\n\t\t\t\telementsMap.get( nextElement )\n\t\t\t);\n\t\t\t// If errors with undefined callbacks are encountered double check that all of your useSelect calls\n\t\t\t// have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected\n\t\t\t// loops and race conditions in the queue.\n\t\t\tcallback();\n\t\t\telementsMap.delete( nextElement );\n\t\t} while ( hasTimeRemaining() );\n\n\t\trequestIdleCallback( runWaitingList );\n\t};\n\n\t/**\n\t * Add a callback to the queue for a given context.\n\t *\n\t * @type {WPPriorityQueueAdd}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add = ( element, item ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\twaitingList.push( element );\n\t\t}\n\t\telementsMap.set( element, item );\n\t\tif ( ! isRunning ) {\n\t\t\tisRunning = true;\n\t\t\trequestIdleCallback( runWaitingList );\n\t\t}\n\t};\n\n\t/**\n\t * Flushes queue for a given context, returning true if the flush was\n\t * performed, or false if there is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\tconst callback = /** @type {WPPriorityQueueCallback} */ (\n\t\t\telementsMap.get( element )\n\t\t);\n\t\telementsMap.delete( element );\n\t\tcallback();\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Clears the queue for a given context, cancelling the callbacks without\n\t * executing them. Returns `true` if there were scheduled callbacks to cancel,\n\t * or `false` if there was is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\telementsMap.delete( element );\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t *\n\t * @type {WPPriorityQueueReset}\n\t */\n\tconst reset = () => {\n\t\twaitingList = [];\n\t\telementsMap = new WeakMap();\n\t\tisRunning = false;\n\t};\n\n\treturn {\n\t\tadd,\n\t\tflush,\n\t\tcancel,\n\t\treset,\n\t};\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/priority-queue/src/index.js"],"names":["requestIdleCallback","createQueue","waitingList","elementsMap","WeakMap","isRunning","runWaitingList","deadline","hasTimeRemaining","timeRemaining","length","nextElement","shift","callback","get","delete","add","element","item","has","push","set","flush","index","indexOf","splice","cancel","reset"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,yBAAhC;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,MAAM;AAChC;AACA,MAAIC,WAAW,GAAG,EAAlB;AAEA;;AACA,MAAIC,WAAW,GAAG,IAAIC,OAAJ,EAAlB;AAEA,MAAIC,SAAS,GAAG,KAAhB;AAEA;AACD;AACA;AACA;AACA;AACA;;AACC,QAAMC,cAAc,GAAKC,QAAF,IAAgB;AACtC,UAAMC,gBAAgB,GACrB,OAAOD,QAAP,KAAoB,QAApB,GACG,MAAM,KADT,GAEG,MAAMA,QAAQ,CAACE,aAAT,KAA2B,CAHrC;;AAKA,OAAG;AACF,UAAKP,WAAW,CAACQ,MAAZ,KAAuB,CAA5B,EAAgC;AAC/BL,QAAAA,SAAS,GAAG,KAAZ;AACA;AACA;;AAED,YAAMM,WAAW;AAAG;AAAwCT,MAAAA,WAAW,CAACU,KAAZ,EAA5D;AACA,YAAMC,QAAQ;AAAG;AAAyCV,MAAAA,WAAW,CAACW,GAAZ,CACzDH,WADyD,CAA1D,CAPE,CAUF;AACA;AACA;;AACAE,MAAAA,QAAQ;AACRV,MAAAA,WAAW,CAACY,MAAZ,CAAoBJ,WAApB;AACA,KAfD,QAeUH,gBAAgB,EA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IAAAA,WAAW,CAACuB,MAAZ,CAAoBF,KAApB,EAA2B,CAA3B;AACApB,IAAAA,WAAW,CAACY,MAAZ,CAAoBE,OAApB;AAEA,WAAO,IAAP;AACA,GAVD;AAYA;AACD;AACA;AACA;AACA;;;AACC,QAAMU,KAAK,GAAG,MAAM;AACnBzB,IAAAA,WAAW,GAAG,EAAd;AACAC,IAAAA,WAAW,GAAG,IAAIC,OAAJ,EAAd;AACAC,IAAAA,SAAS,GAAG,KAAZ;AACA,GAJD;;AAMA,SAAO;AACNW,IAAAA,GADM;AAENM,IAAAA,KAFM;AAGNI,IAAAA,MAHM;AAINC,IAAAA;AAJM,GAAP;AAMA,CA9HM","sourcesContent":["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n *\n * @typedef {()=>void} WPPriorityQueueCallback\n */\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n *\n * @typedef {{}} WPPriorityQueueContext\n */\n\n/**\n * Function to add callback to priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd\n */\n\n/**\n * Function to flush callbacks from priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush\n */\n\n/**\n * Reset the queue.\n *\n * @typedef {()=>void} WPPriorityQueueReset\n */\n\n/**\n * Priority queue instance.\n *\n * @typedef {Object} WPPriorityQueue\n *\n * @property {WPPriorityQueueAdd} add Add callback to queue for context.\n * @property {WPPriorityQueueFlush} flush Flush queue for context.\n * @property {WPPriorityQueueFlush} cancel Clear queue for context.\n * @property {WPPriorityQueueReset} reset Reset queue.\n */\n\n/**\n * Creates a context-aware queue that only executes\n * the last task of a given context.\n *\n * @example\n *```js\n * import { createQueue } from '@wordpress/priority-queue';\n *\n * const queue = createQueue();\n *\n * // Context objects.\n * const ctx1 = {};\n * const ctx2 = {};\n *\n * // For a given context in the queue, only the last callback is executed.\n * queue.add( ctx1, () => console.log( 'This will be printed first' ) );\n * queue.add( ctx2, () => console.log( 'This won\\'t be printed' ) );\n * queue.add( ctx2, () => console.log( 'This will be printed second' ) );\n *```\n *\n * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.\n */\nexport const createQueue = () => {\n\t/** @type {WPPriorityQueueContext[]} */\n\tlet waitingList = [];\n\n\t/** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */\n\tlet elementsMap = new WeakMap();\n\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline ) => {\n\t\tconst hasTimeRemaining =\n\t\t\ttypeof deadline === 'number'\n\t\t\t\t? () => false\n\t\t\t\t: () => deadline.timeRemaining() > 0;\n\n\t\tdo {\n\t\t\tif ( waitingList.length === 0 ) {\n\t\t\t\tisRunning = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextElement = /** @type {WPPriorityQueueContext} */ ( waitingList.shift() );\n\t\t\tconst callback = /** @type {WPPriorityQueueCallback} */ ( elementsMap.get(\n\t\t\t\tnextElement\n\t\t\t) );\n\t\t\t// If errors with undefined callbacks are encountered double check that all of your useSelect calls\n\t\t\t// have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected\n\t\t\t// loops and race conditions in the queue.\n\t\t\tcallback();\n\t\t\telementsMap.delete( nextElement );\n\t\t} while ( hasTimeRemaining() );\n\n\t\trequestIdleCallback( runWaitingList );\n\t};\n\n\t/**\n\t * Add a callback to the queue for a given context.\n\t *\n\t * @type {WPPriorityQueueAdd}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add = ( element, item ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\twaitingList.push( element );\n\t\t}\n\t\telementsMap.set( element, item );\n\t\tif ( ! isRunning ) {\n\t\t\tisRunning = true;\n\t\t\trequestIdleCallback( runWaitingList );\n\t\t}\n\t};\n\n\t/**\n\t * Flushes queue for a given context, returning true if the flush was\n\t * performed, or false if there is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\tconst callback = /** @type {WPPriorityQueueCallback} */ ( elementsMap.get(\n\t\t\telement\n\t\t) );\n\t\telementsMap.delete( element );\n\t\tcallback();\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Clears the queue for a given context, cancelling the callbacks without\n\t * executing them. Returns `true` if there were scheduled callbacks to cancel,\n\t * or `false` if there was is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\telementsMap.delete( element );\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t *\n\t * @type {WPPriorityQueueReset}\n\t */\n\tconst reset = () => {\n\t\twaitingList = [];\n\t\telementsMap = new WeakMap();\n\t\tisRunning = false;\n\t};\n\n\treturn {\n\t\tadd,\n\t\tflush,\n\t\tcancel,\n\t\treset,\n\t};\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/priority-queue/src/index.js"],"names":["requestIdleCallback","createQueue","waitingList","elementsMap","WeakMap","isRunning","runWaitingList","deadline","hasTimeRemaining","timeRemaining","length","nextElement","shift","callback","get","delete","add","element","item","has","push","set","flush","index","indexOf","splice","cancel","reset"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,mBAAP,MAAgC,yBAAhC;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,MAAM;AAChC;AACA,MAAIC,WAAW,GAAG,EAAlB;AAEA;;AACA,MAAIC,WAAW,GAAG,IAAIC,OAAJ,EAAlB;AAEA,MAAIC,SAAS,GAAG,KAAhB;AAEA;AACD;AACA;AACA;AACA;AACA;;AACC,QAAMC,cAAc,GAAKC,QAAF,IAAgB;AACtC,UAAMC,gBAAgB,GACrB,OAAOD,QAAP,KAAoB,QAApB,GACG,MAAM,KADT,GAEG,MAAMA,QAAQ,CAACE,aAAT,KAA2B,CAHrC;;AAKA,OAAG;AACF,UAAKP,WAAW,CAACQ,MAAZ,KAAuB,CAA5B,EAAgC;AAC/BL,QAAAA,SAAS,GAAG,KAAZ;AACA;AACA;;AAED,YAAMM,WAAW;AAAG;AACnBT,MAAAA,WAAW,CAACU,KAAZ,EADD;AAGA,YAAMC,QAAQ;AAAG;AAChBV,MAAAA,WAAW,CAACW,GAAZ,CAAiBH,WAAjB,CADD,CATE,CAYF;AACA;AACA;;AACAE,MAAAA,QAAQ;AACRV,MAAAA,WAAW,CAACY,MAAZ,CAAoBJ,WAApB;AACA,KAjBD,QAiBUH,gBAAgB,EAjB1B;;AAmBAR,IAAAA,mBAAmB,CAAEM,cAAF,CAAnB;AACA,GA1BD;AA4BA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;;AACC,QAAMU,GAAG,GA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AVD;AAYA;AACD;AACA;AACA;AACA;;;AACC,QAAMU,KAAK,GAAG,MAAM;AACnBzB,IAAAA,WAAW,GAAG,EAAd;AACAC,IAAAA,WAAW,GAAG,IAAIC,OAAJ,EAAd;AACAC,IAAAA,SAAS,GAAG,KAAZ;AACA,GAJD;;AAMA,SAAO;AACNW,IAAAA,GADM;AAENM,IAAAA,KAFM;AAGNI,IAAAA,MAHM;AAINC,IAAAA;AAJM,GAAP;AAMA,CAhIM","sourcesContent":["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n *\n * @typedef {()=>void} WPPriorityQueueCallback\n */\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n *\n * @typedef {{}} WPPriorityQueueContext\n */\n\n/**\n * Function to add callback to priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd\n */\n\n/**\n * Function to flush callbacks from priority queue.\n *\n * @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush\n */\n\n/**\n * Reset the queue.\n *\n * @typedef {()=>void} WPPriorityQueueReset\n */\n\n/**\n * Priority queue instance.\n *\n * @typedef {Object} WPPriorityQueue\n *\n * @property {WPPriorityQueueAdd} add Add callback to queue for context.\n * @property {WPPriorityQueueFlush} flush Flush queue for context.\n * @property {WPPriorityQueueFlush} cancel Clear queue for context.\n * @property {WPPriorityQueueReset} reset Reset queue.\n */\n\n/**\n * Creates a context-aware queue that only executes\n * the last task of a given context.\n *\n * @example\n *```js\n * import { createQueue } from '@wordpress/priority-queue';\n *\n * const queue = createQueue();\n *\n * // Context objects.\n * const ctx1 = {};\n * const ctx2 = {};\n *\n * // For a given context in the queue, only the last callback is executed.\n * queue.add( ctx1, () => console.log( 'This will be printed first' ) );\n * queue.add( ctx2, () => console.log( 'This won\\'t be printed' ) );\n * queue.add( ctx2, () => console.log( 'This will be printed second' ) );\n *```\n *\n * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.\n */\nexport const createQueue = () => {\n\t/** @type {WPPriorityQueueContext[]} */\n\tlet waitingList = [];\n\n\t/** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */\n\tlet elementsMap = new WeakMap();\n\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline ) => {\n\t\tconst hasTimeRemaining =\n\t\t\ttypeof deadline === 'number'\n\t\t\t\t? () => false\n\t\t\t\t: () => deadline.timeRemaining() > 0;\n\n\t\tdo {\n\t\t\tif ( waitingList.length === 0 ) {\n\t\t\t\tisRunning = false;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nextElement = /** @type {WPPriorityQueueContext} */ (\n\t\t\t\twaitingList.shift()\n\t\t\t);\n\t\t\tconst callback = /** @type {WPPriorityQueueCallback} */ (\n\t\t\t\telementsMap.get( nextElement )\n\t\t\t);\n\t\t\t// If errors with undefined callbacks are encountered double check that all of your useSelect calls\n\t\t\t// have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected\n\t\t\t// loops and race conditions in the queue.\n\t\t\tcallback();\n\t\t\telementsMap.delete( nextElement );\n\t\t} while ( hasTimeRemaining() );\n\n\t\trequestIdleCallback( runWaitingList );\n\t};\n\n\t/**\n\t * Add a callback to the queue for a given context.\n\t *\n\t * @type {WPPriorityQueueAdd}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add = ( element, item ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\twaitingList.push( element );\n\t\t}\n\t\telementsMap.set( element, item );\n\t\tif ( ! isRunning ) {\n\t\t\tisRunning = true;\n\t\t\trequestIdleCallback( runWaitingList );\n\t\t}\n\t};\n\n\t/**\n\t * Flushes queue for a given context, returning true if the flush was\n\t * performed, or false if there is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\tconst callback = /** @type {WPPriorityQueueCallback} */ (\n\t\t\telementsMap.get( element )\n\t\t);\n\t\telementsMap.delete( element );\n\t\tcallback();\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Clears the queue for a given context, cancelling the callbacks without\n\t * executing them. Returns `true` if there were scheduled callbacks to cancel,\n\t * or `false` if there was is no queue for the given context.\n\t *\n\t * @type {WPPriorityQueueFlush}\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel = ( element ) => {\n\t\tif ( ! elementsMap.has( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst index = waitingList.indexOf( element );\n\t\twaitingList.splice( index, 1 );\n\t\telementsMap.delete( element );\n\n\t\treturn true;\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t *\n\t * @type {WPPriorityQueueReset}\n\t */\n\tconst reset = () => {\n\t\twaitingList = [];\n\t\telementsMap = new WeakMap();\n\t\tisRunning = false;\n\t};\n\n\treturn {\n\t\tadd,\n\t\tflush,\n\t\tcancel,\n\t\treset,\n\t};\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAoEO,+BAFK,eAAe,CAgI1B;;;;sCA1LY,MAAI,IAAI;;;;qCAMR,EAAE;;;;2CAMO,sBAAsB,QAAM,uBAAuB,KAAG,IAAI;;;;6CAM1D,sBAAsB,KAAG,OAAO;;;;mCAMzC,MAAI,IAAI;;;;;;;;SAQP,kBAAkB;;;;WAClB,oBAAoB;;;;YACpB,oBAAoB;;;;WACpB,oBAAoB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAoEO,+BAFK,eAAe,CAkI1B;;;;sCA5LY,MAAI,IAAI;;;;qCAMR,EAAE;;;;2CAMO,sBAAsB,QAAM,uBAAuB,KAAG,IAAI;;;;6CAM1D,sBAAsB,KAAG,OAAO;;;;mCAMzC,MAAI,IAAI;;;;;;;;SAQP,kBAAkB;;;;WAClB,oBAAoB;;;;YACpB,oBAAoB;;;;WACpB,oBAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/priority-queue",
3
- "version": "2.10.0",
3
+ "version": "2.13.0",
4
4
  "description": "Generic browser priority queue.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "a3e0b62091e8a8bdf5e2518e42d60d7098af48cc"
36
+ "gitHead": "9d9d33bbdf317a4381b8ca1713e43bb50df653b3"
37
37
  }
package/src/index.js CHANGED
@@ -93,10 +93,12 @@ export const createQueue = () => {
93
93
  return;
94
94
  }
95
95
 
96
- const nextElement = /** @type {WPPriorityQueueContext} */ ( waitingList.shift() );
97
- const callback = /** @type {WPPriorityQueueCallback} */ ( elementsMap.get(
98
- nextElement
99
- ) );
96
+ const nextElement = /** @type {WPPriorityQueueContext} */ (
97
+ waitingList.shift()
98
+ );
99
+ const callback = /** @type {WPPriorityQueueCallback} */ (
100
+ elementsMap.get( nextElement )
101
+ );
100
102
  // If errors with undefined callbacks are encountered double check that all of your useSelect calls
101
103
  // have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected
102
104
  // loops and race conditions in the queue.
@@ -143,9 +145,9 @@ export const createQueue = () => {
143
145
 
144
146
  const index = waitingList.indexOf( element );
145
147
  waitingList.splice( index, 1 );
146
- const callback = /** @type {WPPriorityQueueCallback} */ ( elementsMap.get(
147
- element
148
- ) );
148
+ const callback = /** @type {WPPriorityQueueCallback} */ (
149
+ elementsMap.get( element )
150
+ );
149
151
  elementsMap.delete( element );
150
152
  callback();
151
153
 
@@ -1 +1 @@
1
- {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","./src/request-idle-callback.js","./src/index.js","../../node_modules/@types/requestidlecallback/index.d.ts"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"78e8bcd74d07239f0301d11024c1a21adfad1f8836775fada144e53da950c82d","997d37a1bcedbf95d459aacf334f11e36bdc09309dc21a44b661e10f968c1fab",{"version":"9b66eb641b8ff1824e4d04022ba1a051c5c10746ea94147b24c2f5e27c5f9c88","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[45]],"referencedMap":[[46,1]],"exportedModulesMap":[[46,1]],"semanticDiagnosticsPerFile":[47,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,46,45]},"version":"4.4.2"}
1
+ {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","./src/request-idle-callback.js","./src/index.js","../../node_modules/@types/requestidlecallback/index.d.ts"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"78e8bcd74d07239f0301d11024c1a21adfad1f8836775fada144e53da950c82d","4de4926f27ba2917ff0afe8021ff358b78098358aa83e4cf05afee9905709d73",{"version":"9b66eb641b8ff1824e4d04022ba1a051c5c10746ea94147b24c2f5e27c5f9c88","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[45]],"referencedMap":[[46,1]],"exportedModulesMap":[[46,1]],"semanticDiagnosticsPerFile":[47,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,46,45]},"version":"4.4.2"}