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
package/dist/index.js
CHANGED
|
@@ -118889,6 +118889,12 @@ var init_error_codes21 = __esm({
|
|
|
118889
118889
|
});
|
|
118890
118890
|
|
|
118891
118891
|
// packages/safejs/src/parse/bindings.ts
|
|
118892
|
+
function getFunctionLength(params) {
|
|
118893
|
+
const firstOptional = params.findIndex(
|
|
118894
|
+
(param) => param.type === "AssignmentPattern" || param.type === "RestElement"
|
|
118895
|
+
);
|
|
118896
|
+
return firstOptional === -1 ? params.length : firstOptional;
|
|
118897
|
+
}
|
|
118892
118898
|
function* boundIdentifiers(pattern) {
|
|
118893
118899
|
switch (pattern.type) {
|
|
118894
118900
|
case "Identifier":
|
|
@@ -139889,6 +139895,9 @@ function createSandboxClosure(input) {
|
|
|
139889
139895
|
if (input.sandbox === true) {
|
|
139890
139896
|
Object.defineProperty(closure, "sandbox", { value: true });
|
|
139891
139897
|
}
|
|
139898
|
+
if (input.length !== void 0) {
|
|
139899
|
+
Object.defineProperty(closure, "length", { value: input.length });
|
|
139900
|
+
}
|
|
139892
139901
|
if (input.boundTarget !== void 0) {
|
|
139893
139902
|
Object.defineProperty(closure, "boundTarget", { value: input.boundTarget });
|
|
139894
139903
|
}
|
|
@@ -141148,6 +141157,7 @@ function createInterpretedClosure(node, context, evaluateNode3) {
|
|
|
141148
141157
|
} : void 0;
|
|
141149
141158
|
return createSandboxClosure({
|
|
141150
141159
|
sandbox: true,
|
|
141160
|
+
length: getFunctionLength(node.params),
|
|
141151
141161
|
...node.async ? { async: true } : {},
|
|
141152
141162
|
...node.type === "FunctionDeclaration" || node.type === "FunctionExpression" ? node.id === void 0 ? {} : { name: node.id.name } : {},
|
|
141153
141163
|
...construct === void 0 ? {} : { construct },
|
|
@@ -141199,6 +141209,7 @@ function createInterpretedClosure(node, context, evaluateNode3) {
|
|
|
141199
141209
|
function createGeneratorClosure(node, context, evaluateNode3) {
|
|
141200
141210
|
return createSandboxClosure({
|
|
141201
141211
|
sandbox: true,
|
|
141212
|
+
length: getFunctionLength(node.params),
|
|
141202
141213
|
...node.id === void 0 ? {} : { name: node.id.name },
|
|
141203
141214
|
retainedValues: () => context.scope.retainedValues(),
|
|
141204
141215
|
call: async (args, callContext) => {
|
|
@@ -143660,6 +143671,9 @@ function getFunctionMember(target, property, options) {
|
|
|
143660
143671
|
if (propertyValue !== void 0 || Object.hasOwn(target.properties ?? {}, String(property))) {
|
|
143661
143672
|
return propertyValue;
|
|
143662
143673
|
}
|
|
143674
|
+
if (property === "length") {
|
|
143675
|
+
return target.length;
|
|
143676
|
+
}
|
|
143663
143677
|
if (!isFunctionMethodName(property)) {
|
|
143664
143678
|
return void 0;
|
|
143665
143679
|
}
|
|
@@ -143679,6 +143693,7 @@ function callFunctionMethod(target, methodName, args, options, stack) {
|
|
|
143679
143693
|
return createSandboxClosure({
|
|
143680
143694
|
sandbox: true,
|
|
143681
143695
|
name: `bound ${target.name ?? ""}`,
|
|
143696
|
+
length: target.length === void 0 ? void 0 : Math.max(0, target.length - boundArgs.length),
|
|
143682
143697
|
boundTarget: target,
|
|
143683
143698
|
retainedValues: () => [target, thisValue, ...boundArgs],
|
|
143684
143699
|
call: (callArgs, context) => options.callClosure(target, [...boundArgs, ...callArgs], context?.stack ?? [], thisValue),
|
|
@@ -144325,6 +144340,7 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure) {
|
|
|
144325
144340
|
);
|
|
144326
144341
|
}
|
|
144327
144342
|
async function replaceRegex(value, regex, replacement, replaceAll2, budget, callClosure) {
|
|
144343
|
+
if (regex.flags.includes("g")) regex.lastIndex = 0;
|
|
144328
144344
|
const matches = collectRegexMatches(regex, value, replaceAll2 || regex.flags.includes("g"));
|
|
144329
144345
|
let result = "";
|
|
144330
144346
|
let copiedThrough = 0;
|
|
@@ -144413,11 +144429,16 @@ function callSplit(value, args, budget) {
|
|
|
144413
144429
|
if (args.some(isSandboxClosure))
|
|
144414
144430
|
throw new TypeError("String#split does not support function arguments.");
|
|
144415
144431
|
if (isSandboxRegex(args[0])) {
|
|
144432
|
+
const regex = args[0];
|
|
144433
|
+
const splitter = createSandboxRegex(
|
|
144434
|
+
regex.source,
|
|
144435
|
+
regex.flags.includes("g") ? regex.flags : `${regex.flags}g`
|
|
144436
|
+
);
|
|
144416
144437
|
const limit2 = asNumberOrUndefined(args[1]) ?? 2 ** 32 - 1;
|
|
144417
144438
|
const result2 = [];
|
|
144418
144439
|
let copiedThrough = 0;
|
|
144419
144440
|
let endedWithZeroWidthMatch = false;
|
|
144420
|
-
for (const match of collectRegexMatches(
|
|
144441
|
+
for (const match of collectRegexMatches(splitter, value, true)) {
|
|
144421
144442
|
endedWithZeroWidthMatch = match.text.length === 0 && match.index === value.length;
|
|
144422
144443
|
if (match.text.length === 0 && match.index === 0) continue;
|
|
144423
144444
|
if (result2.length >= limit2) break;
|
|
@@ -144455,18 +144476,18 @@ function callMatchLikeMethod(value, methodName, args) {
|
|
|
144455
144476
|
throw new TypeError("String#matchAll requires a global regex.");
|
|
144456
144477
|
if (methodName === "match" && !regex.flags.includes("g"))
|
|
144457
144478
|
return toMatchArray(executeRegex(regex, value), value);
|
|
144458
|
-
|
|
144479
|
+
if (methodName === "match") regex.lastIndex = 0;
|
|
144480
|
+
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, regex.lastIndex) : regex;
|
|
144481
|
+
const matches = collectRegexMatches(matcher, value, true);
|
|
144459
144482
|
return methodName === "match" ? matches.map((match) => match.text) : matches.map((match) => toMatchArray(match, value));
|
|
144460
144483
|
}
|
|
144461
144484
|
function collectRegexMatches(regex, value, all) {
|
|
144462
144485
|
const matches = [];
|
|
144463
|
-
const pattern = getSandboxRegexPattern(regex);
|
|
144464
|
-
let startIndex = 0;
|
|
144465
144486
|
do {
|
|
144466
|
-
const match =
|
|
144487
|
+
const match = executeRegex(regex, value);
|
|
144467
144488
|
if (match === null) break;
|
|
144468
144489
|
matches.push(match);
|
|
144469
|
-
|
|
144490
|
+
if (all && match.text.length === 0) regex.lastIndex += 1;
|
|
144470
144491
|
} while (all);
|
|
144471
144492
|
return matches;
|
|
144472
144493
|
}
|
|
@@ -144488,7 +144509,6 @@ var init_string = __esm({
|
|
|
144488
144509
|
"packages/safejs/src/interp/methods/string.ts"() {
|
|
144489
144510
|
"use strict";
|
|
144490
144511
|
init_values();
|
|
144491
|
-
init_engine2();
|
|
144492
144512
|
init_regex2();
|
|
144493
144513
|
SPLIT_STRING_MESSAGE = "String#split only supports string separator values.";
|
|
144494
144514
|
stringMethodNames = /* @__PURE__ */ new Set([
|
|
@@ -155609,7 +155629,7 @@ var init_package2 = __esm({
|
|
|
155609
155629
|
"package.json"() {
|
|
155610
155630
|
package_default2 = {
|
|
155611
155631
|
name: "poe-code",
|
|
155612
|
-
version: "11.0.
|
|
155632
|
+
version: "11.0.14",
|
|
155613
155633
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
155614
155634
|
license: "MIT",
|
|
155615
155635
|
type: "module",
|