ripple 0.2.180 → 0.2.183
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.
- package/package.json +4 -2
- package/src/compiler/errors.js +3 -1
- package/src/compiler/index.d.ts +2 -1
- package/src/compiler/phases/1-parse/index.js +525 -311
- package/src/compiler/phases/1-parse/style.js +3 -1
- package/src/compiler/phases/2-analyze/css-analyze.js +116 -97
- package/src/compiler/phases/2-analyze/index.js +80 -50
- package/src/compiler/phases/2-analyze/prune.js +200 -58
- package/src/compiler/phases/2-analyze/validation.js +9 -7
- package/src/compiler/phases/3-transform/client/index.js +871 -394
- package/src/compiler/phases/3-transform/segments.js +6 -4
- package/src/compiler/phases/3-transform/server/index.js +278 -121
- package/src/compiler/scope.js +45 -93
- package/src/compiler/types/index.d.ts +619 -199
- package/src/compiler/types/parse.d.ts +1580 -0
- package/src/compiler/utils.js +62 -74
- package/src/runtime/internal/client/blocks.js +4 -1
- package/src/utils/ast.js +247 -192
- package/src/utils/builders.js +309 -247
- package/src/utils/sanitize_template_string.js +2 -2
|
@@ -1,30 +1,313 @@
|
|
|
1
|
-
import type * as
|
|
1
|
+
import type * as AST from 'estree';
|
|
2
|
+
import type * as ESTreeJSX from 'estree-jsx';
|
|
3
|
+
import type { TSESTree } from '@typescript-eslint/types';
|
|
4
|
+
import type { NAMESPACE_URI } from '../../runtime/internal/client/constants.js';
|
|
5
|
+
import type { Parse } from '#parser';
|
|
6
|
+
|
|
7
|
+
export type RpcModules = Map<string, [string, string]>;
|
|
8
|
+
|
|
9
|
+
declare global {
|
|
10
|
+
var rpc_modules: RpcModules | undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type NameSpace = keyof typeof NAMESPACE_URI;
|
|
14
|
+
interface BaseNodeMetaData {
|
|
15
|
+
scoped?: boolean;
|
|
16
|
+
path: AST.Node[];
|
|
17
|
+
has_template?: boolean;
|
|
18
|
+
original_name?: string;
|
|
19
|
+
is_capitalized?: boolean;
|
|
20
|
+
has_await?: boolean;
|
|
21
|
+
commentContainerId?: number;
|
|
22
|
+
openingTagEnd?: number;
|
|
23
|
+
openingTagEndLoc?: AST.Position;
|
|
24
|
+
parenthesized?: boolean;
|
|
25
|
+
elementLeadingComments?: AST.Comment[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface FunctionMetaData extends BaseNodeMetaData {
|
|
29
|
+
was_component?: boolean;
|
|
30
|
+
tracked?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Strip parent, loc, and range from TSESTree nodes to match @sveltejs/acorn-typescript output
|
|
34
|
+
// acorn-typescript uses start/end instead of range, and loc is optional
|
|
35
|
+
type AcornTSNode<T> = Omit<T, 'parent' | 'loc' | 'range' | 'expression'> & {
|
|
36
|
+
start: number;
|
|
37
|
+
end: number;
|
|
38
|
+
loc?: AST.SourceLocation;
|
|
39
|
+
range?: AST.BaseNode['range'];
|
|
40
|
+
metadata: BaseNodeMetaData;
|
|
41
|
+
|
|
42
|
+
leadingComments?: AST.Comment[] | undefined;
|
|
43
|
+
trailingComments?: AST.Comment[] | undefined;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
interface FunctionLikeTS {
|
|
47
|
+
returnType?: AST.TSTypeAnnotation;
|
|
48
|
+
typeParameters?: AST.TSTypeParameterDeclaration;
|
|
49
|
+
typeAnnotation?: AST.TSTypeAnnotation;
|
|
50
|
+
}
|
|
2
51
|
|
|
3
52
|
// Ripple augmentation for ESTree function nodes
|
|
4
53
|
declare module 'estree' {
|
|
5
|
-
interface FunctionDeclaration {
|
|
6
|
-
metadata
|
|
54
|
+
interface FunctionDeclaration extends FunctionLikeTS {
|
|
55
|
+
metadata: FunctionMetaData;
|
|
7
56
|
}
|
|
8
|
-
interface FunctionExpression {
|
|
9
|
-
metadata
|
|
57
|
+
interface FunctionExpression extends FunctionLikeTS {
|
|
58
|
+
metadata: FunctionMetaData;
|
|
10
59
|
}
|
|
11
|
-
interface ArrowFunctionExpression {
|
|
12
|
-
metadata
|
|
60
|
+
interface ArrowFunctionExpression extends FunctionLikeTS {
|
|
61
|
+
metadata: FunctionMetaData;
|
|
13
62
|
}
|
|
14
|
-
|
|
63
|
+
|
|
64
|
+
interface Identifier extends TrackedNode {
|
|
65
|
+
metadata: BaseNode['metadata'] & {
|
|
66
|
+
tracked_shorthand?: '#Map' | '#Set';
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface MemberExpression extends TrackedNode {}
|
|
71
|
+
|
|
72
|
+
interface TrackedNode {
|
|
15
73
|
tracked?: boolean;
|
|
16
74
|
}
|
|
17
|
-
|
|
75
|
+
|
|
76
|
+
// Include TypeScript node types and Ripple-specific nodes in NodeMap
|
|
77
|
+
interface NodeMap {
|
|
78
|
+
Component: Component;
|
|
79
|
+
TsxCompat: TsxCompat;
|
|
80
|
+
Html: Html;
|
|
81
|
+
Element: Element;
|
|
82
|
+
Text: TextNode;
|
|
83
|
+
ServerBlock: ServerBlock;
|
|
84
|
+
ServerIdentifier: ServerIdentifier;
|
|
85
|
+
TrackedExpression: TrackedExpression;
|
|
86
|
+
Attribute: Attribute;
|
|
87
|
+
RefAttribute: RefAttribute;
|
|
88
|
+
SpreadAttribute: SpreadAttribute;
|
|
89
|
+
// Stylesheet: AST.CSS.StyleSheet;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface ExpressionMap {
|
|
93
|
+
TrackedArrayExpression: TrackedArrayExpression;
|
|
94
|
+
TrackedObjectExpression: TrackedObjectExpression;
|
|
95
|
+
TrackedMapExpression: TrackedMapExpression;
|
|
96
|
+
TrackedSetExpression: TrackedSetExpression;
|
|
97
|
+
TrackedExpression: TrackedExpression;
|
|
98
|
+
Text: TextNode;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface Comment {
|
|
102
|
+
context?: Parse.CommentMetaData | null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Custom Comment interface with location information
|
|
107
|
+
*/
|
|
108
|
+
type CommentWithLocation = Comment & NodeWithLocation;
|
|
109
|
+
|
|
110
|
+
interface TryStatement {
|
|
111
|
+
pending?: BlockStatement | null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface ForOfStatement {
|
|
115
|
+
index?: Identifier | null;
|
|
116
|
+
key?: Expression | null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface ServerIdentifier extends BaseNode {
|
|
120
|
+
type: 'ServerIdentifier';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
interface ImportDeclaration {
|
|
124
|
+
importKind: TSESTree.ImportDeclaration['importKind'];
|
|
125
|
+
}
|
|
126
|
+
interface ImportSpecifier {
|
|
127
|
+
importKind: TSESTree.ImportSpecifier['importKind'];
|
|
128
|
+
}
|
|
129
|
+
interface ExportNamedDeclaration {
|
|
130
|
+
exportKind: TSESTree.ExportNamedDeclaration['exportKind'];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
interface BaseNodeWithoutComments {
|
|
134
|
+
// Adding start, end for now as always there
|
|
135
|
+
// later might change to optional
|
|
136
|
+
// And only define on certain nodes
|
|
137
|
+
// BaseNode inherits from this interface
|
|
138
|
+
start?: number;
|
|
139
|
+
end?: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface BaseNode {
|
|
143
|
+
is_controlled?: boolean;
|
|
144
|
+
// This is for Pattern but it's a type alias
|
|
145
|
+
// So it's just easy to extend BaseNode even though
|
|
146
|
+
// typeAnnotation, typeArguments do not apply to all nodes
|
|
147
|
+
typeAnnotation?: TSTypeAnnotation;
|
|
148
|
+
typeArguments?: TSTypeParameterInstantiation;
|
|
149
|
+
|
|
150
|
+
// even though technically metadata starts out as undefined
|
|
151
|
+
// metadata is always populated by the `_` visitor
|
|
152
|
+
// which runs for every node before other visitors
|
|
153
|
+
// so taking a practical approach and making it required
|
|
154
|
+
// to avoid lots of typecasting or checking for undefined
|
|
155
|
+
metadata: BaseNodeMetaData;
|
|
156
|
+
|
|
157
|
+
comments?: AST.Comment[];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
interface NodeWithLocation {
|
|
161
|
+
start: number;
|
|
162
|
+
end: number;
|
|
163
|
+
loc: SourceLocation;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Ripple custom interfaces and types section
|
|
168
|
+
*/
|
|
169
|
+
interface Component extends BaseNode {
|
|
18
170
|
type: 'Component';
|
|
19
|
-
|
|
171
|
+
// null is for anonymous components {component: () => {}}
|
|
172
|
+
id: Identifier | null;
|
|
20
173
|
params: Pattern[];
|
|
174
|
+
body: Node[];
|
|
175
|
+
css: CSS.StyleSheet | null;
|
|
176
|
+
metadata: BaseNodeMetaData & {
|
|
177
|
+
inherited_css?: boolean;
|
|
178
|
+
};
|
|
179
|
+
default: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface TsxCompat extends BaseNode {
|
|
183
|
+
type: 'TsxCompat';
|
|
184
|
+
kind: string;
|
|
185
|
+
attributes: Array<any>;
|
|
186
|
+
children: ESTreeJSX.JSXElement['children'];
|
|
187
|
+
selfClosing?: boolean;
|
|
188
|
+
unclosed?: boolean;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interface Html extends BaseNode {
|
|
192
|
+
type: 'Html';
|
|
193
|
+
expression: Expression;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
interface Element extends BaseNode {
|
|
197
|
+
type: 'Element';
|
|
198
|
+
id: Identifier;
|
|
199
|
+
attributes: RippleAttribute[];
|
|
200
|
+
children: Node[];
|
|
201
|
+
selfClosing?: boolean;
|
|
202
|
+
unclosed?: boolean;
|
|
203
|
+
loc: AST.SourceLocation;
|
|
204
|
+
metadata: BaseNodeMetaData & {
|
|
205
|
+
ts_name?: string;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// currently only for <style> and <script> tags
|
|
209
|
+
openingElement?: ESTreeJSX.JSXOpeningElement;
|
|
210
|
+
closingElement?: ESTreeJSX.JSXClosingElement;
|
|
211
|
+
|
|
212
|
+
// for <style> tags
|
|
213
|
+
css?: string;
|
|
214
|
+
|
|
215
|
+
// for <script> tags
|
|
216
|
+
content?: string;
|
|
217
|
+
|
|
218
|
+
innerComments?: Comment[];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface TextNode extends AST.BaseNode {
|
|
222
|
+
type: 'Text';
|
|
223
|
+
expression: Expression;
|
|
224
|
+
loc?: SourceLocation;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
interface ServerBlock extends BaseNode {
|
|
228
|
+
type: 'ServerBlock';
|
|
21
229
|
body: BlockStatement;
|
|
230
|
+
metadata: BaseNodeMetaData & {
|
|
231
|
+
exports: string[];
|
|
232
|
+
};
|
|
22
233
|
}
|
|
23
234
|
|
|
24
|
-
|
|
25
|
-
|
|
235
|
+
/**
|
|
236
|
+
* Tracked Expressions
|
|
237
|
+
*/
|
|
238
|
+
interface TrackedArrayExpression extends Omit<ArrayExpression, 'type'> {
|
|
239
|
+
type: 'TrackedArrayExpression';
|
|
240
|
+
elements: (Expression | SpreadElement | null)[];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
interface TrackedExpression extends BaseNode {
|
|
244
|
+
argument: Expression;
|
|
245
|
+
type: 'TrackedExpression';
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface TrackedObjectExpression extends Omit<ObjectExpression, 'type'> {
|
|
249
|
+
type: 'TrackedObjectExpression';
|
|
250
|
+
properties: (Property | SpreadElement)[];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
interface TrackedMapExpression extends BaseNode {
|
|
254
|
+
type: 'TrackedMapExpression';
|
|
255
|
+
arguments: (Expression | SpreadElement)[];
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
interface TrackedSetExpression extends BaseNode {
|
|
259
|
+
type: 'TrackedSetExpression';
|
|
260
|
+
arguments: (Expression | SpreadElement)[];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Ripple attribute nodes
|
|
265
|
+
*/
|
|
266
|
+
interface Attribute extends BaseNode {
|
|
267
|
+
type: 'Attribute';
|
|
268
|
+
name: Identifier;
|
|
269
|
+
value: Expression | null;
|
|
270
|
+
loc?: SourceLocation;
|
|
271
|
+
shorthand?: boolean;
|
|
272
|
+
metadata: BaseNodeMetaData & {
|
|
273
|
+
delegated?: boolean;
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
interface RefAttribute extends BaseNode {
|
|
278
|
+
type: 'RefAttribute';
|
|
279
|
+
argument: Expression;
|
|
280
|
+
loc?: SourceLocation;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
interface SpreadAttribute extends BaseNode {
|
|
284
|
+
type: 'SpreadAttribute';
|
|
285
|
+
argument: Expression;
|
|
286
|
+
loc?: SourceLocation;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Ripple's extended Declaration type that includes Component
|
|
291
|
+
* Use this instead of AST.Declaration when you need Component support
|
|
292
|
+
*/
|
|
293
|
+
export type RippleDeclaration = AST.Declaration | AST.Component | AST.TSDeclareFunction;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Ripple's extended ExportNamedDeclaration with Component support
|
|
297
|
+
*/
|
|
298
|
+
interface RippleExportNamedDeclaration extends Omit<AST.ExportNamedDeclaration, 'declaration'> {
|
|
299
|
+
declaration?: RippleDeclaration | null | undefined;
|
|
26
300
|
}
|
|
27
301
|
|
|
302
|
+
/**
|
|
303
|
+
* Ripple's extended Program with Component support
|
|
304
|
+
*/
|
|
305
|
+
interface RippleProgram extends Omit<AST.Program, 'body'> {
|
|
306
|
+
body: (AST.Program['body'][number] | Component)[];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export type RippleAttribute = Attribute | SpreadAttribute | RefAttribute;
|
|
310
|
+
|
|
28
311
|
export namespace CSS {
|
|
29
312
|
export interface BaseNode {
|
|
30
313
|
start: number;
|
|
@@ -79,6 +362,7 @@ declare module 'estree' {
|
|
|
79
362
|
metadata: {
|
|
80
363
|
rule: Rule | null;
|
|
81
364
|
used: boolean;
|
|
365
|
+
is_global?: boolean;
|
|
82
366
|
};
|
|
83
367
|
}
|
|
84
368
|
|
|
@@ -199,33 +483,198 @@ declare module 'estree-jsx' {
|
|
|
199
483
|
shorthand: boolean;
|
|
200
484
|
}
|
|
201
485
|
|
|
202
|
-
interface
|
|
203
|
-
loc:
|
|
486
|
+
interface JSXEmptyExpression {
|
|
487
|
+
loc: AST.SourceLocation;
|
|
488
|
+
innerComments?: Comment[];
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
interface JSXOpeningFragment {
|
|
492
|
+
attributes: Array<JSXAttribute | JSXSpreadAttribute>;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
interface JSXElement {
|
|
496
|
+
metadata: BaseNodeMetaData & {
|
|
497
|
+
ts_name?: string;
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
interface JSXExpressionContainer {
|
|
502
|
+
html?: boolean;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
interface JSXMemberExpression {
|
|
506
|
+
computed?: boolean;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
interface ExpressionMap {
|
|
510
|
+
JSXIdentifier: JSXIdentifier;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
declare module 'estree' {
|
|
515
|
+
interface NodeMap {
|
|
516
|
+
// TypeScript nodes
|
|
517
|
+
TSAnyKeyword: TSAnyKeyword;
|
|
518
|
+
TSArrayType: TSArrayType;
|
|
519
|
+
TSAsExpression: TSAsExpression;
|
|
520
|
+
TSBigIntKeyword: TSBigIntKeyword;
|
|
521
|
+
TSBooleanKeyword: TSBooleanKeyword;
|
|
522
|
+
TSCallSignatureDeclaration: TSCallSignatureDeclaration;
|
|
523
|
+
TSConditionalType: TSConditionalType;
|
|
524
|
+
TSConstructorType: TSConstructorType;
|
|
525
|
+
TSConstructSignatureDeclaration: TSConstructSignatureDeclaration;
|
|
526
|
+
TSDeclareFunction: TSDeclareFunction;
|
|
527
|
+
TSEnumDeclaration: TSEnumDeclaration;
|
|
528
|
+
TSEnumMember: TSEnumMember;
|
|
529
|
+
TSExportAssignment: TSExportAssignment;
|
|
530
|
+
TSExternalModuleReference: TSExternalModuleReference;
|
|
531
|
+
TSFunctionType: TSFunctionType;
|
|
532
|
+
TSImportEqualsDeclaration: TSImportEqualsDeclaration;
|
|
533
|
+
TSImportType: TSImportType;
|
|
534
|
+
TSIndexedAccessType: TSIndexedAccessType;
|
|
535
|
+
TSIndexSignature: TSIndexSignature;
|
|
536
|
+
TSInferType: TSInferType;
|
|
537
|
+
TSInstantiationExpression: TSInstantiationExpression;
|
|
538
|
+
TSInterfaceBody: TSInterfaceBody;
|
|
539
|
+
TSInterfaceDeclaration: TSInterfaceDeclaration;
|
|
540
|
+
TSIntersectionType: TSIntersectionType;
|
|
541
|
+
TSIntrinsicKeyword: TSIntrinsicKeyword;
|
|
542
|
+
TSLiteralType: TSLiteralType;
|
|
543
|
+
TSMappedType: TSMappedType;
|
|
544
|
+
TSMethodSignature: TSMethodSignature;
|
|
545
|
+
TSModuleBlock: TSModuleBlock;
|
|
546
|
+
TSModuleDeclaration: TSModuleDeclaration;
|
|
547
|
+
TSNamedTupleMember: TSNamedTupleMember;
|
|
548
|
+
TSNamespaceExportDeclaration: TSNamespaceExportDeclaration;
|
|
549
|
+
TSNeverKeyword: TSNeverKeyword;
|
|
550
|
+
TSNonNullExpression: TSNonNullExpression;
|
|
551
|
+
TSNullKeyword: TSNullKeyword;
|
|
552
|
+
TSNumberKeyword: TSNumberKeyword;
|
|
553
|
+
TSObjectKeyword: TSObjectKeyword;
|
|
554
|
+
TSOptionalType: TSOptionalType;
|
|
555
|
+
TSParameterProperty: TSParameterProperty;
|
|
556
|
+
TSPropertySignature: TSPropertySignature;
|
|
557
|
+
TSQualifiedName: TSQualifiedName;
|
|
558
|
+
TSRestType: TSRestType;
|
|
559
|
+
TSSatisfiesExpression: TSSatisfiesExpression;
|
|
560
|
+
TSStringKeyword: TSStringKeyword;
|
|
561
|
+
TSSymbolKeyword: TSSymbolKeyword;
|
|
562
|
+
TSThisType: TSThisType;
|
|
563
|
+
TSTupleType: TSTupleType;
|
|
564
|
+
TSTypeAliasDeclaration: TSTypeAliasDeclaration;
|
|
565
|
+
TSTypeAnnotation: TSTypeAnnotation;
|
|
566
|
+
TSTypeAssertion: TSTypeAssertion;
|
|
567
|
+
TSTypeLiteral: TSTypeLiteral;
|
|
568
|
+
TSTypeOperator: TSTypeOperator;
|
|
569
|
+
TSTypeParameter: TSTypeParameter;
|
|
570
|
+
TSTypeParameterDeclaration: TSTypeParameterDeclaration;
|
|
571
|
+
TSTypeParameterInstantiation: TSTypeParameterInstantiation;
|
|
572
|
+
TSTypePredicate: TSTypePredicate;
|
|
573
|
+
TSTypeQuery: TSTypeQuery;
|
|
574
|
+
TSTypeReference: TSTypeReference;
|
|
575
|
+
TSUndefinedKeyword: TSUndefinedKeyword;
|
|
576
|
+
TSUnionType: TSUnionType;
|
|
577
|
+
TSUnknownKeyword: TSUnknownKeyword;
|
|
578
|
+
TSVoidKeyword: TSVoidKeyword;
|
|
579
|
+
TSParenthesizedType: TSParenthesizedType;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// TypeScript AST node interfaces from @sveltejs/acorn-typescript
|
|
583
|
+
// Based on TSESTree types but adapted for acorn's output format
|
|
584
|
+
interface TSAnyKeyword extends AcornTSNode<TSESTree.TSAnyKeyword> {}
|
|
585
|
+
interface TSArrayType extends AcornTSNode<TSESTree.TSArrayType> {}
|
|
586
|
+
interface TSAsExpression extends AcornTSNode<TSESTree.TSAsExpression> {
|
|
587
|
+
// Have to override it to use our Expression for required properties like metadata
|
|
588
|
+
expression: AST.Expression;
|
|
589
|
+
}
|
|
590
|
+
interface TSBigIntKeyword extends AcornTSNode<TSESTree.TSBigIntKeyword> {}
|
|
591
|
+
interface TSBooleanKeyword extends AcornTSNode<TSESTree.TSBooleanKeyword> {}
|
|
592
|
+
interface TSCallSignatureDeclaration extends AcornTSNode<TSESTree.TSCallSignatureDeclaration> {}
|
|
593
|
+
interface TSConditionalType extends AcornTSNode<TSESTree.TSConditionalType> {}
|
|
594
|
+
interface TSConstructorType extends AcornTSNode<TSESTree.TSConstructorType> {}
|
|
595
|
+
interface TSConstructSignatureDeclaration
|
|
596
|
+
extends AcornTSNode<TSESTree.TSConstructSignatureDeclaration> {}
|
|
597
|
+
interface TSDeclareFunction extends AcornTSNode<TSESTree.TSDeclareFunction> {}
|
|
598
|
+
interface TSEnumDeclaration extends AcornTSNode<TSESTree.TSEnumDeclaration> {}
|
|
599
|
+
interface TSEnumMember extends AcornTSNode<TSESTree.TSEnumMember> {}
|
|
600
|
+
interface TSExportAssignment extends AcornTSNode<TSESTree.TSExportAssignment> {}
|
|
601
|
+
interface TSExternalModuleReference extends AcornTSNode<TSESTree.TSExternalModuleReference> {}
|
|
602
|
+
interface TSFunctionType extends AcornTSNode<TSESTree.TSFunctionType> {}
|
|
603
|
+
interface TSImportEqualsDeclaration extends AcornTSNode<TSESTree.TSImportEqualsDeclaration> {}
|
|
604
|
+
interface TSImportType extends AcornTSNode<TSESTree.TSImportType> {}
|
|
605
|
+
interface TSIndexedAccessType extends AcornTSNode<TSESTree.TSIndexedAccessType> {}
|
|
606
|
+
interface TSIndexSignature extends AcornTSNode<TSESTree.TSIndexSignature> {}
|
|
607
|
+
interface TSInferType extends AcornTSNode<TSESTree.TSInferType> {}
|
|
608
|
+
interface TSInstantiationExpression extends AcornTSNode<TSESTree.TSInstantiationExpression> {
|
|
609
|
+
expression: AST.Expression;
|
|
610
|
+
}
|
|
611
|
+
interface TSInterfaceBody extends AcornTSNode<TSESTree.TSInterfaceBody> {}
|
|
612
|
+
interface TSInterfaceDeclaration extends AcornTSNode<TSESTree.TSInterfaceDeclaration> {}
|
|
613
|
+
interface TSIntersectionType extends AcornTSNode<TSESTree.TSIntersectionType> {}
|
|
614
|
+
interface TSIntrinsicKeyword extends AcornTSNode<TSESTree.TSIntrinsicKeyword> {}
|
|
615
|
+
interface TSLiteralType extends AcornTSNode<TSESTree.TSLiteralType> {}
|
|
616
|
+
interface TSMappedType extends AcornTSNode<TSESTree.TSMappedType> {}
|
|
617
|
+
interface TSMethodSignature extends AcornTSNode<TSESTree.TSMethodSignature> {}
|
|
618
|
+
interface TSModuleBlock extends AcornTSNode<TSESTree.TSModuleBlock> {}
|
|
619
|
+
interface TSModuleDeclaration extends AcornTSNode<TSESTree.TSModuleDeclaration> {}
|
|
620
|
+
interface TSNamedTupleMember extends AcornTSNode<TSESTree.TSNamedTupleMember> {}
|
|
621
|
+
interface TSNamespaceExportDeclaration
|
|
622
|
+
extends AcornTSNode<TSESTree.TSNamespaceExportDeclaration> {}
|
|
623
|
+
interface TSNeverKeyword extends AcornTSNode<TSESTree.TSNeverKeyword> {}
|
|
624
|
+
interface TSNonNullExpression extends AcornTSNode<TSESTree.TSNonNullExpression> {
|
|
625
|
+
expression: AST.Expression;
|
|
626
|
+
}
|
|
627
|
+
interface TSNullKeyword extends AcornTSNode<TSESTree.TSNullKeyword> {}
|
|
628
|
+
interface TSNumberKeyword extends AcornTSNode<TSESTree.TSNumberKeyword> {}
|
|
629
|
+
interface TSObjectKeyword extends AcornTSNode<TSESTree.TSObjectKeyword> {}
|
|
630
|
+
interface TSOptionalType extends AcornTSNode<TSESTree.TSOptionalType> {}
|
|
631
|
+
interface TSParameterProperty extends AcornTSNode<TSESTree.TSParameterProperty> {}
|
|
632
|
+
interface TSPropertySignature extends AcornTSNode<TSESTree.TSPropertySignature> {}
|
|
633
|
+
interface TSQualifiedName extends AcornTSNode<TSESTree.TSQualifiedName> {}
|
|
634
|
+
interface TSRestType extends AcornTSNode<TSESTree.TSRestType> {}
|
|
635
|
+
interface TSSatisfiesExpression extends AcornTSNode<TSESTree.TSSatisfiesExpression> {
|
|
636
|
+
expression: AST.Expression;
|
|
637
|
+
}
|
|
638
|
+
interface TSStringKeyword extends AcornTSNode<TSESTree.TSStringKeyword> {}
|
|
639
|
+
interface TSSymbolKeyword extends AcornTSNode<TSESTree.TSSymbolKeyword> {}
|
|
640
|
+
interface TSThisType extends AcornTSNode<TSESTree.TSThisType> {}
|
|
641
|
+
interface TSTupleType extends AcornTSNode<TSESTree.TSTupleType> {}
|
|
642
|
+
interface TSTypeAliasDeclaration extends AcornTSNode<TSESTree.TSTypeAliasDeclaration> {}
|
|
643
|
+
interface TSTypeAnnotation extends AcornTSNode<TSESTree.TSTypeAnnotation> {}
|
|
644
|
+
interface TSTypeAssertion extends AcornTSNode<TSESTree.TSTypeAssertion> {
|
|
645
|
+
expression: AST.Expression;
|
|
646
|
+
}
|
|
647
|
+
interface TSTypeLiteral extends AcornTSNode<TSESTree.TSTypeLiteral> {}
|
|
648
|
+
interface TSTypeOperator extends AcornTSNode<TSESTree.TSTypeOperator> {}
|
|
649
|
+
interface TSTypeParameter extends AcornTSNode<TSESTree.TSTypeParameter> {}
|
|
650
|
+
interface TSTypeParameterDeclaration extends AcornTSNode<TSESTree.TSTypeParameterDeclaration> {}
|
|
651
|
+
interface TSTypeParameterInstantiation
|
|
652
|
+
extends AcornTSNode<TSESTree.TSTypeParameterInstantiation> {}
|
|
653
|
+
interface TSTypePredicate extends AcornTSNode<TSESTree.TSTypePredicate> {}
|
|
654
|
+
interface TSTypeQuery extends AcornTSNode<TSESTree.TSTypeQuery> {}
|
|
655
|
+
interface TSTypeReference extends AcornTSNode<TSESTree.TSTypeReference> {}
|
|
656
|
+
interface TSUndefinedKeyword extends AcornTSNode<TSESTree.TSUndefinedKeyword> {}
|
|
657
|
+
interface TSUnionType extends AcornTSNode<TSESTree.TSUnionType> {}
|
|
658
|
+
interface TSUnknownKeyword extends AcornTSNode<TSESTree.TSUnknownKeyword> {}
|
|
659
|
+
interface TSVoidKeyword extends AcornTSNode<TSESTree.TSVoidKeyword> {}
|
|
660
|
+
|
|
661
|
+
// acorn-typescript specific nodes (not in @typescript-eslint/types)
|
|
662
|
+
interface TSParenthesizedType extends AST.BaseNode {
|
|
663
|
+
type: 'TSParenthesizedType';
|
|
204
664
|
}
|
|
205
665
|
|
|
206
|
-
|
|
207
|
-
|
|
666
|
+
// Extend ExpressionMap for TypeScript expressions
|
|
667
|
+
interface ExpressionMap {
|
|
668
|
+
TSAsExpression: TSAsExpression;
|
|
669
|
+
TSInstantiationExpression: TSInstantiationExpression;
|
|
670
|
+
TSNonNullExpression: TSNonNullExpression;
|
|
671
|
+
TSSatisfiesExpression: TSSatisfiesExpression;
|
|
672
|
+
TSTypeAssertion: TSTypeAssertion;
|
|
208
673
|
}
|
|
209
674
|
}
|
|
210
675
|
|
|
211
676
|
import type { Comment, Position } from 'acorn';
|
|
212
|
-
import type {
|
|
213
|
-
Program,
|
|
214
|
-
Node,
|
|
215
|
-
Identifier,
|
|
216
|
-
VariableDeclarator,
|
|
217
|
-
FunctionDeclaration,
|
|
218
|
-
FunctionExpression,
|
|
219
|
-
ArrowFunctionExpression,
|
|
220
|
-
ClassDeclaration,
|
|
221
|
-
ImportDeclaration,
|
|
222
|
-
ArrayExpression,
|
|
223
|
-
ObjectExpression,
|
|
224
|
-
Expression,
|
|
225
|
-
Property,
|
|
226
|
-
SpreadElement,
|
|
227
|
-
Pattern,
|
|
228
|
-
} from 'estree';
|
|
677
|
+
import type { M } from 'vitest/dist/chunks/environment.d.cL3nLXbE.js';
|
|
229
678
|
|
|
230
679
|
/**
|
|
231
680
|
* Parse error information
|
|
@@ -240,113 +689,15 @@ export interface ParseError {
|
|
|
240
689
|
* Result of parsing operation
|
|
241
690
|
*/
|
|
242
691
|
export interface ParseResult {
|
|
243
|
-
ast: Program;
|
|
692
|
+
ast: AST.Program;
|
|
244
693
|
errors: ParseError[];
|
|
245
694
|
}
|
|
246
695
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
end: number;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Tracked array expression node
|
|
257
|
-
*/
|
|
258
|
-
export interface TrackedArrayExpression extends Omit<ArrayExpression, 'type'> {
|
|
259
|
-
type: 'TrackedArrayExpression';
|
|
260
|
-
elements: (Expression | null)[];
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
export interface TrackedExpression extends Omit<Expression, 'type'> {
|
|
264
|
-
argument: Expression;
|
|
265
|
-
type: 'TrackedExpression';
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Tracked object expression node
|
|
270
|
-
*/
|
|
271
|
-
export interface TrackedObjectExpression extends Omit<ObjectExpression, 'type'> {
|
|
272
|
-
type: 'TrackedObjectExpression';
|
|
273
|
-
properties: (Property | SpreadElement)[];
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Tracked Map expression node
|
|
278
|
-
*/
|
|
279
|
-
export interface TrackedMapExpression extends Omit<Node, 'type'> {
|
|
280
|
-
type: 'TrackedMapExpression';
|
|
281
|
-
arguments: (Expression | SpreadElement)[];
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Tracked Set expression node
|
|
286
|
-
*/
|
|
287
|
-
export interface TrackedSetExpression extends Omit<Node, 'type'> {
|
|
288
|
-
type: 'TrackedSetExpression';
|
|
289
|
-
arguments: (Expression | SpreadElement)[];
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Ripple component node
|
|
294
|
-
*/
|
|
295
|
-
export interface Component extends Omit<Node, 'type'> {
|
|
296
|
-
type: 'Component';
|
|
297
|
-
id: Identifier;
|
|
298
|
-
params: Pattern[];
|
|
299
|
-
body: Node[];
|
|
300
|
-
css: any;
|
|
301
|
-
start?: number;
|
|
302
|
-
end?: number;
|
|
303
|
-
loc?: any;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Ripple element node
|
|
308
|
-
*/
|
|
309
|
-
export interface Element extends Omit<Node, 'type'> {
|
|
310
|
-
type: 'Element';
|
|
311
|
-
id: Identifier;
|
|
312
|
-
attributes: Array<Attribute | SpreadAttribute>;
|
|
313
|
-
children: Node[];
|
|
314
|
-
metadata: any;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* TSX compatibility node for elements with namespaces like <tsx:react>
|
|
319
|
-
* Note: TsxCompat elements cannot be self-closing and must have a closing tag
|
|
320
|
-
*/
|
|
321
|
-
export interface TsxCompat extends Omit<Node, 'type'> {
|
|
322
|
-
type: 'TsxCompat';
|
|
323
|
-
kind: string;
|
|
324
|
-
attributes: Array<Attribute | SpreadAttribute>;
|
|
325
|
-
children: Node[];
|
|
326
|
-
metadata: any;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Ripple attribute node
|
|
331
|
-
*/
|
|
332
|
-
export interface Attribute {
|
|
333
|
-
type: 'Attribute';
|
|
334
|
-
name: Identifier;
|
|
335
|
-
value: Expression | null;
|
|
336
|
-
start?: number;
|
|
337
|
-
end?: number;
|
|
338
|
-
loc?: any;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Ripple spread attribute node
|
|
343
|
-
*/
|
|
344
|
-
export interface SpreadAttribute {
|
|
345
|
-
type: 'SpreadAttribute';
|
|
346
|
-
argument: Expression;
|
|
347
|
-
start?: number;
|
|
348
|
-
end?: number;
|
|
349
|
-
loc?: any;
|
|
696
|
+
export interface AnalysisResult {
|
|
697
|
+
ast: AST.Program;
|
|
698
|
+
scopes: Map<AST.Node, ScopeInterface>;
|
|
699
|
+
scope: ScopeInterface;
|
|
700
|
+
component_metadata: Array<{ id: string; async: boolean }>;
|
|
350
701
|
}
|
|
351
702
|
|
|
352
703
|
/**
|
|
@@ -374,18 +725,29 @@ export type DeclarationKind =
|
|
|
374
725
|
/**
|
|
375
726
|
* Binding kinds
|
|
376
727
|
*/
|
|
377
|
-
export type BindingKind =
|
|
728
|
+
export type BindingKind =
|
|
729
|
+
| 'normal'
|
|
730
|
+
| 'for_pattern'
|
|
731
|
+
| 'rest_prop'
|
|
732
|
+
| 'prop'
|
|
733
|
+
| 'prop_fallback'
|
|
734
|
+
| 'index';
|
|
378
735
|
|
|
379
736
|
/**
|
|
380
737
|
* A variable binding in a scope
|
|
381
738
|
*/
|
|
382
739
|
export interface Binding {
|
|
383
740
|
/** The identifier node that declares this binding */
|
|
384
|
-
node: Identifier;
|
|
741
|
+
node: AST.Identifier;
|
|
385
742
|
/** References to this binding */
|
|
386
|
-
references: Array<{ node: Identifier; path: Node[] }>;
|
|
743
|
+
references: Array<{ node: AST.Identifier; path: AST.Node[] }>;
|
|
387
744
|
/** Initial value/declaration */
|
|
388
|
-
initial:
|
|
745
|
+
initial:
|
|
746
|
+
| null
|
|
747
|
+
| AST.Expression
|
|
748
|
+
| AST.FunctionDeclaration
|
|
749
|
+
| AST.ClassDeclaration
|
|
750
|
+
| AST.ImportDeclaration;
|
|
389
751
|
/** Whether this binding has been reassigned */
|
|
390
752
|
reassigned: boolean;
|
|
391
753
|
/** Whether this binding has been mutated (property access) */
|
|
@@ -395,13 +757,23 @@ export interface Binding {
|
|
|
395
757
|
/** Whether this binding represents a called function */
|
|
396
758
|
is_called: boolean;
|
|
397
759
|
/** Additional metadata for this binding */
|
|
398
|
-
metadata
|
|
760
|
+
metadata: {
|
|
761
|
+
is_dynamic_component?: boolean;
|
|
762
|
+
pattern?: AST.Identifier;
|
|
763
|
+
is_tracked_object?: boolean;
|
|
764
|
+
} | null;
|
|
399
765
|
/** Kind of binding */
|
|
400
766
|
kind: BindingKind;
|
|
401
767
|
/** Declaration kind */
|
|
402
768
|
declaration_kind?: DeclarationKind;
|
|
403
769
|
/** The scope that contains this binding */
|
|
404
|
-
scope
|
|
770
|
+
scope: ScopeInterface;
|
|
771
|
+
/** Transform functions for reading, assigning, and updating this binding */
|
|
772
|
+
transform?: {
|
|
773
|
+
read: (node?: AST.Identifier) => AST.Expression;
|
|
774
|
+
assign?: (node: AST.Pattern, value: AST.Expression) => AST.AssignmentExpression;
|
|
775
|
+
update?: (node: AST.UpdateExpression) => AST.UpdateExpression;
|
|
776
|
+
};
|
|
405
777
|
}
|
|
406
778
|
|
|
407
779
|
/**
|
|
@@ -411,7 +783,7 @@ export interface ScopeRoot {
|
|
|
411
783
|
/** Set of conflicting/reserved names */
|
|
412
784
|
conflicts: Set<string>;
|
|
413
785
|
/** Generate unique identifier name */
|
|
414
|
-
unique(preferred_name: string): Identifier;
|
|
786
|
+
unique(preferred_name: string): AST.Identifier;
|
|
415
787
|
}
|
|
416
788
|
|
|
417
789
|
/**
|
|
@@ -425,98 +797,146 @@ export interface ScopeInterface {
|
|
|
425
797
|
/** Map of declared bindings */
|
|
426
798
|
declarations: Map<string, Binding>;
|
|
427
799
|
/** Map of declarators to their bindings */
|
|
428
|
-
declarators: Map<VariableDeclarator, Binding[]>;
|
|
800
|
+
declarators: Map<AST.VariableDeclarator, Binding[]>;
|
|
429
801
|
/** Map of references in this scope */
|
|
430
|
-
references: Map<string, Array<{ node: Identifier; path: Node[] }>>;
|
|
802
|
+
references: Map<string, Array<{ node: AST.Identifier; path: AST.Node[] }>>;
|
|
431
803
|
/** Function nesting depth */
|
|
432
804
|
function_depth: number;
|
|
433
805
|
/** Whether reactive tracing is enabled */
|
|
434
|
-
tracing: null | Expression;
|
|
806
|
+
tracing: null | AST.Expression;
|
|
807
|
+
server_block?: boolean;
|
|
435
808
|
|
|
436
809
|
/** Create child scope */
|
|
437
810
|
child(porous?: boolean): ScopeInterface;
|
|
438
811
|
/** Declare a binding */
|
|
439
812
|
declare(
|
|
440
|
-
node: Identifier,
|
|
813
|
+
node: AST.Identifier,
|
|
441
814
|
kind: BindingKind,
|
|
442
815
|
declaration_kind: DeclarationKind,
|
|
443
|
-
initial?:
|
|
816
|
+
initial?:
|
|
817
|
+
| null
|
|
818
|
+
| AST.Expression
|
|
819
|
+
| AST.FunctionDeclaration
|
|
820
|
+
| AST.ClassDeclaration
|
|
821
|
+
| AST.ImportDeclaration,
|
|
444
822
|
): Binding;
|
|
445
823
|
/** Get binding by name */
|
|
446
824
|
get(name: string): Binding | null;
|
|
447
825
|
/** Get bindings for a declarator */
|
|
448
|
-
get_bindings(node: VariableDeclarator): Binding[];
|
|
826
|
+
get_bindings(node: AST.VariableDeclarator): Binding[];
|
|
449
827
|
/** Find the scope that owns a name */
|
|
450
828
|
owner(name: string): ScopeInterface | null;
|
|
451
829
|
/** Add a reference */
|
|
452
|
-
reference(node: Identifier, path: Node[]): void;
|
|
830
|
+
reference(node: AST.Identifier, path: AST.Node[]): void;
|
|
453
831
|
/** Generate unique identifier name */
|
|
454
832
|
generate(preferred_name: string): string;
|
|
455
833
|
}
|
|
456
834
|
|
|
457
835
|
/**
|
|
458
|
-
*
|
|
836
|
+
* Compiler state object
|
|
459
837
|
*/
|
|
460
|
-
export interface TextNode {
|
|
461
|
-
type: 'Text';
|
|
462
|
-
expression: Expression;
|
|
463
|
-
start?: number;
|
|
464
|
-
end?: number;
|
|
465
|
-
loc?: any;
|
|
466
|
-
}
|
|
467
838
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
839
|
+
interface BaseStateMetaData {
|
|
840
|
+
tracking?: boolean | null;
|
|
841
|
+
await?: boolean;
|
|
842
|
+
}
|
|
472
843
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
*/
|
|
476
|
-
export interface CompilerState {
|
|
477
|
-
/** Current scope */
|
|
844
|
+
export interface BaseState {
|
|
845
|
+
/** For utils */
|
|
478
846
|
scope: ScopeInterface;
|
|
479
|
-
|
|
480
|
-
analysis?: {
|
|
481
|
-
/** Module analysis */
|
|
482
|
-
module?: {
|
|
483
|
-
/** Module scope */
|
|
484
|
-
scope?: {
|
|
485
|
-
/** Module references */
|
|
486
|
-
references?: Set<string>;
|
|
487
|
-
};
|
|
488
|
-
};
|
|
489
|
-
/** Exported identifiers */
|
|
490
|
-
exports?: Array<{ name: string }>;
|
|
491
|
-
};
|
|
492
|
-
/** Scopes map */
|
|
493
|
-
scopes?: Map<RippleNode, ScopeInterface>;
|
|
494
|
-
/** Whether inside head element */
|
|
847
|
+
scopes: Map<AST.Node | AST.Node[], ScopeInterface>;
|
|
495
848
|
inside_head?: boolean;
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
849
|
+
|
|
850
|
+
/** Common For All */
|
|
851
|
+
to_ts: boolean;
|
|
852
|
+
component?: AST.Component;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
export interface AnalysisState extends BaseState {
|
|
856
|
+
analysis: AnalysisResult & {
|
|
857
|
+
module: {
|
|
858
|
+
ast: AnalysisResult['ast'];
|
|
859
|
+
scope: AnalysisResult['scope'];
|
|
860
|
+
scopes: AnalysisResult['scopes'];
|
|
861
|
+
filename: string;
|
|
862
|
+
};
|
|
500
863
|
};
|
|
864
|
+
elements?: AST.Element[];
|
|
865
|
+
function_depth?: number;
|
|
866
|
+
inside_server_block?: boolean;
|
|
867
|
+
loose?: boolean;
|
|
868
|
+
metadata: BaseStateMetaData;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
export interface TransformServerState extends BaseState {
|
|
872
|
+
imports: Set<string>;
|
|
873
|
+
init: Array<AST.Statement> | null;
|
|
874
|
+
stylesheets: AST.CSS.StyleSheet[];
|
|
875
|
+
component_metadata: AnalysisResult['component_metadata'];
|
|
876
|
+
inside_server_block: boolean;
|
|
877
|
+
filename: string;
|
|
878
|
+
metadata: BaseStateMetaData;
|
|
879
|
+
namespace: NameSpace;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
type UpdateList = Array<{
|
|
883
|
+
identity?: AST.Identifier | AST.Expression;
|
|
884
|
+
initial?: AST.Expression;
|
|
885
|
+
operation: (expr?: AST.Expression, prev?: AST.Expression) => AST.ExpressionStatement;
|
|
886
|
+
expression?: AST.Expression;
|
|
887
|
+
needsPrevTracking?: boolean;
|
|
888
|
+
}> & { async?: boolean };
|
|
889
|
+
|
|
890
|
+
export interface TransformClientState extends BaseState {
|
|
891
|
+
events: Set<string>;
|
|
892
|
+
filename: string;
|
|
893
|
+
final: Array<AST.Statement> | null;
|
|
894
|
+
flush_node: ((is_controlled?: boolean) => AST.Identifier) | null;
|
|
895
|
+
hoisted: Array<AST.Statement>;
|
|
896
|
+
imports: Set<string>;
|
|
897
|
+
init: Array<AST.Statement> | null;
|
|
898
|
+
metadata: BaseStateMetaData;
|
|
899
|
+
namespace: NameSpace;
|
|
900
|
+
ripple_user_imports: Map<string, string>;
|
|
901
|
+
setup: Array<AST.Statement> | null;
|
|
902
|
+
stylesheets: Array<AST.CSS.StyleSheet>;
|
|
903
|
+
template: Array<string | AST.Expression> | null;
|
|
904
|
+
update: UpdateList | null;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
/** Override zimmerframe types and provide our own */
|
|
908
|
+
type NodeOf<T extends string, X> = X extends { type: T } ? X : never;
|
|
909
|
+
|
|
910
|
+
type SpecializedVisitors<T extends AST.Node | AST.CSS.Node, U> = {
|
|
911
|
+
[K in T['type']]?: Visitor<NodeOf<K, T>, U, T>;
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
export type Visitor<T, U, V> = (node: T, context: Context<V, U>) => V | void;
|
|
915
|
+
|
|
916
|
+
export type Visitors<T extends AST.Node | AST.CSS.Node, U> = T['type'] extends '_'
|
|
917
|
+
? never
|
|
918
|
+
: SpecializedVisitors<T, U> & { _?: Visitor<T, U, T> };
|
|
919
|
+
|
|
920
|
+
export interface Context<T, U> {
|
|
921
|
+
next: (state?: U) => T | void;
|
|
922
|
+
path: T[];
|
|
923
|
+
state: U;
|
|
924
|
+
stop: () => void;
|
|
925
|
+
visit: (node: T, state?: U) => T;
|
|
501
926
|
}
|
|
502
927
|
|
|
503
928
|
/**
|
|
504
929
|
* Transform context object
|
|
505
930
|
*/
|
|
506
|
-
export
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
/** Visit function */
|
|
512
|
-
visit: (node: any, state?: any) => any;
|
|
513
|
-
/** Transform metadata */
|
|
514
|
-
metadata?: any;
|
|
515
|
-
}
|
|
931
|
+
export type TransformClientContext = Context<AST.Node, TransformClientState>;
|
|
932
|
+
export type TransformServerContext = Context<AST.Node, TransformServerState>;
|
|
933
|
+
export type AnalysisContext = Context<AST.Node, AnalysisState>;
|
|
934
|
+
export type CommonContext = TransformClientContext | TransformServerContext | AnalysisContext;
|
|
935
|
+
export type VisitorClientContext = TransformClientContext & { root?: boolean };
|
|
516
936
|
|
|
517
937
|
/**
|
|
518
938
|
* Delegated event result
|
|
519
939
|
*/
|
|
520
940
|
export interface DelegatedEventResult {
|
|
521
|
-
function?: FunctionExpression | FunctionDeclaration | ArrowFunctionExpression;
|
|
941
|
+
function?: AST.FunctionExpression | AST.FunctionDeclaration | AST.ArrowFunctionExpression;
|
|
522
942
|
}
|