poe-code 11.0.17 → 11.0.19
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 +90 -24
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-COHIMIAF.js → chunk-2USRJY3R.js} +2 -2
- package/packages/safejs/dist/chunks/{chunk-D4DDI3HH.js → chunk-TIKUUEG2.js} +83 -24
- package/packages/safejs/dist/chunks/{chunk-D4DDI3HH.js.map → chunk-TIKUUEG2.js.map} +3 -3
- 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/exceptions.d.ts +3 -2
- package/packages/safejs/dist/interp/exceptions.js +6 -2
- package/packages/safejs/dist/interp/interpreter.js +14 -14
- 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-COHIMIAF.js.map → chunk-2USRJY3R.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -136317,7 +136317,6 @@ function graphEntries(value) {
|
|
|
136317
136317
|
if (isSandboxArguments(value)) {
|
|
136318
136318
|
return getSandboxArgumentEntries(value).map(([key3, entry]) => [`.${key3}`, entry]);
|
|
136319
136319
|
}
|
|
136320
|
-
if (Array.isArray(value)) return value.map((entry, index) => [`[${index}]`, entry]);
|
|
136321
136320
|
if (value instanceof Map) {
|
|
136322
136321
|
return [...value.entries()].flatMap(([key3, entry], index) => [
|
|
136323
136322
|
[`.<map>[${index}].key`, key3],
|
|
@@ -136331,7 +136330,7 @@ function graphEntries(value) {
|
|
|
136331
136330
|
for (const key3 of Object.keys(value)) {
|
|
136332
136331
|
const descriptor = Object.getOwnPropertyDescriptor(value, key3);
|
|
136333
136332
|
if (descriptor !== void 0 && "value" in descriptor)
|
|
136334
|
-
entries.push([`.${key3}`, descriptor.value]);
|
|
136333
|
+
entries.push([Array.isArray(value) ? `[${key3}]` : `.${key3}`, descriptor.value]);
|
|
136335
136334
|
}
|
|
136336
136335
|
return entries;
|
|
136337
136336
|
}
|
|
@@ -136399,6 +136398,40 @@ var init_arguments2 = __esm({
|
|
|
136399
136398
|
}
|
|
136400
136399
|
});
|
|
136401
136400
|
|
|
136401
|
+
// packages/safejs/src/snapshot/arrays.ts
|
|
136402
|
+
function requiresArrayEntries(value) {
|
|
136403
|
+
const keys = Object.keys(value);
|
|
136404
|
+
return keys.length !== value.length || keys.some((key3, index) => key3 !== String(index));
|
|
136405
|
+
}
|
|
136406
|
+
function serializeArray(value, serializeValue) {
|
|
136407
|
+
if (!requiresArrayEntries(value)) {
|
|
136408
|
+
return {
|
|
136409
|
+
kind: "array",
|
|
136410
|
+
items: Array.from({ length: value.length }, (_, index) => {
|
|
136411
|
+
const key3 = String(index);
|
|
136412
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key3);
|
|
136413
|
+
return serializeValue(
|
|
136414
|
+
descriptor !== void 0 && "value" in descriptor ? descriptor.value : void 0,
|
|
136415
|
+
key3
|
|
136416
|
+
);
|
|
136417
|
+
})
|
|
136418
|
+
};
|
|
136419
|
+
}
|
|
136420
|
+
const entries = /* @__PURE__ */ Object.create(null);
|
|
136421
|
+
for (const key3 of Object.keys(value)) {
|
|
136422
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key3);
|
|
136423
|
+
if (descriptor !== void 0 && "value" in descriptor) {
|
|
136424
|
+
entries[key3] = serializeValue(descriptor.value, key3);
|
|
136425
|
+
}
|
|
136426
|
+
}
|
|
136427
|
+
return { kind: "array", length: value.length, entries };
|
|
136428
|
+
}
|
|
136429
|
+
var init_arrays = __esm({
|
|
136430
|
+
"packages/safejs/src/snapshot/arrays.ts"() {
|
|
136431
|
+
"use strict";
|
|
136432
|
+
}
|
|
136433
|
+
});
|
|
136434
|
+
|
|
136402
136435
|
// packages/safejs/src/snapshot/dump-format.ts
|
|
136403
136436
|
function serializeSafeJSSnapshot(snapshot2) {
|
|
136404
136437
|
const replayError = Object.getOwnPropertyDescriptor(snapshot2, "replayError");
|
|
@@ -136482,10 +136515,10 @@ function serializeHeapReference(value, path191, state) {
|
|
|
136482
136515
|
return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
136483
136516
|
});
|
|
136484
136517
|
} else if (Array.isArray(value)) {
|
|
136485
|
-
state.heap[String(id)] = {
|
|
136486
|
-
|
|
136487
|
-
|
|
136488
|
-
};
|
|
136518
|
+
state.heap[String(id)] = serializeArray(value, (entry, key3) => {
|
|
136519
|
+
const serialized = serializeDumpValue(entry, `${path191}[${key3}]`, state);
|
|
136520
|
+
return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
136521
|
+
});
|
|
136489
136522
|
} else {
|
|
136490
136523
|
const errorType = sandboxErrorTypes.get(value);
|
|
136491
136524
|
state.heap[String(id)] = {
|
|
@@ -136522,7 +136555,7 @@ function indexHeapContainers(snapshot2) {
|
|
|
136522
136555
|
const heapIds = /* @__PURE__ */ new WeakMap();
|
|
136523
136556
|
let nextId = 1;
|
|
136524
136557
|
for (const [value, stat36] of stats2.entries()) {
|
|
136525
|
-
if (stat36.count > 1 || stat36.cyclic || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
136558
|
+
if (stat36.count > 1 || stat36.cyclic || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
136526
136559
|
heapIds.set(value, nextId);
|
|
136527
136560
|
nextId += 1;
|
|
136528
136561
|
}
|
|
@@ -136555,7 +136588,7 @@ function collectContainerStats(value, stats2, ancestors) {
|
|
|
136555
136588
|
}
|
|
136556
136589
|
stat36.expanded = true;
|
|
136557
136590
|
ancestors.add(value);
|
|
136558
|
-
const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) :
|
|
136591
|
+
const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) : getEnumerableDataValues(value);
|
|
136559
136592
|
for (const entry of entries) {
|
|
136560
136593
|
collectContainerStats(entry, stats2, ancestors);
|
|
136561
136594
|
}
|
|
@@ -136600,6 +136633,7 @@ var init_dump_format = __esm({
|
|
|
136600
136633
|
init_shape();
|
|
136601
136634
|
init_arguments();
|
|
136602
136635
|
init_arguments2();
|
|
136636
|
+
init_arrays();
|
|
136603
136637
|
DUMP_FORMAT_VERSION = 1;
|
|
136604
136638
|
EXECUTION_SEMANTICS = "jobs-v6";
|
|
136605
136639
|
SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
|
|
@@ -136658,7 +136692,7 @@ function validateDumpHeap(root, state) {
|
|
|
136658
136692
|
continue;
|
|
136659
136693
|
}
|
|
136660
136694
|
if (entry.kind === "array") {
|
|
136661
|
-
|
|
136695
|
+
validateArrayHeap(entry, path191, state);
|
|
136662
136696
|
continue;
|
|
136663
136697
|
}
|
|
136664
136698
|
if (entry.kind === "object") {
|
|
@@ -136805,6 +136839,30 @@ function validateGeneratorShape(record2, path191, state) {
|
|
|
136805
136839
|
}
|
|
136806
136840
|
});
|
|
136807
136841
|
}
|
|
136842
|
+
function validateArrayHeap(record2, path191, state) {
|
|
136843
|
+
if (Object.hasOwn(record2, "items")) {
|
|
136844
|
+
requireArray(record2.items, `${path191}.items`, state);
|
|
136845
|
+
if (Object.hasOwn(record2, "length") || Object.hasOwn(record2, "entries"))
|
|
136846
|
+
fail2("invalidValue", path191, "array must use either items or length and entries");
|
|
136847
|
+
return;
|
|
136848
|
+
}
|
|
136849
|
+
const length = requireSafeInteger(record2.length, `${path191}.length`, 0);
|
|
136850
|
+
if (length > 4294967295) fail2("invalidValue", `${path191}.length`, "exceeds maximum array length");
|
|
136851
|
+
if (length > state.limits.maxEntries)
|
|
136852
|
+
fail2(
|
|
136853
|
+
"budgetExceeded",
|
|
136854
|
+
`${path191}.length`,
|
|
136855
|
+
`exceeds collection entry limit ${state.limits.maxEntries}`
|
|
136856
|
+
);
|
|
136857
|
+
const entries = requireRecord3(record2.entries, `${path191}.entries`);
|
|
136858
|
+
for (const key3 of Object.keys(entries)) {
|
|
136859
|
+
if (key3 === "length")
|
|
136860
|
+
fail2("invalidValue", `${path191}.entries.length`, "array length is stored separately");
|
|
136861
|
+
const index = Number(key3);
|
|
136862
|
+
if (String(index) === key3 && Number.isInteger(index) && index >= 0 && index < 4294967295 && index >= length)
|
|
136863
|
+
fail2("invalidValue", `${path191}.entries${formatKey(key3)}`, "array index exceeds its length");
|
|
136864
|
+
}
|
|
136865
|
+
}
|
|
136808
136866
|
function validateErrorType(record2, path191) {
|
|
136809
136867
|
if (!Object.hasOwn(record2, "errorType")) return;
|
|
136810
136868
|
if (record2.kind !== "object" || !sandboxErrorNames.includes(record2.errorType)) {
|
|
@@ -138317,9 +138375,10 @@ async function evaluateTryStatement(node, context, evaluateNode3) {
|
|
|
138317
138375
|
}
|
|
138318
138376
|
return finalizerResult;
|
|
138319
138377
|
}
|
|
138320
|
-
function createCapturedException(reason, stackFrames) {
|
|
138378
|
+
function createCapturedException(reason, stackFrames, sandbox = false) {
|
|
138321
138379
|
return {
|
|
138322
138380
|
reason,
|
|
138381
|
+
sandbox,
|
|
138323
138382
|
stackFrames,
|
|
138324
138383
|
[capturedExceptionBrand]: true
|
|
138325
138384
|
};
|
|
@@ -138327,7 +138386,7 @@ function createCapturedException(reason, stackFrames) {
|
|
|
138327
138386
|
function isCapturedException(value) {
|
|
138328
138387
|
return typeof value === "object" && value !== null && capturedExceptionBrand in value;
|
|
138329
138388
|
}
|
|
138330
|
-
function coerceThrownValue(reason, budget, stackFrames, span) {
|
|
138389
|
+
function coerceThrownValue(reason, budget, stackFrames, span, sandbox = false) {
|
|
138331
138390
|
if (isSubsetErrorValue(reason)) {
|
|
138332
138391
|
attachErrorSpan(reason, readErrorSpan(reason) ?? span);
|
|
138333
138392
|
return reason;
|
|
@@ -138339,6 +138398,9 @@ function coerceThrownValue(reason, budget, stackFrames, span) {
|
|
|
138339
138398
|
span
|
|
138340
138399
|
});
|
|
138341
138400
|
}
|
|
138401
|
+
if (sandbox) {
|
|
138402
|
+
return reason;
|
|
138403
|
+
}
|
|
138342
138404
|
if (isErrorLikeValue(reason)) {
|
|
138343
138405
|
return createSubsetErrorValue(reason.name || "Error", reason.message, stackFrames, budget, {
|
|
138344
138406
|
chargeBudget: false,
|
|
@@ -144996,7 +145058,7 @@ async function evaluateNode2(node, context) {
|
|
|
144996
145058
|
error: error3
|
|
144997
145059
|
};
|
|
144998
145060
|
}
|
|
144999
|
-
const exception = isCapturedException(error3) ? coerceThrownValue(error3.reason, context.budget, error3.stackFrames, node.span) : coerceThrownValue(error3, context.budget, context.callStack, node.span);
|
|
145061
|
+
const exception = isCapturedException(error3) ? coerceThrownValue(error3.reason, context.budget, error3.stackFrames, node.span, error3.sandbox) : coerceThrownValue(error3, context.budget, context.callStack, node.span, true);
|
|
145000
145062
|
return {
|
|
145001
145063
|
kind: "throw",
|
|
145002
145064
|
hasValue: true,
|
|
@@ -146691,7 +146753,7 @@ async function evaluateStringMethodCall(node, target, methodName, context) {
|
|
|
146691
146753
|
if (isFatalSandboxError(error3)) {
|
|
146692
146754
|
throw error3;
|
|
146693
146755
|
}
|
|
146694
|
-
throw captureException(error3, [...context.callStack, formatStackFrame(node, methodName)]);
|
|
146756
|
+
throw captureException(error3, [...context.callStack, formatStackFrame(node, methodName)], true);
|
|
146695
146757
|
} finally {
|
|
146696
146758
|
leaveCall();
|
|
146697
146759
|
}
|
|
@@ -146718,7 +146780,7 @@ async function evaluateArrayMethodCall(node, target, methodName, context) {
|
|
|
146718
146780
|
if (isFatalSandboxError(error3)) {
|
|
146719
146781
|
throw error3;
|
|
146720
146782
|
}
|
|
146721
|
-
throw captureException(error3, [...context.callStack, formatStackFrame(node, methodName)]);
|
|
146783
|
+
throw captureException(error3, [...context.callStack, formatStackFrame(node, methodName)], true);
|
|
146722
146784
|
} finally {
|
|
146723
146785
|
leaveCall();
|
|
146724
146786
|
}
|
|
@@ -146745,7 +146807,7 @@ async function evaluateMapMethodCall(node, target, methodName, context) {
|
|
|
146745
146807
|
if (isFatalSandboxError(error3)) {
|
|
146746
146808
|
throw error3;
|
|
146747
146809
|
}
|
|
146748
|
-
throw captureException(error3, [...context.callStack, formatStackFrame(node, methodName)]);
|
|
146810
|
+
throw captureException(error3, [...context.callStack, formatStackFrame(node, methodName)], true);
|
|
146749
146811
|
} finally {
|
|
146750
146812
|
leaveCall();
|
|
146751
146813
|
}
|
|
@@ -146772,7 +146834,7 @@ async function evaluateSetMethodCall(node, target, methodName, context) {
|
|
|
146772
146834
|
if (isFatalSandboxError(error3)) {
|
|
146773
146835
|
throw error3;
|
|
146774
146836
|
}
|
|
146775
|
-
throw captureException(error3, [...context.callStack, formatStackFrame(node, methodName)]);
|
|
146837
|
+
throw captureException(error3, [...context.callStack, formatStackFrame(node, methodName)], true);
|
|
146776
146838
|
} finally {
|
|
146777
146839
|
leaveCall();
|
|
146778
146840
|
}
|
|
@@ -147150,7 +147212,7 @@ async function evaluateNumberMethodCall(node, target, methodName, context) {
|
|
|
147150
147212
|
if (isFatalSandboxError(error3)) {
|
|
147151
147213
|
throw error3;
|
|
147152
147214
|
}
|
|
147153
|
-
throw captureException(error3, [...context.callStack, formatStackFrame(node, methodName)]);
|
|
147215
|
+
throw captureException(error3, [...context.callStack, formatStackFrame(node, methodName)], true);
|
|
147154
147216
|
}
|
|
147155
147217
|
}
|
|
147156
147218
|
function createArrayMethodOptions(context) {
|
|
@@ -147192,12 +147254,15 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
|
|
|
147192
147254
|
if (isSandboxPromise(result) && result.synchronousPrefix !== void 0) {
|
|
147193
147255
|
await result.synchronousPrefix;
|
|
147194
147256
|
}
|
|
147195
|
-
return !construct && callee.async === true ? normalizeClosureResult(
|
|
147257
|
+
return !construct && callee.async === true ? normalizeClosureResult(
|
|
147258
|
+
wrapHostResult(result, stack, callee.sandbox === true),
|
|
147259
|
+
context.budget
|
|
147260
|
+
) : await wrapHostResult(result, stack, callee.sandbox === true);
|
|
147196
147261
|
} catch (error3) {
|
|
147197
147262
|
if (isFatalSandboxError(error3)) {
|
|
147198
147263
|
throw error3;
|
|
147199
147264
|
}
|
|
147200
|
-
throw captureException(error3, stack);
|
|
147265
|
+
throw captureException(error3, stack, callee.sandbox === true);
|
|
147201
147266
|
} finally {
|
|
147202
147267
|
leaveCall();
|
|
147203
147268
|
}
|
|
@@ -147322,19 +147387,19 @@ function isInterpreterError(value) {
|
|
|
147322
147387
|
function hasOwnProperty15(value, name) {
|
|
147323
147388
|
return Object.prototype.hasOwnProperty.call(value, name);
|
|
147324
147389
|
}
|
|
147325
|
-
function wrapHostResult(result, stack) {
|
|
147390
|
+
function wrapHostResult(result, stack, sandbox) {
|
|
147326
147391
|
if (!isPromiseLikeResult(result)) {
|
|
147327
147392
|
return result;
|
|
147328
147393
|
}
|
|
147329
147394
|
return Promise.resolve(result).then(
|
|
147330
147395
|
(value) => value,
|
|
147331
147396
|
(reason) => Promise.reject(
|
|
147332
|
-
isInterpreterError(reason) || reason instanceof SandboxError || isCapturedException(reason) ? reason : createCapturedException(reason, stack)
|
|
147397
|
+
isInterpreterError(reason) || reason instanceof SandboxError || isCapturedException(reason) ? reason : createCapturedException(reason, stack, sandbox)
|
|
147333
147398
|
)
|
|
147334
147399
|
);
|
|
147335
147400
|
}
|
|
147336
|
-
function captureException(error3, stack) {
|
|
147337
|
-
return isCapturedException(error3) ? error3 : createCapturedException(error3, stack);
|
|
147401
|
+
function captureException(error3, stack, sandbox) {
|
|
147402
|
+
return isCapturedException(error3) ? error3 : createCapturedException(error3, stack, sandbox);
|
|
147338
147403
|
}
|
|
147339
147404
|
function isFatalSandboxError(error3) {
|
|
147340
147405
|
return error3 instanceof SandboxError && (error3.code === "budgetExceeded" || error3.code === "reentry");
|
|
@@ -147978,6 +148043,7 @@ var init_serialize = __esm({
|
|
|
147978
148043
|
init_shape();
|
|
147979
148044
|
init_graph_depth();
|
|
147980
148045
|
init_arguments2();
|
|
148046
|
+
init_arrays();
|
|
147981
148047
|
init_values();
|
|
147982
148048
|
UnsnapshotableValueError = class extends Error {
|
|
147983
148049
|
path;
|
|
@@ -155642,7 +155708,7 @@ var init_package2 = __esm({
|
|
|
155642
155708
|
"package.json"() {
|
|
155643
155709
|
package_default2 = {
|
|
155644
155710
|
name: "poe-code",
|
|
155645
|
-
version: "11.0.
|
|
155711
|
+
version: "11.0.19",
|
|
155646
155712
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
155647
155713
|
license: "MIT",
|
|
155648
155714
|
type: "module",
|