forked from vuejs/vue-component-compiler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
171 lines (149 loc) · 4.2 KB
/
index.d.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
declare module VueComponentCompiler {
/**
* Parse SFC file into block descriptors.
*
* @param content Contents of the SFC.
* @param file Filepath (used for cache key & in generated source maps)
*/
export function parse(content: string, file: string, config: ParserConfig): SFCDescriptor
/**
* Compile styles for SFC
*
* @param styles List of styles to process.
* @param file SFC file path
*/
export function compileStyles(styles: Array<StyleCompilerSource>, file: string, config: StyleCompilerConfig): Promise<Array<StyleCompilerOutput>>
/**
* Compile template to render functions
*
* @param template Template to compile
* @param file SFC file path
*/
export function compileTemplate(template: TemplateCompilerSource, file: string, config: TemplateCompilerConfig): Promise<TemplateCompilerOutput>
/**
* Assemble processed parts of SFC.
*
* @param source Processed sources with resolvable identifiers (`id`)
* @param file SFC file path
*/
export function assemble(source: AssemblerSource, file: string, config: AssemblerConfig): string
/**
* Generate scope id for SFC, used in scoped styles.
*
* @param file SFC file path
* @param context file is required in context
* @param key
*/
export function generateScopeId(file: string, context: string, key?: string): string
type ParserConfig = {
needMap: boolean
}
type SFCDescriptor = {
script: ScriptDescriptor
styles: Array<StyleDescriptor>
template: TemplateDescriptor
customBlocks: Array<BlockDescriptor>
}
type BlockDescriptor = {
type: string // tag
content: string
start: number
end: number
attrs: Array<{ name: string, value: string | boolean}>
}
type StyleDescriptor = BlockDescriptor & {
scoped?: boolean
module?: string | boolean
lang?: string
src?: string
}
type ScriptDescriptor = BlockDescriptor & {
lang?: string
src?: string
}
type TemplateDescriptor = BlockDescriptor & {
lang?: string
src?: string
}
type CompilerSource = {
code: string
map?: object // prev source map
}
type StyleCompilerSource = CompilerSource & {
descriptor: StyleDescriptor
}
type StyleCompilerConfig = {
scopeId: string // used for scoped styles.
needMap?: boolean
plugins?: Array<object> // postcss plugins
options?: object // postcss options
onWarn?: MessageHandler
}
type MessageHandler = (message: Message) => void
type Message = {
type: string
text?: string
}
type CompilerOutput = {
code: string,
map?: object
}
type StyleCompilerOutput = CompilerOutput & {}
type TemplateCompilerSource = CompilerSource & {
descriptor: TemplateDescriptor
}
type TemplateCompilerConfig = {
scopeId: string
isHot?: boolean // false
isServer?: boolean // false
isProduction?: boolean // true
esModule?: boolean // true
optimizeSSR?: boolean // true
buble: object // see https://github.com/vuejs/vue-template-es2015-compiler/blob/master/index.js#L6
options?: {
preserveWhitspace?: boolean // true
}
transformToRequire?: object
plugins?: Array<Function>
}
type TemplateCompilerOutput = CompilerOutput & {
errors: Array<object>
tips: Array<object>
}
type AssemblerSource = {
script: {
id: string,
descriptor: ScriptDescriptor
}
styles: Array<{
id: string
hotPath: string
descriptor: StyleDescriptor
}>
render: {
id: string
descriptor: TemplateDescriptor
}
customBlocks: Array<{
id: string
descriptor: BlockDescriptor
}>
}
type AssemblerConfig = {
hashKey?: string
esModule?: boolean // true
shortFilePath?: string // = filename
require?: {
vueHotReloadAPI?: string // vue-hot-reload-api
normalizeComponent?: string // vue-component-compiler/src/normalize-component.js
}
scopeId: string // same as scopeId of style compiler.
moduleIdentifier?: string // autogenerated
isHot?: boolean // false
isServer?: boolean // false
isProduction?: boolean // true
isInjectable?: boolean // false
hasStyleInjectFn?: boolean // false
onWarn?: MessageHandler // console.warn
}
}