fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

100
node_modules/@wordpress/hooks/build/createAddHook.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _validateNamespace = _interopRequireDefault(require("./validateNamespace.js"));
var _validateHookName = _interopRequireDefault(require("./validateHookName.js"));
/**
* Internal dependencies
*/
/**
* @callback AddHook
*
* Adds the hook to the appropriate hooks container.
*
* @param {string} hookName Name of hook to add
* @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.
* @param {import('.').Callback} callback Function to call when the hook is run
* @param {number} [priority=10] Priority of this hook
*/
/**
* Returns a function which, when invoked, will add a hook.
*
* @param {import('.').Hooks} hooks Hooks instance.
* @param {import('.').StoreKey} storeKey
*
* @return {AddHook} Function that adds a new hook.
*/
function createAddHook(hooks, storeKey) {
return function addHook(hookName, namespace, callback, priority = 10) {
const hooksStore = hooks[storeKey];
if (!(0, _validateHookName.default)(hookName)) {
return;
}
if (!(0, _validateNamespace.default)(namespace)) {
return;
}
if ('function' !== typeof callback) {
// eslint-disable-next-line no-console
console.error('The hook callback must be a function.');
return;
}
// Validate numeric priority
if ('number' !== typeof priority) {
// eslint-disable-next-line no-console
console.error('If specified, the hook priority must be a number.');
return;
}
const handler = {
callback,
priority,
namespace
};
if (hooksStore[hookName]) {
// Find the correct insert index of the new hook.
const handlers = hooksStore[hookName].handlers;
/** @type {number} */
let i;
for (i = handlers.length; i > 0; i--) {
if (priority >= handlers[i - 1].priority) {
break;
}
}
if (i === handlers.length) {
// If append, operate via direct assignment.
handlers[i] = handler;
} else {
// Otherwise, insert before index via splice.
handlers.splice(i, 0, handler);
}
// We may also be currently executing this hook. If the callback
// we're adding would come after the current callback, there's no
// problem; otherwise we need to increase the execution index of
// any other runs by 1 to account for the added element.
hooksStore.__current.forEach(hookInfo => {
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
hookInfo.currentIndex++;
}
});
} else {
// This is the first hook of its type.
hooksStore[hookName] = {
handlers: [handler],
runs: 0
};
}
if (hookName !== 'hookAdded') {
hooks.doAction('hookAdded', hookName, namespace, callback, priority);
}
};
}
var _default = exports.default = createAddHook;
//# sourceMappingURL=createAddHook.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* Returns a function which, when invoked, will return the name of the
* currently running hook, or `null` if no hook of the given type is currently
* running.
*
* @param {import('.').Hooks} hooks Hooks instance.
* @param {import('.').StoreKey} storeKey
*
* @return {() => string | null} Function that returns the current hook name or null.
*/
function createCurrentHook(hooks, storeKey) {
return function currentHook() {
var _hooksStore$__current;
const hooksStore = hooks[storeKey];
return (_hooksStore$__current = hooksStore.__current[hooksStore.__current.length - 1]?.name) !== null && _hooksStore$__current !== void 0 ? _hooksStore$__current : null;
};
}
var _default = exports.default = createCurrentHook;
//# sourceMappingURL=createCurrentHook.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createCurrentHook","hooks","storeKey","currentHook","_hooksStore$__current","hooksStore","__current","length","name","_default","exports","default"],"sources":["@wordpress/hooks/src/createCurrentHook.js"],"sourcesContent":["/**\n * Returns a function which, when invoked, will return the name of the\n * currently running hook, or `null` if no hook of the given type is currently\n * running.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n *\n * @return {() => string | null} Function that returns the current hook name or null.\n */\nfunction createCurrentHook( hooks, storeKey ) {\n\treturn function currentHook() {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\treturn (\n\t\t\thooksStore.__current[ hooksStore.__current.length - 1 ]?.name ??\n\t\t\tnull\n\t\t);\n\t};\n}\n\nexport default createCurrentHook;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAiBA,CAAEC,KAAK,EAAEC,QAAQ,EAAG;EAC7C,OAAO,SAASC,WAAWA,CAAA,EAAG;IAAA,IAAAC,qBAAA;IAC7B,MAAMC,UAAU,GAAGJ,KAAK,CAAEC,QAAQ,CAAE;IAEpC,QAAAE,qBAAA,GACCC,UAAU,CAACC,SAAS,CAAED,UAAU,CAACC,SAAS,CAACC,MAAM,GAAG,CAAC,CAAE,EAAEC,IAAI,cAAAJ,qBAAA,cAAAA,qBAAA,GAC7D,IAAI;EAEN,CAAC;AACF;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcX,iBAAiB","ignoreList":[]}

42
node_modules/@wordpress/hooks/build/createDidHook.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _validateHookName = _interopRequireDefault(require("./validateHookName.js"));
/**
* Internal dependencies
*/
/**
* @callback DidHook
*
* Returns the number of times an action has been fired.
*
* @param {string} hookName The hook name to check.
*
* @return {number | undefined} The number of times the hook has run.
*/
/**
* Returns a function which, when invoked, will return the number of times a
* hook has been called.
*
* @param {import('.').Hooks} hooks Hooks instance.
* @param {import('.').StoreKey} storeKey
*
* @return {DidHook} Function that returns a hook's call count.
*/
function createDidHook(hooks, storeKey) {
return function didHook(hookName) {
const hooksStore = hooks[storeKey];
if (!(0, _validateHookName.default)(hookName)) {
return;
}
return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
};
}
var _default = exports.default = createDidHook;
//# sourceMappingURL=createDidHook.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_validateHookName","_interopRequireDefault","require","createDidHook","hooks","storeKey","didHook","hookName","hooksStore","validateHookName","runs","_default","exports","default"],"sources":["@wordpress/hooks/src/createDidHook.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport validateHookName from './validateHookName.js';\n\n/**\n * @callback DidHook\n *\n * Returns the number of times an action has been fired.\n *\n * @param {string} hookName The hook name to check.\n *\n * @return {number | undefined} The number of times the hook has run.\n */\n\n/**\n * Returns a function which, when invoked, will return the number of times a\n * hook has been called.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n *\n * @return {DidHook} Function that returns a hook's call count.\n */\nfunction createDidHook( hooks, storeKey ) {\n\treturn function didHook( hookName ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! validateHookName( hookName ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn hooksStore[ hookName ] && hooksStore[ hookName ].runs\n\t\t\t? hooksStore[ hookName ].runs\n\t\t\t: 0;\n\t};\n}\n\nexport default createDidHook;\n"],"mappings":";;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAAEC,KAAK,EAAEC,QAAQ,EAAG;EACzC,OAAO,SAASC,OAAOA,CAAEC,QAAQ,EAAG;IACnC,MAAMC,UAAU,GAAGJ,KAAK,CAAEC,QAAQ,CAAE;IAEpC,IAAK,CAAE,IAAAI,yBAAgB,EAAEF,QAAS,CAAC,EAAG;MACrC;IACD;IAEA,OAAOC,UAAU,CAAED,QAAQ,CAAE,IAAIC,UAAU,CAAED,QAAQ,CAAE,CAACG,IAAI,GACzDF,UAAU,CAAED,QAAQ,CAAE,CAACG,IAAI,GAC3B,CAAC;EACL,CAAC;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcV,aAAa","ignoreList":[]}

