80 /******/ // __webpack_public_path__ |
80 /******/ // __webpack_public_path__ |
81 /******/ __webpack_require__.p = ""; |
81 /******/ __webpack_require__.p = ""; |
82 /******/ |
82 /******/ |
83 /******/ |
83 /******/ |
84 /******/ // Load entry module and return exports |
84 /******/ // Load entry module and return exports |
85 /******/ return __webpack_require__(__webpack_require__.s = 346); |
85 /******/ return __webpack_require__(__webpack_require__.s = 467); |
86 /******/ }) |
86 /******/ }) |
87 /************************************************************************/ |
87 /************************************************************************/ |
88 /******/ ({ |
88 /******/ ({ |
89 |
89 |
90 /***/ 346: |
90 /***/ 467: |
91 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
91 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
92 |
92 |
93 "use strict"; |
93 "use strict"; |
|
94 // ESM COMPAT FLAG |
94 __webpack_require__.r(__webpack_exports__); |
95 __webpack_require__.r(__webpack_exports__); |
95 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createQueue", function() { return createQueue; }); |
96 |
96 var requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame; |
97 // EXPORTS |
|
98 __webpack_require__.d(__webpack_exports__, "createQueue", function() { return /* binding */ build_module_createQueue; }); |
|
99 |
|
100 // CONCATENATED MODULE: ./node_modules/@wordpress/priority-queue/build-module/request-idle-callback.js |
|
101 /** |
|
102 * @typedef {( timeOrDeadline: IdleDeadline | number ) => void} Callback |
|
103 */ |
|
104 |
|
105 /** |
|
106 * @return {(callback: Callback) => void} RequestIdleCallback |
|
107 */ |
|
108 function createRequestIdleCallback() { |
|
109 if (typeof window === 'undefined') { |
|
110 return function (callback) { |
|
111 setTimeout(function () { |
|
112 return callback(Date.now()); |
|
113 }, 0); |
|
114 }; |
|
115 } |
|
116 |
|
117 return window.requestIdleCallback || window.requestAnimationFrame; |
|
118 } |
|
119 /* harmony default export */ var request_idle_callback = (createRequestIdleCallback()); |
|
120 |
|
121 // CONCATENATED MODULE: ./node_modules/@wordpress/priority-queue/build-module/index.js |
|
122 /** |
|
123 * Internal dependencies |
|
124 */ |
|
125 |
|
126 /** |
|
127 * Enqueued callback to invoke once idle time permits. |
|
128 * |
|
129 * @typedef {()=>void} WPPriorityQueueCallback |
|
130 */ |
|
131 |
|
132 /** |
|
133 * An object used to associate callbacks in a particular context grouping. |
|
134 * |
|
135 * @typedef {{}} WPPriorityQueueContext |
|
136 */ |
|
137 |
|
138 /** |
|
139 * Function to add callback to priority queue. |
|
140 * |
|
141 * @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd |
|
142 */ |
|
143 |
|
144 /** |
|
145 * Function to flush callbacks from priority queue. |
|
146 * |
|
147 * @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush |
|
148 */ |
|
149 |
|
150 /** |
|
151 * Reset the queue. |
|
152 * |
|
153 * @typedef {()=>void} WPPriorityQueueReset |
|
154 */ |
|
155 |
|
156 /** |
|
157 * Priority queue instance. |
|
158 * |
|
159 * @typedef {Object} WPPriorityQueue |
|
160 * |
|
161 * @property {WPPriorityQueueAdd} add Add callback to queue for context. |
|
162 * @property {WPPriorityQueueFlush} flush Flush queue for context. |
|
163 * @property {WPPriorityQueueReset} reset Reset queue. |
|
164 */ |
|
165 |
97 /** |
166 /** |
98 * Creates a context-aware queue that only executes |
167 * Creates a context-aware queue that only executes |
99 * the last task of a given context. |
168 * the last task of a given context. |
100 * |
169 * |
101 * @example |
170 * @example |
112 * queue.add( ctx1, () => console.log( 'This will be printed first' ) ); |
181 * queue.add( ctx1, () => console.log( 'This will be printed first' ) ); |
113 * queue.add( ctx2, () => console.log( 'This won\'t be printed' ) ); |
182 * queue.add( ctx2, () => console.log( 'This won\'t be printed' ) ); |
114 * queue.add( ctx2, () => console.log( 'This will be printed second' ) ); |
183 * queue.add( ctx2, () => console.log( 'This will be printed second' ) ); |
115 *``` |
184 *``` |
116 * |
185 * |
117 * @return {Object} Queue object with `add` and `flush` methods. |
186 * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods. |
118 */ |
187 */ |
119 |
188 |
120 var createQueue = function createQueue() { |
189 var build_module_createQueue = function createQueue() { |
|
190 /** @type {WPPriorityQueueContext[]} */ |
121 var waitingList = []; |
191 var waitingList = []; |
|
192 /** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */ |
|
193 |
122 var elementsMap = new WeakMap(); |
194 var elementsMap = new WeakMap(); |
123 var isRunning = false; |
195 var isRunning = false; |
|
196 /* eslint-disable jsdoc/valid-types */ |
|
197 |
|
198 /** |
|
199 * Callback to process as much queue as time permits. |
|
200 * |
|
201 * @param {IdleDeadline|number} deadline Idle callback deadline object, or |
|
202 * animation frame timestamp. |
|
203 */ |
|
204 |
|
205 /* eslint-enable */ |
124 |
206 |
125 var runWaitingList = function runWaitingList(deadline) { |
207 var runWaitingList = function runWaitingList(deadline) { |
|
208 var hasTimeRemaining = typeof deadline === 'number' ? function () { |
|
209 return false; |
|
210 } : function () { |
|
211 return deadline.timeRemaining() > 0; |
|
212 }; |
|
213 |
126 do { |
214 do { |
127 if (waitingList.length === 0) { |
215 if (waitingList.length === 0) { |
128 isRunning = false; |
216 isRunning = false; |
129 return; |
217 return; |
130 } |
218 } |
131 |
219 |
132 var nextElement = waitingList.shift(); |
220 var nextElement = |
133 elementsMap.get(nextElement)(); |
221 /** @type {WPPriorityQueueContext} */ |
|
222 waitingList.shift(); |
|
223 var callback = |
|
224 /** @type {WPPriorityQueueCallback} */ |
|
225 elementsMap.get(nextElement); |
|
226 callback(); |
134 elementsMap.delete(nextElement); |
227 elementsMap.delete(nextElement); |
135 } while (deadline && deadline.timeRemaining && deadline.timeRemaining() > 0); |
228 } while (hasTimeRemaining()); |
136 |
229 |
137 requestIdleCallback(runWaitingList); |
230 request_idle_callback(runWaitingList); |
138 }; |
231 }; |
|
232 /** |
|
233 * Add a callback to the queue for a given context. |
|
234 * |
|
235 * @type {WPPriorityQueueAdd} |
|
236 * |
|
237 * @param {WPPriorityQueueContext} element Context object. |
|
238 * @param {WPPriorityQueueCallback} item Callback function. |
|
239 */ |
|
240 |
139 |
241 |
140 var add = function add(element, item) { |
242 var add = function add(element, item) { |
141 if (!elementsMap.has(element)) { |
243 if (!elementsMap.has(element)) { |
142 waitingList.push(element); |
244 waitingList.push(element); |
143 } |
245 } |
144 |
246 |
145 elementsMap.set(element, item); |
247 elementsMap.set(element, item); |
146 |
248 |
147 if (!isRunning) { |
249 if (!isRunning) { |
148 isRunning = true; |
250 isRunning = true; |
149 requestIdleCallback(runWaitingList); |
251 request_idle_callback(runWaitingList); |
150 } |
252 } |
151 }; |
253 }; |
|
254 /** |
|
255 * Flushes queue for a given context, returning true if the flush was |
|
256 * performed, or false if there is no queue for the given context. |
|
257 * |
|
258 * @type {WPPriorityQueueFlush} |
|
259 * |
|
260 * @param {WPPriorityQueueContext} element Context object. |
|
261 * |
|
262 * @return {boolean} Whether flush was performed. |
|
263 */ |
|
264 |
152 |
265 |
153 var flush = function flush(element) { |
266 var flush = function flush(element) { |
154 if (!elementsMap.has(element)) { |
267 if (!elementsMap.has(element)) { |
155 return false; |
268 return false; |
156 } |
269 } |
157 |
270 |
158 elementsMap.delete(element); |
|
159 var index = waitingList.indexOf(element); |
271 var index = waitingList.indexOf(element); |
160 waitingList.splice(index, 1); |
272 waitingList.splice(index, 1); |
|
273 var callback = |
|
274 /** @type {WPPriorityQueueCallback} */ |
|
275 elementsMap.get(element); |
|
276 elementsMap.delete(element); |
|
277 callback(); |
161 return true; |
278 return true; |
|
279 }; |
|
280 /** |
|
281 * Reset the queue without running the pending callbacks. |
|
282 * |
|
283 * @type {WPPriorityQueueReset} |
|
284 */ |
|
285 |
|
286 |
|
287 var reset = function reset() { |
|
288 waitingList = []; |
|
289 elementsMap = new WeakMap(); |
|
290 isRunning = false; |
162 }; |
291 }; |
163 |
292 |
164 return { |
293 return { |
165 add: add, |
294 add: add, |
166 flush: flush |
295 flush: flush, |
|
296 reset: reset |
167 }; |
297 }; |
168 }; |
298 }; |
169 |
299 |
170 |
300 |
171 /***/ }) |
301 /***/ }) |