[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> hooks.js (source)

   1  this["wp"] = this["wp"] || {}; this["wp"]["hooks"] =
   2  /******/ (function(modules) { // webpackBootstrap
   3  /******/     // The module cache
   4  /******/     var installedModules = {};
   5  /******/
   6  /******/     // The require function
   7  /******/ 	function __webpack_require__(moduleId) {
   8  /******/
   9  /******/         // Check if module is in cache
  10  /******/         if(installedModules[moduleId]) {
  11  /******/             return installedModules[moduleId].exports;
  12  /******/         }
  13  /******/         // Create a new module (and put it into the cache)
  14  /******/         var module = installedModules[moduleId] = {
  15  /******/             i: moduleId,
  16  /******/             l: false,
  17  /******/             exports: {}
  18  /******/         };
  19  /******/
  20  /******/         // Execute the module function
  21  /******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22  /******/
  23  /******/         // Flag the module as loaded
  24  /******/         module.l = true;
  25  /******/
  26  /******/         // Return the exports of the module
  27  /******/         return module.exports;
  28  /******/     }
  29  /******/
  30  /******/
  31  /******/     // expose the modules object (__webpack_modules__)
  32  /******/     __webpack_require__.m = modules;
  33  /******/
  34  /******/     // expose the module cache
  35  /******/     __webpack_require__.c = installedModules;
  36  /******/
  37  /******/     // define getter function for harmony exports
  38  /******/     __webpack_require__.d = function(exports, name, getter) {
  39  /******/         if(!__webpack_require__.o(exports, name)) {
  40  /******/             Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41  /******/         }
  42  /******/     };
  43  /******/
  44  /******/     // define __esModule on exports
  45  /******/     __webpack_require__.r = function(exports) {
  46  /******/         if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47  /******/             Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48  /******/         }
  49  /******/         Object.defineProperty(exports, '__esModule', { value: true });
  50  /******/     };
  51  /******/
  52  /******/     // create a fake namespace object
  53  /******/     // mode & 1: value is a module id, require it
  54  /******/     // mode & 2: merge all properties of value into the ns
  55  /******/     // mode & 4: return value when already ns object
  56  /******/     // mode & 8|1: behave like require
  57  /******/     __webpack_require__.t = function(value, mode) {
  58  /******/         if(mode & 1) value = __webpack_require__(value);
  59  /******/         if(mode & 8) return value;
  60  /******/         if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61  /******/         var ns = Object.create(null);
  62  /******/         __webpack_require__.r(ns);
  63  /******/         Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64  /******/         if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65  /******/         return ns;
  66  /******/     };
  67  /******/
  68  /******/     // getDefaultExport function for compatibility with non-harmony modules
  69  /******/     __webpack_require__.n = function(module) {
  70  /******/         var getter = module && module.__esModule ?
  71  /******/ 			function getDefault() { return module['default']; } :
  72  /******/ 			function getModuleExports() { return module; };
  73  /******/         __webpack_require__.d(getter, 'a', getter);
  74  /******/         return getter;
  75  /******/     };
  76  /******/
  77  /******/     // Object.prototype.hasOwnProperty.call
  78  /******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79  /******/
  80  /******/     // __webpack_public_path__
  81  /******/     __webpack_require__.p = "";
  82  /******/
  83  /******/
  84  /******/     // Load entry module and return exports
  85  /******/     return __webpack_require__(__webpack_require__.s = 467);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 15:
  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__(24);
 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__(37);
 108  
 109  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
 110  var unsupportedIterableToArray = __webpack_require__(31);
 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  /***/ 24:
 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  /***/ 25:
 145  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 146  
 147  "use strict";
 148  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
 149  function _classCallCheck(instance, Constructor) {
 150    if (!(instance instanceof Constructor)) {
 151      throw new TypeError("Cannot call a class as a function");
 152    }
 153  }
 154  
 155  /***/ }),
 156  
 157  /***/ 31:
 158  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 159  
 160  "use strict";
 161  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
 162  /* harmony import */ var _babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
 163  
 164  function _unsupportedIterableToArray(o, minLen) {
 165    if (!o) return;
 166    if (typeof o === "string") return Object(_babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 167    var n = Object.prototype.toString.call(o).slice(8, -1);
 168    if (n === "Object" && o.constructor) n = o.constructor.name;
 169    if (n === "Map" || n === "Set") return Array.from(o);
 170    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 171  }
 172  
 173  /***/ }),
 174  
 175  /***/ 37:
 176  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 177  
 178  "use strict";
 179  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
 180  function _iterableToArray(iter) {
 181    if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
 182  }
 183  
 184  /***/ }),
 185  
 186  /***/ 467:
 187  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 188  
 189  "use strict";
 190  // ESM COMPAT FLAG
 191  __webpack_require__.r(__webpack_exports__);
 192  
 193  // EXPORTS
 194  __webpack_require__.d(__webpack_exports__, "createHooks", function() { return /* reexport */ build_module_createHooks; });
 195  __webpack_require__.d(__webpack_exports__, "addAction", function() { return /* binding */ addAction; });
 196  __webpack_require__.d(__webpack_exports__, "addFilter", function() { return /* binding */ addFilter; });
 197  __webpack_require__.d(__webpack_exports__, "removeAction", function() { return /* binding */ removeAction; });
 198  __webpack_require__.d(__webpack_exports__, "removeFilter", function() { return /* binding */ removeFilter; });
 199  __webpack_require__.d(__webpack_exports__, "hasAction", function() { return /* binding */ hasAction; });
 200  __webpack_require__.d(__webpack_exports__, "hasFilter", function() { return /* binding */ hasFilter; });
 201  __webpack_require__.d(__webpack_exports__, "removeAllActions", function() { return /* binding */ removeAllActions; });
 202  __webpack_require__.d(__webpack_exports__, "removeAllFilters", function() { return /* binding */ removeAllFilters; });
 203  __webpack_require__.d(__webpack_exports__, "doAction", function() { return /* binding */ doAction; });
 204  __webpack_require__.d(__webpack_exports__, "applyFilters", function() { return /* binding */ applyFilters; });
 205  __webpack_require__.d(__webpack_exports__, "currentAction", function() { return /* binding */ currentAction; });
 206  __webpack_require__.d(__webpack_exports__, "currentFilter", function() { return /* binding */ currentFilter; });
 207  __webpack_require__.d(__webpack_exports__, "doingAction", function() { return /* binding */ doingAction; });
 208  __webpack_require__.d(__webpack_exports__, "doingFilter", function() { return /* binding */ doingFilter; });
 209  __webpack_require__.d(__webpack_exports__, "didAction", function() { return /* binding */ didAction; });
 210  __webpack_require__.d(__webpack_exports__, "didFilter", function() { return /* binding */ didFilter; });
 211  __webpack_require__.d(__webpack_exports__, "actions", function() { return /* binding */ actions; });
 212  __webpack_require__.d(__webpack_exports__, "filters", function() { return /* binding */ filters; });
 213  
 214  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
 215  var classCallCheck = __webpack_require__(25);
 216  
 217  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateNamespace.js
 218  /**
 219   * Validate a namespace string.
 220   *
 221   * @param  {string} namespace The namespace to validate - should take the form
 222   *                            `vendor/plugin/function`.
 223   *
 224   * @return {boolean}             Whether the namespace is valid.
 225   */
 226  function validateNamespace(namespace) {
 227    if ('string' !== typeof namespace || '' === namespace) {
 228      // eslint-disable-next-line no-console
 229      console.error('The namespace must be a non-empty string.');
 230      return false;
 231    }
 232  
 233    if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
 234      // eslint-disable-next-line no-console
 235      console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.');
 236      return false;
 237    }
 238  
 239    return true;
 240  }
 241  
 242  /* harmony default export */ var build_module_validateNamespace = (validateNamespace);
 243  
 244  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateHookName.js
 245  /**
 246   * Validate a hookName string.
 247   *
 248   * @param  {string} hookName The hook name to validate. Should be a non empty string containing
 249   *                           only numbers, letters, dashes, periods and underscores. Also,
 250   *                           the hook name cannot begin with `__`.
 251   *
 252   * @return {boolean}            Whether the hook name is valid.
 253   */
 254  function validateHookName(hookName) {
 255    if ('string' !== typeof hookName || '' === hookName) {
 256      // eslint-disable-next-line no-console
 257      console.error('The hook name must be a non-empty string.');
 258      return false;
 259    }
 260  
 261    if (/^__/.test(hookName)) {
 262      // eslint-disable-next-line no-console
 263      console.error('The hook name cannot begin with `__`.');
 264      return false;
 265    }
 266  
 267    if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
 268      // eslint-disable-next-line no-console
 269      console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.');
 270      return false;
 271    }
 272  
 273    return true;
 274  }
 275  
 276  /* harmony default export */ var build_module_validateHookName = (validateHookName);
 277  
 278  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createAddHook.js
 279  /**
 280   * Internal dependencies
 281   */
 282  
 283  
 284  /**
 285   * @callback AddHook
 286   *
 287   * Adds the hook to the appropriate hooks container.
 288   *
 289   * @param {string}               hookName  Name of hook to add
 290   * @param {string}               namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.
 291   * @param {import('.').Callback} callback  Function to call when the hook is run
 292   * @param {number}               [priority=10]  Priority of this hook
 293   */
 294  
 295  /**
 296   * Returns a function which, when invoked, will add a hook.
 297   *
 298   * @param  {import('.').Hooks}    hooks Hooks instance.
 299   * @param  {import('.').StoreKey} storeKey
 300   *
 301   * @return {AddHook} Function that adds a new hook.
 302   */
 303  
 304  function createAddHook(hooks, storeKey) {
 305    return function addHook(hookName, namespace, callback) {
 306      var priority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
 307      var hooksStore = hooks[storeKey];
 308  
 309      if (!build_module_validateHookName(hookName)) {
 310        return;
 311      }
 312  
 313      if (!build_module_validateNamespace(namespace)) {
 314        return;
 315      }
 316  
 317      if ('function' !== typeof callback) {
 318        // eslint-disable-next-line no-console
 319        console.error('The hook callback must be a function.');
 320        return;
 321      } // Validate numeric priority
 322  
 323  
 324      if ('number' !== typeof priority) {
 325        // eslint-disable-next-line no-console
 326        console.error('If specified, the hook priority must be a number.');
 327        return;
 328      }
 329  
 330      var handler = {
 331        callback: callback,
 332        priority: priority,
 333        namespace: namespace
 334      };
 335  
 336      if (hooksStore[hookName]) {
 337        // Find the correct insert index of the new hook.
 338        var handlers = hooksStore[hookName].handlers;
 339        /** @type {number} */
 340  
 341        var i;
 342  
 343        for (i = handlers.length; i > 0; i--) {
 344          if (priority >= handlers[i - 1].priority) {
 345            break;
 346          }
 347        }
 348  
 349        if (i === handlers.length) {
 350          // If append, operate via direct assignment.
 351          handlers[i] = handler;
 352        } else {
 353          // Otherwise, insert before index via splice.
 354          handlers.splice(i, 0, handler);
 355        } // We may also be currently executing this hook.  If the callback
 356        // we're adding would come after the current callback, there's no
 357        // problem; otherwise we need to increase the execution index of
 358        // any other runs by 1 to account for the added element.
 359  
 360  
 361        hooksStore.__current.forEach(function (hookInfo) {
 362          if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
 363            hookInfo.currentIndex++;
 364          }
 365        });
 366      } else {
 367        // This is the first hook of its type.
 368        hooksStore[hookName] = {
 369          handlers: [handler],
 370          runs: 0
 371        };
 372      }
 373  
 374      if (hookName !== 'hookAdded') {
 375        hooks.doAction('hookAdded', hookName, namespace, callback, priority);
 376      }
 377    };
 378  }
 379  
 380  /* harmony default export */ var build_module_createAddHook = (createAddHook);
 381  
 382  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRemoveHook.js
 383  /**
 384   * Internal dependencies
 385   */
 386  
 387  
 388  /**
 389   * @callback RemoveHook
 390   * Removes the specified callback (or all callbacks) from the hook with a given hookName
 391   * and namespace.
 392   *
 393   * @param {string} hookName  The name of the hook to modify.
 394   * @param {string} namespace The unique namespace identifying the callback in the
 395   *                           form `vendor/plugin/function`.
 396   *
 397   * @return {number | undefined} The number of callbacks removed.
 398   */
 399  
 400  /**
 401   * Returns a function which, when invoked, will remove a specified hook or all
 402   * hooks by the given name.
 403   *
 404   * @param  {import('.').Hooks}    hooks Hooks instance.
 405   * @param  {import('.').StoreKey} storeKey
 406   * @param  {boolean}              [removeAll=false] Whether to remove all callbacks for a hookName,
 407   *                                                  without regard to namespace. Used to create
 408   *                                                  `removeAll*` functions.
 409   *
 410   * @return {RemoveHook} Function that removes hooks.
 411   */
 412  
 413  function createRemoveHook(hooks, storeKey) {
 414    var removeAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
 415    return function removeHook(hookName, namespace) {
 416      var hooksStore = hooks[storeKey];
 417  
 418      if (!build_module_validateHookName(hookName)) {
 419        return;
 420      }
 421  
 422      if (!removeAll && !build_module_validateNamespace(namespace)) {
 423        return;
 424      } // Bail if no hooks exist by this name
 425  
 426  
 427      if (!hooksStore[hookName]) {
 428        return 0;
 429      }
 430  
 431      var handlersRemoved = 0;
 432  
 433      if (removeAll) {
 434        handlersRemoved = hooksStore[hookName].handlers.length;
 435        hooksStore[hookName] = {
 436          runs: hooksStore[hookName].runs,
 437          handlers: []
 438        };
 439      } else {
 440        // Try to find the specified callback to remove.
 441        var handlers = hooksStore[hookName].handlers;
 442  
 443        var _loop = function _loop(i) {
 444          if (handlers[i].namespace === namespace) {
 445            handlers.splice(i, 1);
 446            handlersRemoved++; // This callback may also be part of a hook that is
 447            // currently executing.  If the callback we're removing
 448            // comes after the current callback, there's no problem;
 449            // otherwise we need to decrease the execution index of any
 450            // other runs by 1 to account for the removed element.
 451  
 452            hooksStore.__current.forEach(function (hookInfo) {
 453              if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
 454                hookInfo.currentIndex--;
 455              }
 456            });
 457          }
 458        };
 459  
 460        for (var i = handlers.length - 1; i >= 0; i--) {
 461          _loop(i);
 462        }
 463      }
 464  
 465      if (hookName !== 'hookRemoved') {
 466        hooks.doAction('hookRemoved', hookName, namespace);
 467      }
 468  
 469      return handlersRemoved;
 470    };
 471  }
 472  
 473  /* harmony default export */ var build_module_createRemoveHook = (createRemoveHook);
 474  
 475  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHasHook.js
 476  /**
 477   * @callback HasHook
 478   *
 479   * Returns whether any handlers are attached for the given hookName and optional namespace.
 480   *
 481   * @param {string} hookName    The name of the hook to check for.
 482   * @param {string} [namespace] Optional. The unique namespace identifying the callback
 483   *                             in the form `vendor/plugin/function`.
 484   *
 485   * @return {boolean} Whether there are handlers that are attached to the given hook.
 486   */
 487  
 488  /**
 489   * Returns a function which, when invoked, will return whether any handlers are
 490   * attached to a particular hook.
 491   *
 492   * @param  {import('.').Hooks}    hooks Hooks instance.
 493   * @param  {import('.').StoreKey} storeKey
 494   *
 495   * @return {HasHook} Function that returns whether any handlers are
 496   *                   attached to a particular hook and optional namespace.
 497   */
 498  function createHasHook(hooks, storeKey) {
 499    return function hasHook(hookName, namespace) {
 500      var hooksStore = hooks[storeKey]; // Use the namespace if provided.
 501  
 502      if ('undefined' !== typeof namespace) {
 503        return hookName in hooksStore && hooksStore[hookName].handlers.some(function (hook) {
 504          return hook.namespace === namespace;
 505        });
 506      }
 507  
 508      return hookName in hooksStore;
 509    };
 510  }
 511  
 512  /* harmony default export */ var build_module_createHasHook = (createHasHook);
 513  
 514  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
 515  var toConsumableArray = __webpack_require__(15);
 516  
 517  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRunHook.js
 518  
 519  
 520  /**
 521   * Returns a function which, when invoked, will execute all callbacks
 522   * registered to a hook of the specified type, optionally returning the final
 523   * value of the call chain.
 524   *
 525   * @param  {import('.').Hooks}    hooks Hooks instance.
 526   * @param  {import('.').StoreKey} storeKey
 527   * @param  {boolean}              [returnFirstArg=false] Whether each hook callback is expected to
 528   *                                                       return its first argument.
 529   *
 530   * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks.
 531   */
 532  function createRunHook(hooks, storeKey) {
 533    var returnFirstArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
 534    return function runHooks(hookName) {
 535      var hooksStore = hooks[storeKey];
 536  
 537      if (!hooksStore[hookName]) {
 538        hooksStore[hookName] = {
 539          handlers: [],
 540          runs: 0
 541        };
 542      }
 543  
 544      hooksStore[hookName].runs++;
 545      var handlers = hooksStore[hookName].handlers; // The following code is stripped from production builds.
 546  
 547      if (false) {}
 548  
 549      for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
 550        args[_key - 1] = arguments[_key];
 551      }
 552  
 553      if (!handlers || !handlers.length) {
 554        return returnFirstArg ? args[0] : undefined;
 555      }
 556  
 557      var hookInfo = {
 558        name: hookName,
 559        currentIndex: 0
 560      };
 561  
 562      hooksStore.__current.push(hookInfo);
 563  
 564      while (hookInfo.currentIndex < handlers.length) {
 565        var handler = handlers[hookInfo.currentIndex];
 566        var result = handler.callback.apply(null, args);
 567  
 568        if (returnFirstArg) {
 569          args[0] = result;
 570        }
 571  
 572        hookInfo.currentIndex++;
 573      }
 574  
 575      hooksStore.__current.pop();
 576  
 577      if (returnFirstArg) {
 578        return args[0];
 579      }
 580    };
 581  }
 582  
 583  /* harmony default export */ var build_module_createRunHook = (createRunHook);
 584  
 585  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js
 586  /**
 587   * Returns a function which, when invoked, will return the name of the
 588   * currently running hook, or `null` if no hook of the given type is currently
 589   * running.
 590   *
 591   * @param  {import('.').Hooks}    hooks Hooks instance.
 592   * @param  {import('.').StoreKey} storeKey
 593   *
 594   * @return {() => string | null} Function that returns the current hook name or null.
 595   */
 596  function createCurrentHook(hooks, storeKey) {
 597    return function currentHook() {
 598      var _hooksStore$__current, _hooksStore$__current2;
 599  
 600      var hooksStore = hooks[storeKey];
 601      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;
 602    };
 603  }
 604  
 605  /* harmony default export */ var build_module_createCurrentHook = (createCurrentHook);
 606  
 607  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDoingHook.js
 608  /**
 609   * @callback DoingHook
 610   * Returns whether a hook is currently being executed.
 611   *
 612   * @param  {string} [hookName] The name of the hook to check for.  If
 613   *                             omitted, will check for any hook being executed.
 614   *
 615   * @return {boolean} Whether the hook is being executed.
 616   */
 617  
 618  /**
 619   * Returns a function which, when invoked, will return whether a hook is
 620   * currently being executed.
 621   *
 622   * @param  {import('.').Hooks}    hooks Hooks instance.
 623   * @param  {import('.').StoreKey} storeKey
 624   *
 625   * @return {DoingHook} Function that returns whether a hook is currently
 626   *                     being executed.
 627   */
 628  function createDoingHook(hooks, storeKey) {
 629    return function doingHook(hookName) {
 630      var hooksStore = hooks[storeKey]; // If the hookName was not passed, check for any current hook.
 631  
 632      if ('undefined' === typeof hookName) {
 633        return 'undefined' !== typeof hooksStore.__current[0];
 634      } // Return the __current hook.
 635  
 636  
 637      return hooksStore.__current[0] ? hookName === hooksStore.__current[0].name : false;
 638    };
 639  }
 640  
 641  /* harmony default export */ var build_module_createDoingHook = (createDoingHook);
 642  
 643  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDidHook.js
 644  /**
 645   * Internal dependencies
 646   */
 647  
 648  /**
 649   * @callback DidHook
 650   *
 651   * Returns the number of times an action has been fired.
 652   *
 653   * @param  {string} hookName The hook name to check.
 654   *
 655   * @return {number | undefined} The number of times the hook has run.
 656   */
 657  
 658  /**
 659   * Returns a function which, when invoked, will return the number of times a
 660   * hook has been called.
 661   *
 662   * @param  {import('.').Hooks}    hooks Hooks instance.
 663   * @param  {import('.').StoreKey} storeKey
 664   *
 665   * @return {DidHook} Function that returns a hook's call count.
 666   */
 667  
 668  function createDidHook(hooks, storeKey) {
 669    return function didHook(hookName) {
 670      var hooksStore = hooks[storeKey];
 671  
 672      if (!build_module_validateHookName(hookName)) {
 673        return;
 674      }
 675  
 676      return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
 677    };
 678  }
 679  
 680  /* harmony default export */ var build_module_createDidHook = (createDidHook);
 681  
 682  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHooks.js
 683  
 684  
 685  /**
 686   * Internal dependencies
 687   */
 688  
 689  
 690  
 691  
 692  
 693  
 694  
 695  /**
 696   * Internal class for constructing hooks. Use `createHooks()` function
 697   *
 698   * Note, it is necessary to expose this class to make its type public.
 699   *
 700   * @private
 701   */
 702  
 703  var createHooks_Hooks = function _Hooks() {
 704    Object(classCallCheck["a" /* default */])(this, _Hooks);
 705  
 706    /** @type {import('.').Store} actions */
 707    this.actions = Object.create(null);
 708    this.actions.__current = [];
 709    /** @type {import('.').Store} filters */
 710  
 711    this.filters = Object.create(null);
 712    this.filters.__current = [];
 713    this.addAction = build_module_createAddHook(this, 'actions');
 714    this.addFilter = build_module_createAddHook(this, 'filters');
 715    this.removeAction = build_module_createRemoveHook(this, 'actions');
 716    this.removeFilter = build_module_createRemoveHook(this, 'filters');
 717    this.hasAction = build_module_createHasHook(this, 'actions');
 718    this.hasFilter = build_module_createHasHook(this, 'filters');
 719    this.removeAllActions = build_module_createRemoveHook(this, 'actions', true);
 720    this.removeAllFilters = build_module_createRemoveHook(this, 'filters', true);
 721    this.doAction = build_module_createRunHook(this, 'actions');
 722    this.applyFilters = build_module_createRunHook(this, 'filters', true);
 723    this.currentAction = build_module_createCurrentHook(this, 'actions');
 724    this.currentFilter = build_module_createCurrentHook(this, 'filters');
 725    this.doingAction = build_module_createDoingHook(this, 'actions');
 726    this.doingFilter = build_module_createDoingHook(this, 'filters');
 727    this.didAction = build_module_createDidHook(this, 'actions');
 728    this.didFilter = build_module_createDidHook(this, 'filters');
 729  };
 730  /** @typedef {_Hooks} Hooks */
 731  
 732  /**
 733   * Returns an instance of the hooks object.
 734   *
 735   * @return {Hooks} A Hooks instance.
 736   */
 737  
 738  function createHooks() {
 739    return new createHooks_Hooks();
 740  }
 741  
 742  /* harmony default export */ var build_module_createHooks = (createHooks);
 743  
 744  // CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/index.js
 745  /**
 746   * Internal dependencies
 747   */
 748  
 749  /** @typedef {(...args: any[])=>any} Callback */
 750  
 751  /**
 752   * @typedef Handler
 753   * @property {Callback} callback  The callback
 754   * @property {string}   namespace The namespace
 755   * @property {number}   priority  The namespace
 756   */
 757  
 758  /**
 759   * @typedef Hook
 760   * @property {Handler[]} handlers Array of handlers
 761   * @property {number}    runs     Run counter
 762   */
 763  
 764  /**
 765   * @typedef Current
 766   * @property {string} name         Hook name
 767   * @property {number} currentIndex The index
 768   */
 769  
 770  /**
 771   * @typedef {Record<string, Hook> & {__current: Current[]}} Store
 772   */
 773  
 774  /**
 775   * @typedef {'actions' | 'filters'} StoreKey
 776   */
 777  
 778  /**
 779   * @typedef {import('./createHooks').Hooks} Hooks
 780   */
 781  
 782  var _createHooks = build_module_createHooks(),
 783      addAction = _createHooks.addAction,
 784      addFilter = _createHooks.addFilter,
 785      removeAction = _createHooks.removeAction,
 786      removeFilter = _createHooks.removeFilter,
 787      hasAction = _createHooks.hasAction,
 788      hasFilter = _createHooks.hasFilter,
 789      removeAllActions = _createHooks.removeAllActions,
 790      removeAllFilters = _createHooks.removeAllFilters,
 791      doAction = _createHooks.doAction,
 792      applyFilters = _createHooks.applyFilters,
 793      currentAction = _createHooks.currentAction,
 794      currentFilter = _createHooks.currentFilter,
 795      doingAction = _createHooks.doingAction,
 796      doingFilter = _createHooks.doingFilter,
 797      didAction = _createHooks.didAction,
 798      didFilter = _createHooks.didFilter,
 799      actions = _createHooks.actions,
 800      filters = _createHooks.filters;
 801  
 802  
 803  
 804  
 805  /***/ })
 806  
 807  /******/ });


Generated: Sat Mar 6 01:00:04 2021 Cross-referenced by PHPXref 0.7.1