@poe-platform/safe-js 0.1.110 → 0.1.112
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-FPFTLLMZ.js → chunk-7Z6HCXET.js} +2 -2
- package/dist/safe-js/chunks/{chunk-OCJ6MUNL.js → chunk-DVWTNFTV.js} +218 -50
- package/dist/safe-js/chunks/chunk-DVWTNFTV.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/interp/collection-brands.d.ts +5 -0
- package/dist/safe-js/interp/collection-iterator.d.ts +27 -0
- package/dist/safe-js/interp/iteration.d.ts +2 -1
- package/dist/safe-js/interp/patterns.d.ts +2 -0
- package/dist/safe-js/interp/values.d.ts +4 -5
- package/dist/safe-js/snapshot/replay-data.d.ts +10 -0
- package/dist/tiny-stdio-mcp-server/types.d.ts +1 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-OCJ6MUNL.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-FPFTLLMZ.js.map → chunk-7Z6HCXET.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-DVWTNFTV.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8245,4 +8245,4 @@ export {
|
|
|
8245
8245
|
parseMcpConfig,
|
|
8246
8246
|
makeMcpModule
|
|
8247
8247
|
};
|
|
8248
|
-
//# sourceMappingURL=chunk-
|
|
8248
|
+
//# sourceMappingURL=chunk-7Z6HCXET.js.map
|
|
@@ -6337,6 +6337,72 @@ function serializedDateTime(value) {
|
|
|
6337
6337
|
return Number.isNaN(time) ? null : time;
|
|
6338
6338
|
}
|
|
6339
6339
|
|
|
6340
|
+
// packages/safe-js/src/interp/collection-brands.ts
|
|
6341
|
+
var sandboxMapBrand = /* @__PURE__ */ Symbol("SandboxMap");
|
|
6342
|
+
var sandboxSetBrand = /* @__PURE__ */ Symbol("SandboxSet");
|
|
6343
|
+
function isSandboxMap(value) {
|
|
6344
|
+
return typeof value === "object" && value !== null && sandboxMapBrand in value;
|
|
6345
|
+
}
|
|
6346
|
+
function isSandboxSet(value) {
|
|
6347
|
+
return typeof value === "object" && value !== null && sandboxSetBrand in value;
|
|
6348
|
+
}
|
|
6349
|
+
|
|
6350
|
+
// packages/safe-js/src/interp/collection-iterator.ts
|
|
6351
|
+
var states = /* @__PURE__ */ new WeakMap();
|
|
6352
|
+
function isSandboxCollectionIterator(value) {
|
|
6353
|
+
return typeof value === "object" && value !== null && states.has(value);
|
|
6354
|
+
}
|
|
6355
|
+
function createSandboxCollectionIterator(collection, method) {
|
|
6356
|
+
return restoreSandboxCollectionIterator({ collection, collectionKind: collection.kind, method, index: 0, exhausted: false });
|
|
6357
|
+
}
|
|
6358
|
+
function restoreSandboxCollectionIterator(snapshot, target = /* @__PURE__ */ Object.create(null)) {
|
|
6359
|
+
const { collection, collectionKind, method, index, exhausted } = snapshot;
|
|
6360
|
+
if (collection !== void 0 && collection.kind !== collectionKind)
|
|
6361
|
+
throw new TypeError("Collection iterator source has the wrong brand.");
|
|
6362
|
+
if (!exhausted && collection === void 0)
|
|
6363
|
+
throw new TypeError("Live collection iterator requires its source collection.");
|
|
6364
|
+
const iterator = exhausted ? void 0 : nativeIterator(collection, method);
|
|
6365
|
+
for (let skipped = 0; skipped < index; skipped += 1) {
|
|
6366
|
+
if (iterator === void 0 || iterator.next().done)
|
|
6367
|
+
throw new TypeError("Collection iterator cursor exceeds its source.");
|
|
6368
|
+
}
|
|
6369
|
+
states.set(target, { collection: exhausted ? void 0 : collection, collectionKind, method, exhausted, iterator });
|
|
6370
|
+
return target;
|
|
6371
|
+
}
|
|
6372
|
+
function collectionIteratorState(value) {
|
|
6373
|
+
const state = states.get(value);
|
|
6374
|
+
if (state === void 0) throw new TypeError("Expected a collection iterator.");
|
|
6375
|
+
return state;
|
|
6376
|
+
}
|
|
6377
|
+
function snapshotCollectionIterator(value) {
|
|
6378
|
+
const state = collectionIteratorState(value);
|
|
6379
|
+
if (state.exhausted) return { ...state, index: 0 };
|
|
6380
|
+
const collection = state.collection;
|
|
6381
|
+
const size = collection.kind === "map" ? collection.entries.size : collection.values.size;
|
|
6382
|
+
let remaining = 0;
|
|
6383
|
+
while (!state.iterator.next().done) remaining += 1;
|
|
6384
|
+
const snapshot = { ...state, index: size - remaining };
|
|
6385
|
+
restoreSandboxCollectionIterator(snapshot, value);
|
|
6386
|
+
return snapshot;
|
|
6387
|
+
}
|
|
6388
|
+
function nextCollectionIterator(value, budget) {
|
|
6389
|
+
const state = states.get(value);
|
|
6390
|
+
budget?.visitNode();
|
|
6391
|
+
if (state.exhausted) return { value: void 0, done: true };
|
|
6392
|
+
const result = state.iterator.next();
|
|
6393
|
+
if (result.done) {
|
|
6394
|
+
state.exhausted = true;
|
|
6395
|
+
state.collection = void 0;
|
|
6396
|
+
state.iterator = void 0;
|
|
6397
|
+
return { value: void 0, done: true };
|
|
6398
|
+
}
|
|
6399
|
+
if (state.method === "entries") budget?.allocateArrayLength(2);
|
|
6400
|
+
return { value: result.value, done: false };
|
|
6401
|
+
}
|
|
6402
|
+
function nativeIterator(collection, method) {
|
|
6403
|
+
return collection.kind === "map" ? collection.entries[method]() : collection.values[method]();
|
|
6404
|
+
}
|
|
6405
|
+
|
|
6340
6406
|
// packages/safe-js/src/interp/host-capabilities.ts
|
|
6341
6407
|
import { types as types3 } from "node:util";
|
|
6342
6408
|
var MAX_INDEXED_LENGTH = 65536;
|
|
@@ -6909,16 +6975,19 @@ function graphEntries(value) {
|
|
|
6909
6975
|
if (isSandboxArguments(value)) {
|
|
6910
6976
|
return getSandboxArgumentEntries(value).map(([key, entry]) => [`.${key}`, entry]);
|
|
6911
6977
|
}
|
|
6912
|
-
|
|
6913
|
-
|
|
6978
|
+
const map = isSandboxMap(value) ? value.entries : value instanceof Map ? value : void 0;
|
|
6979
|
+
if (map !== void 0) {
|
|
6980
|
+
return [...map.entries()].flatMap(([key, entry], index) => [
|
|
6914
6981
|
[`.<map>[${index}].key`, key],
|
|
6915
6982
|
[`.<map>[${index}].value`, entry]
|
|
6916
6983
|
]);
|
|
6917
6984
|
}
|
|
6918
|
-
|
|
6919
|
-
|
|
6985
|
+
const set = isSandboxSet(value) ? value.values : value instanceof Set ? value : void 0;
|
|
6986
|
+
if (set !== void 0) {
|
|
6987
|
+
return [...set.values()].map((entry, index) => [`.<set>[${index}]`, entry]);
|
|
6920
6988
|
}
|
|
6921
6989
|
const entries = [];
|
|
6990
|
+
if (isSandboxCollectionIterator(value)) entries.push([".<collection>", collectionIteratorState(value).collection]);
|
|
6922
6991
|
for (const key of Object.keys(value)) {
|
|
6923
6992
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
6924
6993
|
if (descriptor !== void 0 && "value" in descriptor)
|
|
@@ -7581,6 +7650,7 @@ function validateTaggedValue(record2, path, state) {
|
|
|
7581
7650
|
case "object":
|
|
7582
7651
|
case "map":
|
|
7583
7652
|
case "set":
|
|
7653
|
+
case "collection-iterator":
|
|
7584
7654
|
return;
|
|
7585
7655
|
}
|
|
7586
7656
|
}
|
|
@@ -8548,7 +8618,7 @@ async function objectToPrimitive(value, budget, context, joining, hint) {
|
|
|
8548
8618
|
}
|
|
8549
8619
|
}
|
|
8550
8620
|
function conversionHook(value, name, budget) {
|
|
8551
|
-
const implicitBuiltin = !hasExplicitSandboxPrototype(value) && (Array.isArray(value) || isSandboxDate(value) || isFloat32Array(value) || sandboxErrorTypes.has(value) || isSandboxClosure(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value) || isSandboxGenerator(value) || isGuestHostObject(value));
|
|
8621
|
+
const implicitBuiltin = !hasExplicitSandboxPrototype(value) && (Array.isArray(value) || isSandboxDate(value) || isFloat32Array(value) || sandboxErrorTypes.has(value) || isSandboxClosure(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxCollectionIterator(value) || isSandboxPromise(value) || isSandboxRegex(value) || isSandboxGenerator(value) || isGuestHostObject(value));
|
|
8552
8622
|
let current = value;
|
|
8553
8623
|
let depth = 0;
|
|
8554
8624
|
while (current !== null) {
|
|
@@ -8574,6 +8644,7 @@ function conversionHook(value, name, budget) {
|
|
|
8574
8644
|
async function defaultToString(value, budget, context, joining) {
|
|
8575
8645
|
if (isSandboxMap(value)) return "[object Map]";
|
|
8576
8646
|
if (isSandboxSet(value)) return "[object Set]";
|
|
8647
|
+
if (isSandboxCollectionIterator(value)) return collectionIteratorState(value).collectionKind === "map" ? "[object Map Iterator]" : "[object Set Iterator]";
|
|
8577
8648
|
if (isSandboxGenerator(value)) return "[object Generator]";
|
|
8578
8649
|
if (isSandboxRegex(value)) {
|
|
8579
8650
|
return budget.allocateString(
|
|
@@ -9119,7 +9190,8 @@ function assertSnapshotInactive(snapshot) {
|
|
|
9119
9190
|
}
|
|
9120
9191
|
|
|
9121
9192
|
// packages/safe-js/src/interp/iteration.ts
|
|
9122
|
-
function getSandboxIterator(value) {
|
|
9193
|
+
function getSandboxIterator(value, budget) {
|
|
9194
|
+
if (isSandboxCollectionIterator(value)) return { next: () => nextCollectionIterator(value, budget), snapshotIndex: () => 0 };
|
|
9123
9195
|
if (isGuestHostObject(value)) return getHostObjectIterator(value);
|
|
9124
9196
|
if (isFloat32Array(value)) {
|
|
9125
9197
|
return syncIterator(Float32Array.prototype.values.call(value));
|
|
@@ -9685,7 +9757,7 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
9685
9757
|
const promiseResolve = readPromiseReceiverProperty(constructor, "resolve", prototype);
|
|
9686
9758
|
if (!isSandboxClosure(promiseResolve))
|
|
9687
9759
|
throw new TypeError("Promise constructor requires a callable resolve.");
|
|
9688
|
-
const iterator = getSandboxIterator(iterable);
|
|
9760
|
+
const iterator = getSandboxIterator(iterable, budget);
|
|
9689
9761
|
if (iterator === void 0) throw new TypeError("Promise helpers require an iterable.");
|
|
9690
9762
|
let index = 0;
|
|
9691
9763
|
while (true) {
|
|
@@ -10127,6 +10199,7 @@ function registerCancelablePromises(value, signal) {
|
|
|
10127
10199
|
} else if (isSandboxSet(current)) {
|
|
10128
10200
|
for (const entry of current.values) pending.push(entry);
|
|
10129
10201
|
} else {
|
|
10202
|
+
if (isSandboxCollectionIterator(current)) pending.push(collectionIteratorState(current).collection);
|
|
10130
10203
|
for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(current))) {
|
|
10131
10204
|
if ("value" in descriptor) pending.push(descriptor.value);
|
|
10132
10205
|
}
|
|
@@ -10228,11 +10301,9 @@ function isPromiseLike2(value) {
|
|
|
10228
10301
|
// packages/safe-js/src/interp/values.ts
|
|
10229
10302
|
var sandboxClosureBrand = /* @__PURE__ */ Symbol("SandboxClosure");
|
|
10230
10303
|
var sandboxGeneratorBrand = /* @__PURE__ */ Symbol("SandboxGenerator");
|
|
10231
|
-
var sandboxMapBrand = /* @__PURE__ */ Symbol("SandboxMap");
|
|
10232
10304
|
var sandboxPromiseBrand = /* @__PURE__ */ Symbol("SandboxPromise");
|
|
10233
10305
|
var sandboxRegexBrand = /* @__PURE__ */ Symbol("SandboxRegex");
|
|
10234
10306
|
var sandboxRegexPattern = /* @__PURE__ */ Symbol("SandboxRegexPattern");
|
|
10235
|
-
var sandboxSetBrand = /* @__PURE__ */ Symbol("SandboxSet");
|
|
10236
10307
|
var sandboxRetainedValues = /* @__PURE__ */ Symbol("SandboxRetainedValues");
|
|
10237
10308
|
function createSandboxClosure(input) {
|
|
10238
10309
|
const closure = {
|
|
@@ -10399,15 +10470,9 @@ function getSandboxRegexPattern(regex) {
|
|
|
10399
10470
|
function isSandboxClosure(value) {
|
|
10400
10471
|
return typeof value === "object" && value !== null && sandboxClosureBrand in value;
|
|
10401
10472
|
}
|
|
10402
|
-
function isSandboxMap(value) {
|
|
10403
|
-
return typeof value === "object" && value !== null && sandboxMapBrand in value;
|
|
10404
|
-
}
|
|
10405
10473
|
function isSandboxPromise(value) {
|
|
10406
10474
|
return typeof value === "object" && value !== null && sandboxPromiseBrand in value;
|
|
10407
10475
|
}
|
|
10408
|
-
function isSandboxSet(value) {
|
|
10409
|
-
return typeof value === "object" && value !== null && sandboxSetBrand in value;
|
|
10410
|
-
}
|
|
10411
10476
|
function isSandboxGenerator(value) {
|
|
10412
10477
|
return typeof value === "object" && value !== null && sandboxGeneratorBrand in value;
|
|
10413
10478
|
}
|
|
@@ -10420,14 +10485,18 @@ function deepCopyToSandbox(value) {
|
|
|
10420
10485
|
});
|
|
10421
10486
|
}
|
|
10422
10487
|
function cloneSandboxValue(value) {
|
|
10423
|
-
|
|
10488
|
+
const initializeIterators = [];
|
|
10489
|
+
const copy = copyToSandbox(
|
|
10424
10490
|
value,
|
|
10425
10491
|
{
|
|
10426
|
-
seen: /* @__PURE__ */ new WeakMap()
|
|
10492
|
+
seen: /* @__PURE__ */ new WeakMap(),
|
|
10493
|
+
initializeIterators
|
|
10427
10494
|
},
|
|
10428
10495
|
"<root>",
|
|
10429
10496
|
true
|
|
10430
10497
|
);
|
|
10498
|
+
for (const initialize of initializeIterators) initialize();
|
|
10499
|
+
return copy;
|
|
10431
10500
|
}
|
|
10432
10501
|
function allocateProducedSandboxValue(value, budget) {
|
|
10433
10502
|
allocateSandboxValue2(value, budget, /* @__PURE__ */ new WeakSet());
|
|
@@ -10492,6 +10561,14 @@ function measureSandboxData(values, options = {}) {
|
|
|
10492
10561
|
}
|
|
10493
10562
|
return;
|
|
10494
10563
|
}
|
|
10564
|
+
if (isSandboxCollectionIterator(value)) {
|
|
10565
|
+
visit(collectionIteratorState(value).collection, depth + 1);
|
|
10566
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
10567
|
+
usage += key.length + 1;
|
|
10568
|
+
if ("value" in descriptor) visit(descriptor.value, depth + 1);
|
|
10569
|
+
}
|
|
10570
|
+
return;
|
|
10571
|
+
}
|
|
10495
10572
|
if (isSandboxSet(value)) {
|
|
10496
10573
|
usage += value.values.size;
|
|
10497
10574
|
for (const entry of value.values) visit(entry, depth + 1);
|
|
@@ -10600,6 +10677,24 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
10600
10677
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxRegex(value) || isSandboxPromise(value)) {
|
|
10601
10678
|
return value;
|
|
10602
10679
|
}
|
|
10680
|
+
if (isSandboxCollectionIterator(value)) {
|
|
10681
|
+
if (hasGuestObjectState(value)) throw new TypeError("Guest prototype links and custom descriptors cannot be copied as data.");
|
|
10682
|
+
if (!cloneSandboxCollections) return value;
|
|
10683
|
+
const existing = state.seen.get(value);
|
|
10684
|
+
if (existing !== void 0) return existing;
|
|
10685
|
+
const snapshot = snapshotCollectionIterator(value);
|
|
10686
|
+
const copy = restoreSandboxCollectionIterator({ ...snapshot, collection: void 0, index: 0, exhausted: true });
|
|
10687
|
+
state.seen.set(value, copy);
|
|
10688
|
+
const collection = copyToSandbox(snapshot.collection, state, `${path}.<collection>`, true, depth + 1);
|
|
10689
|
+
if (collection !== void 0 && !isSandboxMap(collection) && !isSandboxSet(collection)) throw new TypeError("Invalid cloned collection iterator source.");
|
|
10690
|
+
state.initializeIterators.push(() => {
|
|
10691
|
+
restoreSandboxCollectionIterator({ ...snapshot, collection }, copy);
|
|
10692
|
+
});
|
|
10693
|
+
for (const entry of getEnumerableObjectEntries(value, path)) {
|
|
10694
|
+
defineOwnDataProperty(copy, entry.key, copyToSandbox(entry.value, state, joinPath(path, entry.key), true, depth + 1));
|
|
10695
|
+
}
|
|
10696
|
+
return copy;
|
|
10697
|
+
}
|
|
10603
10698
|
if (typeof value === "object" && value !== null && hasGuestObjectState(value)) {
|
|
10604
10699
|
throw new TypeError("Guest prototype links and custom descriptors cannot be copied as data.");
|
|
10605
10700
|
}
|
|
@@ -10855,6 +10950,9 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
10855
10950
|
if (isSandboxGenerator(value)) {
|
|
10856
10951
|
throw new TypeError("Sandbox generators cannot cross into host values.");
|
|
10857
10952
|
}
|
|
10953
|
+
if (isSandboxCollectionIterator(value)) {
|
|
10954
|
+
throw new TypeError("Sandbox collection iterators cannot cross into host values.");
|
|
10955
|
+
}
|
|
10858
10956
|
if (isSandboxRegex(value)) {
|
|
10859
10957
|
throw new TypeError("Invalid sandbox RegExp brand.");
|
|
10860
10958
|
}
|
|
@@ -11148,6 +11246,14 @@ function encodeReplayData(value, options = {}) {
|
|
|
11148
11246
|
};
|
|
11149
11247
|
}
|
|
11150
11248
|
nodes[id] = { ...storage, properties, extensible: Object.isExtensible(entry) };
|
|
11249
|
+
} else if (isSandboxCollectionIterator(entry)) {
|
|
11250
|
+
const snapshot = snapshotCollectionIterator(entry);
|
|
11251
|
+
const properties = /* @__PURE__ */ Object.create(null);
|
|
11252
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(entry))) {
|
|
11253
|
+
if (!("value" in descriptor)) throw new TypeError(`Cannot record replay data accessor '${key}'.`);
|
|
11254
|
+
properties[key] = { value: child(descriptor.value, JSON.stringify(["property", key])), configurable: descriptor.configurable === true, enumerable: descriptor.enumerable === true, writable: descriptor.writable === true };
|
|
11255
|
+
}
|
|
11256
|
+
nodes[id] = { kind: "collection-iterator", collectionKind: snapshot.collectionKind, method: snapshot.method, collection: child(snapshot.collection, "<collection>"), index: snapshot.index, exhausted: snapshot.exhausted, properties, extensible: Object.isExtensible(entry) };
|
|
11151
11257
|
} else if (isSandboxMap(entry)) {
|
|
11152
11258
|
nodes[id] = {
|
|
11153
11259
|
kind: "map",
|
|
@@ -11206,6 +11312,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
11206
11312
|
const graph = record(input);
|
|
11207
11313
|
const nodes = list(own(graph, "nodes"));
|
|
11208
11314
|
const restored = /* @__PURE__ */ new Map();
|
|
11315
|
+
const initializeIterators = [];
|
|
11209
11316
|
const decode = (entry, depth = 0) => {
|
|
11210
11317
|
if (depth > MAX_DATA_DEPTH) throw new TypeError("Replay data exceeds the nesting limit.");
|
|
11211
11318
|
if (entry === null || typeof entry === "boolean" || typeof entry === "string") return entry;
|
|
@@ -11298,6 +11405,23 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
11298
11405
|
if (!node.extensible) Object.preventExtensions(result3);
|
|
11299
11406
|
return result3;
|
|
11300
11407
|
}
|
|
11408
|
+
if (kind === "collection-iterator") {
|
|
11409
|
+
const collectionKind = own(node, "collectionKind");
|
|
11410
|
+
const method = own(node, "method");
|
|
11411
|
+
const index = own(node, "index");
|
|
11412
|
+
const exhausted = own(node, "exhausted");
|
|
11413
|
+
if (collectionKind !== "map" && collectionKind !== "set" || method !== "keys" && method !== "values" && method !== "entries" || typeof index !== "number" || !Number.isSafeInteger(index) || index < 0 || typeof exhausted !== "boolean" || typeof node.extensible !== "boolean") throw new TypeError("Invalid replay collection iterator.");
|
|
11414
|
+
const result3 = restoreSandboxCollectionIterator({ collection: void 0, collectionKind, method, index: 0, exhausted: true });
|
|
11415
|
+
restored.set(id, result3);
|
|
11416
|
+
const collection = child(own(node, "collection"));
|
|
11417
|
+
if (collection !== void 0 && !isSandboxMap(collection) && !isSandboxSet(collection)) throw new TypeError("Invalid replay collection iterator source.");
|
|
11418
|
+
initializeIterators.push(() => {
|
|
11419
|
+
restoreSandboxCollectionIterator({ collection, collectionKind, method, index, exhausted }, result3);
|
|
11420
|
+
});
|
|
11421
|
+
defineProperties(result3, record(own(node, "properties")), child);
|
|
11422
|
+
if (!node.extensible) Object.preventExtensions(result3);
|
|
11423
|
+
return result3;
|
|
11424
|
+
}
|
|
11301
11425
|
if (kind === "map") {
|
|
11302
11426
|
const result3 = createSandboxMap();
|
|
11303
11427
|
restored.set(id, result3);
|
|
@@ -11354,6 +11478,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
11354
11478
|
return result2;
|
|
11355
11479
|
};
|
|
11356
11480
|
const result = decode(own(graph, "root"));
|
|
11481
|
+
for (const initialize of initializeIterators) initialize();
|
|
11357
11482
|
if (parent !== void 0) compilation.forward(compilation.tickets, parent);
|
|
11358
11483
|
return result;
|
|
11359
11484
|
} finally {
|
|
@@ -23540,13 +23665,27 @@ async function bindAssignmentPattern2(pattern, value, target, scope, context) {
|
|
|
23540
23665
|
return bindPattern2(pattern.left, defaultValue.value, target, scope, context);
|
|
23541
23666
|
}
|
|
23542
23667
|
async function bindArrayPattern2(pattern, value, target, scope, context) {
|
|
23543
|
-
const
|
|
23668
|
+
const iterator = isSandboxCollectionIterator(value) ? value : void 0;
|
|
23669
|
+
const values = iterator === void 0 ? getArrayPatternValues(value) : void 0;
|
|
23544
23670
|
for (let index = 0; index < pattern.elements.length; index += 1) {
|
|
23545
23671
|
const element = pattern.elements[index];
|
|
23546
23672
|
if (element === null) {
|
|
23673
|
+
if (iterator !== void 0) nextCollectionIterator(iterator, context.budget);
|
|
23547
23674
|
continue;
|
|
23548
23675
|
}
|
|
23549
|
-
|
|
23676
|
+
let elementValue;
|
|
23677
|
+
if (iterator === void 0) {
|
|
23678
|
+
elementValue = element.type === "RestElement" ? values.slice(index) : values[index];
|
|
23679
|
+
} else if (element.type === "RestElement") {
|
|
23680
|
+
const rest = [];
|
|
23681
|
+
for (let entry = nextCollectionIterator(iterator, context.budget); !entry.done; entry = nextCollectionIterator(iterator, context.budget)) {
|
|
23682
|
+
context.budget?.allocateArrayLength(rest.length + 1);
|
|
23683
|
+
rest.push(entry.value);
|
|
23684
|
+
}
|
|
23685
|
+
elementValue = rest;
|
|
23686
|
+
} else {
|
|
23687
|
+
elementValue = nextCollectionIterator(iterator, context.budget).value;
|
|
23688
|
+
}
|
|
23550
23689
|
const binding = await bindPattern2(element, elementValue, target, scope, context);
|
|
23551
23690
|
if (!binding.ok) {
|
|
23552
23691
|
return binding;
|
|
@@ -24528,7 +24667,11 @@ function getMapMember(target, property, options) {
|
|
|
24528
24667
|
}
|
|
24529
24668
|
return createSandboxClosure({
|
|
24530
24669
|
sandbox: true,
|
|
24531
|
-
call: (args, context) =>
|
|
24670
|
+
call: (args, context) => {
|
|
24671
|
+
const receiver = context?.thisValue;
|
|
24672
|
+
if (!isSandboxMap(receiver)) throw new TypeError(`Map#${property} requires a Map receiver.`);
|
|
24673
|
+
return callMapMethod(receiver, property, args, options, context?.stack ?? []);
|
|
24674
|
+
},
|
|
24532
24675
|
name: property
|
|
24533
24676
|
});
|
|
24534
24677
|
}
|
|
@@ -24576,14 +24719,9 @@ async function callMapMethod(target, methodName, args, options, stack = []) {
|
|
|
24576
24719
|
return void 0;
|
|
24577
24720
|
}
|
|
24578
24721
|
case "keys":
|
|
24579
|
-
return allocateProducedSandboxValue([...target.entries.keys()], options.budget);
|
|
24580
24722
|
case "values":
|
|
24581
|
-
return allocateProducedSandboxValue([...target.entries.values()], options.budget);
|
|
24582
24723
|
case "entries":
|
|
24583
|
-
return
|
|
24584
|
-
[...target.entries].map(([key, value]) => [key, value]),
|
|
24585
|
-
options.budget
|
|
24586
|
-
);
|
|
24724
|
+
return createSandboxCollectionIterator(target, methodName);
|
|
24587
24725
|
}
|
|
24588
24726
|
}
|
|
24589
24727
|
|
|
@@ -25130,7 +25268,11 @@ function getSetMember(target, property, options) {
|
|
|
25130
25268
|
}
|
|
25131
25269
|
return createSandboxClosure({
|
|
25132
25270
|
sandbox: true,
|
|
25133
|
-
call: (args, context) =>
|
|
25271
|
+
call: (args, context) => {
|
|
25272
|
+
const receiver = context?.thisValue;
|
|
25273
|
+
if (!isSandboxSet(receiver)) throw new TypeError(`Set#${property} requires a Set receiver.`);
|
|
25274
|
+
return callSetMethod(receiver, property, args, options, context?.stack ?? []);
|
|
25275
|
+
},
|
|
25134
25276
|
name: property
|
|
25135
25277
|
});
|
|
25136
25278
|
}
|
|
@@ -25176,12 +25318,8 @@ async function callSetMethod(target, methodName, args, options, stack = []) {
|
|
|
25176
25318
|
}
|
|
25177
25319
|
case "keys":
|
|
25178
25320
|
case "values":
|
|
25179
|
-
return allocateProducedSandboxValue([...target.values], options.budget);
|
|
25180
25321
|
case "entries":
|
|
25181
|
-
return
|
|
25182
|
-
[...target.values].map((value) => [value, value]),
|
|
25183
|
-
options.budget
|
|
25184
|
-
);
|
|
25322
|
+
return createSandboxCollectionIterator(target, methodName);
|
|
25185
25323
|
}
|
|
25186
25324
|
}
|
|
25187
25325
|
|
|
@@ -25356,6 +25494,7 @@ function typeTag(value) {
|
|
|
25356
25494
|
if (isSandboxRegex(value)) return "RegExp";
|
|
25357
25495
|
if (isSandboxMap(value)) return "Map";
|
|
25358
25496
|
if (isSandboxSet(value)) return "Set";
|
|
25497
|
+
if (isSandboxCollectionIterator(value)) return collectionIteratorState(value).collectionKind === "map" ? "Map Iterator" : "Set Iterator";
|
|
25359
25498
|
if (isSandboxPromise(value)) return "Promise";
|
|
25360
25499
|
if (isSandboxGenerator(value)) return "Generator";
|
|
25361
25500
|
if (isFloat32Array(value)) return "Float32Array";
|
|
@@ -25444,7 +25583,7 @@ function isSandboxSetConstructor(value) {
|
|
|
25444
25583
|
function populateCollection(source, collection, { name, budget, context, append, retainedValues }) {
|
|
25445
25584
|
budget.allocateCollectionEntries(0);
|
|
25446
25585
|
if (source === void 0 || source === null) return collection;
|
|
25447
|
-
const iterator = getSandboxIterator(source);
|
|
25586
|
+
const iterator = getSandboxIterator(source, budget);
|
|
25448
25587
|
if (iterator === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
|
|
25449
25588
|
let entry;
|
|
25450
25589
|
let failure;
|
|
@@ -25505,6 +25644,23 @@ function populateCollection(source, collection, { name, budget, context, append,
|
|
|
25505
25644
|
}
|
|
25506
25645
|
}
|
|
25507
25646
|
|
|
25647
|
+
// packages/safe-js/src/interp/methods/collection-iterator.ts
|
|
25648
|
+
function getCollectionIteratorMember(target, property, budget) {
|
|
25649
|
+
if (Object.hasOwn(target, property)) return target[property];
|
|
25650
|
+
if (property !== "next") return void 0;
|
|
25651
|
+
const { collectionKind } = collectionIteratorState(target);
|
|
25652
|
+
return createSandboxClosure({
|
|
25653
|
+
sandbox: true,
|
|
25654
|
+
name: "next",
|
|
25655
|
+
call: (_args, context) => {
|
|
25656
|
+
const receiver = context?.thisValue;
|
|
25657
|
+
if (!isSandboxCollectionIterator(receiver) || collectionIteratorState(receiver).collectionKind !== collectionKind)
|
|
25658
|
+
throw new TypeError("Iterator next requires a matching collection iterator receiver.");
|
|
25659
|
+
return nextCollectionIterator(receiver, budget);
|
|
25660
|
+
}
|
|
25661
|
+
});
|
|
25662
|
+
}
|
|
25663
|
+
|
|
25508
25664
|
// packages/safe-js/src/interp/globals/float32array.ts
|
|
25509
25665
|
var constructors = /* @__PURE__ */ new WeakSet();
|
|
25510
25666
|
function createFloat32ArrayGlobal(budget) {
|
|
@@ -26689,6 +26845,9 @@ function isRestorableBindingValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
26689
26845
|
}
|
|
26690
26846
|
if (seen.has(value)) return true;
|
|
26691
26847
|
seen.add(value);
|
|
26848
|
+
if (isSandboxCollectionIterator(value)) {
|
|
26849
|
+
return isRestorableBindingValue(collectionIteratorState(value).collection, seen);
|
|
26850
|
+
}
|
|
26692
26851
|
if (isSandboxMap(value)) {
|
|
26693
26852
|
for (const [key, entry] of value.entries) {
|
|
26694
26853
|
if (!isRestorableBindingValue(key, seen) || !isRestorableBindingValue(entry, seen)) {
|
|
@@ -26931,7 +27090,7 @@ async function evaluateForOfStatement(node, context) {
|
|
|
26931
27090
|
const restored = context.scope.consumeRestoredBinding(restoredIteration.values[0]);
|
|
26932
27091
|
if (restored.found && Array.isArray(restored.value)) {
|
|
26933
27092
|
restoredEntry = { done: false, value: restored.value[1] };
|
|
26934
|
-
if (isSandboxMap(restored.value[0]) || isSandboxSet(restored.value[0])) {
|
|
27093
|
+
if (isSandboxMap(restored.value[0]) || isSandboxSet(restored.value[0]) || isSandboxCollectionIterator(restored.value[0])) {
|
|
26935
27094
|
return evaluateForOfIterator(node, restored.value[0], context, restoredEntry);
|
|
26936
27095
|
}
|
|
26937
27096
|
}
|
|
@@ -26979,7 +27138,7 @@ async function evaluateForOfStatement(node, context) {
|
|
|
26979
27138
|
};
|
|
26980
27139
|
}
|
|
26981
27140
|
async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
26982
|
-
const iterator = getSandboxIterator(value);
|
|
27141
|
+
const iterator = getSandboxIterator(value, context.budget);
|
|
26983
27142
|
if (iterator === void 0) {
|
|
26984
27143
|
throw new TypeError(`${String(value)} is not a supported iterable`);
|
|
26985
27144
|
}
|
|
@@ -27278,7 +27437,7 @@ function createLoopIterationContext(context, scope) {
|
|
|
27278
27437
|
if (context.activeLoopIterations.size === 0) return snapshot;
|
|
27279
27438
|
snapshot.loopIterations = {};
|
|
27280
27439
|
for (const [nodeId, iteration] of context.activeLoopIterations) {
|
|
27281
|
-
if (typeof iteration !== "number" && (isSandboxMap(iteration.values[0]) || isSandboxSet(iteration.values[0]))) {
|
|
27440
|
+
if (typeof iteration !== "number" && (isSandboxMap(iteration.values[0]) || isSandboxSet(iteration.values[0]) || isSandboxCollectionIterator(iteration.values[0]))) {
|
|
27282
27441
|
const bindingName = `#for-of:${nodeId}`;
|
|
27283
27442
|
snapshot.bindings[bindingName] = iteration.values;
|
|
27284
27443
|
snapshot.loopIterations[nodeId] = { index: iteration.index, values: [bindingName] };
|
|
@@ -27405,7 +27564,7 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
27405
27564
|
if (argument.kind !== "normal") {
|
|
27406
27565
|
return argument;
|
|
27407
27566
|
}
|
|
27408
|
-
const iterator = getSandboxIterator(argument.value);
|
|
27567
|
+
const iterator = getSandboxIterator(argument.value, context.budget);
|
|
27409
27568
|
if (iterator === void 0) {
|
|
27410
27569
|
throw new TypeError(`${String(argument.value)} is not a supported iterable`);
|
|
27411
27570
|
}
|
|
@@ -27615,6 +27774,7 @@ function getPropertyValue(target, property, context) {
|
|
|
27615
27774
|
if (isSandboxDate(target)) return getDateMember(property, context.budget, context.compilation?.owner);
|
|
27616
27775
|
if (isSandboxMap(target)) return getMapMember(target, property, createMapMethodOptions(context));
|
|
27617
27776
|
if (isSandboxSet(target)) return getSetMember(target, property, createSetMethodOptions(context));
|
|
27777
|
+
if (isSandboxCollectionIterator(target)) return getCollectionIteratorMember(target, property, context.budget);
|
|
27618
27778
|
if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
|
|
27619
27779
|
if (isSandboxClosure(target)) return getClosureMemberValue(target, property, context);
|
|
27620
27780
|
if (isSandboxPromise(target)) return getPromiseMember(property, context.budget);
|
|
@@ -27627,6 +27787,7 @@ function getPropertyValue(target, property, context) {
|
|
|
27627
27787
|
function createPatternContext(context, scope = context.scope, evaluate = evaluateNode) {
|
|
27628
27788
|
const evaluationContext = { ...context, scope };
|
|
27629
27789
|
return {
|
|
27790
|
+
budget: context.budget,
|
|
27630
27791
|
evaluate: (node) => evaluate(node, evaluationContext),
|
|
27631
27792
|
toPropertyKey: (value) => toPropertyKey(value, context.budget, createCoercionContext(evaluationContext)),
|
|
27632
27793
|
getProperty: (value, key) => getPropertyValue(value, key, evaluationContext),
|
|
@@ -28134,7 +28295,7 @@ function hasSandboxProperty(value, key, context) {
|
|
|
28134
28295
|
while (typeof current === "object" && current !== null) {
|
|
28135
28296
|
if (isGuestHostObject(current)) return hasHostObjectMember(current, key);
|
|
28136
28297
|
if (hasOwnSandboxProperty(current, key, false)) return true;
|
|
28137
|
-
if (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current)) {
|
|
28298
|
+
if (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current)) {
|
|
28138
28299
|
return getPropertyValue(current, key, context) !== void 0;
|
|
28139
28300
|
}
|
|
28140
28301
|
current = getSandboxPrototype(current, context.budget);
|
|
@@ -28344,7 +28505,7 @@ function getMemberValue(target, property, context) {
|
|
|
28344
28505
|
while (typeof current === "object" && current !== null) {
|
|
28345
28506
|
if (isSandboxClosure(current)) return getClosureMemberValue(current, property, context);
|
|
28346
28507
|
if (Array.isArray(current)) return getArrayMemberValue(current, property, context);
|
|
28347
|
-
if (!isPlainSandboxObject(current) || isSandboxGenerator(current) || isFloat32Array(current)) {
|
|
28508
|
+
if (!isPlainSandboxObject(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current) || isFloat32Array(current)) {
|
|
28348
28509
|
return getPropertyValue(current, property, context);
|
|
28349
28510
|
}
|
|
28350
28511
|
if (Object.hasOwn(current, String(property))) return current[String(property)];
|
|
@@ -28559,7 +28720,7 @@ async function evaluateSpreadElement(node, context) {
|
|
|
28559
28720
|
result: value
|
|
28560
28721
|
};
|
|
28561
28722
|
}
|
|
28562
|
-
const iterator =
|
|
28723
|
+
const iterator = getSandboxIterator(value.value, context.budget);
|
|
28563
28724
|
if (iterator === void 0) {
|
|
28564
28725
|
throw new TypeError("Spread arguments must evaluate to an iterable.");
|
|
28565
28726
|
}
|
|
@@ -28629,9 +28790,6 @@ function describeObjectSpreadValue(value) {
|
|
|
28629
28790
|
}
|
|
28630
28791
|
return typeof value;
|
|
28631
28792
|
}
|
|
28632
|
-
function getSpreadIterator(value) {
|
|
28633
|
-
return getSandboxIterator(value);
|
|
28634
|
-
}
|
|
28635
28793
|
async function closeIterator(iterator) {
|
|
28636
28794
|
if (iterator.generator && iterator.return !== void 0) {
|
|
28637
28795
|
await iterator.return();
|
|
@@ -30416,8 +30574,8 @@ function structuredCloneSandboxValue(value, budget) {
|
|
|
30416
30574
|
return allocateProducedSandboxValue(clone, budget);
|
|
30417
30575
|
}
|
|
30418
30576
|
function assertStructuredCloneable(value, seen) {
|
|
30419
|
-
if (isSandboxClosure(value) || isSandboxPromise(value)) {
|
|
30420
|
-
throw new TypeError("structuredClone() cannot clone closures or
|
|
30577
|
+
if (isSandboxClosure(value) || isSandboxPromise(value) || isSandboxCollectionIterator(value)) {
|
|
30578
|
+
throw new TypeError("structuredClone() cannot clone closures, promises, or collection iterators.");
|
|
30421
30579
|
}
|
|
30422
30580
|
if (typeof value !== "object" || value === null || seen.has(value)) {
|
|
30423
30581
|
return;
|
|
@@ -30545,7 +30703,7 @@ function createObjectArrayGlobals(options) {
|
|
|
30545
30703
|
fromEntries: createSandboxClosure({
|
|
30546
30704
|
sandbox: true,
|
|
30547
30705
|
call: ([value], context) => {
|
|
30548
|
-
const iterator = getSandboxIterator(value);
|
|
30706
|
+
const iterator = getSandboxIterator(value, options.budget);
|
|
30549
30707
|
if (iterator === void 0) {
|
|
30550
30708
|
throw new TypeError("Object.fromEntries requires an iterable.");
|
|
30551
30709
|
}
|
|
@@ -30808,7 +30966,7 @@ async function arrayFromSandboxValues(args, budget, context) {
|
|
|
30808
30966
|
throw new TypeError("Array.from requires a non-null input.");
|
|
30809
30967
|
}
|
|
30810
30968
|
const read = (property) => context?.getProperty !== void 0 ? context.getProperty(items, property) : getSandboxDataProperty(items, property, budget);
|
|
30811
|
-
const iterator = getSandboxIterator(items);
|
|
30969
|
+
const iterator = getSandboxIterator(items, budget);
|
|
30812
30970
|
const constructor = context?.thisValue;
|
|
30813
30971
|
let result;
|
|
30814
30972
|
let currentValue;
|
|
@@ -32388,6 +32546,16 @@ function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestore
|
|
|
32388
32546
|
throw new TypeError("Invalid replay input capability path.");
|
|
32389
32547
|
let value = current;
|
|
32390
32548
|
for (const key of path) {
|
|
32549
|
+
if (isSandboxCollectionIterator(value)) {
|
|
32550
|
+
if (key === "<collection>") value = collectionIteratorState(value).collection;
|
|
32551
|
+
else {
|
|
32552
|
+
const property = JSON.parse(key);
|
|
32553
|
+
if (!Array.isArray(property) || property.length !== 2 || property[0] !== "property" || typeof property[1] !== "string") throw new TypeError("Invalid replay input iterator capability path.");
|
|
32554
|
+
const descriptor2 = Object.getOwnPropertyDescriptor(value, property[1]);
|
|
32555
|
+
value = descriptor2 !== void 0 && "value" in descriptor2 ? descriptor2.value : void 0;
|
|
32556
|
+
}
|
|
32557
|
+
continue;
|
|
32558
|
+
}
|
|
32391
32559
|
if (isSandboxMap(value)) {
|
|
32392
32560
|
const [kind, ordinal] = key.split(":");
|
|
32393
32561
|
const index = Number(ordinal);
|
|
@@ -32448,11 +32616,11 @@ function prepareReplayInputs(current, saved, preparePromise, onCapabilityRestore
|
|
|
32448
32616
|
return { values: restored, snapshot: structuredClone(saved) };
|
|
32449
32617
|
}
|
|
32450
32618
|
function assertReplayInputShape(restored) {
|
|
32451
|
-
if (restored === null || typeof restored !== "object" || Array.isArray(restored) || isSandboxClosure(restored) || isSandboxPromise(restored) || isSandboxMap(restored) || isSandboxSet(restored))
|
|
32619
|
+
if (restored === null || typeof restored !== "object" || Array.isArray(restored) || isSandboxClosure(restored) || isSandboxPromise(restored) || isSandboxCollectionIterator(restored) || isSandboxMap(restored) || isSandboxSet(restored))
|
|
32452
32620
|
throw new TypeError("Invalid replay inputs.");
|
|
32453
32621
|
const values = restored;
|
|
32454
32622
|
for (const key of ["bindings", "imports"]) {
|
|
32455
|
-
if (values[key] === null || typeof values[key] !== "object" || Array.isArray(values[key]) || isSandboxClosure(values[key]) || isSandboxPromise(values[key]) || isSandboxMap(values[key]) || isSandboxSet(values[key]))
|
|
32623
|
+
if (values[key] === null || typeof values[key] !== "object" || Array.isArray(values[key]) || isSandboxClosure(values[key]) || isSandboxPromise(values[key]) || isSandboxCollectionIterator(values[key]) || isSandboxMap(values[key]) || isSandboxSet(values[key]))
|
|
32456
32624
|
throw new TypeError(`Invalid replay input ${key}.`);
|
|
32457
32625
|
}
|
|
32458
32626
|
if (values.entryPointArgs !== void 0 && !Array.isArray(values.entryPointArgs))
|
|
@@ -33045,4 +33213,4 @@ export {
|
|
|
33045
33213
|
FileSnapshotBackend,
|
|
33046
33214
|
run
|
|
33047
33215
|
};
|
|
33048
|
-
//# sourceMappingURL=chunk-
|
|
33216
|
+
//# sourceMappingURL=chunk-DVWTNFTV.js.map
|