@dxos/plugin-sheet 0.6.13 → 0.6.14-main.1366248

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 (330) hide show
  1. package/dist/lib/browser/SheetContainer-JZEKRM4Z.mjs +297 -0
  2. package/dist/lib/browser/SheetContainer-JZEKRM4Z.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-BVUN7SHF.mjs +67 -0
  4. package/dist/lib/browser/chunk-BVUN7SHF.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-G2FUL6PK.mjs +1671 -0
  6. package/dist/lib/browser/chunk-G2FUL6PK.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-RABELMEQ.mjs +15 -0
  8. package/dist/lib/browser/chunk-RABELMEQ.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-D5AGLXJP.mjs → chunk-VMSX6Z4X.mjs} +659 -675
  10. package/dist/lib/browser/chunk-VMSX6Z4X.mjs.map +7 -0
  11. package/dist/lib/browser/compute-graph-GGWUX644.mjs +35 -0
  12. package/dist/lib/browser/compute-graph-GGWUX644.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +168 -67
  14. package/dist/lib/browser/index.mjs.map +4 -4
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/meta.mjs +1 -1
  17. package/dist/lib/browser/types.mjs +6 -12
  18. package/dist/lib/node/SheetContainer-PJE74VO4.cjs +300 -0
  19. package/dist/lib/node/SheetContainer-PJE74VO4.cjs.map +7 -0
  20. package/dist/lib/node/chunk-2ZVZI2KJ.cjs +38 -0
  21. package/dist/lib/node/chunk-2ZVZI2KJ.cjs.map +7 -0
  22. package/dist/lib/node/{chunk-DSYKOI4E.cjs → chunk-AWKOWDMI.cjs} +34 -52
  23. package/dist/lib/node/chunk-AWKOWDMI.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-5KKJ4NPP.cjs → chunk-O7XR4R7Y.cjs} +678 -674
  25. package/dist/lib/node/chunk-O7XR4R7Y.cjs.map +7 -0
  26. package/dist/lib/node/chunk-STZ7S7RF.cjs +1656 -0
  27. package/dist/lib/node/chunk-STZ7S7RF.cjs.map +7 -0
  28. package/dist/lib/node/compute-graph-KGWA2QLE.cjs +57 -0
  29. package/dist/lib/node/compute-graph-KGWA2QLE.cjs.map +7 -0
  30. package/dist/lib/node/index.cjs +178 -75
  31. package/dist/lib/node/index.cjs.map +4 -4
  32. package/dist/lib/node/meta.cjs +3 -3
  33. package/dist/lib/node/meta.cjs.map +1 -1
  34. package/dist/lib/node/meta.json +1 -1
  35. package/dist/lib/node/types.cjs +9 -15
  36. package/dist/lib/node/types.cjs.map +2 -2
  37. package/dist/lib/node-esm/SheetContainer-R73XEXHU.mjs +298 -0
  38. package/dist/lib/node-esm/SheetContainer-R73XEXHU.mjs.map +7 -0
  39. package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs +17 -0
  40. package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs.map +7 -0
  41. package/dist/lib/node-esm/chunk-CR4K75EL.mjs +3220 -0
  42. package/dist/lib/node-esm/chunk-CR4K75EL.mjs.map +7 -0
  43. package/dist/lib/node-esm/chunk-UIBWRHW7.mjs +68 -0
  44. package/dist/lib/node-esm/chunk-UIBWRHW7.mjs.map +7 -0
  45. package/dist/lib/node-esm/chunk-V5N3Y2O5.mjs +1672 -0
  46. package/dist/lib/node-esm/chunk-V5N3Y2O5.mjs.map +7 -0
  47. package/dist/lib/node-esm/compute-graph-2SCZT7N5.mjs +36 -0
  48. package/dist/lib/node-esm/compute-graph-2SCZT7N5.mjs.map +7 -0
  49. package/dist/lib/node-esm/index.mjs +350 -0
  50. package/dist/lib/node-esm/index.mjs.map +7 -0
  51. package/dist/lib/node-esm/meta.json +1 -0
  52. package/dist/lib/node-esm/meta.mjs +10 -0
  53. package/dist/lib/node-esm/meta.mjs.map +7 -0
  54. package/dist/lib/node-esm/types.mjs +17 -0
  55. package/dist/lib/node-esm/types.mjs.map +7 -0
  56. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  57. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +13 -0
  58. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
  59. package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
  60. package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
  61. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +3 -0
  62. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -0
  63. package/dist/types/src/components/FunctionEditor/index.d.ts +2 -0
  64. package/dist/types/src/components/FunctionEditor/index.d.ts.map +1 -0
  65. package/dist/types/src/components/GridSheet/GridSheet.d.ts +3 -0
  66. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
  67. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +6 -0
  68. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
  69. package/dist/types/src/components/{CellEditor/CellEditor.stories.d.ts → GridSheet/SheetCellEditor.stories.d.ts} +5 -9
  70. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -0
  71. package/dist/types/src/components/GridSheet/index.d.ts +2 -0
  72. package/dist/types/src/components/GridSheet/index.d.ts.map +1 -0
  73. package/dist/types/src/components/GridSheet/util.d.ts +15 -0
  74. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
  75. package/dist/types/src/components/RangeList/RangeList.d.ts +7 -0
  76. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -0
  77. package/dist/types/src/components/RangeList/index.d.ts +2 -0
  78. package/dist/types/src/components/RangeList/index.d.ts.map +1 -0
  79. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +9 -0
  80. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -0
  81. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +6 -0
  82. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
  83. package/dist/types/src/components/SheetContainer/index.d.ts +3 -0
  84. package/dist/types/src/components/SheetContainer/index.d.ts.map +1 -0
  85. package/dist/types/src/components/SheetContext/SheetContext.d.ts +28 -0
  86. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -0
  87. package/dist/types/src/components/SheetContext/index.d.ts +2 -0
  88. package/dist/types/src/components/SheetContext/index.d.ts.map +1 -0
  89. package/dist/types/src/components/Toolbar/Toolbar.d.ts +36 -9
  90. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  91. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +4 -32
  92. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
  93. package/dist/types/src/components/index.d.ts +7 -4
  94. package/dist/types/src/components/index.d.ts.map +1 -1
  95. package/dist/types/src/compute-graph/compute-graph-registry.d.ts +34 -0
  96. package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +1 -0
  97. package/dist/types/src/compute-graph/compute-graph.d.ts +64 -0
  98. package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -0
  99. package/dist/types/src/compute-graph/compute-graph.stories.d.ts +6 -0
  100. package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +1 -0
  101. package/dist/types/src/compute-graph/compute-graph.test.d.ts +2 -0
  102. package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +1 -0
  103. package/dist/types/src/compute-graph/compute-node.d.ts +26 -0
  104. package/dist/types/src/compute-graph/compute-node.d.ts.map +1 -0
  105. package/dist/types/src/{components/ComputeGraph → compute-graph/functions}/async-function.d.ts +14 -5
  106. package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -0
  107. package/dist/types/src/compute-graph/functions/edge-function.d.ts +21 -0
  108. package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -0
  109. package/dist/types/src/{model/functions.d.ts → compute-graph/functions/function-defs.d.ts} +1 -1
  110. package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +1 -0
  111. package/dist/types/src/compute-graph/functions/index.d.ts +4 -0
  112. package/dist/types/src/compute-graph/functions/index.d.ts.map +1 -0
  113. package/dist/types/src/compute-graph/hyperformula.test.d.ts +2 -0
  114. package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +1 -0
  115. package/dist/types/src/compute-graph/index.d.ts +5 -0
  116. package/dist/types/src/compute-graph/index.d.ts.map +1 -0
  117. package/dist/types/src/compute-graph/testing/index.d.ts +3 -0
  118. package/dist/types/src/compute-graph/testing/index.d.ts.map +1 -0
  119. package/dist/types/src/compute-graph/testing/test-builder.d.ts +15 -0
  120. package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +1 -0
  121. package/dist/types/src/compute-graph/testing/test-plugin.d.ts +36 -0
  122. package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +1 -0
  123. package/dist/types/src/compute-graph/util.d.ts +2 -0
  124. package/dist/types/src/compute-graph/util.d.ts.map +1 -0
  125. package/dist/types/src/defs/index.d.ts +4 -0
  126. package/dist/types/src/defs/index.d.ts.map +1 -0
  127. package/dist/types/src/defs/sheet-range-types.d.ts +13 -0
  128. package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -0
  129. package/dist/types/src/defs/types.d.ts +28 -0
  130. package/dist/types/src/defs/types.d.ts.map +1 -0
  131. package/dist/types/src/defs/types.test.d.ts.map +1 -0
  132. package/dist/types/src/defs/util.d.ts +39 -0
  133. package/dist/types/src/defs/util.d.ts.map +1 -0
  134. package/dist/types/src/extensions/compute.d.ts +6 -0
  135. package/dist/types/src/extensions/compute.d.ts.map +1 -0
  136. package/dist/types/src/extensions/compute.stories.d.ts +21 -0
  137. package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
  138. package/dist/types/src/extensions/editor/extension.d.ts +39 -0
  139. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -0
  140. package/dist/types/src/extensions/editor/extension.test.d.ts.map +1 -0
  141. package/dist/types/src/extensions/editor/index.d.ts +2 -0
  142. package/dist/types/src/extensions/editor/index.d.ts.map +1 -0
  143. package/dist/types/src/extensions/index.d.ts +3 -0
  144. package/dist/types/src/extensions/index.d.ts.map +1 -0
  145. package/dist/types/src/index.d.ts +1 -1
  146. package/dist/types/src/index.d.ts.map +1 -1
  147. package/dist/types/src/integrations/index.d.ts +2 -0
  148. package/dist/types/src/integrations/index.d.ts.map +1 -0
  149. package/dist/types/src/integrations/thread-ranges.d.ts +7 -0
  150. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -0
  151. package/dist/types/src/meta.d.ts +4 -9
  152. package/dist/types/src/meta.d.ts.map +1 -1
  153. package/dist/types/src/model/index.d.ts +2 -3
  154. package/dist/types/src/model/index.d.ts.map +1 -1
  155. package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +22 -69
  156. package/dist/types/src/model/sheet-model.d.ts.map +1 -0
  157. package/dist/types/src/model/sheet-model.test.d.ts +2 -0
  158. package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
  159. package/dist/types/src/model/useSheetModel.d.ts +8 -0
  160. package/dist/types/src/model/useSheetModel.d.ts.map +1 -0
  161. package/dist/types/src/sanity.test.d.ts +2 -0
  162. package/dist/types/src/sanity.test.d.ts.map +1 -0
  163. package/dist/types/src/serializer.d.ts +4 -0
  164. package/dist/types/src/serializer.d.ts.map +1 -0
  165. package/dist/types/src/testing/index.d.ts +2 -0
  166. package/dist/types/src/testing/index.d.ts.map +1 -0
  167. package/dist/types/src/testing/testing.d.ts +8 -0
  168. package/dist/types/src/testing/testing.d.ts.map +1 -0
  169. package/dist/types/src/translations.d.ts +32 -12
  170. package/dist/types/src/translations.d.ts.map +1 -1
  171. package/dist/types/src/types.d.ts +132 -43
  172. package/dist/types/src/types.d.ts.map +1 -1
  173. package/dist/vendor/hyperformula.mjs +37145 -0
  174. package/package.json +60 -61
  175. package/src/SheetPlugin.tsx +89 -78
  176. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +37 -0
  177. package/src/components/ComputeGraph/index.ts +1 -3
  178. package/src/components/FunctionEditor/FunctionEditor.tsx +45 -0
  179. package/src/components/FunctionEditor/index.ts +5 -0
  180. package/src/components/GridSheet/GridSheet.stories.tsx +46 -0
  181. package/src/components/GridSheet/GridSheet.tsx +358 -0
  182. package/src/components/{CellEditor/CellEditor.stories.tsx → GridSheet/SheetCellEditor.stories.tsx} +18 -15
  183. package/src/components/GridSheet/index.ts +5 -0
  184. package/src/components/GridSheet/util.ts +170 -0
  185. package/src/components/RangeList/RangeList.tsx +53 -0
  186. package/src/components/RangeList/index.ts +5 -0
  187. package/src/components/SheetContainer/SheetContainer.stories.tsx +45 -0
  188. package/src/components/SheetContainer/SheetContainer.tsx +33 -0
  189. package/src/components/SheetContainer/index.ts +7 -0
  190. package/src/components/SheetContext/SheetContext.tsx +127 -0
  191. package/src/components/SheetContext/index.ts +5 -0
  192. package/src/components/Toolbar/Toolbar.stories.tsx +9 -6
  193. package/src/components/Toolbar/Toolbar.tsx +265 -111
  194. package/src/components/index.ts +5 -3
  195. package/src/compute-graph/compute-graph-registry.ts +90 -0
  196. package/src/compute-graph/compute-graph.stories.tsx +97 -0
  197. package/src/compute-graph/compute-graph.test.ts +87 -0
  198. package/src/compute-graph/compute-graph.ts +260 -0
  199. package/src/compute-graph/compute-node.ts +62 -0
  200. package/src/{components/ComputeGraph → compute-graph/functions}/async-function.ts +26 -15
  201. package/src/{components/ComputeGraph → compute-graph/functions}/edge-function.ts +21 -17
  202. package/src/compute-graph/functions/index.ts +7 -0
  203. package/src/compute-graph/hyperformula.test.ts +14 -0
  204. package/src/compute-graph/index.ts +8 -0
  205. package/src/compute-graph/testing/index.ts +6 -0
  206. package/src/compute-graph/testing/test-builder.ts +54 -0
  207. package/src/{components/ComputeGraph/custom.ts → compute-graph/testing/test-plugin.ts} +44 -14
  208. package/src/compute-graph/util.ts +8 -0
  209. package/src/defs/index.ts +7 -0
  210. package/src/defs/sheet-range-types.ts +49 -0
  211. package/src/{model → defs}/types.test.ts +8 -9
  212. package/src/defs/types.ts +86 -0
  213. package/src/defs/util.ts +136 -0
  214. package/src/extensions/compute.stories.tsx +155 -0
  215. package/src/extensions/compute.ts +147 -0
  216. package/src/{components/CellEditor → extensions/editor}/extension.test.ts +4 -6
  217. package/src/{components/CellEditor → extensions/editor}/extension.ts +51 -27
  218. package/src/{components/CellEditor → extensions/editor}/index.ts +0 -1
  219. package/src/extensions/index.ts +6 -0
  220. package/src/index.ts +2 -2
  221. package/src/integrations/index.ts +5 -0
  222. package/src/integrations/thread-ranges.ts +101 -0
  223. package/src/meta.ts +15 -0
  224. package/src/model/index.ts +2 -3
  225. package/src/model/sheet-model.test.ts +59 -0
  226. package/src/model/sheet-model.ts +495 -0
  227. package/src/model/useSheetModel.ts +40 -0
  228. package/src/sanity.test.ts +40 -0
  229. package/src/serializer.ts +27 -0
  230. package/src/{components/Sheet → testing}/index.ts +1 -1
  231. package/src/testing/testing.tsx +68 -0
  232. package/src/translations.ts +24 -4
  233. package/src/types.ts +62 -47
  234. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs +0 -1772
  235. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +0 -7
  236. package/dist/lib/browser/chunk-APHOLYUB.mjs +0 -175
  237. package/dist/lib/browser/chunk-APHOLYUB.mjs.map +0 -7
  238. package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +0 -7
  239. package/dist/lib/browser/chunk-FUAGSXA4.mjs +0 -82
  240. package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +0 -7
  241. package/dist/lib/browser/chunk-JRL5LGCE.mjs +0 -18
  242. package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
  243. package/dist/lib/browser/chunk-NU4PBN33.mjs +0 -8
  244. package/dist/lib/browser/chunk-NU4PBN33.mjs.map +0 -7
  245. package/dist/lib/browser/testing.mjs +0 -92
  246. package/dist/lib/browser/testing.mjs.map +0 -7
  247. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +0 -1765
  248. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +0 -7
  249. package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +0 -7
  250. package/dist/lib/node/chunk-BJ6ZD7MN.cjs +0 -51
  251. package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
  252. package/dist/lib/node/chunk-CN3RPESU.cjs +0 -202
  253. package/dist/lib/node/chunk-CN3RPESU.cjs.map +0 -7
  254. package/dist/lib/node/chunk-DSYKOI4E.cjs.map +0 -7
  255. package/dist/lib/node/chunk-PYXHNAAK.cjs +0 -40
  256. package/dist/lib/node/chunk-PYXHNAAK.cjs.map +0 -7
  257. package/dist/lib/node/testing.cjs +0 -111
  258. package/dist/lib/node/testing.cjs.map +0 -7
  259. package/dist/types/src/components/CellEditor/CellEditor.d.ts +0 -14
  260. package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +0 -1
  261. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +0 -1
  262. package/dist/types/src/components/CellEditor/extension.d.ts +0 -19
  263. package/dist/types/src/components/CellEditor/extension.d.ts.map +0 -1
  264. package/dist/types/src/components/CellEditor/extension.test.d.ts.map +0 -1
  265. package/dist/types/src/components/CellEditor/index.d.ts +0 -3
  266. package/dist/types/src/components/CellEditor/index.d.ts.map +0 -1
  267. package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
  268. package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
  269. package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
  270. package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
  271. package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
  272. package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
  273. package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
  274. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
  275. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
  276. package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
  277. package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
  278. package/dist/types/src/components/Sheet/Sheet.d.ts +0 -55
  279. package/dist/types/src/components/Sheet/Sheet.d.ts.map +0 -1
  280. package/dist/types/src/components/Sheet/Sheet.stories.d.ts +0 -54
  281. package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +0 -1
  282. package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
  283. package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
  284. package/dist/types/src/components/Sheet/grid.d.ts +0 -52
  285. package/dist/types/src/components/Sheet/grid.d.ts.map +0 -1
  286. package/dist/types/src/components/Sheet/index.d.ts +0 -2
  287. package/dist/types/src/components/Sheet/index.d.ts.map +0 -1
  288. package/dist/types/src/components/Sheet/nav.d.ts +0 -29
  289. package/dist/types/src/components/Sheet/nav.d.ts.map +0 -1
  290. package/dist/types/src/components/Sheet/sheet-context.d.ts +0 -25
  291. package/dist/types/src/components/Sheet/sheet-context.d.ts.map +0 -1
  292. package/dist/types/src/components/Sheet/util.d.ts +0 -18
  293. package/dist/types/src/components/Sheet/util.d.ts.map +0 -1
  294. package/dist/types/src/components/SheetContainer.d.ts +0 -9
  295. package/dist/types/src/components/SheetContainer.d.ts.map +0 -1
  296. package/dist/types/src/components/Toolbar/common.d.ts +0 -20
  297. package/dist/types/src/components/Toolbar/common.d.ts.map +0 -1
  298. package/dist/types/src/model/functions.d.ts.map +0 -1
  299. package/dist/types/src/model/model.browser.test.d.ts +0 -2
  300. package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
  301. package/dist/types/src/model/model.d.ts.map +0 -1
  302. package/dist/types/src/model/types.d.ts +0 -17
  303. package/dist/types/src/model/types.d.ts.map +0 -1
  304. package/dist/types/src/model/types.test.d.ts.map +0 -1
  305. package/dist/types/src/model/util.d.ts +0 -15
  306. package/dist/types/src/model/util.d.ts.map +0 -1
  307. package/dist/types/src/testing.d.ts +0 -9
  308. package/dist/types/src/testing.d.ts.map +0 -1
  309. package/src/components/CellEditor/CellEditor.tsx +0 -113
  310. package/src/components/ComputeGraph/graph-context.tsx +0 -50
  311. package/src/components/ComputeGraph/graph.browser.test.ts +0 -50
  312. package/src/components/ComputeGraph/graph.ts +0 -62
  313. package/src/components/Sheet/Sheet.stories.tsx +0 -287
  314. package/src/components/Sheet/Sheet.tsx +0 -1160
  315. package/src/components/Sheet/formatting.ts +0 -106
  316. package/src/components/Sheet/grid.ts +0 -191
  317. package/src/components/Sheet/nav.ts +0 -157
  318. package/src/components/Sheet/sheet-context.tsx +0 -150
  319. package/src/components/Sheet/util.ts +0 -56
  320. package/src/components/SheetContainer.tsx +0 -34
  321. package/src/components/Toolbar/common.tsx +0 -72
  322. package/src/meta.tsx +0 -18
  323. package/src/model/model.browser.test.ts +0 -100
  324. package/src/model/model.ts +0 -550
  325. package/src/model/types.ts +0 -71
  326. package/src/model/util.ts +0 -36
  327. package/src/testing.ts +0 -50
  328. /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
  329. /package/dist/types/src/{components/CellEditor → extensions/editor}/extension.test.d.ts +0 -0
  330. /package/src/{model/functions.ts → compute-graph/functions/function-defs.ts} +0 -0
