You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

508 lines
14 KiB

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