@ricsam/formula-engine 0.2.2 → 0.2.3

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 (337) hide show
  1. package/dist/cjs/core/ast-traverser.cjs +19 -9
  2. package/dist/cjs/core/ast-traverser.cjs.map +2 -2
  3. package/dist/cjs/core/autofill-utils.cjs +19 -9
  4. package/dist/cjs/core/autofill-utils.cjs.map +2 -2
  5. package/dist/cjs/core/cell-mover.cjs +19 -9
  6. package/dist/cjs/core/cell-mover.cjs.map +2 -2
  7. package/dist/cjs/core/commands/command-executor.cjs +24 -13
  8. package/dist/cjs/core/commands/command-executor.cjs.map +3 -3
  9. package/dist/cjs/core/commands/content-commands.cjs +292 -9
  10. package/dist/cjs/core/commands/content-commands.cjs.map +3 -3
  11. package/dist/cjs/core/commands/metadata-commands.cjs +19 -9
  12. package/dist/cjs/core/commands/metadata-commands.cjs.map +2 -2
  13. package/dist/cjs/core/commands/named-expression-commands.cjs +138 -13
  14. package/dist/cjs/core/commands/named-expression-commands.cjs.map +3 -3
  15. package/dist/cjs/core/commands/structure-commands.cjs +216 -15
  16. package/dist/cjs/core/commands/structure-commands.cjs.map +3 -3
  17. package/dist/cjs/core/commands/style-commands.cjs +19 -9
  18. package/dist/cjs/core/commands/style-commands.cjs.map +2 -2
  19. package/dist/cjs/core/commands/table-commands.cjs +134 -13
  20. package/dist/cjs/core/commands/table-commands.cjs.map +3 -3
  21. package/dist/cjs/core/commands/types.cjs +36 -9
  22. package/dist/cjs/core/commands/types.cjs.map +3 -3
  23. package/dist/cjs/core/engine-snapshot.cjs +51 -0
  24. package/dist/cjs/core/engine-snapshot.cjs.map +10 -0
  25. package/dist/cjs/core/engine.cjs +51 -34
  26. package/dist/cjs/core/engine.cjs.map +3 -3
  27. package/dist/cjs/core/managers/cache-manager.cjs +123 -9
  28. package/dist/cjs/core/managers/cache-manager.cjs.map +3 -3
  29. package/dist/cjs/core/managers/copy-manager.cjs +19 -9
  30. package/dist/cjs/core/managers/copy-manager.cjs.map +2 -2
  31. package/dist/cjs/core/managers/dependency-manager.cjs +697 -9
  32. package/dist/cjs/core/managers/dependency-manager.cjs.map +3 -3
  33. package/dist/cjs/core/managers/dependency-node.cjs +14 -8
  34. package/dist/cjs/core/managers/dependency-node.cjs.map +1 -1
  35. package/dist/cjs/core/managers/evaluation-manager.cjs +296 -11
  36. package/dist/cjs/core/managers/evaluation-manager.cjs.map +3 -3
  37. package/dist/cjs/core/managers/event-manager.cjs +19 -9
  38. package/dist/cjs/core/managers/event-manager.cjs.map +2 -2
  39. package/dist/cjs/core/managers/frontier-dependency-manager.cjs +65 -12
  40. package/dist/cjs/core/managers/frontier-dependency-manager.cjs.map +3 -3
  41. package/dist/cjs/core/managers/isDependencyNode.cjs +19 -9
  42. package/dist/cjs/core/managers/isDependencyNode.cjs.map +2 -2
  43. package/dist/cjs/core/managers/named-expression-manager.cjs +121 -29
  44. package/dist/cjs/core/managers/named-expression-manager.cjs.map +3 -3
  45. package/dist/cjs/core/managers/range-eval-order-builder.cjs +19 -9
  46. package/dist/cjs/core/managers/range-eval-order-builder.cjs.map +2 -2
  47. package/dist/cjs/core/managers/reference-manager.cjs +25 -9
  48. package/dist/cjs/core/managers/reference-manager.cjs.map +3 -3
  49. package/dist/cjs/core/managers/schema-manager.cjs +19 -9
  50. package/dist/cjs/core/managers/schema-manager.cjs.map +2 -2
  51. package/dist/cjs/core/managers/style-manager.cjs +28 -9
  52. package/dist/cjs/core/managers/style-manager.cjs.map +3 -3
  53. package/dist/cjs/core/managers/table-manager.cjs +25 -9
  54. package/dist/cjs/core/managers/table-manager.cjs.map +3 -3
  55. package/dist/cjs/core/managers/workbook-manager.cjs +38 -13
  56. package/dist/cjs/core/managers/workbook-manager.cjs.map +3 -3
  57. package/dist/cjs/core/map-serializer.cjs +19 -9
  58. package/dist/cjs/core/map-serializer.cjs.map +2 -2
  59. package/dist/cjs/core/named-expression-renamer.cjs +19 -9
  60. package/dist/cjs/core/named-expression-renamer.cjs.map +2 -2
  61. package/dist/cjs/core/resource-keys.cjs +67 -0
  62. package/dist/cjs/core/resource-keys.cjs.map +10 -0
  63. package/dist/cjs/core/schema/cell-orm.cjs +19 -9
  64. package/dist/cjs/core/schema/cell-orm.cjs.map +2 -2
  65. package/dist/cjs/core/schema/grid-orm.cjs +19 -9
  66. package/dist/cjs/core/schema/grid-orm.cjs.map +2 -2
  67. package/dist/cjs/core/schema/schema-builder.cjs +19 -9
  68. package/dist/cjs/core/schema/schema-builder.cjs.map +2 -2
  69. package/dist/cjs/core/schema/schema-helpers.cjs +19 -9
  70. package/dist/cjs/core/schema/schema-helpers.cjs.map +2 -2
  71. package/dist/cjs/core/schema/schema.cjs +19 -9
  72. package/dist/cjs/core/schema/schema.cjs.map +2 -2
  73. package/dist/cjs/core/schema/table-orm.cjs +19 -9
  74. package/dist/cjs/core/schema/table-orm.cjs.map +2 -2
  75. package/dist/cjs/core/sheet-renamer.cjs +19 -9
  76. package/dist/cjs/core/sheet-renamer.cjs.map +2 -2
  77. package/dist/cjs/core/sheet-utils.cjs +19 -9
  78. package/dist/cjs/core/sheet-utils.cjs.map +2 -2
  79. package/dist/cjs/core/table-renamer.cjs +19 -9
  80. package/dist/cjs/core/table-renamer.cjs.map +2 -2
  81. package/dist/cjs/core/types.cjs +19 -9
  82. package/dist/cjs/core/types.cjs.map +2 -2
  83. package/dist/cjs/core/utils/color-utils.cjs +19 -9
  84. package/dist/cjs/core/utils/color-utils.cjs.map +2 -2
  85. package/dist/cjs/core/utils/range-serializer.cjs +19 -9
  86. package/dist/cjs/core/utils/range-serializer.cjs.map +2 -2
  87. package/dist/cjs/core/utils/range-utils.cjs +19 -9
  88. package/dist/cjs/core/utils/range-utils.cjs.map +2 -2
  89. package/dist/cjs/core/utils/spreadsheet-visualizer.cjs +19 -9
  90. package/dist/cjs/core/utils/spreadsheet-visualizer.cjs.map +2 -2
  91. package/dist/cjs/core/utils.cjs +19 -9
  92. package/dist/cjs/core/utils.cjs.map +2 -2
  93. package/dist/cjs/core/workbook-renamer.cjs +19 -9
  94. package/dist/cjs/core/workbook-renamer.cjs.map +2 -2
  95. package/dist/cjs/debug/flags.cjs +19 -9
  96. package/dist/cjs/debug/flags.cjs.map +2 -2
  97. package/dist/cjs/evaluator/arithmetic/add/add.cjs +19 -9
  98. package/dist/cjs/evaluator/arithmetic/add/add.cjs.map +2 -2
  99. package/dist/cjs/evaluator/arithmetic/divide/divide.cjs +19 -9
  100. package/dist/cjs/evaluator/arithmetic/divide/divide.cjs.map +2 -2
  101. package/dist/cjs/evaluator/arithmetic/multiply/multiply.cjs +19 -9
  102. package/dist/cjs/evaluator/arithmetic/multiply/multiply.cjs.map +2 -2
  103. package/dist/cjs/evaluator/arithmetic/power/power.cjs +19 -9
  104. package/dist/cjs/evaluator/arithmetic/power/power.cjs.map +2 -2
  105. package/dist/cjs/evaluator/arithmetic/subtract/subtract.cjs +19 -9
  106. package/dist/cjs/evaluator/arithmetic/subtract/subtract.cjs.map +2 -2
  107. package/dist/cjs/evaluator/comparison/equals.cjs +19 -9
  108. package/dist/cjs/evaluator/comparison/equals.cjs.map +2 -2
  109. package/dist/cjs/evaluator/comparison/greater-than-or-equal.cjs +19 -9
  110. package/dist/cjs/evaluator/comparison/greater-than-or-equal.cjs.map +2 -2
  111. package/dist/cjs/evaluator/comparison/greater-than.cjs +19 -9
  112. package/dist/cjs/evaluator/comparison/greater-than.cjs.map +2 -2
  113. package/dist/cjs/evaluator/comparison/less-than-or-equal.cjs +19 -9
  114. package/dist/cjs/evaluator/comparison/less-than-or-equal.cjs.map +2 -2
  115. package/dist/cjs/evaluator/comparison/less-than.cjs +19 -9
  116. package/dist/cjs/evaluator/comparison/less-than.cjs.map +2 -2
  117. package/dist/cjs/evaluator/comparison/not-equals.cjs +19 -9
  118. package/dist/cjs/evaluator/comparison/not-equals.cjs.map +2 -2
  119. package/dist/cjs/evaluator/concatenation/concatenate.cjs +19 -9
  120. package/dist/cjs/evaluator/concatenation/concatenate.cjs.map +2 -2
  121. package/dist/cjs/evaluator/dependency-nodes/ast-evaluation-node.cjs +19 -9
  122. package/dist/cjs/evaluator/dependency-nodes/ast-evaluation-node.cjs.map +2 -2
  123. package/dist/cjs/evaluator/dependency-nodes/base-eval-node.cjs +35 -9
  124. package/dist/cjs/evaluator/dependency-nodes/base-eval-node.cjs.map +3 -3
  125. package/dist/cjs/evaluator/dependency-nodes/cell-value-node.cjs +22 -9
  126. package/dist/cjs/evaluator/dependency-nodes/cell-value-node.cjs.map +3 -3
  127. package/dist/cjs/evaluator/dependency-nodes/empty-cell-evaluation-node.cjs +35 -11
  128. package/dist/cjs/evaluator/dependency-nodes/empty-cell-evaluation-node.cjs.map +3 -3
  129. package/dist/cjs/evaluator/dependency-nodes/resource-dependency-node.cjs +61 -0
  130. package/dist/cjs/evaluator/dependency-nodes/resource-dependency-node.cjs.map +10 -0
  131. package/dist/cjs/evaluator/dependency-nodes/spill-meta-node.cjs +19 -9
  132. package/dist/cjs/evaluator/dependency-nodes/spill-meta-node.cjs.map +2 -2
  133. package/dist/cjs/evaluator/dependency-nodes/virtual-cell-value-node.cjs +22 -9
  134. package/dist/cjs/evaluator/dependency-nodes/virtual-cell-value-node.cjs.map +3 -3
  135. package/dist/cjs/evaluator/evaluate-scalar-operator.cjs +19 -9
  136. package/dist/cjs/evaluator/evaluate-scalar-operator.cjs.map +2 -2
  137. package/dist/cjs/evaluator/evaluation-context.cjs +19 -9
  138. package/dist/cjs/evaluator/evaluation-context.cjs.map +2 -2
  139. package/dist/cjs/evaluator/evaluation-error.cjs +19 -9
  140. package/dist/cjs/evaluator/evaluation-error.cjs.map +2 -2
  141. package/dist/cjs/evaluator/formula-evaluator.cjs +55 -12
  142. package/dist/cjs/evaluator/formula-evaluator.cjs.map +3 -3
  143. package/dist/cjs/evaluator/range-evaluation-node.cjs +35 -11
  144. package/dist/cjs/evaluator/range-evaluation-node.cjs.map +3 -3
  145. package/dist/cjs/functions/_template/template.cjs +19 -9
  146. package/dist/cjs/functions/_template/template.cjs.map +2 -2
  147. package/dist/cjs/functions/array/sequence/sequence.cjs +19 -9
  148. package/dist/cjs/functions/array/sequence/sequence.cjs.map +2 -2
  149. package/dist/cjs/functions/criteria-parser.cjs +19 -9
  150. package/dist/cjs/functions/criteria-parser.cjs.map +2 -2
  151. package/dist/cjs/functions/criteria-utils.cjs +19 -9
  152. package/dist/cjs/functions/criteria-utils.cjs.map +2 -2
  153. package/dist/cjs/functions/function-registry.cjs +19 -9
  154. package/dist/cjs/functions/function-registry.cjs.map +2 -2
  155. package/dist/cjs/functions/function-utils.cjs +19 -9
  156. package/dist/cjs/functions/function-utils.cjs.map +2 -2
  157. package/dist/cjs/functions/information/cell/cell.cjs +19 -9
  158. package/dist/cjs/functions/information/cell/cell.cjs.map +2 -2
  159. package/dist/cjs/functions/information/column/column.cjs +19 -9
  160. package/dist/cjs/functions/information/column/column.cjs.map +2 -2
  161. package/dist/cjs/functions/information/row/row.cjs +19 -9
  162. package/dist/cjs/functions/information/row/row.cjs.map +2 -2
  163. package/dist/cjs/functions/logical/and/and.cjs +19 -9
  164. package/dist/cjs/functions/logical/and/and.cjs.map +2 -2
  165. package/dist/cjs/functions/logical/if/if.cjs +19 -9
  166. package/dist/cjs/functions/logical/if/if.cjs.map +2 -2
  167. package/dist/cjs/functions/logical/iferror/iferror.cjs +19 -9
  168. package/dist/cjs/functions/logical/iferror/iferror.cjs.map +2 -2
  169. package/dist/cjs/functions/logical/or/or.cjs +19 -9
  170. package/dist/cjs/functions/logical/or/or.cjs.map +2 -2
  171. package/dist/cjs/functions/lookup/count/count-utils.cjs +19 -9
  172. package/dist/cjs/functions/lookup/count/count-utils.cjs.map +2 -2
  173. package/dist/cjs/functions/lookup/count/count.cjs +19 -9
  174. package/dist/cjs/functions/lookup/count/count.cjs.map +2 -2
  175. package/dist/cjs/functions/lookup/count/countif.cjs +19 -9
  176. package/dist/cjs/functions/lookup/count/countif.cjs.map +2 -2
  177. package/dist/cjs/functions/lookup/count/countifs.cjs +19 -9
  178. package/dist/cjs/functions/lookup/count/countifs.cjs.map +2 -2
  179. package/dist/cjs/functions/lookup/index-lookup/index-lookup.cjs +19 -9
  180. package/dist/cjs/functions/lookup/index-lookup/index-lookup.cjs.map +2 -2
  181. package/dist/cjs/functions/lookup/match/match.cjs +21 -10
  182. package/dist/cjs/functions/lookup/match/match.cjs.map +3 -3
  183. package/dist/cjs/functions/lookup/xlookup/xlookup.cjs +19 -9
  184. package/dist/cjs/functions/lookup/xlookup/xlookup.cjs.map +2 -2
  185. package/dist/cjs/functions/math/average/average-utils.cjs +19 -9
  186. package/dist/cjs/functions/math/average/average-utils.cjs.map +2 -2
  187. package/dist/cjs/functions/math/average/average.cjs +19 -9
  188. package/dist/cjs/functions/math/average/average.cjs.map +2 -2
  189. package/dist/cjs/functions/math/average/averageif.cjs +19 -9
  190. package/dist/cjs/functions/math/average/averageif.cjs.map +2 -2
  191. package/dist/cjs/functions/math/average/averageifs.cjs +19 -9
  192. package/dist/cjs/functions/math/average/averageifs.cjs.map +2 -2
  193. package/dist/cjs/functions/math/ceiling/ceiling.cjs +19 -9
  194. package/dist/cjs/functions/math/ceiling/ceiling.cjs.map +2 -2
  195. package/dist/cjs/functions/math/max/max-utils.cjs +19 -9
  196. package/dist/cjs/functions/math/max/max-utils.cjs.map +2 -2
  197. package/dist/cjs/functions/math/max/max.cjs +19 -9
  198. package/dist/cjs/functions/math/max/max.cjs.map +2 -2
  199. package/dist/cjs/functions/math/max/maxif.cjs +19 -9
  200. package/dist/cjs/functions/math/max/maxif.cjs.map +2 -2
  201. package/dist/cjs/functions/math/max/maxifs.cjs +19 -9
  202. package/dist/cjs/functions/math/max/maxifs.cjs.map +2 -2
  203. package/dist/cjs/functions/math/min/min-utils.cjs +19 -9
  204. package/dist/cjs/functions/math/min/min-utils.cjs.map +2 -2
  205. package/dist/cjs/functions/math/min/min.cjs +19 -9
  206. package/dist/cjs/functions/math/min/min.cjs.map +2 -2
  207. package/dist/cjs/functions/math/min/minif.cjs +19 -9
  208. package/dist/cjs/functions/math/min/minif.cjs.map +2 -2
  209. package/dist/cjs/functions/math/min/minifs.cjs +19 -9
  210. package/dist/cjs/functions/math/min/minifs.cjs.map +2 -2
  211. package/dist/cjs/functions/math/sum/sum.cjs +19 -9
  212. package/dist/cjs/functions/math/sum/sum.cjs.map +2 -2
  213. package/dist/cjs/functions/math/sum/sumif.cjs +19 -9
  214. package/dist/cjs/functions/math/sum/sumif.cjs.map +2 -2
  215. package/dist/cjs/functions/math/sum/sumifs.cjs +19 -9
  216. package/dist/cjs/functions/math/sum/sumifs.cjs.map +2 -2
  217. package/dist/cjs/functions/math/sum/summation-utils.cjs +19 -9
  218. package/dist/cjs/functions/math/sum/summation-utils.cjs.map +2 -2
  219. package/dist/cjs/functions/reference/address/address.cjs +19 -9
  220. package/dist/cjs/functions/reference/address/address.cjs.map +2 -2
  221. package/dist/cjs/functions/reference/indirect/indirect.cjs +19 -9
  222. package/dist/cjs/functions/reference/indirect/indirect.cjs.map +2 -2
  223. package/dist/cjs/functions/reference/offset/offset.cjs +19 -9
  224. package/dist/cjs/functions/reference/offset/offset.cjs.map +2 -2
  225. package/dist/cjs/functions/text/concatenate/concatenate.cjs +21 -9
  226. package/dist/cjs/functions/text/concatenate/concatenate.cjs.map +3 -3
  227. package/dist/cjs/functions/text/exact/exact.cjs +19 -9
  228. package/dist/cjs/functions/text/exact/exact.cjs.map +2 -2
  229. package/dist/cjs/functions/text/find/find.cjs +19 -9
  230. package/dist/cjs/functions/text/find/find.cjs.map +2 -2
  231. package/dist/cjs/functions/text/left/left.cjs +19 -9
  232. package/dist/cjs/functions/text/left/left.cjs.map +2 -2
  233. package/dist/cjs/functions/text/len/len.cjs +19 -9
  234. package/dist/cjs/functions/text/len/len.cjs.map +2 -2
  235. package/dist/cjs/functions/text/mid/mid.cjs +19 -9
  236. package/dist/cjs/functions/text/mid/mid.cjs.map +2 -2
  237. package/dist/cjs/functions/text/right/right.cjs +19 -9
  238. package/dist/cjs/functions/text/right/right.cjs.map +2 -2
  239. package/dist/cjs/functions/text/text-helpers.cjs +19 -9
  240. package/dist/cjs/functions/text/text-helpers.cjs.map +2 -2
  241. package/dist/cjs/functions/text/textjoin/textjoin.cjs +19 -9
  242. package/dist/cjs/functions/text/textjoin/textjoin.cjs.map +2 -2
  243. package/dist/cjs/lib.cjs +24 -13
  244. package/dist/cjs/lib.cjs.map +2 -2
  245. package/dist/cjs/package.json +1 -1
  246. package/dist/cjs/parser/ast.cjs +19 -9
  247. package/dist/cjs/parser/ast.cjs.map +2 -2
  248. package/dist/cjs/parser/formatter.cjs +19 -9
  249. package/dist/cjs/parser/formatter.cjs.map +2 -2
  250. package/dist/cjs/parser/grammar.cjs +19 -9
  251. package/dist/cjs/parser/grammar.cjs.map +2 -2
  252. package/dist/cjs/parser/lexer.cjs +19 -9
  253. package/dist/cjs/parser/lexer.cjs.map +2 -2
  254. package/dist/cjs/parser/parser.cjs +19 -9
  255. package/dist/cjs/parser/parser.cjs.map +2 -2
  256. package/dist/cjs/react/hooks.cjs +31 -10
  257. package/dist/cjs/react/hooks.cjs.map +2 -2
  258. package/dist/mjs/core/commands/command-executor.mjs +7 -5
  259. package/dist/mjs/core/commands/command-executor.mjs.map +3 -3
  260. package/dist/mjs/core/commands/content-commands.mjs +279 -2
  261. package/dist/mjs/core/commands/content-commands.mjs.map +3 -3
  262. package/dist/mjs/core/commands/named-expression-commands.mjs +121 -6
  263. package/dist/mjs/core/commands/named-expression-commands.mjs.map +3 -3
  264. package/dist/mjs/core/commands/structure-commands.mjs +204 -8
  265. package/dist/mjs/core/commands/structure-commands.mjs.map +3 -3
  266. package/dist/mjs/core/commands/table-commands.mjs +117 -6
  267. package/dist/mjs/core/commands/table-commands.mjs.map +3 -3
  268. package/dist/mjs/core/commands/types.mjs +18 -1
  269. package/dist/mjs/core/commands/types.mjs.map +3 -3
  270. package/dist/mjs/core/engine-snapshot.mjs +11 -0
  271. package/dist/mjs/core/engine-snapshot.mjs.map +10 -0
  272. package/dist/mjs/core/engine.mjs +35 -26
  273. package/dist/mjs/core/engine.mjs.map +3 -3
  274. package/dist/mjs/core/managers/cache-manager.mjs +105 -1
  275. package/dist/mjs/core/managers/cache-manager.mjs.map +3 -3
  276. package/dist/mjs/core/managers/dependency-manager.mjs +687 -2
  277. package/dist/mjs/core/managers/dependency-manager.mjs.map +3 -3
  278. package/dist/mjs/core/managers/evaluation-manager.mjs +283 -4
  279. package/dist/mjs/core/managers/evaluation-manager.mjs.map +3 -3
  280. package/dist/mjs/core/managers/frontier-dependency-manager.mjs +47 -4
  281. package/dist/mjs/core/managers/frontier-dependency-manager.mjs.map +3 -3
  282. package/dist/mjs/core/managers/named-expression-manager.mjs +104 -21
  283. package/dist/mjs/core/managers/named-expression-manager.mjs.map +3 -3
  284. package/dist/mjs/core/managers/reference-manager.mjs +7 -1
  285. package/dist/mjs/core/managers/reference-manager.mjs.map +3 -3
  286. package/dist/mjs/core/managers/style-manager.mjs +10 -1
  287. package/dist/mjs/core/managers/style-manager.mjs.map +3 -3
  288. package/dist/mjs/core/managers/table-manager.mjs +7 -1
  289. package/dist/mjs/core/managers/table-manager.mjs.map +3 -3
  290. package/dist/mjs/core/managers/workbook-manager.mjs +20 -5
  291. package/dist/mjs/core/managers/workbook-manager.mjs.map +3 -3
  292. package/dist/mjs/core/resource-keys.mjs +27 -0
  293. package/dist/mjs/core/resource-keys.mjs.map +10 -0
  294. package/dist/mjs/evaluator/dependency-nodes/base-eval-node.mjs +17 -1
  295. package/dist/mjs/evaluator/dependency-nodes/base-eval-node.mjs.map +3 -3
  296. package/dist/mjs/evaluator/dependency-nodes/cell-value-node.mjs +4 -1
  297. package/dist/mjs/evaluator/dependency-nodes/cell-value-node.mjs.map +3 -3
  298. package/dist/mjs/evaluator/dependency-nodes/empty-cell-evaluation-node.mjs +17 -3
  299. package/dist/mjs/evaluator/dependency-nodes/empty-cell-evaluation-node.mjs.map +3 -3
  300. package/dist/mjs/evaluator/dependency-nodes/resource-dependency-node.mjs +21 -0
  301. package/dist/mjs/evaluator/dependency-nodes/resource-dependency-node.mjs.map +10 -0
  302. package/dist/mjs/evaluator/dependency-nodes/virtual-cell-value-node.mjs +4 -1
  303. package/dist/mjs/evaluator/dependency-nodes/virtual-cell-value-node.mjs.map +3 -3
  304. package/dist/mjs/evaluator/formula-evaluator.mjs +42 -4
  305. package/dist/mjs/evaluator/formula-evaluator.mjs.map +3 -3
  306. package/dist/mjs/evaluator/range-evaluation-node.mjs +17 -3
  307. package/dist/mjs/evaluator/range-evaluation-node.mjs.map +3 -3
  308. package/dist/mjs/functions/lookup/match/match.mjs +3 -2
  309. package/dist/mjs/functions/lookup/match/match.mjs.map +3 -3
  310. package/dist/mjs/functions/text/concatenate/concatenate.mjs +3 -1
  311. package/dist/mjs/functions/text/concatenate/concatenate.mjs.map +3 -3
  312. package/dist/mjs/package.json +1 -1
  313. package/dist/types/core/commands/content-commands.d.ts +31 -1
  314. package/dist/types/core/commands/named-expression-commands.d.ts +16 -1
  315. package/dist/types/core/commands/structure-commands.d.ts +24 -1
  316. package/dist/types/core/commands/table-commands.d.ts +16 -1
  317. package/dist/types/core/commands/types.d.ts +25 -1
  318. package/dist/types/core/engine-snapshot.d.ts +138 -0
  319. package/dist/types/core/engine.d.ts +1 -0
  320. package/dist/types/core/managers/cache-manager.d.ts +9 -0
  321. package/dist/types/core/managers/dependency-manager.d.ts +56 -1
  322. package/dist/types/core/managers/dependency-node.d.ts +2 -1
  323. package/dist/types/core/managers/evaluation-manager.d.ts +21 -1
  324. package/dist/types/core/managers/frontier-dependency-manager.d.ts +12 -2
  325. package/dist/types/core/managers/named-expression-manager.d.ts +17 -1
  326. package/dist/types/core/managers/reference-manager.d.ts +3 -0
  327. package/dist/types/core/managers/style-manager.d.ts +3 -0
  328. package/dist/types/core/managers/table-manager.d.ts +3 -0
  329. package/dist/types/core/managers/workbook-manager.d.ts +4 -1
  330. package/dist/types/core/resource-keys.d.ts +14 -0
  331. package/dist/types/evaluator/dependency-nodes/base-eval-node.d.ts +5 -0
  332. package/dist/types/evaluator/dependency-nodes/cell-value-node.d.ts +1 -0
  333. package/dist/types/evaluator/dependency-nodes/empty-cell-evaluation-node.d.ts +8 -1
  334. package/dist/types/evaluator/dependency-nodes/resource-dependency-node.d.ts +8 -0
  335. package/dist/types/evaluator/dependency-nodes/virtual-cell-value-node.d.ts +1 -0
  336. package/dist/types/evaluator/range-evaluation-node.d.ts +8 -1
  337. package/package.json +6 -2
