@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.
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs +1772 -0
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-5WPZCXNS.mjs → browser/chunk-D5AGLXJP.mjs} +678 -411
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
- package/dist/lib/browser/chunk-FUAGSXA4.mjs +82 -0
- package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +7 -0
- package/dist/lib/browser/chunk-JRL5LGCE.mjs +18 -0
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +7 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +62 -93
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/testing.mjs +92 -0
- package/dist/lib/browser/testing.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +12 -6
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs +1765 -0
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-5KKJ4NPP.cjs} +678 -418
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs +51 -0
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +7 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
- package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-DSYKOI4E.cjs} +51 -40
- package/dist/lib/node/chunk-DSYKOI4E.cjs.map +7 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +69 -105
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing.cjs +111 -0
- package/dist/lib/node/testing.cjs.map +7 -0
- package/dist/lib/node/types.cjs +15 -9
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +14 -0
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -0
- package/dist/types/src/components/{GridSheet/SheetCellEditor.stories.d.ts → CellEditor/CellEditor.stories.d.ts} +4 -4
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/{extensions/editor → components/CellEditor}/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -0
- package/dist/types/src/components/CellEditor/extension.test.d.ts.map +1 -0
- package/dist/types/src/components/CellEditor/index.d.ts +3 -0
- package/dist/types/src/components/CellEditor/index.d.ts.map +1 -0
- package/dist/types/src/{graph/functions → components/ComputeGraph}/async-function.d.ts +5 -14
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/custom.d.ts +21 -0
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +20 -0
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +12 -0
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +2 -0
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts +26 -0
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +55 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +54 -0
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/formatting.d.ts +14 -0
- package/dist/types/src/components/Sheet/formatting.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/grid.d.ts +52 -0
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/index.d.ts +2 -0
- package/dist/types/src/components/Sheet/index.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/nav.d.ts +29 -0
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/sheet-context.d.ts +25 -0
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/util.d.ts +18 -0
- package/dist/types/src/components/Sheet/util.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer.d.ts +9 -0
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +9 -33
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +15 -19
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/common.d.ts +20 -0
- package/dist/types/src/components/Toolbar/common.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +9 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/{graph/functions/function-defs.d.ts → model/functions.d.ts} +1 -1
- package/dist/types/src/model/functions.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +3 -2
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/model.browser.test.d.ts +2 -0
- package/dist/types/src/model/model.browser.test.d.ts.map +1 -0
- package/dist/types/src/model/{sheet-model.d.ts → model.d.ts} +67 -13
- package/dist/types/src/model/model.d.ts.map +1 -0
- package/dist/types/src/{defs → model}/types.d.ts +3 -8
- package/dist/types/src/model/types.d.ts.map +1 -0
- package/dist/types/src/model/types.test.d.ts.map +1 -0
- package/dist/types/src/model/util.d.ts +15 -0
- package/dist/types/src/model/util.d.ts.map +1 -0
- package/dist/types/src/testing.d.ts +9 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +12 -17
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +40 -125
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +52 -58
- package/src/SheetPlugin.tsx +74 -52
- package/src/components/{GridSheet/SheetCellEditor.stories.tsx → CellEditor/CellEditor.stories.tsx} +8 -8
- package/src/components/CellEditor/CellEditor.tsx +113 -0
- package/src/{extensions/editor → components/CellEditor}/extension.test.ts +6 -4
- package/src/{extensions/editor → components/CellEditor}/extension.ts +6 -5
- package/src/{extensions/editor → components/CellEditor}/index.ts +1 -0
- package/src/{graph/functions → components/ComputeGraph}/async-function.ts +15 -25
- package/src/{graph/testing/test-plugin.ts → components/ComputeGraph/custom.ts} +14 -44
- package/src/{graph/functions → components/ComputeGraph}/edge-function.ts +14 -16
- package/src/components/ComputeGraph/graph-context.tsx +50 -0
- package/src/components/ComputeGraph/graph.browser.test.ts +50 -0
- package/src/components/ComputeGraph/graph.ts +62 -0
- package/src/components/ComputeGraph/index.ts +3 -1
- package/src/components/Sheet/Sheet.stories.tsx +287 -0
- package/src/components/Sheet/Sheet.tsx +1160 -0
- package/src/components/Sheet/formatting.ts +106 -0
- package/src/components/Sheet/grid.ts +191 -0
- package/src/{testing → components/Sheet}/index.ts +1 -1
- package/src/components/Sheet/nav.ts +157 -0
- package/src/components/Sheet/sheet-context.tsx +150 -0
- package/src/components/Sheet/util.ts +56 -0
- package/src/components/SheetContainer.tsx +34 -0
- package/src/components/Toolbar/Toolbar.tsx +112 -242
- package/src/components/Toolbar/common.tsx +72 -0
- package/src/components/index.ts +0 -2
- package/src/meta.tsx +18 -0
- package/src/model/index.ts +3 -2
- package/src/model/model.browser.test.ts +100 -0
- package/src/model/model.ts +550 -0
- package/src/{defs → model}/types.test.ts +9 -8
- package/src/{defs → model}/types.ts +14 -24
- package/src/model/util.ts +36 -0
- package/src/testing.ts +50 -0
- package/src/translations.ts +1 -6
- package/src/types.ts +47 -40
- package/dist/lib/browser/SheetContainer-RVRACGCZ.mjs +0 -290
- package/dist/lib/browser/SheetContainer-RVRACGCZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-BWN5DZWZ.mjs +0 -74
- package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-D3QTX46O.mjs +0 -14
- package/dist/lib/browser/chunk-D3QTX46O.mjs.map +0 -7
- package/dist/lib/browser/chunk-GSV5QNLD.mjs +0 -2966
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +0 -7
- package/dist/lib/browser/chunk-HOG37RYS.mjs +0 -1528
- package/dist/lib/browser/chunk-HOG37RYS.mjs.map +0 -7
- package/dist/lib/browser/graph-M4IQ76QX.mjs +0 -33
- package/dist/lib/browser/graph-M4IQ76QX.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-J7XROAMN.cjs +0 -300
- package/dist/lib/node/SheetContainer-J7XROAMN.cjs.map +0 -7
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +0 -7
- package/dist/lib/node/chunk-AXQZA2YS.cjs +0 -1527
- package/dist/lib/node/chunk-AXQZA2YS.cjs.map +0 -7
- package/dist/lib/node/chunk-NZARD7UP.cjs.map +0 -7
- package/dist/lib/node/chunk-QIFIGEKV.cjs +0 -37
- package/dist/lib/node/chunk-QIFIGEKV.cjs.map +0 -7
- package/dist/lib/node/graph-Q3N2X26H.cjs +0 -55
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-YWQVKHQB.mjs +0 -291
- package/dist/lib/node-esm/SheetContainer-YWQVKHQB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BPXXIAOQ.mjs +0 -1529
- package/dist/lib/node-esm/chunk-BPXXIAOQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VCYJWE3O.mjs +0 -16
- package/dist/lib/node-esm/chunk-VCYJWE3O.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WFDTY3IC.mjs +0 -75
- package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +0 -7
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs +0 -34
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -280
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- 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/ComputeGraph/ComputeGraphContextProvider.d.ts +0 -11
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +0 -1
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +0 -3
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +0 -1
- package/dist/types/src/components/FunctionEditor/index.d.ts +0 -2
- package/dist/types/src/components/FunctionEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -3
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -9
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/index.d.ts +0 -2
- package/dist/types/src/components/GridSheet/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/util.d.ts +0 -16
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -6
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +0 -11
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/index.d.ts +0 -3
- package/dist/types/src/components/SheetContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +0 -26
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/index.d.ts +0 -2
- package/dist/types/src/components/SheetContext/index.d.ts.map +0 -1
- package/dist/types/src/defs/index.d.ts +0 -4
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/sheet-range-types.d.ts +0 -13
- package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts +0 -43
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.d.ts +0 -6
- package/dist/types/src/extensions/compute.d.ts.map +0 -1
- package/dist/types/src/extensions/compute.stories.d.ts +0 -26
- package/dist/types/src/extensions/compute.stories.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/extension.test.d.ts.map +0 -1
- package/dist/types/src/extensions/editor/index.d.ts +0 -2
- package/dist/types/src/extensions/editor/index.d.ts.map +0 -1
- package/dist/types/src/extensions/index.d.ts +0 -3
- package/dist/types/src/extensions/index.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph-registry.d.ts +0 -34
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts +0 -64
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts +0 -10
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.test.d.ts +0 -2
- package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/graph/compute-node.d.ts +0 -26
- package/dist/types/src/graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/edge-function.d.ts +0 -21
- package/dist/types/src/graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/functions/index.d.ts +0 -4
- package/dist/types/src/graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts +0 -5
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/index.d.ts +0 -3
- package/dist/types/src/graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-builder.d.ts +0 -15
- package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-plugin.d.ts +0 -36
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts +0 -2
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -11
- package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/threads.d.ts +0 -8
- package/dist/types/src/hooks/threads.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useSheetModel.d.ts +0 -8
- package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/decorations.d.ts +0 -25
- package/dist/types/src/model/decorations.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.d.ts.map +0 -1
- package/dist/types/src/model/sheet-model.test.d.ts +0 -2
- package/dist/types/src/model/sheet-model.test.d.ts.map +0 -1
- package/dist/types/src/sanity.test.d.ts +0 -2
- package/dist/types/src/sanity.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts +0 -8
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +0 -20
- package/src/components/FunctionEditor/FunctionEditor.tsx +0 -45
- package/src/components/FunctionEditor/index.ts +0 -5
- package/src/components/GridSheet/GridSheet.stories.tsx +0 -41
- package/src/components/GridSheet/GridSheet.tsx +0 -163
- package/src/components/GridSheet/index.ts +0 -5
- package/src/components/GridSheet/util.ts +0 -158
- package/src/components/SheetContainer/SheetContainer.stories.tsx +0 -40
- package/src/components/SheetContainer/SheetContainer.tsx +0 -27
- package/src/components/SheetContainer/index.ts +0 -7
- package/src/components/SheetContext/SheetContext.tsx +0 -104
- package/src/components/SheetContext/index.ts +0 -5
- package/src/defs/index.ts +0 -7
- package/src/defs/sheet-range-types.ts +0 -46
- package/src/defs/util.ts +0 -151
- package/src/extensions/compute.stories.tsx +0 -151
- package/src/extensions/compute.ts +0 -147
- package/src/extensions/index.ts +0 -6
- package/src/graph/compute-graph-registry.ts +0 -90
- package/src/graph/compute-graph.stories.tsx +0 -93
- package/src/graph/compute-graph.test.ts +0 -87
- package/src/graph/compute-graph.ts +0 -242
- package/src/graph/compute-node.ts +0 -63
- package/src/graph/functions/index.ts +0 -7
- package/src/graph/hyperformula.test.ts +0 -14
- package/src/graph/index.ts +0 -8
- package/src/graph/testing/index.ts +0 -6
- package/src/graph/testing/test-builder.ts +0 -54
- package/src/graph/util.ts +0 -8
- package/src/hooks/hooks.stories.tsx +0 -50
- package/src/hooks/index.ts +0 -7
- package/src/hooks/threads.ts +0 -147
- package/src/hooks/useComputeGraph.ts +0 -28
- package/src/hooks/useSheetModel.ts +0 -40
- package/src/meta.ts +0 -14
- package/src/model/decorations.ts +0 -64
- package/src/model/sheet-model.test.ts +0 -57
- package/src/model/sheet-model.ts +0 -418
- package/src/sanity.test.ts +0 -40
- package/src/testing/testing.tsx +0 -68
- /package/dist/types/src/{extensions/editor → components/CellEditor}/extension.test.d.ts +0 -0
- /package/dist/types/src/{defs → model}/types.test.d.ts +0 -0
- /package/src/{graph/functions/function-defs.ts → model/functions.ts} +0 -0
|
@@ -26,97 +26,45 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
createSheetName: () => createSheetName,
|
|
40
|
-
defaultFunctionContextOptions: () => defaultFunctionContextOptions,
|
|
29
|
+
var chunk_5KKJ4NPP_exports = {};
|
|
30
|
+
__export(chunk_5KKJ4NPP_exports, {
|
|
31
|
+
CustomPlugin: () => CustomPlugin,
|
|
32
|
+
CustomPluginTranslations: () => CustomPluginTranslations,
|
|
33
|
+
FunctionPluginAsync: () => FunctionPluginAsync,
|
|
34
|
+
SheetModel: () => SheetModel,
|
|
35
|
+
addressFromA1Notation: () => addressFromA1Notation,
|
|
36
|
+
addressToA1Notation: () => addressToA1Notation,
|
|
37
|
+
columnLetter: () => columnLetter,
|
|
38
|
+
createComputeGraph: () => createComputeGraph,
|
|
41
39
|
defaultFunctions: () => defaultFunctions,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
inRange: () => inRange,
|
|
41
|
+
posEquals: () => posEquals,
|
|
42
|
+
rangeToA1Notation: () => rangeToA1Notation
|
|
45
43
|
});
|
|
46
|
-
module.exports = __toCommonJS(
|
|
44
|
+
module.exports = __toCommonJS(chunk_5KKJ4NPP_exports);
|
|
45
|
+
var import_chunk_DSYKOI4E = require("./chunk-DSYKOI4E.cjs");
|
|
46
|
+
var import_hyperformula = require("hyperformula");
|
|
47
47
|
var import_async = require("@dxos/async");
|
|
48
|
-
var import_echo = require("@dxos/client/echo");
|
|
49
|
-
var import_context = require("@dxos/context");
|
|
50
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
51
|
-
var import_invariant = require("@dxos/invariant");
|
|
52
48
|
var import_keys = require("@dxos/keys");
|
|
53
49
|
var import_log = require("@dxos/log");
|
|
54
|
-
var
|
|
55
|
-
var import_util = require("@dxos/util");
|
|
56
|
-
var import_hyperformula = require("#hyperformula");
|
|
57
|
-
var import_async2 = require("@dxos/async");
|
|
58
|
-
var import_context2 = require("@dxos/context");
|
|
59
|
-
var import_hyperformula2 = require("#hyperformula");
|
|
50
|
+
var import_hyperformula2 = require("hyperformula");
|
|
60
51
|
var import_lodash = __toESM(require("lodash.defaultsdeep"));
|
|
61
|
-
var
|
|
52
|
+
var import_async2 = require("@dxos/async");
|
|
62
53
|
var import_log2 = require("@dxos/log");
|
|
63
|
-
var import_hyperformula3 = require("
|
|
64
|
-
var
|
|
65
|
-
var
|
|
54
|
+
var import_hyperformula3 = require("hyperformula");
|
|
55
|
+
var import_async3 = require("@dxos/async");
|
|
56
|
+
var import_context = require("@dxos/context");
|
|
57
|
+
var import_invariant = require("@dxos/invariant");
|
|
58
|
+
var import_keys2 = require("@dxos/keys");
|
|
66
59
|
var import_log3 = require("@dxos/log");
|
|
67
|
-
var import_edge = require("@dxos/plugin-script/edge");
|
|
68
|
-
var import_types2 = require("@dxos/plugin-script/types");
|
|
69
|
-
var import_util2 = require("@dxos/util");
|
|
70
|
-
var import_hyperformula4 = require("#hyperformula");
|
|
71
|
-
var import_lodash2 = __toESM(require("lodash.defaultsdeep"));
|
|
72
|
-
var import_context3 = require("@dxos/context");
|
|
73
60
|
var import_invariant2 = require("@dxos/invariant");
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
super();
|
|
79
|
-
this._graph = _graph;
|
|
80
|
-
this.sheetId = sheetId;
|
|
81
|
-
this.update = new import_async2.Event();
|
|
82
|
-
}
|
|
83
|
-
get graph() {
|
|
84
|
-
return this._graph;
|
|
85
|
-
}
|
|
86
|
-
clear() {
|
|
87
|
-
this._graph.hf.clearSheet(this.sheetId);
|
|
88
|
-
}
|
|
89
|
-
getValue(cell) {
|
|
90
|
-
const value = this._graph.hf.getCellValue({
|
|
91
|
-
sheet: this.sheetId,
|
|
92
|
-
row: cell.row,
|
|
93
|
-
col: cell.col
|
|
94
|
-
});
|
|
95
|
-
if (value instanceof import_hyperformula2.DetailedCellError) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
return value;
|
|
99
|
-
}
|
|
100
|
-
setValue(cell, value) {
|
|
101
|
-
const mappedValue = typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value;
|
|
102
|
-
this._graph.hf.setCellContents({
|
|
103
|
-
sheet: this.sheetId,
|
|
104
|
-
row: cell.row,
|
|
105
|
-
col: cell.col
|
|
106
|
-
}, [
|
|
107
|
-
[
|
|
108
|
-
mappedValue
|
|
109
|
-
]
|
|
110
|
-
]);
|
|
111
|
-
}
|
|
112
|
-
// TODO(burdon): Load data into sheet.
|
|
113
|
-
async _open() {
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/functions/async-function.ts";
|
|
61
|
+
var import_crypto = require("@dxos/crypto");
|
|
62
|
+
var import_hyperformula4 = require("hyperformula");
|
|
63
|
+
var import_util = require("@dxos/util");
|
|
64
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/ComputeGraph/async-function.ts";
|
|
117
65
|
var defaultFunctionContextOptions = {
|
|
118
66
|
defaultTtl: 5e3,
|
|
119
|
-
|
|
67
|
+
recalculationDelay: 200,
|
|
120
68
|
remoteFunctionUrl: "https://edge.dxos.workers.dev/functions"
|
|
121
69
|
};
|
|
122
70
|
var FunctionContext = class _FunctionContext {
|
|
@@ -127,7 +75,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
127
75
|
...args
|
|
128
76
|
});
|
|
129
77
|
}
|
|
130
|
-
constructor(_hf, _space, _options) {
|
|
78
|
+
constructor(_hf, _space, onUpdate, _options) {
|
|
131
79
|
this._hf = _hf;
|
|
132
80
|
this._space = _space;
|
|
133
81
|
this._cache = /* @__PURE__ */ new Map();
|
|
@@ -135,10 +83,10 @@ var FunctionContext = class _FunctionContext {
|
|
|
135
83
|
this._subscriptions = /* @__PURE__ */ new Map();
|
|
136
84
|
this._invocations = {};
|
|
137
85
|
this._options = (0, import_lodash.default)(_options ?? {}, defaultFunctionContextOptions);
|
|
138
|
-
this._onUpdate = (0,
|
|
86
|
+
this._onUpdate = (0, import_async2.debounce)(() => {
|
|
139
87
|
this._hf.resumeEvaluation();
|
|
140
|
-
|
|
141
|
-
}, this._options.
|
|
88
|
+
onUpdate(this);
|
|
89
|
+
}, this._options.recalculationDelay);
|
|
142
90
|
}
|
|
143
91
|
get space() {
|
|
144
92
|
return this._space;
|
|
@@ -188,26 +136,23 @@ var FunctionContext = class _FunctionContext {
|
|
|
188
136
|
value: value2
|
|
189
137
|
}, {
|
|
190
138
|
F: __dxlog_file,
|
|
191
|
-
L:
|
|
139
|
+
L: 136,
|
|
192
140
|
S: this,
|
|
193
141
|
C: (f, a) => f(...a)
|
|
194
142
|
});
|
|
195
|
-
this._onUpdate(
|
|
196
|
-
name,
|
|
197
|
-
cell
|
|
198
|
-
});
|
|
143
|
+
this._onUpdate();
|
|
199
144
|
} catch (err) {
|
|
200
145
|
import_log2.log.warn("failed", {
|
|
201
146
|
cell,
|
|
202
147
|
err
|
|
203
148
|
}, {
|
|
204
149
|
F: __dxlog_file,
|
|
205
|
-
L:
|
|
150
|
+
L: 140,
|
|
206
151
|
S: this,
|
|
207
152
|
C: (f, a) => f(...a)
|
|
208
153
|
});
|
|
209
154
|
this._cache.set(invocationKey, {
|
|
210
|
-
value: new
|
|
155
|
+
value: new import_hyperformula2.CellError(import_hyperformula2.ErrorType.ERROR, "Function failed."),
|
|
211
156
|
ts: Date.now()
|
|
212
157
|
});
|
|
213
158
|
} finally {
|
|
@@ -222,137 +167,59 @@ var FunctionContext = class _FunctionContext {
|
|
|
222
167
|
cache: value
|
|
223
168
|
}, {
|
|
224
169
|
F: __dxlog_file,
|
|
225
|
-
L:
|
|
170
|
+
L: 148,
|
|
226
171
|
S: this,
|
|
227
172
|
C: (f, a) => f(...a)
|
|
228
173
|
});
|
|
229
174
|
return value;
|
|
230
175
|
}
|
|
231
176
|
};
|
|
232
|
-
var
|
|
177
|
+
var FunctionPluginAsync = class extends import_hyperformula2.FunctionPlugin {
|
|
233
178
|
get context() {
|
|
234
179
|
return this.config.context;
|
|
235
180
|
}
|
|
236
|
-
/**
|
|
237
|
-
* Immediately returns cached value then runs the async function.
|
|
238
|
-
*/
|
|
239
181
|
runAsyncFunction(ast, state, cb, options) {
|
|
240
182
|
const { procedureName } = ast;
|
|
241
183
|
const metadata = this.metadata(procedureName);
|
|
242
184
|
return this.runFunction(ast.args, state, metadata, (...args) => {
|
|
243
|
-
return this.context.invokeFunction(procedureName, state, args, cb, options) ??
|
|
185
|
+
return this.context.invokeFunction(procedureName, state, args, cb, options) ?? import_hyperformula2.EmptyValue;
|
|
244
186
|
});
|
|
245
187
|
}
|
|
246
188
|
};
|
|
247
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/
|
|
248
|
-
var
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
const { objects: [fn] } = await space.db.query(import_echo2.Filter.schema(import_types2.FunctionType, {
|
|
258
|
-
binding
|
|
259
|
-
})).run();
|
|
260
|
-
if (!fn) {
|
|
261
|
-
import_log3.log.info("Function not found", {
|
|
262
|
-
binding
|
|
263
|
-
}, {
|
|
264
|
-
F: __dxlog_file2,
|
|
265
|
-
L: 41,
|
|
266
|
-
S: this,
|
|
267
|
-
C: (f, a) => f(...a)
|
|
268
|
-
});
|
|
269
|
-
return new import_hyperformula4.CellError(import_hyperformula4.ErrorType.REF, "Function not found");
|
|
270
|
-
}
|
|
271
|
-
if (subscribe) {
|
|
272
|
-
const unsubscribe = (0, import_signals_core.effect)(() => {
|
|
273
|
-
import_log3.log.info("function changed", {
|
|
274
|
-
fn
|
|
275
|
-
}, {
|
|
276
|
-
F: __dxlog_file2,
|
|
277
|
-
L: 47,
|
|
278
|
-
S: this,
|
|
279
|
-
C: (f, a) => f(...a)
|
|
280
|
-
});
|
|
281
|
-
const _ = fn?.version;
|
|
282
|
-
this.runAsyncFunction(ast, state, handler(false), {
|
|
283
|
-
ttl: FUNCTION_TTL
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
this.context.createSubscription(ast.procedureName, unsubscribe);
|
|
287
|
-
}
|
|
288
|
-
const path = (0, import_edge.getUserFunctionUrlInMetadata)((0, import_echo2.getMeta)(fn));
|
|
289
|
-
const result = await fetch(`${this.context.remoteFunctionUrl}${path}`, {
|
|
290
|
-
method: "POST",
|
|
291
|
-
headers: {
|
|
292
|
-
"Content-Type": "application/json"
|
|
293
|
-
},
|
|
294
|
-
body: JSON.stringify({
|
|
295
|
-
args: args.filter(import_util2.nonNullable)
|
|
296
|
-
})
|
|
297
|
-
});
|
|
298
|
-
return await result.text();
|
|
299
|
-
};
|
|
300
|
-
return this.runAsyncFunction(ast, state, handler(true), {
|
|
301
|
-
ttl: FUNCTION_TTL
|
|
302
|
-
});
|
|
303
|
-
}
|
|
189
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/ComputeGraph/graph.ts";
|
|
190
|
+
var createComputeGraph = (functionPlugins = [], space, options) => {
|
|
191
|
+
functionPlugins.forEach(({ plugin, translations }) => {
|
|
192
|
+
import_hyperformula.HyperFormula.registerFunctionPlugin(plugin, translations);
|
|
193
|
+
});
|
|
194
|
+
const hf = import_hyperformula.HyperFormula.buildEmpty({
|
|
195
|
+
licenseKey: "gpl-v3"
|
|
196
|
+
});
|
|
197
|
+
return new ComputeGraph(hf, space, options);
|
|
304
198
|
};
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
{
|
|
319
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
320
|
-
optionalArg: true
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
324
|
-
optionalArg: true
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
328
|
-
optionalArg: true
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
332
|
-
optionalArg: true
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
336
|
-
optionalArg: true
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
340
|
-
optionalArg: true
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
344
|
-
optionalArg: true
|
|
345
|
-
}
|
|
346
|
-
],
|
|
347
|
-
isVolatile: true
|
|
199
|
+
var ComputeGraph = class {
|
|
200
|
+
constructor(hf, _space, _options) {
|
|
201
|
+
this.hf = hf;
|
|
202
|
+
this._space = _space;
|
|
203
|
+
this._options = _options;
|
|
204
|
+
this.id = `graph-${import_keys.PublicKey.random().truncate()}`;
|
|
205
|
+
this.update = new import_async.Event();
|
|
206
|
+
this.context = new FunctionContext(this.hf, this._space, () => {
|
|
207
|
+
this.refresh();
|
|
208
|
+
}, this._options);
|
|
209
|
+
this.hf.updateConfig({
|
|
210
|
+
context: this.context
|
|
211
|
+
});
|
|
348
212
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
213
|
+
refresh() {
|
|
214
|
+
(0, import_log.log)("refresh", {
|
|
215
|
+
id: this.id
|
|
216
|
+
}, {
|
|
217
|
+
F: __dxlog_file2,
|
|
218
|
+
L: 59,
|
|
219
|
+
S: this,
|
|
220
|
+
C: (f, a) => f(...a)
|
|
221
|
+
});
|
|
222
|
+
this.update.emit();
|
|
356
223
|
}
|
|
357
224
|
};
|
|
358
225
|
var defaultFunctions = [
|
|
@@ -2727,273 +2594,666 @@ var defaultFunctions = [
|
|
|
2727
2594
|
section: "Text"
|
|
2728
2595
|
}
|
|
2729
2596
|
];
|
|
2730
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/
|
|
2731
|
-
var
|
|
2732
|
-
var
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2597
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/types.ts";
|
|
2598
|
+
var MAX_COLUMNS = 26 * 26;
|
|
2599
|
+
var posEquals = (a, b) => {
|
|
2600
|
+
return a?.column === b?.column && a?.row === b?.row;
|
|
2601
|
+
};
|
|
2602
|
+
var columnLetter = (column) => {
|
|
2603
|
+
(0, import_invariant2.invariant)(column < MAX_COLUMNS, `Invalid column: ${column}`, {
|
|
2604
|
+
F: __dxlog_file3,
|
|
2605
|
+
L: 17,
|
|
2606
|
+
S: void 0,
|
|
2607
|
+
A: [
|
|
2608
|
+
"column < MAX_COLUMNS",
|
|
2609
|
+
"`Invalid column: ${column}`"
|
|
2610
|
+
]
|
|
2611
|
+
});
|
|
2612
|
+
return (column >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(column / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + column % 26);
|
|
2613
|
+
};
|
|
2614
|
+
var addressToA1Notation = ({ column, row }) => {
|
|
2615
|
+
return `${columnLetter(column)}${row + 1}`;
|
|
2616
|
+
};
|
|
2617
|
+
var addressFromA1Notation = (ref) => {
|
|
2618
|
+
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
2619
|
+
(0, import_invariant2.invariant)(match, `Invalid notation: ${ref}`, {
|
|
2620
|
+
F: __dxlog_file3,
|
|
2621
|
+
L: 30,
|
|
2622
|
+
S: void 0,
|
|
2623
|
+
A: [
|
|
2624
|
+
"match",
|
|
2625
|
+
"`Invalid notation: ${ref}`"
|
|
2626
|
+
]
|
|
2627
|
+
});
|
|
2628
|
+
return {
|
|
2629
|
+
row: parseInt(match[2], 10) - 1,
|
|
2630
|
+
column: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
2740
2631
|
};
|
|
2741
2632
|
};
|
|
2742
|
-
var
|
|
2743
|
-
|
|
2633
|
+
var rangeToA1Notation = (range) => {
|
|
2634
|
+
return [
|
|
2635
|
+
range?.from && addressToA1Notation(range?.from),
|
|
2636
|
+
range?.to && addressToA1Notation(range?.to)
|
|
2637
|
+
].filter(Boolean).join(":");
|
|
2638
|
+
};
|
|
2639
|
+
var inRange = (range, cell) => {
|
|
2640
|
+
if (!range) {
|
|
2641
|
+
return false;
|
|
2642
|
+
}
|
|
2643
|
+
const { from, to } = range;
|
|
2644
|
+
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
2645
|
+
return true;
|
|
2646
|
+
}
|
|
2647
|
+
if (!from || !to) {
|
|
2648
|
+
return false;
|
|
2649
|
+
}
|
|
2650
|
+
const { column: c1, row: r1 } = from;
|
|
2651
|
+
const { column: c2, row: r2 } = to;
|
|
2652
|
+
const cMin = Math.min(c1, c2);
|
|
2653
|
+
const cMax = Math.max(c1, c2);
|
|
2654
|
+
const rMin = Math.min(r1, r2);
|
|
2655
|
+
const rMax = Math.max(r1, r2);
|
|
2656
|
+
const { column, row } = cell;
|
|
2657
|
+
return column >= cMin && column <= cMax && row >= rMin && row <= rMax;
|
|
2658
|
+
};
|
|
2659
|
+
var ApiError = class extends Error {
|
|
2660
|
+
};
|
|
2661
|
+
var ReadonlyException = class extends ApiError {
|
|
2662
|
+
};
|
|
2663
|
+
var RangeException = class extends ApiError {
|
|
2664
|
+
constructor(n) {
|
|
2744
2665
|
super();
|
|
2745
|
-
|
|
2666
|
+
}
|
|
2667
|
+
};
|
|
2668
|
+
var createIndex = (length = 8) => {
|
|
2669
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
2670
|
+
const charactersLength = characters.length;
|
|
2671
|
+
const randomBuffer = (0, import_crypto.randomBytes)(length);
|
|
2672
|
+
return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
|
|
2673
|
+
};
|
|
2674
|
+
var createIndices = (length) => Array.from({
|
|
2675
|
+
length
|
|
2676
|
+
}).map(() => createIndex());
|
|
2677
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/model.ts";
|
|
2678
|
+
var DEFAULT_ROWS = 100;
|
|
2679
|
+
var DEFAULT_COLUMNS = 26;
|
|
2680
|
+
var typeMap = {
|
|
2681
|
+
BOOLEAN: import_chunk_DSYKOI4E.ValueTypeEnum.Boolean,
|
|
2682
|
+
NUMBER_RAW: import_chunk_DSYKOI4E.ValueTypeEnum.Number,
|
|
2683
|
+
NUMBER_PERCENT: import_chunk_DSYKOI4E.ValueTypeEnum.Percent,
|
|
2684
|
+
NUMBER_CURRENCY: import_chunk_DSYKOI4E.ValueTypeEnum.Currency,
|
|
2685
|
+
NUMBER_DATETIME: import_chunk_DSYKOI4E.ValueTypeEnum.DateTime,
|
|
2686
|
+
NUMBER_DATE: import_chunk_DSYKOI4E.ValueTypeEnum.Date,
|
|
2687
|
+
NUMBER_TIME: import_chunk_DSYKOI4E.ValueTypeEnum.Time
|
|
2688
|
+
};
|
|
2689
|
+
var defaultOptions = {
|
|
2690
|
+
rows: 50,
|
|
2691
|
+
columns: 26,
|
|
2692
|
+
mapFormulaBindingFromId: () => (formula) => formula,
|
|
2693
|
+
mapFormulaBindingToId: () => (formula) => formula
|
|
2694
|
+
};
|
|
2695
|
+
var getTopLeft = (range) => {
|
|
2696
|
+
const to = range.to ?? range.from;
|
|
2697
|
+
return {
|
|
2698
|
+
row: Math.min(range.from.row, to.row),
|
|
2699
|
+
column: Math.min(range.from.column, to.column)
|
|
2700
|
+
};
|
|
2701
|
+
};
|
|
2702
|
+
var toSimpleCellAddress = (sheet, cell) => ({
|
|
2703
|
+
sheet,
|
|
2704
|
+
row: cell.row,
|
|
2705
|
+
col: cell.column
|
|
2706
|
+
});
|
|
2707
|
+
var toModelRange = (sheet, range) => ({
|
|
2708
|
+
start: toSimpleCellAddress(sheet, range.from),
|
|
2709
|
+
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
2710
|
+
});
|
|
2711
|
+
var SheetModel = class {
|
|
2712
|
+
constructor(_graph, _sheet, _space, options = {}) {
|
|
2713
|
+
this._graph = _graph;
|
|
2714
|
+
this._sheet = _sheet;
|
|
2746
2715
|
this._space = _space;
|
|
2747
|
-
this.
|
|
2748
|
-
this.
|
|
2749
|
-
this.
|
|
2750
|
-
this.
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
const { sheet } = change;
|
|
2760
|
-
const node = this._nodes.get(sheet);
|
|
2761
|
-
if (node) {
|
|
2762
|
-
node.update.emit({
|
|
2763
|
-
type: "valuesUpdated",
|
|
2764
|
-
change
|
|
2765
|
-
});
|
|
2766
|
-
}
|
|
2767
|
-
}
|
|
2768
|
-
}
|
|
2716
|
+
this.id = `model-${import_keys2.PublicKey.random().truncate()}`;
|
|
2717
|
+
this._ctx = void 0;
|
|
2718
|
+
this._functions = [];
|
|
2719
|
+
this.update = new import_async3.Event();
|
|
2720
|
+
const name = this._sheet.id;
|
|
2721
|
+
if (!this._graph.hf.doesSheetExist(name)) {
|
|
2722
|
+
this._graph.hf.addSheet(name);
|
|
2723
|
+
}
|
|
2724
|
+
this._sheetId = this._graph.hf.getSheetId(name);
|
|
2725
|
+
this._options = {
|
|
2726
|
+
...defaultOptions,
|
|
2727
|
+
...options
|
|
2769
2728
|
};
|
|
2770
|
-
this.
|
|
2771
|
-
|
|
2729
|
+
this.reset();
|
|
2730
|
+
}
|
|
2731
|
+
get graph() {
|
|
2732
|
+
return this._graph;
|
|
2733
|
+
}
|
|
2734
|
+
get sheet() {
|
|
2735
|
+
return this._sheet;
|
|
2772
2736
|
}
|
|
2773
|
-
get
|
|
2774
|
-
return this.
|
|
2737
|
+
get readonly() {
|
|
2738
|
+
return this._options.readonly;
|
|
2775
2739
|
}
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2740
|
+
get bounds() {
|
|
2741
|
+
return {
|
|
2742
|
+
rows: this._sheet.rows.length,
|
|
2743
|
+
columns: this._sheet.columns.length
|
|
2744
|
+
};
|
|
2745
|
+
}
|
|
2746
|
+
get functions() {
|
|
2747
|
+
const hfFunctions = this._graph.hf.getRegisteredFunctionNames().map((name) => defaultFunctions.find((fn) => fn.name === name) ?? {
|
|
2748
|
+
name
|
|
2749
|
+
});
|
|
2750
|
+
const echoFunctions = this._functions.map((fn) => ({
|
|
2751
|
+
name: fn.binding
|
|
2752
|
+
}));
|
|
2780
2753
|
return [
|
|
2781
|
-
...
|
|
2782
|
-
|
|
2783
|
-
}) : [],
|
|
2784
|
-
...echo ? this._remoteFunctions.map((fn) => ({
|
|
2785
|
-
name: fn.binding
|
|
2786
|
-
})) : []
|
|
2754
|
+
...hfFunctions,
|
|
2755
|
+
...echoFunctions
|
|
2787
2756
|
];
|
|
2788
2757
|
}
|
|
2758
|
+
get initialized() {
|
|
2759
|
+
return !!this._ctx;
|
|
2760
|
+
}
|
|
2789
2761
|
/**
|
|
2790
|
-
*
|
|
2762
|
+
* Initialize sheet and engine.
|
|
2791
2763
|
*/
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2764
|
+
async initialize() {
|
|
2765
|
+
(0, import_log3.log)("initialize", {
|
|
2766
|
+
id: this.id
|
|
2767
|
+
}, {
|
|
2768
|
+
F: __dxlog_file4,
|
|
2769
|
+
L: 142,
|
|
2770
|
+
S: this,
|
|
2771
|
+
C: (f, a) => f(...a)
|
|
2772
|
+
});
|
|
2773
|
+
(0, import_invariant.invariant)(!this.initialized, "Already initialized.", {
|
|
2774
|
+
F: __dxlog_file4,
|
|
2775
|
+
L: 143,
|
|
2801
2776
|
S: this,
|
|
2802
2777
|
A: [
|
|
2803
|
-
"
|
|
2804
|
-
""
|
|
2778
|
+
"!this.initialized",
|
|
2779
|
+
"'Already initialized.'"
|
|
2805
2780
|
]
|
|
2806
2781
|
});
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2782
|
+
this._ctx = new import_context.Context(void 0, {
|
|
2783
|
+
F: __dxlog_file4,
|
|
2784
|
+
L: 144
|
|
2785
|
+
});
|
|
2786
|
+
if (!this._sheet.rows.length) {
|
|
2787
|
+
this._insertIndices(this._sheet.rows, 0, this._options.rows, DEFAULT_ROWS);
|
|
2788
|
+
}
|
|
2789
|
+
if (!this._sheet.columns.length) {
|
|
2790
|
+
this._insertIndices(this._sheet.columns, 0, this._options.columns, DEFAULT_COLUMNS);
|
|
2791
|
+
}
|
|
2792
|
+
this.reset();
|
|
2793
|
+
const unsubscribe = this._graph.update.on(() => this.update.emit());
|
|
2794
|
+
this._ctx.onDispose(unsubscribe);
|
|
2795
|
+
if (this._space) {
|
|
2796
|
+
const { Filter } = await import("@dxos/client/echo");
|
|
2797
|
+
const { FunctionType } = await import("@dxos/plugin-script/types");
|
|
2798
|
+
const query = this._space?.db.query(Filter.schema(FunctionType));
|
|
2799
|
+
const unsubscribe2 = query.subscribe(({ objects }) => {
|
|
2800
|
+
this._functions = objects.filter((fn) => fn.binding);
|
|
2801
|
+
this.update.emit();
|
|
2816
2802
|
});
|
|
2817
|
-
this.
|
|
2803
|
+
this._ctx.onDispose(unsubscribe2);
|
|
2818
2804
|
}
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2805
|
+
return this;
|
|
2806
|
+
}
|
|
2807
|
+
async destroy() {
|
|
2808
|
+
(0, import_log3.log)("destroy", {
|
|
2809
|
+
id: this.id
|
|
2810
|
+
}, {
|
|
2811
|
+
F: __dxlog_file4,
|
|
2812
|
+
L: 174,
|
|
2823
2813
|
S: this,
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2814
|
+
C: (f, a) => f(...a)
|
|
2815
|
+
});
|
|
2816
|
+
if (this._ctx) {
|
|
2817
|
+
await this._ctx.dispose();
|
|
2818
|
+
this._ctx = void 0;
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
/**
|
|
2822
|
+
* Update engine.
|
|
2823
|
+
* NOTE: This resets the undo history.
|
|
2824
|
+
* @deprecated
|
|
2825
|
+
*/
|
|
2826
|
+
reset() {
|
|
2827
|
+
this._graph.hf.clearSheet(this._sheetId);
|
|
2828
|
+
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
2829
|
+
const { column, row } = this.addressFromIndex(key);
|
|
2830
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
2831
|
+
value = this.mapFormulaBindingToFormula(this.mapFormulaBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
2832
|
+
}
|
|
2833
|
+
this._graph.hf.setCellContents({
|
|
2834
|
+
sheet: this._sheetId,
|
|
2835
|
+
row,
|
|
2836
|
+
col: column
|
|
2837
|
+
}, value);
|
|
2838
|
+
});
|
|
2839
|
+
}
|
|
2840
|
+
/**
|
|
2841
|
+
* Recalculate formulas.
|
|
2842
|
+
* NOTE: This resets the undo history.
|
|
2843
|
+
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
2844
|
+
* @deprecated
|
|
2845
|
+
*/
|
|
2846
|
+
// TODO(burdon): Remove.
|
|
2847
|
+
recalculate() {
|
|
2848
|
+
this._graph.hf.rebuildAndRecalculate();
|
|
2849
|
+
}
|
|
2850
|
+
insertRows(i, n = 1) {
|
|
2851
|
+
this._insertIndices(this._sheet.rows, i, n, DEFAULT_ROWS);
|
|
2852
|
+
this.reset();
|
|
2853
|
+
}
|
|
2854
|
+
insertColumns(i, n = 1) {
|
|
2855
|
+
this._insertIndices(this._sheet.columns, i, n, DEFAULT_COLUMNS);
|
|
2856
|
+
this.reset();
|
|
2857
|
+
}
|
|
2858
|
+
//
|
|
2859
|
+
// Undoable actions.
|
|
2860
|
+
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
2861
|
+
//
|
|
2862
|
+
/**
|
|
2863
|
+
* Clear range of values.
|
|
2864
|
+
*/
|
|
2865
|
+
clear(range) {
|
|
2866
|
+
const topLeft = getTopLeft(range);
|
|
2867
|
+
const values = this._iterRange(range, () => null);
|
|
2868
|
+
this._graph.hf.setCellContents(toSimpleCellAddress(this._sheetId, topLeft), values);
|
|
2869
|
+
this._iterRange(range, (cell) => {
|
|
2870
|
+
const idx = this.addressToIndex(cell);
|
|
2871
|
+
delete this._sheet.cells[idx];
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
cut(range) {
|
|
2875
|
+
this._graph.hf.cut(toModelRange(this._sheetId, range));
|
|
2876
|
+
this._iterRange(range, (cell) => {
|
|
2877
|
+
const idx = this.addressToIndex(cell);
|
|
2878
|
+
delete this._sheet.cells[idx];
|
|
2879
|
+
});
|
|
2880
|
+
}
|
|
2881
|
+
copy(range) {
|
|
2882
|
+
this._graph.hf.copy(toModelRange(this._sheetId, range));
|
|
2883
|
+
}
|
|
2884
|
+
paste(cell) {
|
|
2885
|
+
if (!this._graph.hf.isClipboardEmpty()) {
|
|
2886
|
+
const changes = this._graph.hf.paste(toSimpleCellAddress(this._sheetId, cell));
|
|
2887
|
+
for (const change of changes) {
|
|
2888
|
+
if (change instanceof import_hyperformula3.ExportedCellChange) {
|
|
2889
|
+
const { address, newValue } = change;
|
|
2890
|
+
const idx = this.addressToIndex({
|
|
2891
|
+
row: address.row,
|
|
2892
|
+
column: address.col
|
|
2893
|
+
});
|
|
2894
|
+
this._sheet.cells[idx] = {
|
|
2895
|
+
value: newValue
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
// TODO(burdon): Display undo/redo state.
|
|
2902
|
+
undo() {
|
|
2903
|
+
if (this._graph.hf.isThereSomethingToUndo()) {
|
|
2904
|
+
this._graph.hf.undo();
|
|
2905
|
+
this.update.emit();
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
redo() {
|
|
2909
|
+
if (this._graph.hf.isThereSomethingToRedo()) {
|
|
2910
|
+
this._graph.hf.redo();
|
|
2911
|
+
this.update.emit();
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Get value from sheet.
|
|
2916
|
+
*/
|
|
2917
|
+
getCellValue(cell) {
|
|
2918
|
+
const idx = this.addressToIndex(cell);
|
|
2919
|
+
return this._sheet.cells[idx]?.value ?? null;
|
|
2920
|
+
}
|
|
2921
|
+
/**
|
|
2922
|
+
* Get value as a string for editing.
|
|
2923
|
+
*/
|
|
2924
|
+
getCellText(cell) {
|
|
2925
|
+
const value = this.getCellValue(cell);
|
|
2926
|
+
if (value == null) {
|
|
2927
|
+
return void 0;
|
|
2928
|
+
}
|
|
2929
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
2930
|
+
return this.mapFormulaBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
2931
|
+
} else {
|
|
2932
|
+
return String(value);
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
/**
|
|
2936
|
+
* Get array of raw values from sheet.
|
|
2937
|
+
*/
|
|
2938
|
+
getCellValues(range) {
|
|
2939
|
+
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
2940
|
+
}
|
|
2941
|
+
/**
|
|
2942
|
+
* Gets the regular or computed value from the engine.
|
|
2943
|
+
*/
|
|
2944
|
+
getValue(cell) {
|
|
2945
|
+
const value = this._graph.hf.getCellValue(toSimpleCellAddress(this._sheetId, cell));
|
|
2946
|
+
if (value instanceof import_hyperformula3.DetailedCellError) {
|
|
2947
|
+
return value.toString();
|
|
2948
|
+
}
|
|
2949
|
+
return value;
|
|
2950
|
+
}
|
|
2951
|
+
/**
|
|
2952
|
+
* Get value type.
|
|
2953
|
+
*/
|
|
2954
|
+
getValueType(cell) {
|
|
2955
|
+
const addr = toSimpleCellAddress(this._sheetId, cell);
|
|
2956
|
+
const type = this._graph.hf.getCellValueDetailedType(addr);
|
|
2957
|
+
return typeMap[type];
|
|
2958
|
+
}
|
|
2959
|
+
/**
|
|
2960
|
+
* Sets the value, updating the sheet and engine.
|
|
2961
|
+
*/
|
|
2962
|
+
setValue(cell, value) {
|
|
2963
|
+
if (this._options.readonly) {
|
|
2964
|
+
throw new ReadonlyException();
|
|
2965
|
+
}
|
|
2966
|
+
let refresh = false;
|
|
2967
|
+
if (cell.row >= this._sheet.rows.length) {
|
|
2968
|
+
this._insertIndices(this._sheet.rows, cell.row, 1, DEFAULT_ROWS);
|
|
2969
|
+
refresh = true;
|
|
2970
|
+
}
|
|
2971
|
+
if (cell.column >= this._sheet.columns.length) {
|
|
2972
|
+
this._insertIndices(this._sheet.columns, cell.column, 1, DEFAULT_COLUMNS);
|
|
2973
|
+
refresh = true;
|
|
2974
|
+
}
|
|
2975
|
+
if (refresh) {
|
|
2976
|
+
this.reset();
|
|
2977
|
+
}
|
|
2978
|
+
this._graph.hf.setCellContents({
|
|
2979
|
+
sheet: this._sheetId,
|
|
2980
|
+
row: cell.row,
|
|
2981
|
+
col: cell.column
|
|
2982
|
+
}, [
|
|
2983
|
+
[
|
|
2984
|
+
typeof value === "string" && value.charAt(0) === "=" ? this.mapFormulaBindingToFormula(value) : value
|
|
2827
2985
|
]
|
|
2986
|
+
]);
|
|
2987
|
+
const idx = this.addressToIndex(cell);
|
|
2988
|
+
if (value === void 0 || value === null) {
|
|
2989
|
+
delete this._sheet.cells[idx];
|
|
2990
|
+
} else {
|
|
2991
|
+
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
2992
|
+
value = this.mapFormulaBindingToId(this.mapFormulaRefsToIndices(value));
|
|
2993
|
+
}
|
|
2994
|
+
this._sheet.cells[idx] = {
|
|
2995
|
+
value
|
|
2996
|
+
};
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
/**
|
|
3000
|
+
* Sets values from a simple map.
|
|
3001
|
+
*/
|
|
3002
|
+
setValues(values) {
|
|
3003
|
+
Object.entries(values).forEach(([key, { value }]) => {
|
|
3004
|
+
this.setValue(addressFromA1Notation(key), value);
|
|
2828
3005
|
});
|
|
2829
|
-
const node = new ComputeNode(this, sheetId);
|
|
2830
|
-
this._nodes.set(sheetId, node);
|
|
2831
|
-
return node;
|
|
2832
3006
|
}
|
|
2833
3007
|
/**
|
|
2834
|
-
*
|
|
2835
|
-
* E.g., "HELLO(...args)" => "EDGE("HELLO", ...args)".
|
|
3008
|
+
* Iterate range.
|
|
2836
3009
|
*/
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
3010
|
+
_iterRange(range, cb) {
|
|
3011
|
+
const to = range.to ?? range.from;
|
|
3012
|
+
const rowRange = [
|
|
3013
|
+
Math.min(range.from.row, to.row),
|
|
3014
|
+
Math.max(range.from.row, to.row)
|
|
3015
|
+
];
|
|
3016
|
+
const columnRange = [
|
|
3017
|
+
Math.min(range.from.column, to.column),
|
|
3018
|
+
Math.max(range.from.column, to.column)
|
|
3019
|
+
];
|
|
3020
|
+
const rows = [];
|
|
3021
|
+
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
3022
|
+
const rowCells = [];
|
|
3023
|
+
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
3024
|
+
const value = cb({
|
|
3025
|
+
row,
|
|
3026
|
+
column
|
|
3027
|
+
});
|
|
3028
|
+
if (value !== void 0) {
|
|
3029
|
+
rowCells.push(value);
|
|
2852
3030
|
}
|
|
2853
3031
|
}
|
|
2854
|
-
|
|
2855
|
-
}
|
|
2856
|
-
|
|
3032
|
+
rows.push(rowCells);
|
|
3033
|
+
}
|
|
3034
|
+
return rows;
|
|
3035
|
+
}
|
|
3036
|
+
/**
|
|
3037
|
+
*
|
|
3038
|
+
*/
|
|
3039
|
+
// TODO(burdon): Insert indices into sheet.
|
|
3040
|
+
_insertIndices(indices, i, n, max) {
|
|
3041
|
+
if (i + n > max) {
|
|
3042
|
+
throw new RangeException(i + n);
|
|
3043
|
+
}
|
|
3044
|
+
const idx = createIndices(n);
|
|
3045
|
+
indices.splice(i, 0, ...idx);
|
|
3046
|
+
}
|
|
3047
|
+
// TODO(burdon): Delete index.
|
|
3048
|
+
_deleteIndices(indices, i, n) {
|
|
3049
|
+
throw new Error("Not implemented");
|
|
3050
|
+
}
|
|
3051
|
+
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
3052
|
+
_moveIndices(indices, i, j, n) {
|
|
3053
|
+
throw new Error("Not implemented");
|
|
3054
|
+
}
|
|
3055
|
+
//
|
|
3056
|
+
// Indices.
|
|
3057
|
+
//
|
|
3058
|
+
/**
|
|
3059
|
+
* E.g., "A1" => "x1@y1".
|
|
3060
|
+
*/
|
|
3061
|
+
addressToIndex(cell) {
|
|
3062
|
+
return `${this._sheet.columns[cell.column]}@${this._sheet.rows[cell.row]}`;
|
|
3063
|
+
}
|
|
3064
|
+
/**
|
|
3065
|
+
* E.g., "x1@y1" => "A1".
|
|
3066
|
+
*/
|
|
3067
|
+
addressFromIndex(idx) {
|
|
3068
|
+
const [column, row] = idx.split("@");
|
|
3069
|
+
return {
|
|
3070
|
+
column: this._sheet.columns.indexOf(column),
|
|
3071
|
+
row: this._sheet.rows.indexOf(row)
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
/**
|
|
3075
|
+
* E.g., "A1:B2" => "x1@y1:x2@y2".
|
|
3076
|
+
*/
|
|
3077
|
+
rangeToIndex(range) {
|
|
3078
|
+
return [
|
|
3079
|
+
range.from,
|
|
3080
|
+
range.to ?? range.from
|
|
3081
|
+
].map((cell) => this.addressToIndex(cell)).join(":");
|
|
3082
|
+
}
|
|
3083
|
+
/**
|
|
3084
|
+
* E.g., "x1@y1:x2@y2" => "A1:B2".
|
|
3085
|
+
*/
|
|
3086
|
+
rangeFromIndex(idx) {
|
|
3087
|
+
const [from, to] = idx.split(":").map((idx2) => this.addressFromIndex(idx2));
|
|
3088
|
+
return {
|
|
3089
|
+
from,
|
|
3090
|
+
to
|
|
3091
|
+
};
|
|
3092
|
+
}
|
|
3093
|
+
/**
|
|
3094
|
+
* E.g., "HELLO()" => "EDGE("HELLO")".
|
|
3095
|
+
*/
|
|
3096
|
+
mapFormulaBindingToFormula(formula) {
|
|
3097
|
+
return formula.replace(/([a-zA-Z0-9]+)\((.*)\)/g, (match, binding, args) => {
|
|
3098
|
+
const fn = this._functions.find((fn2) => fn2.binding === binding);
|
|
2857
3099
|
if (!fn) {
|
|
2858
3100
|
return match;
|
|
2859
3101
|
}
|
|
2860
3102
|
if (args.trim() === "") {
|
|
2861
|
-
return
|
|
2862
|
-
} else {
|
|
2863
|
-
return `${EDGE_FUNCTION_NAME}("${binding}", ${args})`;
|
|
3103
|
+
return `EDGE("${binding}")`;
|
|
2864
3104
|
}
|
|
3105
|
+
return `EDGE("${binding}", ${args})`;
|
|
2865
3106
|
});
|
|
2866
3107
|
}
|
|
2867
3108
|
/**
|
|
2868
|
-
*
|
|
2869
|
-
* E.g., HELLO() => spaceId:objectId()
|
|
3109
|
+
* E.g., "EDGE("HELLO")" => "HELLO()".
|
|
2870
3110
|
*/
|
|
2871
|
-
|
|
2872
|
-
return formula.replace(/(
|
|
2873
|
-
if (
|
|
2874
|
-
return
|
|
2875
|
-
}
|
|
2876
|
-
const fn = this._remoteFunctions.find((fn2) => fn2.binding === binding);
|
|
2877
|
-
if (fn) {
|
|
2878
|
-
const id = (0, import_echo.fullyQualifiedId)(fn);
|
|
2879
|
-
return `${id}(${args})`;
|
|
2880
|
-
} else {
|
|
2881
|
-
return match;
|
|
3111
|
+
mapFormulaBindingFromFormula(formula) {
|
|
3112
|
+
return formula.replace(/EDGE\("([a-zA-Z0-9]+)"(.*)\)/, (_match, binding, args) => {
|
|
3113
|
+
if (args.trim() === "") {
|
|
3114
|
+
return `${binding}()`;
|
|
2882
3115
|
}
|
|
3116
|
+
return `${binding}(${args.slice(2)})`;
|
|
2883
3117
|
});
|
|
2884
3118
|
}
|
|
2885
3119
|
/**
|
|
2886
|
-
* Map from fully qualified ECHO ID
|
|
2887
|
-
* E.g., spaceId:objectId() => HELLO()
|
|
3120
|
+
* Map from binding to fully qualified ECHO ID.
|
|
2888
3121
|
*/
|
|
2889
|
-
|
|
2890
|
-
return
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
3122
|
+
mapFormulaBindingToId(formula) {
|
|
3123
|
+
return this._options.mapFormulaBindingToId(this._functions)(formula);
|
|
3124
|
+
}
|
|
3125
|
+
/**
|
|
3126
|
+
* Map from fully qualified ECHO ID to binding.
|
|
3127
|
+
*/
|
|
3128
|
+
mapFormulaBindingFromId(formula) {
|
|
3129
|
+
return this._options.mapFormulaBindingFromId(this._functions)(formula);
|
|
3130
|
+
}
|
|
3131
|
+
/**
|
|
3132
|
+
* Map from A1 notation to indices.
|
|
3133
|
+
*/
|
|
3134
|
+
mapFormulaRefsToIndices(formula) {
|
|
3135
|
+
(0, import_invariant.invariant)(formula.charAt(0) === "=", void 0, {
|
|
3136
|
+
F: __dxlog_file4,
|
|
3137
|
+
L: 509,
|
|
3138
|
+
S: this,
|
|
3139
|
+
A: [
|
|
3140
|
+
"formula.charAt(0) === '='",
|
|
3141
|
+
""
|
|
3142
|
+
]
|
|
3143
|
+
});
|
|
3144
|
+
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
3145
|
+
return this.addressToIndex(addressFromA1Notation(match));
|
|
2901
3146
|
});
|
|
2902
3147
|
}
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
3148
|
+
/**
|
|
3149
|
+
* Map from indices to A1 notation.
|
|
3150
|
+
*/
|
|
3151
|
+
mapFormulaIndicesToRefs(formula) {
|
|
3152
|
+
(0, import_invariant.invariant)(formula.charAt(0) === "=", void 0, {
|
|
3153
|
+
F: __dxlog_file4,
|
|
3154
|
+
L: 519,
|
|
3155
|
+
S: this,
|
|
3156
|
+
A: [
|
|
3157
|
+
"formula.charAt(0) === '='",
|
|
3158
|
+
""
|
|
3159
|
+
]
|
|
3160
|
+
});
|
|
3161
|
+
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
3162
|
+
return addressToA1Notation(this.addressFromIndex(idx));
|
|
3163
|
+
});
|
|
2914
3164
|
}
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
3165
|
+
//
|
|
3166
|
+
// Values
|
|
3167
|
+
//
|
|
3168
|
+
/**
|
|
3169
|
+
* https://hyperformula.handsontable.com/guide/date-and-time-handling.html#example
|
|
3170
|
+
* https://hyperformula.handsontable.com/api/interfaces/configparams.html#nulldate
|
|
3171
|
+
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
3172
|
+
*/
|
|
3173
|
+
toLocalDate(num) {
|
|
3174
|
+
const { year, month, day, hours, minutes, seconds } = this.toDateTime(num);
|
|
3175
|
+
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
3176
|
+
}
|
|
3177
|
+
toDateTime(num) {
|
|
3178
|
+
return this._graph.hf.numberToDateTime(num);
|
|
3179
|
+
}
|
|
3180
|
+
toDate(num) {
|
|
3181
|
+
return this._graph.hf.numberToDate(num);
|
|
3182
|
+
}
|
|
3183
|
+
toTime(num) {
|
|
3184
|
+
return this._graph.hf.numberToTime(num);
|
|
2919
3185
|
}
|
|
2920
3186
|
};
|
|
2921
|
-
var
|
|
2922
|
-
|
|
2923
|
-
licenseKey: "gpl-v3"
|
|
3187
|
+
var parseNumberString = (str) => {
|
|
3188
|
+
return parseFloat(str.replace(/[^\d.]/g, ""));
|
|
2924
3189
|
};
|
|
2925
|
-
var
|
|
2926
|
-
{
|
|
2927
|
-
|
|
2928
|
-
|
|
3190
|
+
var CustomPlugin = class extends FunctionPluginAsync {
|
|
3191
|
+
test(ast, state) {
|
|
3192
|
+
const handler = async () => {
|
|
3193
|
+
return Math.random();
|
|
3194
|
+
};
|
|
3195
|
+
return this.runAsyncFunction(ast, state, handler);
|
|
2929
3196
|
}
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
3197
|
+
crypto(ast, state) {
|
|
3198
|
+
const handler = async (_currency) => {
|
|
3199
|
+
const currency = (_currency || "USD").toUpperCase();
|
|
3200
|
+
const result = await fetch(`https://api.coindesk.com/v1/bpi/currentprice/${currency}.json`);
|
|
3201
|
+
const data = await result.json();
|
|
3202
|
+
const rate = (0, import_util.getDeep)(data, [
|
|
3203
|
+
"bpi",
|
|
3204
|
+
currency,
|
|
3205
|
+
"rate"
|
|
3206
|
+
]);
|
|
3207
|
+
if (!rate) {
|
|
3208
|
+
return NaN;
|
|
3209
|
+
}
|
|
3210
|
+
return parseNumberString(rate);
|
|
3211
|
+
};
|
|
3212
|
+
return this.runAsyncFunction(ast, state, handler, {
|
|
3213
|
+
ttl: 1e4
|
|
2940
3214
|
});
|
|
2941
3215
|
}
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
}
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
return graph;
|
|
3216
|
+
};
|
|
3217
|
+
CustomPlugin.implementedFunctions = {
|
|
3218
|
+
TEST: {
|
|
3219
|
+
method: "test",
|
|
3220
|
+
parameters: [],
|
|
3221
|
+
isVolatile: true
|
|
3222
|
+
},
|
|
3223
|
+
CRYPTO: {
|
|
3224
|
+
method: "crypto",
|
|
3225
|
+
parameters: [
|
|
3226
|
+
{
|
|
3227
|
+
argumentType: import_hyperformula4.FunctionArgumentType.STRING,
|
|
3228
|
+
optionalArg: true
|
|
3229
|
+
}
|
|
3230
|
+
],
|
|
3231
|
+
isVolatile: true
|
|
2959
3232
|
}
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
});
|
|
2970
|
-
const hf = import_hyperformula5.HyperFormula.buildEmpty(this._options);
|
|
2971
|
-
const graph = new ComputeGraph(hf, space, this._options);
|
|
2972
|
-
this._graphs.set(space.id, graph);
|
|
2973
|
-
return graph;
|
|
2974
|
-
}
|
|
2975
|
-
async _close() {
|
|
2976
|
-
for (const graph of this._graphs.values()) {
|
|
2977
|
-
await graph.close();
|
|
2978
|
-
}
|
|
2979
|
-
this._graphs.clear();
|
|
3233
|
+
};
|
|
3234
|
+
var CustomPluginTranslations = {
|
|
3235
|
+
enGB: {
|
|
3236
|
+
TEST: "TEST",
|
|
3237
|
+
CRYPTO: "CRYPTO"
|
|
3238
|
+
},
|
|
3239
|
+
enUS: {
|
|
3240
|
+
TEST: "TEST",
|
|
3241
|
+
CRYPTO: "CRYPTO"
|
|
2980
3242
|
}
|
|
2981
3243
|
};
|
|
2982
3244
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2983
3245
|
0 && (module.exports = {
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
createSheetName,
|
|
2993
|
-
defaultFunctionContextOptions,
|
|
3246
|
+
CustomPlugin,
|
|
3247
|
+
CustomPluginTranslations,
|
|
3248
|
+
FunctionPluginAsync,
|
|
3249
|
+
SheetModel,
|
|
3250
|
+
addressFromA1Notation,
|
|
3251
|
+
addressToA1Notation,
|
|
3252
|
+
columnLetter,
|
|
3253
|
+
createComputeGraph,
|
|
2994
3254
|
defaultFunctions,
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
3255
|
+
inRange,
|
|
3256
|
+
posEquals,
|
|
3257
|
+
rangeToA1Notation
|
|
2998
3258
|
});
|
|
2999
|
-
//# sourceMappingURL=chunk-
|
|
3259
|
+
//# sourceMappingURL=chunk-5KKJ4NPP.cjs.map
|