poe-code 11.0.11 → 11.0.13

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/index.js CHANGED
@@ -142791,10 +142791,22 @@ function createObjectArrayGlobals(options) {
142791
142791
  }),
142792
142792
  fromEntries: createSandboxClosure({
142793
142793
  sandbox: true,
142794
- call: ([value]) => allocateProducedSandboxValue(
142795
- Object.setPrototypeOf(Reflect.apply(Object.fromEntries, Object, [value]), null),
142796
- options.budget
142797
- ),
142794
+ call: ([value]) => {
142795
+ const iterator = getSandboxIterator(value);
142796
+ if (iterator === void 0) {
142797
+ throw new TypeError("Object.fromEntries requires an iterable.");
142798
+ }
142799
+ if (!iterator.generator) {
142800
+ return allocateProducedSandboxValue(
142801
+ Object.setPrototypeOf(
142802
+ Reflect.apply(Object.fromEntries, Object, [{ [Symbol.iterator]: () => iterator }]),
142803
+ null
142804
+ ),
142805
+ options.budget
142806
+ );
142807
+ }
142808
+ return objectFromSandboxEntries(iterator, options.budget);
142809
+ },
142798
142810
  name: "fromEntries"
142799
142811
  }),
142800
142812
  freeze: createSandboxClosure({
@@ -142915,6 +142927,38 @@ function createObjectArrayGlobals(options) {
142915
142927
  })
142916
142928
  };
142917
142929
  }
142930
+ async function objectFromSandboxEntries(iterator, budget) {
142931
+ const object = /* @__PURE__ */ Object.create(null);
142932
+ try {
142933
+ while (true) {
142934
+ const result = await iterator.next();
142935
+ if (typeof result !== "object" && typeof result !== "function" || result === null) {
142936
+ throw new TypeError("Iterator result must be an object.");
142937
+ }
142938
+ if (result.done) break;
142939
+ const entry = result.value;
142940
+ if (typeof entry !== "object" && typeof entry !== "function" || entry === null) {
142941
+ throw new TypeError("Object.fromEntries requires entry objects.");
142942
+ }
142943
+ const key3 = entry[0];
142944
+ const value = entry[1];
142945
+ Object.defineProperty(object, key3, {
142946
+ configurable: true,
142947
+ enumerable: true,
142948
+ value,
142949
+ writable: true
142950
+ });
142951
+ }
142952
+ } catch (error3) {
142953
+ try {
142954
+ await iterator.return?.();
142955
+ } catch {
142956
+ throw error3;
142957
+ }
142958
+ throw error3;
142959
+ }
142960
+ return allocateProducedSandboxValue(object, budget);
142961
+ }
142918
142962
  function assignSandboxValues(target, sources) {
142919
142963
  if (target === null || target === void 0) {
142920
142964
  throw new TypeError("Object.assign(target, ...sources) requires a non-null target.");
@@ -144281,6 +144325,7 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
144281
144325
  );
144282
144326
  }
144283
144327
  async function replaceRegex(value, regex, replacement, replaceAll2, budget, callClosure) {
144328
+ if (regex.flags.includes("g")) regex.lastIndex = 0;
144284
144329
  const matches = collectRegexMatches(regex, value, replaceAll2 || regex.flags.includes("g"));
144285
144330
  let result = "";
144286
144331
  let copiedThrough = 0;
@@ -144369,11 +144414,16 @@ function callSplit(value, args, budget) {
144369
144414
  if (args.some(isSandboxClosure))
144370
144415
  throw new TypeError("String#split does not support function arguments.");
144371
144416
  if (isSandboxRegex(args[0])) {
144417
+ const regex = args[0];
144418
+ const splitter = createSandboxRegex(
144419
+ regex.source,
144420
+ regex.flags.includes("g") ? regex.flags : `${regex.flags}g`
144421
+ );
144372
144422
  const limit2 = asNumberOrUndefined(args[1]) ?? 2 ** 32 - 1;
144373
144423
  const result2 = [];
144374
144424
  let copiedThrough = 0;
144375
144425
  let endedWithZeroWidthMatch = false;
144376
- for (const match of collectRegexMatches(args[0], value, true)) {
144426
+ for (const match of collectRegexMatches(splitter, value, true)) {
144377
144427
  endedWithZeroWidthMatch = match.text.length === 0 && match.index === value.length;
144378
144428
  if (match.text.length === 0 && match.index === 0) continue;
144379
144429
  if (result2.length >= limit2) break;
@@ -144411,18 +144461,18 @@ function callMatchLikeMethod(value, methodName, args) {
144411
144461
  throw new TypeError("String#matchAll requires a global regex.");
144412
144462
  if (methodName === "match" && !regex.flags.includes("g"))
144413
144463
  return toMatchArray(executeRegex(regex, value), value);
144414
- const matches = collectRegexMatches(regex, value, true);
144464
+ if (methodName === "match") regex.lastIndex = 0;
144465
+ const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, regex.lastIndex) : regex;
144466
+ const matches = collectRegexMatches(matcher, value, true);
144415
144467
  return methodName === "match" ? matches.map((match) => match.text) : matches.map((match) => toMatchArray(match, value));
144416
144468
  }
144417
144469
  function collectRegexMatches(regex, value, all) {
144418
144470
  const matches = [];
144419
- const pattern = getSandboxRegexPattern(regex);
144420
- let startIndex = 0;
144421
144471
  do {
144422
- const match = matchRegexFrom(pattern, value, startIndex);
144472
+ const match = executeRegex(regex, value);
144423
144473
  if (match === null) break;
144424
144474
  matches.push(match);
144425
- startIndex = match.index + Math.max(match.text.length, 1);
144475
+ if (all && match.text.length === 0) regex.lastIndex += 1;
144426
144476
  } while (all);
144427
144477
  return matches;
144428
144478
  }
@@ -144444,7 +144494,6 @@ var init_string = __esm({
144444
144494
  "packages/safejs/src/interp/methods/string.ts"() {
144445
144495
  "use strict";
144446
144496
  init_values();
144447
- init_engine2();
144448
144497
  init_regex2();
144449
144498
  SPLIT_STRING_MESSAGE = "String#split only supports string separator values.";
144450
144499
  stringMethodNames = /* @__PURE__ */ new Set([
@@ -155565,7 +155614,7 @@ var init_package2 = __esm({
155565
155614
  "package.json"() {
155566
155615
  package_default2 = {
155567
155616
  name: "poe-code",
155568
- version: "11.0.11",
155617
+ version: "11.0.13",
155569
155618
  description: "CLI tool to configure Poe API for developer workflows.",
155570
155619
  license: "MIT",
155571
155620
  type: "module",