@poe-platform/safe-js 0.1.301 → 0.1.303
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-R2SP3JEZ.js → chunk-5WFKY3Y3.js} +2 -2
- package/dist/safe-js/chunks/{chunk-M4L3EZHL.js → chunk-S5C5SAU4.js} +225 -73
- package/dist/safe-js/chunks/chunk-S5C5SAU4.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/async.d.ts +1 -1
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-M4L3EZHL.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-R2SP3JEZ.js.map → chunk-5WFKY3Y3.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-S5C5SAU4.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-5WFKY3Y3.js.map
|
|
@@ -7398,6 +7398,9 @@ function graphEntries(value) {
|
|
|
7398
7398
|
return entries;
|
|
7399
7399
|
}
|
|
7400
7400
|
|
|
7401
|
+
// packages/safe-js/src/interp/generator-prototypes.ts
|
|
7402
|
+
var generatorPrototypes = /* @__PURE__ */ new WeakMap();
|
|
7403
|
+
|
|
7401
7404
|
// packages/safe-js/src/interp/resources.ts
|
|
7402
7405
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7403
7406
|
var runResources = new AsyncLocalStorage();
|
|
@@ -8082,6 +8085,7 @@ function releaseObjectPrototype(budget) {
|
|
|
8082
8085
|
datePrototypes.delete(budget);
|
|
8083
8086
|
arrayPrototypes.delete(budget);
|
|
8084
8087
|
functionPrototypes.delete(budget);
|
|
8088
|
+
generatorPrototypes.delete(budget);
|
|
8085
8089
|
initialRegexDescriptors.delete(budget);
|
|
8086
8090
|
intrinsicPrototypes.delete(budget);
|
|
8087
8091
|
}
|
|
@@ -9455,13 +9459,12 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
|
|
|
9455
9459
|
return asyncProtocol ? getSandboxAsyncIterator(value, budget, context, signal) : getSandboxIterator(value, budget, context);
|
|
9456
9460
|
if (getSandboxPropertyDescriptor(value, key, budget) === void 0 && !(isSandboxRegExpIterator(value) && !asyncProtocol && getSandboxPropertyDescriptor(value, "next", budget) !== void 0)) {
|
|
9457
9461
|
if (isSandboxGenerator(value)) {
|
|
9458
|
-
if (hasExplicitSandboxPrototype(value))
|
|
9459
|
-
if (value.async === true === asyncProtocol && getSandboxPropertyDescriptor(value, "next", budget) !== void 0)
|
|
9462
|
+
if (!hasExplicitSandboxPrototype(value) && value.async === true === asyncProtocol && getSandboxPropertyDescriptor(value, "next", budget) !== void 0)
|
|
9460
9463
|
return guestIterator(value, await context.getProperty(value, "next"), asyncProtocol, budget, context, signal);
|
|
9461
9464
|
}
|
|
9462
9465
|
if (!asyncProtocol && Array.isArray(value) && getSandboxPrototype(value, budget) !== null) return void 0;
|
|
9463
9466
|
if (!asyncProtocol) return getSandboxIterator(value, budget, context);
|
|
9464
|
-
if (isSandboxGenerator(value) && value.async)
|
|
9467
|
+
if (isSandboxGenerator(value) && value.async && !hasExplicitSandboxPrototype(value))
|
|
9465
9468
|
return getSandboxAsyncIterator(value, budget, context, signal);
|
|
9466
9469
|
const iterator2 = await acquireSandboxIterator(value, budget, context);
|
|
9467
9470
|
return iterator2 === void 0 ? void 0 : asyncFromSyncIterator(iterator2, budget, signal, context);
|
|
@@ -9523,7 +9526,7 @@ async function readIteratorResult(iterator, result, property) {
|
|
|
9523
9526
|
}
|
|
9524
9527
|
function getSandboxAsyncIterator(value, budget, context, signal) {
|
|
9525
9528
|
if (isSandboxGenerator(value) && value.async) {
|
|
9526
|
-
return hasExplicitSandboxPrototype(value) ? void 0 : { ...generatorObjectIterator(value, budget, context), asyncProtocol: true };
|
|
9529
|
+
return hasExplicitSandboxPrototype(value) ? context?.getProperty === void 0 ? generatorProtocolAdapter(value, budget, context, true, signal) : void 0 : { ...generatorObjectIterator(value, budget, context), asyncProtocol: true };
|
|
9527
9530
|
}
|
|
9528
9531
|
if (value !== null && (typeof value === "object" || typeof value === "function") && !isGuestHostObject(value)) {
|
|
9529
9532
|
const method = value[Symbol.asyncIterator];
|
|
@@ -9673,7 +9676,9 @@ function getSandboxIterator(value, budget, context) {
|
|
|
9673
9676
|
return syncIterator(Float32Array.prototype.values.call(value));
|
|
9674
9677
|
}
|
|
9675
9678
|
if (isSandboxGenerator(value)) {
|
|
9676
|
-
|
|
9679
|
+
if (value.async) return void 0;
|
|
9680
|
+
if (hasExplicitSandboxPrototype(value)) return context?.getProperty === void 0 ? generatorProtocolAdapter(value, budget ?? new Budget(), context, false) : void 0;
|
|
9681
|
+
return generatorObjectIterator(value, budget, context);
|
|
9677
9682
|
}
|
|
9678
9683
|
if (typeof value === "string") {
|
|
9679
9684
|
const iterator2 = value[Symbol.iterator]();
|
|
@@ -9750,6 +9755,38 @@ function collectionIterator(collection, value) {
|
|
|
9750
9755
|
return adapter;
|
|
9751
9756
|
}
|
|
9752
9757
|
var asyncGeneratorRequests = /* @__PURE__ */ new WeakMap();
|
|
9758
|
+
function generatorProtocolAdapter(value, budget, context, asyncProtocol, signal) {
|
|
9759
|
+
const bridge = {
|
|
9760
|
+
...context,
|
|
9761
|
+
stack: context?.stack ?? [],
|
|
9762
|
+
thisValue: value,
|
|
9763
|
+
invokeClosure: (closure, args, receiver, construct) => invokeBuiltinClosure(closure, args, budget, context, receiver, construct),
|
|
9764
|
+
getProperty: (target, key) => {
|
|
9765
|
+
const descriptor = getSandboxPropertyDescriptor(target, key, budget);
|
|
9766
|
+
return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, target, bridge, true);
|
|
9767
|
+
}
|
|
9768
|
+
};
|
|
9769
|
+
let resolved;
|
|
9770
|
+
let pending;
|
|
9771
|
+
const initialize = () => pending ??= acquireSandboxIterator(value, budget, bridge, asyncProtocol, signal).then((iterator) => {
|
|
9772
|
+
if (iterator === void 0) throw new TypeError("Generator does not provide an iterator protocol.");
|
|
9773
|
+
return resolved = iterator;
|
|
9774
|
+
});
|
|
9775
|
+
return {
|
|
9776
|
+
asynchronous: true,
|
|
9777
|
+
...asyncProtocol ? { asyncProtocol: true } : {},
|
|
9778
|
+
get retainedValue() {
|
|
9779
|
+
return [value, resolved?.retainedValue];
|
|
9780
|
+
},
|
|
9781
|
+
snapshot: () => resolved?.snapshot?.() ?? { kind: "unsupported" },
|
|
9782
|
+
next: async (...args) => (await initialize()).next(...args),
|
|
9783
|
+
getOperation: async (method) => {
|
|
9784
|
+
const iterator = await initialize();
|
|
9785
|
+
return iterator.getOperation === void 0 ? iterator[method] : iterator.getOperation(method);
|
|
9786
|
+
},
|
|
9787
|
+
readResultProperty: async (result, property) => readIteratorResult(await initialize(), result, property)
|
|
9788
|
+
};
|
|
9789
|
+
}
|
|
9753
9790
|
function generatorObjectIterator(generator, budget, context) {
|
|
9754
9791
|
const iterator = generatorIterator(generator, budget, context);
|
|
9755
9792
|
if (context?.getProperty === void 0) return iterator;
|
|
@@ -10225,12 +10262,12 @@ async function evaluateFunctionExpression(node, context, evaluateNode2) {
|
|
|
10225
10262
|
value: closure
|
|
10226
10263
|
};
|
|
10227
10264
|
}
|
|
10228
|
-
function createInterpretedClosure(node, context, evaluateNode2, homeObject) {
|
|
10265
|
+
function createInterpretedClosure(node, context, evaluateNode2, homeObject, initializeGeneratorPrototype = true) {
|
|
10229
10266
|
if (node.type !== "ArrowFunctionExpression") {
|
|
10230
10267
|
context = { ...context, functionEnvironment: { homeObject } };
|
|
10231
10268
|
}
|
|
10232
10269
|
if (node.type !== "ArrowFunctionExpression" && node.generator) {
|
|
10233
|
-
return createGeneratorClosure(node, context, evaluateNode2);
|
|
10270
|
+
return createGeneratorClosure(node, context, evaluateNode2, initializeGeneratorPrototype);
|
|
10234
10271
|
}
|
|
10235
10272
|
const construct = node.type !== "ArrowFunctionExpression" && !(node.type === "FunctionExpression" && node.method === true) && !node.async ? async (args, callContext) => {
|
|
10236
10273
|
const thisValue = {};
|
|
@@ -10317,7 +10354,8 @@ function executeAsyncFunction(execute, budget, signal, callContext) {
|
|
|
10317
10354
|
});
|
|
10318
10355
|
return createSandboxPromise(promise, { synchronousPrefix });
|
|
10319
10356
|
}
|
|
10320
|
-
function createGeneratorClosure(node, context, evaluateNode2) {
|
|
10357
|
+
function createGeneratorClosure(node, context, evaluateNode2, initializePrototype) {
|
|
10358
|
+
const prototypes2 = !initializePrototype || runResources.getStore()?.functionSourceText === false ? void 0 : generatorPrototypes.get(context.budget)?.get(node.async === true);
|
|
10321
10359
|
const closure = createSandboxClosure({
|
|
10322
10360
|
sourceRange: functionSources.get(node),
|
|
10323
10361
|
guest: true,
|
|
@@ -10327,54 +10365,69 @@ function createGeneratorClosure(node, context, evaluateNode2) {
|
|
|
10327
10365
|
...node.id === void 0 ? { name: context.inferredName } : { name: node.id.name },
|
|
10328
10366
|
retainedValues: () => [...context.scope.retainedValues(), context.functionEnvironment?.homeObject, context.functionEnvironment?.newTarget],
|
|
10329
10367
|
call: async (args, callContext) => {
|
|
10330
|
-
const
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
|
|
10338
|
-
callContext?.thisValue,
|
|
10339
|
-
closureContext,
|
|
10340
|
-
evaluateNode2
|
|
10341
|
-
);
|
|
10342
|
-
const channel = createGeneratorChannel((generatorYield) => {
|
|
10343
|
-
const execute = async () => {
|
|
10344
|
-
const result = await evaluateNode2(node.body, {
|
|
10345
|
-
...closureContext,
|
|
10346
|
-
functionBody: node.body,
|
|
10347
|
-
asyncGenerator: node.async,
|
|
10348
|
-
generatorBlockScopes: /* @__PURE__ */ new Map(),
|
|
10349
|
-
generatorExpressionStates: /* @__PURE__ */ new Map(),
|
|
10350
|
-
captureGeneratorScope: (suspendedScope, blocks, completions, expressions) => {
|
|
10351
|
-
origin.suspendedScope = suspendedScope;
|
|
10352
|
-
origin.blockScopes = blocks;
|
|
10353
|
-
origin.finallyCompletions = completions;
|
|
10354
|
-
origin.expressionStates = expressions;
|
|
10355
|
-
},
|
|
10356
|
-
generatorYield: (value2, yieldNodeId) => {
|
|
10357
|
-
generator.state = "suspended";
|
|
10358
|
-
return generatorYield(value2, yieldNodeId);
|
|
10359
|
-
},
|
|
10360
|
-
scope
|
|
10361
|
-
});
|
|
10362
|
-
if (result.kind === "error") {
|
|
10363
|
-
throw result.error;
|
|
10364
|
-
}
|
|
10365
|
-
if (result.kind === "throw") {
|
|
10366
|
-
throw result.value;
|
|
10367
|
-
}
|
|
10368
|
-
const value = result.hasValue ? result.value : void 0;
|
|
10369
|
-
return node.async ? awaitSandboxValue(value, context.signal, context.budget, createCoercionContext(context)) : value;
|
|
10368
|
+
const candidate = prototypes2 === void 0 ? void 0 : getGuestFunctionProperty(closure, "prototype");
|
|
10369
|
+
const prototype = typeof candidate === "object" && candidate !== null ? candidate : prototypes2?.instancePrototype;
|
|
10370
|
+
const releasePrototype = prototype === void 0 ? void 0 : retainValues(context.budget, () => [prototype]);
|
|
10371
|
+
try {
|
|
10372
|
+
const closureContext = {
|
|
10373
|
+
...context,
|
|
10374
|
+
compilation: callContext?.compilation ?? context.compilation,
|
|
10375
|
+
callStack: [...callContext?.stack ?? context.callStack]
|
|
10370
10376
|
};
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10377
|
+
const scope = await createClosureScope(
|
|
10378
|
+
node,
|
|
10379
|
+
args,
|
|
10380
|
+
callContext?.thisValue,
|
|
10381
|
+
closureContext,
|
|
10382
|
+
evaluateNode2
|
|
10383
|
+
);
|
|
10384
|
+
const channel = createGeneratorChannel((generatorYield) => {
|
|
10385
|
+
const execute = async () => {
|
|
10386
|
+
const result = await evaluateNode2(node.body, {
|
|
10387
|
+
...closureContext,
|
|
10388
|
+
functionBody: node.body,
|
|
10389
|
+
asyncGenerator: node.async,
|
|
10390
|
+
generatorBlockScopes: /* @__PURE__ */ new Map(),
|
|
10391
|
+
generatorExpressionStates: /* @__PURE__ */ new Map(),
|
|
10392
|
+
captureGeneratorScope: (suspendedScope, blocks, completions, expressions) => {
|
|
10393
|
+
origin.suspendedScope = suspendedScope;
|
|
10394
|
+
origin.blockScopes = blocks;
|
|
10395
|
+
origin.finallyCompletions = completions;
|
|
10396
|
+
origin.expressionStates = expressions;
|
|
10397
|
+
},
|
|
10398
|
+
generatorYield: (value2, yieldNodeId) => {
|
|
10399
|
+
generator.state = "suspended";
|
|
10400
|
+
return generatorYield(value2, yieldNodeId);
|
|
10401
|
+
},
|
|
10402
|
+
scope
|
|
10403
|
+
});
|
|
10404
|
+
if (result.kind === "error") {
|
|
10405
|
+
throw result.error;
|
|
10406
|
+
}
|
|
10407
|
+
if (result.kind === "throw") {
|
|
10408
|
+
throw result.value;
|
|
10409
|
+
}
|
|
10410
|
+
const value = result.hasValue ? result.value : void 0;
|
|
10411
|
+
return node.async ? awaitSandboxValue(value, context.signal, context.budget, createCoercionContext(context)) : value;
|
|
10412
|
+
};
|
|
10413
|
+
return node.async ? runAsyncPrefix(execute) : execute();
|
|
10414
|
+
});
|
|
10415
|
+
const generator = createSandboxGenerator(channel, { async: node.async });
|
|
10416
|
+
if (prototype !== void 0) setSandboxPrototype(generator, prototype, context.budget);
|
|
10417
|
+
const origin = registerGeneratorOrigin(generator, node, scope, closureContext);
|
|
10418
|
+
return generator;
|
|
10419
|
+
} finally {
|
|
10420
|
+
releasePrototype?.();
|
|
10421
|
+
}
|
|
10376
10422
|
}
|
|
10377
10423
|
});
|
|
10424
|
+
if (prototypes2 !== void 0) {
|
|
10425
|
+
const prototype = /* @__PURE__ */ Object.create(null);
|
|
10426
|
+
markDescriptorObject(prototype);
|
|
10427
|
+
setSandboxPrototype(prototype, prototypes2.instancePrototype);
|
|
10428
|
+
Object.defineProperty(materializeFunctionProperties(closure), "prototype", { value: prototype, writable: true });
|
|
10429
|
+
setSandboxPrototype(closure, prototypes2.functionPrototype);
|
|
10430
|
+
}
|
|
10378
10431
|
registerClosureOrigin(closure, node, context);
|
|
10379
10432
|
return closure;
|
|
10380
10433
|
}
|
|
@@ -13261,6 +13314,32 @@ function createArrayGlobal(budget) {
|
|
|
13261
13314
|
length: 0,
|
|
13262
13315
|
call: (_args, context) => context?.thisValue
|
|
13263
13316
|
}), writable: true, configurable: true });
|
|
13317
|
+
const iteratorTagGetter = createSandboxClosure({
|
|
13318
|
+
guest: true,
|
|
13319
|
+
sandbox: true,
|
|
13320
|
+
name: "get [Symbol.toStringTag]",
|
|
13321
|
+
length: 0,
|
|
13322
|
+
call: () => "Iterator"
|
|
13323
|
+
});
|
|
13324
|
+
const iteratorTagSetter = createSandboxClosure({
|
|
13325
|
+
guest: true,
|
|
13326
|
+
sandbox: true,
|
|
13327
|
+
name: "set [Symbol.toStringTag]",
|
|
13328
|
+
length: 1,
|
|
13329
|
+
call: ([value], context) => {
|
|
13330
|
+
const receiver = context?.thisValue;
|
|
13331
|
+
if (receiver === iterablePrototype || receiver === null || typeof receiver !== "object")
|
|
13332
|
+
throw new TypeError("Iterator tag setter requires a distinct object receiver.");
|
|
13333
|
+
defineOwnDataProperty(objectProperties(receiver, true), Symbol.toStringTag, value);
|
|
13334
|
+
createDataCheckpoint(budget, context)(receiver, 0, true);
|
|
13335
|
+
return void 0;
|
|
13336
|
+
}
|
|
13337
|
+
});
|
|
13338
|
+
Object.defineProperty(iterablePrototype, Symbol.toStringTag, {
|
|
13339
|
+
get: accessorAdapter(iteratorTagGetter, "get"),
|
|
13340
|
+
set: accessorAdapter(iteratorTagSetter, "set"),
|
|
13341
|
+
configurable: true
|
|
13342
|
+
});
|
|
13264
13343
|
setSandboxPrototype(iterablePrototype, getSandboxPrototype(/* @__PURE__ */ Object.create(null), budget));
|
|
13265
13344
|
setSandboxPrototype(iteratorPrototype, iterablePrototype);
|
|
13266
13345
|
Object.defineProperties(iteratorPrototype, {
|
|
@@ -13274,6 +13353,9 @@ function createArrayGlobal(budget) {
|
|
|
13274
13353
|
[Symbol.toStringTag]: { value: "Array Iterator", configurable: true }
|
|
13275
13354
|
});
|
|
13276
13355
|
registerBuiltinIdentities(budget, { "%ArrayIteratorPrototype%": iteratorPrototype, "%IteratorPrototype%": iterablePrototype });
|
|
13356
|
+
registerIntrinsicFunction(budget, iterablePrototype[Symbol.iterator]);
|
|
13357
|
+
registerIntrinsicFunction(budget, iteratorTagGetter);
|
|
13358
|
+
registerIntrinsicFunction(budget, iteratorTagSetter);
|
|
13277
13359
|
registerIntrinsicObject(budget, iterablePrototype);
|
|
13278
13360
|
registerIntrinsicObject(budget, iteratorPrototype);
|
|
13279
13361
|
for (const method of ["keys", "values", "entries"]) {
|
|
@@ -14049,6 +14131,8 @@ function callFunctionMethod(target, methodName, args, options, stack, context) {
|
|
|
14049
14131
|
const thisValue = args[0];
|
|
14050
14132
|
if (methodName === "bind") {
|
|
14051
14133
|
const boundArgs = args.slice(1);
|
|
14134
|
+
const explicitPrototype = hasExplicitSandboxPrototype(target);
|
|
14135
|
+
const prototype = getSandboxPrototype(target, options.budget);
|
|
14052
14136
|
const bind = (length, name) => {
|
|
14053
14137
|
const bound = createSandboxClosure({
|
|
14054
14138
|
guest: true,
|
|
@@ -14069,8 +14153,7 @@ function callFunctionMethod(target, methodName, args, options, stack, context) {
|
|
|
14069
14153
|
)
|
|
14070
14154
|
}
|
|
14071
14155
|
});
|
|
14072
|
-
if (
|
|
14073
|
-
setSandboxPrototype(bound, getSandboxPrototype(target, options.budget), options.budget);
|
|
14156
|
+
if (explicitPrototype) setSandboxPrototype(bound, prototype, options.budget);
|
|
14074
14157
|
return bound;
|
|
14075
14158
|
};
|
|
14076
14159
|
if (context?.getProperty === void 0)
|
|
@@ -14079,15 +14162,20 @@ function callFunctionMethod(target, methodName, args, options, stack, context) {
|
|
|
14079
14162
|
target.name ?? ""
|
|
14080
14163
|
);
|
|
14081
14164
|
return (async () => {
|
|
14082
|
-
const
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14165
|
+
const release = options.budget !== void 0 && explicitPrototype && prototype !== null ? retainValues(options.budget, () => [prototype]) : void 0;
|
|
14166
|
+
try {
|
|
14167
|
+
const properties = target.properties;
|
|
14168
|
+
const defaultName = target.name;
|
|
14169
|
+
const hasLength = !isGuestClosure(target) || target.properties === void 0 || Object.hasOwn(target.properties, "length");
|
|
14170
|
+
const length = hasLength ? await context.getProperty(target, "length") : void 0;
|
|
14171
|
+
const name = !isGuestClosure(target) && !Object.hasOwn(properties ?? {}, "name") ? defaultName : await context.getProperty(target, "name");
|
|
14172
|
+
return bind(
|
|
14173
|
+
typeof length === "number" && !Number.isNaN(length) ? Math.max(0, Math.trunc(length) - boundArgs.length) : 0,
|
|
14174
|
+
typeof name === "string" ? name : ""
|
|
14175
|
+
);
|
|
14176
|
+
} finally {
|
|
14177
|
+
release?.();
|
|
14178
|
+
}
|
|
14091
14179
|
})();
|
|
14092
14180
|
}
|
|
14093
14181
|
if (methodName === "call") {
|
|
@@ -14272,16 +14360,19 @@ function getGeneratorMember(target, property, budget) {
|
|
|
14272
14360
|
return createSandboxClosure({
|
|
14273
14361
|
sandbox: true,
|
|
14274
14362
|
name: property,
|
|
14275
|
-
call: ([value], context) =>
|
|
14276
|
-
const iterator = generatorIterator(target, budget, context);
|
|
14277
|
-
const result = Promise.resolve(iterator[property](value)).then((result2) => allocateProducedSandboxValue(
|
|
14278
|
-
{ value: result2.value, done: result2.done === true },
|
|
14279
|
-
budget
|
|
14280
|
-
));
|
|
14281
|
-
return target.async ? createSandboxPromise(result) : result;
|
|
14282
|
-
}
|
|
14363
|
+
call: ([value], context) => callGeneratorMethod(target, property, value, budget, context, target.async === true)
|
|
14283
14364
|
});
|
|
14284
14365
|
}
|
|
14366
|
+
function callGeneratorMethod(target, method, value, budget, context, async) {
|
|
14367
|
+
const result = (async () => {
|
|
14368
|
+
if (!isSandboxGenerator(target) || target.async === true !== async)
|
|
14369
|
+
throw new TypeError(`${async ? "AsyncGenerator" : "Generator"}.${method} requires a matching generator receiver.`);
|
|
14370
|
+
const iterator = generatorIterator(target, budget, context);
|
|
14371
|
+
const result2 = await iterator[method](value);
|
|
14372
|
+
return allocateProducedSandboxValue({ value: result2.value, done: result2.done === true }, budget);
|
|
14373
|
+
})();
|
|
14374
|
+
return async ? createSandboxPromise(result) : result;
|
|
14375
|
+
}
|
|
14285
14376
|
|
|
14286
14377
|
// packages/safe-js/src/interp/methods/set.ts
|
|
14287
14378
|
var setMethodNames = /* @__PURE__ */ new Set([
|
|
@@ -23968,6 +24059,66 @@ function createFunctionPrototype(budget) {
|
|
|
23968
24059
|
installFunctionPrototype(budget, prototype);
|
|
23969
24060
|
}
|
|
23970
24061
|
|
|
24062
|
+
// packages/safe-js/src/interp/globals/generator.ts
|
|
24063
|
+
function createGeneratorPrototypes(budget) {
|
|
24064
|
+
const asyncIteratorPrototype = /* @__PURE__ */ Object.create(null);
|
|
24065
|
+
const asyncIterator = createSandboxClosure({
|
|
24066
|
+
guest: true,
|
|
24067
|
+
sandbox: true,
|
|
24068
|
+
name: "[Symbol.asyncIterator]",
|
|
24069
|
+
length: 0,
|
|
24070
|
+
call: (_args, context) => context?.thisValue
|
|
24071
|
+
});
|
|
24072
|
+
Object.defineProperty(asyncIteratorPrototype, Symbol.asyncIterator, {
|
|
24073
|
+
value: asyncIterator,
|
|
24074
|
+
writable: true,
|
|
24075
|
+
configurable: true
|
|
24076
|
+
});
|
|
24077
|
+
setSandboxPrototype(asyncIteratorPrototype, getSandboxPrototype(/* @__PURE__ */ Object.create(null), budget));
|
|
24078
|
+
registerBuiltinIdentities(budget, { "%AsyncIteratorPrototype%": asyncIteratorPrototype });
|
|
24079
|
+
registerIntrinsicObject(budget, asyncIteratorPrototype);
|
|
24080
|
+
registerIntrinsicFunction(budget, asyncIterator);
|
|
24081
|
+
const state = /* @__PURE__ */ new Map();
|
|
24082
|
+
for (const async of [false, true]) {
|
|
24083
|
+
const tag = async ? "AsyncGenerator" : "Generator";
|
|
24084
|
+
const functionPrototype = /* @__PURE__ */ Object.create(null);
|
|
24085
|
+
const instancePrototype = /* @__PURE__ */ Object.create(null);
|
|
24086
|
+
setSandboxPrototype(functionPrototype, resolveIntrinsicIdentity(budget, JSON.stringify(["%FunctionPrototype%"])));
|
|
24087
|
+
setSandboxPrototype(instancePrototype, async ? asyncIteratorPrototype : resolveIntrinsicIdentity(budget, JSON.stringify(["%IteratorPrototype%"])));
|
|
24088
|
+
Object.defineProperties(functionPrototype, {
|
|
24089
|
+
prototype: { value: instancePrototype, configurable: true },
|
|
24090
|
+
// Do not expose native dynamic-source constructors through this graph.
|
|
24091
|
+
constructor: { value: void 0, configurable: true },
|
|
24092
|
+
[Symbol.toStringTag]: { value: `${tag}Function`, configurable: true }
|
|
24093
|
+
});
|
|
24094
|
+
Object.defineProperties(instancePrototype, {
|
|
24095
|
+
constructor: { value: functionPrototype, configurable: true },
|
|
24096
|
+
[Symbol.toStringTag]: { value: tag, configurable: true }
|
|
24097
|
+
});
|
|
24098
|
+
for (const method of ["next", "return", "throw"]) {
|
|
24099
|
+
Object.defineProperty(instancePrototype, method, {
|
|
24100
|
+
writable: true,
|
|
24101
|
+
configurable: true,
|
|
24102
|
+
value: createSandboxClosure({
|
|
24103
|
+
guest: true,
|
|
24104
|
+
sandbox: true,
|
|
24105
|
+
name: method,
|
|
24106
|
+
length: 1,
|
|
24107
|
+
call: ([value], context) => callGeneratorMethod(context?.thisValue, method, value, budget, context, async)
|
|
24108
|
+
})
|
|
24109
|
+
});
|
|
24110
|
+
}
|
|
24111
|
+
registerBuiltinIdentities(budget, {
|
|
24112
|
+
[`%${tag}Prototype%`]: instancePrototype,
|
|
24113
|
+
[`%${tag}FunctionPrototype%`]: functionPrototype
|
|
24114
|
+
});
|
|
24115
|
+
registerIntrinsicObject(budget, functionPrototype);
|
|
24116
|
+
registerIntrinsicObject(budget, instancePrototype);
|
|
24117
|
+
state.set(async, { functionPrototype, instancePrototype });
|
|
24118
|
+
}
|
|
24119
|
+
generatorPrototypes.set(budget, state);
|
|
24120
|
+
}
|
|
24121
|
+
|
|
23971
24122
|
// packages/safe-js/src/interp/globals/symbol.ts
|
|
23972
24123
|
var registries = /* @__PURE__ */ new WeakMap();
|
|
23973
24124
|
function createSymbolGlobal(budget) {
|
|
@@ -24199,6 +24350,7 @@ function createBuiltinBindings(options) {
|
|
|
24199
24350
|
...createRegexGlobals(options)
|
|
24200
24351
|
};
|
|
24201
24352
|
createFunctionPrototype(options.budget);
|
|
24353
|
+
createGeneratorPrototypes(options.budget);
|
|
24202
24354
|
registerBuiltinIdentities(options.budget, bindings);
|
|
24203
24355
|
return bindings;
|
|
24204
24356
|
}
|
|
@@ -41049,4 +41201,4 @@ export {
|
|
|
41049
41201
|
FileSnapshotBackend,
|
|
41050
41202
|
run
|
|
41051
41203
|
};
|
|
41052
|
-
//# sourceMappingURL=chunk-
|
|
41204
|
+
//# sourceMappingURL=chunk-S5C5SAU4.js.map
|