@wordpress/hooks 3.3.0 → 3.3.2-next.a55ed9455a.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/README.md +7 -1
- package/build/createRemoveHook.js +1 -1
- package/build/createRemoveHook.js.map +1 -1
- package/build-module/createRemoveHook.js +1 -1
- package/build-module/createRemoveHook.js.map +1 -1
- package/package.json +2 -2
- package/src/createRemoveHook.js +1 -1
- package/src/test/index.test.js +2 -2
- package/tsconfig.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -63,4 +63,10 @@ Whenever an action or filter is added or removed, a matching `hookAdded` or `hoo
|
|
|
63
63
|
|
|
64
64
|
In non-minified builds developers can register a filter or action that will be called on _all_ hooks, for example: `addAction( 'all', 'namespace', callbackFunction );`. Useful for debugging, the code supporting the `all` hook is stripped from the production code for performance reasons.
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
## Contributing to this package
|
|
67
|
+
|
|
68
|
+
This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
|
|
69
|
+
|
|
70
|
+
To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
|
|
71
|
+
|
|
72
|
+
<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
|
|
@@ -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;A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AU,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
|
|
1
|
+
{"version":3,"sources":["@wordpress/hooks/src/createRemoveHook.js"],"names":["createRemoveHook","hooks","storeKey","removeAll","removeHook","hookName","namespace","hooksStore","handlersRemoved","handlers","length","runs","i","spl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A,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 +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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,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
|
|
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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/hooks",
|
|
3
|
-
"version": "3.3.0",
|
|
3
|
+
"version": "3.3.2-next.a55ed9455a.0",
|
|
4
4
|
"description": "WordPress hooks library.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "c5108185851b824d531bce55991a3589947e8551"
|
|
35
35
|
}
|
package/src/createRemoveHook.js
CHANGED
package/src/test/index.test.js
CHANGED
|
@@ -268,7 +268,7 @@ test( 'filters with the same and different priorities', () => {
|
|
|
268
268
|
addFilter( 'test_order', 'my_callback_fn_1d', callbacks.fn_1d, 1 );
|
|
269
269
|
|
|
270
270
|
expect( applyFilters( 'test_order', [] ) ).toEqual( [
|
|
271
|
-
//
|
|
271
|
+
// All except 2b and 3a, which we removed earlier.
|
|
272
272
|
'1a',
|
|
273
273
|
'1b',
|
|
274
274
|
'1c',
|
|
@@ -566,7 +566,7 @@ test( 'doingAction, didAction and hasAction.', () => {
|
|
|
566
566
|
doAction( 'another.action' );
|
|
567
567
|
expect( doingAction( 'test.action' ) ).toBe( false );
|
|
568
568
|
|
|
569
|
-
// Verify an action with no handlers is still counted
|
|
569
|
+
// Verify an action with no handlers is still counted.
|
|
570
570
|
expect( didAction( 'unattached.action' ) ).toBe( 0 );
|
|
571
571
|
doAction( 'unattached.action' );
|
|
572
572
|
expect( doingAction( 'unattached.action' ) ).toBe( false );
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
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/
|
|
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","6ade2d4a5b7fbd0d08bed49004ff33b2a39d8e90886a639f6014de17ecc15510","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"}
|