solve-engine 2.38.13 → 2.38.14

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.
Files changed (63) hide show
  1. package/dist/{PackageCompatibility-Cu_bHpwY.d.cts → PackageCompatibility-ByCnkoxf.d.cts} +1 -1
  2. package/dist/{PackageCompatibility-BILTZSHP.d.ts → PackageCompatibility-WzScL1Av.d.ts} +1 -1
  3. package/dist/{PackageRegistry-DMKDsYiA.d.ts → PackageRegistry-11ThI3Qg.d.ts} +36 -1
  4. package/dist/{PackageRegistry-wZgm2zzk.d.cts → PackageRegistry-BN4zOado.d.cts} +36 -1
  5. package/dist/{VMBuiltins-D3rXBm2k.d.cts → VMBuiltins-5ATHQ045.d.cts} +203 -1
  6. package/dist/{VMBuiltins-Dd0KZR4G.d.ts → VMBuiltins-BbNZtVJc.d.ts} +203 -1
  7. package/dist/{chunk-CW623SJ7.cjs → chunk-54MEZ574.cjs} +2 -2
  8. package/dist/{chunk-CW623SJ7.cjs.map → chunk-54MEZ574.cjs.map} +1 -1
  9. package/dist/{chunk-PN6S4SW3.js → chunk-5M4F7PCU.js} +2 -2
  10. package/dist/{chunk-PN6S4SW3.js.map → chunk-5M4F7PCU.js.map} +1 -1
  11. package/dist/chunk-CH6NLOVG.js +2 -0
  12. package/dist/chunk-CH6NLOVG.js.map +1 -0
  13. package/dist/{chunk-3X2DR2QH.js → chunk-NGHH4QKV.js} +4 -4
  14. package/dist/chunk-NGHH4QKV.js.map +1 -0
  15. package/dist/chunk-OXZWX5WY.cjs +2 -0
  16. package/dist/chunk-OXZWX5WY.cjs.map +1 -0
  17. package/dist/chunk-UM5A6VXI.js +3 -0
  18. package/dist/chunk-UM5A6VXI.js.map +1 -0
  19. package/dist/{chunk-QCH4JXSZ.cjs → chunk-V52TAWYV.cjs} +4 -4
  20. package/dist/chunk-V52TAWYV.cjs.map +1 -0
  21. package/dist/chunk-VR35R5MV.cjs +3 -0
  22. package/dist/chunk-VR35R5MV.cjs.map +1 -0
  23. package/dist/constants.cjs +1 -1
  24. package/dist/constants.js +1 -1
  25. package/dist/engine.cjs +1 -1
  26. package/dist/engine.d.cts +4 -4
  27. package/dist/engine.d.ts +4 -4
  28. package/dist/engine.js +1 -1
  29. package/dist/engine.worker.cjs +1 -1
  30. package/dist/engine.worker.js +1 -1
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +4 -4
  34. package/dist/index.d.ts +4 -4
  35. package/dist/index.js +1 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/language.d.cts +3 -3
  38. package/dist/language.d.ts +3 -3
  39. package/dist/packages.d.cts +2 -2
  40. package/dist/packages.d.ts +2 -2
  41. package/dist/testing.cjs +2 -2
  42. package/dist/testing.d.cts +3 -3
  43. package/dist/testing.d.ts +3 -3
  44. package/dist/testing.js +1 -1
  45. package/dist/vm.cjs +1 -1
  46. package/dist/vm.cjs.map +1 -1
  47. package/dist/vm.d.cts +1 -2
  48. package/dist/vm.d.ts +1 -2
  49. package/dist/vm.js +1 -1
  50. package/dist/vm.js.map +1 -1
  51. package/dist/worker.cjs +2 -2
  52. package/dist/worker.d.cts +2 -2
  53. package/dist/worker.d.ts +2 -2
  54. package/dist/worker.js +1 -1
  55. package/package.json +1 -1
  56. package/dist/VMCheckpoints-BXavssWa.d.ts +0 -176
  57. package/dist/VMCheckpoints-BwLCnV8C.d.cts +0 -176
  58. package/dist/chunk-3X2DR2QH.js.map +0 -1
  59. package/dist/chunk-QCH4JXSZ.cjs.map +0 -1
  60. package/dist/chunk-SWONJJK3.js +0 -3
  61. package/dist/chunk-SWONJJK3.js.map +0 -1
  62. package/dist/chunk-WLY2OSWU.cjs +0 -3
  63. package/dist/chunk-WLY2OSWU.cjs.map +0 -1
