@oxc-parser/binding-wasm32-wasi 0.65.0 → 0.67.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/browser-bundle.mjs +86 -73
- package/package.json +1 -1
- package/parser.wasm32-wasi.wasm +0 -0
package/browser-bundle.mjs
CHANGED
|
@@ -5,7 +5,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
5
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
// ../../node_modules/.pnpm/@napi-rs+wasm-runtime@0.2.
|
|
8
|
+
// ../../node_modules/.pnpm/@napi-rs+wasm-runtime@0.2.9/node_modules/@napi-rs/wasm-runtime/dist/runtime.js
|
|
9
9
|
var _WebAssembly$2 = typeof WebAssembly !== "undefined" ? WebAssembly : typeof WXWebAssembly !== "undefined" ? WXWebAssembly : void 0;
|
|
10
10
|
var ENVIRONMENT_IS_NODE = false;
|
|
11
11
|
function getPostMessage(options) {
|
|
@@ -12481,6 +12481,14 @@ function requireFsProxy() {
|
|
|
12481
12481
|
if (typeof value2 === "bigint") {
|
|
12482
12482
|
return `BigInt(${String(value2)})`;
|
|
12483
12483
|
}
|
|
12484
|
+
if (value2 instanceof Error) {
|
|
12485
|
+
return {
|
|
12486
|
+
...value2,
|
|
12487
|
+
message: value2.message,
|
|
12488
|
+
stack: value2.stack,
|
|
12489
|
+
__error__: value2.constructor.name
|
|
12490
|
+
};
|
|
12491
|
+
}
|
|
12484
12492
|
return value2;
|
|
12485
12493
|
});
|
|
12486
12494
|
const view = new TextEncoder().encode(json);
|
|
@@ -12496,34 +12504,74 @@ function requireFsProxy() {
|
|
|
12496
12504
|
throw new Error("unsupported data");
|
|
12497
12505
|
}
|
|
12498
12506
|
};
|
|
12507
|
+
const decodeValue = (memfs, payload, type) => {
|
|
12508
|
+
if (type === 0) return void 0;
|
|
12509
|
+
if (type === 1) return null;
|
|
12510
|
+
if (type === 2) return Boolean(payload[0]);
|
|
12511
|
+
if (type === 3) return new Float64Array(payload.buffer, payload.byteOffset, 1)[0];
|
|
12512
|
+
if (type === 4) return new TextDecoder().decode(payload.slice());
|
|
12513
|
+
if (type === 6) {
|
|
12514
|
+
const obj = JSON.parse(new TextDecoder().decode(payload.slice()), (_key, value) => {
|
|
12515
|
+
if (typeof value === "string") {
|
|
12516
|
+
const matched = value.match(/^BigInt\((-?\d+)\)$/);
|
|
12517
|
+
if (matched && matched[1]) {
|
|
12518
|
+
return BigInt(matched[1]);
|
|
12519
|
+
}
|
|
12520
|
+
}
|
|
12521
|
+
return value;
|
|
12522
|
+
});
|
|
12523
|
+
if (obj.__constructor__) {
|
|
12524
|
+
const ctor = obj.__constructor__;
|
|
12525
|
+
delete obj.__constructor__;
|
|
12526
|
+
Object.setPrototypeOf(obj, memfs[ctor].prototype);
|
|
12527
|
+
}
|
|
12528
|
+
if (obj.__error__) {
|
|
12529
|
+
const name = obj.__error__;
|
|
12530
|
+
const ErrorConstructor = globalThis[name] || Error;
|
|
12531
|
+
delete obj.__error__;
|
|
12532
|
+
const err = new ErrorConstructor(obj.message);
|
|
12533
|
+
Object.defineProperty(err, "stack", {
|
|
12534
|
+
configurable: true,
|
|
12535
|
+
enumerable: false,
|
|
12536
|
+
writable: true,
|
|
12537
|
+
value: err.stack
|
|
12538
|
+
});
|
|
12539
|
+
Object.defineProperty(err, Symbol.toStringTag, {
|
|
12540
|
+
configurable: true,
|
|
12541
|
+
enumerable: false,
|
|
12542
|
+
writable: true,
|
|
12543
|
+
value: name
|
|
12544
|
+
});
|
|
12545
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
12546
|
+
if (k === "message" || k === "stack") continue;
|
|
12547
|
+
err[k] = v;
|
|
12548
|
+
}
|
|
12549
|
+
return err;
|
|
12550
|
+
}
|
|
12551
|
+
return obj;
|
|
12552
|
+
}
|
|
12553
|
+
if (type === 9) return new BigInt64Array(payload.buffer, payload.byteOffset, 1)[0];
|
|
12554
|
+
throw new Error("unsupported data");
|
|
12555
|
+
};
|
|
12499
12556
|
fsProxy.createOnMessage = (fs) => function onMessage(e) {
|
|
12500
12557
|
if (e.data.__fs__) {
|
|
12501
12558
|
const { sab, type, payload } = e.data.__fs__;
|
|
12502
12559
|
const fn = fs[type];
|
|
12503
|
-
const args = payload ? payload.map((value) => {
|
|
12504
|
-
if (value instanceof Uint8Array) {
|
|
12505
|
-
value._isBuffer = true;
|
|
12506
|
-
}
|
|
12507
|
-
return value;
|
|
12508
|
-
}) : payload;
|
|
12509
12560
|
try {
|
|
12510
|
-
const ret = fn.apply(fs,
|
|
12511
|
-
const t = getType(ret);
|
|
12512
|
-
const v = encodeValue(fs, ret, t);
|
|
12561
|
+
const ret = fn.apply(fs, payload);
|
|
12513
12562
|
Atomics.store(sab, 0, 0);
|
|
12563
|
+
const t = getType(ret);
|
|
12514
12564
|
Atomics.store(sab, 1, t);
|
|
12565
|
+
const v = encodeValue(fs, ret, t);
|
|
12515
12566
|
Atomics.store(sab, 2, v.length);
|
|
12516
12567
|
new Uint8Array(sab.buffer).set(v, 16);
|
|
12517
12568
|
} catch (err) {
|
|
12518
12569
|
Atomics.store(sab, 0, 1);
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12524
|
-
}));
|
|
12525
|
-
Atomics.store(sab, 2, payloadContent.length);
|
|
12526
|
-
new Uint8Array(sab.buffer).set(payloadContent, 16);
|
|
12570
|
+
const t = getType(err);
|
|
12571
|
+
Atomics.store(sab, 1, t);
|
|
12572
|
+
const v = encodeValue(fs, err, t);
|
|
12573
|
+
Atomics.store(sab, 2, v.length);
|
|
12574
|
+
new Uint8Array(sab.buffer).set(v, 16);
|
|
12527
12575
|
} finally {
|
|
12528
12576
|
Atomics.notify(sab, 0);
|
|
12529
12577
|
}
|
|
@@ -12532,7 +12580,7 @@ function requireFsProxy() {
|
|
|
12532
12580
|
fsProxy.createFsProxy = (memfs) => new Proxy({}, {
|
|
12533
12581
|
get(_target, p, _receiver) {
|
|
12534
12582
|
return function(...args) {
|
|
12535
|
-
const sab = new SharedArrayBuffer(16 +
|
|
12583
|
+
const sab = new SharedArrayBuffer(16 + 10240);
|
|
12536
12584
|
const i32arr = new Int32Array(sab);
|
|
12537
12585
|
Atomics.store(i32arr, 0, 21);
|
|
12538
12586
|
postMessage({
|
|
@@ -12547,45 +12595,11 @@ function requireFsProxy() {
|
|
|
12547
12595
|
const type = Atomics.load(i32arr, 1);
|
|
12548
12596
|
const size = Atomics.load(i32arr, 2);
|
|
12549
12597
|
const content = new Uint8Array(sab, 16, size);
|
|
12598
|
+
const value = decodeValue(memfs, content, type);
|
|
12550
12599
|
if (status === 1) {
|
|
12551
|
-
|
|
12552
|
-
const err = new Error(errobj.message);
|
|
12553
|
-
Object.defineProperty(err, "stack", {
|
|
12554
|
-
configurable: true,
|
|
12555
|
-
enumerable: false,
|
|
12556
|
-
writable: true,
|
|
12557
|
-
value: errobj.stack
|
|
12558
|
-
});
|
|
12559
|
-
for (const [k, v] of Object.entries(errobj)) {
|
|
12560
|
-
if (k === "message" || k === "stack") continue;
|
|
12561
|
-
err[k] = v;
|
|
12562
|
-
}
|
|
12563
|
-
throw err;
|
|
12600
|
+
throw value;
|
|
12564
12601
|
}
|
|
12565
|
-
|
|
12566
|
-
if (type === 1) return null;
|
|
12567
|
-
if (type === 2) return Boolean(content[0]);
|
|
12568
|
-
if (type === 3) return new Float64Array(sab, 16, 1)[0];
|
|
12569
|
-
if (type === 4) return new TextDecoder().decode(content.slice());
|
|
12570
|
-
if (type === 6) {
|
|
12571
|
-
const obj = JSON.parse(new TextDecoder().decode(content.slice()), (_key, value) => {
|
|
12572
|
-
if (typeof value === "string") {
|
|
12573
|
-
const matched = value.match(/^BigInt\((-?\d+)\)$/);
|
|
12574
|
-
if (matched && matched[1]) {
|
|
12575
|
-
return BigInt(matched[1]);
|
|
12576
|
-
}
|
|
12577
|
-
}
|
|
12578
|
-
return value;
|
|
12579
|
-
});
|
|
12580
|
-
if (obj.__constructor__) {
|
|
12581
|
-
const ctor = obj.__constructor__;
|
|
12582
|
-
delete obj.__constructor__;
|
|
12583
|
-
Object.setPrototypeOf(obj, memfs[ctor].prototype);
|
|
12584
|
-
}
|
|
12585
|
-
return obj;
|
|
12586
|
-
}
|
|
12587
|
-
if (type === 9) return new BigInt64Array(sab, 16, 1)[0];
|
|
12588
|
-
throw new Error("unsupported data");
|
|
12602
|
+
return value;
|
|
12589
12603
|
};
|
|
12590
12604
|
}
|
|
12591
12605
|
});
|
|
@@ -12657,9 +12671,7 @@ function wrap(result) {
|
|
|
12657
12671
|
let program, module, comments, errors;
|
|
12658
12672
|
return {
|
|
12659
12673
|
get program() {
|
|
12660
|
-
if (!program)
|
|
12661
|
-
program = jsonParseAst(result.program);
|
|
12662
|
-
}
|
|
12674
|
+
if (!program) program = jsonParseAst(result.program);
|
|
12663
12675
|
return program;
|
|
12664
12676
|
},
|
|
12665
12677
|
get module() {
|
|
@@ -12676,22 +12688,23 @@ function wrap(result) {
|
|
|
12676
12688
|
}
|
|
12677
12689
|
};
|
|
12678
12690
|
}
|
|
12679
|
-
function jsonParseAst(
|
|
12680
|
-
return JSON.parse(
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
|
|
12691
|
+
function jsonParseAst(program) {
|
|
12692
|
+
return JSON.parse(program, transform);
|
|
12693
|
+
}
|
|
12694
|
+
function transform(key, value) {
|
|
12695
|
+
if (value === null && key === "value" && Object.hasOwn(this, "type") && this.type === "Literal") {
|
|
12696
|
+
if (Object.hasOwn(this, "bigint")) {
|
|
12697
|
+
return BigInt(this.bigint);
|
|
12698
|
+
}
|
|
12699
|
+
if (Object.hasOwn(this, "regex")) {
|
|
12700
|
+
const { regex } = this;
|
|
12701
|
+
try {
|
|
12702
|
+
return RegExp(regex.pattern, regex.flags);
|
|
12703
|
+
} catch (_err) {
|
|
12691
12704
|
}
|
|
12692
12705
|
}
|
|
12693
|
-
|
|
12694
|
-
|
|
12706
|
+
}
|
|
12707
|
+
return value;
|
|
12695
12708
|
}
|
|
12696
12709
|
|
|
12697
12710
|
// wasm.mjs
|
package/package.json
CHANGED
package/parser.wasm32-wasi.wasm
CHANGED
|
Binary file
|