@@ -4,7 +4,27 @@
4
4
  * Commands encapsulate all mutating operations on the engine,
5
5
  * enabling undo/redo, schema validation with rollback, and action serialization.
6
6
  */
7
- import type { CellAddress } from "../types";
7
+ import type { CellAddress, SerializedCellValue } from "../types";
8
+ export type CellContentKind = "empty" | "scalar" | "formula";
9
+ export type RemovedScope = {
10
+ type: "workbook";
11
+ workbookName: string;
12
+ } | {
13
+ type: "sheet";
14
+ workbookName: string;
15
+ sheetName: string;
16
+ };
17
+ export type MutationInvalidation = {
18
+ touchedCells: Array<{
19
+ address: CellAddress;
20
+ beforeKind: CellContentKind;
21
+ afterKind: CellContentKind;
22
+ }>;
23
+ resourceKeys: string[];
24
+ removedScopes?: RemovedScope[];
25
+ };
26
+ export declare function getSerializedCellValueKind(value: SerializedCellValue | undefined): CellContentKind;
27
+ export declare function emptyMutationInvalidation(): MutationInvalidation;
8
28
  /**
9
29
  * Serializable action representation of a command.
10
30
  * Used for persistence, collaboration, and changelog functionality.
@@ -23,6 +43,10 @@ export interface EngineCommand {
23
43
  * Commands that only affect metadata or styles don't need re-evaluation.
24
44
  */
