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