@wordpress/hooks 3.2.1-next.5df0cd52b7.0 → 3.3.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.3.0 (2022-01-27)
6
+
5
7
  ## 3.2.0 (2021-07-21)
6
8
 
7
9
  ## 3.1.0 (2021-05-20)
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Gutenberg
2
2
 
3
- Copyright 2016-2021 by the contributors
3
+ Copyright 2016-2022 by the contributors
4
4
 
5
5
  **License for Contributions (on and after April 15, 2021)**
6
6
 
package/README.md CHANGED
@@ -10,7 +10,7 @@ Install the module
10
10
  npm install @wordpress/hooks --save
11
11
  ```
12
12
 
13
- _This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for ES2015+ such as IE browsers then using [core-js](https://github.com/zloirock/core-js) will add polyfills for these methods._
13
+ _This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for such language features and APIs, you should include [the polyfill shipped in `@wordpress/babel-preset-default`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/babel-preset-default#polyfill) in your code._
14
14
 
15
15
  ### Usage
16
16
 
@@ -35,7 +35,8 @@ var _validateHookName = _interopRequireDefault(require("./validateHookName.js"))
35
35
  * @return {AddHook} Function that adds a new hook.
36
36
  */
37
37
  function createAddHook(hooks, storeKey) {
38
- return function addHook(hookName, namespace, callback, priority = 10) {
38
+ return function addHook(hookName, namespace, callback) {
39
+ let priority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
39
40
  const hooksStore = hooks[storeKey];
40
41
 
41
42
  if (!(0, _validateHookName.default)(hookName)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/hooks/src/createAddHook.js"],"names":["createAddHook","hooks","storeKey","addHook","hookName","namespace","callback","priority","hooksStore","console","error","handler","handlers","i","length","splice","__current","forEach","hookInfo","name","currentIndex","runs","doAction"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,CAAwBC,KAAxB,EAA+BC,QAA/B,EAA0C;AACzC,SAAO,SAASC,OAAT,CAAkBC,QAAlB,EAA4BC,SAA5B,EAAuCC,QAAvC,EAAiDC,QAAQ,GAAG,EAA5D,EAAiE;AACvE,UAAMC,UAAU,GAAGP,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAE,+BAAkBE,QAAlB,CAAP,EAAsC;AACrC;AACA;;AAED,QAAK,CAAE,gCAAmBC,SAAnB,CAAP,EAAwC;AACvC;AACA;;AAED,QAAK,eAAe,OAAOC,QAA3B,EAAsC;AACrC;AACAG,MAAAA,OAAO,CAACC,KAAR,CAAe,uCAAf;AACA;AACA,KAfsE,CAiBvE;;;AACA,QAAK,aAAa,OAAOH,QAAzB,EAAoC;AACnC;AACAE,MAAAA,OAAO,CAACC,KAAR,CACC,mDADD;AAGA;AACA;;AAED,UAAMC,OAAO,GAAG;AAAEL,MAAAA,QAAF;AAAYC,MAAAA,QAAZ;AAAsBF,MAAAA;AAAtB,KAAhB;;AAEA,QAAKG,UAAU,CAAEJ,QAAF,CAAf,EAA8B;AAC7B;AACA,YAAMQ,QAAQ,GAAGJ,UAAU,CAAEJ,QAAF,CAAV,CAAuBQ,QAAxC;AAEA;;AACA,UAAIC,CAAJ;;AACA,WAAMA,CAAC,GAAGD,QAAQ,CAACE,MAAnB,EAA2BD,CAAC,GAAG,CAA/B,EAAkCA,CAAC,EAAnC,EAAwC;AACvC,YAAKN,QAAQ,IAAIK,QAAQ,CAAEC,CAAC,GAAG,CAAN,CAAR,CAAkBN,QAAnC,EAA8C;AAC7C;AACA;AACD;;AAED,UAAKM,CAAC,KAAKD,QAAQ,CAACE,MAApB,EAA6B;AAC5B;AACAF,QAAAA,QAAQ,CAAEC,CAAF,CAAR,GAAgBF,OAAhB;AACA,OAHD,MAGO;AACN;AACAC,QAAAA,QAAQ,CAACG,MAAT,CAAiBF,CAAjB,EAAoB,CAApB,EAAuBF,OAAvB;AACA,OAlB4B,CAoB7B;AACA;AACA;AACA;;;AACAH,MAAAA,UAAU,CAACQ,SAAX,CAAqBC,OAArB,CAAgCC,QAAF,IAAgB;AAC7C,YACCA,QAAQ,CAACC,IAAT,KAAkBf,QAAlB,IACAc,QAAQ,CAACE,YAAT,IAAyBP,CAF1B,EAGE;AACDK,UAAAA,QAAQ,CAACE,YAAT;AACA;AACD,OAPD;AAQA,KAhCD,MAgCO;AACN;AACAZ,MAAAA,UAAU,CAAEJ,QAAF,CAAV,GAAyB;AACxBQ,QAAAA,QAAQ,EAAE,CAAED,OAAF,CADc;AAExBU,QAAAA,IAAI,EAAE;AAFkB,OAAzB;AAIA;;AAED,QAAKjB,QAAQ,KAAK,WAAlB,EAAgC;AAC/BH,MAAAA,KAAK,CAACqB,QAAN,CACC,WADD,EAEClB,QAFD,EAGCC,SAHD,EAICC,QAJD,EAKCC,QALD;AAOA;AACD,GA7ED;AA8EA;;eAEcP,a","sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace.js';\nimport validateHookName from './validateHookName.js';\n\n/**\n * @callback AddHook\n *\n * Adds the hook to the appropriate hooks container.\n *\n * @param {string} hookName Name of hook to add\n * @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.\n * @param {import('.').Callback} callback Function to call when the hook is run\n * @param {number} [priority=10] Priority of this hook\n */\n\n/**\n * Returns a function which, when invoked, will add a hook.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n *\n * @return {AddHook} Function that adds a new hook.\n */\nfunction createAddHook( hooks, storeKey ) {\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 = { 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\t/** @type {number} */\n\t\t\tlet i;\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 ) => {\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"]}
1
+ {"version":3,"sources":["@wordpress/hooks/src/createAddHook.js"],"names":["createAddHook","hooks","storeKey","addHook","hookName","namespace","callback","priority","hooksStore","console","error","handler","handlers","i","length","splice","__current","forEach","hookInfo","name","currentIndex","runs","doAction"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,CAAwBC,KAAxB,EAA+BC,QAA/B,EAA0C;AACzC,SAAO,SAASC,OAAT,CAAkBC,QAAlB,EAA4BC,SAA5B,EAAuCC,QAAvC,EAAiE;AAAA,QAAhBC,QAAgB,uEAAL,EAAK;AACvE,UAAMC,UAAU,GAAGP,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAE,+BAAkBE,QAAlB,CAAP,EAAsC;AACrC;AACA;;AAED,QAAK,CAAE,gCAAmBC,SAAnB,CAAP,EAAwC;AACvC;AACA;;AAED,QAAK,eAAe,OAAOC,QAA3B,EAAsC;AACrC;AACAG,MAAAA,OAAO,CAACC,KAAR,CAAe,uCAAf;AACA;AACA,KAfsE,CAiBvE;;;AACA,QAAK,aAAa,OAAOH,QAAzB,EAAoC;AACnC;AACAE,MAAAA,OAAO,CAACC,KAAR,CACC,mDADD;AAGA;AACA;;AAED,UAAMC,OAAO,GAAG;AAAEL,MAAAA,QAAF;AAAYC,MAAAA,QAAZ;AAAsBF,MAAAA;AAAtB,KAAhB;;AAEA,QAAKG,UAAU,CAAEJ,QAAF,CAAf,EAA8B;AAC7B;AACA,YAAMQ,QAAQ,GAAGJ,UAAU,CAAEJ,QAAF,CAAV,CAAuBQ,QAAxC;AAEA;;AACA,UAAIC,CAAJ;;AACA,WAAMA,CAAC,GAAGD,QAAQ,CAACE,MAAnB,EAA2BD,CAAC,GAAG,CAA/B,EAAkCA,CAAC,EAAnC,EAAwC;AACvC,YAAKN,QAAQ,IAAIK,QAAQ,CAAEC,CAAC,GAAG,CAAN,CAAR,CAAkBN,QAAnC,EAA8C;AAC7C;AACA;AACD;;AAED,UAAKM,CAAC,KAAKD,QAAQ,CAACE,MAApB,EAA6B;AAC5B;AACAF,QAAAA,QAAQ,CAAEC,CAAF,CAAR,GAAgBF,OAAhB;AACA,OAHD,MAGO;AACN;AACAC,QAAAA,QAAQ,CAACG,MAAT,CAAiBF,CAAjB,EAAoB,CAApB,EAAuBF,OAAvB;AACA,OAlB4B,CAoB7B;AACA;AACA;AACA;;;AACAH,MAAAA,UAAU,CAACQ,SAAX,CAAqBC,OAArB,CAAgCC,QAAF,IAAgB;AAC7C,YACCA,QAAQ,CAACC,IAAT,KAAkBf,QAAlB,IACAc,QAAQ,CAACE,YAAT,IAAyBP,CAF1B,EAGE;AACDK,UAAAA,QAAQ,CAACE,YAAT;AACA;AACD,OAPD;AAQA,KAhCD,MAgCO;AACN;AACAZ,MAAAA,UAAU,CAAEJ,QAAF,CAAV,GAAyB;AACxBQ,QAAAA,QAAQ,EAAE,CAAED,OAAF,CADc;AAExBU,QAAAA,IAAI,EAAE;AAFkB,OAAzB;AAIA;;AAED,QAAKjB,QAAQ,KAAK,WAAlB,EAAgC;AAC/BH,MAAAA,KAAK,CAACqB,QAAN,CACC,WADD,EAEClB,QAFD,EAGCC,SAHD,EAICC,QAJD,EAKCC,QALD;AAOA;AACD,GA7ED;AA8EA;;eAEcP,a","sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace.js';\nimport validateHookName from './validateHookName.js';\n\n/**\n * @callback AddHook\n *\n * Adds the hook to the appropriate hooks container.\n *\n * @param {string} hookName Name of hook to add\n * @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.\n * @param {import('.').Callback} callback Function to call when the hook is run\n * @param {number} [priority=10] Priority of this hook\n */\n\n/**\n * Returns a function which, when invoked, will add a hook.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n *\n * @return {AddHook} Function that adds a new hook.\n */\nfunction createAddHook( hooks, storeKey ) {\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 = { 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\t/** @type {number} */\n\t\t\tlet i;\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 ) => {\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"]}
@@ -39,7 +39,8 @@ var _validateHookName = _interopRequireDefault(require("./validateHookName.js"))
39
39
  *
40
40
  * @return {RemoveHook} Function that removes hooks.
41
41
  */
42
- function createRemoveHook(hooks, storeKey, removeAll = false) {
42
+ function createRemoveHook(hooks, storeKey) {
43
+ let removeAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
43
44
  return function removeHook(hookName, namespace) {
44
45
  const hooksStore = hooks[storeKey];
45
46
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/hooks/src/createRemoveHook.js"],"names":["createRemoveHook","hooks","storeKey","removeAll","removeHook","hookName","namespace","hooksStore","handlersRemoved","handlers","length","runs","i","splice","__current","forEach","hookInfo","name","currentIndex","doAction"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAT,CAA2BC,KAA3B,EAAkCC,QAAlC,EAA4CC,SAAS,GAAG,KAAxD,EAAgE;AAC/D,SAAO,SAASC,UAAT,CAAqBC,QAArB,EAA+BC,SAA/B,EAA2C;AACjD,UAAMC,UAAU,GAAGN,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAE,+BAAkBG,QAAlB,CAAP,EAAsC;AACrC;AACA;;AAED,QAAK,CAAEF,SAAF,IAAe,CAAE,gCAAmBG,SAAnB,CAAtB,EAAuD;AACtD;AACA,KATgD,CAWjD;;;AACA,QAAK,CAAEC,UAAU,CAAEF,QAAF,CAAjB,EAAgC;AAC/B,aAAO,CAAP;AACA;;AAED,QAAIG,eAAe,GAAG,CAAtB;;AAEA,QAAKL,SAAL,EAAiB;AAChBK,MAAAA,eAAe,GAAGD,UAAU,CAAEF,QAAF,CAAV,CAAuBI,QAAvB,CAAgCC,MAAlD;AACAH,MAAAA,UAAU,CAAEF,QAAF,CAAV,GAAyB;AACxBM,QAAAA,IAAI,EAAEJ,UAAU,CAAEF,QAAF,CAAV,CAAuBM,IADL;AAExBF,QAAAA,QAAQ,EAAE;AAFc,OAAzB;AAIA,KAND,MAMO;AACN;AACA,YAAMA,QAAQ,GAAGF,UAAU,CAAEF,QAAF,CAAV,CAAuBI,QAAxC;;AACA,WAAM,IAAIG,CAAC,GAAGH,QAAQ,CAACC,MAAT,GAAkB,CAAhC,EAAmCE,CAAC,IAAI,CAAxC,EAA2CA,CAAC,EAA5C,EAAiD;AAChD,YAAKH,QAAQ,CAAEG,CAAF,CAAR,CAAcN,SAAd,KAA4BA,SAAjC,EAA6C;AAC5CG,UAAAA,QAAQ,CAACI,MAAT,CAAiBD,CAAjB,EAAoB,CAApB;AACAJ,UAAAA,eAAe,GAF6B,CAG5C;AACA;AACA;AACA;AACA;;AACAD,UAAAA,UAAU,CAACO,SAAX,CAAqBC,OAArB,CAAgCC,QAAF,IAAgB;AAC7C,gBACCA,QAAQ,CAACC,IAAT,KAAkBZ,QAAlB,IACAW,QAAQ,CAACE,YAAT,IAAyBN,CAF1B,EAGE;AACDI,cAAAA,QAAQ,CAACE,YAAT;AACA;AACD,WAPD;AAQA;AACD;AACD;;AAED,QAAKb,QAAQ,KAAK,aAAlB,EAAkC;AACjCJ,MAAAA,KAAK,CAACkB,QAAN,CAAgB,aAAhB,EAA+Bd,QAA/B,EAAyCC,SAAzC;AACA;;AAED,WAAOE,eAAP;AACA,GArDD;AAsDA;;eAEcR,gB","sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace.js';\nimport validateHookName from './validateHookName.js';\n\n/**\n * @callback RemoveHook\n * Removes the specified callback (or all callbacks) from the hook with a given hookName\n * and namespace.\n *\n * @param {string} hookName The name of the hook to modify.\n * @param {string} namespace The unique namespace identifying the callback in the\n * form `vendor/plugin/function`.\n *\n * @return {number | undefined} The number of callbacks removed.\n */\n\n/**\n * Returns a function which, when invoked, will remove a specified hook or all\n * hooks by the given name.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n * @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName,\n * without regard to namespace. Used to create\n * `removeAll*` functions.\n *\n * @return {RemoveHook} Function that removes hooks.\n */\nfunction createRemoveHook( hooks, storeKey, removeAll = false ) {\n\treturn function removeHook( hookName, namespace ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! validateHookName( hookName ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! removeAll && ! validateNamespace( namespace ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Bail if no hooks exist by this name\n\t\tif ( ! hooksStore[ hookName ] ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tlet handlersRemoved = 0;\n\n\t\tif ( removeAll ) {\n\t\t\thandlersRemoved = hooksStore[ hookName ].handlers.length;\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\truns: hooksStore[ hookName ].runs,\n\t\t\t\thandlers: [],\n\t\t\t};\n\t\t} else {\n\t\t\t// Try to find the specified callback to remove.\n\t\t\tconst handlers = hooksStore[ hookName ].handlers;\n\t\t\tfor ( let i = handlers.length - 1; i >= 0; i-- ) {\n\t\t\t\tif ( handlers[ i ].namespace === namespace ) {\n\t\t\t\t\thandlers.splice( i, 1 );\n\t\t\t\t\thandlersRemoved++;\n\t\t\t\t\t// This callback may also be part of a hook that is\n\t\t\t\t\t// currently executing. If the callback we're removing\n\t\t\t\t\t// comes after the current callback, there's no problem;\n\t\t\t\t\t// otherwise we need to decrease the execution index of any\n\t\t\t\t\t// other runs by 1 to account for the removed element.\n\t\t\t\t\thooksStore.__current.forEach( ( hookInfo ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thookInfo.name === hookName &&\n\t\t\t\t\t\t\thookInfo.currentIndex >= i\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thookInfo.currentIndex--;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( hookName !== 'hookRemoved' ) {\n\t\t\thooks.doAction( 'hookRemoved', hookName, namespace );\n\t\t}\n\n\t\treturn handlersRemoved;\n\t};\n}\n\nexport default createRemoveHook;\n"]}
1
+ {"version":3,"sources":["@wordpress/hooks/src/createRemoveHook.js"],"names":["createRemoveHook","hooks","storeKey","removeAll","removeHook","hookName","namespace","hooksStore","handlersRemoved","handlers","length","runs","i","splice","__current","forEach","hookInfo","name","currentIndex","doAction"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAT,CAA2BC,KAA3B,EAAkCC,QAAlC,EAAgE;AAAA,MAApBC,SAAoB,uEAAR,KAAQ;AAC/D,SAAO,SAASC,UAAT,CAAqBC,QAArB,EAA+BC,SAA/B,EAA2C;AACjD,UAAMC,UAAU,GAAGN,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAE,+BAAkBG,QAAlB,CAAP,EAAsC;AACrC;AACA;;AAED,QAAK,CAAEF,SAAF,IAAe,CAAE,gCAAmBG,SAAnB,CAAtB,EAAuD;AACtD;AACA,KATgD,CAWjD;;;AACA,QAAK,CAAEC,UAAU,CAAEF,QAAF,CAAjB,EAAgC;AAC/B,aAAO,CAAP;AACA;;AAED,QAAIG,eAAe,GAAG,CAAtB;;AAEA,QAAKL,SAAL,EAAiB;AAChBK,MAAAA,eAAe,GAAGD,UAAU,CAAEF,QAAF,CAAV,CAAuBI,QAAvB,CAAgCC,MAAlD;AACAH,MAAAA,UAAU,CAAEF,QAAF,CAAV,GAAyB;AACxBM,QAAAA,IAAI,EAAEJ,UAAU,CAAEF,QAAF,CAAV,CAAuBM,IADL;AAExBF,QAAAA,QAAQ,EAAE;AAFc,OAAzB;AAIA,KAND,MAMO;AACN;AACA,YAAMA,QAAQ,GAAGF,UAAU,CAAEF,QAAF,CAAV,CAAuBI,QAAxC;;AACA,WAAM,IAAIG,CAAC,GAAGH,QAAQ,CAACC,MAAT,GAAkB,CAAhC,EAAmCE,CAAC,IAAI,CAAxC,EAA2CA,CAAC,EAA5C,EAAiD;AAChD,YAAKH,QAAQ,CAAEG,CAAF,CAAR,CAAcN,SAAd,KAA4BA,SAAjC,EAA6C;AAC5CG,UAAAA,QAAQ,CAACI,MAAT,CAAiBD,CAAjB,EAAoB,CAApB;AACAJ,UAAAA,eAAe,GAF6B,CAG5C;AACA;AACA;AACA;AACA;;AACAD,UAAAA,UAAU,CAACO,SAAX,CAAqBC,OAArB,CAAgCC,QAAF,IAAgB;AAC7C,gBACCA,QAAQ,CAACC,IAAT,KAAkBZ,QAAlB,IACAW,QAAQ,CAACE,YAAT,IAAyBN,CAF1B,EAGE;AACDI,cAAAA,QAAQ,CAACE,YAAT;AACA;AACD,WAPD;AAQA;AACD;AACD;;AAED,QAAKb,QAAQ,KAAK,aAAlB,EAAkC;AACjCJ,MAAAA,KAAK,CAACkB,QAAN,CAAgB,aAAhB,EAA+Bd,QAA/B,EAAyCC,SAAzC;AACA;;AAED,WAAOE,eAAP;AACA,GArDD;AAsDA;;eAEcR,gB","sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace.js';\nimport validateHookName from './validateHookName.js';\n\n/**\n * @callback RemoveHook\n * Removes the specified callback (or all callbacks) from the hook with a given hookName\n * and namespace.\n *\n * @param {string} hookName The name of the hook to modify.\n * @param {string} namespace The unique namespace identifying the callback in the\n * form `vendor/plugin/function`.\n *\n * @return {number | undefined} The number of callbacks removed.\n */\n\n/**\n * Returns a function which, when invoked, will remove a specified hook or all\n * hooks by the given name.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n * @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName,\n * without regard to namespace. Used to create\n * `removeAll*` functions.\n *\n * @return {RemoveHook} Function that removes hooks.\n */\nfunction createRemoveHook( hooks, storeKey, removeAll = false ) {\n\treturn function removeHook( hookName, namespace ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! validateHookName( hookName ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! removeAll && ! validateNamespace( namespace ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Bail if no hooks exist by this name\n\t\tif ( ! hooksStore[ hookName ] ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tlet handlersRemoved = 0;\n\n\t\tif ( removeAll ) {\n\t\t\thandlersRemoved = hooksStore[ hookName ].handlers.length;\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\truns: hooksStore[ hookName ].runs,\n\t\t\t\thandlers: [],\n\t\t\t};\n\t\t} else {\n\t\t\t// Try to find the specified callback to remove.\n\t\t\tconst handlers = hooksStore[ hookName ].handlers;\n\t\t\tfor ( let i = handlers.length - 1; i >= 0; i-- ) {\n\t\t\t\tif ( handlers[ i ].namespace === namespace ) {\n\t\t\t\t\thandlers.splice( i, 1 );\n\t\t\t\t\thandlersRemoved++;\n\t\t\t\t\t// This callback may also be part of a hook that is\n\t\t\t\t\t// currently executing. If the callback we're removing\n\t\t\t\t\t// comes after the current callback, there's no problem;\n\t\t\t\t\t// otherwise we need to decrease the execution index of any\n\t\t\t\t\t// other runs by 1 to account for the removed element.\n\t\t\t\t\thooksStore.__current.forEach( ( hookInfo ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thookInfo.name === hookName &&\n\t\t\t\t\t\t\thookInfo.currentIndex >= i\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thookInfo.currentIndex--;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( hookName !== 'hookRemoved' ) {\n\t\t\thooks.doAction( 'hookRemoved', hookName, namespace );\n\t\t}\n\n\t\treturn handlersRemoved;\n\t};\n}\n\nexport default createRemoveHook;\n"]}
@@ -17,8 +17,9 @@ exports.default = void 0;
17
17
  *
18
18
  * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks.
19
19
  */
20
- function createRunHook(hooks, storeKey, returnFirstArg = false) {
21
- return function runHooks(hookName, ...args) {
20
+ function createRunHook(hooks, storeKey) {
21
+ let returnFirstArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
22
+ return function runHooks(hookName) {
22
23
  const hooksStore = hooks[storeKey];
23
24
 
24
25
  if (!hooksStore[hookName]) {
@@ -38,6 +39,10 @@ function createRunHook(hooks, storeKey, returnFirstArg = false) {
38
39
  }
39
40
  }
40
41
 
42
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
43
+ args[_key - 1] = arguments[_key];
44
+ }
45
+
41
46
  if (!handlers || !handlers.length) {
42
47
  return returnFirstArg ? args[0] : undefined;
43
48
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/hooks/src/createRunHook.js"],"names":["createRunHook","hooks","storeKey","returnFirstArg","runHooks","hookName","args","hooksStore","handlers","runs","process","env","NODE_ENV","all","push","length","undefined","hookInfo","name","currentIndex","__current","handler","result","callback","apply","pop"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,CAAwBC,KAAxB,EAA+BC,QAA/B,EAAyCC,cAAc,GAAG,KAA1D,EAAkE;AACjE,SAAO,SAASC,QAAT,CAAmBC,QAAnB,EAA6B,GAAGC,IAAhC,EAAuC;AAC7C,UAAMC,UAAU,GAAGN,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAEK,UAAU,CAAEF,QAAF,CAAjB,EAAgC;AAC/BE,MAAAA,UAAU,CAAEF,QAAF,CAAV,GAAyB;AACxBG,QAAAA,QAAQ,EAAE,EADc;AAExBC,QAAAA,IAAI,EAAE;AAFkB,OAAzB;AAIA;;AAEDF,IAAAA,UAAU,CAAEF,QAAF,CAAV,CAAuBI,IAAvB;AAEA,UAAMD,QAAQ,GAAGD,UAAU,CAAEF,QAAF,CAAV,CAAuBG,QAAxC,CAZ6C,CAc7C;;AACA,QAAK,iBAAiBE,OAAO,CAACC,GAAR,CAAYC,QAAlC,EAA6C;AAC5C;AACA,UAAK,gBAAgBP,QAAhB,IAA4BE,UAAU,CAACM,GAA5C,EAAkD;AACjDL,QAAAA,QAAQ,CAACM,IAAT,CAAe,GAAGP,UAAU,CAACM,GAAX,CAAeL,QAAjC;AACA;AACD;;AAED,QAAK,CAAEA,QAAF,IAAc,CAAEA,QAAQ,CAACO,MAA9B,EAAuC;AACtC,aAAOZ,cAAc,GAAGG,IAAI,CAAE,CAAF,CAAP,GAAeU,SAApC;AACA;;AAED,UAAMC,QAAQ,GAAG;AAChBC,MAAAA,IAAI,EAAEb,QADU;AAEhBc,MAAAA,YAAY,EAAE;AAFE,KAAjB;;AAKAZ,IAAAA,UAAU,CAACa,SAAX,CAAqBN,IAArB,CAA2BG,QAA3B;;AAEA,WAAQA,QAAQ,CAACE,YAAT,GAAwBX,QAAQ,CAACO,MAAzC,EAAkD;AACjD,YAAMM,OAAO,GAAGb,QAAQ,CAAES,QAAQ,CAACE,YAAX,CAAxB;AAEA,YAAMG,MAAM,GAAGD,OAAO,CAACE,QAAR,CAAiBC,KAAjB,CAAwB,IAAxB,EAA8BlB,IAA9B,CAAf;;AACA,UAAKH,cAAL,EAAsB;AACrBG,QAAAA,IAAI,CAAE,CAAF,CAAJ,GAAYgB,MAAZ;AACA;;AAEDL,MAAAA,QAAQ,CAACE,YAAT;AACA;;AAEDZ,IAAAA,UAAU,CAACa,SAAX,CAAqBK,GAArB;;AAEA,QAAKtB,cAAL,EAAsB;AACrB,aAAOG,IAAI,CAAE,CAAF,CAAX;AACA;AACD,GAjDD;AAkDA;;eAEcN,a","sourcesContent":["/**\n * Returns a function which, when invoked, will execute all callbacks\n * registered to a hook of the specified type, optionally returning the final\n * value of the call chain.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n * @param {boolean} [returnFirstArg=false] Whether each hook callback is expected to\n * return its first argument.\n *\n * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks.\n */\nfunction createRunHook( hooks, storeKey, returnFirstArg = false ) {\n\treturn function runHooks( hookName, ...args ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! hooksStore[ hookName ] ) {\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\thandlers: [],\n\t\t\t\truns: 0,\n\t\t\t};\n\t\t}\n\n\t\thooksStore[ hookName ].runs++;\n\n\t\tconst handlers = hooksStore[ hookName ].handlers;\n\n\t\t// The following code is stripped from production builds.\n\t\tif ( 'production' !== process.env.NODE_ENV ) {\n\t\t\t// Handle any 'all' hooks registered.\n\t\t\tif ( 'hookAdded' !== hookName && hooksStore.all ) {\n\t\t\t\thandlers.push( ...hooksStore.all.handlers );\n\t\t\t}\n\t\t}\n\n\t\tif ( ! handlers || ! handlers.length ) {\n\t\t\treturn returnFirstArg ? args[ 0 ] : undefined;\n\t\t}\n\n\t\tconst hookInfo = {\n\t\t\tname: hookName,\n\t\t\tcurrentIndex: 0,\n\t\t};\n\n\t\thooksStore.__current.push( hookInfo );\n\n\t\twhile ( hookInfo.currentIndex < handlers.length ) {\n\t\t\tconst handler = handlers[ hookInfo.currentIndex ];\n\n\t\t\tconst result = handler.callback.apply( null, args );\n\t\t\tif ( returnFirstArg ) {\n\t\t\t\targs[ 0 ] = result;\n\t\t\t}\n\n\t\t\thookInfo.currentIndex++;\n\t\t}\n\n\t\thooksStore.__current.pop();\n\n\t\tif ( returnFirstArg ) {\n\t\t\treturn args[ 0 ];\n\t\t}\n\t};\n}\n\nexport default createRunHook;\n"]}
1
+ {"version":3,"sources":["@wordpress/hooks/src/createRunHook.js"],"names":["createRunHook","hooks","storeKey","returnFirstArg","runHooks","hookName","hooksStore","handlers","runs","process","env","NODE_ENV","all","push","args","length","undefined","hookInfo","name","currentIndex","__current","handler","result","callback","apply","pop"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,CAAwBC,KAAxB,EAA+BC,QAA/B,EAAkE;AAAA,MAAzBC,cAAyB,uEAAR,KAAQ;AACjE,SAAO,SAASC,QAAT,CAAmBC,QAAnB,EAAuC;AAC7C,UAAMC,UAAU,GAAGL,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAEI,UAAU,CAAED,QAAF,CAAjB,EAAgC;AAC/BC,MAAAA,UAAU,CAAED,QAAF,CAAV,GAAyB;AACxBE,QAAAA,QAAQ,EAAE,EADc;AAExBC,QAAAA,IAAI,EAAE;AAFkB,OAAzB;AAIA;;AAEDF,IAAAA,UAAU,CAAED,QAAF,CAAV,CAAuBG,IAAvB;AAEA,UAAMD,QAAQ,GAAGD,UAAU,CAAED,QAAF,CAAV,CAAuBE,QAAxC,CAZ6C,CAc7C;;AACA,QAAK,iBAAiBE,OAAO,CAACC,GAAR,CAAYC,QAAlC,EAA6C;AAC5C;AACA,UAAK,gBAAgBN,QAAhB,IAA4BC,UAAU,CAACM,GAA5C,EAAkD;AACjDL,QAAAA,QAAQ,CAACM,IAAT,CAAe,GAAGP,UAAU,CAACM,GAAX,CAAeL,QAAjC;AACA;AACD;;AApB4C,sCAAPO,IAAO;AAAPA,MAAAA,IAAO;AAAA;;AAsB7C,QAAK,CAAEP,QAAF,IAAc,CAAEA,QAAQ,CAACQ,MAA9B,EAAuC;AACtC,aAAOZ,cAAc,GAAGW,IAAI,CAAE,CAAF,CAAP,GAAeE,SAApC;AACA;;AAED,UAAMC,QAAQ,GAAG;AAChBC,MAAAA,IAAI,EAAEb,QADU;AAEhBc,MAAAA,YAAY,EAAE;AAFE,KAAjB;;AAKAb,IAAAA,UAAU,CAACc,SAAX,CAAqBP,IAArB,CAA2BI,QAA3B;;AAEA,WAAQA,QAAQ,CAACE,YAAT,GAAwBZ,QAAQ,CAACQ,MAAzC,EAAkD;AACjD,YAAMM,OAAO,GAAGd,QAAQ,CAAEU,QAAQ,CAACE,YAAX,CAAxB;AAEA,YAAMG,MAAM,GAAGD,OAAO,CAACE,QAAR,CAAiBC,KAAjB,CAAwB,IAAxB,EAA8BV,IAA9B,CAAf;;AACA,UAAKX,cAAL,EAAsB;AACrBW,QAAAA,IAAI,CAAE,CAAF,CAAJ,GAAYQ,MAAZ;AACA;;AAEDL,MAAAA,QAAQ,CAACE,YAAT;AACA;;AAEDb,IAAAA,UAAU,CAACc,SAAX,CAAqBK,GAArB;;AAEA,QAAKtB,cAAL,EAAsB;AACrB,aAAOW,IAAI,CAAE,CAAF,CAAX;AACA;AACD,GAjDD;AAkDA;;eAEcd,a","sourcesContent":["/**\n * Returns a function which, when invoked, will execute all callbacks\n * registered to a hook of the specified type, optionally returning the final\n * value of the call chain.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n * @param {boolean} [returnFirstArg=false] Whether each hook callback is expected to\n * return its first argument.\n *\n * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks.\n */\nfunction createRunHook( hooks, storeKey, returnFirstArg = false ) {\n\treturn function runHooks( hookName, ...args ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! hooksStore[ hookName ] ) {\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\thandlers: [],\n\t\t\t\truns: 0,\n\t\t\t};\n\t\t}\n\n\t\thooksStore[ hookName ].runs++;\n\n\t\tconst handlers = hooksStore[ hookName ].handlers;\n\n\t\t// The following code is stripped from production builds.\n\t\tif ( 'production' !== process.env.NODE_ENV ) {\n\t\t\t// Handle any 'all' hooks registered.\n\t\t\tif ( 'hookAdded' !== hookName && hooksStore.all ) {\n\t\t\t\thandlers.push( ...hooksStore.all.handlers );\n\t\t\t}\n\t\t}\n\n\t\tif ( ! handlers || ! handlers.length ) {\n\t\t\treturn returnFirstArg ? args[ 0 ] : undefined;\n\t\t}\n\n\t\tconst hookInfo = {\n\t\t\tname: hookName,\n\t\t\tcurrentIndex: 0,\n\t\t};\n\n\t\thooksStore.__current.push( hookInfo );\n\n\t\twhile ( hookInfo.currentIndex < handlers.length ) {\n\t\t\tconst handler = handlers[ hookInfo.currentIndex ];\n\n\t\t\tconst result = handler.callback.apply( null, args );\n\t\t\tif ( returnFirstArg ) {\n\t\t\t\targs[ 0 ] = result;\n\t\t\t}\n\n\t\t\thookInfo.currentIndex++;\n\t\t}\n\n\t\thooksStore.__current.pop();\n\n\t\tif ( returnFirstArg ) {\n\t\t\treturn args[ 0 ];\n\t\t}\n\t};\n}\n\nexport default createRunHook;\n"]}
package/build/index.js CHANGED
@@ -5,13 +5,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.applyFilters = exports.addFilter = exports.addAction = exports.actions = void 0;
8
9
  Object.defineProperty(exports, "createHooks", {
9
10
  enumerable: true,
10
11
  get: function () {
11
12
  return _createHooks.default;
12
13
  }
13
14
  });
14
- exports.filters = exports.actions = exports.didFilter = exports.didAction = exports.doingFilter = exports.doingAction = exports.currentFilter = exports.currentAction = exports.applyFilters = exports.doAction = exports.removeAllFilters = exports.removeAllActions = exports.hasFilter = exports.hasAction = exports.removeFilter = exports.removeAction = exports.addFilter = exports.addAction = exports.defaultHooks = void 0;
15
+ exports.removeFilter = exports.removeAllFilters = exports.removeAllActions = exports.removeAction = exports.hasFilter = exports.hasAction = exports.filters = exports.doingFilter = exports.doingAction = exports.doAction = exports.didFilter = exports.didAction = exports.defaultHooks = exports.currentFilter = exports.currentAction = void 0;
15
16
 
16
17
  var _createHooks = _interopRequireDefault(require("./createHooks"));
17
18
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/hooks/src/index.js"],"names":["defaultHooks","addAction","addFilter","removeAction","removeFilter","hasAction","hasFilter","removeAllActions","removeAllFilters","doAction","applyFilters","currentAction","currentFilter","doingAction","doingFilter","didAction","didFilter","actions","filters"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AAEO,MAAMA,YAAY,GAAG,2BAArB;;AAEP,MAAM;AACLC,EAAAA,SADK;AAELC,EAAAA,SAFK;AAGLC,EAAAA,YAHK;AAILC,EAAAA,YAJK;AAKLC,EAAAA,SALK;AAMLC,EAAAA,SANK;AAOLC,EAAAA,gBAPK;AAQLC,EAAAA,gBARK;AASLC,EAAAA,QATK;AAULC,EAAAA,YAVK;AAWLC,EAAAA,aAXK;AAYLC,EAAAA,aAZK;AAaLC,EAAAA,WAbK;AAcLC,EAAAA,WAdK;AAeLC,EAAAA,SAfK;AAgBLC,EAAAA,SAhBK;AAiBLC,EAAAA,OAjBK;AAkBLC,EAAAA;AAlBK,IAmBFlB,YAnBJ","sourcesContent":["/**\n * Internal dependencies\n */\nimport createHooks from './createHooks';\n\n/** @typedef {(...args: any[])=>any} Callback */\n\n/**\n * @typedef Handler\n * @property {Callback} callback The callback\n * @property {string} namespace The namespace\n * @property {number} priority The namespace\n */\n\n/**\n * @typedef Hook\n * @property {Handler[]} handlers Array of handlers\n * @property {number} runs Run counter\n */\n\n/**\n * @typedef Current\n * @property {string} name Hook name\n * @property {number} currentIndex The index\n */\n\n/**\n * @typedef {Record<string, Hook> & {__current: Current[]}} Store\n */\n\n/**\n * @typedef {'actions' | 'filters'} StoreKey\n */\n\n/**\n * @typedef {import('./createHooks').Hooks} Hooks\n */\n\nexport const defaultHooks = createHooks();\n\nconst {\n\taddAction,\n\taddFilter,\n\tremoveAction,\n\tremoveFilter,\n\thasAction,\n\thasFilter,\n\tremoveAllActions,\n\tremoveAllFilters,\n\tdoAction,\n\tapplyFilters,\n\tcurrentAction,\n\tcurrentFilter,\n\tdoingAction,\n\tdoingFilter,\n\tdidAction,\n\tdidFilter,\n\tactions,\n\tfilters,\n} = defaultHooks;\n\nexport {\n\tcreateHooks,\n\taddAction,\n\taddFilter,\n\tremoveAction,\n\tremoveFilter,\n\thasAction,\n\thasFilter,\n\tremoveAllActions,\n\tremoveAllFilters,\n\tdoAction,\n\tapplyFilters,\n\tcurrentAction,\n\tcurrentFilter,\n\tdoingAction,\n\tdoingFilter,\n\tdidAction,\n\tdidFilter,\n\tactions,\n\tfilters,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/hooks/src/index.js"],"names":["defaultHooks","addAction","addFilter","removeAction","removeFilter","hasAction","hasFilter","removeAllActions","removeAllFilters","doAction","applyFilters","currentAction","currentFilter","doingAction","doingFilter","didAction","didFilter","actions","filters"],"mappings":";;;;;;;;;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AAEO,MAAMA,YAAY,GAAG,2BAArB;;AAEP,MAAM;AACLC,EAAAA,SADK;AAELC,EAAAA,SAFK;AAGLC,EAAAA,YAHK;AAILC,EAAAA,YAJK;AAKLC,EAAAA,SALK;AAMLC,EAAAA,SANK;AAOLC,EAAAA,gBAPK;AAQLC,EAAAA,gBARK;AASLC,EAAAA,QATK;AAULC,EAAAA,YAVK;AAWLC,EAAAA,aAXK;AAYLC,EAAAA,aAZK;AAaLC,EAAAA,WAbK;AAcLC,EAAAA,WAdK;AAeLC,EAAAA,SAfK;AAgBLC,EAAAA,SAhBK;AAiBLC,EAAAA,OAjBK;AAkBLC,EAAAA;AAlBK,IAmBFlB,YAnBJ","sourcesContent":["/**\n * Internal dependencies\n */\nimport createHooks from './createHooks';\n\n/** @typedef {(...args: any[])=>any} Callback */\n\n/**\n * @typedef Handler\n * @property {Callback} callback The callback\n * @property {string} namespace The namespace\n * @property {number} priority The namespace\n */\n\n/**\n * @typedef Hook\n * @property {Handler[]} handlers Array of handlers\n * @property {number} runs Run counter\n */\n\n/**\n * @typedef Current\n * @property {string} name Hook name\n * @property {number} currentIndex The index\n */\n\n/**\n * @typedef {Record<string, Hook> & {__current: Current[]}} Store\n */\n\n/**\n * @typedef {'actions' | 'filters'} StoreKey\n */\n\n/**\n * @typedef {import('./createHooks').Hooks} Hooks\n */\n\nexport const defaultHooks = createHooks();\n\nconst {\n\taddAction,\n\taddFilter,\n\tremoveAction,\n\tremoveFilter,\n\thasAction,\n\thasFilter,\n\tremoveAllActions,\n\tremoveAllFilters,\n\tdoAction,\n\tapplyFilters,\n\tcurrentAction,\n\tcurrentFilter,\n\tdoingAction,\n\tdoingFilter,\n\tdidAction,\n\tdidFilter,\n\tactions,\n\tfilters,\n} = defaultHooks;\n\nexport {\n\tcreateHooks,\n\taddAction,\n\taddFilter,\n\tremoveAction,\n\tremoveFilter,\n\thasAction,\n\thasFilter,\n\tremoveAllActions,\n\tremoveAllFilters,\n\tdoAction,\n\tapplyFilters,\n\tcurrentAction,\n\tcurrentFilter,\n\tdoingAction,\n\tdoingFilter,\n\tdidAction,\n\tdidFilter,\n\tactions,\n\tfilters,\n};\n"]}
@@ -24,7 +24,8 @@ import validateHookName from './validateHookName.js';
24
24
  */
25
25
 
26
26
  function createAddHook(hooks, storeKey) {
27
- return function addHook(hookName, namespace, callback, priority = 10) {
27
+ return function addHook(hookName, namespace, callback) {
28
+ let priority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
28
29
  const hooksStore = hooks[storeKey];
29
30
 
30
31
  if (!validateHookName(hookName)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/hooks/src/createAddHook.js"],"names":["validateNamespace","validateHookName","createAddHook","hooks","storeKey","addHook","hookName","namespace","callback","priority","hooksStore","console","error","handler","handlers","i","length","splice","__current","forEach","hookInfo","name","currentIndex","runs","doAction"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,aAAT,CAAwBC,KAAxB,EAA+BC,QAA/B,EAA0C;AACzC,SAAO,SAASC,OAAT,CAAkBC,QAAlB,EAA4BC,SAA5B,EAAuCC,QAAvC,EAAiDC,QAAQ,GAAG,EAA5D,EAAiE;AACvE,UAAMC,UAAU,GAAGP,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAEH,gBAAgB,CAAEK,QAAF,CAAvB,EAAsC;AACrC;AACA;;AAED,QAAK,CAAEN,iBAAiB,CAAEO,SAAF,CAAxB,EAAwC;AACvC;AACA;;AAED,QAAK,eAAe,OAAOC,QAA3B,EAAsC;AACrC;AACAG,MAAAA,OAAO,CAACC,KAAR,CAAe,uCAAf;AACA;AACA,KAfsE,CAiBvE;;;AACA,QAAK,aAAa,OAAOH,QAAzB,EAAoC;AACnC;AACAE,MAAAA,OAAO,CAACC,KAAR,CACC,mDADD;AAGA;AACA;;AAED,UAAMC,OAAO,GAAG;AAAEL,MAAAA,QAAF;AAAYC,MAAAA,QAAZ;AAAsBF,MAAAA;AAAtB,KAAhB;;AAEA,QAAKG,UAAU,CAAEJ,QAAF,CAAf,EAA8B;AAC7B;AACA,YAAMQ,QAAQ,GAAGJ,UAAU,CAAEJ,QAAF,CAAV,CAAuBQ,QAAxC;AAEA;;AACA,UAAIC,CAAJ;;AACA,WAAMA,CAAC,GAAGD,QAAQ,CAACE,MAAnB,EAA2BD,CAAC,GAAG,CAA/B,EAAkCA,CAAC,EAAnC,EAAwC;AACvC,YAAKN,QAAQ,IAAIK,QAAQ,CAAEC,CAAC,GAAG,CAAN,CAAR,CAAkBN,QAAnC,EAA8C;AAC7C;AACA;AACD;;AAED,UAAKM,CAAC,KAAKD,QAAQ,CAACE,MAApB,EAA6B;AAC5B;AACAF,QAAAA,QAAQ,CAAEC,CAAF,CAAR,GAAgBF,OAAhB;AACA,OAHD,MAGO;AACN;AACAC,QAAAA,QAAQ,CAACG,MAAT,CAAiBF,CAAjB,EAAoB,CAApB,EAAuBF,OAAvB;AACA,OAlB4B,CAoB7B;AACA;AACA;AACA;;;AACAH,MAAAA,UAAU,CAACQ,SAAX,CAAqBC,OAArB,CAAgCC,QAAF,IAAgB;AAC7C,YACCA,QAAQ,CAACC,IAAT,KAAkBf,QAAlB,IACAc,QAAQ,CAACE,YAAT,IAAyBP,CAF1B,EAGE;AACDK,UAAAA,QAAQ,CAACE,YAAT;AACA;AACD,OAPD;AAQA,KAhCD,MAgCO;AACN;AACAZ,MAAAA,UAAU,CAAEJ,QAAF,CAAV,GAAyB;AACxBQ,QAAAA,QAAQ,EAAE,CAAED,OAAF,CADc;AAExBU,QAAAA,IAAI,EAAE;AAFkB,OAAzB;AAIA;;AAED,QAAKjB,QAAQ,KAAK,WAAlB,EAAgC;AAC/BH,MAAAA,KAAK,CAACqB,QAAN,CACC,WADD,EAEClB,QAFD,EAGCC,SAHD,EAICC,QAJD,EAKCC,QALD;AAOA;AACD,GA7ED;AA8EA;;AAED,eAAeP,aAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace.js';\nimport validateHookName from './validateHookName.js';\n\n/**\n * @callback AddHook\n *\n * Adds the hook to the appropriate hooks container.\n *\n * @param {string} hookName Name of hook to add\n * @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.\n * @param {import('.').Callback} callback Function to call when the hook is run\n * @param {number} [priority=10] Priority of this hook\n */\n\n/**\n * Returns a function which, when invoked, will add a hook.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n *\n * @return {AddHook} Function that adds a new hook.\n */\nfunction createAddHook( hooks, storeKey ) {\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 = { 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\t/** @type {number} */\n\t\t\tlet i;\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 ) => {\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"]}
1
+ {"version":3,"sources":["@wordpress/hooks/src/createAddHook.js"],"names":["validateNamespace","validateHookName","createAddHook","hooks","storeKey","addHook","hookName","namespace","callback","priority","hooksStore","console","error","handler","handlers","i","length","splice","__current","forEach","hookInfo","name","currentIndex","runs","doAction"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,aAAT,CAAwBC,KAAxB,EAA+BC,QAA/B,EAA0C;AACzC,SAAO,SAASC,OAAT,CAAkBC,QAAlB,EAA4BC,SAA5B,EAAuCC,QAAvC,EAAiE;AAAA,QAAhBC,QAAgB,uEAAL,EAAK;AACvE,UAAMC,UAAU,GAAGP,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAEH,gBAAgB,CAAEK,QAAF,CAAvB,EAAsC;AACrC;AACA;;AAED,QAAK,CAAEN,iBAAiB,CAAEO,SAAF,CAAxB,EAAwC;AACvC;AACA;;AAED,QAAK,eAAe,OAAOC,QAA3B,EAAsC;AACrC;AACAG,MAAAA,OAAO,CAACC,KAAR,CAAe,uCAAf;AACA;AACA,KAfsE,CAiBvE;;;AACA,QAAK,aAAa,OAAOH,QAAzB,EAAoC;AACnC;AACAE,MAAAA,OAAO,CAACC,KAAR,CACC,mDADD;AAGA;AACA;;AAED,UAAMC,OAAO,GAAG;AAAEL,MAAAA,QAAF;AAAYC,MAAAA,QAAZ;AAAsBF,MAAAA;AAAtB,KAAhB;;AAEA,QAAKG,UAAU,CAAEJ,QAAF,CAAf,EAA8B;AAC7B;AACA,YAAMQ,QAAQ,GAAGJ,UAAU,CAAEJ,QAAF,CAAV,CAAuBQ,QAAxC;AAEA;;AACA,UAAIC,CAAJ;;AACA,WAAMA,CAAC,GAAGD,QAAQ,CAACE,MAAnB,EAA2BD,CAAC,GAAG,CAA/B,EAAkCA,CAAC,EAAnC,EAAwC;AACvC,YAAKN,QAAQ,IAAIK,QAAQ,CAAEC,CAAC,GAAG,CAAN,CAAR,CAAkBN,QAAnC,EAA8C;AAC7C;AACA;AACD;;AAED,UAAKM,CAAC,KAAKD,QAAQ,CAACE,MAApB,EAA6B;AAC5B;AACAF,QAAAA,QAAQ,CAAEC,CAAF,CAAR,GAAgBF,OAAhB;AACA,OAHD,MAGO;AACN;AACAC,QAAAA,QAAQ,CAACG,MAAT,CAAiBF,CAAjB,EAAoB,CAApB,EAAuBF,OAAvB;AACA,OAlB4B,CAoB7B;AACA;AACA;AACA;;;AACAH,MAAAA,UAAU,CAACQ,SAAX,CAAqBC,OAArB,CAAgCC,QAAF,IAAgB;AAC7C,YACCA,QAAQ,CAACC,IAAT,KAAkBf,QAAlB,IACAc,QAAQ,CAACE,YAAT,IAAyBP,CAF1B,EAGE;AACDK,UAAAA,QAAQ,CAACE,YAAT;AACA;AACD,OAPD;AAQA,KAhCD,MAgCO;AACN;AACAZ,MAAAA,UAAU,CAAEJ,QAAF,CAAV,GAAyB;AACxBQ,QAAAA,QAAQ,EAAE,CAAED,OAAF,CADc;AAExBU,QAAAA,IAAI,EAAE;AAFkB,OAAzB;AAIA;;AAED,QAAKjB,QAAQ,KAAK,WAAlB,EAAgC;AAC/BH,MAAAA,KAAK,CAACqB,QAAN,CACC,WADD,EAEClB,QAFD,EAGCC,SAHD,EAICC,QAJD,EAKCC,QALD;AAOA;AACD,GA7ED;AA8EA;;AAED,eAAeP,aAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace.js';\nimport validateHookName from './validateHookName.js';\n\n/**\n * @callback AddHook\n *\n * Adds the hook to the appropriate hooks container.\n *\n * @param {string} hookName Name of hook to add\n * @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.\n * @param {import('.').Callback} callback Function to call when the hook is run\n * @param {number} [priority=10] Priority of this hook\n */\n\n/**\n * Returns a function which, when invoked, will add a hook.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n *\n * @return {AddHook} Function that adds a new hook.\n */\nfunction createAddHook( hooks, storeKey ) {\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 = { 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\t/** @type {number} */\n\t\t\tlet i;\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 ) => {\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"]}
@@ -28,7 +28,8 @@ import validateHookName from './validateHookName.js';
28
28
  * @return {RemoveHook} Function that removes hooks.
29
29
  */
30
30
 
31
- function createRemoveHook(hooks, storeKey, removeAll = false) {
31
+ function createRemoveHook(hooks, storeKey) {
32
+ let removeAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
32
33
  return function removeHook(hookName, namespace) {
33
34
  const hooksStore = hooks[storeKey];
34
35
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/hooks/src/createRemoveHook.js"],"names":["validateNamespace","validateHookName","createRemoveHook","hooks","storeKey","removeAll","removeHook","hookName","namespace","hooksStore","handlersRemoved","handlers","length","runs","i","splice","__current","forEach","hookInfo","name","currentIndex","doAction"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CAA2BC,KAA3B,EAAkCC,QAAlC,EAA4CC,SAAS,GAAG,KAAxD,EAAgE;AAC/D,SAAO,SAASC,UAAT,CAAqBC,QAArB,EAA+BC,SAA/B,EAA2C;AACjD,UAAMC,UAAU,GAAGN,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAEH,gBAAgB,CAAEM,QAAF,CAAvB,EAAsC;AACrC;AACA;;AAED,QAAK,CAAEF,SAAF,IAAe,CAAEL,iBAAiB,CAAEQ,SAAF,CAAvC,EAAuD;AACtD;AACA,KATgD,CAWjD;;;AACA,QAAK,CAAEC,UAAU,CAAEF,QAAF,CAAjB,EAAgC;AAC/B,aAAO,CAAP;AACA;;AAED,QAAIG,eAAe,GAAG,CAAtB;;AAEA,QAAKL,SAAL,EAAiB;AAChBK,MAAAA,eAAe,GAAGD,UAAU,CAAEF,QAAF,CAAV,CAAuBI,QAAvB,CAAgCC,MAAlD;AACAH,MAAAA,UAAU,CAAEF,QAAF,CAAV,GAAyB;AACxBM,QAAAA,IAAI,EAAEJ,UAAU,CAAEF,QAAF,CAAV,CAAuBM,IADL;AAExBF,QAAAA,QAAQ,EAAE;AAFc,OAAzB;AAIA,KAND,MAMO;AACN;AACA,YAAMA,QAAQ,GAAGF,UAAU,CAAEF,QAAF,CAAV,CAAuBI,QAAxC;;AACA,WAAM,IAAIG,CAAC,GAAGH,QAAQ,CAACC,MAAT,GAAkB,CAAhC,EAAmCE,CAAC,IAAI,CAAxC,EAA2CA,CAAC,EAA5C,EAAiD;AAChD,YAAKH,QAAQ,CAAEG,CAAF,CAAR,CAAcN,SAAd,KAA4BA,SAAjC,EAA6C;AAC5CG,UAAAA,QAAQ,CAACI,MAAT,CAAiBD,CAAjB,EAAoB,CAApB;AACAJ,UAAAA,eAAe,GAF6B,CAG5C;AACA;AACA;AACA;AACA;;AACAD,UAAAA,UAAU,CAACO,SAAX,CAAqBC,OAArB,CAAgCC,QAAF,IAAgB;AAC7C,gBACCA,QAAQ,CAACC,IAAT,KAAkBZ,QAAlB,IACAW,QAAQ,CAACE,YAAT,IAAyBN,CAF1B,EAGE;AACDI,cAAAA,QAAQ,CAACE,YAAT;AACA;AACD,WAPD;AAQA;AACD;AACD;;AAED,QAAKb,QAAQ,KAAK,aAAlB,EAAkC;AACjCJ,MAAAA,KAAK,CAACkB,QAAN,CAAgB,aAAhB,EAA+Bd,QAA/B,EAAyCC,SAAzC;AACA;;AAED,WAAOE,eAAP;AACA,GArDD;AAsDA;;AAED,eAAeR,gBAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace.js';\nimport validateHookName from './validateHookName.js';\n\n/**\n * @callback RemoveHook\n * Removes the specified callback (or all callbacks) from the hook with a given hookName\n * and namespace.\n *\n * @param {string} hookName The name of the hook to modify.\n * @param {string} namespace The unique namespace identifying the callback in the\n * form `vendor/plugin/function`.\n *\n * @return {number | undefined} The number of callbacks removed.\n */\n\n/**\n * Returns a function which, when invoked, will remove a specified hook or all\n * hooks by the given name.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n * @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName,\n * without regard to namespace. Used to create\n * `removeAll*` functions.\n *\n * @return {RemoveHook} Function that removes hooks.\n */\nfunction createRemoveHook( hooks, storeKey, removeAll = false ) {\n\treturn function removeHook( hookName, namespace ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! validateHookName( hookName ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! removeAll && ! validateNamespace( namespace ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Bail if no hooks exist by this name\n\t\tif ( ! hooksStore[ hookName ] ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tlet handlersRemoved = 0;\n\n\t\tif ( removeAll ) {\n\t\t\thandlersRemoved = hooksStore[ hookName ].handlers.length;\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\truns: hooksStore[ hookName ].runs,\n\t\t\t\thandlers: [],\n\t\t\t};\n\t\t} else {\n\t\t\t// Try to find the specified callback to remove.\n\t\t\tconst handlers = hooksStore[ hookName ].handlers;\n\t\t\tfor ( let i = handlers.length - 1; i >= 0; i-- ) {\n\t\t\t\tif ( handlers[ i ].namespace === namespace ) {\n\t\t\t\t\thandlers.splice( i, 1 );\n\t\t\t\t\thandlersRemoved++;\n\t\t\t\t\t// This callback may also be part of a hook that is\n\t\t\t\t\t// currently executing. If the callback we're removing\n\t\t\t\t\t// comes after the current callback, there's no problem;\n\t\t\t\t\t// otherwise we need to decrease the execution index of any\n\t\t\t\t\t// other runs by 1 to account for the removed element.\n\t\t\t\t\thooksStore.__current.forEach( ( hookInfo ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thookInfo.name === hookName &&\n\t\t\t\t\t\t\thookInfo.currentIndex >= i\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thookInfo.currentIndex--;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( hookName !== 'hookRemoved' ) {\n\t\t\thooks.doAction( 'hookRemoved', hookName, namespace );\n\t\t}\n\n\t\treturn handlersRemoved;\n\t};\n}\n\nexport default createRemoveHook;\n"]}
1
+ {"version":3,"sources":["@wordpress/hooks/src/createRemoveHook.js"],"names":["validateNamespace","validateHookName","createRemoveHook","hooks","storeKey","removeAll","removeHook","hookName","namespace","hooksStore","handlersRemoved","handlers","length","runs","i","splice","__current","forEach","hookInfo","name","currentIndex","doAction"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,gBAAT,CAA2BC,KAA3B,EAAkCC,QAAlC,EAAgE;AAAA,MAApBC,SAAoB,uEAAR,KAAQ;AAC/D,SAAO,SAASC,UAAT,CAAqBC,QAArB,EAA+BC,SAA/B,EAA2C;AACjD,UAAMC,UAAU,GAAGN,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAEH,gBAAgB,CAAEM,QAAF,CAAvB,EAAsC;AACrC;AACA;;AAED,QAAK,CAAEF,SAAF,IAAe,CAAEL,iBAAiB,CAAEQ,SAAF,CAAvC,EAAuD;AACtD;AACA,KATgD,CAWjD;;;AACA,QAAK,CAAEC,UAAU,CAAEF,QAAF,CAAjB,EAAgC;AAC/B,aAAO,CAAP;AACA;;AAED,QAAIG,eAAe,GAAG,CAAtB;;AAEA,QAAKL,SAAL,EAAiB;AAChBK,MAAAA,eAAe,GAAGD,UAAU,CAAEF,QAAF,CAAV,CAAuBI,QAAvB,CAAgCC,MAAlD;AACAH,MAAAA,UAAU,CAAEF,QAAF,CAAV,GAAyB;AACxBM,QAAAA,IAAI,EAAEJ,UAAU,CAAEF,QAAF,CAAV,CAAuBM,IADL;AAExBF,QAAAA,QAAQ,EAAE;AAFc,OAAzB;AAIA,KAND,MAMO;AACN;AACA,YAAMA,QAAQ,GAAGF,UAAU,CAAEF,QAAF,CAAV,CAAuBI,QAAxC;;AACA,WAAM,IAAIG,CAAC,GAAGH,QAAQ,CAACC,MAAT,GAAkB,CAAhC,EAAmCE,CAAC,IAAI,CAAxC,EAA2CA,CAAC,EAA5C,EAAiD;AAChD,YAAKH,QAAQ,CAAEG,CAAF,CAAR,CAAcN,SAAd,KAA4BA,SAAjC,EAA6C;AAC5CG,UAAAA,QAAQ,CAACI,MAAT,CAAiBD,CAAjB,EAAoB,CAApB;AACAJ,UAAAA,eAAe,GAF6B,CAG5C;AACA;AACA;AACA;AACA;;AACAD,UAAAA,UAAU,CAACO,SAAX,CAAqBC,OAArB,CAAgCC,QAAF,IAAgB;AAC7C,gBACCA,QAAQ,CAACC,IAAT,KAAkBZ,QAAlB,IACAW,QAAQ,CAACE,YAAT,IAAyBN,CAF1B,EAGE;AACDI,cAAAA,QAAQ,CAACE,YAAT;AACA;AACD,WAPD;AAQA;AACD;AACD;;AAED,QAAKb,QAAQ,KAAK,aAAlB,EAAkC;AACjCJ,MAAAA,KAAK,CAACkB,QAAN,CAAgB,aAAhB,EAA+Bd,QAA/B,EAAyCC,SAAzC;AACA;;AAED,WAAOE,eAAP;AACA,GArDD;AAsDA;;AAED,eAAeR,gBAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport validateNamespace from './validateNamespace.js';\nimport validateHookName from './validateHookName.js';\n\n/**\n * @callback RemoveHook\n * Removes the specified callback (or all callbacks) from the hook with a given hookName\n * and namespace.\n *\n * @param {string} hookName The name of the hook to modify.\n * @param {string} namespace The unique namespace identifying the callback in the\n * form `vendor/plugin/function`.\n *\n * @return {number | undefined} The number of callbacks removed.\n */\n\n/**\n * Returns a function which, when invoked, will remove a specified hook or all\n * hooks by the given name.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n * @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName,\n * without regard to namespace. Used to create\n * `removeAll*` functions.\n *\n * @return {RemoveHook} Function that removes hooks.\n */\nfunction createRemoveHook( hooks, storeKey, removeAll = false ) {\n\treturn function removeHook( hookName, namespace ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! validateHookName( hookName ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! removeAll && ! validateNamespace( namespace ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Bail if no hooks exist by this name\n\t\tif ( ! hooksStore[ hookName ] ) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tlet handlersRemoved = 0;\n\n\t\tif ( removeAll ) {\n\t\t\thandlersRemoved = hooksStore[ hookName ].handlers.length;\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\truns: hooksStore[ hookName ].runs,\n\t\t\t\thandlers: [],\n\t\t\t};\n\t\t} else {\n\t\t\t// Try to find the specified callback to remove.\n\t\t\tconst handlers = hooksStore[ hookName ].handlers;\n\t\t\tfor ( let i = handlers.length - 1; i >= 0; i-- ) {\n\t\t\t\tif ( handlers[ i ].namespace === namespace ) {\n\t\t\t\t\thandlers.splice( i, 1 );\n\t\t\t\t\thandlersRemoved++;\n\t\t\t\t\t// This callback may also be part of a hook that is\n\t\t\t\t\t// currently executing. If the callback we're removing\n\t\t\t\t\t// comes after the current callback, there's no problem;\n\t\t\t\t\t// otherwise we need to decrease the execution index of any\n\t\t\t\t\t// other runs by 1 to account for the removed element.\n\t\t\t\t\thooksStore.__current.forEach( ( hookInfo ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\thookInfo.name === hookName &&\n\t\t\t\t\t\t\thookInfo.currentIndex >= i\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\thookInfo.currentIndex--;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( hookName !== 'hookRemoved' ) {\n\t\t\thooks.doAction( 'hookRemoved', hookName, namespace );\n\t\t}\n\n\t\treturn handlersRemoved;\n\t};\n}\n\nexport default createRemoveHook;\n"]}
@@ -10,8 +10,9 @@
10
10
  *
11
11
  * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks.
12
12
  */
13
- function createRunHook(hooks, storeKey, returnFirstArg = false) {
14
- return function runHooks(hookName, ...args) {
13
+ function createRunHook(hooks, storeKey) {
14
+ let returnFirstArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
15
+ return function runHooks(hookName) {
15
16
  const hooksStore = hooks[storeKey];
16
17
 
17
18
  if (!hooksStore[hookName]) {
@@ -31,6 +32,10 @@ function createRunHook(hooks, storeKey, returnFirstArg = false) {
31
32
  }
32
33
  }
33
34
 
35
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
36
+ args[_key - 1] = arguments[_key];
37
+ }
38
+
34
39
  if (!handlers || !handlers.length) {
35
40
  return returnFirstArg ? args[0] : undefined;
36
41
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/hooks/src/createRunHook.js"],"names":["createRunHook","hooks","storeKey","returnFirstArg","runHooks","hookName","args","hooksStore","handlers","runs","process","env","NODE_ENV","all","push","length","undefined","hookInfo","name","currentIndex","__current","handler","result","callback","apply","pop"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,CAAwBC,KAAxB,EAA+BC,QAA/B,EAAyCC,cAAc,GAAG,KAA1D,EAAkE;AACjE,SAAO,SAASC,QAAT,CAAmBC,QAAnB,EAA6B,GAAGC,IAAhC,EAAuC;AAC7C,UAAMC,UAAU,GAAGN,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAEK,UAAU,CAAEF,QAAF,CAAjB,EAAgC;AAC/BE,MAAAA,UAAU,CAAEF,QAAF,CAAV,GAAyB;AACxBG,QAAAA,QAAQ,EAAE,EADc;AAExBC,QAAAA,IAAI,EAAE;AAFkB,OAAzB;AAIA;;AAEDF,IAAAA,UAAU,CAAEF,QAAF,CAAV,CAAuBI,IAAvB;AAEA,UAAMD,QAAQ,GAAGD,UAAU,CAAEF,QAAF,CAAV,CAAuBG,QAAxC,CAZ6C,CAc7C;;AACA,QAAK,iBAAiBE,OAAO,CAACC,GAAR,CAAYC,QAAlC,EAA6C;AAC5C;AACA,UAAK,gBAAgBP,QAAhB,IAA4BE,UAAU,CAACM,GAA5C,EAAkD;AACjDL,QAAAA,QAAQ,CAACM,IAAT,CAAe,GAAGP,UAAU,CAACM,GAAX,CAAeL,QAAjC;AACA;AACD;;AAED,QAAK,CAAEA,QAAF,IAAc,CAAEA,QAAQ,CAACO,MAA9B,EAAuC;AACtC,aAAOZ,cAAc,GAAGG,IAAI,CAAE,CAAF,CAAP,GAAeU,SAApC;AACA;;AAED,UAAMC,QAAQ,GAAG;AAChBC,MAAAA,IAAI,EAAEb,QADU;AAEhBc,MAAAA,YAAY,EAAE;AAFE,KAAjB;;AAKAZ,IAAAA,UAAU,CAACa,SAAX,CAAqBN,IAArB,CAA2BG,QAA3B;;AAEA,WAAQA,QAAQ,CAACE,YAAT,GAAwBX,QAAQ,CAACO,MAAzC,EAAkD;AACjD,YAAMM,OAAO,GAAGb,QAAQ,CAAES,QAAQ,CAACE,YAAX,CAAxB;AAEA,YAAMG,MAAM,GAAGD,OAAO,CAACE,QAAR,CAAiBC,KAAjB,CAAwB,IAAxB,EAA8BlB,IAA9B,CAAf;;AACA,UAAKH,cAAL,EAAsB;AACrBG,QAAAA,IAAI,CAAE,CAAF,CAAJ,GAAYgB,MAAZ;AACA;;AAEDL,MAAAA,QAAQ,CAACE,YAAT;AACA;;AAEDZ,IAAAA,UAAU,CAACa,SAAX,CAAqBK,GAArB;;AAEA,QAAKtB,cAAL,EAAsB;AACrB,aAAOG,IAAI,CAAE,CAAF,CAAX;AACA;AACD,GAjDD;AAkDA;;AAED,eAAeN,aAAf","sourcesContent":["/**\n * Returns a function which, when invoked, will execute all callbacks\n * registered to a hook of the specified type, optionally returning the final\n * value of the call chain.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n * @param {boolean} [returnFirstArg=false] Whether each hook callback is expected to\n * return its first argument.\n *\n * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks.\n */\nfunction createRunHook( hooks, storeKey, returnFirstArg = false ) {\n\treturn function runHooks( hookName, ...args ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! hooksStore[ hookName ] ) {\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\thandlers: [],\n\t\t\t\truns: 0,\n\t\t\t};\n\t\t}\n\n\t\thooksStore[ hookName ].runs++;\n\n\t\tconst handlers = hooksStore[ hookName ].handlers;\n\n\t\t// The following code is stripped from production builds.\n\t\tif ( 'production' !== process.env.NODE_ENV ) {\n\t\t\t// Handle any 'all' hooks registered.\n\t\t\tif ( 'hookAdded' !== hookName && hooksStore.all ) {\n\t\t\t\thandlers.push( ...hooksStore.all.handlers );\n\t\t\t}\n\t\t}\n\n\t\tif ( ! handlers || ! handlers.length ) {\n\t\t\treturn returnFirstArg ? args[ 0 ] : undefined;\n\t\t}\n\n\t\tconst hookInfo = {\n\t\t\tname: hookName,\n\t\t\tcurrentIndex: 0,\n\t\t};\n\n\t\thooksStore.__current.push( hookInfo );\n\n\t\twhile ( hookInfo.currentIndex < handlers.length ) {\n\t\t\tconst handler = handlers[ hookInfo.currentIndex ];\n\n\t\t\tconst result = handler.callback.apply( null, args );\n\t\t\tif ( returnFirstArg ) {\n\t\t\t\targs[ 0 ] = result;\n\t\t\t}\n\n\t\t\thookInfo.currentIndex++;\n\t\t}\n\n\t\thooksStore.__current.pop();\n\n\t\tif ( returnFirstArg ) {\n\t\t\treturn args[ 0 ];\n\t\t}\n\t};\n}\n\nexport default createRunHook;\n"]}
1
+ {"version":3,"sources":["@wordpress/hooks/src/createRunHook.js"],"names":["createRunHook","hooks","storeKey","returnFirstArg","runHooks","hookName","hooksStore","handlers","runs","process","env","NODE_ENV","all","push","args","length","undefined","hookInfo","name","currentIndex","__current","handler","result","callback","apply","pop"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,CAAwBC,KAAxB,EAA+BC,QAA/B,EAAkE;AAAA,MAAzBC,cAAyB,uEAAR,KAAQ;AACjE,SAAO,SAASC,QAAT,CAAmBC,QAAnB,EAAuC;AAC7C,UAAMC,UAAU,GAAGL,KAAK,CAAEC,QAAF,CAAxB;;AAEA,QAAK,CAAEI,UAAU,CAAED,QAAF,CAAjB,EAAgC;AAC/BC,MAAAA,UAAU,CAAED,QAAF,CAAV,GAAyB;AACxBE,QAAAA,QAAQ,EAAE,EADc;AAExBC,QAAAA,IAAI,EAAE;AAFkB,OAAzB;AAIA;;AAEDF,IAAAA,UAAU,CAAED,QAAF,CAAV,CAAuBG,IAAvB;AAEA,UAAMD,QAAQ,GAAGD,UAAU,CAAED,QAAF,CAAV,CAAuBE,QAAxC,CAZ6C,CAc7C;;AACA,QAAK,iBAAiBE,OAAO,CAACC,GAAR,CAAYC,QAAlC,EAA6C;AAC5C;AACA,UAAK,gBAAgBN,QAAhB,IAA4BC,UAAU,CAACM,GAA5C,EAAkD;AACjDL,QAAAA,QAAQ,CAACM,IAAT,CAAe,GAAGP,UAAU,CAACM,GAAX,CAAeL,QAAjC;AACA;AACD;;AApB4C,sCAAPO,IAAO;AAAPA,MAAAA,IAAO;AAAA;;AAsB7C,QAAK,CAAEP,QAAF,IAAc,CAAEA,QAAQ,CAACQ,MAA9B,EAAuC;AACtC,aAAOZ,cAAc,GAAGW,IAAI,CAAE,CAAF,CAAP,GAAeE,SAApC;AACA;;AAED,UAAMC,QAAQ,GAAG;AAChBC,MAAAA,IAAI,EAAEb,QADU;AAEhBc,MAAAA,YAAY,EAAE;AAFE,KAAjB;;AAKAb,IAAAA,UAAU,CAACc,SAAX,CAAqBP,IAArB,CAA2BI,QAA3B;;AAEA,WAAQA,QAAQ,CAACE,YAAT,GAAwBZ,QAAQ,CAACQ,MAAzC,EAAkD;AACjD,YAAMM,OAAO,GAAGd,QAAQ,CAAEU,QAAQ,CAACE,YAAX,CAAxB;AAEA,YAAMG,MAAM,GAAGD,OAAO,CAACE,QAAR,CAAiBC,KAAjB,CAAwB,IAAxB,EAA8BV,IAA9B,CAAf;;AACA,UAAKX,cAAL,EAAsB;AACrBW,QAAAA,IAAI,CAAE,CAAF,CAAJ,GAAYQ,MAAZ;AACA;;AAEDL,MAAAA,QAAQ,CAACE,YAAT;AACA;;AAEDb,IAAAA,UAAU,CAACc,SAAX,CAAqBK,GAArB;;AAEA,QAAKtB,cAAL,EAAsB;AACrB,aAAOW,IAAI,CAAE,CAAF,CAAX;AACA;AACD,GAjDD;AAkDA;;AAED,eAAed,aAAf","sourcesContent":["/**\n * Returns a function which, when invoked, will execute all callbacks\n * registered to a hook of the specified type, optionally returning the final\n * value of the call chain.\n *\n * @param {import('.').Hooks} hooks Hooks instance.\n * @param {import('.').StoreKey} storeKey\n * @param {boolean} [returnFirstArg=false] Whether each hook callback is expected to\n * return its first argument.\n *\n * @return {(hookName:string, ...args: unknown[]) => unknown} Function that runs hook callbacks.\n */\nfunction createRunHook( hooks, storeKey, returnFirstArg = false ) {\n\treturn function runHooks( hookName, ...args ) {\n\t\tconst hooksStore = hooks[ storeKey ];\n\n\t\tif ( ! hooksStore[ hookName ] ) {\n\t\t\thooksStore[ hookName ] = {\n\t\t\t\thandlers: [],\n\t\t\t\truns: 0,\n\t\t\t};\n\t\t}\n\n\t\thooksStore[ hookName ].runs++;\n\n\t\tconst handlers = hooksStore[ hookName ].handlers;\n\n\t\t// The following code is stripped from production builds.\n\t\tif ( 'production' !== process.env.NODE_ENV ) {\n\t\t\t// Handle any 'all' hooks registered.\n\t\t\tif ( 'hookAdded' !== hookName && hooksStore.all ) {\n\t\t\t\thandlers.push( ...hooksStore.all.handlers );\n\t\t\t}\n\t\t}\n\n\t\tif ( ! handlers || ! handlers.length ) {\n\t\t\treturn returnFirstArg ? args[ 0 ] : undefined;\n\t\t}\n\n\t\tconst hookInfo = {\n\t\t\tname: hookName,\n\t\t\tcurrentIndex: 0,\n\t\t};\n\n\t\thooksStore.__current.push( hookInfo );\n\n\t\twhile ( hookInfo.currentIndex < handlers.length ) {\n\t\t\tconst handler = handlers[ hookInfo.currentIndex ];\n\n\t\t\tconst result = handler.callback.apply( null, args );\n\t\t\tif ( returnFirstArg ) {\n\t\t\t\targs[ 0 ] = result;\n\t\t\t}\n\n\t\t\thookInfo.currentIndex++;\n\t\t}\n\n\t\thooksStore.__current.pop();\n\n\t\tif ( returnFirstArg ) {\n\t\t\treturn args[ 0 ];\n\t\t}\n\t};\n}\n\nexport default createRunHook;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"createHooks.d.ts","sourceRoot":"","sources":["../src/createHooks.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH;IAEE,wCAAwC;IACxC,SADW,OAAO,GAAG,EAAE,KAAK,CACQ;IAGpC,wCAAwC;IACxC,SADW,OAAO,GAAG,EAAE,KAAK,CACQ;IAGpC,6CAAiD;IACjD,6CAAiD;IACjD,sDAAuD;IACvD,sDAAuD;IACvD,6CAAiD;IACjD,6CAAiD;IACjD,0DAAiE;IACjE,0DAAiE;IACjE,4DAAgD;IAChD,gEAA0D;IAC1D,mCAAyD;IACzD,mCAAyD;IACzD,mDAAqD;IACrD,mDAAqD;IACrD,6CAAiD;IACjD,6CAAiD;CAElD;;;AAED,8BAA8B;AAE9B;;;;GAIG;AACH,gCAFY,KAAK,CAIhB"}
1
+ {"version":3,"file":"createHooks.d.ts","sourceRoot":"","sources":["../src/createHooks.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH;IAEE,wCAAwC;IACxC,SADW,OAAO,GAAG,EAAE,KAAK,CACQ;IAGpC,wCAAwC;IACxC,SADW,OAAO,GAAG,EAAE,KAAK,CACQ;IAGpC,6CAAiD;IACjD,6CAAiD;IACjD,sDAAuD;IACvD,sDAAuD;IACvD,6CAAiD;IACjD,6CAAiD;IACjD,0DAAiE;IACjE,0DAAiE;IACjE,4DAAgD;IAChD,gEAA0D;IAC1D,mCAAyD;IACzD,mCAAyD;IACzD,mDAAqD;IACrD,mDAAqD;IACrD,6CAAiD;IACjD,6CAAiD;CAElD;;oBAEa,MAAM;AAApB,8BAA8B;AAE9B;;;;GAIG;AACH,gCAFY,KAAK,CAIhB"}
@@ -63,8 +63,8 @@ export type Current = {
63
63
  export type Store = Record<string, Hook> & {
64
64
  __current: Current[];
65
65
  };
66
- export type StoreKey = "actions" | "filters";
67
- export type Hooks = import("./createHooks")._Hooks;
66
+ export type StoreKey = 'actions' | 'filters';
67
+ export type Hooks = import('./createHooks').Hooks;
68
68
  import createHooks from "./createHooks";
69
69
  export const addAction: import("./createAddHook").AddHook;
70
70
  export const addFilter: import("./createAddHook").AddHook;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAKA,gDAAgD;AAEhD;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH,0DAA0C;iCAjClB,GAAG,EAAE,KAAG,GAAG;;;;;cAIrB,QAAQ;;;;eACR,MAAM;;;;cACN,MAAM;;;;;;cAKN,OAAO,EAAE;;;;UACT,MAAM;;;;;;UAKN,MAAM;;;;kBACN,MAAM;;;eAI4B,OAAO,EAAE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAKA,gDAAgD;AAEhD;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH,0DAA0C;iCAjClB,GAAG,EAAE,KAAG,GAAG;;;;;cAIrB,QAAQ;;;;eACR,MAAM;;;;cACN,MAAM;;;;;;cAKN,OAAO,EAAE;;;;UACT,MAAM;;;;;;UAKN,MAAM;;;;kBACN,MAAM;;oBAIP,OAAO,MAAM,EAAE,IAAI,CAAC,GAAG;IAAC,SAAS,EAAE,OAAO,EAAE,CAAA;CAAC;uBAI7C,SAAS,GAAG,SAAS;oBAIrB,OAAO,eAAe,EAAE,KAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/hooks",
3
- "version": "3.2.1-next.5df0cd52b7.0",
3
+ "version": "3.3.0",
4
4
  "description": "WordPress hooks library.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,10 +26,10 @@
26
26
  "react-native": "src/index",
27
27
  "types": "build-types",
28
28
  "dependencies": {
29
- "@babel/runtime": "^7.13.10"
29
+ "@babel/runtime": "^7.16.0"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "558d577d12bec15f05e694eb49a094836d885cca"
34
+ "gitHead": "d95ccb9366e249133cdb1d7b25c382446b9ee502"
35
35
  }
@@ -1,455 +1 @@
1
- {
2
- "program": {
3
- "fileInfos": {
4
- "../../node_modules/typescript/lib/lib.es5.d.ts": {
5
- "version": "9622e8bd7cc72a7dab819a8011ecbf81d443638082e5cb99ecf2e75ff56ffc9d",
6
- "signature": "9622e8bd7cc72a7dab819a8011ecbf81d443638082e5cb99ecf2e75ff56ffc9d",
7
- "affectsGlobalScope": true
8
- },
9
- "../../node_modules/typescript/lib/lib.es2015.d.ts": {
10
- "version": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6",
11
- "signature": "dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6",
12
- "affectsGlobalScope": false
13
- },
14
- "../../node_modules/typescript/lib/lib.es2016.d.ts": {
15
- "version": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467",
16
- "signature": "7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467",
17
- "affectsGlobalScope": false
18
- },
19
- "../../node_modules/typescript/lib/lib.es2017.d.ts": {
20
- "version": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9",
21
- "signature": "8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9",
22
- "affectsGlobalScope": false
23
- },
24
- "../../node_modules/typescript/lib/lib.es2018.d.ts": {
25
- "version": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06",
26
- "signature": "5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06",
27
- "affectsGlobalScope": false
28
- },
29
- "../../node_modules/typescript/lib/lib.es2019.d.ts": {
30
- "version": "e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84",
31
- "signature": "e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84",
32
- "affectsGlobalScope": false
33
- },
34
- "../../node_modules/typescript/lib/lib.es2020.d.ts": {
35
- "version": "e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",
36
- "signature": "e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940",
37
- "affectsGlobalScope": false
38
- },
39
- "../../node_modules/typescript/lib/lib.esnext.d.ts": {
40
- "version": "fc7a21dd3ee27fd0a9ff1c46534efcd9c3cec51a445b479bb326d871c0aa8302",
41
- "signature": "fc7a21dd3ee27fd0a9ff1c46534efcd9c3cec51a445b479bb326d871c0aa8302",
42
- "affectsGlobalScope": false
43
- },
44
- "../../node_modules/typescript/lib/lib.dom.d.ts": {
45
- "version": "abadddbf660adeec27e9a56584907d52fa1d6e1e1dc49f639a921baa951b7a84",
46
- "signature": "abadddbf660adeec27e9a56584907d52fa1d6e1e1dc49f639a921baa951b7a84",
47
- "affectsGlobalScope": true
48
- },
49
- "../../node_modules/typescript/lib/lib.es2015.core.d.ts": {
50
- "version": "46ee15e9fefa913333b61eaf6b18885900b139867d89832a515059b62cf16a17",
51
- "signature": "46ee15e9fefa913333b61eaf6b18885900b139867d89832a515059b62cf16a17",
52
- "affectsGlobalScope": true
53
- },
54
- "../../node_modules/typescript/lib/lib.es2015.collection.d.ts": {
55
- "version": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c",
56
- "signature": "43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c",
57
- "affectsGlobalScope": true
58
- },
59
- "../../node_modules/typescript/lib/lib.es2015.generator.d.ts": {
60
- "version": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a",
61
- "signature": "cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a",
62
- "affectsGlobalScope": true
63
- },
64
- "../../node_modules/typescript/lib/lib.es2015.iterable.d.ts": {
65
- "version": "8b2a5df1ce95f78f6b74f1a555ccdb6baab0486b42d8345e0871dd82811f9b9a",
66
- "signature": "8b2a5df1ce95f78f6b74f1a555ccdb6baab0486b42d8345e0871dd82811f9b9a",
67
- "affectsGlobalScope": true
68
- },
69
- "../../node_modules/typescript/lib/lib.es2015.promise.d.ts": {
70
- "version": "2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c",
71
- "signature": "2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c",
72
- "affectsGlobalScope": true
73
- },
74
- "../../node_modules/typescript/lib/lib.es2015.proxy.d.ts": {
75
- "version": "7207e317a2cb07a177e7d963ab7b8c0e85dde7f9ddb50351f830239bf597569e",
76
- "signature": "7207e317a2cb07a177e7d963ab7b8c0e85dde7f9ddb50351f830239bf597569e",
77
- "affectsGlobalScope": true
78
- },
79
- "../../node_modules/typescript/lib/lib.es2015.reflect.d.ts": {
80
- "version": "cb609802a8698aa28b9c56331d4b53f590ca3c1c3a255350304ae3d06017779d",
81
- "signature": "cb609802a8698aa28b9c56331d4b53f590ca3c1c3a255350304ae3d06017779d",
82
- "affectsGlobalScope": true
83
- },
84
- "../../node_modules/typescript/lib/lib.es2015.symbol.d.ts": {
85
- "version": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93",
86
- "signature": "3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93",
87
- "affectsGlobalScope": true
88
- },
89
- "../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": {
90
- "version": "9d122b7e8c1a5c72506eea50c0973cba55b92b5532d5cafa8a6ce2c547d57551",
91
- "signature": "9d122b7e8c1a5c72506eea50c0973cba55b92b5532d5cafa8a6ce2c547d57551",
92
- "affectsGlobalScope": true
93
- },
94
- "../../node_modules/typescript/lib/lib.es2016.array.include.d.ts": {
95
- "version": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006",
96
- "signature": "3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006",
97
- "affectsGlobalScope": true
98
- },
99
- "../../node_modules/typescript/lib/lib.es2017.object.d.ts": {
100
- "version": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a",
101
- "signature": "17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a",
102
- "affectsGlobalScope": true
103
- },
104
- "../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": {
105
- "version": "7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98",
106
- "signature": "7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98",
107
- "affectsGlobalScope": true
108
- },
109
- "../../node_modules/typescript/lib/lib.es2017.string.d.ts": {
110
- "version": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577",
111
- "signature": "6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577",
112
- "affectsGlobalScope": true
113
- },
114
- "../../node_modules/typescript/lib/lib.es2017.intl.d.ts": {
115
- "version": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d",
116
- "signature": "12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d",
117
- "affectsGlobalScope": true
118
- },
119
- "../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": {
120
- "version": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e",
121
- "signature": "b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e",
122
- "affectsGlobalScope": true
123
- },
124
- "../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts": {
125
- "version": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a",
126
- "signature": "0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a",
127
- "affectsGlobalScope": true
128
- },
129
- "../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts": {
130
- "version": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359",
131
- "signature": "a40c4d82bf13fcded295ac29f354eb7d40249613c15e07b53f2fc75e45e16359",
132
- "affectsGlobalScope": true
133
- },
134
- "../../node_modules/typescript/lib/lib.es2018.intl.d.ts": {
135
- "version": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e",
136
- "signature": "df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e",
137
- "affectsGlobalScope": true
138
- },
139
- "../../node_modules/typescript/lib/lib.es2018.promise.d.ts": {
140
- "version": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c",
141
- "signature": "bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c",
142
- "affectsGlobalScope": true
143
- },
144
- "../../node_modules/typescript/lib/lib.es2018.regexp.d.ts": {
145
- "version": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8",
146
- "signature": "c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8",
147
- "affectsGlobalScope": true
148
- },
149
- "../../node_modules/typescript/lib/lib.es2019.array.d.ts": {
150
- "version": "9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951",
151
- "signature": "9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951",
152
- "affectsGlobalScope": true
153
- },
154
- "../../node_modules/typescript/lib/lib.es2019.object.d.ts": {
155
- "version": "6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de",
156
- "signature": "6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de",
157
- "affectsGlobalScope": true
158
- },
159
- "../../node_modules/typescript/lib/lib.es2019.string.d.ts": {
160
- "version": "93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1",
161
- "signature": "93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1",
162
- "affectsGlobalScope": true
163
- },
164
- "../../node_modules/typescript/lib/lib.es2019.symbol.d.ts": {
165
- "version": "2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993",
166
- "signature": "2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993",
167
- "affectsGlobalScope": true
168
- },
169
- "../../node_modules/typescript/lib/lib.es2020.bigint.d.ts": {
170
- "version": "7b5a10e3c897fabece5a51aa85b4111727d7adb53c2734b5d37230ff96802a09",
171
- "signature": "7b5a10e3c897fabece5a51aa85b4111727d7adb53c2734b5d37230ff96802a09",
172
- "affectsGlobalScope": true
173
- },
174
- "../../node_modules/typescript/lib/lib.es2020.promise.d.ts": {
175
- "version": "7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862",
176
- "signature": "7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862",
177
- "affectsGlobalScope": true
178
- },
179
- "../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts": {
180
- "version": "e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40",
181
- "signature": "e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40",
182
- "affectsGlobalScope": true
183
- },
184
- "../../node_modules/typescript/lib/lib.es2020.string.d.ts": {
185
- "version": "faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e",
186
- "signature": "faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e",
187
- "affectsGlobalScope": true
188
- },
189
- "../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts": {
190
- "version": "936d7d2e8851af9ccfa5333b15e877a824417d352b1d7fd06388639dc69ef80a",
191
- "signature": "936d7d2e8851af9ccfa5333b15e877a824417d352b1d7fd06388639dc69ef80a",
192
- "affectsGlobalScope": true
193
- },
194
- "../../node_modules/typescript/lib/lib.es2020.intl.d.ts": {
195
- "version": "31e8df2398e328077079c17ea4f1664bad0a34adf8b0608837e504e310e329a1",
196
- "signature": "31e8df2398e328077079c17ea4f1664bad0a34adf8b0608837e504e310e329a1",
197
- "affectsGlobalScope": true
198
- },
199
- "../../node_modules/typescript/lib/lib.esnext.intl.d.ts": {
200
- "version": "89bf2b7a601b73ea4311eda9c41f86a58994fec1bee3b87c4a14d68d9adcdcbd",
201
- "signature": "89bf2b7a601b73ea4311eda9c41f86a58994fec1bee3b87c4a14d68d9adcdcbd",
202
- "affectsGlobalScope": true
203
- },
204
- "../../node_modules/typescript/lib/lib.esnext.string.d.ts": {
205
- "version": "fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe",
206
- "signature": "fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe",
207
- "affectsGlobalScope": true
208
- },
209
- "../../node_modules/typescript/lib/lib.esnext.promise.d.ts": {
210
- "version": "cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e",
211
- "signature": "cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e",
212
- "affectsGlobalScope": true
213
- },
214
- "../../node_modules/typescript/lib/lib.esnext.weakref.d.ts": {
215
- "version": "1e61418f41d404e744b6536af9f8c6f6674dd4d54c12335cd0c4f7eded69cf3f",
216
- "signature": "1e61418f41d404e744b6536af9f8c6f6674dd4d54c12335cd0c4f7eded69cf3f",
217
- "affectsGlobalScope": true
218
- },
219
- "./src/validatenamespace.js": {
220
- "version": "16fb2ca91cf5fe9e857e5214a31311487524ae87e69b23c7371040bb1a82eaa2",
221
- "signature": "e485e352e38fb56a9adc1f3207373ae8a9457c92bcea70bf36d49bb99813e247",
222
- "affectsGlobalScope": false
223
- },
224
- "./src/validatehookname.js": {
225
- "version": "acf2c9ac7d645ac867c9c6cf8238b1bf9d592c21e9aff3253aecbc546b605858",
226
- "signature": "d2a3bcddc555a9245f0a50a6b729efdc2ad6b13552bc63a2b7498db0e6af9b36",
227
- "affectsGlobalScope": false
228
- },
229
- "./src/createremovehook.js": {
230
- "version": "1dcb3f1f42491479bca845bfa97b3280a877d37183a0e7e4c8bbed77a783cae8",
231
- "signature": "27abed653f600ea0d5c86e94181beb42824e0f3f16337e2f9e7e9e9c2c392edf",
232
- "affectsGlobalScope": false
233
- },
234
- "./src/createhashook.js": {
235
- "version": "5c268d6816af1e751d387a9e573e9376cce62aeef7c7f772aa0572f9aab31726",
236
- "signature": "d7871e0e653aa7197fee88886db5678bee6d42164c1f36e4bce9421ddfa7ca49",
237
- "affectsGlobalScope": false
238
- },
239
- "./src/createrunhook.js": {
240
- "version": "ce9f48cfce31518885fbaa80bbb937c21644d9a172ac927f06f7c5ac6f7978ad",
241
- "signature": "3ed928b931ce331b645fa4f4ee6d5b03b5946df85dabc0e09a81b817b1688f04",
242
- "affectsGlobalScope": false
243
- },
244
- "./src/createcurrenthook.js": {
245
- "version": "26df58dcd89c4225b8d5fe7acd52c98237eb8420e259b6401a257f4f241628fe",
246
- "signature": "33b55f41287dce88fb9b420001dc88fc326de9b35bb7a381703d00b0142194c7",
247
- "affectsGlobalScope": false
248
- },
249
- "./src/createdoinghook.js": {
250
- "version": "90acf630245d1df8d3bc9ddadbb686ca41cbbafd03436b9b1a816d62be4beabc",
251
- "signature": "11ed10bdb3bcc99893570507eac8fece4840add97ee1d4f5a7fbf41cbfdea0d4",
252
- "affectsGlobalScope": false
253
- },
254
- "./src/createdidhook.js": {
255
- "version": "062731f93b86ef4bdf0f4f26b28248169cc6beb751c6c20626655f9342e31b6a",
256
- "signature": "429fb571d3db07d3eaa2e74d43eb4190ece3e0de832ed564aeeaf08873e598eb",
257
- "affectsGlobalScope": false
258
- },
259
- "./src/createhooks.js": {
260
- "version": "8835293f95a59a22184bd02c10230993231124240e6da9f6844ee7902ea1ca3f",
261
- "signature": "d3060e0810fc0d0dc009e6f086ef413d3c8aeaaf07da25c8d25fd4e181646acf",
262
- "affectsGlobalScope": false
263
- },
264
- "./src/index.js": {
265
- "version": "27aec6ca27a761f6f7de7f0481b1bf13e82b127e9f6de77c2fdae142c0be2ec7",
266
- "signature": "e1dbde0dd2cee229c90b3f3ebec3fb87089d4c872b5a55dce3a6e1f99665e978",
267
- "affectsGlobalScope": false
268
- },
269
- "./src/createaddhook.js": {
270
- "version": "60282105d2e5ca8103d56b34a8a4dd200f2565529638bf299ad4c31d6c696307",
271
- "signature": "d02ec79cefaf292fae64b3be5a4416e64b4e420a6429fd458fac6e1bb4c7950e",
272
- "affectsGlobalScope": false
273
- },
274
- "../../typings/gutenberg-env/index.d.ts": {
275
- "version": "c63d7c3f912d6f757d2ffee28f25781211661bf966e11eeca080976e4d8e79bb",
276
- "signature": "c63d7c3f912d6f757d2ffee28f25781211661bf966e11eeca080976e4d8e79bb",
277
- "affectsGlobalScope": true
278
- }
279
- },
280
- "options": {
281
- "allowJs": true,
282
- "checkJs": true,
283
- "allowSyntheticDefaultImports": true,
284
- "jsx": 1,
285
- "target": 99,
286
- "module": 99,
287
- "lib": [
288
- "lib.dom.d.ts",
289
- "lib.esnext.d.ts"
290
- ],
291
- "declaration": true,
292
- "declarationMap": true,
293
- "composite": true,
294
- "emitDeclarationOnly": true,
295
- "isolatedModules": true,
296
- "strict": true,
297
- "noUnusedLocals": true,
298
- "noUnusedParameters": true,
299
- "noImplicitReturns": true,
300
- "noFallthroughCasesInSwitch": true,
301
- "importsNotUsedAsValues": 2,
302
- "moduleResolution": 2,
303
- "esModuleInterop": false,
304
- "resolveJsonModule": true,
305
- "typeRoots": [
306
- "../../typings",
307
- "../../node_modules/@types"
308
- ],
309
- "types": [
310
- "gutenberg-env"
311
- ],
312
- "rootDir": "./src",
313
- "declarationDir": "./build-types",
314
- "configFilePath": "./tsconfig.json"
315
- },
316
- "referencedMap": {
317
- "./src/createaddhook.js": [
318
- "./src/index.js",
319
- "./src/validatehookname.js",
320
- "./src/validatenamespace.js"
321
- ],
322
- "./src/createcurrenthook.js": [
323
- "./src/index.js"
324
- ],
325
- "./src/createdidhook.js": [
326
- "./src/index.js",
327
- "./src/validatehookname.js"
328
- ],
329
- "./src/createdoinghook.js": [
330
- "./src/index.js"
331
- ],
332
- "./src/createhashook.js": [
333
- "./src/index.js"
334
- ],
335
- "./src/createhooks.js": [
336
- "./src/createaddhook.js",
337
- "./src/createcurrenthook.js",
338
- "./src/createdidhook.js",
339
- "./src/createdoinghook.js",
340
- "./src/createhashook.js",
341
- "./src/createremovehook.js",
342
- "./src/createrunhook.js",
343
- "./src/index.js"
344
- ],
345
- "./src/createremovehook.js": [
346
- "./src/index.js",
347
- "./src/validatehookname.js",
348
- "./src/validatenamespace.js"
349
- ],
350
- "./src/createrunhook.js": [
351
- "./src/index.js"
352
- ],
353
- "./src/index.js": [
354
- "./src/createhooks.js"
355
- ]
356
- },
357
- "exportedModulesMap": {
358
- "./src/createaddhook.js": [
359
- "./src/index.js"
360
- ],
361
- "./src/createcurrenthook.js": [
362
- "./src/index.js"
363
- ],
364
- "./src/createdidhook.js": [
365
- "./src/index.js"
366
- ],
367
- "./src/createdoinghook.js": [
368
- "./src/index.js"
369
- ],
370
- "./src/createhashook.js": [
371
- "./src/index.js"
372
- ],
373
- "./src/createhooks.js": [
374
- "./src/createaddhook.js",
375
- "./src/createdidhook.js",
376
- "./src/createdoinghook.js",
377
- "./src/createhashook.js",
378
- "./src/createremovehook.js",
379
- "./src/index.js"
380
- ],
381
- "./src/createremovehook.js": [
382
- "./src/index.js"
383
- ],
384
- "./src/createrunhook.js": [
385
- "./src/index.js"
386
- ],
387
- "./src/index.js": [
388
- "./src/createaddhook.js",
389
- "./src/createdidhook.js",
390
- "./src/createdoinghook.js",
391
- "./src/createhashook.js",
392
- "./src/createhooks.js",
393
- "./src/createremovehook.js"
394
- ]
395
- },
396
- "semanticDiagnosticsPerFile": [
397
- "../../node_modules/typescript/lib/lib.dom.d.ts",
398
- "../../node_modules/typescript/lib/lib.es2015.collection.d.ts",
399
- "../../node_modules/typescript/lib/lib.es2015.core.d.ts",
400
- "../../node_modules/typescript/lib/lib.es2015.d.ts",
401
- "../../node_modules/typescript/lib/lib.es2015.generator.d.ts",
402
- "../../node_modules/typescript/lib/lib.es2015.iterable.d.ts",
403
- "../../node_modules/typescript/lib/lib.es2015.promise.d.ts",
404
- "../../node_modules/typescript/lib/lib.es2015.proxy.d.ts",
405
- "../../node_modules/typescript/lib/lib.es2015.reflect.d.ts",
406
- "../../node_modules/typescript/lib/lib.es2015.symbol.d.ts",
407
- "../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts",
408
- "../../node_modules/typescript/lib/lib.es2016.array.include.d.ts",
409
- "../../node_modules/typescript/lib/lib.es2016.d.ts",
410
- "../../node_modules/typescript/lib/lib.es2017.d.ts",
411
- "../../node_modules/typescript/lib/lib.es2017.intl.d.ts",
412
- "../../node_modules/typescript/lib/lib.es2017.object.d.ts",
413
- "../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts",
414
- "../../node_modules/typescript/lib/lib.es2017.string.d.ts",
415
- "../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts",
416
- "../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts",
417
- "../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts",
418
- "../../node_modules/typescript/lib/lib.es2018.d.ts",
419
- "../../node_modules/typescript/lib/lib.es2018.intl.d.ts",
420
- "../../node_modules/typescript/lib/lib.es2018.promise.d.ts",
421
- "../../node_modules/typescript/lib/lib.es2018.regexp.d.ts",
422
- "../../node_modules/typescript/lib/lib.es2019.array.d.ts",
423
- "../../node_modules/typescript/lib/lib.es2019.d.ts",
424
- "../../node_modules/typescript/lib/lib.es2019.object.d.ts",
425
- "../../node_modules/typescript/lib/lib.es2019.string.d.ts",
426
- "../../node_modules/typescript/lib/lib.es2019.symbol.d.ts",
427
- "../../node_modules/typescript/lib/lib.es2020.bigint.d.ts",
428
- "../../node_modules/typescript/lib/lib.es2020.d.ts",
429
- "../../node_modules/typescript/lib/lib.es2020.intl.d.ts",
430
- "../../node_modules/typescript/lib/lib.es2020.promise.d.ts",
431
- "../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts",
432
- "../../node_modules/typescript/lib/lib.es2020.string.d.ts",
433
- "../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts",
434
- "../../node_modules/typescript/lib/lib.es5.d.ts",
435
- "../../node_modules/typescript/lib/lib.esnext.d.ts",
436
- "../../node_modules/typescript/lib/lib.esnext.intl.d.ts",
437
- "../../node_modules/typescript/lib/lib.esnext.promise.d.ts",
438
- "../../node_modules/typescript/lib/lib.esnext.string.d.ts",
439
- "../../node_modules/typescript/lib/lib.esnext.weakref.d.ts",
440
- "./src/createaddhook.js",
441
- "./src/createcurrenthook.js",
442
- "./src/createdidhook.js",
443
- "./src/createdoinghook.js",
444
- "./src/createhashook.js",
445
- "./src/createhooks.js",
446
- "./src/createremovehook.js",
447
- "./src/createrunhook.js",
448
- "./src/index.js",
449
- "./src/validatehookname.js",
450
- "./src/validatenamespace.js",
451
- "../../typings/gutenberg-env/index.d.ts"
452
- ]
453
- },
454
- "version": "4.1.3"
455
- }
1
+ {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","./src/validatenamespace.js","./src/validatehookname.js","./src/createremovehook.js","./src/createhashook.js","./src/createrunhook.js","./src/createcurrenthook.js","./src/createdoinghook.js","./src/createdidhook.js","./src/createhooks.js","./src/index.js","./src/createaddhook.js","../../typings/gutenberg-env/index.d.ts"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},"16fb2ca91cf5fe9e857e5214a31311487524ae87e69b23c7371040bb1a82eaa2","acf2c9ac7d645ac867c9c6cf8238b1bf9d592c21e9aff3253aecbc546b605858","1dcb3f1f42491479bca845bfa97b3280a877d37183a0e7e4c8bbed77a783cae8","5c268d6816af1e751d387a9e573e9376cce62aeef7c7f772aa0572f9aab31726","ce9f48cfce31518885fbaa80bbb937c21644d9a172ac927f06f7c5ac6f7978ad","26df58dcd89c4225b8d5fe7acd52c98237eb8420e259b6401a257f4f241628fe","90acf630245d1df8d3bc9ddadbb686ca41cbbafd03436b9b1a816d62be4beabc","062731f93b86ef4bdf0f4f26b28248169cc6beb751c6c20626655f9342e31b6a","8835293f95a59a22184bd02c10230993231124240e6da9f6844ee7902ea1ca3f","27aec6ca27a761f6f7de7f0481b1bf13e82b127e9f6de77c2fdae142c0be2ec7","60282105d2e5ca8103d56b34a8a4dd200f2565529638bf299ad4c31d6c696307",{"version":"f254c1abf6bb4c92633159831f924588908da902aa5e04ae45c39bd001f62e2e","affectsGlobalScope":true}],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[45,46,54],[54],[46,54],[47,48,49,50,51,52,54,55],[53]],"referencedMap":[[55,1],[50,2],[52,3],[51,2],[48,2],[53,4],[47,1],[49,2],[54,5]],"exportedModulesMap":[[55,1],[50,2],[52,3],[51,2],[48,2],[53,4],[47,1],[49,2],[54,5]],"semanticDiagnosticsPerFile":[10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,55,50,52,51,48,53,47,49,54,46,45,56]},"version":"4.4.2"}