@wordpress/hooks 4.32.0 → 4.32.1-next.b8c8708f3.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 (49) hide show
  1. package/build/createAddHook.js +53 -53
  2. package/build/createAddHook.js.map +7 -1
  3. package/build/createCurrentHook.js +24 -22
  4. package/build/createCurrentHook.js.map +7 -1
  5. package/build/createDidHook.js +35 -28
  6. package/build/createDidHook.js.map +7 -1
  7. package/build/createDoingHook.js +27 -31
  8. package/build/createDoingHook.js.map +7 -1
  9. package/build/createHasHook.js +27 -29
  10. package/build/createHasHook.js.map +7 -1
  11. package/build/createHooks.js +87 -53
  12. package/build/createHooks.js.map +7 -1
  13. package/build/createRemoveHook.js +40 -43
  14. package/build/createRemoveHook.js.map +7 -1
  15. package/build/createRunHook.js +30 -32
  16. package/build/createRunHook.js.map +7 -1
  17. package/build/index.js +81 -73
  18. package/build/index.js.map +7 -1
  19. package/build/types.js +16 -5
  20. package/build/types.js.map +7 -1
  21. package/build/validateHookName.js +29 -22
  22. package/build/validateHookName.js.map +7 -1
  23. package/build/validateNamespace.js +28 -19
  24. package/build/validateNamespace.js.map +7 -1
  25. package/build-module/createAddHook.js +23 -46
  26. package/build-module/createAddHook.js.map +7 -1
  27. package/build-module/createCurrentHook.js +6 -18
  28. package/build-module/createCurrentHook.js.map +7 -1
  29. package/build-module/createDidHook.js +6 -22
  30. package/build-module/createDidHook.js.map +7 -1
  31. package/build-module/createDoingHook.js +9 -27
  32. package/build-module/createDoingHook.js.map +7 -1
  33. package/build-module/createHasHook.js +9 -25
  34. package/build-module/createHasHook.js.map +7 -1
  35. package/build-module/createHooks.js +56 -47
  36. package/build-module/createHooks.js.map +7 -1
  37. package/build-module/createRemoveHook.js +10 -36
  38. package/build-module/createRemoveHook.js.map +7 -1
  39. package/build-module/createRunHook.js +12 -28
  40. package/build-module/createRunHook.js.map +7 -1
  41. package/build-module/index.js +28 -8
  42. package/build-module/index.js.map +7 -1
  43. package/build-module/types.js +1 -2
  44. package/build-module/types.js.map +7 -1
  45. package/build-module/validateHookName.js +11 -18
  46. package/build-module/validateHookName.js.map +7 -1
  47. package/build-module/validateNamespace.js +10 -15
  48. package/build-module/validateNamespace.js.map +7 -1
  49. package/package.json +10 -5