@@ -0,0 +1,87 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type CellValue } from 'hyperformula';
6
+ import { afterEach, beforeEach, describe, expect, test } from 'vitest';
7
+
8
+ import { Trigger } from '@dxos/async';
9
+ import { create, fullyQualifiedId } from '@dxos/client/echo';
10
+ import { FunctionType } from '@dxos/plugin-script/types';
11
+
12
+ import { DetailedCellError } from '#hyperformula';
13
+ import { TestBuilder } from './testing';
14
+
15
+ describe('ComputeGraph', () => {
16
+ let testBuilder: TestBuilder;
17
+ beforeEach(async () => {
18
+ testBuilder = new TestBuilder({ types: [FunctionType] });
19
+ await testBuilder.open();
20
+ });
21
+ afterEach(async () => {
22
+ await testBuilder.close();
23
+ });
24
+
25
+ test('map functions', async () => {
26
+ const space = await testBuilder.client.spaces.create();
27
+ const graph = testBuilder.registry.createGraph(space);
28
+ await graph.open();
29
+
30
+ // Create script.
31
+ const trigger = new Trigger();
32
+ graph.update.once(() => trigger.wake());
33
+ const functionObject = space.db.add(create(FunctionType, { version: 1, binding: 'TEST' }));
34
+ await trigger.wait();
35
+ const functions = graph.getFunctions({ echo: true });
36
+ expect(functions).to.toHaveLength(1);
37
+
38
+ const id = graph.mapFunctionBindingToId('TEST()');
39
+ expect(id).to.eq(`${fullyQualifiedId(functionObject)}()`);
40
+ });
41
+
42
+ test('cross-node references', async () => {
43
+ const space = await testBuilder.client.spaces.create();
44
+ const graph = testBuilder.registry.createGraph(space);
45
+
46
+ // Create nodes.
47
+ const node1 = await graph.getOrCreateNode('node-1').open();
48
+ const node2 = await graph.getOrCreateNode('node-2').open();
49
+ expect(graph.hf.getSheetNames()).to.toHaveLength(2);
50
+
51
+ {
52
+ node1.graph.hf.setCellContents({ sheet: node1.sheetId, row: 0, col: 0 }, [[100, 200, 300, '=SUM(A1:C1)']]);
53
+ node2.graph.hf.setCellContents({ sheet: node2.sheetId, row: 0, col: 0 }, "='node-1'!D1");
54
+ const value1 = node1.graph.hf.getCellValue({ sheet: node1.sheetId, col: 3, row: 0 });
55
+ const value2 = node2.graph.hf.getCellValue({ sheet: node2.sheetId, col: 0, row: 0 });
56
+ expect(value1).to.eq(value2);
57
+ }
58
+
59
+ // Get updated event.
60
+ const trigger = new Trigger<CellValue>();
61
+ node2.update.on(({ change }) => {
62
+ const value = node2.graph.hf.getCellValue({ sheet: node2.sheetId, col: 0, row: 0 });
63
+ expect(value).to.eq(change?.newValue);
64
+ trigger.wake(value);
65
+ });
66
+
67
+ {
68
+ node1.graph.hf.setCellContents({ sheet: node1.sheetId, row: 0, col: 0 }, 400);
69
+ const value1 = node1.graph.hf.getCellValue({ sheet: node1.sheetId, col: 3, row: 0 });
70
+ const value2 = await trigger.wait();
71
+ expect(value1).to.eq(value2);
72
+ }
73
+ });
74
+
75
+ // TODO(burdon): Dynamically load node/model based on dependencies.
76
+ // - Create dependency then close model.
77
+ test('dynamic loading', async () => {
78
+ const space = await testBuilder.client.spaces.create();
79
+ const graph = testBuilder.registry.createGraph(space);
80
+
81
+ const node1 = await graph.getOrCreateNode('node-1').open();
82
+ node1.graph.hf.setCellContents({ sheet: node1.sheetId, row: 0, col: 0 }, "='node-2'!A1");
83
+ const value1 = node1.graph.hf.getCellValue({ sheet: node1.sheetId, col: 0, row: 0 });
84
+ expect(value1).to.be.instanceof(DetailedCellError);
85
+ expect((value1 as DetailedCellError).type).to.eq('REF');
86
+ });
87
+ });
@@ -0,0 +1,260 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type Listeners } from 'hyperformula/typings/Emitter';
6
+
7
+ import { Event } from '@dxos/async';
8
+ import { type Space, Filter, fullyQualifiedId } from '@dxos/client/echo';
9
+ import { FQ_ID_LENGTH } from '@dxos/client/echo';
10
+ import { Resource } from '@dxos/context';
11
+ import { getTypename } from '@dxos/echo-schema';
12
+ import { invariant } from '@dxos/invariant';
13
+ import { PublicKey } from '@dxos/keys';
14
+ import { log } from '@dxos/log';
15
+ import { FunctionType } from '@dxos/plugin-script/types';
16
+ import { nonNullable } from '@dxos/util';
17
+
18
+ import { ExportedCellChange, type HyperFormula } from '#hyperformula';
19
+ import { ComputeNode } from './compute-node';
20
+ import {
21
+ defaultFunctions,
22
+ FunctionContext,
23
+ type FunctionContextOptions,
24
+ type FunctionDefinition,
25
+ EDGE_FUNCTION_NAME,
26
+ } from './functions';
27
+
28
+ // TODO(burdon): Factor out compute-graph.
29
+
30
+ const UNKNOWN_BINDING = '__UNKNOWN__';
31
+
32
+ // TODO(burdon): Factory.
33
+ // export type ComputeNodeGenerator = <T>(obj: T) => ComputeNode;
34
+
35
+ type ObjectRef = { type: string; id: string };
36
+
37
+ /**
38
+ * Marker for sheets that are managed by an ECHO object.
39
+ * Sheet ID: `dxos.org/type/SheetType@1234`
40
+ */
41
+ export const createSheetName = ({ type, id }: ObjectRef) => `${type}@${id}`;
42
+ export const parseSheetName = (name: string): Partial<ObjectRef> => {
43
+ const [type, id] = name.split('@');
44
+ return id ? { type, id } : { id: type };
45
+ };
46
+
47
+ export type ComputeGraphEvent = 'functionsUpdated' | 'valuesUpdated';
48
+
49
+ /**
50
+ * Per-space compute and dependency graph.
51
+ * Consists of multiple ComputeNode (corresponding to a HyperFormula sheet).
52
+ * Manages the set of custom functions.
53
+ * HyperFormula manages the dependency graph.
54
+ */
55
+ export class ComputeGraph extends Resource {
56
+ public readonly id = `graph-${PublicKey.random().truncate()}`;
57
+
58
+ // Map of nodes indexed by sheet number.
59
+ private readonly _nodes = new Map<number, ComputeNode>();
60
+
61
+ // Cached function objects.
62
+ private _remoteFunctions: FunctionType[] = [];
63
+
64
+ public readonly update = new Event<{ type: ComputeGraphEvent }>();
65
+
66
+ // The context is passed to all functions.
67
+ public readonly context: FunctionContext;
68
+
69
+ constructor(
70
+ private readonly _hf: HyperFormula,
71
+ private readonly _space?: Space,
72
+ private readonly _options?: Partial<FunctionContextOptions>,
73
+ ) {
74
+ super();
75
+
76
+ const contextOptions = {
77
+ ...this._options,
78
+ onUpdate: (update) => {
79
+ this._options?.onUpdate?.(update);
80
+ this.update.emit({ type: 'valuesUpdated' });
81
+ },
82
+ } satisfies Partial<FunctionContextOptions>;
83
+ this.context = new FunctionContext(this._hf, this._space, contextOptions);
84
+ this._hf.updateConfig({ context: this.context });
85
+
86
+ // TODO(burdon): If debounce then aggregate changes.
87
+ const onValuesUpdate: Listeners['valuesUpdated'] = (changes) => {
88
+ for (const change of changes) {
89
+ if (change instanceof ExportedCellChange) {
90
+ const { sheet } = change;
91
+ const node = this._nodes.get(sheet);
92
+ if (node) {
93
+ node.update.emit({ type: 'valuesUpdated', change });
94
+ }
95
+ }
96
+ }
97
+ };
98
+
99
+ this._hf.on('valuesUpdated', onValuesUpdate);
100
+ this._ctx.onDispose(() => this._hf.off('valuesUpdated', onValuesUpdate));
101
+ }
102
+
103
+ get hf() {
104
+ return this._hf;
105
+ }
106
+
107
+ getFunctions(
108
+ { standard, echo }: { standard?: boolean; echo?: boolean } = { standard: true, echo: true },
109
+ ): FunctionDefinition[] {
110
+ return [
111
+ ...(standard
112
+ ? this._hf
113
+ .getRegisteredFunctionNames()
114
+ .map((name) => defaultFunctions.find((fn) => fn.name === name) ?? { name })
115
+ : []),
116
+ ...(echo ? this._remoteFunctions.map((fn) => ({ name: fn.binding! })) : []),
117
+ ];
118
+ }
119
+
120
+ /**
121
+ * Get or create cell representing a sheet.
122
+ */
123
+ // TODO(burdon): Async (open node).
124
+ // The graph should be an extensible factory that plugins extend with model constructors.
125
+ // This would enable on-the-fly instantiation of new models when then are referenced.
126
+ // E.g., Cross-object reference would be stored as "ObjectId!A1"
127
+ // The graph would then load the object and create a ComputeNode (model) of the appropriate type.
128
+ getOrCreateNode(name: string): ComputeNode {
129
+ invariant(name.length);
130
+ if (!this._hf.doesSheetExist(name)) {
131
+ log('created node', { space: this._space?.id, sheet: name });
132
+ this._hf.addSheet(name);
133
+ }
134
+
135
+ const sheetId = this._hf.getSheetId(name);
136
+ invariant(sheetId !== undefined);
137
+
138
+ const node = new ComputeNode(this, sheetId);
139
+ this._nodes.set(sheetId, node);
140
+ return node;
141
+ }
142
+
143
+ /**
144
+ * Map bound value to custom function invocation.
145
+ * E.g., "HELLO(...args)" => "DX("HELLO", ...args)".
146
+ */
147
+ mapFormulaToNative(formula: string): string {
148
+ return (
149
+ formula
150
+ //
151
+ // Map cross-sheet references by name onto sheet stored by ECHO object/model.
152
+ // Example: "Test Sheet"!A0 => "dxos.org/type/SheetType@1234"!A0
153
+ // https://hyperformula.handsontable.com/guide/cell-references.html#cell-references
154
+ //
155
+ .replace(/['"]?([ \w]+)['"]?!/, (_match, name) => {
156
+ if (name) {
157
+ // TODO(burdon): Cache map.
158
+ const objects = this._hf
159
+ .getSheetNames()
160
+ .map((name) => {
161
+ const { type, id } = parseSheetName(name);
162
+ return type && id ? this._space?.db.getObjectById(id) : undefined;
163
+ })
164
+ .filter(nonNullable);
165
+
166
+ for (const obj of objects) {
167
+ if (obj.name === name) {
168
+ const type = getTypename(obj)!;
169
+ // NOTE: Names must be single quoted.
170
+ return `'${createSheetName({ type, id: obj.id })}'!`;
171
+ }
172
+ }
173
+ }
174
+
175
+ return `${name}!`;
176
+ })
177
+
178
+ //
179
+ // Map remote function references (i.e., to remote DX function invocation).
180
+ //
181
+ .replace(/(\w+)\((.*)\)/g, (match, binding, args) => {
182
+ const fn = this._remoteFunctions.find((fn) => fn.binding === binding);
183
+ if (!fn) {
184
+ return match;
185
+ }
186
+
187
+ if (args.trim() === '') {
188
+ return `${EDGE_FUNCTION_NAME}("${binding}")`;
189
+ } else {
190
+ return `${EDGE_FUNCTION_NAME}("${binding}", ${args})`;
191
+ }
192
+ })
193
+ );
194
+ }
195
+
196
+ /**
197
+ * Map from binding to fully qualified ECHO ID (to store).
198
+ * E.g., HELLO() => spaceId:objectId()
199
+ */
200
+ mapFunctionBindingToId(formula: string) {
201
+ return formula.replace(/(\w+)\((.*)\)/g, (match, binding, args) => {
202
+ if (binding === EDGE_FUNCTION_NAME || defaultFunctions.find((fn) => fn.name === binding)) {
203
+ return match;
204
+ }
205
+
206
+ const fn = this._remoteFunctions.find((fn) => fn.binding === binding);
207
+ if (fn) {
208
+ const id = fullyQualifiedId(fn);
209
+ return `${id}(${args})`;
210
+ } else {
211
+ return match;
212
+ }
213
+ });
214
+ }
215
+
216
+ /**
217
+ * Map from fully qualified ECHO ID to binding (from store).
218
+ * E.g., spaceId:objectId() => HELLO()
219
+ */
220
+ mapFunctionBindingFromId(formula: string) {
221
+ const binding = formula.replace(/(\w+):([a-zA-Z0-9]+)\((.*)\)/g, (match, spaceId, objectId, args) => {
222
+ const id = `${spaceId}:${objectId}`;
223
+ if (id.length !== FQ_ID_LENGTH) {
224
+ return match;
225
+ }
226
+
227
+ const fn = this._remoteFunctions.find((fn) => fullyQualifiedId(fn) === id);
228
+ if (fn?.binding) {
229
+ return `${fn.binding}(${args})`;
230
+ } else {
231
+ return UNKNOWN_BINDING;
232
+ }
233
+ });
234
+
235
+ if (binding.startsWith(`=${UNKNOWN_BINDING}`)) {
236
+ return undefined;
237
+ } else {
238
+ return binding;
239
+ }
240
+ }
241
+
242
+ protected override async _open() {
243
+ if (this._space) {
244
+ // Subscribe to remote function definitions.
245
+ const query = this._space.db.query(Filter.schema(FunctionType));
246
+ const unsubscribe = query.subscribe(({ objects }) => {
247
+ this._remoteFunctions = objects.filter(({ binding }) => binding);
248
+ this.update.emit({ type: 'functionsUpdated' });
249
+ });
250
+
251
+ this._ctx.onDispose(unsubscribe);
252
+ }
253
+ }
254
+
255
+ protected override async _close() {
256
+ for (const node of this._nodes.values()) {
257
+ await node.close();
258
+ }
259
+ }
260
+ }
@@ -0,0 +1,62 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type Listeners } from 'hyperformula/typings/Emitter';
6
+ import { type ExportedCellChange } from 'hyperformula/typings/Exporter';
7
+
8
+ import { Event } from '@dxos/async';
9
+ import { Resource } from '@dxos/context';
10
+
11
+ import { DetailedCellError } from '#hyperformula';
12
+ import { type ComputeGraph } from './compute-graph';
13
+ import { type CellAddress, isFormula } from '../defs';
14
+ import { type CellScalarValue } from '../types';
15
+
16
+ export type ComputeNodeEvent = {
17
+ type: keyof Listeners;
18
+ change?: ExportedCellChange;
19
+ };
20
+
21
+ /**
22
+ * Individual "sheet" (typically corresponds to an ECHO object).
23
+ */
24
+ // TODO(burdon): Factor out common HF wrapper from from SheetModel.
25
+ export class ComputeNode extends Resource {
26
+ public readonly update = new Event<ComputeNodeEvent>();
27
+
28
+ constructor(
29
+ private readonly _graph: ComputeGraph,
30
+ public readonly sheetId: number,
31
+ ) {
32
+ super();
33
+ }
34
+
35
+ get graph() {
36
+ return this._graph;
37
+ }
38
+
39
+ clear() {
40
+ this._graph.hf.clearSheet(this.sheetId);
41
+ }
42
+
43
+ getValue(cell: CellAddress): CellScalarValue {
44
+ const value = this._graph.hf.getCellValue({ sheet: this.sheetId, row: cell.row, col: cell.col });
45
+ if (value instanceof DetailedCellError) {
46
+ return null;
47
+ }
48
+
49
+ return value;
50
+ }
51
+
52
+ setValue(cell: CellAddress, value: CellScalarValue) {
53
+ const mappedValue = isFormula(value) ? this._graph.mapFormulaToNative(value) : value;
54
+ this._graph.hf.setCellContents({ sheet: this.sheetId, row: cell.row, col: cell.col }, [[mappedValue]]);
55
+ }
56
+
57
+ // TODO(burdon): Load data into sheet.
58
+ protected override async _open() {
59
+ // const unsubscribe = this._graph.update.on(this.update.emit);
60
+ // this._ctx.onDispose(unsubscribe);
61
+ }
62
+ }
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { CellError, ErrorType, EmptyValue, FunctionPlugin, type HyperFormula } from 'hyperformula';
5
+ import { type SimpleCellAddress } from 'hyperformula/typings/Cell';
6
6
  import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
