@ohos-ports/swc-core 1.3.14-beta.0 → 1.13.3-beta.0

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/README.md CHANGED
@@ -10,8 +10,13 @@
10
10
 
11
11
  <p align="center">
12
12
  <a href="https://www.npmjs.com/package/@swc/core">
13
- <img alt="npm Downloads" src="https://img.shields.io/npm/dm/@swc/helpers">
13
+ <img alt="downloads (@swc/core)" src="https://img.shields.io/npm/dm/@swc/core?label=downloads%20%28%40swc%2Fcore%29">
14
14
  </a>
15
+ <a href="https://www.npmjs.com/package/@swc/counter?activeTab=dependents">
16
+ <img alt="downloads (3rd party)" src="https://img.shields.io/npm/dm/@swc/counter?label=downloads%20%283rd%20party%29">
17
+ </a>
18
+ </p>
19
+ <p align="center">
15
20
  <a href="https://crates.io/crates/swc_ecma_parser">
16
21
  <img alt="undefined" src="https://img.shields.io/crates/d/swc_ecma_parser.svg?label=crates.io%20downloads">
17
22
  </a>
@@ -41,7 +46,20 @@ Also, SWC tries to ensure that
41
46
 
42
47
  for rust users.
43
48
 
44
- MSRV of crates named `swc_ecma_*` is the current stable, and nightly for others.
49
+ MSRV of crates is currently `1.73`.
50
+
51
+ To update all SWC crates you use, you can run `curl https://raw.githubusercontent.com/swc-project/swc/main/scripts/update-all-swc-crates.sh | bash -s`. This script will update all dependencies to the latest version and run `cargo build` to ensure that everything works.
52
+ Note that you need
53
+
54
+ - `jq`
55
+ - `cargo upgrade`
56
+
57
+ command to run the script.
58
+
59
+ Supported Node Versions:
60
+
61
+ - Node v10+ for usage
62
+ - Node v20+ for development
45
63
 
46
64
  ---
47
65
 