41
node_modules/@wordpress/hooks/build/createDoingHook.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* @callback DoingHook
* Returns whether a hook is currently being executed.
*
* @param {string} [hookName] The name of the hook to check for. If
* omitted, will check for any hook being executed.
*
* @return {boolean} Whether the hook is being executed.
*/
/**
* Returns a function which, when invoked, will return whether a hook is
* currently being executed.
*
* @param {import('.').Hooks} hooks Hooks instance.
* @param {import('.').StoreKey} storeKey
*
* @return {DoingHook} Function that returns whether a hook is currently
* being executed.
*/
function createDoingHook(hooks, storeKey) {
return function doingHook(hookName) {
const hooksStore = hooks[storeKey];
// If the hookName was not passed, check for any current hook.
if ('undefined' === typeof hookName) {
return 'undefined' !== typeof hooksStore.__current[0];
}
// Return the __current hook.
return hooksStore.__current[0] ? hookName === hooksStore.__current[0].name : false;
};
}
var _default = exports.default = createDoingHook;
//# sourceMappingURL=createDoingHook.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createDoingHook","hooks","storeKey","doingHook","hookName","hooksStore","__current","name","_default","exports","default"],"sources":["@wordpress/hooks/src/createDoingHook.js"],"sourcesContent":["/**\n * @callback DoingHook\n * Returns whether a hook is currently being executed.\n *\n * @param {string} [hookName] The name of the hook to check for. If\n * omitted, will check for any hook being executed.\n *\n * @return {boolean} Whether the hook is being executed.\n */\n\n/**\n * Returns a function which, when invoked, will return whether a hook is\n * currently being executed.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n *\n * @return {DoingHook} Function that returns whether a hook is currently\n * being executed.\n */\nfunction createDoingHook( hooks, storeKey ) {\n\treturn function doingHook( hookName ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\t// If the hookName was not passed, check for any current hook.\n\t\tif ( 'undefined' === typeof hookName ) {\n\t\t\treturn 'undefined' !== typeof hooksStore.__current[ 0 ];\n\t\t}\n\n\t\t// Return the __current hook.\n\t\treturn hooksStore.__current[ 0 ]\n\t\t\t? hookName === hooksStore.__current[ 0 ].name\n\t\t\t: false;\n\t};\n}\n\nexport default createDoingHook;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,eAAeA,CAAEC,KAAK,EAAEC,QAAQ,EAAG;EAC3C,OAAO,SAASC,SAASA,CAAEC,QAAQ,EAAG;IACrC,MAAMC,UAAU,GAAGJ,KAAK,CAAEC,QAAQ,CAAE;;IAEpC;IACA,IAAK,WAAW,KAAK,OAAOE,QAAQ,EAAG;MACtC,OAAO,WAAW,KAAK,OAAOC,UAAU,CAACC,SAAS,CAAE,CAAC,CAAE;IACxD;;IAEA;IACA,OAAOD,UAAU,CAACC,SAAS,CAAE,CAAC,CAAE,GAC7BF,QAAQ,KAAKC,UAAU,CAACC,SAAS,CAAE,CAAC,CAAE,CAACC,IAAI,GAC3C,KAAK;EACT,CAAC;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcV,eAAe","ignoreList":[]}

40
node_modules/@wordpress/hooks/build/createHasHook.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* @callback HasHook
*
* Returns whether any handlers are attached for the given hookName and optional namespace.
*
* @param {string} hookName The name of the hook to check for.
* @param {string} [namespace] Optional. The unique namespace identifying the callback
* in the form `vendor/plugin/function`.
*
* @return {boolean} Whether there are handlers that are attached to the given hook.
*/
/**
* Returns a function which, when invoked, will return whether any handlers are
* attached to a particular hook.
*
* @param {import('.').Hooks} hooks Hooks instance.
* @param {import('.').StoreKey} storeKey
*
* @return {HasHook} Function that returns whether any handlers are
* attached to a particular hook and optional namespace.
*/
function createHasHook(hooks, storeKey) {
return function hasHook(hookName, namespace) {
const hooksStore = hooks[storeKey];
// Use the namespace if provided.
if ('undefined' !== typeof namespace) {
return hookName in hooksStore && hooksStore[hookName].handlers.some(hook => hook.namespace === namespace);
}
return hookName in hooksStore;
};
}
var _default = exports.default = createHasHook;
//# sourceMappingURL=createHasHook.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createHasHook","hooks","storeKey","hasHook","hookName","namespace","hooksStore","handlers","some","hook","_default","exports","default"],"sources":["@wordpress/hooks/src/createHasHook.js"],"sourcesContent":["/**\n * @callback HasHook\n *\n * Returns whether any handlers are attached for the given hookName and optional namespace.\n *\n * @param {string} hookName The name of the hook to check for.\n * @param {string} [namespace] Optional. The unique namespace identifying the callback\n * in the form `vendor/plugin/function`.\n *\n * @return {boolean} Whether there are handlers that are attached to the given hook.\n */\n/**\n * Returns a function which, when invoked, will return whether any handlers are\n * attached to a particular hook.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n *\n * @return {HasHook} Function that returns whether any handlers are\n * attached to a particular hook and optional namespace.\n */\nfunction createHasHook( hooks, storeKey ) {\n\treturn function hasHook( hookName, namespace ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\t// Use the namespace if provided.\n\t\tif ( 'undefined' !== typeof namespace ) {\n\t\t\treturn (\n\t\t\t\thookName in hooksStore &&\n\t\t\t\thooksStore[ hookName ].handlers.some(\n\t\t\t\t\t( hook ) => hook.namespace === namespace\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn hookName in hooksStore;\n\t};\n}\n\nexport default createHasHook;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAaA,CAAEC,KAAK,EAAEC,QAAQ,EAAG;EACzC,OAAO,SAASC,OAAOA,CAAEC,QAAQ,EAAEC,SAAS,EAAG;IAC9C,MAAMC,UAAU,GAAGL,KAAK,CAAEC,QAAQ,CAAE;;IAEpC;IACA,IAAK,WAAW,KAAK,OAAOG,SAAS,EAAG;MACvC,OACCD,QAAQ,IAAIE,UAAU,IACtBA,UAAU,CAAEF,QAAQ,CAAE,CAACG,QAAQ,CAACC,IAAI,CACjCC,IAAI,IAAMA,IAAI,CAACJ,SAAS,KAAKA,SAChC,CAAC;IAEH;IAEA,OAAOD,QAAQ,IAAIE,UAAU;EAC9B,CAAC;AACF;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcZ,aAAa","ignoreList":[]}

