poe-code 11.0.4 → 11.0.6
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 +93 -26
- 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-NP42RTIU.js} +2 -2
- package/packages/safejs/dist/chunks/{chunk-CA342J7E.js → chunk-OPNWSDXC.js} +93 -26
- package/packages/safejs/dist/chunks/chunk-OPNWSDXC.js.map +7 -0
- 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/parse/parser.js +7 -1
- package/packages/safejs/dist/parse/tokenizer.js +0 -1
- package/packages/safejs/dist/chunks/chunk-CA342J7E.js.map +0 -7
- /package/packages/safejs/dist/chunks/{chunk-NBVIHENC.js.map → chunk-NP42RTIU.js.map} +0 -0
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-OPNWSDXC.js";
|
|
31
31
|
|
|
32
32
|
// packages/safejs/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8048,4 +8048,4 @@ export {
|
|
|
8048
8048
|
parseMcpConfig,
|
|
8049
8049
|
makeMcpModule
|
|
8050
8050
|
};
|
|
8051
|
-
//# sourceMappingURL=chunk-
|
|
8051
|
+
//# sourceMappingURL=chunk-NP42RTIU.js.map
|
|
@@ -245,7 +245,6 @@ var KEYWORDS = /* @__PURE__ */ new Set([
|
|
|
245
245
|
"await",
|
|
246
246
|
"yield",
|
|
247
247
|
"import",
|
|
248
|
-
"from",
|
|
249
248
|
"as",
|
|
250
249
|
"true",
|
|
251
250
|
"false",
|
|
@@ -2545,7 +2544,13 @@ var Parser = class {
|
|
|
2545
2544
|
}
|
|
2546
2545
|
];
|
|
2547
2546
|
}
|
|
2548
|
-
this.
|
|
2547
|
+
const fromToken = this.currentToken();
|
|
2548
|
+
if (fromToken.type !== "identifier" || fromToken.value !== "from" || fromToken.end.offset - fromToken.start.offset !== fromToken.value.length) {
|
|
2549
|
+
throw new Error(
|
|
2550
|
+
`Expected 'from' at line ${fromToken.start.line}, column ${fromToken.start.column}.`
|
|
2551
|
+
);
|
|
2552
|
+
}
|
|
2553
|
+
this.index += 1;
|
|
2549
2554
|
const sourceToken = this.currentToken();
|
|
2550
2555
|
if (sourceToken.type !== "string") {
|
|
2551
2556
|
throw unexpectedTokenError(sourceToken);
|
|
@@ -18514,12 +18519,10 @@ function getSandboxIterator(value) {
|
|
|
18514
18519
|
return syncIterator(value[Symbol.iterator]());
|
|
18515
18520
|
}
|
|
18516
18521
|
if (isSandboxMap(value)) {
|
|
18517
|
-
return
|
|
18518
|
-
Array.from(value.entries, ([key, entry]) => [key, entry])[Symbol.iterator]()
|
|
18519
|
-
);
|
|
18522
|
+
return collectionIterator(value.entries);
|
|
18520
18523
|
}
|
|
18521
18524
|
if (isSandboxSet(value)) {
|
|
18522
|
-
return
|
|
18525
|
+
return collectionIterator(value.values);
|
|
18523
18526
|
}
|
|
18524
18527
|
if (typeof value !== "object" && typeof value !== "function" || value === null) {
|
|
18525
18528
|
return void 0;
|
|
@@ -18530,6 +18533,29 @@ function getSandboxIterator(value) {
|
|
|
18530
18533
|
}
|
|
18531
18534
|
return syncIterator(Reflect.apply(iteratorMethod, value, []));
|
|
18532
18535
|
}
|
|
18536
|
+
function collectionIterator(collection) {
|
|
18537
|
+
let iterator = collection[Symbol.iterator]();
|
|
18538
|
+
let exhausted = false;
|
|
18539
|
+
return {
|
|
18540
|
+
...syncIterator({
|
|
18541
|
+
next: () => {
|
|
18542
|
+
if (exhausted) return { done: true, value: void 0 };
|
|
18543
|
+
const result = iterator.next();
|
|
18544
|
+
exhausted = result.done === true;
|
|
18545
|
+
return result;
|
|
18546
|
+
}
|
|
18547
|
+
}),
|
|
18548
|
+
snapshotIndex: () => {
|
|
18549
|
+
if (exhausted) return collection.size;
|
|
18550
|
+
let remaining = 0;
|
|
18551
|
+
while (!iterator.next().done) remaining += 1;
|
|
18552
|
+
const index = collection.size - remaining;
|
|
18553
|
+
iterator = collection[Symbol.iterator]();
|
|
18554
|
+
for (let skipped = 0; skipped < index; skipped += 1) iterator.next();
|
|
18555
|
+
return index;
|
|
18556
|
+
}
|
|
18557
|
+
};
|
|
18558
|
+
}
|
|
18533
18559
|
function generatorIterator(generator) {
|
|
18534
18560
|
const invoke = async (method, value) => {
|
|
18535
18561
|
const leaveRunning = enterRunningState(generator);
|
|
@@ -26221,19 +26247,35 @@ async function evaluateVariableDeclaration(node, context) {
|
|
|
26221
26247
|
value: void 0
|
|
26222
26248
|
};
|
|
26223
26249
|
}
|
|
26224
|
-
function isRestorableBindingValue(value) {
|
|
26225
|
-
if (Array.isArray(value)) {
|
|
26226
|
-
return value.every(isRestorableBindingValue);
|
|
26227
|
-
}
|
|
26250
|
+
function isRestorableBindingValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
26228
26251
|
if (typeof value !== "object" || value === null) {
|
|
26229
26252
|
return true;
|
|
26230
26253
|
}
|
|
26254
|
+
if (seen.has(value)) return true;
|
|
26255
|
+
seen.add(value);
|
|
26256
|
+
if (isSandboxMap(value)) {
|
|
26257
|
+
for (const [key, entry] of value.entries) {
|
|
26258
|
+
if (!isRestorableBindingValue(key, seen) || !isRestorableBindingValue(entry, seen)) {
|
|
26259
|
+
return false;
|
|
26260
|
+
}
|
|
26261
|
+
}
|
|
26262
|
+
return true;
|
|
26263
|
+
}
|
|
26264
|
+
if (isSandboxSet(value)) {
|
|
26265
|
+
for (const entry of value.values) {
|
|
26266
|
+
if (!isRestorableBindingValue(entry, seen)) return false;
|
|
26267
|
+
}
|
|
26268
|
+
return true;
|
|
26269
|
+
}
|
|
26270
|
+
if (Array.isArray(value)) {
|
|
26271
|
+
return value.every((entry) => isRestorableBindingValue(entry, seen));
|
|
26272
|
+
}
|
|
26231
26273
|
if (Object.hasOwn(value, "kind")) {
|
|
26232
26274
|
return !["fn", "generator", "map", "promise", "regex", "set"].includes(
|
|
26233
26275
|
String(value.kind)
|
|
26234
26276
|
);
|
|
26235
26277
|
}
|
|
26236
|
-
return Object.values(value).every(isRestorableBindingValue);
|
|
26278
|
+
return Object.values(value).every((entry) => isRestorableBindingValue(entry, seen));
|
|
26237
26279
|
}
|
|
26238
26280
|
function predeclareDeclarationBindings(node, scope) {
|
|
26239
26281
|
for (const name of getDeclarationBindingNames2(node)) {
|
|
@@ -26447,13 +26489,24 @@ async function evaluateIfStatement(node, context) {
|
|
|
26447
26489
|
return evaluateNode(branch, context);
|
|
26448
26490
|
}
|
|
26449
26491
|
async function evaluateForOfStatement(node, context) {
|
|
26492
|
+
const restoredIteration = context.restoredLoopIterations.get(node.nodeId ?? -1);
|
|
26493
|
+
let restoredEntry;
|
|
26494
|
+
if (typeof restoredIteration === "object" && typeof restoredIteration.values[0] === "string") {
|
|
26495
|
+
const restored = context.scope.consumeRestoredBinding(restoredIteration.values[0]);
|
|
26496
|
+
if (restored.found && Array.isArray(restored.value)) {
|
|
26497
|
+
restoredEntry = { done: false, value: restored.value[1] };
|
|
26498
|
+
if (isSandboxMap(restored.value[0]) || isSandboxSet(restored.value[0])) {
|
|
26499
|
+
return evaluateForOfIterator(node, restored.value[0], context, restoredEntry);
|
|
26500
|
+
}
|
|
26501
|
+
}
|
|
26502
|
+
}
|
|
26450
26503
|
const iterable = await evaluateNode(node.right, context);
|
|
26451
26504
|
if (iterable.kind !== "normal") {
|
|
26452
26505
|
return iterable;
|
|
26453
26506
|
}
|
|
26454
26507
|
const values = snapshotableIterationValues(iterable.value);
|
|
26455
26508
|
if (values === void 0) {
|
|
26456
|
-
return evaluateForOfIterator(node, iterable.value, context);
|
|
26509
|
+
return evaluateForOfIterator(node, iterable.value, context, restoredEntry);
|
|
26457
26510
|
}
|
|
26458
26511
|
const restoredIndex = consumeRestoredLoopIterationIndex(node, context);
|
|
26459
26512
|
for (let index = restoredIndex; index < values.length; index += 1) {
|
|
@@ -26489,7 +26542,7 @@ async function evaluateForOfStatement(node, context) {
|
|
|
26489
26542
|
value: void 0
|
|
26490
26543
|
};
|
|
26491
26544
|
}
|
|
26492
|
-
async function evaluateForOfIterator(node, value, context) {
|
|
26545
|
+
async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
26493
26546
|
const iterator = getSandboxIterator(value);
|
|
26494
26547
|
if (iterator === void 0) {
|
|
26495
26548
|
throw new TypeError(`${String(value)} is not a supported iterable`);
|
|
@@ -26506,7 +26559,8 @@ async function evaluateForOfIterator(node, value, context) {
|
|
|
26506
26559
|
}
|
|
26507
26560
|
}
|
|
26508
26561
|
while (true) {
|
|
26509
|
-
const iteration = await iterator.next();
|
|
26562
|
+
const iteration = restoredEntry ?? await iterator.next();
|
|
26563
|
+
restoredEntry = void 0;
|
|
26510
26564
|
if (typeof iteration !== "object" || iteration === null) {
|
|
26511
26565
|
throw new TypeError("Iterator result must be an object.");
|
|
26512
26566
|
}
|
|
@@ -26514,7 +26568,15 @@ async function evaluateForOfIterator(node, value, context) {
|
|
|
26514
26568
|
context.activeLoopIterations.delete(nodeId);
|
|
26515
26569
|
return normalEmptyResult();
|
|
26516
26570
|
}
|
|
26517
|
-
context.activeLoopIterations.set(
|
|
26571
|
+
context.activeLoopIterations.set(
|
|
26572
|
+
nodeId,
|
|
26573
|
+
iterator.snapshotIndex === void 0 ? index : {
|
|
26574
|
+
get index() {
|
|
26575
|
+
return iterator.snapshotIndex();
|
|
26576
|
+
},
|
|
26577
|
+
values: [value, iteration.value]
|
|
26578
|
+
}
|
|
26579
|
+
);
|
|
26518
26580
|
const scope = context.scope.child();
|
|
26519
26581
|
const binding = await bindForOfLoopVariable(node.left, iteration.value, scope, context);
|
|
26520
26582
|
if (!binding.ok) {
|
|
@@ -26753,10 +26815,21 @@ function createLoopIterationContext(context, scope) {
|
|
|
26753
26815
|
return {
|
|
26754
26816
|
...context,
|
|
26755
26817
|
scope,
|
|
26756
|
-
snapshot: (currentScope) =>
|
|
26757
|
-
|
|
26758
|
-
|
|
26759
|
-
|
|
26818
|
+
snapshot: (currentScope) => {
|
|
26819
|
+
const snapshot = currentScope.snapshot();
|
|
26820
|
+
if (context.activeLoopIterations.size === 0) return snapshot;
|
|
26821
|
+
snapshot.loopIterations = {};
|
|
26822
|
+
for (const [nodeId, iteration] of context.activeLoopIterations) {
|
|
26823
|
+
if (typeof iteration !== "number" && (isSandboxMap(iteration.values[0]) || isSandboxSet(iteration.values[0]))) {
|
|
26824
|
+
const bindingName = `#for-of:${nodeId}`;
|
|
26825
|
+
snapshot.bindings[bindingName] = iteration.values;
|
|
26826
|
+
snapshot.loopIterations[nodeId] = { index: iteration.index, values: [bindingName] };
|
|
26827
|
+
} else {
|
|
26828
|
+
snapshot.loopIterations[nodeId] = iteration;
|
|
26829
|
+
}
|
|
26830
|
+
}
|
|
26831
|
+
return snapshot;
|
|
26832
|
+
}
|
|
26760
26833
|
};
|
|
26761
26834
|
}
|
|
26762
26835
|
function consumeRestoredLoopIteration(node, context) {
|
|
@@ -26776,12 +26849,6 @@ function snapshotableIterationValues(value) {
|
|
|
26776
26849
|
if (Array.isArray(value)) {
|
|
26777
26850
|
return value;
|
|
26778
26851
|
}
|
|
26779
|
-
if (isSandboxMap(value)) {
|
|
26780
|
-
return Array.from(value.entries, ([key, entry]) => [key, entry]);
|
|
26781
|
-
}
|
|
26782
|
-
if (isSandboxSet(value)) {
|
|
26783
|
-
return Array.from(value.values);
|
|
26784
|
-
}
|
|
26785
26852
|
return void 0;
|
|
26786
26853
|
}
|
|
26787
26854
|
function isMatchingBreak(result, labels) {
|
|
@@ -28914,4 +28981,4 @@ export {
|
|
|
28914
28981
|
FileSnapshotBackend,
|
|
28915
28982
|
run
|
|
28916
28983
|
};
|
|
28917
|
-
//# sourceMappingURL=chunk-
|
|
28984
|
+
//# sourceMappingURL=chunk-OPNWSDXC.js.map
|