@dxos/plugin-sheet 0.6.13-main.ed424a1 → 0.6.13

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 (323) hide show
  1. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs +1772 -0
  2. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
  4. package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
  5. package/dist/lib/{node-esm/chunk-5WPZCXNS.mjs → browser/chunk-D5AGLXJP.mjs} +678 -411
  6. package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-FUAGSXA4.mjs +82 -0
  8. package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-JRL5LGCE.mjs +18 -0
  10. package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
  12. package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +62 -93
  14. package/dist/lib/browser/index.mjs.map +3 -3
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/meta.mjs +1 -1
  17. package/dist/lib/browser/testing.mjs +92 -0
  18. package/dist/lib/browser/testing.mjs.map +7 -0
  19. package/dist/lib/browser/types.mjs +12 -6
  20. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +1765 -0
  21. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
  22. package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-5KKJ4NPP.cjs} +678 -418
  23. package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
  24. package/dist/lib/node/chunk-BJ6ZD7MN.cjs +51 -0
  25. package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +7 -0
  26. package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
  27. package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
  28. package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-DSYKOI4E.cjs} +51 -40
  29. package/dist/lib/node/chunk-DSYKOI4E.cjs.map +7 -0
  30. package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
  31. package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
  32. package/dist/lib/node/index.cjs +69 -105
  33. package/dist/lib/node/index.cjs.map +3 -3
  34. package/dist/lib/node/meta.cjs +3 -3
  35. package/dist/lib/node/meta.cjs.map +1 -1
  36. package/dist/lib/node/meta.json +1 -1
  37. package/dist/lib/node/testing.cjs +111 -0
  38. package/dist/lib/node/testing.cjs.map +7 -0
  39. package/dist/lib/node/types.cjs +15 -9
  40. package/dist/lib/node/types.cjs.map +2 -2
  41. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  42. package/dist/types/src/components/CellEditor/CellEditor.d.ts +14 -0
  43. package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -0
  44. package/dist/types/src/components/{GridSheet/SheetCellEditor.stories.d.ts → CellEditor/CellEditor.stories.d.ts} +4 -4
  45. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -0
  46. package/dist/types/src/{extensions/editor → components/CellEditor}/extension.d.ts +1 -1
  47. package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -0
  48. package/dist/types/src/components/CellEditor/extension.test.d.ts.map +1 -0
  49. package/dist/types/src/components/CellEditor/index.d.ts +3 -0
  50. package/dist/types/src/components/CellEditor/index.d.ts.map +1 -0
  51. package/dist/types/src/{graph/functions → components/ComputeGraph}/async-function.d.ts +5 -14
  52. package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +1 -0
  53. package/dist/types/src/components/ComputeGraph/custom.d.ts +21 -0
  54. package/dist/types/src/components/ComputeGraph/custom.d.ts.map +1 -0
  55. package/dist/types/src/components/ComputeGraph/edge-function.d.ts +20 -0
  56. package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -0
  57. package/dist/types/src/components/ComputeGraph/graph-context.d.ts +12 -0
  58. package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -0
  59. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +2 -0
  60. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +1 -0
  61. package/dist/types/src/components/ComputeGraph/graph.d.ts +26 -0
  62. package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -0
  63. package/dist/types/src/components/ComputeGraph/index.d.ts +3 -1
  64. package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
  65. package/dist/types/src/components/Sheet/Sheet.d.ts +55 -0
  66. package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -0
  67. package/dist/types/src/components/Sheet/Sheet.stories.d.ts +54 -0
  68. package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -0
  69. package/dist/types/src/components/Sheet/formatting.d.ts +14 -0
  70. package/dist/types/src/components/Sheet/formatting.d.ts.map +1 -0
  71. package/dist/types/src/components/Sheet/grid.d.ts +52 -0
  72. package/dist/types/src/components/Sheet/grid.d.ts.map +1 -0
  73. package/dist/types/src/components/Sheet/index.d.ts +2 -0
  74. package/dist/types/src/components/Sheet/index.d.ts.map +1 -0
  75. package/dist/types/src/components/Sheet/nav.d.ts +29 -0
  76. package/dist/types/src/components/Sheet/nav.d.ts.map +1 -0
  77. package/dist/types/src/components/Sheet/sheet-context.d.ts +25 -0
  78. package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -0
  79. package/dist/types/src/components/Sheet/util.d.ts +18 -0
  80. package/dist/types/src/components/Sheet/util.d.ts.map +1 -0
  81. package/dist/types/src/components/SheetContainer.d.ts +9 -0
  82. package/dist/types/src/components/SheetContainer.d.ts.map +1 -0
  83. package/dist/types/src/components/Toolbar/Toolbar.d.ts +9 -33
  84. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  85. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +15 -19
  86. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
  87. package/dist/types/src/components/Toolbar/common.d.ts +20 -0
  88. package/dist/types/src/components/Toolbar/common.d.ts.map +1 -0
  89. package/dist/types/src/components/index.d.ts +2 -3
  90. package/dist/types/src/components/index.d.ts.map +1 -1
  91. package/dist/types/src/meta.d.ts +9 -3
  92. package/dist/types/src/meta.d.ts.map +1 -1
  93. package/dist/types/src/{graph/functions/function-defs.d.ts → model/functions.d.ts} +1 -1
  94. package/dist/types/src/model/functions.d.ts.map +1 -0
  95. package/dist/types/src/model/index.d.ts +3 -2
  96. package/dist/types/src/model/index.d.ts.map +1 -1
  97. package/dist/types/src/model/model.browser.test.d.ts +2 -0
  98. package/dist/types/src/model/model.browser.test.d.ts.map +1 -0
  99. package/dist/types/src/model/{sheet-model.d.ts → model.d.ts} +67 -13
  100. package/dist/types/src/model/model.d.ts.map +1 -0
  101. package/dist/types/src/{defs → model}/types.d.ts +3 -8
  102. package/dist/types/src/model/types.d.ts.map +1 -0
  103. package/dist/types/src/model/types.test.d.ts.map +1 -0
  104. package/dist/types/src/model/util.d.ts +15 -0
  105. package/dist/types/src/model/util.d.ts.map +1 -0
  106. package/dist/types/src/testing.d.ts +9 -0
  107. package/dist/types/src/testing.d.ts.map +1 -0
  108. package/dist/types/src/translations.d.ts +12 -17
  109. package/dist/types/src/translations.d.ts.map +1 -1
  110. package/dist/types/src/types.d.ts +40 -125
  111. package/dist/types/src/types.d.ts.map +1 -1
  112. package/package.json +52 -58
  113. package/src/SheetPlugin.tsx +74 -52
  114. package/src/components/{GridSheet/SheetCellEditor.stories.tsx → CellEditor/CellEditor.stories.tsx} +8 -8
  115. package/src/components/CellEditor/CellEditor.tsx +113 -0
  116. package/src/{extensions/editor → components/CellEditor}/extension.test.ts +6 -4
  117. package/src/{extensions/editor → components/CellEditor}/extension.ts +6 -5
  118. package/src/{extensions/editor → components/CellEditor}/index.ts +1 -0
  119. package/src/{graph/functions → components/ComputeGraph}/async-function.ts +15 -25
  120. package/src/{graph/testing/test-plugin.ts → components/ComputeGraph/custom.ts} +14 -44
  121. package/src/{graph/functions → components/ComputeGraph}/edge-function.ts +14 -16
  122. package/src/components/ComputeGraph/graph-context.tsx +50 -0
  123. package/src/components/ComputeGraph/graph.browser.test.ts +50 -0
  124. package/src/components/ComputeGraph/graph.ts +62 -0
  125. package/src/components/ComputeGraph/index.ts +3 -1
  126. package/src/components/Sheet/Sheet.stories.tsx +287 -0
  127. package/src/components/Sheet/Sheet.tsx +1160 -0
  128. package/src/components/Sheet/formatting.ts +106 -0
  129. package/src/components/Sheet/grid.ts +191 -0
  130. package/src/{testing → components/Sheet}/index.ts +1 -1
  131. package/src/components/Sheet/nav.ts +157 -0
  132. package/src/components/Sheet/sheet-context.tsx +150 -0
  133. package/src/components/Sheet/util.ts +56 -0
  134. package/src/components/SheetContainer.tsx +34 -0
  135. package/src/components/Toolbar/Toolbar.tsx +112 -242
  136. package/src/components/Toolbar/common.tsx +72 -0
  137. package/src/components/index.ts +0 -2
  138. package/src/meta.tsx +18 -0
  139. package/src/model/index.ts +3 -2
  140. package/src/model/model.browser.test.ts +100 -0
  141. package/src/model/model.ts +550 -0
  142. package/src/{defs → model}/types.test.ts +9 -8
  143. package/src/{defs → model}/types.ts +14 -24
  144. package/src/model/util.ts +36 -0
  145. package/src/testing.ts +50 -0
  146. package/src/translations.ts +1 -6
  147. package/src/types.ts +47 -40
  148. package/dist/lib/browser/SheetContainer-RVRACGCZ.mjs +0 -290
  149. package/dist/lib/browser/SheetContainer-RVRACGCZ.mjs.map +0 -7
  150. package/dist/lib/browser/chunk-BWN5DZWZ.mjs +0 -74
  151. package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +0 -7
  152. package/dist/lib/browser/chunk-D3QTX46O.mjs +0 -14
  153. package/dist/lib/browser/chunk-D3QTX46O.mjs.map +0 -7
  154. package/dist/lib/browser/chunk-GSV5QNLD.mjs +0 -2966
  155. package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +0 -7
  156. package/dist/lib/browser/chunk-HOG37RYS.mjs +0 -1528
  157. package/dist/lib/browser/chunk-HOG37RYS.mjs.map +0 -7
  158. package/dist/lib/browser/graph-M4IQ76QX.mjs +0 -33
  159. package/dist/lib/browser/graph-M4IQ76QX.mjs.map +0 -7
  160. package/dist/lib/node/SheetContainer-J7XROAMN.cjs +0 -300
  161. package/dist/lib/node/SheetContainer-J7XROAMN.cjs.map +0 -7
  162. package/dist/lib/node/chunk-5XPK2V4A.cjs.map +0 -7
  163. package/dist/lib/node/chunk-AXQZA2YS.cjs +0 -1527
  164. package/dist/lib/node/chunk-AXQZA2YS.cjs.map +0 -7
  165. package/dist/lib/node/chunk-NZARD7UP.cjs.map +0 -7
  166. package/dist/lib/node/chunk-QIFIGEKV.cjs +0 -37
  167. package/dist/lib/node/chunk-QIFIGEKV.cjs.map +0 -7
  168. package/dist/lib/node/graph-Q3N2X26H.cjs +0 -55
  169. package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
  170. package/dist/lib/node-esm/SheetContainer-YWQVKHQB.mjs +0 -291
  171. package/dist/lib/node-esm/SheetContainer-YWQVKHQB.mjs.map +0 -7
  172. package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +0 -7
  173. package/dist/lib/node-esm/chunk-BPXXIAOQ.mjs +0 -1529
  174. package/dist/lib/node-esm/chunk-BPXXIAOQ.mjs.map +0 -7
  175. package/dist/lib/node-esm/chunk-VCYJWE3O.mjs +0 -16
  176. package/dist/lib/node-esm/chunk-VCYJWE3O.mjs.map +0 -7
  177. package/dist/lib/node-esm/chunk-WFDTY3IC.mjs +0 -75
  178. package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +0 -7
  179. package/dist/lib/node-esm/graph-SMPUMOV2.mjs +0 -34
  180. package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +0 -7
  181. package/dist/lib/node-esm/index.mjs +0 -280
  182. package/dist/lib/node-esm/index.mjs.map +0 -7
  183. package/dist/lib/node-esm/meta.json +0 -1
  184. package/dist/lib/node-esm/meta.mjs +0 -10
  185. package/dist/lib/node-esm/meta.mjs.map +0 -7
  186. package/dist/lib/node-esm/types.mjs +0 -17
  187. package/dist/lib/node-esm/types.mjs.map +0 -7
  188. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +0 -11
  189. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +0 -1
  190. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +0 -3
  191. package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +0 -1
  192. package/dist/types/src/components/FunctionEditor/index.d.ts +0 -2
  193. package/dist/types/src/components/FunctionEditor/index.d.ts.map +0 -1
  194. package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -3
  195. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
  196. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -9
  197. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
  198. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +0 -1
  199. package/dist/types/src/components/GridSheet/index.d.ts +0 -2
  200. package/dist/types/src/components/GridSheet/index.d.ts.map +0 -1
  201. package/dist/types/src/components/GridSheet/util.d.ts +0 -16
  202. package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
  203. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -6
  204. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
  205. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +0 -11
  206. package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +0 -1
  207. package/dist/types/src/components/SheetContainer/index.d.ts +0 -3
  208. package/dist/types/src/components/SheetContainer/index.d.ts.map +0 -1
  209. package/dist/types/src/components/SheetContext/SheetContext.d.ts +0 -26
  210. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +0 -1
  211. package/dist/types/src/components/SheetContext/index.d.ts +0 -2
  212. package/dist/types/src/components/SheetContext/index.d.ts.map +0 -1
  213. package/dist/types/src/defs/index.d.ts +0 -4
  214. package/dist/types/src/defs/index.d.ts.map +0 -1
  215. package/dist/types/src/defs/sheet-range-types.d.ts +0 -13
  216. package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
  217. package/dist/types/src/defs/types.d.ts.map +0 -1
  218. package/dist/types/src/defs/types.test.d.ts.map +0 -1
  219. package/dist/types/src/defs/util.d.ts +0 -43
  220. package/dist/types/src/defs/util.d.ts.map +0 -1
  221. package/dist/types/src/extensions/compute.d.ts +0 -6
  222. package/dist/types/src/extensions/compute.d.ts.map +0 -1
  223. package/dist/types/src/extensions/compute.stories.d.ts +0 -26
  224. package/dist/types/src/extensions/compute.stories.d.ts.map +0 -1
  225. package/dist/types/src/extensions/editor/extension.d.ts.map +0 -1
  226. package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
  227. package/dist/types/src/extensions/editor/index.d.ts +0 -2
  228. package/dist/types/src/extensions/editor/index.d.ts.map +0 -1
  229. package/dist/types/src/extensions/index.d.ts +0 -3
  230. package/dist/types/src/extensions/index.d.ts.map +0 -1
  231. package/dist/types/src/graph/compute-graph-registry.d.ts +0 -34
  232. package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
  233. package/dist/types/src/graph/compute-graph.d.ts +0 -64
  234. package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
  235. package/dist/types/src/graph/compute-graph.stories.d.ts +0 -10
  236. package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
  237. package/dist/types/src/graph/compute-graph.test.d.ts +0 -2
  238. package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
  239. package/dist/types/src/graph/compute-node.d.ts +0 -26
  240. package/dist/types/src/graph/compute-node.d.ts.map +0 -1
  241. package/dist/types/src/graph/functions/async-function.d.ts.map +0 -1
  242. package/dist/types/src/graph/functions/edge-function.d.ts +0 -21
  243. package/dist/types/src/graph/functions/edge-function.d.ts.map +0 -1
  244. package/dist/types/src/graph/functions/function-defs.d.ts.map +0 -1
  245. package/dist/types/src/graph/functions/index.d.ts +0 -4
  246. package/dist/types/src/graph/functions/index.d.ts.map +0 -1
  247. package/dist/types/src/graph/hyperformula.test.d.ts +0 -2
  248. package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
  249. package/dist/types/src/graph/index.d.ts +0 -5
  250. package/dist/types/src/graph/index.d.ts.map +0 -1
  251. package/dist/types/src/graph/testing/index.d.ts +0 -3
  252. package/dist/types/src/graph/testing/index.d.ts.map +0 -1
  253. package/dist/types/src/graph/testing/test-builder.d.ts +0 -15
  254. package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
  255. package/dist/types/src/graph/testing/test-plugin.d.ts +0 -36
  256. package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
  257. package/dist/types/src/graph/util.d.ts +0 -2
  258. package/dist/types/src/graph/util.d.ts.map +0 -1
  259. package/dist/types/src/hooks/hooks.stories.d.ts +0 -11
  260. package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
  261. package/dist/types/src/hooks/index.d.ts +0 -4
  262. package/dist/types/src/hooks/index.d.ts.map +0 -1
  263. package/dist/types/src/hooks/threads.d.ts +0 -8
  264. package/dist/types/src/hooks/threads.d.ts.map +0 -1
  265. package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
  266. package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
  267. package/dist/types/src/hooks/useSheetModel.d.ts +0 -8
  268. package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
  269. package/dist/types/src/model/decorations.d.ts +0 -25
  270. package/dist/types/src/model/decorations.d.ts.map +0 -1
  271. package/dist/types/src/model/sheet-model.d.ts.map +0 -1
  272. package/dist/types/src/model/sheet-model.test.d.ts +0 -2
  273. package/dist/types/src/model/sheet-model.test.d.ts.map +0 -1
  274. package/dist/types/src/sanity.test.d.ts +0 -2
  275. package/dist/types/src/sanity.test.d.ts.map +0 -1
  276. package/dist/types/src/testing/index.d.ts +0 -2
  277. package/dist/types/src/testing/index.d.ts.map +0 -1
  278. package/dist/types/src/testing/testing.d.ts +0 -8
  279. package/dist/types/src/testing/testing.d.ts.map +0 -1
  280. package/dist/vendor/hyperformula.mjs +0 -37145
  281. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +0 -20
  282. package/src/components/FunctionEditor/FunctionEditor.tsx +0 -45
  283. package/src/components/FunctionEditor/index.ts +0 -5
  284. package/src/components/GridSheet/GridSheet.stories.tsx +0 -41
  285. package/src/components/GridSheet/GridSheet.tsx +0 -163
  286. package/src/components/GridSheet/index.ts +0 -5
  287. package/src/components/GridSheet/util.ts +0 -158
  288. package/src/components/SheetContainer/SheetContainer.stories.tsx +0 -40
  289. package/src/components/SheetContainer/SheetContainer.tsx +0 -27
  290. package/src/components/SheetContainer/index.ts +0 -7
  291. package/src/components/SheetContext/SheetContext.tsx +0 -104
  292. package/src/components/SheetContext/index.ts +0 -5
  293. package/src/defs/index.ts +0 -7
  294. package/src/defs/sheet-range-types.ts +0 -46
  295. package/src/defs/util.ts +0 -151
  296. package/src/extensions/compute.stories.tsx +0 -151
  297. package/src/extensions/compute.ts +0 -147
  298. package/src/extensions/index.ts +0 -6
  299. package/src/graph/compute-graph-registry.ts +0 -90
  300. package/src/graph/compute-graph.stories.tsx +0 -93
  301. package/src/graph/compute-graph.test.ts +0 -87
  302. package/src/graph/compute-graph.ts +0 -242
  303. package/src/graph/compute-node.ts +0 -63
  304. package/src/graph/functions/index.ts +0 -7
  305. package/src/graph/hyperformula.test.ts +0 -14
  306. package/src/graph/index.ts +0 -8
  307. package/src/graph/testing/index.ts +0 -6
  308. package/src/graph/testing/test-builder.ts +0 -54
  309. package/src/graph/util.ts +0 -8
  310. package/src/hooks/hooks.stories.tsx +0 -50
  311. package/src/hooks/index.ts +0 -7
  312. package/src/hooks/threads.ts +0 -147
  313. package/src/hooks/useComputeGraph.ts +0 -28
  314. package/src/hooks/useSheetModel.ts +0 -40
  315. package/src/meta.ts +0 -14
  316. package/src/model/decorations.ts +0 -64
  317. package/src/model/sheet-model.test.ts +0 -57
  318. package/src/model/sheet-model.ts +0 -418
  319. package/src/sanity.test.ts +0 -40
  320. package/src/testing/testing.tsx +0 -68
  321. /package/dist/types/src/{extensions/editor → components/CellEditor}/extension.test.d.ts +0 -0
  322. /package/dist/types/src/{defs → model}/types.test.d.ts +0 -0
  323. /package/src/{graph/functions/function-defs.ts → model/functions.ts} +0 -0
