poe-code 11.0.18 → 11.0.20
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 +70 -10
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-6BCUWJFF.js → chunk-7IOZFASL.js} +63 -10
- package/packages/safejs/dist/chunks/{chunk-6BCUWJFF.js.map → chunk-7IOZFASL.js.map} +3 -3
- package/packages/safejs/dist/chunks/{chunk-BIGMX2WV.js → chunk-JFP4YVY2.js} +2 -2
- package/packages/safejs/dist/cli.js +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/graph-depth.js +1 -3
- package/packages/safejs/dist/index.js +2 -2
- package/packages/safejs/dist/interp/methods/string.js +2 -0
- package/packages/safejs/dist/snapshot/arrays.d.ts +10 -0
- package/packages/safejs/dist/snapshot/arrays.js +24 -0
- package/packages/safejs/dist/snapshot/dump-format.js +7 -7
- package/packages/safejs/dist/snapshot/restore.js +9 -3
- package/packages/safejs/dist/snapshot/serialize.d.ts +2 -4
- package/packages/safejs/dist/snapshot/serialize.js +4 -7
- package/packages/safejs/dist/snapshot/validation.js +27 -2
- /package/packages/safejs/dist/chunks/{chunk-BIGMX2WV.js.map → chunk-JFP4YVY2.js.map} +0 -0
package/package.json
CHANGED
|
@@ -16879,7 +16879,6 @@ function graphEntries(value) {
|
|
|
16879
16879
|
if (isSandboxArguments(value)) {
|
|
16880
16880
|
return getSandboxArgumentEntries(value).map(([key, entry]) => [`.${key}`, entry]);
|
|
16881
16881
|
}
|
|
16882
|
-
if (Array.isArray(value)) return value.map((entry, index) => [`[${index}]`, entry]);
|
|
16883
16882
|
if (value instanceof Map) {
|
|
16884
16883
|
return [...value.entries()].flatMap(([key, entry], index) => [
|
|
16885
16884
|
[`.<map>[${index}].key`, key],
|
|
@@ -16893,7 +16892,7 @@ function graphEntries(value) {
|
|
|
16893
16892
|
for (const key of Object.keys(value)) {
|
|
16894
16893
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
16895
16894
|
if (descriptor !== void 0 && "value" in descriptor)
|
|
16896
|
-
entries.push([`.${key}`, descriptor.value]);
|
|
16895
|
+
entries.push([Array.isArray(value) ? `[${key}]` : `.${key}`, descriptor.value]);
|
|
16897
16896
|
}
|
|
16898
16897
|
return entries;
|
|
16899
16898
|
}
|
|
@@ -16931,6 +16930,35 @@ function serializeArguments(value, serializeValue) {
|
|
|
16931
16930
|
};
|
|
16932
16931
|
}
|
|
16933
16932
|
|
|
16933
|
+
// packages/safejs/src/snapshot/arrays.ts
|
|
16934
|
+
function requiresArrayEntries(value) {
|
|
16935
|
+
const keys = Object.keys(value);
|
|
16936
|
+
return keys.length !== value.length || keys.some((key, index) => key !== String(index));
|
|
16937
|
+
}
|
|
16938
|
+
function serializeArray(value, serializeValue) {
|
|
16939
|
+
if (!requiresArrayEntries(value)) {
|
|
16940
|
+
return {
|
|
16941
|
+
kind: "array",
|
|
16942
|
+
items: Array.from({ length: value.length }, (_, index) => {
|
|
16943
|
+
const key = String(index);
|
|
16944
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
16945
|
+
return serializeValue(
|
|
16946
|
+
descriptor !== void 0 && "value" in descriptor ? descriptor.value : void 0,
|
|
16947
|
+
key
|
|
16948
|
+
);
|
|
16949
|
+
})
|
|
16950
|
+
};
|
|
16951
|
+
}
|
|
16952
|
+
const entries = /* @__PURE__ */ Object.create(null);
|
|
16953
|
+
for (const key of Object.keys(value)) {
|
|
16954
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
16955
|
+
if (descriptor !== void 0 && "value" in descriptor) {
|
|
16956
|
+
entries[key] = serializeValue(descriptor.value, key);
|
|
16957
|
+
}
|
|
16958
|
+
}
|
|
16959
|
+
return { kind: "array", length: value.length, entries };
|
|
16960
|
+
}
|
|
16961
|
+
|
|
16934
16962
|
// packages/safejs/src/snapshot/dump-format.ts
|
|
16935
16963
|
var DUMP_FORMAT_VERSION = 1;
|
|
16936
16964
|
var EXECUTION_SEMANTICS = "jobs-v6";
|
|
@@ -17017,10 +17045,10 @@ function serializeHeapReference(value, path, state) {
|
|
|
17017
17045
|
return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
17018
17046
|
});
|
|
17019
17047
|
} else if (Array.isArray(value)) {
|
|
17020
|
-
state.heap[String(id)] = {
|
|
17021
|
-
|
|
17022
|
-
|
|
17023
|
-
};
|
|
17048
|
+
state.heap[String(id)] = serializeArray(value, (entry, key) => {
|
|
17049
|
+
const serialized = serializeDumpValue(entry, `${path}[${key}]`, state);
|
|
17050
|
+
return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
17051
|
+
});
|
|
17024
17052
|
} else {
|
|
17025
17053
|
const errorType = sandboxErrorTypes.get(value);
|
|
17026
17054
|
state.heap[String(id)] = {
|
|
@@ -17057,7 +17085,7 @@ function indexHeapContainers(snapshot) {
|
|
|
17057
17085
|
const heapIds = /* @__PURE__ */ new WeakMap();
|
|
17058
17086
|
let nextId = 1;
|
|
17059
17087
|
for (const [value, stat2] of stats.entries()) {
|
|
17060
|
-
if (stat2.count > 1 || stat2.cyclic || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
17088
|
+
if (stat2.count > 1 || stat2.cyclic || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
17061
17089
|
heapIds.set(value, nextId);
|
|
17062
17090
|
nextId += 1;
|
|
17063
17091
|
}
|
|
@@ -17090,7 +17118,7 @@ function collectContainerStats(value, stats, ancestors) {
|
|
|
17090
17118
|
}
|
|
17091
17119
|
stat2.expanded = true;
|
|
17092
17120
|
ancestors.add(value);
|
|
17093
|
-
const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) :
|
|
17121
|
+
const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) : getEnumerableDataValues(value);
|
|
17094
17122
|
for (const entry of entries) {
|
|
17095
17123
|
collectContainerStats(entry, stats, ancestors);
|
|
17096
17124
|
}
|
|
@@ -17209,7 +17237,7 @@ function validateDumpHeap(root, state) {
|
|
|
17209
17237
|
continue;
|
|
17210
17238
|
}
|
|
17211
17239
|
if (entry.kind === "array") {
|
|
17212
|
-
|
|
17240
|
+
validateArrayHeap(entry, path, state);
|
|
17213
17241
|
continue;
|
|
17214
17242
|
}
|
|
17215
17243
|
if (entry.kind === "object") {
|
|
@@ -17356,6 +17384,30 @@ function validateGeneratorShape(record2, path, state) {
|
|
|
17356
17384
|
}
|
|
17357
17385
|
});
|
|
17358
17386
|
}
|
|
17387
|
+
function validateArrayHeap(record2, path, state) {
|
|
17388
|
+
if (Object.hasOwn(record2, "items")) {
|
|
17389
|
+
requireArray(record2.items, `${path}.items`, state);
|
|
17390
|
+
if (Object.hasOwn(record2, "length") || Object.hasOwn(record2, "entries"))
|
|
17391
|
+
fail("invalidValue", path, "array must use either items or length and entries");
|
|
17392
|
+
return;
|
|
17393
|
+
}
|
|
17394
|
+
const length = requireSafeInteger(record2.length, `${path}.length`, 0);
|
|
17395
|
+
if (length > 4294967295) fail("invalidValue", `${path}.length`, "exceeds maximum array length");
|
|
17396
|
+
if (length > state.limits.maxEntries)
|
|
17397
|
+
fail(
|
|
17398
|
+
"budgetExceeded",
|
|
17399
|
+
`${path}.length`,
|
|
17400
|
+
`exceeds collection entry limit ${state.limits.maxEntries}`
|
|
17401
|
+
);
|
|
17402
|
+
const entries = requireRecord(record2.entries, `${path}.entries`);
|
|
17403
|
+
for (const key of Object.keys(entries)) {
|
|
17404
|
+
if (key === "length")
|
|
17405
|
+
fail("invalidValue", `${path}.entries.length`, "array length is stored separately");
|
|
17406
|
+
const index = Number(key);
|
|
17407
|
+
if (String(index) === key && Number.isInteger(index) && index >= 0 && index < 4294967295 && index >= length)
|
|
17408
|
+
fail("invalidValue", `${path}.entries${formatKey(key)}`, "array index exceeds its length");
|
|
17409
|
+
}
|
|
17410
|
+
}
|
|
17359
17411
|
function validateErrorType(record2, path) {
|
|
17360
17412
|
if (!Object.hasOwn(record2, "errorType")) return;
|
|
17361
17413
|
if (record2.kind !== "object" || !sandboxErrorNames.includes(record2.errorType)) {
|
|
@@ -25350,6 +25402,7 @@ function callMatchLikeMethod(value, methodName, args) {
|
|
|
25350
25402
|
if (methodName === "match") regex.lastIndex = 0;
|
|
25351
25403
|
const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, regex.lastIndex) : regex;
|
|
25352
25404
|
const matches = collectRegexMatches(matcher, value, true);
|
|
25405
|
+
if (methodName === "match" && matches.length === 0) return null;
|
|
25353
25406
|
return methodName === "match" ? matches.map((match) => match.text) : matches.map((match) => toMatchArray(match, value));
|
|
25354
25407
|
}
|
|
25355
25408
|
function collectRegexMatches(regex, value, all) {
|
|
@@ -29072,4 +29125,4 @@ export {
|
|
|
29072
29125
|
FileSnapshotBackend,
|
|
29073
29126
|
run
|
|
29074
29127
|
};
|
|
29075
|
-
//# sourceMappingURL=chunk-
|
|
29128
|
+
//# sourceMappingURL=chunk-7IOZFASL.js.map
|