@@ -59,27 +77,30 @@ Please see [comparison with babel](https://swc.rs/docs/migrating-from-babel).
59
77
 
60
78
  Please see [benchmark results](https://swc.rs/docs/benchmark-transform) on the website.
61
79
 
80
+ # Supporting development
81
+
62
82
  <h2 align="center">Supporting swc</h2>
63
83
 
84
+ ## Star History
85
+
86
+ [![Star History Chart](https://api.star-history.com/svg?repos=swc-project/swc&type=Timeline)](https://www.star-history.com/#swc-project/swc&Timeline)
87
+
88
+ ## Powered by
89
+
90
+ [![JetBrains logo.](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg)](https://jb.gg/OpenSourceSupport)
91
+
92
+ ## Sponsors
93
+
64
94
  <p align="center">
65
- <a href="#backers">
66
- <img alt="Backers on Open Collective" src="https://opencollective.com/swc/tiers/backer/badge.svg?label=backer&color=brightgreen" />
67
- </a>
68
- <a href="#gold-sponsors">
69
- <img alt="Gold sponsors on Open Collective" src="https://opencollective.com/swc/tiers/gold-sponsors/badge.svg?label=Gold%20sponsors&color=brightgreen"/>
70
- </a>
71
- <a href="#silver-sponsors">
72
- <img alt="Silver sponsors on Open Collective" src="https://opencollective.com/swc/tiers/silver-sponsors/badge.svg?label=Silver%20sponsors&color=brightgreen"/>
73
- </a>
74
- <a href="#bronze-sponsors">
75
- <img alt="Bronze sponsors on Open Collective" src="https://opencollective.com/swc/tiers/bronze-sponsors/badge.svg?label=Bronze%20sponsors&color=brightgreen"/>
95
+ <a href="https://opencollective.com/swc">
96
+ <img src="https://raw.githubusercontent.com/swc-project/swc-sponsor-images/main/sponsors.svg" alt="Sponsors">
76
97
  </a>
77
98
  </p>
78
99
 
79
- SWC is a community-driven project, and is maintained by a group of [volunteers](https://opencollective.com/swc#team). If you'd like to help support the future of the project, please consider:
100
+ SWC is a community-driven project, and is maintained by a group of [volunteers](https://swc.rs/docs/team). If you'd like to help support the future of the project, please consider:
80
101
 
81
- - Giving developer time on the project. (Message us on [Discord](https://discord.gg/GnHbXTdZz6) (preferred) or [Github discussions](https://github.com/swc-project/swc/discussions) for guidance!)
82
- - Giving funds by becoming a sponsor (see https://opencollective.com/swc)!
102
+ - Giving developer time on the project. (Message us on [Discord](https://discord.gg/GnHbXTdZz6) (preferred) or [Github discussions](https://github.com/swc-project/swc/discussions) for guidance!)
103
+ - Giving funds by becoming a sponsor (see https://opencollective.com/swc)!
83
104
 
84
105
  ## Contributing
85
106
 
package/Visitor.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- import { Accessibility, ArrayExpression, ArrayPattern, ArrowFunctionExpression, Argument, AssignmentExpression, AssignmentPattern, AssignmentPatternProperty, AssignmentProperty, AwaitExpression, BigIntLiteral, BinaryExpression, BlockStatement, BooleanLiteral, BreakStatement, CallExpression, CatchClause, Class, ClassDeclaration, ClassExpression, ClassMember, ClassMethod, ClassProperty, ComputedPropName, ConditionalExpression, Constructor, ContinueStatement, DebuggerStatement, Declaration, Decorator, DefaultDecl, DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportDefaultExpression, ExportDefaultSpecifier, ExportNamedDeclaration, ExportNamespaceSpecifier, ExportSpecifier, Expression, ExpressionStatement, Fn, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, GetterProperty, Identifier, IfStatement, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, JSXAttribute, JSXAttributeName, JSXAttributeOrSpread, JSXAttrValue, JSXClosingElement, JSXClosingFragment, JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpression, JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXNamespacedName, JSXObject, JSXOpeningElement, JSXOpeningFragment, JSXSpreadChild, JSXText, KeyValuePatternProperty, KeyValueProperty, LabeledStatement, MemberExpression, MetaProperty, MethodProperty, Module, ModuleDeclaration, ModuleExportName, ModuleItem, NamedExportSpecifier, NamedImportSpecifier, NewExpression, NullLiteral, NumericLiteral, ObjectExpression, ObjectPattern, ObjectPatternProperty, OptionalChainingCall, OptionalChainingExpression, ParenthesisExpression, Pattern, PrivateMethod, PrivateName, PrivateProperty, Program, Property, PropertyName, RegExpLiteral, RestElement, ReturnStatement, Script, SequenceExpression, SetterProperty, SpreadElement, Statement, StaticBlock, StringLiteral, Super, SwitchCase, SwitchStatement, TaggedTemplateExpression, TemplateLiteral, ThisExpression, ThrowStatement, TryStatement, TsAsExpression, TsCallSignatureDeclaration, TsConstructSignatureDeclaration, TsEntityName, TsEnumDeclaration, TsEnumMember, TsEnumMemberId, TsExportAssignment, TsExpressionWithTypeArguments, TsExternalModuleReference, TsFnParameter, TsGetterSignature, TsImportEqualsDeclaration, TsIndexSignature, TsInstantiation, TsInterfaceBody, TsInterfaceDeclaration, TsMethodSignature, TsModuleBlock, TsModuleDeclaration, TsModuleName, TsModuleReference, TsNamespaceBody, TsNamespaceDeclaration, TsNamespaceExportDeclaration, TsNonNullExpression, TsParameterProperty, TsParameterPropertyParameter, TsPropertySignature, TsQualifiedName, TsSetterSignature, TsType, TsTypeAliasDeclaration, TsTypeAnnotation, TsTypeAssertion, TsTypeElement, TsTypeParameter, TsTypeParameterDeclaration, TsTypeParameterInstantiation, UnaryExpression, UpdateExpression, VariableDeclaration, VariableDeclarator, WhileStatement, WithStatement, YieldExpression, Param, ExprOrSpread, TsConstAssertion, Import, SuperPropExpression } from "./types";
1
+ import { Accessibility, Argument, ArrayExpression, ArrayPattern, ArrowFunctionExpression, AssignmentExpression, AssignmentPattern, AssignmentPatternProperty, AssignmentProperty, AwaitExpression, BigIntLiteral, BinaryExpression, BindingIdentifier, BlockStatement, BooleanLiteral, BreakStatement, CallExpression, CatchClause, Class, ClassDeclaration, ClassExpression, ClassMember, ClassMethod, ClassProperty, ComputedPropName, ConditionalExpression, Constructor, ContinueStatement, DebuggerStatement, Declaration, Decorator, DefaultDecl, DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportDefaultExpression, ExportDefaultSpecifier, ExportNamedDeclaration, ExportNamespaceSpecifier, ExportSpecifier, ExprOrSpread, Expression, ExpressionStatement, Fn, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, GetterProperty, Identifier, IfStatement, Import, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, JSXAttrValue, JSXAttribute, JSXAttributeName, JSXAttributeOrSpread, JSXClosingElement, JSXClosingFragment, JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpression, JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXNamespacedName, JSXObject, JSXOpeningElement, JSXOpeningFragment, JSXSpreadChild, JSXText, KeyValuePatternProperty, KeyValueProperty, LabeledStatement, MemberExpression, MetaProperty, MethodProperty, Module, ModuleDeclaration, ModuleExportName, ModuleItem, NamedExportSpecifier, NamedImportSpecifier, NewExpression, NullLiteral, NumericLiteral, ObjectExpression, ObjectPattern, ObjectPatternProperty, OptionalChainingCall, OptionalChainingExpression, Param, ParenthesisExpression, Pattern, PrivateMethod, PrivateName, PrivateProperty, Program, Property, PropertyName, RegExpLiteral, RestElement, ReturnStatement, Script, SequenceExpression, SetterProperty, SpreadElement, Statement, StaticBlock, StringLiteral, Super, SuperPropExpression, SwitchCase, SwitchStatement, TaggedTemplateExpression, TemplateLiteral, ThisExpression, ThrowStatement, TryStatement, TsAsExpression, TsCallSignatureDeclaration, TsConstAssertion, TsConstructSignatureDeclaration, TsEntityName, TsEnumDeclaration, TsEnumMember, TsEnumMemberId, TsExportAssignment, TsExpressionWithTypeArguments, TsExternalModuleReference, TsFnParameter, TsGetterSignature, TsImportEqualsDeclaration, TsIndexSignature, TsInstantiation, TsInterfaceBody, TsInterfaceDeclaration, TsMethodSignature, TsModuleBlock, TsModuleDeclaration, TsModuleName, TsModuleReference, TsNamespaceBody, TsNamespaceDeclaration, TsNamespaceExportDeclaration, TsNonNullExpression, TsParameterProperty, TsParameterPropertyParameter, TsPropertySignature, TsQualifiedName, TsSatisfiesExpression, TsSetterSignature, TsType, TsTypeAliasDeclaration, TsTypeAnnotation, TsTypeAssertion, TsTypeElement, TsTypeParameter, TsTypeParameterDeclaration, TsTypeParameterInstantiation, UnaryExpression, UpdateExpression, VariableDeclaration, VariableDeclarator, WhileStatement, WithStatement, YieldExpression } from "@swc/types";
2
+ /**
3
+ * @deprecated JavaScript API is deprecated. Please use Wasm plugin instead.
4
+ */
2
5
  export declare class Visitor {
3
6
  visitProgram(n: Program): Program;
4
7
  visitModule(m: Module): Module;
@@ -127,6 +130,7 @@ export declare class Visitor {
127
130
  visitTsInstantiation(n: TsInstantiation): TsInstantiation;
128
131
  visitTsNonNullExpression(n: TsNonNullExpression): Expression;
129
132
  visitTsAsExpression(n: TsAsExpression): Expression;
133
+ visitTsSatisfiesExpression(n: TsSatisfiesExpression): Expression;
130
134
  visitThisExpression(n: ThisExpression): Expression;
131
135
  visitTemplateLiteral(n: TemplateLiteral): Expression;
132
136
  visitParameters(n: Param[]): Param[];
@@ -192,7 +196,7 @@ export declare class Visitor {
192
196
  visitNamedImportSpecifier(node: NamedImportSpecifier): NamedImportSpecifier;
193
197
  visitImportNamespaceSpecifier(node: ImportNamespaceSpecifier): ImportNamespaceSpecifier;
194
198
  visitImportDefaultSpecifier(node: ImportDefaultSpecifier): ImportSpecifier;
195
- visitBindingIdentifier(i: Identifier): Identifier;
199
+ visitBindingIdentifier(i: BindingIdentifier): BindingIdentifier;
196
200
  visitIdentifierReference(i: Identifier): Identifier;
197
201
  visitLabelIdentifier(label: Identifier): Identifier;
198
202
  visitIdentifier(n: Identifier): Identifier;
package/Visitor.js CHANGED
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Visitor = void 0;
4
+ /**
5
+ * @deprecated JavaScript API is deprecated. Please use Wasm plugin instead.
6
+ */
4
7
  class Visitor {
5
8
  visitProgram(n) {
6
9
  switch (n.type) {
@@ -505,7 +508,6 @@ class Visitor {
505
508
  return n;
506
509
  }
507
510
  visitTsPropertySignature(n) {
508
- n.params = this.visitTsFnParameters(n.params);
509
511
  n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation);
510
512
  return n;
511
513
  }
@@ -813,6 +815,8 @@ class Visitor {
813
815
  return this.visitThisExpression(n);
814
816
  case "TsAsExpression":
815
817
  return this.visitTsAsExpression(n);
818
+ case "TsSatisfiesExpression":
819
+ return this.visitTsSatisfiesExpression(n);
816
820
  case "TsNonNullExpression":
817
821
  return this.visitTsNonNullExpression(n);
818
822
  case "TsTypeAssertion":
@@ -903,6 +907,11 @@ class Visitor {
903
907
  n.typeAnnotation = this.visitTsType(n.typeAnnotation);
904
908
  return n;
905
909
  }
910
+ visitTsSatisfiesExpression(n) {
911
+ n.expression = this.visitExpression(n.expression);
912
+ n.typeAnnotation = this.visitTsType(n.typeAnnotation);
913
+ return n;
914
+ }
906
915
  visitThisExpression(n) {
907
916
  return n;
908
917
  }
@@ -1036,15 +1045,15 @@ class Visitor {
1036
1045
  visitMemberExpression(n) {
1037
1046
  n.object = this.visitExpression(n.object);
1038
1047
  switch (n.property.type) {
1039
- case 'Computed': {
1048
+ case "Computed": {
1040
1049
  n.property = this.visitComputedPropertyKey(n.property);
1041
1050
  return n;
1042
1051
  }
1043
- case 'Identifier': {
1052
+ case "Identifier": {
1044
1053
  n.property = this.visitIdentifier(n.property);
1045
1054
  return n;
1046
1055
  }
1047
- case 'PrivateName': {
1056
+ case "PrivateName": {
1048
1057
  n.property = this.visitPrivateName(n.property);
1049
1058
  return n;
1050
1059
  }
@@ -1052,11 +1061,11 @@ class Visitor {
1052
1061
  }
1053
1062
  visitSuperPropExpression(n) {
1054
1063
  switch (n.property.type) {
1055
- case 'Computed': {
1064
+ case "Computed": {
1056
1065
  n.property = this.visitComputedPropertyKey(n.property);
1057
1066
  return n;
1058
1067
  }
1059
- case 'Identifier': {
1068
+ case "Identifier": {
1060
1069
  n.property = this.visitIdentifier(n.property);
1061
1070
  return n;
1062
1071
  }
@@ -1301,6 +1310,9 @@ class Visitor {
1301
1310
  return node;
1302
1311
  }
1303
1312
  visitBindingIdentifier(i) {
1313
+ if (i.typeAnnotation) {
1314
+ i.typeAnnotation = this.visitTsTypeAnnotation(i.typeAnnotation);
1315
+ }
1304
1316
  return this.visitIdentifier(i);
1305
1317
  }
1306
1318
  visitIdentifierReference(i) {
package/binding.d.ts CHANGED
@@ -1,16 +1,59 @@
1
- export const bundle: any;
2
- export const minify: any;
3
- export const minifySync: any;
4
- export const parse: any;
5
- export const parseSync: any;
6
- export const parseFileSync: any;
7
- export const parseFile: any;
8
- export const print: any;
9
- export const printSync: any;
10
- export const transform: any;
11
- export const transformSync: any;
12
- export const transformFile: any;
13
- export const transformFileSync: any;
14
- export const getTargetTriple: any;
15
- export const initCustomTraceSubscriber: any;
16
- export const Compiler: any;
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+
4
+ export class Compiler {
5
+ constructor()
6
+ }
7
+ export type JsCompiler = Compiler
8
+
9
+ export declare function analyze(src: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<string>
10
+
11
+ export declare function bundle(confItems: Buffer, signal?: AbortSignal | undefined | null): Promise<{ [index: string]: { code: string, map?: string } }>
12
+
13
+ export declare function getTargetTriple(): string
14
+
15
+ export declare function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void
16
+
17
+ export declare function minify(code: Buffer, opts: Buffer, isJson: boolean, extras: NapiMinifyExtra, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
18
+
19
+ export declare function minifySync(code: Buffer, opts: Buffer, isJson: boolean, extras: NapiMinifyExtra): TransformOutput
20
+
21
+ export interface NapiMinifyExtra {
22
+ mangleNameCache?: object
23
+ }
24
+
25
+ export declare function newMangleNameCache(): object
26
+
27
+ export declare function parse(src: Buffer | string, options: Buffer, filename?: string | undefined | null, signal?: AbortSignal | undefined | null): Promise<string>
28
+
29
+ export declare function parseFile(path: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<string>
30
+
31
+ export declare function parseFileSync(path: string, opts: Buffer): string
32
+
33
+ export declare function parseSync(src: Buffer | string, opts: Buffer, filename?: string | undefined | null): string
34
+
35
+ export declare function print(programJson: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
36
+
37
+ export declare function printSync(program: string, options: Buffer): TransformOutput
38
+
39
+ export declare function transform(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
40
+
41
+ export declare function transformFile(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise<TransformOutput>
42
+
43
+ export declare function transformFileSync(s: string, isModule: boolean, opts: Buffer): TransformOutput
44
+
45
+ export interface TransformOutput {
46
+ code: string
47
+ map?: string
48
+ output?: string
49
+ diagnostics: Array<string>
50
+ }
51
+
52
+ /** Hack for `Type Generation` */
53
+ export interface TransformOutput {
54
+ code: string
55
+ map?: string
56
+ }
57
+
58
+ export declare function transformSync(s: string, isModule: boolean, opts: Buffer): TransformOutput
59
+