7
7
  import { type InterpreterValue } from 'hyperformula/typings/interpreter/InterpreterValue';
8
8
  import { type ProcedureAst } from 'hyperformula/typings/parser';
@@ -12,28 +12,35 @@ import { debounce, type UnsubscribeCallback } from '@dxos/async';
12
12
  import { type Space } from '@dxos/client/echo';
13
13
  import { log } from '@dxos/log';
14
14
 
15
- // TODO(burdon): API gateways!
15
+ import { CellError, ErrorType, EmptyValue, FunctionPlugin, type HyperFormula } from '#hyperformula';
16
+
17
+ // TODO(burdon): Create API gateways:
16
18
  // https://publicapis.io
17
19
  // https://api-ninjas.com/api/cryptoprice
18
20
  // https://developers.google.com/apis-explorer
19
21
  // https://publicapis.io/coin-desk-api
20
22
 
21
- // TODO(burdon): Create wrapper.
22
23
  export type AsyncFunction = (...args: any) => Promise<InterpreterValue>;
23
24
 
25
+ export type FunctionUpdateEvent = {
26
+ name: string;
27
+ cell: SimpleCellAddress;
28
+ };
29
+
24
30
  export type FunctionOptions = {
25
31
  ttl?: number;
26
32
  };
27
33
 
