solve-engine 2.38.16 → 2.38.18
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/{PackageCompatibility-zdsKvwQI.d.ts → PackageCompatibility-BRas0tSN.d.ts} +1 -1
- package/dist/{PackageCompatibility-C-3vPMKp.d.cts → PackageCompatibility-CUWuzzGW.d.cts} +1 -1
- package/dist/{PackageRegistry-CStmqgw_.d.ts → PackageRegistry-DMcI-_Qz.d.ts} +126 -4
- package/dist/{PackageRegistry-DiHxyxrn.d.cts → PackageRegistry-JqudPxo6.d.cts} +126 -4
- package/dist/{VMBuiltins-BwqFO2TY.d.cts → VMBuiltins-0C4z3yDS.d.cts} +32 -2
- package/dist/{VMBuiltins-h09nijID.d.ts → VMBuiltins-Bu6qaKi0.d.ts} +32 -2
- package/dist/{chunk-44BWHZ5V.js → chunk-2YHOWQ43.js} +2 -2
- package/dist/chunk-2YHOWQ43.js.map +1 -0
- package/dist/chunk-45J6ALYU.js +3 -0
- package/dist/{chunk-4LMPCB2V.js.map → chunk-45J6ALYU.js.map} +1 -1
- package/dist/chunk-4I7XP3KF.js +2 -0
- package/dist/chunk-4I7XP3KF.js.map +1 -0
- package/dist/chunk-5E22VW42.cjs +5 -0
- package/dist/chunk-5E22VW42.cjs.map +1 -0
- package/dist/chunk-5MFUZDYK.cjs +2 -0
- package/dist/chunk-5MFUZDYK.cjs.map +1 -0
- package/dist/{chunk-KVONXXPJ.cjs → chunk-5QZQIZTS.cjs} +3 -3
- package/dist/{chunk-KVONXXPJ.cjs.map → chunk-5QZQIZTS.cjs.map} +1 -1
- package/dist/chunk-EQMNMV2O.js +5 -0
- package/dist/chunk-EQMNMV2O.js.map +1 -0
- package/dist/chunk-JDMHZHL7.js +3 -0
- package/dist/chunk-JDMHZHL7.js.map +1 -0
- package/dist/{chunk-HFES6BF5.cjs → chunk-K2OUNZZG.cjs} +2 -2
- package/dist/chunk-K2OUNZZG.cjs.map +1 -0
- package/dist/chunk-MYGNBES2.cjs +3 -0
- package/dist/chunk-MYGNBES2.cjs.map +1 -0
- package/dist/{chunk-ZOS4RCB7.js → chunk-NMMYBXTV.js} +2 -2
- package/dist/{chunk-ZOS4RCB7.js.map → chunk-NMMYBXTV.js.map} +1 -1
- package/dist/{chunk-DTOSRC6E.cjs → chunk-TVT3SOU5.cjs} +2 -2
- package/dist/{chunk-DTOSRC6E.cjs.map → chunk-TVT3SOU5.cjs.map} +1 -1
- package/dist/{chunk-TOCCIZVE.cjs → chunk-UP7TB5KO.cjs} +2 -2
- package/dist/{chunk-TOCCIZVE.cjs.map → chunk-UP7TB5KO.cjs.map} +1 -1
- package/dist/{chunk-U54BIYXO.cjs → chunk-WR5HTFDE.cjs} +2 -2
- package/dist/{chunk-U54BIYXO.cjs.map → chunk-WR5HTFDE.cjs.map} +1 -1
- package/dist/{chunk-IUCUBHFW.js → chunk-X2UPN2J3.js} +2 -2
- package/dist/{chunk-IUCUBHFW.js.map → chunk-X2UPN2J3.js.map} +1 -1
- package/dist/chunk-XDL542DB.js +2 -0
- package/dist/{chunk-ZXNM355C.js.map → chunk-XDL542DB.js.map} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +42 -4
- package/dist/engine.d.ts +42 -4
- package/dist/engine.js +1 -1
- package/dist/engine.worker.cjs +1 -1
- package/dist/engine.worker.js +1 -1
- package/dist/engine.worker.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/language.d.cts +3 -3
- package/dist/language.d.ts +3 -3
- package/dist/packages.cjs +1 -1
- package/dist/packages.d.cts +2 -2
- package/dist/packages.d.ts +2 -2
- package/dist/packages.js +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.d.cts +3 -3
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.d.cts +1 -1
- package/dist/vm.d.ts +1 -1
- package/dist/vm.js +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.d.cts +2 -2
- package/dist/worker.d.ts +2 -2
- package/dist/worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-25JO4SYL.cjs +0 -5
- package/dist/chunk-25JO4SYL.cjs.map +0 -1
- package/dist/chunk-3TXVKQLL.js +0 -5
- package/dist/chunk-3TXVKQLL.js.map +0 -1
- package/dist/chunk-44BWHZ5V.js.map +0 -1
- package/dist/chunk-4LMPCB2V.js +0 -3
- package/dist/chunk-6ADFAXTZ.cjs +0 -2
- package/dist/chunk-6ADFAXTZ.cjs.map +0 -1
- package/dist/chunk-AFNK2LUO.js +0 -2
- package/dist/chunk-AFNK2LUO.js.map +0 -1
- package/dist/chunk-H4EJRCXT.js +0 -3
- package/dist/chunk-H4EJRCXT.js.map +0 -1
- package/dist/chunk-HFES6BF5.cjs.map +0 -1
- package/dist/chunk-OUMFZQ6N.cjs +0 -3
- package/dist/chunk-OUMFZQ6N.cjs.map +0 -1
- package/dist/chunk-ZXNM355C.js +0 -2
|
@@ -2,7 +2,7 @@ import { a as PrecedenceParser, b as PrefixParselet, I as InfixParselet } from '
|
|
|
2
2
|
import { M as MarkdownLineType, L as Lexer, e as TokenCategory, c as LexerVocabulary } from './Lexer-DPn5dfCH.js';
|
|
3
3
|
import { IAsyncResolver } from './resolvers.js';
|
|
4
4
|
import { T as TokenFusion, c as TokenNormalizer, a as NormalizerRule } from './TokenNormalizer-DAzPp-j1.js';
|
|
5
|
-
import { b as VMCheckpointer, D as DependencyGraph, V as VM, h as DagSnapshot, i as EngineContext, S as ScopeManager, P as PluginFunctionHandler, A as AsConverter } from './VMBuiltins-
|
|
5
|
+
import { b as VMCheckpointer, D as DependencyGraph, V as VM, h as DagSnapshot, i as EngineContext, S as ScopeManager, P as PluginFunctionHandler, A as AsConverter } from './VMBuiltins-Bu6qaKi0.js';
|
|
6
6
|
import { V as Value, b as ValueType, D as DatetimeGrain } from './Value-B55Hvn3e.js';
|
|
7
7
|
import { a as BytecodeProgram } from './BytecodeBuilder-DSWKZi4f.js';
|
|
8
8
|
import { C as CalendarBackend } from './CalendarBackend-MdS3Bb4P.js';
|
|
@@ -910,11 +910,37 @@ declare class AsyncResolutionBatcher {
|
|
|
910
910
|
constructor(dag: DependencyGraph, lineCache: LineCache, vm: VM, highWaterMark?: number);
|
|
911
911
|
/**
|
|
912
912
|
* Create a fresh internal event stream and wire its controller.
|
|
913
|
-
*
|
|
914
|
-
*
|
|
915
|
-
*
|
|
913
|
+
*
|
|
914
|
+
* Called from {@link eventStream} on first use and again after clearAll(),
|
|
915
|
+
* so the batcher keeps emitting events after an engine clear: the engine
|
|
916
|
+
* instance (and this batcher) live on across clear() calls.
|
|
916
917
|
*/
|
|
917
918
|
private createEventStream;
|
|
919
|
+
/**
|
|
920
|
+
* The event stream, built the first time anything needs one.
|
|
921
|
+
*
|
|
922
|
+
* It used to be built in the constructor, and a ReadableStream is not free
|
|
923
|
+
* to build: its start algorithm queues promise reactions, so every engine
|
|
924
|
+
* paid for a stream, and a host that constructs engines in a synchronous
|
|
925
|
+
* loop accumulated one engine's worth of pending microtasks per engine
|
|
926
|
+
* because nothing drained them until the loop ended. At roughly nine
|
|
927
|
+
* kilobytes each that is ninety megabytes over ten thousand engines, for a
|
|
928
|
+
* stream almost none of them ever read.
|
|
929
|
+
*
|
|
930
|
+
* Building it on first use rather than on first subscribe is what keeps the
|
|
931
|
+
* behaviour identical. The stream buffers up to `highWaterMark` events with
|
|
932
|
+
* no reader attached, so a consumer that subscribes after some events have
|
|
933
|
+
* already flowed still receives them; deferring until {@link getEventStream}
|
|
934
|
+
* would have dropped exactly those. So the emit path asks for it too, and
|
|
935
|
+
* the engine that never resolves anything asynchronously and never
|
|
936
|
+
* subscribes is the only one that never builds it, which is the case worth
|
|
937
|
+
* optimising.
|
|
938
|
+
*
|
|
939
|
+
* A cancelled stream is not rebuilt: cancellation clears the controller but
|
|
940
|
+
* leaves the stream itself in place, so the check below sees one and the
|
|
941
|
+
* events go nowhere, which is what cancelling asked for.
|
|
942
|
+
*/
|
|
943
|
+
private eventStream;
|
|
918
944
|
/**
|
|
919
945
|
* Add a resolved query key to the pending batch.
|
|
920
946
|
*
|
|
@@ -2241,6 +2267,13 @@ declare class ExpressionEngine {
|
|
|
2241
2267
|
* DAG walk + re-evaluation pass. Replaces the old single-callback pattern.
|
|
2242
2268
|
*/
|
|
2243
2269
|
private batcher;
|
|
2270
|
+
/**
|
|
2271
|
+
* Names that may no longer be defined, pending the end of the pass.
|
|
2272
|
+
*
|
|
2273
|
+
* Null rather than an empty set, because a document that never removes a
|
|
2274
|
+
* definition never allocates one. See {@link settleOrphanedNames}.
|
|
2275
|
+
*/
|
|
2276
|
+
private orphanCandidates;
|
|
2244
2277
|
/**
|
|
2245
2278
|
* Drives proactive background refresh of live values, or `null` when the
|
|
2246
2279
|
* host has not enabled it (the default). See {@link BackgroundRefreshManager}.
|
|
@@ -2386,6 +2419,27 @@ declare class ExpressionEngine {
|
|
|
2386
2419
|
* Tests use this to access `batcher._testCaptures` for synchronous
|
|
2387
2420
|
* event observation without async stream reader timing issues.
|
|
2388
2421
|
*/
|
|
2422
|
+
/** The names of every user-defined unit in scope, for detecting a removal. */
|
|
2423
|
+
userUnitNames(): string[];
|
|
2424
|
+
/**
|
|
2425
|
+
* Drop every user unit defined by `lineNumber`, for a line being removed.
|
|
2426
|
+
*
|
|
2427
|
+
* A line being recompiled clears its own definitions on the way through, so
|
|
2428
|
+
* this is for the line that will never be compiled again.
|
|
2429
|
+
*
|
|
2430
|
+
* @param lineId - The persistent id of the line being deleted.
|
|
2431
|
+
* @returns Whether the line had defined anything.
|
|
2432
|
+
*/
|
|
2433
|
+
undefineUserUnitsFrom(lineId: number): boolean;
|
|
2434
|
+
/**
|
|
2435
|
+
* Recompile everything, because a user unit is no longer in scope.
|
|
2436
|
+
*
|
|
2437
|
+
* A unit is expanded while a line is compiled, so a line that used one holds
|
|
2438
|
+
* bytecode built around it. Losing the definition has to reach that bytecode
|
|
2439
|
+
* or the conversion goes on working from a definition the document no longer
|
|
2440
|
+
* contains.
|
|
2441
|
+
*/
|
|
2442
|
+
invalidateForRemovedUserUnits(): void;
|
|
2389
2443
|
getBatcher(): AsyncResolutionBatcher;
|
|
2390
2444
|
/**
|
|
2391
2445
|
* Register a package with the engine's isolated registries.
|
|
@@ -2544,6 +2598,74 @@ declare class ExpressionEngine {
|
|
|
2544
2598
|
* @param reads - Variable keys the line reads.
|
|
2545
2599
|
* @param writes - Variable keys the line writes.
|
|
2546
2600
|
*/
|
|
2601
|
+
/**
|
|
2602
|
+
* Forget names that no line defines any more.
|
|
2603
|
+
*
|
|
2604
|
+
* The graph reports a key when the line that wrote it stops doing so and no
|
|
2605
|
+
* other line writes it. The VM's variable store only ever accumulated, so
|
|
2606
|
+
* the value outlived the line: deleting `:x = 12` left `x + 4` answering
|
|
2607
|
+
* `16` for the rest of the session.
|
|
2608
|
+
*
|
|
2609
|
+
* The checkpoint chain is told as well, since it records what each line
|
|
2610
|
+
* wrote and would otherwise put the name back on the next restore.
|
|
2611
|
+
*
|
|
2612
|
+
* Only variable names. The key space also holds category tags, globals,
|
|
2613
|
+
* data sources and line positions, and none of those is a VM binding; a
|
|
2614
|
+
* prefix is what tells them apart, and a variable's key is the bare name.
|
|
2615
|
+
*
|
|
2616
|
+
* @param orphaned - Keys the graph reports as no longer written by any line.
|
|
2617
|
+
*/
|
|
2618
|
+
/**
|
|
2619
|
+
* Forget a name the graph says no line writes any more.
|
|
2620
|
+
*
|
|
2621
|
+
* Reported by {@link DependencyGraph.registerLine} and its `removeLine` when
|
|
2622
|
+
* the line that wrote a key stops doing so and no other line writes it. The
|
|
2623
|
+
* VM's variable store only ever accumulated, so the value outlived the line:
|
|
2624
|
+
* deleting `:x = 12` left `x + 4` answering `16` for the rest of the
|
|
2625
|
+
* session.
|
|
2626
|
+
*
|
|
2627
|
+
* The graph is not the authority here, the document is, and for two
|
|
2628
|
+
* ordering reasons. A line holding several inline expressions registers once
|
|
2629
|
+
* per expression, so the one that defines a name is followed by one that
|
|
2630
|
+
* does not, and the graph would report an orphan mid-line; the document
|
|
2631
|
+
* holds the line's aggregate write set and does not. And a structural edit
|
|
2632
|
+
* clears the graph, so afterwards it would call every name undefined. A
|
|
2633
|
+
* line's recorded write set survives both, and is up to date for the line
|
|
2634
|
+
* being registered, because a pass stores the line's results before it
|
|
2635
|
+
* registers its edges.
|
|
2636
|
+
*
|
|
2637
|
+
* Answering here rather than at the end of the pass is what lets the lines
|
|
2638
|
+
* BELOW the edit see it on the same pass rather than the next one.
|
|
2639
|
+
*
|
|
2640
|
+
* The checkpoint chain is told as well, since it records what each line
|
|
2641
|
+
* wrote and would otherwise put the name back on the next restore.
|
|
2642
|
+
*
|
|
2643
|
+
* Only variable names: the key space also holds category tags, globals,
|
|
2644
|
+
* data sources and line positions, and none of those is a VM binding.
|
|
2645
|
+
*
|
|
2646
|
+
* @param orphaned - Keys that just lost their last writer in the graph.
|
|
2647
|
+
*/
|
|
2648
|
+
forgetOrphanedNames(orphaned: readonly string[]): void;
|
|
2649
|
+
/**
|
|
2650
|
+
* Decide the candidates: forget the ones no line defines any more.
|
|
2651
|
+
*
|
|
2652
|
+
* Asked once, at the end of a pass, because deciding as each line registers
|
|
2653
|
+
* cannot work. A line holding several inline expressions registers once per
|
|
2654
|
+
* expression, so the one that defines a name is followed by one that does
|
|
2655
|
+
* not; and the engine registers a line before the pass records that line's
|
|
2656
|
+
* results, so its recorded write set is a pass behind. Both would answer
|
|
2657
|
+
* wrongly mid-pass. At the end of one, every line has registered and the
|
|
2658
|
+
* document is current.
|
|
2659
|
+
*
|
|
2660
|
+
* The document is the authority, not the graph: a structural edit clears
|
|
2661
|
+
* the graph, and a viewport leaves the lines outside it unregistered, while
|
|
2662
|
+
* a line's recorded write set survives both.
|
|
2663
|
+
*
|
|
2664
|
+
* The reader of a forgotten name updates on the following pass, which an
|
|
2665
|
+
* editor makes anyway. It is not made to happen sooner because every way of
|
|
2666
|
+
* doing that answers the question before it can be answered correctly.
|
|
2667
|
+
*/
|
|
2668
|
+
settleOrphanedNames(): void;
|
|
2547
2669
|
private registerLineWithTags;
|
|
2548
2670
|
/**
|
|
2549
2671
|
* Execute bytecode and handle the result.
|
|
@@ -2,7 +2,7 @@ import { a as PrecedenceParser, b as PrefixParselet, I as InfixParselet } from '
|
|
|
2
2
|
import { M as MarkdownLineType, L as Lexer, e as TokenCategory, c as LexerVocabulary } from './Lexer-DaWkCu84.cjs';
|
|
3
3
|
import { IAsyncResolver } from './resolvers.cjs';
|
|
4
4
|
import { T as TokenFusion, c as TokenNormalizer, a as NormalizerRule } from './TokenNormalizer-D382VSYh.cjs';
|
|
5
|
-
import { b as VMCheckpointer, D as DependencyGraph, V as VM, h as DagSnapshot, i as EngineContext, S as ScopeManager, P as PluginFunctionHandler, A as AsConverter } from './VMBuiltins-
|
|
5
|
+
import { b as VMCheckpointer, D as DependencyGraph, V as VM, h as DagSnapshot, i as EngineContext, S as ScopeManager, P as PluginFunctionHandler, A as AsConverter } from './VMBuiltins-0C4z3yDS.cjs';
|
|
6
6
|
import { V as Value, b as ValueType, D as DatetimeGrain } from './Value-B55Hvn3e.cjs';
|
|
7
7
|
import { a as BytecodeProgram } from './BytecodeBuilder-DSWKZi4f.cjs';
|
|
8
8
|
import { C as CalendarBackend } from './CalendarBackend-MdS3Bb4P.cjs';
|
|
@@ -910,11 +910,37 @@ declare class AsyncResolutionBatcher {
|
|
|
910
910
|
constructor(dag: DependencyGraph, lineCache: LineCache, vm: VM, highWaterMark?: number);
|
|
911
911
|
/**
|
|
912
912
|
* Create a fresh internal event stream and wire its controller.
|
|
913
|
-
*
|
|
914
|
-
*
|
|
915
|
-
*
|
|
913
|
+
*
|
|
914
|
+
* Called from {@link eventStream} on first use and again after clearAll(),
|
|
915
|
+
* so the batcher keeps emitting events after an engine clear: the engine
|
|
916
|
+
* instance (and this batcher) live on across clear() calls.
|
|
916
917
|
*/
|
|
917
918
|
private createEventStream;
|
|
919
|
+
/**
|
|
920
|
+
* The event stream, built the first time anything needs one.
|
|
921
|
+
*
|
|
922
|
+
* It used to be built in the constructor, and a ReadableStream is not free
|
|
923
|
+
* to build: its start algorithm queues promise reactions, so every engine
|
|
924
|
+
* paid for a stream, and a host that constructs engines in a synchronous
|
|
925
|
+
* loop accumulated one engine's worth of pending microtasks per engine
|
|
926
|
+
* because nothing drained them until the loop ended. At roughly nine
|
|
927
|
+
* kilobytes each that is ninety megabytes over ten thousand engines, for a
|
|
928
|
+
* stream almost none of them ever read.
|
|
929
|
+
*
|
|
930
|
+
* Building it on first use rather than on first subscribe is what keeps the
|
|
931
|
+
* behaviour identical. The stream buffers up to `highWaterMark` events with
|
|
932
|
+
* no reader attached, so a consumer that subscribes after some events have
|
|
933
|
+
* already flowed still receives them; deferring until {@link getEventStream}
|
|
934
|
+
* would have dropped exactly those. So the emit path asks for it too, and
|
|
935
|
+
* the engine that never resolves anything asynchronously and never
|
|
936
|
+
* subscribes is the only one that never builds it, which is the case worth
|
|
937
|
+
* optimising.
|
|
938
|
+
*
|
|
939
|
+
* A cancelled stream is not rebuilt: cancellation clears the controller but
|
|
940
|
+
* leaves the stream itself in place, so the check below sees one and the
|
|
941
|
+
* events go nowhere, which is what cancelling asked for.
|
|
942
|
+
*/
|
|
943
|
+
private eventStream;
|
|
918
944
|
/**
|
|
919
945
|
* Add a resolved query key to the pending batch.
|
|
920
946
|
*
|
|
@@ -2241,6 +2267,13 @@ declare class ExpressionEngine {
|
|
|
2241
2267
|
* DAG walk + re-evaluation pass. Replaces the old single-callback pattern.
|
|
2242
2268
|
*/
|
|
2243
2269
|
private batcher;
|
|
2270
|
+
/**
|
|
2271
|
+
* Names that may no longer be defined, pending the end of the pass.
|
|
2272
|
+
*
|
|
2273
|
+
* Null rather than an empty set, because a document that never removes a
|
|
2274
|
+
* definition never allocates one. See {@link settleOrphanedNames}.
|
|
2275
|
+
*/
|
|
2276
|
+
private orphanCandidates;
|
|
2244
2277
|
/**
|
|
2245
2278
|
* Drives proactive background refresh of live values, or `null` when the
|
|
2246
2279
|
* host has not enabled it (the default). See {@link BackgroundRefreshManager}.
|
|
@@ -2386,6 +2419,27 @@ declare class ExpressionEngine {
|
|
|
2386
2419
|
* Tests use this to access `batcher._testCaptures` for synchronous
|
|
2387
2420
|
* event observation without async stream reader timing issues.
|
|
2388
2421
|
*/
|
|
2422
|
+
/** The names of every user-defined unit in scope, for detecting a removal. */
|
|
2423
|
+
userUnitNames(): string[];
|
|
2424
|
+
/**
|
|
2425
|
+
* Drop every user unit defined by `lineNumber`, for a line being removed.
|
|
2426
|
+
*
|
|
2427
|
+
* A line being recompiled clears its own definitions on the way through, so
|
|
2428
|
+
* this is for the line that will never be compiled again.
|
|
2429
|
+
*
|
|
2430
|
+
* @param lineId - The persistent id of the line being deleted.
|
|
2431
|
+
* @returns Whether the line had defined anything.
|
|
2432
|
+
*/
|
|
2433
|
+
undefineUserUnitsFrom(lineId: number): boolean;
|
|
2434
|
+
/**
|
|
2435
|
+
* Recompile everything, because a user unit is no longer in scope.
|
|
2436
|
+
*
|
|
2437
|
+
* A unit is expanded while a line is compiled, so a line that used one holds
|
|
2438
|
+
* bytecode built around it. Losing the definition has to reach that bytecode
|
|
2439
|
+
* or the conversion goes on working from a definition the document no longer
|
|
2440
|
+
* contains.
|
|
2441
|
+
*/
|
|
2442
|
+
invalidateForRemovedUserUnits(): void;
|
|
2389
2443
|
getBatcher(): AsyncResolutionBatcher;
|
|
2390
2444
|
/**
|
|
2391
2445
|
* Register a package with the engine's isolated registries.
|
|
@@ -2544,6 +2598,74 @@ declare class ExpressionEngine {
|
|
|
2544
2598
|
* @param reads - Variable keys the line reads.
|
|
2545
2599
|
* @param writes - Variable keys the line writes.
|
|
2546
2600
|
*/
|
|
2601
|
+
/**
|
|
2602
|
+
* Forget names that no line defines any more.
|
|
2603
|
+
*
|
|
2604
|
+
* The graph reports a key when the line that wrote it stops doing so and no
|
|
2605
|
+
* other line writes it. The VM's variable store only ever accumulated, so
|
|
2606
|
+
* the value outlived the line: deleting `:x = 12` left `x + 4` answering
|
|
2607
|
+
* `16` for the rest of the session.
|
|
2608
|
+
*
|
|
2609
|
+
* The checkpoint chain is told as well, since it records what each line
|
|
2610
|
+
* wrote and would otherwise put the name back on the next restore.
|
|
2611
|
+
*
|
|
2612
|
+
* Only variable names. The key space also holds category tags, globals,
|
|
2613
|
+
* data sources and line positions, and none of those is a VM binding; a
|
|
2614
|
+
* prefix is what tells them apart, and a variable's key is the bare name.
|
|
2615
|
+
*
|
|
2616
|
+
* @param orphaned - Keys the graph reports as no longer written by any line.
|
|
2617
|
+
*/
|
|
2618
|
+
/**
|
|
2619
|
+
* Forget a name the graph says no line writes any more.
|
|
2620
|
+
*
|
|
2621
|
+
* Reported by {@link DependencyGraph.registerLine} and its `removeLine` when
|
|
2622
|
+
* the line that wrote a key stops doing so and no other line writes it. The
|
|
2623
|
+
* VM's variable store only ever accumulated, so the value outlived the line:
|
|
2624
|
+
* deleting `:x = 12` left `x + 4` answering `16` for the rest of the
|
|
2625
|
+
* session.
|
|
2626
|
+
*
|
|
2627
|
+
* The graph is not the authority here, the document is, and for two
|
|
2628
|
+
* ordering reasons. A line holding several inline expressions registers once
|
|
2629
|
+
* per expression, so the one that defines a name is followed by one that
|
|
2630
|
+
* does not, and the graph would report an orphan mid-line; the document
|
|
2631
|
+
* holds the line's aggregate write set and does not. And a structural edit
|
|
2632
|
+
* clears the graph, so afterwards it would call every name undefined. A
|
|
2633
|
+
* line's recorded write set survives both, and is up to date for the line
|
|
2634
|
+
* being registered, because a pass stores the line's results before it
|
|
2635
|
+
* registers its edges.
|
|
2636
|
+
*
|
|
2637
|
+
* Answering here rather than at the end of the pass is what lets the lines
|
|
2638
|
+
* BELOW the edit see it on the same pass rather than the next one.
|
|
2639
|
+
*
|
|
2640
|
+
* The checkpoint chain is told as well, since it records what each line
|
|
2641
|
+
* wrote and would otherwise put the name back on the next restore.
|
|
2642
|
+
*
|
|
2643
|
+
* Only variable names: the key space also holds category tags, globals,
|
|
2644
|
+
* data sources and line positions, and none of those is a VM binding.
|
|
2645
|
+
*
|
|
2646
|
+
* @param orphaned - Keys that just lost their last writer in the graph.
|
|
2647
|
+
*/
|
|
2648
|
+
forgetOrphanedNames(orphaned: readonly string[]): void;
|
|
2649
|
+
/**
|
|
2650
|
+
* Decide the candidates: forget the ones no line defines any more.
|
|
2651
|
+
*
|
|
2652
|
+
* Asked once, at the end of a pass, because deciding as each line registers
|
|
2653
|
+
* cannot work. A line holding several inline expressions registers once per
|
|
2654
|
+
* expression, so the one that defines a name is followed by one that does
|
|
2655
|
+
* not; and the engine registers a line before the pass records that line's
|
|
2656
|
+
* results, so its recorded write set is a pass behind. Both would answer
|
|
2657
|
+
* wrongly mid-pass. At the end of one, every line has registered and the
|
|
2658
|
+
* document is current.
|
|
2659
|
+
*
|
|
2660
|
+
* The document is the authority, not the graph: a structural edit clears
|
|
2661
|
+
* the graph, and a viewport leaves the lines outside it unregistered, while
|
|
2662
|
+
* a line's recorded write set survives both.
|
|
2663
|
+
*
|
|
2664
|
+
* The reader of a forgotten name updates on the following pass, which an
|
|
2665
|
+
* editor makes anyway. It is not made to happen sooner because every way of
|
|
2666
|
+
* doing that answers the question before it can be answered correctly.
|
|
2667
|
+
*/
|
|
2668
|
+
settleOrphanedNames(): void;
|
|
2547
2669
|
private registerLineWithTags;
|
|
2548
2670
|
/**
|
|
2549
2671
|
* Execute bytecode and handle the result.
|
|
@@ -680,7 +680,7 @@ declare class DependencyGraph {
|
|
|
680
680
|
* @param reads - Variable names this line reads
|
|
681
681
|
* @param writes - Variable names this line writes (assigns to)
|
|
682
682
|
*/
|
|
683
|
-
registerLine(lineNumber: number, reads: string[], writes: string[]):
|
|
683
|
+
registerLine(lineNumber: number, reads: string[], writes: string[]): readonly string[];
|
|
684
684
|
/**
|
|
685
685
|
* Register a line's dependency on an external data source (e.g., currency rate, OSRS GE price).
|
|
686
686
|
*
|
|
@@ -729,6 +729,25 @@ declare class DependencyGraph {
|
|
|
729
729
|
* @param dependsOnLine - 1-based line whose result it read
|
|
730
730
|
*/
|
|
731
731
|
registerLinePositionDependency(lineNumber: number, dependsOnLine: number): void;
|
|
732
|
+
/**
|
|
733
|
+
* Every line that read some position's result, whichever position it was.
|
|
734
|
+
*
|
|
735
|
+
* For a structural edit, which changes what a position *means* rather than
|
|
736
|
+
* what any line says. Inserting a line moves everything below it, so `line 5`
|
|
737
|
+
* now names different text, `prev` names a different neighbour, and an
|
|
738
|
+
* `above` aggregate covers a different block, all without a character
|
|
739
|
+
* changing on the line that reads them.
|
|
740
|
+
*
|
|
741
|
+
* Deliberately not filtered by which positions moved. A reader whose target
|
|
742
|
+
* shifted has to re-run, and so does one that shifted past its own target and
|
|
743
|
+
* became a self-reference, and the second is not visible from the target
|
|
744
|
+
* alone. Positional readers are a small minority of a document's lines, so
|
|
745
|
+
* re-running all of them costs almost nothing and cannot be wrong.
|
|
746
|
+
*
|
|
747
|
+
* @returns The 1-based line numbers doing the reading, valid until the next
|
|
748
|
+
* structural change.
|
|
749
|
+
*/
|
|
750
|
+
linesReadingAPosition(): Iterable<number>;
|
|
732
751
|
/**
|
|
733
752
|
* The lines that read the result of line `lineNumber`.
|
|
734
753
|
*
|
|
@@ -758,7 +777,7 @@ declare class DependencyGraph {
|
|
|
758
777
|
*
|
|
759
778
|
* @param lineNumber - The line number being removed
|
|
760
779
|
*/
|
|
761
|
-
removeLine(lineNumber: number):
|
|
780
|
+
removeLine(lineNumber: number): readonly string[];
|
|
762
781
|
/**
|
|
763
782
|
* Get all line numbers that consume (read) a given variable.
|
|
764
783
|
*
|
|
@@ -1058,6 +1077,17 @@ declare class VMCheckpointer {
|
|
|
1058
1077
|
* @returns Whether a checkpoint existed at that line.
|
|
1059
1078
|
*/
|
|
1060
1079
|
applyCheckpointAt(lineNumber: number): boolean;
|
|
1080
|
+
/**
|
|
1081
|
+
* Drop `names` from every checkpoint, as though no line had ever set them.
|
|
1082
|
+
*
|
|
1083
|
+
* A checkpoint records what its line wrote, so a name whose defining line
|
|
1084
|
+
* has been deleted or edited into something else is still in the chain, and
|
|
1085
|
+
* the next restore would put it back into the VM after the VM had been told
|
|
1086
|
+
* to forget it. The two have to agree.
|
|
1087
|
+
*
|
|
1088
|
+
* @param names - The names no line defines any more.
|
|
1089
|
+
*/
|
|
1090
|
+
forget(names: readonly string[]): void;
|
|
1061
1091
|
/**
|
|
1062
1092
|
* Find the nearest checkpoint at or before the given line number.
|
|
1063
1093
|
*
|
|
@@ -680,7 +680,7 @@ declare class DependencyGraph {
|
|
|
680
680
|
* @param reads - Variable names this line reads
|
|
681
681
|
* @param writes - Variable names this line writes (assigns to)
|
|
682
682
|
*/
|
|
683
|
-
registerLine(lineNumber: number, reads: string[], writes: string[]):
|
|
683
|
+
registerLine(lineNumber: number, reads: string[], writes: string[]): readonly string[];
|
|
684
684
|
/**
|
|
685
685
|
* Register a line's dependency on an external data source (e.g., currency rate, OSRS GE price).
|
|
686
686
|
*
|
|
@@ -729,6 +729,25 @@ declare class DependencyGraph {
|
|
|
729
729
|
* @param dependsOnLine - 1-based line whose result it read
|
|
730
730
|
*/
|
|
731
731
|
registerLinePositionDependency(lineNumber: number, dependsOnLine: number): void;
|
|
732
|
+
/**
|
|
733
|
+
* Every line that read some position's result, whichever position it was.
|
|
734
|
+
*
|
|
735
|
+
* For a structural edit, which changes what a position *means* rather than
|
|
736
|
+
* what any line says. Inserting a line moves everything below it, so `line 5`
|
|
737
|
+
* now names different text, `prev` names a different neighbour, and an
|
|
738
|
+
* `above` aggregate covers a different block, all without a character
|
|
739
|
+
* changing on the line that reads them.
|
|
740
|
+
*
|
|
741
|
+
* Deliberately not filtered by which positions moved. A reader whose target
|
|
742
|
+
* shifted has to re-run, and so does one that shifted past its own target and
|
|
743
|
+
* became a self-reference, and the second is not visible from the target
|
|
744
|
+
* alone. Positional readers are a small minority of a document's lines, so
|
|
745
|
+
* re-running all of them costs almost nothing and cannot be wrong.
|
|
746
|
+
*
|
|
747
|
+
* @returns The 1-based line numbers doing the reading, valid until the next
|
|
748
|
+
* structural change.
|
|
749
|
+
*/
|
|
750
|
+
linesReadingAPosition(): Iterable<number>;
|
|
732
751
|
/**
|
|
733
752
|
* The lines that read the result of line `lineNumber`.
|
|
734
753
|
*
|
|
@@ -758,7 +777,7 @@ declare class DependencyGraph {
|
|
|
758
777
|
*
|
|
759
778
|
* @param lineNumber - The line number being removed
|
|
760
779
|
*/
|
|
761
|
-
removeLine(lineNumber: number):
|
|
780
|
+
removeLine(lineNumber: number): readonly string[];
|
|
762
781
|
/**
|
|
763
782
|
* Get all line numbers that consume (read) a given variable.
|
|
764
783
|
*
|
|
@@ -1058,6 +1077,17 @@ declare class VMCheckpointer {
|
|
|
1058
1077
|
* @returns Whether a checkpoint existed at that line.
|
|
1059
1078
|
*/
|
|
1060
1079
|
applyCheckpointAt(lineNumber: number): boolean;
|
|
1080
|
+
/**
|
|
1081
|
+
* Drop `names` from every checkpoint, as though no line had ever set them.
|
|
1082
|
+
*
|
|
1083
|
+
* A checkpoint records what its line wrote, so a name whose defining line
|
|
1084
|
+
* has been deleted or edited into something else is still in the chain, and
|
|
1085
|
+
* the next restore would put it back into the VM after the VM had been told
|
|
1086
|
+
* to forget it. The two have to agree.
|
|
1087
|
+
*
|
|
1088
|
+
* @param names - The names no line defines any more.
|
|
1089
|
+
*/
|
|
1090
|
+
forget(names: readonly string[]): void;
|
|
1061
1091
|
/**
|
|
1062
1092
|
* Find the nearest checkpoint at or before the given line number.
|
|
1063
1093
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var f=class{constructor(t){this.checkpoints=[];this.vm=t;}snapshot(t,e,n){if(n.length===0)return null;let i=this.indexOfCheckpointAt(t),s=i>=0?i:this.insertionIndexFor(t),r=s>0?this.checkpoints[s-1]:null,h=Object.create(null),u=Object.create(null);for(let o of n){if(this.vm.hasUserFunction(o)){let l=this.vm.getUserFunction(o);l&&(u[o]=l);continue}let p=this.vm.getVar(o);p!==void 0&&(h[o]=p);}let c={lineNumber:t,lineId:e,variables:h,functions:u,parent:r};i>=0?this.checkpoints[i]=c:this.checkpoints.splice(s,0,c);let a=this.checkpoints[s+1];return a!==void 0&&(a.parent=c),c}restoreTo(t){let e=this.nearestCheckpointIndex(t);this.vm.reset();for(let n=0;n<=e;n++){let i=this.checkpoints[n];for(let s of Object.keys(i.variables))this.vm.setVar(s,i.variables[s]);for(let s of Object.keys(i.functions)){let r=i.functions[s];this.vm.defineUserFunction(r.name,r.params,r.program);}}}indexOfCheckpointAt(t){let e=this.nearestCheckpointIndex(t);return e>=0&&this.checkpoints[e].lineNumber===t?e:-1}insertionIndexFor(t){return this.nearestCheckpointIndex(t)+1}nearestCheckpointIndex(t){let e=0,n=this.checkpoints.length-1,i=-1;for(;e<=n;){let s=e+n>>1;this.checkpoints[s].lineNumber<=t?(i=s,e=s+1):n=s-1;}return i}updateCheckpointAt(t,e){let n=this.getCheckpointAt(t);if(!n)return false;for(let i of e){if(this.vm.hasUserFunction(i)){let r=this.vm.getUserFunction(i);r&&(n.functions[i]=r);continue}let s=this.vm.getVar(i);s!==void 0&&(n.variables[i]=s);}return true}applyCheckpointAt(t){let e=this.getCheckpointAt(t);if(!e)return false;for(let n of Object.keys(e.variables))this.vm.setVar(n,e.variables[n]);for(let n of Object.keys(e.functions)){let i=e.functions[n];this.vm.defineUserFunction(i.name,i.params,i.program);}return true}getNearestCheckpoint(t){let e=this.nearestCheckpointIndex(t);return e<0?null:this.checkpoints[e]}getCheckpointAt(t){let e=this.nearestCheckpointIndex(t);if(e<0)return;let n=this.checkpoints[e];return n.lineNumber===t?n:void 0}getAllCheckpoints(){return this.checkpoints}lookupVariable(t){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1];for(;e;){if(Object.prototype.hasOwnProperty.call(e.variables,t))return e.variables[t];e=e.parent;}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};export{f as a};//# sourceMappingURL=chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
var f=class{constructor(t){this.checkpoints=[];this.vm=t;}snapshot(t,e,n){if(n.length===0)return null;let i=this.indexOfCheckpointAt(t),s=i>=0?i:this.insertionIndexFor(t),r=s>0?this.checkpoints[s-1]:null,h=Object.create(null),u=Object.create(null);for(let o of n){if(this.vm.hasUserFunction(o)){let l=this.vm.getUserFunction(o);l&&(u[o]=l);continue}let p=this.vm.getVar(o);p!==void 0&&(h[o]=p);}let c={lineNumber:t,lineId:e,variables:h,functions:u,parent:r};i>=0?this.checkpoints[i]=c:this.checkpoints.splice(s,0,c);let a=this.checkpoints[s+1];return a!==void 0&&(a.parent=c),c}restoreTo(t){let e=this.nearestCheckpointIndex(t);this.vm.reset();for(let n=0;n<=e;n++){let i=this.checkpoints[n];for(let s of Object.keys(i.variables))this.vm.setVar(s,i.variables[s]);for(let s of Object.keys(i.functions)){let r=i.functions[s];this.vm.defineUserFunction(r.name,r.params,r.program);}}}indexOfCheckpointAt(t){let e=this.nearestCheckpointIndex(t);return e>=0&&this.checkpoints[e].lineNumber===t?e:-1}insertionIndexFor(t){return this.nearestCheckpointIndex(t)+1}nearestCheckpointIndex(t){let e=0,n=this.checkpoints.length-1,i=-1;for(;e<=n;){let s=e+n>>1;this.checkpoints[s].lineNumber<=t?(i=s,e=s+1):n=s-1;}return i}updateCheckpointAt(t,e){let n=this.getCheckpointAt(t);if(!n)return false;for(let i of e){if(this.vm.hasUserFunction(i)){let r=this.vm.getUserFunction(i);r&&(n.functions[i]=r);continue}let s=this.vm.getVar(i);s!==void 0&&(n.variables[i]=s);}return true}applyCheckpointAt(t){let e=this.getCheckpointAt(t);if(!e)return false;for(let n of Object.keys(e.variables))this.vm.setVar(n,e.variables[n]);for(let n of Object.keys(e.functions)){let i=e.functions[n];this.vm.defineUserFunction(i.name,i.params,i.program);}return true}forget(t){if(t.length!==0)for(let e of this.checkpoints)for(let n of t)delete e.variables[n],delete e.functions[n];}getNearestCheckpoint(t){let e=this.nearestCheckpointIndex(t);return e<0?null:this.checkpoints[e]}getCheckpointAt(t){let e=this.nearestCheckpointIndex(t);if(e<0)return;let n=this.checkpoints[e];return n.lineNumber===t?n:void 0}getAllCheckpoints(){return this.checkpoints}lookupVariable(t){if(this.checkpoints.length===0)return;let e=this.checkpoints[this.checkpoints.length-1];for(;e;){if(Object.prototype.hasOwnProperty.call(e.variables,t))return e.variables[t];e=e.parent;}}clear(){this.checkpoints=[];}get count(){return this.checkpoints.length}get isEmpty(){return this.checkpoints.length===0}get vmInstance(){return this.vm}};export{f as a};//# sourceMappingURL=chunk-2YHOWQ43.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-2YHOWQ43.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/vm/VMCheckpoints.ts"],"names":["VMCheckpointer","vm","lineNumber","lineId","variableNames","existing","insertAt","parent","variables","functions","name","fn","val","checkpoint","next","targetIndex","i","cp","key","index","low","high","result","mid","value","names","candidate"],"mappings":"AAuFO,IAAMA,CAAAA,CAAN,KAAqB,CAM3B,WAAA,CAAYC,CAAAA,CAAQ,CAJpB,IAAA,CAAQ,WAAA,CAA8B,EAAC,CAKtC,IAAA,CAAK,EAAA,CAAKA,EACX,CAqBA,QAAA,CACCC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACsB,CACtB,GAAIA,CAAAA,CAAc,MAAA,GAAW,CAAA,CAAG,OAAO,IAAA,CAqBvC,IAAMC,CAAAA,CAAW,IAAA,CAAK,mBAAA,CAAoBH,CAAU,CAAA,CAC9CI,CAAAA,CAAWD,CAAAA,EAAY,CAAA,CAAIA,CAAAA,CAAW,IAAA,CAAK,iBAAA,CAAkBH,CAAU,CAAA,CACvEK,CAAAA,CAASD,CAAAA,CAAW,CAAA,CAAI,IAAA,CAAK,WAAA,CAAYA,CAAAA,CAAW,CAAC,EAAI,IAAA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AA,CAAUH,CAAI,EAEjCG,CAAAA,CAAaA,CAAAA,CAAW,OACzB,CAED,CAQA,KAAA,EAAc,CACb,IAAA,CAAK,WAAA,CAAc,GACpB,CAGA,IAAI,KAAA,EAAgB,CACnB,OAAO,KAAK,WAAA,CAAY,MACzB,CAGA,IAAI,OAAA,EAAmB,CACtB,OAAO,IAAA,CAAK,YAAY,MAAA,GAAW,CACpC,CAGA,IAAI,UAAA,EAAiB,CACpB,OAAO,IAAA,CAAK,EACb,CACD","file":"chunk-2YHOWQ43.js","sourcesContent":["import { Value } from \"@solve-js/vm/Value\";\nimport type { VM } from \"@solve-js/vm/OpRegistry\";\nimport type { UserFunctionDef } from \"@solve-js/parser/BytecodeBuilder\";\n\n// ── VMCheckpoint ────────────────────────────────────────────────────────\n\n/**\n * A point-in-time snapshot of VM variable state.\n *\n * Each checkpoint holds only the variables that CHANGED at its line, and\n * reaches the rest through its `parent` link. A lookup walks that chain until\n * it finds the name; a restore walks it from the root applying each link's own\n * bindings in turn, so a later line's value naturally overwrites an earlier\n * one's.\n *\n * ```text\n * Checkpoint 0 (root): {} // empty scope\n * Checkpoint 1 (:x=5): { x: 5 } parent → 0\n * Checkpoint 2 (:y=8): { y: 8 } parent → 1\n * Checkpoint 3 (:x=3): { x: 3 } parent → 2 // shadows x=5\n * ```\n *\n * To look up `x` at checkpoint 3: find own `x=3` → done.\n * To look up `y` at checkpoint 3: not own → walk parent to checkpoint 2 → `y=8`.\n * To look up `z` at checkpoint 3: not found anywhere → undefined.\n *\n * **Memory:** O(number of variable definitions) heap, independent of\n * document length. Typical Obsidian documents have < 100 variable defs,\n * so total checkpoint heap is < 10 KB.\n */\nexport interface VMCheckpoint {\n\t/** 1-based line number where this checkpoint was created. */\n\tlineNumber: number;\n\t/** Persistent line ID from DocumentModel. */\n\tlineId: number;\n\t/**\n\t * Variable name → Value at this checkpoint.\n\t * Only the variables set or updated at this line; the rest are reached\n\t * through {@link VMCheckpoint.parent}.\n\t */\n\tvariables: Record<string, Value>;\n\t/**\n\t * User-defined-function name → definition at this checkpoint. SEPARATE\n\t * from `variables` above (not prototypally chained the same way\n\t * `restoreTo()` replays every checkpoint in the chain in order, so a\n\t * later redefinition of the same function name naturally overwrites an\n\t * earlier one during replay, without needing its own prototype walk).\n\t *\n\t * Without this field, a function definition's checkpoint entry would be\n\t * SILENTLY LOST: `snapshot()` used to call `vm.getVar(name)` for every\n\t * written name, which returns `undefined` for a function name (function\n\t * defs live in `vm.userFunctions`, not the flat variable store), and a\n\t * `val !== undefined` guard silently skipped it. A scroll-triggered\n\t * `restoreTo()` would then reset the VM and replay only `variables`,\n\t * making a function defined above the new viewport vanish (calling it\n\t * would throw `UNDEFINED_FUNCTION`) even though the document still\n\t * shows its definition line as clean/cached.\n\t */\n\tfunctions: Record<string, UserFunctionDef>;\n\t/** Parent checkpoint (closer to document start), or null for root. */\n\tparent: VMCheckpoint | null;\n}\n\n// ── VMCheckpointer ──────────────────────────────────────────────────────\n\n/**\n * Manages VM state checkpoints for the three-tier evaluation strategy.\n *\n * **Checkpoint creation:** After a variable-definition line executes\n * (Tier 1 or Tier 3), `snapshot()` records the current values of the\n * written variables. The checkpoint is linked via prototypal inheritance\n * to the previous checkpoint, so only changed variables consume memory.\n *\n * **Checkpoint restoration:** Before evaluating a viewport whose start line\n * is not line 1, `restoreTo(lineNumber)` resets the VM and replays all\n * variable definitions up to and including that line. This avoids\n * re-evaluating the entire document from line 1 on every scroll.\n *\n * **Thread safety:** Checkpoints are created synchronously on the main\n * thread during evaluation. They are immutable after creation (Value is\n * an immutable type), so no synchronization is needed.\n *\n * **Integration with Phase 5.2e:** `setViewport()` will use `getNearestCheckpoint()`\n * to find the checkpoint just before the new viewport start, then call\n * `restoreTo()` to set up the VM before evaluating only the visible lines.\n * This is the key to O(visible lines) scrolling instead of O(document).\n */\nexport class VMCheckpointer {\n\t/** Ordered array of checkpoints (ascending lineNumber). */\n\tprivate checkpoints: VMCheckpoint[] = [];\n\t/** The VM instance whose variables are snapshotted/restored. */\n\tprivate vm: VM;\n\n\tconstructor(vm: VM) {\n\t\tthis.vm = vm;\n\t}\n\n\t// ── Snapshot ─────────────────────────────────────────────────────\n\n\t/**\n\t * Create a checkpoint at the current line, recording the VM values of\n\t * the specified variables.\n\t *\n\t * Records only what this line wrote; the rest is reached through the\n\t * parent link rather than copied.\n\t *\n\t * A line that is snapshotted again drops every checkpoint at or after it\n\t * first, so the list stays in document order and the new checkpoint\n\t * inherits from the line before it rather than from one after it. See the\n\t * body for what went wrong without that.\n\t *\n\t * @param lineNumber 1-based line position.\n\t * @param lineId Persistent line ID from DocumentModel.\n\t * @param variableNames Names of variables that were written at this line.\n\t * @returns The new checkpoint, or null if no variable names provided.\n\t */\n\tsnapshot(\n\t\tlineNumber: number,\n\t\tlineId: number,\n\t\tvariableNames: string[]\n\t): VMCheckpoint | null {\n\t\tif (variableNames.length === 0) return null;\n\n\t\t// This line's own entry is replaced, and nothing else is touched.\n\t\t//\n\t\t// The list is a sequence of document positions and `restoreTo` reads it\n\t\t// as one, so a re-run must not append after entries that come later in\n\t\t// the document: editing line 2 of a document whose lines 1, 2 and 3 each\n\t\t// define something left the list as [1, 2, 3, 2], and a restore to line\n\t\t// 2 then found the stale entry.\n\t\t//\n\t\t// Replacing rather than truncating is the part that took a second go.\n\t\t// Dropping every entry at or after the line is sound only for a pass\n\t\t// running from line 1, which re-takes them as it continues. A pass\n\t\t// limited to a viewport does not: it re-snapshots the top of the\n\t\t// document and never reaches the definitions below its end line, so the\n\t\t// chain lost them, and `restoreTo` then RESET the VM and replayed a\n\t\t// prefix that no longer mentioned them. A line further down reading one\n\t\t// answered `Undefined variable` where it had answered a number. Absent\n\t\t// is worse than stale here: a stale entry is what the document is\n\t\t// currently showing anyway, and the pass corrects it when it reaches\n\t\t// that line.\n\t\tconst existing = this.indexOfCheckpointAt(lineNumber);\n\t\tconst insertAt = existing >= 0 ? existing : this.insertionIndexFor(lineNumber);\n\t\tconst parent = insertAt > 0 ? this.checkpoints[insertAt - 1] : null;\n\n\t\t// Each checkpoint holds only what its line wrote, and reaches the rest\n\t\t// through `parent`. It used to reach it through the prototype chain\n\t\t// instead, which held the same entries and cost the same memory, and\n\t\t// made the chain as deep as the document has definitions: a null\n\t\t// prototype is a flat object, and one per definition is a chain two\n\t\t// thousand deep on a document of two thousand definitions. Creating and\n\t\t// reading those took a pass over such a document from 6.0 ms to 23.1 ms.\n\t\t//\n\t\t// Nothing needed the inheritance. `restoreTo` walks `parent` and applies\n\t\t// each checkpoint's OWN keys, which is the same set either way, and the\n\t\t// one reader that did walk the prototype now walks `parent` too.\n\t\t//\n\t\t// Null-prototyped rather than `{}`, so a variable named `constructor` or\n\t\t// `toString` is a key like any other.\n\t\tconst variables: Record<string, Value> = Object.create(null) as Record<string, Value>;\n\t\tconst functions: Record<string, UserFunctionDef> = Object.create(null) as Record<string, UserFunctionDef>;\n\n\t\t// Record current VM values for the written names, routing each into\n\t\t// the right bag (a name is either a variable or a user-defined\n\t\t// function, never both; see VMCheckpoint.functions's doc comment for\n\t\t// why this dispatch is required, not optional).\n\t\tfor (const name of variableNames) {\n\t\t\tif (this.vm.hasUserFunction(name)) {\n\t\t\t\tconst fn = this.vm.getUserFunction(name);\n\t\t\t\tif (fn) functions[name] = fn;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst val = this.vm.getVar(name);\n\t\t\tif (val !== undefined) {\n\t\t\t\tvariables[name] = val;\n\t\t\t}\n\t\t}\n\n\t\tconst checkpoint: VMCheckpoint = {\n\t\t\tlineNumber,\n\t\t\tlineId,\n\t\t\tvariables,\n\t\t\tfunctions,\n\t\t\tparent,\n\t\t};\n\t\tif (existing >= 0) this.checkpoints[existing] = checkpoint;\n\t\telse this.checkpoints.splice(insertAt, 0, checkpoint);\n\t\t// The entry after this one now follows a different object.\n\t\tconst next = this.checkpoints[insertAt + 1];\n\t\tif (next !== undefined) next.parent = checkpoint;\n\t\treturn checkpoint;\n\t}\n\n\t// ── Restore ──────────────────────────────────────────────────────\n\n\t/**\n\t * Restore the VM to the state at or just after the given line number.\n\t *\n\t * Finds the nearest checkpoint whose `lineNumber <= targetLineNumber`,\n\t * then replays all variable definitions from root → that checkpoint\n\t * into the VM via `setVar()`. The VM's stack is also reset.\n\t *\n\t * If no checkpoint exists at or before the target line, the VM is\n\t * fully reset (empty scope, empty stack).\n\t *\n\t * **Performance:** O(total variable definitions before the line), since\n\t * each checkpoint in the chain contributes only the names its own line\n\t * wrote.\n\t *\n\t * @param lineNumber Target 1-based line number. The VM will have the\n\t * state that existed AFTER evaluating lines up to `lineNumber`.\n\t */\n\trestoreTo(lineNumber: number): void {\n\t\t// The chain from the root to the target IS the array up to that index.\n\t\t//\n\t\t// Every checkpoint is created with the one before it in the array as its\n\t\t// parent (see {@link snapshot}), and the array is kept in document\n\t\t// order, so walking parent links would visit exactly these entries in\n\t\t// exactly this order. Reading the array instead of the links costs no\n\t\t// allocation, and it was the links that made this quadratic: the walk\n\t\t// runs target-to-root, so the chain was assembled by `unshift`ing each\n\t\t// entry onto the front, which shifts every entry already there. A\n\t\t// document with two thousand definitions did four million shifts per\n\t\t// restore, and a scroll restores.\n\t\t//\n\t\t// `CheckpointsStayInDocumentOrder.spec.ts` asserts the invariant this\n\t\t// relies on, so a change that broke it would fail there rather than\n\t\t// quietly restoring the wrong state here.\n\t\tconst targetIndex = this.nearestCheckpointIndex(lineNumber);\n\n\t\tthis.vm.reset();\n\t\tfor (let i = 0; i <= targetIndex; i++) {\n\t\t\tconst cp = this.checkpoints[i];\n\t\t\t// Only the names this checkpoint's own line wrote; the ones before\n\t\t\t// it are applied by their own entries earlier in this same walk.\n\t\t\tfor (const key of Object.keys(cp.variables)) {\n\t\t\t\tthis.vm.setVar(key, cp.variables[key]);\n\t\t\t}\n\t\t\t// Replay function definitions the same way, a later checkpoint's\n\t\t\t// redefinition of the same name naturally overwrites an earlier\n\t\t\t// one since the walk runs root-to-target.\n\t\t\tfor (const key of Object.keys(cp.functions)) {\n\t\t\t\tconst fn = cp.functions[key];\n\t\t\t\tthis.vm.defineUserFunction(fn.name, fn.params, fn.program);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** The index of the checkpoint recorded exactly at `lineNumber`, or -1. */\n\tprivate indexOfCheckpointAt(lineNumber: number): number {\n\t\tconst index = this.nearestCheckpointIndex(lineNumber);\n\t\treturn index >= 0 && this.checkpoints[index].lineNumber === lineNumber ? index : -1;\n\t}\n\n\t/** Where a checkpoint for `lineNumber` belongs, keeping the list in order. */\n\tprivate insertionIndexFor(lineNumber: number): number {\n\t\treturn this.nearestCheckpointIndex(lineNumber) + 1;\n\t}\n\n\t/**\n\t * The index of the last checkpoint at or before `lineNumber`, or -1.\n\t *\n\t * A binary search rather than a scan. The array is in document order, and\n\t * this is asked once per scroll and once per async batch, on a document\n\t * that can hold a checkpoint per definition.\n\t */\n\tprivate nearestCheckpointIndex(lineNumber: number): number {\n\t\tlet low = 0;\n\t\tlet high = this.checkpoints.length - 1;\n\t\tlet result = -1;\n\t\twhile (low <= high) {\n\t\t\tconst mid = (low + high) >> 1;\n\t\t\tif (this.checkpoints[mid].lineNumber <= lineNumber) {\n\t\t\t\tresult = mid;\n\t\t\t\tlow = mid + 1;\n\t\t\t} else {\n\t\t\t\thigh = mid - 1;\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Record what `lineNumber` has just written, without disturbing the chain\n\t * after it.\n\t *\n\t * {@link snapshot} drops every checkpoint at or after the line, which is\n\t * right for a pass running forward in document order: it re-takes them as it\n\t * goes. A caller re-running a few lines out of a document does not, and\n\t * dropping the entries for lines it will never visit would lose the very\n\t * bindings it is sweeping through them to collect. So this overwrites in\n\t * place instead.\n\t *\n\t * Safe against the prototype chain, because it replaces only the\n\t * checkpoint's OWN bindings: a later checkpoint that also writes the name\n\t * holds its own copy and goes on shadowing this one.\n\t *\n\t * @param lineNumber 1-based line whose recorded bindings are refreshed.\n\t * @param variableNames The names it wrote.\n\t * @returns Whether a checkpoint existed at that line to update.\n\t */\n\tupdateCheckpointAt(lineNumber: number, variableNames: string[]): boolean {\n\t\tconst checkpoint = this.getCheckpointAt(lineNumber);\n\t\tif (!checkpoint) return false;\n\t\tfor (const name of variableNames) {\n\t\t\tif (this.vm.hasUserFunction(name)) {\n\t\t\t\tconst fn = this.vm.getUserFunction(name);\n\t\t\t\tif (fn) checkpoint.functions[name] = fn;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst value = this.vm.getVar(name);\n\t\t\tif (value !== undefined) checkpoint.variables[name] = value;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Apply the bindings recorded AT `lineNumber`, leaving the rest of the VM\n\t * alone.\n\t *\n\t * {@link restoreTo} rebuilds the whole prefix, which costs the chain every\n\t * time it is called. A caller moving forward through the document already\n\t * holds the prefix up to the line before, and needs only what this line\n\t * added: restoring once and then applying each line in turn as it is passed\n\t * costs the chain once rather than once per line.\n\t *\n\t * @param lineNumber 1-based line whose own bindings are applied.\n\t * @returns Whether a checkpoint existed at that line.\n\t */\n\tapplyCheckpointAt(lineNumber: number): boolean {\n\t\tconst checkpoint = this.getCheckpointAt(lineNumber);\n\t\tif (!checkpoint) return false;\n\t\tfor (const key of Object.keys(checkpoint.variables)) {\n\t\t\tthis.vm.setVar(key, checkpoint.variables[key]);\n\t\t}\n\t\tfor (const key of Object.keys(checkpoint.functions)) {\n\t\t\tconst fn = checkpoint.functions[key];\n\t\t\tthis.vm.defineUserFunction(fn.name, fn.params, fn.program);\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Drop `names` from every checkpoint, as though no line had ever set them.\n\t *\n\t * A checkpoint records what its line wrote, so a name whose defining line\n\t * has been deleted or edited into something else is still in the chain, and\n\t * the next restore would put it back into the VM after the VM had been told\n\t * to forget it. The two have to agree.\n\t *\n\t * @param names - The names no line defines any more.\n\t */\n\tforget(names: readonly string[]): void {\n\t\tif (names.length === 0) return;\n\t\tfor (const checkpoint of this.checkpoints) {\n\t\t\tfor (const name of names) {\n\t\t\t\tdelete checkpoint.variables[name];\n\t\t\t\tdelete checkpoint.functions[name];\n\t\t\t}\n\t\t}\n\t}\n\n\t// ── Queries ──────────────────────────────────────────────────────\n\n\t/**\n\t * Find the nearest checkpoint at or before the given line number.\n\t *\n\t * Uses linear scan (checkpoints are sorted by lineNumber and the list\n\t * is short, typically < 20 for Obsidian documents). Can be upgraded\n\t * to binary search if needed for documents with 1000+ variable defs.\n\t *\n\t * @returns The nearest checkpoint, or null if none exists before the line.\n\t */\n\tgetNearestCheckpoint(lineNumber: number): VMCheckpoint | null {\n\t\tconst index = this.nearestCheckpointIndex(lineNumber);\n\t\treturn index < 0 ? null : this.checkpoints[index];\n\t}\n\n\t/**\n\t * Get a specific checkpoint by its line number.\n\t * @returns The checkpoint, or undefined if not found.\n\t */\n\tgetCheckpointAt(lineNumber: number): VMCheckpoint | undefined {\n\t\t// Searched, not scanned: the async sweep asks this once for every line\n\t\t// it walks past, and a scan would make that walk quadratic.\n\t\tconst index = this.nearestCheckpointIndex(lineNumber);\n\t\tif (index < 0) return undefined;\n\t\tconst candidate = this.checkpoints[index];\n\t\treturn candidate.lineNumber === lineNumber ? candidate : undefined;\n\t}\n\n\t/**\n\t * Get the entire checkpoint chain from root to the last checkpoint.\n\t * Useful for debugging and serialization.\n\t */\n\tgetAllCheckpoints(): readonly VMCheckpoint[] {\n\t\treturn this.checkpoints;\n\t}\n\n\t/**\n\t * Look up a variable's value through the checkpoint chain.\n\t *\n\t * Walks the prototype chain starting from the most recent checkpoint,\n\t * looking for the variable name as an own property. This is O(depth)\n\t * where depth is the number of checkpoints since the variable was\n\t * last set.\n\t *\n\t * **Note:** This queries the checkpointer's snapshot, not the VM.\n\t * The VM may have been modified since the last snapshot (e.g., by\n\t * Tier 2 execution of non-variable-def lines that don't create checkpoints).\n\t *\n\t * @returns The Value, or undefined if the variable was never set.\n\t */\n\tlookupVariable(name: string): Value | undefined {\n\t\tif (this.checkpoints.length === 0) return undefined;\n\n\t\tlet checkpoint: VMCheckpoint | null = this.checkpoints[this.checkpoints.length - 1];\n\t\twhile (checkpoint) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(checkpoint.variables, name)) {\n\t\t\t\treturn checkpoint.variables[name];\n\t\t\t}\n\t\t\tcheckpoint = checkpoint.parent;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t// ── Lifecycle ────────────────────────────────────────────────────\n\n\t/**\n\t * Clear all checkpoints. The underlying VM is NOT reset, call\n\t * `vm.reset()` separately if needed.\n\t */\n\tclear(): void {\n\t\tthis.checkpoints = [];\n\t}\n\n\t/** Number of checkpoints stored. */\n\tget count(): number {\n\t\treturn this.checkpoints.length;\n\t}\n\n\t/** Returns true if no checkpoints have been created. */\n\tget isEmpty(): boolean {\n\t\treturn this.checkpoints.length === 0;\n\t}\n\n\t/** The associated VM instance. */\n\tget vmInstance(): VM {\n\t\treturn this.vm;\n\t}\n}\n"]}
|