@poe-platform/safe-js 0.1.352 → 0.1.354
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/dist/safe-js/chunks/{chunk-ZCAXO5OU.js → chunk-CJ7PNS2V.js} +26 -7
- package/dist/safe-js/chunks/{chunk-ZCAXO5OU.js.map → chunk-CJ7PNS2V.js.map} +2 -2
- package/dist/safe-js/chunks/{chunk-J2YBAXLB.js → chunk-FVRRXM5H.js} +2 -2
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/snapshot/array-buffer.d.ts +2 -1
- package/package.json +2 -2
- /package/dist/safe-js/chunks/{chunk-J2YBAXLB.js.map → chunk-FVRRXM5H.js.map} +0 -0
|
@@ -21532,6 +21532,7 @@ function serializeArray(value, serializeValue) {
|
|
|
21532
21532
|
// packages/safe-js/src/snapshot/float32array.ts
|
|
21533
21533
|
function encodeFloat32Layout(value) {
|
|
21534
21534
|
const storage = float32Storage(value);
|
|
21535
|
+
if (arrayBufferDetached(storage.buffer)) return { byteOffset: 0, length: 0 };
|
|
21535
21536
|
if (arrayBufferOptions(storage.buffer) === void 0) return { byteOffset: storage.byteOffset, length: storage.length };
|
|
21536
21537
|
const layout = float32ViewLayouts.get(value);
|
|
21537
21538
|
if (layout === void 0) throw new TypeError("Resizable Float32Array snapshots require known view layout.");
|
|
@@ -21581,9 +21582,16 @@ function encodeArrayBufferStorage(value, id, buffers, reference) {
|
|
|
21581
21582
|
arrayBufferLength(value);
|
|
21582
21583
|
const existing = buffers.get(value);
|
|
21583
21584
|
if (existing === void 0) buffers.set(value, id);
|
|
21584
|
-
|
|
21585
|
+
const detached = arrayBufferDetached(value);
|
|
21586
|
+
return { kind: "arraybuffer", ...existing === void 0 ? {
|
|
21587
|
+
bytes: detached ? [] : Array.from(new Uint8Array(value)),
|
|
21588
|
+
...arrayBufferOptions(value),
|
|
21589
|
+
...detached ? { detached: true } : {}
|
|
21590
|
+
} : { buffer: reference(existing) } };
|
|
21585
21591
|
}
|
|
21586
21592
|
function validateArrayBufferStorage(value) {
|
|
21593
|
+
if (Object.hasOwn(value, "detached") && (value.detached !== true || !Array.isArray(value.bytes) || value.bytes.length !== 0 || Object.hasOwn(value, "maxByteLength") && value.maxByteLength !== 0))
|
|
21594
|
+
throw new TypeError("Invalid detached ArrayBuffer storage.");
|
|
21587
21595
|
if (Object.hasOwn(value, "bytes") === Object.hasOwn(value, "buffer"))
|
|
21588
21596
|
throw new TypeError("ArrayBuffer requires one backing storage description.");
|
|
21589
21597
|
if (Object.hasOwn(value, "bytes") && (!Array.isArray(value.bytes) || value.bytes.some((byte) => !Number.isInteger(byte) || byte < 0 || byte > 255)))
|
|
@@ -21591,7 +21599,7 @@ function validateArrayBufferStorage(value) {
|
|
|
21591
21599
|
if (Object.hasOwn(value, "maxByteLength") && (!Array.isArray(value.bytes) || !Number.isSafeInteger(value.maxByteLength) || Number(value.maxByteLength) < value.bytes.length))
|
|
21592
21600
|
throw new TypeError("Invalid ArrayBuffer maximum length.");
|
|
21593
21601
|
}
|
|
21594
|
-
function decodeArrayBufferStorage(value, resolve, budget) {
|
|
21602
|
+
function decodeArrayBufferStorage(value, resolve, budget, deferredDetachment) {
|
|
21595
21603
|
validateArrayBufferStorage(value);
|
|
21596
21604
|
if (Array.isArray(value.bytes)) {
|
|
21597
21605
|
budget?.allocateArrayLength(Number(value.maxByteLength ?? value.bytes.length));
|
|
@@ -21602,6 +21610,15 @@ function decodeArrayBufferStorage(value, resolve, budget) {
|
|
|
21602
21610
|
if (Object.hasOwn(value, "maxByteLength") && arrayBufferOptions(buffer)?.maxByteLength !== value.maxByteLength)
|
|
21603
21611
|
throw new TypeError("Resizable ArrayBuffer restoration is not supported by this host.");
|
|
21604
21612
|
new Uint8Array(buffer).set(value.bytes);
|
|
21613
|
+
if (value.detached === true) {
|
|
21614
|
+
const detach = () => {
|
|
21615
|
+
budget?.visitNode();
|
|
21616
|
+
structuredClone(buffer, { transfer: [buffer] });
|
|
21617
|
+
if (!arrayBufferDetached(buffer)) throw new TypeError("Restored ArrayBuffer could not be detached.");
|
|
21618
|
+
};
|
|
21619
|
+
if (deferredDetachment === void 0) detach();
|
|
21620
|
+
else deferredDetachment.push(detach);
|
|
21621
|
+
}
|
|
21605
21622
|
return buffer;
|
|
21606
21623
|
}
|
|
21607
21624
|
const referenced = resolve(value.buffer);
|
|
@@ -22380,6 +22397,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
22380
22397
|
const nodes = list(own(graph, "nodes"));
|
|
22381
22398
|
const restored = /* @__PURE__ */ new Map();
|
|
22382
22399
|
const initializeValues = [];
|
|
22400
|
+
const detachBuffers = [];
|
|
22383
22401
|
const decode = (entry, depth = 0) => {
|
|
22384
22402
|
if (depth > MAX_DATA_DEPTH) throw new TypeError("Replay data exceeds the nesting limit.");
|
|
22385
22403
|
if (entry === null || typeof entry === "boolean" || typeof entry === "string") return entry;
|
|
@@ -22506,7 +22524,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
22506
22524
|
}
|
|
22507
22525
|
if (kind === "arraybuffer") {
|
|
22508
22526
|
if (typeof node.extensible !== "boolean") throw new TypeError("Invalid ArrayBuffer extensibility.");
|
|
22509
|
-
const result3 = decodeArrayBufferStorage(node, child, compilation.owner?.budget);
|
|
22527
|
+
const result3 = decodeArrayBufferStorage(node, child, compilation.owner?.budget, detachBuffers);
|
|
22510
22528
|
restored.set(id, result3);
|
|
22511
22529
|
initializeValues.push(() => {
|
|
22512
22530
|
defineProperties(result3, record2(own(node, "properties")), child, node.symbolEntries);
|
|
@@ -22625,6 +22643,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
22625
22643
|
};
|
|
22626
22644
|
const result = decode(own(graph, "root"));
|
|
22627
22645
|
for (const initialize of initializeValues) initialize();
|
|
22646
|
+
for (const detach of detachBuffers) detach();
|
|
22628
22647
|
if (parent !== void 0) compilation.forward(compilation.tickets, parent);
|
|
22629
22648
|
return result;
|
|
22630
22649
|
} finally {
|
|
@@ -25612,13 +25631,13 @@ function createArrayBufferGlobal(budget) {
|
|
|
25612
25631
|
}
|
|
25613
25632
|
})
|
|
25614
25633
|
});
|
|
25615
|
-
Object.defineProperty(prototype,
|
|
25634
|
+
for (const key of ["transfer", "transferToFixedLength"]) Object.defineProperty(prototype, key, {
|
|
25616
25635
|
writable: true,
|
|
25617
25636
|
configurable: true,
|
|
25618
25637
|
value: createSandboxClosure({
|
|
25619
25638
|
guest: true,
|
|
25620
25639
|
sandbox: true,
|
|
25621
|
-
name:
|
|
25640
|
+
name: key,
|
|
25622
25641
|
length: 0,
|
|
25623
25642
|
call: async (args, context) => {
|
|
25624
25643
|
const receiver = context?.thisValue;
|
|
@@ -25631,7 +25650,7 @@ function createArrayBufferGlobal(budget) {
|
|
|
25631
25650
|
const length = Number.isNaN(number) ? 0 : Math.trunc(number);
|
|
25632
25651
|
if (!Number.isSafeInteger(length) || length < 0) throw new RangeError("Invalid ArrayBuffer transfer length.");
|
|
25633
25652
|
if (arrayBufferDetached(receiver)) throw new TypeError("Cannot transfer a detached ArrayBuffer.");
|
|
25634
|
-
const options = arrayBufferOptions(receiver);
|
|
25653
|
+
const options = key === "transfer" ? arrayBufferOptions(receiver) : void 0;
|
|
25635
25654
|
if (options !== void 0 && length > options.maxByteLength) throw new RangeError("Transfer length exceeds ArrayBuffer capacity.");
|
|
25636
25655
|
budget.allocateArrayLength(options?.maxByteLength ?? length);
|
|
25637
25656
|
checkData(receiver, 0, true);
|
|
@@ -42736,4 +42755,4 @@ export {
|
|
|
42736
42755
|
FileSnapshotBackend,
|
|
42737
42756
|
run
|
|
42738
42757
|
};
|
|
42739
|
-
//# sourceMappingURL=chunk-
|
|
42758
|
+
//# sourceMappingURL=chunk-CJ7PNS2V.js.map
|