66
node_modules/@wordpress/hooks/build/createHooks.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports._Hooks = void 0;
var _createAddHook = _interopRequireDefault(require("./createAddHook"));
var _createRemoveHook = _interopRequireDefault(require("./createRemoveHook"));
var _createHasHook = _interopRequireDefault(require("./createHasHook"));
var _createRunHook = _interopRequireDefault(require("./createRunHook"));
var _createCurrentHook = _interopRequireDefault(require("./createCurrentHook"));
var _createDoingHook = _interopRequireDefault(require("./createDoingHook"));
var _createDidHook = _interopRequireDefault(require("./createDidHook"));
/**
* Internal dependencies
*/
/**
* Internal class for constructing hooks. Use `createHooks()` function
*
* Note, it is necessary to expose this class to make its type public.
*
* @private
*/
class _Hooks {
constructor() {
/** @type {import('.').Store} actions */
this.actions = Object.create(null);
this.actions.__current = [];
/** @type {import('.').Store} filters */
this.filters = Object.create(null);
this.filters.__current = [];
this.addAction = (0, _createAddHook.default)(this, 'actions');
this.addFilter = (0, _createAddHook.default)(this, 'filters');
this.removeAction = (0, _createRemoveHook.default)(this, 'actions');
this.removeFilter = (0, _createRemoveHook.default)(this, 'filters');
this.hasAction = (0, _createHasHook.default)(this, 'actions');
this.hasFilter = (0, _createHasHook.default)(this, 'filters');
this.removeAllActions = (0, _createRemoveHook.default)(this, 'actions', true);
this.removeAllFilters = (0, _createRemoveHook.default)(this, 'filters', true);
this.doAction = (0, _createRunHook.default)(this, 'actions');
this.applyFilters = (0, _createRunHook.default)(this, 'filters', true);
this.currentAction = (0, _createCurrentHook.default)(this, 'actions');
this.currentFilter = (0, _createCurrentHook.default)(this, 'filters');
this.doingAction = (0, _createDoingHook.default)(this, 'actions');
this.doingFilter = (0, _createDoingHook.default)(this, 'filters');
this.didAction = (0, _createDidHook.default)(this, 'actions');
this.didFilter = (0, _createDidHook.default)(this, 'filters');
}
}
/** @typedef {_Hooks} Hooks */
/**
* Returns an instance of the hooks object.
*
* @return {Hooks} A Hooks instance.
*/
exports._Hooks = _Hooks;
function createHooks() {
return new _Hooks();
}
var _default = exports.default = createHooks;
//# sourceMappingURL=createHooks.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_createAddHook","_interopRequireDefault","require","_createRemoveHook","_createHasHook","_createRunHook","_createCurrentHook","_createDoingHook","_createDidHook","_Hooks","constructor","actions","Object","create","__current","filters","addAction","createAddHook","addFilter","removeAction","createRemoveHook","removeFilter","hasAction","createHasHook","hasFilter","removeAllActions","removeAllFilters","doAction","createRunHook","applyFilters","currentAction","createCurrentHook","currentFilter","doingAction","createDoingHook","doingFilter","didAction","createDidHook","didFilter","exports","createHooks","_default","default"],"sources":["@wordpress/hooks/src/createHooks.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport createAddHook from './createAddHook';\nimport createRemoveHook from './createRemoveHook';\nimport createHasHook from './createHasHook';\nimport createRunHook from './createRunHook';\nimport createCurrentHook from './createCurrentHook';\nimport createDoingHook from './createDoingHook';\nimport createDidHook from './createDidHook';\n\n/**\n * Internal class for constructing hooks. Use `createHooks()` function\n *\n * Note, it is necessary to expose this class to make its type public.\n *\n * @private\n */\nexport class _Hooks {\n\tconstructor() {\n\t\t/** @type {import('.').Store} actions */\n\t\tthis.actions = Object.create( null );\n\t\tthis.actions.__current = [];\n\n\t\t/** @type {import('.').Store} filters */\n\t\tthis.filters = Object.create( null );\n\t\tthis.filters.__current = [];\n\n\t\tthis.addAction = createAddHook( this, 'actions' );\n\t\tthis.addFilter = createAddHook( this, 'filters' );\n\t\tthis.removeAction = createRemoveHook( this, 'actions' );\n\t\tthis.removeFilter = createRemoveHook( this, 'filters' );\n\t\tthis.hasAction = createHasHook( this, 'actions' );\n\t\tthis.hasFilter = createHasHook( this, 'filters' );\n\t\tthis.removeAllActions = createRemoveHook( this, 'actions', true );\n\t\tthis.removeAllFilters = createRemoveHook( this, 'filters', true );\n\t\tthis.doAction = createRunHook( this, 'actions' );\n\t\tthis.applyFilters = createRunHook( this, 'filters', true );\n\t\tthis.currentAction = createCurrentHook( this, 'actions' );\n\t\tthis.currentFilter = createCurrentHook( this, 'filters' );\n\t\tthis.doingAction = createDoingHook( this, 'actions' );\n\t\tthis.doingFilter = createDoingHook( this, 'filters' );\n\t\tthis.didAction = createDidHook( this, 'actions' );\n\t\tthis.didFilter = createDidHook( this, 'filters' );\n\t}\n}\n\n/** @typedef {_Hooks} Hooks */\n\n/**\n * Returns an instance of the hooks object.\n *\n * @return {Hooks} A Hooks instance.\n */\nfunction createHooks() {\n\treturn new _Hooks();\n}\n\nexport default createHooks;\n"],"mappings":";;;;;;;AAGA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,kBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,gBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,cAAA,GAAAP,sBAAA,CAAAC,OAAA;AATA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMO,MAAM,CAAC;EACnBC,WAAWA,CAAA,EAAG;IACb;IACA,IAAI,CAACC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAAE,IAAK,CAAC;IACpC,IAAI,CAACF,OAAO,CAACG,SAAS,GAAG,EAAE;;IAE3B;IACA,IAAI,CAACC,OAAO,GAAGH,MAAM,CAACC,MAAM,CAAE,IAAK,CAAC;IACpC,IAAI,CAACE,OAAO,CAACD,SAAS,GAAG,EAAE;IAE3B,IAAI,CAACE,SAAS,GAAG,IAAAC,sBAAa,EAAE,IAAI,EAAE,SAAU,CAAC;IACjD,IAAI,CAACC,SAAS,GAAG,IAAAD,sBAAa,EAAE,IAAI,EAAE,SAAU,CAAC;IACjD,IAAI,CAACE,YAAY,GAAG,IAAAC,yBAAgB,EAAE,IAAI,EAAE,SAAU,CAAC;IACvD,IAAI,CAACC,YAAY,GAAG,IAAAD,yBAAgB,EAAE,IAAI,EAAE,SAAU,CAAC;IACvD,IAAI,CAACE,SAAS,GAAG,IAAAC,sBAAa,EAAE,IAAI,EAAE,SAAU,CAAC;IACjD,IAAI,CAACC,SAAS,GAAG,IAAAD,sBAAa,EAAE,IAAI,EAAE,SAAU,CAAC;IACjD,IAAI,CAACE,gBAAgB,GAAG,IAAAL,yBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAK,CAAC;IACjE,IAAI,CAACM,gBAAgB,GAAG,IAAAN,yBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAK,CAAC;IACjE,IAAI,CAACO,QAAQ,GAAG,IAAAC,sBAAa,EAAE,IAAI,EAAE,SAAU,CAAC;IAChD,IAAI,CAACC,YAAY,GAAG,IAAAD,sBAAa,EAAE,IAAI,EAAE,SAAS,EAAE,IAAK,CAAC;IAC1D,IAAI,CAACE,aAAa,GAAG,IAAAC,0BAAiB,EAAE,IAAI,EAAE,SAAU,CAAC;IACzD,IAAI,CAACC,aAAa,GAAG,IAAAD,0BAAiB,EAAE,IAAI,EAAE,SAAU,CAAC;IACzD,IAAI,CAACE,WAAW,GAAG,IAAAC,wBAAe,EAAE,IAAI,EAAE,SAAU,CAAC;IACrD,IAAI,CAACC,WAAW,GAAG,IAAAD,wBAAe,EAAE,IAAI,EAAE,SAAU,CAAC;IACrD,IAAI,CAACE,SAAS,GAAG,IAAAC,sBAAa,EAAE,IAAI,EAAE,SAAU,CAAC;IACjD,IAAI,CAACC,SAAS,GAAG,IAAAD,sBAAa,EAAE,IAAI,EAAE,SAAU,CAAC;EAClD;AACD;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AAJAE,OAAA,CAAA9B,MAAA,GAAAA,MAAA;AAKA,SAAS+B,WAAWA,CAAA,EAAG;EACtB,OAAO,IAAI/B,MAAM,CAAC,CAAC;AACpB;AAAC,IAAAgC,QAAA,GAAAF,OAAA,CAAAG,OAAA,GAEcF,WAAW","ignoreList":[]}