25
45
  readonly requiresReevaluation: boolean;
46
+ /**
47
+ * Returns the exact mutation footprint for the last execute/undo pass.
48
+ */
49
+ getInvalidationFootprint?(phase: "execute" | "undo"): MutationInvalidation;
26
50
  /**
27
51
  * Execute the command (forward operation).
28
52
  */
@@ -0,0 +1,138 @@
1
+ import type { ContextDependency } from "../evaluator/evaluation-context";
2
+ import type { DependencyNode } from "./managers/dependency-node";
3
+ import type { CellAddress, CellInRangeResult, CellValue, ConditionalStyle, DirectCellStyle, FormulaError, NamedExpression, RangeAddress, RelativeRange, SpreadsheetRange, TableDefinition, TrackedReference, Workbook } from "./types";
4
+ export declare const ENGINE_SNAPSHOT_VERSION: 3;
5
+ export type NodeSnapshotId = string;
6
+ export type NamedExpressionManagerSnapshot = {
7
+ sheetExpressions: Map<string, Map<string, Map<string, NamedExpression>>>;
8
+ workbookExpressions: Map<string, Map<string, NamedExpression>>;
9
+ globalExpressions: Map<string, NamedExpression>;
10
+ };
11
+ export type WorkbookManagerSnapshot = Map<string, Workbook>;
12
+ export type TableManagerSnapshot = Map<string, Map<string, TableDefinition>>;
13
+ export type StyleManagerSnapshot = {
14
+ conditionalStyles: ConditionalStyle[];
15
+ cellStyles: DirectCellStyle[];
16
+ };
17
+ export type ReferenceManagerSnapshot = Map<string, TrackedReference>;
18
+ export type SerializedValueEvaluationResultSnapshot = {
19
+ type: "value";
20
+ result: CellValue;
21
+ sourceCell?: CellAddress;
22
+ };
23
+ export type SerializedErrorEvaluationResultSnapshot = {
24
+ type: "error";
25
+ err: FormulaError;
26
+ message: string;
27
+ errAddressId: NodeSnapshotId;
28
+ sourceCell?: CellAddress;
29
+ };
30
+ export type SerializedSingleEvaluationResultSnapshot = SerializedValueEvaluationResultSnapshot | SerializedErrorEvaluationResultSnapshot;
31
+ export type SerializedCellInRangeResultSnapshot = {
32
+ relativePos: CellInRangeResult["relativePos"];
33
+ result: SerializedSingleEvaluationResultSnapshot;
34
+ };
35
+ export type SerializedEvaluateAllCellsResultSnapshot = SerializedErrorEvaluationResultSnapshot | {
36
+ type: "values";
37
+ values: SerializedCellInRangeResultSnapshot[];
38
+ };
39
+ export type SerializedMaterializedSpillSnapshot = {
40
+ kind: "materialized";
41
+ relativeSpillArea: RelativeRange;
42
+ source: string;
43
+ sourceCell?: CellAddress;
44
+ sourceRange?: RangeAddress;
45
+ values: SerializedCellInRangeResultSnapshot[];
46
+ };
47
+ export type SerializedSourceRangeSpillSnapshot = {
48
+ kind: "source-range";
49
+ relativeSpillArea: RelativeRange;
50
+ source: string;
51
+ sourceCell?: CellAddress;
52
+ sourceRange: RangeAddress;
53
+ };
54
+ export type SerializedSpillResultSnapshot = SerializedMaterializedSpillSnapshot | SerializedSourceRangeSpillSnapshot;
55
+ export type SerializedSpilledValuesEvaluationResultSnapshot = {
56
+ type: "spilled-values";
57
+ spill: SerializedSpillResultSnapshot;
58
+ };
59
+ export type SerializedFunctionEvaluationResultSnapshot = SerializedSingleEvaluationResultSnapshot | SerializedSpilledValuesEvaluationResultSnapshot;
60
+ export type SerializedSpillMetaEvaluationResultSnapshot = SerializedErrorEvaluationResultSnapshot | SerializedSpilledValuesEvaluationResultSnapshot | {
61
+ type: "does-not-spill";
62
+ };
63
+ type SerializedBaseNodeSnapshot = {
64
+ snapshotId: NodeSnapshotId;
65
+ key: string;
66
+ dependencies: NodeSnapshotId[];
67
+ };
68
+ export type SerializedCellValueNodeSnapshot = SerializedBaseNodeSnapshot & {
69
+ kind: "cell-value";
70
+ evaluationResult: SerializedSingleEvaluationResultSnapshot;
71
+ spillMetaSnapshotId?: NodeSnapshotId;
72
+ };
73
+ export type SerializedSpillMetaNodeSnapshot = SerializedBaseNodeSnapshot & {
74
+ kind: "spill-meta";
75
+ evaluationResult: SerializedSpillMetaEvaluationResultSnapshot;
76
+ };
77
+ export type SerializedEmptyCellNodeSnapshot = SerializedBaseNodeSnapshot & {
78
+ kind: "empty";
79
+ evaluationResult: SerializedSingleEvaluationResultSnapshot;
80
+ };
81
+ export type SerializedRangeNodeSnapshot = SerializedBaseNodeSnapshot & {
82
+ kind: "range";
83
+ result: SerializedEvaluateAllCellsResultSnapshot;
84
+ };
85
+ export type SerializedAstNodeSnapshot = SerializedBaseNodeSnapshot & {
86
+ kind: "ast";
87
+ contextDependency: ContextDependency;
88
+ evaluationResult: SerializedFunctionEvaluationResultSnapshot;
89
+ };
90
+ export type SerializedResourceNodeSnapshot = SerializedBaseNodeSnapshot & {
91
+ kind: "resource";
92
+ };
93
+ export type SerializedDependencyNodeSnapshot = SerializedCellValueNodeSnapshot | SerializedSpillMetaNodeSnapshot | SerializedEmptyCellNodeSnapshot | SerializedRangeNodeSnapshot | SerializedAstNodeSnapshot | SerializedResourceNodeSnapshot;
94
+ export type DependencyManagerSnapshot = {
95
+ nodes: SerializedDependencyNodeSnapshot[];
96
+ spilledValues: Array<[string, {
97
+ origin: CellAddress;
98
+ spillOnto: SpreadsheetRange;
99
+ }]>;
100
+ };
101
+ export type SerializedSCCSnapshot = {
102
+ id: number;
103
+ nodes: NodeSnapshotId[];
104
+ evaluationOrder: NodeSnapshotId[];
105
+ resolved: boolean;
106
+ hardEdgeSCCs: NodeSnapshotId[][];
107
+ };
108
+ export type SerializedEvaluationOrderSnapshot = {
109
+ nodeKey: string;
110
+ evaluationOrder: NodeSnapshotId[];
111
+ hasCycle: boolean;
112
+ cycleNodes?: NodeSnapshotId[];
113
+ hash: string;
114
+ };
115
+ export type CacheManagerSnapshot = {
116
+ evaluationOrders: SerializedEvaluationOrderSnapshot[];
117
+ sccs: Array<{
118
+ hash: string;
119
+ scc: SerializedSCCSnapshot;
120
+ }>;
121
+ };
122
+ export type EngineSnapshotV3 = {
123
+ version: typeof ENGINE_SNAPSHOT_VERSION;
124
+ managers: {
125
+ workbook: WorkbookManagerSnapshot;
126
+ namedExpression: NamedExpressionManagerSnapshot;
127
+ table: TableManagerSnapshot;
128
+ style: StyleManagerSnapshot;
129
+ reference: ReferenceManagerSnapshot;
130
+ dependency: DependencyManagerSnapshot;
131
+ cache: CacheManagerSnapshot;
132
+ };
133
+ };
134
+ export type EngineSnapshotV2 = EngineSnapshotV3;
135
+ export declare function getAstNodeSnapshotId(node: DependencyNode & {
136
+ getContextDependency(): ContextDependency;
137
+ }): NodeSnapshotId;
138
+ export {};
@@ -520,6 +520,7 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreat
520
520
  references: Map<string, import("./types").TrackedReference>;
