@gesslar/bedoc 1.4.4 → 1.4.7
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.
|
@@ -21,13 +21,16 @@ export type MetaType = ParseMetaDefinition | PrintMetaDefinition
|
|
|
21
21
|
|
|
22
22
|
export interface ActionDefinition {
|
|
23
23
|
meta: MetaType
|
|
24
|
+
setup?: (params: { parent: ActionManager; log: Logger }) => void
|
|
25
|
+
run({ module, content }: { module: string; content: object }): Promise<string>
|
|
26
|
+
hook?: (event: string, ...args: unknown[]) => Promise<unknown>
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
export interface PrintActionDefinition {
|
|
29
|
+
export interface PrintActionDefinition extends ActionDefinition {
|
|
27
30
|
meta: PrintMetaDefinition
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
export interface ParseActionDefinition {
|
|
33
|
+
export interface ParseActionDefinition extends ActionDefinition {
|
|
31
34
|
meta: ParseMetaDefinition
|
|
32
35
|
}
|
|
33
36
|
|
|
@@ -48,4 +51,6 @@ export default class ActionManager {
|
|
|
48
51
|
toString(): string
|
|
49
52
|
#private
|
|
50
53
|
}
|
|
54
|
+
|
|
55
|
+
export type ActionContract = string
|
|
51
56
|
//# sourceMappingURL=ActionManager.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Logger from './Logger';
|
|
2
2
|
import { FileMap } from './util/FDUtil';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
export type HookEventType = 'start' | 'section_load' | 'enter' | 'exit' | 'end';
|
|
5
5
|
|
|
6
6
|
interface HookResult {
|
|
7
7
|
status?: 'success' | 'error';
|
|
@@ -27,7 +27,7 @@ interface HookManagerConstructorParams {
|
|
|
27
27
|
timeOut: number;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export const hookPoints: Readonly<Record<Uppercase<
|
|
30
|
+
export const hookPoints: Readonly<Record<Uppercase<HookEventType>, HookEventType>>;
|
|
31
31
|
|
|
32
32
|
export default class HookManager {
|
|
33
33
|
static new(arg: HookManagerConstructorParams): Promise<HookManager | null>;
|
|
@@ -35,7 +35,7 @@ export default class HookManager {
|
|
|
35
35
|
constructor({ action, hooksFile, logger, timeOut: timeout }: HookManagerConstructorParams);
|
|
36
36
|
|
|
37
37
|
get action(): string;
|
|
38
|
-
get hooksFile(): FileMap;
|
|
38
|
+
get hooksFile(): FileMap | null;
|
|
39
39
|
get hooks(): HooksDefinition | null;
|
|
40
40
|
get log(): Logger;
|
|
41
41
|
get timeout(): number;
|
|
@@ -49,8 +49,9 @@ export default class HookManager {
|
|
|
49
49
|
* @param args - The hook arguments
|
|
50
50
|
* @returns The result of the hook
|
|
51
51
|
*/
|
|
52
|
-
on(event:
|
|
52
|
+
on(event: HookEventType, ...args: unknown[]): Promise<HookResult | undefined>;
|
|
53
53
|
|
|
54
|
+
HOOKS?: HookPoints
|
|
54
55
|
#hooksFile: FileMap | null;
|
|
55
56
|
#log: Logger | null;
|
|
56
57
|
#hooks: HooksDefinition | null;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {HookPoints} from "./HookManager.js"
|
|
2
2
|
|
|
3
3
|
export default class ActionManager {
|
|
4
4
|
#action = null
|
|
@@ -48,7 +48,7 @@ export default class ActionManager {
|
|
|
48
48
|
throw new Error("Hooks already set")
|
|
49
49
|
|
|
50
50
|
this.action.hook = hookManager.on.bind(this.action)
|
|
51
|
-
this.action.HOOKS =
|
|
51
|
+
this.action.HOOKS = HookPoints
|
|
52
52
|
this.#hookManager = hookManager
|
|
53
53
|
this.action.hooks = hookManager.hooks
|
|
54
54
|
}
|
package/src/core/HookManager.js
CHANGED
|
@@ -8,7 +8,7 @@ const {assert} = ValidUtil
|
|
|
8
8
|
const freeze = Object.freeze
|
|
9
9
|
|
|
10
10
|
const hookEvents = freeze(["start", "section_load", "enter", "exit", "end"])
|
|
11
|
-
export const
|
|
11
|
+
export const HookPoints = freeze(
|
|
12
12
|
await allocateObject(
|
|
13
13
|
hookEvents.map((event) => event.toUpperCase()),
|
|
14
14
|
hookEvents,
|