@poe-platform/safe-js 0.1.365 → 0.1.367
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-NLDDBHDH.js → chunk-2UQ2QDUV.js} +122 -42
- package/dist/safe-js/chunks/{chunk-NLDDBHDH.js.map → chunk-2UQ2QDUV.js.map} +4 -4
- package/dist/safe-js/chunks/{chunk-A7CQH53A.js → chunk-U6OK5SV5.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/interp/values.d.ts +1 -0
- package/package.json +2 -2
- /package/dist/safe-js/chunks/{chunk-A7CQH53A.js.map → chunk-U6OK5SV5.js.map} +0 -0
|
@@ -25555,55 +25555,115 @@ function createRegexGlobals(options) {
|
|
|
25555
25555
|
return { RegExp: constructor };
|
|
25556
25556
|
}
|
|
25557
25557
|
|
|
25558
|
-
// packages/safe-js/src/interp/globals/
|
|
25559
|
-
|
|
25560
|
-
|
|
25561
|
-
|
|
25562
|
-
|
|
25563
|
-
|
|
25564
|
-
|
|
25565
|
-
|
|
25566
|
-
|
|
25567
|
-
|
|
25568
|
-
|
|
25569
|
-
|
|
25570
|
-
|
|
25571
|
-
|
|
25572
|
-
|
|
25573
|
-
|
|
25574
|
-
|
|
25575
|
-
|
|
25576
|
-
|
|
25577
|
-
|
|
25578
|
-
|
|
25579
|
-
|
|
25580
|
-
|
|
25581
|
-
|
|
25558
|
+
// packages/safe-js/src/interp/globals/structured-clone.ts
|
|
25559
|
+
var transferBuffer = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "transfer")?.value;
|
|
25560
|
+
function createStructuredCloneGlobal(budget) {
|
|
25561
|
+
return createSandboxClosure({
|
|
25562
|
+
guest: true,
|
|
25563
|
+
sandbox: true,
|
|
25564
|
+
name: "structuredClone",
|
|
25565
|
+
length: 1,
|
|
25566
|
+
call: (args, context) => {
|
|
25567
|
+
if (args.length === 0) throw new TypeError("structuredClone requires a value argument.");
|
|
25568
|
+
const [value, options] = args;
|
|
25569
|
+
if (options === void 0 || options === null) return cloneStructuredValue(value, [], budget, context);
|
|
25570
|
+
if (typeof options !== "object") throw new TypeError("structuredClone options must be an object.");
|
|
25571
|
+
return cloneWithOptions(value, options, budget, context);
|
|
25572
|
+
}
|
|
25573
|
+
});
|
|
25574
|
+
}
|
|
25575
|
+
async function cloneWithOptions(value, options, budget, context) {
|
|
25576
|
+
const bridge = {
|
|
25577
|
+
...context,
|
|
25578
|
+
stack: context?.stack ?? [],
|
|
25579
|
+
thisValue: void 0,
|
|
25580
|
+
getProperty: context?.getProperty ?? ((object, key) => {
|
|
25581
|
+
const descriptor = getSandboxPropertyDescriptor(object, key, budget);
|
|
25582
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, object, context);
|
|
25582
25583
|
})
|
|
25583
25584
|
};
|
|
25585
|
+
let current;
|
|
25586
|
+
let iterator;
|
|
25587
|
+
const items = [];
|
|
25588
|
+
const release = retainValues(budget, () => [value, options, current, items, iterator?.retainedValue]);
|
|
25589
|
+
try {
|
|
25590
|
+
current = await bridge.getProperty(options, "transfer");
|
|
25591
|
+
if (current !== void 0) {
|
|
25592
|
+
if (current === null || typeof current !== "object") throw new TypeError("Transfer list must be an iterable object.");
|
|
25593
|
+
iterator = await acquireSandboxIterator(current, budget, bridge);
|
|
25594
|
+
if (iterator === void 0) throw new TypeError("Transfer list must be iterable.");
|
|
25595
|
+
for (; ; ) {
|
|
25596
|
+
budget.visitNode();
|
|
25597
|
+
const result = await iterator.next();
|
|
25598
|
+
current = result;
|
|
25599
|
+
if ((await readIteratorResult(iterator, result, "done")).value) break;
|
|
25600
|
+
current = (await readIteratorResult(iterator, result, "value")).value;
|
|
25601
|
+
if (current === null || typeof current !== "object") {
|
|
25602
|
+
throw new TypeError("Transfer list elements must be objects.");
|
|
25603
|
+
}
|
|
25604
|
+
budget.allocateArrayLength(items.length + 1);
|
|
25605
|
+
budget.provisionDataUsage(items.length + 2)();
|
|
25606
|
+
items.push(current);
|
|
25607
|
+
}
|
|
25608
|
+
}
|
|
25609
|
+
const seen = /* @__PURE__ */ new Set();
|
|
25610
|
+
const transfers = [];
|
|
25611
|
+
for (const item of items) {
|
|
25612
|
+
budget.visitNode();
|
|
25613
|
+
if (!isSandboxArrayBuffer(item) || seen.has(item))
|
|
25614
|
+
throw new DOMException("Invalid or duplicate transferable.", "DataCloneError");
|
|
25615
|
+
seen.add(item);
|
|
25616
|
+
transfers.push(item);
|
|
25617
|
+
}
|
|
25618
|
+
return cloneStructuredValue(value, transfers, budget, context);
|
|
25619
|
+
} finally {
|
|
25620
|
+
release();
|
|
25621
|
+
}
|
|
25584
25622
|
}
|
|
25585
|
-
function
|
|
25623
|
+
function cloneStructuredValue(value, transfers, budget, context) {
|
|
25624
|
+
const parent = context?.compilation;
|
|
25586
25625
|
const operation = budget.acquireCompileOwner(false, parent?.owner);
|
|
25587
25626
|
const compilation = parent?.owner === operation.owner ? parent : new CompileScope(operation.owner);
|
|
25627
|
+
const buffers = /* @__PURE__ */ new WeakMap();
|
|
25628
|
+
let clone;
|
|
25629
|
+
const release = retainValues(budget, () => [value, clone, transfers]);
|
|
25588
25630
|
try {
|
|
25589
|
-
|
|
25631
|
+
let transferSize = 0;
|
|
25632
|
+
for (const buffer of transfers) {
|
|
25633
|
+
const length = arrayBufferLength(buffer);
|
|
25634
|
+
budget.allocateArrayLength(arrayBufferOptions(buffer)?.maxByteLength ?? length);
|
|
25635
|
+
transferSize += length + 1;
|
|
25636
|
+
if (arrayBufferDetached(buffer)) buffers.set(buffer, new ArrayBuffer(0));
|
|
25637
|
+
}
|
|
25638
|
+
budget.provisionDataUsage(transferSize)();
|
|
25639
|
+
clone = cloneSandboxValue(value, { compilation, resetRegexLastIndex: true, structuredClone: true, float32Buffers: buffers });
|
|
25590
25640
|
assertSandboxGraphDepth(clone);
|
|
25591
25641
|
assertStructuredCloneable(clone, /* @__PURE__ */ new WeakSet());
|
|
25592
25642
|
allocateProducedSandboxValue(clone, budget);
|
|
25593
25643
|
if (compilation !== parent) reconcileCompiledValues(budget, [clone], compilation);
|
|
25644
|
+
if (transfers.length > 0) {
|
|
25645
|
+
createDataCheckpoint(budget, context)(clone, 0, true);
|
|
25646
|
+
budget.visitNode(transferSize + transfers.length);
|
|
25647
|
+
budget.provisionDataUsage(transferBuffer === void 0 ? transferSize : transfers.length)();
|
|
25648
|
+
for (const buffer of transfers) {
|
|
25649
|
+
if (arrayBufferDetached(buffer)) throw new DOMException("Cannot transfer a detached ArrayBuffer.", "DataCloneError");
|
|
25650
|
+
if (transferBuffer !== void 0) Reflect.apply(transferBuffer, buffer, [0]);
|
|
25651
|
+
else structuredClone(buffer, { transfer: [buffer] });
|
|
25652
|
+
if (!arrayBufferDetached(buffer)) throw new DOMException("ArrayBuffer cannot be transferred.", "DataCloneError");
|
|
25653
|
+
}
|
|
25654
|
+
}
|
|
25594
25655
|
return clone;
|
|
25595
25656
|
} finally {
|
|
25657
|
+
release();
|
|
25596
25658
|
if (compilation !== parent) compilation.dispose();
|
|
25597
25659
|
operation.release();
|
|
25598
25660
|
}
|
|
25599
25661
|
}
|
|
25600
25662
|
function assertStructuredCloneable(value, seen) {
|
|
25601
|
-
if (
|
|
25602
|
-
|
|
25603
|
-
|
|
25604
|
-
if (typeof value !== "object" || value === null || seen.has(value))
|
|
25605
|
-
return;
|
|
25606
|
-
}
|
|
25663
|
+
if (typeof value === "symbol") throw new DOMException("Cannot clone a symbol value.", "DataCloneError");
|
|
25664
|
+
if (isSandboxClosure(value) || isSandboxPromise(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value))
|
|
25665
|
+
throw new DOMException("Cannot clone closures, promises, or collection iterators.", "DataCloneError");
|
|
25666
|
+
if (typeof value !== "object" || value === null || seen.has(value)) return;
|
|
25607
25667
|
seen.add(value);
|
|
25608
25668
|
if (isSandboxMap(value)) {
|
|
25609
25669
|
for (const [key, entry] of value.entries) {
|
|
@@ -25613,14 +25673,34 @@ function assertStructuredCloneable(value, seen) {
|
|
|
25613
25673
|
return;
|
|
25614
25674
|
}
|
|
25615
25675
|
if (isSandboxSet(value)) {
|
|
25616
|
-
for (const entry of value.values)
|
|
25617
|
-
assertStructuredCloneable(entry, seen);
|
|
25618
|
-
}
|
|
25676
|
+
for (const entry of value.values) assertStructuredCloneable(entry, seen);
|
|
25619
25677
|
return;
|
|
25620
25678
|
}
|
|
25621
|
-
for (const entry of Object.values(value))
|
|
25622
|
-
|
|
25623
|
-
|
|
25679
|
+
for (const entry of Object.values(value)) assertStructuredCloneable(entry, seen);
|
|
25680
|
+
}
|
|
25681
|
+
|
|
25682
|
+
// packages/safe-js/src/interp/globals/misc.ts
|
|
25683
|
+
function createMiscGlobals(options) {
|
|
25684
|
+
return {
|
|
25685
|
+
structuredClone: createStructuredCloneGlobal(options.budget),
|
|
25686
|
+
...createNumericParsers(options.budget),
|
|
25687
|
+
isNaN: createSandboxClosure({
|
|
25688
|
+
sandbox: true,
|
|
25689
|
+
call: ([value], context) => {
|
|
25690
|
+
const number = sandboxNumber(value, options.budget, context);
|
|
25691
|
+
return typeof number === "number" ? Number.isNaN(number) : number.then(Number.isNaN);
|
|
25692
|
+
},
|
|
25693
|
+
name: "isNaN"
|
|
25694
|
+
}),
|
|
25695
|
+
isFinite: createSandboxClosure({
|
|
25696
|
+
sandbox: true,
|
|
25697
|
+
call: ([value], context) => {
|
|
25698
|
+
const number = sandboxNumber(value, options.budget, context);
|
|
25699
|
+
return typeof number === "number" ? Number.isFinite(number) : number.then(Number.isFinite);
|
|
25700
|
+
},
|
|
25701
|
+
name: "isFinite"
|
|
25702
|
+
})
|
|
25703
|
+
};
|
|
25624
25704
|
}
|
|
25625
25705
|
|
|
25626
25706
|
// packages/safe-js/src/interp/globals/uri.ts
|
|
@@ -25955,7 +26035,7 @@ function createBigIntGlobal(budget) {
|
|
|
25955
26035
|
|
|
25956
26036
|
// packages/safe-js/src/interp/globals/array-buffer.ts
|
|
25957
26037
|
var resizeBuffer2 = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resize")?.value;
|
|
25958
|
-
var
|
|
26038
|
+
var transferBuffer2 = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "transfer")?.value;
|
|
25959
26039
|
function createArrayBufferGlobal(budget) {
|
|
25960
26040
|
const prototype = /* @__PURE__ */ Object.create(null);
|
|
25961
26041
|
const constructor = createSandboxClosure({
|
|
@@ -26128,9 +26208,9 @@ function createArrayBufferGlobal(budget) {
|
|
|
26128
26208
|
const count = Math.min(length, arrayBufferLength(receiver));
|
|
26129
26209
|
budget.visitNode(count);
|
|
26130
26210
|
new Uint8Array(result, 0, count).set(new Uint8Array(receiver, 0, count));
|
|
26131
|
-
if (
|
|
26211
|
+
if (transferBuffer2 !== void 0) {
|
|
26132
26212
|
budget.provisionDataUsage(1)();
|
|
26133
|
-
Reflect.apply(
|
|
26213
|
+
Reflect.apply(transferBuffer2, receiver, [0]);
|
|
26134
26214
|
} else {
|
|
26135
26215
|
budget.provisionDataUsage(arrayBufferLength(receiver) + 1)();
|
|
26136
26216
|
budget.visitNode(arrayBufferLength(receiver));
|
|
@@ -43423,4 +43503,4 @@ export {
|
|
|
43423
43503
|
FileSnapshotBackend,
|
|
43424
43504
|
run
|
|
43425
43505
|
};
|
|
43426
|
-
//# sourceMappingURL=chunk-
|
|
43506
|
+
//# sourceMappingURL=chunk-2UQ2QDUV.js.map
|