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/dist/index.js +28 -8
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-5BWI6HAZ.js → chunk-DZH7JZC4.js} +28 -7
- package/packages/safejs/dist/chunks/chunk-DZH7JZC4.js.map +7 -0
- package/packages/safejs/dist/chunks/{chunk-WV23C6SS.js → chunk-X745DTOB.js} +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/async.js +3 -1
- package/packages/safejs/dist/interp/methods/function.js +4 -0
- package/packages/safejs/dist/interp/methods/string.js +15 -8
- package/packages/safejs/dist/interp/values.d.ts +2 -0
- package/packages/safejs/dist/interp/values.js +3 -0
- package/packages/safejs/dist/parse/bindings.d.ts +2 -1
- package/packages/safejs/dist/parse/bindings.js +4 -0
- package/packages/safejs/dist/snapshot/restore.js +2 -0
- package/packages/safejs/dist/chunks/chunk-5BWI6HAZ.js.map +0 -7
- /package/packages/safejs/dist/chunks/{chunk-WV23C6SS.js.map → chunk-X745DTOB.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-DZH7JZC4.js";
|
|
31
31
|
|
|
32
32
|
// packages/safejs/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8055,4 +8055,4 @@ export {
|
|
|
8055
8055
|
parseMcpConfig,
|
|
8056
8056
|
makeMcpModule
|
|
8057
8057
|
};
|
|
8058
|
-
//# sourceMappingURL=chunk-
|
|
8058
|
+
//# sourceMappingURL=chunk-X745DTOB.js.map
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
parseMcpConfig,
|
|
21
21
|
splitFrontmatter,
|
|
22
22
|
withBrokenPipeGuard
|
|
23
|
-
} from "./chunks/chunk-
|
|
23
|
+
} from "./chunks/chunk-X745DTOB.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-DZH7JZC4.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-X745DTOB.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-DZH7JZC4.js";
|
|
53
53
|
import "./chunks/chunk-4YIDX44G.js";
|
|
54
54
|
|
|
55
55
|
// packages/safejs/src/runner/run-harness.ts
|
|
@@ -5,7 +5,7 @@ import { getThenable, resolveSandboxValue } from "./promise.js";
|
|
|
5
5
|
import { runAsyncPrefix, suspendJob } from "./jobs.js";
|
|
6
6
|
import { awaitSandboxValue } from "./cancel.js";
|
|
7
7
|
import { hoistVarDeclarations } from "./var-hoist.js";
|
|
8
|
-
import { boundIdentifiers, containsParameterExpression, hoistedVarDeclarations } from "../parse/bindings.js";
|
|
8
|
+
import { boundIdentifiers, containsParameterExpression, getFunctionLength, hoistedVarDeclarations } from "../parse/bindings.js";
|
|
9
9
|
import { createSandboxArguments, createSandboxClosure, createSandboxGenerator, createSandboxPromise, allocateProducedSandboxValue, isSandboxPromise } from "./values.js";
|
|
10
10
|
export function emitResumeBreakpoint(context, breakpoint) {
|
|
11
11
|
context.onYield?.({
|
|
@@ -55,6 +55,7 @@ export function createInterpretedClosure(node, context, evaluateNode) {
|
|
|
55
55
|
: undefined;
|
|
56
56
|
return createSandboxClosure({
|
|
57
57
|
sandbox: true,
|
|
58
|
+
length: getFunctionLength(node.params),
|
|
58
59
|
...(node.async ? { async: true } : {}),
|
|
59
60
|
...(node.type === "FunctionDeclaration" || node.type === "FunctionExpression"
|
|
60
61
|
? node.id === undefined
|
|
@@ -102,6 +103,7 @@ export function createInterpretedClosure(node, context, evaluateNode) {
|
|
|
102
103
|
function createGeneratorClosure(node, context, evaluateNode) {
|
|
103
104
|
return createSandboxClosure({
|
|
104
105
|
sandbox: true,
|
|
106
|
+
length: getFunctionLength(node.params),
|
|
105
107
|
...(node.id === undefined ? {} : { name: node.id.name }),
|
|
106
108
|
retainedValues: () => context.scope.retainedValues(),
|
|
107
109
|
call: async (args, callContext) => {
|
|
@@ -5,6 +5,9 @@ export function getFunctionMember(target, property, options) {
|
|
|
5
5
|
if (propertyValue !== undefined || Object.hasOwn(target.properties ?? {}, String(property))) {
|
|
6
6
|
return propertyValue;
|
|
7
7
|
}
|
|
8
|
+
if (property === "length") {
|
|
9
|
+
return target.length;
|
|
10
|
+
}
|
|
8
11
|
if (!isFunctionMethodName(property)) {
|
|
9
12
|
return undefined;
|
|
10
13
|
}
|
|
@@ -24,6 +27,7 @@ function callFunctionMethod(target, methodName, args, options, stack) {
|
|
|
24
27
|
return createSandboxClosure({
|
|
25
28
|
sandbox: true,
|
|
26
29
|
name: `bound ${target.name ?? ""}`,
|
|
30
|
+
length: target.length === undefined ? undefined : Math.max(0, target.length - boundArgs.length),
|
|
27
31
|
boundTarget: target,
|
|
28
32
|
retainedValues: () => [target, thisValue, ...boundArgs],
|
|
29
33
|
call: (callArgs, context) => options.callClosure(target, [...boundArgs, ...callArgs], context?.stack ?? [], thisValue),
|
|
@@ -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
|
}
|
|
@@ -56,6 +56,7 @@ export type SandboxClosure = {
|
|
|
56
56
|
readonly boundTarget?: SandboxClosure;
|
|
57
57
|
readonly cancellationSignal?: AbortSignal;
|
|
58
58
|
readonly kind: "fn";
|
|
59
|
+
readonly length?: number;
|
|
59
60
|
readonly name?: string;
|
|
60
61
|
readonly properties?: SandboxObject;
|
|
61
62
|
readonly call: (args: readonly SandboxValue[], context?: SandboxCallContext) => SandboxValue | Promise<SandboxValue>;
|
|
@@ -91,6 +92,7 @@ export declare function createSandboxClosure(input: {
|
|
|
91
92
|
call: (args: readonly SandboxValue[], context?: SandboxCallContext) => SandboxValue | Promise<SandboxValue>;
|
|
92
93
|
construct?: (args: readonly SandboxValue[], context?: SandboxCallContext) => SandboxValue | Promise<SandboxValue>;
|
|
93
94
|
name?: string;
|
|
95
|
+
length?: number;
|
|
94
96
|
properties?: SandboxObject | ((closure: SandboxClosure) => SandboxObject);
|
|
95
97
|
retainedValues?: () => Iterable<SandboxValue>;
|
|
96
98
|
}): SandboxClosure;
|
|
@@ -35,6 +35,9 @@ export function createSandboxClosure(input) {
|
|
|
35
35
|
if (input.sandbox === true) {
|
|
36
36
|
Object.defineProperty(closure, "sandbox", { value: true });
|
|
37
37
|
}
|
|
38
|
+
if (input.length !== undefined) {
|
|
39
|
+
Object.defineProperty(closure, "length", { value: input.length });
|
|
40
|
+
}
|
|
38
41
|
if (input.boundTarget !== undefined) {
|
|
39
42
|
Object.defineProperty(closure, "boundTarget", { value: input.boundTarget });
|
|
40
43
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ArrayPattern, AssignmentPattern, Identifier, MemberExpression, ObjectPattern, ParseResult, RestElement, VariableDeclaration } from "./parser.js";
|
|
1
|
+
import type { ArrowFunctionExpression, ArrayPattern, AssignmentPattern, Identifier, MemberExpression, ObjectPattern, ParseResult, RestElement, VariableDeclaration } from "./parser.js";
|
|
2
2
|
type BindingPattern = Identifier | ArrayPattern | ObjectPattern | AssignmentPattern | RestElement | MemberExpression;
|
|
3
|
+
export declare function getFunctionLength(params: ArrowFunctionExpression["params"]): number;
|
|
3
4
|
export declare function boundIdentifiers(pattern: BindingPattern): Iterable<Identifier>;
|
|
4
5
|
export declare function containsParameterExpression(pattern: BindingPattern): boolean;
|
|
5
6
|
export declare function hoistedVarDeclarations(nodes: readonly ParseResult[]): Iterable<VariableDeclaration>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export function getFunctionLength(params) {
|
|
2
|
+
const firstOptional = params.findIndex((param) => param.type === "AssignmentPattern" || param.type === "RestElement");
|
|
3
|
+
return firstOptional === -1 ? params.length : firstOptional;
|
|
4
|
+
}
|
|
1
5
|
export function* boundIdentifiers(pattern) {
|
|
2
6
|
switch (pattern.type) {
|
|
3
7
|
case "Identifier":
|
|
@@ -6,6 +6,7 @@ import { wrapCallerInjectedBindings } from "../interp/host-bridge.js";
|
|
|
6
6
|
import { createSandboxArguments, createSandboxClosure, createSandboxGenerator, createSandboxMap, createSandboxPromise, createSandboxRegex, createSandboxSet, measureSandboxData } from "../interp/values.js";
|
|
7
7
|
import { createGeneratorChannel, restoreGeneratorChannel } from "../interp/generator.js";
|
|
8
8
|
import { hashSource } from "../parse/hash.js";
|
|
9
|
+
import { getFunctionLength } from "../parse/bindings.js";
|
|
9
10
|
import { parseModule } from "../parse/parser.js";
|
|
10
11
|
import { createUnknownModuleMessage } from "../modules/registry.js";
|
|
11
12
|
import { interpret } from "../interp/interpreter.js";
|
|
@@ -386,6 +387,7 @@ function restoreClosureValue(astNodeId, capturedScopeId, state) {
|
|
|
386
387
|
}
|
|
387
388
|
const baseClosure = createSandboxClosure({
|
|
388
389
|
async: true,
|
|
390
|
+
length: getFunctionLength(node.params),
|
|
389
391
|
...(node.type !== "ArrowFunctionExpression" &&
|
|
390
392
|
!(node.type === "FunctionExpression" && node.method === true) &&
|
|
391
393
|
!node.async
|