@poe-platform/safe-js 0.1.300 → 0.1.302
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-JBOD6COV.js → chunk-RPUBUYIO.js} +2 -2
- package/dist/safe-js/chunks/{chunk-ONR2CYEH.js → chunk-T2TQBEDG.js} +241 -70
- package/dist/safe-js/chunks/chunk-T2TQBEDG.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-ONR2CYEH.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-JBOD6COV.js.map → chunk-RPUBUYIO.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-T2TQBEDG.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-RPUBUYIO.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();
|
|
@@ -7862,6 +7865,7 @@ function namedKeys(state) {
|
|
|
7862
7865
|
// packages/safe-js/src/interp/object-model.ts
|
|
7863
7866
|
var guestClosures = /* @__PURE__ */ new WeakSet();
|
|
7864
7867
|
var functionProperties = /* @__PURE__ */ new WeakMap();
|
|
7868
|
+
var functionPropertyRevisions = /* @__PURE__ */ new WeakMap();
|
|
7865
7869
|
var prototypes = /* @__PURE__ */ new WeakMap();
|
|
7866
7870
|
var intrinsicPrototypes = /* @__PURE__ */ new WeakMap();
|
|
7867
7871
|
var boxedPrototypes = /* @__PURE__ */ new WeakMap();
|
|
@@ -7906,9 +7910,23 @@ function materializeFunctionProperties(closure) {
|
|
|
7906
7910
|
descriptorObjects.add(prototype);
|
|
7907
7911
|
Object.defineProperty(properties, "prototype", { value: prototype, writable: true });
|
|
7908
7912
|
}
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7913
|
+
const state = { revision: 0 };
|
|
7914
|
+
const tracked = new Proxy(properties, {
|
|
7915
|
+
defineProperty(target, key, descriptor) {
|
|
7916
|
+
const changed = Reflect.defineProperty(target, key, descriptor);
|
|
7917
|
+
if (changed) state.revision++;
|
|
7918
|
+
return changed;
|
|
7919
|
+
},
|
|
7920
|
+
deleteProperty(target, key) {
|
|
7921
|
+
const changed = Reflect.deleteProperty(target, key);
|
|
7922
|
+
if (changed) state.revision++;
|
|
7923
|
+
return changed;
|
|
7924
|
+
}
|
|
7925
|
+
});
|
|
7926
|
+
functionPropertyRevisions.set(tracked, state);
|
|
7927
|
+
descriptorObjects.add(tracked);
|
|
7928
|
+
functionProperties.set(closure, tracked);
|
|
7929
|
+
return tracked;
|
|
7912
7930
|
}
|
|
7913
7931
|
function getGuestFunctionProperty(closure, key) {
|
|
7914
7932
|
let properties = functionProperties.get(closure);
|
|
@@ -8018,6 +8036,9 @@ function trackIntrinsicState(budget, root, owner, targets) {
|
|
|
8018
8036
|
explicit: hasExplicitSandboxPrototype(target)
|
|
8019
8037
|
})).map((record4) => ({
|
|
8020
8038
|
...record4,
|
|
8039
|
+
revision: functionPropertyRevisions.get(record4.value),
|
|
8040
|
+
capturedRevision: -1,
|
|
8041
|
+
captured: [],
|
|
8021
8042
|
extensible: Object.isExtensible(record4.value),
|
|
8022
8043
|
descriptors: new Map(Reflect.ownKeys(record4.value).map((key) => [key, Object.getOwnPropertyDescriptor(record4.value, key)]))
|
|
8023
8044
|
}));
|
|
@@ -8033,14 +8054,21 @@ function trackIntrinsicState(budget, root, owner, targets) {
|
|
|
8033
8054
|
);
|
|
8034
8055
|
budget.setRetainedValues(root, () => {
|
|
8035
8056
|
const retained = [];
|
|
8036
|
-
for (const
|
|
8057
|
+
for (const record4 of records) {
|
|
8058
|
+
const { target, value, descriptors: descriptors2, prototype: parent, revision } = record4;
|
|
8037
8059
|
const currentPrototype = getSandboxPrototype(target);
|
|
8038
8060
|
if (currentPrototype !== parent) retained.push(currentPrototype);
|
|
8039
|
-
|
|
8040
|
-
const
|
|
8041
|
-
|
|
8042
|
-
|
|
8061
|
+
if (revision === void 0 || revision.revision !== record4.capturedRevision) {
|
|
8062
|
+
const captured = [];
|
|
8063
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
8064
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
8065
|
+
if (unchanged(descriptors2.get(key), descriptor)) continue;
|
|
8066
|
+
captured.push(key, descriptor.value, ...retainedAccessorClosures(descriptor));
|
|
8067
|
+
}
|
|
8068
|
+
record4.captured = captured;
|
|
8069
|
+
record4.capturedRevision = revision?.revision ?? -1;
|
|
8043
8070
|
}
|
|
8071
|
+
for (const item of record4.captured) retained.push(item);
|
|
8044
8072
|
}
|
|
8045
8073
|
return retained;
|
|
8046
8074
|
});
|
|
@@ -8057,6 +8085,7 @@ function releaseObjectPrototype(budget) {
|
|
|
8057
8085
|
datePrototypes.delete(budget);
|
|
8058
8086
|
arrayPrototypes.delete(budget);
|
|
8059
8087
|
functionPrototypes.delete(budget);
|
|
8088
|
+
generatorPrototypes.delete(budget);
|
|
8060
8089
|
initialRegexDescriptors.delete(budget);
|
|
8061
8090
|
intrinsicPrototypes.delete(budget);
|
|
8062
8091
|
}
|
|
@@ -9430,13 +9459,12 @@ async function acquireSandboxIterator(value, budget, context, asyncProtocol = fa
|
|
|
9430
9459
|
return asyncProtocol ? getSandboxAsyncIterator(value, budget, context, signal) : getSandboxIterator(value, budget, context);
|
|
9431
9460
|
if (getSandboxPropertyDescriptor(value, key, budget) === void 0 && !(isSandboxRegExpIterator(value) && !asyncProtocol && getSandboxPropertyDescriptor(value, "next", budget) !== void 0)) {
|
|
9432
9461
|
if (isSandboxGenerator(value)) {
|
|
9433
|
-
if (hasExplicitSandboxPrototype(value))
|
|
9434
|
-
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)
|
|
9435
9463
|
return guestIterator(value, await context.getProperty(value, "next"), asyncProtocol, budget, context, signal);
|
|
9436
9464
|
}
|
|
9437
9465
|
if (!asyncProtocol && Array.isArray(value) && getSandboxPrototype(value, budget) !== null) return void 0;
|
|
9438
9466
|
if (!asyncProtocol) return getSandboxIterator(value, budget, context);
|
|
9439
|
-
if (isSandboxGenerator(value) && value.async)
|
|
9467
|
+
if (isSandboxGenerator(value) && value.async && !hasExplicitSandboxPrototype(value))
|
|
9440
9468
|
return getSandboxAsyncIterator(value, budget, context, signal);
|
|
9441
9469
|
const iterator2 = await acquireSandboxIterator(value, budget, context);
|
|
9442
9470
|
return iterator2 === void 0 ? void 0 : asyncFromSyncIterator(iterator2, budget, signal, context);
|
|
@@ -9498,7 +9526,7 @@ async function readIteratorResult(iterator, result, property) {
|
|
|
9498
9526
|
}
|
|
9499
9527
|
function getSandboxAsyncIterator(value, budget, context, signal) {
|
|
9500
9528
|
if (isSandboxGenerator(value) && value.async) {
|
|
9501
|
-
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 };
|
|
9502
9530
|
}
|
|
9503
9531
|
if (value !== null && (typeof value === "object" || typeof value === "function") && !isGuestHostObject(value)) {
|
|
9504
9532
|
const method = value[Symbol.asyncIterator];
|
|
@@ -9648,7 +9676,9 @@ function getSandboxIterator(value, budget, context) {
|
|
|
9648
9676
|
return syncIterator(Float32Array.prototype.values.call(value));
|
|
9649
9677
|
}
|
|
9650
9678
|
if (isSandboxGenerator(value)) {
|
|
9651
|
-
|
|
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);
|
|
9652
9682
|
}
|
|
9653
9683
|
if (typeof value === "string") {
|
|
9654
9684
|
const iterator2 = value[Symbol.iterator]();
|
|
@@ -9725,6 +9755,38 @@ function collectionIterator(collection, value) {
|
|
|
9725
9755
|
return adapter;
|
|
9726
9756
|
}
|
|
9727
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
|
+
}
|
|
9728
9790
|
function generatorObjectIterator(generator, budget, context) {
|
|
9729
9791
|
const iterator = generatorIterator(generator, budget, context);
|
|
9730
9792
|
if (context?.getProperty === void 0) return iterator;
|
|
@@ -10200,12 +10262,12 @@ async function evaluateFunctionExpression(node, context, evaluateNode2) {
|
|
|
10200
10262
|
value: closure
|
|
10201
10263
|
};
|
|
10202
10264
|
}
|
|
10203
|
-
function createInterpretedClosure(node, context, evaluateNode2, homeObject) {
|
|
10265
|
+
function createInterpretedClosure(node, context, evaluateNode2, homeObject, initializeGeneratorPrototype = true) {
|
|
10204
10266
|
if (node.type !== "ArrowFunctionExpression") {
|
|
10205
10267
|
context = { ...context, functionEnvironment: { homeObject } };
|
|
10206
10268
|
}
|
|
10207
10269
|
if (node.type !== "ArrowFunctionExpression" && node.generator) {
|
|
10208
|
-
return createGeneratorClosure(node, context, evaluateNode2);
|
|
10270
|
+
return createGeneratorClosure(node, context, evaluateNode2, initializeGeneratorPrototype);
|
|
10209
10271
|
}
|
|
10210
10272
|
const construct = node.type !== "ArrowFunctionExpression" && !(node.type === "FunctionExpression" && node.method === true) && !node.async ? async (args, callContext) => {
|
|
10211
10273
|
const thisValue = {};
|
|
@@ -10292,7 +10354,8 @@ function executeAsyncFunction(execute, budget, signal, callContext) {
|
|
|
10292
10354
|
});
|
|
10293
10355
|
return createSandboxPromise(promise, { synchronousPrefix });
|
|
10294
10356
|
}
|
|
10295
|
-
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);
|
|
10296
10359
|
const closure = createSandboxClosure({
|
|
10297
10360
|
sourceRange: functionSources.get(node),
|
|
10298
10361
|
guest: true,
|
|
@@ -10302,54 +10365,69 @@ function createGeneratorClosure(node, context, evaluateNode2) {
|
|
|
10302
10365
|
...node.id === void 0 ? { name: context.inferredName } : { name: node.id.name },
|
|
10303
10366
|
retainedValues: () => [...context.scope.retainedValues(), context.functionEnvironment?.homeObject, context.functionEnvironment?.newTarget],
|
|
10304
10367
|
call: async (args, callContext) => {
|
|
10305
|
-
const
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
callContext?.thisValue,
|
|
10314
|
-
closureContext,
|
|
10315
|
-
evaluateNode2
|
|
10316
|
-
);
|
|
10317
|
-
const channel = createGeneratorChannel((generatorYield) => {
|
|
10318
|
-
const execute = async () => {
|
|
10319
|
-
const result = await evaluateNode2(node.body, {
|
|
10320
|
-
...closureContext,
|
|
10321
|
-
functionBody: node.body,
|
|
10322
|
-
asyncGenerator: node.async,
|
|
10323
|
-
generatorBlockScopes: /* @__PURE__ */ new Map(),
|
|
10324
|
-
generatorExpressionStates: /* @__PURE__ */ new Map(),
|
|
10325
|
-
captureGeneratorScope: (suspendedScope, blocks, completions, expressions) => {
|
|
10326
|
-
origin.suspendedScope = suspendedScope;
|
|
10327
|
-
origin.blockScopes = blocks;
|
|
10328
|
-
origin.finallyCompletions = completions;
|
|
10329
|
-
origin.expressionStates = expressions;
|
|
10330
|
-
},
|
|
10331
|
-
generatorYield: (value2, yieldNodeId) => {
|
|
10332
|
-
generator.state = "suspended";
|
|
10333
|
-
return generatorYield(value2, yieldNodeId);
|
|
10334
|
-
},
|
|
10335
|
-
scope
|
|
10336
|
-
});
|
|
10337
|
-
if (result.kind === "error") {
|
|
10338
|
-
throw result.error;
|
|
10339
|
-
}
|
|
10340
|
-
if (result.kind === "throw") {
|
|
10341
|
-
throw result.value;
|
|
10342
|
-
}
|
|
10343
|
-
const value = result.hasValue ? result.value : void 0;
|
|
10344
|
-
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]
|
|
10345
10376
|
};
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
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
|
+
}
|
|
10351
10422
|
}
|
|
10352
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
|
+
}
|
|
10353
10431
|
registerClosureOrigin(closure, node, context);
|
|
10354
10432
|
return closure;
|
|
10355
10433
|
}
|
|
@@ -13236,6 +13314,32 @@ function createArrayGlobal(budget) {
|
|
|
13236
13314
|
length: 0,
|
|
13237
13315
|
call: (_args, context) => context?.thisValue
|
|
13238
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
|
+
});
|
|
13239
13343
|
setSandboxPrototype(iterablePrototype, getSandboxPrototype(/* @__PURE__ */ Object.create(null), budget));
|
|
13240
13344
|
setSandboxPrototype(iteratorPrototype, iterablePrototype);
|
|
13241
13345
|
Object.defineProperties(iteratorPrototype, {
|
|
@@ -13249,6 +13353,9 @@ function createArrayGlobal(budget) {
|
|
|
13249
13353
|
[Symbol.toStringTag]: { value: "Array Iterator", configurable: true }
|
|
13250
13354
|
});
|
|
13251
13355
|
registerBuiltinIdentities(budget, { "%ArrayIteratorPrototype%": iteratorPrototype, "%IteratorPrototype%": iterablePrototype });
|
|
13356
|
+
registerIntrinsicFunction(budget, iterablePrototype[Symbol.iterator]);
|
|
13357
|
+
registerIntrinsicFunction(budget, iteratorTagGetter);
|
|
13358
|
+
registerIntrinsicFunction(budget, iteratorTagSetter);
|
|
13252
13359
|
registerIntrinsicObject(budget, iterablePrototype);
|
|
13253
13360
|
registerIntrinsicObject(budget, iteratorPrototype);
|
|
13254
13361
|
for (const method of ["keys", "values", "entries"]) {
|
|
@@ -14247,16 +14354,19 @@ function getGeneratorMember(target, property, budget) {
|
|
|
14247
14354
|
return createSandboxClosure({
|
|
14248
14355
|
sandbox: true,
|
|
14249
14356
|
name: property,
|
|
14250
|
-
call: ([value], context) =>
|
|
14251
|
-
const iterator = generatorIterator(target, budget, context);
|
|
14252
|
-
const result = Promise.resolve(iterator[property](value)).then((result2) => allocateProducedSandboxValue(
|
|
14253
|
-
{ value: result2.value, done: result2.done === true },
|
|
14254
|
-
budget
|
|
14255
|
-
));
|
|
14256
|
-
return target.async ? createSandboxPromise(result) : result;
|
|
14257
|
-
}
|
|
14357
|
+
call: ([value], context) => callGeneratorMethod(target, property, value, budget, context, target.async === true)
|
|
14258
14358
|
});
|
|
14259
14359
|
}
|
|
14360
|
+
function callGeneratorMethod(target, method, value, budget, context, async) {
|
|
14361
|
+
const result = (async () => {
|
|
14362
|
+
if (!isSandboxGenerator(target) || target.async === true !== async)
|
|
14363
|
+
throw new TypeError(`${async ? "AsyncGenerator" : "Generator"}.${method} requires a matching generator receiver.`);
|
|
14364
|
+
const iterator = generatorIterator(target, budget, context);
|
|
14365
|
+
const result2 = await iterator[method](value);
|
|
14366
|
+
return allocateProducedSandboxValue({ value: result2.value, done: result2.done === true }, budget);
|
|
14367
|
+
})();
|
|
14368
|
+
return async ? createSandboxPromise(result) : result;
|
|
14369
|
+
}
|
|
14260
14370
|
|
|
14261
14371
|
// packages/safe-js/src/interp/methods/set.ts
|
|
14262
14372
|
var setMethodNames = /* @__PURE__ */ new Set([
|
|
@@ -23943,6 +24053,66 @@ function createFunctionPrototype(budget) {
|
|
|
23943
24053
|
installFunctionPrototype(budget, prototype);
|
|
23944
24054
|
}
|
|
23945
24055
|
|
|
24056
|
+
// packages/safe-js/src/interp/globals/generator.ts
|
|
24057
|
+
function createGeneratorPrototypes(budget) {
|
|
24058
|
+
const asyncIteratorPrototype = /* @__PURE__ */ Object.create(null);
|
|
24059
|
+
const asyncIterator = createSandboxClosure({
|
|
24060
|
+
guest: true,
|
|
24061
|
+
sandbox: true,
|
|
24062
|
+
name: "[Symbol.asyncIterator]",
|
|
24063
|
+
length: 0,
|
|
24064
|
+
call: (_args, context) => context?.thisValue
|
|
24065
|
+
});
|
|
24066
|
+
Object.defineProperty(asyncIteratorPrototype, Symbol.asyncIterator, {
|
|
24067
|
+
value: asyncIterator,
|
|
24068
|
+
writable: true,
|
|
24069
|
+
configurable: true
|
|
24070
|
+
});
|
|
24071
|
+
setSandboxPrototype(asyncIteratorPrototype, getSandboxPrototype(/* @__PURE__ */ Object.create(null), budget));
|
|
24072
|
+
registerBuiltinIdentities(budget, { "%AsyncIteratorPrototype%": asyncIteratorPrototype });
|
|
24073
|
+
registerIntrinsicObject(budget, asyncIteratorPrototype);
|
|
24074
|
+
registerIntrinsicFunction(budget, asyncIterator);
|
|
24075
|
+
const state = /* @__PURE__ */ new Map();
|
|
24076
|
+
for (const async of [false, true]) {
|
|
24077
|
+
const tag = async ? "AsyncGenerator" : "Generator";
|
|
24078
|
+
const functionPrototype = /* @__PURE__ */ Object.create(null);
|
|
24079
|
+
const instancePrototype = /* @__PURE__ */ Object.create(null);
|
|
24080
|
+
setSandboxPrototype(functionPrototype, resolveIntrinsicIdentity(budget, JSON.stringify(["%FunctionPrototype%"])));
|
|
24081
|
+
setSandboxPrototype(instancePrototype, async ? asyncIteratorPrototype : resolveIntrinsicIdentity(budget, JSON.stringify(["%IteratorPrototype%"])));
|
|
24082
|
+
Object.defineProperties(functionPrototype, {
|
|
24083
|
+
prototype: { value: instancePrototype, configurable: true },
|
|
24084
|
+
// Do not expose native dynamic-source constructors through this graph.
|
|
24085
|
+
constructor: { value: void 0, configurable: true },
|
|
24086
|
+
[Symbol.toStringTag]: { value: `${tag}Function`, configurable: true }
|
|
24087
|
+
});
|
|
24088
|
+
Object.defineProperties(instancePrototype, {
|
|
24089
|
+
constructor: { value: functionPrototype, configurable: true },
|
|
24090
|
+
[Symbol.toStringTag]: { value: tag, configurable: true }
|
|
24091
|
+
});
|
|
24092
|
+
for (const method of ["next", "return", "throw"]) {
|
|
24093
|
+
Object.defineProperty(instancePrototype, method, {
|
|
24094
|
+
writable: true,
|
|
24095
|
+
configurable: true,
|
|
24096
|
+
value: createSandboxClosure({
|
|
24097
|
+
guest: true,
|
|
24098
|
+
sandbox: true,
|
|
24099
|
+
name: method,
|
|
24100
|
+
length: 1,
|
|
24101
|
+
call: ([value], context) => callGeneratorMethod(context?.thisValue, method, value, budget, context, async)
|
|
24102
|
+
})
|
|
24103
|
+
});
|
|
24104
|
+
}
|
|
24105
|
+
registerBuiltinIdentities(budget, {
|
|
24106
|
+
[`%${tag}Prototype%`]: instancePrototype,
|
|
24107
|
+
[`%${tag}FunctionPrototype%`]: functionPrototype
|
|
24108
|
+
});
|
|
24109
|
+
registerIntrinsicObject(budget, functionPrototype);
|
|
24110
|
+
registerIntrinsicObject(budget, instancePrototype);
|
|
24111
|
+
state.set(async, { functionPrototype, instancePrototype });
|
|
24112
|
+
}
|
|
24113
|
+
generatorPrototypes.set(budget, state);
|
|
24114
|
+
}
|
|
24115
|
+
|
|
23946
24116
|
// packages/safe-js/src/interp/globals/symbol.ts
|
|
23947
24117
|
var registries = /* @__PURE__ */ new WeakMap();
|
|
23948
24118
|
function createSymbolGlobal(budget) {
|
|
@@ -24174,6 +24344,7 @@ function createBuiltinBindings(options) {
|
|
|
24174
24344
|
...createRegexGlobals(options)
|
|
24175
24345
|
};
|
|
24176
24346
|
createFunctionPrototype(options.budget);
|
|
24347
|
+
createGeneratorPrototypes(options.budget);
|
|
24177
24348
|
registerBuiltinIdentities(options.budget, bindings);
|
|
24178
24349
|
return bindings;
|
|
24179
24350
|
}
|
|
@@ -41024,4 +41195,4 @@ export {
|
|
|
41024
41195
|
FileSnapshotBackend,
|
|
41025
41196
|
run
|
|
41026
41197
|
};
|
|
41027
|
-
//# sourceMappingURL=chunk-
|
|
41198
|
+
//# sourceMappingURL=chunk-T2TQBEDG.js.map
|