poe-code 14.0.53 → 14.0.55

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": "14.0.53",
3
+ "version": "14.0.55",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -24935,14 +24935,28 @@ function getStringMember(value, property, budget) {
24935
24935
  name: `String#${property}`,
24936
24936
  ...property === "localeCompare" ? { length: 1 } : {},
24937
24937
  ...property === "isWellFormed" || property === "toWellFormed" ? { length: 0 } : {},
24938
- call: (args, context) => callStringMethod(
24939
- value,
24940
- property,
24941
- args,
24942
- budget,
24943
- context === void 0 ? void 0 : async (closure, closureArgs) => await closure.call(closureArgs, { ...context, thisValue: void 0 }),
24944
- context?.compilation
24945
- )
24938
+ call: async (args, context) => {
24939
+ const receiver = context?.thisValue;
24940
+ if (receiver === null || receiver === void 0) {
24941
+ throw new TypeError(`String#${property} requires a non-null receiver.`);
24942
+ }
24943
+ const retainedReceiver = {};
24944
+ budget.setRetainedValues(retainedReceiver, () => [receiver]);
24945
+ try {
24946
+ const string = await sandboxString(receiver, budget, context);
24947
+ return await callStringMethod(
24948
+ string,
24949
+ property,
24950
+ args,
24951
+ budget,
24952
+ (closure, closureArgs) => invokeBuiltinClosure(closure, closureArgs, budget, context, void 0),
24953
+ context?.compilation,
24954
+ context
24955
+ );
24956
+ } finally {
24957
+ budget.setRetainedValues(retainedReceiver, void 0);
24958
+ }
24959
+ }
24946
24960
  });
24947
24961
  }
