@wordpress/hooks 4.26.1-next.719a03cbe.0 → 4.27.1-next.46f643fa0.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 +2 -0
- package/build/createAddHook.js +5 -13
- package/build/createAddHook.js.map +1 -1
- package/build/createCurrentHook.js +7 -3
- package/build/createCurrentHook.js.map +1 -1
- package/build/createDidHook.js +4 -8
- package/build/createDidHook.js.map +1 -1
- package/build/createDoingHook.js +7 -8
- package/build/createDoingHook.js.map +1 -1
- package/build/createHasHook.js +8 -10
- package/build/createHasHook.js.map +1 -1
- package/build/createHooks.js +2 -8
- package/build/createHooks.js.map +1 -1
- package/build/createRemoveHook.js +8 -15
- package/build/createRemoveHook.js.map +1 -1
- package/build/createRunHook.js +9 -5
- package/build/createRunHook.js.map +1 -1
- package/build/index.js +36 -33
- package/build/index.js.map +1 -1
- package/build/types.js +6 -0
- package/build/types.js.map +1 -0
- package/build/validateHookName.js +4 -4
- package/build/validateHookName.js.map +1 -1
- package/build/validateNamespace.js +3 -3
- package/build/validateNamespace.js.map +1 -1
- package/build-module/createAddHook.js +5 -13
- package/build-module/createAddHook.js.map +1 -1
- package/build-module/createCurrentHook.js +7 -3
- package/build-module/createCurrentHook.js.map +1 -1
- package/build-module/createDidHook.js +4 -8
- package/build-module/createDidHook.js.map +1 -1
- package/build-module/createDoingHook.js +7 -8
- package/build-module/createDoingHook.js.map +1 -1
- package/build-module/createHasHook.js +8 -10
- package/build-module/createHasHook.js.map +1 -1
- package/build-module/createHooks.js +1 -8
- package/build-module/createHooks.js.map +1 -1
- package/build-module/createRemoveHook.js +8 -15
- package/build-module/createRemoveHook.js.map +1 -1
- package/build-module/createRunHook.js +9 -5
- package/build-module/createRunHook.js.map +1 -1
- package/build-module/index.js +1 -34
- package/build-module/index.js.map +1 -1
- package/build-module/types.js +2 -0
- package/build-module/types.js.map +1 -0
- package/build-module/validateHookName.js +4 -4
- package/build-module/validateHookName.js.map +1 -1
- package/build-module/validateNamespace.js +3 -3
- package/build-module/validateNamespace.js.map +1 -1
- package/build-types/createAddHook.d.ts +22 -14
- package/build-types/createAddHook.d.ts.map +1 -1
- package/build-types/createCurrentHook.d.ts +9 -5
- package/build-types/createCurrentHook.d.ts.map +1 -1
- package/build-types/createDidHook.d.ts +11 -13
- package/build-types/createDidHook.d.ts.map +1 -1
- package/build-types/createDoingHook.d.ts +12 -12
- package/build-types/createDoingHook.d.ts.map +1 -1
- package/build-types/createHasHook.d.ts +16 -14
- package/build-types/createHasHook.d.ts.map +1 -1
- package/build-types/createHooks.d.ts +35 -26
- package/build-types/createHooks.d.ts.map +1 -1
- package/build-types/createRemoveHook.d.ts +16 -18
- package/build-types/createRemoveHook.d.ts.map +1 -1
- package/build-types/createRunHook.d.ts +12 -7
- package/build-types/createRunHook.d.ts.map +1 -1
- package/build-types/index.d.ts +5 -86
- package/build-types/index.d.ts.map +1 -1
- package/build-types/types.d.ts +27 -0
- package/build-types/types.d.ts.map +1 -0
- package/build-types/validateHookName.d.ts +5 -5
- package/build-types/validateHookName.d.ts.map +1 -1
- package/build-types/validateNamespace.d.ts +4 -4
- package/build-types/validateNamespace.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/{createAddHook.js → createAddHook.ts} +29 -16
- package/src/{createCurrentHook.js → createCurrentHook.ts} +12 -4
- package/src/{createDidHook.js → createDidHook.ts} +12 -9
- package/src/{createDoingHook.js → createDoingHook.ts} +15 -9
- package/src/{createHasHook.js → createHasHook.ts} +19 -11
- package/src/{createHooks.js → createHooks.ts} +26 -5
- package/src/{createRemoveHook.js → createRemoveHook.ts} +24 -16
- package/src/{createRunHook.js → createRunHook.ts} +21 -6
- package/src/{index.js → index.ts} +1 -32
- package/src/types.ts +31 -0
- package/src/{validateHookName.js → validateHookName.ts} +5 -5
- package/src/{validateNamespace.js → validateNamespace.ts} +4 -4
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,25 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Callback, Hooks, StoreKey } from '.';
|
|
2
2
|
/**
|
|
3
|
+
*
|
|
3
4
|
* Adds the hook to the appropriate hooks container.
|
|
4
5
|
*/
|
|
5
|
-
export type AddHook = (
|
|
6
|
+
export type AddHook = (
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
* Name of hook to add
|
|
9
|
+
*/
|
|
10
|
+
hookName: string,
|
|
11
|
+
/**
|
|
12
|
+
* The unique namespace identifying the callback in the form.
|
|
13
|
+
*/
|
|
14
|
+
namespace: string,
|
|
15
|
+
/**
|
|
16
|
+
* Function to call when the hook is run.
|
|
15
17
|
*/
|
|
18
|
+
callback: Callback,
|
|
19
|
+
/**
|
|
20
|
+
* Priority of this hook
|
|
21
|
+
*/
|
|
22
|
+
priority?: number) => void;
|
|
16
23
|
/**
|
|
17
24
|
* Returns a function which, when invoked, will add a hook.
|
|
18
25
|
*
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
26
|
+
* @param hooks Hooks instance.
|
|
27
|
+
* @param storeKey
|
|
21
28
|
*
|
|
22
|
-
* @return
|
|
29
|
+
* @return Function that adds a new hook.
|
|
23
30
|
*/
|
|
24
|
-
declare function createAddHook(hooks:
|
|
31
|
+
declare function createAddHook(hooks: Hooks, storeKey: StoreKey): AddHook;
|
|
32
|
+
export default createAddHook;
|
|
25
33
|
//# sourceMappingURL=createAddHook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAddHook.d.ts","sourceRoot":"","sources":["../src/createAddHook.
|
|
1
|
+
{"version":3,"file":"createAddHook.d.ts","sourceRoot":"","sources":["../src/createAddHook.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AAGnD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG;AACrB;;GAEG;AACH,QAAQ,EAAE,MAAM;AAChB;;GAEG;AACH,SAAS,EAAE,MAAM;AACjB;;GAEG;AACH,QAAQ,EAAE,QAAQ;AAClB;;GAEG;AACH,QAAQ,CAAC,EAAE,MAAM,KACb,IAAI,CAAC;AAEV;;;;;;;GAOG;AACH,iBAAS,aAAa,CAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,OAAO,CA8ElE;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Hooks, StoreKey } from './types';
|
|
2
5
|
/**
|
|
3
6
|
* Returns a function which, when invoked, will return the name of the
|
|
4
7
|
* currently running hook, or `null` if no hook of the given type is currently
|
|
5
8
|
* running.
|
|
6
9
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
10
|
+
* @param hooks Hooks instance.
|
|
11
|
+
* @param storeKey
|
|
9
12
|
*
|
|
10
|
-
* @return
|
|
13
|
+
* @return Function that returns the current hook name or null.
|
|
11
14
|
*/
|
|
12
|
-
declare function createCurrentHook(hooks:
|
|
15
|
+
declare function createCurrentHook(hooks: Hooks, storeKey: StoreKey): () => string | null;
|
|
16
|
+
export default createCurrentHook;
|
|
13
17
|
//# sourceMappingURL=createCurrentHook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCurrentHook.d.ts","sourceRoot":"","sources":["../src/createCurrentHook.
|
|
1
|
+
{"version":3,"file":"createCurrentHook.d.ts","sourceRoot":"","sources":["../src/createCurrentHook.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;;;GASG;AACH,iBAAS,iBAAiB,CACzB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,GAChB,MAAM,MAAM,GAAG,IAAI,CAMrB;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Returns the number of times an action has been fired.
|
|
4
|
-
*/
|
|
5
|
-
export type DidHook = (hookName: string) => number | undefined;
|
|
1
|
+
import type { Hooks, StoreKey } from './types';
|
|
6
2
|
/**
|
|
7
|
-
* @callback DidHook
|
|
8
3
|
*
|
|
9
4
|
* Returns the number of times an action has been fired.
|
|
10
5
|
*
|
|
11
|
-
* @param {string} hookName The hook name to check.
|
|
12
|
-
*
|
|
13
|
-
* @return {number | undefined} The number of times the hook has run.
|
|
14
6
|
*/
|
|
7
|
+
export type DidHook = (
|
|
8
|
+
/**
|
|
9
|
+
* The hook name to check.
|
|
10
|
+
*/
|
|
11
|
+
hookName: string) => number | undefined;
|
|
15
12
|
/**
|
|
16
13
|
* Returns a function which, when invoked, will return the number of times a
|
|
17
14
|
* hook has been called.
|
|
18
15
|
*
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
16
|
+
* @param hooks Hooks instance.
|
|
17
|
+
* @param storeKey
|
|
21
18
|
*
|
|
22
|
-
* @return
|
|
19
|
+
* @return Function that returns a hook's call count.
|
|
23
20
|
*/
|
|
24
|
-
declare function createDidHook(hooks:
|
|
21
|
+
declare function createDidHook(hooks: Hooks, storeKey: StoreKey): DidHook;
|
|
22
|
+
export default createDidHook;
|
|
25
23
|
//# sourceMappingURL=createDidHook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDidHook.d.ts","sourceRoot":"","sources":["../src/createDidHook.
|
|
1
|
+
{"version":3,"file":"createDidHook.d.ts","sourceRoot":"","sources":["../src/createDidHook.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG;AACrB;;GAEG;AACH,QAAQ,EAAE,MAAM,KACZ,MAAM,GAAG,SAAS,CAAC;AAExB;;;;;;;;GAQG;AACH,iBAAS,aAAa,CAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,OAAO,CAYlE;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
export default createDoingHook;
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Internal dependencies
|
|
4
3
|
*/
|
|
5
|
-
|
|
4
|
+
import type { Hooks, StoreKey } from './types';
|
|
6
5
|
/**
|
|
7
|
-
* @callback DoingHook
|
|
8
6
|
* Returns whether a hook is currently being executed.
|
|
9
7
|
*
|
|
10
|
-
* @param {string} [hookName] The name of the hook to check for. If
|
|
11
|
-
* omitted, will check for any hook being executed.
|
|
12
|
-
*
|
|
13
|
-
* @return {boolean} Whether the hook is being executed.
|
|
14
8
|
*/
|
|
9
|
+
export type DoingHook = (
|
|
10
|
+
/**
|
|
11
|
+
* The name of the hook to check for.
|
|
12
|
+
* If omitted, will check for any hook being executed.
|
|
13
|
+
*/ hookName?: string) => boolean;
|
|
15
14
|
/**
|
|
16
15
|
* Returns a function which, when invoked, will return whether a hook is
|
|
17
16
|
* currently being executed.
|
|
18
17
|
*
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
18
|
+
* @param hooks Hooks instance.
|
|
19
|
+
* @param storeKey
|
|
21
20
|
*
|
|
22
|
-
* @return
|
|
21
|
+
* @return Function that returns whether a hook is currently
|
|
23
22
|
* being executed.
|
|
24
23
|
*/
|
|
25
|
-
declare function createDoingHook(hooks:
|
|
24
|
+
declare function createDoingHook(hooks: Hooks, storeKey: StoreKey): DoingHook;
|
|
25
|
+
export default createDoingHook;
|
|
26
26
|
//# sourceMappingURL=createDoingHook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDoingHook.d.ts","sourceRoot":"","sources":["../src/createDoingHook.
|
|
1
|
+
{"version":3,"file":"createDoingHook.d.ts","sourceRoot":"","sources":["../src/createDoingHook.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;AACvB;;;GAGG,CAAC,QAAQ,CAAC,EAAE,MAAM,KACjB,OAAO,CAAC;AAEb;;;;;;;;;GASG;AACH,iBAAS,eAAe,CAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,SAAS,CActE;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
export default createHasHook;
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* Internal dependencies
|
|
4
3
|
*/
|
|
5
|
-
|
|
4
|
+
import type { Hooks, StoreKey } from './types';
|
|
6
5
|
/**
|
|
7
|
-
* @callback HasHook
|
|
8
6
|
*
|
|
9
7
|
* Returns whether any handlers are attached for the given hookName and optional namespace.
|
|
10
|
-
*
|
|
11
|
-
* @param {string} hookName The name of the hook to check for.
|
|
12
|
-
* @param {string} [namespace] Optional. The unique namespace identifying the callback
|
|
13
|
-
* in the form `vendor/plugin/function`.
|
|
14
|
-
*
|
|
15
|
-
* @return {boolean} Whether there are handlers that are attached to the given hook.
|
|
16
8
|
*/
|
|
9
|
+
export type HasHook = (
|
|
10
|
+
/**
|
|
11
|
+
* The name of the hook to check for.
|
|
12
|
+
*/
|
|
13
|
+
hookname: string,
|
|
14
|
+
/**
|
|
15
|
+
* The unique namespace identifying the callback in the form `vendor/plugin/function`.
|
|
16
|
+
*/
|
|
17
|
+
namespace?: string) => boolean;
|
|
17
18
|
/**
|
|
18
19
|
* Returns a function which, when invoked, will return whether any handlers are
|
|
19
20
|
* attached to a particular hook.
|
|
20
21
|
*
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
22
|
+
* @param hooks Hooks instance.
|
|
23
|
+
* @param storeKey
|
|
23
24
|
*
|
|
24
|
-
* @return
|
|
25
|
+
* @return Function that returns whether any handlers are
|
|
25
26
|
* attached to a particular hook and optional namespace.
|
|
26
27
|
*/
|
|
27
|
-
declare function createHasHook(hooks:
|
|
28
|
+
declare function createHasHook(hooks: Hooks, storeKey: StoreKey): HasHook;
|
|
29
|
+
export default createHasHook;
|
|
28
30
|
//# sourceMappingURL=createHasHook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHasHook.d.ts","sourceRoot":"","sources":["../src/createHasHook.
|
|
1
|
+
{"version":3,"file":"createHasHook.d.ts","sourceRoot":"","sources":["../src/createHasHook.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG;AACrB;;GAEG;AACH,QAAQ,EAAE,MAAM;AAChB;;GAEG;AACH,SAAS,CAAC,EAAE,MAAM,KACd,OAAO,CAAC;AAEb;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,OAAO,CAgBlE;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import createAddHook from './createAddHook';
|
|
5
|
+
import createRemoveHook from './createRemoveHook';
|
|
6
|
+
import createHasHook from './createHasHook';
|
|
7
|
+
import createRunHook from './createRunHook';
|
|
8
|
+
import createCurrentHook from './createCurrentHook';
|
|
9
|
+
import createDoingHook from './createDoingHook';
|
|
10
|
+
import createDidHook from './createDidHook';
|
|
11
|
+
import type { Store } from './types';
|
|
1
12
|
/**
|
|
2
13
|
* Internal class for constructing hooks. Use `createHooks()` function
|
|
3
14
|
*
|
|
@@ -5,37 +16,35 @@
|
|
|
5
16
|
*
|
|
6
17
|
* @private
|
|
7
18
|
*/
|
|
8
|
-
export class _Hooks {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
didFilter: import("./createDidHook").DidHook;
|
|
19
|
+
export declare class _Hooks {
|
|
20
|
+
actions: Store;
|
|
21
|
+
filters: Store;
|
|
22
|
+
addAction: ReturnType<typeof createAddHook>;
|
|
23
|
+
addFilter: ReturnType<typeof createAddHook>;
|
|
24
|
+
removeAction: ReturnType<typeof createRemoveHook>;
|
|
25
|
+
removeFilter: ReturnType<typeof createRemoveHook>;
|
|
26
|
+
hasAction: ReturnType<typeof createHasHook>;
|
|
27
|
+
hasFilter: ReturnType<typeof createHasHook>;
|
|
28
|
+
removeAllActions: ReturnType<typeof createRemoveHook>;
|
|
29
|
+
removeAllFilters: ReturnType<typeof createRemoveHook>;
|
|
30
|
+
doAction: ReturnType<typeof createRunHook>;
|
|
31
|
+
doActionAsync: ReturnType<typeof createRunHook>;
|
|
32
|
+
applyFilters: ReturnType<typeof createRunHook>;
|
|
33
|
+
applyFiltersAsync: ReturnType<typeof createRunHook>;
|
|
34
|
+
currentAction: ReturnType<typeof createCurrentHook>;
|
|
35
|
+
currentFilter: ReturnType<typeof createCurrentHook>;
|
|
36
|
+
doingAction: ReturnType<typeof createDoingHook>;
|
|
37
|
+
doingFilter: ReturnType<typeof createDoingHook>;
|
|
38
|
+
didAction: ReturnType<typeof createDidHook>;
|
|
39
|
+
didFilter: ReturnType<typeof createDidHook>;
|
|
40
|
+
constructor();
|
|
31
41
|
}
|
|
32
|
-
export default createHooks;
|
|
33
42
|
export type Hooks = _Hooks;
|
|
34
|
-
/** @typedef {_Hooks} Hooks */
|
|
35
43
|
/**
|
|
36
44
|
* Returns an instance of the hooks object.
|
|
37
45
|
*
|
|
38
|
-
* @return
|
|
46
|
+
* @return A Hooks instance.
|
|
39
47
|
*/
|
|
40
48
|
declare function createHooks(): Hooks;
|
|
49
|
+
export default createHooks;
|
|
41
50
|
//# sourceMappingURL=createHooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHooks.d.ts","sourceRoot":"","sources":["../src/createHooks.
|
|
1
|
+
{"version":3,"file":"createHooks.d.ts","sourceRoot":"","sources":["../src/createHooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;;GAMG;AACH,qBAAa,MAAM;IACX,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE,KAAK,CAAC;IAEf,SAAS,EAAE,UAAU,CAAE,OAAO,aAAa,CAAE,CAAC;IAC9C,SAAS,EAAE,UAAU,CAAE,OAAO,aAAa,CAAE,CAAC;IAC9C,YAAY,EAAE,UAAU,CAAE,OAAO,gBAAgB,CAAE,CAAC;IACpD,YAAY,EAAE,UAAU,CAAE,OAAO,gBAAgB,CAAE,CAAC;IACpD,SAAS,EAAE,UAAU,CAAE,OAAO,aAAa,CAAE,CAAC;IAC9C,SAAS,EAAE,UAAU,CAAE,OAAO,aAAa,CAAE,CAAC;IAC9C,gBAAgB,EAAE,UAAU,CAAE,OAAO,gBAAgB,CAAE,CAAC;IACxD,gBAAgB,EAAE,UAAU,CAAE,OAAO,gBAAgB,CAAE,CAAC;IACxD,QAAQ,EAAE,UAAU,CAAE,OAAO,aAAa,CAAE,CAAC;IAC7C,aAAa,EAAE,UAAU,CAAE,OAAO,aAAa,CAAE,CAAC;IAClD,YAAY,EAAE,UAAU,CAAE,OAAO,aAAa,CAAE,CAAC;IACjD,iBAAiB,EAAE,UAAU,CAAE,OAAO,aAAa,CAAE,CAAC;IACtD,aAAa,EAAE,UAAU,CAAE,OAAO,iBAAiB,CAAE,CAAC;IACtD,aAAa,EAAE,UAAU,CAAE,OAAO,iBAAiB,CAAE,CAAC;IACtD,WAAW,EAAE,UAAU,CAAE,OAAO,eAAe,CAAE,CAAC;IAClD,WAAW,EAAE,UAAU,CAAE,OAAO,eAAe,CAAE,CAAC;IAClD,SAAS,EAAE,UAAU,CAAE,OAAO,aAAa,CAAE,CAAC;IAC9C,SAAS,EAAE,UAAU,CAAE,OAAO,aAAa,CAAE,CAAC;;CA4BrD;AAED,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAE3B;;;;GAIG;AACH,iBAAS,WAAW,IAAI,KAAK,CAE5B;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Hooks, StoreKey } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Removes the specified callback (or all callbacks) from the hook with a given hookName
|
|
4
4
|
* and namespace.
|
|
5
5
|
*/
|
|
6
|
-
export type RemoveHook = (
|
|
6
|
+
export type RemoveHook = (
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
* @param {string} namespace The unique namespace identifying the callback in the
|
|
14
|
-
* form `vendor/plugin/function`.
|
|
15
|
-
*
|
|
16
|
-
* @return {number | undefined} The number of callbacks removed.
|
|
8
|
+
* The name of the hook to modify.
|
|
9
|
+
*/
|
|
10
|
+
hookName: string,
|
|
11
|
+
/**
|
|
12
|
+
* The unique namespace identifying the callback in the form `vendor/plugin/function`.
|
|
17
13
|
*/
|
|
14
|
+
namespace: string) => number | undefined;
|
|
18
15
|
/**
|
|
19
16
|
* Returns a function which, when invoked, will remove a specified hook or all
|
|
20
17
|
* hooks by the given name.
|
|
21
18
|
*
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
*
|
|
26
|
-
*
|
|
19
|
+
* @param hooks Hooks instance.
|
|
20
|
+
* @param storeKey
|
|
21
|
+
* @param [removeAll=false] Whether to remove all callbacks for a hookName,
|
|
22
|
+
* without regard to namespace. Used to create
|
|
23
|
+
* `removeAll*` functions.
|
|
27
24
|
*
|
|
28
|
-
* @return
|
|
25
|
+
* @return Function that removes hooks.
|
|
29
26
|
*/
|
|
30
|
-
declare function createRemoveHook(hooks:
|
|
27
|
+
declare function createRemoveHook(hooks: Hooks, storeKey: StoreKey, removeAll?: boolean): RemoveHook;
|
|
28
|
+
export default createRemoveHook;
|
|
31
29
|
//# sourceMappingURL=createRemoveHook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRemoveHook.d.ts","sourceRoot":"","sources":["../src/createRemoveHook.
|
|
1
|
+
{"version":3,"file":"createRemoveHook.d.ts","sourceRoot":"","sources":["../src/createRemoveHook.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;AACxB;;GAEG;AACH,QAAQ,EAAE,MAAM;AAChB;;GAEG;AACH,SAAS,EAAE,MAAM,KACb,MAAM,GAAG,SAAS,CAAC;AAExB;;;;;;;;;;;GAWG;AACH,iBAAS,gBAAgB,CACxB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,SAAS,GAAE,OAAe,GACxB,UAAU,CAuDZ;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Hooks, StoreKey } from './types';
|
|
5
|
+
export type RunHook = (hookName: string, ...args: unknown[]) => undefined | unknown;
|
|
2
6
|
/**
|
|
3
7
|
* Returns a function which, when invoked, will execute all callbacks
|
|
4
8
|
* registered to a hook of the specified type, optionally returning the final
|
|
5
9
|
* value of the call chain.
|
|
6
10
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
+
* @param hooks Hooks instance.
|
|
12
|
+
* @param storeKey
|
|
13
|
+
* @param returnFirstArg Whether each hook callback is expected to return its first argument.
|
|
14
|
+
* @param async Whether the hook callback should be run asynchronously
|
|
11
15
|
*
|
|
12
|
-
* @return
|
|
16
|
+
* @return Function that runs hook callbacks.
|
|
13
17
|
*/
|
|
14
|
-
declare function createRunHook(hooks:
|
|
18
|
+
declare function createRunHook(hooks: Hooks, storeKey: StoreKey, returnFirstArg: boolean, async: boolean): RunHook;
|
|
19
|
+
export default createRunHook;
|
|
15
20
|
//# sourceMappingURL=createRunHook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRunHook.d.ts","sourceRoot":"","sources":["../src/createRunHook.
|
|
1
|
+
{"version":3,"file":"createRunHook.d.ts","sourceRoot":"","sources":["../src/createRunHook.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,OAAO,GAAG,CACrB,QAAQ,EAAE,MAAM,EAChB,GAAG,IAAI,EAAE,OAAO,EAAE,KACd,SAAS,GAAG,OAAO,CAAC;AAEzB;;;;;;;;;;;GAWG;AACH,iBAAS,aAAa,CACrB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,OAAO,EACvB,KAAK,EAAE,OAAO,GACZ,OAAO,CAsET;AAED,eAAe,aAAa,CAAC"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1,90 +1,9 @@
|
|
|
1
|
-
/** @typedef {(...args: any[])=>any} Callback */
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @property {Callback} callback The callback
|
|
5
|
-
* @property {string} namespace The namespace
|
|
6
|
-
* @property {number} priority The namespace
|
|
2
|
+
* Internal dependencies
|
|
7
3
|
*/
|
|
8
|
-
/**
|
|
9
|
-
* @typedef Hook
|
|
10
|
-
* @property {Handler[]} handlers Array of handlers
|
|
11
|
-
* @property {number} runs Run counter
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* @typedef Current
|
|
15
|
-
* @property {string} name Hook name
|
|
16
|
-
* @property {number} currentIndex The index
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {Record<string, Hook> & {__current: Set<Current>}} Store
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {'actions' | 'filters'} StoreKey
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* @typedef {import('./createHooks').Hooks} Hooks
|
|
26
|
-
*/
|
|
27
|
-
export const defaultHooks: import("./createHooks")._Hooks;
|
|
28
|
-
export type Callback = (...args: any[]) => any;
|
|
29
|
-
export type Handler = {
|
|
30
|
-
/**
|
|
31
|
-
* The callback
|
|
32
|
-
*/
|
|
33
|
-
callback: Callback;
|
|
34
|
-
/**
|
|
35
|
-
* The namespace
|
|
36
|
-
*/
|
|
37
|
-
namespace: string;
|
|
38
|
-
/**
|
|
39
|
-
* The namespace
|
|
40
|
-
*/
|
|
41
|
-
priority: number;
|
|
42
|
-
};
|
|
43
|
-
export type Hook = {
|
|
44
|
-
/**
|
|
45
|
-
* Array of handlers
|
|
46
|
-
*/
|
|
47
|
-
handlers: Handler[];
|
|
48
|
-
/**
|
|
49
|
-
* Run counter
|
|
50
|
-
*/
|
|
51
|
-
runs: number;
|
|
52
|
-
};
|
|
53
|
-
export type Current = {
|
|
54
|
-
/**
|
|
55
|
-
* Hook name
|
|
56
|
-
*/
|
|
57
|
-
name: string;
|
|
58
|
-
/**
|
|
59
|
-
* The index
|
|
60
|
-
*/
|
|
61
|
-
currentIndex: number;
|
|
62
|
-
};
|
|
63
|
-
export type Store = Record<string, Hook> & {
|
|
64
|
-
__current: Set<Current>;
|
|
65
|
-
};
|
|
66
|
-
export type StoreKey = "actions" | "filters";
|
|
67
|
-
export type Hooks = import("./createHooks").Hooks;
|
|
68
4
|
import createHooks from './createHooks';
|
|
69
|
-
export
|
|
70
|
-
export const
|
|
71
|
-
|
|
72
|
-
export
|
|
73
|
-
export const hasAction: import("./createHasHook").HasHook;
|
|
74
|
-
export const hasFilter: import("./createHasHook").HasHook;
|
|
75
|
-
export const removeAllActions: import("./createRemoveHook").RemoveHook;
|
|
76
|
-
export const removeAllFilters: import("./createRemoveHook").RemoveHook;
|
|
77
|
-
export const doAction: (hookName: string, ...args: unknown[]) => undefined | unknown;
|
|
78
|
-
export const doActionAsync: (hookName: string, ...args: unknown[]) => undefined | unknown;
|
|
79
|
-
export const applyFilters: (hookName: string, ...args: unknown[]) => undefined | unknown;
|
|
80
|
-
export const applyFiltersAsync: (hookName: string, ...args: unknown[]) => undefined | unknown;
|
|
81
|
-
export const currentAction: () => string | null;
|
|
82
|
-
export const currentFilter: () => string | null;
|
|
83
|
-
export const doingAction: import("./createDoingHook").DoingHook;
|
|
84
|
-
export const doingFilter: import("./createDoingHook").DoingHook;
|
|
85
|
-
export const didAction: import("./createDidHook").DidHook;
|
|
86
|
-
export const didFilter: import("./createDidHook").DidHook;
|
|
87
|
-
export const actions: Store;
|
|
88
|
-
export const filters: Store;
|
|
89
|
-
export { createHooks };
|
|
5
|
+
export * from './types';
|
|
6
|
+
export declare const defaultHooks: import("./createHooks")._Hooks;
|
|
7
|
+
declare const addAction: import("./createAddHook").AddHook, addFilter: import("./createAddHook").AddHook, removeAction: import("./createRemoveHook").RemoveHook, removeFilter: import("./createRemoveHook").RemoveHook, hasAction: import("./createHasHook").HasHook, hasFilter: import("./createHasHook").HasHook, removeAllActions: import("./createRemoveHook").RemoveHook, removeAllFilters: import("./createRemoveHook").RemoveHook, doAction: import("./createRunHook").RunHook, doActionAsync: import("./createRunHook").RunHook, applyFilters: import("./createRunHook").RunHook, applyFiltersAsync: import("./createRunHook").RunHook, currentAction: () => string | null, currentFilter: () => string | null, doingAction: import("./createDoingHook").DoingHook, doingFilter: import("./createDoingHook").DoingHook, didAction: import("./createDidHook").DidHook, didFilter: import("./createDidHook").DidHook, actions: import("./types").Store, filters: import("./types").Store;
|
|
8
|
+
export { createHooks, addAction, addFilter, removeAction, removeFilter, hasAction, hasFilter, removeAllActions, removeAllFilters, doAction, doActionAsync, applyFilters, applyFiltersAsync, currentAction, currentFilter, doingAction, doingFilter, didAction, didFilter, actions, filters, };
|
|
90
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,YAAY,gCAAgB,CAAC;AAE1C,QAAA,MACC,SAAS,qCACT,SAAS,qCACT,YAAY,2CACZ,YAAY,2CACZ,SAAS,qCACT,SAAS,qCACT,gBAAgB,2CAChB,gBAAgB,2CAChB,QAAQ,qCACR,aAAa,qCACb,YAAY,qCACZ,iBAAiB,qCACjB,aAAa,uBACb,aAAa,uBACb,WAAW,yCACX,WAAW,yCACX,SAAS,qCACT,SAAS,qCACT,OAAO,2BACP,OAAO,yBACQ,CAAC;AAEjB,OAAO,EACN,WAAW,EACX,SAAS,EACT,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,SAAS,EACT,OAAO,EACP,OAAO,GACP,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
export type { Hooks } from './createHooks';
|
|
5
|
+
export type Callback = (...args: any[]) => any;
|
|
6
|
+
export type Handler = {
|
|
7
|
+
callback: Callback;
|
|
8
|
+
namespace: string;
|
|
9
|
+
priority: number;
|
|
10
|
+
};
|
|
11
|
+
export type Hook = {
|
|
12
|
+
handlers: Handler[];
|
|
13
|
+
runs: number;
|
|
14
|
+
};
|
|
15
|
+
export type Current = {
|
|
16
|
+
name: string;
|
|
17
|
+
currentIndex: number;
|
|
18
|
+
};
|
|
19
|
+
export type HookInfo = {
|
|
20
|
+
name: string;
|
|
21
|
+
currentIndex: number;
|
|
22
|
+
};
|
|
23
|
+
export type Store = Record<string, Hook> & {
|
|
24
|
+
__current: Set<Current>;
|
|
25
|
+
};
|
|
26
|
+
export type StoreKey = 'actions' | 'filters';
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,YAAY,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,MAAM,QAAQ,GAAG,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAM,GAAG,CAAC;AAEjD,MAAM,MAAM,OAAO,GAAG;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IAClB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,MAAM,CAAE,MAAM,EAAE,IAAI,CAAE,GAAG;IAAE,SAAS,EAAE,GAAG,CAAE,OAAO,CAAE,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export default validateHookName;
|
|
2
1
|
/**
|
|
3
2
|
* Validate a hookName string.
|
|
4
3
|
*
|
|
5
|
-
* @param
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* @param hookName The hook name to validate. Should be a non empty string containing
|
|
5
|
+
* only numbers, letters, dashes, periods and underscores. Also,
|
|
6
|
+
* the hook name cannot begin with `__`.
|
|
8
7
|
*
|
|
9
|
-
* @return
|
|
8
|
+
* @return Whether the hook name is valid.
|
|
10
9
|
*/
|
|
11
10
|
declare function validateHookName(hookName: string): boolean;
|
|
11
|
+
export default validateHookName;
|
|
12
12
|
//# sourceMappingURL=validateHookName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateHookName.d.ts","sourceRoot":"","sources":["../src/validateHookName.
|
|
1
|
+
{"version":3,"file":"validateHookName.d.ts","sourceRoot":"","sources":["../src/validateHookName.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,iBAAS,gBAAgB,CAAE,QAAQ,EAAE,MAAM,GAAI,OAAO,CAsBrD;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export default validateNamespace;
|
|
2
1
|
/**
|
|
3
2
|
* Validate a namespace string.
|
|
4
3
|
*
|
|
5
|
-
* @param
|
|
6
|
-
*
|
|
4
|
+
* @param namespace The namespace to validate - should take the form
|
|
5
|
+
* `vendor/plugin/function`.
|
|
7
6
|
*
|
|
8
|
-
* @return
|
|
7
|
+
* @return Whether the namespace is valid.
|
|
9
8
|
*/
|
|
10
9
|
declare function validateNamespace(namespace: string): boolean;
|
|
10
|
+
export default validateNamespace;
|
|
11
11
|
//# sourceMappingURL=validateNamespace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateNamespace.d.ts","sourceRoot":"","sources":["../src/validateNamespace.
|
|
1
|
+
{"version":3,"file":"validateNamespace.d.ts","sourceRoot":"","sources":["../src/validateNamespace.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,iBAAS,iBAAiB,CAAE,SAAS,EAAE,MAAM,GAAI,OAAO,CAgBvD;AAED,eAAe,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/hooks",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.27.1-next.46f643fa0.0",
|
|
4
4
|
"description": "WordPress hooks library.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "17e600e091675c5e3d809adfea23ac456bbeae19"
|
|
37
37
|
}
|