Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@wordpress/priority-queue

Package Overview
Dependencies
Maintainers
23
Versions
223
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/priority-queue - npm Package Compare versions

Comparing version
3.32.0
to
3.32.1-next.47f435fc9.0
+12
-99
build-module/index.js

@@ -1,65 +0,10 @@

/**
* Internal dependencies
*/
import requestIdleCallback from './request-idle-callback';
/**
* Enqueued callback to invoke once idle time permits.
*/
/**
* An object used to associate callbacks in a particular context grouping.
*/
/**
* Interface for the priority queue instance.
*/
/**
* Creates a context-aware queue that only executes
* the last task of a given context.
*
* @example
*```js
* import { createQueue } from '@wordpress/priority-queue';
*
* const queue = createQueue();
*
* // Context objects.
* const ctx1 = {};
* const ctx2 = {};
*
* // For a given context in the queue, only the last callback is executed.
* queue.add( ctx1, () => console.log( 'This will be printed first' ) );
* queue.add( ctx2, () => console.log( 'This won\'t be printed' ) );
* queue.add( ctx2, () => console.log( 'This will be printed second' ) );
*```
*
* @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.
*/
export const createQueue = () => {
const waitingList = new Map();
import requestIdleCallback from "./request-idle-callback";
const createQueue = () => {
const waitingList = /* @__PURE__ */ new Map();
let isRunning = false;
/**
* Callback to process as much queue as time permits.
*
* Map Iteration follows the original insertion order. This means that here
* we can iterate the queue and know that the first contexts which were
* added will be run first. On the other hand, if anyone adds a new callback
* for an existing context it will supplant the previously-set callback for
* that context because we reassigned that map key's value.
*
* In the case that a callback adds a new callback to its own context then
* the callback it adds will appear at the end of the iteration and will be
* run only after all other existing contexts have finished executing.
*
* @param {IdleDeadline|number} deadline Idle callback deadline object, or
* animation frame timestamp.
*/
const runWaitingList = deadline => {
const runWaitingList = (deadline) => {
for (const [nextElement, callback] of waitingList) {
waitingList.delete(nextElement);
callback();
if ('number' === typeof deadline || deadline.timeRemaining() <= 0) {
if ("number" === typeof deadline || deadline.timeRemaining() <= 0) {
break;

@@ -74,14 +19,2 @@ }

};
/**
* Add a callback to the queue for a given context.
*
* If errors with undefined callbacks are encountered double check that
* all of your useSelect calls have the right dependencies set correctly
* in their second parameter. Missing dependencies can cause unexpected
* loops and race conditions in the queue.
*
* @param {WPPriorityQueueContext} element Context object.
* @param {WPPriorityQueueCallback} item Callback function.
*/
const add = (element, item) => {

@@ -94,14 +27,5 @@ waitingList.set(element, item);

};
/**
* Flushes queue for a given context, returning true if the flush was
* performed, or false if there is no queue for the given context.
*
* @param {WPPriorityQueueContext} element Context object.
*
* @return {boolean} Whether flush was performed.
*/
const flush = element => {
const flush = (element) => {
const callback = waitingList.get(element);
if (undefined === callback) {
if (void 0 === callback) {
return false;

@@ -113,19 +37,5 @@ }

};
/**
* Clears the queue for a given context, cancelling the callbacks without
* executing them. Returns `true` if there were scheduled callbacks to cancel,
* or `false` if there was is no queue for the given context.
*
* @param {WPPriorityQueueContext} element Context object.
*
* @return {boolean} Whether any callbacks got cancelled.
*/
const cancel = element => {
const cancel = (element) => {
return waitingList.delete(element);
};
/**
* Reset the queue without running the pending callbacks.
*/
const reset = () => {

@@ -142,2 +52,5 @@ waitingList.clear();

};
//# sourceMappingURL=index.js.map
export {
createQueue
};
//# sourceMappingURL=index.js.map
+7
-1

@@ -1,1 +0,7 @@

{"version":3,"names":["requestIdleCallback","createQueue","waitingList","Map","isRunning","runWaitingList","deadline","nextElement","callback","delete","timeRemaining","size","add","element","item","set","flush","get","undefined","cancel","reset","clear"],"sources":["@wordpress/priority-queue/src/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n */\nexport type WPPriorityQueueCallback = VoidFunction;\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n */\nexport type WPPriorityQueueContext = object;\n\n/**\n * Interface for the priority queue instance.\n */\nexport interface WPPriorityQueue {\n\t/**\n\t * Add a callback to the queue for a given context.\n\t */\n\tadd: (\n\t\telement: WPPriorityQueueContext,\n\t\titem: WPPriorityQueueCallback\n\t) => void;\n\n\t/**\n\t * Flush and run the callback for a given context immediately.\n\t * @return true if a callback was run, false otherwise.\n\t */\n\tflush: ( element: WPPriorityQueueContext ) => boolean;\n\n\t/**\n\t * Cancel (remove) the callback for a given context without running it.\n\t * @return true if a callback was cancelled, false otherwise.\n\t */\n\tcancel: ( element: WPPriorityQueueContext ) => boolean;\n\n\t/**\n\t * Reset the entire queue, clearing pending callbacks.\n\t */\n\treset: VoidFunction;\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 = (): WPPriorityQueue => {\n\tconst waitingList = new Map<\n\t\tWPPriorityQueueContext,\n\t\tWPPriorityQueueCallback\n\t>();\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * Map Iteration follows the original insertion order. This means that here\n\t * we can iterate the queue and know that the first contexts which were\n\t * added will be run first. On the other hand, if anyone adds a new callback\n\t * for an existing context it will supplant the previously-set callback for\n\t * that context because we reassigned that map key's value.\n\t *\n\t * In the case that a callback adds a new callback to its own context then\n\t * the callback it adds will appear at the end of the iteration and will be\n\t * run only after all other existing contexts have finished executing.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline: IdleDeadline | number ): void => {\n\t\tfor ( const [ nextElement, callback ] of waitingList ) {\n\t\t\twaitingList.delete( nextElement );\n\t\t\tcallback();\n\n\t\t\tif (\n\t\t\t\t'number' === typeof deadline ||\n\t\t\t\tdeadline.timeRemaining() <= 0\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( waitingList.size === 0 ) {\n\t\t\tisRunning = false;\n\t\t\treturn;\n\t\t}\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 * If errors with undefined callbacks are encountered double check that\n\t * all of your useSelect calls have the right dependencies set correctly\n\t * in their second parameter. Missing dependencies can cause unexpected\n\t * loops and race conditions in the queue.\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add: WPPriorityQueue[ 'add' ] = (\n\t\telement: WPPriorityQueueContext,\n\t\titem: WPPriorityQueueCallback\n\t) => {\n\t\twaitingList.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 * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush: WPPriorityQueue[ 'flush' ] = (\n\t\telement: WPPriorityQueueContext\n\t) => {\n\t\tconst callback = waitingList.get( element );\n\t\tif ( undefined === callback ) {\n\t\t\treturn false;\n\t\t}\n\n\t\twaitingList.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 * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel: WPPriorityQueue[ 'cancel' ] = (\n\t\telement: WPPriorityQueueContext\n\t) => {\n\t\treturn waitingList.delete( element );\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t */\n\tconst reset: WPPriorityQueue[ 'reset' ] = () => {\n\t\twaitingList.clear();\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"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,mBAAmB,MAAM,yBAAyB;;AAEzD;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AA4BA;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,GAAGA,CAAA,KAAuB;EACjD,MAAMC,WAAW,GAAG,IAAIC,GAAG,CAGzB,CAAC;EACH,IAAIC,SAAS,GAAG,KAAK;;EAErB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMC,cAAc,GAAKC,QAA+B,IAAY;IACnE,KAAM,MAAM,CAAEC,WAAW,EAAEC,QAAQ,CAAE,IAAIN,WAAW,EAAG;MACtDA,WAAW,CAACO,MAAM,CAAEF,WAAY,CAAC;MACjCC,QAAQ,CAAC,CAAC;MAEV,IACC,QAAQ,KAAK,OAAOF,QAAQ,IAC5BA,QAAQ,CAACI,aAAa,CAAC,CAAC,IAAI,CAAC,EAC5B;QACD;MACD;IACD;IAEA,IAAKR,WAAW,CAACS,IAAI,KAAK,CAAC,EAAG;MAC7BP,SAAS,GAAG,KAAK;MACjB;IACD;IAEAJ,mBAAmB,CAAEK,cAAe,CAAC;EACtC,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMO,GAA6B,GAAGA,CACrCC,OAA+B,EAC/BC,IAA6B,KACzB;IACJZ,WAAW,CAACa,GAAG,CAAEF,OAAO,EAAEC,IAAK,CAAC;IAChC,IAAK,CAAEV,SAAS,EAAG;MAClBA,SAAS,GAAG,IAAI;MAChBJ,mBAAmB,CAAEK,cAAe,CAAC;IACtC;EACD,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMW,KAAiC,GACtCH,OAA+B,IAC3B;IACJ,MAAML,QAAQ,GAAGN,WAAW,CAACe,GAAG,CAAEJ,OAAQ,CAAC;IAC3C,IAAKK,SAAS,KAAKV,QAAQ,EAAG;MAC7B,OAAO,KAAK;IACb;IAEAN,WAAW,CAACO,MAAM,CAAEI,OAAQ,CAAC;IAC7BL,QAAQ,CAAC,CAAC;IAEV,OAAO,IAAI;EACZ,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMW,MAAmC,GACxCN,OAA+B,IAC3B;IACJ,OAAOX,WAAW,CAACO,MAAM,CAAEI,OAAQ,CAAC;EACrC,CAAC;;EAED;AACD;AACA;EACC,MAAMO,KAAiC,GAAGA,CAAA,KAAM;IAC/ClB,WAAW,CAACmB,KAAK,CAAC,CAAC;IACnBjB,SAAS,GAAG,KAAK;EAClB,CAAC;EAED,OAAO;IACNQ,GAAG;IACHI,KAAK;IACLG,MAAM;IACNC;EACD,CAAC;AACF,CAAC","ignoreList":[]}
{
"version": 3,
"sources": ["../src/index.ts"],
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n */\nexport type WPPriorityQueueCallback = VoidFunction;\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n */\nexport type WPPriorityQueueContext = object;\n\n/**\n * Interface for the priority queue instance.\n */\nexport interface WPPriorityQueue {\n\t/**\n\t * Add a callback to the queue for a given context.\n\t */\n\tadd: (\n\t\telement: WPPriorityQueueContext,\n\t\titem: WPPriorityQueueCallback\n\t) => void;\n\n\t/**\n\t * Flush and run the callback for a given context immediately.\n\t * @return true if a callback was run, false otherwise.\n\t */\n\tflush: ( element: WPPriorityQueueContext ) => boolean;\n\n\t/**\n\t * Cancel (remove) the callback for a given context without running it.\n\t * @return true if a callback was cancelled, false otherwise.\n\t */\n\tcancel: ( element: WPPriorityQueueContext ) => boolean;\n\n\t/**\n\t * Reset the entire queue, clearing pending callbacks.\n\t */\n\treset: VoidFunction;\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 = (): WPPriorityQueue => {\n\tconst waitingList = new Map<\n\t\tWPPriorityQueueContext,\n\t\tWPPriorityQueueCallback\n\t>();\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * Map Iteration follows the original insertion order. This means that here\n\t * we can iterate the queue and know that the first contexts which were\n\t * added will be run first. On the other hand, if anyone adds a new callback\n\t * for an existing context it will supplant the previously-set callback for\n\t * that context because we reassigned that map key's value.\n\t *\n\t * In the case that a callback adds a new callback to its own context then\n\t * the callback it adds will appear at the end of the iteration and will be\n\t * run only after all other existing contexts have finished executing.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline: IdleDeadline | number ): void => {\n\t\tfor ( const [ nextElement, callback ] of waitingList ) {\n\t\t\twaitingList.delete( nextElement );\n\t\t\tcallback();\n\n\t\t\tif (\n\t\t\t\t'number' === typeof deadline ||\n\t\t\t\tdeadline.timeRemaining() <= 0\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( waitingList.size === 0 ) {\n\t\t\tisRunning = false;\n\t\t\treturn;\n\t\t}\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 * If errors with undefined callbacks are encountered double check that\n\t * all of your useSelect calls have the right dependencies set correctly\n\t * in their second parameter. Missing dependencies can cause unexpected\n\t * loops and race conditions in the queue.\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add: WPPriorityQueue[ 'add' ] = (\n\t\telement: WPPriorityQueueContext,\n\t\titem: WPPriorityQueueCallback\n\t) => {\n\t\twaitingList.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 * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush: WPPriorityQueue[ 'flush' ] = (\n\t\telement: WPPriorityQueueContext\n\t) => {\n\t\tconst callback = waitingList.get( element );\n\t\tif ( undefined === callback ) {\n\t\t\treturn false;\n\t\t}\n\n\t\twaitingList.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 * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel: WPPriorityQueue[ 'cancel' ] = (\n\t\telement: WPPriorityQueueContext\n\t) => {\n\t\treturn waitingList.delete( element );\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t */\n\tconst reset: WPPriorityQueue[ 'reset' ] = () => {\n\t\twaitingList.clear();\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"],
"mappings": "AAGA,OAAO,yBAAyB;AAgEzB,MAAM,cAAc,MAAuB;AACjD,QAAM,cAAc,oBAAI,IAGtB;AACF,MAAI,YAAY;AAkBhB,QAAM,iBAAiB,CAAE,aAA2C;AACnE,eAAY,CAAE,aAAa,QAAS,KAAK,aAAc;AACtD,kBAAY,OAAQ,WAAY;AAChC,eAAS;AAET,UACC,aAAa,OAAO,YACpB,SAAS,cAAc,KAAK,GAC3B;AACD;AAAA,MACD;AAAA,IACD;AAEA,QAAK,YAAY,SAAS,GAAI;AAC7B,kBAAY;AACZ;AAAA,IACD;AAEA,wBAAqB,cAAe;AAAA,EACrC;AAaA,QAAM,MAAgC,CACrC,SACA,SACI;AACJ,gBAAY,IAAK,SAAS,IAAK;AAC/B,QAAK,CAAE,WAAY;AAClB,kBAAY;AACZ,0BAAqB,cAAe;AAAA,IACrC;AAAA,EACD;AAUA,QAAM,QAAoC,CACzC,YACI;AACJ,UAAM,WAAW,YAAY,IAAK,OAAQ;AAC1C,QAAK,WAAc,UAAW;AAC7B,aAAO;AAAA,IACR;AAEA,gBAAY,OAAQ,OAAQ;AAC5B,aAAS;AAET,WAAO;AAAA,EACR;AAWA,QAAM,SAAsC,CAC3C,YACI;AACJ,WAAO,YAAY,OAAQ,OAAQ;AAAA,EACpC;AAKA,QAAM,QAAoC,MAAM;AAC/C,gBAAY,MAAM;AAClB,gBAAY;AAAA,EACb;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
"names": []
}

@@ -1,16 +0,5 @@

/**
* External dependencies
*/
import 'requestidlecallback';
/**
* Internal dependencies
*/
/**
* @return A function that schedules a callback when the browser is idle or via setTimeout on the server.
*/
export function createRequestIdleCallback() {
if (typeof window === 'undefined') {
return callback => {
import "requestidlecallback";
function createRequestIdleCallback() {
if (typeof window === "undefined") {
return (callback) => {
setTimeout(() => callback(Date.now()), 0);

@@ -21,3 +10,7 @@ };

}
export default createRequestIdleCallback();
//# sourceMappingURL=request-idle-callback.js.map
var request_idle_callback_default = createRequestIdleCallback();
export {
createRequestIdleCallback,
request_idle_callback_default as default
};
//# sourceMappingURL=request-idle-callback.js.map

@@ -1,1 +0,7 @@

{"version":3,"names":["createRequestIdleCallback","window","callback","setTimeout","Date","now","requestIdleCallback"],"sources":["@wordpress/priority-queue/src/request-idle-callback.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport 'requestidlecallback';\n\n/**\n * Internal dependencies\n */\nimport type { RequestIdleCallbackCallback } from './types';\n\n/**\n * @return A function that schedules a callback when the browser is idle or via setTimeout on the server.\n */\nexport function createRequestIdleCallback() {\n\tif ( typeof window === 'undefined' ) {\n\t\treturn ( callback: RequestIdleCallbackCallback ) => {\n\t\t\tsetTimeout( () => callback( Date.now() ), 0 );\n\t\t};\n\t}\n\n\treturn window.requestIdleCallback;\n}\n\nexport default createRequestIdleCallback();\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,qBAAqB;;AAE5B;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAO,SAASA,yBAAyBA,CAAA,EAAG;EAC3C,IAAK,OAAOC,MAAM,KAAK,WAAW,EAAG;IACpC,OAASC,QAAqC,IAAM;MACnDC,UAAU,CAAE,MAAMD,QAAQ,CAAEE,IAAI,CAACC,GAAG,CAAC,CAAE,CAAC,EAAE,CAAE,CAAC;IAC9C,CAAC;EACF;EAEA,OAAOJ,MAAM,CAACK,mBAAmB;AAClC;AAEA,eAAeN,yBAAyB,CAAC,CAAC","ignoreList":[]}
{
"version": 3,
"sources": ["../src/request-idle-callback.ts"],
"sourcesContent": ["/**\n * External dependencies\n */\nimport 'requestidlecallback';\n\n/**\n * Internal dependencies\n */\nimport type { RequestIdleCallbackCallback } from './types';\n\n/**\n * @return A function that schedules a callback when the browser is idle or via setTimeout on the server.\n */\nexport function createRequestIdleCallback() {\n\tif ( typeof window === 'undefined' ) {\n\t\treturn ( callback: RequestIdleCallbackCallback ) => {\n\t\t\tsetTimeout( () => callback( Date.now() ), 0 );\n\t\t};\n\t}\n\n\treturn window.requestIdleCallback;\n}\n\nexport default createRequestIdleCallback();\n"],
"mappings": "AAGA,OAAO;AAUA,SAAS,4BAA4B;AAC3C,MAAK,OAAO,WAAW,aAAc;AACpC,WAAO,CAAE,aAA2C;AACnD,iBAAY,MAAM,SAAU,KAAK,IAAI,CAAE,GAAG,CAAE;AAAA,IAC7C;AAAA,EACD;AAEA,SAAO,OAAO;AACf;AAEA,IAAO,gCAAQ,0BAA0B;",
"names": []
}

@@ -1,2 +0,1 @@

export {};
//# sourceMappingURL=types.js.map
//# sourceMappingURL=types.js.map

@@ -1,1 +0,7 @@

{"version":3,"names":[],"sources":["@wordpress/priority-queue/src/types.ts"],"sourcesContent":["export type RequestIdleCallbackCallback = (\n\t/**\n\t * @param timeOrDeadline - IdleDeadline object or a timestamp number.\n\t */\n\ttimeOrDeadline: IdleDeadline | number\n) => void;\n"],"mappings":"","ignoreList":[]}
{
"version": 3,
"sources": [],
"sourcesContent": [],
"mappings": "",
"names": []
}
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export(index_exports, {
createQueue: () => createQueue
});
exports.createQueue = void 0;
var _requestIdleCallback = _interopRequireDefault(require("./request-idle-callback"));
/**
* Internal dependencies
*/
/**
* Enqueued callback to invoke once idle time permits.
*/
/**
* An object used to associate callbacks in a particular context grouping.
*/
/**
* Interface for the priority queue instance.
*/
/**
* Creates a context-aware queue that only executes
* the last task of a given context.
*
* @example
*```js
* import { createQueue } from '@wordpress/priority-queue';
*
* const queue = createQueue();
*
* // Context objects.
* const ctx1 = {};
* const ctx2 = {};
*
* // For a given context in the queue, only the last callback is executed.
* queue.add( ctx1, () => console.log( 'This will be printed first' ) );
* queue.add( ctx2, () => console.log( 'This won\'t be printed' ) );
* queue.add( ctx2, () => console.log( 'This will be printed second' ) );
*```
*
* @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.
*/
module.exports = __toCommonJS(index_exports);
var import_request_idle_callback = __toESM(require("./request-idle-callback"));
const createQueue = () => {
const waitingList = new Map();
const waitingList = /* @__PURE__ */ new Map();
let isRunning = false;
/**
* Callback to process as much queue as time permits.
*
* Map Iteration follows the original insertion order. This means that here
* we can iterate the queue and know that the first contexts which were
* added will be run first. On the other hand, if anyone adds a new callback
* for an existing context it will supplant the previously-set callback for
* that context because we reassigned that map key's value.
*
* In the case that a callback adds a new callback to its own context then
* the callback it adds will appear at the end of the iteration and will be
* run only after all other existing contexts have finished executing.
*
* @param {IdleDeadline|number} deadline Idle callback deadline object, or
* animation frame timestamp.
*/
const runWaitingList = deadline => {
const runWaitingList = (deadline) => {
for (const [nextElement, callback] of waitingList) {
waitingList.delete(nextElement);
callback();
if ('number' === typeof deadline || deadline.timeRemaining() <= 0) {
if ("number" === typeof deadline || deadline.timeRemaining() <= 0) {
break;

@@ -79,16 +50,4 @@ }

}
(0, _requestIdleCallback.default)(runWaitingList);
(0, import_request_idle_callback.default)(runWaitingList);
};
/**
* Add a callback to the queue for a given context.
*
* If errors with undefined callbacks are encountered double check that
* all of your useSelect calls have the right dependencies set correctly
* in their second parameter. Missing dependencies can cause unexpected
* loops and race conditions in the queue.
*
* @param {WPPriorityQueueContext} element Context object.
* @param {WPPriorityQueueCallback} item Callback function.
*/
const add = (element, item) => {

@@ -98,17 +57,8 @@ waitingList.set(element, item);

isRunning = true;
(0, _requestIdleCallback.default)(runWaitingList);
(0, import_request_idle_callback.default)(runWaitingList);
}
};
/**
* Flushes queue for a given context, returning true if the flush was
* performed, or false if there is no queue for the given context.
*
* @param {WPPriorityQueueContext} element Context object.
*
* @return {boolean} Whether flush was performed.
*/
const flush = element => {
const flush = (element) => {
const callback = waitingList.get(element);
if (undefined === callback) {
if (void 0 === callback) {
return false;

@@ -120,19 +70,5 @@ }

};
/**
* Clears the queue for a given context, cancelling the callbacks without
* executing them. Returns `true` if there were scheduled callbacks to cancel,
* or `false` if there was is no queue for the given context.
*
* @param {WPPriorityQueueContext} element Context object.
*
* @return {boolean} Whether any callbacks got cancelled.
*/
const cancel = element => {
const cancel = (element) => {
return waitingList.delete(element);
};
/**
* Reset the queue without running the pending callbacks.
*/
const reset = () => {

@@ -149,3 +85,6 @@ waitingList.clear();

};
exports.createQueue = createQueue;
//# sourceMappingURL=index.js.map
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createQueue
});
//# sourceMappingURL=index.js.map

@@ -1,1 +0,7 @@

{"version":3,"names":["_requestIdleCallback","_interopRequireDefault","require","createQueue","waitingList","Map","isRunning","runWaitingList","deadline","nextElement","callback","delete","timeRemaining","size","requestIdleCallback","add","element","item","set","flush","get","undefined","cancel","reset","clear","exports"],"sources":["@wordpress/priority-queue/src/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n */\nexport type WPPriorityQueueCallback = VoidFunction;\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n */\nexport type WPPriorityQueueContext = object;\n\n/**\n * Interface for the priority queue instance.\n */\nexport interface WPPriorityQueue {\n\t/**\n\t * Add a callback to the queue for a given context.\n\t */\n\tadd: (\n\t\telement: WPPriorityQueueContext,\n\t\titem: WPPriorityQueueCallback\n\t) => void;\n\n\t/**\n\t * Flush and run the callback for a given context immediately.\n\t * @return true if a callback was run, false otherwise.\n\t */\n\tflush: ( element: WPPriorityQueueContext ) => boolean;\n\n\t/**\n\t * Cancel (remove) the callback for a given context without running it.\n\t * @return true if a callback was cancelled, false otherwise.\n\t */\n\tcancel: ( element: WPPriorityQueueContext ) => boolean;\n\n\t/**\n\t * Reset the entire queue, clearing pending callbacks.\n\t */\n\treset: VoidFunction;\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 = (): WPPriorityQueue => {\n\tconst waitingList = new Map<\n\t\tWPPriorityQueueContext,\n\t\tWPPriorityQueueCallback\n\t>();\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * Map Iteration follows the original insertion order. This means that here\n\t * we can iterate the queue and know that the first contexts which were\n\t * added will be run first. On the other hand, if anyone adds a new callback\n\t * for an existing context it will supplant the previously-set callback for\n\t * that context because we reassigned that map key's value.\n\t *\n\t * In the case that a callback adds a new callback to its own context then\n\t * the callback it adds will appear at the end of the iteration and will be\n\t * run only after all other existing contexts have finished executing.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline: IdleDeadline | number ): void => {\n\t\tfor ( const [ nextElement, callback ] of waitingList ) {\n\t\t\twaitingList.delete( nextElement );\n\t\t\tcallback();\n\n\t\t\tif (\n\t\t\t\t'number' === typeof deadline ||\n\t\t\t\tdeadline.timeRemaining() <= 0\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( waitingList.size === 0 ) {\n\t\t\tisRunning = false;\n\t\t\treturn;\n\t\t}\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 * If errors with undefined callbacks are encountered double check that\n\t * all of your useSelect calls have the right dependencies set correctly\n\t * in their second parameter. Missing dependencies can cause unexpected\n\t * loops and race conditions in the queue.\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add: WPPriorityQueue[ 'add' ] = (\n\t\telement: WPPriorityQueueContext,\n\t\titem: WPPriorityQueueCallback\n\t) => {\n\t\twaitingList.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 * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush: WPPriorityQueue[ 'flush' ] = (\n\t\telement: WPPriorityQueueContext\n\t) => {\n\t\tconst callback = waitingList.get( element );\n\t\tif ( undefined === callback ) {\n\t\t\treturn false;\n\t\t}\n\n\t\twaitingList.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 * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel: WPPriorityQueue[ 'cancel' ] = (\n\t\telement: WPPriorityQueueContext\n\t) => {\n\t\treturn waitingList.delete( element );\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t */\n\tconst reset: WPPriorityQueue[ 'reset' ] = () => {\n\t\twaitingList.clear();\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"],"mappings":";;;;;;;AAGA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAAW,GAAGA,CAAA,KAAuB;EACjD,MAAMC,WAAW,GAAG,IAAIC,GAAG,CAGzB,CAAC;EACH,IAAIC,SAAS,GAAG,KAAK;;EAErB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMC,cAAc,GAAKC,QAA+B,IAAY;IACnE,KAAM,MAAM,CAAEC,WAAW,EAAEC,QAAQ,CAAE,IAAIN,WAAW,EAAG;MACtDA,WAAW,CAACO,MAAM,CAAEF,WAAY,CAAC;MACjCC,QAAQ,CAAC,CAAC;MAEV,IACC,QAAQ,KAAK,OAAOF,QAAQ,IAC5BA,QAAQ,CAACI,aAAa,CAAC,CAAC,IAAI,CAAC,EAC5B;QACD;MACD;IACD;IAEA,IAAKR,WAAW,CAACS,IAAI,KAAK,CAAC,EAAG;MAC7BP,SAAS,GAAG,KAAK;MACjB;IACD;IAEA,IAAAQ,4BAAmB,EAAEP,cAAe,CAAC;EACtC,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMQ,GAA6B,GAAGA,CACrCC,OAA+B,EAC/BC,IAA6B,KACzB;IACJb,WAAW,CAACc,GAAG,CAAEF,OAAO,EAAEC,IAAK,CAAC;IAChC,IAAK,CAAEX,SAAS,EAAG;MAClBA,SAAS,GAAG,IAAI;MAChB,IAAAQ,4BAAmB,EAAEP,cAAe,CAAC;IACtC;EACD,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMY,KAAiC,GACtCH,OAA+B,IAC3B;IACJ,MAAMN,QAAQ,GAAGN,WAAW,CAACgB,GAAG,CAAEJ,OAAQ,CAAC;IAC3C,IAAKK,SAAS,KAAKX,QAAQ,EAAG;MAC7B,OAAO,KAAK;IACb;IAEAN,WAAW,CAACO,MAAM,CAAEK,OAAQ,CAAC;IAC7BN,QAAQ,CAAC,CAAC;IAEV,OAAO,IAAI;EACZ,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAMY,MAAmC,GACxCN,OAA+B,IAC3B;IACJ,OAAOZ,WAAW,CAACO,MAAM,CAAEK,OAAQ,CAAC;EACrC,CAAC;;EAED;AACD;AACA;EACC,MAAMO,KAAiC,GAAGA,CAAA,KAAM;IAC/CnB,WAAW,CAACoB,KAAK,CAAC,CAAC;IACnBlB,SAAS,GAAG,KAAK;EAClB,CAAC;EAED,OAAO;IACNS,GAAG;IACHI,KAAK;IACLG,MAAM;IACNC;EACD,CAAC;AACF,CAAC;AAACE,OAAA,CAAAtB,WAAA,GAAAA,WAAA","ignoreList":[]}
{
"version": 3,
"sources": ["../src/index.ts"],
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport requestIdleCallback from './request-idle-callback';\n\n/**\n * Enqueued callback to invoke once idle time permits.\n */\nexport type WPPriorityQueueCallback = VoidFunction;\n\n/**\n * An object used to associate callbacks in a particular context grouping.\n */\nexport type WPPriorityQueueContext = object;\n\n/**\n * Interface for the priority queue instance.\n */\nexport interface WPPriorityQueue {\n\t/**\n\t * Add a callback to the queue for a given context.\n\t */\n\tadd: (\n\t\telement: WPPriorityQueueContext,\n\t\titem: WPPriorityQueueCallback\n\t) => void;\n\n\t/**\n\t * Flush and run the callback for a given context immediately.\n\t * @return true if a callback was run, false otherwise.\n\t */\n\tflush: ( element: WPPriorityQueueContext ) => boolean;\n\n\t/**\n\t * Cancel (remove) the callback for a given context without running it.\n\t * @return true if a callback was cancelled, false otherwise.\n\t */\n\tcancel: ( element: WPPriorityQueueContext ) => boolean;\n\n\t/**\n\t * Reset the entire queue, clearing pending callbacks.\n\t */\n\treset: VoidFunction;\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 = (): WPPriorityQueue => {\n\tconst waitingList = new Map<\n\t\tWPPriorityQueueContext,\n\t\tWPPriorityQueueCallback\n\t>();\n\tlet isRunning = false;\n\n\t/**\n\t * Callback to process as much queue as time permits.\n\t *\n\t * Map Iteration follows the original insertion order. This means that here\n\t * we can iterate the queue and know that the first contexts which were\n\t * added will be run first. On the other hand, if anyone adds a new callback\n\t * for an existing context it will supplant the previously-set callback for\n\t * that context because we reassigned that map key's value.\n\t *\n\t * In the case that a callback adds a new callback to its own context then\n\t * the callback it adds will appear at the end of the iteration and will be\n\t * run only after all other existing contexts have finished executing.\n\t *\n\t * @param {IdleDeadline|number} deadline Idle callback deadline object, or\n\t * animation frame timestamp.\n\t */\n\tconst runWaitingList = ( deadline: IdleDeadline | number ): void => {\n\t\tfor ( const [ nextElement, callback ] of waitingList ) {\n\t\t\twaitingList.delete( nextElement );\n\t\t\tcallback();\n\n\t\t\tif (\n\t\t\t\t'number' === typeof deadline ||\n\t\t\t\tdeadline.timeRemaining() <= 0\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( waitingList.size === 0 ) {\n\t\t\tisRunning = false;\n\t\t\treturn;\n\t\t}\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 * If errors with undefined callbacks are encountered double check that\n\t * all of your useSelect calls have the right dependencies set correctly\n\t * in their second parameter. Missing dependencies can cause unexpected\n\t * loops and race conditions in the queue.\n\t *\n\t * @param {WPPriorityQueueContext} element Context object.\n\t * @param {WPPriorityQueueCallback} item Callback function.\n\t */\n\tconst add: WPPriorityQueue[ 'add' ] = (\n\t\telement: WPPriorityQueueContext,\n\t\titem: WPPriorityQueueCallback\n\t) => {\n\t\twaitingList.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 * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether flush was performed.\n\t */\n\tconst flush: WPPriorityQueue[ 'flush' ] = (\n\t\telement: WPPriorityQueueContext\n\t) => {\n\t\tconst callback = waitingList.get( element );\n\t\tif ( undefined === callback ) {\n\t\t\treturn false;\n\t\t}\n\n\t\twaitingList.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 * @param {WPPriorityQueueContext} element Context object.\n\t *\n\t * @return {boolean} Whether any callbacks got cancelled.\n\t */\n\tconst cancel: WPPriorityQueue[ 'cancel' ] = (\n\t\telement: WPPriorityQueueContext\n\t) => {\n\t\treturn waitingList.delete( element );\n\t};\n\n\t/**\n\t * Reset the queue without running the pending callbacks.\n\t */\n\tconst reset: WPPriorityQueue[ 'reset' ] = () => {\n\t\twaitingList.clear();\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"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mCAAgC;AAgEzB,MAAM,cAAc,MAAuB;AACjD,QAAM,cAAc,oBAAI,IAGtB;AACF,MAAI,YAAY;AAkBhB,QAAM,iBAAiB,CAAE,aAA2C;AACnE,eAAY,CAAE,aAAa,QAAS,KAAK,aAAc;AACtD,kBAAY,OAAQ,WAAY;AAChC,eAAS;AAET,UACC,aAAa,OAAO,YACpB,SAAS,cAAc,KAAK,GAC3B;AACD;AAAA,MACD;AAAA,IACD;AAEA,QAAK,YAAY,SAAS,GAAI;AAC7B,kBAAY;AACZ;AAAA,IACD;AAEA,qCAAAA,SAAqB,cAAe;AAAA,EACrC;AAaA,QAAM,MAAgC,CACrC,SACA,SACI;AACJ,gBAAY,IAAK,SAAS,IAAK;AAC/B,QAAK,CAAE,WAAY;AAClB,kBAAY;AACZ,uCAAAA,SAAqB,cAAe;AAAA,IACrC;AAAA,EACD;AAUA,QAAM,QAAoC,CACzC,YACI;AACJ,UAAM,WAAW,YAAY,IAAK,OAAQ;AAC1C,QAAK,WAAc,UAAW;AAC7B,aAAO;AAAA,IACR;AAEA,gBAAY,OAAQ,OAAQ;AAC5B,aAAS;AAET,WAAO;AAAA,EACR;AAWA,QAAM,SAAsC,CAC3C,YACI;AACJ,WAAO,YAAY,OAAQ,OAAQ;AAAA,EACpC;AAKA,QAAM,QAAoC,MAAM;AAC/C,gBAAY,MAAM;AAClB,gBAAY;AAAA,EACb;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
"names": ["requestIdleCallback"]
}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var request_idle_callback_exports = {};
__export(request_idle_callback_exports, {
createRequestIdleCallback: () => createRequestIdleCallback,
default: () => request_idle_callback_default
});
exports.createRequestIdleCallback = createRequestIdleCallback;
exports.default = void 0;
require("requestidlecallback");
/**
* External dependencies
*/
/**
* Internal dependencies
*/
/**
* @return A function that schedules a callback when the browser is idle or via setTimeout on the server.
*/
module.exports = __toCommonJS(request_idle_callback_exports);
var import_requestidlecallback = require("requestidlecallback");
function createRequestIdleCallback() {
if (typeof window === 'undefined') {
return callback => {
if (typeof window === "undefined") {
return (callback) => {
setTimeout(() => callback(Date.now()), 0);

@@ -28,3 +34,7 @@ };

}
var _default = exports.default = createRequestIdleCallback();
//# sourceMappingURL=request-idle-callback.js.map
var request_idle_callback_default = createRequestIdleCallback();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
createRequestIdleCallback
});
//# sourceMappingURL=request-idle-callback.js.map

@@ -1,1 +0,7 @@

{"version":3,"names":["require","createRequestIdleCallback","window","callback","setTimeout","Date","now","requestIdleCallback","_default","exports","default"],"sources":["@wordpress/priority-queue/src/request-idle-callback.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport 'requestidlecallback';\n\n/**\n * Internal dependencies\n */\nimport type { RequestIdleCallbackCallback } from './types';\n\n/**\n * @return A function that schedules a callback when the browser is idle or via setTimeout on the server.\n */\nexport function createRequestIdleCallback() {\n\tif ( typeof window === 'undefined' ) {\n\t\treturn ( callback: RequestIdleCallbackCallback ) => {\n\t\t\tsetTimeout( () => callback( Date.now() ), 0 );\n\t\t};\n\t}\n\n\treturn window.requestIdleCallback;\n}\n\nexport default createRequestIdleCallback();\n"],"mappings":";;;;;;;AAGAA,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACO,SAASC,yBAAyBA,CAAA,EAAG;EAC3C,IAAK,OAAOC,MAAM,KAAK,WAAW,EAAG;IACpC,OAASC,QAAqC,IAAM;MACnDC,UAAU,CAAE,MAAMD,QAAQ,CAAEE,IAAI,CAACC,GAAG,CAAC,CAAE,CAAC,EAAE,CAAE,CAAC;IAC9C,CAAC;EACF;EAEA,OAAOJ,MAAM,CAACK,mBAAmB;AAClC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcT,yBAAyB,CAAC,CAAC","ignoreList":[]}
{
"version": 3,
"sources": ["../src/request-idle-callback.ts"],
"sourcesContent": ["/**\n * External dependencies\n */\nimport 'requestidlecallback';\n\n/**\n * Internal dependencies\n */\nimport type { RequestIdleCallbackCallback } from './types';\n\n/**\n * @return A function that schedules a callback when the browser is idle or via setTimeout on the server.\n */\nexport function createRequestIdleCallback() {\n\tif ( typeof window === 'undefined' ) {\n\t\treturn ( callback: RequestIdleCallbackCallback ) => {\n\t\t\tsetTimeout( () => callback( Date.now() ), 0 );\n\t\t};\n\t}\n\n\treturn window.requestIdleCallback;\n}\n\nexport default createRequestIdleCallback();\n"],
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iCAAO;AAUA,SAAS,4BAA4B;AAC3C,MAAK,OAAO,WAAW,aAAc;AACpC,WAAO,CAAE,aAA2C;AACnD,iBAAY,MAAM,SAAU,KAAK,IAAI,CAAE,GAAG,CAAE;AAAA,IAC7C;AAAA,EACD;AAEA,SAAO,OAAO;AACf;AAEA,IAAO,gCAAQ,0BAA0B;",
"names": []
}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var types_exports = {};
module.exports = __toCommonJS(types_exports);
//# sourceMappingURL=types.js.map

@@ -1,1 +0,7 @@

{"version":3,"names":[],"sources":["@wordpress/priority-queue/src/types.ts"],"sourcesContent":["export type RequestIdleCallbackCallback = (\n\t/**\n\t * @param timeOrDeadline - IdleDeadline object or a timestamp number.\n\t */\n\ttimeOrDeadline: IdleDeadline | number\n) => void;\n"],"mappings":"","ignoreList":[]}
{
"version": 3,
"sources": ["../src/types.ts"],
"sourcesContent": ["export type RequestIdleCallbackCallback = (\n\t/**\n\t * @param timeOrDeadline - IdleDeadline object or a timestamp number.\n\t */\n\ttimeOrDeadline: IdleDeadline | number\n) => void;\n"],
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
"names": []
}
{
"name": "@wordpress/priority-queue",
"version": "3.32.0",
"version": "3.32.1-next.47f435fc9.0",
"description": "Generic browser priority queue.",

@@ -28,2 +28,10 @@ "author": "The WordPress Contributors",

"module": "build-module/index.js",
"exports": {
".": {
"types": "./build-types/index.d.ts",
"import": "./build-module/index.js",
"require": "./build/index.js"
},
"./package.json": "./package.json"
},
"react-native": "src/index",

@@ -34,3 +42,2 @@ "wpScript": true,

"dependencies": {
"@babel/runtime": "7.25.7",
"requestidlecallback": "^0.3.0"

@@ -41,3 +48,3 @@ },

},
"gitHead": "a030b4c0e0695239b942c7dc18511782b64f10ed"
"gitHead": "9720f22c138771d2ed1a0522725c3cdf1c242953"
}