521
521
  };
522
522
  onUpdate(listener: () => void): () => void;
523
+ private buildSerializedSnapshot;
523
524
  serializeEngine(): string;
524
525
  resetToSerializedEngine(data: string): void;
525
526
  /**
@@ -1,4 +1,6 @@
1
1
  import type { EvaluationOrder, SCC } from "../types";
2
+ import type { DependencyNode } from "./dependency-node";
3
+ import type { CacheManagerSnapshot, NodeSnapshotId } from "../engine-snapshot";
2
4
  export declare class CacheManager {
3
5
  private _evaluationOrderCache;
4
6
  /**
@@ -8,7 +10,14 @@ export declare class CacheManager {
8
10
  constructor();
9
11
  setEvaluationOrder(nodeKey: string, evaluationOrder: EvaluationOrder): void;
10
12
  getEvaluationOrder(nodeKey: string): EvaluationOrder | undefined;
13
+ deleteEvaluationOrder(nodeKey: string): void;
14
+ deleteEvaluationOrders(nodeKeys: Iterable<string>): void;
11
15
  setSCC(sccHash: string, scc: SCC): void;
12
16
  getSCC(sccHash: string): SCC | undefined;
17
+ clearSCCCache(): void;
13
18
  clear(): void;
19
+ toSnapshot(getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId | undefined): CacheManagerSnapshot;
20
+ restoreFromSnapshot(snapshot: CacheManagerSnapshot, resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode | undefined): void;
21
+ private serializeSCC;
22
+ private deserializeSCC;
14
23
  }
@@ -1,3 +1,4 @@
1
+ import { type CacheManagerSnapshot, type DependencyManagerSnapshot } from "../engine-snapshot";
1
2
  import { type ContextDependency } from "../../evaluator/evaluation-context";
2
3
  import { type CellAddress, type EvaluationOrder, type SerializedCellValue, type SpilledValue } from "../types";
3
4
  import { AstEvaluationNode } from "../../evaluator/dependency-nodes/ast-evaluation-node";
@@ -10,6 +11,9 @@ import { CacheManager } from "./cache-manager";
10
11
  import type { DependencyNode } from "./dependency-node";
11
12
  import { WorkbookManager } from "./workbook-manager";
12
13
  import { VirtualCellValueNode } from "../../evaluator/dependency-nodes/virtual-cell-value-node";
14
+ import type { EvaluationManager } from "./evaluation-manager";
15
+ import type { MutationInvalidation } from "../commands/types";
16
+ import { ResourceDependencyNode } from "../../evaluator/dependency-nodes/resource-dependency-node";
13
17
  export interface DependencyTreeNode {
14
18
  type: "cell" | "range" | "empty";
15
19
  circular?: boolean;
@@ -17,7 +21,7 @@ export interface DependencyTreeNode {
17
21
  directDepsUpdated?: boolean;
18
22
  resolved?: boolean;
19
23
  canResolve: boolean;
20
- resultType: "awaiting-evaluation" | "spilled-values" | "value" | "range" | "error" | "does-not-spill";
24
+ resultType: "awaiting-evaluation" | "spilled-values" | "value" | "range" | "error" | "does-not-spill" | "resource";
21
25
  deps?: DependencyTreeNode[];
22
26
  frontierDependencies?: DependencyTreeNode[];
23
27
  self?: boolean;
@@ -48,7 +52,33 @@ export declare class DependencyManager {
48
52
  * Key is workbook:sheetName:rangeKey, e.g. Workbook1:Sheet1:A1:D10, from rangeAddressToKey
49
53
  */
