@sdk-usage/plugin-jsx 0.0.0-next-b45188f → 0.0.0-next-193dba9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdk-usage/plugin-jsx",
3
- "version": "0.0.0-next-b45188f",
3
+ "version": "0.0.0-next-193dba9",
4
4
  "description": "sdk-usage parser plugin to enable JSX syntax analysis",
5
5
  "keywords": [
6
6
  "analyze",
@@ -40,9 +40,9 @@
40
40
  "dist"
41
41
  ],
42
42
  "devDependencies": {
43
- "@types/node": "22.18.12",
44
- "quickbundle": "2.8.0",
45
- "@sdk-usage/core": "0.0.0-next-b45188f"
43
+ "@types/node": "24.12.4",
44
+ "quickbundle": "3.0.0",
45
+ "@sdk-usage/core": "0.0.0-next-193dba9"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@sdk-usage/core": "^0.0.0"
package/dist/index.cjs DELETED
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- var core = require('@sdk-usage/core');
4
-
5
- var index = core.createPlugin((context, { getJSXAttributeValue })=>{
6
- return {
7
- JSXOpeningElement (node) {
8
- if (node.name.type !== "Identifier") return;
9
- const name = node.name.value;
10
- const importMetadata = context.imports.get(name);
11
- if (!importMetadata) return;
12
- return {
13
- name: importMetadata.name,
14
- input: {
15
- data: node.attributes.reduce((props, property)=>{
16
- if (property.type !== "JSXAttribute" || property.name.type !== "Identifier") return props;
17
- props[property.name.value] = getJSXAttributeValue(property.value);
18
- return props;
19
- }, {}),
20
- metadata: {
21
- withSpreading: false
22
- }
23
- },
24
- module: importMetadata.module,
25
- offset: node.span.start,
26
- type: "jsx/element"
27
- };
28
- }
29
- };
30
- });
31
-
32
- module.exports = index;
package/dist/index.d.ts DELETED
@@ -1,1048 +0,0 @@
1
- interface Span {
2
- start: number;
3
- end: number;
4
- ctxt: number;
5
- }
6
- interface Node {
7
- type: string;
8
- }
9
- interface HasSpan {
10
- span: Span;
11
- }
12
- interface HasDecorator {
13
- decorators?: Decorator[];
14
- }
15
- interface Class extends HasSpan, HasDecorator {
16
- body: ClassMember[];
17
- superClass?: Expression;
18
- isAbstract: boolean;
19
- typeParams?: TsTypeParameterDeclaration;
20
- superTypeParams?: TsTypeParameterInstantiation;
21
- implements: TsExpressionWithTypeArguments[];
22
- }
23
- type ClassMember = Constructor | ClassMethod | PrivateMethod | ClassProperty | PrivateProperty | TsIndexSignature | EmptyStatement | StaticBlock;
24
- interface ClassPropertyBase extends Node, HasSpan, HasDecorator {
25
- value?: Expression;
26
- typeAnnotation?: TsTypeAnnotation;
27
- isStatic: boolean;
28
- accessibility?: Accessibility;
29
- isOptional: boolean;
30
- isOverride: boolean;
31
- readonly: boolean;
32
- definite: boolean;
33
- }
34
- interface ClassProperty extends ClassPropertyBase {
35
- type: "ClassProperty";
36
- key: PropertyName;
37
- isAbstract: boolean;
38
- declare: boolean;
39
- }
40
- interface PrivateProperty extends ClassPropertyBase {
41
- type: "PrivateProperty";
42
- key: PrivateName;
43
- }
44
- interface Param extends Node, HasSpan, HasDecorator {
45
- type: "Parameter";
46
- pat: Pattern;
47
- }
48
- interface Constructor extends Node, HasSpan {
49
- type: "Constructor";
50
- key: PropertyName;
51
- params: (TsParameterProperty | Param)[];
52
- body?: BlockStatement;
53
- accessibility?: Accessibility;
54
- isOptional: boolean;
55
- }
56
- interface ClassMethodBase extends Node, HasSpan {
57
- function: Fn;
58
- kind: MethodKind;
59
- isStatic: boolean;
60
- accessibility?: Accessibility;
61
- isAbstract: boolean;
62
- isOptional: boolean;
63
- isOverride: boolean;
64
- }
65
- interface ClassMethod extends ClassMethodBase {
66
- type: "ClassMethod";
67
- key: PropertyName;
68
- }
69
- interface PrivateMethod extends ClassMethodBase {
70
- type: "PrivateMethod";
71
- key: PrivateName;
72
- }
73
- interface StaticBlock extends Node, HasSpan {
74
- type: "StaticBlock";
75
- body: BlockStatement;
76
- }
77
- interface Decorator extends Node, HasSpan {
78
- type: "Decorator";
79
- expression: Expression;
80
- }
81
- type MethodKind = "method" | "getter" | "setter";
82
- type Declaration = ClassDeclaration | FunctionDeclaration | VariableDeclaration | TsInterfaceDeclaration | TsTypeAliasDeclaration | TsEnumDeclaration | TsModuleDeclaration;
83
- interface FunctionDeclaration extends Fn {
84
- type: "FunctionDeclaration";
85
- identifier: Identifier;
86
- declare: boolean;
87
- }
88
- interface ClassDeclaration extends Class, Node {
89
- type: "ClassDeclaration";
90
- identifier: Identifier;
91
- declare: boolean;
92
- }
93
- interface VariableDeclaration extends Node, HasSpan {
94
- type: "VariableDeclaration";
95
- kind: VariableDeclarationKind;
96
- declare: boolean;
97
- declarations: VariableDeclarator[];
98
- }
99
- type VariableDeclarationKind = "var" | "let" | "const";
100
- interface VariableDeclarator extends Node, HasSpan {
101
- type: "VariableDeclarator";
102
- id: Pattern;
103
- init?: Expression;
104
- definite: boolean;
105
- }
106
- type Expression = ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression | UnaryExpression | UpdateExpression | BinaryExpression | AssignmentExpression | MemberExpression | SuperPropExpression | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | Identifier | Literal | TemplateLiteral | TaggedTemplateExpression | ArrowFunctionExpression | ClassExpression | YieldExpression | MetaProperty | AwaitExpression | ParenthesisExpression | JSXMemberExpression | JSXNamespacedName | JSXEmptyExpression | JSXElement | JSXFragment | TsTypeAssertion | TsConstAssertion | TsNonNullExpression | TsAsExpression | TsSatisfiesExpression | TsInstantiation | PrivateName | OptionalChainingExpression | Invalid;
107
- interface ExpressionBase extends Node, HasSpan {
108
- }
109
- interface Identifier extends ExpressionBase {
110
- type: "Identifier";
111
- value: string;
112
- optional: boolean;
113
- }
114
- interface OptionalChainingExpression extends ExpressionBase {
115
- type: "OptionalChainingExpression";
116
- questionDotToken: Span;
117
- /**
118
- * Call expression or member expression.
119
- */
120
- base: MemberExpression | OptionalChainingCall;
121
- }
122
- interface OptionalChainingCall extends ExpressionBase {
123
- type: "CallExpression";
124
- callee: Expression;
125
- arguments: ExprOrSpread[];
126
- typeArguments?: TsTypeParameterInstantiation;
127
- }
128
- interface ThisExpression extends ExpressionBase {
129
- type: "ThisExpression";
130
- }
131
- interface ArrayExpression extends ExpressionBase {
132
- type: "ArrayExpression";
133
- elements: (ExprOrSpread | undefined)[];
134
- }
135
- interface ExprOrSpread {
136
- spread?: Span;
137
- expression: Expression;
138
- }
139
- interface ObjectExpression extends ExpressionBase {
140
- type: "ObjectExpression";
141
- properties: (SpreadElement | Property)[];
142
- }
143
- interface Argument {
144
- spread?: Span;
145
- expression: Expression;
146
- }
147
- interface SpreadElement extends Node {
148
- type: "SpreadElement";
149
- spread: Span;
150
- arguments: Expression;
151
- }
152
- interface UnaryExpression extends ExpressionBase {
153
- type: "UnaryExpression";
154
- operator: UnaryOperator;
155
- argument: Expression;
156
- }
157
- interface UpdateExpression extends ExpressionBase {
158
- type: "UpdateExpression";
159
- operator: UpdateOperator;
160
- prefix: boolean;
161
- argument: Expression;
162
- }
163
- interface BinaryExpression extends ExpressionBase {
164
- type: "BinaryExpression";
165
- operator: BinaryOperator;
166
- left: Expression;
167
- right: Expression;
168
- }
169
- interface FunctionExpression extends Fn, ExpressionBase {
170
- type: "FunctionExpression";
171
- identifier?: Identifier;
172
- }
173
- interface ClassExpression extends Class, ExpressionBase {
174
- type: "ClassExpression";
175
- identifier?: Identifier;
176
- }
177
- interface AssignmentExpression extends ExpressionBase {
178
- type: "AssignmentExpression";
179
- operator: AssignmentOperator;
180
- left: Expression | Pattern;
181
- right: Expression;
182
- }
183
- interface MemberExpression extends ExpressionBase {
184
- type: "MemberExpression";
185
- object: Expression;
186
- property: Identifier | PrivateName | ComputedPropName;
187
- }
188
- interface SuperPropExpression extends ExpressionBase {
189
- type: "SuperPropExpression";
190
- obj: Super;
191
- property: Identifier | ComputedPropName;
192
- }
193
- interface ConditionalExpression extends ExpressionBase {
194
- type: "ConditionalExpression";
195
- test: Expression;
196
- consequent: Expression;
197
- alternate: Expression;
198
- }
199
- interface Super extends Node, HasSpan {
200
- type: "Super";
201
- }
202
- interface Import extends Node, HasSpan {
203
- type: "Import";
204
- }
205
- interface CallExpression extends ExpressionBase {
206
- type: "CallExpression";
207
- callee: Super | Import | Expression;
208
- arguments: Argument[];
209
- typeArguments?: TsTypeParameterInstantiation;
210
- }
211
- interface NewExpression extends ExpressionBase {
212
- type: "NewExpression";
213
- callee: Expression;
214
- arguments?: Argument[];
215
- typeArguments?: TsTypeParameterInstantiation;
216
- }
217
- interface SequenceExpression extends ExpressionBase {
218
- type: "SequenceExpression";
219
- expressions: Expression[];
220
- }
221
- interface ArrowFunctionExpression extends ExpressionBase {
222
- type: "ArrowFunctionExpression";
223
- params: Pattern[];
224
- body: BlockStatement | Expression;
225
- async: boolean;
226
- generator: boolean;
227
- typeParameters?: TsTypeParameterDeclaration;
228
- returnType?: TsTypeAnnotation;
229
- }
230
- interface YieldExpression extends ExpressionBase {
231
- type: "YieldExpression";
232
- argument?: Expression;
233
- delegate: boolean;
234
- }
235
- interface MetaProperty extends Node, HasSpan {
236
- type: "MetaProperty";
237
- kind: "new.target" | "import.meta";
238
- }
239
- interface AwaitExpression extends ExpressionBase {
240
- type: "AwaitExpression";
241
- argument: Expression;
242
- }
243
- interface TemplateLiteral extends ExpressionBase {
244
- type: "TemplateLiteral";
245
- expressions: Expression[];
246
- quasis: TemplateElement[];
247
- }
248
- interface TaggedTemplateExpression extends ExpressionBase {
249
- type: "TaggedTemplateExpression";
250
- tag: Expression;
251
- typeParameters?: TsTypeParameterInstantiation;
252
- template: TemplateLiteral;
253
- }
254
- interface TemplateElement extends ExpressionBase {
255
- type: "TemplateElement";
256
- tail: boolean;
257
- cooked?: string;
258
- raw: string;
259
- }
260
- interface ParenthesisExpression extends ExpressionBase {
261
- type: "ParenthesisExpression";
262
- expression: Expression;
263
- }
264
- interface Fn extends HasSpan, HasDecorator {
265
- params: Param[];
266
- body?: BlockStatement;
267
- generator: boolean;
268
- async: boolean;
269
- typeParameters?: TsTypeParameterDeclaration;
270
- returnType?: TsTypeAnnotation;
271
- }
272
- interface PatternBase extends Node, HasSpan {
273
- typeAnnotation?: TsTypeAnnotation;
274
- }
275
- interface PrivateName extends ExpressionBase {
276
- type: "PrivateName";
277
- id: Identifier;
278
- }
279
- type JSXObject = JSXMemberExpression | Identifier;
280
- interface JSXMemberExpression extends Node {
281
- type: "JSXMemberExpression";
282
- object: JSXObject;
283
- property: Identifier;
284
- }
285
- /**
286
- * XML-based namespace syntax:
287
- */
288
- interface JSXNamespacedName extends Node {
289
- type: "JSXNamespacedName";
290
- namespace: Identifier;
291
- name: Identifier;
292
- }
293
- interface JSXEmptyExpression extends Node, HasSpan {
294
- type: "JSXEmptyExpression";
295
- }
296
- interface JSXExpressionContainer extends Node, HasSpan {
297
- type: "JSXExpressionContainer";
298
- expression: JSXExpression;
299
- }
300
- type JSXExpression = JSXEmptyExpression | Expression;
301
- interface JSXSpreadChild extends Node, HasSpan {
302
- type: "JSXSpreadChild";
303
- expression: Expression;
304
- }
305
- type JSXElementName = Identifier | JSXMemberExpression | JSXNamespacedName;
306
- interface JSXOpeningElement extends Node, HasSpan {
307
- type: "JSXOpeningElement";
308
- name: JSXElementName;
309
- attributes: JSXAttributeOrSpread[];
310
- selfClosing: boolean;
311
- typeArguments?: TsTypeParameterInstantiation;
312
- }
313
- type JSXAttributeOrSpread = JSXAttribute | SpreadElement;
314
- interface JSXClosingElement extends Node, HasSpan {
315
- type: "JSXClosingElement";
316
- name: JSXElementName;
317
- }
318
- interface JSXAttribute extends Node, HasSpan {
319
- type: "JSXAttribute";
320
- name: JSXAttributeName;
321
- value?: JSXAttrValue;
322
- }
323
- type JSXAttributeName = Identifier | JSXNamespacedName;
324
- type JSXAttrValue = Literal | JSXExpressionContainer | JSXElement | JSXFragment;
325
- interface JSXText extends Node, HasSpan {
326
- type: "JSXText";
327
- value: string;
328
- raw: string;
329
- }
330
- interface JSXElement extends Node, HasSpan {
331
- type: "JSXElement";
332
- opening: JSXOpeningElement;
333
- children: JSXElementChild[];
334
- closing?: JSXClosingElement;
335
- }
336
- type JSXElementChild = JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment;
337
- interface JSXFragment extends Node, HasSpan {
338
- type: "JSXFragment";
339
- opening: JSXOpeningFragment;
340
- children: JSXElementChild[];
341
- closing: JSXClosingFragment;
342
- }
343
- interface JSXOpeningFragment extends Node, HasSpan {
344
- type: "JSXOpeningFragment";
345
- }
346
- interface JSXClosingFragment extends Node, HasSpan {
347
- type: "JSXClosingFragment";
348
- }
349
- type Literal = StringLiteral | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | JSXText;
350
- interface StringLiteral extends Node, HasSpan {
351
- type: "StringLiteral";
352
- value: string;
353
- raw?: string;
354
- }
355
- interface BooleanLiteral extends Node, HasSpan {
356
- type: "BooleanLiteral";
357
- value: boolean;
358
- }
359
- interface NullLiteral extends Node, HasSpan {
360
- type: "NullLiteral";
361
- }
362
- interface RegExpLiteral extends Node, HasSpan {
363
- type: "RegExpLiteral";
364
- pattern: string;
365
- flags: string;
366
- }
367
- interface NumericLiteral extends Node, HasSpan {
368
- type: "NumericLiteral";
369
- value: number;
370
- raw?: string;
371
- }
372
- interface BigIntLiteral extends Node, HasSpan {
373
- type: "BigIntLiteral";
374
- value: bigint;
375
- raw?: string;
376
- }
377
- type ModuleDeclaration = ImportDeclaration | ExportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportDefaultExpression | ExportAllDeclaration | TsImportEqualsDeclaration | TsExportAssignment | TsNamespaceExportDeclaration;
378
- interface ExportDefaultExpression extends Node, HasSpan {
379
- type: "ExportDefaultExpression";
380
- expression: Expression;
381
- }
382
- interface ExportDeclaration extends Node, HasSpan {
383
- type: "ExportDeclaration";
384
- declaration: Declaration;
385
- }
386
- interface ImportDeclaration extends Node, HasSpan {
387
- type: "ImportDeclaration";
388
- specifiers: ImportSpecifier[];
389
- source: StringLiteral;
390
- typeOnly: boolean;
391
- asserts?: ObjectExpression;
392
- }
393
- interface ExportAllDeclaration extends Node, HasSpan {
394
- type: "ExportAllDeclaration";
395
- source: StringLiteral;
396
- asserts?: ObjectExpression;
397
- }
398
- /**
399
- * - `export { foo } from 'mod'`
400
- * - `export { foo as bar } from 'mod'`
401
- */
402
- interface ExportNamedDeclaration extends Node, HasSpan {
403
- type: "ExportNamedDeclaration";
404
- specifiers: ExportSpecifier[];
405
- source?: StringLiteral;
406
- typeOnly: boolean;
407
- asserts?: ObjectExpression;
408
- }
409
- interface ExportDefaultDeclaration extends Node, HasSpan {
410
- type: "ExportDefaultDeclaration";
411
- decl: DefaultDecl;
412
- }
413
- type DefaultDecl = ClassExpression | FunctionExpression | TsInterfaceDeclaration;
414
- type ImportSpecifier = NamedImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier;
415
- /**
416
- * e.g. `import foo from 'mod.js'`
417
- */
418
- interface ImportDefaultSpecifier extends Node, HasSpan {
419
- type: "ImportDefaultSpecifier";
420
- local: Identifier;
421
- }
422
- /**
423
- * e.g. `import * as foo from 'mod.js'`.
424
- */
425
- interface ImportNamespaceSpecifier extends Node, HasSpan {
426
- type: "ImportNamespaceSpecifier";
427
- local: Identifier;
428
- }
429
- /**
430
- * e.g. - `import { foo } from 'mod.js'`
431
- *
432
- * local = foo, imported = None
433
- *
434
- * e.g. `import { foo as bar } from 'mod.js'`
435
- *
436
- * local = bar, imported = Some(foo) for
437
- */
438
- interface NamedImportSpecifier extends Node, HasSpan {
439
- type: "ImportSpecifier";
440
- local: Identifier;
441
- imported?: ModuleExportName;
442
- isTypeOnly: boolean;
443
- }
444
- type ModuleExportName = Identifier | StringLiteral;
445
- type ExportSpecifier = ExportNamespaceSpecifier | ExportDefaultSpecifier | NamedExportSpecifier;
446
- /**
447
- * `export * as foo from 'src';`
448
- */
449
- interface ExportNamespaceSpecifier extends Node, HasSpan {
450
- type: "ExportNamespaceSpecifier";
451
- name: ModuleExportName;
452
- }
453
- interface ExportDefaultSpecifier extends Node, HasSpan {
454
- type: "ExportDefaultSpecifier";
455
- exported: Identifier;
456
- }
457
- interface NamedExportSpecifier extends Node, HasSpan {
458
- type: "ExportSpecifier";
459
- orig: ModuleExportName;
460
- /**
461
- * `Some(bar)` in `export { foo as bar }`
462
- */
463
- exported?: ModuleExportName;
464
- isTypeOnly: boolean;
465
- }
466
- type ModuleItem = ModuleDeclaration | Statement;
467
- type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "||" | "&&" | "in" | "instanceof" | "**" | "??";
468
- type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=" | "&&=" | "||=" | "??=";
469
- type UpdateOperator = "++" | "--";
470
- type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
471
- type Pattern = BindingIdentifier | ArrayPattern | RestElement | ObjectPattern | AssignmentPattern | Invalid | Expression;
472
- interface BindingIdentifier extends PatternBase {
473
- type: "Identifier";
474
- value: string;
475
- optional: boolean;
476
- }
477
- interface ArrayPattern extends PatternBase {
478
- type: "ArrayPattern";
479
- elements: (Pattern | undefined)[];
480
- optional: boolean;
481
- }
482
- interface ObjectPattern extends PatternBase {
483
- type: "ObjectPattern";
484
- properties: ObjectPatternProperty[];
485
- optional: boolean;
486
- }
487
- interface AssignmentPattern extends PatternBase {
488
- type: "AssignmentPattern";
489
- left: Pattern;
490
- right: Expression;
491
- }
492
- interface RestElement extends PatternBase {
493
- type: "RestElement";
494
- rest: Span;
495
- argument: Pattern;
496
- }
497
- type ObjectPatternProperty = KeyValuePatternProperty | AssignmentPatternProperty | RestElement;
498
- /**
499
- * `{key: value}`
500
- */
501
- interface KeyValuePatternProperty extends Node {
502
- type: "KeyValuePatternProperty";
503
- key: PropertyName;
504
- value: Pattern;
505
- }
506
- /**
507
- * `{key}` or `{key = value}`
508
- */
509
- interface AssignmentPatternProperty extends Node, HasSpan {
510
- type: "AssignmentPatternProperty";
511
- key: Identifier;
512
- value?: Expression;
513
- }
514
- /** Identifier is `a` in `{ a, }` */
515
- type Property = Identifier | KeyValueProperty | AssignmentProperty | GetterProperty | SetterProperty | MethodProperty;
516
- interface PropBase extends Node {
517
- key: PropertyName;
518
- }
519
- interface KeyValueProperty extends PropBase {
520
- type: "KeyValueProperty";
521
- value: Expression;
522
- }
523
- interface AssignmentProperty extends Node {
524
- type: "AssignmentProperty";
525
- key: Identifier;
526
- value: Expression;
527
- }
528
- interface GetterProperty extends PropBase, HasSpan {
529
- type: "GetterProperty";
530
- typeAnnotation?: TsTypeAnnotation;
531
- body?: BlockStatement;
532
- }
533
- interface SetterProperty extends PropBase, HasSpan {
534
- type: "SetterProperty";
535
- param: Pattern;
536
- body?: BlockStatement;
537
- }
538
- interface MethodProperty extends PropBase, Fn {
539
- type: "MethodProperty";
540
- }
541
- type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropName | BigIntLiteral;
542
- interface ComputedPropName extends Node, HasSpan {
543
- type: "Computed";
544
- expression: Expression;
545
- }
546
- interface BlockStatement extends Node, HasSpan {
547
- type: "BlockStatement";
548
- stmts: Statement[];
549
- }
550
- interface ExpressionStatement extends Node, HasSpan {
551
- type: "ExpressionStatement";
552
- expression: Expression;
553
- }
554
- type Statement = BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration | ExpressionStatement;
555
- interface EmptyStatement extends Node, HasSpan {
556
- type: "EmptyStatement";
557
- }
558
- interface DebuggerStatement extends Node, HasSpan {
559
- type: "DebuggerStatement";
560
- }
561
- interface WithStatement extends Node, HasSpan {
562
- type: "WithStatement";
563
- object: Expression;
564
- body: Statement;
565
- }
566
- interface ReturnStatement extends Node, HasSpan {
567
- type: "ReturnStatement";
568
- argument?: Expression;
569
- }
570
- interface LabeledStatement extends Node, HasSpan {
571
- type: "LabeledStatement";
572
- label: Identifier;
573
- body: Statement;
574
- }
575
- interface BreakStatement extends Node, HasSpan {
576
- type: "BreakStatement";
577
- label?: Identifier;
578
- }
579
- interface ContinueStatement extends Node, HasSpan {
580
- type: "ContinueStatement";
581
- label?: Identifier;
582
- }
583
- interface IfStatement extends Node, HasSpan {
584
- type: "IfStatement";
585
- test: Expression;
586
- consequent: Statement;
587
- alternate?: Statement;
588
- }
589
- interface SwitchStatement extends Node, HasSpan {
590
- type: "SwitchStatement";
591
- discriminant: Expression;
592
- cases: SwitchCase[];
593
- }
594
- interface ThrowStatement extends Node, HasSpan {
595
- type: "ThrowStatement";
596
- argument: Expression;
597
- }
598
- interface TryStatement extends Node, HasSpan {
599
- type: "TryStatement";
600
- block: BlockStatement;
601
- handler?: CatchClause;
602
- finalizer?: BlockStatement;
603
- }
604
- interface WhileStatement extends Node, HasSpan {
605
- type: "WhileStatement";
606
- test: Expression;
607
- body: Statement;
608
- }
609
- interface DoWhileStatement extends Node, HasSpan {
610
- type: "DoWhileStatement";
611
- test: Expression;
612
- body: Statement;
613
- }
614
- interface ForStatement extends Node, HasSpan {
615
- type: "ForStatement";
616
- init?: VariableDeclaration | Expression;
617
- test?: Expression;
618
- update?: Expression;
619
- body: Statement;
620
- }
621
- interface ForInStatement extends Node, HasSpan {
622
- type: "ForInStatement";
623
- left: VariableDeclaration | Pattern;
624
- right: Expression;
625
- body: Statement;
626
- }
627
- interface ForOfStatement extends Node, HasSpan {
628
- type: "ForOfStatement";
629
- /**
630
- * Span of the await token.
631
- *
632
- * es2018 for-await-of statements, e.g., `for await (const x of xs) {`
633
- */
634
- await?: Span;
635
- left: VariableDeclaration | Pattern;
636
- right: Expression;
637
- body: Statement;
638
- }
639
- interface SwitchCase extends Node, HasSpan {
640
- type: "SwitchCase";
641
- /**
642
- * Undefined for default case
643
- */
644
- test?: Expression;
645
- consequent: Statement[];
646
- }
647
- interface CatchClause extends Node, HasSpan {
648
- type: "CatchClause";
649
- /**
650
- * The param is `undefined` if the catch binding is omitted. E.g., `try { foo() } catch {}`
651
- */
652
- param?: Pattern;
653
- body: BlockStatement;
654
- }
655
- interface TsTypeAnnotation extends Node, HasSpan {
656
- type: "TsTypeAnnotation";
657
- typeAnnotation: TsType;
658
- }
659
- interface TsTypeParameterDeclaration extends Node, HasSpan {
660
- type: "TsTypeParameterDeclaration";
661
- parameters: TsTypeParameter[];
662
- }
663
- interface TsTypeParameter extends Node, HasSpan {
664
- type: "TsTypeParameter";
665
- name: Identifier;
666
- in: boolean;
667
- out: boolean;
668
- constraint?: TsType;
669
- default?: TsType;
670
- }
671
- interface TsTypeParameterInstantiation extends Node, HasSpan {
672
- type: "TsTypeParameterInstantiation";
673
- params: TsType[];
674
- }
675
- interface TsParameterProperty extends Node, HasSpan, HasDecorator {
676
- type: "TsParameterProperty";
677
- accessibility?: Accessibility;
678
- override: boolean;
679
- readonly: boolean;
680
- param: TsParameterPropertyParameter;
681
- }
682
- type TsParameterPropertyParameter = BindingIdentifier | AssignmentPattern;
683
- interface TsQualifiedName extends Node {
684
- type: "TsQualifiedName";
685
- left: TsEntityName;
686
- right: Identifier;
687
- }
688
- type TsEntityName = TsQualifiedName | Identifier;
689
- type TsTypeElement = TsCallSignatureDeclaration | TsConstructSignatureDeclaration | TsPropertySignature | TsGetterSignature | TsSetterSignature | TsMethodSignature | TsIndexSignature;
690
- interface TsCallSignatureDeclaration extends Node, HasSpan {
691
- type: "TsCallSignatureDeclaration";
692
- params: TsFnParameter[];
693
- typeAnnotation?: TsTypeAnnotation;
694
- typeParams?: TsTypeParameterDeclaration;
695
- }
696
- interface TsConstructSignatureDeclaration extends Node, HasSpan {
697
- type: "TsConstructSignatureDeclaration";
698
- params: TsFnParameter[];
699
- typeAnnotation?: TsTypeAnnotation;
700
- typeParams?: TsTypeParameterDeclaration;
701
- }
702
- interface TsPropertySignature extends Node, HasSpan {
703
- type: "TsPropertySignature";
704
- readonly: boolean;
705
- key: Expression;
706
- computed: boolean;
707
- optional: boolean;
708
- typeAnnotation?: TsTypeAnnotation;
709
- }
710
- interface TsGetterSignature extends Node, HasSpan {
711
- type: "TsGetterSignature";
712
- readonly: boolean;
713
- key: Expression;
714
- computed: boolean;
715
- optional: boolean;
716
- typeAnnotation?: TsTypeAnnotation;
717
- }
718
- interface TsSetterSignature extends Node, HasSpan {
719
- type: "TsSetterSignature";
720
- readonly: boolean;
721
- key: Expression;
722
- computed: boolean;
723
- optional: boolean;
724
- param: TsFnParameter;
725
- }
726
- interface TsMethodSignature extends Node, HasSpan {
727
- type: "TsMethodSignature";
728
- readonly: boolean;
729
- key: Expression;
730
- computed: boolean;
731
- optional: boolean;
732
- params: TsFnParameter[];
733
- typeAnn?: TsTypeAnnotation;
734
- typeParams?: TsTypeParameterDeclaration;
735
- }
736
- interface TsIndexSignature extends Node, HasSpan {
737
- type: "TsIndexSignature";
738
- params: TsFnParameter[];
739
- typeAnnotation?: TsTypeAnnotation;
740
- readonly: boolean;
741
- static: boolean;
742
- }
743
- type TsType = TsKeywordType | TsThisType | TsFnOrConstructorType | TsTypeReference | TsTypeQuery | TsTypeLiteral | TsArrayType | TsTupleType | TsOptionalType | TsRestType | TsUnionOrIntersectionType | TsConditionalType | TsInferType | TsParenthesizedType | TsTypeOperator | TsIndexedAccessType | TsMappedType | TsLiteralType | TsTypePredicate | TsImportType;
744
- type TsFnOrConstructorType = TsFunctionType | TsConstructorType;
745
- interface TsKeywordType extends Node, HasSpan {
746
- type: "TsKeywordType";
747
- kind: TsKeywordTypeKind;
748
- }
749
- type TsKeywordTypeKind = "any" | "unknown" | "number" | "object" | "boolean" | "bigint" | "string" | "symbol" | "void" | "undefined" | "null" | "never" | "intrinsic";
750
- interface TsThisType extends Node, HasSpan {
751
- type: "TsThisType";
752
- }
753
- type TsFnParameter = BindingIdentifier | ArrayPattern | RestElement | ObjectPattern;
754
- interface TsFunctionType extends Node, HasSpan {
755
- type: "TsFunctionType";
756
- params: TsFnParameter[];
757
- typeParams?: TsTypeParameterDeclaration;
758
- typeAnnotation: TsTypeAnnotation;
759
- }
760
- interface TsConstructorType extends Node, HasSpan {
761
- type: "TsConstructorType";
762
- params: TsFnParameter[];
763
- typeParams?: TsTypeParameterDeclaration;
764
- typeAnnotation: TsTypeAnnotation;
765
- isAbstract: boolean;
766
- }
767
- interface TsTypeReference extends Node, HasSpan {
768
- type: "TsTypeReference";
769
- typeName: TsEntityName;
770
- typeParams?: TsTypeParameterInstantiation;
771
- }
772
- interface TsTypePredicate extends Node, HasSpan {
773
- type: "TsTypePredicate";
774
- asserts: boolean;
775
- paramName: TsThisTypeOrIdent;
776
- typeAnnotation?: TsTypeAnnotation;
777
- }
778
- type TsThisTypeOrIdent = TsThisType | Identifier;
779
- interface TsImportType extends Node, HasSpan {
780
- type: "TsImportType";
781
- argument: StringLiteral;
782
- qualifier?: TsEntityName;
783
- typeArguments?: TsTypeParameterInstantiation;
784
- }
785
- /**
786
- * `typeof` operator
787
- */
788
- interface TsTypeQuery extends Node, HasSpan {
789
- type: "TsTypeQuery";
790
- exprName: TsTypeQueryExpr;
791
- typeArguments?: TsTypeParameterInstantiation;
792
- }
793
- type TsTypeQueryExpr = TsEntityName | TsImportType;
794
- interface TsTypeLiteral extends Node, HasSpan {
795
- type: "TsTypeLiteral";
796
- members: TsTypeElement[];
797
- }
798
- interface TsArrayType extends Node, HasSpan {
799
- type: "TsArrayType";
800
- elemType: TsType;
801
- }
802
- interface TsTupleType extends Node, HasSpan {
803
- type: "TsTupleType";
804
- elemTypes: TsTupleElement[];
805
- }
806
- interface TsTupleElement extends Node, HasSpan {
807
- type: "TsTupleElement";
808
- label?: Pattern;
809
- ty: TsType;
810
- }
811
- interface TsOptionalType extends Node, HasSpan {
812
- type: "TsOptionalType";
813
- typeAnnotation: TsType;
814
- }
815
- interface TsRestType extends Node, HasSpan {
816
- type: "TsRestType";
817
- typeAnnotation: TsType;
818
- }
819
- type TsUnionOrIntersectionType = TsUnionType | TsIntersectionType;
820
- interface TsUnionType extends Node, HasSpan {
821
- type: "TsUnionType";
822
- types: TsType[];
823
- }
824
- interface TsIntersectionType extends Node, HasSpan {
825
- type: "TsIntersectionType";
826
- types: TsType[];
827
- }
828
- interface TsConditionalType extends Node, HasSpan {
829
- type: "TsConditionalType";
830
- checkType: TsType;
831
- extendsType: TsType;
832
- trueType: TsType;
833
- falseType: TsType;
834
- }
835
- interface TsInferType extends Node, HasSpan {
836
- type: "TsInferType";
837
- typeParam: TsTypeParameter;
838
- }
839
- interface TsParenthesizedType extends Node, HasSpan {
840
- type: "TsParenthesizedType";
841
- typeAnnotation: TsType;
842
- }
843
- interface TsTypeOperator extends Node, HasSpan {
844
- type: "TsTypeOperator";
845
- op: TsTypeOperatorOp;
846
- typeAnnotation: TsType;
847
- }
848
- type TsTypeOperatorOp = "keyof" | "unique" | "readonly";
849
- interface TsIndexedAccessType extends Node, HasSpan {
850
- type: "TsIndexedAccessType";
851
- readonly: boolean;
852
- objectType: TsType;
853
- indexType: TsType;
854
- }
855
- type TruePlusMinus = true | "+" | "-";
856
- interface TsMappedType extends Node, HasSpan {
857
- type: "TsMappedType";
858
- readonly?: TruePlusMinus;
859
- typeParam: TsTypeParameter;
860
- nameType?: TsType;
861
- optional?: TruePlusMinus;
862
- typeAnnotation?: TsType;
863
- }
864
- interface TsLiteralType extends Node, HasSpan {
865
- type: "TsLiteralType";
866
- literal: TsLiteral;
867
- }
868
- type TsLiteral = NumericLiteral | StringLiteral | BooleanLiteral | BigIntLiteral | TsTemplateLiteralType;
869
- interface TsTemplateLiteralType extends Node, HasSpan {
870
- type: "TemplateLiteral";
871
- types: TsType[];
872
- quasis: TemplateElement[];
873
- }
874
- interface TsInterfaceDeclaration extends Node, HasSpan {
875
- type: "TsInterfaceDeclaration";
876
- id: Identifier;
877
- declare: boolean;
878
- typeParams?: TsTypeParameterDeclaration;
879
- extends: TsExpressionWithTypeArguments[];
880
- body: TsInterfaceBody;
881
- }
882
- interface TsInterfaceBody extends Node, HasSpan {
883
- type: "TsInterfaceBody";
884
- body: TsTypeElement[];
885
- }
886
- interface TsExpressionWithTypeArguments extends Node, HasSpan {
887
- type: "TsExpressionWithTypeArguments";
888
- expression: Expression;
889
- typeArguments?: TsTypeParameterInstantiation;
890
- }
891
- interface TsTypeAliasDeclaration extends Node, HasSpan {
892
- type: "TsTypeAliasDeclaration";
893
- declare: boolean;
894
- id: Identifier;
895
- typeParams?: TsTypeParameterDeclaration;
896
- typeAnnotation: TsType;
897
- }
898
- interface TsEnumDeclaration extends Node, HasSpan {
899
- type: "TsEnumDeclaration";
900
- declare: boolean;
901
- isConst: boolean;
902
- id: Identifier;
903
- members: TsEnumMember[];
904
- }
905
- interface TsEnumMember extends Node, HasSpan {
906
- type: "TsEnumMember";
907
- id: TsEnumMemberId;
908
- init?: Expression;
909
- }
910
- type TsEnumMemberId = Identifier | StringLiteral;
911
- interface TsModuleDeclaration extends Node, HasSpan {
912
- type: "TsModuleDeclaration";
913
- declare: boolean;
914
- global: boolean;
915
- id: TsModuleName;
916
- body?: TsNamespaceBody;
917
- }
918
- /**
919
- * `namespace A.B { }` is a namespace named `A` with another TsNamespaceDecl as its body.
920
- */
921
- type TsNamespaceBody = TsModuleBlock | TsNamespaceDeclaration;
922
- interface TsModuleBlock extends Node, HasSpan {
923
- type: "TsModuleBlock";
924
- body: ModuleItem[];
925
- }
926
- interface TsNamespaceDeclaration extends Node, HasSpan {
927
- type: "TsNamespaceDeclaration";
928
- declare: boolean;
929
- global: boolean;
930
- id: Identifier;
931
- body: TsNamespaceBody;
932
- }
933
- type TsModuleName = Identifier | StringLiteral;
934
- interface TsImportEqualsDeclaration extends Node, HasSpan {
935
- type: "TsImportEqualsDeclaration";
936
- declare: boolean;
937
- isExport: boolean;
938
- isTypeOnly: boolean;
939
- id: Identifier;
940
- moduleRef: TsModuleReference;
941
- }
942
- type TsModuleReference = TsEntityName | TsExternalModuleReference;
943
- interface TsExternalModuleReference extends Node, HasSpan {
944
- type: "TsExternalModuleReference";
945
- expression: StringLiteral;
946
- }
947
- interface TsExportAssignment extends Node, HasSpan {
948
- type: "TsExportAssignment";
949
- expression: Expression;
950
- }
951
- interface TsNamespaceExportDeclaration extends Node, HasSpan {
952
- type: "TsNamespaceExportDeclaration";
953
- id: Identifier;
954
- }
955
- interface TsAsExpression extends ExpressionBase {
956
- type: "TsAsExpression";
957
- expression: Expression;
958
- typeAnnotation: TsType;
959
- }
960
- interface TsSatisfiesExpression extends ExpressionBase {
961
- type: "TsSatisfiesExpression";
962
- expression: Expression;
963
- typeAnnotation: TsType;
964
- }
965
- interface TsInstantiation extends Node, HasSpan {
966
- type: "TsInstantiation";
967
- expression: Expression;
968
- typeArguments: TsTypeParameterInstantiation;
969
- }
970
- interface TsTypeAssertion extends ExpressionBase {
971
- type: "TsTypeAssertion";
972
- expression: Expression;
973
- typeAnnotation: TsType;
974
- }
975
- interface TsConstAssertion extends ExpressionBase {
976
- type: "TsConstAssertion";
977
- expression: Expression;
978
- }
979
- interface TsNonNullExpression extends ExpressionBase {
980
- type: "TsNonNullExpression";
981
- expression: Expression;
982
- }
983
- type Accessibility = "public" | "protected" | "private";
984
- interface Invalid extends Node, HasSpan {
985
- type: "Invalid";
986
- }
987
-
988
- declare const _default: (context: {
989
- imports: Map<string, {
990
- name: string;
991
- alias: string;
992
- module: string;
993
- }>;
994
- }, helpers: {
995
- getJSXAttributeValue: (node: JSXAttrValue | undefined) => string | number | bigint | boolean | null | undefined;
996
- }) => { [Key in keyof {
997
- ImportDeclaration: ImportDeclaration;
998
- JSXAttrValue: JSXAttrValue;
999
- JSXOpeningElement: JSXOpeningElement;
1000
- TsType: TsType;
1001
- }]?: (node: {
1002
- ImportDeclaration: ImportDeclaration;
1003
- JSXAttrValue: JSXAttrValue;
1004
- JSXOpeningElement: JSXOpeningElement;
1005
- TsType: TsType;
1006
- }[Key]) => (Partial<Pick<{
1007
- name: string;
1008
- createdAt: string;
1009
- input: {
1010
- data: Record<string, unknown>;
1011
- metadata: {
1012
- withSpreading: boolean;
1013
- };
1014
- };
1015
- location: {
1016
- column: number;
1017
- file: string;
1018
- line: number;
1019
- link: string;
1020
- module: string;
1021
- };
1022
- module: string;
1023
- type: string;
1024
- version: string;
1025
- }, "input">> & Pick<{
1026
- name: string;
1027
- createdAt: string;
1028
- input: {
1029
- data: Record<string, unknown>;
1030
- metadata: {
1031
- withSpreading: boolean;
1032
- };
1033
- };
1034
- location: {
1035
- column: number;
1036
- file: string;
1037
- line: number;
1038
- link: string;
1039
- module: string;
1040
- };
1041
- module: string;
1042
- type: string;
1043
- version: string;
1044
- }, "module" | "name" | "type"> & {
1045
- offset: number;
1046
- }) | undefined; };
1047
-
1048
- export { _default as default };
package/dist/index.mjs DELETED
@@ -1,30 +0,0 @@
1
- import { createPlugin } from '@sdk-usage/core';
2
-
3
- var index = createPlugin((context, { getJSXAttributeValue })=>{
4
- return {
5
- JSXOpeningElement (node) {
6
- if (node.name.type !== "Identifier") return;
7
- const name = node.name.value;
8
- const importMetadata = context.imports.get(name);
9
- if (!importMetadata) return;
10
- return {
11
- name: importMetadata.name,
12
- input: {
13
- data: node.attributes.reduce((props, property)=>{
14
- if (property.type !== "JSXAttribute" || property.name.type !== "Identifier") return props;
15
- props[property.name.value] = getJSXAttributeValue(property.value);
16
- return props;
17
- }, {}),
18
- metadata: {
19
- withSpreading: false
20
- }
21
- },
22
- module: importMetadata.module,
23
- offset: node.span.start,
24
- type: "jsx/element"
25
- };
26
- }
27
- };
28
- });
29
-
30
- export { index as default };