@poe-platform/safe-js 0.1.400 → 0.1.402
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-ETP3MEHS.js → chunk-3DXEWN6Z.js} +2 -2
- package/dist/safe-js/chunks/{chunk-L5I53V56.js → chunk-5RNME7ZM.js} +203 -61
- package/dist/safe-js/chunks/chunk-5RNME7ZM.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 +67 -0
- package/dist/safe-js/snapshot/guest-heap.d.ts +32 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-L5I53V56.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-ETP3MEHS.js.map → chunk-3DXEWN6Z.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-5RNME7ZM.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-3DXEWN6Z.js.map
|
|
@@ -8812,17 +8812,34 @@ async function flushPromiseJobs() {
|
|
|
8812
8812
|
var promiseStates = /* @__PURE__ */ new WeakMap();
|
|
8813
8813
|
|
|
8814
8814
|
// packages/safe-js/src/interp/promise-continuations.ts
|
|
8815
|
+
var promiseAggregateHandlers = /* @__PURE__ */ new WeakMap();
|
|
8816
|
+
var promiseAggregateStates = /* @__PURE__ */ new WeakMap();
|
|
8817
|
+
var promiseAggregateEntries = /* @__PURE__ */ new WeakMap();
|
|
8815
8818
|
var promiseAdoptions = /* @__PURE__ */ new WeakMap();
|
|
8816
8819
|
var promiseAdoptionBridges = /* @__PURE__ */ new WeakMap();
|
|
8817
8820
|
var promiseAdoptionResolvers = /* @__PURE__ */ new WeakMap();
|
|
8818
8821
|
var promiseContinuations = /* @__PURE__ */ new WeakMap();
|
|
8819
8822
|
var promiseReactionResults = /* @__PURE__ */ new WeakMap();
|
|
8823
|
+
var promiseProducers = /* @__PURE__ */ new WeakMap();
|
|
8824
|
+
function linkPromiseAggregateProducer(producer, aggregate) {
|
|
8825
|
+
const continuation = promiseContinuations.get(producer);
|
|
8826
|
+
if (continuation?.kind !== "reaction") return;
|
|
8827
|
+
continuation.aggregate = aggregate;
|
|
8828
|
+
let producers = promiseProducers.get(aggregate);
|
|
8829
|
+
if (producers === void 0) promiseProducers.set(aggregate, producers = /* @__PURE__ */ new Set());
|
|
8830
|
+
producers.add(producer);
|
|
8831
|
+
}
|
|
8820
8832
|
function trackPromiseContinuation(promise, continuation) {
|
|
8821
8833
|
promiseContinuations.set(promise, continuation);
|
|
8822
8834
|
if (continuation.kind === "reaction") {
|
|
8823
8835
|
let results = promiseReactionResults.get(continuation.source);
|
|
8824
8836
|
if (results === void 0) promiseReactionResults.set(continuation.source, results = /* @__PURE__ */ new Set());
|
|
8825
8837
|
results.add(promise);
|
|
8838
|
+
if (continuation.capability !== void 0) {
|
|
8839
|
+
let producers = promiseProducers.get(continuation.capability.promise);
|
|
8840
|
+
if (producers === void 0) promiseProducers.set(continuation.capability.promise, producers = /* @__PURE__ */ new Set());
|
|
8841
|
+
producers.add(promise);
|
|
8842
|
+
}
|
|
8826
8843
|
}
|
|
8827
8844
|
const release = () => {
|
|
8828
8845
|
promiseContinuations.delete(promise);
|
|
@@ -8831,6 +8848,16 @@ function trackPromiseContinuation(promise, continuation) {
|
|
|
8831
8848
|
const results = promiseReactionResults.get(continuation.source);
|
|
8832
8849
|
results?.delete(promise);
|
|
8833
8850
|
if (results?.size === 0) promiseReactionResults.delete(continuation.source);
|
|
8851
|
+
if (continuation.capability !== void 0) {
|
|
8852
|
+
const producers = promiseProducers.get(continuation.capability.promise);
|
|
8853
|
+
producers?.delete(promise);
|
|
8854
|
+
if (producers?.size === 0) promiseProducers.delete(continuation.capability.promise);
|
|
8855
|
+
}
|
|
8856
|
+
if (continuation.aggregate !== void 0) {
|
|
8857
|
+
const producers = promiseProducers.get(continuation.aggregate);
|
|
8858
|
+
producers?.delete(promise);
|
|
8859
|
+
if (producers?.size === 0) promiseProducers.delete(continuation.aggregate);
|
|
8860
|
+
}
|
|
8834
8861
|
}
|
|
8835
8862
|
};
|
|
8836
8863
|
promise.promise.then(release, release);
|
|
@@ -21549,18 +21576,28 @@ function getPromisePrototype(budget) {
|
|
|
21549
21576
|
const finish = (constructor2) => {
|
|
21550
21577
|
if (!isSandboxPromiseConstructor(constructor2)) {
|
|
21551
21578
|
return createPromiseCapability(constructor2, budget, context).then((capability) => {
|
|
21552
|
-
|
|
21553
|
-
|
|
21554
|
-
|
|
21579
|
+
observeSandboxPromise(target, isSandboxPromise(capability.promise));
|
|
21580
|
+
const continuation2 = isSandboxPromise(capability.promise) ? {
|
|
21581
|
+
kind: "reaction",
|
|
21582
|
+
phase: "waiting",
|
|
21583
|
+
source: target,
|
|
21584
|
+
onFulfilled,
|
|
21585
|
+
onRejected,
|
|
21586
|
+
capability: { ...capability, promise: capability.promise }
|
|
21587
|
+
} : void 0;
|
|
21588
|
+
const completion = createSandboxPromise(target.promise.then(
|
|
21555
21589
|
(value) => {
|
|
21590
|
+
if (continuation2 !== void 0) continuation2.phase = "running";
|
|
21556
21591
|
consumeSettledHostCall(target);
|
|
21557
21592
|
return runCapabilityReaction(onFulfilled, value, "fulfilled", capability, budget, context);
|
|
21558
21593
|
},
|
|
21559
21594
|
(reason) => {
|
|
21595
|
+
if (continuation2 !== void 0) continuation2.phase = "running";
|
|
21560
21596
|
consumeSettledHostCall(target);
|
|
21561
21597
|
return runCapabilityReaction(onRejected, reason, "rejected", capability, budget, context);
|
|
21562
21598
|
}
|
|
21563
21599
|
));
|
|
21600
|
+
if (continuation2 !== void 0) trackPromiseContinuation(completion, continuation2);
|
|
21564
21601
|
return capability.promise;
|
|
21565
21602
|
});
|
|
21566
21603
|
}
|
|
@@ -21736,34 +21773,9 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21736
21773
|
const prototype = getPromisePrototype(budget);
|
|
21737
21774
|
if (isSandboxPromise(capability.promise)) unrepresentedPromiseContinuations.add(capability.promise);
|
|
21738
21775
|
const values = [];
|
|
21739
|
-
|
|
21740
|
-
|
|
21741
|
-
|
|
21742
|
-
if (method === "any") {
|
|
21743
|
-
const error = createSubsetErrorValue(
|
|
21744
|
-
"AggregateError",
|
|
21745
|
-
"All promises were rejected",
|
|
21746
|
-
[],
|
|
21747
|
-
budget
|
|
21748
|
-
);
|
|
21749
|
-
error.errors = values;
|
|
21750
|
-
await callPromiseClosure(
|
|
21751
|
-
capability.reject,
|
|
21752
|
-
[budgetSandboxValue2(error, budget)],
|
|
21753
|
-
void 0,
|
|
21754
|
-
budget,
|
|
21755
|
-
context
|
|
21756
|
-
);
|
|
21757
|
-
} else {
|
|
21758
|
-
await callPromiseClosure(
|
|
21759
|
-
capability.resolve,
|
|
21760
|
-
[budgetSandboxValue2(values, budget)],
|
|
21761
|
-
void 0,
|
|
21762
|
-
budget,
|
|
21763
|
-
context
|
|
21764
|
-
);
|
|
21765
|
-
}
|
|
21766
|
-
};
|
|
21776
|
+
const aggregate = { method, capability, values, remaining: 1, size: 0, iteration: "active" };
|
|
21777
|
+
promiseAggregateStates.set(aggregate, aggregate);
|
|
21778
|
+
let represented = true;
|
|
21767
21779
|
try {
|
|
21768
21780
|
const promiseResolve = await readPromiseReceiverProperty(constructor, "resolve", prototype, context);
|
|
21769
21781
|
if (!isSandboxClosure(promiseResolve))
|
|
@@ -21772,7 +21784,6 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21772
21784
|
if (iterator === void 0) throw new TypeError("Promise helpers require an iterable.");
|
|
21773
21785
|
const releaseIterator = retainValues(budget, () => [iterator.retainedValue]);
|
|
21774
21786
|
try {
|
|
21775
|
-
let index = 0;
|
|
21776
21787
|
while (true) {
|
|
21777
21788
|
budget.visitNode();
|
|
21778
21789
|
const next = iterator.generator || iterator.asynchronous ? await iterator.next() : iterator.next();
|
|
@@ -21781,8 +21792,8 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21781
21792
|
if ((await readIteratorResult(iterator, next, "done")).value) break;
|
|
21782
21793
|
const value = (await readIteratorResult(iterator, next, "value")).value;
|
|
21783
21794
|
try {
|
|
21784
|
-
budget.allocateArrayLength(
|
|
21785
|
-
const entryIndex =
|
|
21795
|
+
budget.allocateArrayLength(aggregate.size + 1);
|
|
21796
|
+
const entryIndex = aggregate.size++;
|
|
21786
21797
|
if (method !== "race") values.push(void 0);
|
|
21787
21798
|
const entry = await callPromiseClosure(
|
|
21788
21799
|
promiseResolve,
|
|
@@ -21791,45 +21802,41 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21791
21802
|
budget,
|
|
21792
21803
|
context
|
|
21793
21804
|
);
|
|
21794
|
-
|
|
21805
|
+
const aggregateEntry = { aggregate, index: entryIndex, called: false };
|
|
21795
21806
|
const handlers = ["fulfilled", "rejected"].map((state) => {
|
|
21796
21807
|
if (method === "race" || method === "any" && state === "fulfilled")
|
|
21797
21808
|
return state === "fulfilled" ? capability.resolve : capability.reject;
|
|
21798
21809
|
if (method === "all" && state === "rejected") return capability.reject;
|
|
21799
|
-
return
|
|
21800
|
-
sandbox: true,
|
|
21801
|
-
retainedValues: () => [
|
|
21802
|
-
capability.promise,
|
|
21803
|
-
capability.resolve,
|
|
21804
|
-
capability.reject,
|
|
21805
|
-
values
|
|
21806
|
-
],
|
|
21807
|
-
call: async ([settlement]) => {
|
|
21808
|
-
if (called) return void 0;
|
|
21809
|
-
called = true;
|
|
21810
|
-
values[entryIndex] = method === "allSettled" ? state === "fulfilled" ? { status: state, value: settlement } : { status: state, reason: settlement } : settlement;
|
|
21811
|
-
remaining--;
|
|
21812
|
-
await complete2();
|
|
21813
|
-
return void 0;
|
|
21814
|
-
}
|
|
21815
|
-
});
|
|
21810
|
+
return createPromiseAggregateHandler(aggregateEntry, state, budget, context);
|
|
21816
21811
|
});
|
|
21817
|
-
remaining++;
|
|
21812
|
+
aggregate.remaining++;
|
|
21818
21813
|
const then = await readPromiseProperty(entry, "then", prototype, budget, context);
|
|
21819
21814
|
if (!isSandboxClosure(then))
|
|
21820
21815
|
throw new TypeError("Promise resolver result requires a callable then.");
|
|
21821
|
-
|
|
21816
|
+
const previousReactions = isSandboxPromise(entry) ? new Set(promiseReactionResults.get(entry)) : void 0;
|
|
21817
|
+
const completion = await callPromiseClosure(then, handlers, entry, budget, context);
|
|
21818
|
+
if (!intrinsicPromiseThenMethods.has(then) || !isSandboxPromise(entry) || !isSandboxPromise(completion)) represented = false;
|
|
21819
|
+
else if (isSandboxPromise(capability.promise)) {
|
|
21820
|
+
for (const producer of promiseReactionResults.get(entry) ?? []) {
|
|
21821
|
+
const reaction = promiseContinuations.get(producer);
|
|
21822
|
+
if (!previousReactions?.has(producer) && reaction?.kind === "reaction" && reaction.onFulfilled === handlers[0] && reaction.onRejected === handlers[1])
|
|
21823
|
+
linkPromiseAggregateProducer(producer, capability.promise);
|
|
21824
|
+
}
|
|
21825
|
+
}
|
|
21822
21826
|
} catch (error) {
|
|
21823
21827
|
await closeIterator(iterator, true);
|
|
21824
21828
|
throw error;
|
|
21825
21829
|
}
|
|
21826
21830
|
}
|
|
21827
|
-
remaining--;
|
|
21828
|
-
|
|
21831
|
+
aggregate.remaining--;
|
|
21832
|
+
aggregate.iteration = "complete";
|
|
21833
|
+
await completePromiseAggregate(aggregate, budget, context);
|
|
21834
|
+
if (represented && isSandboxPromise(capability.promise)) unrepresentedPromiseContinuations.delete(capability.promise);
|
|
21829
21835
|
} finally {
|
|
21830
21836
|
releaseIterator();
|
|
21831
21837
|
}
|
|
21832
21838
|
} catch (error) {
|
|
21839
|
+
aggregate.iteration = "abrupt";
|
|
21833
21840
|
if (error instanceof SandboxError && (error.code === "budgetExceeded" || error.code === "reentry")) {
|
|
21834
21841
|
if (isSandboxPromise(capability.promise)) observeSandboxPromise(capability.promise);
|
|
21835
21842
|
throw error;
|
|
@@ -21844,6 +21851,39 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
21844
21851
|
}
|
|
21845
21852
|
return capability.promise;
|
|
21846
21853
|
}
|
|
21854
|
+
async function completePromiseAggregate(aggregate, budget, context) {
|
|
21855
|
+
const { method, capability, values, remaining } = aggregate;
|
|
21856
|
+
if (remaining !== 0 || method === "race") return;
|
|
21857
|
+
if (method === "any") {
|
|
21858
|
+
const error = createSubsetErrorValue("AggregateError", "All promises were rejected", [], budget);
|
|
21859
|
+
error.errors = values;
|
|
21860
|
+
await callPromiseClosure(capability.reject, [budgetSandboxValue2(error, budget)], void 0, budget, context);
|
|
21861
|
+
} else {
|
|
21862
|
+
await callPromiseClosure(capability.resolve, [budgetSandboxValue2(values, budget)], void 0, budget, context);
|
|
21863
|
+
}
|
|
21864
|
+
}
|
|
21865
|
+
function createPromiseAggregateHandler(entry, action, budget, context) {
|
|
21866
|
+
const { aggregate } = entry;
|
|
21867
|
+
promiseAggregateEntries.set(entry, entry);
|
|
21868
|
+
const handler = createSandboxClosure({
|
|
21869
|
+
sandbox: true,
|
|
21870
|
+
guest: true,
|
|
21871
|
+
name: "",
|
|
21872
|
+
length: 1,
|
|
21873
|
+
retainedValues: () => [aggregate.capability.promise, aggregate.capability.resolve, aggregate.capability.reject, aggregate.values],
|
|
21874
|
+
call: async ([settlement]) => {
|
|
21875
|
+
if (entry.called) return void 0;
|
|
21876
|
+
entry.called = true;
|
|
21877
|
+
const { method, values } = aggregate;
|
|
21878
|
+
values[entry.index] = method === "allSettled" ? action === "fulfilled" ? { status: action, value: settlement } : { status: action, reason: settlement } : settlement;
|
|
21879
|
+
aggregate.remaining--;
|
|
21880
|
+
await completePromiseAggregate(aggregate, budget, context);
|
|
21881
|
+
return void 0;
|
|
21882
|
+
}
|
|
21883
|
+
});
|
|
21884
|
+
promiseAggregateHandlers.set(handler, { entry, action });
|
|
21885
|
+
return handler;
|
|
21886
|
+
}
|
|
21847
21887
|
function schedulePromise(promise, budget) {
|
|
21848
21888
|
return Promise.resolve().then(
|
|
21849
21889
|
() => promise.then(
|
|
@@ -22319,6 +22359,29 @@ function serializeCollectionProperties(value, encode, dataOnly = false) {
|
|
|
22319
22359
|
|
|
22320
22360
|
// packages/safe-js/src/snapshot/guest-heap.ts
|
|
22321
22361
|
function captureGuestHeapNode(value, encode) {
|
|
22362
|
+
const aggregate = promiseAggregateStates.get(value);
|
|
22363
|
+
if (aggregate !== void 0) {
|
|
22364
|
+
if (aggregate.iteration === "active") throw new TypeError("Cannot snapshot an active promise aggregate iterator.");
|
|
22365
|
+
return {
|
|
22366
|
+
kind: "promise-aggregate",
|
|
22367
|
+
method: aggregate.method,
|
|
22368
|
+
remaining: aggregate.remaining,
|
|
22369
|
+
size: aggregate.size,
|
|
22370
|
+
iteration: aggregate.iteration,
|
|
22371
|
+
values: encode(aggregate.values),
|
|
22372
|
+
capability: {
|
|
22373
|
+
promise: encode(aggregate.capability.promise),
|
|
22374
|
+
resolve: encode(aggregate.capability.resolve),
|
|
22375
|
+
reject: encode(aggregate.capability.reject)
|
|
22376
|
+
}
|
|
22377
|
+
};
|
|
22378
|
+
}
|
|
22379
|
+
const aggregateEntry = promiseAggregateEntries.get(value);
|
|
22380
|
+
if (aggregateEntry !== void 0)
|
|
22381
|
+
return { kind: "aggregate-entry", aggregate: encode(aggregateEntry.aggregate), index: aggregateEntry.index, called: aggregateEntry.called };
|
|
22382
|
+
const aggregateHandler = isSandboxClosure(value) ? promiseAggregateHandlers.get(value) : void 0;
|
|
22383
|
+
if (aggregateHandler !== void 0)
|
|
22384
|
+
return { kind: "aggregate-handler", entry: encode(aggregateHandler.entry), action: aggregateHandler.action, state: captureObjectState(value, encode) };
|
|
22322
22385
|
const bridge = promiseAdoptionBridges.get(value);
|
|
22323
22386
|
if (bridge !== void 0) {
|
|
22324
22387
|
if (bridge.settled || bridge.owner === void 0) return void 0;
|
|
@@ -22339,12 +22402,14 @@ function captureGuestHeapNode(value, encode) {
|
|
|
22339
22402
|
return { kind: "promise-resolver", promise: encode(resolver.promise), state: captureObjectState(value, encode) };
|
|
22340
22403
|
}
|
|
22341
22404
|
if (isSandboxPromise(value)) {
|
|
22405
|
+
const producerState = promiseProducers.has(value) ? { producers: [...promiseProducers.get(value)].map(encode) } : {};
|
|
22342
22406
|
const settlement = promiseStates.get(value);
|
|
22343
22407
|
if (settlement !== void 0 && settlement.status !== "pending")
|
|
22344
22408
|
return {
|
|
22345
22409
|
kind: "guest-promise",
|
|
22346
22410
|
status: settlement.status,
|
|
22347
22411
|
value: encode(settlement.value),
|
|
22412
|
+
...producerState,
|
|
22348
22413
|
...promiseReactionResults.has(value) ? { reactions: [...promiseReactionResults.get(value)].map(encode) } : {},
|
|
22349
22414
|
state: captureObjectState(value, encode)
|
|
22350
22415
|
};
|
|
@@ -22358,6 +22423,7 @@ function captureGuestHeapNode(value, encode) {
|
|
|
22358
22423
|
return {
|
|
22359
22424
|
kind: "pending-promise",
|
|
22360
22425
|
...continuation.state.settled ? { adoption: encode(adoption) } : {},
|
|
22426
|
+
...producerState,
|
|
22361
22427
|
reactions: [...promiseReactionResults.get(value) ?? []].map(encode),
|
|
22362
22428
|
state: captureObjectState(value, encode)
|
|
22363
22429
|
};
|
|
@@ -22366,6 +22432,13 @@ function captureGuestHeapNode(value, encode) {
|
|
|
22366
22432
|
return {
|
|
22367
22433
|
kind: "promise-reaction",
|
|
22368
22434
|
source: encode(continuation.source),
|
|
22435
|
+
...producerState,
|
|
22436
|
+
...continuation.aggregate === void 0 ? {} : { aggregate: encode(continuation.aggregate) },
|
|
22437
|
+
...continuation.capability === void 0 ? {} : { capability: {
|
|
22438
|
+
promise: encode(continuation.capability.promise),
|
|
22439
|
+
resolve: encode(continuation.capability.resolve),
|
|
22440
|
+
reject: encode(continuation.capability.reject)
|
|
22441
|
+
} },
|
|
22369
22442
|
onFulfilled: encode(continuation.onFulfilled),
|
|
22370
22443
|
onRejected: encode(continuation.onRejected),
|
|
22371
22444
|
reactions: [...promiseReactionResults.get(value) ?? []].map(encode),
|
|
@@ -27828,7 +27901,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27828
27901
|
createRawJson(node.text);
|
|
27829
27902
|
return true;
|
|
27830
27903
|
}
|
|
27831
|
-
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;
|
|
27904
|
+
if (!["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;
|
|
27832
27905
|
const reference = (value, kinds) => {
|
|
27833
27906
|
const ref = record3(value);
|
|
27834
27907
|
fields(ref, ["kind", "id"]);
|
|
@@ -27900,6 +27973,17 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27900
27973
|
if (typeof descriptor.enumerable !== "boolean" || typeof descriptor.configurable !== "boolean") throw new TypeError("Invalid guest descriptor flags.");
|
|
27901
27974
|
}
|
|
27902
27975
|
};
|
|
27976
|
+
if (Object.hasOwn(node, "producers")) {
|
|
27977
|
+
const producers = /* @__PURE__ */ new Set();
|
|
27978
|
+
for (const entry of array(node.producers)) {
|
|
27979
|
+
const producer = reference(entry, ["promise-reaction"]);
|
|
27980
|
+
const capabilityOwner = producer.capability === void 0 ? void 0 : reference(record3(producer.capability).promise);
|
|
27981
|
+
const aggregateOwner = producer.aggregate === void 0 ? void 0 : reference(producer.aggregate);
|
|
27982
|
+
if (producers.has(producer) || capabilityOwner !== node && aggregateOwner !== node)
|
|
27983
|
+
throw new TypeError("Invalid promise producer ownership.");
|
|
27984
|
+
producers.add(producer);
|
|
27985
|
+
}
|
|
27986
|
+
}
|
|
27903
27987
|
if (node.kind === "map" || node.kind === "set") {
|
|
27904
27988
|
fields(node, ["kind", node.kind === "map" ? "entries" : "values"], ["propertyState", "prototype", "privateElements"]);
|
|
27905
27989
|
if (node.privateElements !== void 0) privateState(node.privateElements);
|
|
@@ -27909,7 +27993,30 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27909
27993
|
});
|
|
27910
27994
|
return false;
|
|
27911
27995
|
}
|
|
27912
|
-
if (node.kind === "promise-
|
|
27996
|
+
if (node.kind === "promise-aggregate") {
|
|
27997
|
+
fields(node, ["kind", "method", "capability", "values", "remaining", "size", "iteration"]);
|
|
27998
|
+
if (!["all", "allSettled", "race", "any"].includes(String(node.method))) throw new TypeError("Invalid promise aggregate method.");
|
|
27999
|
+
const size = integer(node.size);
|
|
28000
|
+
if (size > maxArrayLength || node.iteration !== "complete" && node.iteration !== "abrupt") throw new TypeError("Invalid promise aggregate iteration.");
|
|
28001
|
+
if (integer(node.remaining) > size + (node.iteration === "abrupt" ? 1 : 0)) throw new TypeError("Invalid promise aggregate remaining count.");
|
|
28002
|
+
reference(node.values, ["array", "guest-array"]);
|
|
28003
|
+
const capability = record3(node.capability);
|
|
28004
|
+
fields(capability, ["promise", "resolve", "reject"]);
|
|
28005
|
+
if (absent(capability.resolve) || absent(capability.reject)) throw new TypeError("Missing promise aggregate resolver.");
|
|
28006
|
+
callable(capability.resolve);
|
|
28007
|
+
callable(capability.reject);
|
|
28008
|
+
} else if (node.kind === "aggregate-entry") {
|
|
28009
|
+
fields(node, ["kind", "aggregate", "index", "called"]);
|
|
28010
|
+
const aggregate = reference(node.aggregate, ["promise-aggregate"]);
|
|
28011
|
+
if (integer(node.index) >= integer(aggregate.size) || typeof node.called !== "boolean") throw new TypeError("Invalid promise aggregate entry.");
|
|
28012
|
+
} else if (node.kind === "aggregate-handler") {
|
|
28013
|
+
fields(node, ["kind", "entry", "action", "state"]);
|
|
28014
|
+
state(node.state);
|
|
28015
|
+
const entry = reference(node.entry, ["aggregate-entry"]);
|
|
28016
|
+
const aggregate = reference(entry.aggregate, ["promise-aggregate"]);
|
|
28017
|
+
if (node.action !== "fulfilled" && node.action !== "rejected" || aggregate.method === "all" && node.action !== "fulfilled" || aggregate.method === "any" && node.action !== "rejected" || aggregate.method === "race")
|
|
28018
|
+
throw new TypeError("Invalid promise aggregate handler action.");
|
|
28019
|
+
} else if (node.kind === "promise-adoption") {
|
|
27913
28020
|
fields(node, ["kind", "owner", "source"]);
|
|
27914
28021
|
const owner = reference(node.owner, ["pending-promise"]);
|
|
27915
28022
|
if (reference(owner.adoption, ["promise-adoption"]) !== node) throw new TypeError("Invalid promise adoption owner.");
|
|
@@ -27941,12 +28048,40 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27941
28048
|
throw new TypeError("Invalid promise resolver action.");
|
|
27942
28049
|
state(node.state);
|
|
27943
28050
|
} else if (node.kind === "pending-promise" || node.kind === "promise-reaction") {
|
|
27944
|
-
fields(node, node.kind === "pending-promise" ? ["kind", "reactions", "state"] : ["kind", "source", "onFulfilled", "onRejected", "reactions", "state"], node.kind === "pending-promise" ? ["adoption"] : []);
|
|
28051
|
+
fields(node, node.kind === "pending-promise" ? ["kind", "reactions", "state"] : ["kind", "source", "onFulfilled", "onRejected", "reactions", "state"], node.kind === "pending-promise" ? ["adoption", "producers"] : ["capability", "aggregate", "producers"]);
|
|
27945
28052
|
if (node.kind === "pending-promise" && Object.hasOwn(node, "adoption")) {
|
|
27946
28053
|
const bridge = reference(node.adoption, ["promise-adoption"]);
|
|
27947
28054
|
if (reference(bridge.owner, ["pending-promise"]) !== node) throw new TypeError("Invalid promise adoption owner.");
|
|
27948
28055
|
}
|
|
27949
28056
|
if (node.kind === "promise-reaction") {
|
|
28057
|
+
if (Object.hasOwn(node, "aggregate")) {
|
|
28058
|
+
const aggregate = reference(node.aggregate, ["pending-promise", "guest-promise", "promise-reaction"]);
|
|
28059
|
+
if (aggregate === node || !Array.isArray(aggregate.producers) || !aggregate.producers.some((entry) => reference(entry, ["promise-reaction"]) === node))
|
|
28060
|
+
throw new TypeError("Invalid promise aggregate producer ownership.");
|
|
28061
|
+
for (const value of [node.onFulfilled, node.onRejected]) {
|
|
28062
|
+
if (absent(value)) continue;
|
|
28063
|
+
const handler = reference(value);
|
|
28064
|
+
let owner;
|
|
28065
|
+
if (handler.kind === "promise-resolver") owner = reference(handler.promise);
|
|
28066
|
+
else if (handler.kind === "aggregate-handler") {
|
|
28067
|
+
const entry = reference(handler.entry, ["aggregate-entry"]);
|
|
28068
|
+
const state2 = reference(entry.aggregate, ["promise-aggregate"]);
|
|
28069
|
+
owner = reference(record3(state2.capability).promise);
|
|
28070
|
+
}
|
|
28071
|
+
if (owner !== void 0 && owner !== aggregate) throw new TypeError("Invalid promise aggregate handler ownership.");
|
|
28072
|
+
}
|
|
28073
|
+
}
|
|
28074
|
+
if (Object.hasOwn(node, "capability")) {
|
|
28075
|
+
const capability = record3(node.capability);
|
|
28076
|
+
fields(capability, ["promise", "resolve", "reject"]);
|
|
28077
|
+
const result = reference(capability.promise, ["pending-promise", "guest-promise", "promise-reaction"]);
|
|
28078
|
+
if (result === node) throw new TypeError("Invalid promise producer ownership.");
|
|
28079
|
+
if (!Array.isArray(result.producers) || !result.producers.some((entry) => reference(entry, ["promise-reaction"]) === node))
|
|
28080
|
+
throw new TypeError("Unlisted promise producer.");
|
|
28081
|
+
if (absent(capability.resolve) || absent(capability.reject)) throw new TypeError("Missing promise producer resolver.");
|
|
28082
|
+
callable(capability.resolve);
|
|
28083
|
+
callable(capability.reject);
|
|
28084
|
+
}
|
|
27950
28085
|
const source = reference(node.source, ["pending-promise", "promise-reaction", "guest-promise"]);
|
|
27951
28086
|
if (!Array.isArray(source.reactions) || !source.reactions.some((entry) => reference(entry, ["promise-reaction"]) === node))
|
|
27952
28087
|
throw new TypeError("Unlisted promise reaction.");
|
|
@@ -27961,7 +28096,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
27961
28096
|
}
|
|
27962
28097
|
state(node.state);
|
|
27963
28098
|
} else if (node.kind === "guest-promise") {
|
|
27964
|
-
fields(node, ["kind", "status", "value", "state"], ["reactions"]);
|
|
28099
|
+
fields(node, ["kind", "status", "value", "state"], ["reactions", "producers"]);
|
|
27965
28100
|
if (Object.hasOwn(node, "reactions")) {
|
|
27966
28101
|
if (!Array.isArray(node.reactions)) throw new TypeError("Invalid promise reactions.");
|
|
27967
28102
|
const reactions = /* @__PURE__ */ new Set();
|
|
@@ -30200,8 +30335,15 @@ function measureSandboxData(values, options = {}) {
|
|
|
30200
30335
|
visit(continuation.source, depth + 1);
|
|
30201
30336
|
visit(continuation.onFulfilled, depth + 1);
|
|
30202
30337
|
visit(continuation.onRejected, depth + 1);
|
|
30338
|
+
if (continuation.capability !== void 0) {
|
|
30339
|
+
visit(continuation.capability.promise, depth + 1);
|
|
30340
|
+
visit(continuation.capability.resolve, depth + 1);
|
|
30341
|
+
visit(continuation.capability.reject, depth + 1);
|
|
30342
|
+
}
|
|
30343
|
+
if (continuation.aggregate !== void 0) visit(continuation.aggregate, depth + 1);
|
|
30203
30344
|
}
|
|
30204
30345
|
for (const reaction of promiseReactionResults.get(value) ?? []) visit(reaction, depth + 1);
|
|
30346
|
+
for (const producer of promiseProducers.get(value) ?? []) visit(producer, depth + 1);
|
|
30205
30347
|
for (const key of Reflect.ownKeys(getPromiseProperties(value))) {
|
|
30206
30348
|
const descriptor = Object.getOwnPropertyDescriptor(getPromiseProperties(value), key);
|
|
30207
30349
|
usage += typeof key === "string" ? key.length + 1 : 1;
|
|
@@ -45217,4 +45359,4 @@ export {
|
|
|
45217
45359
|
FileSnapshotBackend,
|
|
45218
45360
|
run
|
|
45219
45361
|
};
|
|
45220
|
-
//# sourceMappingURL=chunk-
|
|
45362
|
+
//# sourceMappingURL=chunk-5RNME7ZM.js.map
|