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