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