View File

@@ -0,0 +1,86 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _validateNamespace = _interopRequireDefault(require("./validateNamespace.js"));
var _validateHookName = _interopRequireDefault(require("./validateHookName.js"));
/**
* Internal dependencies
*/
/**
* @callback RemoveHook
* Removes the specified callback (or all callbacks) from the hook with a given hookName
* and namespace.
*
* @param {string} hookName The name of the hook to modify.
* @param {string} namespace The unique namespace identifying the callback in the
* form `vendor/plugin/function`.
*
* @return {number | undefined} The number of callbacks removed.
*/
/**
* Returns a function which, when invoked, will remove a specified hook or all
* hooks by the given name.
*
* @param {import('.').Hooks} hooks Hooks instance.
* @param {import('.').StoreKey} storeKey
* @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName,
* without regard to namespace. Used to create
* `removeAll*` functions.
*
* @return {RemoveHook} Function that removes hooks.
*/
function createRemoveHook(hooks, storeKey, removeAll = false) {
return function removeHook(hookName, namespace) {
const hooksStore = hooks[storeKey];
if (!(0, _validateHookName.default)(hookName)) {
return;
}
if (!removeAll && !(0, _validateNamespace.default)(namespace)) {
return;
}
// Bail if no hooks exist by this name.
if (!hooksStore[hookName]) {
return 0;
}
let handlersRemoved = 0;
if (removeAll) {
handlersRemoved = hooksStore[hookName].handlers.length;
hooksStore[hookName] = {
runs: hooksStore[hookName].runs,
handlers: []
};
} else {
// Try to find the specified callback to remove.
const handlers = hooksStore[hookName].handlers;
for (let i = handlers.length - 1; i >= 0; i--) {
if (handlers[i].namespace === namespace) {
handlers.splice(i, 1);
handlersRemoved++;
// This callback may also be part of a hook that is
// currently executing. If the callback we're removing
// comes after the current callback, there's no problem;
// otherwise we need to decrease the execution index of any
// other runs by 1 to account for the removed element.
hooksStore.__current.forEach(hookInfo => {
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
hookInfo.currentIndex--;
}
});
}
}
}
if (hookName !== 'hookRemoved') {
hooks.doAction('hookRemoved', hookName, namespace);
}
return handlersRemoved;
};
}
var _default = exports.default = createRemoveHook;
//# sourceMappingURL=createRemoveHook.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["_validateNamespace","_interopRequireDefault","require","_validateHookName","createRemoveHook","hooks","storeKey","removeAll","removeHook","hookName","namespace","hooksStore","validateHookName","validateNamespace","handlersRemoved","handlers","length","runs","i","splice","__current","forEach","hookInfo","name","currentIndex","doAction","_default","exports","default"],"sources":["@wordpress/hooks/src/createRemoveHook.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace.js';\nimport validateHookName from './validateHookName.js';\n\n/**\n * @callback RemoveHook\n * Removes the specified callback (or all callbacks) from the hook with a given hookName\n * and namespace.\n *\n * @param {string} hookName The name of the hook to modify.\n * @param {string} namespace The unique namespace identifying the callback in the\n * form `vendor/plugin/function`.\n *\n * @return {number | undefined} The number of callbacks removed.\n */\n\n/**\n * Returns a function which, when invoked, will remove a specified hook or all\n * hooks by the given name.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n * @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName,\n * without regard to namespace. Used to create\n * `removeAll*` functions.\n *\n * @return {RemoveHook} Function that removes hooks.\n */\nfunction createRemoveHook( hooks, storeKey, removeAll = false ) {\n\treturn function removeHook( hookName, namespace ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! validateHookName( hookName ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! removeAll && ! validateNamespace( namespace ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Bail if no hooks exist by this name.\n\t\tif ( ! hooksStore[ hookName ] ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tlet handlersRemoved = 0;\n\n\t\tif ( removeAll ) {\n\t\t\thandlersRemoved = hooksStore[ hookName ].handlers.length;\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\truns: hooksStore[ hookName ].runs,\n\t\t\t\thandlers: [],\n\t\t\t};\n\t\t} else {\n\t\t\t// Try to find the specified callback to remove.\n\t\t\tconst handlers = hooksStore[ hookName ].handlers;\n\t\t\tfor ( let i = handlers.length - 1; i >= 0; i-- ) {\n\t\t\t\tif ( handlers[ i ].namespace === namespace ) {\n\t\t\t\t\thandlers.splice( i, 1 );\n\t\t\t\t\thandlersRemoved++;\n\t\t\t\t\t// This callback may also be part of a hook that is\n\t\t\t\t\t// currently executing. If the callback we're removing\n\t\t\t\t\t// comes after the current callback, there's no problem;\n\t\t\t\t\t// otherwise we need to decrease the execution index of any\n\t\t\t\t\t// other runs by 1 to account for the removed element.\n\t\t\t\t\thooksStore.__current.forEach( ( hookInfo ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thookInfo.name === hookName &&\n\t\t\t\t\t\t\thookInfo.currentIndex >= i\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thookInfo.currentIndex--;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( hookName !== 'hookRemoved' ) {\n\t\t\thooks.doAction( 'hookRemoved', hookName, namespace );\n\t\t}\n\n\t\treturn handlersRemoved;\n\t};\n}\n\nexport default createRemoveHook;\n"],"mappings":";;;;;;;AAGA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,gBAAgBA,CAAEC,KAAK,EAAEC,QAAQ,EAAEC,SAAS,GAAG,KAAK,EAAG;EAC/D,OAAO,SAASC,UAAUA,CAAEC,QAAQ,EAAEC,SAAS,EAAG;IACjD,MAAMC,UAAU,GAAGN,KAAK,CAAEC,QAAQ,CAAE;IAEpC,IAAK,CAAE,IAAAM,yBAAgB,EAAEH,QAAS,CAAC,EAAG;MACrC;IACD;IAEA,IAAK,CAAEF,SAAS,IAAI,CAAE,IAAAM,0BAAiB,EAAEH,SAAU,CAAC,EAAG;MACtD;IACD;;IAEA;IACA,IAAK,CAAEC,UAAU,CAAEF,QAAQ,CAAE,EAAG;MAC/B,OAAO,CAAC;IACT;IAEA,IAAIK,eAAe,GAAG,CAAC;IAEvB,IAAKP,SAAS,EAAG;MAChBO,eAAe,GAAGH,UAAU,CAAEF,QAAQ,CAAE,CAACM,QAAQ,CAACC,MAAM;MACxDL,UAAU,CAAEF,QAAQ,CAAE,GAAG;QACxBQ,IAAI,EAAEN,UAAU,CAAEF,QAAQ,CAAE,CAACQ,IAAI;QACjCF,QAAQ,EAAE;MACX,CAAC;IACF,CAAC,MAAM;MACN;MACA,MAAMA,QAAQ,GAAGJ,UAAU,CAAEF,QAAQ,CAAE,CAACM,QAAQ;MAChD,KAAM,IAAIG,CAAC,GAAGH,QAAQ,CAACC,MAAM,GAAG,CAAC,EAAEE,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAG;QAChD,IAAKH,QAAQ,CAAEG,CAAC,CAAE,CAACR,SAAS,KAAKA,SAAS,EAAG;UAC5CK,QAAQ,CAACI,MAAM,CAAED,CAAC,EAAE,CAAE,CAAC;UACvBJ,eAAe,EAAE;UACjB;UACA;UACA;UACA;UACA;UACAH,UAAU,CAACS,SAAS,CAACC,OAAO,CAAIC,QAAQ,IAAM;YAC7C,IACCA,QAAQ,CAACC,IAAI,KAAKd,QAAQ,IAC1Ba,QAAQ,CAACE,YAAY,IAAIN,CAAC,EACzB;cACDI,QAAQ,CAACE,YAAY,EAAE;YACxB;UACD,CAAE,CAAC;QACJ;MACD;IACD;IAEA,IAAKf,QAAQ,KAAK,aAAa,EAAG;MACjCJ,KAAK,CAACoB,QAAQ,CAAE,aAAa,EAAEhB,QAAQ,EAAEC,SAAU,CAAC;IACrD;IAEA,OAAOI,eAAe;EACvB,CAAC;AACF;AAAC,IAAAY,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcxB,gBAAgB","ignoreList":[]}

