poe-code 11.0.12 → 11.0.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "11.0.12",
3
+ "version": "11.0.14",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -139,6 +139,12 @@ function findSourceOffset(source, line, column) {
139
139
  }
140
140
 
141
141
  // packages/safejs/src/parse/bindings.ts
142
+ function getFunctionLength(params) {
143
+ const firstOptional = params.findIndex(
144
+ (param) => param.type === "AssignmentPattern" || param.type === "RestElement"
145
+ );
146
+ return firstOptional === -1 ? params.length : firstOptional;
147
+ }
142
148
  function* boundIdentifiers(pattern) {
143
149
  switch (pattern.type) {
144
150
  case "Identifier":
@@ -19632,6 +19638,9 @@ function createSandboxClosure(input) {
19632
19638
  if (input.sandbox === true) {
19633
19639
  Object.defineProperty(closure, "sandbox", { value: true });
19634
19640
  }
19641
+ if (input.length !== void 0) {
19642
+ Object.defineProperty(closure, "length", { value: input.length });
19643
+ }
19635
19644
  if (input.boundTarget !== void 0) {
19636
19645
  Object.defineProperty(closure, "boundTarget", { value: input.boundTarget });
19637
19646
  }
@@ -21722,6 +21731,7 @@ function createInterpretedClosure(node, context, evaluateNode2) {
21722
21731
  } : void 0;
21723
21732
  return createSandboxClosure({
21724
21733
  sandbox: true,
21734
+ length: getFunctionLength(node.params),
21725
21735
  ...node.async ? { async: true } : {},
21726
21736
  ...node.type === "FunctionDeclaration" || node.type === "FunctionExpression" ? node.id === void 0 ? {} : { name: node.id.name } : {},
21727
21737
  ...construct === void 0 ? {} : { construct },
@@ -21773,6 +21783,7 @@ function createInterpretedClosure(node, context, evaluateNode2) {
21773
21783
  function createGeneratorClosure(node, context, evaluateNode2) {
21774
21784
  return createSandboxClosure({
21775
21785
  sandbox: true,
21786
+ length: getFunctionLength(node.params),
21776
21787
  ...node.id === void 0 ? {} : { name: node.id.name },
21777
21788
  retainedValues: () => context.scope.retainedValues(),
21778
21789
  call: async (args, callContext) => {
@@ -24528,6 +24539,9 @@ function getFunctionMember(target, property, options) {
24528
24539
  if (propertyValue !== void 0 || Object.hasOwn(target.properties ?? {}, String(property))) {
24529
24540
  return propertyValue;
24530
24541
  }
24542
+ if (property === "length") {
24543
+ return target.length;
24544
+ }
24531
24545
  if (!isFunctionMethodName(property)) {
24532
24546
  return void 0;
24533
24547
  }
@@ -24547,6 +24561,7 @@ function callFunctionMethod(target, methodName, args, options, stack) {
24547
24561
  return createSandboxClosure({
24548
24562
  sandbox: true,
24549
24563
  name: `bound ${target.name ?? ""}`,
24564
+ length: target.length === void 0 ? void 0 : Math.max(0, target.length - boundArgs.length),
24550
24565
  boundTarget: target,
24551
24566
  retainedValues: () => [target, thisValue, ...boundArgs],
24552
24567
  call: (callArgs, context) => options.callClosure(target, [...boundArgs, ...callArgs], context?.stack ?? [], thisValue),
@@ -25179,6 +25194,7 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
25179
25194
  );
25180
25195
  }
25181
25196
  async function replaceRegex(value, regex, replacement, replaceAll, budget, callClosure) {
25197
+ if (regex.flags.includes("g")) regex.lastIndex = 0;
25182
25198
  const matches = collectRegexMatches(regex, value, replaceAll || regex.flags.includes("g"));
25183
25199
  let result = "";
25184
25200
  let copiedThrough = 0;
@@ -25267,11 +25283,16 @@ function callSplit(value, args, budget) {
25267
25283
  if (args.some(isSandboxClosure))
25268
25284
  throw new TypeError("String#split does not support function arguments.");
25269
25285
  if (isSandboxRegex(args[0])) {
25286
+ const regex = args[0];
25287
+ const splitter = createSandboxRegex(
25288
+ regex.source,
25289
+ regex.flags.includes("g") ? regex.flags : `${regex.flags}g`
25290
+ );
25270
25291
  const limit2 = asNumberOrUndefined(args[1]) ?? 2 ** 32 - 1;
25271
25292
  const result2 = [];
25272
25293
  let copiedThrough = 0;
25273
25294
  let endedWithZeroWidthMatch = false;
25274
- for (const match of collectRegexMatches(args[0], value, true)) {
25295
+ for (const match of collectRegexMatches(splitter, value, true)) {
25275
25296
  endedWithZeroWidthMatch = match.text.length === 0 && match.index === value.length;
25276
25297
  if (match.text.length === 0 && match.index === 0) continue;
25277
25298
  if (result2.length >= limit2) break;
@@ -25309,18 +25330,18 @@ function callMatchLikeMethod(value, methodName, args) {
25309
25330
  throw new TypeError("String#matchAll requires a global regex.");
25310
25331
  if (methodName === "match" && !regex.flags.includes("g"))
25311
25332
  return toMatchArray(executeRegex(regex, value), value);
25312
- const matches = collectRegexMatches(regex, value, true);
25333
+ if (methodName === "match") regex.lastIndex = 0;
25334
+ const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, regex.lastIndex) : regex;
25335
+ const matches = collectRegexMatches(matcher, value, true);
25313
25336
  return methodName === "match" ? matches.map((match) => match.text) : matches.map((match) => toMatchArray(match, value));
25314
25337
  }
25315
25338
  function collectRegexMatches(regex, value, all) {
25316
25339
  const matches = [];
25317
- const pattern = getSandboxRegexPattern(regex);
25318
- let startIndex = 0;
25319
25340
  do {
25320
- const match = matchRegexFrom(pattern, value, startIndex);
25341
+ const match = executeRegex(regex, value);
25321
25342
  if (match === null) break;
25322
25343
  matches.push(match);
25323
- startIndex = match.index + Math.max(match.text.length, 1);
25344
+ if (all && match.text.length === 0) regex.lastIndex += 1;
25324
25345
  } while (all);
25325
25346
  return matches;
25326
25347
  }
@@ -29031,4 +29052,4 @@ export {
29031
29052
  FileSnapshotBackend,
29032
29053
  run
29033
29054
  };
29034
- //# sourceMappingURL=chunk-5BWI6HAZ.js.map
29055
+ //# sourceMappingURL=chunk-DZH7JZC4.js.map