solve-engine 1.0.0-beta.0 → 1.0.0-beta.2

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 (253) hide show
  1. package/dist/BytecodeBuilder-3egMyuDi.d.cts +274 -0
  2. package/dist/BytecodeBuilder-3egMyuDi.d.ts +274 -0
  3. package/dist/Configuration-fVpd-HC-.d.cts +228 -0
  4. package/dist/Configuration-fVpd-HC-.d.ts +228 -0
  5. package/dist/EngineError-DvPSnhZi.d.cts +304 -0
  6. package/dist/EngineError-DvPSnhZi.d.ts +304 -0
  7. package/dist/Lexer-BJdhlnej.d.cts +531 -0
  8. package/dist/Lexer-D9l4Yrk2.d.ts +531 -0
  9. package/dist/NormalizerRule-BrVoVjmP.d.cts +163 -0
  10. package/dist/NormalizerRule-CEjf1FyD.d.ts +163 -0
  11. package/dist/PackageRegistry-D-Tv_7ca.d.cts +2572 -0
  12. package/dist/PackageRegistry-DaH4aIKP.d.ts +2572 -0
  13. package/dist/Parselet-CK8cQu2a.d.cts +299 -0
  14. package/dist/Parselet-ConOIdRO.d.ts +299 -0
  15. package/dist/ScopeManager-B5k0nk05.d.ts +559 -0
  16. package/dist/ScopeManager-CKfQtl7l.d.cts +559 -0
  17. package/dist/Token-0jpvUdPY.d.cts +245 -0
  18. package/dist/Token-0jpvUdPY.d.ts +245 -0
  19. package/dist/VMCheckpoints-BmDwIXgK.d.ts +171 -0
  20. package/dist/VMCheckpoints-CqFuLwrT.d.cts +171 -0
  21. package/dist/Value-KtAQNHur.d.cts +295 -0
  22. package/dist/Value-KtAQNHur.d.ts +295 -0
  23. package/dist/chunk-2RWAXT6O.js +3 -0
  24. package/dist/chunk-2RWAXT6O.js.map +1 -0
  25. package/dist/chunk-34RRD7PC.js +1492 -0
  26. package/dist/chunk-34RRD7PC.js.map +1 -0
  27. package/dist/chunk-3PPFLFH4.js +5097 -0
  28. package/dist/chunk-3PPFLFH4.js.map +1 -0
  29. package/dist/chunk-3VGDNEE3.js +84 -0
  30. package/dist/chunk-3VGDNEE3.js.map +1 -0
  31. package/dist/chunk-3YNVWKR2.cjs +370 -0
  32. package/dist/chunk-3YNVWKR2.cjs.map +1 -0
  33. package/dist/chunk-47LRVGOT.cjs +316 -0
  34. package/dist/chunk-47LRVGOT.cjs.map +1 -0
  35. package/dist/chunk-4MG4XKO2.js +1644 -0
  36. package/dist/chunk-4MG4XKO2.js.map +1 -0
  37. package/dist/chunk-4QADQTWS.js +2392 -0
  38. package/dist/chunk-4QADQTWS.js.map +1 -0
  39. package/dist/chunk-53B6KDDJ.cjs +1651 -0
  40. package/dist/chunk-53B6KDDJ.cjs.map +1 -0
  41. package/dist/chunk-5X2PTP6F.cjs +104 -0
  42. package/dist/chunk-5X2PTP6F.cjs.map +1 -0
  43. package/dist/chunk-5YEMOYSE.js +264 -0
  44. package/dist/chunk-5YEMOYSE.js.map +1 -0
  45. package/dist/chunk-64W6GLLZ.js +481 -0
  46. package/dist/chunk-64W6GLLZ.js.map +1 -0
  47. package/dist/chunk-6BKTCEUP.cjs +233 -0
  48. package/dist/chunk-6BKTCEUP.cjs.map +1 -0
  49. package/dist/chunk-6NTVRDQV.cjs +1642 -0
  50. package/dist/chunk-6NTVRDQV.cjs.map +1 -0
  51. package/dist/chunk-6RDSQURE.js +290 -0
  52. package/dist/chunk-6RDSQURE.js.map +1 -0
  53. package/dist/chunk-75JP4BZX.js +93 -0
  54. package/dist/chunk-75JP4BZX.js.map +1 -0
  55. package/dist/chunk-B7LXJ6LC.cjs +36 -0
  56. package/dist/chunk-B7LXJ6LC.cjs.map +1 -0
  57. package/dist/chunk-BVAR5J2F.js +257 -0
  58. package/dist/chunk-BVAR5J2F.js.map +1 -0
  59. package/dist/chunk-C4XZV6E7.cjs +269 -0
  60. package/dist/chunk-C4XZV6E7.cjs.map +1 -0
  61. package/dist/chunk-CCJPSHGI.cjs +40 -0
  62. package/dist/chunk-CCJPSHGI.cjs.map +1 -0
  63. package/dist/chunk-CLL7RUQV.cjs +316 -0
  64. package/dist/chunk-CLL7RUQV.cjs.map +1 -0
  65. package/dist/chunk-DM3LMRBC.js +329 -0
  66. package/dist/chunk-DM3LMRBC.js.map +1 -0
  67. package/dist/chunk-DUEZFTK2.js +38 -0
  68. package/dist/chunk-DUEZFTK2.js.map +1 -0
  69. package/dist/chunk-EBSPLUW4.cjs +489 -0
  70. package/dist/chunk-EBSPLUW4.cjs.map +1 -0
  71. package/dist/chunk-EHAHVROS.cjs +261 -0
  72. package/dist/chunk-EHAHVROS.cjs.map +1 -0
  73. package/dist/chunk-EIGTWK5N.js +167 -0
  74. package/dist/chunk-EIGTWK5N.js.map +1 -0
  75. package/dist/chunk-EPOXXJBK.js +96 -0
  76. package/dist/chunk-EPOXXJBK.js.map +1 -0
  77. package/dist/chunk-FEAIOR7N.cjs +91 -0
  78. package/dist/chunk-FEAIOR7N.cjs.map +1 -0
  79. package/dist/chunk-G535KJEG.js +312 -0
  80. package/dist/chunk-G535KJEG.js.map +1 -0
  81. package/dist/chunk-GCM5JHMX.js +88 -0
  82. package/dist/chunk-GCM5JHMX.js.map +1 -0
  83. package/dist/chunk-GOLDJNMZ.js +368 -0
  84. package/dist/chunk-GOLDJNMZ.js.map +1 -0
  85. package/dist/chunk-GW32KPCU.cjs +360 -0
  86. package/dist/chunk-GW32KPCU.cjs.map +1 -0
  87. package/dist/chunk-HTXVVJRA.cjs +1549 -0
  88. package/dist/chunk-HTXVVJRA.cjs.map +1 -0
  89. package/dist/chunk-HWSZJQCI.js +311 -0
  90. package/dist/chunk-HWSZJQCI.js.map +1 -0
  91. package/dist/chunk-IF532O7C.js +101 -0
  92. package/dist/chunk-IF532O7C.js.map +1 -0
  93. package/dist/chunk-J73SJHR3.cjs +2415 -0
  94. package/dist/chunk-J73SJHR3.cjs.map +1 -0
  95. package/dist/chunk-JBSYC7BB.cjs +7473 -0
  96. package/dist/chunk-JBSYC7BB.cjs.map +1 -0
  97. package/dist/chunk-KVILKGMS.js +228 -0
  98. package/dist/chunk-KVILKGMS.js.map +1 -0
  99. package/dist/chunk-LIPPNDBE.js +258 -0
  100. package/dist/chunk-LIPPNDBE.js.map +1 -0
  101. package/dist/chunk-LR7YASZF.cjs +172 -0
  102. package/dist/chunk-LR7YASZF.cjs.map +1 -0
  103. package/dist/chunk-M4N5GA5Z.cjs +309 -0
  104. package/dist/chunk-M4N5GA5Z.cjs.map +1 -0
  105. package/dist/chunk-M5LX5AOO.js +7459 -0
  106. package/dist/chunk-M5LX5AOO.js.map +1 -0
  107. package/dist/chunk-MZOVP3WI.cjs +96 -0
  108. package/dist/chunk-MZOVP3WI.cjs.map +1 -0
  109. package/dist/chunk-N5YFR4UP.cjs +10 -0
  110. package/dist/chunk-N5YFR4UP.cjs.map +1 -0
  111. package/dist/chunk-NGBBNL4K.cjs +4 -0
  112. package/dist/chunk-NGBBNL4K.cjs.map +1 -0
  113. package/dist/chunk-NH2O2AUR.js +146 -0
  114. package/dist/chunk-NH2O2AUR.js.map +1 -0
  115. package/dist/chunk-NLNDMWZC.js +31 -0
  116. package/dist/chunk-NLNDMWZC.js.map +1 -0
  117. package/dist/chunk-NMCRQP3Z.cjs +778 -0
  118. package/dist/chunk-NMCRQP3Z.cjs.map +1 -0
  119. package/dist/chunk-NMD5VRN4.cjs +1327 -0
  120. package/dist/chunk-NMD5VRN4.cjs.map +1 -0
  121. package/dist/chunk-OC6LTXYS.cjs +286 -0
  122. package/dist/chunk-OC6LTXYS.cjs.map +1 -0
  123. package/dist/chunk-OT6OJY7C.cjs +114 -0
  124. package/dist/chunk-OT6OJY7C.cjs.map +1 -0
  125. package/dist/chunk-PFSDGGYL.js +8 -0
  126. package/dist/chunk-PFSDGGYL.js.map +1 -0
  127. package/dist/chunk-QNJ4ACRT.cjs +155 -0
  128. package/dist/chunk-QNJ4ACRT.cjs.map +1 -0
  129. package/dist/chunk-QWY3VEZN.js +1637 -0
  130. package/dist/chunk-QWY3VEZN.js.map +1 -0
  131. package/dist/chunk-RFYD5TJE.js +111 -0
  132. package/dist/chunk-RFYD5TJE.js.map +1 -0
  133. package/dist/chunk-RIN643A3.js +354 -0
  134. package/dist/chunk-RIN643A3.js.map +1 -0
  135. package/dist/chunk-RZCWSXTA.cjs +5122 -0
  136. package/dist/chunk-RZCWSXTA.cjs.map +1 -0
  137. package/dist/chunk-SDGRK7EP.js +774 -0
  138. package/dist/chunk-SDGRK7EP.js.map +1 -0
  139. package/dist/chunk-VEKIWQ3F.cjs +39 -0
  140. package/dist/chunk-VEKIWQ3F.cjs.map +1 -0
  141. package/dist/chunk-WQTTOGXC.cjs +99 -0
  142. package/dist/chunk-WQTTOGXC.cjs.map +1 -0
  143. package/dist/chunk-X6K3HUOY.cjs +86 -0
  144. package/dist/chunk-X6K3HUOY.cjs.map +1 -0
  145. package/dist/chunk-XJCMXB2E.cjs +333 -0
  146. package/dist/chunk-XJCMXB2E.cjs.map +1 -0
  147. package/dist/chunk-XVWCOTR6.js +1324 -0
  148. package/dist/chunk-XVWCOTR6.js.map +1 -0
  149. package/dist/chunk-YLJ4XMA6.js +33 -0
  150. package/dist/chunk-YLJ4XMA6.js.map +1 -0
  151. package/dist/chunk-Z2XP767T.cjs +35 -0
  152. package/dist/chunk-Z2XP767T.cjs.map +1 -0
  153. package/dist/chunk-Z4X2RWOF.js +37 -0
  154. package/dist/chunk-Z4X2RWOF.js.map +1 -0
  155. package/dist/constants.cjs +22 -0
  156. package/dist/constants.cjs.map +1 -0
  157. package/dist/constants.d.cts +12 -0
  158. package/dist/constants.d.ts +12 -0
  159. package/dist/constants.js +5 -0
  160. package/dist/constants.js.map +1 -0
  161. package/dist/engine.cjs +79 -0
  162. package/dist/engine.cjs.map +1 -0
  163. package/dist/engine.d.cts +587 -0
  164. package/dist/engine.d.ts +587 -0
  165. package/dist/engine.js +34 -0
  166. package/dist/engine.js.map +1 -0
  167. package/dist/errors.cjs +81 -0
  168. package/dist/errors.cjs.map +1 -0
  169. package/dist/errors.d.cts +95 -0
  170. package/dist/errors.d.ts +95 -0
  171. package/dist/errors.js +4 -0
  172. package/dist/errors.js.map +1 -0
  173. package/dist/format.cjs +171 -0
  174. package/dist/format.cjs.map +1 -0
  175. package/dist/format.d.cts +51 -0
  176. package/dist/format.d.ts +51 -0
  177. package/dist/format.js +168 -0
  178. package/dist/format.js.map +1 -0
  179. package/dist/index.cjs +97 -0
  180. package/dist/index.cjs.map +1 -0
  181. package/dist/index.d.cts +152 -0
  182. package/dist/index.d.ts +152 -0
  183. package/dist/index.js +75 -0
  184. package/dist/index.js.map +1 -0
  185. package/dist/language.cjs +308 -0
  186. package/dist/language.cjs.map +1 -0
  187. package/dist/language.d.cts +110 -0
  188. package/dist/language.d.ts +110 -0
  189. package/dist/language.js +287 -0
  190. package/dist/language.js.map +1 -0
  191. package/dist/lexer.cjs +64 -0
  192. package/dist/lexer.cjs.map +1 -0
  193. package/dist/lexer.d.cts +56 -0
  194. package/dist/lexer.d.ts +56 -0
  195. package/dist/lexer.js +11 -0
  196. package/dist/lexer.js.map +1 -0
  197. package/dist/normalizer.cjs +40 -0
  198. package/dist/normalizer.cjs.map +1 -0
  199. package/dist/normalizer.d.cts +364 -0
  200. package/dist/normalizer.d.ts +364 -0
  201. package/dist/normalizer.js +11 -0
  202. package/dist/normalizer.js.map +1 -0
  203. package/dist/packages.cjs +121 -0
  204. package/dist/packages.cjs.map +1 -0
  205. package/dist/packages.d.cts +691 -0
  206. package/dist/packages.d.ts +691 -0
  207. package/dist/packages.js +24 -0
  208. package/dist/packages.js.map +1 -0
  209. package/dist/parser.cjs +55 -0
  210. package/dist/parser.cjs.map +1 -0
  211. package/dist/parser.d.cts +46 -0
  212. package/dist/parser.d.ts +46 -0
  213. package/dist/parser.js +10 -0
  214. package/dist/parser.js.map +1 -0
  215. package/dist/pipeline-CrsRPmsv.d.ts +285 -0
  216. package/dist/pipeline-DPUQt7yL.d.cts +285 -0
  217. package/dist/resolvers.cjs +13 -0
  218. package/dist/resolvers.cjs.map +1 -0
  219. package/dist/resolvers.d.cts +111 -0
  220. package/dist/resolvers.d.ts +111 -0
  221. package/dist/resolvers.js +4 -0
  222. package/dist/resolvers.js.map +1 -0
  223. package/dist/services.cjs +21 -0
  224. package/dist/services.cjs.map +1 -0
  225. package/dist/services.d.cts +30 -0
  226. package/dist/services.d.ts +30 -0
  227. package/dist/services.js +4 -0
  228. package/dist/services.js.map +1 -0
  229. package/dist/uom.cjs +56 -0
  230. package/dist/uom.cjs.map +1 -0
  231. package/dist/uom.d.cts +224 -0
  232. package/dist/uom.d.ts +224 -0
  233. package/dist/uom.js +11 -0
  234. package/dist/uom.js.map +1 -0
  235. package/dist/utilities.cjs +32 -0
  236. package/dist/utilities.cjs.map +1 -0
  237. package/dist/utilities.d.cts +113 -0
  238. package/dist/utilities.d.ts +113 -0
  239. package/dist/utilities.js +7 -0
  240. package/dist/utilities.js.map +1 -0
  241. package/dist/variables.cjs +17 -0
  242. package/dist/variables.cjs.map +1 -0
  243. package/dist/variables.d.cts +87 -0
  244. package/dist/variables.d.ts +87 -0
  245. package/dist/variables.js +4 -0
  246. package/dist/variables.js.map +1 -0
  247. package/dist/vm.cjs +284 -0
  248. package/dist/vm.cjs.map +1 -0
  249. package/dist/vm.d.cts +68 -0
  250. package/dist/vm.d.ts +68 -0
  251. package/dist/vm.js +194 -0
  252. package/dist/vm.js.map +1 -0
  253. package/package.json +4 -4
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Lexer token produced by {@link ExpressionLexer} and consumed by parsers.
3
+ *
4
+ * Each token carries:
5
+ * - `type`: string name (e.g. "NUMBER", "PLUS") for diagnostics and parselet lookup
6
+ * - `typeId`: integer ID for O(1) comparison in parser hot paths
7
+ * - `value`/`text`: the token's semantic value and raw source text
8
+ * - `offset`/`line`/`col`: source position for error messages and highlighting
9
+ */
10
+ interface Token {
11
+ /** String token type (e.g., "NUMBER", "PLUS", "IDENT"). Used by ParseletRegistry string-keyed maps and error messages. */
12
+ type: string;
13
+ /** Integer token type ID for fast comparison in Parser hot path.
14
+ * Populated by the Lexer via registerTokenType(). Use tokenTypeId(type) to get a type's ID. */
15
+ typeId: number;
16
+ value: string;
17
+ text: string;
18
+ offset: number;
19
+ lineBreaks: number;
20
+ line: number;
21
+ col: number;
22
+ }
23
+ /**
24
+ * Canonical token type name constants.
25
+ * All token types used by the lexer, parser, and VM are defined here.
26
+ * Custom/plugin token types should be registered via {@link registerTokenType}.
27
+ */
28
+ declare const TokenTypes: {
29
+ readonly NUMBER: "NUMBER";
30
+ readonly BIGINT: "BIGINT";
31
+ readonly STRING: "STRING";
32
+ readonly IDENT: "IDENT";
33
+ readonly PLUS: "PLUS";
34
+ readonly MINUS: "MINUS";
35
+ readonly STAR: "STAR";
36
+ readonly SLASH: "SLASH";
37
+ readonly CARET: "CARET";
38
+ readonly PERCENT: "PERCENT";
39
+ readonly LSHIFT: "LSHIFT";
40
+ readonly RSHIFT: "RSHIFT";
41
+ readonly URSHIFT: "URSHIFT";
42
+ readonly LPAREN: "LPAREN";
43
+ readonly RPAREN: "RPAREN";
44
+ readonly LBRACKET: "LBRACKET";
45
+ readonly RBRACKET: "RBRACKET";
46
+ readonly LBRACE: "LBRACE";
47
+ readonly RBRACE: "RBRACE";
48
+ readonly COMMA: "COMMA";
49
+ readonly DOT: "DOT";
50
+ readonly COLON: "COLON";
51
+ readonly SEMICOLON: "SEMICOLON";
52
+ readonly EQUALS: "EQUALS";
53
+ readonly DOLLAR: "DOLLAR";
54
+ readonly POUND: "POUND";
55
+ readonly EURO: "EURO";
56
+ readonly YEN: "YEN";
57
+ readonly RUBLE: "RUBLE";
58
+ readonly WON: "WON";
59
+ readonly QUESTION: "QUESTION";
60
+ readonly BANG: "BANG";
61
+ readonly BIT_AND: "BIT_AND";
62
+ readonly BIT_OR: "BIT_OR";
63
+ readonly BIT_NOT: "BIT_NOT";
64
+ readonly KEYWORD: "KEYWORD";
65
+ readonly EOF: "EOF";
66
+ readonly ERROR: "ERROR";
67
+ readonly WS: "WS";
68
+ readonly NEWLINE: "NEWLINE";
69
+ readonly DATETIME_LITERAL: "DATETIME_LITERAL";
70
+ readonly DURATION: "DURATION";
71
+ readonly UNIT: "UNIT";
72
+ readonly ROLL: "ROLL";
73
+ readonly PI: "PI";
74
+ readonly E: "E";
75
+ readonly MOD: "MOD";
76
+ readonly OF: "OF";
77
+ readonly INCREASE_BY: "INCREASE_BY";
78
+ readonly DECREASE_BY: "DECREASE_BY";
79
+ readonly OF_WHAT_IS: "OF_WHAT_IS";
80
+ readonly ON_WHAT_IS: "ON_WHAT_IS";
81
+ readonly OFF_WHAT_IS: "OFF_WHAT_IS";
82
+ readonly NOW: "NOW";
83
+ readonly TODAY: "TODAY";
84
+ readonly TOMORROW: "TOMORROW";
85
+ readonly YESTERDAY: "YESTERDAY";
86
+ readonly DURATION_DAY: "DURATION_DAY";
87
+ readonly DURATION_WEEK: "DURATION_WEEK";
88
+ readonly DURATION_MONTH: "DURATION_MONTH";
89
+ readonly DURATION_YEAR: "DURATION_YEAR";
90
+ readonly DURATION_HOUR: "DURATION_HOUR";
91
+ readonly DURATION_MINUTE: "DURATION_MINUTE";
92
+ readonly DURATION_SECOND: "DURATION_SECOND";
93
+ readonly FUNC: "FUNC";
94
+ readonly CONVERT: "CONVERT";
95
+ readonly TO: "TO";
96
+ readonly BEST: "BEST";
97
+ readonly NEXT: "NEXT";
98
+ readonly LAST: "LAST";
99
+ readonly UNTIL: "UNTIL";
100
+ readonly SINCE: "SINCE";
101
+ readonly BETWEEN: "BETWEEN";
102
+ readonly FROM: "FROM";
103
+ readonly INCREASE: "INCREASE";
104
+ readonly DECREASE: "DECREASE";
105
+ readonly UNICODE_MATH: "UNICODE_MATH";
106
+ readonly TIMES_BY: "TIMES_BY";
107
+ readonly MULTIPLY_BY: "MULTIPLY_BY";
108
+ readonly DIVIDE_BY: "DIVIDE_BY";
109
+ readonly NEQ: "NEQ";
110
+ readonly IN: "IN";
111
+ readonly BIT_XOR: "BIT_XOR";
112
+ readonly EQUALITY: "EQUALITY";
113
+ readonly GTE: "GTE";
114
+ readonly LTE: "LTE";
115
+ readonly LT: "LT";
116
+ readonly GT: "GT";
117
+ readonly LOGICAL_AND: "LOGICAL_AND";
118
+ readonly LOGICAL_OR: "LOGICAL_OR";
119
+ readonly OR: "OR";
120
+ readonly TRUE: "TRUE";
121
+ readonly FALSE: "FALSE";
122
+ readonly IF: "IF";
123
+ readonly THEN: "THEN";
124
+ readonly ELSE: "ELSE";
125
+ readonly AS: "AS";
126
+ readonly CONVERTER_NAME: "CONVERTER_NAME";
127
+ readonly AVERAGE_OF: "AVERAGE_OF";
128
+ readonly MEDIAN_OF: "MEDIAN_OF";
129
+ readonly TOTAL_OF: "TOTAL_OF";
130
+ readonly COUNT_OF: "COUNT_OF";
131
+ readonly LARGER_OF: "LARGER_OF";
132
+ readonly SMALLER_OF: "SMALLER_OF";
133
+ readonly HALF_OF: "HALF_OF";
134
+ readonly MIDPOINT_BETWEEN: "MIDPOINT_BETWEEN";
135
+ readonly RANDOM_NUMBER: "RANDOM_NUMBER";
136
+ readonly IS_TO: "IS_TO";
137
+ readonly CLAMP: "CLAMP";
138
+ readonly MAP: "MAP";
139
+ readonly REDUCE: "REDUCE";
140
+ readonly SUM_FN: "SUM_FN";
141
+ readonly PROD_FN: "PROD_FN";
142
+ readonly EXPAND_FN: "EXPAND_FN";
143
+ readonly FACTOR_FN: "FACTOR_FN";
144
+ readonly SOLVE_FN: "SOLVE_FN";
145
+ readonly DER_FN: "DER_FN";
146
+ readonly INTEGRAL_FN: "INTEGRAL_FN";
147
+ readonly TAYLOR_FN: "TAYLOR_FN";
148
+ readonly JACOBIAN_FN: "JACOBIAN_FN";
149
+ readonly CONJ_FN: "CONJ_FN";
150
+ readonly RE_FN: "RE_FN";
151
+ readonly IM_FN: "IM_FN";
152
+ readonly CANCEL_FN: "CANCEL_FN";
153
+ readonly APART_FN: "APART_FN";
154
+ readonly IMAGINARY: "IMAGINARY";
155
+ readonly THEREFORE: "THEREFORE";
156
+ readonly TIME_IN: "TIME_IN";
157
+ readonly DATE_IN: "DATE_IN";
158
+ readonly TIME_DIFFERENCE_BETWEEN: "TIME_DIFFERENCE_BETWEEN";
159
+ readonly CITY_NAME: "CITY_NAME";
160
+ readonly BACKTICK_OPEN: "BACKTICK_OPEN";
161
+ readonly INLINE_SOLVE_START: "INLINE_SOLVE_START";
162
+ readonly COMMENT: "COMMENT";
163
+ readonly VEC2: "VEC2";
164
+ readonly VEC3: "VEC3";
165
+ readonly VEC4: "VEC4";
166
+ readonly FLOAT: "FLOAT";
167
+ readonly GLOBAL: "GLOBAL";
168
+ readonly OVER: "OVER";
169
+ readonly RATE_AT: "RATE_AT";
170
+ readonly COMPOUND_INTEREST_ON: "COMPOUND_INTEREST_ON";
171
+ readonly INTEREST_ON: "INTEREST_ON";
172
+ readonly DAILY_REPAYMENT_ON: "DAILY_REPAYMENT_ON";
173
+ readonly MONTHLY_REPAYMENT_ON: "MONTHLY_REPAYMENT_ON";
174
+ readonly ANNUAL_REPAYMENT_ON: "ANNUAL_REPAYMENT_ON";
175
+ readonly TOTAL_REPAYMENT_ON: "TOTAL_REPAYMENT_ON";
176
+ readonly DAILY_LOAN_INTEREST_ON: "DAILY_LOAN_INTEREST_ON";
177
+ readonly MONTHLY_LOAN_INTEREST_ON: "MONTHLY_LOAN_INTEREST_ON";
178
+ readonly ANNUAL_LOAN_INTEREST_ON: "ANNUAL_LOAN_INTEREST_ON";
179
+ readonly TOTAL_LOAN_INTEREST_ON: "TOTAL_LOAN_INTEREST_ON";
180
+ readonly TAX_ON: "TAX_ON";
181
+ readonly TAX_OFF: "TAX_OFF";
182
+ readonly WHAT_IS: "WHAT_IS";
183
+ readonly WHAT_WAS: "WHAT_WAS";
184
+ readonly VALUE_OF: "VALUE_OF";
185
+ readonly WORTH_IN: "WORTH_IN";
186
+ readonly ASSUMING: "ASSUMING";
187
+ readonly IN_YEAR_DOLLARS: "IN_YEAR_DOLLARS";
188
+ readonly INGREDIENT_NAME: "INGREDIENT_NAME";
189
+ readonly WORKDAYS_IN: "WORKDAYS_IN";
190
+ readonly WEEKDAY_ON: "WEEKDAY_ON";
191
+ readonly CURRENT_TIMESTAMP: "CURRENT_TIMESTAMP";
192
+ readonly TO_DATE: "TO_DATE";
193
+ readonly TO_TIMESTAMP: "TO_TIMESTAMP";
194
+ readonly WEEKDAY_IN: "WEEKDAY_IN";
195
+ readonly MONTH_ON: "MONTH_ON";
196
+ readonly MONTH_IN: "MONTH_IN";
197
+ readonly WEEK_ON: "WEEK_ON";
198
+ readonly WEEK_IN: "WEEK_IN";
199
+ readonly BETWEEN_UNIT: "BETWEEN_UNIT";
200
+ readonly IS_WEEKEND: "IS_WEEKEND";
201
+ readonly IS_WORKDAY: "IS_WORKDAY";
202
+ readonly VIDEO_TIMECODE: "VIDEO_TIMECODE";
203
+ readonly FRAME_COUNT: "FRAME_COUNT";
204
+ readonly AT: "AT";
205
+ readonly CURRENCY_SYMBOL: "CURRENCY_SYMBOL";
206
+ readonly PREV: "PREV";
207
+ readonly LINE_REF: "LINE_REF";
208
+ readonly SUM_RANGE_CALL: "SUM_RANGE_CALL";
209
+ readonly AVERAGE_RANGE_CALL: "AVERAGE_RANGE_CALL";
210
+ readonly TOTAL_ABOVE: "TOTAL_ABOVE";
211
+ readonly SUM_ABOVE: "SUM_ABOVE";
212
+ readonly AVERAGE_ABOVE: "AVERAGE_ABOVE";
213
+ };
214
+ /**
215
+ * A token's kind, as a string.
216
+ *
217
+ * Deliberately open rather than an enum: a package registers its own token
218
+ * types at runtime, and a closed set would make that impossible.
219
+ */
220
+ type TokenType = (typeof TokenTypes)[keyof typeof TokenTypes];
221
+ /**
222
+ * Register a token type name and get back its integer ID.
223
+ * Idempotent, returns existing ID if already registered.
224
+ * Call once per token type at module initialization time.
225
+ */
226
+ declare function registerTokenType(name: string): number;
227
+ /**
228
+ * Get the integer ID for a token type name.
229
+ * Lazily registers unknown token types on first access, enabling plugin providers
230
+ * to define custom token types (VEC2, VEC3, etc.) without pre-registration.
231
+ * All built-in TokenTypes are pre-registered via registerAllTokenTypes().
232
+ */
233
+ declare function tokenTypeId(name: string): number;
234
+ /**
235
+ * Get the string name for a token type ID (for error messages and debugging).
236
+ * Returns `UNKNOWN_${id}` if the ID is not registered.
237
+ */
238
+ declare function tokenTypeName(id: number): string;
239
+ /**
240
+ * Bootstrap all known token types from TokenTypes at module load.
241
+ * Call this once after TokenTypes is defined.
242
+ */
243
+ declare function registerAllTokenTypes(): void;
244
+
245
+ export { type Token as T, type TokenType as a, TokenTypes as b, registerTokenType as c, tokenTypeName as d, registerAllTokenTypes as r, tokenTypeId as t };
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Lexer token produced by {@link ExpressionLexer} and consumed by parsers.
3
+ *
4
+ * Each token carries:
5
+ * - `type`: string name (e.g. "NUMBER", "PLUS") for diagnostics and parselet lookup
6
+ * - `typeId`: integer ID for O(1) comparison in parser hot paths
7
+ * - `value`/`text`: the token's semantic value and raw source text
8
+ * - `offset`/`line`/`col`: source position for error messages and highlighting
9
+ */
10
+ interface Token {
11
+ /** String token type (e.g., "NUMBER", "PLUS", "IDENT"). Used by ParseletRegistry string-keyed maps and error messages. */
12
+ type: string;
13
+ /** Integer token type ID for fast comparison in Parser hot path.
14
+ * Populated by the Lexer via registerTokenType(). Use tokenTypeId(type) to get a type's ID. */
15
+ typeId: number;
16
+ value: string;
17
+ text: string;
18
+ offset: number;
19
+ lineBreaks: number;
20
+ line: number;
21
+ col: number;
22
+ }
23
+ /**
24
+ * Canonical token type name constants.
25
+ * All token types used by the lexer, parser, and VM are defined here.
26
+ * Custom/plugin token types should be registered via {@link registerTokenType}.
27
+ */
28
+ declare const TokenTypes: {
29
+ readonly NUMBER: "NUMBER";
30
+ readonly BIGINT: "BIGINT";
31
+ readonly STRING: "STRING";
32
+ readonly IDENT: "IDENT";
33
+ readonly PLUS: "PLUS";
34
+ readonly MINUS: "MINUS";
35
+ readonly STAR: "STAR";
36
+ readonly SLASH: "SLASH";
37
+ readonly CARET: "CARET";
38
+ readonly PERCENT: "PERCENT";
39
+ readonly LSHIFT: "LSHIFT";
40
+ readonly RSHIFT: "RSHIFT";
41
+ readonly URSHIFT: "URSHIFT";
42
+ readonly LPAREN: "LPAREN";
43
+ readonly RPAREN: "RPAREN";
44
+ readonly LBRACKET: "LBRACKET";
45
+ readonly RBRACKET: "RBRACKET";
46
+ readonly LBRACE: "LBRACE";
47
+ readonly RBRACE: "RBRACE";
48
+ readonly COMMA: "COMMA";
49
+ readonly DOT: "DOT";
50
+ readonly COLON: "COLON";
51
+ readonly SEMICOLON: "SEMICOLON";
52
+ readonly EQUALS: "EQUALS";
53
+ readonly DOLLAR: "DOLLAR";
54
+ readonly POUND: "POUND";
55
+ readonly EURO: "EURO";
56
+ readonly YEN: "YEN";
57
+ readonly RUBLE: "RUBLE";
58
+ readonly WON: "WON";
59
+ readonly QUESTION: "QUESTION";
60
+ readonly BANG: "BANG";
61
+ readonly BIT_AND: "BIT_AND";
62
+ readonly BIT_OR: "BIT_OR";
63
+ readonly BIT_NOT: "BIT_NOT";
64
+ readonly KEYWORD: "KEYWORD";
65
+ readonly EOF: "EOF";
66
+ readonly ERROR: "ERROR";
67
+ readonly WS: "WS";
68
+ readonly NEWLINE: "NEWLINE";
69
+ readonly DATETIME_LITERAL: "DATETIME_LITERAL";
70
+ readonly DURATION: "DURATION";
71
+ readonly UNIT: "UNIT";
72
+ readonly ROLL: "ROLL";
73
+ readonly PI: "PI";
74
+ readonly E: "E";
75
+ readonly MOD: "MOD";
76
+ readonly OF: "OF";
77
+ readonly INCREASE_BY: "INCREASE_BY";
78
+ readonly DECREASE_BY: "DECREASE_BY";
79
+ readonly OF_WHAT_IS: "OF_WHAT_IS";
80
+ readonly ON_WHAT_IS: "ON_WHAT_IS";
81
+ readonly OFF_WHAT_IS: "OFF_WHAT_IS";
82
+ readonly NOW: "NOW";
83
+ readonly TODAY: "TODAY";
84
+ readonly TOMORROW: "TOMORROW";
85
+ readonly YESTERDAY: "YESTERDAY";
86
+ readonly DURATION_DAY: "DURATION_DAY";
87
+ readonly DURATION_WEEK: "DURATION_WEEK";
88
+ readonly DURATION_MONTH: "DURATION_MONTH";
89
+ readonly DURATION_YEAR: "DURATION_YEAR";
90
+ readonly DURATION_HOUR: "DURATION_HOUR";
91
+ readonly DURATION_MINUTE: "DURATION_MINUTE";
92
+ readonly DURATION_SECOND: "DURATION_SECOND";
93
+ readonly FUNC: "FUNC";
94
+ readonly CONVERT: "CONVERT";
95
+ readonly TO: "TO";
96
+ readonly BEST: "BEST";
97
+ readonly NEXT: "NEXT";
98
+ readonly LAST: "LAST";
99
+ readonly UNTIL: "UNTIL";
100
+ readonly SINCE: "SINCE";
101
+ readonly BETWEEN: "BETWEEN";
102
+ readonly FROM: "FROM";
103
+ readonly INCREASE: "INCREASE";
104
+ readonly DECREASE: "DECREASE";
105
+ readonly UNICODE_MATH: "UNICODE_MATH";
106
+ readonly TIMES_BY: "TIMES_BY";
107
+ readonly MULTIPLY_BY: "MULTIPLY_BY";
108
+ readonly DIVIDE_BY: "DIVIDE_BY";
109
+ readonly NEQ: "NEQ";
110
+ readonly IN: "IN";
111
+ readonly BIT_XOR: "BIT_XOR";
112
+ readonly EQUALITY: "EQUALITY";
113
+ readonly GTE: "GTE";
114
+ readonly LTE: "LTE";
115
+ readonly LT: "LT";
116
+ readonly GT: "GT";
117
+ readonly LOGICAL_AND: "LOGICAL_AND";
118
+ readonly LOGICAL_OR: "LOGICAL_OR";
119
+ readonly OR: "OR";
120
+ readonly TRUE: "TRUE";
121
+ readonly FALSE: "FALSE";
122
+ readonly IF: "IF";
123
+ readonly THEN: "THEN";
124
+ readonly ELSE: "ELSE";
125
+ readonly AS: "AS";
126
+ readonly CONVERTER_NAME: "CONVERTER_NAME";
127
+ readonly AVERAGE_OF: "AVERAGE_OF";
128
+ readonly MEDIAN_OF: "MEDIAN_OF";
129
+ readonly TOTAL_OF: "TOTAL_OF";
130
+ readonly COUNT_OF: "COUNT_OF";
131
+ readonly LARGER_OF: "LARGER_OF";
132
+ readonly SMALLER_OF: "SMALLER_OF";
133
+ readonly HALF_OF: "HALF_OF";
134
+ readonly MIDPOINT_BETWEEN: "MIDPOINT_BETWEEN";
135
+ readonly RANDOM_NUMBER: "RANDOM_NUMBER";
136
+ readonly IS_TO: "IS_TO";
137
+ readonly CLAMP: "CLAMP";
138
+ readonly MAP: "MAP";
139
+ readonly REDUCE: "REDUCE";
140
+ readonly SUM_FN: "SUM_FN";
141
+ readonly PROD_FN: "PROD_FN";
142
+ readonly EXPAND_FN: "EXPAND_FN";
143
+ readonly FACTOR_FN: "FACTOR_FN";
144
+ readonly SOLVE_FN: "SOLVE_FN";
145
+ readonly DER_FN: "DER_FN";
146
+ readonly INTEGRAL_FN: "INTEGRAL_FN";
147
+ readonly TAYLOR_FN: "TAYLOR_FN";
148
+ readonly JACOBIAN_FN: "JACOBIAN_FN";
149
+ readonly CONJ_FN: "CONJ_FN";
150
+ readonly RE_FN: "RE_FN";
151
+ readonly IM_FN: "IM_FN";
152
+ readonly CANCEL_FN: "CANCEL_FN";
153
+ readonly APART_FN: "APART_FN";
154
+ readonly IMAGINARY: "IMAGINARY";
155
+ readonly THEREFORE: "THEREFORE";
156
+ readonly TIME_IN: "TIME_IN";
157
+ readonly DATE_IN: "DATE_IN";
158
+ readonly TIME_DIFFERENCE_BETWEEN: "TIME_DIFFERENCE_BETWEEN";
159
+ readonly CITY_NAME: "CITY_NAME";
160
+ readonly BACKTICK_OPEN: "BACKTICK_OPEN";
161
+ readonly INLINE_SOLVE_START: "INLINE_SOLVE_START";
162
+ readonly COMMENT: "COMMENT";
163
+ readonly VEC2: "VEC2";
164
+ readonly VEC3: "VEC3";
165
+ readonly VEC4: "VEC4";
166
+ readonly FLOAT: "FLOAT";
167
+ readonly GLOBAL: "GLOBAL";
168
+ readonly OVER: "OVER";
169
+ readonly RATE_AT: "RATE_AT";
170
+ readonly COMPOUND_INTEREST_ON: "COMPOUND_INTEREST_ON";
171
+ readonly INTEREST_ON: "INTEREST_ON";
172
+ readonly DAILY_REPAYMENT_ON: "DAILY_REPAYMENT_ON";
173
+ readonly MONTHLY_REPAYMENT_ON: "MONTHLY_REPAYMENT_ON";
174
+ readonly ANNUAL_REPAYMENT_ON: "ANNUAL_REPAYMENT_ON";
175
+ readonly TOTAL_REPAYMENT_ON: "TOTAL_REPAYMENT_ON";
176
+ readonly DAILY_LOAN_INTEREST_ON: "DAILY_LOAN_INTEREST_ON";
177
+ readonly MONTHLY_LOAN_INTEREST_ON: "MONTHLY_LOAN_INTEREST_ON";
178
+ readonly ANNUAL_LOAN_INTEREST_ON: "ANNUAL_LOAN_INTEREST_ON";
179
+ readonly TOTAL_LOAN_INTEREST_ON: "TOTAL_LOAN_INTEREST_ON";
180
+ readonly TAX_ON: "TAX_ON";
181
+ readonly TAX_OFF: "TAX_OFF";
182
+ readonly WHAT_IS: "WHAT_IS";
183
+ readonly WHAT_WAS: "WHAT_WAS";
184
+ readonly VALUE_OF: "VALUE_OF";
185
+ readonly WORTH_IN: "WORTH_IN";
186
+ readonly ASSUMING: "ASSUMING";
187
+ readonly IN_YEAR_DOLLARS: "IN_YEAR_DOLLARS";
188
+ readonly INGREDIENT_NAME: "INGREDIENT_NAME";
189
+ readonly WORKDAYS_IN: "WORKDAYS_IN";
190
+ readonly WEEKDAY_ON: "WEEKDAY_ON";
191
+ readonly CURRENT_TIMESTAMP: "CURRENT_TIMESTAMP";
192
+ readonly TO_DATE: "TO_DATE";
193
+ readonly TO_TIMESTAMP: "TO_TIMESTAMP";
194
+ readonly WEEKDAY_IN: "WEEKDAY_IN";
195
+ readonly MONTH_ON: "MONTH_ON";
196
+ readonly MONTH_IN: "MONTH_IN";
197
+ readonly WEEK_ON: "WEEK_ON";
198
+ readonly WEEK_IN: "WEEK_IN";
199
+ readonly BETWEEN_UNIT: "BETWEEN_UNIT";
200
+ readonly IS_WEEKEND: "IS_WEEKEND";
201
+ readonly IS_WORKDAY: "IS_WORKDAY";
202
+ readonly VIDEO_TIMECODE: "VIDEO_TIMECODE";
203
+ readonly FRAME_COUNT: "FRAME_COUNT";
204
+ readonly AT: "AT";
205
+ readonly CURRENCY_SYMBOL: "CURRENCY_SYMBOL";
206
+ readonly PREV: "PREV";
207
+ readonly LINE_REF: "LINE_REF";
208
+ readonly SUM_RANGE_CALL: "SUM_RANGE_CALL";
209
+ readonly AVERAGE_RANGE_CALL: "AVERAGE_RANGE_CALL";
210
+ readonly TOTAL_ABOVE: "TOTAL_ABOVE";
211
+ readonly SUM_ABOVE: "SUM_ABOVE";
212
+ readonly AVERAGE_ABOVE: "AVERAGE_ABOVE";
213
+ };
214
+ /**
215
+ * A token's kind, as a string.
216
+ *
217
+ * Deliberately open rather than an enum: a package registers its own token
218
+ * types at runtime, and a closed set would make that impossible.
219
+ */
220
+ type TokenType = (typeof TokenTypes)[keyof typeof TokenTypes];
221
+ /**
222
+ * Register a token type name and get back its integer ID.
223
+ * Idempotent, returns existing ID if already registered.
224
+ * Call once per token type at module initialization time.
225
+ */
226
+ declare function registerTokenType(name: string): number;
227
+ /**
228
+ * Get the integer ID for a token type name.
229
+ * Lazily registers unknown token types on first access, enabling plugin providers
230
+ * to define custom token types (VEC2, VEC3, etc.) without pre-registration.
231
+ * All built-in TokenTypes are pre-registered via registerAllTokenTypes().
232
+ */
233
+ declare function tokenTypeId(name: string): number;
234
+ /**
235
+ * Get the string name for a token type ID (for error messages and debugging).
236
+ * Returns `UNKNOWN_${id}` if the ID is not registered.
237
+ */
238
+ declare function tokenTypeName(id: number): string;
239
+ /**
240
+ * Bootstrap all known token types from TokenTypes at module load.
241
+ * Call this once after TokenTypes is defined.
242
+ */
243
+ declare function registerAllTokenTypes(): void;
244
+
245
+ export { type Token as T, type TokenType as a, TokenTypes as b, registerTokenType as c, tokenTypeName as d, registerAllTokenTypes as r, tokenTypeId as t };
@@ -0,0 +1,171 @@
1
+ import { V as Value } from './Value-KtAQNHur.js';
2
+ import { V as VM } from './ScopeManager-B5k0nk05.js';
3
+ import { U as UserFunctionDef } from './BytecodeBuilder-3egMyuDi.js';
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
+ * @param lineNumber 1-based line position.
98
+ * @param lineId Persistent line ID from DocumentModel.
99
+ * @param variableNames Names of variables that were written at this line.
100
+ * @returns The new checkpoint, or null if no variable names provided.
101
+ */
102
+ snapshot(lineNumber: number, lineId: number, variableNames: string[]): VMCheckpoint | null;
103
+ /**
104
+ * Restore the VM to the state at or just after the given line number.
105
+ *
106
+ * Finds the nearest checkpoint whose `lineNumber <= targetLineNumber`,
107
+ * then replays all variable definitions from root → that checkpoint
108
+ * into the VM via `setVar()`. The VM's stack is also reset.
109
+ *
110
+ * If no checkpoint exists at or before the target line, the VM is
111
+ * fully reset (empty scope, empty stack).
112
+ *
113
+ * **Performance:** O(number of checkpoints × variables per checkpoint).
114
+ * With prototypal inheritance, `Object.keys()` on each checkpoint
115
+ * returns only the variables that were set at that checkpoint (not
116
+ * inherited ones), so the total work is O(total variable definitions
117
+ * in the document), which is < 100 for typical Obsidian documents.
118
+ *
119
+ * @param lineNumber Target 1-based line number. The VM will have the
120
+ * state that existed AFTER evaluating lines up to `lineNumber`.
121
+ */
122
+ restoreTo(lineNumber: number): void;
123
+ /**
124
+ * Find the nearest checkpoint at or before the given line number.
125
+ *
126
+ * Uses linear scan (checkpoints are sorted by lineNumber and the list
127
+ * is short, typically < 20 for Obsidian documents). Can be upgraded
128
+ * to binary search if needed for documents with 1000+ variable defs.
129
+ *
130
+ * @returns The nearest checkpoint, or null if none exists before the line.
131
+ */
132
+ getNearestCheckpoint(lineNumber: number): VMCheckpoint | null;
133
+ /**
134
+ * Get a specific checkpoint by its line number.
135
+ * @returns The checkpoint, or undefined if not found.
136
+ */
137
+ getCheckpointAt(lineNumber: number): VMCheckpoint | undefined;
138
+ /**
139
+ * Get the entire checkpoint chain from root to the last checkpoint.
140
+ * Useful for debugging and serialization.
141
+ */
142
+ getAllCheckpoints(): readonly VMCheckpoint[];
143
+ /**
144
+ * Look up a variable's value through the checkpoint chain.
145
+ *
146
+ * Walks the prototype chain starting from the most recent checkpoint,
147
+ * looking for the variable name as an own property. This is O(depth)
148
+ * where depth is the number of checkpoints since the variable was
149
+ * last set.
150
+ *
151
+ * **Note:** This queries the checkpointer's snapshot, not the VM.
152
+ * The VM may have been modified since the last snapshot (e.g., by
153
+ * Tier 2 execution of non-variable-def lines that don't create checkpoints).
154
+ *
155
+ * @returns The Value, or undefined if the variable was never set.
156
+ */
157
+ lookupVariable(name: string): Value | undefined;
158
+ /**
159
+ * Clear all checkpoints. The underlying VM is NOT reset, call
160
+ * `vm.reset()` separately if needed.
161
+ */
162
+ clear(): void;
163
+ /** Number of checkpoints stored. */
164
+ get count(): number;
165
+ /** Returns true if no checkpoints have been created. */
166
+ get isEmpty(): boolean;
167
+ /** The associated VM instance. */
168
+ get vmInstance(): VM;
169
+ }
170
+
171
+ export { type VMCheckpoint as V, VMCheckpointer as a };