50
54
  private ranges;
55
+ private resourceNodes;
56
+ private hardDependents;
57
+ private frontierDependents;
58
+ private registeredDependencies;
59
+ private coverageWatchersBySheet;
60
+ private frontierWatchersBySheet;
51
61
  constructor(cacheManager: CacheManager, workbookManager: WorkbookManager);
62
+ private getSheetWatcherKey;
63
+ private addReverseEdge;
64
+ private removeReverseEdge;
65
+ private getWatcherRange;
66
+ private addWatcher;
67
+ private removeWatcher;
68
+ private registerWatcherNode;
69
+ private unregisterWatcherNode;
70
+ private isWatcherNodeResolved;
71
+ private getAllPersistentNodes;
72
+ private getExistingCellValueNode;
73
+ private getExistingSpillMetaNode;
74
+ private getExistingEmptyCellNode;
75
+ private collectExistingNodesForCell;
76
+ private collectSpillOriginsAffectingCell;
77
+ private getLinkedSpillMetaNode;
78
+ private getLinkedCellValueNode;
79
+ registerNode(node: DependencyNode): void;
80
+ unregisterNode(node: DependencyNode): void;
81
+ private rebuildRuntimeIndexes;
52
82
  get spilledValues(): IterableIterator<SpilledValue>;
