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 +61 -12
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-2M5F6OIT.js → chunk-EV4BL6HH.js} +2 -2
- package/packages/safejs/dist/chunks/{chunk-QWNCR7EZ.js → chunk-GTX2EXKD.js} +61 -11
- package/packages/safejs/dist/chunks/{chunk-QWNCR7EZ.js.map → chunk-GTX2EXKD.js.map} +2 -2
- package/packages/safejs/dist/cli.js +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/index.js +2 -2
- package/packages/safejs/dist/interp/globals/object-array.js +45 -1
- package/packages/safejs/dist/interp/methods/string.js +15 -8
- /package/packages/safejs/dist/chunks/{chunk-2M5F6OIT.js.map → chunk-EV4BL6HH.js.map} +0 -0
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
parseMcpConfig,
|
|
21
21
|
splitFrontmatter,
|
|
22
22
|
withBrokenPipeGuard
|
|
23
|
-
} from "./chunks/chunk-
|
|
23
|
+
} from "./chunks/chunk-EV4BL6HH.js";
|
|
24
24
|
import {
|
|
25
25
|
Budget,
|
|
26
26
|
SandboxError,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
replaceErrorStack,
|
|
33
33
|
restore,
|
|
34
34
|
run
|
|
35
|
-
} from "./chunks/chunk-
|
|
35
|
+
} from "./chunks/chunk-GTX2EXKD.js";
|
|
36
36
|
import "./chunks/chunk-4YIDX44G.js";
|
|
37
37
|
|
|
38
38
|
// packages/safejs/src/cli.ts
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
runWithSpawnUsageAccumulator,
|
|
28
28
|
splitFrontmatter,
|
|
29
29
|
supportsSpawnMode
|
|
30
|
-
} from "./chunks/chunk-
|
|
30
|
+
} from "./chunks/chunk-EV4BL6HH.js";
|
|
31
31
|
import {
|
|
32
32
|
Budget,
|
|
33
33
|
FileSnapshotBackend,
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
registerPendingHostCallPolicy,
|
|
50
50
|
restore,
|
|
51
51
|
run
|
|
52
|
-
} from "./chunks/chunk-
|
|
52
|
+
} from "./chunks/chunk-GTX2EXKD.js";
|
|
53
53
|
import "./chunks/chunk-4YIDX44G.js";
|
|
54
54
|
|
|
55
55
|
// packages/safejs/src/runner/run-harness.ts
|
|
@@ -30,7 +30,16 @@ export function createObjectArrayGlobals(options) {
|
|
|
30
30
|
}),
|
|
31
31
|
fromEntries: createSandboxClosure({
|
|
32
32
|
sandbox: true,
|
|
33
|
-
call: ([value]) =>
|
|
33
|
+
call: ([value]) => {
|
|
34
|
+
const iterator = getSandboxIterator(value);
|
|
35
|
+
if (iterator === undefined) {
|
|
36
|
+
throw new TypeError("Object.fromEntries requires an iterable.");
|
|
37
|
+
}
|
|
38
|
+
if (!iterator.generator) {
|
|
39
|
+
return allocateProducedSandboxValue(Object.setPrototypeOf(Reflect.apply(Object.fromEntries, Object, [{ [Symbol.iterator]: () => iterator }]), null), options.budget);
|
|
40
|
+
}
|
|
41
|
+
return objectFromSandboxEntries(iterator, options.budget);
|
|
42
|
+
},
|
|
34
43
|
name: "fromEntries"
|
|
35
44
|
}),
|
|
36
45
|
freeze: createSandboxClosure({
|
|
@@ -151,6 +160,41 @@ export function createObjectArrayGlobals(options) {
|
|
|
151
160
|
})
|
|
152
161
|
};
|
|
153
162
|
}
|
|
163
|
+
async function objectFromSandboxEntries(iterator, budget) {
|
|
164
|
+
const object = Object.create(null);
|
|
165
|
+
try {
|
|
166
|
+
while (true) {
|
|
167
|
+
const result = await iterator.next();
|
|
168
|
+
if ((typeof result !== "object" && typeof result !== "function") || result === null) {
|
|
169
|
+
throw new TypeError("Iterator result must be an object.");
|
|
170
|
+
}
|
|
171
|
+
if (result.done)
|
|
172
|
+
break;
|
|
173
|
+
const entry = result.value;
|
|
174
|
+
if ((typeof entry !== "object" && typeof entry !== "function") || entry === null) {
|
|
175
|
+
throw new TypeError("Object.fromEntries requires entry objects.");
|
|
176
|
+
}
|
|
177
|
+
const key = entry[0];
|
|
178
|
+
const value = entry[1];
|
|
179
|
+
Object.defineProperty(object, key, {
|
|
180
|
+
configurable: true,
|
|
181
|
+
enumerable: true,
|
|
182
|
+
value,
|
|
183
|
+
writable: true
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
try {
|
|
189
|
+
await iterator.return?.();
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
return allocateProducedSandboxValue(object, budget);
|
|
197
|
+
}
|
|
154
198
|
function assignSandboxValues(target, sources) {
|
|
155
199
|
if (target === null || target === undefined) {
|
|
156
200
|
throw new TypeError("Object.assign(target, ...sources) requires a non-null target.");
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createSandboxClosure,
|
|
2
|
-
import { matchRegexFrom } from "../regex/engine.js";
|
|
1
|
+
import { createSandboxClosure, createSandboxRegex, isSandboxClosure, isSandboxRegex } from "../values.js";
|
|
3
2
|
import { executeRegex, toMatchArray } from "./regex.js";
|
|
4
3
|
const SPLIT_STRING_MESSAGE = "String#split only supports string separator values.";
|
|
5
4
|
const stringMethodNames = new Set([
|
|
@@ -143,6 +142,8 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
|
143
142
|
return replaceWithClosure(value, search, replacement, methodName === "replaceAll", budget, callClosure);
|
|
144
143
|
}
|
|
145
144
|
async function replaceRegex(value, regex, replacement, replaceAll, budget, callClosure) {
|
|
145
|
+
if (regex.flags.includes("g"))
|
|
146
|
+
regex.lastIndex = 0;
|
|
146
147
|
const matches = collectRegexMatches(regex, value, replaceAll || regex.flags.includes("g"));
|
|
147
148
|
let result = "";
|
|
148
149
|
let copiedThrough = 0;
|
|
@@ -237,11 +238,13 @@ function callSplit(value, args, budget) {
|
|
|
237
238
|
if (args.some(isSandboxClosure))
|
|
238
239
|
throw new TypeError("String#split does not support function arguments.");
|
|
239
240
|
if (isSandboxRegex(args[0])) {
|
|
241
|
+
const regex = args[0];
|
|
242
|
+
const splitter = createSandboxRegex(regex.source, regex.flags.includes("g") ? regex.flags : `${regex.flags}g`);
|
|
240
243
|
const limit = asNumberOrUndefined(args[1]) ?? 2 ** 32 - 1;
|
|
241
244
|
const result = [];
|
|
242
245
|
let copiedThrough = 0;
|
|
243
246
|
let endedWithZeroWidthMatch = false;
|
|
244
|
-
for (const match of collectRegexMatches(
|
|
247
|
+
for (const match of collectRegexMatches(splitter, value, true)) {
|
|
245
248
|
endedWithZeroWidthMatch = match.text.length === 0 && match.index === value.length;
|
|
246
249
|
if (match.text.length === 0 && match.index === 0)
|
|
247
250
|
continue;
|
|
@@ -282,21 +285,25 @@ function callMatchLikeMethod(value, methodName, args) {
|
|
|
282
285
|
throw new TypeError("String#matchAll requires a global regex.");
|
|
283
286
|
if (methodName === "match" && !regex.flags.includes("g"))
|
|
284
287
|
return toMatchArray(executeRegex(regex, value), value);
|
|
285
|
-
|
|
288
|
+
if (methodName === "match")
|
|
289
|
+
regex.lastIndex = 0;
|
|
290
|
+
const matcher = methodName === "matchAll"
|
|
291
|
+
? createSandboxRegex(regex.source, regex.flags, regex.lastIndex)
|
|
292
|
+
: regex;
|
|
293
|
+
const matches = collectRegexMatches(matcher, value, true);
|
|
286
294
|
return methodName === "match"
|
|
287
295
|
? matches.map((match) => match.text)
|
|
288
296
|
: matches.map((match) => toMatchArray(match, value));
|
|
289
297
|
}
|
|
290
298
|
function collectRegexMatches(regex, value, all) {
|
|
291
299
|
const matches = [];
|
|
292
|
-
const pattern = getSandboxRegexPattern(regex);
|
|
293
|
-
let startIndex = 0;
|
|
294
300
|
do {
|
|
295
|
-
const match =
|
|
301
|
+
const match = executeRegex(regex, value);
|
|
296
302
|
if (match === null)
|
|
297
303
|
break;
|
|
298
304
|
matches.push(match);
|
|
299
|
-
|
|
305
|
+
if (all && match.text.length === 0)
|
|
306
|
+
regex.lastIndex += 1;
|
|
300
307
|
} while (all);
|
|
301
308
|
return matches;
|
|
302
309
|
}
|
|
File without changes
|