@tsrx/core 0.1.20 → 0.1.24
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 +3 -3
- package/src/analyze/prune.js +117 -70
- package/src/analyze/validation.js +122 -5
- package/src/diagnostics.js +1 -0
- package/src/index.js +10 -4
- package/src/parse/index.js +157 -99
- package/src/plugin.js +2540 -867
- package/src/runtime/html.js +1 -1
- package/src/runtime/iterable.js +15 -13
- package/src/runtime/language-helpers.js +39 -0
- package/src/scope.js +25 -10
- package/src/source-map-utils.js +1 -1
- package/src/transform/await.js +5 -1
- package/src/transform/jsx/ast-builders.js +6 -81
- package/src/transform/jsx/helpers.js +8 -5
- package/src/transform/jsx/index.js +1440 -451
- package/src/transform/jsx-interleave.js +1 -2
- package/src/transform/scoping.js +26 -63
- package/src/transform/segments.js +66 -48
- package/src/transform/style-ref.js +3 -11
- package/src/utils/builders.js +2 -3
- package/types/index.d.ts +181 -115
- package/types/jsx-platform.d.ts +14 -11
- package/types/parse.d.ts +36 -10
- package/types/runtime/html.d.ts +1 -0
- package/types/runtime/language-helpers.d.ts +4 -0
- package/types/runtime/ref.d.ts +1 -0
package/types/index.d.ts
CHANGED
|
@@ -59,7 +59,6 @@ export interface CompileOptions {
|
|
|
59
59
|
minify_css?: boolean;
|
|
60
60
|
dev?: boolean;
|
|
61
61
|
hmr?: boolean;
|
|
62
|
-
compat_kinds?: string[];
|
|
63
62
|
/**
|
|
64
63
|
* When true, non-fatal errors are collected on the result's `errors`
|
|
65
64
|
* array instead of being thrown. Defaults to false (strict mode: throws).
|
|
@@ -83,6 +82,20 @@ interface BaseNodeMetaData {
|
|
|
83
82
|
is_capitalized?: boolean;
|
|
84
83
|
commentContainerId?: number;
|
|
85
84
|
parenthesized?: boolean;
|
|
85
|
+
native_tsrx?: boolean;
|
|
86
|
+
native_tsrx_template_block?: boolean;
|
|
87
|
+
runtime_dynamic_element?: boolean;
|
|
88
|
+
templateMode?: 'script' | 'template';
|
|
89
|
+
script_only?: boolean;
|
|
90
|
+
tsrxDirective?: 'if' | 'for' | 'switch' | 'try';
|
|
91
|
+
ts_name?: string;
|
|
92
|
+
delegated?: any;
|
|
93
|
+
returned_tsrx_return?: AST.ReturnStatement;
|
|
94
|
+
styleScopeHash?: string;
|
|
95
|
+
css?: {
|
|
96
|
+
scopedClasses: Map<string, { start: number; end: number; selector: any }>;
|
|
97
|
+
hash: string;
|
|
98
|
+
};
|
|
86
99
|
elementLeadingComments?: AST.Comment[];
|
|
87
100
|
returns?: AST.ReturnStatement[];
|
|
88
101
|
has_return?: boolean;
|
|
@@ -93,6 +106,7 @@ interface BaseNodeMetaData {
|
|
|
93
106
|
regular_js?: boolean;
|
|
94
107
|
returned_tsrx_child?: boolean;
|
|
95
108
|
forceMapping?: boolean;
|
|
109
|
+
generated_loop_skip_if?: boolean;
|
|
96
110
|
lazy_id?: string;
|
|
97
111
|
disable_verification?: boolean;
|
|
98
112
|
lazy_param_binding_mappings?: Array<{
|
|
@@ -171,6 +185,8 @@ declare module 'estree' {
|
|
|
171
185
|
metadata: BaseNodeMetaData & {
|
|
172
186
|
hook_split_block?: boolean;
|
|
173
187
|
native_return_block?: boolean;
|
|
188
|
+
native_tsrx_template_block?: boolean;
|
|
189
|
+
allows_native_return?: boolean;
|
|
174
190
|
};
|
|
175
191
|
}
|
|
176
192
|
|
|
@@ -216,8 +232,7 @@ declare module 'estree' {
|
|
|
216
232
|
lazy?: boolean;
|
|
217
233
|
}
|
|
218
234
|
|
|
219
|
-
//
|
|
220
|
-
// Otherwise, we only mark Identifier nodes
|
|
235
|
+
// Ripple analysis may mark a whole member expression as tracked metadata.
|
|
221
236
|
interface MemberExpression {
|
|
222
237
|
tracked?: boolean;
|
|
223
238
|
}
|
|
@@ -236,26 +251,175 @@ declare module 'estree' {
|
|
|
236
251
|
|
|
237
252
|
// Include TypeScript node types and TSRX-specific nodes in NodeMap
|
|
238
253
|
interface NodeMap {
|
|
254
|
+
Element: Element;
|
|
239
255
|
TsrxFragment: TsrxFragment;
|
|
240
|
-
|
|
256
|
+
Text: Text;
|
|
257
|
+
TSRXJSXElement: TSRXJSXElement;
|
|
241
258
|
TSRXExpression: TSRXExpression;
|
|
242
|
-
Element: Element;
|
|
243
|
-
Text: TextNode;
|
|
244
259
|
Attribute: Attribute;
|
|
245
260
|
SpreadAttribute: SpreadAttribute;
|
|
261
|
+
JSXCodeBlock: JSXCodeBlock;
|
|
262
|
+
JSXStyleElement: JSXStyleElement;
|
|
263
|
+
JSXIfExpression: JSXIfExpression;
|
|
264
|
+
JSXForExpression: JSXForExpression;
|
|
265
|
+
JSXSwitchExpression: JSXSwitchExpression;
|
|
266
|
+
JSXTryExpression: JSXTryExpression;
|
|
246
267
|
ParenthesizedExpression: ParenthesizedExpression;
|
|
247
|
-
ScriptContent: ScriptContent;
|
|
248
268
|
}
|
|
249
269
|
|
|
250
270
|
interface ExpressionMap {
|
|
271
|
+
Element: Element;
|
|
251
272
|
TsrxFragment: TsrxFragment;
|
|
252
|
-
Text:
|
|
273
|
+
Text: Text;
|
|
274
|
+
TSRXExpression: TSRXExpression;
|
|
275
|
+
JSXCodeBlock: JSXCodeBlock;
|
|
276
|
+
JSXStyleElement: JSXStyleElement;
|
|
277
|
+
JSXIfExpression: JSXIfExpression;
|
|
278
|
+
JSXForExpression: JSXForExpression;
|
|
279
|
+
JSXSwitchExpression: JSXSwitchExpression;
|
|
280
|
+
JSXTryExpression: JSXTryExpression;
|
|
253
281
|
JSXEmptyExpression: ESTreeJSX.JSXEmptyExpression;
|
|
254
282
|
ParenthesizedExpression: ParenthesizedExpression;
|
|
255
283
|
TSAsExpression: TSAsExpression;
|
|
256
284
|
}
|
|
257
285
|
|
|
258
|
-
//
|
|
286
|
+
// Ripple-normalized template node shapes. The core parser emits JSX-shaped
|
|
287
|
+
// TSRX nodes; @tsrx/ripple creates these during its normalization pass.
|
|
288
|
+
interface Attribute extends AST.BaseNode {
|
|
289
|
+
type: 'Attribute';
|
|
290
|
+
name: AST.Identifier;
|
|
291
|
+
value: any;
|
|
292
|
+
shorthand?: boolean;
|
|
293
|
+
metadata: BaseNodeMetaData;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
interface SpreadAttribute extends AST.BaseNode {
|
|
297
|
+
type: 'SpreadAttribute';
|
|
298
|
+
argument: AST.Expression;
|
|
299
|
+
metadata: BaseNodeMetaData;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface Element extends AST.BaseExpression {
|
|
303
|
+
type: 'Element';
|
|
304
|
+
id: AST.Identifier | AST.MemberExpression | AST.Literal;
|
|
305
|
+
attributes: Array<Attribute | SpreadAttribute>;
|
|
306
|
+
children: AST.Node[];
|
|
307
|
+
openingElement: ESTreeJSX.JSXOpeningElement;
|
|
308
|
+
closingElement: ESTreeJSX.JSXClosingElement | null;
|
|
309
|
+
selfClosing?: boolean;
|
|
310
|
+
unclosed?: boolean;
|
|
311
|
+
css?: string;
|
|
312
|
+
metadata: BaseNodeMetaData;
|
|
313
|
+
start: number;
|
|
314
|
+
end: number;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
interface TsrxFragment extends AST.BaseExpression {
|
|
318
|
+
type: 'TsrxFragment';
|
|
319
|
+
children: AST.Node[];
|
|
320
|
+
openingElement?: ESTreeJSX.JSXOpeningFragment;
|
|
321
|
+
closingElement?: ESTreeJSX.JSXClosingFragment | null;
|
|
322
|
+
selfClosing?: boolean;
|
|
323
|
+
attributes?: Array<Attribute | SpreadAttribute>;
|
|
324
|
+
metadata: BaseNodeMetaData;
|
|
325
|
+
start: number;
|
|
326
|
+
end: number;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
interface Text extends AST.BaseExpression {
|
|
330
|
+
type: 'Text';
|
|
331
|
+
expression: AST.Expression;
|
|
332
|
+
metadata: BaseNodeMetaData;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
interface TSRXExpression extends AST.BaseExpression {
|
|
336
|
+
type: 'TSRXExpression';
|
|
337
|
+
expression: AST.Expression;
|
|
338
|
+
metadata: BaseNodeMetaData;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
type TSRXJSXChild =
|
|
342
|
+
| ESTreeJSX.JSXText
|
|
343
|
+
| ESTreeJSX.JSXExpressionContainer
|
|
344
|
+
| ESTreeJSX.JSXSpreadChild
|
|
345
|
+
| TSRXJSXElement
|
|
346
|
+
| TSRXJSXFragment
|
|
347
|
+
| AST.JSXCodeBlock;
|
|
348
|
+
|
|
349
|
+
interface TSRXJSXElement
|
|
350
|
+
extends Omit<ESTreeJSX.JSXElement, 'children'>, AST.NodeWithMaybeComments {
|
|
351
|
+
children: TSRXJSXChild[];
|
|
352
|
+
metadata: BaseNodeMetaData & {
|
|
353
|
+
ts_name?: string;
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
interface TSRXJSXFragment
|
|
358
|
+
extends Omit<ESTreeJSX.JSXFragment, 'children'>, AST.NodeWithMaybeComments {
|
|
359
|
+
children: TSRXJSXChild[];
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
interface JSXCodeBlock extends AST.BaseExpression {
|
|
363
|
+
type: 'JSXCodeBlock';
|
|
364
|
+
body: AST.Statement[];
|
|
365
|
+
render: AST.Node | null;
|
|
366
|
+
metadata: BaseNodeMetaData;
|
|
367
|
+
innerComments?: AST.Comment[] | undefined;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
interface JSXStyleElement extends AST.BaseExpression {
|
|
371
|
+
type: 'JSXStyleElement';
|
|
372
|
+
openingElement: ESTreeJSX.JSXOpeningElement;
|
|
373
|
+
closingElement: ESTreeJSX.JSXClosingElement | null;
|
|
374
|
+
children: AST.CSS.StyleSheet[];
|
|
375
|
+
css?: string;
|
|
376
|
+
metadata: BaseNodeMetaData;
|
|
377
|
+
unclosed?: boolean;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
interface JSXIfExpression extends AST.BaseExpression {
|
|
381
|
+
type: 'JSXIfExpression';
|
|
382
|
+
statementType: 'IfStatement';
|
|
383
|
+
test: AST.Expression;
|
|
384
|
+
consequent: AST.Statement;
|
|
385
|
+
alternate: AST.Statement | null;
|
|
386
|
+
metadata: BaseNodeMetaData;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
interface JSXForExpression extends AST.BaseExpression {
|
|
390
|
+
type: 'JSXForExpression';
|
|
391
|
+
statementType: 'ForStatement' | 'ForInStatement' | 'ForOfStatement';
|
|
392
|
+
body: AST.Statement;
|
|
393
|
+
init?: AST.VariableDeclaration | AST.Expression | null;
|
|
394
|
+
test?: AST.Expression | null;
|
|
395
|
+
update?: AST.Expression | null;
|
|
396
|
+
left?: AST.VariableDeclaration | AST.Pattern;
|
|
397
|
+
right?: AST.Expression;
|
|
398
|
+
await?: boolean;
|
|
399
|
+
index?: AST.Identifier | null;
|
|
400
|
+
key?: AST.Expression | null;
|
|
401
|
+
empty?: AST.BlockStatement | null;
|
|
402
|
+
metadata: BaseNodeMetaData;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
interface JSXSwitchExpression extends AST.BaseExpression {
|
|
406
|
+
type: 'JSXSwitchExpression';
|
|
407
|
+
statementType: 'SwitchStatement';
|
|
408
|
+
discriminant: AST.Expression;
|
|
409
|
+
cases: AST.SwitchCase[];
|
|
410
|
+
metadata: BaseNodeMetaData;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
interface JSXTryExpression extends AST.BaseExpression {
|
|
414
|
+
type: 'JSXTryExpression';
|
|
415
|
+
statementType: 'TryStatement';
|
|
416
|
+
block: AST.BlockStatement;
|
|
417
|
+
handler: AST.CatchClause | null;
|
|
418
|
+
finalizer: AST.BlockStatement | null;
|
|
419
|
+
pending?: AST.BlockStatement | null;
|
|
420
|
+
metadata: BaseNodeMetaData;
|
|
421
|
+
}
|
|
422
|
+
|
|
259
423
|
interface ParenthesizedExpression extends AST.BaseNode {
|
|
260
424
|
type: 'ParenthesizedExpression';
|
|
261
425
|
expression: AST.Expression;
|
|
@@ -293,6 +457,7 @@ declare module 'estree' {
|
|
|
293
457
|
interface ForOfStatement {
|
|
294
458
|
index?: AST.Identifier | null;
|
|
295
459
|
key?: AST.Expression | null;
|
|
460
|
+
empty?: AST.BlockStatement | null;
|
|
296
461
|
}
|
|
297
462
|
|
|
298
463
|
interface ImportDeclaration {
|
|
@@ -344,99 +509,7 @@ declare module 'estree' {
|
|
|
344
509
|
trailingComments?: AST.Comment[] | undefined;
|
|
345
510
|
}
|
|
346
511
|
|
|
347
|
-
|
|
348
|
-
type: 'TsrxFragment';
|
|
349
|
-
attributes: Array<any>;
|
|
350
|
-
children: AST.Node[];
|
|
351
|
-
selfClosing?: boolean;
|
|
352
|
-
unclosed?: boolean;
|
|
353
|
-
openingElement: ESTreeJSX.JSXOpeningElement;
|
|
354
|
-
closingElement: ESTreeJSX.JSXClosingElement;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
interface TsxCompat extends AST.BaseNode {
|
|
358
|
-
type: 'TsxCompat';
|
|
359
|
-
kind: string;
|
|
360
|
-
attributes: Array<any>;
|
|
361
|
-
children: ESTreeJSX.JSXElement['children'];
|
|
362
|
-
selfClosing?: boolean;
|
|
363
|
-
unclosed?: boolean;
|
|
364
|
-
openingElement: ESTreeJSX.JSXOpeningElement;
|
|
365
|
-
closingElement: ESTreeJSX.JSXClosingElement;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
export interface TSRXExpression extends AST.BaseExpression {
|
|
369
|
-
type: 'TSRXExpression';
|
|
370
|
-
expression: AST.Expression;
|
|
371
|
-
loc?: AST.SourceLocation;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
interface Element extends AST.BaseNode {
|
|
375
|
-
type: 'Element';
|
|
376
|
-
// MemberExpression for namespaced or dynamic elements
|
|
377
|
-
id: AST.Identifier | AST.MemberExpression;
|
|
378
|
-
attributes: TSRXAttribute[];
|
|
379
|
-
children: AST.Node[];
|
|
380
|
-
selfClosing?: boolean;
|
|
381
|
-
unclosed?: boolean;
|
|
382
|
-
loc: SourceLocation;
|
|
383
|
-
metadata: BaseNodeMetaData & {
|
|
384
|
-
ts_name?: string;
|
|
385
|
-
// for <style> tag
|
|
386
|
-
styleScopeHash?: string;
|
|
387
|
-
// for elements with scoped style classes
|
|
388
|
-
css?: {
|
|
389
|
-
scopedClasses: Map<
|
|
390
|
-
string,
|
|
391
|
-
{
|
|
392
|
-
start: number;
|
|
393
|
-
end: number;
|
|
394
|
-
selector: CSS.ClassSelector;
|
|
395
|
-
}
|
|
396
|
-
>;
|
|
397
|
-
hash: string;
|
|
398
|
-
};
|
|
399
|
-
};
|
|
400
|
-
openingElement: ESTreeJSX.JSXOpeningElement;
|
|
401
|
-
closingElement: ESTreeJSX.JSXClosingElement;
|
|
402
|
-
// for <style> tags
|
|
403
|
-
css?: string;
|
|
404
|
-
innerComments?: Comment[];
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
export interface TextNode extends AST.BaseExpression {
|
|
408
|
-
type: 'Text';
|
|
409
|
-
expression: AST.Expression;
|
|
410
|
-
raw?: string;
|
|
411
|
-
loc?: AST.SourceLocation;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
interface ScriptContent extends Omit<AST.Element, 'type'> {
|
|
415
|
-
type: 'ScriptContent';
|
|
416
|
-
content: string;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* TSRX attribute nodes
|
|
421
|
-
*/
|
|
422
|
-
interface Attribute extends AST.BaseNode {
|
|
423
|
-
type: 'Attribute';
|
|
424
|
-
name: AST.Identifier;
|
|
425
|
-
value: AST.Expression | null;
|
|
426
|
-
loc?: AST.SourceLocation;
|
|
427
|
-
shorthand?: boolean;
|
|
428
|
-
metadata: BaseNodeMetaData & {
|
|
429
|
-
delegated?: boolean;
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
interface SpreadAttribute extends AST.BaseNode {
|
|
434
|
-
type: 'SpreadAttribute';
|
|
435
|
-
argument: AST.Expression;
|
|
436
|
-
loc?: AST.SourceLocation;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
export type TSRXDeclaration = AST.Declaration | AST.TSDeclareFunction;
|
|
512
|
+
type TSRXDeclaration = AST.Declaration | AST.TSDeclareFunction;
|
|
440
513
|
|
|
441
514
|
interface TSRXExportNamedDeclaration extends Omit<AST.ExportNamedDeclaration, 'declaration'> {
|
|
442
515
|
declaration?: TSRXDeclaration | null | undefined;
|
|
@@ -446,11 +519,9 @@ declare module 'estree' {
|
|
|
446
519
|
body: (Program['body'][number] | FunctionExpression)[];
|
|
447
520
|
}
|
|
448
521
|
|
|
449
|
-
|
|
522
|
+
type TSRXStatement = AST.Statement | TSESTree.Statement;
|
|
450
523
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
export type NodeWithChildren = AST.Element | AST.TsrxFragment | AST.TsxCompat;
|
|
524
|
+
type NodeWithChildren = TSRXJSXElement | TSRXJSXFragment | JSXStyleElement;
|
|
454
525
|
|
|
455
526
|
export namespace CSS {
|
|
456
527
|
export interface BaseNode extends AST.NodeWithMaybeComments {
|
|
@@ -629,7 +700,6 @@ declare module 'estree-jsx' {
|
|
|
629
700
|
}
|
|
630
701
|
|
|
631
702
|
interface JSXIdentifier {
|
|
632
|
-
tracked?: boolean;
|
|
633
703
|
metadata: BaseNodeMetaData & {
|
|
634
704
|
is_component?: boolean;
|
|
635
705
|
};
|
|
@@ -1132,8 +1202,7 @@ export interface ParseOptions {
|
|
|
1132
1202
|
/**
|
|
1133
1203
|
* Analyze options
|
|
1134
1204
|
*/
|
|
1135
|
-
export interface AnalyzeOptions
|
|
1136
|
-
extends ParseOptions, Pick<CompileOptions, 'mode' | 'compat_kinds'> {
|
|
1205
|
+
export interface AnalyzeOptions extends ParseOptions, Pick<CompileOptions, 'mode'> {
|
|
1137
1206
|
errors?: CompileError[];
|
|
1138
1207
|
to_ts?: boolean;
|
|
1139
1208
|
}
|
|
@@ -1211,7 +1280,7 @@ export interface Binding {
|
|
|
1211
1280
|
| AST.ClassDeclaration
|
|
1212
1281
|
| AST.ImportDeclaration
|
|
1213
1282
|
| AST.TSModuleDeclaration
|
|
1214
|
-
|
|
|
1283
|
+
| ESTreeJSX.JSXFragment;
|
|
1215
1284
|
/** Whether this binding has been reassigned */
|
|
1216
1285
|
reassigned: boolean;
|
|
1217
1286
|
/** Whether this binding has been mutated (property access) */
|
|
@@ -1222,7 +1291,6 @@ export interface Binding {
|
|
|
1222
1291
|
is_called: boolean;
|
|
1223
1292
|
/** Additional metadata for this binding */
|
|
1224
1293
|
metadata: {
|
|
1225
|
-
is_dynamic_component?: boolean;
|
|
1226
1294
|
pattern?: AST.Identifier;
|
|
1227
1295
|
is_ripple_object?: boolean;
|
|
1228
1296
|
is_template_value?: boolean;
|
|
@@ -1311,7 +1379,7 @@ export interface ScopeInterface {
|
|
|
1311
1379
|
| AST.ClassDeclaration
|
|
1312
1380
|
| AST.ImportDeclaration
|
|
1313
1381
|
| AST.TSModuleDeclaration
|
|
1314
|
-
|
|
|
1382
|
+
| ESTreeJSX.JSXFragment,
|
|
1315
1383
|
): Binding;
|
|
1316
1384
|
/** Get binding by name */
|
|
1317
1385
|
get(name: string): Binding | null;
|
|
@@ -1356,10 +1424,9 @@ export interface AnalysisState extends BaseState {
|
|
|
1356
1424
|
filename: string;
|
|
1357
1425
|
};
|
|
1358
1426
|
};
|
|
1359
|
-
elements?: AST.Element
|
|
1427
|
+
elements?: Array<ESTreeJSX.JSXElement | AST.Element>;
|
|
1360
1428
|
function_depth?: number;
|
|
1361
1429
|
collect?: boolean;
|
|
1362
|
-
configured_compat_kinds?: Set<string>;
|
|
1363
1430
|
metadata: BaseStateMetaData & {
|
|
1364
1431
|
styleClasses?: StyleClasses;
|
|
1365
1432
|
};
|
|
@@ -1381,7 +1448,6 @@ export interface TransformServerState extends BaseState {
|
|
|
1381
1448
|
namespace: NameSpace;
|
|
1382
1449
|
server_block_locals: AST.VariableDeclaration[];
|
|
1383
1450
|
server_exported_names: string[];
|
|
1384
|
-
dynamicElementName?: AST.TemplateLiteral;
|
|
1385
1451
|
applyParentCssScope?: AST.CSS.StyleSheet['hash'];
|
|
1386
1452
|
dev?: boolean;
|
|
1387
1453
|
return_flags?: Map<AST.ReturnStatement, { name: string; tracked: boolean }>;
|
package/types/jsx-platform.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export interface JsxTransformContext {
|
|
|
53
53
|
hook_helpers_enabled: boolean;
|
|
54
54
|
available_bindings: Map<string, AST.Identifier>;
|
|
55
55
|
lazy_next_id: number;
|
|
56
|
+
/** Scope map used to resolve runtime Dynamic imports for scoped CSS pruning. */
|
|
57
|
+
runtime_dynamic_scopes: Map<any, any> | null;
|
|
56
58
|
inside_element_child?: boolean;
|
|
57
59
|
/** Full source text for source-aware diagnostics. */
|
|
58
60
|
source: string;
|
|
@@ -197,7 +199,7 @@ export interface JsxPlatformHooks {
|
|
|
197
199
|
renderForOf?: (node: any, loopParams: any[], bodyStatements: any[], ctx: any) => any | null;
|
|
198
200
|
/**
|
|
199
201
|
* Optionally replace the default React-style pending lowering for
|
|
200
|
-
*
|
|
202
|
+
* `@try { ... } @pending { ... }`. The default emits
|
|
201
203
|
* `<Suspense fallback={fallbackContent}>tryContent</Suspense>`.
|
|
202
204
|
* Vue Vapor uses this to provide `default` and `fallback` slots via
|
|
203
205
|
* `v-slots`.
|
|
@@ -241,11 +243,11 @@ export interface JsxPlatformHooks {
|
|
|
241
243
|
*/
|
|
242
244
|
createErrorBoundaryContent?: (tryContent: any, ctx: any, node: any) => any | null;
|
|
243
245
|
/**
|
|
244
|
-
*
|
|
246
|
+
* Customize lowering for a native JSX element. Default is the
|
|
245
247
|
* factory's `to_jsx_element`. The hook receives the walker-transformed
|
|
246
248
|
* node (`inner`, with children already lowered) plus the element's
|
|
247
249
|
* raw pre-walk children — Solid uses the latter to detect a lone
|
|
248
|
-
* `
|
|
250
|
+
* `JSXText` child it can hoist to a `textContent` attribute before the
|
|
249
251
|
* generic text→JSXExpressionContainer transform runs.
|
|
250
252
|
*/
|
|
251
253
|
transformElement?: (inner: any, ctx: any, rawChildren: any[]) => any;
|
|
@@ -314,12 +316,18 @@ export interface JsxPlatform {
|
|
|
314
316
|
*/
|
|
315
317
|
fragment?: string;
|
|
316
318
|
/**
|
|
317
|
-
* Module to import `Suspense` from when
|
|
319
|
+
* Module to import `Suspense` from when an `@try { ... } @pending { ... }`
|
|
318
320
|
* block appears. React: `'react'`. Preact: `'preact/compat'`.
|
|
319
321
|
*/
|
|
320
322
|
suspense: string;
|
|
321
323
|
/**
|
|
322
|
-
* Module
|
|
324
|
+
* Module that exports the target runtime `Dynamic` component. When set,
|
|
325
|
+
* the shared JSX transform treats imported `Dynamic` elements with an
|
|
326
|
+
* `is` prop as runtime-dynamic for scoped CSS pruning.
|
|
327
|
+
*/
|
|
328
|
+
dynamic?: string;
|
|
329
|
+
/**
|
|
330
|
+
* Module to import `TsrxErrorBoundary` from when an `@try { ... } @catch (...)`
|
|
323
331
|
* block appears. Usually `'@tsrx/<platform>/error-boundary'`.
|
|
324
332
|
*/
|
|
325
333
|
errorBoundary: string;
|
|
@@ -357,11 +365,6 @@ export interface JsxPlatform {
|
|
|
357
365
|
* not rewrite authored attributes.
|
|
358
366
|
*/
|
|
359
367
|
classAttrName?: 'class' | 'className';
|
|
360
|
-
/**
|
|
361
|
-
* Accepted values of `kind` in `<tsx:kind>` compat blocks. React accepts
|
|
362
|
-
* only `'react'`. Preact accepts both `'preact'` and `'react'`.
|
|
363
|
-
*/
|
|
364
|
-
acceptedTsxKinds: readonly string[];
|
|
365
368
|
/**
|
|
366
369
|
* How to collapse multiple `ref` attributes on the same element into
|
|
367
370
|
* one. React's and Preact's runtimes treat duplicate `ref` props as
|
|
@@ -408,7 +411,7 @@ export interface JsxPlatform {
|
|
|
408
411
|
scanUseServerDirectiveForAwaitWithCustomValidator?: boolean;
|
|
409
412
|
/**
|
|
410
413
|
* Optional branded compiler error for targets that cannot lower
|
|
411
|
-
*
|
|
414
|
+
* `@try { ... } @pending { ... }` in component template context.
|
|
412
415
|
*
|
|
413
416
|
* When provided, the shared try-block lowering rejects any `pending`
|
|
414
417
|
* block with this message instead of emitting a React-style
|
package/types/parse.d.ts
CHANGED
|
@@ -422,6 +422,11 @@ export namespace Parse {
|
|
|
422
422
|
tokContexts: AcornTypeScriptTokContexts;
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
+
export interface AcornTypeScriptFunctionBodyConfig {
|
|
426
|
+
isFunctionDeclaration?: boolean | number;
|
|
427
|
+
isClassMethod?: boolean;
|
|
428
|
+
}
|
|
429
|
+
|
|
425
430
|
interface Scope {
|
|
426
431
|
flags: number;
|
|
427
432
|
var: string[];
|
|
@@ -489,6 +494,8 @@ export namespace Parse {
|
|
|
489
494
|
inAsync: boolean;
|
|
490
495
|
/** Whether we're inside a function */
|
|
491
496
|
inFunction: boolean;
|
|
497
|
+
/** Whether @sveltejs/acorn-typescript is currently parsing a TypeScript type */
|
|
498
|
+
inType: boolean;
|
|
492
499
|
/** Stack of label names for break/continue statements */
|
|
493
500
|
labels: Array<{ kind: string | null; name?: string; statementStart?: number }>;
|
|
494
501
|
/** Current scope flags stack */
|
|
@@ -600,6 +607,12 @@ export namespace Parse {
|
|
|
600
607
|
*/
|
|
601
608
|
getTokenFromCode(code: number): void;
|
|
602
609
|
|
|
610
|
+
/**
|
|
611
|
+
* Get token from character code while in a TypeScript type context
|
|
612
|
+
* Added by @sveltejs/acorn-typescript
|
|
613
|
+
*/
|
|
614
|
+
getTokenFromCodeInType(code: number): void;
|
|
615
|
+
|
|
603
616
|
/**
|
|
604
617
|
* Get current position as Position object
|
|
605
618
|
* @returns { line: number, column: number, index: number }
|
|
@@ -1116,6 +1129,16 @@ export namespace Parse {
|
|
|
1116
1129
|
|
|
1117
1130
|
tsCheckTypeAnnotationForReadOnly(node: AST.TSTypeOperator): void;
|
|
1118
1131
|
|
|
1132
|
+
/**
|
|
1133
|
+
* Run a parser callback with @sveltejs/acorn-typescript's type-context flag enabled
|
|
1134
|
+
*/
|
|
1135
|
+
tsInType<T>(cb: () => T): T;
|
|
1136
|
+
|
|
1137
|
+
/**
|
|
1138
|
+
* Parse a TypeScript return type or type predicate annotation
|
|
1139
|
+
*/
|
|
1140
|
+
tsParseTypeOrTypePredicateAnnotation(returnToken: TokenType): AST.TSTypeAnnotation;
|
|
1141
|
+
|
|
1119
1142
|
tsParseTypeArguments(): AST.Node;
|
|
1120
1143
|
|
|
1121
1144
|
tsTryParseTypeAnnotation(): AST.TSTypeAnnotation;
|
|
@@ -1172,9 +1195,7 @@ export namespace Parse {
|
|
|
1172
1195
|
*/
|
|
1173
1196
|
parseTopLevel(node: AST.Program): AST.Program;
|
|
1174
1197
|
|
|
1175
|
-
parseElement():
|
|
1176
|
-
|
|
1177
|
-
parseDoubleQuotedTextChild(): AST.TextNode;
|
|
1198
|
+
parseElement(): ESTreeJSX.JSXElement | ESTreeJSX.JSXFragment | AST.JSXStyleElement;
|
|
1178
1199
|
|
|
1179
1200
|
parseTemplateBody(
|
|
1180
1201
|
body: (AST.Statement | AST.Node | ESTreeJSX.JSXText | ESTreeJSX.JSXElement['children'])[],
|
|
@@ -1192,10 +1213,11 @@ export namespace Parse {
|
|
|
1192
1213
|
topLevel?: boolean,
|
|
1193
1214
|
exports?: AST.ExportSpecifier,
|
|
1194
1215
|
):
|
|
1195
|
-
| AST.TSRXExpression
|
|
1196
|
-
| AST.TextNode
|
|
1197
|
-
| ESTreeJSX.JSXEmptyExpression
|
|
1198
1216
|
| ESTreeJSX.JSXExpressionContainer
|
|
1217
|
+
| ESTreeJSX.JSXElement
|
|
1218
|
+
| ESTreeJSX.JSXFragment
|
|
1219
|
+
| AST.JSXStyleElement
|
|
1220
|
+
| ESTreeJSX.JSXText
|
|
1199
1221
|
| AST.ExpressionStatement
|
|
1200
1222
|
| ReturnType<Parser['parseElement']>
|
|
1201
1223
|
| AST.Statement;
|
|
@@ -1351,11 +1373,15 @@ export namespace Parse {
|
|
|
1351
1373
|
* Parse function body
|
|
1352
1374
|
*/
|
|
1353
1375
|
parseFunctionBody(
|
|
1354
|
-
node: AST.
|
|
1376
|
+
node: AST.FunctionDeclaration | AST.FunctionExpression | AST.ArrowFunctionExpression,
|
|
1355
1377
|
isArrowFunction: boolean,
|
|
1356
1378
|
isMethod: boolean,
|
|
1357
1379
|
forInit?: ForInit,
|
|
1358
|
-
|
|
1380
|
+
tsConfig?: AcornTypeScriptFunctionBodyConfig,
|
|
1381
|
+
): AST.Node;
|
|
1382
|
+
|
|
1383
|
+
/** Check function parameters for duplicate names and invalid bindings */
|
|
1384
|
+
checkParams(node: AST.Node, allowDuplicates: boolean): void;
|
|
1359
1385
|
|
|
1360
1386
|
/** Initialize function node properties */
|
|
1361
1387
|
initFunction(node: AST.Node): void;
|
|
@@ -1627,7 +1653,7 @@ export namespace Parse {
|
|
|
1627
1653
|
* Parse JSX attribute (name="value" or {spread})
|
|
1628
1654
|
* @returns JSXAttribute or JSXSpreadAttribute
|
|
1629
1655
|
*/
|
|
1630
|
-
jsx_parseAttribute():
|
|
1656
|
+
jsx_parseAttribute(): ESTreeJSX.JSXAttribute | ESTreeJSX.JSXSpreadAttribute;
|
|
1631
1657
|
|
|
1632
1658
|
/**
|
|
1633
1659
|
* Parse JSX opening element at position
|
|
@@ -1670,7 +1696,7 @@ export namespace Parse {
|
|
|
1670
1696
|
* Parse complete JSX element
|
|
1671
1697
|
* @returns JSXElement or JSXFragment
|
|
1672
1698
|
*/
|
|
1673
|
-
jsx_parseElement(): ESTreeJSX.JSXElement;
|
|
1699
|
+
jsx_parseElement(): ESTreeJSX.JSXElement | AST.JSXStyleElement;
|
|
1674
1700
|
|
|
1675
1701
|
// ============================================================
|
|
1676
1702
|
// Try-Parse for Recovery
|
package/types/runtime/html.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export function escape<V>(value: V, is_attr?: boolean): string;
|
|
2
2
|
export function escape_script(str: string): string;
|
|
3
3
|
export function is_boolean_attribute(name: string): boolean;
|
|
4
|
+
export function is_void_element(name: string): boolean;
|
|
4
5
|
export function normalize_css_property_name(str: string): string;
|
|
@@ -19,3 +19,7 @@ export function iterable_array_from<T>(
|
|
|
19
19
|
iterable: Iterable<T> | Iterator<T> | ArrayLike<T>,
|
|
20
20
|
index?: number,
|
|
21
21
|
): T[];
|
|
22
|
+
export function exclude_prop_from_object(
|
|
23
|
+
props: Record<PropertyKey, any> | null | undefined,
|
|
24
|
+
exclude_prop: PropertyKey,
|
|
25
|
+
): Record<PropertyKey, any>;
|
package/types/runtime/ref.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type MergeableVueRef<T> = { value: T | null };
|
|
|
6
6
|
export type RefProp<T = unknown> = (node: T | null) => void | (() => void);
|
|
7
7
|
export type RefValue<T = Element> =
|
|
8
8
|
| ((node: T) => void | (() => void))
|
|
9
|
+
| readonly RefValue<T>[]
|
|
9
10
|
| { current: T | null }
|
|
10
11
|
| { value: T | null }
|
|
11
12
|
| T
|