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