@vue/compiler-sfc 2.7.0-alpha.1 → 2.7.0-alpha.10

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,432 @@
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 ASTAttr = {
9
+ name: string;
10
+ value: any;
11
+ dynamic?: boolean;
12
+ start?: number;
13
+ end?: number;
14
+ };
15
+
16
+ declare type ASTDirective = {
17
+ name: string;
18
+ rawName: string;
19
+ value: string;
20
+ arg: string | null;
21
+ isDynamicArg: boolean;
22
+ modifiers: ASTModifiers | null;
23
+ start?: number;
24
+ end?: number;
25
+ };
26
+
27
+ declare type ASTElement = {
28
+ type: 1;
29
+ tag: string;
30
+ attrsList: Array<ASTAttr>;
31
+ attrsMap: {
32
+ [key: string]: any;
33
+ };
34
+ rawAttrsMap: {
35
+ [key: string]: ASTAttr;
36
+ };
37
+ parent: ASTElement | void;
38
+ children: Array<ASTNode>;
39
+ start?: number;
40
+ end?: number;
41
+ processed?: true;
42
+ static?: boolean;
43
+ staticRoot?: boolean;
44
+ staticInFor?: boolean;
45
+ staticProcessed?: boolean;
46
+ hasBindings?: boolean;
47
+ text?: string;
48
+ attrs?: Array<ASTAttr>;
49
+ dynamicAttrs?: Array<ASTAttr>;
50
+ props?: Array<ASTAttr>;
51
+ plain?: boolean;
52
+ pre?: true;
53
+ ns?: string;
54
+ component?: string;
55
+ inlineTemplate?: true;
56
+ transitionMode?: string | null;
57
+ slotName?: string | null;
58
+ slotTarget?: string | null;
59
+ slotTargetDynamic?: boolean;
60
+ slotScope?: string | null;
61
+ scopedSlots?: {
62
+ [name: string]: ASTElement;
63
+ };
64
+ ref?: string;
65
+ refInFor?: boolean;
66
+ if?: string;
67
+ ifProcessed?: boolean;
68
+ elseif?: string;
69
+ else?: true;
70
+ ifConditions?: ASTIfConditions;
71
+ for?: string;
72
+ forProcessed?: boolean;
73
+ key?: string;
74
+ alias?: string;
75
+ iterator1?: string;
76
+ iterator2?: string;
77
+ staticClass?: string;
78
+ classBinding?: string;
79
+ staticStyle?: string;
80
+ styleBinding?: string;
81
+ events?: ASTElementHandlers;
82
+ nativeEvents?: ASTElementHandlers;
83
+ transition?: string | true;
84
+ transitionOnAppear?: boolean;
85
+ model?: {
86
+ value: string;
87
+ callback: string;
88
+ expression: string;
89
+ };
90
+ directives?: Array<ASTDirective>;
91
+ forbidden?: true;
92
+ once?: true;
93
+ onceProcessed?: boolean;
94
+ wrapData?: (code: string) => string;
95
+ wrapListeners?: (code: string) => string;
96
+ ssrOptimizability?: number;
97
+ };
98
+
99
+ declare type ASTElementHandler = {
100
+ value: string;
101
+ params?: Array<any>;
102
+ modifiers: ASTModifiers | null;
103
+ dynamic?: boolean;
104
+ start?: number;
105
+ end?: number;
106
+ };
107
+
108
+ declare type ASTElementHandlers = {
109
+ [key: string]: ASTElementHandler | Array<ASTElementHandler>;
110
+ };
111
+
112
+ declare type ASTExpression = {
113
+ type: 2;
114
+ expression: string;
115
+ text: string;
116
+ tokens: Array<string | Object>;
117
+ static?: boolean;
118
+ ssrOptimizability?: number;
119
+ start?: number;
120
+ end?: number;
121
+ };
122
+
123
+ declare type ASTIfCondition = {
124
+ exp: string | null;
125
+ block: ASTElement;
126
+ };
127
+
128
+ declare type ASTIfConditions = Array<ASTIfCondition>;
129
+
130
+ declare type ASTModifiers = {
131
+ [key: string]: boolean;
132
+ };
133
+
134
+ declare type ASTNode = ASTElement | ASTText | ASTExpression;
135
+
136
+ declare type ASTText = {
137
+ type: 3;
138
+ text: string;
139
+ static?: boolean;
140
+ isComment?: boolean;
141
+ ssrOptimizability?: number;
142
+ start?: number;
143
+ end?: number;
144
+ };
145
+
146
+ declare type BindingMetadata = {
147
+ [key: string]: BindingTypes | undefined;
148
+ } & {
149
+ __isScriptSetup?: boolean;
150
+ };
151
+
152
+ declare const enum BindingTypes {
153
+ /**
154
+ * returned from data()
155
+ */
156
+ DATA = "data",
157
+ /**
158
+ * declared as a prop
159
+ */
160
+ PROPS = "props",
161
+ /**
162
+ * a local alias of a `<script setup>` destructured prop.
163
+ * the original is stored in __propsAliases of the bindingMetadata object.
164
+ */
165
+ PROPS_ALIASED = "props-aliased",
166
+ /**
167
+ * a let binding (may or may not be a ref)
168
+ */
169
+ SETUP_LET = "setup-let",
170
+ /**
171
+ * a const binding that can never be a ref.
172
+ * these bindings don't need `unref()` calls when processed in inlined
173
+ * template expressions.
174
+ */
175
+ SETUP_CONST = "setup-const",
176
+ /**
177
+ * a const binding that does not need `unref()`, but may be mutated.
178
+ */
179
+ SETUP_REACTIVE_CONST = "setup-reactive-const",
180
+ /**
181
+ * a const binding that may be a ref.
182
+ */
183
+ SETUP_MAYBE_REF = "setup-maybe-ref",
184
+ /**
185
+ * bindings that are guaranteed to be refs
186
+ */
187
+ SETUP_REF = "setup-ref",
188
+ /**
189
+ * declared by other options, e.g. computed, inject
190
+ */
191
+ OPTIONS = "options"
192
+ }
193
+
194
+ declare type CompiledResult = {
195
+ ast: ASTElement | null;
196
+ render: string;
197
+ staticRenderFns: Array<string>;
198
+ stringRenderFns?: Array<string>;
199
+ errors?: Array<string | WarningMessage>;
200
+ tips?: Array<string | WarningMessage>;
201
+ };
202
+
203
+ declare type CompilerOptions = {
204
+ warn?: Function;
205
+ modules?: Array<ModuleOptions>;
206
+ directives?: {
207
+ [key: string]: Function;
208
+ };
209
+ staticKeys?: string;
210
+ isUnaryTag?: (tag: string) => boolean | undefined;
211
+ canBeLeftOpenTag?: (tag: string) => boolean | undefined;
212
+ isReservedTag?: (tag: string) => boolean | undefined;
213
+ preserveWhitespace?: boolean;
214
+ whitespace?: 'preserve' | 'condense';
215
+ optimize?: boolean;
216
+ mustUseProp?: (tag: string, type: string | null, name: string) => boolean;
217
+ isPreTag?: (attr: string) => boolean | null;
218
+ getTagNamespace?: (tag: string) => string | undefined;
219
+ expectHTML?: boolean;
220
+ isFromDOM?: boolean;
221
+ shouldDecodeTags?: boolean;
222
+ shouldDecodeNewlines?: boolean;
223
+ shouldDecodeNewlinesForHref?: boolean;
224
+ outputSourceRange?: boolean;
225
+ shouldKeepComment?: boolean;
226
+ delimiters?: [string, string];
227
+ comments?: boolean;
228
+ scopeId?: string;
229
+ bindings?: BindingMetadata;
230
+ };
231
+
232
+ /**
233
+ * Compile `<script setup>`
234
+ * It requires the whole SFC descriptor because we need to handle and merge
235
+ * normal `<script>` + `<script setup>` if both are present.
236
+ */
237
+ export declare function compileScript(sfc: SFCDescriptor, options?: SFCScriptCompileOptions): SFCScriptBlock;
238
+
239
+ export declare function compileStyle(options: SFCStyleCompileOptions): SFCStyleCompileResults;
240
+
241
+ export declare function compileStyleAsync(options: SFCStyleCompileOptions): Promise<SFCStyleCompileResults>;
242
+
243
+ export declare function compileTemplate(options: SFCTemplateCompileOptions): SFCTemplateCompileResult;
244
+
245
+ export declare function generateCodeFrame(source: string, start?: number, end?: number): string;
246
+
247
+ declare interface ImportBinding {
248
+ isType: boolean;
249
+ imported: string;
250
+ source: string;
251
+ isFromSetup: boolean;
252
+ isUsedInTemplate: boolean;
253
+ }
254
+
255
+ declare type ModuleOptions = {
256
+ preTransformNode?: (el: ASTElement) => ASTElement | null | void;
257
+ transformNode?: (el: ASTElement) => ASTElement | null | void;
258
+ postTransformNode?: (el: ASTElement) => void;
259
+ genData?: (el: ASTElement) => string;
260
+ transformCode?: (el: ASTElement, code: string) => string;
261
+ staticKeys?: Array<string>;
262
+ };
263
+
264
+ export declare function parse(options: ParseOptions): SFCDescriptor;
265
+
266
+ declare interface ParseOptions {
267
+ source: string;
268
+ filename?: string;
269
+ compiler?: VueTemplateCompiler;
270
+ compilerParseOptions?: VueTemplateCompilerParseOptions;
271
+ sourceRoot?: string;
272
+ needMap?: boolean;
273
+ }
274
+
275
+ declare interface RawSourceMap extends StartOfSourceMap {
276
+ version: string;
277
+ sources: string[];
278
+ names: string[];
279
+ sourcesContent?: string[];
280
+ mappings: string;
281
+ }
282
+
283
+ export declare interface SFCBlock extends SFCCustomBlock {
284
+ lang?: string;
285
+ src?: string;
286
+ scoped?: boolean;
287
+ module?: string | boolean;
288
+ }
289
+
290
+ export declare interface SFCCustomBlock {
291
+ type: string;
292
+ content: string;
293
+ attrs: {
294
+ [key: string]: string | true;
295
+ };
296
+ start: number;
297
+ end: number;
298
+ map?: RawSourceMap;
299
+ }
300
+
301
+ export declare interface SFCDescriptor {
302
+ source: string;
303
+ filename: string;
304
+ template: SFCBlock | null;
305
+ script: SFCScriptBlock | null;
306
+ scriptSetup: SFCScriptBlock | null;
307
+ styles: SFCBlock[];
308
+ customBlocks: SFCCustomBlock[];
309
+ errors: WarningMessage[];
310
+ /**
311
+ * compare with an existing descriptor to determine whether HMR should perform
312
+ * a reload vs. re-render.
313
+ *
314
+ * Note: this comparison assumes the prev/next script are already identical,
315
+ * and only checks the special case where `<script setup lang="ts">` unused
316
+ * import pruning result changes due to template changes.
317
+ */
318
+ shouldForceReload: (prevImports: Record<string, ImportBinding>) => boolean;
319
+ }
320
+
321
+ declare interface SFCScriptBlock extends SFCBlock {
322
+ type: 'script';
323
+ setup?: string | boolean;
324
+ bindings?: BindingMetadata;
325
+ imports?: Record<string, ImportBinding>;
326
+ /**
327
+ * import('\@babel/types').Statement
328
+ */
329
+ scriptAst?: any[];
330
+ /**
331
+ * import('\@babel/types').Statement
332
+ */
333
+ scriptSetupAst?: any[];
334
+ }
335
+
336
+ export declare interface SFCScriptCompileOptions {
337
+ /**
338
+ * Production mode. Used to determine whether to generate hashed CSS variables
339
+ */
340
+ isProd?: boolean;
341
+ /**
342
+ * Enable/disable source map. Defaults to true.
343
+ */
344
+ sourceMap?: boolean;
345
+ /**
346
+ * https://babeljs.io/docs/en/babel-parser#plugins
347
+ */
348
+ babelParserPlugins?: ParserPlugin[];
349
+ }
350
+
351
+ export declare interface SFCStyleCompileOptions {
352
+ source: string;
353
+ filename: string;
354
+ id: string;
355
+ map?: any;
356
+ scoped?: boolean;
357
+ trim?: boolean;
358
+ preprocessLang?: string;
359
+ preprocessOptions?: any;
360
+ postcssOptions?: any;
361
+ postcssPlugins?: any[];
362
+ }
363
+
364
+ export declare interface SFCStyleCompileResults {
365
+ code: string;
366
+ map: any | void;
367
+ rawResult: LazyResult | void;
368
+ errors: string[];
369
+ }
370
+
371
+ export declare interface SFCTemplateCompileOptions {
372
+ source: string;
373
+ filename: string;
374
+ compiler?: VueTemplateCompiler;
375
+ compilerOptions?: VueTemplateCompilerOptions;
376
+ transformAssetUrls?: AssetURLOptions | boolean;
377
+ transformAssetUrlsOptions?: TransformAssetUrlsOptions;
378
+ preprocessLang?: string;
379
+ preprocessOptions?: any;
380
+ transpileOptions?: any;
381
+ isProduction?: boolean;
382
+ isFunctional?: boolean;
383
+ optimizeSSR?: boolean;
384
+ prettify?: boolean;
385
+ isTS?: boolean;
386
+ bindings?: BindingMetadata;
387
+ }
388
+
389
+ export declare interface SFCTemplateCompileResult {
390
+ ast: Object | undefined;
391
+ code: string;
392
+ source: string;
393
+ tips: (string | WarningMessage)[];
394
+ errors: (string | WarningMessage)[];
395
+ }
396
+
397
+ declare interface StartOfSourceMap {
398
+ file?: string;
399
+ sourceRoot?: string;
400
+ }
401
+
402
+ declare interface TransformAssetUrlsOptions {
403
+ /**
404
+ * If base is provided, instead of transforming relative asset urls into
405
+ * imports, they will be directly rewritten to absolute urls.
406
+ */
407
+ base?: string;
408
+ }
409
+
410
+ declare interface VueTemplateCompiler {
411
+ parseComponent(source: string, options?: any): SFCDescriptor;
412
+ compile(template: string, options: VueTemplateCompilerOptions): VueTemplateCompilerResults;
413
+ ssrCompile(template: string, options: VueTemplateCompilerOptions): VueTemplateCompilerResults;
414
+ }
415
+
416
+ declare type VueTemplateCompilerOptions = CompilerOptions;
417
+
418
+ declare interface VueTemplateCompilerParseOptions {
419
+ pad?: 'line' | 'space' | boolean;
420
+ deindent?: boolean;
421
+ outputSourceRange?: boolean;
422
+ }
423
+
424
+ declare type VueTemplateCompilerResults = CompiledResult;
425
+
426
+ declare type WarningMessage = {
427
+ msg: string;
428
+ start?: number;
429
+ end?: number;
430
+ };
431
+
432
+ export { }