vendor: 3,749 bytes, lines 1-93
1this["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 = "gEOj"); 86/******/ }) 87/************************************************************************/ 88/******/ ({ 89 90/***/ "gEOj": 91/***/ (function(module, __webpack_exports__, __webpack_require__) { 92 93"use strict";
94// ESM COMPAT FLAG 95__webpack_require__.r(__webpack_exports__); 96 97// EXPORTS 98__webpack_require__.d(__webpack_exports__, "defaultHooks", function() { return /* binding */ defaultHooks; }); 99__webpack_require__.d(__webpack_exports__, "createHooks", function() { return /* reexport */ build_module_createHooks; }); 100__webpack_require__.d(__webpack_exports__, "addAction", function() { return /* binding */ addAction; }); 101__webpack_require__.d(__webpack_exports__, "addFilter", function() { return /* binding */ addFilter; }); 102__webpack_require__.d(__webpack_exports__, "removeAction", function() { return /* binding */ removeAction; }); 103__webpack_require__.d(__webpack_exports__, "removeFilter", function() { return /* binding */ removeFilter; }); 104__webpack_require__.d(__webpack_exports__, "hasAction", function() { return /* binding */ hasAction; }); 105__webpack_require__.d(__webpack_exports__, "hasFilter", function() { return /* binding */ hasFilter; }); 106__webpack_require__.d(__webpack_exports__, "removeAllActions", function() { return /* binding */ removeAllActions; }); 107__webpack_require__.d(__webpack_exports__, "removeAllFilters", function() { return /* binding */ removeAllFilters; }); 108__webpack_require__.d(__webpack_exports__, "doAction", function() { return /* binding */ doAction; }); 109__webpack_require__.d(__webpack_exports__, "applyFilters", function() { return /* binding */ applyFilters; }); 110__webpack_require__.d(__webpack_exports__, "currentAction", function() { return /* binding */ currentAction; }); 111__webpack_require__.d(__webpack_exports__, "currentFilter", function() { return /* binding */ currentFilter; }); 112__webpack_require__.d(__webpack_exports__, "doingAction", function() { return /* binding */ doingAction; }); 113__webpack_require__.d(__webpack_exports__, "doingFilter", function() { return /* binding */ doingFilter; }); 114__webpack_require__.d(__webpack_exports__, "didAction", function() { return /* binding */ didAction; }); 115__webpack_require__.d(__webpack_exports__, "didFilter", function() { return /* binding */ didFilter; }); 116__webpack_require__.d(__webpack_exports__, "actions", function() { return /* binding */ actions; }); 117__webpack_require__.d(__webpack_exports__, "filters", function() { return /* binding */ filters; }); 118 119// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateNamespace.js 120/** 121 * Validate a namespace string. 122 * 123 * @param {string} namespace The namespace to validate - should take the form 124 * `vendor/plugin/function`. 125 * 126 * @return {boolean} Whether the namespace is valid. 127 */ 128function validateNamespace(namespace) { 129 if ('string' !== typeof namespace || '' === namespace) { 130 // eslint-disable-next-line no-console 131 console.error('The namespace must be a non-empty string.'); 132 return false; 133 } 134 135 if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) { 136 // eslint-disable-next-line no-console 137 console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.'); 138 return false; 139 } 140 141 return true; 142} 143 144/* harmony default export */ var build_module_validateNamespace = (validateNamespace); 145 146// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateHookName.js 147/** 148 * Validate a hookName string. 149 * 150 * @param {string} hookName The hook name to validate. Should be a non empty string containing 151 * only numbers, letters, dashes, periods and underscores. Also, 152 * the hook name cannot begin with `__`. 153 * 154 * @return {boolean} Whether the hook name is valid. 155 */ 156function validateHookName(hookName) { 157 if ('string' !== typeof hookName || '' === hookName) { 158 // eslint-disable-next-line no-console 159 console.error('The hook name must be a non-empty string.'); 160 return false; 161 } 162 163 if (/^__/.test(hookName)) { 164 // eslint-disable-next-line no-console 165 console.error('The hook name cannot begin with `__`.'); 166 return false; 167 } 168 169 if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) { 170 // eslint-disable-next-line no-console 171 console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.'); 172 return false;
173 } 174 175 return true; 176} 177 178/* harmony default export */ var build_module_validateHookName = (validateHookName); 179 180// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createAddHook.js 181/** 182 * Internal dependencies 183 */ 184 185 186/** 187 * @callback AddHook 188 * 189 * Adds the hook to the appropriate hooks container. 190 * 191 * @param {string} hookName Name of hook to add 192 * @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`. 193 * @param {import('.').Callback} callback Function to call when the hook is run 194 * @param {number} [priority=10] Priority of this hook 195 */ 196 197/** 198 * Returns a function which, when invoked, will add a hook. 199 * 200 * @param {import('.').Hooks} hooks Hooks instance. 201 * @param {import('.').StoreKey} storeKey 202 * 203 * @return {AddHook} Function that adds a new hook. 204 */ 205 206function createAddHook(hooks, storeKey) { 207 return function addHook(hookName, namespace, callback) { 208 let priority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10; 209 const hooksStore = hooks[storeKey]; 210 211 if (!build_module_validateHookName(hookName)) { 212 return; 213 } 214 215 if (!build_module_validateNamespace(namespace)) { 216 return; 217 } 218 219 if ('function' !== typeof callback) { 220 // eslint-disable-next-line no-console 221 console.error('The hook callback must be a function.'); 222 return; 223 } // Validate numeric priority 224 225 226 if ('number' !== typeof priority) { 227 // eslint-disable-next-line no-console 228 console.error('If specified, the hook priority must be a number.'); 229 return; 230 } 231 232 const handler = { 233 callback, 234 priority, 235 namespace 236 }; 237 238 if (hooksStore[hookName]) { 239 // Find the correct insert index of the new hook. 240 const handlers = hooksStore[hookName].handlers; 241 /** @type {number} */ 242 243 let i; 244 245 for (i = handlers.length; i > 0; i--) { 246 if (priority >= handlers[i - 1].priority) { 247 break; 248 } 249 } 250 251 if (i === handlers.length) { 252 // If append, operate via direct assignment. 253 handlers[i] = handler; 254 } else { 255 // Otherwise, insert before index via splice. 256 handlers.splice(i, 0, handler); 257 } // We may also be currently executing this hook. If the callback 258 // we're adding would come after the current callback, there's no 259 // problem; otherwise we need to increase the execution index of 260 // any other runs by 1 to account for the added element. 261 262 263 hooksStore.__current.forEach(hookInfo => { 264 if (hookInfo.name === hookName && hookInfo.currentIndex >= i) { 265 hookInfo.currentIndex++; 266 } 267 }); 268 } else { 269 // This is the first hook of its type. 270 hooksStore[hookName] = { 271 handlers: [handler], 272 runs: 0 273 }; 274 } 275 276 if (hookName !== 'hookAdded') { 277 hooks.doAction('hookAdded', hookName, namespace, callback, priority); 278 } 279 }; 280} 281 282/* harmony default export */ var build_module_createAddHook = (createAddHook); 283 284// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRemoveHook.js 285/** 286 * Internal dependencies 287 */ 288 289 290/** 291 * @callback RemoveHook 292 * Removes the specified callback (or all callbacks) from the hook with a given hookName 293 * and namespace. 294 * 295 * @param {string} hookName The name of the hook to modify. 296 * @param {string} namespace The unique namespace identifying the callback in the 297 * form `vendor/plugin/function`. 298 * 299 * @return {number | undefined} The number of callbacks removed. 300 */ 301 302/** 303 * Returns a function which, when invoked, will remove a specified hook or all 304 * hooks by the given name. 305 * 306 * @param {import('.').Hooks} hooks Hooks instance. 307 * @param {import('.').StoreKey} storeKey 308 * @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName, 309 * without regard to namespace. Used to create 310 * `removeAll*` functions. 311 * 312 * @return {RemoveHook} Function that removes hooks. 313 */ 314 315function createRemoveHook(hooks, storeKey) { 316 let removeAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
317 return function removeHook(hookName, namespace) { 318 const hooksStore = hooks[storeKey]; 319 320 if (!build_module_validateHookName(hookName)) { 321 return; 322 } 323 324 if (!removeAll && !build_module_validateNamespace(namespace)) { 325 return; 326 } // Bail if no hooks exist by this name 327 328 329 if (!hooksStore[hookName]) { 330 return 0; 331 } 332 333 let handlersRemoved = 0; 334 335 if (removeAll) { 336 handlersRemoved = hooksStore[hookName].handlers.length; 337 hooksStore[hookName] = { 338 runs: hooksStore[hookName].runs, 339 handlers: [] 340 }; 341 } else { 342 // Try to find the specified callback to remove. 343 const handlers = hooksStore[hookName].handlers; 344 345 for (let i = handlers.length - 1; i >= 0; i--) { 346 if (handlers[i].namespace === namespace) { 347 handlers.splice(i, 1); 348 handlersRemoved++; // This callback may also be part of a hook that is 349 // currently executing. If the callback we're removing 350 // comes after the current callback, there's no problem; 351 // otherwise we need to decrease the execution index of any 352 // other runs by 1 to account for the removed element. 353 354 hooksStore.__current.forEach(hookInfo => { 355 if (hookInfo.name === hookName && hookInfo.currentIndex >= i) { 356 hookInfo.currentIndex--; 357 } 358 }); 359 } 360 } 361 } 362 363 if (hookName !== 'hookRemoved') { 364 hooks.doAction('hookRemoved', hookName, namespace); 365 } 366 367 return handlersRemoved; 368 }; 369} 370 371/* harmony default export */ var build_module_createRemoveHook = (createRemoveHook); 372 373// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHasHook.js 374/** 375 * @callback HasHook 376 * 377 * Returns whether any handlers are attached for the given hookName and optional namespace. 378 * 379 * @param {string} hookName The name of the hook to check for. 380 * @param {string} [namespace] Optional. The unique namespace identifying the callback 381 * in the form `vendor/plugin/function`. 382 * 383 * @return {boolean} Whether there are handlers that are attached to the given hook. 384 */ 385 386/** 387 * Returns a function which, when invoked, will return whether any handlers are 388 * attached to a particular hook. 389 * 390 * @param {import('.').Hooks} hooks Hooks instance. 391 * @param {import('.').StoreKey} storeKey 392 * 393 * @return {HasHook} Function that returns whether any handlers are 394 * attached to a particular hook and optional namespace. 395 */ 396function createHasHook(hooks, storeKey) { 397 return function hasHook(hookName, namespace) { 398 const hooksStore = hooks[storeKey]; // Use the namespace if provided. 399 400 if ('undefined' !== typeof namespace) { 401 return hookName in hooksStore && hooksStore[hookName].handlers.some(hook => hook.namespace === namespace); 402 } 403 404 return hookName in hooksStore; 405 }; 406} 407 408/* harmony default export */ var build_module_createHasHook = (createHasHook); 409 410// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRunHook.js 411/** 412 * Returns a function which, when invoked, will execute all callbacks 413 * registered to a hook of the specified type, optionally returning the final 414 * value of the call chain. 415 * 416 * @param {import('.').Hooks} hooks Hooks instance. 417 * @param {import('.').StoreKey} storeKey 418 * @param {boolean} [returnFirstArg=false] Whether each hook callback is expected to 419 * return its first argument. 420 * 421 * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks. 422 */ 423function createRunHook(hooks, storeKey) { 424 let returnFirstArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 425 return function runHooks(hookName) { 426 const hooksStore = hooks[storeKey]; 427 428 if (!hooksStore[hookName]) { 429 hooksStore[hookName] = { 430 handlers: [], 431 runs: 0 432 }; 433 } 434 435 hooksStore[hookName].runs++; 436 const handlers = hooksStore[hookName].handlers; // The following code is stripped from production builds. 437 438 if (false) {} 439 440 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 441 args[_key - 1] = arguments[_key]; 442 } 443 444 if (!handlers || !handlers.length) { 445 return returnFirstArg ? args[0] : undefined; 446 } 447 448 const hookInfo = { 449 name: hookName, 450 currentIndex: 0 451 }; 452 453 hooksStore.__current.push(hookInfo); 454 455 while (hookInfo.currentIndex < handlers.length) { 456 const handler = handlers[hookInfo.currentIndex];
457 const result = handler.callback.apply(null, args); 458 459 if (returnFirstArg) { 460 args[0] = result; 461 } 462 463 hookInfo.currentIndex++; 464 } 465 466 hooksStore.__current.pop(); 467 468 if (returnFirstArg) { 469 return args[0]; 470 } 471 }; 472} 473 474/* harmony default export */ var build_module_createRunHook = (createRunHook); 475 476// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js 477/** 478 * Returns a function which, when invoked, will return the name of the 479 * currently running hook, or `null` if no hook of the given type is currently 480 * running. 481 * 482 * @param {import('.').Hooks} hooks Hooks instance. 483 * @param {import('.').StoreKey} storeKey 484 * 485 * @return {() => string | null} Function that returns the current hook name or null. 486 */ 487function createCurrentHook(hooks, storeKey) { 488 return function currentHook() { 489 var _hooksStore$__current, _hooksStore$__current2; 490 491 const hooksStore = hooks[storeKey]; 492 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; 493 }; 494} 495 496/* harmony default export */ var build_module_createCurrentHook = (createCurrentHook); 497 498// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDoingHook.js 499/** 500 * @callback DoingHook 501 * Returns whether a hook is currently being executed. 502 * 503 * @param {string} [hookName] The name of the hook to check for. If 504 * omitted, will check for any hook being executed. 505 * 506 * @return {boolean} Whether the hook is being executed. 507 */ 508 509/** 510 * Returns a function which, when invoked, will return whether a hook is 511 * currently being executed. 512 * 513 * @param {import('.').Hooks} hooks Hooks instance. 514 * @param {import('.').StoreKey} storeKey 515 * 516 * @return {DoingHook} Function that returns whether a hook is currently 517 * being executed. 518 */ 519function createDoingHook(hooks, storeKey) { 520 return function doingHook(hookName) { 521 const hooksStore = hooks[storeKey]; // If the hookName was not passed, check for any current hook. 522 523 if ('undefined' === typeof hookName) { 524 return 'undefined' !== typeof hooksStore.__current[0]; 525 } // Return the __current hook. 526 527 528 return hooksStore.__current[0] ? hookName === hooksStore.__current[0].name : false; 529 }; 530} 531 532/* harmony default export */ var build_module_createDoingHook = (createDoingHook); 533 534// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDidHook.js 535/** 536 * Internal dependencies 537 */ 538 539/** 540 * @callback DidHook 541 * 542 * Returns the number of times an action has been fired. 543 * 544 * @param {string} hookName The hook name to check. 545 * 546 * @return {number | undefined} The number of times the hook has run. 547 */ 548 549/** 550 * Returns a function which, when invoked, will return the number of times a 551 * hook has been called. 552 * 553 * @param {import('.').Hooks} hooks Hooks instance. 554 * @param {import('.').StoreKey} storeKey 555 * 556 * @return {DidHook} Function that returns a hook's call count. 557 */ 558 559function createDidHook(hooks, storeKey) { 560 return function didHook(hookName) { 561 const hooksStore = hooks[storeKey]; 562 563 if (!build_module_validateHookName(hookName)) { 564 return; 565 } 566 567 return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0; 568 }; 569} 570 571/* harmony default export */ var build_module_createDidHook = (createDidHook); 572 573// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHooks.js 574/** 575 * Internal dependencies 576 */ 577 578 579 580 581 582 583 584/** 585 * Internal class for constructing hooks. Use `createHooks()` function 586 * 587 * Note, it is necessary to expose this class to make its type public. 588 * 589 * @private 590 */ 591 592class createHooks_Hooks { 593 constructor() { 594 /** @type {import('.').Store} actions */ 595 this.actions = Object.create(null); 596 this.actions.__current = []; 597 /** @type {import('.').Store} filters */ 598 599 this.filters = Object.create(null); 600 this.filters.__current = []; 601 this.addAction = build_module_createAddHook(this, 'actions'); 602 this.addFilter = build_module_createAddHook(this, 'filters'); 603 this.removeAction = build_module_createRemoveHook(this, 'actions'); 604 this.removeFilter = build_module_createRemoveHook(this, 'filters'); 605 this.hasAction = build_module_createHasHook(this, 'actions'); 606 this.hasFilter = build_module_createHasHook(this, 'filters'); 607 this.removeAllActions = build_module_createRemoveHook(this, 'actions', true); 608 this.removeAllFilters = build_module_createRemoveHook(this, 'filters', true);
609 this.doAction = build_module_createRunHook(this, 'actions'); 610 this.applyFilters = build_module_createRunHook(this, 'filters', true); 611 this.currentAction = build_module_createCurrentHook(this, 'actions'); 612 this.currentFilter = build_module_createCurrentHook(this, 'filters'); 613 this.doingAction = build_module_createDoingHook(this, 'actions'); 614 this.doingFilter = build_module_createDoingHook(this, 'filters'); 615 this.didAction = build_module_createDidHook(this, 'actions'); 616 this.didFilter = build_module_createDidHook(this, 'filters'); 617 } 618 619} 620/** @typedef {_Hooks} Hooks */ 621 622/** 623 * Returns an instance of the hooks object. 624 * 625 * @return {Hooks} A Hooks instance. 626 */ 627 628function createHooks() { 629 return new createHooks_Hooks(); 630} 631 632/* harmony default export */ var build_module_createHooks = (createHooks); 633 634// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/index.js 635/** 636 * Internal dependencies 637 */ 638 639/** @typedef {(...args: any[])=>any} Callback */ 640 641/** 642 * @typedef Handler 643 * @property {Callback} callback The callback 644 * @property {string} namespace The namespace 645 * @property {number} priority The namespace 646 */ 647 648/** 649 * @typedef Hook 650 * @property {Handler[]} handlers Array of handlers 651 * @property {number} runs Run counter 652 */ 653 654/** 655 * @typedef Current 656 * @property {string} name Hook name 657 * @property {number} currentIndex The index 658 */ 659 660/** 661 * @typedef {Record<string, Hook> & {__current: Current[]}} Store 662 */ 663 664/** 665 * @typedef {'actions' | 'filters'} StoreKey 666 */ 667 668/** 669 * @typedef {import('./createHooks').Hooks} Hooks 670 */ 671 672const defaultHooks = build_module_createHooks(); 673const { 674 addAction, 675 addFilter, 676 removeAction, 677 removeFilter, 678 hasAction, 679 hasFilter, 680 removeAllActions, 681 removeAllFilters, 682 doAction, 683 applyFilters, 684 currentAction, 685 currentFilter, 686 doingAction, 687 doingFilter, 688 didAction, 689 didFilter, 690 actions, 691 filters 692} = defaultHooks; 693 694 695 696/***/ }) 697 698/******/ });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.