@@ -1,176 +0,0 @@
1
- import { V as Value } from './Value-B55Hvn3e.cjs';
2
- import { V as VM } from './VMBuiltins-D3rXBm2k.cjs';
3
- import { U as UserFunctionDef } from './BytecodeBuilder-DSWKZi4f.cjs';
4
-
5
- /**
6
- * A point-in-time snapshot of VM variable state.
7
- *
8
- * Uses **prototypal inheritance** for memory efficiency: each checkpoint's
9
- * `variables` object has its parent checkpoint's `variables` as its
10
- * `__proto__`. This means a `getVar("x")` lookup walks the prototype chain
11
- * until it finds `x`, and only variables that CHANGED at this checkpoint
12
- * consume heap space. Unchanged variables are inherited from the parent.
13
- *
14
- * ```text
15
- * Checkpoint 0 (root): {} // empty scope
16
- * Checkpoint 1 (:x=5): { x: 5 } __proto__ → 0
17
- * Checkpoint 2 (:y=8): { y: 8 } __proto__ → 1
18
- * Checkpoint 3 (:x=3): { x: 3 } __proto__ → 2 // shadows x=5
19
- * ```
20
- *
21
- * To look up `x` at checkpoint 3: find own `x=3` → done.
22
- * To look up `y` at checkpoint 3: not own → walk proto to checkpoint 2 → `y=8`.
23
- * To look up `z` at checkpoint 3: not found anywhere → undefined.
24
- *
25
- * **Memory:** O(number of variable definitions) heap, independent of
26
- * document length. Typical Obsidian documents have < 100 variable defs,
27
- * so total checkpoint heap is < 10 KB.
28
- */
29
- interface VMCheckpoint {
30
- /** 1-based line number where this checkpoint was created. */
31
- lineNumber: number;
32
- /** Persistent line ID from DocumentModel. */
33
- lineId: number;
34
- /**
35
- * Variable name → Value at this checkpoint.
36
- * Own properties are variables set/updated at this line.
37
- * The prototype chain provides inherited variables from parent checkpoints.
38
- */
39
- variables: Record<string, Value>;
40
- /**
41
- * User-defined-function name → definition at this checkpoint. SEPARATE
42
- * from `variables` above (not prototypally chained the same way
43
- * `restoreTo()` replays every checkpoint in the chain in order, so a
44
- * later redefinition of the same function name naturally overwrites an
45
- * earlier one during replay, without needing its own prototype walk).
46
- *
47
- * Without this field, a function definition's checkpoint entry would be
48
- * SILENTLY LOST: `snapshot()` used to call `vm.getVar(name)` for every
49
- * written name, which returns `undefined` for a function name (function
50
- * defs live in `vm.userFunctions`, not the flat variable store), and a
51
- * `val !== undefined` guard silently skipped it. A scroll-triggered
52
- * `restoreTo()` would then reset the VM and replay only `variables`,
53
- * making a function defined above the new viewport vanish (calling it
54
- * would throw `UNDEFINED_FUNCTION`) even though the document still
55
- * shows its definition line as clean/cached.
56
- */
57
- functions: Record<string, UserFunctionDef>;
58
- /** Parent checkpoint (closer to document start), or null for root. */
59
- parent: VMCheckpoint | null;
60
- }
61
- /**
62
- * Manages VM state checkpoints for the three-tier evaluation strategy.
63
- *
64
- * **Checkpoint creation:** After a variable-definition line executes
65
- * (Tier 1 or Tier 3), `snapshot()` records the current values of the
66
- * written variables. The checkpoint is linked via prototypal inheritance
67
- * to the previous checkpoint, so only changed variables consume memory.
68
- *
69
- * **Checkpoint restoration:** Before evaluating a viewport whose start line
70
- * is not line 1, `restoreTo(lineNumber)` resets the VM and replays all
71
- * variable definitions up to and including that line. This avoids
72
- * re-evaluating the entire document from line 1 on every scroll.
73
- *
74
- * **Thread safety:** Checkpoints are created synchronously on the main
75
- * thread during evaluation. They are immutable after creation (Value is
76
- * an immutable type), so no synchronization is needed.
77
- *
78
- * **Integration with Phase 5.2e:** `setViewport()` will use `getNearestCheckpoint()`
79
- * to find the checkpoint just before the new viewport start, then call
80
- * `restoreTo()` to set up the VM before evaluating only the visible lines.
81
- * This is the key to O(visible lines) scrolling instead of O(document).
82
- */
83
- declare class VMCheckpointer {
84
- /** Ordered array of checkpoints (ascending lineNumber). */
85
- private checkpoints;
86
- /** The VM instance whose variables are snapshotted/restored. */
87
- private vm;
88
- constructor(vm: VM);
89
- /**
90
- * Create a checkpoint at the current line, recording the VM values of
91
- * the specified variables.
92
- *
93
- * Uses prototypal inheritance: `Object.create(parent.variables)` so
94
- * that inherited variable lookups fall through to previous checkpoints
95
- * without copying all variables into each checkpoint.
96
- *
97
- * A line that is snapshotted again drops every checkpoint at or after it
98
- * first, so the list stays in document order and the new checkpoint
99
- * inherits from the line before it rather than from one after it. See the
100
- * body for what went wrong without that.
101
- *
102
- * @param lineNumber 1-based line position.
103
- * @param lineId Persistent line ID from DocumentModel.
104
- * @param variableNames Names of variables that were written at this line.
105
- * @returns The new checkpoint, or null if no variable names provided.
106
- */
107
- snapshot(lineNumber: number, lineId: number, variableNames: string[]): VMCheckpoint | null;
108
- /**
109
- * Restore the VM to the state at or just after the given line number.
110
- *
111
- * Finds the nearest checkpoint whose `lineNumber <= targetLineNumber`,
112
- * then replays all variable definitions from root → that checkpoint
113
- * into the VM via `setVar()`. The VM's stack is also reset.
114
- *
115
- * If no checkpoint exists at or before the target line, the VM is
116
- * fully reset (empty scope, empty stack).
117
- *
118
- * **Performance:** O(number of checkpoints × variables per checkpoint).
119
- * With prototypal inheritance, `Object.keys()` on each checkpoint
120
- * returns only the variables that were set at that checkpoint (not
121
- * inherited ones), so the total work is O(total variable definitions
122
- * in the document), which is < 100 for typical Obsidian documents.
123
- *
124
- * @param lineNumber Target 1-based line number. The VM will have the
125
- * state that existed AFTER evaluating lines up to `lineNumber`.
126
- */
127
- restoreTo(lineNumber: number): void;
128
- /**
129
- * Find the nearest checkpoint at or before the given line number.
130
- *
131
- * Uses linear scan (checkpoints are sorted by lineNumber and the list
132
- * is short, typically < 20 for Obsidian documents). Can be upgraded
133
- * to binary search if needed for documents with 1000+ variable defs.
134
- *
135
- * @returns The nearest checkpoint, or null if none exists before the line.
136
- */
137
- getNearestCheckpoint(lineNumber: number): VMCheckpoint | null;
138
- /**
139
- * Get a specific checkpoint by its line number.
140
- * @returns The checkpoint, or undefined if not found.
141
- */
142
- getCheckpointAt(lineNumber: number): VMCheckpoint | undefined;
143
- /**
144
- * Get the entire checkpoint chain from root to the last checkpoint.
145
- * Useful for debugging and serialization.
146
- */
147
- getAllCheckpoints(): readonly VMCheckpoint[];
148
- /**
149
- * Look up a variable's value through the checkpoint chain.
150
- *
151
- * Walks the prototype chain starting from the most recent checkpoint,
152
- * looking for the variable name as an own property. This is O(depth)
153
- * where depth is the number of checkpoints since the variable was
154
- * last set.
155
- *
156
- * **Note:** This queries the checkpointer's snapshot, not the VM.
157
- * The VM may have been modified since the last snapshot (e.g., by
158
- * Tier 2 execution of non-variable-def lines that don't create checkpoints).
159
- *
160
- * @returns The Value, or undefined if the variable was never set.
161
- */
162
- lookupVariable(name: string): Value | undefined;
163
- /**
164
- * Clear all checkpoints. The underlying VM is NOT reset, call
165
- * `vm.reset()` separately if needed.
166
- */
167
- clear(): void;
168
- /** Number of checkpoints stored. */
169
- get count(): number;
170
- /** Returns true if no checkpoints have been created. */
171
- get isEmpty(): boolean;
172
- /** The associated VM instance. */
173
- get vmInstance(): VM;
174
- }
175
-
176
- export { type VMCheckpoint as V, VMCheckpointer as a };