@poe-platform/safe-js 0.1.298 → 0.1.300
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-2MU4KXPO.js → chunk-JBOD6COV.js} +2 -2
- package/dist/safe-js/chunks/{chunk-BGSPSHLP.js → chunk-ONR2CYEH.js} +187 -85
- package/dist/safe-js/chunks/chunk-ONR2CYEH.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/package.json +2 -2
- package/dist/safe-js/chunks/chunk-BGSPSHLP.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-2MU4KXPO.js.map → chunk-JBOD6COV.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-ONR2CYEH.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-JBOD6COV.js.map
|
|
@@ -7013,6 +7013,17 @@ function serializedDateTime(value) {
|
|
|
7013
7013
|
// packages/safe-js/src/interp/internal-symbols.ts
|
|
7014
7014
|
var internalSymbols = /* @__PURE__ */ new Set();
|
|
7015
7015
|
|
|
7016
|
+
// packages/safe-js/src/interp/generator-properties.ts
|
|
7017
|
+
var generatorGuestProperties = /* @__PURE__ */ new WeakMap();
|
|
7018
|
+
function getGeneratorProperties(value) {
|
|
7019
|
+
let properties = generatorGuestProperties.get(value);
|
|
7020
|
+
if (properties === void 0) {
|
|
7021
|
+
properties = /* @__PURE__ */ Object.create(null);
|
|
7022
|
+
generatorGuestProperties.set(value, properties);
|
|
7023
|
+
}
|
|
7024
|
+
return properties;
|
|
7025
|
+
}
|
|
7026
|
+
|
|
7016
7027
|
// packages/safe-js/src/interp/regexp-properties.ts
|
|
7017
7028
|
var regexGuestProperties = /* @__PURE__ */ new WeakMap();
|
|
7018
7029
|
function getRegexProperties(value) {
|
|
@@ -7355,7 +7366,7 @@ function walkGraphDepth(root, rootPath, assertDepth) {
|
|
|
7355
7366
|
}
|
|
7356
7367
|
}
|
|
7357
7368
|
function graphEntries(value) {
|
|
7358
|
-
const properties = regexGuestProperties.get(value);
|
|
7369
|
+
const properties = regexGuestProperties.get(value) ?? generatorGuestProperties.get(value);
|
|
7359
7370
|
if (properties !== void 0) return Reflect.ownKeys(properties).flatMap((key) => {
|
|
7360
7371
|
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
7361
7372
|
return "value" in descriptor ? [[`.${String(key)}`, descriptor.value]] : [];
|
|
@@ -7387,6 +7398,55 @@ function graphEntries(value) {
|
|
|
7387
7398
|
return entries;
|
|
7388
7399
|
}
|
|
7389
7400
|
|
|
7401
|
+
// packages/safe-js/src/interp/resources.ts
|
|
7402
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7403
|
+
var runResources = new AsyncLocalStorage();
|
|
7404
|
+
function retainValues(budget, values) {
|
|
7405
|
+
const retained = {};
|
|
7406
|
+
budget.setRetainedValues(retained, values);
|
|
7407
|
+
const pending = runResources.getStore()?.referenceReleases;
|
|
7408
|
+
const release = () => {
|
|
7409
|
+
budget.setRetainedValues(retained, void 0);
|
|
7410
|
+
pending?.delete(release);
|
|
7411
|
+
};
|
|
7412
|
+
pending?.add(release);
|
|
7413
|
+
return release;
|
|
7414
|
+
}
|
|
7415
|
+
async function withRunResources(signal, execute) {
|
|
7416
|
+
const controller = new AbortController();
|
|
7417
|
+
const cancel = () => controller.abort(signal?.reason);
|
|
7418
|
+
const cleanups = /* @__PURE__ */ new Set();
|
|
7419
|
+
const resources = {
|
|
7420
|
+
signal: controller.signal,
|
|
7421
|
+
referenceReleases: /* @__PURE__ */ new Set(),
|
|
7422
|
+
add(close) {
|
|
7423
|
+
cleanups.add(close);
|
|
7424
|
+
}
|
|
7425
|
+
};
|
|
7426
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
7427
|
+
if (signal?.aborted) cancel();
|
|
7428
|
+
let result;
|
|
7429
|
+
let failure;
|
|
7430
|
+
let errors = [];
|
|
7431
|
+
try {
|
|
7432
|
+
result = await runResources.run(resources, execute);
|
|
7433
|
+
} catch (error) {
|
|
7434
|
+
failure = { reason: error };
|
|
7435
|
+
} finally {
|
|
7436
|
+
signal?.removeEventListener("abort", cancel);
|
|
7437
|
+
controller.abort(new Error("SafeJS run finished."));
|
|
7438
|
+
for (const release of resources.referenceReleases) release();
|
|
7439
|
+
resources.referenceReleases.clear();
|
|
7440
|
+
const outcomes = await Promise.allSettled(
|
|
7441
|
+
[...cleanups].map((close) => Promise.resolve().then(close))
|
|
7442
|
+
);
|
|
7443
|
+
errors = outcomes.flatMap((outcome) => outcome.status === "rejected" ? [outcome.reason] : []);
|
|
7444
|
+
}
|
|
7445
|
+
if (failure !== void 0) throw failure.reason;
|
|
7446
|
+
if (errors.length > 0) throw new AggregateError(errors, "SafeJS resource cleanup failed.");
|
|
7447
|
+
return result;
|
|
7448
|
+
}
|
|
7449
|
+
|
|
7390
7450
|
// packages/safe-js/src/interp/symbols.ts
|
|
7391
7451
|
var wellKnownSymbols = Object.freeze({
|
|
7392
7452
|
iterator: Symbol.iterator,
|
|
@@ -7810,6 +7870,7 @@ var collectionPrototypes = /* @__PURE__ */ new WeakMap();
|
|
|
7810
7870
|
var promisePrototypes = /* @__PURE__ */ new WeakMap();
|
|
7811
7871
|
var datePrototypes = /* @__PURE__ */ new WeakMap();
|
|
7812
7872
|
var arrayPrototypes = /* @__PURE__ */ new WeakMap();
|
|
7873
|
+
var functionPrototypes = /* @__PURE__ */ new WeakMap();
|
|
7813
7874
|
var initialArrayMethods = /* @__PURE__ */ new WeakMap();
|
|
7814
7875
|
var initialRegexDescriptors = /* @__PURE__ */ new WeakMap();
|
|
7815
7876
|
var intrinsicPrototypeRoots = /* @__PURE__ */ new WeakMap();
|
|
@@ -7865,6 +7926,12 @@ function installObjectPrototype(budget, prototype, constructor) {
|
|
|
7865
7926
|
intrinsicPrototypes.set(budget, prototype);
|
|
7866
7927
|
registerIntrinsicPrototype(budget, prototype, constructor);
|
|
7867
7928
|
}
|
|
7929
|
+
function installFunctionPrototype(budget, prototype) {
|
|
7930
|
+
functionPrototypes.set(budget, prototype);
|
|
7931
|
+
registerBuiltinIdentities(budget, { "%FunctionPrototype%": prototype });
|
|
7932
|
+
registerIntrinsicFunction(budget, prototype);
|
|
7933
|
+
registerIntrinsicObject(budget, materializeFunctionProperties(prototype));
|
|
7934
|
+
}
|
|
7868
7935
|
function installBoxedPrototype(budget, prototype, constructor, kind = typeof boxedValue(prototype)) {
|
|
7869
7936
|
let state = boxedPrototypes.get(budget);
|
|
7870
7937
|
if (state === void 0) boxedPrototypes.set(budget, state = /* @__PURE__ */ new Map());
|
|
@@ -7989,11 +8056,14 @@ function releaseObjectPrototype(budget) {
|
|
|
7989
8056
|
promisePrototypes.delete(budget);
|
|
7990
8057
|
datePrototypes.delete(budget);
|
|
7991
8058
|
arrayPrototypes.delete(budget);
|
|
8059
|
+
functionPrototypes.delete(budget);
|
|
7992
8060
|
initialRegexDescriptors.delete(budget);
|
|
7993
8061
|
intrinsicPrototypes.delete(budget);
|
|
7994
8062
|
}
|
|
7995
8063
|
function getSandboxPrototype(value, budget) {
|
|
7996
8064
|
if (prototypes.has(value)) return prototypes.get(value) ?? null;
|
|
8065
|
+
if (budget !== void 0 && isGuestClosure(value) && runResources.getStore()?.functionSourceText !== false)
|
|
8066
|
+
return functionPrototypes.get(budget) ?? null;
|
|
7997
8067
|
if (budget !== void 0 && Array.isArray(value)) return arrayPrototypes.get(budget) ?? null;
|
|
7998
8068
|
if (budget !== void 0 && isSandboxDate(value)) return datePrototypes.get(budget) ?? null;
|
|
7999
8069
|
if (budget !== void 0 && isSandboxPromise(value)) return promisePrototypes.get(budget) ?? null;
|
|
@@ -8018,8 +8088,15 @@ function getSandboxPropertyDescriptor(value, key, budget) {
|
|
|
8018
8088
|
return hostProperties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(hostProperties, key);
|
|
8019
8089
|
let current = value;
|
|
8020
8090
|
let depth = 0;
|
|
8021
|
-
while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxDate(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxMap(current) || isSandboxSet(current) || isPrototypeRecord(current))) {
|
|
8022
|
-
const properties = isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
8091
|
+
while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxGenerator(current) || isSandboxDate(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxMap(current) || isSandboxSet(current) || isPrototypeRecord(current))) {
|
|
8092
|
+
const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? key === "prototype" && current.construct !== void 0 && current.boundTarget === void 0 ? materializeFunctionProperties(current) : getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
8093
|
+
if (properties === void 0 && isGuestClosure(current) && (key === "name" || key === "length"))
|
|
8094
|
+
return {
|
|
8095
|
+
value: key === "name" ? current.name ?? "" : current.length ?? 0,
|
|
8096
|
+
writable: false,
|
|
8097
|
+
enumerable: false,
|
|
8098
|
+
configurable: true
|
|
8099
|
+
};
|
|
8023
8100
|
const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key);
|
|
8024
8101
|
if (descriptor !== void 0) return descriptor;
|
|
8025
8102
|
current = getSandboxPrototype(current, budget);
|
|
@@ -8037,6 +8114,10 @@ function getSandboxDataProperty(value, key, budget) {
|
|
|
8037
8114
|
if (isGuestHostObject(current)) return typeof key === "symbol" ? void 0 : getHostObjectMember(current, String(key));
|
|
8038
8115
|
if (isSandboxRegex(current)) return Object.getOwnPropertyDescriptor(getRegexProperties(current), key)?.value;
|
|
8039
8116
|
if (isSandboxPromise(current)) return Object.getOwnPropertyDescriptor(getPromiseProperties(current), key)?.value;
|
|
8117
|
+
if (isSandboxGenerator(current)) {
|
|
8118
|
+
const descriptor = Object.getOwnPropertyDescriptor(getGeneratorProperties(current), key);
|
|
8119
|
+
if (descriptor !== void 0) return descriptor.value;
|
|
8120
|
+
}
|
|
8040
8121
|
if (isSandboxMap(current) || isSandboxSet(current)) return Object.getOwnPropertyDescriptor(getCollectionProperties(current), key)?.value;
|
|
8041
8122
|
if (isGuestClosure(current)) {
|
|
8042
8123
|
const entry = getGuestFunctionProperty(current, key);
|
|
@@ -8045,9 +8126,9 @@ function getSandboxDataProperty(value, key, budget) {
|
|
|
8045
8126
|
const properties = current.properties;
|
|
8046
8127
|
return properties !== void 0 && Object.hasOwn(properties, key) ? properties[key] : void 0;
|
|
8047
8128
|
}
|
|
8048
|
-
if (isSandboxMap(current) || isSandboxSet(current) || isSandboxPromise(current) || isSandboxRegex(current)
|
|
8129
|
+
if (isSandboxMap(current) || isSandboxSet(current) || isSandboxPromise(current) || isSandboxRegex(current))
|
|
8049
8130
|
return void 0;
|
|
8050
|
-
if (!isSandboxClosure(current) && Object.hasOwn(current, key)) return current[key];
|
|
8131
|
+
if (!isSandboxClosure(current) && !isSandboxGenerator(current) && Object.hasOwn(current, key)) return current[key];
|
|
8051
8132
|
current = getSandboxPrototype(current, budget);
|
|
8052
8133
|
if (current !== null) {
|
|
8053
8134
|
budget?.visitNode();
|
|
@@ -8060,7 +8141,7 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
8060
8141
|
if (budget !== void 0 && intrinsicPrototypes.get(budget) === value && prototype !== null) {
|
|
8061
8142
|
throw new TypeError("Object.prototype has an immutable null prototype.");
|
|
8062
8143
|
}
|
|
8063
|
-
if (!Array.isArray(value) && !isSandboxDate(value) && !isSandboxPromise(value) && !isSandboxRegex(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isPrototypeRecord(value) || prototype !== null && !Array.isArray(prototype) && !isSandboxDate(prototype) && !isSandboxPromise(prototype) && !isSandboxRegex(prototype) && !isSandboxMap(prototype) && !isSandboxSet(prototype) && !isPrototypeRecord(prototype)) {
|
|
8144
|
+
if (!Array.isArray(value) && !isSandboxGenerator(value) && !isSandboxDate(value) && !isSandboxPromise(value) && !isSandboxRegex(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isPrototypeRecord(value) || prototype !== null && !Array.isArray(prototype) && !isSandboxGenerator(prototype) && !isSandboxDate(prototype) && !isSandboxPromise(prototype) && !isSandboxRegex(prototype) && !isSandboxMap(prototype) && !isSandboxSet(prototype) && !isPrototypeRecord(prototype)) {
|
|
8064
8145
|
throw new TypeError(
|
|
8065
8146
|
"Prototype links require supported sandbox objects."
|
|
8066
8147
|
);
|
|
@@ -8069,7 +8150,7 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
8069
8150
|
if (prototype === null) prototypes.set(value, null);
|
|
8070
8151
|
return;
|
|
8071
8152
|
}
|
|
8072
|
-
if (!Object.isExtensible(isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value)) {
|
|
8153
|
+
if (!Object.isExtensible(isSandboxGenerator(value) ? getGeneratorProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value)) {
|
|
8073
8154
|
throw new TypeError("Cannot change the prototype of a non-extensible object.");
|
|
8074
8155
|
}
|
|
8075
8156
|
let depth = 0;
|
|
@@ -8126,7 +8207,7 @@ function isRawJson(value) {
|
|
|
8126
8207
|
import { types as nodeTypes } from "node:util";
|
|
8127
8208
|
|
|
8128
8209
|
// packages/safe-js/src/interp/promise-tracker.ts
|
|
8129
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8210
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
8130
8211
|
var SandboxPromiseRejectionTracker = class {
|
|
8131
8212
|
records = /* @__PURE__ */ new Set();
|
|
8132
8213
|
recordsByPromise = /* @__PURE__ */ new WeakMap();
|
|
@@ -8203,8 +8284,8 @@ var SandboxPromiseRejectionTracker = class {
|
|
|
8203
8284
|
return void 0;
|
|
8204
8285
|
}
|
|
8205
8286
|
};
|
|
8206
|
-
var activePromiseTracker = new
|
|
8207
|
-
var fatalRejectionCleanup = new
|
|
8287
|
+
var activePromiseTracker = new AsyncLocalStorage2();
|
|
8288
|
+
var fatalRejectionCleanup = new AsyncLocalStorage2();
|
|
8208
8289
|
function assertPromiseExecutionAllowed() {
|
|
8209
8290
|
const failure = activePromiseTracker.getStore()?.failure;
|
|
8210
8291
|
if (failure !== void 0 && fatalRejectionCleanup.getStore() !== true) throw failure;
|
|
@@ -8766,55 +8847,6 @@ function isLineTerminator(character) {
|
|
|
8766
8847
|
return character === "\n" || character === "\r" || character === "\u2028" || character === "\u2029";
|
|
8767
8848
|
}
|
|
8768
8849
|
|
|
8769
|
-
// packages/safe-js/src/interp/resources.ts
|
|
8770
|
-
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
8771
|
-
var runResources = new AsyncLocalStorage2();
|
|
8772
|
-
function retainValues(budget, values) {
|
|
8773
|
-
const retained = {};
|
|
8774
|
-
budget.setRetainedValues(retained, values);
|
|
8775
|
-
const pending = runResources.getStore()?.referenceReleases;
|
|
8776
|
-
const release = () => {
|
|
8777
|
-
budget.setRetainedValues(retained, void 0);
|
|
8778
|
-
pending?.delete(release);
|
|
8779
|
-
};
|
|
8780
|
-
pending?.add(release);
|
|
8781
|
-
return release;
|
|
8782
|
-
}
|
|
8783
|
-
async function withRunResources(signal, execute) {
|
|
8784
|
-
const controller = new AbortController();
|
|
8785
|
-
const cancel = () => controller.abort(signal?.reason);
|
|
8786
|
-
const cleanups = /* @__PURE__ */ new Set();
|
|
8787
|
-
const resources = {
|
|
8788
|
-
signal: controller.signal,
|
|
8789
|
-
referenceReleases: /* @__PURE__ */ new Set(),
|
|
8790
|
-
add(close) {
|
|
8791
|
-
cleanups.add(close);
|
|
8792
|
-
}
|
|
8793
|
-
};
|
|
8794
|
-
signal?.addEventListener("abort", cancel, { once: true });
|
|
8795
|
-
if (signal?.aborted) cancel();
|
|
8796
|
-
let result;
|
|
8797
|
-
let failure;
|
|
8798
|
-
let errors = [];
|
|
8799
|
-
try {
|
|
8800
|
-
result = await runResources.run(resources, execute);
|
|
8801
|
-
} catch (error) {
|
|
8802
|
-
failure = { reason: error };
|
|
8803
|
-
} finally {
|
|
8804
|
-
signal?.removeEventListener("abort", cancel);
|
|
8805
|
-
controller.abort(new Error("SafeJS run finished."));
|
|
8806
|
-
for (const release of resources.referenceReleases) release();
|
|
8807
|
-
resources.referenceReleases.clear();
|
|
8808
|
-
const outcomes = await Promise.allSettled(
|
|
8809
|
-
[...cleanups].map((close) => Promise.resolve().then(close))
|
|
8810
|
-
);
|
|
8811
|
-
errors = outcomes.flatMap((outcome) => outcome.status === "rejected" ? [outcome.reason] : []);
|
|
8812
|
-
}
|
|
8813
|
-
if (failure !== void 0) throw failure.reason;
|
|
8814
|
-
if (errors.length > 0) throw new AggregateError(errors, "SafeJS resource cleanup failed.");
|
|
8815
|
-
return result;
|
|
8816
|
-
}
|
|
8817
|
-
|
|
8818
8850
|
// packages/safe-js/src/interp/bigint-operators.ts
|
|
8819
8851
|
function bigIntOperation(operator, left, right, budget) {
|
|
8820
8852
|
if (operator === ">>>") throw new TypeError("BigInts have no unsigned right shift.");
|
|
@@ -9384,7 +9416,10 @@ async function restoreSandboxIterator(snapshot, budget, context, signal) {
|
|
|
9384
9416
|
if (snapshot.kind === "guest") return guestIterator(snapshot.value, snapshot.next, snapshot.async, budget, context, signal);
|
|
9385
9417
|
if (snapshot.kind === "async-from-sync") return asyncFromSyncIterator(await restoreSandboxIterator(snapshot.inner, budget, context, signal), budget, signal, context);
|
|
9386
9418
|
if (Array.isArray(snapshot.value)) return arrayIterator(snapshot.value, context, budget, snapshot.index);
|
|
9387
|
-
const iterator = isSandboxGenerator(snapshot.value)
|
|
9419
|
+
const iterator = isSandboxGenerator(snapshot.value) ? {
|
|
9420
|
+
...generatorObjectIterator(snapshot.value, budget, context),
|
|
9421
|
+
...snapshot.value.async ? { asyncProtocol: true } : {}
|
|
9422
|
+
} : getSandboxIterator(snapshot.value, budget, context);
|
|
9388
9423
|
if (iterator === void 0) throw new TypeError("Invalid builtin iterator snapshot.");
|
|
9389
9424
|
for (let index = 0; index < snapshot.index; index++) await iterator.next();
|
|
9390
9425
|
return iterator;
|
|
@@ -9394,6 +9429,11 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
|
|
|
9394
9429
|
if (context.getProperty === void 0 || isGuestHostObject(value))
|
|
9395
9430
|
return asyncProtocol ? getSandboxAsyncIterator(value, budget, context, signal) : getSandboxIterator(value, budget, context);
|
|
9396
9431
|
if (getSandboxPropertyDescriptor(value, key, budget) === void 0 && !(isSandboxRegExpIterator(value) && !asyncProtocol && getSandboxPropertyDescriptor(value, "next", budget) !== void 0)) {
|
|
9432
|
+
if (isSandboxGenerator(value)) {
|
|
9433
|
+
if (hasExplicitSandboxPrototype(value)) return void 0;
|
|
9434
|
+
if (value.async === true === asyncProtocol && getSandboxPropertyDescriptor(value, "next", budget) !== void 0)
|
|
9435
|
+
return guestIterator(value, await context.getProperty(value, "next"), asyncProtocol, budget, context, signal);
|
|
9436
|
+
}
|
|
9397
9437
|
if (!asyncProtocol && Array.isArray(value) && getSandboxPrototype(value, budget) !== null) return void 0;
|
|
9398
9438
|
if (!asyncProtocol) return getSandboxIterator(value, budget, context);
|
|
9399
9439
|
if (isSandboxGenerator(value) && value.async)
|
|
@@ -9458,7 +9498,7 @@ async function readIteratorResult(iterator, result, property) {
|
|
|
9458
9498
|
}
|
|
9459
9499
|
function getSandboxAsyncIterator(value, budget, context, signal) {
|
|
9460
9500
|
if (isSandboxGenerator(value) && value.async) {
|
|
9461
|
-
return { ...
|
|
9501
|
+
return hasExplicitSandboxPrototype(value) ? void 0 : { ...generatorObjectIterator(value, budget, context), asyncProtocol: true };
|
|
9462
9502
|
}
|
|
9463
9503
|
if (value !== null && (typeof value === "object" || typeof value === "function") && !isGuestHostObject(value)) {
|
|
9464
9504
|
const method = value[Symbol.asyncIterator];
|
|
@@ -9608,7 +9648,7 @@ function getSandboxIterator(value, budget, context) {
|
|
|
9608
9648
|
return syncIterator(Float32Array.prototype.values.call(value));
|
|
9609
9649
|
}
|
|
9610
9650
|
if (isSandboxGenerator(value)) {
|
|
9611
|
-
return value.async ? void 0 :
|
|
9651
|
+
return value.async || hasExplicitSandboxPrototype(value) ? void 0 : generatorObjectIterator(value, budget, context);
|
|
9612
9652
|
}
|
|
9613
9653
|
if (typeof value === "string") {
|
|
9614
9654
|
const iterator2 = value[Symbol.iterator]();
|
|
@@ -9685,6 +9725,26 @@ function collectionIterator(collection, value) {
|
|
|
9685
9725
|
return adapter;
|
|
9686
9726
|
}
|
|
9687
9727
|
var asyncGeneratorRequests = /* @__PURE__ */ new WeakMap();
|
|
9728
|
+
function generatorObjectIterator(generator, budget, context) {
|
|
9729
|
+
const iterator = generatorIterator(generator, budget, context);
|
|
9730
|
+
if (context?.getProperty === void 0) return iterator;
|
|
9731
|
+
return {
|
|
9732
|
+
...iterator,
|
|
9733
|
+
getOperation: async (method) => {
|
|
9734
|
+
if (method === "next" || !hasExplicitSandboxPrototype(generator) && getSandboxPropertyDescriptor(generator, method, budget) === void 0) return iterator[method];
|
|
9735
|
+
const operation = await context.getProperty(generator, method);
|
|
9736
|
+
if (operation === void 0 || operation === null) return void 0;
|
|
9737
|
+
if (!isSandboxClosure(operation)) throw new TypeError("Iterator operation must be callable.");
|
|
9738
|
+
return async (...args) => {
|
|
9739
|
+
const result = await invokeBuiltinClosure(operation, args, budget ?? new Budget(), context, generator);
|
|
9740
|
+
return generator.async ? await awaitSandboxValue(result, void 0, budget, context) : result;
|
|
9741
|
+
};
|
|
9742
|
+
},
|
|
9743
|
+
readResultProperty: async (result, property) => ({
|
|
9744
|
+
value: await context.getProperty(result, property)
|
|
9745
|
+
})
|
|
9746
|
+
};
|
|
9747
|
+
}
|
|
9688
9748
|
function generatorIterator(generator, budget, context) {
|
|
9689
9749
|
const invoke = async (method, value) => {
|
|
9690
9750
|
const leaveRunning = enterRunningState(generator);
|
|
@@ -13006,14 +13066,14 @@ function createObjectArrayGlobals(options) {
|
|
|
13006
13066
|
call: ([value]) => {
|
|
13007
13067
|
if (isGuestHostObject(value))
|
|
13008
13068
|
throw new TypeError("Live host objects cannot be made non-extensible.");
|
|
13009
|
-
Object.preventExtensions(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
|
|
13069
|
+
Object.preventExtensions(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
|
|
13010
13070
|
return value;
|
|
13011
13071
|
},
|
|
13012
13072
|
name: "preventExtensions"
|
|
13013
13073
|
}),
|
|
13014
13074
|
isExtensible: createSandboxClosure({
|
|
13015
13075
|
sandbox: true,
|
|
13016
|
-
call: ([value]) => Object.isExtensible(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
|
|
13076
|
+
call: ([value]) => Object.isExtensible(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
|
|
13017
13077
|
name: "isExtensible"
|
|
13018
13078
|
}),
|
|
13019
13079
|
seal: createSandboxClosure({
|
|
@@ -13021,14 +13081,14 @@ function createObjectArrayGlobals(options) {
|
|
|
13021
13081
|
call: ([value]) => {
|
|
13022
13082
|
if (isGuestHostObject(value))
|
|
13023
13083
|
throw new TypeError("Live host objects cannot be sealed.");
|
|
13024
|
-
Object.seal(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
|
|
13084
|
+
Object.seal(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
|
|
13025
13085
|
return value;
|
|
13026
13086
|
},
|
|
13027
13087
|
name: "seal"
|
|
13028
13088
|
}),
|
|
13029
13089
|
isSealed: createSandboxClosure({
|
|
13030
13090
|
sandbox: true,
|
|
13031
|
-
call: ([value]) => Object.isSealed(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
|
|
13091
|
+
call: ([value]) => Object.isSealed(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
|
|
13032
13092
|
name: "isSealed"
|
|
13033
13093
|
}),
|
|
13034
13094
|
freeze: createSandboxClosure({
|
|
@@ -13037,7 +13097,7 @@ function createObjectArrayGlobals(options) {
|
|
|
13037
13097
|
if (isGuestHostObject(value))
|
|
13038
13098
|
throw new TypeError("Live host objects cannot be frozen.");
|
|
13039
13099
|
if (typeof value === "object" && value !== null) {
|
|
13040
|
-
Object.freeze(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
|
|
13100
|
+
Object.freeze(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value);
|
|
13041
13101
|
}
|
|
13042
13102
|
return value;
|
|
13043
13103
|
},
|
|
@@ -13045,7 +13105,7 @@ function createObjectArrayGlobals(options) {
|
|
|
13045
13105
|
}),
|
|
13046
13106
|
isFrozen: createSandboxClosure({
|
|
13047
13107
|
sandbox: true,
|
|
13048
|
-
call: ([value]) => Object.isFrozen(isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
|
|
13108
|
+
call: ([value]) => Object.isFrozen(isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isGuestClosure(value) ? materializeFunctionProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : value),
|
|
13049
13109
|
name: "isFrozen"
|
|
13050
13110
|
}),
|
|
13051
13111
|
assign: createSandboxClosure({
|
|
@@ -13388,6 +13448,7 @@ function reflectionProperties(value) {
|
|
|
13388
13448
|
return objectProperties(value);
|
|
13389
13449
|
}
|
|
13390
13450
|
function objectProperties(value, mutable = false) {
|
|
13451
|
+
if (isSandboxGenerator(value)) return getGeneratorProperties(value);
|
|
13391
13452
|
if (isSandboxPromise(value)) return getPromiseProperties(value);
|
|
13392
13453
|
if (isSandboxMap(value) || isSandboxSet(value)) return getCollectionProperties(value);
|
|
13393
13454
|
if (isSandboxRegex(value)) return getRegexProperties(value);
|
|
@@ -13929,7 +13990,7 @@ function getFunctionMember(target, property, options) {
|
|
|
13929
13990
|
} else if (Object.hasOwn(current, String(property))) {
|
|
13930
13991
|
return current[String(property)];
|
|
13931
13992
|
}
|
|
13932
|
-
if (isSandboxClosure(current) && !hasExplicitSandboxPrototype(current)) break;
|
|
13993
|
+
if (isSandboxClosure(current) && !hasExplicitSandboxPrototype(current) && getSandboxPrototype(current, options.budget) === null) break;
|
|
13933
13994
|
current = getSandboxPrototype(current, options.budget);
|
|
13934
13995
|
if (current !== null) {
|
|
13935
13996
|
options.budget?.visitNode();
|
|
@@ -16192,7 +16253,7 @@ function forInKeys(object, budget) {
|
|
|
16192
16253
|
for (let current = object; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
16193
16254
|
if (depth > 0) budget.visitNode();
|
|
16194
16255
|
assertSandboxDataDepth(depth++);
|
|
16195
|
-
const properties = isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
16256
|
+
const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
16196
16257
|
for (const key of Object.getOwnPropertyNames(properties)) {
|
|
16197
16258
|
if (seen.has(key)) continue;
|
|
16198
16259
|
seen.add(key);
|
|
@@ -16208,7 +16269,7 @@ function hasForInProperty(object, key, budget) {
|
|
|
16208
16269
|
for (let current = object; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
16209
16270
|
if (depth > 0) budget.visitNode();
|
|
16210
16271
|
assertSandboxDataDepth(depth++);
|
|
16211
|
-
const properties = isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
16272
|
+
const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? materializeFunctionProperties(current) : isSandboxClosure(current) ? current.properties ?? {} : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
16212
16273
|
if (Object.hasOwn(properties, key)) return true;
|
|
16213
16274
|
}
|
|
16214
16275
|
return false;
|
|
@@ -16764,7 +16825,7 @@ function getPropertyValue(target, property, context, receiver = target) {
|
|
|
16764
16825
|
if (isSandboxSet(target)) return getSandboxPrototype(target, context.budget) === null ? getSetMember(target, property, createSetMethodOptions(context)) : void 0;
|
|
16765
16826
|
if (isSandboxCollectionIterator(target))
|
|
16766
16827
|
return getCollectionIteratorMember(target, property, context.budget);
|
|
16767
|
-
if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
|
|
16828
|
+
if (isSandboxGenerator(target)) return hasExplicitSandboxPrototype(target) ? void 0 : getGeneratorMember(target, property, context.budget);
|
|
16768
16829
|
if (isSandboxClosure(target)) return getClosureMemberValue(target, property, context);
|
|
16769
16830
|
if (isSandboxPromise(target)) return hasExplicitSandboxPrototype(target) ? void 0 : getPromiseMember(property, context.budget);
|
|
16770
16831
|
if (isSandboxRegex(target)) return hasExplicitSandboxPrototype(target) || getSandboxPrototype(target, context.budget) !== null ? void 0 : getRegexMember(target, property, context.budget, createCoercionContext(context));
|
|
@@ -17080,7 +17141,7 @@ async function evaluateMemberCallExpression(node, context) {
|
|
|
17080
17141
|
);
|
|
17081
17142
|
}
|
|
17082
17143
|
if (isSandboxGenerator(member.object)) {
|
|
17083
|
-
const memberValue =
|
|
17144
|
+
const memberValue = await getPropertyValue(member.object, member.property, context);
|
|
17084
17145
|
if (memberValue === void 0) {
|
|
17085
17146
|
throw new TypeError(`Generator#${String(member.property)} is not a supported method.`);
|
|
17086
17147
|
}
|
|
@@ -17384,7 +17445,7 @@ function hasSandboxProperty(value, key, context) {
|
|
|
17384
17445
|
while (typeof current === "object" && current !== null) {
|
|
17385
17446
|
if (isGuestHostObject(current)) return typeof key === "symbol" ? false : hasHostObjectMember(current, String(key));
|
|
17386
17447
|
if (hasOwnSandboxProperty(current, key, false)) return true;
|
|
17387
|
-
if (!isSandboxDate(current) && !isSandboxRegex(current) && !isSandboxMap(current) && !isSandboxSet(current) && !((isGuestClosure(current) || Array.isArray(current)) && hasExplicitSandboxPrototype(current)) && (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current) || isSandboxRegExpIterator(current))) {
|
|
17448
|
+
if (!isSandboxDate(current) && !isSandboxRegex(current) && !isSandboxMap(current) && !isSandboxSet(current) && !((isGuestClosure(current) || isSandboxGenerator(current) || Array.isArray(current)) && hasExplicitSandboxPrototype(current)) && (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current) || isSandboxRegExpIterator(current))) {
|
|
17388
17449
|
return getPropertyValue(current, key, context) !== void 0;
|
|
17389
17450
|
}
|
|
17390
17451
|
current = getSandboxPrototype(current, context.budget);
|
|
@@ -17630,6 +17691,7 @@ function setSandboxProperty(target, property, value, budget, checkInherited = tr
|
|
|
17630
17691
|
}
|
|
17631
17692
|
if (isGuestClosure(target)) target = materializeFunctionProperties(target);
|
|
17632
17693
|
if (isSandboxPromise(target)) target = getPromiseProperties(target);
|
|
17694
|
+
if (isSandboxGenerator(target)) target = getGeneratorProperties(target);
|
|
17633
17695
|
if (isSandboxMap(target) || isSandboxSet(target)) target = getCollectionProperties(target);
|
|
17634
17696
|
if (isFloat32Array(target)) {
|
|
17635
17697
|
if (typeof property === "symbol") throw new TypeError("Typed array symbol properties are not yet supported.");
|
|
@@ -17663,7 +17725,7 @@ function setSandboxProperty(target, property, value, budget, checkInherited = tr
|
|
|
17663
17725
|
for (let prototype = getSandboxPrototype(prototypeOwner, budget); prototype !== null; prototype = getSandboxPrototype(prototype, budget)) {
|
|
17664
17726
|
budget.visitNode();
|
|
17665
17727
|
assertSandboxDataDepth(depth++);
|
|
17666
|
-
const properties = isSandboxClosure(prototype) ? prototype.properties : prototype;
|
|
17728
|
+
const properties = isSandboxGenerator(prototype) ? getGeneratorProperties(prototype) : isSandboxClosure(prototype) ? prototype.properties : prototype;
|
|
17667
17729
|
const inherited = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key);
|
|
17668
17730
|
if (inherited === void 0) continue;
|
|
17669
17731
|
if (inherited.writable !== true)
|
|
@@ -17682,7 +17744,7 @@ function setSuperProperty(base, receiver, key, value, context) {
|
|
|
17682
17744
|
for (let current = base; current !== null; current = getSandboxPrototype(current, budget)) {
|
|
17683
17745
|
budget.visitNode();
|
|
17684
17746
|
assertSandboxDataDepth(depth++);
|
|
17685
|
-
const properties = isSandboxClosure(current) ? current.properties : current;
|
|
17747
|
+
const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxClosure(current) ? current.properties : current;
|
|
17686
17748
|
const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, key);
|
|
17687
17749
|
if (descriptor === void 0) continue;
|
|
17688
17750
|
if (!("value" in descriptor))
|
|
@@ -17700,6 +17762,7 @@ function deleteSandboxProperty(target, property) {
|
|
|
17700
17762
|
if (isGuestClosure(target)) target = materializeFunctionProperties(target);
|
|
17701
17763
|
if (isSandboxRegex(target)) target = getRegexProperties(target);
|
|
17702
17764
|
if (isSandboxPromise(target)) target = getPromiseProperties(target);
|
|
17765
|
+
if (isSandboxGenerator(target)) target = getGeneratorProperties(target);
|
|
17703
17766
|
if (isSandboxMap(target) || isSandboxSet(target)) target = getCollectionProperties(target);
|
|
17704
17767
|
if (Array.isArray(target)) {
|
|
17705
17768
|
assertCollectionMutable(target);
|
|
@@ -18266,11 +18329,11 @@ async function objectToPrimitive(value, budget, context, joining, hint, ordinary
|
|
|
18266
18329
|
}
|
|
18267
18330
|
}
|
|
18268
18331
|
function conversionHook(value, name, budget, context) {
|
|
18269
|
-
const implicitBuiltin = !hasExplicitSandboxPrototype(value) && (Array.isArray(value) && getSandboxPrototype(value, budget) === null || isFloat32Array(value) || sandboxErrorTypes.has(value) || isSandboxClosure(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxPromise(value) || isSandboxRegex(value) && getSandboxPrototype(value, budget) === null || isSandboxGenerator(value) || isGuestHostObject(value));
|
|
18332
|
+
const implicitBuiltin = !hasExplicitSandboxPrototype(value) && (Array.isArray(value) && getSandboxPrototype(value, budget) === null || isFloat32Array(value) || sandboxErrorTypes.has(value) || isSandboxClosure(value) && getSandboxPrototype(value, budget) === null || isSandboxMap(value) || isSandboxSet(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxPromise(value) || isSandboxRegex(value) && getSandboxPrototype(value, budget) === null || isSandboxGenerator(value) || isGuestHostObject(value));
|
|
18270
18333
|
let current = value;
|
|
18271
18334
|
let depth = 0;
|
|
18272
18335
|
while (current !== null) {
|
|
18273
|
-
const properties = isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
18336
|
+
const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
18274
18337
|
const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, name);
|
|
18275
18338
|
if (descriptor !== void 0) {
|
|
18276
18339
|
return readPropertyDescriptor(descriptor, value, context);
|
|
@@ -18483,8 +18546,7 @@ function hasOwnSandboxProperty(value, key, enumerable) {
|
|
|
18483
18546
|
properties = value.properties ?? /* @__PURE__ */ Object.create(null);
|
|
18484
18547
|
} else if (isSandboxMap(value) || isSandboxSet(value)) properties = getCollectionProperties(value);
|
|
18485
18548
|
else if (isSandboxPromise(value)) properties = getPromiseProperties(value);
|
|
18486
|
-
else if (isSandboxGenerator(value))
|
|
18487
|
-
return false;
|
|
18549
|
+
else if (isSandboxGenerator(value)) properties = getGeneratorProperties(value);
|
|
18488
18550
|
else if (isSandboxRegex(value)) properties = getRegexProperties(value);
|
|
18489
18551
|
else properties = Object(value);
|
|
18490
18552
|
const descriptor = Object.getOwnPropertyDescriptor(properties, key);
|
|
@@ -20153,6 +20215,7 @@ function captureGuestHeapNode(value, encode) {
|
|
|
20153
20215
|
state: value.state,
|
|
20154
20216
|
astNodeId: origin2.node.nodeId,
|
|
20155
20217
|
async: value.async === true,
|
|
20218
|
+
objectState: captureObjectState(value, encode),
|
|
20156
20219
|
scope: encode(origin2.scope),
|
|
20157
20220
|
closureScope: encode(origin2.closureScope),
|
|
20158
20221
|
...value.state !== "suspended" || origin2.suspendedScope === void 0 ? {} : { suspendedScope: encode(origin2.suspendedScope) },
|
|
@@ -20268,6 +20331,7 @@ function captureGuestHeapNode(value, encode) {
|
|
|
20268
20331
|
}
|
|
20269
20332
|
function captureObjectState(value, encode) {
|
|
20270
20333
|
let properties = value;
|
|
20334
|
+
if (isSandboxGenerator(value)) properties = getGeneratorProperties(value);
|
|
20271
20335
|
if (isSandboxClosure(value)) {
|
|
20272
20336
|
properties = value.properties;
|
|
20273
20337
|
if (isGuestClosure(value)) properties = materializeFunctionProperties(value);
|
|
@@ -23854,6 +23918,31 @@ function createUriGlobals(budget) {
|
|
|
23854
23918
|
}));
|
|
23855
23919
|
}
|
|
23856
23920
|
|
|
23921
|
+
// packages/safe-js/src/interp/globals/function.ts
|
|
23922
|
+
function createFunctionPrototype(budget) {
|
|
23923
|
+
const prototype = createSandboxClosure({ guest: true, sandbox: true, name: "", length: 0, call: () => void 0 });
|
|
23924
|
+
const properties = materializeFunctionProperties(prototype);
|
|
23925
|
+
Object.defineProperty(properties, "constructor", { value: void 0, writable: true, configurable: true });
|
|
23926
|
+
for (const [name, length] of [["call", 1], ["apply", 2], ["bind", 1], ["toString", 0]]) {
|
|
23927
|
+
Object.defineProperty(properties, name, {
|
|
23928
|
+
writable: true,
|
|
23929
|
+
configurable: true,
|
|
23930
|
+
value: createSandboxClosure({
|
|
23931
|
+
guest: true,
|
|
23932
|
+
sandbox: true,
|
|
23933
|
+
name,
|
|
23934
|
+
length,
|
|
23935
|
+
call: (args, context) => callFunctionMethod(context?.thisValue, name, args, {
|
|
23936
|
+
budget,
|
|
23937
|
+
callClosure: (target, values, stack, thisValue, construct, newTarget) => context?.invokeClosure !== void 0 ? context.invokeClosure(target, values, thisValue, construct, newTarget) : invokeBuiltinClosure(target, values, budget, { ...context, stack, thisValue, newTarget }, thisValue, construct)
|
|
23938
|
+
}, context?.stack ?? [], context)
|
|
23939
|
+
})
|
|
23940
|
+
});
|
|
23941
|
+
}
|
|
23942
|
+
setSandboxPrototype(prototype, getSandboxPrototype(/* @__PURE__ */ Object.create(null), budget));
|
|
23943
|
+
installFunctionPrototype(budget, prototype);
|
|
23944
|
+
}
|
|
23945
|
+
|
|
23857
23946
|
// packages/safe-js/src/interp/globals/symbol.ts
|
|
23858
23947
|
var registries = /* @__PURE__ */ new WeakMap();
|
|
23859
23948
|
function createSymbolGlobal(budget) {
|
|
@@ -24084,6 +24173,7 @@ function createBuiltinBindings(options) {
|
|
|
24084
24173
|
...createPromiseGlobals(options),
|
|
24085
24174
|
...createRegexGlobals(options)
|
|
24086
24175
|
};
|
|
24176
|
+
createFunctionPrototype(options.budget);
|
|
24087
24177
|
registerBuiltinIdentities(options.budget, bindings);
|
|
24088
24178
|
return bindings;
|
|
24089
24179
|
}
|
|
@@ -24254,7 +24344,8 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
24254
24344
|
}
|
|
24255
24345
|
state(node.state);
|
|
24256
24346
|
} else if (node.kind === "guest-generator") {
|
|
24257
|
-
fields(node, ["kind", "state", "astNodeId", "async", "scope", "closureScope", "sent"], ["suspendedScope", "yieldNodeId", "environment", "blockScopes", "finallyCompletions", "expressionStates"]);
|
|
24347
|
+
fields(node, ["kind", "state", "astNodeId", "async", "scope", "closureScope", "sent"], ["suspendedScope", "yieldNodeId", "environment", "blockScopes", "finallyCompletions", "expressionStates", "objectState"]);
|
|
24348
|
+
if (Object.hasOwn(node, "objectState")) state(node.objectState);
|
|
24258
24349
|
if (!["start", "running", "suspended", "done"].includes(String(node.state)) || typeof node.async !== "boolean" || integer(node.astNodeId) < 1)
|
|
24259
24350
|
throw new TypeError("Invalid generator state.");
|
|
24260
24351
|
reference(node.scope, ["scope-frame"]);
|
|
@@ -25767,6 +25858,7 @@ function ownEnumerableSandboxEntries(value, excludedKeys) {
|
|
|
25767
25858
|
if (isGuestClosure(value)) entries = Object.entries(value.properties ?? {});
|
|
25768
25859
|
else if (isSandboxRegex(value)) entries = Object.entries(getRegexProperties(value));
|
|
25769
25860
|
else if (isSandboxPromise(value)) entries = Object.entries(getPromiseProperties(value));
|
|
25861
|
+
else if (isSandboxGenerator(value)) entries = Object.entries(getGeneratorProperties(value));
|
|
25770
25862
|
else if (isSandboxMap(value) || isSandboxSet(value)) entries = Object.entries(getCollectionProperties(value));
|
|
25771
25863
|
else if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
25772
25864
|
else entries = Object.entries(Object(value));
|
|
@@ -25778,19 +25870,20 @@ function ownSandboxSymbolKeys(value) {
|
|
|
25778
25870
|
if (isSandboxClosure(value)) value = value.properties ?? {};
|
|
25779
25871
|
else if (isSandboxRegex(value)) value = getRegexProperties(value);
|
|
25780
25872
|
else if (isSandboxPromise(value)) value = getPromiseProperties(value);
|
|
25873
|
+
else if (isSandboxGenerator(value)) value = getGeneratorProperties(value);
|
|
25781
25874
|
else if (isSandboxMap(value) || isSandboxSet(value)) value = getCollectionProperties(value);
|
|
25782
|
-
else if (isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
25783
25875
|
return Object.getOwnPropertySymbols(Object(value)).filter((key) => !internalSymbols.has(key));
|
|
25784
25876
|
}
|
|
25785
25877
|
function ownEnumerableSandboxKeys(value, includeSymbols = false) {
|
|
25786
25878
|
if (includeSymbols) {
|
|
25787
|
-
const properties = isSandboxClosure(value) ? value.properties ?? {} : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : Object(value);
|
|
25879
|
+
const properties = isSandboxClosure(value) ? value.properties ?? {} : isSandboxGenerator(value) ? getGeneratorProperties(value) : isSandboxPromise(value) ? getPromiseProperties(value) : isSandboxRegex(value) ? getRegexProperties(value) : isSandboxMap(value) || isSandboxSet(value) ? getCollectionProperties(value) : Object(value);
|
|
25788
25880
|
return [...ownEnumerableSandboxKeys(value), ...ownSandboxSymbolKeys(value).filter((key) => Object.getOwnPropertyDescriptor(properties, key)?.enumerable === true)];
|
|
25789
25881
|
}
|
|
25790
25882
|
if (isGuestHostObject(value)) return getHostObjectKeys(value);
|
|
25791
25883
|
if (value === null || value === void 0) throw new TypeError("Cannot convert undefined or null to object.");
|
|
25792
25884
|
if (isGuestClosure(value)) return Object.keys(value.properties ?? {});
|
|
25793
25885
|
if (isSandboxPromise(value)) return Object.keys(getPromiseProperties(value));
|
|
25886
|
+
if (isSandboxGenerator(value)) return Object.keys(getGeneratorProperties(value));
|
|
25794
25887
|
if (isSandboxRegex(value)) return Object.keys(getRegexProperties(value));
|
|
25795
25888
|
if (isSandboxMap(value) || isSandboxSet(value)) return Object.keys(getCollectionProperties(value));
|
|
25796
25889
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxPromise(value) || isSandboxRegex(value)) return [];
|
|
@@ -25842,6 +25935,7 @@ function createSandboxGenerator(channel, metadata = void 0) {
|
|
|
25842
25935
|
enumerable: false,
|
|
25843
25936
|
value: true
|
|
25844
25937
|
});
|
|
25938
|
+
getGeneratorProperties(generator);
|
|
25845
25939
|
return generator;
|
|
25846
25940
|
}
|
|
25847
25941
|
function createSandboxMap(entries = []) {
|
|
@@ -26096,6 +26190,14 @@ function measureSandboxData(values, options = {}) {
|
|
|
26096
26190
|
return;
|
|
26097
26191
|
}
|
|
26098
26192
|
if (isSandboxGenerator(value)) {
|
|
26193
|
+
const descriptors3 = Object.getOwnPropertyDescriptors(getGeneratorProperties(value));
|
|
26194
|
+
for (const key of Reflect.ownKeys(descriptors3)) {
|
|
26195
|
+
const descriptor = descriptors3[key];
|
|
26196
|
+
usage += typeof key === "string" ? key.length + 1 : 1;
|
|
26197
|
+
if (typeof key === "symbol") visit(key, depth + 1);
|
|
26198
|
+
if ("value" in descriptor) visit(descriptor.value, depth + 1);
|
|
26199
|
+
else for (const closure of retainedAccessorClosures(descriptor)) visit(closure, depth + 1);
|
|
26200
|
+
}
|
|
26099
26201
|
const snapshot = value.channel.snapshot();
|
|
26100
26202
|
usage += snapshot.sent.length;
|
|
26101
26203
|
for (const completion of snapshot.sent) visit(completion.value, depth + 1);
|
|
@@ -40889,12 +40991,12 @@ export {
|
|
|
40889
40991
|
safeAddEvent,
|
|
40890
40992
|
safeRecordException,
|
|
40891
40993
|
safeEndSpan,
|
|
40994
|
+
runResources,
|
|
40892
40995
|
defineExtension,
|
|
40893
40996
|
encodeReplayData,
|
|
40894
40997
|
HostOperationResumePolicyError,
|
|
40895
40998
|
registerPendingHostCallPolicy,
|
|
40896
40999
|
HostCallResumabilityError,
|
|
40897
|
-
runResources,
|
|
40898
41000
|
assertSnapshotInactive,
|
|
40899
41001
|
isSandboxClosure,
|
|
40900
41002
|
deepCopyToSandbox,
|
|
@@ -40922,4 +41024,4 @@ export {
|
|
|
40922
41024
|
FileSnapshotBackend,
|
|
40923
41025
|
run
|
|
40924
41026
|
};
|
|
40925
|
-
//# sourceMappingURL=chunk-
|
|
41027
|
+
//# sourceMappingURL=chunk-ONR2CYEH.js.map
|