53
83
  isSpillOrigin(cellAddress: CellAddress): boolean;
54
84
  getSpillValue(cellAddress: CellAddress): SpilledValue | undefined;
@@ -64,11 +94,23 @@ export declare class DependencyManager {
64
94
  };
65
95
  };
66
96
  clearEvaluationCache(): void;
97
+ toSnapshot(evaluationManager: EvaluationManager): {
98
+ dependency: DependencyManagerSnapshot;
99
+ cache: CacheManagerSnapshot;
100
+ };
101
+ restoreFromSnapshot(snapshots: {
102
+ dependency: DependencyManagerSnapshot;
103
+ cache: CacheManagerSnapshot;
104
+ }, evaluationManager: EvaluationManager): void;
105
+ private serializeNodeSnapshot;
106
+ private createNodeFromSnapshot;
67
107
  setSpilledValue(nodeKey: string, spilledValue: SpilledValue): void;
68
108
  getSpilledValue(nodeKey: string): SpilledValue | undefined;
109
+ deleteSpilledValue(nodeKey: string): void;
69
110
  getEmptyCellNode(nodeKey: string): EmptyCellEvaluationNode;
70
111
  getSpillMetaNode(nodeKey: string): SpillMetaNode;
71
112
  getCellValueNode(nodeKey: string): CellValueNode;
113
+ getResourceNode(resourceKey: string): ResourceDependencyNode;
72
114
  getCellValueOrEmptyCellNode(nodeKey: string): CellValueNode | EmptyCellEvaluationNode;
73
115
  getSpillMetaOrEmptySpillMetaNode(nodeKey: string): SpillMetaNode | EmptyCellEvaluationNode;
74
116
  getVirtualCellValueNode(cellAddress: CellAddress, cellValue: SerializedCellValue): VirtualCellValueNode;
