poe-code 11.0.4 → 11.0.5
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 +86 -24
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-NBVIHENC.js → chunk-EWC7GLGM.js} +2 -2
- package/packages/safejs/dist/chunks/{chunk-CA342J7E.js → chunk-WC2N7PM5.js} +86 -24
- package/packages/safejs/dist/chunks/{chunk-CA342J7E.js.map → chunk-WC2N7PM5.js.map} +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/interpreter.js +64 -21
- package/packages/safejs/dist/interp/iteration.d.ts +1 -0
- package/packages/safejs/dist/interp/iteration.js +29 -2
- /package/packages/safejs/dist/chunks/{chunk-NBVIHENC.js.map → chunk-EWC7GLGM.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -138743,12 +138743,10 @@ function getSandboxIterator(value) {
|
|
|
138743
138743
|
return syncIterator(value[Symbol.iterator]());
|
|
138744
138744
|
}
|
|
138745
138745
|
if (isSandboxMap(value)) {
|
|
138746
|
-
return
|
|
138747
|
-
Array.from(value.entries, ([key3, entry]) => [key3, entry])[Symbol.iterator]()
|
|
138748
|
-
);
|
|
138746
|
+
return collectionIterator(value.entries);
|
|
138749
138747
|
}
|
|
138750
138748
|
if (isSandboxSet(value)) {
|
|
138751
|
-
return
|
|
138749
|
+
return collectionIterator(value.values);
|
|
138752
138750
|
}
|
|
138753
138751
|
if (typeof value !== "object" && typeof value !== "function" || value === null) {
|
|
138754
138752
|
return void 0;
|
|
@@ -138759,6 +138757,29 @@ function getSandboxIterator(value) {
|
|
|
138759
138757
|
}
|
|
138760
138758
|
return syncIterator(Reflect.apply(iteratorMethod, value, []));
|
|
138761
138759
|
}
|
|
138760
|
+
function collectionIterator(collection) {
|
|
138761
|
+
let iterator = collection[Symbol.iterator]();
|
|
138762
|
+
let exhausted = false;
|
|
138763
|
+
return {
|
|
138764
|
+
...syncIterator({
|
|
138765
|
+
next: () => {
|
|
138766
|
+
if (exhausted) return { done: true, value: void 0 };
|
|
138767
|
+
const result = iterator.next();
|
|
138768
|
+
exhausted = result.done === true;
|
|
138769
|
+
return result;
|
|
138770
|
+
}
|
|
138771
|
+
}),
|
|
138772
|
+
snapshotIndex: () => {
|
|
138773
|
+
if (exhausted) return collection.size;
|
|
138774
|
+
let remaining = 0;
|
|
138775
|
+
while (!iterator.next().done) remaining += 1;
|
|
138776
|
+
const index = collection.size - remaining;
|
|
138777
|
+
iterator = collection[Symbol.iterator]();
|
|
138778
|
+
for (let skipped = 0; skipped < index; skipped += 1) iterator.next();
|
|
138779
|
+
return index;
|
|
138780
|
+
}
|
|
138781
|
+
};
|
|
138782
|
+
}
|
|
138762
138783
|
function generatorIterator(generator) {
|
|
138763
138784
|
const invoke2 = async (method, value) => {
|
|
138764
138785
|
const leaveRunning = enterRunningState(generator);
|
|
@@ -145372,19 +145393,35 @@ async function evaluateVariableDeclaration(node, context) {
|
|
|
145372
145393
|
value: void 0
|
|
145373
145394
|
};
|
|
145374
145395
|
}
|
|
145375
|
-
function isRestorableBindingValue(value) {
|
|
145376
|
-
if (Array.isArray(value)) {
|
|
145377
|
-
return value.every(isRestorableBindingValue);
|
|
145378
|
-
}
|
|
145396
|
+
function isRestorableBindingValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
145379
145397
|
if (typeof value !== "object" || value === null) {
|
|
145380
145398
|
return true;
|
|
145381
145399
|
}
|
|
145400
|
+
if (seen.has(value)) return true;
|
|
145401
|
+
seen.add(value);
|
|
145402
|
+
if (isSandboxMap(value)) {
|
|
145403
|
+
for (const [key3, entry] of value.entries) {
|
|
145404
|
+
if (!isRestorableBindingValue(key3, seen) || !isRestorableBindingValue(entry, seen)) {
|
|
145405
|
+
return false;
|
|
145406
|
+
}
|
|
145407
|
+
}
|
|
145408
|
+
return true;
|
|
145409
|
+
}
|
|
145410
|
+
if (isSandboxSet(value)) {
|
|
145411
|
+
for (const entry of value.values) {
|
|
145412
|
+
if (!isRestorableBindingValue(entry, seen)) return false;
|
|
145413
|
+
}
|
|
145414
|
+
return true;
|
|
145415
|
+
}
|
|
145416
|
+
if (Array.isArray(value)) {
|
|
145417
|
+
return value.every((entry) => isRestorableBindingValue(entry, seen));
|
|
145418
|
+
}
|
|
145382
145419
|
if (Object.hasOwn(value, "kind")) {
|
|
145383
145420
|
return !["fn", "generator", "map", "promise", "regex", "set"].includes(
|
|
145384
145421
|
String(value.kind)
|
|
145385
145422
|
);
|
|
145386
145423
|
}
|
|
145387
|
-
return Object.values(value).every(isRestorableBindingValue);
|
|
145424
|
+
return Object.values(value).every((entry) => isRestorableBindingValue(entry, seen));
|
|
145388
145425
|
}
|
|
145389
145426
|
function predeclareDeclarationBindings(node, scope) {
|
|
145390
145427
|
for (const name of getDeclarationBindingNames2(node)) {
|
|
@@ -145598,13 +145635,24 @@ async function evaluateIfStatement(node, context) {
|
|
|
145598
145635
|
return evaluateNode2(branch, context);
|
|
145599
145636
|
}
|
|
145600
145637
|
async function evaluateForOfStatement(node, context) {
|
|
145638
|
+
const restoredIteration = context.restoredLoopIterations.get(node.nodeId ?? -1);
|
|
145639
|
+
let restoredEntry;
|
|
145640
|
+
if (typeof restoredIteration === "object" && typeof restoredIteration.values[0] === "string") {
|
|
145641
|
+
const restored = context.scope.consumeRestoredBinding(restoredIteration.values[0]);
|
|
145642
|
+
if (restored.found && Array.isArray(restored.value)) {
|
|
145643
|
+
restoredEntry = { done: false, value: restored.value[1] };
|
|
145644
|
+
if (isSandboxMap(restored.value[0]) || isSandboxSet(restored.value[0])) {
|
|
145645
|
+
return evaluateForOfIterator(node, restored.value[0], context, restoredEntry);
|
|
145646
|
+
}
|
|
145647
|
+
}
|
|
145648
|
+
}
|
|
145601
145649
|
const iterable = await evaluateNode2(node.right, context);
|
|
145602
145650
|
if (iterable.kind !== "normal") {
|
|
145603
145651
|
return iterable;
|
|
145604
145652
|
}
|
|
145605
145653
|
const values = snapshotableIterationValues(iterable.value);
|
|
145606
145654
|
if (values === void 0) {
|
|
145607
|
-
return evaluateForOfIterator(node, iterable.value, context);
|
|
145655
|
+
return evaluateForOfIterator(node, iterable.value, context, restoredEntry);
|
|
145608
145656
|
}
|
|
145609
145657
|
const restoredIndex = consumeRestoredLoopIterationIndex(node, context);
|
|
145610
145658
|
for (let index = restoredIndex; index < values.length; index += 1) {
|
|
@@ -145640,7 +145688,7 @@ async function evaluateForOfStatement(node, context) {
|
|
|
145640
145688
|
value: void 0
|
|
145641
145689
|
};
|
|
145642
145690
|
}
|
|
145643
|
-
async function evaluateForOfIterator(node, value, context) {
|
|
145691
|
+
async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
145644
145692
|
const iterator = getSandboxIterator(value);
|
|
145645
145693
|
if (iterator === void 0) {
|
|
145646
145694
|
throw new TypeError(`${String(value)} is not a supported iterable`);
|
|
@@ -145657,7 +145705,8 @@ async function evaluateForOfIterator(node, value, context) {
|
|
|
145657
145705
|
}
|
|
145658
145706
|
}
|
|
145659
145707
|
while (true) {
|
|
145660
|
-
const iteration = await iterator.next();
|
|
145708
|
+
const iteration = restoredEntry ?? await iterator.next();
|
|
145709
|
+
restoredEntry = void 0;
|
|
145661
145710
|
if (typeof iteration !== "object" || iteration === null) {
|
|
145662
145711
|
throw new TypeError("Iterator result must be an object.");
|
|
145663
145712
|
}
|
|
@@ -145665,7 +145714,15 @@ async function evaluateForOfIterator(node, value, context) {
|
|
|
145665
145714
|
context.activeLoopIterations.delete(nodeId);
|
|
145666
145715
|
return normalEmptyResult();
|
|
145667
145716
|
}
|
|
145668
|
-
context.activeLoopIterations.set(
|
|
145717
|
+
context.activeLoopIterations.set(
|
|
145718
|
+
nodeId,
|
|
145719
|
+
iterator.snapshotIndex === void 0 ? index : {
|
|
145720
|
+
get index() {
|
|
145721
|
+
return iterator.snapshotIndex();
|
|
145722
|
+
},
|
|
145723
|
+
values: [value, iteration.value]
|
|
145724
|
+
}
|
|
145725
|
+
);
|
|
145669
145726
|
const scope = context.scope.child();
|
|
145670
145727
|
const binding = await bindForOfLoopVariable(node.left, iteration.value, scope, context);
|
|
145671
145728
|
if (!binding.ok) {
|
|
@@ -145904,10 +145961,21 @@ function createLoopIterationContext(context, scope) {
|
|
|
145904
145961
|
return {
|
|
145905
145962
|
...context,
|
|
145906
145963
|
scope,
|
|
145907
|
-
snapshot: (currentScope) =>
|
|
145908
|
-
|
|
145909
|
-
|
|
145910
|
-
|
|
145964
|
+
snapshot: (currentScope) => {
|
|
145965
|
+
const snapshot2 = currentScope.snapshot();
|
|
145966
|
+
if (context.activeLoopIterations.size === 0) return snapshot2;
|
|
145967
|
+
snapshot2.loopIterations = {};
|
|
145968
|
+
for (const [nodeId, iteration] of context.activeLoopIterations) {
|
|
145969
|
+
if (typeof iteration !== "number" && (isSandboxMap(iteration.values[0]) || isSandboxSet(iteration.values[0]))) {
|
|
145970
|
+
const bindingName = `#for-of:${nodeId}`;
|
|
145971
|
+
snapshot2.bindings[bindingName] = iteration.values;
|
|
145972
|
+
snapshot2.loopIterations[nodeId] = { index: iteration.index, values: [bindingName] };
|
|
145973
|
+
} else {
|
|
145974
|
+
snapshot2.loopIterations[nodeId] = iteration;
|
|
145975
|
+
}
|
|
145976
|
+
}
|
|
145977
|
+
return snapshot2;
|
|
145978
|
+
}
|
|
145911
145979
|
};
|
|
145912
145980
|
}
|
|
145913
145981
|
function consumeRestoredLoopIteration(node, context) {
|
|
@@ -145927,12 +145995,6 @@ function snapshotableIterationValues(value) {
|
|
|
145927
145995
|
if (Array.isArray(value)) {
|
|
145928
145996
|
return value;
|
|
145929
145997
|
}
|
|
145930
|
-
if (isSandboxMap(value)) {
|
|
145931
|
-
return Array.from(value.entries, ([key3, entry]) => [key3, entry]);
|
|
145932
|
-
}
|
|
145933
|
-
if (isSandboxSet(value)) {
|
|
145934
|
-
return Array.from(value.values);
|
|
145935
|
-
}
|
|
145936
145998
|
return void 0;
|
|
145937
145999
|
}
|
|
145938
146000
|
function isMatchingBreak(result, labels) {
|
|
@@ -155492,7 +155554,7 @@ var init_package2 = __esm({
|
|
|
155492
155554
|
"package.json"() {
|
|
155493
155555
|
package_default2 = {
|
|
155494
155556
|
name: "poe-code",
|
|
155495
|
-
version: "11.0.
|
|
155557
|
+
version: "11.0.5",
|
|
155496
155558
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
155497
155559
|
license: "MIT",
|
|
155498
155560
|
type: "module",
|