@dxos/plugin-sheet 0.7.4 → 0.7.5-labs.a279d8c
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.
- package/dist/lib/browser/SheetContainer-CM4CO3DC.mjs +370 -0
- package/dist/lib/browser/SheetContainer-CM4CO3DC.mjs.map +7 -0
- package/dist/lib/browser/chunk-FOO6NGBM.mjs +229 -0
- package/dist/lib/browser/chunk-FOO6NGBM.mjs.map +7 -0
- package/dist/lib/browser/chunk-H23JW3DX.mjs +800 -0
- package/dist/lib/browser/chunk-H23JW3DX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-RABELMEQ.mjs → chunk-K6EUYKWT.mjs} +3 -3
- package/dist/lib/browser/chunk-K6EUYKWT.mjs.map +7 -0
- package/dist/lib/browser/chunk-PW25VUP6.mjs +15 -0
- package/dist/lib/browser/chunk-PW25VUP6.mjs.map +7 -0
- package/dist/lib/browser/chunk-T3IVPMRX.mjs +900 -0
- package/dist/lib/browser/chunk-T3IVPMRX.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-XH6B2SWG.mjs +27 -0
- package/dist/lib/browser/compute-graph-registry-XH6B2SWG.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +86 -324
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-Q7DTHAM5.mjs +47 -0
- package/dist/lib/browser/intent-resolver-Q7DTHAM5.mjs.map +7 -0
- package/dist/lib/browser/markdown-IKG5FNCA.mjs +26 -0
- package/dist/lib/browser/markdown-IKG5FNCA.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-JG43577H.mjs +28 -0
- package/dist/lib/browser/react-context-JG43577H.mjs.map +7 -0
- package/dist/lib/browser/react-surface-URRC3AFC.mjs +43 -0
- package/dist/lib/browser/react-surface-URRC3AFC.mjs.map +7 -0
- package/dist/lib/browser/thread-YX6KBQNQ.mjs +17 -0
- package/dist/lib/browser/thread-YX6KBQNQ.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +62 -0
- package/dist/lib/node/SheetContainer-TJ3JQLWM.cjs +364 -0
- package/dist/lib/node/SheetContainer-TJ3JQLWM.cjs.map +7 -0
- package/dist/lib/node/chunk-E3RXOEL6.cjs +935 -0
- package/dist/lib/node/chunk-E3RXOEL6.cjs.map +7 -0
- package/dist/lib/node/{types.cjs → chunk-FU5K66DS.cjs} +12 -16
- package/dist/lib/node/chunk-FU5K66DS.cjs.map +7 -0
- package/dist/lib/node/{chunk-2ZVZI2KJ.cjs → chunk-NLDXUFDG.cjs} +7 -7
- package/dist/lib/node/chunk-NLDXUFDG.cjs.map +7 -0
- package/dist/lib/node/chunk-P4KSGZSS.cjs +251 -0
- package/dist/lib/node/chunk-P4KSGZSS.cjs.map +7 -0
- package/dist/lib/node/chunk-ZPWW4LPY.cjs +807 -0
- package/dist/lib/node/chunk-ZPWW4LPY.cjs.map +7 -0
- package/dist/lib/node/compute-graph-registry-ORGTIE5M.cjs +53 -0
- package/dist/lib/node/compute-graph-registry-ORGTIE5M.cjs.map +7 -0
- package/dist/lib/node/index.cjs +87 -318
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-ZUDJJUFG.cjs +60 -0
- package/dist/lib/node/intent-resolver-ZUDJJUFG.cjs.map +7 -0
- package/dist/lib/node/markdown-EUUL3Q36.cjs +40 -0
- package/dist/lib/node/markdown-EUUL3Q36.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-context-OOH5QFE2.cjs +50 -0
- package/dist/lib/node/react-context-OOH5QFE2.cjs.map +7 -0
- package/dist/lib/node/react-surface-IQN5JKSS.cjs +64 -0
- package/dist/lib/node/react-surface-IQN5JKSS.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → thread-VBPS23P2.cjs} +12 -10
- package/dist/lib/node/thread-VBPS23P2.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +84 -0
- package/dist/lib/node/types/index.cjs.map +7 -0
- package/dist/lib/node-esm/SheetContainer-QEEFORIC.mjs +371 -0
- package/dist/lib/node-esm/SheetContainer-QEEFORIC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-BM2Q3FFC.mjs → chunk-FMOVRTS4.mjs} +3 -3
- package/dist/lib/node-esm/chunk-FMOVRTS4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KCXK5UM6.mjs +16 -0
- package/dist/lib/node-esm/chunk-KCXK5UM6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NSVUOAI6.mjs +901 -0
- package/dist/lib/node-esm/chunk-NSVUOAI6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-OXD6RBFF.mjs +801 -0
- package/dist/lib/node-esm/chunk-OXD6RBFF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PTOI45NK.mjs +231 -0
- package/dist/lib/node-esm/chunk-PTOI45NK.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-JH2FRHLD.mjs +28 -0
- package/dist/lib/node-esm/compute-graph-registry-JH2FRHLD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +86 -324
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-IF64RN7B.mjs +48 -0
- package/dist/lib/node-esm/intent-resolver-IF64RN7B.mjs.map +7 -0
- package/dist/lib/node-esm/markdown-D2ZMN7LR.mjs +27 -0
- package/dist/lib/node-esm/markdown-D2ZMN7LR.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-context-CJVSLO74.mjs +29 -0
- package/dist/lib/node-esm/react-context-CJVSLO74.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-XJIX5G3I.mjs +44 -0
- package/dist/lib/node-esm/react-surface-XJIX5G3I.mjs.map +7 -0
- package/dist/lib/node-esm/thread-HSJD3SR6.mjs +18 -0
- package/dist/lib/node-esm/thread-HSJD3SR6.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +63 -0
- package/dist/types/src/SheetPlugin.d.ts +1 -3
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +4 -0
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +17 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown.d.ts +6 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-context.d.ts +8 -0
- package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/thread.d.ts +6 -0
- package/dist/types/src/capabilities/thread.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +1 -2
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +7 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +6 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/align.d.ts +28 -0
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/comment.d.ts +23 -0
- package/dist/types/src/components/SheetToolbar/comment.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/index.d.ts +2 -0
- package/dist/types/src/components/SheetToolbar/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/style.d.ts +26 -0
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts +8 -0
- package/dist/types/src/components/SheetToolbar/useToolbarAction.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +6 -0
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +6 -8
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +1 -1
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/{defs → types}/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +105 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/{defs → types}/sheet-range-types.d.ts +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +71 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/{defs → types}/util.d.ts +5 -1
- package/dist/types/src/types/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +47 -61
- package/src/SheetPlugin.tsx +70 -176
- package/src/capabilities/capabilities.ts +14 -0
- package/src/capabilities/compute-graph-registry.ts +25 -0
- package/src/capabilities/index.ts +14 -0
- package/src/capabilities/intent-resolver.ts +29 -0
- package/src/capabilities/markdown.ts +22 -0
- package/src/capabilities/react-context.tsx +20 -0
- package/src/capabilities/react-surface.tsx +30 -0
- package/src/capabilities/thread.ts +14 -0
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -2
- package/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.tsx +6 -7
- package/src/components/FunctionEditor/FunctionEditor.tsx +2 -1
- package/src/components/GridSheet/GridSheet.stories.tsx +2 -0
- package/src/components/GridSheet/GridSheet.tsx +15 -18
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +6 -7
- package/src/components/GridSheet/util.ts +3 -2
- package/src/components/RangeList/RangeList.tsx +2 -1
- package/src/components/SheetContainer/SheetContainer.stories.tsx +25 -23
- package/src/components/SheetContainer/SheetContainer.tsx +3 -8
- package/src/components/SheetContext/SheetContext.tsx +1 -2
- package/src/components/{Toolbar/Toolbar.stories.tsx → SheetToolbar/SheetToolbar.stories.tsx} +4 -8
- package/src/components/SheetToolbar/SheetToolbar.tsx +48 -0
- package/src/components/SheetToolbar/align.ts +68 -0
- package/src/components/SheetToolbar/comment.ts +56 -0
- package/src/components/{Toolbar → SheetToolbar}/index.ts +1 -1
- package/src/components/SheetToolbar/style.ts +72 -0
- package/src/components/SheetToolbar/useToolbarAction.ts +87 -0
- package/src/components/SheetToolbar/useToolbarState.ts +17 -0
- package/src/components/index.ts +0 -1
- package/src/extensions/compute.ts +7 -4
- package/src/extensions/editor/extension.test.ts +2 -1
- package/src/extensions/editor/extension.ts +2 -3
- package/src/index.ts +2 -7
- package/src/integrations/thread-ranges.ts +28 -24
- package/src/meta.ts +1 -1
- package/src/model/sheet-model.test.ts +4 -10
- package/src/model/sheet-model.ts +30 -22
- package/src/model/testing.ts +3 -2
- package/src/model/useSheetModel.ts +2 -1
- package/src/sanity.test.ts +1 -1
- package/src/testing/testing.tsx +2 -3
- package/src/{defs → types}/index.ts +1 -0
- package/src/types/schema.ts +56 -0
- package/src/{defs → types}/sheet-range-types.ts +1 -1
- package/src/types/types.ts +67 -0
- package/src/{defs → types}/util.ts +13 -13
- package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs +0 -296
- package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs.map +0 -7
- package/dist/lib/browser/chunk-E5WQ7U7G.mjs +0 -1675
- package/dist/lib/browser/chunk-E5WQ7U7G.mjs.map +0 -7
- package/dist/lib/browser/chunk-F3HE6D3J.mjs +0 -3269
- package/dist/lib/browser/chunk-F3HE6D3J.mjs.map +0 -7
- package/dist/lib/browser/chunk-JXFPOYNA.mjs +0 -67
- package/dist/lib/browser/chunk-JXFPOYNA.mjs.map +0 -7
- package/dist/lib/browser/chunk-RABELMEQ.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-SNUS7HOH.mjs +0 -35
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/browser/types.mjs +0 -16
- package/dist/lib/browser/types.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-VVVRYTQG.cjs +0 -298
- package/dist/lib/node/SheetContainer-VVVRYTQG.cjs.map +0 -7
- package/dist/lib/node/chunk-2ZVZI2KJ.cjs.map +0 -7
- package/dist/lib/node/chunk-45YW2DX2.cjs +0 -1656
- package/dist/lib/node/chunk-45YW2DX2.cjs.map +0 -7
- package/dist/lib/node/chunk-KSEEI5VC.cjs +0 -3323
- package/dist/lib/node/chunk-KSEEI5VC.cjs.map +0 -7
- package/dist/lib/node/chunk-OWH2EUHZ.cjs +0 -90
- package/dist/lib/node/chunk-OWH2EUHZ.cjs.map +0 -7
- package/dist/lib/node/compute-graph-WILPHO4A.cjs +0 -57
- package/dist/lib/node/compute-graph-WILPHO4A.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs +0 -297
- package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6JF2AHKO.mjs +0 -3270
- package/dist/lib/node-esm/chunk-6JF2AHKO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BM2Q3FFC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BVS2IQRO.mjs +0 -68
- package/dist/lib/node-esm/chunk-BVS2IQRO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NYDNXI7L.mjs +0 -1676
- package/dist/lib/node-esm/chunk-NYDNXI7L.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs +0 -36
- package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -17
- package/dist/lib/node-esm/types.mjs.map +0 -7
- package/dist/types/src/components/SheetObjectSettings.d.ts +0 -7
- package/dist/types/src/components/SheetObjectSettings.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -48
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +0 -7
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts +0 -34
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.d.ts +0 -64
- package/dist/types/src/compute-graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.test.d.ts +0 -2
- package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-node.d.ts +0 -26
- package/dist/types/src/compute-graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/async-function.d.ts +0 -66
- package/dist/types/src/compute-graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/edge-function.d.ts +0 -21
- package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/function-defs.d.ts +0 -11
- package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/index.d.ts +0 -4
- package/dist/types/src/compute-graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/compute-graph/index.d.ts +0 -5
- package/dist/types/src/compute-graph/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/index.d.ts +0 -3
- package/dist/types/src/compute-graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/test-builder.d.ts +0 -15
- package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts +0 -36
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/compute-graph/util.d.ts +0 -2
- package/dist/types/src/compute-graph/util.d.ts.map +0 -1
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts +0 -26
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts +0 -2
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -182
- package/dist/types/src/types.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/components/SheetObjectSettings.tsx +0 -38
- package/src/components/Toolbar/Toolbar.tsx +0 -346
- package/src/compute-graph/compute-graph-registry.ts +0 -90
- package/src/compute-graph/compute-graph.test.ts +0 -87
- package/src/compute-graph/compute-graph.ts +0 -260
- package/src/compute-graph/compute-node.ts +0 -62
- package/src/compute-graph/functions/async-function.ts +0 -179
- package/src/compute-graph/functions/edge-function.ts +0 -102
- package/src/compute-graph/functions/function-defs.ts +0 -2427
- package/src/compute-graph/functions/index.ts +0 -7
- package/src/compute-graph/hyperformula.test.ts +0 -14
- package/src/compute-graph/index.ts +0 -8
- package/src/compute-graph/testing/index.ts +0 -6
- package/src/compute-graph/testing/test-builder.ts +0 -54
- package/src/compute-graph/testing/test-plugin.ts +0 -100
- package/src/compute-graph/util.ts +0 -8
- package/src/defs/types.test.ts +0 -91
- package/src/defs/types.ts +0 -88
- package/src/types.ts +0 -125
- /package/dist/lib/browser/{compute-graph-SNUS7HOH.mjs.map → types/index.mjs.map} +0 -0
- /package/dist/lib/{browser/meta.mjs.map → node-esm/types/index.mjs.map} +0 -0
- /package/dist/types/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.d.ts +0 -0
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { SPACE_PLUGIN } from '@dxos/plugin-space/meta';
|
|
8
|
-
import { Input, useTranslation } from '@dxos/react-ui';
|
|
9
|
-
|
|
10
|
-
import { RangeList } from './RangeList';
|
|
11
|
-
import { type SheetType } from '../types';
|
|
12
|
-
|
|
13
|
-
export type SheetObjectSettingsProps = {
|
|
14
|
-
sheet: SheetType;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const SheetObjectSettings = ({ sheet }: SheetObjectSettingsProps) => {
|
|
18
|
-
const { t } = useTranslation(SPACE_PLUGIN);
|
|
19
|
-
|
|
20
|
-
// TODO(burdon): Standardize forms.
|
|
21
|
-
return (
|
|
22
|
-
<>
|
|
23
|
-
<div role='form' className='flex flex-col w-full p-2 gap-1'>
|
|
24
|
-
<Input.Root>
|
|
25
|
-
<Input.Label>{t('name label')}</Input.Label>
|
|
26
|
-
<Input.TextInput
|
|
27
|
-
placeholder={t('name placeholder')}
|
|
28
|
-
value={sheet.name ?? ''}
|
|
29
|
-
onChange={(event) => {
|
|
30
|
-
sheet.name = event.target.value;
|
|
31
|
-
}}
|
|
32
|
-
/>
|
|
33
|
-
</Input.Root>
|
|
34
|
-
</div>
|
|
35
|
-
<RangeList sheet={sheet} />
|
|
36
|
-
</>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { createContext } from '@radix-ui/react-context';
|
|
6
|
-
import React, { type PropsWithChildren, useCallback } from 'react';
|
|
7
|
-
|
|
8
|
-
import { useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
-
import {
|
|
10
|
-
Icon,
|
|
11
|
-
type ThemedClassName,
|
|
12
|
-
Toolbar as NaturalToolbar,
|
|
13
|
-
type ToolbarButtonProps as NaturalToolbarButtonProps,
|
|
14
|
-
type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,
|
|
15
|
-
type ToolbarToggleProps as NaturalToolbarToggleProps,
|
|
16
|
-
Tooltip,
|
|
17
|
-
useTranslation,
|
|
18
|
-
} from '@dxos/react-ui';
|
|
19
|
-
import { useAttention } from '@dxos/react-ui-attention';
|
|
20
|
-
import { nonNullable } from '@dxos/util';
|
|
21
|
-
|
|
22
|
-
import {
|
|
23
|
-
alignKey,
|
|
24
|
-
type AlignKey,
|
|
25
|
-
type AlignValue,
|
|
26
|
-
type CommentKey,
|
|
27
|
-
type CommentValue,
|
|
28
|
-
inRange,
|
|
29
|
-
rangeFromIndex,
|
|
30
|
-
rangeToIndex,
|
|
31
|
-
styleKey,
|
|
32
|
-
type StyleKey,
|
|
33
|
-
type StyleValue,
|
|
34
|
-
} from '../../defs';
|
|
35
|
-
import { completeCellRangeToThreadCursor } from '../../integrations';
|
|
36
|
-
import { SHEET_PLUGIN } from '../../meta';
|
|
37
|
-
import { type SheetType } from '../../types';
|
|
38
|
-
import { useSheetContext } from '../SheetContext';
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
// Buttons
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
const buttonStyles = 'min-bs-0 p-2';
|
|
45
|
-
const tooltipProps = { side: 'bottom' as const, classNames: 'z-10' };
|
|
46
|
-
|
|
47
|
-
const ToolbarSeparator = () => <div role='separator' className='grow' />;
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
// ToolbarItem
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
type ToolbarItemProps =
|
|
54
|
-
| (NaturalToolbarButtonProps & { itemType: 'button'; icon: string })
|
|
55
|
-
| (NaturalToolbarToggleGroupItemProps & { itemType: 'toggleGroupItem'; icon: string })
|
|
56
|
-
| (NaturalToolbarToggleProps & { itemType: 'toggle'; icon: string });
|
|
57
|
-
|
|
58
|
-
export const ToolbarItem = ({ itemType, icon, children, ...props }: ToolbarItemProps) => {
|
|
59
|
-
const Invoker =
|
|
60
|
-
itemType === 'toggleGroupItem'
|
|
61
|
-
? NaturalToolbar.ToggleGroupItem
|
|
62
|
-
: itemType === 'toggle'
|
|
63
|
-
? NaturalToolbar.Toggle
|
|
64
|
-
: NaturalToolbar.Button;
|
|
65
|
-
return (
|
|
66
|
-
<Tooltip.Root>
|
|
67
|
-
<Tooltip.Trigger asChild>
|
|
68
|
-
{/* TODO(thure): type the props spread better. */}
|
|
69
|
-
<Invoker variant='ghost' {...(props as any)} classNames={buttonStyles}>
|
|
70
|
-
<Icon icon={icon} size={5} />
|
|
71
|
-
<span className='sr-only'>{children}</span>
|
|
72
|
-
</Invoker>
|
|
73
|
-
</Tooltip.Trigger>
|
|
74
|
-
<Tooltip.Portal>
|
|
75
|
-
<Tooltip.Content {...tooltipProps}>
|
|
76
|
-
{children}
|
|
77
|
-
<Tooltip.Arrow />
|
|
78
|
-
</Tooltip.Content>
|
|
79
|
-
</Tooltip.Portal>
|
|
80
|
-
</Tooltip.Root>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
// Root
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
type AlignAction = { key: AlignKey; value: AlignValue };
|
|
89
|
-
type CommentAction = { key: CommentKey; value: CommentValue; cellContent?: string };
|
|
90
|
-
type StyleAction = { key: StyleKey; value: StyleValue };
|
|
91
|
-
|
|
92
|
-
export type ToolbarAction = StyleAction | AlignAction | CommentAction;
|
|
93
|
-
export type ToolbarActionAnnotated = ToolbarAction & { unset?: boolean };
|
|
94
|
-
|
|
95
|
-
export type ToolbarActionType = ToolbarAction['key'];
|
|
96
|
-
|
|
97
|
-
export type ToolbarActionHandler = (action: ToolbarActionAnnotated) => void;
|
|
98
|
-
|
|
99
|
-
export type ToolbarProps = ThemedClassName<
|
|
100
|
-
PropsWithChildren<{
|
|
101
|
-
role?: string;
|
|
102
|
-
}>
|
|
103
|
-
>;
|
|
104
|
-
|
|
105
|
-
const [ToolbarContextProvider, useToolbarContext] = createContext<{
|
|
106
|
-
onAction: (action: ToolbarActionAnnotated) => void;
|
|
107
|
-
}>('Toolbar');
|
|
108
|
-
|
|
109
|
-
type Range = SheetType['ranges'][number];
|
|
110
|
-
|
|
111
|
-
const ToolbarRoot = ({ children, role, classNames }: ToolbarProps) => {
|
|
112
|
-
const { id, model, cursorFallbackRange, cursor } = useSheetContext();
|
|
113
|
-
const { hasAttention } = useAttention(id);
|
|
114
|
-
const dispatch = useIntentDispatcher();
|
|
115
|
-
|
|
116
|
-
// TODO(Zan): Externalize the toolbar action handler. E.g., Toolbar/keys should both fire events.
|
|
117
|
-
const handleAction = useCallback(
|
|
118
|
-
(action: ToolbarActionAnnotated) => {
|
|
119
|
-
switch (action.key) {
|
|
120
|
-
case 'alignment':
|
|
121
|
-
if (cursorFallbackRange) {
|
|
122
|
-
const index =
|
|
123
|
-
model.sheet.ranges?.findIndex(
|
|
124
|
-
(range) =>
|
|
125
|
-
range.key === action.key &&
|
|
126
|
-
inRange(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from),
|
|
127
|
-
) ?? -1;
|
|
128
|
-
const nextRangeEntity = {
|
|
129
|
-
range: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
130
|
-
key: action.key,
|
|
131
|
-
value: action.value,
|
|
132
|
-
};
|
|
133
|
-
if (index < 0) {
|
|
134
|
-
model.sheet.ranges?.push(nextRangeEntity);
|
|
135
|
-
} else if (model.sheet.ranges![index].value === action.value) {
|
|
136
|
-
model.sheet.ranges?.splice(index, 1);
|
|
137
|
-
} else {
|
|
138
|
-
model.sheet.ranges?.splice(index, 1, nextRangeEntity);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
break;
|
|
142
|
-
case 'style':
|
|
143
|
-
if (action.unset) {
|
|
144
|
-
const index = model.sheet.ranges?.findIndex(
|
|
145
|
-
(range) =>
|
|
146
|
-
range.key === action.key &&
|
|
147
|
-
cursorFallbackRange &&
|
|
148
|
-
inRange(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from),
|
|
149
|
-
);
|
|
150
|
-
if (index >= 0) {
|
|
151
|
-
model.sheet.ranges?.splice(index, 1);
|
|
152
|
-
}
|
|
153
|
-
} else if (cursorFallbackRange) {
|
|
154
|
-
model.sheet.ranges?.push({
|
|
155
|
-
range: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
156
|
-
key: action.key,
|
|
157
|
-
value: action.value,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
break;
|
|
161
|
-
case 'comment': {
|
|
162
|
-
// TODO(Zan): We shouldn't hardcode the action ID.
|
|
163
|
-
if (cursorFallbackRange) {
|
|
164
|
-
void dispatch({
|
|
165
|
-
action: 'dxos.org/plugin/thread/action/create',
|
|
166
|
-
data: {
|
|
167
|
-
cursor: completeCellRangeToThreadCursor(cursorFallbackRange),
|
|
168
|
-
name: action.cellContent,
|
|
169
|
-
subject: model.sheet,
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
[model.sheet, cursorFallbackRange, cursor, dispatch],
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<ToolbarContextProvider onAction={handleAction}>
|
|
181
|
-
<NaturalToolbar.Root classNames={['pli-0.5 attention-surface', !hasAttention && 'opacity-20', classNames]}>
|
|
182
|
-
{children}
|
|
183
|
-
</NaturalToolbar.Root>
|
|
184
|
-
</ToolbarContextProvider>
|
|
185
|
-
);
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// TODO(burdon): Generalize.
|
|
189
|
-
// TODO(burdon): Detect and display current state.
|
|
190
|
-
type ButtonProps<T> = {
|
|
191
|
-
value: T;
|
|
192
|
-
icon: string;
|
|
193
|
-
disabled?: (state: Range) => boolean;
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
//
|
|
197
|
-
// Alignment
|
|
198
|
-
//
|
|
199
|
-
|
|
200
|
-
const alignmentOptions: ButtonProps<AlignValue>[] = [
|
|
201
|
-
{ value: 'start', icon: 'ph--text-align-left--regular' },
|
|
202
|
-
{ value: 'center', icon: 'ph--text-align-center--regular' },
|
|
203
|
-
{ value: 'end', icon: 'ph--text-align-right--regular' },
|
|
204
|
-
];
|
|
205
|
-
|
|
206
|
-
const Alignment = () => {
|
|
207
|
-
const { cursor, model } = useSheetContext();
|
|
208
|
-
const { onAction } = useToolbarContext('Alignment');
|
|
209
|
-
const { t } = useTranslation(SHEET_PLUGIN);
|
|
210
|
-
|
|
211
|
-
// TODO(thure): Can this O(n) call be memoized?
|
|
212
|
-
const value = cursor
|
|
213
|
-
? model.sheet.ranges?.findLast(
|
|
214
|
-
({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),
|
|
215
|
-
)?.value
|
|
216
|
-
: undefined;
|
|
217
|
-
|
|
218
|
-
return (
|
|
219
|
-
<NaturalToolbar.ToggleGroup
|
|
220
|
-
type='single'
|
|
221
|
-
value={
|
|
222
|
-
// TODO(thure): providing `undefined` leaves the last item active which was active rather than showing none.
|
|
223
|
-
value ?? 'never'
|
|
224
|
-
}
|
|
225
|
-
onValueChange={(value: AlignValue) => onAction?.({ key: alignKey, value })}
|
|
226
|
-
>
|
|
227
|
-
{alignmentOptions.map(({ value, icon }) => (
|
|
228
|
-
<ToolbarItem
|
|
229
|
-
itemType='toggleGroupItem'
|
|
230
|
-
key={value}
|
|
231
|
-
value={value}
|
|
232
|
-
icon={icon}
|
|
233
|
-
data-testid={`grid.toolbar.${alignKey}.${value}`}
|
|
234
|
-
>
|
|
235
|
-
{t('toolbar action label', {
|
|
236
|
-
key: t(`range key ${alignKey} label`),
|
|
237
|
-
value: t(`range value ${value} label`),
|
|
238
|
-
})}
|
|
239
|
-
</ToolbarItem>
|
|
240
|
-
))}
|
|
241
|
-
</NaturalToolbar.ToggleGroup>
|
|
242
|
-
);
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
const styleOptions: ButtonProps<StyleValue>[] = [
|
|
246
|
-
{ value: 'highlight', icon: 'ph--highlighter--regular' },
|
|
247
|
-
{ value: 'softwrap', icon: 'ph--paragraph--regular' },
|
|
248
|
-
];
|
|
249
|
-
|
|
250
|
-
const Styles = () => {
|
|
251
|
-
const { cursorFallbackRange, model } = useSheetContext();
|
|
252
|
-
const { onAction } = useToolbarContext('Styles');
|
|
253
|
-
const { t } = useTranslation(SHEET_PLUGIN);
|
|
254
|
-
|
|
255
|
-
// TODO(thure): Can this O(n) call be memoized?
|
|
256
|
-
const activeValues = cursorFallbackRange
|
|
257
|
-
? model.sheet.ranges
|
|
258
|
-
?.filter(
|
|
259
|
-
({ range, key }) => key === 'style' && inRange(rangeFromIndex(model.sheet, range), cursorFallbackRange.from),
|
|
260
|
-
)
|
|
261
|
-
.reduce((acc, { value }) => {
|
|
262
|
-
acc.add(value);
|
|
263
|
-
return acc;
|
|
264
|
-
}, new Set())
|
|
265
|
-
: undefined;
|
|
266
|
-
|
|
267
|
-
return (
|
|
268
|
-
<>
|
|
269
|
-
{styleOptions.map(({ value, icon }) => (
|
|
270
|
-
<ToolbarItem
|
|
271
|
-
itemType='toggle'
|
|
272
|
-
key={value}
|
|
273
|
-
pressed={activeValues?.has(value)}
|
|
274
|
-
onPressedChange={(nextPressed: boolean) => {
|
|
275
|
-
onAction?.({ key: 'style', value, unset: !nextPressed });
|
|
276
|
-
}}
|
|
277
|
-
icon={icon}
|
|
278
|
-
>
|
|
279
|
-
{t('toolbar action label', {
|
|
280
|
-
key: t(`range key ${styleKey} label`),
|
|
281
|
-
value: t(`range value ${value} label`),
|
|
282
|
-
})}
|
|
283
|
-
</ToolbarItem>
|
|
284
|
-
))}
|
|
285
|
-
</>
|
|
286
|
-
);
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
//
|
|
290
|
-
// Actions
|
|
291
|
-
//
|
|
292
|
-
|
|
293
|
-
const Actions = () => {
|
|
294
|
-
const { onAction } = useToolbarContext('Actions');
|
|
295
|
-
const { cursorFallbackRange, cursor, model } = useSheetContext();
|
|
296
|
-
const { t } = useTranslation(SHEET_PLUGIN);
|
|
297
|
-
|
|
298
|
-
// TODO(thure): Can this O(n) call be memoized?
|
|
299
|
-
const overlapsCommentAnchor = (model.sheet.threads ?? [])
|
|
300
|
-
.filter(nonNullable)
|
|
301
|
-
.filter((thread) => thread.status !== 'resolved')
|
|
302
|
-
.some((thread) => {
|
|
303
|
-
if (!cursorFallbackRange) {
|
|
304
|
-
return false;
|
|
305
|
-
}
|
|
306
|
-
return rangeToIndex(model.sheet, cursorFallbackRange) === thread.anchor;
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
const tooltipLabelKey = !cursor
|
|
310
|
-
? 'no cursor label'
|
|
311
|
-
: overlapsCommentAnchor
|
|
312
|
-
? 'selection overlaps existing comment label'
|
|
313
|
-
: 'comment label';
|
|
314
|
-
|
|
315
|
-
return (
|
|
316
|
-
<ToolbarItem
|
|
317
|
-
itemType='button'
|
|
318
|
-
value='comment'
|
|
319
|
-
icon='ph--chat-text--regular'
|
|
320
|
-
data-testid='editor.toolbar.comment'
|
|
321
|
-
onClick={() => {
|
|
322
|
-
if (!cursorFallbackRange) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
return onAction?.({
|
|
326
|
-
key: 'comment',
|
|
327
|
-
value: rangeToIndex(model.sheet, cursorFallbackRange),
|
|
328
|
-
cellContent: model.getCellText(cursorFallbackRange.from),
|
|
329
|
-
});
|
|
330
|
-
}}
|
|
331
|
-
disabled={!cursorFallbackRange || overlapsCommentAnchor}
|
|
332
|
-
>
|
|
333
|
-
{t(tooltipLabelKey)}
|
|
334
|
-
</ToolbarItem>
|
|
335
|
-
);
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
export const Toolbar = {
|
|
339
|
-
Root: ToolbarRoot,
|
|
340
|
-
Separator: ToolbarSeparator,
|
|
341
|
-
Alignment,
|
|
342
|
-
Styles,
|
|
343
|
-
Actions,
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
export { useToolbarContext };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import type { FunctionPluginDefinition } from 'hyperformula';
|
|
6
|
-
import type { ConfigParams } from 'hyperformula/typings/ConfigParams';
|
|
7
|
-
import type { FunctionTranslationsPackage } from 'hyperformula/typings/interpreter';
|
|
8
|
-
import defaultsDeep from 'lodash.defaultsdeep';
|
|
9
|
-
|
|
10
|
-
import { type SpaceId, type Space } from '@dxos/client/echo';
|
|
11
|
-
import { Resource } from '@dxos/context';
|
|
12
|
-
import { invariant } from '@dxos/invariant';
|
|
13
|
-
import { log } from '@dxos/log';
|
|
14
|
-
|
|
15
|
-
import { HyperFormula } from '#hyperformula';
|
|
16
|
-
import { ComputeGraph } from './compute-graph';
|
|
17
|
-
import { EdgeFunctionPlugin, EdgeFunctionPluginTranslations, type FunctionContextOptions } from './functions';
|
|
18
|
-
|
|
19
|
-
export type ComputeGraphPlugin = {
|
|
20
|
-
plugin: FunctionPluginDefinition;
|
|
21
|
-
translations: FunctionTranslationsPackage;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type ComputeGraphOptions = {
|
|
25
|
-
plugins?: ComputeGraphPlugin[];
|
|
26
|
-
} & Partial<FunctionContextOptions> &
|
|
27
|
-
Partial<ConfigParams>;
|
|
28
|
-
|
|
29
|
-
export const defaultOptions: ComputeGraphOptions = {
|
|
30
|
-
licenseKey: 'gpl-v3',
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const defaultPlugins: ComputeGraphPlugin[] = [
|
|
34
|
-
{
|
|
35
|
-
plugin: EdgeFunctionPlugin,
|
|
36
|
-
translations: EdgeFunctionPluginTranslations,
|
|
37
|
-
},
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Manages a collection of ComputeGraph instances for each space.
|
|
42
|
-
*
|
|
43
|
-
* [ComputePlugin] => [ComputeGraphRegistry] => [ComputeGraph(Space)] => [ComputeNode(Object)]
|
|
44
|
-
*
|
|
45
|
-
* NOTE: The ComputeGraphRegistry manages the hierarchy of resources via its root Context.
|
|
46
|
-
* NOTE: The package.json file defines the packaged #hyperformula module.
|
|
47
|
-
*/
|
|
48
|
-
// TODO(burdon): Move graph into separate plugin; isolate HF deps.
|
|
49
|
-
export class ComputeGraphRegistry extends Resource {
|
|
50
|
-
private readonly _graphs = new Map<SpaceId, ComputeGraph>();
|
|
51
|
-
|
|
52
|
-
private readonly _options: ComputeGraphOptions;
|
|
53
|
-
|
|
54
|
-
constructor(options: ComputeGraphOptions = { plugins: defaultPlugins }) {
|
|
55
|
-
super();
|
|
56
|
-
this._options = defaultsDeep({}, options, defaultOptions);
|
|
57
|
-
this._options.plugins?.forEach(({ plugin, translations }) => {
|
|
58
|
-
HyperFormula.registerFunctionPlugin(plugin, translations);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
getGraph(spaceId: SpaceId): ComputeGraph | undefined {
|
|
63
|
-
return this._graphs.get(spaceId);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
getOrCreateGraph(space: Space): ComputeGraph {
|
|
67
|
-
let graph = this._graphs.get(space.id);
|
|
68
|
-
if (!graph) {
|
|
69
|
-
log('create graph', { space: space.id });
|
|
70
|
-
graph = this.createGraph(space);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return graph;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
createGraph(space: Space): ComputeGraph {
|
|
77
|
-
invariant(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`);
|
|
78
|
-
const hf = HyperFormula.buildEmpty(this._options);
|
|
79
|
-
const graph = new ComputeGraph(hf, space, this._options);
|
|
80
|
-
this._graphs.set(space.id, graph);
|
|
81
|
-
return graph;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
protected override async _close() {
|
|
85
|
-
for (const graph of this._graphs.values()) {
|
|
86
|
-
await graph.close();
|
|
87
|
-
}
|
|
88
|
-
this._graphs.clear();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
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, { name: 'test', version: '0.0.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
|
-
});
|