oxc-parser 0.61.2 → 0.62.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/bindings.js +8 -0
- package/deserialize-js.js +15 -3
- package/deserialize-ts.js +12 -3
- package/package.json +16 -14
- package/webcontainer-fallback.js +23 -0
package/bindings.js
CHANGED
|
@@ -359,6 +359,14 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
|
|
363
|
+
try {
|
|
364
|
+
nativeBinding = require('./webcontainer-fallback.js');
|
|
365
|
+
} catch (err) {
|
|
366
|
+
loadErrors.push(err)
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
362
370
|
if (!nativeBinding) {
|
|
363
371
|
if (loadErrors.length > 0) {
|
|
364
372
|
// TODO Link to documentation with potential fixes
|
package/deserialize-js.js
CHANGED
|
@@ -1061,11 +1061,15 @@ function deserializeNumericLiteral(pos) {
|
|
|
1061
1061
|
}
|
|
1062
1062
|
|
|
1063
1063
|
function deserializeStringLiteral(pos) {
|
|
1064
|
+
let value = deserializeStr(pos + 8);
|
|
1065
|
+
if (deserializeBool(pos + 40)) {
|
|
1066
|
+
value = value.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
|
|
1067
|
+
}
|
|
1064
1068
|
return {
|
|
1065
1069
|
type: 'Literal',
|
|
1066
1070
|
start: deserializeU32(pos),
|
|
1067
1071
|
end: deserializeU32(pos + 4),
|
|
1068
|
-
value
|
|
1072
|
+
value,
|
|
1069
1073
|
raw: deserializeOptionStr(pos + 24),
|
|
1070
1074
|
};
|
|
1071
1075
|
}
|
|
@@ -1610,12 +1614,13 @@ function deserializeTSClassImplements(pos) {
|
|
|
1610
1614
|
}
|
|
1611
1615
|
|
|
1612
1616
|
function deserializeTSInterfaceDeclaration(pos) {
|
|
1617
|
+
const extendsArr = deserializeOptionVecTSInterfaceHeritage(pos + 40);
|
|
1613
1618
|
return {
|
|
1614
1619
|
type: 'TSInterfaceDeclaration',
|
|
1615
1620
|
start: deserializeU32(pos),
|
|
1616
1621
|
end: deserializeU32(pos + 4),
|
|
1617
1622
|
id: deserializeBindingIdentifier(pos + 8),
|
|
1618
|
-
extends:
|
|
1623
|
+
extends: extendsArr === null ? [] : extendsArr,
|
|
1619
1624
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 72),
|
|
1620
1625
|
body: deserializeBoxTSInterfaceBody(pos + 80),
|
|
1621
1626
|
declare: deserializeBool(pos + 88),
|
|
@@ -1641,6 +1646,8 @@ function deserializeTSPropertySignature(pos) {
|
|
|
1641
1646
|
readonly: deserializeBool(pos + 10),
|
|
1642
1647
|
key: deserializePropertyKey(pos + 16),
|
|
1643
1648
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 32),
|
|
1649
|
+
accessibility: null,
|
|
1650
|
+
static: false,
|
|
1644
1651
|
};
|
|
1645
1652
|
}
|
|
1646
1653
|
|
|
@@ -1653,6 +1660,7 @@ function deserializeTSIndexSignature(pos) {
|
|
|
1653
1660
|
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 40),
|
|
1654
1661
|
readonly: deserializeBool(pos + 48),
|
|
1655
1662
|
static: deserializeBool(pos + 49),
|
|
1663
|
+
accessibility: null,
|
|
1656
1664
|
};
|
|
1657
1665
|
}
|
|
1658
1666
|
|
|
@@ -1677,9 +1685,11 @@ function deserializeTSMethodSignature(pos) {
|
|
|
1677
1685
|
optional: deserializeBool(pos + 25),
|
|
1678
1686
|
kind: deserializeTSMethodSignatureKind(pos + 26),
|
|
1679
1687
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 32),
|
|
1680
|
-
thisParam: deserializeOptionBoxTSThisParameter(pos + 40),
|
|
1681
1688
|
params: deserializeBoxFormalParameters(pos + 48),
|
|
1682
1689
|
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
1690
|
+
accessibility: null,
|
|
1691
|
+
readonly: false,
|
|
1692
|
+
static: false,
|
|
1683
1693
|
};
|
|
1684
1694
|
}
|
|
1685
1695
|
|
|
@@ -1701,6 +1711,8 @@ function deserializeTSIndexSignatureName(pos) {
|
|
|
1701
1711
|
end: deserializeU32(pos + 4),
|
|
1702
1712
|
name: deserializeStr(pos + 8),
|
|
1703
1713
|
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 24),
|
|
1714
|
+
decorators: [],
|
|
1715
|
+
optional: false,
|
|
1704
1716
|
};
|
|
1705
1717
|
}
|
|
1706
1718
|
|
package/deserialize-ts.js
CHANGED
|
@@ -1126,11 +1126,15 @@ function deserializeNumericLiteral(pos) {
|
|
|
1126
1126
|
}
|
|
1127
1127
|
|
|
1128
1128
|
function deserializeStringLiteral(pos) {
|
|
1129
|
+
let value = deserializeStr(pos + 8);
|
|
1130
|
+
if (deserializeBool(pos + 40)) {
|
|
1131
|
+
value = value.replace(/\uFFFD(.{4})/g, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
|
|
1132
|
+
}
|
|
1129
1133
|
return {
|
|
1130
1134
|
type: 'Literal',
|
|
1131
1135
|
start: deserializeU32(pos),
|
|
1132
1136
|
end: deserializeU32(pos + 4),
|
|
1133
|
-
value
|
|
1137
|
+
value,
|
|
1134
1138
|
raw: deserializeOptionStr(pos + 24),
|
|
1135
1139
|
};
|
|
1136
1140
|
}
|
|
@@ -1676,12 +1680,13 @@ function deserializeTSClassImplements(pos) {
|
|
|
1676
1680
|
}
|
|
1677
1681
|
|
|
1678
1682
|
function deserializeTSInterfaceDeclaration(pos) {
|
|
1683
|
+
const extendsArr = deserializeOptionVecTSInterfaceHeritage(pos + 40);
|
|
1679
1684
|
return {
|
|
1680
1685
|
type: 'TSInterfaceDeclaration',
|
|
1681
1686
|
start: deserializeU32(pos),
|
|
1682
1687
|
end: deserializeU32(pos + 4),
|
|
1683
1688
|
id: deserializeBindingIdentifier(pos + 8),
|
|
1684
|
-
extends:
|
|
1689
|
+
extends: extendsArr === null ? [] : extendsArr,
|
|
1685
1690
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 72),
|
|
1686
1691
|
body: deserializeBoxTSInterfaceBody(pos + 80),
|
|
1687
1692
|
declare: deserializeBool(pos + 88),
|
|
@@ -1707,6 +1712,8 @@ function deserializeTSPropertySignature(pos) {
|
|
|
1707
1712
|
readonly: deserializeBool(pos + 10),
|
|
1708
1713
|
key: deserializePropertyKey(pos + 16),
|
|
1709
1714
|
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 32),
|
|
1715
|
+
accessibility: null,
|
|
1716
|
+
static: false,
|
|
1710
1717
|
};
|
|
1711
1718
|
}
|
|
1712
1719
|
|
|
@@ -1744,9 +1751,11 @@ function deserializeTSMethodSignature(pos) {
|
|
|
1744
1751
|
optional: deserializeBool(pos + 25),
|
|
1745
1752
|
kind: deserializeTSMethodSignatureKind(pos + 26),
|
|
1746
1753
|
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 32),
|
|
1747
|
-
thisParam: deserializeOptionBoxTSThisParameter(pos + 40),
|
|
1748
1754
|
params: deserializeBoxFormalParameters(pos + 48),
|
|
1749
1755
|
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
|
|
1756
|
+
accessibility: null,
|
|
1757
|
+
readonly: false,
|
|
1758
|
+
static: false,
|
|
1750
1759
|
};
|
|
1751
1760
|
}
|
|
1752
1761
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"browser": "wasm.mjs",
|
|
6
6
|
"engines": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"wrap.mjs",
|
|
31
31
|
"wasm.mjs",
|
|
32
32
|
"bindings.js",
|
|
33
|
+
"webcontainer-fallback.js",
|
|
33
34
|
"deserialize-js.js",
|
|
34
35
|
"deserialize-ts.js"
|
|
35
36
|
],
|
|
@@ -38,15 +39,15 @@
|
|
|
38
39
|
"access": "public"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@oxc-project/types": "^0.
|
|
42
|
+
"@oxc-project/types": "^0.62.0"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@codspeed/vitest-plugin": "^4.0.0",
|
|
45
46
|
"@napi-rs/wasm-runtime": "^0.2.7",
|
|
46
|
-
"@vitest/browser": "3.0.
|
|
47
|
+
"@vitest/browser": "3.0.9",
|
|
47
48
|
"esbuild": "^0.25.0",
|
|
48
49
|
"playwright": "^1.51.0",
|
|
49
|
-
"vitest": "3.0.
|
|
50
|
+
"vitest": "3.0.9"
|
|
50
51
|
},
|
|
51
52
|
"napi": {
|
|
52
53
|
"binaryName": "parser",
|
|
@@ -71,20 +72,21 @@
|
|
|
71
72
|
"dtsHeaderFile": "header.js"
|
|
72
73
|
},
|
|
73
74
|
"optionalDependencies": {
|
|
74
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
75
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
76
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
77
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
78
|
-
"@oxc-parser/binding-linux-arm64-gnu": "0.
|
|
79
|
-
"@oxc-parser/binding-linux-arm64-musl": "0.
|
|
80
|
-
"@oxc-parser/binding-linux-arm-gnueabihf": "0.
|
|
81
|
-
"@oxc-parser/binding-darwin-x64": "0.
|
|
82
|
-
"@oxc-parser/binding-darwin-arm64": "0.
|
|
83
|
-
"@oxc-parser/binding-wasm32-wasi": "0.
|
|
75
|
+
"@oxc-parser/binding-win32-x64-msvc": "0.62.0",
|
|
76
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.62.0",
|
|
77
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.62.0",
|
|
78
|
+
"@oxc-parser/binding-linux-x64-musl": "0.62.0",
|
|
79
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.62.0",
|
|
80
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.62.0",
|
|
81
|
+
"@oxc-parser/binding-linux-arm-gnueabihf": "0.62.0",
|
|
82
|
+
"@oxc-parser/binding-darwin-x64": "0.62.0",
|
|
83
|
+
"@oxc-parser/binding-darwin-arm64": "0.62.0",
|
|
84
|
+
"@oxc-parser/binding-wasm32-wasi": "0.62.0"
|
|
84
85
|
},
|
|
85
86
|
"scripts": {
|
|
86
87
|
"build-dev": "napi build --no-dts-cache --platform --js bindings.js",
|
|
87
88
|
"build": "pnpm run build-dev --features allocator --release",
|
|
89
|
+
"postbuild-dev": "node patch.mjs",
|
|
88
90
|
"build-wasi": "pnpm run build-dev --release --target wasm32-wasip1-threads",
|
|
89
91
|
"build-npm-dir": "rm -rf npm-dir && napi create-npm-dirs --npm-dir npm-dir && pnpm napi artifacts --npm-dir npm-dir --output-dir .",
|
|
90
92
|
"build-browser-bundle": "node build-browser-bundle.mjs",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const childProcess = require('node:child_process');
|
|
3
|
+
|
|
4
|
+
const pkg = JSON.parse(
|
|
5
|
+
fs.readFileSync(require.resolve('oxc-parser/package.json'), 'utf-8'),
|
|
6
|
+
);
|
|
7
|
+
const version = pkg.version;
|
|
8
|
+
const baseDir = `/tmp/oxc-parser-${version}`;
|
|
9
|
+
const bindingEntry = `${baseDir}/node_modules/@oxc-parser/binding-wasm32-wasi/parser.wasi.cjs`;
|
|
10
|
+
|
|
11
|
+
if (!fs.existsSync(bindingEntry)) {
|
|
12
|
+
fs.rmSync(baseDir, { recursive: true, force: true });
|
|
13
|
+
fs.mkdirSync(baseDir, { recursive: true });
|
|
14
|
+
const bindingPkg = `@oxc-parser/binding-wasm32-wasi@${version}`;
|
|
15
|
+
// eslint-disable-next-line: no-console
|
|
16
|
+
console.log(`[oxc-parser] Downloading ${bindingPkg} on WebContainer...`);
|
|
17
|
+
childProcess.execFileSync('pnpm', ['i', bindingPkg], {
|
|
18
|
+
cwd: baseDir,
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = require(bindingEntry);
|