@tsrx/core 0.1.20 → 0.1.22
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 +119 -61
- package/src/analyze/validation.js +122 -5
- package/src/index.js +11 -3
- package/src/parse/index.js +157 -99
- package/src/plugin.js +2417 -844
- package/src/runtime/iterable.js +15 -13
- 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 +44 -59
- package/src/transform/jsx/helpers.js +8 -5
- package/src/transform/jsx/index.js +755 -344
- package/src/transform/jsx-interleave.js +1 -2
- package/src/transform/scoping.js +26 -63
- package/src/transform/segments.js +53 -5
- package/src/transform/style-ref.js +3 -11
- package/src/utils/builders.js +2 -3
- package/types/index.d.ts +179 -110
- package/types/jsx-platform.d.ts +6 -11
- package/types/parse.d.ts +36 -10
- 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,19 @@ 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
|
+
templateMode?: 'script' | 'template';
|
|
88
|
+
script_only?: boolean;
|
|
89
|
+
tsrxDirective?: 'if' | 'for' | 'switch' | 'try';
|
|
90
|
+
ts_name?: string;
|
|
91
|
+
delegated?: any;
|
|
92
|
+
returned_tsrx_return?: AST.ReturnStatement;
|
|
93
|
+
styleScopeHash?: string;
|
|
94
|
+
css?: {
|
|
95
|
+
scopedClasses: Map<string, { start: number; end: number; selector: any }>;
|
|
96
|
+
hash: string;
|
|
97
|
+
};
|
|
86
98
|
elementLeadingComments?: AST.Comment[];
|
|
87
99
|
returns?: AST.ReturnStatement[];
|
|
88
100
|
has_return?: boolean;
|
|
@@ -93,6 +105,7 @@ interface BaseNodeMetaData {
|
|
|
93
105
|
regular_js?: boolean;
|
|
94
106
|
returned_tsrx_child?: boolean;
|
|
95
107
|
forceMapping?: boolean;
|
|
108
|
+
generated_loop_skip_if?: boolean;
|
|
96
109
|
lazy_id?: string;
|
|
97
110
|
disable_verification?: boolean;
|
|
98
111
|
lazy_param_binding_mappings?: Array<{
|
|
@@ -171,6 +184,8 @@ declare module 'estree' {
|
|
|
171
184
|
metadata: BaseNodeMetaData & {
|
|
172
185
|
hook_split_block?: boolean;
|
|
173
186
|
native_return_block?: boolean;
|
|
187
|
+
native_tsrx_template_block?: boolean;
|
|
188
|
+
allows_native_return?: boolean;
|
|
174
189
|
};
|
|
175
190
|
}
|
|
176
191
|
|
|
@@ -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
|
-
|
|
450
|
-
|
|
451
|
-
export type TSRXStatement = AST.Statement | TSESTree.Statement;
|
|
522
|
+
type TSRXStatement = AST.Statement | TSESTree.Statement;
|
|
452
523
|
|
|
453
|
-
|
|
524
|
+
type NodeWithChildren = TSRXJSXElement | TSRXJSXFragment | JSXStyleElement;
|
|
454
525
|
|
|
455
526
|
export namespace CSS {
|
|
456
527
|
export interface BaseNode extends AST.NodeWithMaybeComments {
|
|
@@ -1132,8 +1203,7 @@ export interface ParseOptions {
|
|
|
1132
1203
|
/**
|
|
1133
1204
|
* Analyze options
|
|
1134
1205
|
*/
|
|
1135
|
-
export interface AnalyzeOptions
|
|
1136
|
-
extends ParseOptions, Pick<CompileOptions, 'mode' | 'compat_kinds'> {
|
|
1206
|
+
export interface AnalyzeOptions extends ParseOptions, Pick<CompileOptions, 'mode'> {
|
|
1137
1207
|
errors?: CompileError[];
|
|
1138
1208
|
to_ts?: boolean;
|
|
1139
1209
|
}
|
|
@@ -1211,7 +1281,7 @@ export interface Binding {
|
|
|
1211
1281
|
| AST.ClassDeclaration
|
|
1212
1282
|
| AST.ImportDeclaration
|
|
1213
1283
|
| AST.TSModuleDeclaration
|
|
1214
|
-
|
|
|
1284
|
+
| ESTreeJSX.JSXFragment;
|
|
1215
1285
|
/** Whether this binding has been reassigned */
|
|
1216
1286
|
reassigned: boolean;
|
|
1217
1287
|
/** Whether this binding has been mutated (property access) */
|
|
@@ -1311,7 +1381,7 @@ export interface ScopeInterface {
|
|
|
1311
1381
|
| AST.ClassDeclaration
|
|
1312
1382
|
| AST.ImportDeclaration
|
|
1313
1383
|
| AST.TSModuleDeclaration
|
|
1314
|
-
|
|
|
1384
|
+
| ESTreeJSX.JSXFragment,
|
|
1315
1385
|
): Binding;
|
|
1316
1386
|
/** Get binding by name */
|
|
1317
1387
|
get(name: string): Binding | null;
|
|
@@ -1356,10 +1426,9 @@ export interface AnalysisState extends BaseState {
|
|
|
1356
1426
|
filename: string;
|
|
1357
1427
|
};
|
|
1358
1428
|
};
|
|
1359
|
-
elements?: AST.Element
|
|
1429
|
+
elements?: Array<ESTreeJSX.JSXElement | AST.Element>;
|
|
1360
1430
|
function_depth?: number;
|
|
1361
1431
|
collect?: boolean;
|
|
1362
|
-
configured_compat_kinds?: Set<string>;
|
|
1363
1432
|
metadata: BaseStateMetaData & {
|
|
1364
1433
|
styleClasses?: StyleClasses;
|
|
1365
1434
|
};
|
package/types/jsx-platform.d.ts
CHANGED
|
@@ -197,7 +197,7 @@ export interface JsxPlatformHooks {
|
|
|
197
197
|
renderForOf?: (node: any, loopParams: any[], bodyStatements: any[], ctx: any) => any | null;
|
|
198
198
|
/**
|
|
199
199
|
* Optionally replace the default React-style pending lowering for
|
|
200
|
-
*
|
|
200
|
+
* `@try { ... } @pending { ... }`. The default emits
|
|
201
201
|
* `<Suspense fallback={fallbackContent}>tryContent</Suspense>`.
|
|
202
202
|
* Vue Vapor uses this to provide `default` and `fallback` slots via
|
|
203
203
|
* `v-slots`.
|
|
@@ -241,11 +241,11 @@ export interface JsxPlatformHooks {
|
|
|
241
241
|
*/
|
|
242
242
|
createErrorBoundaryContent?: (tryContent: any, ctx: any, node: any) => any | null;
|
|
243
243
|
/**
|
|
244
|
-
*
|
|
244
|
+
* Customize lowering for a native JSX element. Default is the
|
|
245
245
|
* factory's `to_jsx_element`. The hook receives the walker-transformed
|
|
246
246
|
* node (`inner`, with children already lowered) plus the element's
|
|
247
247
|
* raw pre-walk children — Solid uses the latter to detect a lone
|
|
248
|
-
* `
|
|
248
|
+
* `JSXText` child it can hoist to a `textContent` attribute before the
|
|
249
249
|
* generic text→JSXExpressionContainer transform runs.
|
|
250
250
|
*/
|
|
251
251
|
transformElement?: (inner: any, ctx: any, rawChildren: any[]) => any;
|
|
@@ -314,12 +314,12 @@ export interface JsxPlatform {
|
|
|
314
314
|
*/
|
|
315
315
|
fragment?: string;
|
|
316
316
|
/**
|
|
317
|
-
* Module to import `Suspense` from when
|
|
317
|
+
* Module to import `Suspense` from when an `@try { ... } @pending { ... }`
|
|
318
318
|
* block appears. React: `'react'`. Preact: `'preact/compat'`.
|
|
319
319
|
*/
|
|
320
320
|
suspense: string;
|
|
321
321
|
/**
|
|
322
|
-
* Module to import `TsrxErrorBoundary` from when
|
|
322
|
+
* Module to import `TsrxErrorBoundary` from when an `@try { ... } @catch (...)`
|
|
323
323
|
* block appears. Usually `'@tsrx/<platform>/error-boundary'`.
|
|
324
324
|
*/
|
|
325
325
|
errorBoundary: string;
|
|
@@ -357,11 +357,6 @@ export interface JsxPlatform {
|
|
|
357
357
|
* not rewrite authored attributes.
|
|
358
358
|
*/
|
|
359
359
|
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
360
|
/**
|
|
366
361
|
* How to collapse multiple `ref` attributes on the same element into
|
|
367
362
|
* one. React's and Preact's runtimes treat duplicate `ref` props as
|
|
@@ -408,7 +403,7 @@ export interface JsxPlatform {
|
|
|
408
403
|
scanUseServerDirectiveForAwaitWithCustomValidator?: boolean;
|
|
409
404
|
/**
|
|
410
405
|
* Optional branded compiler error for targets that cannot lower
|
|
411
|
-
*
|
|
406
|
+
* `@try { ... } @pending { ... }` in component template context.
|
|
412
407
|
*
|
|
413
408
|
* When provided, the shared try-block lowering rejects any `pending`
|
|
414
409
|
* 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/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
|