@poe-platform/safe-js 0.1.380 → 0.1.382
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-DYT6M5F7.js → chunk-DRWLAPG6.js} +89 -8
- package/dist/safe-js/chunks/chunk-DRWLAPG6.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-GDXESSU6.js → chunk-FUPQ2J76.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/guest-heap.d.ts +5 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-DYT6M5F7.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-GDXESSU6.js.map → chunk-FUPQ2J76.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;
|
|
@@ -8503,6 +8504,41 @@ function copyCollectionProperties(source, target, encode) {
|
|
|
8503
8504
|
if (!Object.isExtensible(properties)) Object.preventExtensions(target);
|
|
8504
8505
|
}
|
|
8505
8506
|
|
|
8507
|
+
// packages/safe-js/src/interp/string-iterator.ts
|
|
8508
|
+
var states4 = /* @__PURE__ */ new WeakMap();
|
|
8509
|
+
function isSandboxStringIterator(value) {
|
|
8510
|
+
return typeof value === "object" && value !== null && states4.has(value);
|
|
8511
|
+
}
|
|
8512
|
+
function restoreSandboxStringIterator(state, target = /* @__PURE__ */ Object.create(null)) {
|
|
8513
|
+
validateStringIteratorState(state);
|
|
8514
|
+
states4.set(target, { ...state });
|
|
8515
|
+
return target;
|
|
8516
|
+
}
|
|
8517
|
+
function validateStringIteratorState(state) {
|
|
8518
|
+
if (!Number.isSafeInteger(state.index) || state.index < 0 || (state.input === void 0 ? state.index !== 0 : typeof state.input !== "string" || state.index > state.input.length || state.index > 0 && state.input.codePointAt(state.index - 1) > 65535))
|
|
8519
|
+
throw new TypeError("Invalid String iterator state.");
|
|
8520
|
+
}
|
|
8521
|
+
function stringIteratorState(value) {
|
|
8522
|
+
const state = states4.get(value);
|
|
8523
|
+
if (state === void 0) throw new TypeError("String iterator next requires a String iterator receiver.");
|
|
8524
|
+
return state;
|
|
8525
|
+
}
|
|
8526
|
+
function nextStringIterator(value, budget) {
|
|
8527
|
+
if (!isSandboxStringIterator(value)) throw new TypeError("String iterator next requires a String iterator receiver.");
|
|
8528
|
+
const state = stringIteratorState(value);
|
|
8529
|
+
budget.visitNode();
|
|
8530
|
+
if (state.input === void 0) return { value: void 0, done: true };
|
|
8531
|
+
if (state.index >= state.input.length) {
|
|
8532
|
+
state.input = void 0;
|
|
8533
|
+
state.index = 0;
|
|
8534
|
+
return { value: void 0, done: true };
|
|
8535
|
+
}
|
|
8536
|
+
const width = state.input.codePointAt(state.index) > 65535 ? 2 : 1;
|
|
8537
|
+
const entry = budget.allocateString(state.input.slice(state.index, state.index + width));
|
|
8538
|
+
state.index += width;
|
|
8539
|
+
return { value: entry, done: false };
|
|
8540
|
+
}
|
|
8541
|
+
|
|
8506
8542
|
// packages/safe-js/src/interp/raw-json.ts
|
|
8507
8543
|
var rawJsonValues = /* @__PURE__ */ new WeakSet();
|
|
8508
8544
|
function createRawJson(text) {
|
|
@@ -9745,7 +9781,8 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
|
|
|
9745
9781
|
const key = asyncProtocol ? Symbol.asyncIterator : Symbol.iterator;
|
|
9746
9782
|
if (context.getProperty === void 0 || isGuestHostObject(value))
|
|
9747
9783
|
return asyncProtocol ? getSandboxAsyncIterator(value, budget, context, signal) : getSandboxIterator(value, budget, context);
|
|
9748
|
-
|
|
9784
|
+
const lookupTarget = value !== void 0 && value !== null && typeof value !== "object" ? getBoxedPrototype(value, budget) : value;
|
|
9785
|
+
if (getSandboxPropertyDescriptor(lookupTarget, key, budget) === void 0 && !(isSandboxRegExpIterator(value) && !asyncProtocol && getSandboxPropertyDescriptor(value, "next", budget) !== void 0)) {
|
|
9749
9786
|
if (isSandboxGenerator(value)) {
|
|
9750
9787
|
if (!hasExplicitSandboxPrototype(value) && value.async === true === asyncProtocol && getSandboxPropertyDescriptor(value, "next", budget) !== void 0)
|
|
9751
9788
|
return guestIterator(value, await context.getProperty(value, "next"), asyncProtocol, budget, context, signal);
|
|
@@ -13352,6 +13389,36 @@ function createPrimitiveConstructor(options, budget) {
|
|
|
13352
13389
|
}
|
|
13353
13390
|
for (const [name, value] of methods2)
|
|
13354
13391
|
Object.defineProperty(prototype, name, { value, writable: true, configurable: true });
|
|
13392
|
+
if (kind === "string") {
|
|
13393
|
+
const iteratorPrototype = /* @__PURE__ */ Object.create(null);
|
|
13394
|
+
setSandboxPrototype(iteratorPrototype, resolveIntrinsicIdentity(budget, '["%IteratorPrototype%"]'));
|
|
13395
|
+
Object.defineProperties(iteratorPrototype, {
|
|
13396
|
+
next: { value: createSandboxClosure({
|
|
13397
|
+
guest: true,
|
|
13398
|
+
sandbox: true,
|
|
13399
|
+
name: "next",
|
|
13400
|
+
length: 0,
|
|
13401
|
+
call: (_args, context) => nextStringIterator(context?.thisValue, budget)
|
|
13402
|
+
}), writable: true, configurable: true },
|
|
13403
|
+
[Symbol.toStringTag]: { value: "String Iterator", configurable: true }
|
|
13404
|
+
});
|
|
13405
|
+
registerBuiltinIdentities(budget, { "%StringIteratorPrototype%": iteratorPrototype });
|
|
13406
|
+
registerIntrinsicObject(budget, iteratorPrototype);
|
|
13407
|
+
Object.defineProperty(prototype, Symbol.iterator, { value: createSandboxClosure({
|
|
13408
|
+
guest: true,
|
|
13409
|
+
sandbox: true,
|
|
13410
|
+
name: "[Symbol.iterator]",
|
|
13411
|
+
length: 0,
|
|
13412
|
+
call: async (_args, context) => {
|
|
13413
|
+
const receiver = context?.thisValue;
|
|
13414
|
+
if (receiver === null || receiver === void 0) throw new TypeError("String iterator requires a receiver.");
|
|
13415
|
+
const input = await sandboxString(receiver, budget, context);
|
|
13416
|
+
const iterator = restoreSandboxStringIterator({ input, index: 0 });
|
|
13417
|
+
setSandboxPrototype(iterator, iteratorPrototype, budget);
|
|
13418
|
+
return iterator;
|
|
13419
|
+
}
|
|
13420
|
+
}), writable: true, configurable: true });
|
|
13421
|
+
}
|
|
13355
13422
|
installBoxedPrototype(budget, prototype, constructor);
|
|
13356
13423
|
return constructor;
|
|
13357
13424
|
}
|
|
@@ -15281,7 +15348,9 @@ async function arrayFromSandboxValues(args, budget, context) {
|
|
|
15281
15348
|
let failure;
|
|
15282
15349
|
const retained = {};
|
|
15283
15350
|
budget.setRetainedValues(retained, () => [
|
|
15284
|
-
|
|
15351
|
+
// Once acquired, a rooted protocol iterator owns the remaining input. Keep
|
|
15352
|
+
// the original only for array-like reads or implicit unrooted iterators.
|
|
15353
|
+
iterator?.retainedValue === void 0 ? items : void 0,
|
|
15285
15354
|
iteratorMethod,
|
|
15286
15355
|
iterator?.retainedValue,
|
|
15287
15356
|
mapFn,
|
|
@@ -21923,6 +21992,10 @@ function serializeCollectionProperties(value, encode, dataOnly = false) {
|
|
|
21923
21992
|
function captureGuestHeapNode(value, encode) {
|
|
21924
21993
|
if (isSandboxModuleNamespace(value))
|
|
21925
21994
|
return { kind: "module-namespace", entries: Object.keys(value).map((key) => [key, encode(value[key])]) };
|
|
21995
|
+
if (isSandboxStringIterator(value)) {
|
|
21996
|
+
const cursor = stringIteratorState(value);
|
|
21997
|
+
return { kind: "string-iterator", input: encode(cursor.input), index: cursor.index, state: captureObjectState(value, encode) };
|
|
21998
|
+
}
|
|
21926
21999
|
if (isRawJson(value)) return { kind: "raw-json", text: value.rawJSON };
|
|
21927
22000
|
const intrinsic = getIntrinsicIdentity(value);
|
|
21928
22001
|
if (intrinsic !== void 0) {
|
|
@@ -26869,7 +26942,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
26869
26942
|
createRawJson(node.text);
|
|
26870
26943
|
return true;
|
|
26871
26944
|
}
|
|
26872
|
-
if (!["intrinsic", "bound-function", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "array-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
26945
|
+
if (!["intrinsic", "bound-function", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "array-iterator", "string-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
26873
26946
|
const reference = (value, kinds) => {
|
|
26874
26947
|
const ref = record3(value);
|
|
26875
26948
|
fields(ref, ["kind", "id"]);
|
|
@@ -26927,6 +27000,13 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
26927
27000
|
fields(node, ["kind", "id"], ["state"]);
|
|
26928
27001
|
if (typeof node.id !== "string" || !intrinsicCatalogue().has(node.id)) throw new TypeError("Unknown intrinsic identity.");
|
|
26929
27002
|
if (Object.hasOwn(node, "state")) state(node.state);
|
|
27003
|
+
} else if (node.kind === "string-iterator") {
|
|
27004
|
+
fields(node, ["kind", "input", "index", "state"]);
|
|
27005
|
+
const index = integer(node.index);
|
|
27006
|
+
if (typeof node.input !== "string" && !absent(node.input))
|
|
27007
|
+
throw new TypeError("Invalid String iterator state.");
|
|
27008
|
+
validateStringIteratorState({ input: typeof node.input === "string" ? node.input : void 0, index });
|
|
27009
|
+
state(node.state);
|
|
26930
27010
|
} else if (node.kind === "array-iterator") {
|
|
26931
27011
|
fields(node, ["kind", "source", "index", "method", "state"]);
|
|
26932
27012
|
integer(node.index);
|
|
@@ -28733,7 +28813,7 @@ var structuredCloneErrorNames = ["Error", "EvalError", "RangeError", "ReferenceE
|
|
|
28733
28813
|
function* cloneStructuredGraph(value, state, budget, depth = 0) {
|
|
28734
28814
|
assertSandboxDataDepth(depth);
|
|
28735
28815
|
budget.visitNode();
|
|
28736
|
-
if (typeof value === "symbol" || isSandboxModuleNamespace(value) || isSandboxClosure(value) || isSandboxPromise(value) || isSandboxGenerator(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxArrayIterator(value) || isSandboxArguments(value))
|
|
28816
|
+
if (typeof value === "symbol" || isSandboxModuleNamespace(value) || isSandboxClosure(value) || isSandboxPromise(value) || isSandboxGenerator(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxArrayIterator(value) || isSandboxStringIterator(value) || isSandboxArguments(value))
|
|
28737
28817
|
throw new DOMException("Value cannot be structured cloned.", "DataCloneError");
|
|
28738
28818
|
if (typeof value !== "object" || value === null) return allocateProducedSandboxValue(value, budget);
|
|
28739
28819
|
if (isLiveCapability(value)) throw new DOMException("Capabilities cannot be structured cloned.", "DataCloneError");
|
|
@@ -28920,6 +29000,7 @@ function measureSandboxData(values, options = {}) {
|
|
|
28920
29000
|
return;
|
|
28921
29001
|
}
|
|
28922
29002
|
if (isSandboxArrayIterator(value)) visit(arrayIteratorState(value).source, depth + 1);
|
|
29003
|
+
if (isSandboxStringIterator(value)) visit(stringIteratorState(value).input, depth + 1);
|
|
28923
29004
|
if (isSandboxRegExpIterator(value)) {
|
|
28924
29005
|
const state = regexpIteratorState(value);
|
|
28925
29006
|
visit(state.matcher, depth + 1);
|
|
@@ -29117,7 +29198,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
29117
29198
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxPromise(value)) {
|
|
29118
29199
|
return value;
|
|
29119
29200
|
}
|
|
29120
|
-
if (isSandboxArrayIterator(value)) {
|
|
29201
|
+
if (isSandboxArrayIterator(value) || isSandboxStringIterator(value)) {
|
|
29121
29202
|
if (!cloneSandboxCollections) return value;
|
|
29122
29203
|
throw new TypeError("Array iterators require a portable guest snapshot, not a data copy.");
|
|
29123
29204
|
}
|
|
@@ -29597,7 +29678,7 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
29597
29678
|
if (isSandboxGenerator(value)) {
|
|
29598
29679
|
throw new TypeError("Sandbox generators cannot cross into host values.");
|
|
29599
29680
|
}
|
|
29600
|
-
if (isSandboxArrayIterator(value)) throw new TypeError("Sandbox
|
|
29681
|
+
if (isSandboxArrayIterator(value) || isSandboxStringIterator(value)) throw new TypeError("Sandbox iterators cannot cross into host values.");
|
|
29601
29682
|
if (isSandboxCollectionIterator(value)) {
|
|
29602
29683
|
throw new TypeError("Sandbox collection iterators cannot cross into host values.");
|
|
29603
29684
|
}
|
|
@@ -43983,4 +44064,4 @@ export {
|
|
|
43983
44064
|
FileSnapshotBackend,
|
|
43984
44065
|
run
|
|
43985
44066
|
};
|
|
43986
|
-
//# sourceMappingURL=chunk-
|
|
44067
|
+
//# sourceMappingURL=chunk-DRWLAPG6.js.map
|