poe-code 11.0.2 → 11.0.4

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-XU36QFFX.js";
30
+ } from "./chunk-CA342J7E.js";
31
31
 
32
32
  // packages/safejs/src/migrate.ts
33
33
  import { createHash } from "node:crypto";
@@ -8048,4 +8048,4 @@ export {
8048
8048
  parseMcpConfig,
8049
8049
  makeMcpModule
8050
8050
  };
8051
- //# sourceMappingURL=chunk-JUF273GA.js.map
8051
+ //# sourceMappingURL=chunk-NBVIHENC.js.map
@@ -19,7 +19,7 @@ import {
19
19
  parseMcpConfig,
20
20
  splitFrontmatter,
21
21
  withBrokenPipeGuard
22
- } from "./chunks/chunk-JUF273GA.js";
22
+ } from "./chunks/chunk-NBVIHENC.js";
23
23
  import {
24
24
  Budget,
25
25
  SandboxError,
@@ -31,7 +31,7 @@ import {
31
31
  replaceErrorStack,
32
32
  restore,
33
33
  run
34
- } from "./chunks/chunk-XU36QFFX.js";
34
+ } from "./chunks/chunk-CA342J7E.js";
35
35
  import "./chunks/chunk-4YIDX44G.js";
36
36
 
37
37
  // packages/safejs/src/cli.ts
@@ -3,7 +3,7 @@ import {
3
3
  createReplayableRandom,
4
4
  lint,
5
5
  run
6
- } from "./chunks/chunk-XU36QFFX.js";
6
+ } from "./chunks/chunk-CA342J7E.js";
7
7
  import "./chunks/chunk-4YIDX44G.js";
8
8
  export {
9
9
  Budget,
@@ -26,7 +26,7 @@ import {
26
26
  runWithSpawnUsageAccumulator,
27
27
  splitFrontmatter,
28
28
  supportsSpawnMode
29
- } from "./chunks/chunk-JUF273GA.js";
29
+ } from "./chunks/chunk-NBVIHENC.js";
30
30
  import {
31
31
  Budget,
32
32
  FileSnapshotBackend,
@@ -48,7 +48,7 @@ import {
48
48
  registerPendingHostCallPolicy,
49
49
  restore,
50
50
  run
51
- } from "./chunks/chunk-XU36QFFX.js";
51
+ } from "./chunks/chunk-CA342J7E.js";
52
52
  import "./chunks/chunk-4YIDX44G.js";
53
53
 
54
54
  // packages/safejs/src/runner/run-harness.ts
@@ -150,21 +150,57 @@ async function replaceRegex(value, regex, replacement, replaceAll, budget, callC
150
150
  result += value.slice(copiedThrough, match.index);
151
151
  result +=
152
152
  typeof replacement === "string"
153
- ? expandReplacement(replacement, match.text, match.captures)
153
+ ? expandReplacement(replacement, match.text, match.captures, value, match.index)
154
154
  : String(await callClosure(replacement, [match.text, ...match.captures, match.index, value]));
155
155
  copiedThrough = match.index + match.text.length;
156
156
  }
157
157
  result += value.slice(copiedThrough);
158
158
  return budget.allocateString(result);
159
159
  }
160
- function expandReplacement(replacement, match, captures) {
161
- return replacement.replace(/\$([$&]|[1-9][0-9]?)/g, (token, part) => {
162
- if (part === "$")
163
- return "$";
164
- if (part === "&")
165
- return match;
166
- return captures[Number(part) - 1] ?? token;
167
- });
160
+ function expandReplacement(replacement, match, captures, input, matchIndex) {
161
+ let result = "";
162
+ for (let index = 0; index < replacement.length; index += 1) {
163
+ const character = replacement.charAt(index);
164
+ if (character !== "$") {
165
+ result += character;
166
+ continue;
167
+ }
168
+ const token = replacement.charAt(index + 1);
169
+ if (token === "$") {
170
+ result += "$";
171
+ }
172
+ else if (token === "&") {
173
+ result += match;
174
+ }
175
+ else if (token === "`") {
176
+ result += input.slice(0, matchIndex);
177
+ }
178
+ else if (token === "'") {
179
+ result += input.slice(matchIndex + match.length);
180
+ }
181
+ else if (token >= "0" && token <= "9") {
182
+ let captureIndex = Number(token);
183
+ const nextDigit = replacement.charAt(index + 2);
184
+ if (nextDigit >= "0" && nextDigit <= "9") {
185
+ const twoDigitIndex = Number(token + nextDigit);
186
+ if (twoDigitIndex > 0 && twoDigitIndex <= captures.length) {
187
+ captureIndex = twoDigitIndex;
188
+ index += 1;
189
+ }
190
+ }
191
+ if (captureIndex === 0 || captureIndex > captures.length) {
192
+ result += "$";
193
+ continue;
194
+ }
195
+ result += captures[captureIndex - 1] ?? "";
196
+ }
197
+ else {
198
+ result += "$";
199
+ continue;
200
+ }
201
+ index += 1;
202
+ }
203
+ return result;
168
204
  }
169
205
  async function replaceWithClosure(value, searchValue, replacer, replaceAll, budget, callClosure) {
170
206
  const offsets = findReplacementOffsets(value, searchValue, replaceAll);
@@ -1 +1 @@
1
- export declare const KNOWN_RUNTIME_GLOBALS: readonly ["AggregateError", "Array", "Boolean", "Error", "isFinite", "isNaN", "JSON", "Map", "Math", "Number", "Object", "parseFloat", "parseInt", "Promise", "RangeError", "ReferenceError", "RegExp", "Set", "String", "structuredClone", "SyntaxError", "TypeError", "console"];
1
+ export declare const KNOWN_RUNTIME_GLOBALS: readonly ["AggregateError", "Array", "Boolean", "Error", "Infinity", "isFinite", "isNaN", "JSON", "Map", "Math", "NaN", "Number", "Object", "parseFloat", "parseInt", "Promise", "RangeError", "ReferenceError", "RegExp", "Set", "String", "structuredClone", "SyntaxError", "TypeError", "console"];
@@ -3,11 +3,13 @@ export const KNOWN_RUNTIME_GLOBALS = [
3
3
  "Array",
4
4
  "Boolean",
5
5
  "Error",
6
+ "Infinity",
6
7
  "isFinite",
7
8
  "isNaN",
8
9
  "JSON",
9
10
  "Map",
10
11
  "Math",
12
+ "NaN",
11
13
  "Number",
12
14
  "Object",
13
15
  "parseFloat",