62
node_modules/@wordpress/hooks/build/createRunHook.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* Returns a function which, when invoked, will execute all callbacks
* registered to a hook of the specified type, optionally returning the final
* value of the call chain.
*
* @param {import('.').Hooks} hooks Hooks instance.
* @param {import('.').StoreKey} storeKey
* @param {boolean} [returnFirstArg=false] Whether each hook callback is expected to
* return its first argument.
*
* @return {(hookName:string, ...args: unknown[]) => undefined|unknown} Function that runs hook callbacks.
*/
function createRunHook(hooks, storeKey, returnFirstArg = false) {
return function runHooks(hookName, ...args) {
const hooksStore = hooks[storeKey];
if (!hooksStore[hookName]) {
hooksStore[hookName] = {
handlers: [],
runs: 0
};
}
hooksStore[hookName].runs++;
const handlers = hooksStore[hookName].handlers;
// The following code is stripped from production builds.
if ('production' !== process.env.NODE_ENV) {
// Handle any 'all' hooks registered.
if ('hookAdded' !== hookName && hooksStore.all) {
handlers.push(...hooksStore.all.handlers);
}
}
if (!handlers || !handlers.length) {
return returnFirstArg ? args[0] : undefined;
}
const hookInfo = {
name: hookName,
currentIndex: 0
};
hooksStore.__current.push(hookInfo);
while (hookInfo.currentIndex < handlers.length) {
const handler = handlers[hookInfo.currentIndex];
const result = handler.callback.apply(null, args);
if (returnFirstArg) {
args[0] = result;
}
hookInfo.currentIndex++;
}
hooksStore.__current.pop();
if (returnFirstArg) {
return args[0];
}
return undefined;
};
}
var _default = exports.default = createRunHook;
//# sourceMappingURL=createRunHook.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createRunHook","hooks","storeKey","returnFirstArg","runHooks","hookName","args","hooksStore","handlers","runs","process","env","NODE_ENV","all","push","length","undefined","hookInfo","name","currentIndex","__current","handler","result","callback","apply","pop","_default","exports","default"],"sources":["@wordpress/hooks/src/createRunHook.js"],"sourcesContent":["/**\n * Returns a function which, when invoked, will execute all callbacks\n * registered to a hook of the specified type, optionally returning the final\n * value of the call chain.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n * @param {boolean} [returnFirstArg=false] Whether each hook callback is expected to\n * return its first argument.\n *\n * @return {(hookName:string, ...args: unknown[]) => undefined|unknown} Function that runs hook callbacks.\n */\nfunction createRunHook( hooks, storeKey, returnFirstArg = false ) {\n\treturn function runHooks( hookName, ...args ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! hooksStore[ hookName ] ) {\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\thandlers: [],\n\t\t\t\truns: 0,\n\t\t\t};\n\t\t}\n\n\t\thooksStore[ hookName ].runs++;\n\n\t\tconst handlers = hooksStore[ hookName ].handlers;\n\n\t\t// The following code is stripped from production builds.\n\t\tif ( 'production' !== process.env.NODE_ENV ) {\n\t\t\t// Handle any 'all' hooks registered.\n\t\t\tif ( 'hookAdded' !== hookName && hooksStore.all ) {\n\t\t\t\thandlers.push( ...hooksStore.all.handlers );\n\t\t\t}\n\t\t}\n\n\t\tif ( ! handlers || ! handlers.length ) {\n\t\t\treturn returnFirstArg ? args[ 0 ] : undefined;\n\t\t}\n\n\t\tconst hookInfo = {\n\t\t\tname: hookName,\n\t\t\tcurrentIndex: 0,\n\t\t};\n\n\t\thooksStore.__current.push( hookInfo );\n\n\t\twhile ( hookInfo.currentIndex < handlers.length ) {\n\t\t\tconst handler = handlers[ hookInfo.currentIndex ];\n\n\t\t\tconst result = handler.callback.apply( null, args );\n\t\t\tif ( returnFirstArg ) {\n\t\t\t\targs[ 0 ] = result;\n\t\t\t}\n\n\t\t\thookInfo.currentIndex++;\n\t\t}\n\n\t\thooksStore.__current.pop();\n\n\t\tif ( returnFirstArg ) {\n\t\t\treturn args[ 0 ];\n\t\t}\n\n\t\treturn undefined;\n\t};\n}\n\nexport default createRunHook;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAaA,CAAEC,KAAK,EAAEC,QAAQ,EAAEC,cAAc,GAAG,KAAK,EAAG;EACjE,OAAO,SAASC,QAAQA,CAAEC,QAAQ,EAAE,GAAGC,IAAI,EAAG;IAC7C,MAAMC,UAAU,GAAGN,KAAK,CAAEC,QAAQ,CAAE;IAEpC,IAAK,CAAEK,UAAU,CAAEF,QAAQ,CAAE,EAAG;MAC/BE,UAAU,CAAEF,QAAQ,CAAE,GAAG;QACxBG,QAAQ,EAAE,EAAE;QACZC,IAAI,EAAE;MACP,CAAC;IACF;IAEAF,UAAU,CAAEF,QAAQ,CAAE,CAACI,IAAI,EAAE;IAE7B,MAAMD,QAAQ,GAAGD,UAAU,CAAEF,QAAQ,CAAE,CAACG,QAAQ;;IAEhD;IACA,IAAK,YAAY,KAAKE,OAAO,CAACC,GAAG,CAACC,QAAQ,EAAG;MAC5C;MACA,IAAK,WAAW,KAAKP,QAAQ,IAAIE,UAAU,CAACM,GAAG,EAAG;QACjDL,QAAQ,CAACM,IAAI,CAAE,GAAGP,UAAU,CAACM,GAAG,CAACL,QAAS,CAAC;MAC5C;IACD;IAEA,IAAK,CAAEA,QAAQ,IAAI,CAAEA,QAAQ,CAACO,MAAM,EAAG;MACtC,OAAOZ,cAAc,GAAGG,IAAI,CAAE,CAAC,CAAE,GAAGU,SAAS;IAC9C;IAEA,MAAMC,QAAQ,GAAG;MAChBC,IAAI,EAAEb,QAAQ;MACdc,YAAY,EAAE;IACf,CAAC;IAEDZ,UAAU,CAACa,SAAS,CAACN,IAAI,CAAEG,QAAS,CAAC;IAErC,OAAQA,QAAQ,CAACE,YAAY,GAAGX,QAAQ,CAACO,MAAM,EAAG;MACjD,MAAMM,OAAO,GAAGb,QAAQ,CAAES,QAAQ,CAACE,YAAY,CAAE;MAEjD,MAAMG,MAAM,GAAGD,OAAO,CAACE,QAAQ,CAACC,KAAK,CAAE,IAAI,EAAElB,IAAK,CAAC;MACnD,IAAKH,cAAc,EAAG;QACrBG,IAAI,CAAE,CAAC,CAAE,GAAGgB,MAAM;MACnB;MAEAL,QAAQ,CAACE,YAAY,EAAE;IACxB;IAEAZ,UAAU,CAACa,SAAS,CAACK,GAAG,CAAC,CAAC;IAE1B,IAAKtB,cAAc,EAAG;MACrB,OAAOG,IAAI,CAAE,CAAC,CAAE;IACjB;IAEA,OAAOU,SAAS;EACjB,CAAC;AACF;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc5B,aAAa","ignoreList":[]}