@@ -2,71 +2,84 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ import { type IconProps, GridNine } from '@phosphor-icons/react';
5
6
  import React from 'react';
6
7
 
7
- import { NavigationAction, parseIntentPlugin, resolvePlugin, type PluginDefinition } from '@dxos/app-framework';
8
- import { invariant } from '@dxos/invariant';
8
+ import {
9
+ NavigationAction,
10
+ parseIntentPlugin,
11
+ resolvePlugin,
12
+ type PluginDefinition,
13
+ type LayoutCoordinate,
14
+ } from '@dxos/app-framework';
15
+ import { create } from '@dxos/echo-schema';
9
16
  import { parseClientPlugin } from '@dxos/plugin-client';
10
- import { createExtension, isActionGroup, type ActionGroup } from '@dxos/plugin-graph';
17
+ import { type ActionGroup, createExtension, isActionGroup } from '@dxos/plugin-graph';
11
18
  import { FunctionType } from '@dxos/plugin-script/types';
12
19
  import { SpaceAction } from '@dxos/plugin-space';
13
20
  import { getSpace, isEchoObject } from '@dxos/react-client/echo';
14
- import { Icon } from '@dxos/react-ui';
15
21
 
16
- import { ComputeGraphContextProvider, SheetContainer } from './components';
17
- import { compareIndexPositions, createSheet } from './defs';
18
- import { computeGraphFacet } from './extensions';
19
- import { type ComputeGraphRegistry } from './graph';
20
- import { useComputeGraph } from './hooks';
22
+ import {
23
+ createComputeGraph,
24
+ CustomPlugin,
25
+ CustomPluginTranslations,
26
+ SheetContainer,
27
+ type ComputeGraph,
28
+ } from './components';
29
+ // TODO(wittjosiah): Refactor. These are not exported from ./components due to depending on ECHO.
30
+ import { EdgeFunctionPlugin, EdgeFunctionPluginTranslations } from './components/ComputeGraph/edge-function';
31
+ import { ComputeGraphContextProvider } from './components/ComputeGraph/graph-context';
21
32
  import meta, { SHEET_PLUGIN } from './meta';
