@wordpress/hooks 4.31.1-next.f56bd8138.0 → 4.32.1-next.47f435fc9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/createAddHook.js +53 -53
  3. package/build/createAddHook.js.map +7 -1
  4. package/build/createCurrentHook.js +24 -22
  5. package/build/createCurrentHook.js.map +7 -1
  6. package/build/createDidHook.js +35 -28
  7. package/build/createDidHook.js.map +7 -1
  8. package/build/createDoingHook.js +27 -31
  9. package/build/createDoingHook.js.map +7 -1
  10. package/build/createHasHook.js +27 -29
  11. package/build/createHasHook.js.map +7 -1
  12. package/build/createHooks.js +87 -53
  13. package/build/createHooks.js.map +7 -1
  14. package/build/createRemoveHook.js +40 -43
  15. package/build/createRemoveHook.js.map +7 -1
  16. package/build/createRunHook.js +30 -32
  17. package/build/createRunHook.js.map +7 -1
  18. package/build/index.js +81 -73
  19. package/build/index.js.map +7 -1
  20. package/build/types.js +16 -5
  21. package/build/types.js.map +7 -1
  22. package/build/validateHookName.js +29 -22
  23. package/build/validateHookName.js.map +7 -1
  24. package/build/validateNamespace.js +28 -19
  25. package/build/validateNamespace.js.map +7 -1
  26. package/build-module/createAddHook.js +23 -46
  27. package/build-module/createAddHook.js.map +7 -1
  28. package/build-module/createCurrentHook.js +6 -18
  29. package/build-module/createCurrentHook.js.map +7 -1
  30. package/build-module/createDidHook.js +6 -22
  31. package/build-module/createDidHook.js.map +7 -1
  32. package/build-module/createDoingHook.js +9 -27
  33. package/build-module/createDoingHook.js.map +7 -1
  34. package/build-module/createHasHook.js +9 -25
  35. package/build-module/createHasHook.js.map +7 -1
  36. package/build-module/createHooks.js +56 -47
  37. package/build-module/createHooks.js.map +7 -1
  38. package/build-module/createRemoveHook.js +10 -36
  39. package/build-module/createRemoveHook.js.map +7 -1
  40. package/build-module/createRunHook.js +12 -28
  41. package/build-module/createRunHook.js.map +7 -1
  42. package/build-module/index.js +28 -8
  43. package/build-module/index.js.map +7 -1
  44. package/build-module/types.js +1 -2
  45. package/build-module/types.js.map +7 -1
  46. package/build-module/validateHookName.js +11 -18
  47. package/build-module/validateHookName.js.map +7 -1
  48. package/build-module/validateNamespace.js +10 -15
  49. package/build-module/validateNamespace.js.map +7 -1
  50. package/package.json +10 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.32.0 (2025-10-01)
6
+
5
7
  ## 4.31.0 (2025-09-17)
6
8
 
7
9
  ## 4.30.0 (2025-09-03)
@@ -1,57 +1,59 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var createAddHook_exports = {};
30
+ __export(createAddHook_exports, {
31
+ default: () => createAddHook_default
6
32
  });