28
34
  export type FunctionContextOptions = {
29
35
  defaultTtl: number;
30
- recalculationDelay: number;
36
+ debounceDelay: number;
31
37
  remoteFunctionUrl: string;
38
+ onUpdate?: (update: FunctionUpdateEvent) => void;
32
39
  };
33
40
 
34
41
  export const defaultFunctionContextOptions: FunctionContextOptions = {
35
42
  defaultTtl: 5_000,
36
- recalculationDelay: 200,
43
+ debounceDelay: 200,
37
44
  remoteFunctionUrl: 'https://edge.dxos.workers.dev/functions', // TODO(burdon): Config.
38
45
  };
39
46
 
@@ -65,21 +72,22 @@ export class FunctionContext {
65
72
  private _invocations: Record<string, number> = {};
66
73
 
67
74
  private readonly _options: FunctionContextOptions;
68
- private readonly _onUpdate: () => void;
75
+
76
+ // Debounced update handler.
77
+ private readonly _onUpdate: (update: FunctionUpdateEvent) => void;
69
78
 
70
79
  constructor(
71
80
  private readonly _hf: HyperFormula,
72
81
  private readonly _space: Space | undefined,
73
- onUpdate: (context: FunctionContext) => void,
74
82
  _options?: Partial<FunctionContextOptions>,
75
83
  ) {
76
84
  this._options = defaultsDeep(_options ?? {}, defaultFunctionContextOptions);
77
- this._onUpdate = debounce(() => {
78
- // TODO(burdon): Better way to trigger recalculation?
79
- // NOTE: rebuildAndRecalculate resets the undo history.
85
+ this._onUpdate = debounce((update) => {
86
+ log('update', update);
87
+ // TODO(burdon): Better way to trigger recalculation? (NOTE: rebuildAndRecalculate resets the undo history.)
80
88
  this._hf.resumeEvaluation();
81
- onUpdate(this);
82
- }, this._options.recalculationDelay);
89
+ this._options.onUpdate?.(update);
90
+ }, this._options.debounceDelay);
83
91
  }
84
92
 
85
93
  get space() {
@@ -134,7 +142,7 @@ export class FunctionContext {
134
142
  const value = await cb(...args);
135
143
  this._cache.set(invocationKey, { value, ts: Date.now() });
136
144
  log('set', { cell, value });
137
- this._onUpdate();
145
+ this._onUpdate({ name, cell });
138
146
  } catch (err) {
139
147
  // TODO(burdon): Show error to user.
140
148
  log.warn('failed', { cell, err });
@@ -153,12 +161,15 @@ export class FunctionContext {
153
161
  /**
154
162
  * Base class for async functions.
155
163
  */
156
- export class FunctionPluginAsync extends FunctionPlugin {
164
+ export class AsyncFunctionPlugin extends FunctionPlugin {
157
165
  get context() {
158
166
  return this.config.context as FunctionContext;
159
167
  }
160
168
 
161
- runAsyncFunction(ast: ProcedureAst, state: InterpreterState, cb: AsyncFunction, options?: FunctionOptions) {
169
+ /**
170
+ * Immediately returns cached value then runs the async function.
171
+ */
172
+ protected runAsyncFunction(ast: ProcedureAst, state: InterpreterState, cb: AsyncFunction, options?: FunctionOptions) {
162
173
  const { procedureName } = ast;
163
174
  const metadata = this.metadata(procedureName);
164
175
  return this.runFunction(ast.args, state, metadata, (...args: any) => {
@@ -3,7 +3,6 @@
3
3
  //
4
4
 
5
5
  import { effect } from '@preact/signals-core';
6
- import { CellError, ErrorType, FunctionArgumentType } from 'hyperformula';
7
6
  import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
8
7
  import { type ProcedureAst } from 'hyperformula/typings/parser';
9
8
 
@@ -13,17 +12,20 @@ import { getUserFunctionUrlInMetadata } from '@dxos/plugin-script/edge';
13
12
  import { FunctionType } from '@dxos/plugin-script/types';
14
13
  import { nonNullable } from '@dxos/util';
15
14
 
16
- import { type AsyncFunction, FunctionPluginAsync } from './async-function';
15
+ import { CellError, ErrorType, FunctionArgumentType } from '#hyperformula';
16
+ import { type AsyncFunction, AsyncFunctionPlugin } from './async-function';
17
17
 
18
- const EDGE_FUNCTION_TTL = 10_000;
18
+ export const EDGE_FUNCTION_NAME = 'DX';
19
+
20
+ const FUNCTION_TTL = 10_000;
19
21
 
20
22
  /**
21
- * A hyperformula function plugin for calling EDGE functions.
23
+ * A hyperformula function plugin for calling remote (EDGE) functions.
22
24
  *
23
25
  * https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
24
26
  */
25
- export class EdgeFunctionPlugin extends FunctionPluginAsync {
26
- edge(ast: ProcedureAst, state: InterpreterState) {
27
+ export class EdgeFunctionPlugin extends AsyncFunctionPlugin {
28
+ dx(ast: ProcedureAst, state: InterpreterState) {
27
29
  const handler =
28
30
  (subscribe = false): AsyncFunction =>
29
31
  async (binding: string, ...args: any) => {
@@ -42,39 +44,41 @@ export class EdgeFunctionPlugin extends FunctionPluginAsync {
42
44
 
43
45
  if (subscribe) {
44
46
  const unsubscribe = effect(() => {
45
- log.info('function changed', { fn });
47
+ log('function changed', { fn });
46
48
  const _ = fn?.version;
47
49
 
48
50
  // TODO(wittjosiah): `ttl` should be 0 to force a recalculation when a new version is deployed.
49
51
  // This needs a ttl to prevent a binding change from causing the function not to be found.
50
- this.runAsyncFunction(ast, state, handler(false), { ttl: EDGE_FUNCTION_TTL });
52
+ this.runAsyncFunction(ast, state, handler(false), { ttl: FUNCTION_TTL });
51
53
  });
52
54
 
53
55
  this.context.createSubscription(ast.procedureName, unsubscribe);
54
56
  }
55
57
 
56
58
  const path = getUserFunctionUrlInMetadata(getMeta(fn));
57
- const result = await fetch(`${this.context.remoteFunctionUrl}${path}`, {
59
+ const response = await fetch(`${this.context.remoteFunctionUrl}${path}`, {
58
60
  method: 'POST',
59
61
  headers: { 'Content-Type': 'application/json' },
60
62
  body: JSON.stringify({ args: args.filter(nonNullable) }),
61
63
  });
62
- return await result.text();
64
+ const result = await response.text();
65
+ log('function executed', { result });
66
+
67
+ return result;
63
68
  };
64
69
 
65
- return this.runAsyncFunction(ast, state, handler(true), { ttl: EDGE_FUNCTION_TTL });
70
+ return this.runAsyncFunction(ast, state, handler(true), { ttl: FUNCTION_TTL });
66
71
  }
67
72
  }
68
73
 
69
74
  EdgeFunctionPlugin.implementedFunctions = {
70
- EDGE: {
71
- method: 'edge',
75
+ [EDGE_FUNCTION_NAME]: {
76
+ method: 'dx',
72
77
  parameters: [
73
78
  // Binding
74
79
  { argumentType: FunctionArgumentType.STRING },
75
80
 
76
- // Remote function arguments (currently supporting up to 9).
77
- { argumentType: FunctionArgumentType.ANY, optionalArg: true },
81
+ // Remote function arguments (currently supporting up to 8).
78
82
  { argumentType: FunctionArgumentType.ANY, optionalArg: true },
79
83
  { argumentType: FunctionArgumentType.ANY, optionalArg: true },
80
84
  { argumentType: FunctionArgumentType.ANY, optionalArg: true },
@@ -90,9 +94,9 @@ EdgeFunctionPlugin.implementedFunctions = {
90
94
 
91
95
  export const EdgeFunctionPluginTranslations = {
92
96
  enGB: {
93
- EDGE: 'EDGE',
97
+ [EDGE_FUNCTION_NAME]: 'Remote function',
94
98
  },
95
99
  enUS: {
96
- EDGE: 'EDGE',
100
+ [EDGE_FUNCTION_NAME]: 'Remote function',
97
101
  },
98
102
  };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './async-function';
6
+ export * from './edge-function';
7
+ export * from './function-defs';
@@ -0,0 +1,14 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { describe, test, expect } from 'vitest';
6
+
7
+ import { HyperFormula } from '#hyperformula';
8
+
9
+ describe('hyperformula', () => {
10
+ test('sanity test', async () => {
11
+ const hf = HyperFormula.buildEmpty({ licenseKey: 'gpl-v3' });
12
+ expect(hf).to.exist;
13
+ });
14
+ });
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './compute-graph';
6
+ export * from './compute-graph-registry';
7
+ export * from './compute-node';
8
+ export * from './functions';
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './test-builder';
6
+ export * from './test-plugin';