@poe-platform/safe-js 0.1.387 → 0.1.388
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-D6I4WNJU.js → chunk-RLZ6CCXJ.js} +2 -2
- package/dist/safe-js/chunks/{chunk-KSILYYRR.js → chunk-VQ4F2UCI.js} +76 -3
- package/dist/safe-js/chunks/chunk-VQ4F2UCI.js.map +7 -0
- 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-KSILYYRR.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-D6I4WNJU.js.map → chunk-RLZ6CCXJ.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-VQ4F2UCI.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8249,4 +8249,4 @@ export {
|
|
|
8249
8249
|
parseMcpConfig,
|
|
8250
8250
|
makeMcpModule
|
|
8251
8251
|
};
|
|
8252
|
-
//# sourceMappingURL=chunk-
|
|
8252
|
+
//# sourceMappingURL=chunk-RLZ6CCXJ.js.map
|
|
@@ -8546,6 +8546,9 @@ function nextStringIterator(value, budget) {
|
|
|
8546
8546
|
return { value: entry, done: false };
|
|
8547
8547
|
}
|
|
8548
8548
|
|
|
8549
|
+
// packages/safe-js/src/interp/iterator-wrapper.ts
|
|
8550
|
+
var iteratorWrapperStates = /* @__PURE__ */ new WeakMap();
|
|
8551
|
+
|
|
8549
8552
|
// packages/safe-js/src/interp/raw-json.ts
|
|
8550
8553
|
var rawJsonValues = /* @__PURE__ */ new WeakSet();
|
|
8551
8554
|
function createRawJson(text) {
|
|
@@ -22030,6 +22033,9 @@ function serializeCollectionProperties(value, encode, dataOnly = false) {
|
|
|
22030
22033
|
|
|
22031
22034
|
// packages/safe-js/src/snapshot/guest-heap.ts
|
|
22032
22035
|
function captureGuestHeapNode(value, encode) {
|
|
22036
|
+
const wrapper = iteratorWrapperStates.get(value);
|
|
22037
|
+
if (wrapper !== void 0)
|
|
22038
|
+
return { kind: "iterator-wrapper", iterator: encode(wrapper.iterator), next: encode(wrapper.next), state: captureObjectState(value, encode) };
|
|
22033
22039
|
if (isSandboxModuleNamespace(value))
|
|
22034
22040
|
return { kind: "module-namespace", entries: Object.keys(value).map((key) => [key, encode(value[key])]) };
|
|
22035
22041
|
if (isSandboxStringIterator(value)) {
|
|
@@ -26347,6 +26353,62 @@ function createGeneratorPrototypes(budget) {
|
|
|
26347
26353
|
generatorPrototypes.set(budget, state);
|
|
26348
26354
|
}
|
|
26349
26355
|
|
|
26356
|
+
// packages/safe-js/src/interp/globals/iterator-from.ts
|
|
26357
|
+
function installIteratorFrom(constructor, budget) {
|
|
26358
|
+
const prototype = /* @__PURE__ */ Object.create(null);
|
|
26359
|
+
setSandboxPrototype(prototype, resolveIntrinsicIdentity(budget, '["%IteratorPrototype%"]'));
|
|
26360
|
+
for (const name of ["next", "return"]) {
|
|
26361
|
+
Object.defineProperty(prototype, name, { writable: true, configurable: true, value: createSandboxClosure({
|
|
26362
|
+
guest: true,
|
|
26363
|
+
sandbox: true,
|
|
26364
|
+
name,
|
|
26365
|
+
length: 0,
|
|
26366
|
+
call: async (_args, context) => {
|
|
26367
|
+
const receiver = context?.thisValue;
|
|
26368
|
+
const state = receiver !== null && typeof receiver === "object" ? iteratorWrapperStates.get(receiver) : void 0;
|
|
26369
|
+
if (state === void 0) throw new TypeError("Iterator wrapper method requires a branded receiver.");
|
|
26370
|
+
const method = name === "next" ? state.next : await read(state.iterator, "return", context);
|
|
26371
|
+
if (name === "return" && (method === void 0 || method === null)) return { value: void 0, done: true };
|
|
26372
|
+
if (!isSandboxClosure(method)) throw new TypeError("Iterator method must be callable.");
|
|
26373
|
+
return invokeBuiltinClosure(method, [], budget, context, state.iterator);
|
|
26374
|
+
}
|
|
26375
|
+
}) });
|
|
26376
|
+
}
|
|
26377
|
+
const from = createSandboxClosure({ guest: true, sandbox: true, name: "from", length: 1, call: async ([input], context) => {
|
|
26378
|
+
if (input === null || typeof input !== "object" && typeof input !== "string")
|
|
26379
|
+
throw new TypeError("Iterator.from requires an object or string.");
|
|
26380
|
+
let iterator = input;
|
|
26381
|
+
let next;
|
|
26382
|
+
const release = retainValues(budget, () => [input, iterator, next]);
|
|
26383
|
+
try {
|
|
26384
|
+
const method = await read(input, Symbol.iterator, context);
|
|
26385
|
+
if (method !== void 0 && method !== null) {
|
|
26386
|
+
if (!isSandboxClosure(method)) throw new TypeError("Symbol.iterator must be callable.");
|
|
26387
|
+
iterator = await invokeBuiltinClosure(method, [], budget, context, input);
|
|
26388
|
+
}
|
|
26389
|
+
if (iterator === null || typeof iterator !== "object") throw new TypeError("Iterator must be an object.");
|
|
26390
|
+
next = await read(iterator, "next", context);
|
|
26391
|
+
if (await ordinaryHasInstance(iterator, constructor, budget, context)) return iterator;
|
|
26392
|
+
const wrapper = /* @__PURE__ */ Object.create(null);
|
|
26393
|
+
iteratorWrapperStates.set(wrapper, { iterator, next });
|
|
26394
|
+
setSandboxPrototype(wrapper, prototype, budget);
|
|
26395
|
+
createDataCheckpoint(budget, context)(wrapper, 0, true);
|
|
26396
|
+
return wrapper;
|
|
26397
|
+
} finally {
|
|
26398
|
+
release();
|
|
26399
|
+
}
|
|
26400
|
+
} });
|
|
26401
|
+
Object.defineProperty(materializeFunctionProperties(constructor), "from", { value: from, writable: true, configurable: true });
|
|
26402
|
+
registerBuiltinIdentities(budget, { Iterator: constructor, "%WrapForValidIteratorPrototype%": prototype });
|
|
26403
|
+
registerIntrinsicFunction(budget, from);
|
|
26404
|
+
registerIntrinsicObject(budget, prototype);
|
|
26405
|
+
async function read(value, key, context) {
|
|
26406
|
+
if (context?.getProperty !== void 0) return context.getProperty(value, key);
|
|
26407
|
+
const descriptor = getSandboxPropertyDescriptor(value, key, budget);
|
|
26408
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, context);
|
|
26409
|
+
}
|
|
26410
|
+
}
|
|
26411
|
+
|
|
26350
26412
|
// packages/safe-js/src/interp/globals/iterator.ts
|
|
26351
26413
|
function createIteratorGlobal(budget) {
|
|
26352
26414
|
const prototype = resolveIntrinsicIdentity(budget, '["%IteratorPrototype%"]');
|
|
@@ -26384,6 +26446,7 @@ function createIteratorGlobal(budget) {
|
|
|
26384
26446
|
Object.defineProperty(prototype, "constructor", { get: accessorAdapter(getter, "get"), set: accessorAdapter(setter, "set"), configurable: true });
|
|
26385
26447
|
registerIntrinsicFunction(budget, getter);
|
|
26386
26448
|
registerIntrinsicFunction(budget, setter);
|
|
26449
|
+
installIteratorFrom(constructor, budget);
|
|
26387
26450
|
registerIntrinsicFunction(budget, constructor);
|
|
26388
26451
|
registerIntrinsicObject(budget, prototype);
|
|
26389
26452
|
return constructor;
|
|
@@ -27089,7 +27152,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27089
27152
|
createRawJson(node.text);
|
|
27090
27153
|
return true;
|
|
27091
27154
|
}
|
|
27092
|
-
if (!["intrinsic", "bound-function", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "array-iterator", "string-iterator", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
27155
|
+
if (!["intrinsic", "bound-function", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "array-iterator", "string-iterator", "iterator-wrapper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
27093
27156
|
const reference = (value, kinds) => {
|
|
27094
27157
|
const ref = record3(value);
|
|
27095
27158
|
fields(ref, ["kind", "id"]);
|
|
@@ -27143,7 +27206,12 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27143
27206
|
});
|
|
27144
27207
|
return false;
|
|
27145
27208
|
}
|
|
27146
|
-
if (node.kind === "
|
|
27209
|
+
if (node.kind === "iterator-wrapper") {
|
|
27210
|
+
fields(node, ["kind", "iterator", "next", "state"]);
|
|
27211
|
+
const iterator = reference(node.iterator);
|
|
27212
|
+
if (iterator.kind === "symbol" || iterator.kind === "scope-frame") throw new TypeError("Invalid wrapped iterator.");
|
|
27213
|
+
state(node.state);
|
|
27214
|
+
} else if (node.kind === "intrinsic") {
|
|
27147
27215
|
fields(node, ["kind", "id"], ["state"]);
|
|
27148
27216
|
if (typeof node.id !== "string" || !intrinsicCatalogue().has(node.id)) throw new TypeError("Unknown intrinsic identity.");
|
|
27149
27217
|
if (Object.hasOwn(node, "state")) state(node.state);
|
|
@@ -29108,6 +29176,11 @@ function measureSandboxData(values, options = {}) {
|
|
|
29108
29176
|
}
|
|
29109
29177
|
return;
|
|
29110
29178
|
}
|
|
29179
|
+
const wrapperState = iteratorWrapperStates.get(value);
|
|
29180
|
+
if (wrapperState !== void 0) {
|
|
29181
|
+
visit(wrapperState.iterator, depth + 1);
|
|
29182
|
+
visit(wrapperState.next, depth + 1);
|
|
29183
|
+
}
|
|
29111
29184
|
if (isSandboxDate(value)) usage += 8;
|
|
29112
29185
|
if (isGuestHostObject(value)) {
|
|
29113
29186
|
usage += measureHostObjectData(value);
|
|
@@ -44237,4 +44310,4 @@ export {
|
|
|
44237
44310
|
FileSnapshotBackend,
|
|
44238
44311
|
run
|
|
44239
44312
|
};
|
|
44240
|
-
//# sourceMappingURL=chunk-
|
|
44313
|
+
//# sourceMappingURL=chunk-VQ4F2UCI.js.map
|