33
+ import { SheetModel } from './model';
22
34
  import translations from './translations';
23
- import { SheetAction, SheetType, type SheetPluginProvides } from './types';
35
+ import { createSheet, SheetAction, type SheetPluginProvides, SheetType } from './types';
24
36
 
25
37
  export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
26
- let computeGraphRegistry: ComputeGraphRegistry | undefined;
38
+ let remoteFunctionUrl: string | undefined;
39
+
40
+ const graphs = create<Record<string, ComputeGraph>>({});
41
+ const setGraph = (key: string, graph: ComputeGraph) => {
42
+ graphs[key] = graph;
43
+ };
27
44
 
28
45
  return {
29
46
  meta,
30
47
  ready: async (plugins) => {
31
48
  const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
32
- invariant(client);
33
- let remoteFunctionUrl: string | undefined;
49
+ if (!client) {
50
+ return;
51
+ }
52
+
34
53
  if (client.config.values.runtime?.services?.edge?.url) {
35
54
  const url = new URL('/functions', client.config.values.runtime?.services?.edge?.url);
36
55
  url.protocol = 'https';
37
56
  remoteFunctionUrl = url.toString();
38
57
  }
39
-
40
- // Async import removes direct dependency on hyperformula.
41
- const { ComputeGraphRegistry } = await import('./graph');
42
- computeGraphRegistry = new ComputeGraphRegistry({ remoteFunctionUrl });
43
58
  },
44
59
  provides: {
45
60
  context: ({ children }) => {
46
- invariant(computeGraphRegistry);
47
- return <ComputeGraphContextProvider registry={computeGraphRegistry}>{children}</ComputeGraphContextProvider>;
61
+ return (
62
+ <ComputeGraphContextProvider graphs={graphs} setGraph={setGraph}>
63
+ {children}
64
+ </ComputeGraphContextProvider>
65
+ );
48
66
  },
49
67
  metadata: {
50
68
  records: {
51
69
  [SheetType.typename]: {
52
- label: (object: any) => (object instanceof SheetType ? object.name : undefined),
70
+ label: (object: any) => (object instanceof SheetType ? object.title : undefined),
53
71
  placeholder: ['sheet title placeholder', { ns: SHEET_PLUGIN }],
54
- icon: 'ph--grid-nine--regular',
72
+ icon: (props: IconProps) => <GridNine {...props} />,
73
+ iconSymbol: 'ph--grid-nine--regular',
55
74
  },
56
75
  },
57
76
  },
58
77
  translations,
59
78
  echo: {
60
79
  // TODO(wittjosiah): Factor out to common package/plugin.
61
- // FunctionType is currently registered here in case script plugin isn't enabled.
80
+ // FunctionType is currently registered here in case script plugin isn't enabled.
62
81
  schema: [SheetType, FunctionType],
63
82
  },
64
- space: {
65
- onSpaceCreate: {
66
- label: ['create sheet label', { ns: SHEET_PLUGIN }],
67
- action: SheetAction.CREATE,
68
- },
69
- },
70
83
  graph: {
71
84
  builder: (plugins) => {
72
85
  const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
@@ -100,7 +113,8 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
100
113
  },
101
114
  properties: {
102
115
  label: ['create sheet label', { ns: SHEET_PLUGIN }],
103
- icon: 'ph--grid-nine--regular',
116
+ icon: (props: IconProps) => <GridNine {...props} />,
117
+ iconSymbol: 'ph--grid-nine--regular',
104
118
  testId: 'sheetPlugin.createObject',
105
119
  },
106
120
  },
@@ -109,16 +123,6 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
109
123
  });
