-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHookCallbackInterface.ts
84 lines (73 loc) · 2.11 KB
/
HookCallbackInterface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { DefaultSettings } from "./SettingsInterfaces"
import { HTMLElement } from "node-html-parser"
import { FileUtil } from "../utils/file"
import { SpearLog } from "../utils/log"
export type SpearSettings = DefaultSettings
export type Element = HTMLElement & { props: { [key: string]: string } }
export interface Component {
fname: string
tagName: string
rawData?: string
node: Element
props: { [key: string]: string }
}
export interface AssetFile {
filePath: string
rawData?: Buffer
}
export interface SpearState {
pagesList: Component[]
componentsList: Component[]
body: Element
globalProps: { [key: string]: string }
out: {
assetsFiles: AssetFile[]
}
}
export interface SpearOption {
fileUtil: FileUtil,
logger: SpearLog
}
/**
* Call after configuration has finished.
* If you change the original settings value, you need to return
* SpearSetting object in this function.
*/
export interface ConfigurationHookFunction {
(setting: SpearSettings, option: SpearOption): Promise<SpearSettings | null>
}
/**
* Call before starting build process.
* If you change the original state value, you need to return
* SpearState object in this function.
*/
export interface BeforeBuildHookFunction {
(state: SpearState, option: SpearOption): Promise<SpearState | null>
}
/**
* Call after finishing build process.
* If you change the original state value, you need to return
* SpearState object in this function.
*/
export interface AfterBuildHookFunction {
(state: SpearState, option: SpearOption): Promise<SpearState | null>
}
/**
* Call before starting bundle process.
* If you change the original state value, you need to return
* SpearState object in this function.
*/
export interface BundleHookFunction {
(state: SpearState, option: SpearOption): Promise<SpearState | null>
}
/**
* Hook API structure.
* You can specify this object into spear.config.mjs.
*/
export interface HookApi {
pluginName: string,
configuration?: ConfigurationHookFunction,
beforeBuild?: BeforeBuildHookFunction,
afterBuild? : AfterBuildHookFunction,
bundle? : BundleHookFunction,
}