@poe-platform/safe-js 0.1.401 → 0.1.403
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-YFCLIG72.js → chunk-5KXKPBGW.js} +2 -2
- package/dist/safe-js/chunks/{chunk-HDEGJ4AI.js → chunk-DXLKDLGM.js} +173 -72
- package/dist/safe-js/chunks/chunk-DXLKDLGM.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/promise-continuations.d.ts +72 -0
- package/dist/safe-js/snapshot/guest-heap.d.ts +29 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-HDEGJ4AI.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-YFCLIG72.js.map → chunk-5KXKPBGW.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-DXLKDLGM.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8249,4 +8249,4 @@ export {
|
|
|
8249
8249
|
parseMcpConfig,
|
|
8250
8250
|
makeMcpModule
|
|
8251
8251
|
};
|
|
8252
|
-
//# sourceMappingURL=chunk-
|
|
8252
|
+
//# sourceMappingURL=chunk-5KXKPBGW.js.map
|
|
@@ -8812,12 +8812,24 @@ async function flushPromiseJobs() {
|
|
|
8812
8812
|
var promiseStates = /* @__PURE__ */ new WeakMap();
|
|
8813
8813
|
|
|
8814
8814
|
// packages/safe-js/src/interp/promise-continuations.ts
|
|
8815
|
+
var promiseCapabilityExecutors = /* @__PURE__ */ new WeakMap();
|
|
8816
|
+
var promiseAggregateHandlers = /* @__PURE__ */ new WeakMap();
|
|
8817
|
+
var promiseAggregateStates = /* @__PURE__ */ new WeakMap();
|
|
8818
|
+
var promiseAggregateEntries = /* @__PURE__ */ new WeakMap();
|
|
8815
8819
|
var promiseAdoptions = /* @__PURE__ */ new WeakMap();
|
|
8816
8820
|
var promiseAdoptionBridges = /* @__PURE__ */ new WeakMap();
|
|
8817
8821
|
var promiseAdoptionResolvers = /* @__PURE__ */ new WeakMap();
|
|
8818
8822
|
var promiseContinuations = /* @__PURE__ */ new WeakMap();
|
|
8819
8823
|
var promiseReactionResults = /* @__PURE__ */ new WeakMap();
|
|
8820
8824
|
var promiseProducers = /* @__PURE__ */ new WeakMap();
|
|
8825
|
+
function linkPromiseAggregateProducer(producer, aggregate) {
|
|
8826
|
+
const continuation = promiseContinuations.get(producer);
|
|
8827
|
+
if (continuation?.kind !== "reaction") return;
|
|
8828
|
+
continuation.aggregate = aggregate;
|
|
8829
|
+
let producers = promiseProducers.get(aggregate);
|
|
8830
|
+
if (producers === void 0) promiseProducers.set(aggregate, producers = /* @__PURE__ */ new Set());
|
|
8831
|
+
producers.add(producer);
|
|
8832
|
+
}
|
|
8821
8833
|
function trackPromiseContinuation(promise, continuation) {
|
|
8822
8834
|
promiseContinuations.set(promise, continuation);
|
|
8823
8835
|
if (continuation.kind === "reaction") {
|
|
@@ -8842,6 +8854,11 @@ function trackPromiseContinuation(promise, continuation) {
|
|
|
8842
8854
|
producers?.delete(promise);
|
|
8843
8855
|
if (producers?.size === 0) promiseProducers.delete(continuation.capability.promise);
|
|
8844
8856
|
}
|
|
8857
|
+
if (continuation.aggregate !== void 0) {
|
|
8858
|
+
const producers = promiseProducers.get(continuation.aggregate);
|
|
8859
|
+
producers?.delete(promise);
|
|
8860
|
+
if (producers?.size === 0) promiseProducers.delete(continuation.aggregate);
|
|
8861
|
+
}
|
|
8845
8862
|
}
|
|
8846
8863
|
};
|
|
8847
8864
|
promise.promise.then(release, release);
|
|
@@ -21500,19 +21517,8 @@ async function createPromiseCapability(constructor, budget, context) {
|
|
|
21500
21517
|
if (!isSandboxClosure(constructor) || constructor.construct === void 0) {
|
|
21501
21518
|
throw new TypeError("Promise method requires a constructor receiver.");
|
|
21502
21519
|
}
|
|
21503
|
-
|
|
21504
|
-
|
|
21505
|
-
const executor = createSandboxClosure({
|
|
21506
|
-
sandbox: true,
|
|
21507
|
-
retainedValues: () => [resolve, reject],
|
|
21508
|
-
call: (args) => {
|
|
21509
|
-
if (resolve !== void 0 || reject !== void 0) {
|
|
21510
|
-
throw new TypeError("Promise capability is already initialized.");
|
|
21511
|
-
}
|
|
21512
|
-
[resolve, reject] = args;
|
|
21513
|
-
return void 0;
|
|
21514
|
-
}
|
|
21515
|
-
});
|
|
21520
|
+
const state = { resolve: void 0, reject: void 0 };
|
|
21521
|
+
const executor = createPromiseCapabilityExecutor(state);
|
|
21516
21522
|
const leaveCall = budget.enterCall();
|
|
21517
21523
|
try {
|
|
21518
21524
|
const promise = await constructor.construct([executor], {
|
|
@@ -21521,6 +21527,7 @@ async function createPromiseCapability(constructor, budget, context) {
|
|
|
21521
21527
|
thisValue: void 0,
|
|
21522
21528
|
newTarget: constructor
|
|
21523
21529
|
});
|
|
21530
|
+
const { resolve, reject } = state;
|
|
21524
21531
|
if (!isSandboxClosure(resolve) || !isSandboxClosure(reject)) {
|
|
21525
21532
|
throw new TypeError("Promise capability requires callable resolve and reject functions.");
|
|
21526
21533
|
}
|
|
@@ -21529,6 +21536,24 @@ async function createPromiseCapability(constructor, budget, context) {
|
|
|
21529
21536
|
leaveCall();
|
|
21530
21537
|
}
|
|
21531
21538
|
}
|
|
21539
|
+
function createPromiseCapabilityExecutor(state) {
|
|
21540
|
+
const executor = createSandboxClosure({
|
|
21541
|
+
sandbox: true,
|
|
21542
|
+
guest: true,
|
|
21543
|
+
name: "",
|
|
21544
|
+
length: 2,
|
|
21545
|
+
retainedValues: () => [state.resolve, state.reject],
|
|
21546
|
+
call: ([resolve, reject]) => {
|
|
21547
|
+
if (state.resolve !== void 0 || state.reject !== void 0)
|
|
21548
|
+
throw new TypeError("Promise capability is already initialized.");
|
|
21549
|
+
state.resolve = resolve;
|
|
21550
|
+
state.reject = reject;
|
|
21551
|
+
return void 0;
|
|
21552
|
+
}
|
|
21553
|
+
});
|
|
21554
|
+
promiseCapabilityExecutors.set(executor, state);
|
|
21555
|
+
return executor;
|
|
21556
|
+
}
|
|
21532
21557
|
async function callPromiseClosure(callback, args, thisValue, budget, context) {
|
|
21533
21558
|
const leaveCall = budget.enterCall();
|
|
21534
21559
|
try {
|
|
@@ -21757,34 +21782,9 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21757
21782
|
const prototype = getPromisePrototype(budget);
|
|
21758
21783
|
if (isSandboxPromise(capability.promise)) unrepresentedPromiseContinuations.add(capability.promise);
|
|
21759
21784
|
const values = [];
|
|
21760
|
-
|
|
21761
|
-
|
|
21762
|
-
|
|
21763
|
-
if (method === "any") {
|
|
21764
|
-
const error = createSubsetErrorValue(
|
|
21765
|
-
"AggregateError",
|
|
21766
|
-
"All promises were rejected",
|
|
21767
|
-
[],
|
|
21768
|
-
budget
|
|
21769
|
-
);
|
|
21770
|
-
error.errors = values;
|
|
21771
|
-
await callPromiseClosure(
|
|
21772
|
-
capability.reject,
|
|
21773
|
-
[budgetSandboxValue2(error, budget)],
|
|
21774
|
-
void 0,
|
|
21775
|
-
budget,
|
|
21776
|
-
context
|
|
21777
|
-
);
|
|
21778
|
-
} else {
|
|
21779
|
-
await callPromiseClosure(
|
|
21780
|
-
capability.resolve,
|
|
21781
|
-
[budgetSandboxValue2(values, budget)],
|
|
21782
|
-
void 0,
|
|
21783
|
-
budget,
|
|
21784
|
-
context
|
|
21785
|
-
);
|
|
21786
|
-
}
|
|
21787
|
-
};
|
|
21785
|
+
const aggregate = { method, capability, values, remaining: 1, size: 0, iteration: "active" };
|
|
21786
|
+
promiseAggregateStates.set(aggregate, aggregate);
|
|
21787
|
+
let represented = true;
|
|
21788
21788
|
try {
|
|
21789
21789
|
const promiseResolve = await readPromiseReceiverProperty(constructor, "resolve", prototype, context);
|
|
21790
21790
|
if (!isSandboxClosure(promiseResolve))
|
|
@@ -21793,7 +21793,6 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21793
21793
|
if (iterator === void 0) throw new TypeError("Promise helpers require an iterable.");
|
|
21794
21794
|
const releaseIterator = retainValues(budget, () => [iterator.retainedValue]);
|
|
21795
21795
|
try {
|
|
21796
|
-
let index = 0;
|
|
21797
21796
|
while (true) {
|
|
21798
21797
|
budget.visitNode();
|
|
21799
21798
|
const next = iterator.generator || iterator.asynchronous ? await iterator.next() : iterator.next();
|
|
@@ -21802,8 +21801,8 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21802
21801
|
if ((await readIteratorResult(iterator, next, "done")).value) break;
|
|
21803
21802
|
const value = (await readIteratorResult(iterator, next, "value")).value;
|
|
21804
21803
|
try {
|
|
21805
|
-
budget.allocateArrayLength(
|
|
21806
|
-
const entryIndex =
|
|
21804
|
+
budget.allocateArrayLength(aggregate.size + 1);
|
|
21805
|
+
const entryIndex = aggregate.size++;
|
|
21807
21806
|
if (method !== "race") values.push(void 0);
|
|
21808
21807
|
const entry = await callPromiseClosure(
|
|
21809
21808
|
promiseResolve,
|
|
@@ -21812,45 +21811,41 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21812
21811
|
budget,
|
|
21813
21812
|
context
|
|
21814
21813
|
);
|
|
21815
|
-
|
|
21814
|
+
const aggregateEntry = { aggregate, index: entryIndex, called: false };
|
|
21816
21815
|
const handlers = ["fulfilled", "rejected"].map((state) => {
|
|
21817
21816
|
if (method === "race" || method === "any" && state === "fulfilled")
|
|
21818
21817
|
return state === "fulfilled" ? capability.resolve : capability.reject;
|
|
21819
21818
|
if (method === "all" && state === "rejected") return capability.reject;
|
|
21820
|
-
return
|
|
21821
|
-
sandbox: true,
|
|
21822
|
-
retainedValues: () => [
|
|
21823
|
-
capability.promise,
|
|
21824
|
-
capability.resolve,
|
|
21825
|
-
capability.reject,
|
|
21826
|
-
values
|
|
21827
|
-
],
|
|
21828
|
-
call: async ([settlement]) => {
|
|
21829
|
-
if (called) return void 0;
|
|
21830
|
-
called = true;
|
|
21831
|
-
values[entryIndex] = method === "allSettled" ? state === "fulfilled" ? { status: state, value: settlement } : { status: state, reason: settlement } : settlement;
|
|
21832
|
-
remaining--;
|
|
21833
|
-
await complete2();
|
|
21834
|
-
return void 0;
|
|
21835
|
-
}
|
|
21836
|
-
});
|
|
21819
|
+
return createPromiseAggregateHandler(aggregateEntry, state, budget, context);
|
|
21837
21820
|
});
|
|
21838
|
-
remaining++;
|
|
21821
|
+
aggregate.remaining++;
|
|
21839
21822
|
const then = await readPromiseProperty(entry, "then", prototype, budget, context);
|
|
21840
21823
|
if (!isSandboxClosure(then))
|
|
21841
21824
|
throw new TypeError("Promise resolver result requires a callable then.");
|
|
21842
|
-
|
|
21825
|
+
const previousReactions = isSandboxPromise(entry) ? new Set(promiseReactionResults.get(entry)) : void 0;
|
|
21826
|
+
const completion = await callPromiseClosure(then, handlers, entry, budget, context);
|
|
21827
|
+
if (!intrinsicPromiseThenMethods.has(then) || !isSandboxPromise(entry) || !isSandboxPromise(completion)) represented = false;
|
|
21828
|
+
else if (isSandboxPromise(capability.promise)) {
|
|
21829
|
+
for (const producer of promiseReactionResults.get(entry) ?? []) {
|
|
21830
|
+
const reaction = promiseContinuations.get(producer);
|
|
21831
|
+
if (!previousReactions?.has(producer) && reaction?.kind === "reaction" && reaction.onFulfilled === handlers[0] && reaction.onRejected === handlers[1])
|
|
21832
|
+
linkPromiseAggregateProducer(producer, capability.promise);
|
|
21833
|
+
}
|
|
21834
|
+
}
|
|
21843
21835
|
} catch (error) {
|
|
21844
21836
|
await closeIterator(iterator, true);
|
|
21845
21837
|
throw error;
|
|
21846
21838
|
}
|
|
21847
21839
|
}
|
|
21848
|
-
remaining--;
|
|
21849
|
-
|
|
21840
|
+
aggregate.remaining--;
|
|
21841
|
+
aggregate.iteration = "complete";
|
|
21842
|
+
await completePromiseAggregate(aggregate, budget, context);
|
|
21843
|
+
if (represented && isSandboxPromise(capability.promise)) unrepresentedPromiseContinuations.delete(capability.promise);
|
|
21850
21844
|
} finally {
|
|
21851
21845
|
releaseIterator();
|
|
21852
21846
|
}
|
|
21853
21847
|
} catch (error) {
|
|
21848
|
+
aggregate.iteration = "abrupt";
|
|
21854
21849
|
if (error instanceof SandboxError && (error.code === "budgetExceeded" || error.code === "reentry")) {
|
|
21855
21850
|
if (isSandboxPromise(capability.promise)) observeSandboxPromise(capability.promise);
|
|
21856
21851
|
throw error;
|
|
@@ -21865,6 +21860,39 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21865
21860
|
}
|
|
21866
21861
|
return capability.promise;
|
|
21867
21862
|
}
|
|
21863
|
+
async function completePromiseAggregate(aggregate, budget, context) {
|
|
21864
|
+
const { method, capability, values, remaining } = aggregate;
|
|
21865
|
+
if (remaining !== 0 || method === "race") return;
|
|
21866
|
+
if (method === "any") {
|
|
21867
|
+
const error = createSubsetErrorValue("AggregateError", "All promises were rejected", [], budget);
|
|
21868
|
+
error.errors = values;
|
|
21869
|
+
await callPromiseClosure(capability.reject, [budgetSandboxValue2(error, budget)], void 0, budget, context);
|
|
21870
|
+
} else {
|
|
21871
|
+
await callPromiseClosure(capability.resolve, [budgetSandboxValue2(values, budget)], void 0, budget, context);
|
|
21872
|
+
}
|
|
21873
|
+
}
|
|
21874
|
+
function createPromiseAggregateHandler(entry, action, budget, context) {
|
|
21875
|
+
const { aggregate } = entry;
|
|
21876
|
+
promiseAggregateEntries.set(entry, entry);
|
|
21877
|
+
const handler = createSandboxClosure({
|
|
21878
|
+
sandbox: true,
|
|
21879
|
+
guest: true,
|
|
21880
|
+
name: "",
|
|
21881
|
+
length: 1,
|
|
21882
|
+
retainedValues: () => [aggregate.capability.promise, aggregate.capability.resolve, aggregate.capability.reject, aggregate.values],
|
|
21883
|
+
call: async ([settlement]) => {
|
|
21884
|
+
if (entry.called) return void 0;
|
|
21885
|
+
entry.called = true;
|
|
21886
|
+
const { method, values } = aggregate;
|
|
21887
|
+
values[entry.index] = method === "allSettled" ? action === "fulfilled" ? { status: action, value: settlement } : { status: action, reason: settlement } : settlement;
|
|
21888
|
+
aggregate.remaining--;
|
|
21889
|
+
await completePromiseAggregate(aggregate, budget, context);
|
|
21890
|
+
return void 0;
|
|
21891
|
+
}
|
|
21892
|
+
});
|
|
21893
|
+
promiseAggregateHandlers.set(handler, { entry, action });
|
|
21894
|
+
return handler;
|
|
21895
|
+
}
|
|
21868
21896
|
function schedulePromise(promise, budget) {
|
|
21869
21897
|
return Promise.resolve().then(
|
|
21870
21898
|
() => promise.then(
|
|
@@ -22340,6 +22368,32 @@ function serializeCollectionProperties(value, encode, dataOnly = false) {
|
|
|
22340
22368
|
|
|
22341
22369
|
// packages/safe-js/src/snapshot/guest-heap.ts
|
|
22342
22370
|
function captureGuestHeapNode(value, encode) {
|
|
22371
|
+
const executor = isSandboxClosure(value) ? promiseCapabilityExecutors.get(value) : void 0;
|
|
22372
|
+
if (executor !== void 0)
|
|
22373
|
+
return { kind: "capability-executor", resolve: encode(executor.resolve), reject: encode(executor.reject), state: captureObjectState(value, encode) };
|
|
22374
|
+
const aggregate = promiseAggregateStates.get(value);
|
|
22375
|
+
if (aggregate !== void 0) {
|
|
22376
|
+
if (aggregate.iteration === "active") throw new TypeError("Cannot snapshot an active promise aggregate iterator.");
|
|
22377
|
+
return {
|
|
22378
|
+
kind: "promise-aggregate",
|
|
22379
|
+
method: aggregate.method,
|
|
22380
|
+
remaining: aggregate.remaining,
|
|
22381
|
+
size: aggregate.size,
|
|
22382
|
+
iteration: aggregate.iteration,
|
|
22383
|
+
values: encode(aggregate.values),
|
|
22384
|
+
capability: {
|
|
22385
|
+
promise: encode(aggregate.capability.promise),
|
|
22386
|
+
resolve: encode(aggregate.capability.resolve),
|
|
22387
|
+
reject: encode(aggregate.capability.reject)
|
|
22388
|
+
}
|
|
22389
|
+
};
|
|
22390
|
+
}
|
|
22391
|
+
const aggregateEntry = promiseAggregateEntries.get(value);
|
|
22392
|
+
if (aggregateEntry !== void 0)
|
|
22393
|
+
return { kind: "aggregate-entry", aggregate: encode(aggregateEntry.aggregate), index: aggregateEntry.index, called: aggregateEntry.called };
|
|
22394
|
+
const aggregateHandler = isSandboxClosure(value) ? promiseAggregateHandlers.get(value) : void 0;
|
|
22395
|
+
if (aggregateHandler !== void 0)
|
|
22396
|
+
return { kind: "aggregate-handler", entry: encode(aggregateHandler.entry), action: aggregateHandler.action, state: captureObjectState(value, encode) };
|
|
22343
22397
|
const bridge = promiseAdoptionBridges.get(value);
|
|
22344
22398
|
if (bridge !== void 0) {
|
|
22345
22399
|
if (bridge.settled || bridge.owner === void 0) return void 0;
|
|
@@ -22391,6 +22445,7 @@ function captureGuestHeapNode(value, encode) {
|
|
|
22391
22445
|
kind: "promise-reaction",
|
|
22392
22446
|
source: encode(continuation.source),
|
|
22393
22447
|
...producerState,
|
|
22448
|
+
...continuation.aggregate === void 0 ? {} : { aggregate: encode(continuation.aggregate) },
|
|
22394
22449
|
...continuation.capability === void 0 ? {} : { capability: {
|
|
22395
22450
|
promise: encode(continuation.capability.promise),
|
|
22396
22451
|
resolve: encode(continuation.capability.resolve),
|
|
@@ -27858,7 +27913,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27858
27913
|
createRawJson(node.text);
|
|
27859
27914
|
return true;
|
|
27860
27915
|
}
|
|
27861
|
-
if (!["intrinsic", "bound-function", "promise-resolver", "pending-promise", "promise-reaction", "promise-adoption", "adoption-resolver", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-regex", "guest-promise", "array-iterator", "string-iterator", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
27916
|
+
if (!["capability-executor", "promise-aggregate", "aggregate-entry", "aggregate-handler", "intrinsic", "bound-function", "promise-resolver", "pending-promise", "promise-reaction", "promise-adoption", "adoption-resolver", "guest-function", "guest-class", "guest-generator", "scope-frame", "guest-object", "guest-array", "guest-boxed", "guest-date", "guest-regex", "guest-promise", "array-iterator", "string-iterator", "iterator-wrapper", "iterator-helper", "guest-collection-iterator", "guest-regexp-iterator", "map", "set"].includes(String(node.kind))) return false;
|
|
27862
27917
|
const reference = (value, kinds) => {
|
|
27863
27918
|
const ref = record3(value);
|
|
27864
27919
|
fields(ref, ["kind", "id"]);
|
|
@@ -27869,7 +27924,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27869
27924
|
};
|
|
27870
27925
|
const callable = (value) => {
|
|
27871
27926
|
if (absent(value)) return;
|
|
27872
|
-
const target = reference(value, ["intrinsic", "bound-function", "promise-resolver", "guest-function", "guest-class"]);
|
|
27927
|
+
const target = reference(value, ["capability-executor", "intrinsic", "bound-function", "promise-resolver", "guest-function", "guest-class"]);
|
|
27873
27928
|
if (target.kind === "intrinsic" && intrinsicCatalogue().get(String(target.id)) !== true)
|
|
27874
27929
|
throw new TypeError("Guest accessor reference is not callable.");
|
|
27875
27930
|
};
|
|
@@ -27934,7 +27989,9 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27934
27989
|
const producers = /* @__PURE__ */ new Set();
|
|
27935
27990
|
for (const entry of array(node.producers)) {
|
|
27936
27991
|
const producer = reference(entry, ["promise-reaction"]);
|
|
27937
|
-
|
|
27992
|
+
const capabilityOwner = producer.capability === void 0 ? void 0 : reference(record3(producer.capability).promise);
|
|
27993
|
+
const aggregateOwner = producer.aggregate === void 0 ? void 0 : reference(producer.aggregate);
|
|
27994
|
+
if (producers.has(producer) || capabilityOwner !== node && aggregateOwner !== node)
|
|
27938
27995
|
throw new TypeError("Invalid promise producer ownership.");
|
|
27939
27996
|
producers.add(producer);
|
|
27940
27997
|
}
|
|
@@ -27948,7 +28005,33 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27948
28005
|
});
|
|
27949
28006
|
return false;
|
|
27950
28007
|
}
|
|
27951
|
-
if (node.kind === "
|
|
28008
|
+
if (node.kind === "capability-executor") {
|
|
28009
|
+
fields(node, ["kind", "resolve", "reject", "state"]);
|
|
28010
|
+
state(node.state);
|
|
28011
|
+
} else if (node.kind === "promise-aggregate") {
|
|
28012
|
+
fields(node, ["kind", "method", "capability", "values", "remaining", "size", "iteration"]);
|
|
28013
|
+
if (!["all", "allSettled", "race", "any"].includes(String(node.method))) throw new TypeError("Invalid promise aggregate method.");
|
|
28014
|
+
const size = integer(node.size);
|
|
28015
|
+
if (size > maxArrayLength || node.iteration !== "complete" && node.iteration !== "abrupt") throw new TypeError("Invalid promise aggregate iteration.");
|
|
28016
|
+
if (integer(node.remaining) > size + (node.iteration === "abrupt" ? 1 : 0)) throw new TypeError("Invalid promise aggregate remaining count.");
|
|
28017
|
+
reference(node.values, ["array", "guest-array"]);
|
|
28018
|
+
const capability = record3(node.capability);
|
|
28019
|
+
fields(capability, ["promise", "resolve", "reject"]);
|
|
28020
|
+
if (absent(capability.resolve) || absent(capability.reject)) throw new TypeError("Missing promise aggregate resolver.");
|
|
28021
|
+
callable(capability.resolve);
|
|
28022
|
+
callable(capability.reject);
|
|
28023
|
+
} else if (node.kind === "aggregate-entry") {
|
|
28024
|
+
fields(node, ["kind", "aggregate", "index", "called"]);
|
|
28025
|
+
const aggregate = reference(node.aggregate, ["promise-aggregate"]);
|
|
28026
|
+
if (integer(node.index) >= integer(aggregate.size) || typeof node.called !== "boolean") throw new TypeError("Invalid promise aggregate entry.");
|
|
28027
|
+
} else if (node.kind === "aggregate-handler") {
|
|
28028
|
+
fields(node, ["kind", "entry", "action", "state"]);
|
|
28029
|
+
state(node.state);
|
|
28030
|
+
const entry = reference(node.entry, ["aggregate-entry"]);
|
|
28031
|
+
const aggregate = reference(entry.aggregate, ["promise-aggregate"]);
|
|
28032
|
+
if (node.action !== "fulfilled" && node.action !== "rejected" || aggregate.method === "all" && node.action !== "fulfilled" || aggregate.method === "any" && node.action !== "rejected" || aggregate.method === "race")
|
|
28033
|
+
throw new TypeError("Invalid promise aggregate handler action.");
|
|
28034
|
+
} else if (node.kind === "promise-adoption") {
|
|
27952
28035
|
fields(node, ["kind", "owner", "source"]);
|
|
27953
28036
|
const owner = reference(node.owner, ["pending-promise"]);
|
|
27954
28037
|
if (reference(owner.adoption, ["promise-adoption"]) !== node) throw new TypeError("Invalid promise adoption owner.");
|
|
@@ -27980,12 +28063,29 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27980
28063
|
throw new TypeError("Invalid promise resolver action.");
|
|
27981
28064
|
state(node.state);
|
|
27982
28065
|
} else if (node.kind === "pending-promise" || node.kind === "promise-reaction") {
|
|
27983
|
-
fields(node, node.kind === "pending-promise" ? ["kind", "reactions", "state"] : ["kind", "source", "onFulfilled", "onRejected", "reactions", "state"], node.kind === "pending-promise" ? ["adoption", "producers"] : ["capability", "producers"]);
|
|
28066
|
+
fields(node, node.kind === "pending-promise" ? ["kind", "reactions", "state"] : ["kind", "source", "onFulfilled", "onRejected", "reactions", "state"], node.kind === "pending-promise" ? ["adoption", "producers"] : ["capability", "aggregate", "producers"]);
|
|
27984
28067
|
if (node.kind === "pending-promise" && Object.hasOwn(node, "adoption")) {
|
|
27985
28068
|
const bridge = reference(node.adoption, ["promise-adoption"]);
|
|
27986
28069
|
if (reference(bridge.owner, ["pending-promise"]) !== node) throw new TypeError("Invalid promise adoption owner.");
|
|
27987
28070
|
}
|
|
27988
28071
|
if (node.kind === "promise-reaction") {
|
|
28072
|
+
if (Object.hasOwn(node, "aggregate")) {
|
|
28073
|
+
const aggregate = reference(node.aggregate, ["pending-promise", "guest-promise", "promise-reaction"]);
|
|
28074
|
+
if (aggregate === node || !Array.isArray(aggregate.producers) || !aggregate.producers.some((entry) => reference(entry, ["promise-reaction"]) === node))
|
|
28075
|
+
throw new TypeError("Invalid promise aggregate producer ownership.");
|
|
28076
|
+
for (const value of [node.onFulfilled, node.onRejected]) {
|
|
28077
|
+
if (absent(value)) continue;
|
|
28078
|
+
const handler = reference(value);
|
|
28079
|
+
let owner;
|
|
28080
|
+
if (handler.kind === "promise-resolver") owner = reference(handler.promise);
|
|
28081
|
+
else if (handler.kind === "aggregate-handler") {
|
|
28082
|
+
const entry = reference(handler.entry, ["aggregate-entry"]);
|
|
28083
|
+
const state2 = reference(entry.aggregate, ["promise-aggregate"]);
|
|
28084
|
+
owner = reference(record3(state2.capability).promise);
|
|
28085
|
+
}
|
|
28086
|
+
if (owner !== void 0 && owner !== aggregate) throw new TypeError("Invalid promise aggregate handler ownership.");
|
|
28087
|
+
}
|
|
28088
|
+
}
|
|
27989
28089
|
if (Object.hasOwn(node, "capability")) {
|
|
27990
28090
|
const capability = record3(node.capability);
|
|
27991
28091
|
fields(capability, ["promise", "resolve", "reject"]);
|
|
@@ -30255,6 +30355,7 @@ function measureSandboxData(values, options = {}) {
|
|
|
30255
30355
|
visit(continuation.capability.resolve, depth + 1);
|
|
30256
30356
|
visit(continuation.capability.reject, depth + 1);
|
|
30257
30357
|
}
|
|
30358
|
+
if (continuation.aggregate !== void 0) visit(continuation.aggregate, depth + 1);
|
|
30258
30359
|
}
|
|
30259
30360
|
for (const reaction of promiseReactionResults.get(value) ?? []) visit(reaction, depth + 1);
|
|
30260
30361
|
for (const producer of promiseProducers.get(value) ?? []) visit(producer, depth + 1);
|
|
@@ -45273,4 +45374,4 @@ export {
|
|
|
45273
45374
|
FileSnapshotBackend,
|
|
45274
45375
|
run
|
|
45275
45376
|
};
|
|
45276
|
-
//# sourceMappingURL=chunk-
|
|
45377
|
+
//# sourceMappingURL=chunk-DXLKDLGM.js.map
|