@@ -1,53 +1,62 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import createAddHook from './createAddHook';
5
- import createRemoveHook from './createRemoveHook';
6
- import createHasHook from './createHasHook';
7
- import createRunHook from './createRunHook';
8
- import createCurrentHook from './createCurrentHook';
9
- import createDoingHook from './createDoingHook';
10
- import createDidHook from './createDidHook';
11
- /**
12
- * Internal class for constructing hooks. Use `createHooks()` function
13
- *
14
- * Note, it is necessary to expose this class to make its type public.
15
- *
16
- * @private
17
- */
18
- export class _Hooks {
1
+ import createAddHook from "./createAddHook";
2
+ import createRemoveHook from "./createRemoveHook";
3
+ import createHasHook from "./createHasHook";
4
+ import createRunHook from "./createRunHook";
5
+ import createCurrentHook from "./createCurrentHook";
6
+ import createDoingHook from "./createDoingHook";
7
+ import createDidHook from "./createDidHook";
8
+ class _Hooks {
9
+ actions;
10
+ filters;
11
+ addAction;
12
+ addFilter;
13
+ removeAction;
14
+ removeFilter;
15
+ hasAction;
16
+ hasFilter;
17
+ removeAllActions;
18
+ removeAllFilters;
19
+ doAction;
20
+ doActionAsync;
21
+ applyFilters;
22
+ applyFiltersAsync;
23
+ currentAction;
24
+ currentFilter;
25
+ doingAction;
26
+ doingFilter;
27
+ didAction;
28
+ didFilter;
19
29
  constructor() {
20
- this.actions = Object.create(null);
21
- this.actions.__current = new Set();
22
- this.filters = Object.create(null);
23
- this.filters.__current = new Set();
24
- this.addAction = createAddHook(this, 'actions');
25
- this.addFilter = createAddHook(this, 'filters');
26
- this.removeAction = createRemoveHook(this, 'actions');
27
- this.removeFilter = createRemoveHook(this, 'filters');
28
- this.hasAction = createHasHook(this, 'actions');
29
- this.hasFilter = createHasHook(this, 'filters');
30
- this.removeAllActions = createRemoveHook(this, 'actions', true);
31
- this.removeAllFilters = createRemoveHook(this, 'filters', true);
32
- this.doAction = createRunHook(this, 'actions', false, false);
33
- this.doActionAsync = createRunHook(this, 'actions', false, true);
34
- this.applyFilters = createRunHook(this, 'filters', true, false);
35
- this.applyFiltersAsync = createRunHook(this, 'filters', true, true);
36
- this.currentAction = createCurrentHook(this, 'actions');
37
- this.currentFilter = createCurrentHook(this, 'filters');
38
- this.doingAction = createDoingHook(this, 'actions');
39
- this.doingFilter = createDoingHook(this, 'filters');
40
- this.didAction = createDidHook(this, 'actions');
41
- this.didFilter = createDidHook(this, 'filters');
30
+ this.actions = /* @__PURE__ */ Object.create(null);
31
+ this.actions.__current = /* @__PURE__ */ new Set();
32
+ this.filters = /* @__PURE__ */ Object.create(null);
33
+ this.filters.__current = /* @__PURE__ */ new Set();
34
+ this.addAction = createAddHook(this, "actions");
35
+ this.addFilter = createAddHook(this, "filters");
36
+ this.removeAction = createRemoveHook(this, "actions");
37
+ this.removeFilter = createRemoveHook(this, "filters");
38
+ this.hasAction = createHasHook(this, "actions");
39
+ this.hasFilter = createHasHook(this, "filters");
40
+ this.removeAllActions = createRemoveHook(this, "actions", true);
41
+ this.removeAllFilters = createRemoveHook(this, "filters", true);
42
+ this.doAction = createRunHook(this, "actions", false, false);
43
+ this.doActionAsync = createRunHook(this, "actions", false, true);
44
+ this.applyFilters = createRunHook(this, "filters", true, false);
45
+ this.applyFiltersAsync = createRunHook(this, "filters", true, true);
46
+ this.currentAction = createCurrentHook(this, "actions");
47
+ this.currentFilter = createCurrentHook(this, "filters");
48
+ this.doingAction = createDoingHook(this, "actions");
49
+ this.doingFilter = createDoingHook(this, "filters");
50
+ this.didAction = createDidHook(this, "actions");
51
+ this.didFilter = createDidHook(this, "filters");
42
52
  }
43
53
  }
44
- /**
45
- * Returns an instance of the hooks object.
46
- *
47
- * @return A Hooks instance.
48
- */
49
54
  function createHooks() {
50
55
  return new _Hooks();
51
56
  }
52
- export default createHooks;
53
- //# sourceMappingURL=createHooks.js.map
57
+ var createHooks_default = createHooks;
58
+ export {
59
+ _Hooks,
60
+ createHooks_default as default
61
+ };
62
+ //# sourceMappingURL=createHooks.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createAddHook","createRemoveHook","createHasHook","createRunHook","createCurrentHook","createDoingHook","createDidHook","_Hooks","constructor","actions","Object","create","__current","Set","filters","addAction","addFilter","removeAction","removeFilter","hasAction","hasFilter","removeAllActions","removeAllFilters","doAction","doActionAsync","applyFilters","applyFiltersAsync","currentAction","currentFilter","doingAction","doingFilter","didAction","didFilter","createHooks"],"sources":["@wordpress/hooks/src/createHooks.ts"],"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';\nimport type { Store } from './types';\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\tpublic actions: Store;\n\tpublic filters: Store;\n\n\tpublic addAction: ReturnType< typeof createAddHook >;\n\tpublic addFilter: ReturnType< typeof createAddHook >;\n\tpublic removeAction: ReturnType< typeof createRemoveHook >;\n\tpublic removeFilter: ReturnType< typeof createRemoveHook >;\n\tpublic hasAction: ReturnType< typeof createHasHook >;\n\tpublic hasFilter: ReturnType< typeof createHasHook >;\n\tpublic removeAllActions: ReturnType< typeof createRemoveHook >;\n\tpublic removeAllFilters: ReturnType< typeof createRemoveHook >;\n\tpublic doAction: ReturnType< typeof createRunHook >;\n\tpublic doActionAsync: ReturnType< typeof createRunHook >;\n\tpublic applyFilters: ReturnType< typeof createRunHook >;\n\tpublic applyFiltersAsync: ReturnType< typeof createRunHook >;\n\tpublic currentAction: ReturnType< typeof createCurrentHook >;\n\tpublic currentFilter: ReturnType< typeof createCurrentHook >;\n\tpublic doingAction: ReturnType< typeof createDoingHook >;\n\tpublic doingFilter: ReturnType< typeof createDoingHook >;\n\tpublic didAction: ReturnType< typeof createDidHook >;\n\tpublic didFilter: ReturnType< typeof createDidHook >;\n\n\tconstructor() {\n\t\tthis.actions = Object.create( null );\n\t\tthis.actions.__current = new Set();\n\n\t\tthis.filters = Object.create( null );\n\t\tthis.filters.__current = new Set();\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', false, false );\n\t\tthis.doActionAsync = createRunHook( this, 'actions', false, true );\n\t\tthis.applyFilters = createRunHook( this, 'filters', true, false );\n\t\tthis.applyFiltersAsync = createRunHook( this, 'filters', true, 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\nexport type Hooks = _Hooks;\n\n/**\n * Returns an instance of the hooks object.\n *\n * @return A Hooks instance.\n */\nfunction createHooks(): Hooks {\n\treturn new _Hooks();\n}\n\nexport default createHooks;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,aAAa,MAAM,iBAAiB;AAG3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,MAAM,CAAC;EAuBnBC,WAAWA,CAAA,EAAG;IACb,IAAI,CAACC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAAE,IAAK,CAAC;IACpC,IAAI,CAACF,OAAO,CAACG,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;IAElC,IAAI,CAACC,OAAO,GAAGJ,MAAM,CAACC,MAAM,CAAE,IAAK,CAAC;IACpC,IAAI,CAACG,OAAO,CAACF,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;IAElC,IAAI,CAACE,SAAS,GAAGf,aAAa,CAAE,IAAI,EAAE,SAAU,CAAC;IACjD,IAAI,CAACgB,SAAS,GAAGhB,aAAa,CAAE,IAAI,EAAE,SAAU,CAAC;IACjD,IAAI,CAACiB,YAAY,GAAGhB,gBAAgB,CAAE,IAAI,EAAE,SAAU,CAAC;IACvD,IAAI,CAACiB,YAAY,GAAGjB,gBAAgB,CAAE,IAAI,EAAE,SAAU,CAAC;IACvD,IAAI,CAACkB,SAAS,GAAGjB,aAAa,CAAE,IAAI,EAAE,SAAU,CAAC;IACjD,IAAI,CAACkB,SAAS,GAAGlB,aAAa,CAAE,IAAI,EAAE,SAAU,CAAC;IACjD,IAAI,CAACmB,gBAAgB,GAAGpB,gBAAgB,CAAE,IAAI,EAAE,SAAS,EAAE,IAAK,CAAC;IACjE,IAAI,CAACqB,gBAAgB,GAAGrB,gBAAgB,CAAE,IAAI,EAAE,SAAS,EAAE,IAAK,CAAC;IACjE,IAAI,CAACsB,QAAQ,GAAGpB,aAAa,CAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAM,CAAC;IAC9D,IAAI,CAACqB,aAAa,GAAGrB,aAAa,CAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAK,CAAC;IAClE,IAAI,CAACsB,YAAY,GAAGtB,aAAa,CAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAM,CAAC;IACjE,IAAI,CAACuB,iBAAiB,GAAGvB,aAAa,CAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAK,CAAC;IACrE,IAAI,CAACwB,aAAa,GAAGvB,iBAAiB,CAAE,IAAI,EAAE,SAAU,CAAC;IACzD,IAAI,CAACwB,aAAa,GAAGxB,iBAAiB,CAAE,IAAI,EAAE,SAAU,CAAC;IACzD,IAAI,CAACyB,WAAW,GAAGxB,eAAe,CAAE,IAAI,EAAE,SAAU,CAAC;IACrD,IAAI,CAACyB,WAAW,GAAGzB,eAAe,CAAE,IAAI,EAAE,SAAU,CAAC;IACrD,IAAI,CAAC0B,SAAS,GAAGzB,aAAa,CAAE,IAAI,EAAE,SAAU,CAAC;IACjD,IAAI,CAAC0B,SAAS,GAAG1B,aAAa,CAAE,IAAI,EAAE,SAAU,CAAC;EAClD;AACD;AAIA;AACA;AACA;AACA;AACA;AACA,SAAS2B,WAAWA,CAAA,EAAU;EAC7B,OAAO,IAAI1B,MAAM,CAAC,CAAC;AACpB;AAEA,eAAe0B,WAAW","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createHooks.ts"],
4
+ "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';\nimport type { Store } from './types';\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\tpublic actions: Store;\n\tpublic filters: Store;\n\n\tpublic addAction: ReturnType< typeof createAddHook >;\n\tpublic addFilter: ReturnType< typeof createAddHook >;\n\tpublic removeAction: ReturnType< typeof createRemoveHook >;\n\tpublic removeFilter: ReturnType< typeof createRemoveHook >;\n\tpublic hasAction: ReturnType< typeof createHasHook >;\n\tpublic hasFilter: ReturnType< typeof createHasHook >;\n\tpublic removeAllActions: ReturnType< typeof createRemoveHook >;\n\tpublic removeAllFilters: ReturnType< typeof createRemoveHook >;\n\tpublic doAction: ReturnType< typeof createRunHook >;\n\tpublic doActionAsync: ReturnType< typeof createRunHook >;\n\tpublic applyFilters: ReturnType< typeof createRunHook >;\n\tpublic applyFiltersAsync: ReturnType< typeof createRunHook >;\n\tpublic currentAction: ReturnType< typeof createCurrentHook >;\n\tpublic currentFilter: ReturnType< typeof createCurrentHook >;\n\tpublic doingAction: ReturnType< typeof createDoingHook >;\n\tpublic doingFilter: ReturnType< typeof createDoingHook >;\n\tpublic didAction: ReturnType< typeof createDidHook >;\n\tpublic didFilter: ReturnType< typeof createDidHook >;\n\n\tconstructor() {\n\t\tthis.actions = Object.create( null );\n\t\tthis.actions.__current = new Set();\n\n\t\tthis.filters = Object.create( null );\n\t\tthis.filters.__current = new Set();\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', false, false );\n\t\tthis.doActionAsync = createRunHook( this, 'actions', false, true );\n\t\tthis.applyFilters = createRunHook( this, 'filters', true, false );\n\t\tthis.applyFiltersAsync = createRunHook( this, 'filters', true, 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\nexport type Hooks = _Hooks;\n\n/**\n * Returns an instance of the hooks object.\n *\n * @return A Hooks instance.\n */\nfunction createHooks(): Hooks {\n\treturn new _Hooks();\n}\n\nexport default createHooks;\n"],
5
+ "mappings": "AAGA,OAAO,mBAAmB;AAC1B,OAAO,sBAAsB;AAC7B,OAAO,mBAAmB;AAC1B,OAAO,mBAAmB;AAC1B,OAAO,uBAAuB;AAC9B,OAAO,qBAAqB;AAC5B,OAAO,mBAAmB;AAUnB,MAAM,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEP,cAAc;AACb,SAAK,UAAU,uBAAO,OAAQ,IAAK;AACnC,SAAK,QAAQ,YAAY,oBAAI,IAAI;AAEjC,SAAK,UAAU,uBAAO,OAAQ,IAAK;AACnC,SAAK,QAAQ,YAAY,oBAAI,IAAI;AAEjC,SAAK,YAAY,cAAe,MAAM,SAAU;AAChD,SAAK,YAAY,cAAe,MAAM,SAAU;AAChD,SAAK,eAAe,iBAAkB,MAAM,SAAU;AACtD,SAAK,eAAe,iBAAkB,MAAM,SAAU;AACtD,SAAK,YAAY,cAAe,MAAM,SAAU;AAChD,SAAK,YAAY,cAAe,MAAM,SAAU;AAChD,SAAK,mBAAmB,iBAAkB,MAAM,WAAW,IAAK;AAChE,SAAK,mBAAmB,iBAAkB,MAAM,WAAW,IAAK;AAChE,SAAK,WAAW,cAAe,MAAM,WAAW,OAAO,KAAM;AAC7D,SAAK,gBAAgB,cAAe,MAAM,WAAW,OAAO,IAAK;AACjE,SAAK,eAAe,cAAe,MAAM,WAAW,MAAM,KAAM;AAChE,SAAK,oBAAoB,cAAe,MAAM,WAAW,MAAM,IAAK;AACpE,SAAK,gBAAgB,kBAAmB,MAAM,SAAU;AACxD,SAAK,gBAAgB,kBAAmB,MAAM,SAAU;AACxD,SAAK,cAAc,gBAAiB,MAAM,SAAU;AACpD,SAAK,cAAc,gBAAiB,MAAM,SAAU;AACpD,SAAK,YAAY,cAAe,MAAM,SAAU;AAChD,SAAK,YAAY,cAAe,MAAM,SAAU;AAAA,EACjD;AACD;AASA,SAAS,cAAqB;AAC7B,SAAO,IAAI,OAAO;AACnB;AAEA,IAAO,sBAAQ;",
6
+ "names": []
7
+ }
@@ -1,26 +1,5 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import validateNamespace from './validateNamespace';
5
- import validateHookName from './validateHookName';
6
-
7
- /**
8
- * Removes the specified callback (or all callbacks) from the hook with a given hookName
9
- * and namespace.
10
- */
11
-
12
- /**
13
- * Returns a function which, when invoked, will remove a specified hook or all
14
- * hooks by the given name.
15
- *
16
- * @param hooks Hooks instance.
17
- * @param storeKey
18
- * @param [removeAll=false] Whether to remove all callbacks for a hookName,
19
- * without regard to namespace. Used to create
20
- * `removeAll*` functions.
21
- *
22
- * @return Function that removes hooks.
23
- */
1
+ import validateNamespace from "./validateNamespace";
2
+ import validateHookName from "./validateHookName";
24
3
  function createRemoveHook(hooks, storeKey, removeAll = false) {
25
4
  return function removeHook(hookName, namespace) {
26
5
  const hooksStore = hooks[storeKey];
@@ -30,8 +9,6 @@ function createRemoveHook(hooks, storeKey, removeAll = false) {
30
9
  if (!removeAll && !validateNamespace(namespace)) {
31
10
  return;
32
11
  }
33
-
34
- // Bail if no hooks exist by this name.
35
12
  if (!hooksStore[hookName]) {
36
13
  return 0;
37
14
  }
@@ -43,18 +20,12 @@ function createRemoveHook(hooks, storeKey, removeAll = false) {
43
20
  handlers: []
44
21
  };
45
22
  } else {
46
- // Try to find the specified callback to remove.
47
23
  const handlers = hooksStore[hookName].handlers;
48
24
  for (let i = handlers.length - 1; i >= 0; i--) {
49
25
  if (handlers[i].namespace === namespace) {
50
26
  handlers.splice(i, 1);
51
27
  handlersRemoved++;
52
- // This callback may also be part of a hook that is
53
- // currently executing. If the callback we're removing
54
- // comes after the current callback, there's no problem;
55
- // otherwise we need to decrease the execution index of any
56
- // other runs by 1 to account for the removed element.
57
- hooksStore.__current.forEach(hookInfo => {
28
+ hooksStore.__current.forEach((hookInfo) => {
58
29
  if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
59
30
  hookInfo.currentIndex--;
60
31
  }
@@ -62,11 +33,14 @@ function createRemoveHook(hooks, storeKey, removeAll = false) {
62
33
  }
63
34
  }
64
35
  }
65
- if (hookName !== 'hookRemoved') {
66
- hooks.doAction('hookRemoved', hookName, namespace);
36
+ if (hookName !== "hookRemoved") {
37
+ hooks.doAction("hookRemoved", hookName, namespace);
67
38
  }
68
39
  return handlersRemoved;
69
40
  };
70
41
  }
71
- export default createRemoveHook;
72
- //# sourceMappingURL=createRemoveHook.js.map
42
+ var createRemoveHook_default = createRemoveHook;
43
+ export {
44
+ createRemoveHook_default as default
45
+ };
46
+ //# sourceMappingURL=createRemoveHook.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["validateNamespace","validateHookName","createRemoveHook","hooks","storeKey","removeAll","removeHook","hookName","namespace","hooksStore","handlersRemoved","handlers","length","runs","i","splice","__current","forEach","hookInfo","name","currentIndex","doAction"],"sources":["@wordpress/hooks/src/createRemoveHook.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace';\nimport validateHookName from './validateHookName';\nimport type { Hooks, StoreKey } from './types';\n\n/**\n * Removes the specified callback (or all callbacks) from the hook with a given hookName\n * and namespace.\n */\nexport type RemoveHook = (\n\t/**\n\t * The name of the hook to modify.\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) => number | undefined;\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 hooks Hooks instance.\n * @param storeKey\n * @param [removeAll=false] Whether to remove all callbacks for a hookName,\n * without regard to namespace. Used to create\n * `removeAll*` functions.\n *\n * @return Function that removes hooks.\n */\nfunction createRemoveHook(\n\thooks: Hooks,\n\tstoreKey: StoreKey,\n\tremoveAll: boolean = false\n): RemoveHook {\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":"AAAA;AACA;AACA;AACA,OAAOA,iBAAiB,MAAM,qBAAqB;AACnD,OAAOC,gBAAgB,MAAM,oBAAoB;;AAGjD;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CACxBC,KAAY,EACZC,QAAkB,EAClBC,SAAkB,GAAG,KAAK,EACb;EACb,OAAO,SAASC,UAAUA,CAAEC,QAAQ,EAAEC,SAAS,EAAG;IACjD,MAAMC,UAAU,GAAGN,KAAK,CAAEC,QAAQ,CAAE;IAEpC,IAAK,CAAEH,gBAAgB,CAAEM,QAAS,CAAC,EAAG;MACrC;IACD;IAEA,IAAK,CAAEF,SAAS,IAAI,CAAEL,iBAAiB,CAAEQ,SAAU,CAAC,EAAG;MACtD;IACD;;IAEA;IACA,IAAK,CAAEC,UAAU,CAAEF,QAAQ,CAAE,EAAG;MAC/B,OAAO,CAAC;IACT;IAEA,IAAIG,eAAe,GAAG,CAAC;IAEvB,IAAKL,SAAS,EAAG;MAChBK,eAAe,GAAGD,UAAU,CAAEF,QAAQ,CAAE,CAACI,QAAQ,CAACC,MAAM;MACxDH,UAAU,CAAEF,QAAQ,CAAE,GAAG;QACxBM,IAAI,EAAEJ,UAAU,CAAEF,QAAQ,CAAE,CAACM,IAAI;QACjCF,QAAQ,EAAE;MACX,CAAC;IACF,CAAC,MAAM;MACN;MACA,MAAMA,QAAQ,GAAGF,UAAU,CAAEF,QAAQ,CAAE,CAACI,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,CAACN,SAAS,KAAKA,SAAS,EAAG;UAC5CG,QAAQ,CAACI,MAAM,CAAED,CAAC,EAAE,CAAE,CAAC;UACvBJ,eAAe,EAAE;UACjB;UACA;UACA;UACA;UACA;UACAD,UAAU,CAACO,SAAS,CAACC,OAAO,CAAIC,QAAQ,IAAM;YAC7C,IACCA,QAAQ,CAACC,IAAI,KAAKZ,QAAQ,IAC1BW,QAAQ,CAACE,YAAY,IAAIN,CAAC,EACzB;cACDI,QAAQ,CAACE,YAAY,EAAE;YACxB;UACD,CAAE,CAAC;QACJ;MACD;IACD;IAEA,IAAKb,QAAQ,KAAK,aAAa,EAAG;MACjCJ,KAAK,CAACkB,QAAQ,CAAE,aAAa,EAAEd,QAAQ,EAAEC,SAAU,CAAC;IACrD;IAEA,OAAOE,eAAe;EACvB,CAAC;AACF;AAEA,eAAeR,gBAAgB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createRemoveHook.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace';\nimport validateHookName from './validateHookName';\nimport type { Hooks, StoreKey } from './types';\n\n/**\n * Removes the specified callback (or all callbacks) from the hook with a given hookName\n * and namespace.\n */\nexport type RemoveHook = (\n\t/**\n\t * The name of the hook to modify.\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) => number | undefined;\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 hooks Hooks instance.\n * @param storeKey\n * @param [removeAll=false] Whether to remove all callbacks for a hookName,\n * without regard to namespace. Used to create\n * `removeAll*` functions.\n *\n * @return Function that removes hooks.\n */\nfunction createRemoveHook(\n\thooks: Hooks,\n\tstoreKey: StoreKey,\n\tremoveAll: boolean = false\n): RemoveHook {\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"],
5
+ "mappings": "AAGA,OAAO,uBAAuB;AAC9B,OAAO,sBAAsB;AA8B7B,SAAS,iBACR,OACA,UACA,YAAqB,OACR;AACb,SAAO,SAAS,WAAY,UAAU,WAAY;AACjD,UAAM,aAAa,MAAO,QAAS;AAEnC,QAAK,CAAE,iBAAkB,QAAS,GAAI;AACrC;AAAA,IACD;AAEA,QAAK,CAAE,aAAa,CAAE,kBAAmB,SAAU,GAAI;AACtD;AAAA,IACD;AAGA,QAAK,CAAE,WAAY,QAAS,GAAI;AAC/B,aAAO;AAAA,IACR;AAEA,QAAI,kBAAkB;AAEtB,QAAK,WAAY;AAChB,wBAAkB,WAAY,QAAS,EAAE,SAAS;AAClD,iBAAY,QAAS,IAAI;AAAA,QACxB,MAAM,WAAY,QAAS,EAAE;AAAA,QAC7B,UAAU,CAAC;AAAA,MACZ;AAAA,IACD,OAAO;AAEN,YAAM,WAAW,WAAY,QAAS,EAAE;AACxC,eAAU,IAAI,SAAS,SAAS,GAAG,KAAK,GAAG,KAAM;AAChD,YAAK,SAAU,CAAE,EAAE,cAAc,WAAY;AAC5C,mBAAS,OAAQ,GAAG,CAAE;AACtB;AAMA,qBAAW,UAAU,QAAS,CAAE,aAAc;AAC7C,gBACC,SAAS,SAAS,YAClB,SAAS,gBAAgB,GACxB;AACD,uBAAS;AAAA,YACV;AAAA,UACD,CAAE;AAAA,QACH;AAAA,MACD;AAAA,IACD;AAEA,QAAK,aAAa,eAAgB;AACjC,YAAM,SAAU,eAAe,UAAU,SAAU;AAAA,IACpD;AAEA,WAAO;AAAA,EACR;AACD;AAEA,IAAO,2BAAQ;",
6
+ "names": []
7
+ }
@@ -1,19 +1,3 @@
1
- /**
2
- * Internal dependencies
3
- */
4
-
5
- /**
6
- * Returns a function which, when invoked, will execute all callbacks
7
- * registered to a hook of the specified type, optionally returning the final
8
- * value of the call chain.
9
- *
10
- * @param hooks Hooks instance.
11
- * @param storeKey
12
- * @param returnFirstArg Whether each hook callback is expected to return its first argument.
13
- * @param async Whether the hook callback should be run asynchronously
14
- *
15
- * @return Function that runs hook callbacks.
16
- */
17
1
  function createRunHook(hooks, storeKey, returnFirstArg, async) {
18
2
  return function runHook(hookName, ...args) {
19
3
  const hooksStore = hooks[storeKey];
@@ -25,16 +9,13 @@ function createRunHook(hooks, storeKey, returnFirstArg, async) {
25
9
  }
26
10
  hooksStore[hookName].runs++;
27
11
  const handlers = hooksStore[hookName].handlers;
28
-
29
- // The following code is stripped from production builds.
30
- if ('production' !== process.env.NODE_ENV) {
31
- // Handle any 'all' hooks registered.
32
- if ('hookAdded' !== hookName && hooksStore.all) {
12
+ if ("production" !== process.env.NODE_ENV) {
13
+ if ("hookAdded" !== hookName && hooksStore.all) {
33
14
  handlers.push(...hooksStore.all.handlers);
34
15
  }
35
16
  }
36
17
  if (!handlers || !handlers.length) {
37
- return returnFirstArg ? args[0] : undefined;
18
+ return returnFirstArg ? args[0] : void 0;
38
19
  }
39
20
  const hookInfo = {
40
21
  name: hookName,
@@ -43,7 +24,7 @@ function createRunHook(hooks, storeKey, returnFirstArg, async) {
43
24
  async function asyncRunner() {
44
25
  try {
45
26
  hooksStore.__current.add(hookInfo);
46
- let result = returnFirstArg ? args[0] : undefined;
27
+ let result = returnFirstArg ? args[0] : void 0;
47
28
  while (hookInfo.currentIndex < handlers.length) {
48
29
  const handler = handlers[hookInfo.currentIndex];
49
30
  result = await handler.callback.apply(null, args);
@@ -52,7 +33,7 @@ function createRunHook(hooks, storeKey, returnFirstArg, async) {
52
33
  }
53
34
  hookInfo.currentIndex++;
54
35
  }
55
- return returnFirstArg ? result : undefined;
36
+ return returnFirstArg ? result : void 0;
56
37
  } finally {
57
38
  hooksStore.__current.delete(hookInfo);
58
39
  }
@@ -60,7 +41,7 @@ function createRunHook(hooks, storeKey, returnFirstArg, async) {
60
41
  function syncRunner() {
61
42
  try {
62
43
  hooksStore.__current.add(hookInfo);
63
- let result = returnFirstArg ? args[0] : undefined;
44
+ let result = returnFirstArg ? args[0] : void 0;
64
45
  while (hookInfo.currentIndex < handlers.length) {
65
46
  const handler = handlers[hookInfo.currentIndex];
66
47
  result = handler.callback.apply(null, args);
@@ -69,7 +50,7 @@ function createRunHook(hooks, storeKey, returnFirstArg, async) {
69
50
  }
70
51
  hookInfo.currentIndex++;
71
52
  }
72
- return returnFirstArg ? result : undefined;
53
+ return returnFirstArg ? result : void 0;
73
54
  } finally {
74
55
  hooksStore.__current.delete(hookInfo);
75
56
  }
@@ -77,5 +58,8 @@ function createRunHook(hooks, storeKey, returnFirstArg, async) {
77
58
  return (async ? asyncRunner : syncRunner)();
78
59
  };
79
60
  }
80
- export default createRunHook;
81
- //# sourceMappingURL=createRunHook.js.map
61
+ var createRunHook_default = createRunHook;
62
+ export {
63
+ createRunHook_default as default
64
+ };
65
+ //# sourceMappingURL=createRunHook.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createRunHook","hooks","storeKey","returnFirstArg","async","runHook","hookName","args","hooksStore","handlers","runs","process","env","NODE_ENV","all","push","length","undefined","hookInfo","name","currentIndex","asyncRunner","__current","add","result","handler","callback","apply","delete","syncRunner"],"sources":["@wordpress/hooks/src/createRunHook.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { Hooks, StoreKey } from './types';\n\nexport type RunHook = (\n\thookName: string,\n\t...args: unknown[]\n) => undefined | unknown;\n\n/**\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 hooks Hooks instance.\n * @param storeKey\n * @param returnFirstArg Whether each hook callback is expected to return its first argument.\n * @param async Whether the hook callback should be run asynchronously\n *\n * @return Function that runs hook callbacks.\n */\nfunction createRunHook(\n\thooks: Hooks,\n\tstoreKey: StoreKey,\n\treturnFirstArg: boolean,\n\tasync: boolean\n): RunHook {\n\treturn function runHook( 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\tasync function asyncRunner() {\n\t\t\ttry {\n\t\t\t\thooksStore.__current.add( hookInfo );\n\t\t\t\tlet result = returnFirstArg ? args[ 0 ] : undefined;\n\t\t\t\twhile ( hookInfo.currentIndex < handlers.length ) {\n\t\t\t\t\tconst handler = handlers[ hookInfo.currentIndex ];\n\t\t\t\t\tresult = await handler.callback.apply( null, args );\n\t\t\t\t\tif ( returnFirstArg ) {\n\t\t\t\t\t\targs[ 0 ] = result;\n\t\t\t\t\t}\n\t\t\t\t\thookInfo.currentIndex++;\n\t\t\t\t}\n\t\t\t\treturn returnFirstArg ? result : undefined;\n\t\t\t} finally {\n\t\t\t\thooksStore.__current.delete( hookInfo );\n\t\t\t}\n\t\t}\n\n\t\tfunction syncRunner() {\n\t\t\ttry {\n\t\t\t\thooksStore.__current.add( hookInfo );\n\t\t\t\tlet result = returnFirstArg ? args[ 0 ] : undefined;\n\t\t\t\twhile ( hookInfo.currentIndex < handlers.length ) {\n\t\t\t\t\tconst handler = handlers[ hookInfo.currentIndex ];\n\t\t\t\t\tresult = handler.callback.apply( null, args );\n\t\t\t\t\tif ( returnFirstArg ) {\n\t\t\t\t\t\targs[ 0 ] = result;\n\t\t\t\t\t}\n\t\t\t\t\thookInfo.currentIndex++;\n\t\t\t\t}\n\t\t\t\treturn returnFirstArg ? result : undefined;\n\t\t\t} finally {\n\t\t\t\thooksStore.__current.delete( hookInfo );\n\t\t\t}\n\t\t}\n\n\t\treturn ( async ? asyncRunner : syncRunner )();\n\t};\n}\n\nexport default createRunHook;\n"],"mappings":"AAAA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAaA,CACrBC,KAAY,EACZC,QAAkB,EAClBC,cAAuB,EACvBC,KAAc,EACJ;EACV,OAAO,SAASC,OAAOA,CAAEC,QAAQ,EAAE,GAAGC,IAAI,EAAG;IAC5C,MAAMC,UAAU,GAAGP,KAAK,CAAEC,QAAQ,CAAE;IAEpC,IAAK,CAAEM,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,OAAOb,cAAc,GAAGI,IAAI,CAAE,CAAC,CAAE,GAAGU,SAAS;IAC9C;IAEA,MAAMC,QAAQ,GAAG;MAChBC,IAAI,EAAEb,QAAQ;MACdc,YAAY,EAAE;IACf,CAAC;IAED,eAAeC,WAAWA,CAAA,EAAG;MAC5B,IAAI;QACHb,UAAU,CAACc,SAAS,CAACC,GAAG,CAAEL,QAAS,CAAC;QACpC,IAAIM,MAAM,GAAGrB,cAAc,GAAGI,IAAI,CAAE,CAAC,CAAE,GAAGU,SAAS;QACnD,OAAQC,QAAQ,CAACE,YAAY,GAAGX,QAAQ,CAACO,MAAM,EAAG;UACjD,MAAMS,OAAO,GAAGhB,QAAQ,CAAES,QAAQ,CAACE,YAAY,CAAE;UACjDI,MAAM,GAAG,MAAMC,OAAO,CAACC,QAAQ,CAACC,KAAK,CAAE,IAAI,EAAEpB,IAAK,CAAC;UACnD,IAAKJ,cAAc,EAAG;YACrBI,IAAI,CAAE,CAAC,CAAE,GAAGiB,MAAM;UACnB;UACAN,QAAQ,CAACE,YAAY,EAAE;QACxB;QACA,OAAOjB,cAAc,GAAGqB,MAAM,GAAGP,SAAS;MAC3C,CAAC,SAAS;QACTT,UAAU,CAACc,SAAS,CAACM,MAAM,CAAEV,QAAS,CAAC;MACxC;IACD;IAEA,SAASW,UAAUA,CAAA,EAAG;MACrB,IAAI;QACHrB,UAAU,CAACc,SAAS,CAACC,GAAG,CAAEL,QAAS,CAAC;QACpC,IAAIM,MAAM,GAAGrB,cAAc,GAAGI,IAAI,CAAE,CAAC,CAAE,GAAGU,SAAS;QACnD,OAAQC,QAAQ,CAACE,YAAY,GAAGX,QAAQ,CAACO,MAAM,EAAG;UACjD,MAAMS,OAAO,GAAGhB,QAAQ,CAAES,QAAQ,CAACE,YAAY,CAAE;UACjDI,MAAM,GAAGC,OAAO,CAACC,QAAQ,CAACC,KAAK,CAAE,IAAI,EAAEpB,IAAK,CAAC;UAC7C,IAAKJ,cAAc,EAAG;YACrBI,IAAI,CAAE,CAAC,CAAE,GAAGiB,MAAM;UACnB;UACAN,QAAQ,CAACE,YAAY,EAAE;QACxB;QACA,OAAOjB,cAAc,GAAGqB,MAAM,GAAGP,SAAS;MAC3C,CAAC,SAAS;QACTT,UAAU,CAACc,SAAS,CAACM,MAAM,CAAEV,QAAS,CAAC;MACxC;IACD;IAEA,OAAO,CAAEd,KAAK,GAAGiB,WAAW,GAAGQ,UAAU,EAAG,CAAC;EAC9C,CAAC;AACF;AAEA,eAAe7B,aAAa","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createRunHook.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { Hooks, StoreKey } from './types';\n\nexport type RunHook = (\n\thookName: string,\n\t...args: unknown[]\n) => undefined | unknown;\n\n/**\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 hooks Hooks instance.\n * @param storeKey\n * @param returnFirstArg Whether each hook callback is expected to return its first argument.\n * @param async Whether the hook callback should be run asynchronously\n *\n * @return Function that runs hook callbacks.\n */\nfunction createRunHook(\n\thooks: Hooks,\n\tstoreKey: StoreKey,\n\treturnFirstArg: boolean,\n\tasync: boolean\n): RunHook {\n\treturn function runHook( 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\tasync function asyncRunner() {\n\t\t\ttry {\n\t\t\t\thooksStore.__current.add( hookInfo );\n\t\t\t\tlet result = returnFirstArg ? args[ 0 ] : undefined;\n\t\t\t\twhile ( hookInfo.currentIndex < handlers.length ) {\n\t\t\t\t\tconst handler = handlers[ hookInfo.currentIndex ];\n\t\t\t\t\tresult = await handler.callback.apply( null, args );\n\t\t\t\t\tif ( returnFirstArg ) {\n\t\t\t\t\t\targs[ 0 ] = result;\n\t\t\t\t\t}\n\t\t\t\t\thookInfo.currentIndex++;\n\t\t\t\t}\n\t\t\t\treturn returnFirstArg ? result : undefined;\n\t\t\t} finally {\n\t\t\t\thooksStore.__current.delete( hookInfo );\n\t\t\t}\n\t\t}\n\n\t\tfunction syncRunner() {\n\t\t\ttry {\n\t\t\t\thooksStore.__current.add( hookInfo );\n\t\t\t\tlet result = returnFirstArg ? args[ 0 ] : undefined;\n\t\t\t\twhile ( hookInfo.currentIndex < handlers.length ) {\n\t\t\t\t\tconst handler = handlers[ hookInfo.currentIndex ];\n\t\t\t\t\tresult = handler.callback.apply( null, args );\n\t\t\t\t\tif ( returnFirstArg ) {\n\t\t\t\t\t\targs[ 0 ] = result;\n\t\t\t\t\t}\n\t\t\t\t\thookInfo.currentIndex++;\n\t\t\t\t}\n\t\t\t\treturn returnFirstArg ? result : undefined;\n\t\t\t} finally {\n\t\t\t\thooksStore.__current.delete( hookInfo );\n\t\t\t}\n\t\t}\n\n\t\treturn ( async ? asyncRunner : syncRunner )();\n\t};\n}\n\nexport default createRunHook;\n"],
5
+ "mappings": "AAsBA,SAAS,cACR,OACA,UACA,gBACA,OACU;AACV,SAAO,SAAS,QAAS,aAAa,MAAO;AAC5C,UAAM,aAAa,MAAO,QAAS;AAEnC,QAAK,CAAE,WAAY,QAAS,GAAI;AAC/B,iBAAY,QAAS,IAAI;AAAA,QACxB,UAAU,CAAC;AAAA,QACX,MAAM;AAAA,MACP;AAAA,IACD;AAEA,eAAY,QAAS,EAAE;AAEvB,UAAM,WAAW,WAAY,QAAS,EAAE;AAGxC,QAAK,iBAAiB,QAAQ,IAAI,UAAW;AAE5C,UAAK,gBAAgB,YAAY,WAAW,KAAM;AACjD,iBAAS,KAAM,GAAG,WAAW,IAAI,QAAS;AAAA,MAC3C;AAAA,IACD;AAEA,QAAK,CAAE,YAAY,CAAE,SAAS,QAAS;AACtC,aAAO,iBAAiB,KAAM,CAAE,IAAI;AAAA,IACrC;AAEA,UAAM,WAAW;AAAA,MAChB,MAAM;AAAA,MACN,cAAc;AAAA,IACf;AAEA,mBAAe,cAAc;AAC5B,UAAI;AACH,mBAAW,UAAU,IAAK,QAAS;AACnC,YAAI,SAAS,iBAAiB,KAAM,CAAE,IAAI;AAC1C,eAAQ,SAAS,eAAe,SAAS,QAAS;AACjD,gBAAM,UAAU,SAAU,SAAS,YAAa;AAChD,mBAAS,MAAM,QAAQ,SAAS,MAAO,MAAM,IAAK;AAClD,cAAK,gBAAiB;AACrB,iBAAM,CAAE,IAAI;AAAA,UACb;AACA,mBAAS;AAAA,QACV;AACA,eAAO,iBAAiB,SAAS;AAAA,MAClC,UAAE;AACD,mBAAW,UAAU,OAAQ,QAAS;AAAA,MACvC;AAAA,IACD;AAEA,aAAS,aAAa;AACrB,UAAI;AACH,mBAAW,UAAU,IAAK,QAAS;AACnC,YAAI,SAAS,iBAAiB,KAAM,CAAE,IAAI;AAC1C,eAAQ,SAAS,eAAe,SAAS,QAAS;AACjD,gBAAM,UAAU,SAAU,SAAS,YAAa;AAChD,mBAAS,QAAQ,SAAS,MAAO,MAAM,IAAK;AAC5C,cAAK,gBAAiB;AACrB,iBAAM,CAAE,IAAI;AAAA,UACb;AACA,mBAAS;AAAA,QACV;AACA,eAAO,iBAAiB,SAAS;AAAA,MAClC,UAAE;AACD,mBAAW,UAAU,OAAQ,QAAS;AAAA,MACvC;AAAA,IACD;AAEA,YAAS,QAAQ,cAAc,YAAa;AAAA,EAC7C;AACD;AAEA,IAAO,wBAAQ;",
6
+ "names": []
7
+ }
@@ -1,9 +1,6 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import createHooks from './createHooks';
5
- export * from './types';
6
- export const defaultHooks = createHooks();
1
+ import createHooks from "./createHooks";
2
+ export * from "./types";
3
+ const defaultHooks = createHooks();
7
4
  const {
8
5
  addAction,
9
6
  addFilter,
@@ -26,5 +23,28 @@ const {
26
23
  actions,
27
24
  filters
28
25
  } = defaultHooks;
29
- export { createHooks, addAction, addFilter, removeAction, removeFilter, hasAction, hasFilter, removeAllActions, removeAllFilters, doAction, doActionAsync, applyFilters, applyFiltersAsync, currentAction, currentFilter, doingAction, doingFilter, didAction, didFilter, actions, filters };
30
- //# sourceMappingURL=index.js.map
26
+ export {
27
+ actions,
28
+ addAction,
29
+ addFilter,
30
+ applyFilters,
31
+ applyFiltersAsync,
32
+ createHooks,
33
+ currentAction,
34
+ currentFilter,
35
+ defaultHooks,
36
+ didAction,
37
+ didFilter,
38
+ doAction,
39
+ doActionAsync,
40
+ doingAction,
41
+ doingFilter,
42
+ filters,
43
+ hasAction,
44
+ hasFilter,
45
+ removeAction,
46
+ removeAllActions,
47
+ removeAllFilters,
48
+ removeFilter
49
+ };
50
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createHooks","defaultHooks","addAction","addFilter","removeAction","removeFilter","hasAction","hasFilter","removeAllActions","removeAllFilters","doAction","doActionAsync","applyFilters","applyFiltersAsync","currentAction","currentFilter","doingAction","doingFilter","didAction","didFilter","actions","filters"],"sources":["@wordpress/hooks/src/index.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport createHooks from './createHooks';\n\nexport * from './types';\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\tdoActionAsync,\n\tapplyFilters,\n\tapplyFiltersAsync,\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\tdoActionAsync,\n\tapplyFilters,\n\tapplyFiltersAsync,\n\tcurrentAction,\n\tcurrentFilter,\n\tdoingAction,\n\tdoingFilter,\n\tdidAction,\n\tdidFilter,\n\tactions,\n\tfilters,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,WAAW,MAAM,eAAe;AAEvC,cAAc,SAAS;AAEvB,OAAO,MAAMC,YAAY,GAAGD,WAAW,CAAC,CAAC;AAEzC,MAAM;EACLE,SAAS;EACTC,SAAS;EACTC,YAAY;EACZC,YAAY;EACZC,SAAS;EACTC,SAAS;EACTC,gBAAgB;EAChBC,gBAAgB;EAChBC,QAAQ;EACRC,aAAa;EACbC,YAAY;EACZC,iBAAiB;EACjBC,aAAa;EACbC,aAAa;EACbC,WAAW;EACXC,WAAW;EACXC,SAAS;EACTC,SAAS;EACTC,OAAO;EACPC;AACD,CAAC,GAAGpB,YAAY;AAEhB,SACCD,WAAW,EACXE,SAAS,EACTC,SAAS,EACTC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,SAAS,EACTC,gBAAgB,EAChBC,gBAAgB,EAChBC,QAAQ,EACRC,aAAa,EACbC,YAAY,EACZC,iBAAiB,EACjBC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,WAAW,EACXC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,OAAO","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport createHooks from './createHooks';\n\nexport * from './types';\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\tdoActionAsync,\n\tapplyFilters,\n\tapplyFiltersAsync,\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\tdoActionAsync,\n\tapplyFilters,\n\tapplyFiltersAsync,\n\tcurrentAction,\n\tcurrentFilter,\n\tdoingAction,\n\tdoingFilter,\n\tdidAction,\n\tdidFilter,\n\tactions,\n\tfilters,\n};\n"],
5
+ "mappings": "AAGA,OAAO,iBAAiB;AAExB,cAAc;AAEP,MAAM,eAAe,YAAY;AAExC,MAAM;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,IAAI;",
6
+ "names": []
7
+ }
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
1
+ //# sourceMappingURL=types.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":[],"sources":["@wordpress/hooks/src/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nexport type { Hooks } from './createHooks';\n\nexport type Callback = ( ...args: any[] ) => any;\n\nexport type Handler = {\n\tcallback: Callback;\n\tnamespace: string;\n\tpriority: number;\n};\n\nexport type Hook = {\n\thandlers: Handler[];\n\truns: number;\n};\n\nexport type Current = {\n\tname: string;\n\tcurrentIndex: number;\n};\n\nexport type HookInfo = {\n\tname: string;\n\tcurrentIndex: number;\n};\n\nexport type Store = Record< string, Hook > & { __current: Set< Current > };\n\nexport type StoreKey = 'actions' | 'filters';\n"],"mappings":"","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,29 +1,22 @@
1
- /**
2
- * Validate a hookName string.
3
- *
4
- * @param hookName The hook name to validate. Should be a non empty string containing
5
- * only numbers, letters, dashes, periods and underscores. Also,
6
- * the hook name cannot begin with `__`.
7
- *
8
- * @return Whether the hook name is valid.
9
- */
10
1
  function validateHookName(hookName) {
11
- if ('string' !== typeof hookName || '' === hookName) {
12
- // eslint-disable-next-line no-console
13
- console.error('The hook name must be a non-empty string.');
2
+ if ("string" !== typeof hookName || "" === hookName) {
3
+ console.error("The hook name must be a non-empty string.");
14
4
  return false;
15
5
  }
16
6
  if (/^__/.test(hookName)) {
17
- // eslint-disable-next-line no-console
18
- console.error('The hook name cannot begin with `__`.');
7
+ console.error("The hook name cannot begin with `__`.");
19
8
  return false;
20
9
  }
21
10
  if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
22
- // eslint-disable-next-line no-console
23
- console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.');
11
+ console.error(
12
+ "The hook name can only contain numbers, letters, dashes, periods and underscores."
13
+ );
24
14
  return false;
25
15
  }
26
16
  return true;
27
17
  }
28
- export default validateHookName;
29
- //# sourceMappingURL=validateHookName.js.map
18
+ var validateHookName_default = validateHookName;
19
+ export {
20
+ validateHookName_default as default
21
+ };
22
+ //# sourceMappingURL=validateHookName.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["validateHookName","hookName","console","error","test"],"sources":["@wordpress/hooks/src/validateHookName.ts"],"sourcesContent":["/**\n * Validate a hookName string.\n *\n * @param 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 Whether the hook name is valid.\n */\nfunction validateHookName( hookName: string ): boolean {\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,QAAgB,EAAY;EACtD,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;AAEA,eAAeH,gBAAgB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/validateHookName.ts"],
4
+ "sourcesContent": ["/**\n * Validate a hookName string.\n *\n * @param 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 Whether the hook name is valid.\n */\nfunction validateHookName( hookName: string ): boolean {\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"],
5
+ "mappings": "AASA,SAAS,iBAAkB,UAA4B;AACtD,MAAK,aAAa,OAAO,YAAY,OAAO,UAAW;AAEtD,YAAQ,MAAO,2CAA4C;AAC3D,WAAO;AAAA,EACR;AAEA,MAAK,MAAM,KAAM,QAAS,GAAI;AAE7B,YAAQ,MAAO,uCAAwC;AACvD,WAAO;AAAA,EACR;AAEA,MAAK,CAAE,4BAA4B,KAAM,QAAS,GAAI;AAErD,YAAQ;AAAA,MACP;AAAA,IACD;AACA,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAEA,IAAO,2BAAQ;",
6
+ "names": []
7
+ }
@@ -1,23 +1,18 @@
1
- /**
2
- * Validate a namespace string.
3
- *
4
- * @param namespace The namespace to validate - should take the form
5
- * `vendor/plugin/function`.
6
- *
7
- * @return Whether the namespace is valid.
8
- */
9
1
  function validateNamespace(namespace) {
10
- if ('string' !== typeof namespace || '' === namespace) {
11
- // eslint-disable-next-line no-console
12
- console.error('The namespace must be a non-empty string.');
2
+ if ("string" !== typeof namespace || "" === namespace) {
3
+ console.error("The namespace must be a non-empty string.");
13
4
  return false;
14
5
  }
15
6
  if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
16
- // eslint-disable-next-line no-console
17
- console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.');
7
+ console.error(
8
+ "The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."
9
+ );
18
10
  return false;
19
11
  }
20
12
  return true;
21
13
  }
22
- export default validateNamespace;
23
- //# sourceMappingURL=validateNamespace.js.map
14
+ var validateNamespace_default = validateNamespace;
15
+ export {
16
+ validateNamespace_default as default
17
+ };
18
+ //# sourceMappingURL=validateNamespace.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["validateNamespace","namespace","console","error","test"],"sources":["@wordpress/hooks/src/validateNamespace.ts"],"sourcesContent":["/**\n * Validate a namespace string.\n *\n * @param namespace The namespace to validate - should take the form\n * `vendor/plugin/function`.\n *\n * @return Whether the namespace is valid.\n */\nfunction validateNamespace( namespace: string ): boolean {\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,SAAiB,EAAY;EACxD,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;AAEA,eAAeH,iBAAiB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/validateNamespace.ts"],
4
+ "sourcesContent": ["/**\n * Validate a namespace string.\n *\n * @param namespace The namespace to validate - should take the form\n * `vendor/plugin/function`.\n *\n * @return Whether the namespace is valid.\n */\nfunction validateNamespace( namespace: string ): boolean {\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"],
5
+ "mappings": "AAQA,SAAS,kBAAmB,WAA6B;AACxD,MAAK,aAAa,OAAO,aAAa,OAAO,WAAY;AAExD,YAAQ,MAAO,2CAA4C;AAC3D,WAAO;AAAA,EACR;AAEA,MAAK,CAAE,+BAA+B,KAAM,SAAU,GAAI;AAEzD,YAAQ;AAAA,MACP;AAAA,IACD;AACA,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAEA,IAAO,4BAAQ;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/hooks",
3
- "version": "4.32.0",
3
+ "version": "4.32.1-next.b8c8708f3.0",
4
4
  "description": "WordPress hooks library.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -24,14 +24,19 @@
24
24
  },
25
25
  "main": "build/index.js",
26
26
  "module": "build-module/index.js",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./build-types/index.d.ts",
30
+ "import": "./build-module/index.js",
31
+ "require": "./build/index.js"
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
27
35
  "react-native": "src/index",
28
36
  "wpScript": true,
29
37
  "types": "build-types",
30
- "dependencies": {
31
- "@babel/runtime": "7.25.7"
32
- },
33
38
  "publishConfig": {
34
39
  "access": "public"
35
40
  },
36
- "gitHead": "a030b4c0e0695239b942c7dc18511782b64f10ed"
41
+ "gitHead": "67cfd7e661931aeb0d06bec894599d287a4f8d0f"
37
42
  }