revojs 0.2.3 → 0.2.5
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/dist/package.js +1 -1
- package/dist/scope/index.d.ts +1 -1
- package/dist/scope/index.js +4 -1
- package/package.json +1 -1
package/dist/package.js
CHANGED
package/dist/scope/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export interface Scope {
|
|
|
21
21
|
context: Record<string, unknown>;
|
|
22
22
|
}
|
|
23
23
|
export declare function registerHook<T extends Hook>(scope: Scope, name: Descriptor<T>, invoke: T): () => void;
|
|
24
|
-
export declare function createRegisterHooks<T extends Record<string, Descriptor<Hook>>>(descriptors: T): (scope: Scope, hooks: Hooks<T
|
|
24
|
+
export declare function createRegisterHooks<T extends Record<string, Descriptor<Hook>>>(descriptors: T): (scope: Scope, hooks: Partial<Hooks<T>>) => void;
|
|
25
25
|
export declare function dispatchHook<T extends Hook>(scope: Scope, name: Descriptor<T>, ...inputs: Parameters<T>): Promise<Awaited<ReturnType<T>>[]>;
|
|
26
26
|
export declare function dispatchHookSingle<T extends Hook>(scope: Scope, name: Descriptor<T>, ...inputs: Parameters<T>): Promise<ReturnType<T> | undefined>;
|
|
27
27
|
export declare function getContext<T>(scope: Scope, input: Descriptor<T>): T;
|
package/dist/scope/index.js
CHANGED
|
@@ -14,7 +14,10 @@ function registerHook(scope, name, invoke) {
|
|
|
14
14
|
}
|
|
15
15
|
function createRegisterHooks(descriptors) {
|
|
16
16
|
return (scope, hooks) => {
|
|
17
|
-
for (const name in descriptors)
|
|
17
|
+
for (const name in descriptors) {
|
|
18
|
+
const hook = hooks[name];
|
|
19
|
+
if (hook) registerHook(scope, descriptors[name], hook);
|
|
20
|
+
}
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
async function dispatchHook(scope, name, ...inputs) {
|