@vue/compiler-sfc 2.7.0-alpha.6 → 2.7.0-alpha.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.
@@ -0,0 +1,259 @@
1
+ import { LazyResult } from 'postcss';
2
+ import { ParserPlugin } from '@babel/parser';
3
+
4
+ declare interface AssetURLOptions {
5
+ [name: string]: string | string[];
6
+ }
7
+
8
+ declare type BindingMetadata = {
9
+ [key: string]: BindingTypes | undefined;
10
+ } & {
11
+ __isScriptSetup?: boolean;
12
+ };
13
+
14
+ declare const enum BindingTypes {
15
+ /**
16
+ * returned from data()
17
+ */
18
+ DATA = "data",
19
+ /**
20
+ * declared as a prop
21
+ */
22
+ PROPS = "props",
23
+ /**
24
+ * a local alias of a `<script setup>` destructured prop.
25
+ * the original is stored in __propsAliases of the bindingMetadata object.
26
+ */
27
+ PROPS_ALIASED = "props-aliased",
28
+ /**
29
+ * a let binding (may or may not be a ref)
30
+ */
31
+ SETUP_LET = "setup-let",
32
+ /**
33
+ * a const binding that can never be a ref.
34
+ * these bindings don't need `unref()` calls when processed in inlined
35
+ * template expressions.
36
+ */
37
+ SETUP_CONST = "setup-const",
38
+ /**
39
+ * a const binding that does not need `unref()`, but may be mutated.
40
+ */
41
+ SETUP_REACTIVE_CONST = "setup-reactive-const",
42
+ /**
43
+ * a const binding that may be a ref.
44
+ */
45
+ SETUP_MAYBE_REF = "setup-maybe-ref",
46
+ /**
47
+ * bindings that are guaranteed to be refs
48
+ */
49
+ SETUP_REF = "setup-ref",
50
+ /**
51
+ * declared by other options, e.g. computed, inject
52
+ */
53
+ OPTIONS = "options"
54
+ }
55
+
56
+ /**
57
+ * Compile `<script setup>`
58
+ * It requires the whole SFC descriptor because we need to handle and merge
59
+ * normal `<script>` + `<script setup>` if both are present.
60
+ */
61
+ export declare function compileScript(sfc: SFCDescriptor, options?: ScriptCompileOptions): SFCScriptBlock;
62
+
63
+ export declare function compileStyle(options: StyleCompileOptions): StyleCompileResults;
64
+
65
+ export declare function compileStyleAsync(options: StyleCompileOptions): Promise<StyleCompileResults>;
66
+
67
+ export declare function compileTemplate(options: TemplateCompileOptions): TemplateCompileResult;
68
+
69
+ export declare function generateCodeFrame(source: string, start?: number, end?: number): string;
70
+
71
+ declare interface ImportBinding {
72
+ isType: boolean;
73
+ imported: string;
74
+ source: string;
75
+ isFromSetup: boolean;
76
+ isUsedInTemplate: boolean;
77
+ }
78
+
79
+ export declare function parse(options: ParseOptions): SFCDescriptor;
80
+
81
+ declare interface ParseOptions {
82
+ source: string;
83
+ filename?: string;
84
+ compiler?: VueTemplateCompiler;
85
+ compilerParseOptions?: VueTemplateCompilerParseOptions;
86
+ sourceRoot?: string;
87
+ needMap?: boolean;
88
+ }
89
+
90
+ declare interface RawSourceMap extends StartOfSourceMap {
91
+ version: string;
92
+ sources: string[];
93
+ names: string[];
94
+ sourcesContent?: string[];
95
+ mappings: string;
96
+ }
97
+
98
+ export declare interface ScriptCompileOptions {
99
+ /**
100
+ * Production mode. Used to determine whether to generate hashed CSS variables
101
+ */
102
+ isProd?: boolean;
103
+ /**
104
+ * Enable/disable source map. Defaults to true.
105
+ */
106
+ sourceMap?: boolean;
107
+ /**
108
+ * https://babeljs.io/docs/en/babel-parser#plugins
109
+ */
110
+ babelParserPlugins?: ParserPlugin[];
111
+ }
112
+
113
+ export declare interface SFCBlock extends SFCCustomBlock {
114
+ lang?: string;
115
+ src?: string;
116
+ scoped?: boolean;
117
+ module?: string | boolean;
118
+ }
119
+
120
+ export declare interface SFCCustomBlock {
121
+ type: string;
122
+ content: string;
123
+ attrs: {
124
+ [key: string]: string | true;
125
+ };
126
+ start: number;
127
+ end: number;
128
+ map?: RawSourceMap;
129
+ }
130
+
131
+ export declare interface SFCDescriptor {
132
+ source: string;
133
+ filename: string;
134
+ template: SFCBlock | null;
135
+ script: SFCScriptBlock | null;
136
+ scriptSetup: SFCScriptBlock | null;
137
+ styles: SFCBlock[];
138
+ customBlocks: SFCCustomBlock[];
139
+ errors: WarningMessage[];
140
+ /**
141
+ * compare with an existing descriptor to determine whether HMR should perform
142
+ * a reload vs. re-render.
143
+ *
144
+ * Note: this comparison assumes the prev/next script are already identical,
145
+ * and only checks the special case where `<script setup lang="ts">` unused
146
+ * import pruning result changes due to template changes.
147
+ */
148
+ shouldForceReload: (prevImports: Record<string, ImportBinding>) => boolean;
149
+ }
150
+
151
+ declare interface SFCScriptBlock extends SFCBlock {
152
+ type: 'script';
153
+ setup?: string | boolean;
154
+ bindings?: BindingMetadata;
155
+ imports?: Record<string, ImportBinding>;
156
+ /**
157
+ * import('\@babel/types').Statement
158
+ */
159
+ scriptAst?: any[];
160
+ /**
161
+ * import('\@babel/types').Statement
162
+ */
163
+ scriptSetupAst?: any[];
164
+ }
165
+
166
+ declare interface StartOfSourceMap {
167
+ file?: string;
168
+ sourceRoot?: string;
169
+ }
170
+
171
+ export declare interface StyleCompileOptions {
172
+ source: string;
173
+ filename: string;
174
+ id: string;
175
+ map?: any;
176
+ scoped?: boolean;
177
+ trim?: boolean;
178
+ preprocessLang?: string;
179
+ preprocessOptions?: any;
180
+ postcssOptions?: any;
181
+ postcssPlugins?: any[];
182
+ }
183
+
184
+ export declare interface StyleCompileResults {
185
+ code: string;
186
+ map: any | void;
187
+ rawResult: LazyResult | void;
188
+ errors: string[];
189
+ }
190
+
191
+ export declare interface TemplateCompileOptions {
192
+ source: string;
193
+ filename: string;
194
+ compiler?: VueTemplateCompiler;
195
+ compilerOptions?: VueTemplateCompilerOptions;
196
+ transformAssetUrls?: AssetURLOptions | boolean;
197
+ transformAssetUrlsOptions?: TransformAssetUrlsOptions;
198
+ preprocessLang?: string;
199
+ preprocessOptions?: any;
200
+ transpileOptions?: any;
201
+ isProduction?: boolean;
202
+ isFunctional?: boolean;
203
+ optimizeSSR?: boolean;
204
+ prettify?: boolean;
205
+ isTS?: boolean;
206
+ }
207
+
208
+ export declare interface TemplateCompileResult {
209
+ ast: Object | undefined;
210
+ code: string;
211
+ source: string;
212
+ tips: (string | WarningMessage)[];
213
+ errors: (string | WarningMessage)[];
214
+ }
215
+
216
+ declare interface TransformAssetUrlsOptions {
217
+ /**
218
+ * If base is provided, instead of transforming relative asset urls into
219
+ * imports, they will be directly rewritten to absolute urls.
220
+ */
221
+ base?: string;
222
+ }
223
+
224
+ declare interface VueTemplateCompiler {
225
+ parseComponent(source: string, options?: any): SFCDescriptor;
226
+ compile(template: string, options: VueTemplateCompilerOptions): VueTemplateCompilerResults;
227
+ ssrCompile(template: string, options: VueTemplateCompilerOptions): VueTemplateCompilerResults;
228
+ }
229
+
230
+ declare interface VueTemplateCompilerOptions {
231
+ modules?: Object[];
232
+ outputSourceRange?: boolean;
233
+ whitespace?: 'preserve' | 'condense';
234
+ directives?: {
235
+ [key: string]: Function;
236
+ };
237
+ }
238
+
239
+ declare interface VueTemplateCompilerParseOptions {
240
+ pad?: 'line' | 'space' | boolean;
241
+ deindent?: boolean;
242
+ outputSourceRange?: boolean;
243
+ }
244
+
245
+ declare interface VueTemplateCompilerResults {
246
+ ast: Object | undefined;
247
+ render: string;
248
+ staticRenderFns: string[];
249
+ errors: (string | WarningMessage)[];
250
+ tips: (string | WarningMessage)[];
251
+ }
252
+
253
+ declare type WarningMessage = {
254
+ msg: string;
255
+ start?: number;
256
+ end?: number;
257
+ };
258
+
259
+ export { }