24948
24962
  function getStringIndex(property) {
@@ -24957,7 +24971,7 @@ function isStringMethodName(property) {
24957
24971
  }
24958
24972
  function validateStringMethodArguments(_methodName, _args) {
24959
24973
  }
24960
- function callStringMethod(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent) {
24974
+ function callStringMethod(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent, context) {
24961
24975
  if (methodName === "isWellFormed") {
24962
24976
  for (let index = 0; index < value.length; index++) {
24963
24977
  const codeUnit = value.charCodeAt(index);
@@ -24996,6 +25010,9 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
24996
25010
  if (methodName === "replace" || methodName === "replaceAll") {
24997
25011
  return callReplaceLikeMethod(value, methodName, args, budget, callClosure);
24998
25012
  }
25013
+ if ((methodName === "match" || methodName === "matchAll" || methodName === "search") && !isSandboxRegex(args[0])) {
25014
+ return callStringPattern(value, methodName, args[0], budget, parent, context);
25015
+ }
24999
25016
  const operation = budget.acquireCompileOwner(false, parent?.owner);
25000
25017
  const compilation = new CompileScope(operation.owner);
25001
25018
  try {
@@ -25266,6 +25283,21 @@ function callSplit(value, args, budget, compilation) {
25266
25283
  budget.allocateArrayLength(result.length);
25267
25284
  return result;
25268
25285
  }
25286
+ async function callStringPattern(value, methodName, pattern, budget, parent, context) {
25287
+ const operation = budget.acquireCompileOwner(false, parent?.owner);
25288
+ const compilation = new CompileScope(operation.owner);
25289
+ const retainedPattern = {};
25290
+ budget.setRetainedValues(retainedPattern, () => [pattern]);
25291
+ try {
25292
+ const source = pattern === void 0 ? "" : await sandboxString(pattern, budget, context);
25293
+ const regex = createSandboxRegex(source, methodName === "matchAll" ? "g" : "", 0, compilation);
25294
+ return callMatchLikeMethod(value, methodName, [regex], compilation);
25295
+ } finally {
25296
+ budget.setRetainedValues(retainedPattern, void 0);
25297
+ compilation.dispose();
25298
+ operation.release();
25299
+ }
25300
+ }
25269
25301
  function callMatchLikeMethod(value, methodName, args, compilation) {
25270
25302
  const regex = args[0];
25271
25303
  if (!isSandboxRegex(regex))
@@ -25283,15 +25315,16 @@ function callMatchLikeMethod(value, methodName, args, compilation) {
25283
25315
  return toMatchArray(executeRegex(regex, value), value);
25284
25316
  if (methodName === "match") regex.lastIndex = 0;
25285
25317
  const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, regex.lastIndex, compilation) : regex;
25286
- const matches = collectRegexMatches(matcher, value, true);
25318
+ const matches = collectRegexMatches(matcher, value, true, compilation.owner?.budget);
25287
25319
  if (methodName === "match" && matches.length === 0) return null;
25288
25320
  return methodName === "match" ? matches.map((match) => match.text) : matches.map((match) => toMatchArray(match, value));
25289
25321
  }
25290
- function collectRegexMatches(regex, value, all) {
25322
+ function collectRegexMatches(regex, value, all, budget) {
25291
25323
  const matches = [];
25292
25324
  do {
25293
25325
  const match = executeRegex(regex, value);
25294
25326
  if (match === null) break;
25327
+ budget?.allocateArrayLength(matches.length + 1);
25295
25328
  matches.push(match);
25296
25329
  if (all && match.text.length === 0) regex.lastIndex += 1;
25297
25330
  } while (all);
@@ -28148,7 +28181,8 @@ async function evaluateStringMethodCall(node, target, methodName, context) {
28148
28181
  args.value,
28149
28182
  context.budget,
28150
28183
  (closure, closureArgs) => invokeSandboxClosure(closure, closureArgs, context, context.callStack),
28151
- context.compilation
28184
+ context.compilation,
28185
+ createCoercionContext(context)
28152
28186
  )
28153
28187
  };
28154
28188
  } catch (error) {
@@ -30578,32 +30612,43 @@ function defineDataProperty(target, key, value) {
30578
30612
  }
30579
30613
 
30580
30614
  // packages/safe-js/src/interp/globals/regex.ts
30581
- function createRegexGlobals(owner) {
30582
- const construct = (args, context) => {
30583
- const selected = owner ?? context?.compilation?.owner;
30615
+ function createRegexGlobals(options) {
30616
+ const invoke = (construct) => async (args, context) => {
30617
+ const selected = options.compileOwner ?? context?.compilation?.owner;
30584
30618
  if (context?.compilation?.owner !== void 0 && selected !== context.compilation.owner) {
30585
30619
  throw new SandboxError("reentry");
30586
30620
  }
30587
- const operation = selected?.budget.acquireCompileOwner(false, selected);
30588
- const compilation = context?.compilation ?? new CompileScope(selected);
30621
+ const operation = options.budget.acquireCompileOwner(false, selected);
30622
+ const compilation = context?.compilation?.owner === operation.owner ? context.compilation : new CompileScope(operation.owner);
30623
+ let source = "";
30624
+ const retained = {};
30625
+ options.budget.setRetainedValues(retained, () => [...args, source]);
30589
30626
  try {
30627
+ const pattern = args[0];
30628
+ const flags = args[1];
30629
+ if (!construct && isSandboxRegex(pattern) && flags === void 0) return pattern;
30630
+ const sourceValue = isSandboxRegex(pattern) ? pattern.source : pattern;
30631
+ const flagsValue = isSandboxRegex(pattern) && flags === void 0 ? pattern.flags : flags;
30632
+ source = sourceValue === void 0 ? "" : await sandboxString(sourceValue, options.budget, context);
30633
+ const flagText = flagsValue === void 0 ? "" : await sandboxString(flagsValue, options.budget, context);
30590
30634
  const regex = createSandboxRegex(
30591
- String(args[0] ?? ""),
30592
- String(args[1] ?? ""),
30635
+ source,
30636
+ flagText,
30593
30637
  0,
30594
30638
  compilation
30595
30639
  );
30596
- if (context?.compilation === void 0 && selected !== void 0) {
30597
- reconcileCompiledValues(selected.budget, [regex], compilation);
30640
+ if (compilation !== context?.compilation) {
30641
+ reconcileCompiledValues(options.budget, [regex], compilation);
30598
30642
  }
30599
30643
  return regex;
30600
30644
  } finally {
30601
- if (context?.compilation === void 0) compilation.dispose();
30602
- operation?.release();
30645
+ options.budget.setRetainedValues(retained, void 0);
30646
+ if (compilation !== context?.compilation) compilation.dispose();
30647
+ operation.release();
30603
30648
  }
30604
30649
  };
30605
30650
  return {
30606
- RegExp: createSandboxClosure({ sandbox: true, name: "RegExp", call: construct, construct })
30651
+ RegExp: createSandboxClosure({ sandbox: true, name: "RegExp", call: invoke(false), construct: invoke(true) })
30607
30652
  };
30608
30653
  }
30609
30654
 
@@ -31160,7 +31205,7 @@ function createBuiltinBindings(options) {
31160
31205
  ...createObjectArrayGlobals(options),
31161
31206
  ...createMiscGlobals(options),
31162
31207
  ...createPromiseGlobals(options),
31163
- ...createRegexGlobals(options.compileOwner)
31208
+ ...createRegexGlobals(options)
31164
31209
  };
31165
31210
  }
31166
31211
 
@@ -33283,4 +33328,4 @@ export {
33283
33328
  FileSnapshotBackend,
33284
33329
  run
33285
33330
  };
33286
- //# sourceMappingURL=chunk-VDFW3EKS.js.map
33331
+ //# sourceMappingURL=chunk-6LFWVA64.js.map