7
- exports.default = void 0;
8
- var _validateNamespace = _interopRequireDefault(require("./validateNamespace"));
9
- var _validateHookName = _interopRequireDefault(require("./validateHookName"));
10
- /**
11
- * Internal dependencies
12
- */
13
-
14
- /**
15
- *
16
- * Adds the hook to the appropriate hooks container.
17
- */
18
-
19
- /**
20
- * Returns a function which, when invoked, will add a hook.
21
- *
22
- * @param hooks Hooks instance.
23
- * @param storeKey
24
- *
25
- * @return Function that adds a new hook.
26
- */
33
+ module.exports = __toCommonJS(createAddHook_exports);
34
+ var import_validateNamespace = __toESM(require("./validateNamespace"));
35
+ var import_validateHookName = __toESM(require("./validateHookName"));
27
36
  function createAddHook(hooks, storeKey) {
28
37
  return function addHook(hookName, namespace, callback, priority = 10) {
29
38
  const hooksStore = hooks[storeKey];
30
- if (!(0, _validateHookName.default)(hookName)) {
39
+ if (!(0, import_validateHookName.default)(hookName)) {
31
40
  return;
32
41
  }
33
- if (!(0, _validateNamespace.default)(namespace)) {
42
+ if (!(0, import_validateNamespace.default)(namespace)) {
34
43
  return;
35
44
  }
36
- if ('function' !== typeof callback) {
37
- // eslint-disable-next-line no-console
38
- console.error('The hook callback must be a function.');
45
+ if ("function" !== typeof callback) {
46
+ console.error("The hook callback must be a function.");
39
47
  return;
40
48
  }
41
-
42
- // Validate numeric priority
43
- if ('number' !== typeof priority) {
44
- // eslint-disable-next-line no-console
45
- console.error('If specified, the hook priority must be a number.');
49
+ if ("number" !== typeof priority) {
50
+ console.error(
51
+ "If specified, the hook priority must be a number."
52
+ );
46
53
  return;
47
54
  }
48
- const handler = {
49
- callback,
50
- priority,
51
- namespace
52
- };
55
+ const handler = { callback, priority, namespace };
53
56
  if (hooksStore[hookName]) {
54
- // Find the correct insert index of the new hook.
55
57
  const handlers = hooksStore[hookName].handlers;
56
58
  let i;
57
59
  for (i = handlers.length; i > 0; i--) {
@@ -60,33 +62,31 @@ function createAddHook(hooks, storeKey) {
60
62
  }
61
63
  }
62
64
  if (i === handlers.length) {
63
- // If append, operate via direct assignment.
64
65
  handlers[i] = handler;
65
66
  } else {
66
- // Otherwise, insert before index via splice.
67
67
  handlers.splice(i, 0, handler);
68
68
  }
69
-
70
- // We may also be currently executing this hook. If the callback
71
- // we're adding would come after the current callback, there's no
72
- // problem; otherwise we need to increase the execution index of
73
- // any other runs by 1 to account for the added element.
74
- hooksStore.__current.forEach(hookInfo => {
69
+ hooksStore.__current.forEach((hookInfo) => {
75
70
  if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
76
71
  hookInfo.currentIndex++;
77
72
  }
78
73
  });
79
74
  } else {
80
- // This is the first hook of its type.
81
75
  hooksStore[hookName] = {
82
76
  handlers: [handler],
83
77
  runs: 0
84
78
  };
85
79
  }
86
- if (hookName !== 'hookAdded') {
87
- hooks.doAction('hookAdded', hookName, namespace, callback, priority);
80
+ if (hookName !== "hookAdded") {
81
+ hooks.doAction(
82
+ "hookAdded",
83
+ hookName,
84
+ namespace,
85
+ callback,
86
+ priority
87
+ );
88
88
  }
89
89
  };
90
90
  }
91
- var _default = exports.default = createAddHook;
92
- //# sourceMappingURL=createAddHook.js.map
91
+ var createAddHook_default = createAddHook;
92
+ //# sourceMappingURL=createAddHook.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_validateNamespace","_interopRequireDefault","require","_validateHookName","createAddHook","hooks","storeKey","addHook","hookName","namespace","callback","priority","hooksStore","validateHookName","validateNamespace","console","error","handler","handlers","i","length","splice","__current","forEach","hookInfo","name","currentIndex","runs","doAction","_default","exports","default"],"sources":["@wordpress/hooks/src/createAddHook.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace';\nimport validateHookName from './validateHookName';\nimport type { Callback, Hooks, StoreKey } from '.';\nimport type { Handler, HookInfo } from './types';\n\n/**\n *\n * Adds the hook to the appropriate hooks container.\n */\nexport type AddHook = (\n\t/**\n\t * Name of hook to add\n\t */\n\thookName: string,\n\t/**\n\t * The unique namespace identifying the callback in the form.\n\t */\n\tnamespace: string,\n\t/**\n\t * Function to call when the hook is run.\n\t */\n\tcallback: Callback,\n\t/**\n\t * Priority of this hook\n\t */\n\tpriority?: number\n) => void;\n\n/**\n * Returns a function which, when invoked, will add a hook.\n *\n * @param hooks Hooks instance.\n * @param storeKey\n *\n * @return Function that adds a new hook.\n */\nfunction createAddHook( hooks: Hooks, storeKey: StoreKey ): AddHook {\n\treturn function addHook( hookName, namespace, callback, priority = 10 ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! validateHookName( hookName ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! validateNamespace( namespace ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( 'function' !== typeof callback ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( 'The hook callback must be a function.' );\n\t\t\treturn;\n\t\t}\n\n\t\t// Validate numeric priority\n\t\tif ( 'number' !== typeof priority ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t'If specified, the hook priority must be a number.'\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst handler: Handler = { callback, priority, namespace };\n\n\t\tif ( hooksStore[ hookName ] ) {\n\t\t\t// Find the correct insert index of the new hook.\n\t\t\tconst handlers = hooksStore[ hookName ].handlers;\n\n\t\t\tlet i: number;\n\t\t\tfor ( i = handlers.length; i > 0; i-- ) {\n\t\t\t\tif ( priority >= handlers[ i - 1 ].priority ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( i === handlers.length ) {\n\t\t\t\t// If append, operate via direct assignment.\n\t\t\t\thandlers[ i ] = handler;\n\t\t\t} else {\n\t\t\t\t// Otherwise, insert before index via splice.\n\t\t\t\thandlers.splice( i, 0, handler );\n\t\t\t}\n\n\t\t\t// We may also be currently executing this hook. If the callback\n\t\t\t// we're adding would come after the current callback, there's no\n\t\t\t// problem; otherwise we need to increase the execution index of\n\t\t\t// any other runs by 1 to account for the added element.\n\t\t\thooksStore.__current.forEach( ( hookInfo: HookInfo ) => {\n\t\t\t\tif (\n\t\t\t\t\thookInfo.name === hookName &&\n\t\t\t\t\thookInfo.currentIndex >= i\n\t\t\t\t) {\n\t\t\t\t\thookInfo.currentIndex++;\n\t\t\t\t}\n\t\t\t} );\n\t\t} else {\n\t\t\t// This is the first hook of its type.\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\thandlers: [ handler ],\n\t\t\t\truns: 0,\n\t\t\t};\n\t\t}\n\n\t\tif ( hookName !== 'hookAdded' ) {\n\t\t\thooks.doAction(\n\t\t\t\t'hookAdded',\n\t\t\t\thookName,\n\t\t\t\tnamespace,\n\t\t\t\tcallback,\n\t\t\t\tpriority\n\t\t\t);\n\t\t}\n\t};\n}\n\nexport default createAddHook;\n"],"mappings":";;;;;;;AAGA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAJA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASE,aAAaA,CAAEC,KAAY,EAAEC,QAAkB,EAAY;EACnE,OAAO,SAASC,OAAOA,CAAEC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,GAAG,EAAE,EAAG;IACvE,MAAMC,UAAU,GAAGP,KAAK,CAAEC,QAAQ,CAAE;IAEpC,IAAK,CAAE,IAAAO,yBAAgB,EAAEL,QAAS,CAAC,EAAG;MACrC;IACD;IAEA,IAAK,CAAE,IAAAM,0BAAiB,EAAEL,SAAU,CAAC,EAAG;MACvC;IACD;IAEA,IAAK,UAAU,KAAK,OAAOC,QAAQ,EAAG;MACrC;MACAK,OAAO,CAACC,KAAK,CAAE,uCAAwC,CAAC;MACxD;IACD;;IAEA;IACA,IAAK,QAAQ,KAAK,OAAOL,QAAQ,EAAG;MACnC;MACAI,OAAO,CAACC,KAAK,CACZ,mDACD,CAAC;MACD;IACD;IAEA,MAAMC,OAAgB,GAAG;MAAEP,QAAQ;MAAEC,QAAQ;MAAEF;IAAU,CAAC;IAE1D,IAAKG,UAAU,CAAEJ,QAAQ,CAAE,EAAG;MAC7B;MACA,MAAMU,QAAQ,GAAGN,UAAU,CAAEJ,QAAQ,CAAE,CAACU,QAAQ;MAEhD,IAAIC,CAAS;MACb,KAAMA,CAAC,GAAGD,QAAQ,CAACE,MAAM,EAAED,CAAC,GAAG,CAAC,EAAEA,CAAC,EAAE,EAAG;QACvC,IAAKR,QAAQ,IAAIO,QAAQ,CAAEC,CAAC,GAAG,CAAC,CAAE,CAACR,QAAQ,EAAG;UAC7C;QACD;MACD;MAEA,IAAKQ,CAAC,KAAKD,QAAQ,CAACE,MAAM,EAAG;QAC5B;QACAF,QAAQ,CAAEC,CAAC,CAAE,GAAGF,OAAO;MACxB,CAAC,MAAM;QACN;QACAC,QAAQ,CAACG,MAAM,CAAEF,CAAC,EAAE,CAAC,EAAEF,OAAQ,CAAC;MACjC;;MAEA;MACA;MACA;MACA;MACAL,UAAU,CAACU,SAAS,CAACC,OAAO,CAAIC,QAAkB,IAAM;QACvD,IACCA,QAAQ,CAACC,IAAI,KAAKjB,QAAQ,IAC1BgB,QAAQ,CAACE,YAAY,IAAIP,CAAC,EACzB;UACDK,QAAQ,CAACE,YAAY,EAAE;QACxB;MACD,CAAE,CAAC;IACJ,CAAC,MAAM;MACN;MACAd,UAAU,CAAEJ,QAAQ,CAAE,GAAG;QACxBU,QAAQ,EAAE,CAAED,OAAO,CAAE;QACrBU,IAAI,EAAE;MACP,CAAC;IACF;IAEA,IAAKnB,QAAQ,KAAK,WAAW,EAAG;MAC/BH,KAAK,CAACuB,QAAQ,CACb,WAAW,EACXpB,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,QACD,CAAC;IACF;EACD,CAAC;AACF;AAAC,IAAAkB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc3B,aAAa","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createAddHook.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace';\nimport validateHookName from './validateHookName';\nimport type { Callback, Hooks, StoreKey } from '.';\nimport type { Handler, HookInfo } from './types';\n\n/**\n *\n * Adds the hook to the appropriate hooks container.\n */\nexport type AddHook = (\n\t/**\n\t * Name of hook to add\n\t */\n\thookName: string,\n\t/**\n\t * The unique namespace identifying the callback in the form.\n\t */\n\tnamespace: string,\n\t/**\n\t * Function to call when the hook is run.\n\t */\n\tcallback: Callback,\n\t/**\n\t * Priority of this hook\n\t */\n\tpriority?: number\n) => void;\n\n/**\n * Returns a function which, when invoked, will add a hook.\n *\n * @param hooks Hooks instance.\n * @param storeKey\n *\n * @return Function that adds a new hook.\n */\nfunction createAddHook( hooks: Hooks, storeKey: StoreKey ): AddHook {\n\treturn function addHook( hookName, namespace, callback, priority = 10 ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! validateHookName( hookName ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! validateNamespace( namespace ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( 'function' !== typeof callback ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( 'The hook callback must be a function.' );\n\t\t\treturn;\n\t\t}\n\n\t\t// Validate numeric priority\n\t\tif ( 'number' !== typeof priority ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t'If specified, the hook priority must be a number.'\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst handler: Handler = { callback, priority, namespace };\n\n\t\tif ( hooksStore[ hookName ] ) {\n\t\t\t// Find the correct insert index of the new hook.\n\t\t\tconst handlers = hooksStore[ hookName ].handlers;\n\n\t\t\tlet i: number;\n\t\t\tfor ( i = handlers.length; i > 0; i-- ) {\n\t\t\t\tif ( priority >= handlers[ i - 1 ].priority ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( i === handlers.length ) {\n\t\t\t\t// If append, operate via direct assignment.\n\t\t\t\thandlers[ i ] = handler;\n\t\t\t} else {\n\t\t\t\t// Otherwise, insert before index via splice.\n\t\t\t\thandlers.splice( i, 0, handler );\n\t\t\t}\n\n\t\t\t// We may also be currently executing this hook. If the callback\n\t\t\t// we're adding would come after the current callback, there's no\n\t\t\t// problem; otherwise we need to increase the execution index of\n\t\t\t// any other runs by 1 to account for the added element.\n\t\t\thooksStore.__current.forEach( ( hookInfo: HookInfo ) => {\n\t\t\t\tif (\n\t\t\t\t\thookInfo.name === hookName &&\n\t\t\t\t\thookInfo.currentIndex >= i\n\t\t\t\t) {\n\t\t\t\t\thookInfo.currentIndex++;\n\t\t\t\t}\n\t\t\t} );\n\t\t} else {\n\t\t\t// This is the first hook of its type.\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\thandlers: [ handler ],\n\t\t\t\truns: 0,\n\t\t\t};\n\t\t}\n\n\t\tif ( hookName !== 'hookAdded' ) {\n\t\t\thooks.doAction(\n\t\t\t\t'hookAdded',\n\t\t\t\thookName,\n\t\t\t\tnamespace,\n\t\t\t\tcallback,\n\t\t\t\tpriority\n\t\t\t);\n\t\t}\n\t};\n}\n\nexport default createAddHook;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAA8B;AAC9B,8BAA6B;AAmC7B,SAAS,cAAe,OAAc,UAA8B;AACnE,SAAO,SAAS,QAAS,UAAU,WAAW,UAAU,WAAW,IAAK;AACvE,UAAM,aAAa,MAAO,QAAS;AAEnC,QAAK,KAAE,wBAAAA,SAAkB,QAAS,GAAI;AACrC;AAAA,IACD;AAEA,QAAK,KAAE,yBAAAC,SAAmB,SAAU,GAAI;AACvC;AAAA,IACD;AAEA,QAAK,eAAe,OAAO,UAAW;AAErC,cAAQ,MAAO,uCAAwC;AACvD;AAAA,IACD;AAGA,QAAK,aAAa,OAAO,UAAW;AAEnC,cAAQ;AAAA,QACP;AAAA,MACD;AACA;AAAA,IACD;AAEA,UAAM,UAAmB,EAAE,UAAU,UAAU,UAAU;AAEzD,QAAK,WAAY,QAAS,GAAI;AAE7B,YAAM,WAAW,WAAY,QAAS,EAAE;AAExC,UAAI;AACJ,WAAM,IAAI,SAAS,QAAQ,IAAI,GAAG,KAAM;AACvC,YAAK,YAAY,SAAU,IAAI,CAAE,EAAE,UAAW;AAC7C;AAAA,QACD;AAAA,MACD;AAEA,UAAK,MAAM,SAAS,QAAS;AAE5B,iBAAU,CAAE,IAAI;AAAA,MACjB,OAAO;AAEN,iBAAS,OAAQ,GAAG,GAAG,OAAQ;AAAA,MAChC;AAMA,iBAAW,UAAU,QAAS,CAAE,aAAwB;AACvD,YACC,SAAS,SAAS,YAClB,SAAS,gBAAgB,GACxB;AACD,mBAAS;AAAA,QACV;AAAA,MACD,CAAE;AAAA,IACH,OAAO;AAEN,iBAAY,QAAS,IAAI;AAAA,QACxB,UAAU,CAAE,OAAQ;AAAA,QACpB,MAAM;AAAA,MACP;AAAA,IACD;AAEA,QAAK,aAAa,aAAc;AAC/B,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,wBAAQ;",
6
+ "names": ["validateHookName", "validateNamespace"]
7
+ }
@@ -1,30 +1,32 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var createCurrentHook_exports = {};
20
+ __export(createCurrentHook_exports, {
21
+ default: () => createCurrentHook_default
5
22
  });
6
- exports.default = void 0;
7
- /**
8
- * Internal dependencies
9
- */
10
-
11
- /**
12
- * Returns a function which, when invoked, will return the name of the
13
- * currently running hook, or `null` if no hook of the given type is currently
14
- * running.
15
- *
16
- * @param hooks Hooks instance.
17
- * @param storeKey
18
- *
19
- * @return Function that returns the current hook name or null.
20
- */
23
+ module.exports = __toCommonJS(createCurrentHook_exports);
21
24
  function createCurrentHook(hooks, storeKey) {
22
25
  return function currentHook() {
23
- var _currentArray$at$name;
24
26
  const hooksStore = hooks[storeKey];
25
27
  const currentArray = Array.from(hooksStore.__current);
26
- return (_currentArray$at$name = currentArray.at(-1)?.name) !== null && _currentArray$at$name !== void 0 ? _currentArray$at$name : null;
28
+ return currentArray.at(-1)?.name ?? null;
27
29
  };
28
30
  }
29
- var _default = exports.default = createCurrentHook;
30
- //# sourceMappingURL=createCurrentHook.js.map
31
+ var createCurrentHook_default = createCurrentHook;
32
+ //# sourceMappingURL=createCurrentHook.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createCurrentHook","hooks","storeKey","currentHook","_currentArray$at$name","hooksStore","currentArray","Array","from","__current","at","name","_default","exports","default"],"sources":["@wordpress/hooks/src/createCurrentHook.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Hooks, StoreKey } from './types';\n\n/**\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 hooks Hooks instance.\n * @param storeKey\n *\n * @return Function that returns the current hook name or null.\n */\nfunction createCurrentHook(\n\thooks: Hooks,\n\tstoreKey: StoreKey\n): () => string | null {\n\treturn function currentHook() {\n\t\tconst hooksStore = hooks[ storeKey ];\n\t\tconst currentArray = Array.from( hooksStore.__current );\n\t\treturn currentArray.at( -1 )?.name ?? null;\n\t};\n}\n\nexport default createCurrentHook;\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAiBA,CACzBC,KAAY,EACZC,QAAkB,EACI;EACtB,OAAO,SAASC,WAAWA,CAAA,EAAG;IAAA,IAAAC,qBAAA;IAC7B,MAAMC,UAAU,GAAGJ,KAAK,CAAEC,QAAQ,CAAE;IACpC,MAAMI,YAAY,GAAGC,KAAK,CAACC,IAAI,CAAEH,UAAU,CAACI,SAAU,CAAC;IACvD,QAAAL,qBAAA,GAAOE,YAAY,CAACI,EAAE,CAAE,CAAC,CAAE,CAAC,EAAEC,IAAI,cAAAP,qBAAA,cAAAA,qBAAA,GAAI,IAAI;EAC3C,CAAC;AACF;AAAC,IAAAQ,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcd,iBAAiB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createCurrentHook.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Hooks, StoreKey } from './types';\n\n/**\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 hooks Hooks instance.\n * @param storeKey\n *\n * @return Function that returns the current hook name or null.\n */\nfunction createCurrentHook(\n\thooks: Hooks,\n\tstoreKey: StoreKey\n): () => string | null {\n\treturn function currentHook() {\n\t\tconst hooksStore = hooks[ storeKey ];\n\t\tconst currentArray = Array.from( hooksStore.__current );\n\t\treturn currentArray.at( -1 )?.name ?? null;\n\t};\n}\n\nexport default createCurrentHook;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,SAAS,kBACR,OACA,UACsB;AACtB,SAAO,SAAS,cAAc;AAC7B,UAAM,aAAa,MAAO,QAAS;AACnC,UAAM,eAAe,MAAM,KAAM,WAAW,SAAU;AACtD,WAAO,aAAa,GAAI,EAAG,GAAG,QAAQ;AAAA,EACvC;AACD;AAEA,IAAO,4BAAQ;",
6
+ "names": []
7
+ }
@@ -1,38 +1,45 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var createDidHook_exports = {};
30
+ __export(createDidHook_exports, {
31
+ default: () => createDidHook_default
6
32
  });
7
- exports.default = void 0;
8
- var _validateHookName = _interopRequireDefault(require("./validateHookName"));
9
- /**
10
- * Internal dependencies
11
- */
12
-
13
- /**
14
- *
15
- * Returns the number of times an action has been fired.
16
- *
17
- */
18
-
19
- /**
20
- * Returns a function which, when invoked, will return the number of times a
21
- * hook has been called.
22
- *
23
- * @param hooks Hooks instance.
24
- * @param storeKey
25
- *
26
- * @return Function that returns a hook's call count.
27
- */
33
+ module.exports = __toCommonJS(createDidHook_exports);
34
+ var import_validateHookName = __toESM(require("./validateHookName"));
28
35
  function createDidHook(hooks, storeKey) {
29
36
  return function didHook(hookName) {
30
37
  const hooksStore = hooks[storeKey];
31
- if (!(0, _validateHookName.default)(hookName)) {
38
+ if (!(0, import_validateHookName.default)(hookName)) {
32
39
  return;
33
40
  }
34
41
  return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
35
42
  };
36
43
  }
37
- var _default = exports.default = createDidHook;
38
- //# sourceMappingURL=createDidHook.js.map
44
+ var createDidHook_default = createDidHook;
45
+ //# sourceMappingURL=createDidHook.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_validateHookName","_interopRequireDefault","require","createDidHook","hooks","storeKey","didHook","hookName","hooksStore","validateHookName","runs","_default","exports","default"],"sources":["@wordpress/hooks/src/createDidHook.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport validateHookName from './validateHookName';\nimport type { Hooks, StoreKey } from './types';\n\n/**\n *\n * Returns the number of times an action has been fired.\n *\n */\nexport type DidHook = (\n\t/**\n\t * The hook name to check.\n\t */\n\thookName: string\n) => number | undefined;\n\n/**\n * Returns a function which, when invoked, will return the number of times a\n * hook has been called.\n *\n * @param hooks Hooks instance.\n * @param storeKey\n *\n * @return Function that returns a hook's call count.\n */\nfunction createDidHook( hooks: Hooks, storeKey: StoreKey ): DidHook {\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;;AAIA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAAEC,KAAY,EAAEC,QAAkB,EAAY;EACnE,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":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createDidHook.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport validateHookName from './validateHookName';\nimport type { Hooks, StoreKey } from './types';\n\n/**\n *\n * Returns the number of times an action has been fired.\n *\n */\nexport type DidHook = (\n\t/**\n\t * The hook name to check.\n\t */\n\thookName: string\n) => number | undefined;\n\n/**\n * Returns a function which, when invoked, will return the number of times a\n * hook has been called.\n *\n * @param hooks Hooks instance.\n * @param storeKey\n *\n * @return Function that returns a hook's call count.\n */\nfunction createDidHook( hooks: Hooks, storeKey: StoreKey ): DidHook {\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,8BAA6B;AAwB7B,SAAS,cAAe,OAAc,UAA8B;AACnE,SAAO,SAAS,QAAS,UAAW;AACnC,UAAM,aAAa,MAAO,QAAS;AAEnC,QAAK,KAAE,wBAAAA,SAAkB,QAAS,GAAI;AACrC;AAAA,IACD;AAEA,WAAO,WAAY,QAAS,KAAK,WAAY,QAAS,EAAE,OACrD,WAAY,QAAS,EAAE,OACvB;AAAA,EACJ;AACD;AAEA,IAAO,wBAAQ;",
6
+ "names": ["validateHookName"]
7
+ }
@@ -1,40 +1,36 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var createDoingHook_exports = {};
20
+ __export(createDoingHook_exports, {
21
+ default: () => createDoingHook_default
5
22
  });
6
- exports.default = void 0;
7
- /**
8
- * Internal dependencies
9
- */
10
-
11
- /**
12
- * Returns whether a hook is currently being executed.
13
- *
14
- */
15
-
16
- /**
17
- * Returns a function which, when invoked, will return whether a hook is
18
- * currently being executed.
19
- *
20
- * @param hooks Hooks instance.
21
- * @param storeKey
22
- *
23
- * @return Function that returns whether a hook is currently
24
- * being executed.
25
- */
23
+ module.exports = __toCommonJS(createDoingHook_exports);
26
24
  function createDoingHook(hooks, storeKey) {
27
25
  return function doingHook(hookName) {
28
26
  const hooksStore = hooks[storeKey];
29
-
30
- // If the hookName was not passed, check for any current hook.
31
- if ('undefined' === typeof hookName) {
27
+ if ("undefined" === typeof hookName) {
32
28
  return hooksStore.__current.size > 0;
33
29
  }
34
-
35
- // Find if the `hookName` hook is in `__current`.
36
- return Array.from(hooksStore.__current).some(hook => hook.name === hookName);
30
+ return Array.from(hooksStore.__current).some(
31
+ (hook) => hook.name === hookName
32
+ );
37
33
  };
38
34
  }
39
- var _default = exports.default = createDoingHook;
40
- //# sourceMappingURL=createDoingHook.js.map
35
+ var createDoingHook_default = createDoingHook;
36
+ //# sourceMappingURL=createDoingHook.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createDoingHook","hooks","storeKey","doingHook","hookName","hooksStore","__current","size","Array","from","some","hook","name","_default","exports","default"],"sources":["@wordpress/hooks/src/createDoingHook.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Hooks, StoreKey } from './types';\n\n/**\n * Returns whether a hook is currently being executed.\n *\n */\nexport type DoingHook = (\n\t/**\n\t * The name of the hook to check for.\n\t * If omitted, will check for any hook being executed.\n\t */ hookName?: string\n) => boolean;\n\n/**\n * Returns a function which, when invoked, will return whether a hook is\n * currently being executed.\n *\n * @param hooks Hooks instance.\n * @param storeKey\n *\n * @return Function that returns whether a hook is currently\n * being executed.\n */\nfunction createDoingHook( hooks: Hooks, storeKey: StoreKey ): DoingHook {\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 hooksStore.__current.size > 0;\n\t\t}\n\n\t\t// Find if the `hookName` hook is in `__current`.\n\t\treturn Array.from( hooksStore.__current ).some(\n\t\t\t( hook ) => hook.name === hookName\n\t\t);\n\t};\n}\n\nexport default createDoingHook;\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,eAAeA,CAAEC,KAAY,EAAEC,QAAkB,EAAc;EACvE,OAAO,SAASC,SAASA,CAAEC,QAAQ,EAAG;IACrC,MAAMC,UAAU,GAAGJ,KAAK,CAAEC,QAAQ,CAAE;;IAEpC;IACA,IAAK,WAAW,KAAK,OAAOE,QAAQ,EAAG;MACtC,OAAOC,UAAU,CAACC,SAAS,CAACC,IAAI,GAAG,CAAC;IACrC;;IAEA;IACA,OAAOC,KAAK,CAACC,IAAI,CAAEJ,UAAU,CAACC,SAAU,CAAC,CAACI,IAAI,CAC3CC,IAAI,IAAMA,IAAI,CAACC,IAAI,KAAKR,QAC3B,CAAC;EACF,CAAC;AACF;AAAC,IAAAS,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcf,eAAe","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createDoingHook.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Hooks, StoreKey } from './types';\n\n/**\n * Returns whether a hook is currently being executed.\n *\n */\nexport type DoingHook = (\n\t/**\n\t * The name of the hook to check for.\n\t * If omitted, will check for any hook being executed.\n\t */ hookName?: string\n) => boolean;\n\n/**\n * Returns a function which, when invoked, will return whether a hook is\n * currently being executed.\n *\n * @param hooks Hooks instance.\n * @param storeKey\n *\n * @return Function that returns whether a hook is currently\n * being executed.\n */\nfunction createDoingHook( hooks: Hooks, storeKey: StoreKey ): DoingHook {\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 hooksStore.__current.size > 0;\n\t\t}\n\n\t\t// Find if the `hookName` hook is in `__current`.\n\t\treturn Array.from( hooksStore.__current ).some(\n\t\t\t( hook ) => hook.name === hookName\n\t\t);\n\t};\n}\n\nexport default createDoingHook;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BA,SAAS,gBAAiB,OAAc,UAAgC;AACvE,SAAO,SAAS,UAAW,UAAW;AACrC,UAAM,aAAa,MAAO,QAAS;AAGnC,QAAK,gBAAgB,OAAO,UAAW;AACtC,aAAO,WAAW,UAAU,OAAO;AAAA,IACpC;AAGA,WAAO,MAAM,KAAM,WAAW,SAAU,EAAE;AAAA,MACzC,CAAE,SAAU,KAAK,SAAS;AAAA,IAC3B;AAAA,EACD;AACD;AAEA,IAAO,0BAAQ;",
6
+ "names": []
7
+ }
@@ -1,38 +1,36 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var createHasHook_exports = {};
20
+ __export(createHasHook_exports, {
21
+ default: () => createHasHook_default
5
22
  });
6
- exports.default = void 0;
7
- /**
8
- * Internal dependencies
9
- */
10
-
11
- /**
12
- *
13
- * Returns whether any handlers are attached for the given hookName and optional namespace.
14
- */
15
-
16
- /**
17
- * Returns a function which, when invoked, will return whether any handlers are
18
- * attached to a particular hook.
19
- *
20
- * @param hooks Hooks instance.
21
- * @param storeKey
22
- *
23
- * @return Function that returns whether any handlers are
24
- * attached to a particular hook and optional namespace.
25
- */
23
+ module.exports = __toCommonJS(createHasHook_exports);
26
24
  function createHasHook(hooks, storeKey) {
27
25
  return function hasHook(hookName, namespace) {
28
26
  const hooksStore = hooks[storeKey];
29
-
30
- // Use the namespace if provided.
31
- if ('undefined' !== typeof namespace) {
32
- return hookName in hooksStore && hooksStore[hookName].handlers.some(hook => hook.namespace === namespace);
27
+ if ("undefined" !== typeof namespace) {
28
+ return hookName in hooksStore && hooksStore[hookName].handlers.some(
29
+ (hook) => hook.namespace === namespace
30
+ );
33
31
  }
34
32
  return hookName in hooksStore;
35
33
  };
36
34
  }
37
- var _default = exports.default = createHasHook;
38
- //# sourceMappingURL=createHasHook.js.map
35
+ var createHasHook_default = createHasHook;
36
+ //# sourceMappingURL=createHasHook.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createHasHook","hooks","storeKey","hasHook","hookName","namespace","hooksStore","handlers","some","hook","_default","exports","default"],"sources":["@wordpress/hooks/src/createHasHook.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Hooks, StoreKey } from './types';\n/**\n *\n * Returns whether any handlers are attached for the given hookName and optional namespace.\n */\nexport type HasHook = (\n\t/**\n\t * The name of the hook to check for.\n\t */\n\thookname: string,\n\t/**\n\t * The unique namespace identifying the callback in the form `vendor/plugin/function`.\n\t */\n\tnamespace?: string\n) => boolean;\n\n/**\n * Returns a function which, when invoked, will return whether any handlers are\n * attached to a particular hook.\n *\n * @param hooks Hooks instance.\n * @param storeKey\n *\n * @return Function that returns whether any handlers are\n * attached to a particular hook and optional namespace.\n */\nfunction createHasHook( hooks: Hooks, storeKey: StoreKey ): HasHook {\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;;AAEA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAaA,CAAEC,KAAY,EAAEC,QAAkB,EAAY;EACnE,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":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createHasHook.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Hooks, StoreKey } from './types';\n/**\n *\n * Returns whether any handlers are attached for the given hookName and optional namespace.\n */\nexport type HasHook = (\n\t/**\n\t * The name of the hook to check for.\n\t */\n\thookname: string,\n\t/**\n\t * The unique namespace identifying the callback in the form `vendor/plugin/function`.\n\t */\n\tnamespace?: string\n) => boolean;\n\n/**\n * Returns a function which, when invoked, will return whether any handlers are\n * attached to a particular hook.\n *\n * @param hooks Hooks instance.\n * @param storeKey\n *\n * @return Function that returns whether any handlers are\n * attached to a particular hook and optional namespace.\n */\nfunction createHasHook( hooks: Hooks, storeKey: StoreKey ): HasHook {\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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,SAAS,cAAe,OAAc,UAA8B;AACnE,SAAO,SAAS,QAAS,UAAU,WAAY;AAC9C,UAAM,aAAa,MAAO,QAAS;AAGnC,QAAK,gBAAgB,OAAO,WAAY;AACvC,aACC,YAAY,cACZ,WAAY,QAAS,EAAE,SAAS;AAAA,QAC/B,CAAE,SAAU,KAAK,cAAc;AAAA,MAChC;AAAA,IAEF;AAEA,WAAO,YAAY;AAAA,EACpB;AACD;AAEA,IAAO,wBAAQ;",
6
+ "names": []
7
+ }