1 /******/ (function() { // webpackBootstrap |
1 /******/ (() => { // webpackBootstrap |
2 /******/ "use strict"; |
2 /******/ var __webpack_modules__ = ({ |
3 /******/ // The require scope |
3 |
4 /******/ var __webpack_require__ = {}; |
4 /***/ 5033: |
|
5 /***/ ((module, exports, __webpack_require__) => { |
|
6 |
|
7 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (factory) { |
|
8 if (true) { |
|
9 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), |
|
10 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? |
|
11 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), |
|
12 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
13 } else {} |
|
14 }(function(){ |
|
15 'use strict'; |
|
16 var scheduleStart, throttleDelay, lazytimer, lazyraf; |
|
17 var root = typeof window != 'undefined' ? |
|
18 window : |
|
19 typeof __webpack_require__.g != undefined ? |
|
20 __webpack_require__.g : |
|
21 this || {}; |
|
22 var requestAnimationFrame = root.cancelRequestAnimationFrame && root.requestAnimationFrame || setTimeout; |
|
23 var cancelRequestAnimationFrame = root.cancelRequestAnimationFrame || clearTimeout; |
|
24 var tasks = []; |
|
25 var runAttempts = 0; |
|
26 var isRunning = false; |
|
27 var remainingTime = 7; |
|
28 var minThrottle = 35; |
|
29 var throttle = 125; |
|
30 var index = 0; |
|
31 var taskStart = 0; |
|
32 var tasklength = 0; |
|
33 var IdleDeadline = { |
|
34 get didTimeout(){ |
|
35 return false; |
|
36 }, |
|
37 timeRemaining: function(){ |
|
38 var timeRemaining = remainingTime - (Date.now() - taskStart); |
|
39 return timeRemaining < 0 ? 0 : timeRemaining; |
|
40 }, |
|
41 }; |
|
42 var setInactive = debounce(function(){ |
|
43 remainingTime = 22; |
|
44 throttle = 66; |
|
45 minThrottle = 0; |
|
46 }); |
|
47 |
|
48 function debounce(fn){ |
|
49 var id, timestamp; |
|
50 var wait = 99; |
|
51 var check = function(){ |
|
52 var last = (Date.now()) - timestamp; |
|
53 |
|
54 if (last < wait) { |
|
55 id = setTimeout(check, wait - last); |
|
56 } else { |
|
57 id = null; |
|
58 fn(); |
|
59 } |
|
60 }; |
|
61 return function(){ |
|
62 timestamp = Date.now(); |
|
63 if(!id){ |
|
64 id = setTimeout(check, wait); |
|
65 } |
|
66 }; |
|
67 } |
|
68 |
|
69 function abortRunning(){ |
|
70 if(isRunning){ |
|
71 if(lazyraf){ |
|
72 cancelRequestAnimationFrame(lazyraf); |
|
73 } |
|
74 if(lazytimer){ |
|
75 clearTimeout(lazytimer); |
|
76 } |
|
77 isRunning = false; |
|
78 } |
|
79 } |
|
80 |
|
81 function onInputorMutation(){ |
|
82 if(throttle != 125){ |
|
83 remainingTime = 7; |
|
84 throttle = 125; |
|
85 minThrottle = 35; |
|
86 |
|
87 if(isRunning) { |
|
88 abortRunning(); |
|
89 scheduleLazy(); |
|
90 } |
|
91 } |
|
92 setInactive(); |
|
93 } |
|
94 |
|
95 function scheduleAfterRaf() { |
|
96 lazyraf = null; |
|
97 lazytimer = setTimeout(runTasks, 0); |
|
98 } |
|
99 |
|
100 function scheduleRaf(){ |
|
101 lazytimer = null; |
|
102 requestAnimationFrame(scheduleAfterRaf); |
|
103 } |
|
104 |
|
105 function scheduleLazy(){ |
|
106 |
|
107 if(isRunning){return;} |
|
108 throttleDelay = throttle - (Date.now() - taskStart); |
|
109 |
|
110 scheduleStart = Date.now(); |
|
111 |
|
112 isRunning = true; |
|
113 |
|
114 if(minThrottle && throttleDelay < minThrottle){ |
|
115 throttleDelay = minThrottle; |
|
116 } |
|
117 |
|
118 if(throttleDelay > 9){ |
|
119 lazytimer = setTimeout(scheduleRaf, throttleDelay); |
|
120 } else { |
|
121 throttleDelay = 0; |
|
122 scheduleRaf(); |
|
123 } |
|
124 } |
|
125 |
|
126 function runTasks(){ |
|
127 var task, i, len; |
|
128 var timeThreshold = remainingTime > 9 ? |
|
129 9 : |
|
130 1 |
|
131 ; |
|
132 |
|
133 taskStart = Date.now(); |
|
134 isRunning = false; |
|
135 |
|
136 lazytimer = null; |
|
137 |
|
138 if(runAttempts > 2 || taskStart - throttleDelay - 50 < scheduleStart){ |
|
139 for(i = 0, len = tasks.length; i < len && IdleDeadline.timeRemaining() > timeThreshold; i++){ |
|
140 task = tasks.shift(); |
|
141 tasklength++; |
|
142 if(task){ |
|
143 task(IdleDeadline); |
|
144 } |
|
145 } |
|
146 } |
|
147 |
|
148 if(tasks.length){ |
|
149 scheduleLazy(); |
|
150 } else { |
|
151 runAttempts = 0; |
|
152 } |
|
153 } |
|
154 |
|
155 function requestIdleCallbackShim(task){ |
|
156 index++; |
|
157 tasks.push(task); |
|
158 scheduleLazy(); |
|
159 return index; |
|
160 } |
|
161 |
|
162 function cancelIdleCallbackShim(id){ |
|
163 var index = id - 1 - tasklength; |
|
164 if(tasks[index]){ |
|
165 tasks[index] = null; |
|
166 } |
|
167 } |
|
168 |
|
169 if(!root.requestIdleCallback || !root.cancelIdleCallback){ |
|
170 root.requestIdleCallback = requestIdleCallbackShim; |
|
171 root.cancelIdleCallback = cancelIdleCallbackShim; |
|
172 |
|
173 if(root.document && document.addEventListener){ |
|
174 root.addEventListener('scroll', onInputorMutation, true); |
|
175 root.addEventListener('resize', onInputorMutation); |
|
176 |
|
177 document.addEventListener('focus', onInputorMutation, true); |
|
178 document.addEventListener('mouseover', onInputorMutation, true); |
|
179 ['click', 'keypress', 'touchstart', 'mousedown'].forEach(function(name){ |
|
180 document.addEventListener(name, onInputorMutation, {capture: true, passive: true}); |
|
181 }); |
|
182 |
|
183 if(root.MutationObserver){ |
|
184 new MutationObserver( onInputorMutation ).observe( document.documentElement, {childList: true, subtree: true, attributes: true} ); |
|
185 } |
|
186 } |
|
187 } else { |
|
188 try{ |
|
189 root.requestIdleCallback(function(){}, {timeout: 0}); |
|
190 } catch(e){ |
|
191 (function(rIC){ |
|
192 var timeRemainingProto, timeRemaining; |
|
193 root.requestIdleCallback = function(fn, timeout){ |
|
194 if(timeout && typeof timeout.timeout == 'number'){ |
|
195 return rIC(fn, timeout.timeout); |
|
196 } |
|
197 return rIC(fn); |
|
198 }; |
|
199 if(root.IdleCallbackDeadline && (timeRemainingProto = IdleCallbackDeadline.prototype)){ |
|
200 timeRemaining = Object.getOwnPropertyDescriptor(timeRemainingProto, 'timeRemaining'); |
|
201 if(!timeRemaining || !timeRemaining.configurable || !timeRemaining.get){return;} |
|
202 Object.defineProperty(timeRemainingProto, 'timeRemaining', { |
|
203 value: function(){ |
|
204 return timeRemaining.get.call(this); |
|
205 }, |
|
206 enumerable: true, |
|
207 configurable: true, |
|
208 }); |
|
209 } |
|
210 })(root.requestIdleCallback) |
|
211 } |
|
212 } |
|
213 |
|
214 return { |
|
215 request: requestIdleCallbackShim, |
|
216 cancel: cancelIdleCallbackShim, |
|
217 }; |
|
218 })); |
|
219 |
|
220 |
|
221 /***/ }) |
|
222 |
|
223 /******/ }); |
|
224 /************************************************************************/ |
|
225 /******/ // The module cache |
|
226 /******/ var __webpack_module_cache__ = {}; |
|
227 /******/ |
|
228 /******/ // The require function |
|
229 /******/ function __webpack_require__(moduleId) { |
|
230 /******/ // Check if module is in cache |
|
231 /******/ var cachedModule = __webpack_module_cache__[moduleId]; |
|
232 /******/ if (cachedModule !== undefined) { |
|
233 /******/ return cachedModule.exports; |
|
234 /******/ } |
|
235 /******/ // Create a new module (and put it into the cache) |
|
236 /******/ var module = __webpack_module_cache__[moduleId] = { |
|
237 /******/ // no module.id needed |
|
238 /******/ // no module.loaded needed |
|
239 /******/ exports: {} |
|
240 /******/ }; |
|
241 /******/ |
|
242 /******/ // Execute the module function |
|
243 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
|
244 /******/ |
|
245 /******/ // Return the exports of the module |
|
246 /******/ return module.exports; |
|
247 /******/ } |
5 /******/ |
248 /******/ |
6 /************************************************************************/ |
249 /************************************************************************/ |
7 /******/ /* webpack/runtime/define property getters */ |
250 /******/ /* webpack/runtime/define property getters */ |
8 /******/ !function() { |
251 /******/ (() => { |
9 /******/ // define getter functions for harmony exports |
252 /******/ // define getter functions for harmony exports |
10 /******/ __webpack_require__.d = function(exports, definition) { |
253 /******/ __webpack_require__.d = (exports, definition) => { |
11 /******/ for(var key in definition) { |
254 /******/ for(var key in definition) { |
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
255 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
256 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
14 /******/ } |
257 /******/ } |
15 /******/ } |
258 /******/ } |
16 /******/ }; |
259 /******/ }; |
17 /******/ }(); |
260 /******/ })(); |
|
261 /******/ |
|
262 /******/ /* webpack/runtime/global */ |
|
263 /******/ (() => { |
|
264 /******/ __webpack_require__.g = (function() { |
|
265 /******/ if (typeof globalThis === 'object') return globalThis; |
|
266 /******/ try { |
|
267 /******/ return this || new Function('return this')(); |
|
268 /******/ } catch (e) { |
|
269 /******/ if (typeof window === 'object') return window; |
|
270 /******/ } |
|
271 /******/ })(); |
|
272 /******/ })(); |
18 /******/ |
273 /******/ |
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
274 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
20 /******/ !function() { |
275 /******/ (() => { |
21 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
276 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
22 /******/ }(); |
277 /******/ })(); |
23 /******/ |
278 /******/ |
24 /******/ /* webpack/runtime/make namespace object */ |
279 /******/ /* webpack/runtime/make namespace object */ |
25 /******/ !function() { |
280 /******/ (() => { |
26 /******/ // define __esModule on exports |
281 /******/ // define __esModule on exports |
27 /******/ __webpack_require__.r = function(exports) { |
282 /******/ __webpack_require__.r = (exports) => { |
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
283 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
284 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
30 /******/ } |
285 /******/ } |
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
286 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
32 /******/ }; |
287 /******/ }; |
33 /******/ }(); |
288 /******/ })(); |
34 /******/ |
289 /******/ |
35 /************************************************************************/ |
290 /************************************************************************/ |
36 var __webpack_exports__ = {}; |
291 var __webpack_exports__ = {}; |
|
292 // This entry need to be wrapped in an IIFE because it need to be in strict mode. |
|
293 (() => { |
|
294 "use strict"; |
37 // ESM COMPAT FLAG |
295 // ESM COMPAT FLAG |
38 __webpack_require__.r(__webpack_exports__); |
296 __webpack_require__.r(__webpack_exports__); |
39 |
297 |
40 // EXPORTS |
298 // EXPORTS |
41 __webpack_require__.d(__webpack_exports__, { |
299 __webpack_require__.d(__webpack_exports__, { |
42 "createQueue": function() { return /* binding */ createQueue; } |
300 createQueue: () => (/* binding */ createQueue) |
43 }); |
301 }); |
44 |
302 |
|
303 // EXTERNAL MODULE: ./node_modules/requestidlecallback/index.js |
|
304 var requestidlecallback = __webpack_require__(5033); |
45 ;// CONCATENATED MODULE: ./node_modules/@wordpress/priority-queue/build-module/request-idle-callback.js |
305 ;// CONCATENATED MODULE: ./node_modules/@wordpress/priority-queue/build-module/request-idle-callback.js |
|
306 /** |
|
307 * External dependencies |
|
308 */ |
|
309 |
|
310 |
46 /** |
311 /** |
47 * @typedef {( timeOrDeadline: IdleDeadline | number ) => void} Callback |
312 * @typedef {( timeOrDeadline: IdleDeadline | number ) => void} Callback |
48 */ |
313 */ |
49 |
314 |
50 /** |
315 /** |
126 * queue.add( ctx2, () => console.log( 'This will be printed second' ) ); |
392 * queue.add( ctx2, () => console.log( 'This will be printed second' ) ); |
127 *``` |
393 *``` |
128 * |
394 * |
129 * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods. |
395 * @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods. |
130 */ |
396 */ |
131 |
|
132 const createQueue = () => { |
397 const createQueue = () => { |
133 /** @type {WPPriorityQueueContext[]} */ |
398 /** @type {Map<WPPriorityQueueContext, WPPriorityQueueCallback>} */ |
134 let waitingList = []; |
399 const waitingList = new Map(); |
135 /** @type {WeakMap<WPPriorityQueueContext,WPPriorityQueueCallback>} */ |
|
136 |
|
137 let elementsMap = new WeakMap(); |
|
138 let isRunning = false; |
400 let isRunning = false; |
|
401 |
139 /** |
402 /** |
140 * Callback to process as much queue as time permits. |
403 * Callback to process as much queue as time permits. |
|
404 * |
|
405 * Map Iteration follows the original insertion order. This means that here |
|
406 * we can iterate the queue and know that the first contexts which were |
|
407 * added will be run first. On the other hand, if anyone adds a new callback |
|
408 * for an existing context it will supplant the previously-set callback for |
|
409 * that context because we reassigned that map key's value. |
|
410 * |
|
411 * In the case that a callback adds a new callback to its own context then |
|
412 * the callback it adds will appear at the end of the iteration and will be |
|
413 * run only after all other existing contexts have finished executing. |
141 * |
414 * |
142 * @param {IdleDeadline|number} deadline Idle callback deadline object, or |
415 * @param {IdleDeadline|number} deadline Idle callback deadline object, or |
143 * animation frame timestamp. |
416 * animation frame timestamp. |
144 */ |
417 */ |
145 |
|
146 const runWaitingList = deadline => { |
418 const runWaitingList = deadline => { |
147 const hasTimeRemaining = typeof deadline === 'number' ? () => false : () => deadline.timeRemaining() > 0; |
419 for (const [nextElement, callback] of waitingList) { |
148 |
420 waitingList.delete(nextElement); |
149 do { |
421 callback(); |
150 if (waitingList.length === 0) { |
422 if ('number' === typeof deadline || deadline.timeRemaining() <= 0) { |
151 isRunning = false; |
423 break; |
152 return; |
|
153 } |
424 } |
154 |
425 } |
155 const nextElement = |
426 if (waitingList.size === 0) { |
156 /** @type {WPPriorityQueueContext} */ |
427 isRunning = false; |
157 waitingList.shift(); |
428 return; |
158 const callback = |
429 } |
159 /** @type {WPPriorityQueueCallback} */ |
|
160 elementsMap.get(nextElement); // If errors with undefined callbacks are encountered double check that all of your useSelect calls |
|
161 // have all dependecies set correctly in second parameter. Missing dependencies can cause unexpected |
|
162 // loops and race conditions in the queue. |
|
163 |
|
164 callback(); |
|
165 elementsMap.delete(nextElement); |
|
166 } while (hasTimeRemaining()); |
|
167 |
|
168 request_idle_callback(runWaitingList); |
430 request_idle_callback(runWaitingList); |
169 }; |
431 }; |
|
432 |
170 /** |
433 /** |
171 * Add a callback to the queue for a given context. |
434 * Add a callback to the queue for a given context. |
|
435 * |
|
436 * If errors with undefined callbacks are encountered double check that |
|
437 * all of your useSelect calls have the right dependencies set correctly |
|
438 * in their second parameter. Missing dependencies can cause unexpected |
|
439 * loops and race conditions in the queue. |
172 * |
440 * |
173 * @type {WPPriorityQueueAdd} |
441 * @type {WPPriorityQueueAdd} |
174 * |
442 * |
175 * @param {WPPriorityQueueContext} element Context object. |
443 * @param {WPPriorityQueueContext} element Context object. |
176 * @param {WPPriorityQueueCallback} item Callback function. |
444 * @param {WPPriorityQueueCallback} item Callback function. |
177 */ |
445 */ |
178 |
|
179 |
|
180 const add = (element, item) => { |
446 const add = (element, item) => { |
181 if (!elementsMap.has(element)) { |
447 waitingList.set(element, item); |
182 waitingList.push(element); |
|
183 } |
|
184 |
|
185 elementsMap.set(element, item); |
|
186 |
|
187 if (!isRunning) { |
448 if (!isRunning) { |
188 isRunning = true; |
449 isRunning = true; |
189 request_idle_callback(runWaitingList); |
450 request_idle_callback(runWaitingList); |
190 } |
451 } |
191 }; |
452 }; |
|
453 |
192 /** |
454 /** |
193 * Flushes queue for a given context, returning true if the flush was |
455 * Flushes queue for a given context, returning true if the flush was |
194 * performed, or false if there is no queue for the given context. |
456 * performed, or false if there is no queue for the given context. |
195 * |
457 * |
196 * @type {WPPriorityQueueFlush} |
458 * @type {WPPriorityQueueFlush} |
197 * |
459 * |
198 * @param {WPPriorityQueueContext} element Context object. |
460 * @param {WPPriorityQueueContext} element Context object. |
199 * |
461 * |
200 * @return {boolean} Whether flush was performed. |
462 * @return {boolean} Whether flush was performed. |
201 */ |
463 */ |
202 |
|
203 |
|
204 const flush = element => { |
464 const flush = element => { |
205 if (!elementsMap.has(element)) { |
465 const callback = waitingList.get(element); |
|
466 if (undefined === callback) { |
206 return false; |
467 return false; |
207 } |
468 } |
208 |
469 waitingList.delete(element); |
209 const index = waitingList.indexOf(element); |
|
210 waitingList.splice(index, 1); |
|
211 const callback = |
|
212 /** @type {WPPriorityQueueCallback} */ |
|
213 elementsMap.get(element); |
|
214 elementsMap.delete(element); |
|
215 callback(); |
470 callback(); |
216 return true; |
471 return true; |
217 }; |
472 }; |
|
473 |
|
474 /** |
|
475 * Clears the queue for a given context, cancelling the callbacks without |
|
476 * executing them. Returns `true` if there were scheduled callbacks to cancel, |
|
477 * or `false` if there was is no queue for the given context. |
|
478 * |
|
479 * @type {WPPriorityQueueFlush} |
|
480 * |
|
481 * @param {WPPriorityQueueContext} element Context object. |
|
482 * |
|
483 * @return {boolean} Whether any callbacks got cancelled. |
|
484 */ |
|
485 const cancel = element => { |
|
486 return waitingList.delete(element); |
|
487 }; |
|
488 |
218 /** |
489 /** |
219 * Reset the queue without running the pending callbacks. |
490 * Reset the queue without running the pending callbacks. |
220 * |
491 * |
221 * @type {WPPriorityQueueReset} |
492 * @type {WPPriorityQueueReset} |
222 */ |
493 */ |
223 |
|
224 |
|
225 const reset = () => { |
494 const reset = () => { |
226 waitingList = []; |
495 waitingList.clear(); |
227 elementsMap = new WeakMap(); |
|
228 isRunning = false; |
496 isRunning = false; |
229 }; |
497 }; |
230 |
|
231 return { |
498 return { |
232 add, |
499 add, |
233 flush, |
500 flush, |
|
501 cancel, |
234 reset |
502 reset |
235 }; |
503 }; |
236 }; |
504 }; |
237 |
505 |
|
506 })(); |
|
507 |
238 (window.wp = window.wp || {}).priorityQueue = __webpack_exports__; |
508 (window.wp = window.wp || {}).priorityQueue = __webpack_exports__; |
239 /******/ })() |
509 /******/ })() |
240 ; |
510 ; |