@@ -98,6 +140,19 @@ export declare class DependencyManager {
98
140
  * only resolved ast nodes can be saved
99
141
  */
100
142
  private saveAstNode;
143
+ private isFiniteEndAfter;
144
+ private doesAddressAffectWatcherFrontier;
145
+ private collectCoverageWatchers;
146
+ private collectFrontierWatchers;
147
+ private collectWatchersIntersectingRange;
148
+ private getNodeDependents;
149
+ private collectInvalidationExtras;
150
+ private invalidateNodeState;
151
+ private isResourceNodeInRemovedScope;
152
+ private isNodeInRemovedScope;
153
+ private collectNodesForRemovedScopes;
154
+ private purgeRemovedScopes;
155
+ invalidateFromMutation(footprint: MutationInvalidation): void;
101
156
  /**
102
157
  * Get transitive dependencies and transitive frontier dependencies
103
158
  * This is only used by buildEvaluationOrder, so we'll optimize it there
@@ -1,9 +1,10 @@
1
1
  import { AstEvaluationNode } from "../../evaluator/dependency-nodes/ast-evaluation-node";
2
2
  import { CellValueNode } from "../../evaluator/dependency-nodes/cell-value-node";
3
3
  import { EmptyCellEvaluationNode } from "../../evaluator/dependency-nodes/empty-cell-evaluation-node";
4
+ import { ResourceDependencyNode } from "../../evaluator/dependency-nodes/resource-dependency-node";
4
5
  import { SpillMetaNode } from "../../evaluator/dependency-nodes/spill-meta-node";
5
6
  import { RangeEvaluationNode } from "../../evaluator/range-evaluation-node";
6
- export type DependencyNode = CellValueNode | RangeEvaluationNode | EmptyCellEvaluationNode | AstEvaluationNode | SpillMetaNode;
7
+ export type DependencyNode = CellValueNode | RangeEvaluationNode | EmptyCellEvaluationNode | AstEvaluationNode | SpillMetaNode | ResourceDependencyNode;
7
8
  export type CellNodeType = "cell-value" | "empty" | "spill-meta";
8
9
  export type CellNodeKey = `${CellNodeType}:${string}`;
9
10
  export type CellNodeKeyDictionary = {
@@ -1,7 +1,8 @@
1
+ import { AstEvaluationNode } from "../../evaluator/dependency-nodes/ast-evaluation-node";
1
2
  import { CellValueNode } from "../../evaluator/dependency-nodes/cell-value-node";
2
3
  import { RangeEvaluationNode } from "../../evaluator/range-evaluation-node";
3
4
  import { FormulaEvaluator } from "../../evaluator/formula-evaluator";
4
- import { type CellAddress, type CellValue, type SerializedCellValue, type SingleEvaluationResult, type SpreadsheetRange } from "../types";
5
+ import { type CellAddress, type CellValue, type EvaluateAllCellsResult, type FunctionEvaluationResult, type SerializedCellValue, type SingleEvaluationResult, type SpreadsheetRange } from "../types";
5
6
  import type { DependencyManager } from "./dependency-manager";
6
7
  import type { WorkbookManager } from "./workbook-manager";
7
8
  import { SpillMetaNode } from "../../evaluator/dependency-nodes/spill-meta-node";
@@ -9,6 +10,8 @@ import { EmptyCellEvaluationNode } from "../../evaluator/dependency-nodes/empty-
9
10
  import type { TableManager } from "./table-manager";
10
11
  import type { DependencyNode } from "./dependency-node";
11
12
  import { VirtualCellValueNode } from "../../evaluator/dependency-nodes/virtual-cell-value-node";
13
+ import type { NodeSnapshotId, SerializedEvaluateAllCellsResultSnapshot, SerializedFunctionEvaluationResultSnapshot, SerializedSingleEvaluationResultSnapshot, SerializedSpillMetaEvaluationResultSnapshot } from "../engine-snapshot";
14
+ import type { MutationInvalidation } from "../commands/types";
12
15
  export declare class EvaluationManager {
13
16
  private workbookManager;
14
17
  private tableManager;
@@ -17,7 +20,24 @@ export declare class EvaluationManager {
17
20
  private isEvaluating;
18
21
  constructor(workbookManager: WorkbookManager, tableManager: TableManager, formulaEvaluator: FormulaEvaluator, dependencyManager: DependencyManager);
19
22
  clearEvaluationCache(): void;
23
+ invalidateFromMutation(footprint: MutationInvalidation): void;
20
24
  evaluationResultToSerializedValue(evaluation: SingleEvaluationResult, cellAddress: CellAddress, debug?: boolean): SerializedCellValue;
25
+ private buildSnapshotOrigin;
26
+ private serializeErrorEvaluationResultSnapshot;
27
+ serializeSingleEvaluationResultSnapshot(evaluation: SingleEvaluationResult, getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId): SerializedSingleEvaluationResultSnapshot | undefined;
28
+ deserializeSingleEvaluationResultSnapshot(evaluation: SerializedSingleEvaluationResultSnapshot, resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode): SingleEvaluationResult;
29
+ serializeEvaluateAllCellsResultSnapshot(evaluation: EvaluateAllCellsResult, getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId): SerializedEvaluateAllCellsResultSnapshot | undefined;
30
+ deserializeEvaluateAllCellsResultSnapshot(evaluation: SerializedEvaluateAllCellsResultSnapshot, resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode): EvaluateAllCellsResult;
31
+ serializeFunctionEvaluationResultSnapshot(evaluation: FunctionEvaluationResult, options: {
32
+ sourceNode: CellValueNode | SpillMetaNode | AstEvaluationNode;
33
+ getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId;
34
+ }): SerializedFunctionEvaluationResultSnapshot | undefined;
35
+ deserializeFunctionEvaluationResultSnapshot(evaluation: SerializedFunctionEvaluationResultSnapshot, resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode): FunctionEvaluationResult;
36
+ serializeSpillMetaEvaluationResultSnapshot(evaluation: SpillMetaNode["evaluationResult"], options: {
37
+ sourceNode: CellValueNode | SpillMetaNode | AstEvaluationNode;
38
+ getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId;
39
+ }): SerializedSpillMetaEvaluationResultSnapshot | undefined;
40
+ deserializeSpillMetaEvaluationResultSnapshot(evaluation: SerializedSpillMetaEvaluationResultSnapshot, resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode): SpillMetaNode["evaluationResult"];
21
41
  evaluateEmptyCell(node: EmptyCellEvaluationNode): void;
22
42
  evaluateRangeNode(node: RangeEvaluationNode): void;
23
43
  evaluateCellNode(node: CellValueNode | SpillMetaNode | VirtualCellValueNode): void;
@@ -18,13 +18,18 @@ type EvalOrderEntry = {
18
18
  candidates: SpillMetaNode[];
19
19
  };
20
20
  export declare class FrontierDependencyManager {
21
- private frontierRange;
21
+ protected readonly frontierRange: RangeAddress;
22
22
  protected workbookManager: WorkbookManager;
23
23
  protected evaluationManager: DependencyManager;
24
24
  private evalOrder;
25
25
  private _resolved;
26
26
  private _directDepsUpdated;
27
- constructor(frontierRange: RangeAddress, workbookManager: WorkbookManager, evaluationManager: DependencyManager);
27
+ private evalOrderInitialized;
28
+ constructor(frontierRange: RangeAddress, workbookManager: WorkbookManager, evaluationManager: DependencyManager, options?: {
29
+ skipInitialBuild?: boolean;
30
+ });
31
+ protected buildInitialEvalOrder(): void;
32
+ protected ensureEvalOrderBuilt(): void;
28
33
  /**
29
34
  * frontierDependencies is the set of dependency node keys that could spill values onto the target range (if evaluationResult is spilled-values)
30
35
  * Key is from cellAddressToKey
@@ -47,6 +52,11 @@ export declare class FrontierDependencyManager {
47
52
  */
48
53
  get iterateAllCells(): undefined | Iterable<CellInRangeResult>;
49
54
  getRangeEvalOrder(): EvalOrderEntry[];
55
+ getFrontierRange(): RangeAddress;
56
+ restoreResolvedSnapshot(options: {
57
+ dependencies: Set<DependencyNode>;
58
+ }): void;
59
+ invalidate(): void;
50
60
  get frontierDependencies(): Set<SpillMetaNode>;
51
61
  get discardedFrontierDependencies(): Set<SpillMetaNode>;
52
62
  maybeDiscardFrontierDependency(dependency: SpillMetaNode): void;
@@ -1,4 +1,5 @@
1
1
  import type { NamedExpression } from "../types";
2
+ import type { NamedExpressionManagerSnapshot } from "../engine-snapshot";
2
3
  import type { NamedExpressionNode } from "../../parser/ast";
3
4
  import type { EvaluationContext } from "../../evaluator/evaluation-context";
4
5
  export declare class NamedExpressionManager {
@@ -28,7 +29,7 @@ export declare class NamedExpressionManager {
28
29
  workbookName?: string;
29
30
  newName: string;
30
31
  }): boolean;
31
- updateAllNamedExpressions(updateCallback: (formula: string) => string): void;
32
+ updateAllNamedExpressions(updateCallback: (formula: string) => string): string[];
32
33
  /**
33
34
  * Replace all named expressions
34
35
  */
@@ -57,6 +58,19 @@ export declare class NamedExpressionManager {
57
58
  sheetName: string;
58
59
  };
59
60
  }): NamedExpression | undefined;
61
+ resolveNamedExpressionWithScope(namedExpression: Pick<NamedExpressionNode, "name" | "sheetName" | "workbookName">, context: EvaluationContext): {
62
+ expression: string;
63
+ scope: {
64
+ type: "global";
65
+ } | {
66
+ type: "workbook";
67
+ workbookName: string;
68
+ } | {
69
+ type: "sheet";
70
+ workbookName: string;
71
+ sheetName: string;
72
+ };
73
+ } | undefined;
60
74
  resolveNamedExpression(namedExpression: Pick<NamedExpressionNode, "name" | "sheetName" | "workbookName">, context: EvaluationContext): string | undefined;