110
124
  },
111
125
  },
112
- markdown: {
113
- extensions: ({ document: doc }) => {
114
- invariant(computeGraphRegistry);
115
- const space = getSpace(doc);
116
- if (space) {
117
- const computeGraph = computeGraphRegistry.getOrCreateGraph(space);
118
- return computeGraphFacet.of(computeGraph);
119
- }
120
- },
121
- },
122
126
  stack: {
123
127
  creators: [
124
128
  {
@@ -126,8 +130,7 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
126
130
  testId: 'sheetPlugin.createSection',
127
131
  type: ['plugin name', { ns: SHEET_PLUGIN }],
128
132
  label: ['create sheet section label', { ns: SHEET_PLUGIN }],
129
- // TODO(thure): Refactor to use strings
130
- icon: (props: any) => <Icon icon='ph--grid-nine--regular' {...props} />,
133
+ icon: (props: any) => <GridNine {...props} />,
131
134
  intent: {
132
135
  plugin: SHEET_PLUGIN,
133
136
  action: SheetAction.CREATE,
@@ -135,20 +138,23 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
135
138
  },
136
139
  ],
137
140
  },
138
- thread: {
139
- predicate: (data) => data instanceof SheetType,
140
- createSort: (sheet) => (indexA, indexB) =>
141
- !indexA || !indexB ? 0 : compareIndexPositions(sheet, indexA, indexB),
142
- },
143
141
  surface: {
144
- component: ({ data, role }) => {
145
- const space = isEchoObject(data.object) ? getSpace(data.object) : undefined;
146
- const graph = useComputeGraph(space);
147
- if (graph && data.object instanceof SheetType) {
142
+ component: ({ data, role = 'never' }) => {
143
+ // TODO(burdon): Standardize wrapper (with room for toolbar).
144
+ const space = isEchoObject(data.object) && getSpace(data.object);
145
+ if (space && data.object instanceof SheetType) {
148
146
  switch (role) {
149
147
  case 'article':
150
148
  case 'section': {
151
- return <SheetContainer graph={graph} sheet={data.object} role={role} />;
149
+ return (
150
+ <SheetContainer
151
+ sheet={data.object}
152
+ space={space}
153
+ role={role}
154
+ coordinate={data.coordinate as LayoutCoordinate}
155
+ remoteFunctionUrl={remoteFunctionUrl}
156
+ />
157
+ );
152
158
  }
153
159
  }
154
160
  }
@@ -160,7 +166,23 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
160
166
  resolver: async (intent) => {
161
167
  switch (intent.action) {
162
168
  case SheetAction.CREATE: {
163
- return { data: createSheet() };
169
+ const space = intent.data?.space;
170
+ const sheet = createSheet();
171
+ const graph =
172
+ graphs[space.id] ??
173
+ createComputeGraph(
174
+ [
175
+ { plugin: EdgeFunctionPlugin, translations: EdgeFunctionPluginTranslations },
176
+ // TODO(wittjosiah): Remove. Needed for current test sheet generated data.
177
+ { plugin: CustomPlugin, translations: CustomPluginTranslations },
178
+ ],
179
+ space,
180
+ { remoteFunctionUrl },
181
+ );
182
+ const model = new SheetModel(graph, sheet);
183
+ await model.initialize();
184
+ await model.destroy();
185
+ return { data: sheet };
164
186
  }
165
187
  }
166
188
  },
@@ -4,19 +4,18 @@
4
4
 
5
5
  import '@dxos-theme';
6
6
 
7
+ import { HyperFormula } from 'hyperformula';
7
8
  import React, { useEffect, useMemo, useState } from 'react';
8
9
 
9
10
  import { Client } from '@dxos/client';
10
11
  import { createDocAccessor, type EchoReactiveObject } from '@dxos/client/echo';
11
12
  import { automerge } from '@dxos/react-ui-editor';
12
- import { CellEditor, type CellEditorProps } from '@dxos/react-ui-grid';
13
13
  import { withTheme } from '@dxos/storybook-utils';
14
14
 
15
- import { HyperFormula } from '#hyperformula';
16
- import { createSheet } from '../../defs';
17
- import { sheetExtension } from '../../extensions';
18
- import { defaultFunctions } from '../../graph';
19
- import { SheetType } from '../../types';
15
+ import { CellEditor, type CellEditorProps } from './CellEditor';
16
+ import { sheetExtension } from './extension';
17
+ import { defaultFunctions } from '../../model';
18
+ import { createSheet, SheetType } from '../../types';
20
19
 
21
20
  export default {
22
21
  title: 'plugin-sheet/CellEditor',
@@ -42,13 +41,14 @@ const AutomergeStory = ({ value, ...props }: StoryProps) => {
42
41
  const [object, setObject] = useState<EchoReactiveObject<SheetType>>();
43
42
  useEffect(() => {
44
43
  setTimeout(async () => {
45
- const client = new Client({ types: [SheetType] });
44
+ const client = new Client();
46
45
  await client.initialize();
47
46
  await client.halo.createIdentity();
48
47
  const space = await client.spaces.create();
48
+ client.addTypes([SheetType]);
49
49
 
50
50
  const sheet = createSheet();
51
- sheet.name = 'Test';
51
+ sheet.title = 'Test';
52
52
  sheet.cells[cell] = { value };
53
53
  space.db.add(sheet);
54
54
  setObject(sheet);
@@ -0,0 +1,113 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { type Extension } from '@codemirror/state';
6
+ import { EditorView, keymap } from '@codemirror/view';
7
+ import React, { type DOMAttributes, type KeyboardEvent } from 'react';
8
+
9
+ import { useThemeContext } from '@dxos/react-ui';
10
+ import {
11
+ type UseTextEditorProps,
12
+ createBasicExtensions,
13
+ createThemeExtensions,
14
+ preventNewline,
15
+ useTextEditor,
16
+ } from '@dxos/react-ui-editor';
17
+
18
+ export type EditorKeysProps = {
19
+ onClose: (value: string | undefined) => void;
20
+ onNav?: (value: string | undefined, ev: Pick<KeyboardEvent<HTMLInputElement>, 'key'>) => void;
21
+ };
22
+
23
+ export const editorKeys = ({ onNav, onClose }: EditorKeysProps): Extension => {
24
+ return keymap.of([
25
+ {
26
+ key: 'ArrowUp',
27
+ run: (editor) => {
28
+ const value = editor.state.doc.toString();
29
+ onNav?.(value, { key: 'ArrowUp' });
30
+ return !!onNav;
31
+ },
32
+ },
33
+ {
34
+ key: 'ArrowDown',
35
+ run: (editor) => {
36
+ const value = editor.state.doc.toString();
37
+ onNav?.(value, { key: 'ArrowDown' });
38
+ return !!onNav;
39
+ },
40
+ },
41
+ {
42
+ key: 'ArrowLeft',
43
+ run: (editor) => {
44
+ const value = editor.state.doc.toString();
45
+ onNav?.(value, { key: 'ArrowLeft' });
46
+ return !!onNav;
47
+ },
48
+ },
49
+ {
50
+ key: 'ArrowRight',
51
+ run: (editor) => {
52
+ const value = editor.state.doc.toString();
53
+ onNav?.(value, { key: 'ArrowRight' });
54
+ return !!onNav;
55
+ },
56
+ },
57
+ {
58
+ key: 'Enter',
59
+ run: (editor) => {
60
+ onClose(editor.state.doc.toString());
61
+ return true;
62
+ },
63
+ },
64
+ {
65
+ key: 'Escape',
66
+ run: () => {
67
+ onClose(undefined);
68
+ return true;
69
+ },
70
+ },
71
+ ]);
72
+ };
73
+
74
+ export type CellEditorProps = {
75
+ value?: string;
76
+ extension?: Extension;
77
+ } & Pick<UseTextEditorProps, 'autoFocus'> &
78
+ Pick<DOMAttributes<HTMLInputElement>, 'onBlur' | 'onKeyDown'>;
79
+
80
+ export const CellEditor = ({ value, extension, autoFocus, onBlur }: CellEditorProps) => {
81
+ const { themeMode } = useThemeContext();
82
+ const { parentRef } = useTextEditor(() => {
83
+ return {
84
+ autoFocus,
85
+ initialValue: value,
86
+ selection: { anchor: value?.length ?? 0 },
87
+ extensions: [
88
+ extension ?? [],
89
+ preventNewline,
90
+ EditorView.focusChangeEffect.of((_, focusing) => {
91
+ if (!focusing) {
92
+ onBlur?.({ type: 'blur' } as any);
93
+ }
94
+ return null;
95
+ }),
96
+ createBasicExtensions({ lineWrapping: false }),
97
+ createThemeExtensions({
98
+ themeMode,
99
+ slots: {
100
+ editor: {
101
+ className: 'flex w-full [&>.cm-scroller]:scrollbar-none',
102
+ },
103
+ content: {
104
+ className: '!px-2 !py-1',
105
+ },
106
+ },
107
+ }),
108
+ ],
109
+ };
110
+ }, [extension]);
111
+
112
+ return <div ref={parentRef} className='flex w-full' />;
113
+ };
@@ -4,12 +4,14 @@
4
4
 
5
5
  import { CompletionContext, type CompletionSource } from '@codemirror/autocomplete';
6
6
  import { EditorState } from '@codemirror/state';
7
+ // @ts-ignore
7
8
  import { testTree } from '@lezer/generator/test';
9
+ import { expect } from 'chai';
8
10
  import { spreadsheet } from 'codemirror-lang-spreadsheet';
9
- import { describe, expect, test } from 'vitest';
11
+ import { describe, test } from 'vitest';
10
12
 
11
13
  import { sheetExtension } from './extension';
12
- import { defaultFunctions } from '../../graph';
14
+ import { defaultFunctions } from '../../model/functions';
13
15
 
14
16
  describe('formula parser', () => {
15
17
  const {
@@ -35,8 +37,8 @@ describe('formula parser', () => {
35
37
  extensions: sheetExtension({ functions }),
36
38
  });
37
39
 
38
- const [fn] = state.languageDataAt<CompletionSource>('autocomplete', text.length);
39
- const result = await fn(new CompletionContext(state, text.length, true));
40
+ const [f] = state.languageDataAt<CompletionSource>('autocomplete', text.length);
41
+ const result = await f(new CompletionContext(state, text.length, true));
40
42
  expect(result?.options).to.have.length(1);
41
43
  });
42
44
  });
@@ -12,16 +12,15 @@ import {
12
12
  startCompletion,
13
13
  } from '@codemirror/autocomplete';
14
14
  import { HighlightStyle, type Language, syntaxHighlighting } from '@codemirror/language';
15
- import { type Extension } from '@codemirror/state';
15
+ import { type Extension, Facet } from '@codemirror/state';
16
16
  import { type EditorView, ViewPlugin, type ViewUpdate, keymap } from '@codemirror/view';
17
17
  import { type SyntaxNode } from '@lezer/common';
18
18
  import { tags } from '@lezer/highlight';
19
19
  import { spreadsheet } from 'codemirror-lang-spreadsheet';
20
20
 
21
- import { singleValueFacet } from '@dxos/react-ui-editor/state';
22
21
  import { mx } from '@dxos/react-ui-theme';
23
22
 
24
- import { type FunctionDefinition } from '../../graph';
23
+ import { type FunctionDefinition } from '../../model';
25
24
 
26
25
  /**
27
26
  * https://codemirror.net/examples/styling
@@ -60,7 +59,7 @@ const highlightStyles = HighlightStyle.define([
60
59
  },
61
60
  ]);
62
61
 
63
- const languageFacet = singleValueFacet<Language>();
62
+ const languageFacet = Facet.define<Language>();
64
63
 
65
64
  export type SheetExtensionOptions = {
66
65
  functions?: FunctionDefinition[];
@@ -166,6 +165,8 @@ export const sheetExtension = ({ functions = [] }: SheetExtensionOptions): Exten
166
165
  icons: false,
167
166
  tooltipClass: () =>
168
167
  mx(
168
+ // TODO(burdon): Factor out fragments.
169
+ // TODO(burdon): Size to make width same as column.
169
170
  '!-left-[1px] !top-[33px] !-m-0 border !border-t-0 [&>ul]:!min-w-[198px]',
170
171
  '[&>ul>li[aria-selected]]:!bg-accentSurface',
171
172
  'border-separator',
@@ -230,7 +231,7 @@ export const rangeExtension = (onInit: (notifier: CellRangeNotifier) => void): E
230
231
 
231
232
  // Find first Range or cell at cursor.
232
233
  activeRange = undefined;
233
- const language = view.state.facet(languageFacet);
234
+ const [language] = view.state.facet(languageFacet);
234
235
  const { topNode } = language.parser.parse(view.state.doc.toString());
235
236
  visitTree(topNode, ({ type, from, to }) => {
236
237
  if (from <= anchor && to >= anchor) {
@@ -2,4 +2,5 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ export * from './CellEditor';
5
6
  export * from './extension';
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { type SimpleCellAddress } from 'hyperformula/typings/Cell';
5
+ import { CellError, ErrorType, EmptyValue, FunctionPlugin, type HyperFormula } from 'hyperformula';
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,35 +12,28 @@ 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
- import { CellError, ErrorType, EmptyValue, FunctionPlugin, type HyperFormula } from '#hyperformula';
16
-
17
- // TODO(burdon): Create API gateways:
15
+ // TODO(burdon): API gateways!
18
16
  // https://publicapis.io
19
17
  // https://api-ninjas.com/api/cryptoprice
20
18
  // https://developers.google.com/apis-explorer
21
19
  // https://publicapis.io/coin-desk-api
22
20
 
21
+ // TODO(burdon): Create wrapper.
23
22
  export type AsyncFunction = (...args: any) => Promise<InterpreterValue>;
24
23
 
25
- export type FunctionUpdateEvent = {
26
- name: string;
27
- cell: SimpleCellAddress;
28
- };
29
-
30
24
  export type FunctionOptions = {
31
25
  ttl?: number;
32
26
  };
33
27
 
34
28
  export type FunctionContextOptions = {
35
29
  defaultTtl: number;
36
- debounceDelay: number;
30
+ recalculationDelay: number;
37
31
  remoteFunctionUrl: string;
38
- onUpdate?: (update: FunctionUpdateEvent) => void;
39
32
  };
40
33
 
41
34
  export const defaultFunctionContextOptions: FunctionContextOptions = {
42
35
  defaultTtl: 5_000,
43
- debounceDelay: 200,
36
+ recalculationDelay: 200,
44
37
  remoteFunctionUrl: 'https://edge.dxos.workers.dev/functions', // TODO(burdon): Config.
45
38
  };
46
39
 
@@ -72,21 +65,21 @@ export class FunctionContext {
72
65
  private _invocations: Record<string, number> = {};
73
66
 
74
67
  private readonly _options: FunctionContextOptions;
75
-
76
- // Debounced update handler.
77
- private readonly _onUpdate: (update: FunctionUpdateEvent) => void;
68
+ private readonly _onUpdate: () => void;
78
69
 
79
70
  constructor(
80
71
  private readonly _hf: HyperFormula,
81
72
  private readonly _space: Space | undefined,
73
+ onUpdate: (context: FunctionContext) => void,
82
74
  _options?: Partial<FunctionContextOptions>,
83
75
  ) {
84
76
  this._options = defaultsDeep(_options ?? {}, defaultFunctionContextOptions);
85
- this._onUpdate = debounce((update) => {
86
- // TODO(burdon): Better way to trigger recalculation? (NOTE: rebuildAndRecalculate resets the undo history.)
77
+ this._onUpdate = debounce(() => {
78
+ // TODO(burdon): Better way to trigger recalculation?
79
+ // NOTE: rebuildAndRecalculate resets the undo history.
87
80
  this._hf.resumeEvaluation();
88
- this._options.onUpdate?.(update);
89
- }, this._options.debounceDelay);
81
+ onUpdate(this);
82
+ }, this._options.recalculationDelay);
90
83
  }
91
84
 
92
85
  get space() {
@@ -141,7 +134,7 @@ export class FunctionContext {
141
134
  const value = await cb(...args);
142
135
  this._cache.set(invocationKey, { value, ts: Date.now() });
143
136
  log('set', { cell, value });
144
- this._onUpdate({ name, cell });
137
+ this._onUpdate();
145
138
  } catch (err) {
146
139
  // TODO(burdon): Show error to user.
147
140
  log.warn('failed', { cell, err });
@@ -160,15 +153,12 @@ export class FunctionContext {
160
153
  /**
161
154
  * Base class for async functions.
162
155
  */
163
- export class AsyncFunctionPlugin extends FunctionPlugin {
156
+ export class FunctionPluginAsync extends FunctionPlugin {
164
157
  get context() {
165
158
  return this.config.context as FunctionContext;
166
159
  }
167
160
 
168
- /**
169
- * Immediately returns cached value then runs the async function.
170
- */
171
- protected runAsyncFunction(ast: ProcedureAst, state: InterpreterState, cb: AsyncFunction, options?: FunctionOptions) {
161
+ runAsyncFunction(ast: ProcedureAst, state: InterpreterState, cb: AsyncFunction, options?: FunctionOptions) {
172
162
  const { procedureName } = ast;
173
163
  const metadata = this.metadata(procedureName);
174
164
  return this.runFunction(ast.args, state, metadata, (...args: any) => {
@@ -2,36 +2,24 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import { FunctionArgumentType } from 'hyperformula';
5
6
  import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
6
7
  import { type ProcedureAst } from 'hyperformula/typings/parser';
7
8
 
8
9
  import { getDeep } from '@dxos/util';
9
10
 
10
- import { FunctionArgumentType } from '#hyperformula';
11
- import { type ComputeGraphPlugin } from '../compute-graph-registry';
12
- import { type AsyncFunction, AsyncFunctionPlugin } from '../functions';
13
- import { parseNumberString } from '../util';
11
+ import { type AsyncFunction, FunctionPluginAsync } from './async-function';
12
+
13
+ // TODO(burdon): Factor out.
14
+ const parseNumberString = (str: string): number => {
15
+ return parseFloat(str.replace(/[^\d.]/g, ''));
16
+ };
14
17
 
15
18
  /**
16
- * Testing functions run locally (not run via EDGE).
17
19
  * https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
18
20
  */
19
- export class TestPlugin extends AsyncFunctionPlugin {
20
- /**
21
- * Simple local function returns input value.
22
- */
21
+ export class CustomPlugin extends FunctionPluginAsync {
23
22
  test(ast: ProcedureAst, state: InterpreterState) {
24
- const handler: AsyncFunction = async (_value) => {
25
- return _value;
26
- };
27
-
28
- return this.runAsyncFunction(ast, state, handler);
29
- }
30
-
31
- /**
32
- * Simple local function returns random number.
33
- */
34
- random(ast: ProcedureAst, state: InterpreterState) {
35
23
  const handler: AsyncFunction = async () => {
36
24
  return Math.random();
37
25
  };
@@ -39,9 +27,6 @@ export class TestPlugin extends AsyncFunctionPlugin {
39
27
  return this.runAsyncFunction(ast, state, handler);
40
28
  }
41
29
 
42
- /**
43
- * Async HTTP function.
44
- */
45
30
  crypto(ast: ProcedureAst, state: InterpreterState) {
46
31
  const handler: AsyncFunction = async (_currency) => {
47
32
  const currency = (_currency || 'USD').toUpperCase();
@@ -59,15 +44,9 @@ export class TestPlugin extends AsyncFunctionPlugin {
59
44
  }
60
45
  }
61
46
 
62
- TestPlugin.implementedFunctions = {
47
+ CustomPlugin.implementedFunctions = {
63
48
  TEST: {
64
49
  method: 'test',
65
- parameters: [{ argumentType: FunctionArgumentType.NUMBER, optionalArg: false }],
66
- isVolatile: true,
67
- },
68
-
69
- RANDOM: {
70
- method: 'random',
71
50
  parameters: [],
72
51
  isVolatile: true,
73
52
  },
@@ -79,22 +58,13 @@ TestPlugin.implementedFunctions = {
79
58
  },
80
59
  };
81
60
 
82
- export const TestPluginTranslations = {
61
+ export const CustomPluginTranslations = {
83
62
  enGB: {
84
- TEST: 'Returns input value',
85
- RANDOM: 'Random number',
86
- CRYPTO: 'Crypto token value',
63
+ TEST: 'TEST',
64
+ CRYPTO: 'CRYPTO',
87
65
  },
88
66
  enUS: {
89
- TEST: 'Returns input value',
90
- RANDOM: 'Random number',
91
- CRYPTO: 'Crypto token value',
67
+ TEST: 'TEST',
68
+ CRYPTO: 'CRYPTO',
92
69
  },
93
70
  };
94
-
95
- export const testFunctionPlugins: ComputeGraphPlugin[] = [
96
- {
97
- plugin: TestPlugin,
98
- translations: TestPluginTranslations,
99
- },
100
- ];