92
node_modules/@wordpress/hooks/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,92 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.applyFilters = exports.addFilter = exports.addAction = exports.actions = void 0;
Object.defineProperty(exports, "createHooks", {
enumerable: true,
get: function () {
return _createHooks.default;
}
});
exports.removeFilter = exports.removeAllFilters = exports.removeAllActions = exports.removeAction = exports.hasFilter = exports.hasAction = exports.filters = exports.doingFilter = exports.doingAction = exports.doAction = exports.didFilter = exports.didAction = exports.defaultHooks = exports.currentFilter = exports.currentAction = void 0;
var _createHooks = _interopRequireDefault(require("./createHooks"));
/**
* Internal dependencies
*/
/** @typedef {(...args: any[])=>any} Callback */
/**
* @typedef Handler
* @property {Callback} callback The callback
* @property {string} namespace The namespace
* @property {number} priority The namespace
*/
/**
* @typedef Hook
* @property {Handler[]} handlers Array of handlers
* @property {number} runs Run counter
*/
/**
* @typedef Current
* @property {string} name Hook name
* @property {number} currentIndex The index
*/
/**
* @typedef {Record<string, Hook> & {__current: Current[]}} Store
*/
/**
* @typedef {'actions' | 'filters'} StoreKey
*/
/**
* @typedef {import('./createHooks').Hooks} Hooks
*/
const defaultHooks = exports.defaultHooks = (0, _createHooks.default)();
const {
addAction,
addFilter,
removeAction,
removeFilter,
hasAction,
hasFilter,
removeAllActions,
removeAllFilters,
doAction,
applyFilters,
currentAction,
currentFilter,
doingAction,
doingFilter,
didAction,
didFilter,
actions,
filters
} = defaultHooks;
exports.filters = filters;
exports.actions = actions;
exports.didFilter = didFilter;
exports.didAction = didAction;
exports.doingFilter = doingFilter;
exports.doingAction = doingAction;
exports.currentFilter = currentFilter;
exports.currentAction = currentAction;
exports.applyFilters = applyFilters;
exports.doAction = doAction;
exports.removeAllFilters = removeAllFilters;
exports.removeAllActions = removeAllActions;
exports.hasFilter = hasFilter;
exports.hasAction = hasAction;
exports.removeFilter = removeFilter;
exports.removeAction = removeAction;
exports.addFilter = addFilter;
exports.addAction = addAction;
//# sourceMappingURL=index.js.map

