poe-code 14.0.40 → 14.0.41
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 +42 -34
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-GO774BRE.js → chunk-5J6BX3HD.js} +43 -35
- package/packages/safe-js/dist/chunks/{chunk-GO774BRE.js.map → chunk-5J6BX3HD.js.map} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-LGJLTEI5.js → chunk-L4NMOY6O.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/async.d.ts +1 -0
- package/packages/safe-js/dist/interp/async.js +29 -26
- package/packages/safe-js/dist/interp/interpreter.d.ts +1 -0
- package/packages/safe-js/dist/interp/interpreter.js +1 -0
- package/packages/safe-js/dist/snapshot/restore.js +20 -8
- /package/packages/safe-js/dist/chunks/{chunk-LGJLTEI5.js.map → chunk-L4NMOY6O.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-5J6BX3HD.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-L4NMOY6O.js.map
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveFsConfig,
|
|
23
23
|
splitFrontmatter,
|
|
24
24
|
withBrokenPipeGuard
|
|
25
|
-
} from "./chunks/chunk-
|
|
25
|
+
} from "./chunks/chunk-L4NMOY6O.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-5J6BX3HD.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-L4NMOY6O.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-5J6BX3HD.js";
|
|
54
54
|
import "./chunks/chunk-UXMKEUH3.js";
|
|
55
55
|
import "./chunks/chunk-5DYEOCT5.js";
|
|
56
56
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -52,6 +52,7 @@ export declare function emitResumeBreakpoint(context: AsyncEvaluationContext, br
|
|
|
52
52
|
export declare function evaluateArrowFunctionExpression(node: ArrowFunctionExpression, context: AsyncEvaluationContext, evaluateNode: EvaluateAsyncNode): Promise<AsyncEvaluationResult>;
|
|
53
53
|
export declare function evaluateFunctionExpression(node: FunctionExpression, context: AsyncEvaluationContext, evaluateNode: EvaluateAsyncNode): Promise<AsyncEvaluationResult>;
|
|
54
54
|
export declare function createInterpretedClosure(node: ArrowFunctionExpression | FunctionDeclaration | FunctionExpression, context: AsyncEvaluationContext, evaluateNode: EvaluateAsyncNode): import("./values.js").SandboxClosure;
|
|
55
|
+
export declare function executeAsyncFunction(execute: (onSuspend: () => void) => Promise<SandboxValue>, budget: Budget, signal?: AbortSignal): import("./values.js").SandboxPromise;
|
|
55
56
|
export declare function evaluateAwaitExpression(node: AwaitExpression, context: AsyncEvaluationContext, evaluateNode: EvaluateAsyncNode): Promise<AsyncEvaluationResult>;
|
|
56
57
|
export declare function normalizeClosureResult(result: SandboxValue | Promise<SandboxValue> | PromiseLike<SandboxValue>, budget?: Budget): SandboxValue;
|
|
57
58
|
export {};
|
|
@@ -81,36 +81,39 @@ export function createInterpretedClosure(node, context, evaluateNode) {
|
|
|
81
81
|
};
|
|
82
82
|
if (!node.async)
|
|
83
83
|
return executeClosure(node, args, callContext?.thisValue, invocationContext, evaluateNode);
|
|
84
|
-
|
|
85
|
-
const synchronousPrefix = new Promise((resolve) => {
|
|
86
|
-
completePrefix = resolve;
|
|
87
|
-
});
|
|
88
|
-
const promise = new Promise((resolve, reject) => {
|
|
89
|
-
runAsyncPrefix(async () => {
|
|
90
|
-
try {
|
|
91
|
-
const value = await executeClosure(node, args, callContext?.thisValue, { ...invocationContext, onSuspend: completePrefix }, evaluateNode);
|
|
92
|
-
resolve(isSandboxPromise(value) || getThenable(value) !== undefined
|
|
93
|
-
? awaitSandboxValue(createSandboxPromise(resolveSandboxValue(value, { budget: context.budget }), {
|
|
94
|
-
trackReplay: false
|
|
95
|
-
}), context.signal, context.budget)
|
|
96
|
-
: allocateProducedSandboxValue(value, context.budget));
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
reject(error);
|
|
100
|
-
}
|
|
101
|
-
finally {
|
|
102
|
-
completePrefix();
|
|
103
|
-
}
|
|
104
|
-
}).catch((error) => {
|
|
105
|
-
reject(error);
|
|
106
|
-
completePrefix();
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
return createSandboxPromise(promise, { synchronousPrefix });
|
|
84
|
+
return executeAsyncFunction((onSuspend) => executeClosure(node, args, callContext?.thisValue, { ...invocationContext, onSuspend }, evaluateNode), context.budget, context.signal);
|
|
110
85
|
}
|
|
111
86
|
});
|
|
112
87
|
return closure;
|
|
113
88
|
}
|
|
89
|
+
export function executeAsyncFunction(execute, budget, signal) {
|
|
90
|
+
let completePrefix;
|
|
91
|
+
const synchronousPrefix = new Promise((resolve) => {
|
|
92
|
+
completePrefix = resolve;
|
|
93
|
+
});
|
|
94
|
+
const promise = new Promise((resolve, reject) => {
|
|
95
|
+
runAsyncPrefix(async () => {
|
|
96
|
+
try {
|
|
97
|
+
const value = await execute(completePrefix);
|
|
98
|
+
resolve(isSandboxPromise(value) || getThenable(value) !== undefined
|
|
99
|
+
? awaitSandboxValue(createSandboxPromise(resolveSandboxValue(value, { budget }), {
|
|
100
|
+
trackReplay: false
|
|
101
|
+
}), signal, budget)
|
|
102
|
+
: allocateProducedSandboxValue(value, budget));
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
reject(error);
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
completePrefix();
|
|
109
|
+
}
|
|
110
|
+
}).catch((error) => {
|
|
111
|
+
reject(error);
|
|
112
|
+
completePrefix();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
return createSandboxPromise(promise, { synchronousPrefix });
|
|
116
|
+
}
|
|
114
117
|
function createGeneratorClosure(node, context, evaluateNode) {
|
|
115
118
|
return createSandboxClosure({
|
|
116
119
|
guest: true,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Budget, SandboxError } from "../interp/budget.js";
|
|
2
|
+
import { executeAsyncFunction } from "../interp/async.js";
|
|
2
3
|
import { CompileScope } from "../interp/regex/compile-guard.js";
|
|
3
4
|
import { decodeFloat32Storage } from "./float32array.js";
|
|
4
5
|
import { restoreDateTime } from "../interp/date.js";
|
|
@@ -429,7 +430,8 @@ function restoreClosureValue(astNodeId, capturedScopeId, state) {
|
|
|
429
430
|
throw new Error(`Snapshot references unknown closure AST node ${astNodeId}.`);
|
|
430
431
|
}
|
|
431
432
|
const baseClosure = createSandboxClosure({
|
|
432
|
-
async:
|
|
433
|
+
async: node.async,
|
|
434
|
+
sandbox: true,
|
|
433
435
|
length: getFunctionLength(node.params),
|
|
434
436
|
...(node.type === "ArrowFunctionExpression" || node.id === undefined ? {} : { name: node.id.name }),
|
|
435
437
|
...(node.type !== "ArrowFunctionExpression" &&
|
|
@@ -437,18 +439,23 @@ function restoreClosureValue(astNodeId, capturedScopeId, state) {
|
|
|
437
439
|
!node.generator &&
|
|
438
440
|
!node.async
|
|
439
441
|
? {
|
|
440
|
-
construct: async (args) => {
|
|
442
|
+
construct: async (args, callContext) => {
|
|
441
443
|
const thisValue = {};
|
|
442
444
|
const prototype = getGuestFunctionProperty(restoredClosure, "prototype");
|
|
443
445
|
if (typeof prototype === "object" && prototype !== null) {
|
|
444
446
|
setSandboxPrototype(thisValue, prototype, state.budget);
|
|
445
447
|
}
|
|
446
|
-
const result = await executeRestoredClosure(node, capturedScopeId, restoredClosure, args, thisValue, state);
|
|
448
|
+
const result = await executeRestoredClosure(node, capturedScopeId, restoredClosure, args, thisValue, state, callContext);
|
|
447
449
|
return typeof result === "object" && result !== null ? result : thisValue;
|
|
448
450
|
}
|
|
449
451
|
}
|
|
450
452
|
: {}),
|
|
451
|
-
call: (args, callContext) =>
|
|
453
|
+
call: (args, callContext) => {
|
|
454
|
+
if (node.async) {
|
|
455
|
+
return executeAsyncFunction((onSuspend) => executeRestoredClosure(node, capturedScopeId, restoredClosure, args, callContext?.thisValue, state, callContext, onSuspend), state.budget);
|
|
456
|
+
}
|
|
457
|
+
return executeRestoredClosure(node, capturedScopeId, restoredClosure, args, callContext?.thisValue, state, callContext);
|
|
458
|
+
}
|
|
452
459
|
});
|
|
453
460
|
const restoredClosure = Object.defineProperties(Object.create(baseClosure), {
|
|
454
461
|
astNodeId: {
|
|
@@ -468,9 +475,10 @@ function restoreClosureValue(astNodeId, capturedScopeId, state) {
|
|
|
468
475
|
Object.defineProperty(restoredClosure, "properties", { get: () => getGuestFunctionProperties(restoredClosure) });
|
|
469
476
|
return restoredClosure;
|
|
470
477
|
}
|
|
471
|
-
async function executeRestoredClosure(node, capturedScopeId, closure, args, thisValue, state) {
|
|
472
|
-
const
|
|
473
|
-
const
|
|
478
|
+
async function executeRestoredClosure(node, capturedScopeId, closure, args, thisValue, state, callContext, onSuspend) {
|
|
479
|
+
const parent = callContext?.compilation ?? state.compilation;
|
|
480
|
+
const operation = state.budget.acquireCompileOwner(false, parent.owner);
|
|
481
|
+
const compilation = new CompileScope(operation.owner, parent);
|
|
474
482
|
state = { ...state, compilation };
|
|
475
483
|
try {
|
|
476
484
|
const capturedScope = state.scopeById.get(capturedScopeId) ?? restoreParentScope(capturedScopeId, state);
|
|
@@ -499,6 +507,7 @@ async function executeRestoredClosure(node, capturedScopeId, closure, args, this
|
|
|
499
507
|
budget: state.budget,
|
|
500
508
|
compilation,
|
|
501
509
|
scope,
|
|
510
|
+
nested: true,
|
|
502
511
|
useScopeDirectly: true
|
|
503
512
|
});
|
|
504
513
|
return result.ok
|
|
@@ -528,6 +537,7 @@ async function executeRestoredClosure(node, capturedScopeId, closure, args, this
|
|
|
528
537
|
budget: state.budget,
|
|
529
538
|
compilation,
|
|
530
539
|
scope,
|
|
540
|
+
nested: true,
|
|
531
541
|
useScopeDirectly: true
|
|
532
542
|
});
|
|
533
543
|
return result.ok
|
|
@@ -551,12 +561,14 @@ async function executeRestoredClosure(node, capturedScopeId, closure, args, this
|
|
|
551
561
|
const result = await interpret(node.body, {
|
|
552
562
|
budget: state.budget,
|
|
553
563
|
compilation,
|
|
564
|
+
nested: true,
|
|
565
|
+
onSuspend,
|
|
554
566
|
scope
|
|
555
567
|
});
|
|
556
568
|
if (!result.ok) {
|
|
557
569
|
throw new Error(result.error.message);
|
|
558
570
|
}
|
|
559
|
-
reconcileCompiledValues(state.budget, [...scope.retainedValues(), ...state.budget.retainedValues(), result.returnValue], compilation);
|
|
571
|
+
reconcileCompiledValues(state.budget, [...scope.retainedValues(), ...state.budget.retainedValues(), result.returnValue], compilation, parent, [result.returnValue]);
|
|
560
572
|
return result.returnValue;
|
|
561
573
|
}
|
|
562
574
|
finally {
|
|
File without changes
|