2024-01-31 07:59:56 -05:00
|
|
|
/******/ (() => { // webpackBootstrap
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ "use strict";
|
|
|
|
/******/ // The require scope
|
|
|
|
/******/ var __webpack_require__ = {};
|
|
|
|
/******/
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ /* webpack/runtime/define property getters */
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ (() => {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ // define getter functions for harmony exports
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ __webpack_require__.d = (exports, definition) => {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ 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] });
|
|
|
|
/******/ }
|
|
|
|
/******/ }
|
|
|
|
/******/ };
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ })();
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ (() => {
|
|
|
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
|
|
/******/ })();
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/make namespace object */
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ (() => {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ // define __esModule on exports
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ __webpack_require__.r = (exports) => {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
/******/ }
|
|
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
2018-12-13 23:41:57 -05:00
|
|
|
/******/ };
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ })();
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/
|
2018-12-13 23:41:57 -05:00
|
|
|
/************************************************************************/
|
2022-04-11 08:04:30 -04:00
|
|
|
var __webpack_exports__ = {};
|
2020-06-29 07:50:29 -04:00
|
|
|
// ESM COMPAT FLAG
|
2018-12-13 23:41:57 -05:00
|
|
|
__webpack_require__.r(__webpack_exports__);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
2020-06-29 07:50:29 -04:00
|
|
|
// EXPORTS
|
2022-04-11 08:04:30 -04:00
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
2024-01-31 07:59:56 -05:00
|
|
|
actions: () => (/* binding */ actions),
|
|
|
|
addAction: () => (/* binding */ addAction),
|
|
|
|
addFilter: () => (/* binding */ addFilter),
|
|
|
|
applyFilters: () => (/* binding */ applyFilters),
|
2024-09-30 01:11:31 -04:00
|
|
|
applyFiltersAsync: () => (/* binding */ applyFiltersAsync),
|
2024-01-31 07:59:56 -05:00
|
|
|
createHooks: () => (/* reexport */ build_module_createHooks),
|
|
|
|
currentAction: () => (/* binding */ currentAction),
|
|
|
|
currentFilter: () => (/* binding */ currentFilter),
|
|
|
|
defaultHooks: () => (/* binding */ defaultHooks),
|
|
|
|
didAction: () => (/* binding */ didAction),
|
|
|
|
didFilter: () => (/* binding */ didFilter),
|
|
|
|
doAction: () => (/* binding */ doAction),
|
2024-09-30 01:11:31 -04:00
|
|
|
doActionAsync: () => (/* binding */ doActionAsync),
|
2024-01-31 07:59:56 -05:00
|
|
|
doingAction: () => (/* binding */ doingAction),
|
|
|
|
doingFilter: () => (/* binding */ doingFilter),
|
|
|
|
filters: () => (/* binding */ filters),
|
|
|
|
hasAction: () => (/* binding */ hasAction),
|
|
|
|
hasFilter: () => (/* binding */ hasFilter),
|
|
|
|
removeAction: () => (/* binding */ removeAction),
|
|
|
|
removeAllActions: () => (/* binding */ removeAllActions),
|
|
|
|
removeAllFilters: () => (/* binding */ removeAllFilters),
|
|
|
|
removeFilter: () => (/* binding */ removeFilter)
|
2022-04-11 08:04:30 -04:00
|
|
|
});
|
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/validateNamespace.js
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* Validate a namespace string.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {string} namespace The namespace to validate - should take the form
|
|
|
|
* `vendor/plugin/function`.
|
2018-12-17 22:14:52 -05:00
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @return {boolean} Whether the namespace is valid.
|
2018-12-17 22:14:52 -05:00
|
|
|
*/
|
|
|
|
function validateNamespace(namespace) {
|
|
|
|
if ('string' !== typeof namespace || '' === namespace) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error('The namespace must be a non-empty string.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const build_module_validateNamespace = (validateNamespace);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/validateHookName.js
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* Validate a hookName string.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {string} hookName The hook name to validate. Should be a non empty string containing
|
|
|
|
* only numbers, letters, dashes, periods and underscores. Also,
|
|
|
|
* the hook name cannot begin with `__`.
|
2018-12-17 22:14:52 -05:00
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @return {boolean} Whether the hook name is valid.
|
2018-12-17 22:14:52 -05:00
|
|
|
*/
|
|
|
|
function validateHookName(hookName) {
|
|
|
|
if ('string' !== typeof hookName || '' === hookName) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error('The hook name must be a non-empty string.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (/^__/.test(hookName)) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error('The hook name cannot begin with `__`.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const build_module_validateHookName = (validateHookName);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/createAddHook.js
|
2019-03-07 04:09:59 -05:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2021-01-27 21:04:13 -05:00
|
|
|
/**
|
|
|
|
* @callback AddHook
|
|
|
|
*
|
|
|
|
* Adds the hook to the appropriate hooks container.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {string} hookName Name of hook to add
|
|
|
|
* @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.
|
|
|
|
* @param {import('.').Callback} callback Function to call when the hook is run
|
|
|
|
* @param {number} [priority=10] Priority of this hook
|
2021-01-27 21:04:13 -05:00
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a function which, when invoked, will add a hook.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
|
|
* @param {import('.').StoreKey} storeKey
|
2018-12-13 23:41:57 -05:00
|
|
|
*
|
2021-01-27 21:04:13 -05:00
|
|
|
* @return {AddHook} Function that adds a new hook.
|
2018-12-13 23:41:57 -05:00
|
|
|
*/
|
2021-01-27 21:04:13 -05:00
|
|
|
function createAddHook(hooks, storeKey) {
|
2023-06-27 10:24:19 -04:00
|
|
|
return function addHook(hookName, namespace, callback, priority = 10) {
|
2021-05-19 11:09:27 -04:00
|
|
|
const hooksStore = hooks[storeKey];
|
2018-12-17 22:14:52 -05:00
|
|
|
if (!build_module_validateHookName(hookName)) {
|
2018-12-13 23:41:57 -05:00
|
|
|
return;
|
|
|
|
}
|
2018-12-17 22:14:52 -05:00
|
|
|
if (!build_module_validateNamespace(namespace)) {
|
2018-12-13 23:41:57 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ('function' !== typeof callback) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error('The hook callback must be a function.');
|
|
|
|
return;
|
2023-09-26 10:23:26 -04:00
|
|
|
}
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// Validate numeric priority
|
2018-12-13 23:41:57 -05:00
|
|
|
if ('number' !== typeof priority) {
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
console.error('If specified, the hook priority must be a number.');
|
|
|
|
return;
|
|
|
|
}
|
2021-05-19 11:09:27 -04:00
|
|
|
const handler = {
|
|
|
|
callback,
|
|
|
|
priority,
|
|
|
|
namespace
|
2018-12-13 23:41:57 -05:00
|
|
|
};
|
2021-01-27 21:04:13 -05:00
|
|
|
if (hooksStore[hookName]) {
|
2018-12-13 23:41:57 -05:00
|
|
|
// Find the correct insert index of the new hook.
|
2021-05-19 11:09:27 -04:00
|
|
|
const handlers = hooksStore[hookName].handlers;
|
2021-01-27 21:04:13 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
/** @type {number} */
|
2021-05-19 11:09:27 -04:00
|
|
|
let i;
|
2019-01-04 14:38:57 -05:00
|
|
|
for (i = handlers.length; i > 0; i--) {
|
|
|
|
if (priority >= handlers[i - 1].priority) {
|
2018-12-13 23:41:57 -05:00
|
|
|
break;
|
|
|
|
}
|
2019-01-04 14:38:57 -05:00
|
|
|
}
|
|
|
|
if (i === handlers.length) {
|
|
|
|
// If append, operate via direct assignment.
|
|
|
|
handlers[i] = handler;
|
|
|
|
} else {
|
|
|
|
// Otherwise, insert before index via splice.
|
|
|
|
handlers.splice(i, 0, handler);
|
2023-09-26 10:23:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// We may also be currently executing this hook. If the callback
|
2018-12-13 23:41:57 -05:00
|
|
|
// we're adding would come after the current callback, there's no
|
|
|
|
// problem; otherwise we need to increase the execution index of
|
|
|
|
// any other runs by 1 to account for the added element.
|
2021-05-19 11:09:27 -04:00
|
|
|
hooksStore.__current.forEach(hookInfo => {
|
2018-12-13 23:41:57 -05:00
|
|
|
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
|
|
|
hookInfo.currentIndex++;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// This is the first hook of its type.
|
2021-01-27 21:04:13 -05:00
|
|
|
hooksStore[hookName] = {
|
2018-12-13 23:41:57 -05:00
|
|
|
handlers: [handler],
|
|
|
|
runs: 0
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if (hookName !== 'hookAdded') {
|
2021-01-27 21:04:13 -05:00
|
|
|
hooks.doAction('hookAdded', hookName, namespace, callback, priority);
|
2018-12-13 23:41:57 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const build_module_createAddHook = (createAddHook);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/createRemoveHook.js
|
2019-03-07 04:09:59 -05:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2021-01-27 21:04:13 -05:00
|
|
|
/**
|
|
|
|
* @callback RemoveHook
|
|
|
|
* Removes the specified callback (or all callbacks) from the hook with a given hookName
|
|
|
|
* and namespace.
|
|
|
|
*
|
|
|
|
* @param {string} hookName The name of the hook to modify.
|
|
|
|
* @param {string} namespace The unique namespace identifying the callback in the
|
|
|
|
* form `vendor/plugin/function`.
|
|
|
|
*
|
|
|
|
* @return {number | undefined} The number of callbacks removed.
|
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a function which, when invoked, will remove a specified hook or all
|
|
|
|
* hooks by the given name.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
|
|
* @param {import('.').StoreKey} storeKey
|
|
|
|
* @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName,
|
|
|
|
* without regard to namespace. Used to create
|
|
|
|
* `removeAll*` functions.
|
2018-12-13 23:41:57 -05:00
|
|
|
*
|
2021-01-27 21:04:13 -05:00
|
|
|
* @return {RemoveHook} Function that removes hooks.
|
2018-12-13 23:41:57 -05:00
|
|
|
*/
|
2023-06-27 10:24:19 -04:00
|
|
|
function createRemoveHook(hooks, storeKey, removeAll = false) {
|
2018-12-13 23:41:57 -05:00
|
|
|
return function removeHook(hookName, namespace) {
|
2021-05-19 11:09:27 -04:00
|
|
|
const hooksStore = hooks[storeKey];
|
2018-12-17 22:14:52 -05:00
|
|
|
if (!build_module_validateHookName(hookName)) {
|
2018-12-13 23:41:57 -05:00
|
|
|
return;
|
|
|
|
}
|
2018-12-17 22:14:52 -05:00
|
|
|
if (!removeAll && !build_module_validateNamespace(namespace)) {
|
2018-12-13 23:41:57 -05:00
|
|
|
return;
|
2023-09-26 10:23:26 -04:00
|
|
|
}
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// Bail if no hooks exist by this name.
|
2021-01-27 21:04:13 -05:00
|
|
|
if (!hooksStore[hookName]) {
|
2018-12-13 23:41:57 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2021-05-19 11:09:27 -04:00
|
|
|
let handlersRemoved = 0;
|
2018-12-13 23:41:57 -05:00
|
|
|
if (removeAll) {
|
2021-01-27 21:04:13 -05:00
|
|
|
handlersRemoved = hooksStore[hookName].handlers.length;
|
|
|
|
hooksStore[hookName] = {
|
|
|
|
runs: hooksStore[hookName].runs,
|
2018-12-13 23:41:57 -05:00
|
|
|
handlers: []
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
// Try to find the specified callback to remove.
|
2021-05-19 11:09:27 -04:00
|
|
|
const handlers = hooksStore[hookName].handlers;
|
|
|
|
for (let i = handlers.length - 1; i >= 0; i--) {
|
2018-12-13 23:41:57 -05:00
|
|
|
if (handlers[i].namespace === namespace) {
|
|
|
|
handlers.splice(i, 1);
|
2023-09-26 10:23:26 -04:00
|
|
|
handlersRemoved++;
|
|
|
|
// This callback may also be part of a hook that is
|
2018-12-13 23:41:57 -05:00
|
|
|
// currently executing. If the callback we're removing
|
|
|
|
// comes after the current callback, there's no problem;
|
|
|
|
// otherwise we need to decrease the execution index of any
|
|
|
|
// other runs by 1 to account for the removed element.
|
2021-05-19 11:09:27 -04:00
|
|
|
hooksStore.__current.forEach(hookInfo => {
|
2018-12-13 23:41:57 -05:00
|
|
|
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
|
|
|
hookInfo.currentIndex--;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hookName !== 'hookRemoved') {
|
2021-01-27 21:04:13 -05:00
|
|
|
hooks.doAction('hookRemoved', hookName, namespace);
|
2018-12-13 23:41:57 -05:00
|
|
|
}
|
|
|
|
return handlersRemoved;
|
|
|
|
};
|
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const build_module_createRemoveHook = (createRemoveHook);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/createHasHook.js
|
2021-01-27 21:04:13 -05:00
|
|
|
/**
|
|
|
|
* @callback HasHook
|
|
|
|
*
|
|
|
|
* Returns whether any handlers are attached for the given hookName and optional namespace.
|
|
|
|
*
|
|
|
|
* @param {string} hookName The name of the hook to check for.
|
|
|
|
* @param {string} [namespace] Optional. The unique namespace identifying the callback
|
|
|
|
* in the form `vendor/plugin/function`.
|
|
|
|
*
|
|
|
|
* @return {boolean} Whether there are handlers that are attached to the given hook.
|
|
|
|
*/
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* Returns a function which, when invoked, will return whether any handlers are
|
|
|
|
* attached to a particular hook.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
|
|
* @param {import('.').StoreKey} storeKey
|
2018-12-17 22:14:52 -05:00
|
|
|
*
|
2021-01-27 21:04:13 -05:00
|
|
|
* @return {HasHook} Function that returns whether any handlers are
|
|
|
|
* attached to a particular hook and optional namespace.
|
2018-12-17 22:14:52 -05:00
|
|
|
*/
|
2021-01-27 21:04:13 -05:00
|
|
|
function createHasHook(hooks, storeKey) {
|
2019-09-19 11:19:18 -04:00
|
|
|
return function hasHook(hookName, namespace) {
|
2023-09-26 10:23:26 -04:00
|
|
|
const hooksStore = hooks[storeKey];
|
2021-01-27 21:04:13 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// Use the namespace if provided.
|
2019-09-19 11:19:18 -04:00
|
|
|
if ('undefined' !== typeof namespace) {
|
2021-05-19 11:09:27 -04:00
|
|
|
return hookName in hooksStore && hooksStore[hookName].handlers.some(hook => hook.namespace === namespace);
|
2019-09-19 11:19:18 -04:00
|
|
|
}
|
2021-01-27 21:04:13 -05:00
|
|
|
return hookName in hooksStore;
|
2018-12-17 22:14:52 -05:00
|
|
|
};
|
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const build_module_createHasHook = (createHasHook);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/createRunHook.js
|
2018-12-13 23:41:57 -05:00
|
|
|
/**
|
|
|
|
* Returns a function which, when invoked, will execute all callbacks
|
|
|
|
* registered to a hook of the specified type, optionally returning the final
|
|
|
|
* value of the call chain.
|
|
|
|
*
|
2024-09-30 01:11:31 -04:00
|
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {import('.').StoreKey} storeKey
|
2024-09-30 01:11:31 -04:00
|
|
|
* @param {boolean} returnFirstArg Whether each hook callback is expected to return its first argument.
|
|
|
|
* @param {boolean} async Whether the hook callback should be run asynchronously
|
2018-12-13 23:41:57 -05:00
|
|
|
*
|
2023-09-26 10:23:26 -04:00
|
|
|
* @return {(hookName:string, ...args: unknown[]) => undefined|unknown} Function that runs hook callbacks.
|
2018-12-13 23:41:57 -05:00
|
|
|
*/
|
2024-09-30 01:11:31 -04:00
|
|
|
function createRunHook(hooks, storeKey, returnFirstArg, async) {
|
|
|
|
return function runHook(hookName, ...args) {
|
2021-05-19 11:09:27 -04:00
|
|
|
const hooksStore = hooks[storeKey];
|
2021-01-27 21:04:13 -05:00
|
|
|
if (!hooksStore[hookName]) {
|
|
|
|
hooksStore[hookName] = {
|
2018-12-13 23:41:57 -05:00
|
|
|
handlers: [],
|
|
|
|
runs: 0
|
|
|
|
};
|
|
|
|
}
|
2021-01-27 21:04:13 -05:00
|
|
|
hooksStore[hookName].runs++;
|
2023-09-26 10:23:26 -04:00
|
|
|
const handlers = hooksStore[hookName].handlers;
|
2019-09-19 11:19:18 -04:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// The following code is stripped from production builds.
|
2019-09-19 11:19:18 -04:00
|
|
|
if (false) {}
|
2018-12-13 23:41:57 -05:00
|
|
|
if (!handlers || !handlers.length) {
|
|
|
|
return returnFirstArg ? args[0] : undefined;
|
|
|
|
}
|
2021-05-19 11:09:27 -04:00
|
|
|
const hookInfo = {
|
2018-12-13 23:41:57 -05:00
|
|
|
name: hookName,
|
|
|
|
currentIndex: 0
|
|
|
|
};
|
2024-09-30 01:11:31 -04:00
|
|
|
async function asyncRunner() {
|
|
|
|
try {
|
|
|
|
hooksStore.__current.add(hookInfo);
|
|
|
|
let result = returnFirstArg ? args[0] : undefined;
|
|
|
|
while (hookInfo.currentIndex < handlers.length) {
|
|
|
|
const handler = handlers[hookInfo.currentIndex];
|
|
|
|
result = await handler.callback.apply(null, args);
|
|
|
|
if (returnFirstArg) {
|
|
|
|
args[0] = result;
|
|
|
|
}
|
|
|
|
hookInfo.currentIndex++;
|
|
|
|
}
|
|
|
|
return returnFirstArg ? result : undefined;
|
|
|
|
} finally {
|
|
|
|
hooksStore.__current.delete(hookInfo);
|
2018-12-13 23:41:57 -05:00
|
|
|
}
|
|
|
|
}
|
2024-09-30 01:11:31 -04:00
|
|
|
function syncRunner() {
|
|
|
|
try {
|
|
|
|
hooksStore.__current.add(hookInfo);
|
|
|
|
let result = returnFirstArg ? args[0] : undefined;
|
|
|
|
while (hookInfo.currentIndex < handlers.length) {
|
|
|
|
const handler = handlers[hookInfo.currentIndex];
|
|
|
|
result = handler.callback.apply(null, args);
|
|
|
|
if (returnFirstArg) {
|
|
|
|
args[0] = result;
|
|
|
|
}
|
|
|
|
hookInfo.currentIndex++;
|
|
|
|
}
|
|
|
|
return returnFirstArg ? result : undefined;
|
|
|
|
} finally {
|
|
|
|
hooksStore.__current.delete(hookInfo);
|
|
|
|
}
|
2018-12-13 23:41:57 -05:00
|
|
|
}
|
2024-09-30 01:11:31 -04:00
|
|
|
return (async ? asyncRunner : syncRunner)();
|
2018-12-13 23:41:57 -05:00
|
|
|
};
|
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const build_module_createRunHook = (createRunHook);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* Returns a function which, when invoked, will return the name of the
|
|
|
|
* currently running hook, or `null` if no hook of the given type is currently
|
|
|
|
* running.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
|
|
* @param {import('.').StoreKey} storeKey
|
2018-12-17 22:14:52 -05:00
|
|
|
*
|
2021-01-27 21:04:13 -05:00
|
|
|
* @return {() => string | null} Function that returns the current hook name or null.
|
2018-12-17 22:14:52 -05:00
|
|
|
*/
|
2021-01-27 21:04:13 -05:00
|
|
|
function createCurrentHook(hooks, storeKey) {
|
2018-12-17 22:14:52 -05:00
|
|
|
return function currentHook() {
|
2024-09-30 01:11:31 -04:00
|
|
|
var _currentArray$at$name;
|
2021-05-19 11:09:27 -04:00
|
|
|
const hooksStore = hooks[storeKey];
|
2024-09-30 01:11:31 -04:00
|
|
|
const currentArray = Array.from(hooksStore.__current);
|
|
|
|
return (_currentArray$at$name = currentArray.at(-1)?.name) !== null && _currentArray$at$name !== void 0 ? _currentArray$at$name : null;
|
2018-12-17 22:14:52 -05:00
|
|
|
};
|
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const build_module_createCurrentHook = (createCurrentHook);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/createDoingHook.js
|
2021-01-27 21:04:13 -05:00
|
|
|
/**
|
|
|
|
* @callback DoingHook
|
|
|
|
* Returns whether a hook is currently being executed.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {string} [hookName] The name of the hook to check for. If
|
|
|
|
* omitted, will check for any hook being executed.
|
2021-01-27 21:04:13 -05:00
|
|
|
*
|
|
|
|
* @return {boolean} Whether the hook is being executed.
|
|
|
|
*/
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* Returns a function which, when invoked, will return whether a hook is
|
|
|
|
* currently being executed.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
|
|
* @param {import('.').StoreKey} storeKey
|
2018-12-17 22:14:52 -05:00
|
|
|
*
|
2021-01-27 21:04:13 -05:00
|
|
|
* @return {DoingHook} Function that returns whether a hook is currently
|
|
|
|
* being executed.
|
2018-12-17 22:14:52 -05:00
|
|
|
*/
|
2021-01-27 21:04:13 -05:00
|
|
|
function createDoingHook(hooks, storeKey) {
|
2018-12-17 22:14:52 -05:00
|
|
|
return function doingHook(hookName) {
|
2023-09-26 10:23:26 -04:00
|
|
|
const hooksStore = hooks[storeKey];
|
2021-01-27 21:04:13 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// If the hookName was not passed, check for any current hook.
|
2018-12-17 22:14:52 -05:00
|
|
|
if ('undefined' === typeof hookName) {
|
2024-09-30 01:11:31 -04:00
|
|
|
return hooksStore.__current.size > 0;
|
2023-09-26 10:23:26 -04:00
|
|
|
}
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2024-09-30 01:11:31 -04:00
|
|
|
// Find if the `hookName` hook is in `__current`.
|
|
|
|
return Array.from(hooksStore.__current).some(hook => hook.name === hookName);
|
2018-12-17 22:14:52 -05:00
|
|
|
};
|
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const build_module_createDoingHook = (createDoingHook);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/createDidHook.js
|
2019-03-07 04:09:59 -05:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2021-01-27 21:04:13 -05:00
|
|
|
/**
|
|
|
|
* @callback DidHook
|
|
|
|
*
|
|
|
|
* Returns the number of times an action has been fired.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {string} hookName The hook name to check.
|
2021-01-27 21:04:13 -05:00
|
|
|
*
|
|
|
|
* @return {number | undefined} The number of times the hook has run.
|
|
|
|
*/
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* Returns a function which, when invoked, will return the number of times a
|
|
|
|
* hook has been called.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {import('.').Hooks} hooks Hooks instance.
|
|
|
|
* @param {import('.').StoreKey} storeKey
|
2018-12-17 22:14:52 -05:00
|
|
|
*
|
2021-01-27 21:04:13 -05:00
|
|
|
* @return {DidHook} Function that returns a hook's call count.
|
2018-12-17 22:14:52 -05:00
|
|
|
*/
|
2021-01-27 21:04:13 -05:00
|
|
|
function createDidHook(hooks, storeKey) {
|
2018-12-17 22:14:52 -05:00
|
|
|
return function didHook(hookName) {
|
2021-05-19 11:09:27 -04:00
|
|
|
const hooksStore = hooks[storeKey];
|
2018-12-17 22:14:52 -05:00
|
|
|
if (!build_module_validateHookName(hookName)) {
|
|
|
|
return;
|
|
|
|
}
|
2021-01-27 21:04:13 -05:00
|
|
|
return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
|
2018-12-17 22:14:52 -05:00
|
|
|
};
|
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const build_module_createDidHook = (createDidHook);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/createHooks.js
|
2019-03-07 04:09:59 -05:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2018-12-17 22:14:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2021-01-27 21:04:13 -05:00
|
|
|
/**
|
|
|
|
* Internal class for constructing hooks. Use `createHooks()` function
|
|
|
|
*
|
|
|
|
* Note, it is necessary to expose this class to make its type public.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
2022-04-11 08:04:30 -04:00
|
|
|
class _Hooks {
|
2021-05-19 11:09:27 -04:00
|
|
|
constructor() {
|
|
|
|
/** @type {import('.').Store} actions */
|
|
|
|
this.actions = Object.create(null);
|
2024-09-30 01:11:31 -04:00
|
|
|
this.actions.__current = new Set();
|
2021-05-19 11:09:27 -04:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
/** @type {import('.').Store} filters */
|
2021-05-19 11:09:27 -04:00
|
|
|
this.filters = Object.create(null);
|
2024-09-30 01:11:31 -04:00
|
|
|
this.filters.__current = new Set();
|
2021-05-19 11:09:27 -04:00
|
|
|
this.addAction = build_module_createAddHook(this, 'actions');
|
|
|
|
this.addFilter = build_module_createAddHook(this, 'filters');
|
|
|
|
this.removeAction = build_module_createRemoveHook(this, 'actions');
|
|
|
|
this.removeFilter = build_module_createRemoveHook(this, 'filters');
|
|
|
|
this.hasAction = build_module_createHasHook(this, 'actions');
|
|
|
|
this.hasFilter = build_module_createHasHook(this, 'filters');
|
|
|
|
this.removeAllActions = build_module_createRemoveHook(this, 'actions', true);
|
|
|
|
this.removeAllFilters = build_module_createRemoveHook(this, 'filters', true);
|
2024-09-30 01:11:31 -04:00
|
|
|
this.doAction = build_module_createRunHook(this, 'actions', false, false);
|
|
|
|
this.doActionAsync = build_module_createRunHook(this, 'actions', false, true);
|
|
|
|
this.applyFilters = build_module_createRunHook(this, 'filters', true, false);
|
|
|
|
this.applyFiltersAsync = build_module_createRunHook(this, 'filters', true, true);
|
2021-05-19 11:09:27 -04:00
|
|
|
this.currentAction = build_module_createCurrentHook(this, 'actions');
|
|
|
|
this.currentFilter = build_module_createCurrentHook(this, 'filters');
|
|
|
|
this.doingAction = build_module_createDoingHook(this, 'actions');
|
|
|
|
this.doingFilter = build_module_createDoingHook(this, 'filters');
|
|
|
|
this.didAction = build_module_createDidHook(this, 'actions');
|
|
|
|
this.didFilter = build_module_createDidHook(this, 'filters');
|
|
|
|
}
|
|
|
|
}
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2021-01-27 21:04:13 -05:00
|
|
|
/** @typedef {_Hooks} Hooks */
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* Returns an instance of the hooks object.
|
|
|
|
*
|
2021-01-27 21:04:13 -05:00
|
|
|
* @return {Hooks} A Hooks instance.
|
2018-12-17 22:14:52 -05:00
|
|
|
*/
|
|
|
|
function createHooks() {
|
2022-04-11 08:04:30 -04:00
|
|
|
return new _Hooks();
|
2018-12-17 22:14:52 -05:00
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const build_module_createHooks = (createHooks);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
2024-12-13 14:06:24 -05:00
|
|
|
;// ./node_modules/@wordpress/hooks/build-module/index.js
|
2019-03-07 04:09:59 -05:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2021-01-27 21:04:13 -05:00
|
|
|
/** @typedef {(...args: any[])=>any} Callback */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef Handler
|
|
|
|
* @property {Callback} callback The callback
|
|
|
|
* @property {string} namespace The namespace
|
|
|
|
* @property {number} priority The namespace
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef Hook
|
|
|
|
* @property {Handler[]} handlers Array of handlers
|
|
|
|
* @property {number} runs Run counter
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef Current
|
|
|
|
* @property {string} name Hook name
|
|
|
|
* @property {number} currentIndex The index
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2024-09-30 01:11:31 -04:00
|
|
|
* @typedef {Record<string, Hook> & {__current: Set<Current>}} Store
|
2021-01-27 21:04:13 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {'actions' | 'filters'} StoreKey
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {import('./createHooks').Hooks} Hooks
|
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2021-05-19 11:09:27 -04:00
|
|
|
const defaultHooks = build_module_createHooks();
|
|
|
|
const {
|
|
|
|
addAction,
|
|
|
|
addFilter,
|
|
|
|
removeAction,
|
|
|
|
removeFilter,
|
|
|
|
hasAction,
|
|
|
|
hasFilter,
|
|
|
|
removeAllActions,
|
|
|
|
removeAllFilters,
|
|
|
|
doAction,
|
2024-09-30 01:11:31 -04:00
|
|
|
doActionAsync,
|
2021-05-19 11:09:27 -04:00
|
|
|
applyFilters,
|
2024-09-30 01:11:31 -04:00
|
|
|
applyFiltersAsync,
|
2021-05-19 11:09:27 -04:00
|
|
|
currentAction,
|
|
|
|
currentFilter,
|
|
|
|
doingAction,
|
|
|
|
doingFilter,
|
|
|
|
didAction,
|
|
|
|
didFilter,
|
|
|
|
actions,
|
|
|
|
filters
|
|
|
|
} = defaultHooks;
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
(window.wp = window.wp || {}).hooks = __webpack_exports__;
|
|
|
|
/******/ })()
|
|
|
|
;
|