@poe-platform/safe-js 0.1.274 → 0.1.276
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-4MTUBJBW.js → chunk-5MDRQKN6.js} +31 -20
- package/dist/safe-js/chunks/chunk-5MDRQKN6.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-DFCAK73K.js → chunk-P44IU3A7.js} +2 -2
- 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/package.json +2 -2
- package/dist/safe-js/chunks/chunk-4MTUBJBW.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-DFCAK73K.js.map → chunk-P44IU3A7.js.map} +0 -0
|
@@ -8012,7 +8012,7 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
8012
8012
|
if (budget !== void 0 && intrinsicPrototypes.get(budget) === value && prototype !== null) {
|
|
8013
8013
|
throw new TypeError("Object.prototype has an immutable null prototype.");
|
|
8014
8014
|
}
|
|
8015
|
-
if (!Array.isArray(value) && !isSandboxRegex(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isPrototypeRecord(value) || prototype !== null && !Array.isArray(prototype) && !isSandboxRegex(prototype) && !isSandboxMap(prototype) && !isSandboxSet(prototype) && !isPrototypeRecord(prototype)) {
|
|
8015
|
+
if (!Array.isArray(value) && !isSandboxPromise(value) && !isSandboxRegex(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isPrototypeRecord(value) || prototype !== null && !Array.isArray(prototype) && !isSandboxPromise(prototype) && !isSandboxRegex(prototype) && !isSandboxMap(prototype) && !isSandboxSet(prototype) && !isPrototypeRecord(prototype)) {
|
|
8016
8016
|
throw new TypeError(
|
|
8017
8017
|
"Prototype links require supported sandbox objects."
|
|
8018
8018
|
);
|
|
@@ -8021,7 +8021,7 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
8021
8021
|
if (prototype === null) prototypes.set(value, null);
|
|
8022
8022
|
return;
|
|
8023
8023
|
}
|
|
8024
|
-
if (!Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value)) {
|
|
8024
|
+
if (!Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value)) {
|
|
8025
8025
|
throw new TypeError("Cannot change the prototype of a non-extensible object.");
|
|
8026
8026
|
}
|
|
8027
8027
|
let depth = 0;
|
|
@@ -11616,6 +11616,8 @@ function createPromiseGlobals(options) {
|
|
|
11616
11616
|
const prototype = getPromisePrototype(options.budget);
|
|
11617
11617
|
const construct = async ([executor], context) => {
|
|
11618
11618
|
if (!isSandboxClosure(executor)) throw new TypeError("Promise executor must be a function.");
|
|
11619
|
+
const prototypeValue = context?.newTarget === void 0 ? prototype : context.getProperty === void 0 ? getSandboxDataProperty(context.newTarget, "prototype", options.budget) : context.getProperty(context.newTarget, "prototype");
|
|
11620
|
+
const targetPrototype = prototypeValue instanceof Promise ? await prototypeValue : prototypeValue;
|
|
11619
11621
|
let fulfill;
|
|
11620
11622
|
let reject;
|
|
11621
11623
|
const pending = createSandboxPromise(
|
|
@@ -11625,6 +11627,8 @@ function createPromiseGlobals(options) {
|
|
|
11625
11627
|
}),
|
|
11626
11628
|
{ span: context?.span }
|
|
11627
11629
|
);
|
|
11630
|
+
if (typeof targetPrototype === "object" && targetPrototype !== null && targetPrototype !== prototype)
|
|
11631
|
+
setSandboxPrototype(pending, targetPrototype, options.budget);
|
|
11628
11632
|
let settled = false;
|
|
11629
11633
|
const settle = (state, value) => {
|
|
11630
11634
|
if (settled) return;
|
|
@@ -11642,7 +11646,7 @@ function createPromiseGlobals(options) {
|
|
|
11642
11646
|
)
|
|
11643
11647
|
);
|
|
11644
11648
|
} else {
|
|
11645
|
-
fulfill(resolveSandboxValue(value, { budget: options.budget, self: pending }));
|
|
11649
|
+
fulfill(resolveSandboxValue(value, { budget: options.budget, self: pending, context }));
|
|
11646
11650
|
}
|
|
11647
11651
|
} catch (error) {
|
|
11648
11652
|
reject(error);
|
|
@@ -11755,11 +11759,11 @@ function createPromiseGlobals(options) {
|
|
|
11755
11759
|
}
|
|
11756
11760
|
const finish = (actualConstructor2) => {
|
|
11757
11761
|
if (isSandboxPromise(value) && actualConstructor2 === constructor) return value;
|
|
11758
|
-
return isSandboxPromiseConstructor(constructor) ? createSandboxPromise(resolveSandboxValue(value, { budget: options.budget })) : settleConstructedPromise(constructor, value, "fulfilled", options.budget, context);
|
|
11762
|
+
return isSandboxPromiseConstructor(constructor) ? createSandboxPromise(resolveSandboxValue(value, { budget: options.budget, context })) : settleConstructedPromise(constructor, value, "fulfilled", options.budget, context);
|
|
11759
11763
|
};
|
|
11760
11764
|
if (!isSandboxPromise(value)) return finish(void 0);
|
|
11761
11765
|
const descriptor = getSandboxPropertyDescriptor(value, "constructor", options.budget);
|
|
11762
|
-
const actualConstructor = descriptor === void 0 ? getPromiseMember("constructor", options.budget) : readPropertyDescriptor(descriptor, value, context, true);
|
|
11766
|
+
const actualConstructor = descriptor === void 0 ? hasExplicitSandboxPrototype(value) ? void 0 : getPromiseMember("constructor", options.budget) : readPropertyDescriptor(descriptor, value, context, true);
|
|
11763
11767
|
return actualConstructor instanceof Promise ? actualConstructor.then(finish) : finish(actualConstructor);
|
|
11764
11768
|
},
|
|
11765
11769
|
guest: true,
|
|
@@ -11853,9 +11857,10 @@ async function createPromiseCapability(constructor, budget, context) {
|
|
|
11853
11857
|
const leaveCall = budget.enterCall();
|
|
11854
11858
|
try {
|
|
11855
11859
|
const promise = await constructor.construct([executor], {
|
|
11860
|
+
...context,
|
|
11856
11861
|
stack: context?.stack ?? [],
|
|
11857
11862
|
thisValue: void 0,
|
|
11858
|
-
|
|
11863
|
+
newTarget: constructor
|
|
11859
11864
|
});
|
|
11860
11865
|
if (!isSandboxClosure(resolve) || !isSandboxClosure(reject)) {
|
|
11861
11866
|
throw new TypeError("Promise capability requires callable resolve and reject functions.");
|
|
@@ -11981,7 +11986,7 @@ function getPromisePrototype(budget) {
|
|
|
11981
11986
|
if (isSandboxPromise(result) && actualConstructor === constructor2) {
|
|
11982
11987
|
pending = result;
|
|
11983
11988
|
} else if (isSandboxPromiseConstructor(constructor2)) {
|
|
11984
|
-
pending = createSandboxPromise(resolveSandboxValue(result, { budget }));
|
|
11989
|
+
pending = createSandboxPromise(resolveSandboxValue(result, { budget, context }));
|
|
11985
11990
|
} else {
|
|
11986
11991
|
pending = await settleConstructedPromise(constructor2, result, "fulfilled", budget, context);
|
|
11987
11992
|
}
|
|
@@ -12035,6 +12040,7 @@ function getPromisePrototype(budget) {
|
|
|
12035
12040
|
return prototype;
|
|
12036
12041
|
}
|
|
12037
12042
|
function readPromiseReceiverProperty(receiver, property, prototype, context) {
|
|
12043
|
+
if (isSandboxPromise(receiver) && hasExplicitSandboxPrototype(receiver)) return void 0;
|
|
12038
12044
|
if (!isSandboxPromise(receiver) && context?.getProperty !== void 0)
|
|
12039
12045
|
return context.getProperty(receiver, property);
|
|
12040
12046
|
const properties = isSandboxPromise(receiver) ? prototype : isSandboxClosure(receiver) ? receiver.properties : receiver;
|
|
@@ -12149,7 +12155,7 @@ async function settleIterable(iterable, method, budget, constructor, context) {
|
|
|
12149
12155
|
});
|
|
12150
12156
|
});
|
|
12151
12157
|
remaining++;
|
|
12152
|
-
const then = await
|
|
12158
|
+
const then = await readPromiseProperty(entry, "then", prototype, budget, context);
|
|
12153
12159
|
if (!isSandboxClosure(then))
|
|
12154
12160
|
throw new TypeError("Promise resolver result requires a callable then.");
|
|
12155
12161
|
await callPromiseClosure(then, handlers, entry, budget, context);
|
|
@@ -12222,7 +12228,7 @@ function resolveSandboxValueNow(value, options) {
|
|
|
12222
12228
|
}
|
|
12223
12229
|
if (isSandboxPromise(value) && !hasCustomPromiseThen(value, options.budget)) {
|
|
12224
12230
|
if (options.budget !== void 0) {
|
|
12225
|
-
return resolvePromiseResult(value, options.budget, options.self);
|
|
12231
|
+
return resolvePromiseResult(value, options.budget, options.self, options.context);
|
|
12226
12232
|
}
|
|
12227
12233
|
observeSandboxPromise(value);
|
|
12228
12234
|
return value.promise.then(
|
|
@@ -12312,7 +12318,8 @@ function resolveThenable(value, then, options) {
|
|
|
12312
12318
|
recordSettlement("rejected", error);
|
|
12313
12319
|
complete();
|
|
12314
12320
|
}
|
|
12315
|
-
}
|
|
12321
|
+
},
|
|
12322
|
+
options.context
|
|
12316
12323
|
).catch(reject);
|
|
12317
12324
|
});
|
|
12318
12325
|
}
|
|
@@ -12354,13 +12361,13 @@ function runPromiseReaction(handler, value, state, budget, self, context) {
|
|
|
12354
12361
|
const argument = state === "rejected" && value instanceof Error ? coerceThrownValue(value, budget, []) : value;
|
|
12355
12362
|
const fulfilled = (result) => {
|
|
12356
12363
|
if (isPromiseLike2(result)) {
|
|
12357
|
-
resolve(resolvePromiseResult(result, budget, self));
|
|
12364
|
+
resolve(resolvePromiseResult(result, budget, self, context));
|
|
12358
12365
|
} else if (isSelfResolution(result, self)) {
|
|
12359
12366
|
reject(
|
|
12360
12367
|
createSubsetErrorValue("TypeError", "Promise cannot resolve to itself.", [], budget)
|
|
12361
12368
|
);
|
|
12362
12369
|
} else if (requiresPromiseResolution(result, budget)) {
|
|
12363
|
-
resolve(resolvePromiseResult(result, budget, self));
|
|
12370
|
+
resolve(resolvePromiseResult(result, budget, self, context));
|
|
12364
12371
|
} else {
|
|
12365
12372
|
resolve(budgetSandboxValue(result, budget));
|
|
12366
12373
|
}
|
|
@@ -12394,9 +12401,9 @@ function callInPromiseJob(handler, args, thisValue = void 0, completion, context
|
|
|
12394
12401
|
}
|
|
12395
12402
|
});
|
|
12396
12403
|
}
|
|
12397
|
-
function resolvePromiseResult(result, budget, self) {
|
|
12404
|
+
function resolvePromiseResult(result, budget, self, context) {
|
|
12398
12405
|
if (isPromiseLike2(result)) {
|
|
12399
|
-
return Promise.resolve(result).then((resolved) => resolvePromiseResult(resolved, budget, self));
|
|
12406
|
+
return Promise.resolve(result).then((resolved) => resolvePromiseResult(resolved, budget, self, context));
|
|
12400
12407
|
}
|
|
12401
12408
|
if (isSelfResolution(result, self)) {
|
|
12402
12409
|
return Promise.reject(
|
|
@@ -12404,7 +12411,7 @@ function resolvePromiseResult(result, budget, self) {
|
|
|
12404
12411
|
);
|
|
12405
12412
|
}
|
|
12406
12413
|
if (!isSandboxPromise(result) || hasCustomPromiseThen(result, budget)) {
|
|
12407
|
-
return resolveSandboxValue(result, { budget, self });
|
|
12414
|
+
return resolveSandboxValue(result, { budget, self, context });
|
|
12408
12415
|
}
|
|
12409
12416
|
const then = getSandboxPropertyDescriptor(result, "then", budget)?.value ?? getPromiseMember("then", budget);
|
|
12410
12417
|
if (!isSandboxClosure(then)) return Promise.resolve(result);
|
|
@@ -12416,7 +12423,7 @@ function resolvePromiseResult(result, budget, self) {
|
|
|
12416
12423
|
try {
|
|
12417
12424
|
if (state === "rejected") reject(budgetSandboxValue(value, budget));
|
|
12418
12425
|
else if (requiresPromiseResolution(value, budget)) {
|
|
12419
|
-
resolve(resolvePromiseResult(value, budget, self));
|
|
12426
|
+
resolve(resolvePromiseResult(value, budget, self, context));
|
|
12420
12427
|
} else {
|
|
12421
12428
|
resolve(budgetSandboxValue(value, budget));
|
|
12422
12429
|
}
|
|
@@ -12445,7 +12452,8 @@ function resolvePromiseResult(result, budget, self) {
|
|
|
12445
12452
|
})
|
|
12446
12453
|
],
|
|
12447
12454
|
result,
|
|
12448
|
-
budget
|
|
12455
|
+
budget,
|
|
12456
|
+
context
|
|
12449
12457
|
);
|
|
12450
12458
|
if (isSandboxPromise(completion)) {
|
|
12451
12459
|
completion.promise.catch((reason) => {
|
|
@@ -12465,6 +12473,7 @@ function isSelfResolution(result, self) {
|
|
|
12465
12473
|
}
|
|
12466
12474
|
function hasCustomPromiseThen(value, budget) {
|
|
12467
12475
|
const descriptor = getSandboxPropertyDescriptor(value, "then", budget);
|
|
12476
|
+
if (descriptor === void 0 && isSandboxPromise(value) && hasExplicitSandboxPrototype(value)) return true;
|
|
12468
12477
|
return descriptor !== void 0 && (!isSandboxClosure(descriptor.value) || !intrinsicPromiseThenMethods.has(descriptor.value));
|
|
12469
12478
|
}
|
|
12470
12479
|
function requiresPromiseResolution(value, budget) {
|
|
@@ -18191,7 +18200,7 @@ function getPropertyValue(target, property, context, receiver = target) {
|
|
|
18191
18200
|
return getCollectionIteratorMember(target, property, context.budget);
|
|
18192
18201
|
if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
|
|
18193
18202
|
if (isSandboxClosure(target)) return getClosureMemberValue(target, property, context);
|
|
18194
|
-
if (isSandboxPromise(target)) return getPromiseMember(property, context.budget);
|
|
18203
|
+
if (isSandboxPromise(target)) return hasExplicitSandboxPrototype(target) ? void 0 : getPromiseMember(property, context.budget);
|
|
18195
18204
|
if (isSandboxRegex(target)) return hasExplicitSandboxPrototype(target) || getSandboxPrototype(target, context.budget) !== null ? void 0 : getRegexMember(target, property, context.budget, createCoercionContext(context));
|
|
18196
18205
|
if (!isIndexableSandboxValue(target)) {
|
|
18197
18206
|
throw new TypeError("Attempted to read a property from a non-object value.");
|
|
@@ -21498,6 +21507,7 @@ function serializeSafeJSSnapshot(snapshot) {
|
|
|
21498
21507
|
}
|
|
21499
21508
|
function createDumpFile(snapshot) {
|
|
21500
21509
|
const state = {
|
|
21510
|
+
replayPromises: inMemoryRunSnapshots.has(snapshot),
|
|
21501
21511
|
float32Buffers: /* @__PURE__ */ new WeakMap(),
|
|
21502
21512
|
heap: {},
|
|
21503
21513
|
...indexHeapContainers(snapshot),
|
|
@@ -21554,7 +21564,7 @@ function serializeDumpValue(value, path, state) {
|
|
|
21554
21564
|
}
|
|
21555
21565
|
return { kind: "ref", id };
|
|
21556
21566
|
}
|
|
21557
|
-
if (hasGuestObjectState(value)) {
|
|
21567
|
+
if (hasGuestObjectState(value) && !(state.replayPromises && isSandboxPromise(value))) {
|
|
21558
21568
|
throw new TypeError("Guest function properties and prototype links cannot be serialized.");
|
|
21559
21569
|
}
|
|
21560
21570
|
if (isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxBox(value) || isSandboxDate(value) || isFloat32Array(value)) return serializeHeapReference(value, path, state);
|
|
@@ -25913,6 +25923,7 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
25913
25923
|
value: copyFromSandbox(descriptor.value, state, `${path}.<property>`, options, depth + 1)
|
|
25914
25924
|
});
|
|
25915
25925
|
}
|
|
25926
|
+
if (hasNullObjectPrototype(value)) Object.setPrototypeOf(copy, null);
|
|
25916
25927
|
if (!Object.isExtensible(properties)) Object.preventExtensions(copy);
|
|
25917
25928
|
return copy;
|
|
25918
25929
|
}
|
|
@@ -40237,4 +40248,4 @@ export {
|
|
|
40237
40248
|
FileSnapshotBackend,
|
|
40238
40249
|
run
|
|
40239
40250
|
};
|
|
40240
|
-
//# sourceMappingURL=chunk-
|
|
40251
|
+
//# sourceMappingURL=chunk-5MDRQKN6.js.map
|