@poe-platform/safe-js 0.1.379 → 0.1.381
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-L3DPV6WY.js → chunk-O3MW27ZJ.js} +48 -20
- package/dist/safe-js/chunks/chunk-O3MW27ZJ.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-M6D276VG.js → chunk-WEP4P7RG.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/iteration.d.ts +1 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-L3DPV6WY.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-M6D276VG.js.map → chunk-WEP4P7RG.js.map} +0 -0
|
@@ -8305,7 +8305,8 @@ function releaseObjectPrototype(budget) {
|
|
|
8305
8305
|
intrinsicPrototypes.delete(budget);
|
|
8306
8306
|
}
|
|
8307
8307
|
function getSandboxPrototype(value, budget) {
|
|
8308
|
-
|
|
8308
|
+
const explicit = prototypes.get(value);
|
|
8309
|
+
if (explicit !== void 0) return explicit;
|
|
8309
8310
|
if (budget === void 0) return null;
|
|
8310
8311
|
if (isSandboxArrayBuffer(value)) return budget === void 0 ? null : arrayBufferPrototypes.get(budget) ?? null;
|
|
8311
8312
|
if (isSandboxDataView(value)) return dataViewPrototypes.get(budget) ?? null;
|
|
@@ -9754,8 +9755,8 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
|
|
|
9754
9755
|
if (!asyncProtocol) return getSandboxIterator(value, budget, context);
|
|
9755
9756
|
if (isSandboxGenerator(value) && value.async && !hasExplicitSandboxPrototype(value))
|
|
9756
9757
|
return getSandboxAsyncIterator(value, budget, context, signal);
|
|
9757
|
-
const
|
|
9758
|
-
return
|
|
9758
|
+
const iterator = await acquireSandboxIterator(value, budget, context);
|
|
9759
|
+
return iterator === void 0 ? void 0 : asyncFromSyncIterator(iterator, budget, signal, context);
|
|
9759
9760
|
}
|
|
9760
9761
|
const factory = await context.getProperty(value, key);
|
|
9761
9762
|
if (!asyncProtocol && factory === void 0 && Array.isArray(value) && !hasExplicitSandboxPrototype(value)) {
|
|
@@ -9763,13 +9764,16 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
|
|
|
9763
9764
|
if (typeof installed === "object" && installed !== null && getIntrinsicIdentity(installed) === JSON.stringify(["Array", "prototype", "values"]))
|
|
9764
9765
|
return arrayIterator(value, context, budget);
|
|
9765
9766
|
}
|
|
9766
|
-
if (!asyncProtocol && (isSandboxMap(value) || isSandboxSet(value)) && typeof factory === "object" && factory !== null && getIntrinsicIdentity(factory) === JSON.stringify(isSandboxMap(value) ? ["Map", "prototype", "entries"] : ["Set", "prototype", "values"])) {
|
|
9767
|
-
return getSandboxIterator(value, budget, context);
|
|
9768
|
-
}
|
|
9769
9767
|
if (factory === null || factory === void 0) {
|
|
9770
9768
|
if (!asyncProtocol) return void 0;
|
|
9771
|
-
const
|
|
9772
|
-
return
|
|
9769
|
+
const iterator = await acquireSandboxIterator(value, budget, context);
|
|
9770
|
+
return iterator === void 0 ? void 0 : asyncFromSyncIterator(iterator, budget, signal, context);
|
|
9771
|
+
}
|
|
9772
|
+
return getSandboxIteratorFromMethod(value, factory, budget, context, asyncProtocol, signal);
|
|
9773
|
+
}
|
|
9774
|
+
async function getSandboxIteratorFromMethod(value, factory, budget, context, asyncProtocol = false, signal) {
|
|
9775
|
+
if (!asyncProtocol && (isSandboxMap(value) || isSandboxSet(value)) && typeof factory === "object" && factory !== null && getIntrinsicIdentity(factory) === JSON.stringify(isSandboxMap(value) ? ["Map", "prototype", "entries"] : ["Set", "prototype", "values"])) {
|
|
9776
|
+
return getSandboxIterator(value, budget, context);
|
|
9773
9777
|
}
|
|
9774
9778
|
if (!isSandboxClosure(factory)) {
|
|
9775
9779
|
if (typeof factory !== "function") throw new TypeError("Iterator method must be callable.");
|
|
@@ -15266,7 +15270,12 @@ async function arrayFromSandboxValues(args, budget, context) {
|
|
|
15266
15270
|
throw new TypeError("Array.from requires a non-null input.");
|
|
15267
15271
|
}
|
|
15268
15272
|
const read = (property) => context?.getProperty !== void 0 ? context.getProperty(items, property) : getSandboxDataProperty(items, property, budget);
|
|
15269
|
-
const
|
|
15273
|
+
const observableMethod = context?.getProperty !== void 0 && !isGuestHostObject(items) && getSandboxPropertyDescriptor(typeof items === "object" ? items : getBoxedPrototype(items, budget), Symbol.iterator, budget) !== void 0;
|
|
15274
|
+
const iteratorMethod = observableMethod ? await context.getProperty(items, Symbol.iterator) : void 0;
|
|
15275
|
+
if (iteratorMethod !== null && iteratorMethod !== void 0 && !isSandboxClosure(iteratorMethod) && typeof iteratorMethod !== "function")
|
|
15276
|
+
throw new TypeError("Iterator method must be callable.");
|
|
15277
|
+
let iterator = observableMethod ? void 0 : context === void 0 ? getSandboxIterator(items, budget) : await acquireSandboxIterator(items, budget, context);
|
|
15278
|
+
const iterable = observableMethod ? iteratorMethod !== null && iteratorMethod !== void 0 : iterator !== void 0;
|
|
15270
15279
|
const constructor = context?.thisValue;
|
|
15271
15280
|
let result;
|
|
15272
15281
|
let currentValue;
|
|
@@ -15274,6 +15283,7 @@ async function arrayFromSandboxValues(args, budget, context) {
|
|
|
15274
15283
|
const retained = {};
|
|
15275
15284
|
budget.setRetainedValues(retained, () => [
|
|
15276
15285
|
items,
|
|
15286
|
+
iteratorMethod,
|
|
15277
15287
|
iterator?.retainedValue,
|
|
15278
15288
|
mapFn,
|
|
15279
15289
|
constructor,
|
|
@@ -15293,19 +15303,21 @@ async function arrayFromSandboxValues(args, budget, context) {
|
|
|
15293
15303
|
};
|
|
15294
15304
|
try {
|
|
15295
15305
|
let length = 0;
|
|
15296
|
-
if (
|
|
15306
|
+
if (!iterable) {
|
|
15297
15307
|
const number = await sandboxNumber(await read("length"), budget, context);
|
|
15298
15308
|
length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
|
|
15299
15309
|
}
|
|
15300
15310
|
result = isSandboxClosure(constructor) && constructor.construct !== void 0 ? await invokeBuiltinClosure(
|
|
15301
15311
|
constructor,
|
|
15302
|
-
|
|
15312
|
+
iterable ? [] : [length],
|
|
15303
15313
|
budget,
|
|
15304
15314
|
context,
|
|
15305
15315
|
void 0,
|
|
15306
15316
|
true
|
|
15307
15317
|
) : createArrayFromConstructorArgs([length], budget);
|
|
15308
15318
|
checkData(result, 0, true);
|
|
15319
|
+
if (observableMethod && iterable)
|
|
15320
|
+
iterator = await getSandboxIteratorFromMethod(items, iteratorMethod, budget, context);
|
|
15309
15321
|
let index = 0;
|
|
15310
15322
|
while (iterator !== void 0 || index < length) {
|
|
15311
15323
|
try {
|
|
@@ -22177,6 +22189,14 @@ function serializeArray(value, serializeValue) {
|
|
|
22177
22189
|
}
|
|
22178
22190
|
|
|
22179
22191
|
// packages/safe-js/src/snapshot/typed-array.ts
|
|
22192
|
+
function captureTypedArrayState(value, encode) {
|
|
22193
|
+
const metadata = Object.defineProperties(/* @__PURE__ */ Object.create(null), Object.fromEntries(typedArrayProperties(value)));
|
|
22194
|
+
if (!Object.isExtensible(value)) Object.preventExtensions(metadata);
|
|
22195
|
+
return {
|
|
22196
|
+
properties: serializePropertyDescriptors(metadata, encode),
|
|
22197
|
+
...hasExplicitSandboxPrototype(value) ? { prototype: encode(getSandboxPrototype(value)) } : {}
|
|
22198
|
+
};
|
|
22199
|
+
}
|
|
22180
22200
|
function encodeTypedArrayLayout(value) {
|
|
22181
22201
|
const storage = typedArrayStorage(value);
|
|
22182
22202
|
const identity = storage.Native === Float32Array ? { kind: "float32array" } : { kind: "typedarray", arrayType: storage.Native.name };
|
|
@@ -22444,7 +22464,7 @@ function serializeDumpValue(value, path, state) {
|
|
|
22444
22464
|
}
|
|
22445
22465
|
return { kind: "ref", id };
|
|
22446
22466
|
}
|
|
22447
|
-
if (hasGuestObjectState(value) && !isSandboxDataView(value) && !(state.trustedRunReplay && (isSandboxDate(value) || isSandboxPromise(value) || isPromiseResolvingFunction(value)))) {
|
|
22467
|
+
if (hasGuestObjectState(value) && !isSandboxDataView(value) && !isNumericTypedArray(value) && !(state.trustedRunReplay && (isSandboxDate(value) || isSandboxPromise(value) || isPromiseResolvingFunction(value)))) {
|
|
22448
22468
|
throw new TypeError("Guest function properties and prototype links cannot be serialized.");
|
|
22449
22469
|
}
|
|
22450
22470
|
if (isSandboxDataView(value) || isSandboxArrayBuffer(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxBox(value) || isSandboxDate(value) || isNumericTypedArray(value)) return serializeHeapReference(value, path, state);
|
|
@@ -22545,12 +22565,17 @@ function serializeHeapReference(value, path, state) {
|
|
|
22545
22565
|
...encodeTypedArrayLayout(value),
|
|
22546
22566
|
buffer: serializeHeapReference(backing.buffer, `${path}.buffer`, state)
|
|
22547
22567
|
};
|
|
22548
|
-
|
|
22549
|
-
|
|
22550
|
-
|
|
22551
|
-
|
|
22552
|
-
|
|
22553
|
-
|
|
22568
|
+
state.heap[String(id)] = {
|
|
22569
|
+
...storage,
|
|
22570
|
+
entries: {},
|
|
22571
|
+
state: captureTypedArrayState(value, (entry) => {
|
|
22572
|
+
if (entry === void 0) return { kind: "undefined" };
|
|
22573
|
+
if (Object.is(entry, -0)) return { kind: "number", value: "-0" };
|
|
22574
|
+
const serialized = serializeDumpValue(entry, `${path}.<typed-array>`, state);
|
|
22575
|
+
if (serialized === SKIP_VALUE) throw new TypeError("Unsupported typed array property in public dump.");
|
|
22576
|
+
return serialized;
|
|
22577
|
+
})
|
|
22578
|
+
};
|
|
22554
22579
|
} else if (isSandboxArguments(value)) {
|
|
22555
22580
|
state.heap[String(id)] = serializeArguments(value, (entry, key) => {
|
|
22556
22581
|
const serialized = serializeDumpValue(entry, `${path}.${key}`, state);
|
|
@@ -22647,6 +22672,9 @@ function collectContainerStats(value, stats, ancestors, guestValues, depth = 0)
|
|
|
22647
22672
|
const guest = isSandboxDataView(value) ? { kind: "dataview", state: captureDataViewState(value, (entry) => {
|
|
22648
22673
|
guestEntries.push(entry);
|
|
22649
22674
|
return null;
|
|
22675
|
+
}) } : isNumericTypedArray(value) ? { kind: "typedarray", state: captureTypedArrayState(value, (entry) => {
|
|
22676
|
+
guestEntries.push(entry);
|
|
22677
|
+
return null;
|
|
22650
22678
|
}) } : isSandboxArrayBuffer(value) ? { kind: "arraybuffer", state: captureArrayBufferState(value, (entry) => {
|
|
22651
22679
|
guestEntries.push(entry);
|
|
22652
22680
|
return null;
|
|
@@ -22655,7 +22683,7 @@ function collectContainerStats(value, stats, ancestors, guestValues, depth = 0)
|
|
|
22655
22683
|
return null;
|
|
22656
22684
|
});
|
|
22657
22685
|
if (guest !== void 0) {
|
|
22658
|
-
if (!isSandboxArrayBuffer(value) && !isSandboxDataView(value)) guestValues.add(value);
|
|
22686
|
+
if (!isSandboxArrayBuffer(value) && !isSandboxDataView(value) && !isNumericTypedArray(value)) guestValues.add(value);
|
|
22659
22687
|
for (const entry of guestEntries) {
|
|
22660
22688
|
collectContainerStats(entry, stats, ancestors, guestValues, depth + 1);
|
|
22661
22689
|
if (entry !== null && typeof entry === "object") stats.get(entry).forceHeap = true;
|
|
@@ -43956,4 +43984,4 @@ export {
|
|
|
43956
43984
|
FileSnapshotBackend,
|
|
43957
43985
|
run
|
|
43958
43986
|
};
|
|
43959
|
-
//# sourceMappingURL=chunk-
|
|
43987
|
+
//# sourceMappingURL=chunk-O3MW27ZJ.js.map
|