@poe-platform/safe-js 0.1.256 → 0.1.258
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-J5L6E3YK.js → chunk-2BZGVMP3.js} +2 -2
- package/dist/safe-js/chunks/{chunk-S2YTYPJP.js → chunk-KBUVHGDL.js} +552 -390
- package/dist/safe-js/chunks/chunk-KBUVHGDL.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-properties.d.ts +4 -0
- package/dist/safe-js/interp/values.d.ts +1 -0
- package/dist/safe-js/snapshot/property-descriptors.d.ts +19 -0
- package/dist/safe-js/snapshot/replay-data.d.ts +3 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-S2YTYPJP.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-J5L6E3YK.js.map → chunk-2BZGVMP3.js.map} +0 -0
|
@@ -7015,6 +7015,23 @@ function getRegexProperties(value) {
|
|
|
7015
7015
|
return properties;
|
|
7016
7016
|
}
|
|
7017
7017
|
|
|
7018
|
+
// packages/safe-js/src/interp/collection-properties.ts
|
|
7019
|
+
var collectionGuestProperties = /* @__PURE__ */ new WeakMap();
|
|
7020
|
+
function getCollectionProperties(value) {
|
|
7021
|
+
const properties = collectionGuestProperties.get(value);
|
|
7022
|
+
if (properties === void 0) throw new TypeError("Invalid sandbox collection storage.");
|
|
7023
|
+
return properties;
|
|
7024
|
+
}
|
|
7025
|
+
function copyCollectionProperties(source, target, encode) {
|
|
7026
|
+
const properties = collectionGuestProperties.get(source) ?? source;
|
|
7027
|
+
for (const key of Reflect.ownKeys(properties)) {
|
|
7028
|
+
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
7029
|
+
if (!("value" in descriptor)) throw new TypeError("Collection accessor properties cannot be copied as data.");
|
|
7030
|
+
Object.defineProperty(target, key, { ...descriptor, value: encode(descriptor.value) });
|
|
7031
|
+
}
|
|
7032
|
+
if (!Object.isExtensible(properties)) Object.preventExtensions(target);
|
|
7033
|
+
}
|
|
7034
|
+
|
|
7018
7035
|
// packages/safe-js/src/interp/accessors.ts
|
|
7019
7036
|
var accessorClosures = /* @__PURE__ */ new WeakMap();
|
|
7020
7037
|
var getterAdapters = /* @__PURE__ */ new WeakMap();
|
|
@@ -7886,10 +7903,10 @@ function trackIntrinsicState(budget, root, owner, targets) {
|
|
|
7886
7903
|
value: isGuestClosure(target) ? materializeFunctionProperties(target) : target,
|
|
7887
7904
|
prototype: getSandboxPrototype(target),
|
|
7888
7905
|
explicit: hasExplicitSandboxPrototype(target)
|
|
7889
|
-
})).map((
|
|
7890
|
-
...
|
|
7891
|
-
extensible: Object.isExtensible(
|
|
7892
|
-
descriptors: new Map(Reflect.ownKeys(
|
|
7906
|
+
})).map((record4) => ({
|
|
7907
|
+
...record4,
|
|
7908
|
+
extensible: Object.isExtensible(record4.value),
|
|
7909
|
+
descriptors: new Map(Reflect.ownKeys(record4.value).map((key) => [key, Object.getOwnPropertyDescriptor(record4.value, key)]))
|
|
7893
7910
|
}));
|
|
7894
7911
|
for (const { target } of records)
|
|
7895
7912
|
if (isGuestClosure(target)) intrinsicFunctions.add(target);
|
|
@@ -7947,7 +7964,7 @@ function getSandboxPropertyDescriptor(value, key, budget) {
|
|
|
7947
7964
|
let current = value;
|
|
7948
7965
|
let depth = 0;
|
|
7949
7966
|
while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxDate(current) || isSandboxRegex(current) || isSandboxMap(current) || isSandboxSet(current) || isPrototypeRecord(current))) {
|
|
7950
|
-
const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ?
|
|
7967
|
+
const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
7951
7968
|
const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key);
|
|
7952
7969
|
if (descriptor !== void 0) return descriptor;
|
|
7953
7970
|
current = getSandboxPrototype(current, budget);
|
|
@@ -7964,6 +7981,7 @@ function getSandboxDataProperty(value, key, budget) {
|
|
|
7964
7981
|
while (typeof current === "object" && current !== null) {
|
|
7965
7982
|
if (isGuestHostObject(current)) return typeof key === "symbol" ? void 0 : getHostObjectMember(current, String(key));
|
|
7966
7983
|
if (isSandboxRegex(current)) return Object.getOwnPropertyDescriptor(getRegexProperties(current), key)?.value;
|
|
7984
|
+
if (isSandboxMap(current) || isSandboxSet(current)) return Object.getOwnPropertyDescriptor(getCollectionProperties(current), key)?.value;
|
|
7967
7985
|
if (isGuestClosure(current)) {
|
|
7968
7986
|
const entry = getGuestFunctionProperty(current, key);
|
|
7969
7987
|
if (entry !== void 0 || Object.hasOwn(current.properties ?? {}, key)) return entry;
|
|
@@ -8079,9 +8097,9 @@ var SandboxPromiseRejectionTracker = class {
|
|
|
8079
8097
|
});
|
|
8080
8098
|
}
|
|
8081
8099
|
observe(promise) {
|
|
8082
|
-
const
|
|
8083
|
-
if (
|
|
8084
|
-
|
|
8100
|
+
const record4 = this.recordsByPromise.get(promise);
|
|
8101
|
+
if (record4 !== void 0) {
|
|
8102
|
+
record4.observed = true;
|
|
8085
8103
|
}
|
|
8086
8104
|
}
|
|
8087
8105
|
track(promise, outcome) {
|
|
@@ -8089,13 +8107,13 @@ var SandboxPromiseRejectionTracker = class {
|
|
|
8089
8107
|
if (existing !== void 0 && outcome === void 0) {
|
|
8090
8108
|
return;
|
|
8091
8109
|
}
|
|
8092
|
-
const
|
|
8110
|
+
const record4 = existing ?? {
|
|
8093
8111
|
observed: false,
|
|
8094
8112
|
promise,
|
|
8095
8113
|
rejected: false
|
|
8096
8114
|
};
|
|
8097
|
-
this.records.add(
|
|
8098
|
-
this.recordsByPromise.set(promise,
|
|
8115
|
+
this.records.add(record4);
|
|
8116
|
+
this.recordsByPromise.set(promise, record4);
|
|
8099
8117
|
const pending = outcome ?? promise.promise;
|
|
8100
8118
|
pending.then(
|
|
8101
8119
|
() => void 0,
|
|
@@ -8105,9 +8123,9 @@ var SandboxPromiseRejectionTracker = class {
|
|
|
8105
8123
|
for (const interrupt of this.fatalWaiters) interrupt(reason);
|
|
8106
8124
|
this.fatalWaiters.clear();
|
|
8107
8125
|
}
|
|
8108
|
-
if (
|
|
8109
|
-
|
|
8110
|
-
|
|
8126
|
+
if (record4.rejected) return;
|
|
8127
|
+
record4.rejected = true;
|
|
8128
|
+
record4.rejectionReason = reason;
|
|
8111
8129
|
}
|
|
8112
8130
|
);
|
|
8113
8131
|
pending.catch(() => void 0);
|
|
@@ -8115,11 +8133,11 @@ var SandboxPromiseRejectionTracker = class {
|
|
|
8115
8133
|
async findUnhandledRejection() {
|
|
8116
8134
|
await flushPromiseJobs();
|
|
8117
8135
|
if (this.fatalRejection !== void 0) throw this.fatalRejection;
|
|
8118
|
-
for (const
|
|
8119
|
-
if (
|
|
8136
|
+
for (const record4 of this.records) {
|
|
8137
|
+
if (record4.rejected && !record4.observed) {
|
|
8120
8138
|
return {
|
|
8121
|
-
reason:
|
|
8122
|
-
span:
|
|
8139
|
+
reason: record4.rejectionReason,
|
|
8140
|
+
span: record4.promise.span
|
|
8123
8141
|
};
|
|
8124
8142
|
}
|
|
8125
8143
|
}
|
|
@@ -8569,6 +8587,81 @@ function serializePropertyDescriptors(target, encode) {
|
|
|
8569
8587
|
extensible: Object.isExtensible(target)
|
|
8570
8588
|
};
|
|
8571
8589
|
}
|
|
8590
|
+
function record(value, names) {
|
|
8591
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
8592
|
+
throw new TypeError("Invalid property descriptor record.");
|
|
8593
|
+
const descriptors2 = Object.getOwnPropertyDescriptors(value);
|
|
8594
|
+
if (Reflect.ownKeys(descriptors2).length !== names.length || names.some((name) => !Object.hasOwn(descriptors2, name) || !("value" in descriptors2[name])))
|
|
8595
|
+
throw new TypeError("Invalid property descriptor fields.");
|
|
8596
|
+
return Object.fromEntries(names.map((name) => [name, descriptors2[name].value]));
|
|
8597
|
+
}
|
|
8598
|
+
function restorePropertyDescriptors(target, raw, decode) {
|
|
8599
|
+
const data = record(raw, ["properties", "extensible"]);
|
|
8600
|
+
if (!Array.isArray(data.properties) || typeof data.extensible !== "boolean")
|
|
8601
|
+
throw new TypeError("Invalid property descriptor state.");
|
|
8602
|
+
const decoded = /* @__PURE__ */ new Map();
|
|
8603
|
+
for (const entry of data.properties) {
|
|
8604
|
+
if (!Array.isArray(entry) || entry.length !== 2)
|
|
8605
|
+
throw new TypeError("Invalid property descriptor entry.");
|
|
8606
|
+
const key = decode(entry[0]);
|
|
8607
|
+
if (typeof key !== "string" && typeof key !== "symbol" || typeof key === "symbol" && internalSymbols.has(key))
|
|
8608
|
+
throw new TypeError("Invalid property key.");
|
|
8609
|
+
if (decoded.has(key)) throw new TypeError("Duplicate property key.");
|
|
8610
|
+
const kind = entry[1] !== null && typeof entry[1] === "object" ? Object.getOwnPropertyDescriptor(entry[1], "kind")?.value : void 0;
|
|
8611
|
+
if (kind !== "data" && kind !== "accessor") throw new TypeError("Invalid property descriptor kind.");
|
|
8612
|
+
const descriptor = record(entry[1], kind === "data" ? ["kind", "value", "writable", "enumerable", "configurable"] : ["kind", "get", "set", "enumerable", "configurable"]);
|
|
8613
|
+
if (typeof descriptor.enumerable !== "boolean" || typeof descriptor.configurable !== "boolean" || kind === "data" && typeof descriptor.writable !== "boolean")
|
|
8614
|
+
throw new TypeError("Invalid property descriptor flags.");
|
|
8615
|
+
const result = { enumerable: descriptor.enumerable, configurable: descriptor.configurable };
|
|
8616
|
+
if (kind === "data") {
|
|
8617
|
+
result.value = decode(descriptor.value);
|
|
8618
|
+
result.writable = descriptor.writable;
|
|
8619
|
+
} else {
|
|
8620
|
+
for (const accessor of ["get", "set"]) {
|
|
8621
|
+
const closure = decode(descriptor[accessor]);
|
|
8622
|
+
if (closure !== void 0 && !isSandboxClosure(closure))
|
|
8623
|
+
throw new TypeError("Property accessors require a sandbox closure.");
|
|
8624
|
+
result[accessor] = closure === void 0 ? void 0 : accessorAdapter(closure, accessor);
|
|
8625
|
+
}
|
|
8626
|
+
}
|
|
8627
|
+
decoded.set(key, result);
|
|
8628
|
+
}
|
|
8629
|
+
const trial = Object.defineProperties(Array.isArray(target) ? [] : /* @__PURE__ */ Object.create(null), Object.getOwnPropertyDescriptors(target));
|
|
8630
|
+
if (!Object.isExtensible(target)) Object.preventExtensions(trial);
|
|
8631
|
+
applyDescriptors(trial, decoded, data.extensible);
|
|
8632
|
+
applyDescriptors(target, decoded, data.extensible);
|
|
8633
|
+
markDescriptorObject(target);
|
|
8634
|
+
}
|
|
8635
|
+
function keyGroup(key) {
|
|
8636
|
+
if (typeof key === "symbol") return "symbol";
|
|
8637
|
+
const index = Number(key);
|
|
8638
|
+
return Number.isInteger(index) && index >= 0 && index < 4294967295 && String(index) === key ? "index" : "string";
|
|
8639
|
+
}
|
|
8640
|
+
function applyDescriptors(target, descriptors2, extensible) {
|
|
8641
|
+
if (extensible && !Object.isExtensible(target)) throw new TypeError("Cannot restore extensibility.");
|
|
8642
|
+
const original = Reflect.ownKeys(target).filter((key) => typeof key !== "symbol" || !internalSymbols.has(key));
|
|
8643
|
+
const keep = /* @__PURE__ */ new Set();
|
|
8644
|
+
for (const group of ["index", "string", "symbol"]) {
|
|
8645
|
+
const positions = new Map(original.filter((key) => keyGroup(key) === group).map((key, index) => [key, index]));
|
|
8646
|
+
let previous = -1;
|
|
8647
|
+
for (const key of descriptors2.keys()) {
|
|
8648
|
+
if (keyGroup(key) !== group) continue;
|
|
8649
|
+
const position = positions.get(key);
|
|
8650
|
+
if (group === "index") {
|
|
8651
|
+
if (position !== void 0) keep.add(key);
|
|
8652
|
+
} else {
|
|
8653
|
+
if (position === void 0 || position <= previous) break;
|
|
8654
|
+
keep.add(key);
|
|
8655
|
+
previous = position;
|
|
8656
|
+
}
|
|
8657
|
+
}
|
|
8658
|
+
}
|
|
8659
|
+
for (const key of original)
|
|
8660
|
+
if (!keep.has(key) && !Reflect.deleteProperty(target, key))
|
|
8661
|
+
throw new TypeError("Cannot restore nonconfigurable property order or deletion.");
|
|
8662
|
+
for (const [key, descriptor] of descriptors2) Object.defineProperty(target, key, descriptor);
|
|
8663
|
+
if (!extensible) Object.preventExtensions(target);
|
|
8664
|
+
}
|
|
8572
8665
|
|
|
8573
8666
|
// packages/safe-js/src/interp/running-state.ts
|
|
8574
8667
|
var runningObjects = /* @__PURE__ */ new WeakSet();
|
|
@@ -9842,7 +9935,8 @@ function hasOwnSandboxProperty(value, key, enumerable) {
|
|
|
9842
9935
|
else if (isSandboxClosure(value)) {
|
|
9843
9936
|
if (key === "length" || key === "name") return !enumerable;
|
|
9844
9937
|
properties = value.properties ?? /* @__PURE__ */ Object.create(null);
|
|
9845
|
-
} else if (isSandboxMap(value) || isSandboxSet(value)
|
|
9938
|
+
} else if (isSandboxMap(value) || isSandboxSet(value)) properties = getCollectionProperties(value);
|
|
9939
|
+
else if (isSandboxPromise(value) || isSandboxGenerator(value))
|
|
9846
9940
|
return false;
|
|
9847
9941
|
else if (isSandboxRegex(value)) properties = getRegexProperties(value);
|
|
9848
9942
|
else properties = Object(value);
|
|
@@ -12486,14 +12580,14 @@ function createObjectArrayGlobals(options) {
|
|
|
12486
12580
|
call: ([value]) => {
|
|
12487
12581
|
if (isGuestHostObject(value))
|
|
12488
12582
|
throw new TypeError("Live host objects cannot be made non-extensible.");
|
|
12489
|
-
Object.preventExtensions(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value);
|
|
12583
|
+
Object.preventExtensions(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
|
|
12490
12584
|
return value;
|
|
12491
12585
|
},
|
|
12492
12586
|
name: "preventExtensions"
|
|
12493
12587
|
}),
|
|
12494
12588
|
isExtensible: createSandboxClosure({
|
|
12495
12589
|
sandbox: true,
|
|
12496
|
-
call: ([value]) => Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value),
|
|
12590
|
+
call: ([value]) => Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
|
|
12497
12591
|
name: "isExtensible"
|
|
12498
12592
|
}),
|
|
12499
12593
|
seal: createSandboxClosure({
|
|
@@ -12501,14 +12595,14 @@ function createObjectArrayGlobals(options) {
|
|
|
12501
12595
|
call: ([value]) => {
|
|
12502
12596
|
if (isGuestHostObject(value))
|
|
12503
12597
|
throw new TypeError("Live host objects cannot be sealed.");
|
|
12504
|
-
Object.seal(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value);
|
|
12598
|
+
Object.seal(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
|
|
12505
12599
|
return value;
|
|
12506
12600
|
},
|
|
12507
12601
|
name: "seal"
|
|
12508
12602
|
}),
|
|
12509
12603
|
isSealed: createSandboxClosure({
|
|
12510
12604
|
sandbox: true,
|
|
12511
|
-
call: ([value]) => Object.isSealed(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value),
|
|
12605
|
+
call: ([value]) => Object.isSealed(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
|
|
12512
12606
|
name: "isSealed"
|
|
12513
12607
|
}),
|
|
12514
12608
|
freeze: createSandboxClosure({
|
|
@@ -12517,7 +12611,7 @@ function createObjectArrayGlobals(options) {
|
|
|
12517
12611
|
if (isGuestHostObject(value))
|
|
12518
12612
|
throw new TypeError("Live host objects cannot be frozen.");
|
|
12519
12613
|
if (typeof value === "object" && value !== null) {
|
|
12520
|
-
Object.freeze(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value);
|
|
12614
|
+
Object.freeze(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
|
|
12521
12615
|
}
|
|
12522
12616
|
return value;
|
|
12523
12617
|
},
|
|
@@ -12525,7 +12619,7 @@ function createObjectArrayGlobals(options) {
|
|
|
12525
12619
|
}),
|
|
12526
12620
|
isFrozen: createSandboxClosure({
|
|
12527
12621
|
sandbox: true,
|
|
12528
|
-
call: ([value]) => Object.isFrozen(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : value),
|
|
12622
|
+
call: ([value]) => Object.isFrozen(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
|
|
12529
12623
|
name: "isFrozen"
|
|
12530
12624
|
}),
|
|
12531
12625
|
assign: createSandboxClosure({
|
|
@@ -12733,6 +12827,7 @@ function assignSandboxValues(target, sources, budget, context) {
|
|
|
12733
12827
|
})();
|
|
12734
12828
|
}
|
|
12735
12829
|
function objectProperties(value, mutable = false) {
|
|
12830
|
+
if (isSandboxMap(value) || isSandboxSet(value)) return getCollectionProperties(value);
|
|
12736
12831
|
if (isSandboxRegex(value)) return getRegexProperties(value);
|
|
12737
12832
|
if (isSandboxDate(value)) {
|
|
12738
12833
|
return value;
|
|
@@ -14845,11 +14940,16 @@ function createCollectionGlobals(options) {
|
|
|
14845
14940
|
budget: options.budget,
|
|
14846
14941
|
context,
|
|
14847
14942
|
retainedValues: () => [key, value],
|
|
14848
|
-
append: (entry) => {
|
|
14943
|
+
append: (entry, adder) => {
|
|
14849
14944
|
if (typeof entry !== "object" || entry === null)
|
|
14850
14945
|
throw new TypeError("Map constructor requires entry objects.");
|
|
14851
14946
|
const store = (entryValue) => {
|
|
14852
14947
|
value = entryValue;
|
|
14948
|
+
if (adder !== void 0)
|
|
14949
|
+
return invokeBuiltinClosure(adder, [key, value], options.budget, context, map).then(() => {
|
|
14950
|
+
key = value = void 0;
|
|
14951
|
+
return 0;
|
|
14952
|
+
});
|
|
14853
14953
|
const added = map.entries.has(key) ? 0 : 1;
|
|
14854
14954
|
const growth = added + (options.budget.limits.dataSize === void 0 ? 0 : measureSandboxData([key, value]));
|
|
14855
14955
|
options.budget.allocateCollectionEntries(map.entries.size + added);
|
|
@@ -14882,7 +14982,9 @@ function createCollectionGlobals(options) {
|
|
|
14882
14982
|
name: "Set",
|
|
14883
14983
|
budget: options.budget,
|
|
14884
14984
|
context,
|
|
14885
|
-
append: (value) => {
|
|
14985
|
+
append: (value, adder) => {
|
|
14986
|
+
if (adder !== void 0)
|
|
14987
|
+
return invokeBuiltinClosure(adder, [value], options.budget, context, set).then(() => 0);
|
|
14886
14988
|
const added = set.values.has(value) ? 0 : 1;
|
|
14887
14989
|
const growth = added + (options.budget.limits.dataSize === void 0 ? 0 : measureSandboxData([value]));
|
|
14888
14990
|
options.budget.allocateCollectionEntries(set.values.size + added);
|
|
@@ -14913,15 +15015,17 @@ function populateCollection(source, collection, {
|
|
|
14913
15015
|
}) {
|
|
14914
15016
|
budget.allocateCollectionEntries(0);
|
|
14915
15017
|
if (source === void 0 || source === null) return collection;
|
|
14916
|
-
|
|
14917
|
-
|
|
15018
|
+
let adder;
|
|
15019
|
+
const populate = (iterator) => {
|
|
15020
|
+
if (iterator === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
|
|
14918
15021
|
let entry;
|
|
14919
15022
|
let failure;
|
|
14920
15023
|
const retained = {};
|
|
14921
15024
|
budget.setRetainedValues(retained, () => [
|
|
14922
15025
|
source,
|
|
14923
|
-
|
|
15026
|
+
iterator.retainedValue,
|
|
14924
15027
|
collection,
|
|
15028
|
+
adder,
|
|
14925
15029
|
entry,
|
|
14926
15030
|
failure,
|
|
14927
15031
|
...retainedValues?.() ?? []
|
|
@@ -14933,13 +15037,13 @@ function populateCollection(source, collection, {
|
|
|
14933
15037
|
if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
|
|
14934
15038
|
throw error;
|
|
14935
15039
|
};
|
|
14936
|
-
if (
|
|
14937
|
-
return closeIterator(
|
|
15040
|
+
if (iterator.getOperation !== void 0)
|
|
15041
|
+
return closeIterator(iterator, true).then(() => {
|
|
14938
15042
|
throw error;
|
|
14939
15043
|
}, rethrow);
|
|
14940
15044
|
try {
|
|
14941
|
-
const closing =
|
|
14942
|
-
if (
|
|
15045
|
+
const closing = iterator.return?.();
|
|
15046
|
+
if (iterator.generator || iterator.asynchronous)
|
|
14943
15047
|
return Promise.resolve(closing).then(() => {
|
|
14944
15048
|
throw error;
|
|
14945
15049
|
}, rethrow);
|
|
@@ -14955,7 +15059,7 @@ function populateCollection(source, collection, {
|
|
|
14955
15059
|
entry = result.value;
|
|
14956
15060
|
try {
|
|
14957
15061
|
budget.visitNode();
|
|
14958
|
-
const growth = append(entry);
|
|
15062
|
+
const growth = append(entry, adder);
|
|
14959
15063
|
if (growth instanceof Promise)
|
|
14960
15064
|
return growth.then((size) => {
|
|
14961
15065
|
entry = void 0;
|
|
@@ -14969,16 +15073,16 @@ function populateCollection(source, collection, {
|
|
|
14969
15073
|
}
|
|
14970
15074
|
return false;
|
|
14971
15075
|
};
|
|
14972
|
-
if (
|
|
15076
|
+
if (iterator.generator || iterator.asynchronous || context !== void 0 || adder !== void 0) {
|
|
14973
15077
|
return (async () => {
|
|
14974
15078
|
try {
|
|
14975
15079
|
checkData(collection, 0, true);
|
|
14976
15080
|
while (true) {
|
|
14977
|
-
const result = await
|
|
15081
|
+
const result = await iterator.next();
|
|
14978
15082
|
if (typeof result !== "object" || result === null)
|
|
14979
15083
|
throw new TypeError("Iterator result must be an object.");
|
|
14980
|
-
if ((await readIteratorResult(
|
|
14981
|
-
const value = (await readIteratorResult(
|
|
15084
|
+
if ((await readIteratorResult(iterator, result, "done")).value) break;
|
|
15085
|
+
const value = (await readIteratorResult(iterator, result, "value")).value;
|
|
14982
15086
|
await consume({ done: false, value });
|
|
14983
15087
|
}
|
|
14984
15088
|
checkData(collection, 0, true);
|
|
@@ -14990,7 +15094,7 @@ function populateCollection(source, collection, {
|
|
|
14990
15094
|
}
|
|
14991
15095
|
try {
|
|
14992
15096
|
checkData(collection, 0, true);
|
|
14993
|
-
while (!consume(
|
|
15097
|
+
while (!consume(iterator.next())) {
|
|
14994
15098
|
}
|
|
14995
15099
|
checkData(collection, 0, true);
|
|
14996
15100
|
return collection;
|
|
@@ -14998,8 +15102,16 @@ function populateCollection(source, collection, {
|
|
|
14998
15102
|
budget.setRetainedValues(retained, void 0);
|
|
14999
15103
|
}
|
|
15000
15104
|
};
|
|
15001
|
-
const
|
|
15002
|
-
|
|
15105
|
+
const method = name === "Map" ? "set" : "add";
|
|
15106
|
+
const start = (candidate2) => {
|
|
15107
|
+
if (!isSandboxClosure(candidate2)) throw new TypeError(`${name} constructor adder must be callable.`);
|
|
15108
|
+
if (getIntrinsicIdentity(candidate2) !== JSON.stringify([name, "prototype", method])) adder = candidate2;
|
|
15109
|
+
const iterator = context === void 0 ? getSandboxIterator(source, budget) : acquireSandboxIterator(source, budget, context);
|
|
15110
|
+
return iterator instanceof Promise ? iterator.then(populate) : populate(iterator);
|
|
15111
|
+
};
|
|
15112
|
+
const descriptor = getSandboxPropertyDescriptor(collection, method, budget);
|
|
15113
|
+
const candidate = context?.getProperty !== void 0 ? context.getProperty(collection, method) : descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, collection, context);
|
|
15114
|
+
return candidate instanceof Promise ? candidate.then(start) : start(candidate);
|
|
15003
15115
|
}
|
|
15004
15116
|
|
|
15005
15117
|
// packages/safe-js/src/interp/methods/collection-iterator.ts
|
|
@@ -17059,7 +17171,7 @@ async function evaluateDeleteExpression(node, context) {
|
|
|
17059
17171
|
}
|
|
17060
17172
|
throw new TypeError("Cannot delete properties of null or undefined.");
|
|
17061
17173
|
}
|
|
17062
|
-
if (!isIndexableSandboxValue(member.object) && !isSandboxRegex(member.object)) {
|
|
17174
|
+
if (!isIndexableSandboxValue(member.object) && !isSandboxRegex(member.object) && !isSandboxMap(member.object) && !isSandboxSet(member.object)) {
|
|
17063
17175
|
throw new TypeError("Unary operator 'delete' requires a sandbox object property.");
|
|
17064
17176
|
}
|
|
17065
17177
|
const property = await toPropertyKey(member.property, context.budget, createCoercionContext(context));
|
|
@@ -18035,6 +18147,7 @@ function setSandboxProperty(target, property, value, budget, checkInherited = tr
|
|
|
18035
18147
|
return writePropertyDescriptor(descriptor2, target, value, context);
|
|
18036
18148
|
}
|
|
18037
18149
|
if (isGuestClosure(target)) target = materializeFunctionProperties(target);
|
|
18150
|
+
if (isSandboxMap(target) || isSandboxSet(target)) target = getCollectionProperties(target);
|
|
18038
18151
|
if (isFloat32Array(target)) {
|
|
18039
18152
|
if (typeof property === "symbol") throw new TypeError("Typed array symbol properties are not yet supported.");
|
|
18040
18153
|
setFloat32Member(target, property, value);
|
|
@@ -18103,6 +18216,7 @@ function deleteSandboxProperty(target, property) {
|
|
|
18103
18216
|
if (isGuestHostObject(target)) return deleteHostObjectMember(target, String(property));
|
|
18104
18217
|
if (isGuestClosure(target)) target = materializeFunctionProperties(target);
|
|
18105
18218
|
if (isSandboxRegex(target)) target = getRegexProperties(target);
|
|
18219
|
+
if (isSandboxMap(target) || isSandboxSet(target)) target = getCollectionProperties(target);
|
|
18106
18220
|
if (Array.isArray(target)) {
|
|
18107
18221
|
assertCollectionMutable(target);
|
|
18108
18222
|
}
|
|
@@ -18719,6 +18833,15 @@ function normalizeClosureResult(result, budget) {
|
|
|
18719
18833
|
});
|
|
18720
18834
|
}
|
|
18721
18835
|
|
|
18836
|
+
// packages/safe-js/src/snapshot/collection-properties.ts
|
|
18837
|
+
function serializeCollectionProperties(value, encode, dataOnly = false) {
|
|
18838
|
+
const properties = getCollectionProperties(value);
|
|
18839
|
+
if (Reflect.ownKeys(properties).length === 0 && Object.isExtensible(properties)) return {};
|
|
18840
|
+
if (dataOnly && Reflect.ownKeys(properties).some((key) => !("value" in Object.getOwnPropertyDescriptor(properties, key))))
|
|
18841
|
+
throw new TypeError("Collection accessor properties cannot be serialized as replay data.");
|
|
18842
|
+
return { propertyState: serializePropertyDescriptors(properties, encode) };
|
|
18843
|
+
}
|
|
18844
|
+
|
|
18722
18845
|
// packages/safe-js/src/snapshot/float32array.ts
|
|
18723
18846
|
function encodeFloat32Storage(value, id, buffers, reference) {
|
|
18724
18847
|
const storage = float32Storage(value);
|
|
@@ -18950,6 +19073,7 @@ function encodeReplayData(value, options = {}) {
|
|
|
18950
19073
|
} else if (isSandboxMap(entry)) {
|
|
18951
19074
|
nodes[id] = {
|
|
18952
19075
|
kind: "map",
|
|
19076
|
+
...serializeCollectionProperties(entry, (value2) => child(value2, "<collection-property>"), true),
|
|
18953
19077
|
entries: [...entry.entries].map(([key, value2], index) => [
|
|
18954
19078
|
child(key, `key:${index}`),
|
|
18955
19079
|
child(value2, `value:${index}`)
|
|
@@ -18958,6 +19082,7 @@ function encodeReplayData(value, options = {}) {
|
|
|
18958
19082
|
} else if (isSandboxSet(entry)) {
|
|
18959
19083
|
nodes[id] = {
|
|
18960
19084
|
kind: "set",
|
|
19085
|
+
...serializeCollectionProperties(entry, (value2) => child(value2, "<collection-property>"), true),
|
|
18961
19086
|
values: [...entry.values].map((value2, index) => child(value2, String(index)))
|
|
18962
19087
|
};
|
|
18963
19088
|
} else if (isSandboxRegex(entry)) {
|
|
@@ -19007,7 +19132,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19007
19132
|
const compilation = new CompileScope(parent?.owner);
|
|
19008
19133
|
try {
|
|
19009
19134
|
validateSnapshotData(input);
|
|
19010
|
-
const graph =
|
|
19135
|
+
const graph = record2(input);
|
|
19011
19136
|
const nodes = list(own(graph, "nodes"));
|
|
19012
19137
|
const restored = /* @__PURE__ */ new Map();
|
|
19013
19138
|
const initializeIterators = [];
|
|
@@ -19015,7 +19140,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19015
19140
|
if (depth > MAX_DATA_DEPTH) throw new TypeError("Replay data exceeds the nesting limit.");
|
|
19016
19141
|
if (entry === null || typeof entry === "boolean" || typeof entry === "string") return entry;
|
|
19017
19142
|
if (typeof entry === "number" && Number.isFinite(entry)) return entry;
|
|
19018
|
-
const atom =
|
|
19143
|
+
const atom = record2(entry);
|
|
19019
19144
|
if (own(atom, "tag") === "promise-capability") {
|
|
19020
19145
|
const id2 = own(atom, "id");
|
|
19021
19146
|
if (typeof id2 !== "string" || id2.length === 0)
|
|
@@ -19059,7 +19184,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19059
19184
|
}
|
|
19060
19185
|
const id = Number(atom.id);
|
|
19061
19186
|
if (restored.has(id)) return restored.get(id);
|
|
19062
|
-
const node =
|
|
19187
|
+
const node = record2(nodes[id]);
|
|
19063
19188
|
const kind = own(node, "kind");
|
|
19064
19189
|
if (Object.hasOwn(node, "errorType") && (kind !== "object" || !sandboxErrorNames.includes(node.errorType))) {
|
|
19065
19190
|
throw new TypeError("Invalid replay error metadata.");
|
|
@@ -19083,7 +19208,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19083
19208
|
const capability = options.resolveCapability?.(capabilityId);
|
|
19084
19209
|
if (!isSandboxClosure(capability))
|
|
19085
19210
|
throw new TypeError(`Missing replay capability '${capabilityId}'.`);
|
|
19086
|
-
if (
|
|
19211
|
+
if (record2(own(node, "properties")).tag === "undefined") {
|
|
19087
19212
|
restored.set(id, capability);
|
|
19088
19213
|
return capability;
|
|
19089
19214
|
}
|
|
@@ -19107,13 +19232,13 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19107
19232
|
if (kind === "boxed") {
|
|
19108
19233
|
validateBoxedProperties(node);
|
|
19109
19234
|
const payload = own(node, "value");
|
|
19110
|
-
const payloadRecord = payload !== null && typeof payload === "object" ?
|
|
19111
|
-
const symbolReference = payloadRecord !== void 0 && own(payloadRecord, "tag") === "ref" && Number.isSafeInteger(payloadRecord.id) && Number(payloadRecord.id) >= 0 && Number(payloadRecord.id) < nodes.length && own(
|
|
19112
|
-
if (typeof payload !== "number" && typeof payload !== "string" && typeof payload !== "boolean" && !symbolReference && (payload === null || typeof payload !== "object" || !["number", "bigint"].includes(String(own(
|
|
19235
|
+
const payloadRecord = payload !== null && typeof payload === "object" ? record2(payload) : void 0;
|
|
19236
|
+
const symbolReference = payloadRecord !== void 0 && own(payloadRecord, "tag") === "ref" && Number.isSafeInteger(payloadRecord.id) && Number(payloadRecord.id) >= 0 && Number(payloadRecord.id) < nodes.length && own(record2(nodes[Number(payloadRecord.id)]), "kind") === "symbol";
|
|
19237
|
+
if (typeof payload !== "number" && typeof payload !== "string" && typeof payload !== "boolean" && !symbolReference && (payload === null || typeof payload !== "object" || !["number", "bigint"].includes(String(own(record2(payload), "tag")))))
|
|
19113
19238
|
throw new TypeError("Invalid boxed primitive payload.");
|
|
19114
19239
|
const result3 = createSandboxBox(child(payload));
|
|
19115
19240
|
restored.set(id, result3);
|
|
19116
|
-
defineProperties(result3,
|
|
19241
|
+
defineProperties(result3, record2(own(node, "properties")), child, node.symbolEntries);
|
|
19117
19242
|
if (!node.extensible) Object.preventExtensions(result3);
|
|
19118
19243
|
return result3;
|
|
19119
19244
|
}
|
|
@@ -19129,7 +19254,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19129
19254
|
if (node.extensible !== void 0 && typeof node.extensible !== "boolean") throw new TypeError("Invalid replay Date extensibility.");
|
|
19130
19255
|
const result3 = restoreDateTime(own(node, "time"));
|
|
19131
19256
|
restored.set(id, result3);
|
|
19132
|
-
defineProperties(result3, node.properties === void 0 ? {} :
|
|
19257
|
+
defineProperties(result3, node.properties === void 0 ? {} : record2(node.properties), child, node.symbolProperties);
|
|
19133
19258
|
if (node.extensible === false) Object.preventExtensions(result3);
|
|
19134
19259
|
return result3;
|
|
19135
19260
|
}
|
|
@@ -19138,7 +19263,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19138
19263
|
throw new TypeError("Invalid Float32Array extensibility.");
|
|
19139
19264
|
const result3 = decodeFloat32Storage(node, child);
|
|
19140
19265
|
restored.set(id, result3);
|
|
19141
|
-
defineProperties(result3,
|
|
19266
|
+
defineProperties(result3, record2(own(node, "properties")), child);
|
|
19142
19267
|
if (!node.extensible) Object.preventExtensions(result3);
|
|
19143
19268
|
return result3;
|
|
19144
19269
|
}
|
|
@@ -19158,7 +19283,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19158
19283
|
exhausted,
|
|
19159
19284
|
...node.global === void 0 ? {} : { global: node.global, unicode: node.unicode }
|
|
19160
19285
|
}, result3);
|
|
19161
|
-
defineProperties(result3,
|
|
19286
|
+
defineProperties(result3, record2(own(node, "properties")), child, node.symbolEntries);
|
|
19162
19287
|
if (!node.extensible) Object.preventExtensions(result3);
|
|
19163
19288
|
return result3;
|
|
19164
19289
|
}
|
|
@@ -19175,13 +19300,14 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19175
19300
|
initializeIterators.push(() => {
|
|
19176
19301
|
restoreSandboxCollectionIterator({ collection, collectionKind, method, index, exhausted }, result3);
|
|
19177
19302
|
});
|
|
19178
|
-
defineProperties(result3,
|
|
19303
|
+
defineProperties(result3, record2(own(node, "properties")), child);
|
|
19179
19304
|
if (!node.extensible) Object.preventExtensions(result3);
|
|
19180
19305
|
return result3;
|
|
19181
19306
|
}
|
|
19182
19307
|
if (kind === "map") {
|
|
19183
19308
|
const result3 = createSandboxMap();
|
|
19184
19309
|
restored.set(id, result3);
|
|
19310
|
+
restoreCollectionDataProperties(result3, node, child);
|
|
19185
19311
|
for (const pair of list(own(node, "entries"))) {
|
|
19186
19312
|
const entries = list(pair);
|
|
19187
19313
|
if (entries.length !== 2) throw new TypeError("Invalid replay map entry.");
|
|
@@ -19192,6 +19318,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19192
19318
|
if (kind === "set") {
|
|
19193
19319
|
const result3 = createSandboxSet();
|
|
19194
19320
|
restored.set(id, result3);
|
|
19321
|
+
restoreCollectionDataProperties(result3, node, child);
|
|
19195
19322
|
for (const value of list(own(node, "values"))) result3.values.add(child(value));
|
|
19196
19323
|
return result3;
|
|
19197
19324
|
}
|
|
@@ -19206,17 +19333,17 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19206
19333
|
return result3;
|
|
19207
19334
|
}
|
|
19208
19335
|
if (kind === "arguments") {
|
|
19209
|
-
const data =
|
|
19336
|
+
const data = record2(own(node, "data"));
|
|
19210
19337
|
validateArgumentsProperties(data, "arguments");
|
|
19211
19338
|
if (data.kind !== "arguments") throw new TypeError("Invalid replay arguments.");
|
|
19212
19339
|
const args = createSandboxArguments([]);
|
|
19213
19340
|
restored.set(id, args);
|
|
19214
19341
|
if (!data.lengthBeforeCallee) delete args.length;
|
|
19215
|
-
defineProperties(args,
|
|
19342
|
+
defineProperties(args, record2(data.properties), child);
|
|
19216
19343
|
if (data.iterator === null) Reflect.deleteProperty(args, Symbol.iterator);
|
|
19217
19344
|
else
|
|
19218
19345
|
Object.defineProperty(args, Symbol.iterator, {
|
|
19219
|
-
...
|
|
19346
|
+
...record2(data.iterator),
|
|
19220
19347
|
value: Array.prototype.values
|
|
19221
19348
|
});
|
|
19222
19349
|
if (!data.extensible) Object.preventExtensions(args);
|
|
@@ -19236,7 +19363,7 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
19236
19363
|
}
|
|
19237
19364
|
if (kind === "array" && node.nullPrototype) Object.setPrototypeOf(result2, null);
|
|
19238
19365
|
restored.set(id, result2);
|
|
19239
|
-
defineProperties(result2,
|
|
19366
|
+
defineProperties(result2, record2(own(node, "properties")), child, node.symbolProperties);
|
|
19240
19367
|
if (!node.extensible) Object.preventExtensions(result2);
|
|
19241
19368
|
return result2;
|
|
19242
19369
|
};
|
|
@@ -19262,7 +19389,7 @@ function defineProperties(target, properties, decode, symbolProperties) {
|
|
|
19262
19389
|
}
|
|
19263
19390
|
}
|
|
19264
19391
|
for (const [key, value] of entries) {
|
|
19265
|
-
const descriptor =
|
|
19392
|
+
const descriptor = record2(value);
|
|
19266
19393
|
for (const field of Object.keys(descriptor)) {
|
|
19267
19394
|
if (!["value", "writable", "enumerable", "configurable"].includes(field))
|
|
19268
19395
|
throw new TypeError("Invalid replay property descriptor.");
|
|
@@ -19278,7 +19405,16 @@ function defineProperties(target, properties, decode, symbolProperties) {
|
|
|
19278
19405
|
});
|
|
19279
19406
|
}
|
|
19280
19407
|
}
|
|
19281
|
-
function
|
|
19408
|
+
function restoreCollectionDataProperties(value, node, decode) {
|
|
19409
|
+
if (!Object.hasOwn(node, "propertyState")) return;
|
|
19410
|
+
const properties = record2(node.propertyState);
|
|
19411
|
+
for (const entry of list(own(properties, "properties"))) {
|
|
19412
|
+
const descriptor = record2(list(entry)[1]);
|
|
19413
|
+
if (own(descriptor, "kind") !== "data") throw new TypeError("Replay collection properties must be data descriptors.");
|
|
19414
|
+
}
|
|
19415
|
+
restorePropertyDescriptors(getCollectionProperties(value), properties, decode);
|
|
19416
|
+
}
|
|
19417
|
+
function record2(value) {
|
|
19282
19418
|
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
19283
19419
|
throw new TypeError("Expected replay data object.");
|
|
19284
19420
|
return value;
|
|
@@ -19532,21 +19668,21 @@ function invokeHostCallback(invoke, options) {
|
|
|
19532
19668
|
throw error;
|
|
19533
19669
|
}
|
|
19534
19670
|
}
|
|
19535
|
-
function executeHostCall(
|
|
19671
|
+
function executeHostCall(record4, restored, invoke, stackFrames, options, span, callbacks, onReplay) {
|
|
19536
19672
|
const hostCalls = options.hostCalls;
|
|
19537
19673
|
let replayed;
|
|
19538
19674
|
try {
|
|
19539
|
-
replayed = restored ? hostCalls.replayOutcome(
|
|
19675
|
+
replayed = restored ? hostCalls.replayOutcome(record4) : void 0;
|
|
19540
19676
|
} catch (error) {
|
|
19541
|
-
if (!(error instanceof UnresolvedReplayCapabilityError) || !
|
|
19677
|
+
if (!(error instanceof UnresolvedReplayCapabilityError) || !record4.asynchronous) throw error;
|
|
19542
19678
|
const promise = (async () => {
|
|
19543
19679
|
let missing = error;
|
|
19544
19680
|
while (true) {
|
|
19545
19681
|
await hostCalls.waitForCapability(missing.id);
|
|
19546
19682
|
try {
|
|
19547
|
-
const outcome2 = hostCalls.replayOutcome(
|
|
19683
|
+
const outcome2 = hostCalls.replayOutcome(record4);
|
|
19548
19684
|
if (outcome2 === void 0) throw new TypeError("Missing restored host outcome.");
|
|
19549
|
-
restoreReplayedHostState(
|
|
19685
|
+
restoreReplayedHostState(record4, outcome2, onReplay);
|
|
19550
19686
|
if (outcome2.status === "rejected") throw outcome2.reason;
|
|
19551
19687
|
return outcome2.value;
|
|
19552
19688
|
} catch (error2) {
|
|
@@ -19556,28 +19692,28 @@ function executeHostCall(record3, restored, invoke, stackFrames, options, span,
|
|
|
19556
19692
|
}
|
|
19557
19693
|
})();
|
|
19558
19694
|
void promise.catch(() => void 0);
|
|
19559
|
-
return createSandboxPromise(promise, { hostCall:
|
|
19695
|
+
return createSandboxPromise(promise, { hostCall: record4, hostCallJournal: hostCalls });
|
|
19560
19696
|
}
|
|
19561
19697
|
if (replayed !== void 0) {
|
|
19562
|
-
restoreReplayedHostState(
|
|
19563
|
-
if (
|
|
19698
|
+
restoreReplayedHostState(record4, replayed, onReplay);
|
|
19699
|
+
if (record4.asynchronous) return createReplayedHostCallResult(replayed, record4, hostCalls);
|
|
19564
19700
|
if (replayed.status === "rejected") throw replayed.reason;
|
|
19565
19701
|
return replayed.value;
|
|
19566
19702
|
}
|
|
19567
|
-
if (restored &&
|
|
19568
|
-
return createReplayedHostCallResult(
|
|
19703
|
+
if (restored && record4.policy === "read-side-effect" && record4.lifecycle === "consumed" && record4.outcome !== void 0) {
|
|
19704
|
+
return createReplayedHostCallResult(record4.outcome, record4, hostCalls);
|
|
19569
19705
|
}
|
|
19570
|
-
if (restored &&
|
|
19571
|
-
return createHostCallPromise(
|
|
19706
|
+
if (restored && record4.policy === "read-side-effect" && record4.lifecycle === "settled" && record4.outcome !== void 0) {
|
|
19707
|
+
return createHostCallPromise(record4, Promise.resolve(record4.outcome), hostCalls);
|
|
19572
19708
|
}
|
|
19573
|
-
if (restored &&
|
|
19709
|
+
if (restored && record4.lifecycle === "cancelled" && record4.policy === "read-side-effect") {
|
|
19574
19710
|
throw new HostCallResumabilityError(
|
|
19575
|
-
|
|
19711
|
+
record4,
|
|
19576
19712
|
"reset",
|
|
19577
|
-
`Host call ${
|
|
19713
|
+
`Host call ${record4.id} was cancelled; reset is required.`
|
|
19578
19714
|
);
|
|
19579
19715
|
}
|
|
19580
|
-
if (restored &&
|
|
19716
|
+
if (restored && record4.policy === "read-side-effect" && record4.lifecycle !== "created") {
|
|
19581
19717
|
let active = true;
|
|
19582
19718
|
const context = callbacks === void 0 ? void 0 : {
|
|
19583
19719
|
callbacks: new Map(callbacks.hostFunctions),
|
|
@@ -19600,13 +19736,13 @@ function executeHostCall(record3, restored, invoke, stackFrames, options, span,
|
|
|
19600
19736
|
);
|
|
19601
19737
|
}
|
|
19602
19738
|
};
|
|
19603
|
-
const outcome2 = hostCalls.reconcile(
|
|
19739
|
+
const outcome2 = hostCalls.reconcile(record4, context).finally(() => {
|
|
19604
19740
|
active = false;
|
|
19605
19741
|
});
|
|
19606
|
-
return createHostCallPromise(
|
|
19742
|
+
return createHostCallPromise(record4, outcome2, hostCalls);
|
|
19607
19743
|
}
|
|
19608
19744
|
if (restored && callbacks !== void 0) callbacks.nextReissuedInvocation = 0;
|
|
19609
|
-
hostCalls.start(
|
|
19745
|
+
hostCalls.start(record4);
|
|
19610
19746
|
let result;
|
|
19611
19747
|
try {
|
|
19612
19748
|
result = invoke();
|
|
@@ -19615,17 +19751,17 @@ function executeHostCall(record3, restored, invoke, stackFrames, options, span,
|
|
|
19615
19751
|
throw error;
|
|
19616
19752
|
}
|
|
19617
19753
|
const reason = createHostErrorValue(error, stackFrames, options.budget, span);
|
|
19618
|
-
hostCalls.settle(
|
|
19754
|
+
hostCalls.settle(record4, { status: "rejected", reason });
|
|
19619
19755
|
throw error;
|
|
19620
19756
|
}
|
|
19621
19757
|
if (!isPromiseLike3(result)) {
|
|
19622
|
-
|
|
19758
|
+
record4.asynchronous = false;
|
|
19623
19759
|
const value = copyHostResultToSandbox(result, stackFrames, options);
|
|
19624
|
-
hostCalls.settle(
|
|
19625
|
-
hostCalls.consume(
|
|
19760
|
+
hostCalls.settle(record4, { status: "fulfilled", value });
|
|
19761
|
+
hostCalls.consume(record4);
|
|
19626
19762
|
return value;
|
|
19627
19763
|
}
|
|
19628
|
-
|
|
19764
|
+
record4.asynchronous = true;
|
|
19629
19765
|
const outcome = wrapHostPromiseWithSignal(Promise.resolve(result), options.signal).then(
|
|
19630
19766
|
(value) => {
|
|
19631
19767
|
try {
|
|
@@ -19653,9 +19789,9 @@ function executeHostCall(record3, restored, invoke, stackFrames, options, span,
|
|
|
19653
19789
|
};
|
|
19654
19790
|
}
|
|
19655
19791
|
);
|
|
19656
|
-
return createHostCallPromise(
|
|
19792
|
+
return createHostCallPromise(record4, outcome, hostCalls);
|
|
19657
19793
|
}
|
|
19658
|
-
function restoreReplayedHostState(
|
|
19794
|
+
function restoreReplayedHostState(record4, outcome, onReplay) {
|
|
19659
19795
|
try {
|
|
19660
19796
|
const result = onReplay?.(outcome);
|
|
19661
19797
|
if (isPromiseLike3(result)) {
|
|
@@ -19664,30 +19800,30 @@ function restoreReplayedHostState(record3, outcome, onReplay) {
|
|
|
19664
19800
|
}
|
|
19665
19801
|
} catch (reason) {
|
|
19666
19802
|
const error = new HostCallResumabilityError(
|
|
19667
|
-
|
|
19803
|
+
record4,
|
|
19668
19804
|
"reset",
|
|
19669
|
-
`Cannot restore host-local state for ${
|
|
19805
|
+
`Cannot restore host-local state for ${record4.id}: ${reason instanceof Error ? reason.message : String(reason)}`
|
|
19670
19806
|
);
|
|
19671
19807
|
promiseReplayContext.getStore()?.fail(error);
|
|
19672
19808
|
throw error;
|
|
19673
19809
|
}
|
|
19674
19810
|
}
|
|
19675
|
-
function createReplayedHostCallResult(outcome,
|
|
19811
|
+
function createReplayedHostCallResult(outcome, record4, hostCalls) {
|
|
19676
19812
|
const promise = outcome.status === "fulfilled" ? Promise.resolve(outcome.value) : Promise.reject(outcome.reason);
|
|
19677
19813
|
promise.catch(() => void 0);
|
|
19678
|
-
return createSandboxPromise(promise, { hostCall:
|
|
19814
|
+
return createSandboxPromise(promise, { hostCall: record4, hostCallJournal: hostCalls });
|
|
19679
19815
|
}
|
|
19680
|
-
function createHostCallPromise(
|
|
19816
|
+
function createHostCallPromise(record4, outcomePromise, hostCalls) {
|
|
19681
19817
|
const promise = outcomePromise.then((outcome) => {
|
|
19682
19818
|
if (outcome.status === "rejected" && isAbortReason(outcome.reason)) {
|
|
19683
|
-
hostCalls.cancel(
|
|
19819
|
+
hostCalls.cancel(record4, outcome.reason);
|
|
19684
19820
|
} else {
|
|
19685
|
-
hostCalls.settle(
|
|
19821
|
+
hostCalls.settle(record4, outcome);
|
|
19686
19822
|
}
|
|
19687
19823
|
return outcome.status === "fulfilled" ? outcome.value : Promise.reject(outcome.reason);
|
|
19688
19824
|
});
|
|
19689
19825
|
promise.catch(() => void 0);
|
|
19690
|
-
return createSandboxPromise(promise, { hostCall:
|
|
19826
|
+
return createSandboxPromise(promise, { hostCall: record4, hostCallJournal: hostCalls });
|
|
19691
19827
|
}
|
|
19692
19828
|
function isAbortReason(reason) {
|
|
19693
19829
|
return typeof reason === "object" && reason !== null && ("name" in reason && reason.name === "AbortError" || "code" in reason && reason.code === "aborted");
|
|
@@ -20489,7 +20625,7 @@ function conversionHook(value, name, budget, context) {
|
|
|
20489
20625
|
let current = value;
|
|
20490
20626
|
let depth = 0;
|
|
20491
20627
|
while (current !== null) {
|
|
20492
|
-
const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : current;
|
|
20628
|
+
const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
20493
20629
|
const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, name);
|
|
20494
20630
|
if (descriptor !== void 0) {
|
|
20495
20631
|
return readPropertyDescriptor(descriptor, value, context);
|
|
@@ -21799,7 +21935,7 @@ async function parseJsonWithReviver(text, reviver, budget, context) {
|
|
|
21799
21935
|
leave();
|
|
21800
21936
|
}
|
|
21801
21937
|
}
|
|
21802
|
-
async function internalize(holder2, key,
|
|
21938
|
+
async function internalize(holder2, key, record4) {
|
|
21803
21939
|
budget.visitNode();
|
|
21804
21940
|
const leave = budget.enterCall();
|
|
21805
21941
|
let value;
|
|
@@ -21811,7 +21947,7 @@ async function parseJsonWithReviver(text, reviver, budget, context) {
|
|
|
21811
21947
|
const descriptor = getSandboxPropertyDescriptor(holder2, key, budget);
|
|
21812
21948
|
value = descriptor === void 0 ? void 0 : await readPropertyDescriptor(descriptor, holder2, context);
|
|
21813
21949
|
}
|
|
21814
|
-
const original =
|
|
21950
|
+
const original = record4 !== void 0 && Object.is(value, record4.value) ? record4 : void 0;
|
|
21815
21951
|
if (original?.source !== void 0) callbackContext.source = budget.allocateString(original.source);
|
|
21816
21952
|
if (typeof value === "object" && value !== null) {
|
|
21817
21953
|
if (Array.isArray(value)) budget.allocateArrayLength(value.length);
|
|
@@ -22092,7 +22228,7 @@ async function stringifyObject(value, state, indent) {
|
|
|
22092
22228
|
const release = retainValues(state.budget, () => entries);
|
|
22093
22229
|
try {
|
|
22094
22230
|
const nextIndent = indent + state.gap;
|
|
22095
|
-
for (const key of state.propertyList ??
|
|
22231
|
+
for (const key of state.propertyList ?? ownEnumerableSandboxKeys(value)) {
|
|
22096
22232
|
const serialized = await stringifyProperty(key, value, state, nextIndent);
|
|
22097
22233
|
if (serialized !== void 0) {
|
|
22098
22234
|
entries.push(`${quoteJsonString(key)}:${state.gap === "" ? "" : " "}${serialized}`);
|
|
@@ -22229,9 +22365,9 @@ async function sumPrecise(source, budget, context) {
|
|
|
22229
22365
|
if (typeof result !== "object" && typeof result !== "function" || result === null)
|
|
22230
22366
|
throw new TypeError("Iterator result must be an object.");
|
|
22231
22367
|
recordValue = result;
|
|
22232
|
-
const
|
|
22233
|
-
if ((await readIteratorResult(iterator,
|
|
22234
|
-
current = (await readIteratorResult(iterator,
|
|
22368
|
+
const record4 = result;
|
|
22369
|
+
if ((await readIteratorResult(iterator, record4, "done")).value) break;
|
|
22370
|
+
current = (await readIteratorResult(iterator, record4, "value")).value;
|
|
22235
22371
|
if (count >= Number.MAX_SAFE_INTEGER || typeof current !== "number") {
|
|
22236
22372
|
const error = count >= Number.MAX_SAFE_INTEGER ? new RangeError("Math.sumPrecise received too many elements.") : new TypeError("Math.sumPrecise requires number elements.");
|
|
22237
22373
|
await closeIterator(iterator, true);
|
|
@@ -23103,7 +23239,7 @@ function intrinsicCatalogue() {
|
|
|
23103
23239
|
releaseObjectPrototype(budget);
|
|
23104
23240
|
}
|
|
23105
23241
|
}
|
|
23106
|
-
function
|
|
23242
|
+
function record3(value) {
|
|
23107
23243
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError("Expected a guest heap record.");
|
|
23108
23244
|
return value;
|
|
23109
23245
|
}
|
|
@@ -23120,23 +23256,23 @@ function integer(value) {
|
|
|
23120
23256
|
}
|
|
23121
23257
|
function absent(value) {
|
|
23122
23258
|
if (value === null || typeof value !== "object") return false;
|
|
23123
|
-
const node =
|
|
23259
|
+
const node = record3(value);
|
|
23124
23260
|
return node.kind === "undefined" && Object.keys(node).length === 1;
|
|
23125
23261
|
}
|
|
23126
23262
|
function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
23127
|
-
const node =
|
|
23263
|
+
const node = record3(raw);
|
|
23128
23264
|
if (node.kind === "raw-json") {
|
|
23129
23265
|
fields(node, ["kind", "text"]);
|
|
23130
23266
|
if (typeof node.text !== "string") throw new TypeError("Invalid raw JSON source.");
|
|
23131
23267
|
createRawJson(node.text);
|
|
23132
23268
|
return true;
|
|
23133
23269
|
}
|
|
23134
|
-
if (!["intrinsic", "guest-function", "guest-generator", "scope-frame", "guest-object", "guest-array"].includes(String(node.kind))) return false;
|
|
23270
|
+
if (!["intrinsic", "guest-function", "guest-generator", "scope-frame", "guest-object", "guest-array", "map", "set"].includes(String(node.kind))) return false;
|
|
23135
23271
|
const reference = (value, kinds) => {
|
|
23136
|
-
const ref =
|
|
23272
|
+
const ref = record3(value);
|
|
23137
23273
|
fields(ref, ["kind", "id"]);
|
|
23138
23274
|
if (ref.kind !== "ref" || integer(ref.id) < 1 || !Object.hasOwn(heap, String(ref.id))) throw new TypeError("Invalid guest heap reference.");
|
|
23139
|
-
const target =
|
|
23275
|
+
const target = record3(heap[String(ref.id)]);
|
|
23140
23276
|
if (kinds !== void 0 && !kinds.includes(String(target.kind))) throw new TypeError("Wrong guest heap reference kind.");
|
|
23141
23277
|
return target;
|
|
23142
23278
|
};
|
|
@@ -23147,10 +23283,10 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23147
23283
|
throw new TypeError("Guest accessor reference is not callable.");
|
|
23148
23284
|
};
|
|
23149
23285
|
const state = (value) => {
|
|
23150
|
-
const object =
|
|
23286
|
+
const object = record3(value);
|
|
23151
23287
|
fields(object, ["properties"], ["prototype"]);
|
|
23152
23288
|
if (Object.hasOwn(object, "prototype") && object.prototype !== null) reference(object.prototype);
|
|
23153
|
-
const properties =
|
|
23289
|
+
const properties = record3(object.properties);
|
|
23154
23290
|
fields(properties, ["properties", "extensible"]);
|
|
23155
23291
|
if (typeof properties.extensible !== "boolean") throw new TypeError("Invalid guest extensibility.");
|
|
23156
23292
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -23161,11 +23297,11 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23161
23297
|
if (typeof entry[0] === "string") key = `string:${entry[0]}`;
|
|
23162
23298
|
else {
|
|
23163
23299
|
const symbol = reference(entry[0], ["symbol"]);
|
|
23164
|
-
key = symbol.wellKnown === void 0 ? `symbol:${
|
|
23300
|
+
key = symbol.wellKnown === void 0 ? `symbol:${record3(entry[0]).id}` : `well-known:${symbol.wellKnown}`;
|
|
23165
23301
|
}
|
|
23166
23302
|
if (keys.has(key)) throw new TypeError("Duplicate guest property key.");
|
|
23167
23303
|
keys.add(key);
|
|
23168
|
-
const descriptor =
|
|
23304
|
+
const descriptor = record3(entry[1]);
|
|
23169
23305
|
if (descriptor.kind === "data") {
|
|
23170
23306
|
fields(descriptor, ["kind", "value", "writable", "enumerable", "configurable"]);
|
|
23171
23307
|
if (typeof descriptor.writable !== "boolean") throw new TypeError("Invalid guest writable flag.");
|
|
@@ -23177,6 +23313,11 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23177
23313
|
if (typeof descriptor.enumerable !== "boolean" || typeof descriptor.configurable !== "boolean") throw new TypeError("Invalid guest descriptor flags.");
|
|
23178
23314
|
}
|
|
23179
23315
|
};
|
|
23316
|
+
if (node.kind === "map" || node.kind === "set") {
|
|
23317
|
+
fields(node, ["kind", node.kind === "map" ? "entries" : "values"], ["propertyState"]);
|
|
23318
|
+
if (Object.hasOwn(node, "propertyState")) state({ properties: node.propertyState });
|
|
23319
|
+
return false;
|
|
23320
|
+
}
|
|
23180
23321
|
if (node.kind === "intrinsic") {
|
|
23181
23322
|
fields(node, ["kind", "id"], ["state"]);
|
|
23182
23323
|
if (typeof node.id !== "string" || !intrinsicCatalogue().has(node.id)) throw new TypeError("Unknown intrinsic identity.");
|
|
@@ -23188,10 +23329,10 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23188
23329
|
throw new TypeError("Invalid template source identity.");
|
|
23189
23330
|
state(node.state);
|
|
23190
23331
|
if (node.kind === "guest-array") {
|
|
23191
|
-
const properties = array(
|
|
23332
|
+
const properties = array(record3(record3(node.state).properties).properties).map((entry) => array(entry));
|
|
23192
23333
|
const length = properties.find((entry) => entry[0] === "length");
|
|
23193
23334
|
if (length === void 0) throw new TypeError("Missing guest array length.");
|
|
23194
|
-
const descriptor =
|
|
23335
|
+
const descriptor = record3(length[1]);
|
|
23195
23336
|
if (descriptor.kind !== "data" || descriptor.configurable !== false || descriptor.enumerable !== false || integer(descriptor.value) > 4294967295) throw new TypeError("Invalid guest array length.");
|
|
23196
23337
|
if (descriptor.value > maxArrayLength) throw new TypeError("Guest array length exceeds allocation limit.");
|
|
23197
23338
|
for (const [key] of properties) {
|
|
@@ -23206,7 +23347,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23206
23347
|
reference(node.scope, ["scope-frame"]);
|
|
23207
23348
|
if (Object.hasOwn(node, "name") && typeof node.name !== "string") throw new TypeError("Invalid guest function name.");
|
|
23208
23349
|
if (Object.hasOwn(node, "environment")) {
|
|
23209
|
-
const environment =
|
|
23350
|
+
const environment = record3(node.environment);
|
|
23210
23351
|
fields(environment, [], ["homeObject", "newTarget"]);
|
|
23211
23352
|
if (Object.hasOwn(environment, "homeObject")) reference(environment.homeObject);
|
|
23212
23353
|
if (Object.hasOwn(environment, "newTarget")) callable(environment.newTarget);
|
|
@@ -23220,15 +23361,15 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23220
23361
|
reference(node.closureScope, ["scope-frame"]);
|
|
23221
23362
|
if (Object.hasOwn(node, "suspendedScope")) reference(node.suspendedScope, ["scope-frame"]);
|
|
23222
23363
|
if (Object.hasOwn(node, "blockScopes")) {
|
|
23223
|
-
for (const [id, scope] of Object.entries(
|
|
23364
|
+
for (const [id, scope] of Object.entries(record3(node.blockScopes))) {
|
|
23224
23365
|
if (integer(Number(id)) < 1 || String(Number(id)) !== id) throw new TypeError("Invalid generator block identity.");
|
|
23225
23366
|
reference(scope, ["scope-frame"]);
|
|
23226
23367
|
}
|
|
23227
23368
|
}
|
|
23228
23369
|
if (Object.hasOwn(node, "expressionStates")) {
|
|
23229
|
-
for (const [id, raw2] of Object.entries(
|
|
23370
|
+
for (const [id, raw2] of Object.entries(record3(node.expressionStates))) {
|
|
23230
23371
|
if (integer(Number(id)) < 1 || String(Number(id)) !== id) throw new TypeError("Invalid expression identity.");
|
|
23231
|
-
const expression =
|
|
23372
|
+
const expression = record3(raw2);
|
|
23232
23373
|
if (expression.kind === "binary") {
|
|
23233
23374
|
fields(expression, ["kind", "left"]);
|
|
23234
23375
|
} else if (expression.kind === "declaration") {
|
|
@@ -23267,13 +23408,13 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23267
23408
|
if (expression.kind !== "yield-delegate") integer(expression.index);
|
|
23268
23409
|
if (expression.kind === "for-of-array") reference(expression.values, ["array", "guest-array"]);
|
|
23269
23410
|
else {
|
|
23270
|
-
let iterator =
|
|
23411
|
+
let iterator = record3(expression.iterator);
|
|
23271
23412
|
let depth = 0;
|
|
23272
23413
|
let protocol = false;
|
|
23273
23414
|
while (iterator.kind === "async-from-sync") {
|
|
23274
23415
|
if (++depth > 1) throw new TypeError("Invalid nested async iterator adapter.");
|
|
23275
23416
|
fields(iterator, ["kind", "inner"]);
|
|
23276
|
-
iterator =
|
|
23417
|
+
iterator = record3(iterator.inner);
|
|
23277
23418
|
protocol = true;
|
|
23278
23419
|
}
|
|
23279
23420
|
if (iterator.kind === "guest") {
|
|
@@ -23352,9 +23493,9 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23352
23493
|
}
|
|
23353
23494
|
}
|
|
23354
23495
|
if (Object.hasOwn(node, "finallyCompletions")) {
|
|
23355
|
-
for (const [id, raw2] of Object.entries(
|
|
23496
|
+
for (const [id, raw2] of Object.entries(record3(node.finallyCompletions))) {
|
|
23356
23497
|
if (integer(Number(id)) < 1 || String(Number(id)) !== id) throw new TypeError("Invalid finally identity.");
|
|
23357
|
-
const completion =
|
|
23498
|
+
const completion = record3(raw2);
|
|
23358
23499
|
fields(completion, ["kind", "hasValue", "value"], ["nodeId", "label", "span", "stackFrames"]);
|
|
23359
23500
|
if (!["normal", "return", "throw", "break", "continue"].includes(String(completion.kind)) || typeof completion.hasValue !== "boolean")
|
|
23360
23501
|
throw new TypeError("Invalid finally completion.");
|
|
@@ -23366,12 +23507,12 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23366
23507
|
if (Object.hasOwn(node, "yieldNodeId") && integer(node.yieldNodeId) < 1) throw new TypeError("Invalid generator yield identity.");
|
|
23367
23508
|
if (node.state === "suspended" && (!Object.hasOwn(node, "yieldNodeId") || !Object.hasOwn(node, "suspendedScope"))) throw new TypeError("Missing suspended generator state.");
|
|
23368
23509
|
for (const rawCompletion of array(node.sent)) {
|
|
23369
|
-
const completion =
|
|
23510
|
+
const completion = record3(rawCompletion);
|
|
23370
23511
|
fields(completion, ["type", "value"]);
|
|
23371
23512
|
if (!["normal", "return", "throw"].includes(String(completion.type))) throw new TypeError("Invalid generator completion type.");
|
|
23372
23513
|
}
|
|
23373
23514
|
if (Object.hasOwn(node, "environment")) {
|
|
23374
|
-
const environment =
|
|
23515
|
+
const environment = record3(node.environment);
|
|
23375
23516
|
fields(environment, [], ["homeObject", "newTarget"]);
|
|
23376
23517
|
if (Object.hasOwn(environment, "homeObject")) reference(environment.homeObject);
|
|
23377
23518
|
if (Object.hasOwn(environment, "newTarget")) callable(environment.newTarget);
|
|
@@ -23382,7 +23523,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23382
23523
|
if (typeof node.functionBoundary !== "boolean" || typeof node.chargeData !== "boolean") throw new TypeError("Invalid guest frame flags.");
|
|
23383
23524
|
const cells = array(node.cells);
|
|
23384
23525
|
for (const rawCell of cells) {
|
|
23385
|
-
const cell =
|
|
23526
|
+
const cell = record3(rawCell);
|
|
23386
23527
|
if (typeof cell.initialized !== "boolean" || !["var", "let", "const"].includes(String(cell.kind))) throw new TypeError("Invalid guest binding cell.");
|
|
23387
23528
|
fields(cell, cell.initialized ? ["kind", "initialized", "value"] : ["kind", "initialized"]);
|
|
23388
23529
|
}
|
|
@@ -23412,26 +23553,26 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
23412
23553
|
function validateGuestScopeParents(heap) {
|
|
23413
23554
|
const finished = /* @__PURE__ */ new Set();
|
|
23414
23555
|
for (const [id, raw] of Object.entries(heap)) {
|
|
23415
|
-
if (
|
|
23556
|
+
if (record3(raw).kind !== "scope-frame" || finished.has(id)) continue;
|
|
23416
23557
|
const path = /* @__PURE__ */ new Set();
|
|
23417
23558
|
let current = id;
|
|
23418
23559
|
while (current !== void 0 && !finished.has(current)) {
|
|
23419
23560
|
if (path.has(current)) throw new TypeError("Cyclic guest scope parent graph.");
|
|
23420
23561
|
path.add(current);
|
|
23421
|
-
const parent =
|
|
23422
|
-
current = absent(parent) ? void 0 : String(
|
|
23562
|
+
const parent = record3(heap[current]).parent;
|
|
23563
|
+
current = absent(parent) ? void 0 : String(record3(parent).id);
|
|
23423
23564
|
}
|
|
23424
23565
|
for (const visited of path) finished.add(visited);
|
|
23425
23566
|
}
|
|
23426
23567
|
}
|
|
23427
23568
|
|
|
23428
23569
|
// packages/safe-js/src/snapshot/guest-ast-validation.ts
|
|
23429
|
-
function validateGuestFunctionAst(
|
|
23570
|
+
function validateGuestFunctionAst(record4, origin) {
|
|
23430
23571
|
if (origin === null || typeof origin !== "object" || !["ArrowFunctionExpression", "FunctionExpression", "FunctionDeclaration"].includes(String(origin.type)))
|
|
23431
23572
|
throw new TypeError("Unknown guest function AST identity");
|
|
23432
|
-
if (
|
|
23573
|
+
if (record4.kind !== "guest-generator") return;
|
|
23433
23574
|
const functionNode = origin;
|
|
23434
|
-
if (functionNode.generator !== true || functionNode.async === true !==
|
|
23575
|
+
if (functionNode.generator !== true || functionNode.async === true !== record4.async)
|
|
23435
23576
|
throw new TypeError("Invalid generator AST identity");
|
|
23436
23577
|
let yieldBlocks;
|
|
23437
23578
|
let yieldFinalizers;
|
|
@@ -23446,10 +23587,10 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
23446
23587
|
if (["ArrowFunctionExpression", "FunctionExpression", "FunctionDeclaration"].includes(String(node.type))) continue;
|
|
23447
23588
|
let blocks = frame.blocks;
|
|
23448
23589
|
if (node.type === "BlockStatement" && typeof node.nodeId === "number") blocks = /* @__PURE__ */ new Set([...blocks, node.nodeId]);
|
|
23449
|
-
if (node.type === "YieldExpression" && node.nodeId ===
|
|
23590
|
+
if (node.type === "YieldExpression" && node.nodeId === record4.yieldNodeId) {
|
|
23450
23591
|
yieldBlocks = blocks;
|
|
23451
23592
|
yieldFinalizers = frame.finalizers;
|
|
23452
|
-
yieldExpressions = node.delegate === true && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "yield-delegate", async:
|
|
23593
|
+
yieldExpressions = node.delegate === true && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "yield-delegate", async: record4.async === true }]]) : frame.expressions;
|
|
23453
23594
|
}
|
|
23454
23595
|
for (const [key, value] of Object.entries(node)) {
|
|
23455
23596
|
if (node.type === "SwitchStatement" && key === "cases" && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
@@ -23551,23 +23692,23 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
23551
23692
|
});
|
|
23552
23693
|
}
|
|
23553
23694
|
}
|
|
23554
|
-
if (
|
|
23695
|
+
if (record4.yieldNodeId !== void 0 && yieldBlocks === void 0)
|
|
23555
23696
|
throw new TypeError("Invalid generator AST identity");
|
|
23556
|
-
if (
|
|
23557
|
-
throw new TypeError(`Invalid generator AST identity: expected blocks ${[...yieldBlocks ?? []]}, received ${Object.keys(
|
|
23558
|
-
if (
|
|
23559
|
-
for (const id of Object.keys(
|
|
23697
|
+
if (record4.state === "suspended" && Object.keys(record4.blockScopes ?? {}).length !== yieldBlocks?.size)
|
|
23698
|
+
throw new TypeError(`Invalid generator AST identity: expected blocks ${[...yieldBlocks ?? []]}, received ${Object.keys(record4.blockScopes ?? {})}.`);
|
|
23699
|
+
if (record4.blockScopes !== void 0) {
|
|
23700
|
+
for (const id of Object.keys(record4.blockScopes)) {
|
|
23560
23701
|
if (!yieldBlocks?.has(Number(id))) throw new TypeError("Invalid generator AST identity");
|
|
23561
23702
|
}
|
|
23562
23703
|
}
|
|
23563
|
-
const completions = Object.keys(
|
|
23564
|
-
if (
|
|
23704
|
+
const completions = Object.keys(record4.finallyCompletions ?? {});
|
|
23705
|
+
if (record4.state === "suspended" && completions.length !== yieldFinalizers?.size)
|
|
23565
23706
|
throw new TypeError("Invalid generator AST identity: missing finally completion");
|
|
23566
23707
|
for (const id of completions) {
|
|
23567
23708
|
if (!yieldFinalizers?.has(Number(id))) throw new TypeError("Invalid generator AST identity: unrelated finally completion");
|
|
23568
23709
|
}
|
|
23569
|
-
const expressions = Object.entries(
|
|
23570
|
-
if (
|
|
23710
|
+
const expressions = Object.entries(record4.expressionStates ?? {});
|
|
23711
|
+
if (record4.state === "suspended" && expressions.length !== yieldExpressions?.size)
|
|
23571
23712
|
throw new TypeError("Invalid generator AST identity: missing expression continuation");
|
|
23572
23713
|
for (const [id, expression] of expressions) {
|
|
23573
23714
|
const expected = yieldExpressions?.get(Number(id));
|
|
@@ -23776,16 +23917,16 @@ function validateDumpReferences(value, path, depth, state, heapIds, heap, role =
|
|
|
23776
23917
|
);
|
|
23777
23918
|
return;
|
|
23778
23919
|
}
|
|
23779
|
-
const
|
|
23780
|
-
if (
|
|
23781
|
-
const id = requireSafeInteger(
|
|
23920
|
+
const record4 = value;
|
|
23921
|
+
if (record4.kind === "ref") {
|
|
23922
|
+
const id = requireSafeInteger(record4.id, `${path}.id`, 1);
|
|
23782
23923
|
if (!heapIds.has(id)) fail("danglingReference", `${path}.id`, `unknown heap value ${id}`);
|
|
23783
23924
|
if (heap[String(id)].kind === "scope-frame" && !allowScopeReference)
|
|
23784
23925
|
fail("invalidValue", path, "Internal scopes cannot be guest data");
|
|
23785
23926
|
}
|
|
23786
|
-
for (const [key, entry] of Object.entries(
|
|
23787
|
-
const childRole = role === "root" && key === "heap" ? "heap" : role === "heap" ? "heap-node" : role === "heap-node" &&
|
|
23788
|
-
const scopeField = role === "scope-map" || role === "expression" && (
|
|
23927
|
+
for (const [key, entry] of Object.entries(record4)) {
|
|
23928
|
+
const childRole = role === "root" && key === "heap" ? "heap" : role === "heap" ? "heap-node" : role === "heap-node" && record4.kind === "guest-generator" && key === "blockScopes" ? "scope-map" : role === "heap-node" && record4.kind === "guest-generator" && key === "expressionStates" ? "expressions" : role === "expressions" ? "expression" : "data";
|
|
23929
|
+
const scopeField = role === "scope-map" || role === "expression" && (record4.kind === "for" && ["loopScope", "activeScope"].includes(key) || ["switch", "for-in", "for-of-array", "for-of-iterator"].includes(String(record4.kind)) && key === "scope") || role === "heap-node" && (record4.kind === "scope-frame" && key === "parent" || record4.kind === "guest-function" && key === "scope" || record4.kind === "guest-generator" && ["scope", "closureScope", "suspendedScope"].includes(key));
|
|
23789
23930
|
validateDumpReferences(entry, `${path}${formatKey(key)}`, depth + 1, state, heapIds, heap, childRole, scopeField);
|
|
23790
23931
|
}
|
|
23791
23932
|
}
|
|
@@ -23840,12 +23981,12 @@ function validatePosition(value, path) {
|
|
|
23840
23981
|
function validateValue(value, path, depth, state) {
|
|
23841
23982
|
validateGenericValue(value, path, depth, state);
|
|
23842
23983
|
}
|
|
23843
|
-
function validateTaggedValue(
|
|
23844
|
-
switch (
|
|
23984
|
+
function validateTaggedValue(record4, path, state) {
|
|
23985
|
+
switch (record4.kind) {
|
|
23845
23986
|
case "bigint":
|
|
23846
|
-
requireString(
|
|
23987
|
+
requireString(record4.value, `${path}.value`, state.limits);
|
|
23847
23988
|
try {
|
|
23848
|
-
validateBigIntData(
|
|
23989
|
+
validateBigIntData(record4.value);
|
|
23849
23990
|
} catch {
|
|
23850
23991
|
fail("invalidValue", `${path}.value`, "invalid BigInt value");
|
|
23851
23992
|
}
|
|
@@ -23853,34 +23994,34 @@ function validateTaggedValue(record3, path, state) {
|
|
|
23853
23994
|
case "undefined":
|
|
23854
23995
|
return;
|
|
23855
23996
|
case "number":
|
|
23856
|
-
if (!["-Infinity", "Infinity", "NaN", "-0"].includes(String(
|
|
23997
|
+
if (!["-Infinity", "Infinity", "NaN", "-0"].includes(String(record4.value))) {
|
|
23857
23998
|
fail("invalidValue", `${path}.value`, "unknown non-finite number value");
|
|
23858
23999
|
}
|
|
23859
24000
|
return;
|
|
23860
24001
|
case "fn":
|
|
23861
|
-
requireSafeInteger(
|
|
23862
|
-
requireSnapshotId(
|
|
24002
|
+
requireSafeInteger(record4.astNodeId, `${path}.astNodeId`, 0);
|
|
24003
|
+
requireSnapshotId(record4.capturedScopeId, `${path}.capturedScopeId`);
|
|
23863
24004
|
return;
|
|
23864
24005
|
case "generator":
|
|
23865
|
-
validateGeneratorShape(
|
|
24006
|
+
validateGeneratorShape(record4, path, state);
|
|
23866
24007
|
return;
|
|
23867
24008
|
case "promise":
|
|
23868
|
-
requireSnapshotId(
|
|
24009
|
+
requireSnapshotId(record4.id, `${path}.id`);
|
|
23869
24010
|
return;
|
|
23870
24011
|
case "ref":
|
|
23871
|
-
requireSafeInteger(
|
|
24012
|
+
requireSafeInteger(record4.id, `${path}.id`, 1);
|
|
23872
24013
|
return;
|
|
23873
24014
|
case "regex":
|
|
23874
|
-
requireString(
|
|
23875
|
-
requireString(
|
|
23876
|
-
requireSafeInteger(
|
|
24015
|
+
requireString(record4.source, `${path}.source`, state.limits);
|
|
24016
|
+
requireString(record4.flags, `${path}.flags`, state.limits);
|
|
24017
|
+
requireSafeInteger(record4.lastIndex, `${path}.lastIndex`, 0);
|
|
23877
24018
|
return;
|
|
23878
24019
|
case "regex-object":
|
|
23879
|
-
requireString(
|
|
23880
|
-
requireString(
|
|
23881
|
-
if (!Object.hasOwn(
|
|
24020
|
+
requireString(record4.source, `${path}.source`, state.limits);
|
|
24021
|
+
requireString(record4.flags, `${path}.flags`, state.limits);
|
|
24022
|
+
if (!Object.hasOwn(record4, "lastIndex")) fail("invalidValue", `${path}.lastIndex`, "missing regex cursor");
|
|
23882
24023
|
try {
|
|
23883
|
-
validateRegexProperties(
|
|
24024
|
+
validateRegexProperties(record4);
|
|
23884
24025
|
} catch {
|
|
23885
24026
|
fail("invalidValue", path, "invalid RegExp property data");
|
|
23886
24027
|
}
|
|
@@ -23889,7 +24030,7 @@ function validateTaggedValue(record3, path, state) {
|
|
|
23889
24030
|
case "arguments":
|
|
23890
24031
|
return;
|
|
23891
24032
|
case "object":
|
|
23892
|
-
if (Object.hasOwn(
|
|
24033
|
+
if (Object.hasOwn(record4, "sandboxNullPrototype") && record4.sandboxNullPrototype !== true)
|
|
23893
24034
|
fail("invalidValue", `${path}.sandboxNullPrototype`, "invalid object prototype");
|
|
23894
24035
|
return;
|
|
23895
24036
|
case "map":
|
|
@@ -23899,29 +24040,29 @@ function validateTaggedValue(record3, path, state) {
|
|
|
23899
24040
|
return;
|
|
23900
24041
|
}
|
|
23901
24042
|
}
|
|
23902
|
-
function validateGeneratorShape(
|
|
23903
|
-
if (
|
|
24043
|
+
function validateGeneratorShape(record4, path, state) {
|
|
24044
|
+
if (record4.async !== void 0 && typeof record4.async !== "boolean") {
|
|
23904
24045
|
fail("invalidType", `${path}.async`, "generator async flag must be a boolean");
|
|
23905
24046
|
}
|
|
23906
|
-
if (!["start", "suspended", "done"].includes(String(
|
|
24047
|
+
if (!["start", "suspended", "done"].includes(String(record4.state))) {
|
|
23907
24048
|
fail("invalidState", `${path}.state`, "unknown generator state");
|
|
23908
24049
|
}
|
|
23909
|
-
if (
|
|
23910
|
-
if (
|
|
24050
|
+
if (record4.state === "done") {
|
|
24051
|
+
if (record4.astNodeId !== void 0 || record4.capturedScopeId !== void 0 || record4.sent !== void 0 || record4.yieldNodeId !== void 0) {
|
|
23911
24052
|
fail("invalidState", path, "done generator cannot contain resume state");
|
|
23912
24053
|
}
|
|
23913
24054
|
return;
|
|
23914
24055
|
}
|
|
23915
|
-
requireSafeInteger(
|
|
23916
|
-
requireSnapshotId(
|
|
23917
|
-
if (
|
|
23918
|
-
if (
|
|
24056
|
+
requireSafeInteger(record4.astNodeId, `${path}.astNodeId`, 0);
|
|
24057
|
+
requireSnapshotId(record4.capturedScopeId, `${path}.capturedScopeId`);
|
|
24058
|
+
if (record4.state === "start") {
|
|
24059
|
+
if (record4.sent !== void 0 || record4.yieldNodeId !== void 0) {
|
|
23919
24060
|
fail("invalidState", path, "unstarted generator cannot contain a resume cursor");
|
|
23920
24061
|
}
|
|
23921
24062
|
return;
|
|
23922
24063
|
}
|
|
23923
|
-
requireSafeInteger(
|
|
23924
|
-
const sent = requireArray(
|
|
24064
|
+
requireSafeInteger(record4.yieldNodeId, `${path}.yieldNodeId`, 0);
|
|
24065
|
+
const sent = requireArray(record4.sent, `${path}.sent`, state);
|
|
23925
24066
|
sent.forEach((completion, index) => {
|
|
23926
24067
|
const completionPath = `${path}.sent[${index}]`;
|
|
23927
24068
|
const candidate = requireRecord(completion, completionPath);
|
|
@@ -23937,13 +24078,13 @@ function validateGeneratorShape(record3, path, state) {
|
|
|
23937
24078
|
});
|
|
23938
24079
|
}
|
|
23939
24080
|
function validateHeapValue(value, path, state, heap) {
|
|
23940
|
-
const
|
|
24081
|
+
const record4 = requireRecord(value, path);
|
|
23941
24082
|
try {
|
|
23942
|
-
if (validateGuestHeapNode(
|
|
24083
|
+
if (validateGuestHeapNode(record4, heap, state.limits.maxEntries)) {
|
|
23943
24084
|
const tagged = state.validateTaggedPayloads;
|
|
23944
24085
|
state.validateTaggedPayloads = false;
|
|
23945
24086
|
try {
|
|
23946
|
-
validateValue(
|
|
24087
|
+
validateValue(record4, path, 1, state);
|
|
23947
24088
|
} finally {
|
|
23948
24089
|
state.validateTaggedPayloads = tagged;
|
|
23949
24090
|
}
|
|
@@ -23952,49 +24093,49 @@ function validateHeapValue(value, path, state, heap) {
|
|
|
23952
24093
|
} catch (error) {
|
|
23953
24094
|
fail("invalidValue", path, String(error));
|
|
23954
24095
|
}
|
|
23955
|
-
validateErrorType(
|
|
23956
|
-
if (!["symbol", "arguments", "array", "object", "map", "set", "float32array", "date", "boxed", "collection-iterator", "regexp-iterator", "regex-object"].includes(String(
|
|
24096
|
+
validateErrorType(record4, path);
|
|
24097
|
+
if (!["symbol", "arguments", "array", "object", "map", "set", "float32array", "date", "boxed", "collection-iterator", "regexp-iterator", "regex-object"].includes(String(record4.kind)))
|
|
23957
24098
|
fail("unknownTag", `${path}.kind`, "unknown heap tag");
|
|
23958
|
-
validateValue(
|
|
23959
|
-
if (
|
|
23960
|
-
if (
|
|
23961
|
-
if (
|
|
23962
|
-
if (
|
|
23963
|
-
if (
|
|
23964
|
-
if (
|
|
23965
|
-
if (
|
|
23966
|
-
validateFloat32Storage(
|
|
23967
|
-
requireRecord(
|
|
23968
|
-
}
|
|
23969
|
-
if (
|
|
23970
|
-
const entries = requireArray(
|
|
24099
|
+
validateValue(record4, path, 1, state);
|
|
24100
|
+
if (record4.kind === "symbol") validateSymbolRecord(record4, path, state);
|
|
24101
|
+
if (record4.kind === "arguments") validateArgumentsProperties(record4, path);
|
|
24102
|
+
if (record4.kind === "array") validateArrayHeap(record4, path, state);
|
|
24103
|
+
if (record4.kind === "object") requireRecord(record4.entries, `${path}.entries`);
|
|
24104
|
+
if (record4.kind === "boxed") validateBoxedRecord(record4, path, heap);
|
|
24105
|
+
if (record4.kind === "date") validateDateRecord(record4, path);
|
|
24106
|
+
if (record4.kind === "float32array") {
|
|
24107
|
+
validateFloat32Storage(record4);
|
|
24108
|
+
requireRecord(record4.entries, `${path}.entries`);
|
|
24109
|
+
}
|
|
24110
|
+
if (record4.kind === "map") {
|
|
24111
|
+
const entries = requireArray(record4.entries, `${path}.entries`, state);
|
|
23971
24112
|
entries.forEach((entry, index) => {
|
|
23972
24113
|
if (!Array.isArray(entry) || entry.length !== 2)
|
|
23973
24114
|
fail("invalidValue", `${path}.entries[${index}]`, "map entry must contain two values");
|
|
23974
24115
|
});
|
|
23975
24116
|
}
|
|
23976
|
-
if (
|
|
23977
|
-
if (
|
|
23978
|
-
if ((
|
|
24117
|
+
if (record4.kind === "set") requireArray(record4.values, `${path}.values`, state);
|
|
24118
|
+
if (record4.kind === "regexp-iterator") {
|
|
24119
|
+
if ((record4.global !== void 0 || record4.unicode !== void 0) && (typeof record4.global !== "boolean" || typeof record4.unicode !== "boolean"))
|
|
23979
24120
|
fail("invalidValue", path, "invalid RegExp iterator modes");
|
|
23980
|
-
if (typeof
|
|
23981
|
-
if (!Object.hasOwn(
|
|
23982
|
-
requireRecord(
|
|
23983
|
-
}
|
|
23984
|
-
if (
|
|
23985
|
-
if (
|
|
23986
|
-
if (
|
|
23987
|
-
if (typeof
|
|
23988
|
-
requireSafeInteger(
|
|
23989
|
-
if (!Object.hasOwn(
|
|
23990
|
-
requireRecord(
|
|
23991
|
-
}
|
|
23992
|
-
}
|
|
23993
|
-
function validateSymbolEntries(
|
|
23994
|
-
if (
|
|
23995
|
-
if (
|
|
24121
|
+
if (typeof record4.exhausted !== "boolean") fail("invalidValue", `${path}.exhausted`, "invalid iterator exhaustion");
|
|
24122
|
+
if (!Object.hasOwn(record4, "matcher") || !Object.hasOwn(record4, "input")) fail("invalidValue", path, "missing RegExp iterator state");
|
|
24123
|
+
requireRecord(record4.entries, `${path}.entries`);
|
|
24124
|
+
}
|
|
24125
|
+
if (record4.kind === "collection-iterator") {
|
|
24126
|
+
if (record4.collectionKind !== "map" && record4.collectionKind !== "set") fail("invalidValue", `${path}.collectionKind`, "invalid iterator brand");
|
|
24127
|
+
if (record4.method !== "keys" && record4.method !== "values" && record4.method !== "entries") fail("invalidValue", `${path}.method`, "invalid iteration method");
|
|
24128
|
+
if (typeof record4.exhausted !== "boolean") fail("invalidValue", `${path}.exhausted`, "invalid iterator exhaustion");
|
|
24129
|
+
requireSafeInteger(record4.index, `${path}.index`, 0);
|
|
24130
|
+
if (!Object.hasOwn(record4, "collection")) fail("invalidValue", `${path}.collection`, "missing iterator source");
|
|
24131
|
+
requireRecord(record4.entries, `${path}.entries`);
|
|
24132
|
+
}
|
|
24133
|
+
}
|
|
24134
|
+
function validateSymbolEntries(record4, path, state, heap) {
|
|
24135
|
+
if (record4.symbolEntries === void 0) return;
|
|
24136
|
+
if (record4.kind !== "object" && record4.kind !== "array" && record4.kind !== "date" && record4.kind !== "boxed" && record4.kind !== "regex-object" && record4.kind !== "regexp-iterator")
|
|
23996
24137
|
fail("invalidValue", `${path}.symbolEntries`, "symbol properties are unsupported for this heap kind");
|
|
23997
|
-
const entries = requireArray(
|
|
24138
|
+
const entries = requireArray(record4.symbolEntries, `${path}.symbolEntries`, state);
|
|
23998
24139
|
const keys = /* @__PURE__ */ new Set();
|
|
23999
24140
|
entries.forEach((entry, index) => {
|
|
24000
24141
|
const entryPath = `${path}.symbolEntries[${index}]`;
|
|
@@ -24010,24 +24151,24 @@ function validateSymbolEntries(record3, path, state, heap) {
|
|
|
24010
24151
|
validateDataDescriptor(requireRecord(entry[1], `${entryPath}[1]`), `${entryPath}[1]`);
|
|
24011
24152
|
});
|
|
24012
24153
|
}
|
|
24013
|
-
function validateSymbolRecord(
|
|
24014
|
-
if (
|
|
24015
|
-
requireString(
|
|
24016
|
-
if (
|
|
24017
|
-
requireString(
|
|
24018
|
-
if (!Object.hasOwn(wellKnownSymbols, String(
|
|
24154
|
+
function validateSymbolRecord(record4, path, state) {
|
|
24155
|
+
if (record4.description !== void 0)
|
|
24156
|
+
requireString(record4.description, `${path}.description`, state.limits);
|
|
24157
|
+
if (record4.wellKnown !== void 0) {
|
|
24158
|
+
requireString(record4.wellKnown, `${path}.wellKnown`, state.limits);
|
|
24159
|
+
if (!Object.hasOwn(wellKnownSymbols, String(record4.wellKnown)))
|
|
24019
24160
|
fail("invalidValue", `${path}.wellKnown`, "unknown well-known symbol");
|
|
24020
|
-
if (Object.hasOwn(
|
|
24161
|
+
if (Object.hasOwn(record4, "description"))
|
|
24021
24162
|
fail("invalidValue", path, "well-known symbol cannot specify a description");
|
|
24022
24163
|
}
|
|
24023
24164
|
}
|
|
24024
|
-
function validateBoxedRecord(
|
|
24165
|
+
function validateBoxedRecord(record4, path, heap) {
|
|
24025
24166
|
try {
|
|
24026
|
-
validateBoxedProperties(
|
|
24167
|
+
validateBoxedProperties(record4);
|
|
24027
24168
|
} catch {
|
|
24028
24169
|
fail("invalidValue", path, "invalid boxed primitive properties");
|
|
24029
24170
|
}
|
|
24030
|
-
const value =
|
|
24171
|
+
const value = record4.value;
|
|
24031
24172
|
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") return;
|
|
24032
24173
|
const number = requireRecord(value, `${path}.value`);
|
|
24033
24174
|
if (number.kind === "bigint") {
|
|
@@ -24047,16 +24188,16 @@ function validateBoxedRecord(record3, path, heap) {
|
|
|
24047
24188
|
if (number.kind !== "number" || !["NaN", "Infinity", "-Infinity", "-0"].includes(String(number.value)))
|
|
24048
24189
|
fail("invalidValue", `${path}.value`, "invalid boxed primitive payload");
|
|
24049
24190
|
}
|
|
24050
|
-
function validateDateRecord(
|
|
24051
|
-
if (Object.keys(
|
|
24191
|
+
function validateDateRecord(record4, path) {
|
|
24192
|
+
if (Object.keys(record4).some((key) => !["kind", "time", "properties", "symbolEntries", "extensible"].includes(key))) fail("invalidValue", path, "invalid Date fields");
|
|
24052
24193
|
try {
|
|
24053
|
-
restoreDateTime(
|
|
24194
|
+
restoreDateTime(record4.time);
|
|
24054
24195
|
} catch {
|
|
24055
24196
|
fail("invalidValue", `${path}.time`, "invalid Date epoch");
|
|
24056
24197
|
}
|
|
24057
|
-
if (
|
|
24058
|
-
if (
|
|
24059
|
-
for (const [key, value] of Object.entries(requireRecord(
|
|
24198
|
+
if (record4.extensible !== void 0 && typeof record4.extensible !== "boolean") fail("invalidType", `${path}.extensible`, "invalid Date extensibility");
|
|
24199
|
+
if (record4.properties !== void 0) {
|
|
24200
|
+
for (const [key, value] of Object.entries(requireRecord(record4.properties, `${path}.properties`))) {
|
|
24060
24201
|
const propertyPath = `${path}.properties${formatKey(key)}`;
|
|
24061
24202
|
validateDataDescriptor(requireRecord(value, propertyPath), propertyPath);
|
|
24062
24203
|
}
|
|
@@ -24070,14 +24211,14 @@ function validateDataDescriptor(descriptor, path) {
|
|
|
24070
24211
|
if (Object.keys(descriptor).some((key) => !["value", "enumerable", "writable", "configurable"].includes(key)))
|
|
24071
24212
|
fail("invalidValue", path, "unsupported property descriptor field");
|
|
24072
24213
|
}
|
|
24073
|
-
function validateArrayHeap(
|
|
24074
|
-
if (Object.hasOwn(
|
|
24075
|
-
requireArray(
|
|
24076
|
-
if (Object.hasOwn(
|
|
24214
|
+
function validateArrayHeap(record4, path, state) {
|
|
24215
|
+
if (Object.hasOwn(record4, "items")) {
|
|
24216
|
+
requireArray(record4.items, `${path}.items`, state);
|
|
24217
|
+
if (Object.hasOwn(record4, "length") || Object.hasOwn(record4, "entries"))
|
|
24077
24218
|
fail("invalidValue", path, "array must use either items or length and entries");
|
|
24078
24219
|
return;
|
|
24079
24220
|
}
|
|
24080
|
-
const length = requireSafeInteger(
|
|
24221
|
+
const length = requireSafeInteger(record4.length, `${path}.length`, 0);
|
|
24081
24222
|
if (length > 4294967295) fail("invalidValue", `${path}.length`, "exceeds maximum array length");
|
|
24082
24223
|
if (length > state.limits.maxEntries)
|
|
24083
24224
|
fail(
|
|
@@ -24085,7 +24226,7 @@ function validateArrayHeap(record3, path, state) {
|
|
|
24085
24226
|
`${path}.length`,
|
|
24086
24227
|
`exceeds collection entry limit ${state.limits.maxEntries}`
|
|
24087
24228
|
);
|
|
24088
|
-
const entries = requireRecord(
|
|
24229
|
+
const entries = requireRecord(record4.entries, `${path}.entries`);
|
|
24089
24230
|
for (const key of Object.keys(entries)) {
|
|
24090
24231
|
if (key === "length")
|
|
24091
24232
|
fail("invalidValue", `${path}.entries.length`, "array length is stored separately");
|
|
@@ -24094,22 +24235,22 @@ function validateArrayHeap(record3, path, state) {
|
|
|
24094
24235
|
fail("invalidValue", `${path}.entries${formatKey(key)}`, "array index exceeds its length");
|
|
24095
24236
|
}
|
|
24096
24237
|
}
|
|
24097
|
-
function validateErrorType(
|
|
24098
|
-
if (!Object.hasOwn(
|
|
24099
|
-
if (
|
|
24238
|
+
function validateErrorType(record4, path) {
|
|
24239
|
+
if (!Object.hasOwn(record4, "errorType")) return;
|
|
24240
|
+
if (record4.kind !== "object" || !sandboxErrorNames.includes(record4.errorType)) {
|
|
24100
24241
|
fail("invalidValue", `${path}.errorType`, "invalid error metadata");
|
|
24101
24242
|
}
|
|
24102
24243
|
}
|
|
24103
|
-
function validateArgumentsProperties(
|
|
24104
|
-
if (typeof
|
|
24244
|
+
function validateArgumentsProperties(record4, path) {
|
|
24245
|
+
if (typeof record4.extensible !== "boolean") {
|
|
24105
24246
|
fail("invalidType", `${path}.extensible`, "expected boolean");
|
|
24106
24247
|
}
|
|
24107
|
-
if (typeof
|
|
24248
|
+
if (typeof record4.lengthBeforeCallee !== "boolean") {
|
|
24108
24249
|
fail("invalidType", `${path}.lengthBeforeCallee`, "expected boolean");
|
|
24109
24250
|
}
|
|
24110
|
-
const properties = requireRecord(
|
|
24111
|
-
if (
|
|
24112
|
-
const iterator = requireRecord(
|
|
24251
|
+
const properties = requireRecord(record4.properties, `${path}.properties`);
|
|
24252
|
+
if (record4.iterator !== null) {
|
|
24253
|
+
const iterator = requireRecord(record4.iterator, `${path}.iterator`);
|
|
24113
24254
|
for (const key of Object.keys(iterator)) {
|
|
24114
24255
|
if (!["configurable", "enumerable", "writable"].includes(key)) {
|
|
24115
24256
|
fail(
|
|
@@ -24124,7 +24265,7 @@ function validateArgumentsProperties(record3, path) {
|
|
|
24124
24265
|
fail("invalidType", `${path}.iterator.${flag}`, "expected boolean");
|
|
24125
24266
|
}
|
|
24126
24267
|
}
|
|
24127
|
-
if (
|
|
24268
|
+
if (record4.lengthBeforeCallee && !Object.hasOwn(properties, "length")) {
|
|
24128
24269
|
fail("invalidValue", `${path}.properties`, "initial length property is required");
|
|
24129
24270
|
}
|
|
24130
24271
|
for (const [key, value] of Object.entries(properties)) {
|
|
@@ -24187,9 +24328,9 @@ function validateGenericValue(value, path, depth, state) {
|
|
|
24187
24328
|
);
|
|
24188
24329
|
}
|
|
24189
24330
|
} else if (value !== null && typeof value === "object") {
|
|
24190
|
-
const
|
|
24191
|
-
if (state.validateTaggedPayloads && isTaggedValueShape(
|
|
24192
|
-
validateTaggedValue(
|
|
24331
|
+
const record4 = value;
|
|
24332
|
+
if (state.validateTaggedPayloads && isTaggedValueShape(record4)) {
|
|
24333
|
+
validateTaggedValue(record4, path, state);
|
|
24193
24334
|
}
|
|
24194
24335
|
const entries = state.dataPropertiesOnly ? snapshotDataEntries(value, path) : Object.entries(value);
|
|
24195
24336
|
for (const [key, entry] of entries) {
|
|
@@ -24698,6 +24839,7 @@ function ownEnumerableSandboxEntries(value, excludedKeys) {
|
|
|
24698
24839
|
let entries;
|
|
24699
24840
|
if (isGuestClosure(value)) entries = Object.entries(value.properties ?? {});
|
|
24700
24841
|
else if (isSandboxRegex(value)) entries = Object.entries(getRegexProperties(value));
|
|
24842
|
+
else if (isSandboxMap(value) || isSandboxSet(value)) entries = Object.entries(getCollectionProperties(value));
|
|
24701
24843
|
else if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
24702
24844
|
else entries = Object.entries(Object(value));
|
|
24703
24845
|
return excludedKeys === void 0 ? entries : entries.filter(([key]) => !excludedKeys.has(key));
|
|
@@ -24707,18 +24849,20 @@ function ownSandboxSymbolKeys(value) {
|
|
|
24707
24849
|
if (isGuestHostObject(value)) return [];
|
|
24708
24850
|
if (isSandboxClosure(value)) value = value.properties ?? {};
|
|
24709
24851
|
else if (isSandboxRegex(value)) value = getRegexProperties(value);
|
|
24852
|
+
else if (isSandboxMap(value) || isSandboxSet(value)) value = getCollectionProperties(value);
|
|
24710
24853
|
else if (isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
24711
24854
|
return Object.getOwnPropertySymbols(Object(value)).filter((key) => !internalSymbols.has(key));
|
|
24712
24855
|
}
|
|
24713
24856
|
function ownEnumerableSandboxKeys(value, includeSymbols = false) {
|
|
24714
24857
|
if (includeSymbols) {
|
|
24715
|
-
const properties = isSandboxClosure(value) ? value.properties ?? {} : isSandboxRegex(value) ? getRegexProperties(value) : Object(value);
|
|
24858
|
+
const properties = isSandboxClosure(value) ? value.properties ?? {} : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : Object(value);
|
|
24716
24859
|
return [...ownEnumerableSandboxKeys(value), ...ownSandboxSymbolKeys(value).filter((key) => Object.getOwnPropertyDescriptor(properties, key)?.enumerable === true)];
|
|
24717
24860
|
}
|
|
24718
24861
|
if (isGuestHostObject(value)) return getHostObjectKeys(value);
|
|
24719
24862
|
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
24720
24863
|
if (isGuestClosure(value)) return Object.keys(value.properties ?? {});
|
|
24721
24864
|
if (isSandboxRegex(value)) return Object.keys(getRegexProperties(value));
|
|
24865
|
+
if (isSandboxMap(value) || isSandboxSet(value)) return Object.keys(getCollectionProperties(value));
|
|
24722
24866
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
24723
24867
|
return Object.keys(Object(value));
|
|
24724
24868
|
}
|
|
@@ -24772,6 +24916,7 @@ function createSandboxGenerator(channel, metadata = void 0) {
|
|
|
24772
24916
|
}
|
|
24773
24917
|
function createSandboxMap(entries = []) {
|
|
24774
24918
|
const map = {};
|
|
24919
|
+
collectionGuestProperties.set(map, /* @__PURE__ */ Object.create(null));
|
|
24775
24920
|
Object.defineProperties(map, {
|
|
24776
24921
|
kind: {
|
|
24777
24922
|
value: "map"
|
|
@@ -24788,6 +24933,7 @@ function createSandboxMap(entries = []) {
|
|
|
24788
24933
|
}
|
|
24789
24934
|
function createSandboxSet(values = []) {
|
|
24790
24935
|
const set = {};
|
|
24936
|
+
collectionGuestProperties.set(set, /* @__PURE__ */ Object.create(null));
|
|
24791
24937
|
Object.defineProperties(set, {
|
|
24792
24938
|
kind: {
|
|
24793
24939
|
value: "set"
|
|
@@ -24960,6 +25106,16 @@ function measureSandboxData(values, options = {}) {
|
|
|
24960
25106
|
}
|
|
24961
25107
|
return;
|
|
24962
25108
|
}
|
|
25109
|
+
if (isSandboxMap(value) || isSandboxSet(value)) {
|
|
25110
|
+
const properties = getCollectionProperties(value);
|
|
25111
|
+
for (const key of Reflect.ownKeys(properties)) {
|
|
25112
|
+
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
25113
|
+
usage += 1 + (typeof key === "string" ? key.length : 0);
|
|
25114
|
+
if (typeof key === "symbol") visit(key, depth + 1);
|
|
25115
|
+
if ("value" in descriptor) visit(descriptor.value, depth + 1);
|
|
25116
|
+
else for (const closure of retainedAccessorClosures(descriptor)) visit(closure, depth + 1);
|
|
25117
|
+
}
|
|
25118
|
+
}
|
|
24963
25119
|
if (isSandboxMap(value)) {
|
|
24964
25120
|
usage += value.entries.size;
|
|
24965
25121
|
for (const [key, entry] of value.entries) {
|
|
@@ -25203,6 +25359,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
25203
25359
|
if (existing !== void 0) return existing;
|
|
25204
25360
|
const copy = createSandboxMap();
|
|
25205
25361
|
state.seen.set(value, copy);
|
|
25362
|
+
if (!state.structuredClone) copyCollectionProperties(value, getCollectionProperties(copy), (entry) => copyToSandbox(entry, state, `${path}.<property>`, true, depth + 1));
|
|
25206
25363
|
for (const [key, entry] of value.entries) {
|
|
25207
25364
|
copy.entries.set(
|
|
25208
25365
|
copyToSandbox(key, state, `${path}.<key>`, true, depth + 1),
|
|
@@ -25217,6 +25374,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
25217
25374
|
if (existing !== void 0) return existing;
|
|
25218
25375
|
const copy = createSandboxSet();
|
|
25219
25376
|
state.seen.set(value, copy);
|
|
25377
|
+
if (!state.structuredClone) copyCollectionProperties(value, getCollectionProperties(copy), (entry) => copyToSandbox(entry, state, `${path}.<property>`, true, depth + 1));
|
|
25220
25378
|
for (const entry of value.values) {
|
|
25221
25379
|
copy.values.add(copyToSandbox(entry, state, `${path}.<value>`, true, depth + 1));
|
|
25222
25380
|
}
|
|
@@ -25275,6 +25433,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
25275
25433
|
}
|
|
25276
25434
|
const copy = createSandboxMap();
|
|
25277
25435
|
state.seen.set(value, copy);
|
|
25436
|
+
if (!state.structuredClone) copyCollectionProperties(value, getCollectionProperties(copy), (entry) => copyToSandbox(entry, state, `${path}.<property>`, cloneSandboxCollections, depth + 1));
|
|
25278
25437
|
for (const [key, entry] of value) {
|
|
25279
25438
|
copy.entries.set(
|
|
25280
25439
|
copyToSandbox(key, state, `${path}.<key>`, cloneSandboxCollections, depth + 1),
|
|
@@ -25290,6 +25449,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
25290
25449
|
}
|
|
25291
25450
|
const copy = createSandboxSet();
|
|
25292
25451
|
state.seen.set(value, copy);
|
|
25452
|
+
if (!state.structuredClone) copyCollectionProperties(value, getCollectionProperties(copy), (entry) => copyToSandbox(entry, state, `${path}.<property>`, cloneSandboxCollections, depth + 1));
|
|
25293
25453
|
for (const entry of value) {
|
|
25294
25454
|
copy.values.add(
|
|
25295
25455
|
copyToSandbox(entry, state, `${path}.<value>`, cloneSandboxCollections, depth + 1)
|
|
@@ -25498,6 +25658,7 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
25498
25658
|
}
|
|
25499
25659
|
const copy = /* @__PURE__ */ new Map();
|
|
25500
25660
|
state.seen.set(value, copy);
|
|
25661
|
+
copyCollectionProperties(value, copy, (entry) => copyFromSandbox(entry, state, `${path}.<property>`, options, depth + 1));
|
|
25501
25662
|
for (const [key, entry] of value.entries) {
|
|
25502
25663
|
copy.set(
|
|
25503
25664
|
copyFromSandbox(key, state, `${path}.<key>`, options, depth + 1),
|
|
@@ -25513,6 +25674,7 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
25513
25674
|
}
|
|
25514
25675
|
const copy = /* @__PURE__ */ new Set();
|
|
25515
25676
|
state.seen.set(value, copy);
|
|
25677
|
+
copyCollectionProperties(value, copy, (entry) => copyFromSandbox(entry, state, `${path}.<property>`, options, depth + 1));
|
|
25516
25678
|
for (const entry of value.values) {
|
|
25517
25679
|
copy.add(copyFromSandbox(entry, state, `${path}.<value>`, options, depth + 1));
|
|
25518
25680
|
}
|
|
@@ -25740,12 +25902,12 @@ var HostCallResumabilityError = class extends Error {
|
|
|
25740
25902
|
static [Symbol.hasInstance](value) {
|
|
25741
25903
|
return typeof value === "object" && value !== null && #nativeInstance in value && Function.prototype[Symbol.hasInstance].call(this, value);
|
|
25742
25904
|
}
|
|
25743
|
-
constructor(
|
|
25905
|
+
constructor(record4, action, message) {
|
|
25744
25906
|
super(message);
|
|
25745
25907
|
this.name = "HostCallResumabilityError";
|
|
25746
25908
|
this.action = action;
|
|
25747
|
-
this.callId =
|
|
25748
|
-
this.lifecycle =
|
|
25909
|
+
this.callId = record4.id;
|
|
25910
|
+
this.lifecycle = record4.lifecycle;
|
|
25749
25911
|
}
|
|
25750
25912
|
};
|
|
25751
25913
|
var UnresolvedReplayCapabilityError = class extends TypeError {
|
|
@@ -25777,33 +25939,33 @@ var HostCallJournal = class {
|
|
|
25777
25939
|
);
|
|
25778
25940
|
const restoredRunId = replayRecords[0]?.runId ?? records[0]?.runId ?? randomUUID();
|
|
25779
25941
|
validateRestoredRecords(records, restoredRunId, sourceHash);
|
|
25780
|
-
for (const
|
|
25781
|
-
const replayRecord = replayRecords[readCallOrdinal(
|
|
25782
|
-
if (replayRecord === void 0 || !callIdentityMatches(
|
|
25942
|
+
for (const record4 of records) {
|
|
25943
|
+
const replayRecord = replayRecords[readCallOrdinal(record4) - 1];
|
|
25944
|
+
if (replayRecord === void 0 || !callIdentityMatches(record4, replayRecord) || record4.lifecycle !== replayRecord.lifecycle) {
|
|
25783
25945
|
throw new HostCallResumabilityError(
|
|
25784
|
-
|
|
25946
|
+
record4,
|
|
25785
25947
|
"reset",
|
|
25786
|
-
`Host call ${
|
|
25948
|
+
`Host call ${record4.id} conflicts with the replay journal; reset is required.`
|
|
25787
25949
|
);
|
|
25788
25950
|
}
|
|
25789
25951
|
}
|
|
25790
25952
|
records = replayRecords;
|
|
25791
25953
|
}
|
|
25792
25954
|
this.runId = records[0]?.runId ?? randomUUID();
|
|
25793
|
-
this.records = records.map((
|
|
25794
|
-
...
|
|
25795
|
-
...
|
|
25796
|
-
...
|
|
25797
|
-
...
|
|
25955
|
+
this.records = records.map((record4) => ({
|
|
25956
|
+
...record4,
|
|
25957
|
+
...record4.functions === void 0 ? {} : { functions: [...record4.functions] },
|
|
25958
|
+
...record4.callbacks === void 0 ? {} : { callbacks: structuredClone(record4.callbacks) },
|
|
25959
|
+
...record4.outcome === void 0 ? {} : { outcome: copyOutcome(record4.outcome) }
|
|
25798
25960
|
}));
|
|
25799
25961
|
validateRestoredRecords(this.records, this.runId, sourceHash);
|
|
25800
25962
|
this.retainedSize = this.records.length;
|
|
25801
25963
|
try {
|
|
25802
25964
|
this.budget?.setRetainedDataUsage(this, this.retainedSize);
|
|
25803
|
-
for (const
|
|
25804
|
-
if (
|
|
25805
|
-
for (const [index, callback] of (
|
|
25806
|
-
let size = this.callbackSizes.get(`${
|
|
25965
|
+
for (const record4 of this.records) {
|
|
25966
|
+
if (record4.outcome !== void 0) this.retainOutcome(record4, record4.outcome);
|
|
25967
|
+
for (const [index, callback] of (record4.callbacks ?? []).entries()) {
|
|
25968
|
+
let size = this.callbackSizes.get(`${record4.id}/callback/${index + 1}`);
|
|
25807
25969
|
if (size === void 0) {
|
|
25808
25970
|
const validation = new CompileScope(operation?.owner);
|
|
25809
25971
|
try {
|
|
@@ -25877,7 +26039,7 @@ var HostCallJournal = class {
|
|
|
25877
26039
|
createRecord(input) {
|
|
25878
26040
|
this.budget?.setRetainedDataUsage(this, this.retainedSize + 1);
|
|
25879
26041
|
this.retainedSize += 1;
|
|
25880
|
-
const
|
|
26042
|
+
const record4 = {
|
|
25881
26043
|
id: `${this.runId}:${this.nextCall++}`,
|
|
25882
26044
|
runId: this.runId,
|
|
25883
26045
|
sourceHash: this.sourceHash,
|
|
@@ -25887,65 +26049,65 @@ var HostCallJournal = class {
|
|
|
25887
26049
|
policy: input.policy,
|
|
25888
26050
|
lifecycle: "created"
|
|
25889
26051
|
};
|
|
25890
|
-
this.records.push(
|
|
26052
|
+
this.records.push(record4);
|
|
25891
26053
|
this.records.sort((left, right) => readCallOrdinal(left) - readCallOrdinal(right));
|
|
25892
|
-
return
|
|
26054
|
+
return record4;
|
|
25893
26055
|
}
|
|
25894
|
-
start(
|
|
25895
|
-
|
|
26056
|
+
start(record4) {
|
|
26057
|
+
record4.lifecycle = "running";
|
|
25896
26058
|
}
|
|
25897
|
-
settle(
|
|
25898
|
-
if (
|
|
25899
|
-
this.retainOutcome(
|
|
25900
|
-
|
|
26059
|
+
settle(record4, outcome) {
|
|
26060
|
+
if (record4.lifecycle === "cancelled") return;
|
|
26061
|
+
this.retainOutcome(record4, outcome);
|
|
26062
|
+
record4.lifecycle = "settled";
|
|
25901
26063
|
}
|
|
25902
|
-
consume(
|
|
25903
|
-
if (
|
|
26064
|
+
consume(record4) {
|
|
26065
|
+
if (record4.lifecycle === "consumed") {
|
|
25904
26066
|
throw new HostCallResumabilityError(
|
|
25905
|
-
|
|
26067
|
+
record4,
|
|
25906
26068
|
"reset",
|
|
25907
|
-
`Host call ${
|
|
26069
|
+
`Host call ${record4.id} result was already consumed; reset is required.`
|
|
25908
26070
|
);
|
|
25909
26071
|
}
|
|
25910
|
-
if (
|
|
25911
|
-
|
|
26072
|
+
if (record4.lifecycle !== "settled") return;
|
|
26073
|
+
record4.lifecycle = "consumed";
|
|
25912
26074
|
}
|
|
25913
|
-
cancel(
|
|
25914
|
-
if (
|
|
25915
|
-
this.retainOutcome(
|
|
25916
|
-
|
|
26075
|
+
cancel(record4, reason) {
|
|
26076
|
+
if (record4.lifecycle === "settled" || record4.lifecycle === "consumed") return;
|
|
26077
|
+
this.retainOutcome(record4, { status: "rejected", reason });
|
|
26078
|
+
record4.lifecycle = "cancelled";
|
|
25917
26079
|
}
|
|
25918
|
-
async reconcile(
|
|
25919
|
-
if (
|
|
25920
|
-
if (
|
|
26080
|
+
async reconcile(record4, context) {
|
|
26081
|
+
if (record4.lifecycle === "settled" && record4.outcome !== void 0) return record4.outcome;
|
|
26082
|
+
if (record4.lifecycle === "consumed") {
|
|
25921
26083
|
throw new HostCallResumabilityError(
|
|
25922
|
-
|
|
26084
|
+
record4,
|
|
25923
26085
|
"reset",
|
|
25924
|
-
`Host call ${
|
|
26086
|
+
`Host call ${record4.id} result was already consumed; reset is required.`
|
|
25925
26087
|
);
|
|
25926
26088
|
}
|
|
25927
|
-
if (
|
|
26089
|
+
if (record4.lifecycle === "cancelled") {
|
|
25928
26090
|
throw new HostCallResumabilityError(
|
|
25929
|
-
|
|
26091
|
+
record4,
|
|
25930
26092
|
"reset",
|
|
25931
|
-
`Host call ${
|
|
26093
|
+
`Host call ${record4.id} was cancelled; reset is required.`
|
|
25932
26094
|
);
|
|
25933
26095
|
}
|
|
25934
|
-
if (
|
|
26096
|
+
if (record4.policy === "re-issue") {
|
|
25935
26097
|
throw new HostCallResumabilityError(
|
|
25936
|
-
|
|
26098
|
+
record4,
|
|
25937
26099
|
"reset",
|
|
25938
|
-
`Host call ${
|
|
26100
|
+
`Host call ${record4.id} must be re-issued by the runtime.`
|
|
25939
26101
|
);
|
|
25940
26102
|
}
|
|
25941
26103
|
if (this.resumeProvider === void 0) {
|
|
25942
26104
|
throw new HostCallResumabilityError(
|
|
25943
|
-
|
|
26105
|
+
record4,
|
|
25944
26106
|
"external-reconciliation",
|
|
25945
|
-
`Host call ${
|
|
26107
|
+
`Host call ${record4.id} may have executed before process death; external reconciliation is required.`
|
|
25946
26108
|
);
|
|
25947
26109
|
}
|
|
25948
|
-
const { id, outcome: ignoredOutcome, ...request } =
|
|
26110
|
+
const { id, outcome: ignoredOutcome, ...request } = record4;
|
|
25949
26111
|
void ignoredOutcome;
|
|
25950
26112
|
const proof = await this.resumeProvider(
|
|
25951
26113
|
{
|
|
@@ -25955,23 +26117,23 @@ var HostCallJournal = class {
|
|
|
25955
26117
|
},
|
|
25956
26118
|
context
|
|
25957
26119
|
);
|
|
25958
|
-
validateProof(
|
|
26120
|
+
validateProof(record4, proof);
|
|
25959
26121
|
if (context !== void 0 && context.callbacks.size > 0 && proof.callbackDisposition === void 0) {
|
|
25960
26122
|
throw new HostCallResumabilityError(
|
|
25961
|
-
|
|
26123
|
+
record4,
|
|
25962
26124
|
"external-reconciliation",
|
|
25963
|
-
`Host call ${
|
|
26125
|
+
`Host call ${record4.id} has sandbox callbacks; its proof must specify callbackDisposition as joined or detached.`
|
|
25964
26126
|
);
|
|
25965
26127
|
}
|
|
25966
26128
|
if (proof.callbackDisposition === "joined") await context?.waitForCallbacks();
|
|
25967
|
-
this.settle(
|
|
26129
|
+
this.settle(record4, proof.outcome);
|
|
25968
26130
|
return proof.outcome;
|
|
25969
26131
|
}
|
|
25970
26132
|
snapshot() {
|
|
25971
26133
|
return this.records.filter(
|
|
25972
|
-
(
|
|
25973
|
-
).map(({ outcome, ...
|
|
25974
|
-
...structuredClone(
|
|
26134
|
+
(record4) => record4.policy === "read-side-effect" || record4.lifecycle === "created" || record4.lifecycle === "running" || record4.lifecycle === "cancelled"
|
|
26135
|
+
).map(({ outcome, ...record4 }) => ({
|
|
26136
|
+
...structuredClone(record4),
|
|
25975
26137
|
...outcome === void 0 ? {} : { outcome: copyOutcome(outcome) }
|
|
25976
26138
|
}));
|
|
25977
26139
|
}
|
|
@@ -25984,12 +26146,12 @@ var HostCallJournal = class {
|
|
|
25984
26146
|
this.capabilityWaiters.clear();
|
|
25985
26147
|
this.budget = void 0;
|
|
25986
26148
|
}
|
|
25987
|
-
registerCallbackFunction(
|
|
25988
|
-
const identity = `${
|
|
26149
|
+
registerCallbackFunction(record4, id, closure, native) {
|
|
26150
|
+
const identity = `${record4.id}/function/${id}`;
|
|
25989
26151
|
const existing = this.capabilities.get(identity);
|
|
25990
26152
|
if (existing !== void 0 && existing !== closure)
|
|
25991
26153
|
throw new TypeError(`Conflicting replay capability '${identity}'.`);
|
|
25992
|
-
if (!(
|
|
26154
|
+
if (!(record4.functions ?? []).includes(id)) (record4.functions ??= []).push(id);
|
|
25993
26155
|
this.capabilities.set(identity, closure);
|
|
25994
26156
|
this.capabilityWaiters.get(identity)?.resolve();
|
|
25995
26157
|
this.capabilityWaiters.delete(identity);
|
|
@@ -26039,11 +26201,11 @@ var HostCallJournal = class {
|
|
|
26039
26201
|
}
|
|
26040
26202
|
return waiter.promise;
|
|
26041
26203
|
}
|
|
26042
|
-
trackCallbackCompletion(
|
|
26204
|
+
trackCallbackCompletion(record4, callbacks) {
|
|
26043
26205
|
const complete = () => {
|
|
26044
|
-
this.completedCallbackOwners.add(
|
|
26206
|
+
this.completedCallbackOwners.add(record4.id);
|
|
26045
26207
|
for (const [id, waiter] of this.capabilityWaiters) {
|
|
26046
|
-
if (!id.startsWith(`${
|
|
26208
|
+
if (!id.startsWith(`${record4.id}/function/`)) continue;
|
|
26047
26209
|
waiter.reject(new UnresolvedReplayCapabilityError(id));
|
|
26048
26210
|
this.capabilityWaiters.delete(id);
|
|
26049
26211
|
}
|
|
@@ -26051,7 +26213,7 @@ var HostCallJournal = class {
|
|
|
26051
26213
|
if (callbacks.length === 0) complete();
|
|
26052
26214
|
else void Promise.allSettled(callbacks).then(complete);
|
|
26053
26215
|
}
|
|
26054
|
-
recordCallback(
|
|
26216
|
+
recordCallback(record4, id, args, step) {
|
|
26055
26217
|
const retainedSize = this.retainedSize + 1 + measureSandboxData([args], { ignoreClosures: true });
|
|
26056
26218
|
this.budget?.setRetainedDataUsage(this, retainedSize);
|
|
26057
26219
|
let data;
|
|
@@ -26062,25 +26224,25 @@ var HostCallJournal = class {
|
|
|
26062
26224
|
throw error;
|
|
26063
26225
|
}
|
|
26064
26226
|
this.retainedSize = retainedSize;
|
|
26065
|
-
(
|
|
26066
|
-
return `${
|
|
26227
|
+
(record4.callbacks ??= []).push({ id, step, arguments: data });
|
|
26228
|
+
return `${record4.id}/callback/${record4.callbacks.length}`;
|
|
26067
26229
|
}
|
|
26068
26230
|
callbackPositions() {
|
|
26069
26231
|
const positions = /* @__PURE__ */ new Map();
|
|
26070
|
-
for (const
|
|
26071
|
-
for (const [index, callback] of (
|
|
26072
|
-
positions.set(`${
|
|
26232
|
+
for (const record4 of this.records) {
|
|
26233
|
+
for (const [index, callback] of (record4.callbacks ?? []).entries()) {
|
|
26234
|
+
positions.set(`${record4.id}/callback/${index + 1}`, callback.step);
|
|
26073
26235
|
}
|
|
26074
26236
|
}
|
|
26075
26237
|
return positions;
|
|
26076
26238
|
}
|
|
26077
|
-
retainOutcome(
|
|
26239
|
+
retainOutcome(record4, outcome, budget = this.budget) {
|
|
26078
26240
|
const included = /* @__PURE__ */ new Set();
|
|
26079
26241
|
const size = measureSandboxData(
|
|
26080
26242
|
[outcome.status === "fulfilled" ? outcome.value : outcome.reason],
|
|
26081
26243
|
{ ignoreClosures: true, compileTickets: included }
|
|
26082
26244
|
);
|
|
26083
|
-
const retainedSize = this.retainedSize + size - (this.outcomeSizes.get(
|
|
26245
|
+
const retainedSize = this.retainedSize + size - (this.outcomeSizes.get(record4.id) ?? 0);
|
|
26084
26246
|
budget?.reconcileCompileData(retainedSize, included, included, this);
|
|
26085
26247
|
let copied;
|
|
26086
26248
|
try {
|
|
@@ -26090,14 +26252,14 @@ var HostCallJournal = class {
|
|
|
26090
26252
|
throw error;
|
|
26091
26253
|
}
|
|
26092
26254
|
this.retainedSize = retainedSize;
|
|
26093
|
-
this.outcomeSizes.set(
|
|
26094
|
-
this.outcomes.set(
|
|
26095
|
-
|
|
26255
|
+
this.outcomeSizes.set(record4.id, size);
|
|
26256
|
+
this.outcomes.set(record4.id, copied);
|
|
26257
|
+
record4.outcome = copied;
|
|
26096
26258
|
}
|
|
26097
|
-
replayOutcome(
|
|
26098
|
-
if (!this.recordedReplay ||
|
|
26259
|
+
replayOutcome(record4) {
|
|
26260
|
+
if (!this.recordedReplay || record4.lifecycle !== "settled" && record4.lifecycle !== "consumed")
|
|
26099
26261
|
return void 0;
|
|
26100
|
-
const encoded = this.encodedOutcomes.get(
|
|
26262
|
+
const encoded = this.encodedOutcomes.get(record4.id);
|
|
26101
26263
|
if (encoded !== void 0) {
|
|
26102
26264
|
const budget = this.compileOwner?.budget ?? this.budget;
|
|
26103
26265
|
const operation = budget?.acquireCompileOwner(false, this.compileOwner);
|
|
@@ -26109,29 +26271,29 @@ var HostCallJournal = class {
|
|
|
26109
26271
|
compilation
|
|
26110
26272
|
);
|
|
26111
26273
|
const outcome2 = encoded.status === "fulfilled" ? { status: "fulfilled", value } : { status: "rejected", reason: value };
|
|
26112
|
-
this.retainOutcome(
|
|
26274
|
+
this.retainOutcome(record4, outcome2, budget);
|
|
26113
26275
|
return outcome2;
|
|
26114
26276
|
} finally {
|
|
26115
26277
|
compilation.dispose();
|
|
26116
26278
|
operation?.release();
|
|
26117
26279
|
}
|
|
26118
26280
|
}
|
|
26119
|
-
const outcome = this.outcomes.get(
|
|
26281
|
+
const outcome = this.outcomes.get(record4.id);
|
|
26120
26282
|
return outcome === void 0 ? void 0 : copyOutcome(outcome);
|
|
26121
26283
|
}
|
|
26122
26284
|
snapshotReplay() {
|
|
26123
26285
|
return structuredClone({
|
|
26124
26286
|
version: 1,
|
|
26125
|
-
calls: this.records.map(({ outcome: ignoredOutcome, asynchronous, ...
|
|
26287
|
+
calls: this.records.map(({ outcome: ignoredOutcome, asynchronous, ...record4 }) => {
|
|
26126
26288
|
void ignoredOutcome;
|
|
26127
|
-
const outcome = this.outcomes.get(
|
|
26289
|
+
const outcome = this.outcomes.get(record4.id);
|
|
26128
26290
|
return {
|
|
26129
|
-
...
|
|
26291
|
+
...record4,
|
|
26130
26292
|
asynchronous: asynchronous === true,
|
|
26131
26293
|
...outcome === void 0 ? {} : {
|
|
26132
26294
|
outcome: {
|
|
26133
26295
|
status: outcome.status,
|
|
26134
|
-
data: this.encodedOutcomes.get(
|
|
26296
|
+
data: this.encodedOutcomes.get(record4.id)?.data ?? encodeReplayData(
|
|
26135
26297
|
outcome.status === "fulfilled" ? outcome.value : outcome.reason,
|
|
26136
26298
|
{ identifyCapability: this.identifyCapability }
|
|
26137
26299
|
)
|
|
@@ -26228,79 +26390,79 @@ function restoreReplayCalls(input, encodedOutcomes, callbackSizes, requiredHostC
|
|
|
26228
26390
|
function validateRestoredRecords(records, runId, sourceHash) {
|
|
26229
26391
|
const ids = /* @__PURE__ */ new Set();
|
|
26230
26392
|
let previousOrdinal = 0;
|
|
26231
|
-
for (const
|
|
26232
|
-
if (
|
|
26393
|
+
for (const record4 of records) {
|
|
26394
|
+
if (record4.runId !== runId || !record4.id.startsWith(`${runId}:`)) {
|
|
26233
26395
|
throw new HostCallResumabilityError(
|
|
26234
|
-
|
|
26396
|
+
record4,
|
|
26235
26397
|
"reset",
|
|
26236
|
-
`Host call ${
|
|
26398
|
+
`Host call ${record4.id} does not belong to restored run ${runId}; reset is required.`
|
|
26237
26399
|
);
|
|
26238
26400
|
}
|
|
26239
|
-
if (
|
|
26401
|
+
if (record4.sourceHash !== sourceHash) {
|
|
26240
26402
|
throw new HostCallResumabilityError(
|
|
26241
|
-
|
|
26403
|
+
record4,
|
|
26242
26404
|
"reset",
|
|
26243
|
-
`Host call ${
|
|
26405
|
+
`Host call ${record4.id} does not match the restored source; reset is required.`
|
|
26244
26406
|
);
|
|
26245
26407
|
}
|
|
26246
|
-
if (ids.has(
|
|
26408
|
+
if (ids.has(record4.id)) {
|
|
26247
26409
|
throw new HostCallResumabilityError(
|
|
26248
|
-
|
|
26410
|
+
record4,
|
|
26249
26411
|
"reset",
|
|
26250
|
-
`Host call ${
|
|
26412
|
+
`Host call ${record4.id} appears more than once; reset is required.`
|
|
26251
26413
|
);
|
|
26252
26414
|
}
|
|
26253
|
-
const ordinal = readCallOrdinal(
|
|
26415
|
+
const ordinal = readCallOrdinal(record4);
|
|
26254
26416
|
if (ordinal <= previousOrdinal) {
|
|
26255
26417
|
throw new HostCallResumabilityError(
|
|
26256
|
-
|
|
26418
|
+
record4,
|
|
26257
26419
|
"reset",
|
|
26258
|
-
`Host call ${
|
|
26420
|
+
`Host call ${record4.id} is out of order; reset is required.`
|
|
26259
26421
|
);
|
|
26260
26422
|
}
|
|
26261
26423
|
previousOrdinal = ordinal;
|
|
26262
|
-
ids.add(
|
|
26424
|
+
ids.add(record4.id);
|
|
26263
26425
|
}
|
|
26264
26426
|
}
|
|
26265
|
-
function readCallOrdinal(
|
|
26266
|
-
const ordinal = Number(
|
|
26427
|
+
function readCallOrdinal(record4) {
|
|
26428
|
+
const ordinal = Number(record4.id.slice(record4.id.lastIndexOf(":") + 1));
|
|
26267
26429
|
if (!Number.isSafeInteger(ordinal) || ordinal < 1) {
|
|
26268
26430
|
throw new HostCallResumabilityError(
|
|
26269
|
-
|
|
26431
|
+
record4,
|
|
26270
26432
|
"reset",
|
|
26271
|
-
`Host call ${
|
|
26433
|
+
`Host call ${record4.id} has an invalid ordinal; reset is required.`
|
|
26272
26434
|
);
|
|
26273
26435
|
}
|
|
26274
26436
|
return ordinal;
|
|
26275
26437
|
}
|
|
26276
|
-
function callIdentityMatches(
|
|
26277
|
-
return
|
|
26438
|
+
function callIdentityMatches(record4, input) {
|
|
26439
|
+
return record4.moduleId === input.moduleId && record4.operation === input.operation && record4.argumentDigest === input.argumentDigest && record4.policy === input.policy;
|
|
26278
26440
|
}
|
|
26279
26441
|
function digestHostCallArguments(args) {
|
|
26280
26442
|
return createHash("sha256").update(stableStringify(args)).digest("hex");
|
|
26281
26443
|
}
|
|
26282
|
-
function validateProof(
|
|
26444
|
+
function validateProof(record4, proof) {
|
|
26283
26445
|
if (proof.callbackDisposition !== void 0 && proof.callbackDisposition !== "joined" && proof.callbackDisposition !== "detached") {
|
|
26284
26446
|
throw new HostCallResumabilityError(
|
|
26285
|
-
|
|
26447
|
+
record4,
|
|
26286
26448
|
"external-reconciliation",
|
|
26287
26449
|
"Invalid callbackDisposition in external result proof."
|
|
26288
26450
|
);
|
|
26289
26451
|
}
|
|
26290
26452
|
if (!pendingHostCallResumeIdentityMatches(
|
|
26291
26453
|
{
|
|
26292
|
-
argumentDigest:
|
|
26293
|
-
callId:
|
|
26294
|
-
moduleId:
|
|
26295
|
-
operation:
|
|
26296
|
-
sourceHash:
|
|
26454
|
+
argumentDigest: record4.argumentDigest,
|
|
26455
|
+
callId: record4.id,
|
|
26456
|
+
moduleId: record4.moduleId,
|
|
26457
|
+
operation: record4.operation,
|
|
26458
|
+
sourceHash: record4.sourceHash
|
|
26297
26459
|
},
|
|
26298
26460
|
proof
|
|
26299
26461
|
)) {
|
|
26300
26462
|
throw new HostCallResumabilityError(
|
|
26301
|
-
|
|
26463
|
+
record4,
|
|
26302
26464
|
"external-reconciliation",
|
|
26303
|
-
`External result proof does not match host call ${
|
|
26465
|
+
`External result proof does not match host call ${record4.id}.`
|
|
26304
26466
|
);
|
|
26305
26467
|
}
|
|
26306
26468
|
}
|
|
@@ -26409,7 +26571,7 @@ function hashParsedAst(ast, includeFunctionSource = true) {
|
|
|
26409
26571
|
write(JSON.stringify(value));
|
|
26410
26572
|
return;
|
|
26411
26573
|
case "object": {
|
|
26412
|
-
const
|
|
26574
|
+
const record4 = value;
|
|
26413
26575
|
const source = includeFunctionSource ? functionSources.get(value) : void 0;
|
|
26414
26576
|
if (source !== void 0 && !(enclosingSource !== void 0 && source.text === enclosingSource.text && source.start >= enclosingSource.start && source.end <= enclosingSource.end)) {
|
|
26415
26577
|
write("function-source:");
|
|
@@ -26417,14 +26579,14 @@ function hashParsedAst(ast, includeFunctionSource = true) {
|
|
|
26417
26579
|
write(":");
|
|
26418
26580
|
write(source.text, source.start, source.end);
|
|
26419
26581
|
}
|
|
26420
|
-
const keys = Object.keys(value).filter((key) => shouldHashKey(
|
|
26582
|
+
const keys = Object.keys(value).filter((key) => shouldHashKey(record4, key, includeTemplateRaw)).sort();
|
|
26421
26583
|
write("{");
|
|
26422
26584
|
for (const key of keys) {
|
|
26423
26585
|
write(JSON.stringify(key));
|
|
26424
26586
|
write(":");
|
|
26425
26587
|
visit(
|
|
26426
|
-
|
|
26427
|
-
shouldIncludeTemplateRaw(
|
|
26588
|
+
record4[key],
|
|
26589
|
+
shouldIncludeTemplateRaw(record4, key, includeTemplateRaw),
|
|
26428
26590
|
source ?? enclosingSource
|
|
26429
26591
|
);
|
|
26430
26592
|
write(",");
|
|
@@ -26443,20 +26605,20 @@ function hashParsedAst(ast, includeFunctionSource = true) {
|
|
|
26443
26605
|
}
|
|
26444
26606
|
}
|
|
26445
26607
|
}
|
|
26446
|
-
function shouldHashKey(
|
|
26608
|
+
function shouldHashKey(record4, key, includeTemplateRaw) {
|
|
26447
26609
|
if (key !== "raw") {
|
|
26448
26610
|
return !IGNORED_KEYS.has(key);
|
|
26449
26611
|
}
|
|
26450
|
-
return includeTemplateRaw ||
|
|
26612
|
+
return includeTemplateRaw || record4.type === "RegexLiteral";
|
|
26451
26613
|
}
|
|
26452
|
-
function shouldIncludeTemplateRaw(
|
|
26453
|
-
if (
|
|
26614
|
+
function shouldIncludeTemplateRaw(record4, key, includeTemplateRaw) {
|
|
26615
|
+
if (record4.type === "TaggedTemplateExpression" && key === "quasi") {
|
|
26454
26616
|
return true;
|
|
26455
26617
|
}
|
|
26456
|
-
if (includeTemplateRaw &&
|
|
26618
|
+
if (includeTemplateRaw && record4.type === "TemplateLiteral" && key === "quasis") {
|
|
26457
26619
|
return true;
|
|
26458
26620
|
}
|
|
26459
|
-
if (includeTemplateRaw &&
|
|
26621
|
+
if (includeTemplateRaw && record4.type === "TemplateElement" && key === "value") {
|
|
26460
26622
|
return true;
|
|
26461
26623
|
}
|
|
26462
26624
|
return false;
|
|
@@ -26613,11 +26775,11 @@ function restore(snapshot, options, owner) {
|
|
|
26613
26775
|
for (const entry of Object.values(node)) pending.push(entry);
|
|
26614
26776
|
}
|
|
26615
26777
|
for (const [id, value] of closures) {
|
|
26616
|
-
const
|
|
26617
|
-
if (
|
|
26618
|
-
const origin = functions.get(
|
|
26778
|
+
const record4 = value;
|
|
26779
|
+
if (record4.kind === "guest-array") continue;
|
|
26780
|
+
const origin = functions.get(record4.astNodeId);
|
|
26619
26781
|
try {
|
|
26620
|
-
validateGuestFunctionAst(
|
|
26782
|
+
validateGuestFunctionAst(record4, origin);
|
|
26621
26783
|
} catch (error) {
|
|
26622
26784
|
throw new SnapshotValidationError("invalidValue", `$.heap[${JSON.stringify(id)}].astNodeId`, error instanceof Error ? error.message : String(error));
|
|
26623
26785
|
}
|
|
@@ -38212,8 +38374,8 @@ var RealmState = class {
|
|
|
38212
38374
|
this.assertOpen();
|
|
38213
38375
|
const closure = readGuestCallback(callback, this);
|
|
38214
38376
|
this.checkCollection(this.pendingCallbacks.size + 1, this.limits.callbacks, "pending callback");
|
|
38215
|
-
const
|
|
38216
|
-
this.pendingCallbacks.add(
|
|
38377
|
+
const record4 = { closure };
|
|
38378
|
+
this.pendingCallbacks.add(record4);
|
|
38217
38379
|
const invoke = async () => {
|
|
38218
38380
|
this.assertOpen();
|
|
38219
38381
|
readGuestCallback(callback, this);
|
|
@@ -38254,13 +38416,13 @@ var RealmState = class {
|
|
|
38254
38416
|
)
|
|
38255
38417
|
)
|
|
38256
38418
|
);
|
|
38257
|
-
|
|
38258
|
-
return await
|
|
38419
|
+
record4.promise = active ? pending : this.perform(() => pending);
|
|
38420
|
+
return await record4.promise;
|
|
38259
38421
|
} catch (error) {
|
|
38260
38422
|
if (error instanceof SandboxError) this.poison(error);
|
|
38261
38423
|
throw error;
|
|
38262
38424
|
} finally {
|
|
38263
|
-
this.pendingCallbacks.delete(
|
|
38425
|
+
this.pendingCallbacks.delete(record4);
|
|
38264
38426
|
if (!this.closed && this.active === void 0)
|
|
38265
38427
|
reconcileCompiledValues(
|
|
38266
38428
|
this.budget,
|
|
@@ -39710,7 +39872,7 @@ function readHostCallSnapshot(snapshot) {
|
|
|
39710
39872
|
if (typeof value !== "object" || value === null) {
|
|
39711
39873
|
throw new TypeError(`Snapshot hostCalls[${index}] must be an object.`);
|
|
39712
39874
|
}
|
|
39713
|
-
const
|
|
39875
|
+
const record4 = value;
|
|
39714
39876
|
const requiredStrings = [
|
|
39715
39877
|
"id",
|
|
39716
39878
|
"runId",
|
|
@@ -39720,23 +39882,23 @@ function readHostCallSnapshot(snapshot) {
|
|
|
39720
39882
|
"argumentDigest"
|
|
39721
39883
|
];
|
|
39722
39884
|
for (const key of requiredStrings) {
|
|
39723
|
-
if (typeof
|
|
39885
|
+
if (typeof record4[key] !== "string" || record4[key].length === 0) {
|
|
39724
39886
|
throw new TypeError(`Snapshot hostCalls[${index}].${key} must be a non-empty string.`);
|
|
39725
39887
|
}
|
|
39726
39888
|
}
|
|
39727
|
-
if (
|
|
39889
|
+
if (record4.sourceHash !== snapshot.sourceHash) {
|
|
39728
39890
|
throw new TypeError(`Snapshot hostCalls[${index}].sourceHash must match the snapshot.`);
|
|
39729
39891
|
}
|
|
39730
|
-
if (
|
|
39892
|
+
if (record4.policy !== "re-issue" && record4.policy !== "read-side-effect") {
|
|
39731
39893
|
throw new TypeError(`Snapshot hostCalls[${index}].policy is invalid.`);
|
|
39732
39894
|
}
|
|
39733
|
-
if (
|
|
39895
|
+
if (record4.lifecycle !== "created" && record4.lifecycle !== "running" && record4.lifecycle !== "settled" && record4.lifecycle !== "consumed" && record4.lifecycle !== "cancelled") {
|
|
39734
39896
|
throw new TypeError(`Snapshot hostCalls[${index}].lifecycle is invalid.`);
|
|
39735
39897
|
}
|
|
39736
|
-
if ((
|
|
39898
|
+
if ((record4.lifecycle === "settled" || record4.lifecycle === "cancelled") && record4.outcome === void 0) {
|
|
39737
39899
|
throw new TypeError(`Snapshot hostCalls[${index}].outcome is required.`);
|
|
39738
39900
|
}
|
|
39739
|
-
return
|
|
39901
|
+
return record4;
|
|
39740
39902
|
});
|
|
39741
39903
|
}
|
|
39742
39904
|
function hasLoopIterationSnapshot(snapshot) {
|
|
@@ -39798,4 +39960,4 @@ export {
|
|
|
39798
39960
|
FileSnapshotBackend,
|
|
39799
39961
|
run
|
|
39800
39962
|
};
|
|
39801
|
-
//# sourceMappingURL=chunk-
|
|
39963
|
+
//# sourceMappingURL=chunk-KBUVHGDL.js.map
|