poe-code 14.0.38 → 14.0.40
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 +196 -157
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-CSC4EXIV.js → chunk-GO774BRE.js} +183 -145
- package/packages/safe-js/dist/chunks/chunk-GO774BRE.js.map +7 -0
- package/packages/safe-js/dist/chunks/{chunk-QXSG4XRW.js → chunk-LGJLTEI5.js} +2 -2
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/interpreter.js +50 -8
- package/packages/safe-js/dist/parse/parser.js +13 -17
- package/packages/safe-js/dist/chunks/chunk-CSC4EXIV.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-QXSG4XRW.js.map → chunk-LGJLTEI5.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-GO774BRE.js";
|
|
31
31
|
import {
|
|
32
32
|
createFileSystem,
|
|
33
33
|
createNodeFileSystemAdapterRegistry,
|
|
@@ -8245,4 +8245,4 @@ export {
|
|
|
8245
8245
|
parseMcpConfig,
|
|
8246
8246
|
makeMcpModule
|
|
8247
8247
|
};
|
|
8248
|
-
//# sourceMappingURL=chunk-
|
|
8248
|
+
//# sourceMappingURL=chunk-LGJLTEI5.js.map
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveFsConfig,
|
|
23
23
|
splitFrontmatter,
|
|
24
24
|
withBrokenPipeGuard
|
|
25
|
-
} from "./chunks/chunk-
|
|
25
|
+
} from "./chunks/chunk-LGJLTEI5.js";
|
|
26
26
|
import {
|
|
27
27
|
Budget,
|
|
28
28
|
SandboxError,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
replaceErrorStack,
|
|
35
35
|
restore,
|
|
36
36
|
run
|
|
37
|
-
} from "./chunks/chunk-
|
|
37
|
+
} from "./chunks/chunk-GO774BRE.js";
|
|
38
38
|
import "./chunks/chunk-UXMKEUH3.js";
|
|
39
39
|
import "./chunks/chunk-5DYEOCT5.js";
|
|
40
40
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
runWithSpawnUsageAccumulator,
|
|
27
27
|
splitFrontmatter,
|
|
28
28
|
supportsSpawnMode
|
|
29
|
-
} from "./chunks/chunk-
|
|
29
|
+
} from "./chunks/chunk-LGJLTEI5.js";
|
|
30
30
|
import {
|
|
31
31
|
Budget,
|
|
32
32
|
FileSnapshotBackend,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
registerPendingHostCallPolicy,
|
|
51
51
|
restore,
|
|
52
52
|
run
|
|
53
|
-
} from "./chunks/chunk-
|
|
53
|
+
} from "./chunks/chunk-GO774BRE.js";
|
|
54
54
|
import "./chunks/chunk-UXMKEUH3.js";
|
|
55
55
|
import "./chunks/chunk-5DYEOCT5.js";
|
|
56
56
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -25,6 +25,7 @@ import { bindPattern } from "./patterns.js";
|
|
|
25
25
|
import { callStringMethod, getStringMember, isStringMethodName, validateStringMethodArguments } from "./methods/string.js";
|
|
26
26
|
import { callSetMethod, getSetMember, isSetMethodName } from "./methods/set.js";
|
|
27
27
|
import { isSandboxErrorConstructorInstance } from "./globals/error.js";
|
|
28
|
+
import { hasOwnSandboxProperty } from "./globals/object.js";
|
|
28
29
|
import { isSandboxMapConstructor, isSandboxSetConstructor } from "./globals/collections.js";
|
|
29
30
|
import { getFloat32Member, isFloat32ArrayConstructor, setFloat32Member } from "./globals/float32array.js";
|
|
30
31
|
import { isFloat32Array } from "./float32.js";
|
|
@@ -437,13 +438,14 @@ async function evaluateBinaryExpression(node, context) {
|
|
|
437
438
|
if (right.kind !== "normal") {
|
|
438
439
|
return right;
|
|
439
440
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
441
|
+
let leftValue = left.value;
|
|
442
|
+
if (node.operator === "in") {
|
|
443
|
+
if (typeof right.value !== "object" || right.value === null) {
|
|
444
|
+
throw new TypeError("Right-hand side of 'in' must be an object.");
|
|
445
|
+
}
|
|
446
|
+
leftValue = await toPropertyKey(leftValue, context);
|
|
447
|
+
}
|
|
448
|
+
const value = applyBinaryOperator(node, leftValue, right.value, context);
|
|
447
449
|
return {
|
|
448
450
|
kind: "normal",
|
|
449
451
|
hasValue: true,
|
|
@@ -2118,9 +2120,49 @@ function applyBinaryOperator(node, left, right, context) {
|
|
|
2118
2120
|
}
|
|
2119
2121
|
return false;
|
|
2120
2122
|
case "in":
|
|
2121
|
-
|
|
2123
|
+
return hasSandboxProperty(right, left, context);
|
|
2122
2124
|
}
|
|
2123
2125
|
}
|
|
2126
|
+
async function toPropertyKey(value, context) {
|
|
2127
|
+
if (isPlainSandboxObject(value) && !isSandboxDate(value) && !isFloat32Array(value) &&
|
|
2128
|
+
!isSandboxGenerator(value) && !isGuestHostObject(value)) {
|
|
2129
|
+
for (const name of ["toString", "valueOf"]) {
|
|
2130
|
+
const method = getMemberValue(value, name, context);
|
|
2131
|
+
if (!isSandboxClosure(method))
|
|
2132
|
+
continue;
|
|
2133
|
+
const primitive = await invokeSandboxClosure(method, [], context, context.callStack, undefined, value);
|
|
2134
|
+
if (primitive === null || typeof primitive !== "object") {
|
|
2135
|
+
return context.budget.allocateString(String(primitive));
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
throw new TypeError("Cannot convert object to primitive value.");
|
|
2139
|
+
}
|
|
2140
|
+
return sandboxString(value, context.budget, {
|
|
2141
|
+
stack: context.callStack,
|
|
2142
|
+
thisValue: undefined,
|
|
2143
|
+
invokeClosure: (closure, args, thisValue) => invokeSandboxClosure(closure, args, context, context.callStack, undefined, thisValue)
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
function hasSandboxProperty(value, key, context) {
|
|
2147
|
+
let current = value;
|
|
2148
|
+
let depth = 0;
|
|
2149
|
+
while (typeof current === "object" && current !== null) {
|
|
2150
|
+
if (isGuestHostObject(current))
|
|
2151
|
+
return hasHostObjectMember(current, key);
|
|
2152
|
+
if (hasOwnSandboxProperty(current, key, false))
|
|
2153
|
+
return true;
|
|
2154
|
+
if (Array.isArray(current) || !isPlainSandboxObject(current) ||
|
|
2155
|
+
isSandboxDate(current) || isFloat32Array(current) || isSandboxGenerator(current)) {
|
|
2156
|
+
return getPropertyValue(current, key, context) !== undefined;
|
|
2157
|
+
}
|
|
2158
|
+
current = getSandboxPrototype(current, context.budget);
|
|
2159
|
+
if (current !== null) {
|
|
2160
|
+
context.budget.visitNode();
|
|
2161
|
+
assertSandboxDataDepth(++depth);
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
return false;
|
|
2165
|
+
}
|
|
2124
2166
|
async function applyCompoundAssignmentOperator(operator, left, right, context) {
|
|
2125
2167
|
left = await toNumericPrimitive(left, context);
|
|
2126
2168
|
right = await toNumericPrimitive(right, context);
|
|
@@ -1131,9 +1131,9 @@ class Parser {
|
|
|
1131
1131
|
};
|
|
1132
1132
|
}
|
|
1133
1133
|
const token = this.currentToken();
|
|
1134
|
-
if (token.type === "identifier") {
|
|
1134
|
+
if (token.type === "identifier" || token.type === "keyword") {
|
|
1135
1135
|
this.index += 1;
|
|
1136
|
-
const key =
|
|
1136
|
+
const key = createIdentifierName(token);
|
|
1137
1137
|
if (this.consumePunctuator(":") !== undefined) {
|
|
1138
1138
|
const value = this.parseBindingElement();
|
|
1139
1139
|
if (value.type === "RestElement") {
|
|
@@ -1148,6 +1148,8 @@ class Parser {
|
|
|
1148
1148
|
span: createSpan(key.span.start, value.span.end)
|
|
1149
1149
|
};
|
|
1150
1150
|
}
|
|
1151
|
+
if (!isIdentifierLikeToken(token))
|
|
1152
|
+
throw unexpectedTokenError(token);
|
|
1151
1153
|
let value = key;
|
|
1152
1154
|
if (this.consumePunctuator("=") !== undefined) {
|
|
1153
1155
|
const right = this.parseExpression().node;
|
|
@@ -1357,9 +1359,9 @@ class Parser {
|
|
|
1357
1359
|
};
|
|
1358
1360
|
}
|
|
1359
1361
|
const token = this.currentToken();
|
|
1360
|
-
if (token.type === "identifier") {
|
|
1362
|
+
if (token.type === "identifier" || token.type === "keyword") {
|
|
1361
1363
|
this.index += 1;
|
|
1362
|
-
const key =
|
|
1364
|
+
const key = createIdentifierName(token);
|
|
1363
1365
|
if (this.consumePunctuator(":") !== undefined) {
|
|
1364
1366
|
const value = this.parseAssignmentPatternElement();
|
|
1365
1367
|
if (value.type === "RestElement") {
|
|
@@ -1374,6 +1376,8 @@ class Parser {
|
|
|
1374
1376
|
span: createSpan(key.span.start, value.span.end)
|
|
1375
1377
|
};
|
|
1376
1378
|
}
|
|
1379
|
+
if (!isIdentifierLikeToken(token))
|
|
1380
|
+
throw unexpectedTokenError(token);
|
|
1377
1381
|
let value = key;
|
|
1378
1382
|
if (this.consumePunctuator("=") !== undefined) {
|
|
1379
1383
|
const right = this.parseAssignmentExpression().node;
|
|
@@ -2027,12 +2031,9 @@ class Parser {
|
|
|
2027
2031
|
};
|
|
2028
2032
|
}
|
|
2029
2033
|
const token = this.currentToken();
|
|
2030
|
-
if (
|
|
2031
|
-
(token.type === "keyword" &&
|
|
2032
|
-
this.peekToken(1).type === "punctuator" &&
|
|
2033
|
-
this.peekToken(1).value === "(")) {
|
|
2034
|
+
if (token.type === "identifier" || token.type === "keyword") {
|
|
2034
2035
|
this.index += 1;
|
|
2035
|
-
const key =
|
|
2036
|
+
const key = createIdentifierName(token);
|
|
2036
2037
|
if (this.currentToken().type === "punctuator" && this.currentToken().value === "(") {
|
|
2037
2038
|
const value = this.parseObjectMethod(asyncToken, key.span.start);
|
|
2038
2039
|
return {
|
|
@@ -2045,6 +2046,8 @@ class Parser {
|
|
|
2045
2046
|
};
|
|
2046
2047
|
}
|
|
2047
2048
|
if (this.consumePunctuator(":") === undefined) {
|
|
2049
|
+
if (!isIdentifierLikeToken(token))
|
|
2050
|
+
throw unexpectedTokenError(token);
|
|
2048
2051
|
assertAllowedIdentifierReference(token);
|
|
2049
2052
|
return {
|
|
2050
2053
|
type: "Property",
|
|
@@ -3484,14 +3487,7 @@ function rebasePosition(position, base) {
|
|
|
3484
3487
|
};
|
|
3485
3488
|
}
|
|
3486
3489
|
function isLiteralPropertyKey(token) {
|
|
3487
|
-
|
|
3488
|
-
return true;
|
|
3489
|
-
}
|
|
3490
|
-
return (token.type === "keyword" &&
|
|
3491
|
-
(token.value === "true" ||
|
|
3492
|
-
token.value === "false" ||
|
|
3493
|
-
token.value === "null" ||
|
|
3494
|
-
token.value === "undefined"));
|
|
3490
|
+
return token.type === "numeric" || token.type === "string";
|
|
3495
3491
|
}
|
|
3496
3492
|
function isIdentifierLikeToken(token) {
|
|
3497
3493
|
return token.type === "identifier" || (token.type === "keyword" && token.value === "async");
|