1
node_modules/@wordpress/hooks/build/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"names":["_createHooks","_interopRequireDefault","require","defaultHooks","exports","createHooks","addAction","addFilter","removeAction","removeFilter","hasAction","hasFilter","removeAllActions","removeAllFilters","doAction","applyFilters","currentAction","currentFilter","doingAction","doingFilter","didAction","didFilter","actions","filters"],"sources":["@wordpress/hooks/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport createHooks from './createHooks';\n\n/** @typedef {(...args: any[])=>any} Callback */\n\n/**\n * @typedef Handler\n * @property {Callback} callback The callback\n * @property {string} namespace The namespace\n * @property {number} priority The namespace\n */\n\n/**\n * @typedef Hook\n * @property {Handler[]} handlers Array of handlers\n * @property {number} runs Run counter\n */\n\n/**\n * @typedef Current\n * @property {string} name Hook name\n * @property {number} currentIndex The index\n */\n\n/**\n * @typedef {Record<string, Hook> & {__current: Current[]}} Store\n */\n\n/**\n * @typedef {'actions' | 'filters'} StoreKey\n */\n\n/**\n * @typedef {import('./createHooks').Hooks} Hooks\n */\n\nexport const defaultHooks = createHooks();\n\nconst {\n\taddAction,\n\taddFilter,\n\tremoveAction,\n\tremoveFilter,\n\thasAction,\n\thasFilter,\n\tremoveAllActions,\n\tremoveAllFilters,\n\tdoAction,\n\tapplyFilters,\n\tcurrentAction,\n\tcurrentFilter,\n\tdoingAction,\n\tdoingFilter,\n\tdidAction,\n\tdidFilter,\n\tactions,\n\tfilters,\n} = defaultHooks;\n\nexport {\n\tcreateHooks,\n\taddAction,\n\taddFilter,\n\tremoveAction,\n\tremoveFilter,\n\thasAction,\n\thasFilter,\n\tremoveAllActions,\n\tremoveAllFilters,\n\tdoAction,\n\tapplyFilters,\n\tcurrentAction,\n\tcurrentFilter,\n\tdoingAction,\n\tdoingFilter,\n\tdidAction,\n\tdidFilter,\n\tactions,\n\tfilters,\n};\n"],"mappings":";;;;;;;;;;;;;;AAGA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEO,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAAE,oBAAW,EAAC,CAAC;AAEzC,MAAM;EACLC,SAAS;EACTC,SAAS;EACTC,YAAY;EACZC,YAAY;EACZC,SAAS;EACTC,SAAS;EACTC,gBAAgB;EAChBC,gBAAgB;EAChBC,QAAQ;EACRC,YAAY;EACZC,aAAa;EACbC,aAAa;EACbC,WAAW;EACXC,WAAW;EACXC,SAAS;EACTC,SAAS;EACTC,OAAO;EACPC;AACD,CAAC,GAAGpB,YAAY;AAACC,OAAA,CAAAmB,OAAA,GAAAA,OAAA;AAAAnB,OAAA,CAAAkB,OAAA,GAAAA,OAAA;AAAAlB,OAAA,CAAAiB,SAAA,GAAAA,SAAA;AAAAjB,OAAA,CAAAgB,SAAA,GAAAA,SAAA;AAAAhB,OAAA,CAAAe,WAAA,GAAAA,WAAA;AAAAf,OAAA,CAAAc,WAAA,GAAAA,WAAA;AAAAd,OAAA,CAAAa,aAAA,GAAAA,aAAA;AAAAb,OAAA,CAAAY,aAAA,GAAAA,aAAA;AAAAZ,OAAA,CAAAW,YAAA,GAAAA,YAAA;AAAAX,OAAA,CAAAU,QAAA,GAAAA,QAAA;AAAAV,OAAA,CAAAS,gBAAA,GAAAA,gBAAA;AAAAT,OAAA,CAAAQ,gBAAA,GAAAA,gBAAA;AAAAR,OAAA,CAAAO,SAAA,GAAAA,SAAA;AAAAP,OAAA,CAAAM,SAAA,GAAAA,SAAA;AAAAN,OAAA,CAAAK,YAAA,GAAAA,YAAA;AAAAL,OAAA,CAAAI,YAAA,GAAAA,YAAA;AAAAJ,OAAA,CAAAG,SAAA,GAAAA,SAAA;AAAAH,OAAA,CAAAE,SAAA,GAAAA,SAAA","ignoreList":[]}

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* Validate a hookName string.
*
* @param {string} hookName The hook name to validate. Should be a non empty string containing
* only numbers, letters, dashes, periods and underscores. Also,
* the hook name cannot begin with `__`.
*
* @return {boolean} Whether the hook name is valid.
*/
function validateHookName(hookName) {
if ('string' !== typeof hookName || '' === hookName) {
// eslint-disable-next-line no-console
console.error('The hook name must be a non-empty string.');
return false;
}
if (/^__/.test(hookName)) {
// eslint-disable-next-line no-console
console.error('The hook name cannot begin with `__`.');
return false;
}
if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
// eslint-disable-next-line no-console
console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.');
return false;
}
return true;
}
var _default = exports.default = validateHookName;
//# sourceMappingURL=validateHookName.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["validateHookName","hookName","console","error","test","_default","exports","default"],"sources":["@wordpress/hooks/src/validateHookName.js"],"sourcesContent":["/**\n * Validate a hookName string.\n *\n * @param {string} hookName The hook name to validate. Should be a non empty string containing\n * only numbers, letters, dashes, periods and underscores. Also,\n * the hook name cannot begin with `__`.\n *\n * @return {boolean} Whether the hook name is valid.\n */\nfunction validateHookName( hookName ) {\n\tif ( 'string' !== typeof hookName || '' === hookName ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error( 'The hook name must be a non-empty string.' );\n\t\treturn false;\n\t}\n\n\tif ( /^__/.test( hookName ) ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error( 'The hook name cannot begin with `__`.' );\n\t\treturn false;\n\t}\n\n\tif ( ! /^[a-zA-Z][a-zA-Z0-9_.-]*$/.test( hookName ) ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error(\n\t\t\t'The hook name can only contain numbers, letters, dashes, periods and underscores.'\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nexport default validateHookName;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgBA,CAAEC,QAAQ,EAAG;EACrC,IAAK,QAAQ,KAAK,OAAOA,QAAQ,IAAI,EAAE,KAAKA,QAAQ,EAAG;IACtD;IACAC,OAAO,CAACC,KAAK,CAAE,2CAA4C,CAAC;IAC5D,OAAO,KAAK;EACb;EAEA,IAAK,KAAK,CAACC,IAAI,CAAEH,QAAS,CAAC,EAAG;IAC7B;IACAC,OAAO,CAACC,KAAK,CAAE,uCAAwC,CAAC;IACxD,OAAO,KAAK;EACb;EAEA,IAAK,CAAE,2BAA2B,CAACC,IAAI,CAAEH,QAAS,CAAC,EAAG;IACrD;IACAC,OAAO,CAACC,KAAK,CACZ,mFACD,CAAC;IACD,OAAO,KAAK;EACb;EAEA,OAAO,IAAI;AACZ;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcP,gBAAgB","ignoreList":[]}

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* Validate a namespace string.
*
* @param {string} namespace The namespace to validate - should take the form
* `vendor/plugin/function`.
*
* @return {boolean} Whether the namespace is valid.
*/
function validateNamespace(namespace) {
if ('string' !== typeof namespace || '' === namespace) {
// eslint-disable-next-line no-console
console.error('The namespace must be a non-empty string.');
return false;
}
if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
// eslint-disable-next-line no-console
console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.');
return false;
}
return true;
}
var _default = exports.default = validateNamespace;
//# sourceMappingURL=validateNamespace.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["validateNamespace","namespace","console","error","test","_default","exports","default"],"sources":["@wordpress/hooks/src/validateNamespace.js"],"sourcesContent":["/**\n * Validate a namespace string.\n *\n * @param {string} namespace The namespace to validate - should take the form\n * `vendor/plugin/function`.\n *\n * @return {boolean} Whether the namespace is valid.\n */\nfunction validateNamespace( namespace ) {\n\tif ( 'string' !== typeof namespace || '' === namespace ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error( 'The namespace must be a non-empty string.' );\n\t\treturn false;\n\t}\n\n\tif ( ! /^[a-zA-Z][a-zA-Z0-9_.\\-\\/]*$/.test( namespace ) ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error(\n\t\t\t'The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.'\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nexport default validateNamespace;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAiBA,CAAEC,SAAS,EAAG;EACvC,IAAK,QAAQ,KAAK,OAAOA,SAAS,IAAI,EAAE,KAAKA,SAAS,EAAG;IACxD;IACAC,OAAO,CAACC,KAAK,CAAE,2CAA4C,CAAC;IAC5D,OAAO,KAAK;EACb;EAEA,IAAK,CAAE,8BAA8B,CAACC,IAAI,CAAEH,SAAU,CAAC,EAAG;IACzD;IACAC,OAAO,CAACC,KAAK,CACZ,4FACD,CAAC;IACD,OAAO,KAAK;EACb;EAEA,OAAO,IAAI;AACZ;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcP,iBAAiB","ignoreList":[]}