@poe-platform/safe-js 0.1.382 → 0.1.383

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.
@@ -27,7 +27,7 @@ import {
27
27
  validateMigrationSemantics,
28
28
  validateSnapshotData,
29
29
  validateSnapshotMigration
30
- } from "./chunk-DRWLAPG6.js";
30
+ } from "./chunk-XIEVJEAG.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-FUPQ2J76.js.map
8252
+ //# sourceMappingURL=chunk-LUFFFEON.js.map
@@ -15041,6 +15041,18 @@ function createArrayGlobal(budget) {
15041
15041
  const statics = {
15042
15042
  isArray: createSandboxClosure({ sandbox: true, name: "isArray", call: ([value]) => Array.isArray(value) }),
15043
15043
  from: createSandboxClosure({ sandbox: true, name: "from", call: (args, context) => arrayFromSandboxValues(args, budget, context) }),
15044
+ fromAsync: createSandboxClosure({
15045
+ guest: true,
15046
+ sandbox: true,
15047
+ name: "fromAsync",
15048
+ length: 1,
15049
+ call: (args, context) => executeAsyncFunction(
15050
+ (onSuspend) => arrayFromSandboxValues(args, budget, context, onSuspend),
15051
+ budget,
15052
+ void 0,
15053
+ context
15054
+ )
15055
+ }),
15044
15056
  of: createSandboxClosure({
15045
15057
  guest: true,
15046
15058
  sandbox: true,
@@ -15327,7 +15339,17 @@ function defineDataProperty(target, key, descriptor, budget, context, throwOnFai
15327
15339
  function isAssignableSandboxTarget(value) {
15328
15340
  return typeof value === "object" && value !== null && !isSandboxClosure(value) && !isSandboxGenerator(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isSandboxPromise(value) && !isSandboxRegex(value);
15329
15341
  }
15330
- async function arrayFromSandboxValues(args, budget, context) {
15342
+ async function arrayFromSandboxValues(args, budget, context, onSuspend) {
15343
+ const asyncProtocol = onSuspend !== void 0;
15344
+ const awaitAsync = async (pending) => {
15345
+ onSuspend();
15346
+ const leaveAwait = budget.enterAwait();
15347
+ try {
15348
+ return await suspendJob(pending);
15349
+ } finally {
15350
+ leaveAwait();
15351
+ }
15352
+ };
15331
15353
  const [items, mapFn, thisValue] = args;
15332
15354
  if (mapFn !== void 0 && !isSandboxClosure(mapFn)) {
15333
15355
  throw new TypeError("Array.from mapping callback must be a function.");
@@ -15336,11 +15358,11 @@ async function arrayFromSandboxValues(args, budget, context) {
15336
15358
  throw new TypeError("Array.from requires a non-null input.");
15337
15359
  }
15338
15360
  const read = (property) => context?.getProperty !== void 0 ? context.getProperty(items, property) : getSandboxDataProperty(items, property, budget);
15339
- const observableMethod = context?.getProperty !== void 0 && !isGuestHostObject(items) && getSandboxPropertyDescriptor(typeof items === "object" ? items : getBoxedPrototype(items, budget), Symbol.iterator, budget) !== void 0;
15361
+ const observableMethod = !asyncProtocol && context?.getProperty !== void 0 && !isGuestHostObject(items) && getSandboxPropertyDescriptor(typeof items === "object" ? items : getBoxedPrototype(items, budget), Symbol.iterator, budget) !== void 0;
15340
15362
  const iteratorMethod = observableMethod ? await context.getProperty(items, Symbol.iterator) : void 0;
15341
15363
  if (iteratorMethod !== null && iteratorMethod !== void 0 && !isSandboxClosure(iteratorMethod) && typeof iteratorMethod !== "function")
15342
15364
  throw new TypeError("Iterator method must be callable.");
15343
- let iterator = observableMethod ? void 0 : context === void 0 ? getSandboxIterator(items, budget) : await acquireSandboxIterator(items, budget, context);
15365
+ let iterator = observableMethod ? void 0 : context === void 0 ? asyncProtocol ? getSandboxAsyncIterator(items, budget) : getSandboxIterator(items, budget) : await acquireSandboxIterator(items, budget, context, asyncProtocol);
15344
15366
  const iterable = observableMethod ? iteratorMethod !== null && iteratorMethod !== void 0 : iterator !== void 0;
15345
15367
  const constructor = context?.thisValue;
15346
15368
  let result;
@@ -15354,6 +15376,7 @@ async function arrayFromSandboxValues(args, budget, context) {
15354
15376
  iteratorMethod,
15355
15377
  iterator?.retainedValue,
15356
15378
  mapFn,
15379
+ thisValue,
15357
15380
  constructor,
15358
15381
  result,
15359
15382
  currentValue,
@@ -15396,17 +15419,19 @@ async function arrayFromSandboxValues(args, budget, context) {
15396
15419
  await closeOnThrow(error);
15397
15420
  }
15398
15421
  if (iterator !== void 0) {
15399
- const next = await iterator.next();
15422
+ const pending = Promise.resolve(iterator.next());
15423
+ const next = await (asyncProtocol ? awaitAsync(pending) : pending);
15400
15424
  if (typeof next !== "object" || next === null)
15401
15425
  throw new TypeError("Iterator result must be an object.");
15402
15426
  if ((await readIteratorResult(iterator, next, "done")).value) break;
15403
15427
  currentValue = (await readIteratorResult(iterator, next, "value")).value;
15404
15428
  } else {
15405
15429
  currentValue = await read(index);
15430
+ if (asyncProtocol) currentValue = await awaitAsync(awaitSandboxValue(currentValue, void 0, budget, context));
15406
15431
  }
15407
15432
  try {
15408
15433
  if (Array.isArray(result)) budget.allocateArrayLength(index + 1);
15409
- if (mapFn !== void 0)
15434
+ if (mapFn !== void 0) {
15410
15435
  currentValue = await invokeBuiltinClosure(
15411
15436
  mapFn,
15412
15437
  [currentValue, index],
@@ -15414,6 +15439,8 @@ async function arrayFromSandboxValues(args, budget, context) {
15414
15439
  context,
15415
15440
  thisValue
15416
15441
  );
15442
+ if (asyncProtocol) currentValue = await awaitAsync(awaitSandboxValue(currentValue, void 0, budget, context));
15443
+ }
15417
15444
  const key = String(index);
15418
15445
  const growth = key.length + 1 + (Array.isArray(result) ? Math.max(0, index + 1 - result.length) : 0) + (budget.limits.dataSize === void 0 ? 0 : measureSandboxData([currentValue]));
15419
15446
  budget.visitNode();
@@ -44064,4 +44091,4 @@ export {
44064
44091
  FileSnapshotBackend,
44065
44092
  run
44066
44093
  };
44067
- //# sourceMappingURL=chunk-DRWLAPG6.js.map
44094
+ //# sourceMappingURL=chunk-XIEVJEAG.js.map