wp/wp-includes/js/dist/hooks.js
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
     1 /******/ (function() { // webpackBootstrap
     1 /******/ (() => { // webpackBootstrap
     2 /******/ 	"use strict";
     2 /******/ 	"use strict";
     3 /******/ 	// The require scope
     3 /******/ 	// The require scope
     4 /******/ 	var __webpack_require__ = {};
     4 /******/ 	var __webpack_require__ = {};
     5 /******/ 	
     5 /******/ 	
     6 /************************************************************************/
     6 /************************************************************************/
     7 /******/ 	/* webpack/runtime/define property getters */
     7 /******/ 	/* webpack/runtime/define property getters */
     8 /******/ 	!function() {
     8 /******/ 	(() => {
     9 /******/ 		// define getter functions for harmony exports
     9 /******/ 		// define getter functions for harmony exports
    10 /******/ 		__webpack_require__.d = function(exports, definition) {
    10 /******/ 		__webpack_require__.d = (exports, definition) => {
    11 /******/ 			for(var key in definition) {
    11 /******/ 			for(var key in definition) {
    12 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
    12 /******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
    13 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
    13 /******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
    14 /******/ 				}
    14 /******/ 				}
    15 /******/ 			}
    15 /******/ 			}
    16 /******/ 		};
    16 /******/ 		};
    17 /******/ 	}();
    17 /******/ 	})();
    18 /******/ 	
    18 /******/ 	
    19 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
    19 /******/ 	/* webpack/runtime/hasOwnProperty shorthand */
    20 /******/ 	!function() {
    20 /******/ 	(() => {
    21 /******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
    21 /******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
    22 /******/ 	}();
    22 /******/ 	})();
    23 /******/ 	
    23 /******/ 	
    24 /******/ 	/* webpack/runtime/make namespace object */
    24 /******/ 	/* webpack/runtime/make namespace object */
    25 /******/ 	!function() {
    25 /******/ 	(() => {
    26 /******/ 		// define __esModule on exports
    26 /******/ 		// define __esModule on exports
    27 /******/ 		__webpack_require__.r = function(exports) {
    27 /******/ 		__webpack_require__.r = (exports) => {
    28 /******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
    28 /******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
    29 /******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
    29 /******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
    30 /******/ 			}
    30 /******/ 			}
    31 /******/ 			Object.defineProperty(exports, '__esModule', { value: true });
    31 /******/ 			Object.defineProperty(exports, '__esModule', { value: true });
    32 /******/ 		};
    32 /******/ 		};
    33 /******/ 	}();
    33 /******/ 	})();
    34 /******/ 	
    34 /******/ 	
    35 /************************************************************************/
    35 /************************************************************************/
    36 var __webpack_exports__ = {};
    36 var __webpack_exports__ = {};
    37 // ESM COMPAT FLAG
    37 // ESM COMPAT FLAG
    38 __webpack_require__.r(__webpack_exports__);
    38 __webpack_require__.r(__webpack_exports__);
    39 
    39 
    40 // EXPORTS
    40 // EXPORTS
    41 __webpack_require__.d(__webpack_exports__, {
    41 __webpack_require__.d(__webpack_exports__, {
    42   "actions": function() { return /* binding */ actions; },
    42   actions: () => (/* binding */ actions),
    43   "addAction": function() { return /* binding */ addAction; },
    43   addAction: () => (/* binding */ addAction),
    44   "addFilter": function() { return /* binding */ addFilter; },
    44   addFilter: () => (/* binding */ addFilter),
    45   "applyFilters": function() { return /* binding */ applyFilters; },
    45   applyFilters: () => (/* binding */ applyFilters),
    46   "createHooks": function() { return /* reexport */ build_module_createHooks; },
    46   createHooks: () => (/* reexport */ build_module_createHooks),
    47   "currentAction": function() { return /* binding */ currentAction; },
    47   currentAction: () => (/* binding */ currentAction),
    48   "currentFilter": function() { return /* binding */ currentFilter; },
    48   currentFilter: () => (/* binding */ currentFilter),
    49   "defaultHooks": function() { return /* binding */ defaultHooks; },
    49   defaultHooks: () => (/* binding */ defaultHooks),
    50   "didAction": function() { return /* binding */ didAction; },
    50   didAction: () => (/* binding */ didAction),
    51   "didFilter": function() { return /* binding */ didFilter; },
    51   didFilter: () => (/* binding */ didFilter),
    52   "doAction": function() { return /* binding */ doAction; },
    52   doAction: () => (/* binding */ doAction),
    53   "doingAction": function() { return /* binding */ doingAction; },
    53   doingAction: () => (/* binding */ doingAction),
    54   "doingFilter": function() { return /* binding */ doingFilter; },
    54   doingFilter: () => (/* binding */ doingFilter),
    55   "filters": function() { return /* binding */ filters; },
    55   filters: () => (/* binding */ filters),
    56   "hasAction": function() { return /* binding */ hasAction; },
    56   hasAction: () => (/* binding */ hasAction),
    57   "hasFilter": function() { return /* binding */ hasFilter; },
    57   hasFilter: () => (/* binding */ hasFilter),
    58   "removeAction": function() { return /* binding */ removeAction; },
    58   removeAction: () => (/* binding */ removeAction),
    59   "removeAllActions": function() { return /* binding */ removeAllActions; },
    59   removeAllActions: () => (/* binding */ removeAllActions),
    60   "removeAllFilters": function() { return /* binding */ removeAllFilters; },
    60   removeAllFilters: () => (/* binding */ removeAllFilters),
    61   "removeFilter": function() { return /* binding */ removeFilter; }
    61   removeFilter: () => (/* binding */ removeFilter)
    62 });
    62 });
    63 
    63 
    64 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateNamespace.js
    64 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateNamespace.js
    65 /**
    65 /**
    66  * Validate a namespace string.
    66  * Validate a namespace string.
    74   if ('string' !== typeof namespace || '' === namespace) {
    74   if ('string' !== typeof namespace || '' === namespace) {
    75     // eslint-disable-next-line no-console
    75     // eslint-disable-next-line no-console
    76     console.error('The namespace must be a non-empty string.');
    76     console.error('The namespace must be a non-empty string.');
    77     return false;
    77     return false;
    78   }
    78   }
    79 
       
    80   if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
    79   if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
    81     // eslint-disable-next-line no-console
    80     // eslint-disable-next-line no-console
    82     console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.');
    81     console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.');
    83     return false;
    82     return false;
    84   }
    83   }
    85 
       
    86   return true;
    84   return true;
    87 }
    85 }
    88 
    86 /* harmony default export */ const build_module_validateNamespace = (validateNamespace);
    89 /* harmony default export */ var build_module_validateNamespace = (validateNamespace);
       
    90 
    87 
    91 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateHookName.js
    88 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateHookName.js
    92 /**
    89 /**
    93  * Validate a hookName string.
    90  * Validate a hookName string.
    94  *
    91  *
   102   if ('string' !== typeof hookName || '' === hookName) {
    99   if ('string' !== typeof hookName || '' === hookName) {
   103     // eslint-disable-next-line no-console
   100     // eslint-disable-next-line no-console
   104     console.error('The hook name must be a non-empty string.');
   101     console.error('The hook name must be a non-empty string.');
   105     return false;
   102     return false;
   106   }
   103   }
   107 
       
   108   if (/^__/.test(hookName)) {
   104   if (/^__/.test(hookName)) {
   109     // eslint-disable-next-line no-console
   105     // eslint-disable-next-line no-console
   110     console.error('The hook name cannot begin with `__`.');
   106     console.error('The hook name cannot begin with `__`.');
   111     return false;
   107     return false;
   112   }
   108   }
   113 
       
   114   if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
   109   if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
   115     // eslint-disable-next-line no-console
   110     // eslint-disable-next-line no-console
   116     console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.');
   111     console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.');
   117     return false;
   112     return false;
   118   }
   113   }
   119 
       
   120   return true;
   114   return true;
   121 }
   115 }
   122 
   116 /* harmony default export */ const build_module_validateHookName = (validateHookName);
   123 /* harmony default export */ var build_module_validateHookName = (validateHookName);
       
   124 
   117 
   125 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createAddHook.js
   118 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createAddHook.js
   126 /**
   119 /**
   127  * Internal dependencies
   120  * Internal dependencies
   128  */
   121  */
       
   122 
   129 
   123 
   130 
   124 
   131 /**
   125 /**
   132  * @callback AddHook
   126  * @callback AddHook
   133  *
   127  *
   145  * @param {import('.').Hooks}    hooks    Hooks instance.
   139  * @param {import('.').Hooks}    hooks    Hooks instance.
   146  * @param {import('.').StoreKey} storeKey
   140  * @param {import('.').StoreKey} storeKey
   147  *
   141  *
   148  * @return {AddHook} Function that adds a new hook.
   142  * @return {AddHook} Function that adds a new hook.
   149  */
   143  */
   150 
       
   151 function createAddHook(hooks, storeKey) {
   144 function createAddHook(hooks, storeKey) {
   152   return function addHook(hookName, namespace, callback) {
   145   return function addHook(hookName, namespace, callback, priority = 10) {
   153     let priority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
   146     const hooksStore = hooks[storeKey];
   154     const hooksStore = hooks[storeKey];
       
   155 
       
   156     if (!build_module_validateHookName(hookName)) {
   147     if (!build_module_validateHookName(hookName)) {
   157       return;
   148       return;
   158     }
   149     }
   159 
       
   160     if (!build_module_validateNamespace(namespace)) {
   150     if (!build_module_validateNamespace(namespace)) {
   161       return;
   151       return;
   162     }
   152     }
   163 
       
   164     if ('function' !== typeof callback) {
   153     if ('function' !== typeof callback) {
   165       // eslint-disable-next-line no-console
   154       // eslint-disable-next-line no-console
   166       console.error('The hook callback must be a function.');
   155       console.error('The hook callback must be a function.');
   167       return;
   156       return;
   168     } // Validate numeric priority
   157     }
   169 
   158 
   170 
   159     // Validate numeric priority
   171     if ('number' !== typeof priority) {
   160     if ('number' !== typeof priority) {
   172       // eslint-disable-next-line no-console
   161       // eslint-disable-next-line no-console
   173       console.error('If specified, the hook priority must be a number.');
   162       console.error('If specified, the hook priority must be a number.');
   174       return;
   163       return;
   175     }
   164     }
   176 
       
   177     const handler = {
   165     const handler = {
   178       callback,
   166       callback,
   179       priority,
   167       priority,
   180       namespace
   168       namespace
   181     };
   169     };
   182 
       
   183     if (hooksStore[hookName]) {
   170     if (hooksStore[hookName]) {
   184       // Find the correct insert index of the new hook.
   171       // Find the correct insert index of the new hook.
   185       const handlers = hooksStore[hookName].handlers;
   172       const handlers = hooksStore[hookName].handlers;
       
   173 
   186       /** @type {number} */
   174       /** @type {number} */
   187 
       
   188       let i;
   175       let i;
   189 
       
   190       for (i = handlers.length; i > 0; i--) {
   176       for (i = handlers.length; i > 0; i--) {
   191         if (priority >= handlers[i - 1].priority) {
   177         if (priority >= handlers[i - 1].priority) {
   192           break;
   178           break;
   193         }
   179         }
   194       }
   180       }
   195 
       
   196       if (i === handlers.length) {
   181       if (i === handlers.length) {
   197         // If append, operate via direct assignment.
   182         // If append, operate via direct assignment.
   198         handlers[i] = handler;
   183         handlers[i] = handler;
   199       } else {
   184       } else {
   200         // Otherwise, insert before index via splice.
   185         // Otherwise, insert before index via splice.
   201         handlers.splice(i, 0, handler);
   186         handlers.splice(i, 0, handler);
   202       } // We may also be currently executing this hook.  If the callback
   187       }
       
   188 
       
   189       // We may also be currently executing this hook.  If the callback
   203       // we're adding would come after the current callback, there's no
   190       // we're adding would come after the current callback, there's no
   204       // problem; otherwise we need to increase the execution index of
   191       // problem; otherwise we need to increase the execution index of
   205       // any other runs by 1 to account for the added element.
   192       // any other runs by 1 to account for the added element.
   206 
       
   207 
       
   208       hooksStore.__current.forEach(hookInfo => {
   193       hooksStore.__current.forEach(hookInfo => {
   209         if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
   194         if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
   210           hookInfo.currentIndex++;
   195           hookInfo.currentIndex++;
   211         }
   196         }
   212       });
   197       });
   215       hooksStore[hookName] = {
   200       hooksStore[hookName] = {
   216         handlers: [handler],
   201         handlers: [handler],
   217         runs: 0
   202         runs: 0
   218       };
   203       };
   219     }
   204     }
   220 
       
   221     if (hookName !== 'hookAdded') {
   205     if (hookName !== 'hookAdded') {
   222       hooks.doAction('hookAdded', hookName, namespace, callback, priority);
   206       hooks.doAction('hookAdded', hookName, namespace, callback, priority);
   223     }
   207     }
   224   };
   208   };
   225 }
   209 }
   226 
   210 /* harmony default export */ const build_module_createAddHook = (createAddHook);
   227 /* harmony default export */ var build_module_createAddHook = (createAddHook);
       
   228 
   211 
   229 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRemoveHook.js
   212 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRemoveHook.js
   230 /**
   213 /**
   231  * Internal dependencies
   214  * Internal dependencies
   232  */
   215  */
       
   216 
   233 
   217 
   234 
   218 
   235 /**
   219 /**
   236  * @callback RemoveHook
   220  * @callback RemoveHook
   237  * Removes the specified callback (or all callbacks) from the hook with a given hookName
   221  * Removes the specified callback (or all callbacks) from the hook with a given hookName
   254  *                                                 without regard to namespace. Used to create
   238  *                                                 without regard to namespace. Used to create
   255  *                                                 `removeAll*` functions.
   239  *                                                 `removeAll*` functions.
   256  *
   240  *
   257  * @return {RemoveHook} Function that removes hooks.
   241  * @return {RemoveHook} Function that removes hooks.
   258  */
   242  */
   259 
   243 function createRemoveHook(hooks, storeKey, removeAll = false) {
   260 function createRemoveHook(hooks, storeKey) {
       
   261   let removeAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
       
   262   return function removeHook(hookName, namespace) {
   244   return function removeHook(hookName, namespace) {
   263     const hooksStore = hooks[storeKey];
   245     const hooksStore = hooks[storeKey];
   264 
       
   265     if (!build_module_validateHookName(hookName)) {
   246     if (!build_module_validateHookName(hookName)) {
   266       return;
   247       return;
   267     }
   248     }
   268 
       
   269     if (!removeAll && !build_module_validateNamespace(namespace)) {
   249     if (!removeAll && !build_module_validateNamespace(namespace)) {
   270       return;
   250       return;
   271     } // Bail if no hooks exist by this name.
   251     }
   272 
   252 
   273 
   253     // Bail if no hooks exist by this name.
   274     if (!hooksStore[hookName]) {
   254     if (!hooksStore[hookName]) {
   275       return 0;
   255       return 0;
   276     }
   256     }
   277 
       
   278     let handlersRemoved = 0;
   257     let handlersRemoved = 0;
   279 
       
   280     if (removeAll) {
   258     if (removeAll) {
   281       handlersRemoved = hooksStore[hookName].handlers.length;
   259       handlersRemoved = hooksStore[hookName].handlers.length;
   282       hooksStore[hookName] = {
   260       hooksStore[hookName] = {
   283         runs: hooksStore[hookName].runs,
   261         runs: hooksStore[hookName].runs,
   284         handlers: []
   262         handlers: []
   285       };
   263       };
   286     } else {
   264     } else {
   287       // Try to find the specified callback to remove.
   265       // Try to find the specified callback to remove.
   288       const handlers = hooksStore[hookName].handlers;
   266       const handlers = hooksStore[hookName].handlers;
   289 
       
   290       for (let i = handlers.length - 1; i >= 0; i--) {
   267       for (let i = handlers.length - 1; i >= 0; i--) {
   291         if (handlers[i].namespace === namespace) {
   268         if (handlers[i].namespace === namespace) {
   292           handlers.splice(i, 1);
   269           handlers.splice(i, 1);
   293           handlersRemoved++; // This callback may also be part of a hook that is
   270           handlersRemoved++;
       
   271           // This callback may also be part of a hook that is
   294           // currently executing.  If the callback we're removing
   272           // currently executing.  If the callback we're removing
   295           // comes after the current callback, there's no problem;
   273           // comes after the current callback, there's no problem;
   296           // otherwise we need to decrease the execution index of any
   274           // otherwise we need to decrease the execution index of any
   297           // other runs by 1 to account for the removed element.
   275           // other runs by 1 to account for the removed element.
   298 
       
   299           hooksStore.__current.forEach(hookInfo => {
   276           hooksStore.__current.forEach(hookInfo => {
   300             if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
   277             if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
   301               hookInfo.currentIndex--;
   278               hookInfo.currentIndex--;
   302             }
   279             }
   303           });
   280           });
   304         }
   281         }
   305       }
   282       }
   306     }
   283     }
   307 
       
   308     if (hookName !== 'hookRemoved') {
   284     if (hookName !== 'hookRemoved') {
   309       hooks.doAction('hookRemoved', hookName, namespace);
   285       hooks.doAction('hookRemoved', hookName, namespace);
   310     }
   286     }
   311 
       
   312     return handlersRemoved;
   287     return handlersRemoved;
   313   };
   288   };
   314 }
   289 }
   315 
   290 /* harmony default export */ const build_module_createRemoveHook = (createRemoveHook);
   316 /* harmony default export */ var build_module_createRemoveHook = (createRemoveHook);
       
   317 
   291 
   318 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHasHook.js
   292 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHasHook.js
   319 /**
   293 /**
   320  * @callback HasHook
   294  * @callback HasHook
   321  *
   295  *
   325  * @param {string} [namespace] Optional. The unique namespace identifying the callback
   299  * @param {string} [namespace] Optional. The unique namespace identifying the callback
   326  *                             in the form `vendor/plugin/function`.
   300  *                             in the form `vendor/plugin/function`.
   327  *
   301  *
   328  * @return {boolean} Whether there are handlers that are attached to the given hook.
   302  * @return {boolean} Whether there are handlers that are attached to the given hook.
   329  */
   303  */
   330 
       
   331 /**
   304 /**
   332  * Returns a function which, when invoked, will return whether any handlers are
   305  * Returns a function which, when invoked, will return whether any handlers are
   333  * attached to a particular hook.
   306  * attached to a particular hook.
   334  *
   307  *
   335  * @param {import('.').Hooks}    hooks    Hooks instance.
   308  * @param {import('.').Hooks}    hooks    Hooks instance.
   338  * @return {HasHook} Function that returns whether any handlers are
   311  * @return {HasHook} Function that returns whether any handlers are
   339  *                   attached to a particular hook and optional namespace.
   312  *                   attached to a particular hook and optional namespace.
   340  */
   313  */
   341 function createHasHook(hooks, storeKey) {
   314 function createHasHook(hooks, storeKey) {
   342   return function hasHook(hookName, namespace) {
   315   return function hasHook(hookName, namespace) {
   343     const hooksStore = hooks[storeKey]; // Use the namespace if provided.
   316     const hooksStore = hooks[storeKey];
   344 
   317 
       
   318     // Use the namespace if provided.
   345     if ('undefined' !== typeof namespace) {
   319     if ('undefined' !== typeof namespace) {
   346       return hookName in hooksStore && hooksStore[hookName].handlers.some(hook => hook.namespace === namespace);
   320       return hookName in hooksStore && hooksStore[hookName].handlers.some(hook => hook.namespace === namespace);
   347     }
   321     }
   348 
       
   349     return hookName in hooksStore;
   322     return hookName in hooksStore;
   350   };
   323   };
   351 }
   324 }
   352 
   325 /* harmony default export */ const build_module_createHasHook = (createHasHook);
   353 /* harmony default export */ var build_module_createHasHook = (createHasHook);
       
   354 
   326 
   355 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRunHook.js
   327 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRunHook.js
   356 /**
   328 /**
   357  * Returns a function which, when invoked, will execute all callbacks
   329  * Returns a function which, when invoked, will execute all callbacks
   358  * registered to a hook of the specified type, optionally returning the final
   330  * registered to a hook of the specified type, optionally returning the final
   361  * @param {import('.').Hooks}    hooks                  Hooks instance.
   333  * @param {import('.').Hooks}    hooks                  Hooks instance.
   362  * @param {import('.').StoreKey} storeKey
   334  * @param {import('.').StoreKey} storeKey
   363  * @param {boolean}              [returnFirstArg=false] Whether each hook callback is expected to
   335  * @param {boolean}              [returnFirstArg=false] Whether each hook callback is expected to
   364  *                                                      return its first argument.
   336  *                                                      return its first argument.
   365  *
   337  *
   366  * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks.
   338  * @return {(hookName:string, ...args: unknown[]) => undefined|unknown} Function that runs hook callbacks.
   367  */
   339  */
   368 function createRunHook(hooks, storeKey) {
   340 function createRunHook(hooks, storeKey, returnFirstArg = false) {
   369   let returnFirstArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
   341   return function runHooks(hookName, ...args) {
   370   return function runHooks(hookName) {
   342     const hooksStore = hooks[storeKey];
   371     const hooksStore = hooks[storeKey];
       
   372 
       
   373     if (!hooksStore[hookName]) {
   343     if (!hooksStore[hookName]) {
   374       hooksStore[hookName] = {
   344       hooksStore[hookName] = {
   375         handlers: [],
   345         handlers: [],
   376         runs: 0
   346         runs: 0
   377       };
   347       };
   378     }
   348     }
   379 
       
   380     hooksStore[hookName].runs++;
   349     hooksStore[hookName].runs++;
   381     const handlers = hooksStore[hookName].handlers; // The following code is stripped from production builds.
   350     const handlers = hooksStore[hookName].handlers;
   382 
   351 
       
   352     // The following code is stripped from production builds.
   383     if (false) {}
   353     if (false) {}
   384 
       
   385     for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
       
   386       args[_key - 1] = arguments[_key];
       
   387     }
       
   388 
       
   389     if (!handlers || !handlers.length) {
   354     if (!handlers || !handlers.length) {
   390       return returnFirstArg ? args[0] : undefined;
   355       return returnFirstArg ? args[0] : undefined;
   391     }
   356     }
   392 
       
   393     const hookInfo = {
   357     const hookInfo = {
   394       name: hookName,
   358       name: hookName,
   395       currentIndex: 0
   359       currentIndex: 0
   396     };
   360     };
   397 
       
   398     hooksStore.__current.push(hookInfo);
   361     hooksStore.__current.push(hookInfo);
   399 
       
   400     while (hookInfo.currentIndex < handlers.length) {
   362     while (hookInfo.currentIndex < handlers.length) {
   401       const handler = handlers[hookInfo.currentIndex];
   363       const handler = handlers[hookInfo.currentIndex];
   402       const result = handler.callback.apply(null, args);
   364       const result = handler.callback.apply(null, args);
   403 
       
   404       if (returnFirstArg) {
   365       if (returnFirstArg) {
   405         args[0] = result;
   366         args[0] = result;
   406       }
   367       }
   407 
       
   408       hookInfo.currentIndex++;
   368       hookInfo.currentIndex++;
   409     }
   369     }
   410 
       
   411     hooksStore.__current.pop();
   370     hooksStore.__current.pop();
   412 
       
   413     if (returnFirstArg) {
   371     if (returnFirstArg) {
   414       return args[0];
   372       return args[0];
   415     }
   373     }
   416   };
   374     return undefined;
   417 }
   375   };
   418 
   376 }
   419 /* harmony default export */ var build_module_createRunHook = (createRunHook);
   377 /* harmony default export */ const build_module_createRunHook = (createRunHook);
   420 
   378 
   421 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js
   379 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js
   422 /**
   380 /**
   423  * Returns a function which, when invoked, will return the name of the
   381  * Returns a function which, when invoked, will return the name of the
   424  * currently running hook, or `null` if no hook of the given type is currently
   382  * currently running hook, or `null` if no hook of the given type is currently
   429  *
   387  *
   430  * @return {() => string | null} Function that returns the current hook name or null.
   388  * @return {() => string | null} Function that returns the current hook name or null.
   431  */
   389  */
   432 function createCurrentHook(hooks, storeKey) {
   390 function createCurrentHook(hooks, storeKey) {
   433   return function currentHook() {
   391   return function currentHook() {
   434     var _hooksStore$__current, _hooksStore$__current2;
   392     var _hooksStore$__current;
   435 
   393     const hooksStore = hooks[storeKey];
   436     const hooksStore = hooks[storeKey];
   394     return (_hooksStore$__current = hooksStore.__current[hooksStore.__current.length - 1]?.name) !== null && _hooksStore$__current !== void 0 ? _hooksStore$__current : null;
   437     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;
   395   };
   438   };
   396 }
   439 }
   397 /* harmony default export */ const build_module_createCurrentHook = (createCurrentHook);
   440 
       
   441 /* harmony default export */ var build_module_createCurrentHook = (createCurrentHook);
       
   442 
   398 
   443 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDoingHook.js
   399 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDoingHook.js
   444 /**
   400 /**
   445  * @callback DoingHook
   401  * @callback DoingHook
   446  * Returns whether a hook is currently being executed.
   402  * Returns whether a hook is currently being executed.
   461  * @return {DoingHook} Function that returns whether a hook is currently
   417  * @return {DoingHook} Function that returns whether a hook is currently
   462  *                     being executed.
   418  *                     being executed.
   463  */
   419  */
   464 function createDoingHook(hooks, storeKey) {
   420 function createDoingHook(hooks, storeKey) {
   465   return function doingHook(hookName) {
   421   return function doingHook(hookName) {
   466     const hooksStore = hooks[storeKey]; // If the hookName was not passed, check for any current hook.
   422     const hooksStore = hooks[storeKey];
   467 
   423 
       
   424     // If the hookName was not passed, check for any current hook.
   468     if ('undefined' === typeof hookName) {
   425     if ('undefined' === typeof hookName) {
   469       return 'undefined' !== typeof hooksStore.__current[0];
   426       return 'undefined' !== typeof hooksStore.__current[0];
   470     } // Return the __current hook.
   427     }
   471 
   428 
   472 
   429     // Return the __current hook.
   473     return hooksStore.__current[0] ? hookName === hooksStore.__current[0].name : false;
   430     return hooksStore.__current[0] ? hookName === hooksStore.__current[0].name : false;
   474   };
   431   };
   475 }
   432 }
   476 
   433 /* harmony default export */ const build_module_createDoingHook = (createDoingHook);
   477 /* harmony default export */ var build_module_createDoingHook = (createDoingHook);
       
   478 
   434 
   479 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDidHook.js
   435 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDidHook.js
   480 /**
   436 /**
   481  * Internal dependencies
   437  * Internal dependencies
   482  */
   438  */
       
   439 
   483 
   440 
   484 /**
   441 /**
   485  * @callback DidHook
   442  * @callback DidHook
   486  *
   443  *
   487  * Returns the number of times an action has been fired.
   444  * Returns the number of times an action has been fired.
   498  * @param {import('.').Hooks}    hooks    Hooks instance.
   455  * @param {import('.').Hooks}    hooks    Hooks instance.
   499  * @param {import('.').StoreKey} storeKey
   456  * @param {import('.').StoreKey} storeKey
   500  *
   457  *
   501  * @return {DidHook} Function that returns a hook's call count.
   458  * @return {DidHook} Function that returns a hook's call count.
   502  */
   459  */
   503 
       
   504 function createDidHook(hooks, storeKey) {
   460 function createDidHook(hooks, storeKey) {
   505   return function didHook(hookName) {
   461   return function didHook(hookName) {
   506     const hooksStore = hooks[storeKey];
   462     const hooksStore = hooks[storeKey];
   507 
       
   508     if (!build_module_validateHookName(hookName)) {
   463     if (!build_module_validateHookName(hookName)) {
   509       return;
   464       return;
   510     }
   465     }
   511 
       
   512     return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
   466     return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
   513   };
   467   };
   514 }
   468 }
   515 
   469 /* harmony default export */ const build_module_createDidHook = (createDidHook);
   516 /* harmony default export */ var build_module_createDidHook = (createDidHook);
       
   517 
   470 
   518 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHooks.js
   471 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHooks.js
   519 /**
   472 /**
   520  * Internal dependencies
   473  * Internal dependencies
   521  */
   474  */
   524 
   477 
   525 
   478 
   526 
   479 
   527 
   480 
   528 
   481 
       
   482 
   529 /**
   483 /**
   530  * Internal class for constructing hooks. Use `createHooks()` function
   484  * Internal class for constructing hooks. Use `createHooks()` function
   531  *
   485  *
   532  * Note, it is necessary to expose this class to make its type public.
   486  * Note, it is necessary to expose this class to make its type public.
   533  *
   487  *
   534  * @private
   488  * @private
   535  */
   489  */
   536 
       
   537 class _Hooks {
   490 class _Hooks {
   538   constructor() {
   491   constructor() {
   539     /** @type {import('.').Store} actions */
   492     /** @type {import('.').Store} actions */
   540     this.actions = Object.create(null);
   493     this.actions = Object.create(null);
   541     this.actions.__current = [];
   494     this.actions.__current = [];
       
   495 
   542     /** @type {import('.').Store} filters */
   496     /** @type {import('.').Store} filters */
   543 
       
   544     this.filters = Object.create(null);
   497     this.filters = Object.create(null);
   545     this.filters.__current = [];
   498     this.filters.__current = [];
   546     this.addAction = build_module_createAddHook(this, 'actions');
   499     this.addAction = build_module_createAddHook(this, 'actions');
   547     this.addFilter = build_module_createAddHook(this, 'filters');
   500     this.addFilter = build_module_createAddHook(this, 'filters');
   548     this.removeAction = build_module_createRemoveHook(this, 'actions');
   501     this.removeAction = build_module_createRemoveHook(this, 'actions');
   558     this.doingAction = build_module_createDoingHook(this, 'actions');
   511     this.doingAction = build_module_createDoingHook(this, 'actions');
   559     this.doingFilter = build_module_createDoingHook(this, 'filters');
   512     this.doingFilter = build_module_createDoingHook(this, 'filters');
   560     this.didAction = build_module_createDidHook(this, 'actions');
   513     this.didAction = build_module_createDidHook(this, 'actions');
   561     this.didFilter = build_module_createDidHook(this, 'filters');
   514     this.didFilter = build_module_createDidHook(this, 'filters');
   562   }
   515   }
   563 
   516 }
   564 }
   517 
   565 /** @typedef {_Hooks} Hooks */
   518 /** @typedef {_Hooks} Hooks */
   566 
   519 
   567 /**
   520 /**
   568  * Returns an instance of the hooks object.
   521  * Returns an instance of the hooks object.
   569  *
   522  *
   570  * @return {Hooks} A Hooks instance.
   523  * @return {Hooks} A Hooks instance.
   571  */
   524  */
   572 
       
   573 function createHooks() {
   525 function createHooks() {
   574   return new _Hooks();
   526   return new _Hooks();
   575 }
   527 }
   576 
   528 /* harmony default export */ const build_module_createHooks = (createHooks);
   577 /* harmony default export */ var build_module_createHooks = (createHooks);
       
   578 
   529 
   579 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/index.js
   530 ;// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/index.js
   580 /**
   531 /**
   581  * Internal dependencies
   532  * Internal dependencies
   582  */
   533  */
       
   534 
   583 
   535 
   584 /** @typedef {(...args: any[])=>any} Callback */
   536 /** @typedef {(...args: any[])=>any} Callback */
   585 
   537 
   586 /**
   538 /**
   587  * @typedef Handler
   539  * @typedef Handler