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 = 449); |
85 /******/ return __webpack_require__(__webpack_require__.s = "gEOj"); |
86 /******/ }) |
86 /******/ }) |
87 /************************************************************************/ |
87 /************************************************************************/ |
88 /******/ ({ |
88 /******/ ({ |
89 |
89 |
90 /***/ 18: |
90 /***/ "gEOj": |
91 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
92 |
|
93 "use strict"; |
|
94 |
|
95 // EXPORTS |
|
96 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; }); |
|
97 |
|
98 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js |
|
99 var arrayLikeToArray = __webpack_require__(26); |
|
100 |
|
101 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
|
102 |
|
103 function _arrayWithoutHoles(arr) { |
|
104 if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr); |
|
105 } |
|
106 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
|
107 var iterableToArray = __webpack_require__(35); |
|
108 |
|
109 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js |
|
110 var unsupportedIterableToArray = __webpack_require__(29); |
|
111 |
|
112 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
|
113 function _nonIterableSpread() { |
|
114 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
|
115 } |
|
116 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 function _toConsumableArray(arr) { |
|
122 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread(); |
|
123 } |
|
124 |
|
125 /***/ }), |
|
126 |
|
127 /***/ 26: |
|
128 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
129 |
|
130 "use strict"; |
|
131 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; }); |
|
132 function _arrayLikeToArray(arr, len) { |
|
133 if (len == null || len > arr.length) len = arr.length; |
|
134 |
|
135 for (var i = 0, arr2 = new Array(len); i < len; i++) { |
|
136 arr2[i] = arr[i]; |
|
137 } |
|
138 |
|
139 return arr2; |
|
140 } |
|
141 |
|
142 /***/ }), |
|
143 |
|
144 /***/ 29: |
|
145 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
146 |
|
147 "use strict"; |
|
148 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; }); |
|
149 /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26); |
|
150 |
|
151 function _unsupportedIterableToArray(o, minLen) { |
|
152 if (!o) return; |
|
153 if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); |
|
154 var n = Object.prototype.toString.call(o).slice(8, -1); |
|
155 if (n === "Object" && o.constructor) n = o.constructor.name; |
|
156 if (n === "Map" || n === "Set") return Array.from(o); |
|
157 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); |
|
158 } |
|
159 |
|
160 /***/ }), |
|
161 |
|
162 /***/ 35: |
|
163 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
164 |
|
165 "use strict"; |
|
166 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); |
|
167 function _iterableToArray(iter) { |
|
168 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); |
|
169 } |
|
170 |
|
171 /***/ }), |
|
172 |
|
173 /***/ 449: |
|
174 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
91 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
175 |
92 |
176 "use strict"; |
93 "use strict"; |
177 // ESM COMPAT FLAG |
94 // ESM COMPAT FLAG |
178 __webpack_require__.r(__webpack_exports__); |
95 __webpack_require__.r(__webpack_exports__); |
179 |
96 |
180 // EXPORTS |
97 // EXPORTS |
|
98 __webpack_require__.d(__webpack_exports__, "defaultHooks", function() { return /* binding */ defaultHooks; }); |
181 __webpack_require__.d(__webpack_exports__, "createHooks", function() { return /* reexport */ build_module_createHooks; }); |
99 __webpack_require__.d(__webpack_exports__, "createHooks", function() { return /* reexport */ build_module_createHooks; }); |
182 __webpack_require__.d(__webpack_exports__, "addAction", function() { return /* binding */ addAction; }); |
100 __webpack_require__.d(__webpack_exports__, "addAction", function() { return /* binding */ addAction; }); |
183 __webpack_require__.d(__webpack_exports__, "addFilter", function() { return /* binding */ addFilter; }); |
101 __webpack_require__.d(__webpack_exports__, "addFilter", function() { return /* binding */ addFilter; }); |
184 __webpack_require__.d(__webpack_exports__, "removeAction", function() { return /* binding */ removeAction; }); |
102 __webpack_require__.d(__webpack_exports__, "removeAction", function() { return /* binding */ removeAction; }); |
185 __webpack_require__.d(__webpack_exports__, "removeFilter", function() { return /* binding */ removeFilter; }); |
103 __webpack_require__.d(__webpack_exports__, "removeFilter", function() { return /* binding */ removeFilter; }); |
361 /** |
284 /** |
362 * Internal dependencies |
285 * Internal dependencies |
363 */ |
286 */ |
364 |
287 |
365 |
288 |
|
289 /** |
|
290 * @callback RemoveHook |
|
291 * Removes the specified callback (or all callbacks) from the hook with a given hookName |
|
292 * and namespace. |
|
293 * |
|
294 * @param {string} hookName The name of the hook to modify. |
|
295 * @param {string} namespace The unique namespace identifying the callback in the |
|
296 * form `vendor/plugin/function`. |
|
297 * |
|
298 * @return {number | undefined} The number of callbacks removed. |
|
299 */ |
366 |
300 |
367 /** |
301 /** |
368 * Returns a function which, when invoked, will remove a specified hook or all |
302 * Returns a function which, when invoked, will remove a specified hook or all |
369 * hooks by the given name. |
303 * hooks by the given name. |
370 * |
304 * |
371 * @param {Object} hooks Stored hooks, keyed by hook name. |
305 * @param {import('.').Hooks} hooks Hooks instance. |
372 * @param {boolean} removeAll Whether to remove all callbacks for a hookName, without regard to namespace. Used to create `removeAll*` functions. |
306 * @param {import('.').StoreKey} storeKey |
373 * |
307 * @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName, |
374 * @return {Function} Function that removes hooks. |
308 * without regard to namespace. Used to create |
375 */ |
309 * `removeAll*` functions. |
376 |
310 * |
377 function createRemoveHook(hooks, removeAll) { |
311 * @return {RemoveHook} Function that removes hooks. |
378 /** |
312 */ |
379 * Removes the specified callback (or all callbacks) from the hook with a |
313 |
380 * given hookName and namespace. |
314 function createRemoveHook(hooks, storeKey, removeAll = false) { |
381 * |
|
382 * @param {string} hookName The name of the hook to modify. |
|
383 * @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`. |
|
384 * |
|
385 * @return {number} The number of callbacks removed. |
|
386 */ |
|
387 return function removeHook(hookName, namespace) { |
315 return function removeHook(hookName, namespace) { |
|
316 const hooksStore = hooks[storeKey]; |
|
317 |
388 if (!build_module_validateHookName(hookName)) { |
318 if (!build_module_validateHookName(hookName)) { |
389 return; |
319 return; |
390 } |
320 } |
391 |
321 |
392 if (!removeAll && !build_module_validateNamespace(namespace)) { |
322 if (!removeAll && !build_module_validateNamespace(namespace)) { |
393 return; |
323 return; |
394 } // Bail if no hooks exist by this name |
324 } // Bail if no hooks exist by this name |
395 |
325 |
396 |
326 |
397 if (!hooks[hookName]) { |
327 if (!hooksStore[hookName]) { |
398 return 0; |
328 return 0; |
399 } |
329 } |
400 |
330 |
401 var handlersRemoved = 0; |
331 let handlersRemoved = 0; |
402 |
332 |
403 if (removeAll) { |
333 if (removeAll) { |
404 handlersRemoved = hooks[hookName].handlers.length; |
334 handlersRemoved = hooksStore[hookName].handlers.length; |
405 hooks[hookName] = { |
335 hooksStore[hookName] = { |
406 runs: hooks[hookName].runs, |
336 runs: hooksStore[hookName].runs, |
407 handlers: [] |
337 handlers: [] |
408 }; |
338 }; |
409 } else { |
339 } else { |
410 // Try to find the specified callback to remove. |
340 // Try to find the specified callback to remove. |
411 var handlers = hooks[hookName].handlers; |
341 const handlers = hooksStore[hookName].handlers; |
412 |
342 |
413 var _loop = function _loop(i) { |
343 for (let i = handlers.length - 1; i >= 0; i--) { |
414 if (handlers[i].namespace === namespace) { |
344 if (handlers[i].namespace === namespace) { |
415 handlers.splice(i, 1); |
345 handlers.splice(i, 1); |
416 handlersRemoved++; // This callback may also be part of a hook that is |
346 handlersRemoved++; // This callback may also be part of a hook that is |
417 // currently executing. If the callback we're removing |
347 // currently executing. If the callback we're removing |
418 // comes after the current callback, there's no problem; |
348 // comes after the current callback, there's no problem; |
419 // otherwise we need to decrease the execution index of any |
349 // otherwise we need to decrease the execution index of any |
420 // other runs by 1 to account for the removed element. |
350 // other runs by 1 to account for the removed element. |
421 |
351 |
422 (hooks.__current || []).forEach(function (hookInfo) { |
352 hooksStore.__current.forEach(hookInfo => { |
423 if (hookInfo.name === hookName && hookInfo.currentIndex >= i) { |
353 if (hookInfo.name === hookName && hookInfo.currentIndex >= i) { |
424 hookInfo.currentIndex--; |
354 hookInfo.currentIndex--; |
425 } |
355 } |
426 }); |
356 }); |
427 } |
357 } |
428 }; |
|
429 |
|
430 for (var i = handlers.length - 1; i >= 0; i--) { |
|
431 _loop(i); |
|
432 } |
358 } |
433 } |
359 } |
434 |
360 |
435 if (hookName !== 'hookRemoved') { |
361 if (hookName !== 'hookRemoved') { |
436 doAction('hookRemoved', hookName, namespace); |
362 hooks.doAction('hookRemoved', hookName, namespace); |
437 } |
363 } |
438 |
364 |
439 return handlersRemoved; |
365 return handlersRemoved; |
440 }; |
366 }; |
441 } |
367 } |
442 |
368 |
443 /* harmony default export */ var build_module_createRemoveHook = (createRemoveHook); |
369 /* harmony default export */ var build_module_createRemoveHook = (createRemoveHook); |
444 |
370 |
445 // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHasHook.js |
371 // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHasHook.js |
446 /** |
372 /** |
|
373 * @callback HasHook |
|
374 * |
|
375 * Returns whether any handlers are attached for the given hookName and optional namespace. |
|
376 * |
|
377 * @param {string} hookName The name of the hook to check for. |
|
378 * @param {string} [namespace] Optional. The unique namespace identifying the callback |
|
379 * in the form `vendor/plugin/function`. |
|
380 * |
|
381 * @return {boolean} Whether there are handlers that are attached to the given hook. |
|
382 */ |
|
383 |
|
384 /** |
447 * Returns a function which, when invoked, will return whether any handlers are |
385 * Returns a function which, when invoked, will return whether any handlers are |
448 * attached to a particular hook. |
386 * attached to a particular hook. |
449 * |
387 * |
450 * @param {Object} hooks Stored hooks, keyed by hook name. |
388 * @param {import('.').Hooks} hooks Hooks instance. |
451 * |
389 * @param {import('.').StoreKey} storeKey |
452 * @return {Function} Function that returns whether any handlers are |
390 * |
453 * attached to a particular hook and optional namespace. |
391 * @return {HasHook} Function that returns whether any handlers are |
454 */ |
392 * attached to a particular hook and optional namespace. |
455 function createHasHook(hooks) { |
393 */ |
456 /** |
394 function createHasHook(hooks, storeKey) { |
457 * Returns whether any handlers are attached for the given hookName and optional namespace. |
|
458 * |
|
459 * @param {string} hookName The name of the hook to check for. |
|
460 * @param {?string} namespace Optional. The unique namespace identifying the callback |
|
461 * in the form `vendor/plugin/function`. |
|
462 * |
|
463 * @return {boolean} Whether there are handlers that are attached to the given hook. |
|
464 */ |
|
465 return function hasHook(hookName, namespace) { |
395 return function hasHook(hookName, namespace) { |
466 // Use the namespace if provided. |
396 const hooksStore = hooks[storeKey]; // Use the namespace if provided. |
|
397 |
467 if ('undefined' !== typeof namespace) { |
398 if ('undefined' !== typeof namespace) { |
468 return hookName in hooks && hooks[hookName].handlers.some(function (hook) { |
399 return hookName in hooksStore && hooksStore[hookName].handlers.some(hook => hook.namespace === namespace); |
469 return hook.namespace === namespace; |
400 } |
470 }); |
401 |
471 } |
402 return hookName in hooksStore; |
472 |
|
473 return hookName in hooks; |
|
474 }; |
403 }; |
475 } |
404 } |
476 |
405 |
477 /* harmony default export */ var build_module_createHasHook = (createHasHook); |
406 /* harmony default export */ var build_module_createHasHook = (createHasHook); |
478 |
407 |
479 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
|
480 var toConsumableArray = __webpack_require__(18); |
|
481 |
|
482 // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRunHook.js |
408 // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRunHook.js |
483 |
|
484 |
|
485 /** |
409 /** |
486 * Returns a function which, when invoked, will execute all callbacks |
410 * Returns a function which, when invoked, will execute all callbacks |
487 * registered to a hook of the specified type, optionally returning the final |
411 * registered to a hook of the specified type, optionally returning the final |
488 * value of the call chain. |
412 * value of the call chain. |
489 * |
413 * |
490 * @param {Object} hooks Stored hooks, keyed by hook name. |
414 * @param {import('.').Hooks} hooks Hooks instance. |
491 * @param {?boolean} returnFirstArg Whether each hook callback is expected to |
415 * @param {import('.').StoreKey} storeKey |
492 * return its first argument. |
416 * @param {boolean} [returnFirstArg=false] Whether each hook callback is expected to |
493 * |
417 * return its first argument. |
494 * @return {Function} Function that runs hook callbacks. |
418 * |
495 */ |
419 * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks. |
496 function createRunHook(hooks, returnFirstArg) { |
420 */ |
497 /** |
421 function createRunHook(hooks, storeKey, returnFirstArg = false) { |
498 * Runs all callbacks for the specified hook. |
422 return function runHooks(hookName, ...args) { |
499 * |
423 const hooksStore = hooks[storeKey]; |
500 * @param {string} hookName The name of the hook to run. |
424 |
501 * @param {...*} args Arguments to pass to the hook callbacks. |
425 if (!hooksStore[hookName]) { |
502 * |
426 hooksStore[hookName] = { |
503 * @return {*} Return value of runner, if applicable. |
|
504 */ |
|
505 return function runHooks(hookName) { |
|
506 if (!hooks[hookName]) { |
|
507 hooks[hookName] = { |
|
508 handlers: [], |
427 handlers: [], |
509 runs: 0 |
428 runs: 0 |
510 }; |
429 }; |
511 } |
430 } |
512 |
431 |
513 hooks[hookName].runs++; |
432 hooksStore[hookName].runs++; |
514 var handlers = hooks[hookName].handlers; // The following code is stripped from production builds. |
433 const handlers = hooksStore[hookName].handlers; // The following code is stripped from production builds. |
515 |
434 |
516 if (false) {} |
435 if (false) {} |
517 |
|
518 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
519 args[_key - 1] = arguments[_key]; |
|
520 } |
|
521 |
436 |
522 if (!handlers || !handlers.length) { |
437 if (!handlers || !handlers.length) { |
523 return returnFirstArg ? args[0] : undefined; |
438 return returnFirstArg ? args[0] : undefined; |
524 } |
439 } |
525 |
440 |
526 var hookInfo = { |
441 const hookInfo = { |
527 name: hookName, |
442 name: hookName, |
528 currentIndex: 0 |
443 currentIndex: 0 |
529 }; |
444 }; |
530 |
445 |
531 hooks.__current.push(hookInfo); |
446 hooksStore.__current.push(hookInfo); |
532 |
447 |
533 while (hookInfo.currentIndex < handlers.length) { |
448 while (hookInfo.currentIndex < handlers.length) { |
534 var handler = handlers[hookInfo.currentIndex]; |
449 const handler = handlers[hookInfo.currentIndex]; |
535 var result = handler.callback.apply(null, args); |
450 const result = handler.callback.apply(null, args); |
536 |
451 |
537 if (returnFirstArg) { |
452 if (returnFirstArg) { |
538 args[0] = result; |
453 args[0] = result; |
539 } |
454 } |
540 |
455 |
541 hookInfo.currentIndex++; |
456 hookInfo.currentIndex++; |
542 } |
457 } |
543 |
458 |
544 hooks.__current.pop(); |
459 hooksStore.__current.pop(); |
545 |
460 |
546 if (returnFirstArg) { |
461 if (returnFirstArg) { |
547 return args[0]; |
462 return args[0]; |
548 } |
463 } |
549 }; |
464 }; |
555 /** |
470 /** |
556 * Returns a function which, when invoked, will return the name of the |
471 * Returns a function which, when invoked, will return the name of the |
557 * currently running hook, or `null` if no hook of the given type is currently |
472 * currently running hook, or `null` if no hook of the given type is currently |
558 * running. |
473 * running. |
559 * |
474 * |
560 * @param {Object} hooks Stored hooks, keyed by hook name. |
475 * @param {import('.').Hooks} hooks Hooks instance. |
561 * |
476 * @param {import('.').StoreKey} storeKey |
562 * @return {Function} Function that returns the current hook. |
477 * |
563 */ |
478 * @return {() => string | null} Function that returns the current hook name or null. |
564 function createCurrentHook(hooks) { |
479 */ |
565 /** |
480 function createCurrentHook(hooks, storeKey) { |
566 * Returns the name of the currently running hook, or `null` if no hook of |
|
567 * the given type is currently running. |
|
568 * |
|
569 * @return {?string} The name of the currently running hook, or |
|
570 * `null` if no hook is currently running. |
|
571 */ |
|
572 return function currentHook() { |
481 return function currentHook() { |
573 if (!hooks.__current || !hooks.__current.length) { |
482 var _hooksStore$__current, _hooksStore$__current2; |
574 return null; |
483 |
575 } |
484 const hooksStore = hooks[storeKey]; |
576 |
485 return (_hooksStore$__current = (_hooksStore$__current2 = hooksStore.__current[hooksStore.__current.length - 1]) === null || _hooksStore$__current2 === void 0 ? void 0 : _hooksStore$__current2.name) !== null && _hooksStore$__current !== void 0 ? _hooksStore$__current : null; |
577 return hooks.__current[hooks.__current.length - 1].name; |
|
578 }; |
486 }; |
579 } |
487 } |
580 |
488 |
581 /* harmony default export */ var build_module_createCurrentHook = (createCurrentHook); |
489 /* harmony default export */ var build_module_createCurrentHook = (createCurrentHook); |
582 |
490 |
583 // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDoingHook.js |
491 // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDoingHook.js |
|
492 /** |
|
493 * @callback DoingHook |
|
494 * Returns whether a hook is currently being executed. |
|
495 * |
|
496 * @param {string} [hookName] The name of the hook to check for. If |
|
497 * omitted, will check for any hook being executed. |
|
498 * |
|
499 * @return {boolean} Whether the hook is being executed. |
|
500 */ |
|
501 |
584 /** |
502 /** |
585 * Returns a function which, when invoked, will return whether a hook is |
503 * Returns a function which, when invoked, will return whether a hook is |
586 * currently being executed. |
504 * currently being executed. |
587 * |
505 * |
588 * @param {Object} hooks Stored hooks, keyed by hook name. |
506 * @param {import('.').Hooks} hooks Hooks instance. |
589 * |
507 * @param {import('.').StoreKey} storeKey |
590 * @return {Function} Function that returns whether a hook is currently |
508 * |
591 * being executed. |
509 * @return {DoingHook} Function that returns whether a hook is currently |
592 */ |
510 * being executed. |
593 function createDoingHook(hooks) { |
511 */ |
594 /** |
512 function createDoingHook(hooks, storeKey) { |
595 * Returns whether a hook is currently being executed. |
|
596 * |
|
597 * @param {?string} hookName The name of the hook to check for. If |
|
598 * omitted, will check for any hook being executed. |
|
599 * |
|
600 * @return {boolean} Whether the hook is being executed. |
|
601 */ |
|
602 return function doingHook(hookName) { |
513 return function doingHook(hookName) { |
603 // If the hookName was not passed, check for any current hook. |
514 const hooksStore = hooks[storeKey]; // If the hookName was not passed, check for any current hook. |
|
515 |
604 if ('undefined' === typeof hookName) { |
516 if ('undefined' === typeof hookName) { |
605 return 'undefined' !== typeof hooks.__current[0]; |
517 return 'undefined' !== typeof hooksStore.__current[0]; |
606 } // Return the __current hook. |
518 } // Return the __current hook. |
607 |
519 |
608 |
520 |
609 return hooks.__current[0] ? hookName === hooks.__current[0].name : false; |
521 return hooksStore.__current[0] ? hookName === hooksStore.__current[0].name : false; |
610 }; |
522 }; |
611 } |
523 } |
612 |
524 |
613 /* harmony default export */ var build_module_createDoingHook = (createDoingHook); |
525 /* harmony default export */ var build_module_createDoingHook = (createDoingHook); |
614 |
526 |
615 // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDidHook.js |
527 // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDidHook.js |
616 /** |
528 /** |
617 * Internal dependencies |
529 * Internal dependencies |
|
530 */ |
|
531 |
|
532 /** |
|
533 * @callback DidHook |
|
534 * |
|
535 * Returns the number of times an action has been fired. |
|
536 * |
|
537 * @param {string} hookName The hook name to check. |
|
538 * |
|
539 * @return {number | undefined} The number of times the hook has run. |
618 */ |
540 */ |
619 |
541 |
620 /** |
542 /** |
621 * Returns a function which, when invoked, will return the number of times a |
543 * Returns a function which, when invoked, will return the number of times a |
622 * hook has been called. |
544 * hook has been called. |
623 * |
545 * |
624 * @param {Object} hooks Stored hooks, keyed by hook name. |
546 * @param {import('.').Hooks} hooks Hooks instance. |
625 * |
547 * @param {import('.').StoreKey} storeKey |
626 * @return {Function} Function that returns a hook's call count. |
548 * |
627 */ |
549 * @return {DidHook} Function that returns a hook's call count. |
628 |
550 */ |
629 function createDidHook(hooks) { |
551 |
630 /** |
552 function createDidHook(hooks, storeKey) { |
631 * Returns the number of times an action has been fired. |
|
632 * |
|
633 * @param {string} hookName The hook name to check. |
|
634 * |
|
635 * @return {number} The number of times the hook has run. |
|
636 */ |
|
637 return function didHook(hookName) { |
553 return function didHook(hookName) { |
|
554 const hooksStore = hooks[storeKey]; |
|
555 |
638 if (!build_module_validateHookName(hookName)) { |
556 if (!build_module_validateHookName(hookName)) { |
639 return; |
557 return; |
640 } |
558 } |
641 |
559 |
642 return hooks[hookName] && hooks[hookName].runs ? hooks[hookName].runs : 0; |
560 return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0; |
643 }; |
561 }; |
644 } |
562 } |
645 |
563 |
646 /* harmony default export */ var build_module_createDidHook = (createDidHook); |
564 /* harmony default export */ var build_module_createDidHook = (createDidHook); |
647 |
565 |
655 |
573 |
656 |
574 |
657 |
575 |
658 |
576 |
659 /** |
577 /** |
|
578 * Internal class for constructing hooks. Use `createHooks()` function |
|
579 * |
|
580 * Note, it is necessary to expose this class to make its type public. |
|
581 * |
|
582 * @private |
|
583 */ |
|
584 |
|
585 class createHooks_Hooks { |
|
586 constructor() { |
|
587 /** @type {import('.').Store} actions */ |
|
588 this.actions = Object.create(null); |
|
589 this.actions.__current = []; |
|
590 /** @type {import('.').Store} filters */ |
|
591 |
|
592 this.filters = Object.create(null); |
|
593 this.filters.__current = []; |
|
594 this.addAction = build_module_createAddHook(this, 'actions'); |
|
595 this.addFilter = build_module_createAddHook(this, 'filters'); |
|
596 this.removeAction = build_module_createRemoveHook(this, 'actions'); |
|
597 this.removeFilter = build_module_createRemoveHook(this, 'filters'); |
|
598 this.hasAction = build_module_createHasHook(this, 'actions'); |
|
599 this.hasFilter = build_module_createHasHook(this, 'filters'); |
|
600 this.removeAllActions = build_module_createRemoveHook(this, 'actions', true); |
|
601 this.removeAllFilters = build_module_createRemoveHook(this, 'filters', true); |
|
602 this.doAction = build_module_createRunHook(this, 'actions'); |
|
603 this.applyFilters = build_module_createRunHook(this, 'filters', true); |
|
604 this.currentAction = build_module_createCurrentHook(this, 'actions'); |
|
605 this.currentFilter = build_module_createCurrentHook(this, 'filters'); |
|
606 this.doingAction = build_module_createDoingHook(this, 'actions'); |
|
607 this.doingFilter = build_module_createDoingHook(this, 'filters'); |
|
608 this.didAction = build_module_createDidHook(this, 'actions'); |
|
609 this.didFilter = build_module_createDidHook(this, 'filters'); |
|
610 } |
|
611 |
|
612 } |
|
613 /** @typedef {_Hooks} Hooks */ |
|
614 |
|
615 /** |
660 * Returns an instance of the hooks object. |
616 * Returns an instance of the hooks object. |
661 * |
617 * |
662 * @return {Object} Object that contains all hooks. |
618 * @return {Hooks} A Hooks instance. |
663 */ |
619 */ |
664 |
620 |
665 function createHooks() { |
621 function createHooks() { |
666 var actions = Object.create(null); |
622 return new createHooks_Hooks(); |
667 var filters = Object.create(null); |
|
668 actions.__current = []; |
|
669 filters.__current = []; |
|
670 return { |
|
671 addAction: build_module_createAddHook(actions), |
|
672 addFilter: build_module_createAddHook(filters), |
|
673 removeAction: build_module_createRemoveHook(actions), |
|
674 removeFilter: build_module_createRemoveHook(filters), |
|
675 hasAction: build_module_createHasHook(actions), |
|
676 hasFilter: build_module_createHasHook(filters), |
|
677 removeAllActions: build_module_createRemoveHook(actions, true), |
|
678 removeAllFilters: build_module_createRemoveHook(filters, true), |
|
679 doAction: build_module_createRunHook(actions), |
|
680 applyFilters: build_module_createRunHook(filters, true), |
|
681 currentAction: build_module_createCurrentHook(actions), |
|
682 currentFilter: build_module_createCurrentHook(filters), |
|
683 doingAction: build_module_createDoingHook(actions), |
|
684 doingFilter: build_module_createDoingHook(filters), |
|
685 didAction: build_module_createDidHook(actions), |
|
686 didFilter: build_module_createDidHook(filters), |
|
687 actions: actions, |
|
688 filters: filters |
|
689 }; |
|
690 } |
623 } |
691 |
624 |
692 /* harmony default export */ var build_module_createHooks = (createHooks); |
625 /* harmony default export */ var build_module_createHooks = (createHooks); |
693 |
626 |
694 // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/index.js |
627 // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/index.js |
695 /** |
628 /** |
696 * Internal dependencies |
629 * Internal dependencies |
697 */ |
630 */ |
698 |
631 |
699 |
632 /** @typedef {(...args: any[])=>any} Callback */ |
700 var _createHooks = build_module_createHooks(), |
633 |
701 addAction = _createHooks.addAction, |
634 /** |
702 addFilter = _createHooks.addFilter, |
635 * @typedef Handler |
703 removeAction = _createHooks.removeAction, |
636 * @property {Callback} callback The callback |
704 removeFilter = _createHooks.removeFilter, |
637 * @property {string} namespace The namespace |
705 hasAction = _createHooks.hasAction, |
638 * @property {number} priority The namespace |
706 hasFilter = _createHooks.hasFilter, |
639 */ |
707 removeAllActions = _createHooks.removeAllActions, |
640 |
708 removeAllFilters = _createHooks.removeAllFilters, |
641 /** |
709 doAction = _createHooks.doAction, |
642 * @typedef Hook |
710 applyFilters = _createHooks.applyFilters, |
643 * @property {Handler[]} handlers Array of handlers |
711 currentAction = _createHooks.currentAction, |
644 * @property {number} runs Run counter |
712 currentFilter = _createHooks.currentFilter, |
645 */ |
713 doingAction = _createHooks.doingAction, |
646 |
714 doingFilter = _createHooks.doingFilter, |
647 /** |
715 didAction = _createHooks.didAction, |
648 * @typedef Current |
716 didFilter = _createHooks.didFilter, |
649 * @property {string} name Hook name |
717 build_module_actions = _createHooks.actions, |
650 * @property {number} currentIndex The index |
718 build_module_filters = _createHooks.filters; |
651 */ |
719 |
652 |
|
653 /** |
|
654 * @typedef {Record<string, Hook> & {__current: Current[]}} Store |
|
655 */ |
|
656 |
|
657 /** |
|
658 * @typedef {'actions' | 'filters'} StoreKey |
|
659 */ |
|
660 |
|
661 /** |
|
662 * @typedef {import('./createHooks').Hooks} Hooks |
|
663 */ |
|
664 |
|
665 const defaultHooks = build_module_createHooks(); |
|
666 const { |
|
667 addAction, |
|
668 addFilter, |
|
669 removeAction, |
|
670 removeFilter, |
|
671 hasAction, |
|
672 hasFilter, |
|
673 removeAllActions, |
|
674 removeAllFilters, |
|
675 doAction, |
|
676 applyFilters, |
|
677 currentAction, |
|
678 currentFilter, |
|
679 doingAction, |
|
680 doingFilter, |
|
681 didAction, |
|
682 didFilter, |
|
683 actions, |
|
684 filters |
|
685 } = defaultHooks; |
720 |
686 |
721 |
687 |
722 |
688 |
723 /***/ }) |
689 /***/ }) |
724 |
690 |