2022-04-11 14:04:30 +02:00
|
|
|
/******/ (function() { // webpackBootstrap
|
|
|
|
/******/ "use strict";
|
|
|
|
/******/ // The require scope
|
|
|
|
/******/ var __webpack_require__ = {};
|
|
|
|
/******/
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ /* webpack/runtime/define property getters */
|
|
|
|
/******/ !function() {
|
|
|
|
/******/ // define getter functions for harmony exports
|
|
|
|
/******/ __webpack_require__.d = function(exports, definition) {
|
|
|
|
/******/ for(var key in definition) {
|
|
|
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
|
|
/******/ }
|
|
|
|
/******/ }
|
|
|
|
/******/ };
|
|
|
|
/******/ }();
|
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
|
|
/******/ !function() {
|
|
|
|
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
|
|
|
/******/ }();
|
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/make namespace object */
|
|
|
|
/******/ !function() {
|
|
|
|
/******/ // define __esModule on exports
|
|
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
/******/ }
|
|
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
2019-03-07 10:09:59 +01:00
|
|
|
/******/ };
|
2022-04-11 14:04:30 +02:00
|
|
|
/******/ }();
|
|
|
|
/******/
|
2019-03-07 10:09:59 +01:00
|
|
|
/************************************************************************/
|
2022-04-11 14:04:30 +02:00
|
|
|
var __webpack_exports__ = {};
|
2020-06-29 13:50:29 +02:00
|
|
|
// ESM COMPAT FLAG
|
2019-03-07 10:09:59 +01:00
|
|
|
__webpack_require__.r(__webpack_exports__);
|
2020-02-06 22:03:31 +01:00
|
|
|
|
2020-06-29 13:50:29 +02:00
|
|
|
// EXPORTS
|
2022-04-11 14:04:30 +02:00
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
|
"createQueue": function() { return /* binding */ createQueue; }
|
|
|
|
});
|
2020-06-29 13:50:29 +02:00
|
|
|
|
2022-04-11 14:04:30 +02:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/priority-queue/build-module/request-idle-callback.js
|
2020-02-06 22:03:31 +01:00
|
|
|
/**
|
2020-06-26 15:33:47 +02:00
|
|
|
* @typedef {( timeOrDeadline: IdleDeadline | number ) => void} Callback
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {(callback: Callback) => void} RequestIdleCallback
|
2020-02-06 22:03:31 +01:00
|
|
|
*/
|
|
|
|
function createRequestIdleCallback() {
|
2020-03-03 00:21:15 +01:00
|
|
|
if (typeof window === 'undefined') {
|
2021-05-19 17:09:27 +02:00
|
|
|
return callback => {
|
|
|
|
setTimeout(() => callback(Date.now()), 0);
|
2020-02-06 22:03:31 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return window.requestIdleCallback || window.requestAnimationFrame;
|
|
|
|
}
|
|
|
|
/* harmony default export */ var request_idle_callback = (createRequestIdleCallback());
|
|
|
|
|
2022-04-11 14:04:30 +02:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/priority-queue/build-module/index.js
|
2020-02-06 22:03:31 +01:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
2020-01-22 23:06:21 +01:00
|
|
|
/**
|
|
|
|
* Enqueued callback to invoke once idle time permits.
|
|
|
|
*
|
|
|
|
* @typedef {()=>void} WPPriorityQueueCallback
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An object used to associate callbacks in a particular context grouping.
|
|
|
|
*
|
|
|
|
* @typedef {{}} WPPriorityQueueContext
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to add callback to priority queue.
|
|
|
|
*
|
|
|
|
* @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to flush callbacks from priority queue.
|
|
|
|
*
|
|
|
|
* @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush
|
|
|
|
*/
|
|
|
|
|
2020-06-26 15:33:47 +02:00
|
|
|
/**
|
|
|
|
* Reset the queue.
|
|
|
|
*
|
|
|
|
* @typedef {()=>void} WPPriorityQueueReset
|
|
|
|
*/
|
|
|
|
|
2020-01-22 23:06:21 +01:00
|
|
|
/**
|
|
|
|
* Priority queue instance.
|
|
|
|
*
|
|
|
|
* @typedef {Object} WPPriorityQueue
|
|
|
|
*
|
|
|
|
* @property {WPPriorityQueueAdd} add Add callback to queue for context.
|
|
|
|
* @property {WPPriorityQueueFlush} flush Flush queue for context.
|
2020-06-26 15:33:47 +02:00
|
|
|
* @property {WPPriorityQueueReset} reset Reset queue.
|
2020-01-22 23:06:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-03-21 13:48:00 +01:00
|
|
|
/**
|
|
|
|
* 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' ) );
|
|
|
|
*```
|
|
|
|
*
|
2020-06-26 15:33:47 +02:00
|
|
|
* @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.
|
2019-03-21 13:48:00 +01:00
|
|
|
*/
|
|
|
|
|
2021-05-19 17:09:27 +02:00
|
|
|
const createQueue = () => {
|
2020-01-22 23:06:21 +01:00
|
|
|
/** @type {WPPriorityQueueContext[]} */
|
2021-05-19 17:09:27 +02:00
|
|
|
let waitingList = [];
|
2020-01-22 23:06:21 +01:00
|
|
|
/** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */
|
|
|
|
|
2021-05-19 17:09:27 +02:00
|
|
|
let elementsMap = new WeakMap();
|
|
|
|
let isRunning = false;
|
2020-01-22 23:06:21 +01:00
|
|
|
/**
|
|
|
|
* Callback to process as much queue as time permits.
|
|
|
|
*
|
|
|
|
* @param {IdleDeadline|number} deadline Idle callback deadline object, or
|
|
|
|
* animation frame timestamp.
|
|
|
|
*/
|
2019-03-07 10:09:59 +01:00
|
|
|
|
2021-05-19 17:09:27 +02:00
|
|
|
const runWaitingList = deadline => {
|
|
|
|
const hasTimeRemaining = typeof deadline === 'number' ? () => false : () => deadline.timeRemaining() > 0;
|
2020-01-22 23:06:21 +01:00
|
|
|
|
2019-03-07 10:09:59 +01:00
|
|
|
do {
|
|
|
|
if (waitingList.length === 0) {
|
|
|
|
isRunning = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-19 17:09:27 +02:00
|
|
|
const nextElement =
|
2020-01-22 23:06:21 +01:00
|
|
|
/** @type {WPPriorityQueueContext} */
|
|
|
|
waitingList.shift();
|
2021-05-19 17:09:27 +02:00
|
|
|
const callback =
|
2020-01-22 23:06:21 +01:00
|
|
|
/** @type {WPPriorityQueueCallback} */
|
2021-04-15 17:19:43 +02:00
|
|
|
elementsMap.get(nextElement); // If errors with undefined callbacks are encountered double check that all of your useSelect calls
|
|
|
|
// have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected
|
|
|
|
// loops and race conditions in the queue.
|
|
|
|
|
2020-01-22 23:06:21 +01:00
|
|
|
callback();
|
2019-03-07 10:09:59 +01:00
|
|
|
elementsMap.delete(nextElement);
|
2020-01-22 23:06:21 +01:00
|
|
|
} while (hasTimeRemaining());
|
2019-03-07 10:09:59 +01:00
|
|
|
|
2020-02-06 22:03:31 +01:00
|
|
|
request_idle_callback(runWaitingList);
|
2019-03-07 10:09:59 +01:00
|
|
|
};
|
2020-01-22 23:06:21 +01:00
|
|
|
/**
|
|
|
|
* Add a callback to the queue for a given context.
|
|
|
|
*
|
|
|
|
* @type {WPPriorityQueueAdd}
|
|
|
|
*
|
|
|
|
* @param {WPPriorityQueueContext} element Context object.
|
|
|
|
* @param {WPPriorityQueueCallback} item Callback function.
|
|
|
|
*/
|
|
|
|
|
2019-03-07 10:09:59 +01:00
|
|
|
|
2021-05-19 17:09:27 +02:00
|
|
|
const add = (element, item) => {
|
2019-03-07 10:09:59 +01:00
|
|
|
if (!elementsMap.has(element)) {
|
|
|
|
waitingList.push(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
elementsMap.set(element, item);
|
|
|
|
|
|
|
|
if (!isRunning) {
|
|
|
|
isRunning = true;
|
2020-02-06 22:03:31 +01:00
|
|
|
request_idle_callback(runWaitingList);
|
2019-03-07 10:09:59 +01:00
|
|
|
}
|
|
|
|
};
|
2020-01-22 23:06:21 +01:00
|
|
|
/**
|
|
|
|
* Flushes queue for a given context, returning true if the flush was
|
|
|
|
* performed, or false if there is no queue for the given context.
|
|
|
|
*
|
|
|
|
* @type {WPPriorityQueueFlush}
|
|
|
|
*
|
|
|
|
* @param {WPPriorityQueueContext} element Context object.
|
|
|
|
*
|
|
|
|
* @return {boolean} Whether flush was performed.
|
|
|
|
*/
|
|
|
|
|
2019-03-07 10:09:59 +01:00
|
|
|
|
2021-05-19 17:09:27 +02:00
|
|
|
const flush = element => {
|
2019-03-07 10:09:59 +01:00
|
|
|
if (!elementsMap.has(element)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-05-19 17:09:27 +02:00
|
|
|
const index = waitingList.indexOf(element);
|
2019-03-07 10:09:59 +01:00
|
|
|
waitingList.splice(index, 1);
|
2021-05-19 17:09:27 +02:00
|
|
|
const callback =
|
2020-02-06 22:03:31 +01:00
|
|
|
/** @type {WPPriorityQueueCallback} */
|
|
|
|
elementsMap.get(element);
|
|
|
|
elementsMap.delete(element);
|
|
|
|
callback();
|
2019-03-07 10:09:59 +01:00
|
|
|
return true;
|
|
|
|
};
|
2020-06-26 15:33:47 +02:00
|
|
|
/**
|
|
|
|
* Reset the queue without running the pending callbacks.
|
|
|
|
*
|
|
|
|
* @type {WPPriorityQueueReset}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-05-19 17:09:27 +02:00
|
|
|
const reset = () => {
|
2020-06-26 15:33:47 +02:00
|
|
|
waitingList = [];
|
|
|
|
elementsMap = new WeakMap();
|
|
|
|
isRunning = false;
|
|
|
|
};
|
2019-03-07 10:09:59 +01:00
|
|
|
|
|
|
|
return {
|
2021-05-19 17:09:27 +02:00
|
|
|
add,
|
|
|
|
flush,
|
|
|
|
reset
|
2019-03-07 10:09:59 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-04-11 14:04:30 +02:00
|
|
|
(window.wp = window.wp || {}).priorityQueue = __webpack_exports__;
|
|
|
|
/******/ })()
|
|
|
|
;
|