61
75
  getNamedExpressions(): {
62
76
  sheetExpressions: Map<string, Map<string, Map<string, NamedExpression>>>;
@@ -64,6 +78,8 @@ export declare class NamedExpressionManager {
64
78
  globalExpressions: Map<string, NamedExpression>;
65
79
  };
66
80
  resetNamedExpressions(namedExpressions: ReturnType<typeof this.getNamedExpressions>): void;
81
+ toSnapshot(): NamedExpressionManagerSnapshot;
82
+ restoreFromSnapshot(snapshot: NamedExpressionManagerSnapshot): void;
67
83
  /**
68
84
  * When adding a sheet, we need to initialize the new maps
69
85
  */
@@ -5,6 +5,7 @@
5
5
  * update when sheets/workbooks are renamed and become invalid when deleted.
6
6
  */
7
7
  import type { RangeAddress, TrackedReference } from "../types";
8
+ import type { ReferenceManagerSnapshot } from "../engine-snapshot";
8
9
  export declare class ReferenceManager {
9
10
  private references;
10
11
  constructor();
@@ -51,4 +52,6 @@ export declare class ReferenceManager {
51
52
  * Restore references from serialization
52
53
  */
53
54
  resetReferences(refs: Map<string, TrackedReference>): void;
55
+ toSnapshot(): ReferenceManagerSnapshot;
56
+ restoreFromSnapshot(snapshot: ReferenceManagerSnapshot): void;
54
57
  }
@@ -2,6 +2,7 @@
2
2
  * StyleManager - Manages conditional styling for cells
3
3
  */
4
4
  import type { CellAddress, CellStyle, ConditionalStyle, DirectCellStyle, RangeAddress } from "../types";
5
+ import type { StyleManagerSnapshot } from "../engine-snapshot";
5
6
  import type { EvaluationManager } from "./evaluation-manager";
6
7
  export declare class StyleManager {
7
8
  private evaluationManager;
@@ -50,6 +51,8 @@ export declare class StyleManager {
50
51
  * Reset all styles (for deserialization)
51
52
  */
52
53
  resetStyles(conditionalStyles?: ConditionalStyle[], cellStyles?: DirectCellStyle[]): void;
54
+ toSnapshot(): StyleManagerSnapshot;
55
+ restoreFromSnapshot(snapshot: StyleManagerSnapshot): void;
53
56
  /**
54
57
  * Remove all styles for a workbook
55
58
  */
@@ -1,4 +1,5 @@
1
1
  import type { CellAddress, SerializedCellValue, SpreadsheetRange, SpreadsheetRangeEnd, TableDefinition } from "../types";
2
+ import type { TableManagerSnapshot } from "../engine-snapshot";
2
3
  import type { WorkbookManager } from "./workbook-manager";
3
4
  export declare class TableManager {
4
5
  tables: Map<
@@ -65,6 +66,8 @@ export declare class TableManager {
65
66
  newWorkbookName: string;
66
67
  }): void;
67
68
  resetTables(newTables: Map<string, Map<string, TableDefinition>>): void;
69
+ toSnapshot(): TableManagerSnapshot;
70
+ restoreFromSnapshot(snapshot: TableManagerSnapshot): void;
68
71
  /**
69
72
  * When adding a workbook, we need to initialize the new maps
70
73
  */
@@ -1,4 +1,5 @@
1
1
  import { type CellAddress, type SerializedCellValue, type Sheet, type Workbook } from "../types";
2
+ import type { WorkbookManagerSnapshot } from "../engine-snapshot";
2
3
  import type { RangeAddress } from "../types";
3
4
  interface IndexEntry {
4
5
  number: number;
@@ -54,6 +55,8 @@ export declare class WorkbookManager {
54
55
  newWorkbookName: string;
55
56
  }): void;
56
57
  resetWorkbooks(workbooks: Map<string, Workbook>): void;
58
+ toSnapshot(): WorkbookManagerSnapshot;
59
+ restoreFromSnapshot(snapshot: WorkbookManagerSnapshot): void;
57
60
  getSheet({ workbookName, sheetName, }: {
58
61
  workbookName: string;
59
62
  sheetName: string;
@@ -71,7 +74,7 @@ export declare class WorkbookManager {
71
74
  sheetName: string;
72
75
  newSheetName: string;
73
76
  }): Sheet;
74
- updateAllFormulas(updateCallback: (formula: string) => string): void;
77
+ updateAllFormulas(updateCallback: (formula: string) => string): CellAddress[];
75
78
  updateFormulasExcluding(excludeCellsSet: Set<string>, updateCallback: (formula: string) => string): void;
76
79
  updateFormulasForWorkbook(workbookName: string, updateCallback: (formula: string) => string): void;
77
80
  getSheetSerialized({ workbookName, sheetName, }: {
@@ -0,0 +1,14 @@
1
+ export declare function getNamedExpressionResourceKey(opts: {
2
+ expressionName: string;
3
+ workbookName?: string;
4
+ sheetName?: string;
5
+ }): string;
6
+ export declare function getTableResourceKey(opts: {
7
+ workbookName: string;
8
+ tableName: string;
9
+ }): string;
10
+ export declare function getSheetResourceKey(opts: {
11
+ workbookName: string;
12
+ sheetName: string;
13
+ }): string;
14
+ export declare function getWorkbookResourceKey(workbookName: string): string;
@@ -14,11 +14,16 @@ export declare class BaseEvalNode<T> {
14
14
  get resolved(): boolean;
15
15
  get evaluationResult(): T;
16
16
  setEvaluationResult(result: T): void;
17
+ invalidate(): void;
17
18
  resetDirectDepsUpdated(): void;
18
19
  /**
19
20
  * Get the direct dependencies of the node, either RangeEvaluationNode or DependencyNode
20
21
  */
21
22
  getDependencies(): Set<DependencyNode>;
23
+ restoreResolvedSnapshot(options: {
24
+ dependencies: Set<DependencyNode>;
25
+ evaluationResult: T;
26
+ }): void;
22
27
  /**
23
28
  * Just to mirror the method in RangeEvaluationNode
24
29
  */
@@ -7,4 +7,5 @@ export declare class CellValueNode extends BaseEvalNode<SingleEvaluationResult>
7
7
  toString(): string;
8
8
  spillMeta: SpillMetaNode | undefined;
9
9
  setSpillMetaNode(node: SpillMetaNode): void;
10
+ clearSpillMetaNode(): void;
10
11
  }
@@ -7,11 +7,18 @@ export declare class EmptyCellEvaluationNode extends FrontierDependencyManager {
7
7
  key: string;
8
8
  cellAddress: CellAddress;
9
9
  private _evaluationResult;
10
- constructor(emptyCellKey: string, evaluationManager: DependencyManager, workbookManager: WorkbookManager);
10
+ constructor(emptyCellKey: string, evaluationManager: DependencyManager, workbookManager: WorkbookManager, options?: {
11
+ skipInitialBuild?: boolean;
12
+ });
11
13
  setEvaluationResult(result: SingleEvaluationResult): void;
12
14
  get evaluationResult(): SingleEvaluationResult;
13
15
  resolve(): void;
14
16
  canResolve(): boolean;
17
+ restoreResolvedSnapshot(options: {
18
+ dependencies: Set<import("../../core/managers/dependency-node").DependencyNode>;
19
+ evaluationResult: SingleEvaluationResult;
20
+ }): void;
21
+ invalidate(): void;
15
22
  toJSON(visitor?: Set<string>): any;
16
23
  toString(): string;
17
24
  }
@@ -0,0 +1,8 @@
1
+ import { BaseEvalNode } from "./base-eval-node";
2
+ export declare class ResourceDependencyNode extends BaseEvalNode<{
3
+ type: "resource";
4
+ }> {
5
+ constructor(key: string);
6
+ invalidate(): void;
7
+ toString(): string;
8
+ }
@@ -8,4 +8,5 @@ export declare class VirtualCellValueNode extends BaseEvalNode<SingleEvaluationR
8
8
  toString(): string;
9
9
  spillMeta: SpillMetaNode | undefined;
10
10
  setSpillMetaNode(node: SpillMetaNode): void;
11
+ clearSpillMetaNode(): void;
11
12
  }
@@ -7,10 +7,17 @@ export declare class RangeEvaluationNode extends FrontierDependencyManager {
7
7
  key: string;
8
8
  address: RangeAddress;
9
9
  private _result;
10
- constructor(rangeKey: string, dependencyManager: DependencyManager, workbookManager: WorkbookManager);
10
+ constructor(rangeKey: string, dependencyManager: DependencyManager, workbookManager: WorkbookManager, options?: {
11
+ skipInitialBuild?: boolean;
12
+ });
11
13
  setResult(result: EvaluateAllCellsResult): void;
12
14
  get result(): EvaluateAllCellsResult;
13
15
  canResolve(): boolean;
16
+ restoreResolvedSnapshot(options: {
17
+ dependencies: Set<import("../core/managers/dependency-node").DependencyNode>;
18
+ result: EvaluateAllCellsResult;
19
+ }): void;
20
+ invalidate(): void;
14
21
  toJSON(visitor?: Set<string>): any;
15
22
  toString(): string;
16
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/formula-engine",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "module": "./dist/mjs/lib.mjs",
5
5
  "scripts": {
6
6
  "test": "bun test",
@@ -37,5 +37,9 @@
37
37
  },
38
38
  "files": [
39
39
  "dist"
40
- ]
40
+ ],
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/ricsam/formula-engine.git"
44
+ }
41
45
  }