oxc-parser 0.69.0 → 0.70.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/generated/deserialize/js.js +31 -16
- package/generated/deserialize/ts.js +37 -22
- package/index.d.ts +2 -1
- package/package.json +21 -18
|
@@ -923,7 +923,7 @@ function deserializeImportDeclaration(pos) {
|
|
|
923
923
|
end: deserializeU32(pos + 4),
|
|
924
924
|
specifiers,
|
|
925
925
|
source: deserializeStringLiteral(pos + 40),
|
|
926
|
-
attributes: withClause === null ? [] : withClause.
|
|
926
|
+
attributes: withClause === null ? [] : withClause.attributes,
|
|
927
927
|
};
|
|
928
928
|
}
|
|
929
929
|
|
|
@@ -957,11 +957,7 @@ function deserializeImportNamespaceSpecifier(pos) {
|
|
|
957
957
|
|
|
958
958
|
function deserializeWithClause(pos) {
|
|
959
959
|
return {
|
|
960
|
-
|
|
961
|
-
start: deserializeU32(pos),
|
|
962
|
-
end: deserializeU32(pos + 4),
|
|
963
|
-
attributesKeyword: deserializeIdentifierName(pos + 8),
|
|
964
|
-
withEntries: deserializeVecImportAttribute(pos + 32),
|
|
960
|
+
attributes: deserializeVecImportAttribute(pos + 32),
|
|
965
961
|
};
|
|
966
962
|
}
|
|
967
963
|
|
|
@@ -984,7 +980,7 @@ function deserializeExportNamedDeclaration(pos) {
|
|
|
984
980
|
declaration: deserializeOptionDeclaration(pos + 8),
|
|
985
981
|
specifiers: deserializeVecExportSpecifier(pos + 24),
|
|
986
982
|
source: deserializeOptionStringLiteral(pos + 56),
|
|
987
|
-
attributes: withClause === null ? [] : withClause.
|
|
983
|
+
attributes: withClause === null ? [] : withClause.attributes,
|
|
988
984
|
};
|
|
989
985
|
}
|
|
990
986
|
|
|
@@ -1005,7 +1001,7 @@ function deserializeExportAllDeclaration(pos) {
|
|
|
1005
1001
|
end: deserializeU32(pos + 4),
|
|
1006
1002
|
exported: deserializeOptionModuleExportName(pos + 8),
|
|
1007
1003
|
source: deserializeStringLiteral(pos + 64),
|
|
1008
|
-
attributes: withClause === null ? [] : withClause.
|
|
1004
|
+
attributes: withClause === null ? [] : withClause.attributes,
|
|
1009
1005
|
};
|
|
1010
1006
|
}
|
|
1011
1007
|
|
|
@@ -1802,13 +1798,32 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
1802
1798
|
|
|
1803
1799
|
// Flatten `body`, and nest `id`
|
|
1804
1800
|
if (body !== null && body.type === 'TSModuleDeclaration') {
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1801
|
+
let innerId = body.id;
|
|
1802
|
+
if (innerId.type === 'Identifier') {
|
|
1803
|
+
id = {
|
|
1804
|
+
type: 'TSQualifiedName',
|
|
1805
|
+
start: id.start,
|
|
1806
|
+
end: innerId.end,
|
|
1807
|
+
left: id,
|
|
1808
|
+
right: innerId,
|
|
1809
|
+
};
|
|
1810
|
+
} else {
|
|
1811
|
+
// Replace `left` of innermost `TSQualifiedName` with a nested `TSQualifiedName` with `id` of
|
|
1812
|
+
// this module on left, and previous `left` of innermost `TSQualifiedName` on right
|
|
1813
|
+
while (true) {
|
|
1814
|
+
innerId.start = id.start;
|
|
1815
|
+
if (innerId.left.type === 'Identifier') break;
|
|
1816
|
+
innerId = innerId.left;
|
|
1817
|
+
}
|
|
1818
|
+
innerId.left = {
|
|
1819
|
+
type: 'TSQualifiedName',
|
|
1820
|
+
start: id.start,
|
|
1821
|
+
end: innerId.left.end,
|
|
1822
|
+
left: id,
|
|
1823
|
+
right: innerId.left,
|
|
1824
|
+
};
|
|
1825
|
+
id = body.id;
|
|
1826
|
+
}
|
|
1812
1827
|
body = Object.hasOwn(body, 'body') ? body.body : null;
|
|
1813
1828
|
}
|
|
1814
1829
|
|
|
@@ -1897,7 +1912,7 @@ function deserializeTSConstructorType(pos) {
|
|
|
1897
1912
|
}
|
|
1898
1913
|
|
|
1899
1914
|
function deserializeTSMappedType(pos) {
|
|
1900
|
-
let optional = deserializeOptionTSMappedTypeModifierOperator(pos + 48)
|
|
1915
|
+
let optional = deserializeOptionTSMappedTypeModifierOperator(pos + 48);
|
|
1901
1916
|
if (optional === null) optional = false;
|
|
1902
1917
|
const typeParameter = deserializeBoxTSTypeParameter(pos + 8);
|
|
1903
1918
|
return {
|
|
@@ -426,9 +426,9 @@ function deserializeAssignmentTargetPropertyIdentifier(pos) {
|
|
|
426
426
|
end: end,
|
|
427
427
|
left: keyCopy,
|
|
428
428
|
right: init,
|
|
429
|
-
typeAnnotation: null,
|
|
430
|
-
optional: false,
|
|
431
429
|
decorators: [],
|
|
430
|
+
optional: false,
|
|
431
|
+
typeAnnotation: null,
|
|
432
432
|
};
|
|
433
433
|
return {
|
|
434
434
|
type: 'Property',
|
|
@@ -858,11 +858,11 @@ function deserializeFormalParameters(pos) {
|
|
|
858
858
|
start: deserializeU32(pos),
|
|
859
859
|
end: deserializeU32(pos + 4),
|
|
860
860
|
argument: deserializeBindingPatternKind(pos + 8),
|
|
861
|
+
decorators: [],
|
|
862
|
+
optional: deserializeBool(pos + 32),
|
|
861
863
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(
|
|
862
864
|
pos + 24,
|
|
863
865
|
),
|
|
864
|
-
optional: deserializeBool(pos + 32),
|
|
865
|
-
decorators: [],
|
|
866
866
|
value: null,
|
|
867
867
|
});
|
|
868
868
|
}
|
|
@@ -877,9 +877,9 @@ function deserializeFormalParameter(pos) {
|
|
|
877
877
|
if (accessibility === null && !readonly && !override) {
|
|
878
878
|
param = {
|
|
879
879
|
...deserializeBindingPatternKind(pos + 40),
|
|
880
|
-
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
881
|
-
optional: deserializeBool(pos + 64),
|
|
882
880
|
decorators: deserializeVecDecorator(pos + 8),
|
|
881
|
+
optional: deserializeBool(pos + 64),
|
|
882
|
+
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
883
883
|
};
|
|
884
884
|
} else {
|
|
885
885
|
param = {
|
|
@@ -1070,7 +1070,7 @@ function deserializeImportDeclaration(pos) {
|
|
|
1070
1070
|
end: deserializeU32(pos + 4),
|
|
1071
1071
|
specifiers,
|
|
1072
1072
|
source: deserializeStringLiteral(pos + 40),
|
|
1073
|
-
attributes: withClause === null ? [] : withClause.
|
|
1073
|
+
attributes: withClause === null ? [] : withClause.attributes,
|
|
1074
1074
|
importKind: deserializeImportOrExportKind(pos + 104),
|
|
1075
1075
|
};
|
|
1076
1076
|
}
|
|
@@ -1106,11 +1106,7 @@ function deserializeImportNamespaceSpecifier(pos) {
|
|
|
1106
1106
|
|
|
1107
1107
|
function deserializeWithClause(pos) {
|
|
1108
1108
|
return {
|
|
1109
|
-
|
|
1110
|
-
start: deserializeU32(pos),
|
|
1111
|
-
end: deserializeU32(pos + 4),
|
|
1112
|
-
attributesKeyword: deserializeIdentifierName(pos + 8),
|
|
1113
|
-
withEntries: deserializeVecImportAttribute(pos + 32),
|
|
1109
|
+
attributes: deserializeVecImportAttribute(pos + 32),
|
|
1114
1110
|
};
|
|
1115
1111
|
}
|
|
1116
1112
|
|
|
@@ -1133,7 +1129,7 @@ function deserializeExportNamedDeclaration(pos) {
|
|
|
1133
1129
|
declaration: deserializeOptionDeclaration(pos + 8),
|
|
1134
1130
|
specifiers: deserializeVecExportSpecifier(pos + 24),
|
|
1135
1131
|
source: deserializeOptionStringLiteral(pos + 56),
|
|
1136
|
-
attributes: withClause === null ? [] : withClause.
|
|
1132
|
+
attributes: withClause === null ? [] : withClause.attributes,
|
|
1137
1133
|
exportKind: deserializeImportOrExportKind(pos + 104),
|
|
1138
1134
|
};
|
|
1139
1135
|
}
|
|
@@ -1156,7 +1152,7 @@ function deserializeExportAllDeclaration(pos) {
|
|
|
1156
1152
|
end: deserializeU32(pos + 4),
|
|
1157
1153
|
exported: deserializeOptionModuleExportName(pos + 8),
|
|
1158
1154
|
source: deserializeStringLiteral(pos + 64),
|
|
1159
|
-
attributes: withClause === null ? [] : withClause.
|
|
1155
|
+
attributes: withClause === null ? [] : withClause.attributes,
|
|
1160
1156
|
exportKind: deserializeImportOrExportKind(pos + 120),
|
|
1161
1157
|
};
|
|
1162
1158
|
}
|
|
@@ -1954,13 +1950,32 @@ function deserializeTSModuleDeclaration(pos) {
|
|
|
1954
1950
|
|
|
1955
1951
|
// Flatten `body`, and nest `id`
|
|
1956
1952
|
if (body !== null && body.type === 'TSModuleDeclaration') {
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1953
|
+
let innerId = body.id;
|
|
1954
|
+
if (innerId.type === 'Identifier') {
|
|
1955
|
+
id = {
|
|
1956
|
+
type: 'TSQualifiedName',
|
|
1957
|
+
start: id.start,
|
|
1958
|
+
end: innerId.end,
|
|
1959
|
+
left: id,
|
|
1960
|
+
right: innerId,
|
|
1961
|
+
};
|
|
1962
|
+
} else {
|
|
1963
|
+
// Replace `left` of innermost `TSQualifiedName` with a nested `TSQualifiedName` with `id` of
|
|
1964
|
+
// this module on left, and previous `left` of innermost `TSQualifiedName` on right
|
|
1965
|
+
while (true) {
|
|
1966
|
+
innerId.start = id.start;
|
|
1967
|
+
if (innerId.left.type === 'Identifier') break;
|
|
1968
|
+
innerId = innerId.left;
|
|
1969
|
+
}
|
|
1970
|
+
innerId.left = {
|
|
1971
|
+
type: 'TSQualifiedName',
|
|
1972
|
+
start: id.start,
|
|
1973
|
+
end: innerId.left.end,
|
|
1974
|
+
left: id,
|
|
1975
|
+
right: innerId.left,
|
|
1976
|
+
};
|
|
1977
|
+
id = body.id;
|
|
1978
|
+
}
|
|
1964
1979
|
body = Object.hasOwn(body, 'body') ? body.body : null;
|
|
1965
1980
|
}
|
|
1966
1981
|
|
|
@@ -2049,7 +2064,7 @@ function deserializeTSConstructorType(pos) {
|
|
|
2049
2064
|
}
|
|
2050
2065
|
|
|
2051
2066
|
function deserializeTSMappedType(pos) {
|
|
2052
|
-
let optional = deserializeOptionTSMappedTypeModifierOperator(pos + 48)
|
|
2067
|
+
let optional = deserializeOptionTSMappedTypeModifierOperator(pos + 48);
|
|
2053
2068
|
if (optional === null) optional = false;
|
|
2054
2069
|
const typeParameter = deserializeBoxTSTypeParameter(pos + 8);
|
|
2055
2070
|
return {
|
package/index.d.ts
CHANGED
|
@@ -140,9 +140,10 @@ export interface OxcError {
|
|
|
140
140
|
export declare function parseAsync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>
|
|
141
141
|
|
|
142
142
|
export interface ParserOptions {
|
|
143
|
-
sourceType?: 'script' | 'module' | 'unambiguous' | undefined
|
|
144
143
|
/** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
|
|
145
144
|
lang?: 'js' | 'jsx' | 'ts' | 'tsx'
|
|
145
|
+
/** Treat the source text as `script` or `module` code. */
|
|
146
|
+
sourceType?: 'script' | 'module' | 'unambiguous' | undefined
|
|
146
147
|
/**
|
|
147
148
|
* Return an AST which includes TypeScript-related properties, or excludes them.
|
|
148
149
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.70.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"browser": "wasm.mjs",
|
|
6
6
|
"engines": {
|
|
@@ -39,15 +39,16 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@oxc-project/types": "^0.
|
|
42
|
+
"@oxc-project/types": "^0.70.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@codspeed/vitest-plugin": "^4.0.0",
|
|
46
46
|
"@napi-rs/wasm-runtime": "^0.2.7",
|
|
47
|
-
"@vitest/browser": "3.1.
|
|
47
|
+
"@vitest/browser": "3.1.3",
|
|
48
48
|
"esbuild": "^0.25.0",
|
|
49
49
|
"playwright": "^1.51.0",
|
|
50
|
-
"vitest": "3.1.
|
|
50
|
+
"vitest": "3.1.3",
|
|
51
|
+
"typescript": "5.8.3"
|
|
51
52
|
},
|
|
52
53
|
"napi": {
|
|
53
54
|
"binaryName": "parser",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"aarch64-unknown-linux-gnu",
|
|
62
63
|
"aarch64-unknown-linux-musl",
|
|
63
64
|
"armv7-unknown-linux-gnueabihf",
|
|
65
|
+
"armv7-unknown-linux-musleabihf",
|
|
64
66
|
"s390x-unknown-linux-gnu",
|
|
65
67
|
"riscv64gc-unknown-linux-gnu",
|
|
66
68
|
"x86_64-apple-darwin",
|
|
@@ -75,19 +77,20 @@
|
|
|
75
77
|
"dtsHeaderFile": "header.js"
|
|
76
78
|
},
|
|
77
79
|
"optionalDependencies": {
|
|
78
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
79
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
80
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
81
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
82
|
-
"@oxc-parser/binding-freebsd-x64": "0.
|
|
83
|
-
"@oxc-parser/binding-linux-arm64-gnu": "0.
|
|
84
|
-
"@oxc-parser/binding-linux-arm64-musl": "0.
|
|
85
|
-
"@oxc-parser/binding-linux-arm-gnueabihf": "0.
|
|
86
|
-
"@oxc-parser/binding-linux-
|
|
87
|
-
"@oxc-parser/binding-linux-
|
|
88
|
-
"@oxc-parser/binding-
|
|
89
|
-
"@oxc-parser/binding-darwin-
|
|
90
|
-
"@oxc-parser/binding-
|
|
80
|
+
"@oxc-parser/binding-win32-x64-msvc": "0.70.0",
|
|
81
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.70.0",
|
|
82
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.70.0",
|
|
83
|
+
"@oxc-parser/binding-linux-x64-musl": "0.70.0",
|
|
84
|
+
"@oxc-parser/binding-freebsd-x64": "0.70.0",
|
|
85
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.70.0",
|
|
86
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.70.0",
|
|
87
|
+
"@oxc-parser/binding-linux-arm-gnueabihf": "0.70.0",
|
|
88
|
+
"@oxc-parser/binding-linux-arm-musleabihf": "0.70.0",
|
|
89
|
+
"@oxc-parser/binding-linux-s390x-gnu": "0.70.0",
|
|
90
|
+
"@oxc-parser/binding-linux-riscv64-gnu": "0.70.0",
|
|
91
|
+
"@oxc-parser/binding-darwin-x64": "0.70.0",
|
|
92
|
+
"@oxc-parser/binding-darwin-arm64": "0.70.0",
|
|
93
|
+
"@oxc-parser/binding-wasm32-wasi": "0.70.0"
|
|
91
94
|
},
|
|
92
95
|
"scripts": {
|
|
93
96
|
"build-dev": "napi build --no-dts-cache --platform --js bindings.js",
|
|
@@ -96,7 +99,7 @@
|
|
|
96
99
|
"build-wasi": "pnpm run build-dev --release --target wasm32-wasip1-threads",
|
|
97
100
|
"build-npm-dir": "rm -rf npm-dir && napi create-npm-dirs --npm-dir npm-dir && pnpm napi artifacts --npm-dir npm-dir --output-dir .",
|
|
98
101
|
"build-browser-bundle": "node build-browser-bundle.mjs",
|
|
99
|
-
"test": "pnpm run test-node run
|
|
102
|
+
"test": "tsc && pnpm run test-node run",
|
|
100
103
|
"test-node": "vitest --dir ./test",
|
|
101
104
|
"test-browser": "vitest -c vitest.config.browser.mts",
|
|
102
105
|
"bench": "vitest bench --run ./bench.bench.mjs"
|