@dxos/plugin-sheet 0.6.12-main.5cc132e → 0.6.12-main.78ddbdf
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-V4GCCZTX.mjs +261 -0
- package/dist/lib/browser/SheetContainer-V4GCCZTX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GNNVBNCX.mjs → chunk-6ZMQVB4Z.mjs} +358 -678
- package/dist/lib/browser/chunk-6ZMQVB4Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JRL5LGCE.mjs → chunk-QILRZNE5.mjs} +2 -5
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +7 -0
- package/dist/lib/{node-esm/chunk-WUPTZUTX.mjs → browser/chunk-T3NJFTD4.mjs} +4 -14
- package/dist/lib/browser/chunk-T3NJFTD4.mjs.map +7 -0
- package/dist/lib/browser/{SheetContainer-Y7ZMFBAP.mjs → chunk-U2JHW3L6.mjs} +819 -498
- package/dist/lib/browser/chunk-U2JHW3L6.mjs.map +7 -0
- package/dist/lib/browser/graph-T27BOBOV.mjs +21 -0
- package/dist/lib/browser/graph-T27BOBOV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +58 -55
- 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/types.mjs +4 -6
- package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs +279 -0
- package/dist/lib/node/SheetContainer-3ZY7MPWJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-BJ6ZD7MN.cjs → chunk-BNARJ5GM.cjs} +5 -18
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +7 -0
- package/dist/lib/node/{chunk-ZRQZFV5T.cjs → chunk-DD6FIXWC.cjs} +359 -679
- package/dist/lib/node/chunk-DD6FIXWC.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-KEOKUKAQ.cjs → chunk-OTTD7FBK.cjs} +875 -551
- package/dist/lib/node/chunk-OTTD7FBK.cjs.map +7 -0
- package/dist/lib/node/{chunk-VJU3NPUJ.cjs → chunk-Q3HBHPRL.cjs} +8 -19
- package/dist/lib/node/chunk-Q3HBHPRL.cjs.map +7 -0
- package/dist/lib/node/graph-SPKGX7W4.cjs +43 -0
- package/dist/lib/node/graph-SPKGX7W4.cjs.map +7 -0
- package/dist/lib/node/index.cjs +75 -64
- 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/types.cjs +10 -12
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs +262 -0
- package/dist/lib/node-esm/SheetContainer-PXSJX6XK.mjs.map +7 -0
- package/dist/lib/node-esm/{SheetContainer-Y7ZMFBAP.mjs → chunk-7HVSOTGA.mjs} +820 -498
- package/dist/lib/node-esm/chunk-7HVSOTGA.mjs.map +7 -0
- package/dist/lib/{browser/chunk-WUPTZUTX.mjs → node-esm/chunk-BMNA27EX.mjs} +5 -14
- package/dist/lib/node-esm/chunk-BMNA27EX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GNNVBNCX.mjs → chunk-D6KU5MI7.mjs} +359 -677
- package/dist/lib/node-esm/chunk-D6KU5MI7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JRL5LGCE.mjs → chunk-IU2L277A.mjs} +4 -5
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +7 -0
- package/dist/lib/node-esm/graph-U67IO4UC.mjs +22 -0
- package/dist/lib/node-esm/graph-U67IO4UC.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +59 -55
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +2 -1
- package/dist/lib/node-esm/types.mjs +5 -6
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +23 -3
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +10 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +7 -0
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +5 -6
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/grid.d.ts +2 -2
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/nav.d.ts +3 -3
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +4 -5
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/threads.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +1 -1
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +1 -1
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defs/index.d.ts +3 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/types.d.ts +8 -3
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/util.d.ts +8 -4
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +5 -0
- package/dist/types/src/extensions/compute.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts +26 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → graph}/async-function.d.ts +1 -1
- package/dist/types/src/graph/async-function.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.browser.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.browser.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.d.ts +81 -0
- package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts +10 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +19 -0
- package/dist/types/src/graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph/custom.d.ts → graph/custom-function.d.ts} +1 -1
- package/dist/types/src/graph/custom-function.d.ts.map +1 -0
- package/dist/types/src/graph/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → graph/function-defs.d.ts} +1 -1
- package/dist/types/src/graph/function-defs.d.ts.map +1 -0
- package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
- package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/graph/index.d.ts +4 -0
- package/dist/types/src/graph/index.d.ts.map +1 -0
- package/dist/types/src/graph/util.d.ts +2 -0
- package/dist/types/src/graph/util.d.ts.map +1 -0
- package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
- package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
- package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +1 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/formatting-model.d.ts +16 -0
- package/dist/types/src/model/formatting-model.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +2 -4
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +9 -48
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/sanity.test.d.ts +2 -0
- package/dist/types/src/sanity.test.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +9 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +12 -2
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +41 -38
- package/src/SheetPlugin.tsx +39 -59
- package/src/components/CellEditor/CellEditor.stories.tsx +4 -3
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +3 -3
- package/src/components/CellEditor/extension.ts +1 -3
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/GridSheet/GridSheet.stories.tsx +36 -0
- package/src/components/GridSheet/GridSheet.tsx +153 -0
- package/src/components/GridSheet/util.ts +108 -0
- package/src/components/Sheet/Sheet.stories.tsx +41 -82
- package/src/components/Sheet/Sheet.tsx +12 -10
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +10 -80
- package/src/components/Sheet/threads.tsx +10 -6
- package/src/components/SheetContainer.tsx +2 -2
- package/src/components/Toolbar/Toolbar.tsx +1 -2
- package/src/components/index.ts +1 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +7 -7
- package/src/{model → defs}/types.ts +23 -14
- package/src/{model → defs}/util.ts +49 -17
- package/src/extensions/compute.stories.tsx +151 -0
- package/src/extensions/compute.ts +98 -0
- package/src/extensions/index.ts +5 -0
- package/src/{components/ComputeGraph → graph}/async-function.ts +3 -1
- package/src/graph/compute-graph.browser.test.ts +104 -0
- package/src/graph/compute-graph.stories.tsx +92 -0
- package/src/graph/compute-graph.ts +290 -0
- package/src/graph/compute-node.ts +51 -0
- package/src/{components/ComputeGraph/custom.ts → graph/custom-function.ts} +2 -6
- package/src/{components/ComputeGraph → graph}/edge-function.ts +2 -1
- package/src/graph/hyperformula.test.ts +15 -0
- package/src/graph/index.ts +7 -0
- package/src/graph/util.ts +8 -0
- package/src/hooks/hooks.stories.tsx +50 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useComputeGraph.ts +20 -0
- package/src/hooks/useFormattingModel.ts +11 -0
- package/src/hooks/useSheetModel.ts +43 -0
- package/src/meta.tsx +1 -5
- package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +20 -13
- package/src/model/index.ts +2 -4
- package/src/model/{model.ts → sheet-model.ts} +67 -184
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +66 -0
- package/src/types.ts +14 -12
- package/dist/lib/browser/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
- package/dist/lib/browser/chunk-GNNVBNCX.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-PGKZPKUD.mjs +0 -175
- package/dist/lib/browser/chunk-PGKZPKUD.mjs.map +0 -7
- package/dist/lib/browser/chunk-VBF7YENS.mjs +0 -8
- package/dist/lib/browser/chunk-VBF7YENS.mjs.map +0 -7
- package/dist/lib/browser/chunk-WUPTZUTX.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-KEOKUKAQ.cjs.map +0 -7
- package/dist/lib/node/chunk-57PB2HPY.cjs +0 -40
- package/dist/lib/node/chunk-57PB2HPY.cjs.map +0 -7
- package/dist/lib/node/chunk-6LWBQAQZ.cjs +0 -202
- package/dist/lib/node/chunk-6LWBQAQZ.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-VJU3NPUJ.cjs.map +0 -7
- package/dist/lib/node/chunk-ZRQZFV5T.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GNNVBNCX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PGKZPKUD.mjs +0 -175
- package/dist/lib/node-esm/chunk-PGKZPKUD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VBF7YENS.mjs +0 -8
- package/dist/lib/node-esm/chunk-VBF7YENS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WUPTZUTX.mjs.map +0 -7
- package/dist/lib/node-esm/testing.mjs +0 -92
- package/dist/lib/node-esm/testing.mjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -49
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/model/model.browser.test.ts +0 -99
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/dist/types/src/{components/ComputeGraph → graph}/edge-function.d.ts +0 -0
- /package/src/{model/functions.ts → graph/function-defs.ts} +0 -0
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ValueTypeEnum
|
|
3
|
-
} from "./chunk-WUPTZUTX.mjs";
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
4
2
|
|
|
5
|
-
// packages/plugins/plugin-sheet/src/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
// packages/plugins/plugin-sheet/src/graph/compute-graph.ts
|
|
4
|
+
import { Event as Event2 } from "@dxos/async";
|
|
5
|
+
import { Filter as Filter2, fullyQualifiedId } from "@dxos/client/echo";
|
|
6
|
+
import { Resource as Resource2 } from "@dxos/context";
|
|
7
|
+
import { invariant } from "@dxos/invariant";
|
|
8
8
|
import { PublicKey } from "@dxos/keys";
|
|
9
|
-
import { log as
|
|
9
|
+
import { log as log3 } from "@dxos/log";
|
|
10
|
+
import { FunctionType as FunctionType2 } from "@dxos/plugin-script/types";
|
|
11
|
+
import { nonNullable as nonNullable2 } from "@dxos/util";
|
|
12
|
+
import { HyperFormula } from "#hyperformula";
|
|
10
13
|
|
|
11
|
-
// packages/plugins/plugin-sheet/src/
|
|
12
|
-
import { CellError, ErrorType, EmptyValue, FunctionPlugin } from "hyperformula";
|
|
14
|
+
// packages/plugins/plugin-sheet/src/graph/async-function.ts
|
|
13
15
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
14
16
|
import { debounce } from "@dxos/async";
|
|
15
17
|
import { log } from "@dxos/log";
|
|
16
|
-
|
|
18
|
+
import { CellError, ErrorType, EmptyValue, FunctionPlugin } from "#hyperformula";
|
|
19
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/async-function.ts";
|
|
17
20
|
var defaultFunctionContextOptions = {
|
|
18
21
|
defaultTtl: 5e3,
|
|
19
22
|
recalculationDelay: 200,
|
|
@@ -40,6 +43,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
40
43
|
onUpdate(this);
|
|
41
44
|
}, this._options.recalculationDelay);
|
|
42
45
|
}
|
|
46
|
+
// TODO(burdon): Remove?
|
|
43
47
|
get space() {
|
|
44
48
|
return this._space;
|
|
45
49
|
}
|
|
@@ -88,7 +92,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
88
92
|
value: value2
|
|
89
93
|
}, {
|
|
90
94
|
F: __dxlog_file,
|
|
91
|
-
L:
|
|
95
|
+
L: 138,
|
|
92
96
|
S: this,
|
|
93
97
|
C: (f, a) => f(...a)
|
|
94
98
|
});
|
|
@@ -99,7 +103,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
99
103
|
err
|
|
100
104
|
}, {
|
|
101
105
|
F: __dxlog_file,
|
|
102
|
-
L:
|
|
106
|
+
L: 142,
|
|
103
107
|
S: this,
|
|
104
108
|
C: (f, a) => f(...a)
|
|
105
109
|
});
|
|
@@ -119,7 +123,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
119
123
|
cache: value
|
|
120
124
|
}, {
|
|
121
125
|
F: __dxlog_file,
|
|
122
|
-
L:
|
|
126
|
+
L: 150,
|
|
123
127
|
S: this,
|
|
124
128
|
C: (f, a) => f(...a)
|
|
125
129
|
});
|
|
@@ -139,53 +143,173 @@ var FunctionPluginAsync = class extends FunctionPlugin {
|
|
|
139
143
|
}
|
|
140
144
|
};
|
|
141
145
|
|
|
142
|
-
// packages/plugins/plugin-sheet/src/
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return new ComputeGraph(hf, space, options);
|
|
152
|
-
};
|
|
153
|
-
var ComputeGraph = class {
|
|
154
|
-
constructor(hf, _space, _options) {
|
|
155
|
-
this.hf = hf;
|
|
156
|
-
this._space = _space;
|
|
157
|
-
this._options = _options;
|
|
158
|
-
this.id = `graph-${PublicKey.random().truncate()}`;
|
|
146
|
+
// packages/plugins/plugin-sheet/src/graph/compute-node.ts
|
|
147
|
+
import { Event } from "@dxos/async";
|
|
148
|
+
import { Resource } from "@dxos/context";
|
|
149
|
+
import { DetailedCellError } from "#hyperformula";
|
|
150
|
+
var ComputeNode = class extends Resource {
|
|
151
|
+
constructor(_graph, sheetId) {
|
|
152
|
+
super();
|
|
153
|
+
this._graph = _graph;
|
|
154
|
+
this.sheetId = sheetId;
|
|
159
155
|
this.update = new Event();
|
|
160
|
-
this.context = new FunctionContext(this.hf, this._space, () => {
|
|
161
|
-
this.refresh();
|
|
162
|
-
}, this._options);
|
|
163
|
-
this.hf.updateConfig({
|
|
164
|
-
context: this.context
|
|
165
|
-
});
|
|
166
156
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
157
|
+
// TODO(burdon): Remove?
|
|
158
|
+
get graph() {
|
|
159
|
+
return this._graph;
|
|
160
|
+
}
|
|
161
|
+
get hf() {
|
|
162
|
+
return this._graph.hf;
|
|
163
|
+
}
|
|
164
|
+
getValue(cell) {
|
|
165
|
+
const value = this._graph.hf.getCellValue({
|
|
166
|
+
sheet: this.sheetId,
|
|
167
|
+
row: cell.row,
|
|
168
|
+
col: cell.col
|
|
175
169
|
});
|
|
176
|
-
|
|
170
|
+
if (value instanceof DetailedCellError) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return value;
|
|
174
|
+
}
|
|
175
|
+
setValue(cell, value) {
|
|
176
|
+
const mappedValue = typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value;
|
|
177
|
+
this._graph.hf.setCellContents({
|
|
178
|
+
sheet: this.sheetId,
|
|
179
|
+
row: cell.row,
|
|
180
|
+
col: cell.col
|
|
181
|
+
}, [
|
|
182
|
+
[
|
|
183
|
+
mappedValue
|
|
184
|
+
]
|
|
185
|
+
]);
|
|
177
186
|
}
|
|
178
187
|
};
|
|
179
188
|
|
|
180
|
-
// packages/plugins/plugin-sheet/src/
|
|
181
|
-
import {
|
|
182
|
-
import {
|
|
183
|
-
import {
|
|
184
|
-
import {
|
|
185
|
-
import {
|
|
186
|
-
import {
|
|
189
|
+
// packages/plugins/plugin-sheet/src/graph/edge-function.ts
|
|
190
|
+
import { effect } from "@preact/signals-core";
|
|
191
|
+
import { Filter, getMeta } from "@dxos/client/echo";
|
|
192
|
+
import { log as log2 } from "@dxos/log";
|
|
193
|
+
import { getUserFunctionUrlInMetadata } from "@dxos/plugin-script/edge";
|
|
194
|
+
import { FunctionType } from "@dxos/plugin-script/types";
|
|
195
|
+
import { nonNullable } from "@dxos/util";
|
|
196
|
+
import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "#hyperformula";
|
|
197
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/edge-function.ts";
|
|
198
|
+
var EDGE_FUNCTION_TTL = 1e4;
|
|
199
|
+
var EdgeFunctionPlugin = class extends FunctionPluginAsync {
|
|
200
|
+
edge(ast, state) {
|
|
201
|
+
const handler = (subscribe = false) => async (binding, ...args) => {
|
|
202
|
+
const space = this.context.space;
|
|
203
|
+
if (!space) {
|
|
204
|
+
return new CellError2(ErrorType2.REF, "Missing space");
|
|
205
|
+
}
|
|
206
|
+
const { objects: [fn] } = await space.db.query(Filter.schema(FunctionType, {
|
|
207
|
+
binding
|
|
208
|
+
})).run();
|
|
209
|
+
if (!fn) {
|
|
210
|
+
log2.info("Function not found", {
|
|
211
|
+
binding
|
|
212
|
+
}, {
|
|
213
|
+
F: __dxlog_file2,
|
|
214
|
+
L: 39,
|
|
215
|
+
S: this,
|
|
216
|
+
C: (f, a) => f(...a)
|
|
217
|
+
});
|
|
218
|
+
return new CellError2(ErrorType2.REF, "Function not found");
|
|
219
|
+
}
|
|
220
|
+
if (subscribe) {
|
|
221
|
+
const unsubscribe = effect(() => {
|
|
222
|
+
log2.info("function changed", {
|
|
223
|
+
fn
|
|
224
|
+
}, {
|
|
225
|
+
F: __dxlog_file2,
|
|
226
|
+
L: 45,
|
|
227
|
+
S: this,
|
|
228
|
+
C: (f, a) => f(...a)
|
|
229
|
+
});
|
|
230
|
+
const _ = fn?.version;
|
|
231
|
+
this.runAsyncFunction(ast, state, handler(false), {
|
|
232
|
+
ttl: EDGE_FUNCTION_TTL
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
this.context.createSubscription(ast.procedureName, unsubscribe);
|
|
236
|
+
}
|
|
237
|
+
const path = getUserFunctionUrlInMetadata(getMeta(fn));
|
|
238
|
+
const result = await fetch(`${this.context.remoteFunctionUrl}${path}`, {
|
|
239
|
+
method: "POST",
|
|
240
|
+
headers: {
|
|
241
|
+
"Content-Type": "application/json"
|
|
242
|
+
},
|
|
243
|
+
body: JSON.stringify({
|
|
244
|
+
args: args.filter(nonNullable)
|
|
245
|
+
})
|
|
246
|
+
});
|
|
247
|
+
return await result.text();
|
|
248
|
+
};
|
|
249
|
+
return this.runAsyncFunction(ast, state, handler(true), {
|
|
250
|
+
ttl: EDGE_FUNCTION_TTL
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
EdgeFunctionPlugin.implementedFunctions = {
|
|
255
|
+
EDGE: {
|
|
256
|
+
method: "edge",
|
|
257
|
+
parameters: [
|
|
258
|
+
// Binding
|
|
259
|
+
{
|
|
260
|
+
argumentType: FunctionArgumentType.STRING
|
|
261
|
+
},
|
|
262
|
+
// Remote function arguments (currently supporting up to 9).
|
|
263
|
+
{
|
|
264
|
+
argumentType: FunctionArgumentType.ANY,
|
|
265
|
+
optionalArg: true
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
argumentType: FunctionArgumentType.ANY,
|
|
269
|
+
optionalArg: true
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
argumentType: FunctionArgumentType.ANY,
|
|
273
|
+
optionalArg: true
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
argumentType: FunctionArgumentType.ANY,
|
|
277
|
+
optionalArg: true
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
argumentType: FunctionArgumentType.ANY,
|
|
281
|
+
optionalArg: true
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
argumentType: FunctionArgumentType.ANY,
|
|
285
|
+
optionalArg: true
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
argumentType: FunctionArgumentType.ANY,
|
|
289
|
+
optionalArg: true
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
argumentType: FunctionArgumentType.ANY,
|
|
293
|
+
optionalArg: true
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
argumentType: FunctionArgumentType.ANY,
|
|
297
|
+
optionalArg: true
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
isVolatile: true
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
var EdgeFunctionPluginTranslations = {
|
|
304
|
+
enGB: {
|
|
305
|
+
EDGE: "EDGE"
|
|
306
|
+
},
|
|
307
|
+
enUS: {
|
|
308
|
+
EDGE: "EDGE"
|
|
309
|
+
}
|
|
310
|
+
};
|
|
187
311
|
|
|
188
|
-
// packages/plugins/plugin-sheet/src/
|
|
312
|
+
// packages/plugins/plugin-sheet/src/graph/function-defs.ts
|
|
189
313
|
var defaultFunctions = [
|
|
190
314
|
// Array
|
|
191
315
|
{
|
|
@@ -2559,685 +2683,243 @@ var defaultFunctions = [
|
|
|
2559
2683
|
}
|
|
2560
2684
|
];
|
|
2561
2685
|
|
|
2562
|
-
// packages/plugins/plugin-sheet/src/
|
|
2563
|
-
|
|
2564
|
-
var
|
|
2565
|
-
var
|
|
2566
|
-
var
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
A: [
|
|
2575
|
-
"column < MAX_COLUMNS",
|
|
2576
|
-
"`Invalid column: ${column}`"
|
|
2577
|
-
]
|
|
2578
|
-
});
|
|
2579
|
-
return (column >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(column / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + column % 26);
|
|
2580
|
-
};
|
|
2581
|
-
var addressToA1Notation = ({ column, row }) => {
|
|
2582
|
-
return `${columnLetter(column)}${row + 1}`;
|
|
2686
|
+
// packages/plugins/plugin-sheet/src/graph/compute-graph.ts
|
|
2687
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/compute-graph.ts";
|
|
2688
|
+
var OBJECT_ID_LENGTH = 60;
|
|
2689
|
+
var CUSTOM_FUNCTION = "ECHO";
|
|
2690
|
+
var defaultOptions = {
|
|
2691
|
+
licenseKey: "gpl-v3",
|
|
2692
|
+
plugins: [
|
|
2693
|
+
{
|
|
2694
|
+
plugin: EdgeFunctionPlugin,
|
|
2695
|
+
translations: EdgeFunctionPluginTranslations
|
|
2696
|
+
}
|
|
2697
|
+
]
|
|
2583
2698
|
};
|
|
2584
|
-
var
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
"match",
|
|
2592
|
-
"`Invalid notation: ${ref}`"
|
|
2593
|
-
]
|
|
2699
|
+
var PREFIX = "__";
|
|
2700
|
+
var createSheetName = (id) => `${PREFIX}${id}`;
|
|
2701
|
+
var getSheetId = (name) => name.startsWith(PREFIX) ? name.slice(PREFIX.length) : void 0;
|
|
2702
|
+
var createComputeGraphRegistry = (options = {}) => {
|
|
2703
|
+
return new ComputeGraphRegistry({
|
|
2704
|
+
...defaultOptions,
|
|
2705
|
+
...options
|
|
2594
2706
|
});
|
|
2595
|
-
return {
|
|
2596
|
-
row: parseInt(match[2], 10) - 1,
|
|
2597
|
-
column: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
2598
|
-
};
|
|
2599
|
-
};
|
|
2600
|
-
var rangeToA1Notation = (range) => {
|
|
2601
|
-
return [
|
|
2602
|
-
range?.from && addressToA1Notation(range?.from),
|
|
2603
|
-
range?.to && addressToA1Notation(range?.to)
|
|
2604
|
-
].filter(Boolean).join(":");
|
|
2605
2707
|
};
|
|
2606
|
-
var
|
|
2607
|
-
|
|
2608
|
-
return false;
|
|
2609
|
-
}
|
|
2610
|
-
const { from, to } = range;
|
|
2611
|
-
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
2612
|
-
return true;
|
|
2613
|
-
}
|
|
2614
|
-
if (!from || !to) {
|
|
2615
|
-
return false;
|
|
2616
|
-
}
|
|
2617
|
-
const { column: c1, row: r1 } = from;
|
|
2618
|
-
const { column: c2, row: r2 } = to;
|
|
2619
|
-
const cMin = Math.min(c1, c2);
|
|
2620
|
-
const cMax = Math.max(c1, c2);
|
|
2621
|
-
const rMin = Math.min(r1, r2);
|
|
2622
|
-
const rMax = Math.max(r1, r2);
|
|
2623
|
-
const { column, row } = cell;
|
|
2624
|
-
return column >= cMin && column <= cMax && row >= rMin && row <= rMax;
|
|
2625
|
-
};
|
|
2626
|
-
|
|
2627
|
-
// packages/plugins/plugin-sheet/src/model/util.ts
|
|
2628
|
-
import { randomBytes } from "@dxos/crypto";
|
|
2629
|
-
var ApiError = class extends Error {
|
|
2630
|
-
};
|
|
2631
|
-
var ReadonlyException = class extends ApiError {
|
|
2632
|
-
};
|
|
2633
|
-
var RangeException = class extends ApiError {
|
|
2634
|
-
constructor(n) {
|
|
2708
|
+
var ComputeGraphRegistry = class extends Resource2 {
|
|
2709
|
+
constructor(_options = defaultOptions) {
|
|
2635
2710
|
super();
|
|
2711
|
+
this._options = _options;
|
|
2712
|
+
this._registry = /* @__PURE__ */ new Map();
|
|
2713
|
+
this._options.plugins?.forEach(({ plugin, translations }) => {
|
|
2714
|
+
HyperFormula.registerFunctionPlugin(plugin, translations);
|
|
2715
|
+
});
|
|
2636
2716
|
}
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
return {
|
|
2653
|
-
column: sheet.columns.indexOf(column),
|
|
2654
|
-
row: sheet.rows.indexOf(row)
|
|
2655
|
-
};
|
|
2656
|
-
};
|
|
2657
|
-
var rangeFromIndex = (sheet, idx) => {
|
|
2658
|
-
const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
|
|
2659
|
-
return {
|
|
2660
|
-
from,
|
|
2661
|
-
to
|
|
2662
|
-
};
|
|
2663
|
-
};
|
|
2664
|
-
var closest = (cursor, cells) => {
|
|
2665
|
-
let closestCell;
|
|
2666
|
-
let closestDistance = Number.MAX_SAFE_INTEGER;
|
|
2667
|
-
for (const cell of cells) {
|
|
2668
|
-
const distance = Math.abs(cell.row - cursor.row) + Math.abs(cell.column - cursor.column);
|
|
2669
|
-
if (distance < closestDistance) {
|
|
2670
|
-
closestCell = cell;
|
|
2671
|
-
closestDistance = distance;
|
|
2717
|
+
getGraph(spaceId) {
|
|
2718
|
+
return this._registry.get(spaceId);
|
|
2719
|
+
}
|
|
2720
|
+
async getOrCreateGraph(space) {
|
|
2721
|
+
let graph = this.getGraph(space.id);
|
|
2722
|
+
if (!graph) {
|
|
2723
|
+
log3.info("create graph", {
|
|
2724
|
+
space: space.id
|
|
2725
|
+
}, {
|
|
2726
|
+
F: __dxlog_file3,
|
|
2727
|
+
L: 95,
|
|
2728
|
+
S: this,
|
|
2729
|
+
C: (f, a) => f(...a)
|
|
2730
|
+
});
|
|
2731
|
+
graph = await this.createGraph(space);
|
|
2672
2732
|
}
|
|
2733
|
+
return graph;
|
|
2673
2734
|
}
|
|
2674
|
-
|
|
2675
|
-
}
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2735
|
+
async createGraph(space) {
|
|
2736
|
+
invariant(!this._registry.has(space.id), `ComputeGraph already exists for space: ${space.id}`, {
|
|
2737
|
+
F: __dxlog_file3,
|
|
2738
|
+
L: 103,
|
|
2739
|
+
S: this,
|
|
2740
|
+
A: [
|
|
2741
|
+
"!this._registry.has(space.id)",
|
|
2742
|
+
"`ComputeGraph already exists for space: ${space.id}`"
|
|
2743
|
+
]
|
|
2744
|
+
});
|
|
2745
|
+
const hf = HyperFormula.buildEmpty(this._options);
|
|
2746
|
+
const graph = new ComputeGraph(hf, space, this._options);
|
|
2747
|
+
await graph.open(this._ctx);
|
|
2748
|
+
this._registry.set(space.id, graph);
|
|
2749
|
+
return graph;
|
|
2683
2750
|
}
|
|
2684
2751
|
};
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
var DEFAULT_COLUMNS = 26;
|
|
2690
|
-
var typeMap = {
|
|
2691
|
-
BOOLEAN: ValueTypeEnum.Boolean,
|
|
2692
|
-
NUMBER_RAW: ValueTypeEnum.Number,
|
|
2693
|
-
NUMBER_PERCENT: ValueTypeEnum.Percent,
|
|
2694
|
-
NUMBER_CURRENCY: ValueTypeEnum.Currency,
|
|
2695
|
-
NUMBER_DATETIME: ValueTypeEnum.DateTime,
|
|
2696
|
-
NUMBER_DATE: ValueTypeEnum.Date,
|
|
2697
|
-
NUMBER_TIME: ValueTypeEnum.Time
|
|
2698
|
-
};
|
|
2699
|
-
var defaultOptions = {
|
|
2700
|
-
rows: 50,
|
|
2701
|
-
columns: 26,
|
|
2702
|
-
mapFormulaBindingFromId: () => (formula) => formula,
|
|
2703
|
-
mapFormulaBindingToId: () => (formula) => formula
|
|
2704
|
-
};
|
|
2705
|
-
var getTopLeft = (range) => {
|
|
2706
|
-
const to = range.to ?? range.from;
|
|
2707
|
-
return {
|
|
2708
|
-
row: Math.min(range.from.row, to.row),
|
|
2709
|
-
column: Math.min(range.from.column, to.column)
|
|
2710
|
-
};
|
|
2711
|
-
};
|
|
2712
|
-
var toSimpleCellAddress = (sheet, cell) => ({
|
|
2713
|
-
sheet,
|
|
2714
|
-
row: cell.row,
|
|
2715
|
-
col: cell.column
|
|
2716
|
-
});
|
|
2717
|
-
var toModelRange = (sheet, range) => ({
|
|
2718
|
-
start: toSimpleCellAddress(sheet, range.from),
|
|
2719
|
-
end: toSimpleCellAddress(sheet, range.to ?? range.from)
|
|
2720
|
-
});
|
|
2721
|
-
var SheetModel = class {
|
|
2722
|
-
constructor(_graph, _sheet, _space, options = {}) {
|
|
2723
|
-
this._graph = _graph;
|
|
2724
|
-
this._sheet = _sheet;
|
|
2752
|
+
var ComputeGraph = class extends Resource2 {
|
|
2753
|
+
constructor(_hf, _space, _options) {
|
|
2754
|
+
super();
|
|
2755
|
+
this._hf = _hf;
|
|
2725
2756
|
this._space = _space;
|
|
2726
|
-
this.
|
|
2727
|
-
this.
|
|
2757
|
+
this._options = _options;
|
|
2758
|
+
this.id = `graph-${PublicKey.random().truncate()}`;
|
|
2759
|
+
this._nodes = /* @__PURE__ */ new Map();
|
|
2728
2760
|
this._functions = [];
|
|
2761
|
+
this.context = new FunctionContext(this._hf, this._space, this.refresh.bind(this), this._options);
|
|
2729
2762
|
this.update = new Event2();
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
this._graph.hf.addSheet(name);
|
|
2733
|
-
}
|
|
2734
|
-
this._sheetId = this._graph.hf.getSheetId(name);
|
|
2735
|
-
this._options = {
|
|
2736
|
-
...defaultOptions,
|
|
2737
|
-
...options
|
|
2738
|
-
};
|
|
2739
|
-
this.reset();
|
|
2740
|
-
}
|
|
2741
|
-
get graph() {
|
|
2742
|
-
return this._graph;
|
|
2743
|
-
}
|
|
2744
|
-
get sheet() {
|
|
2745
|
-
return this._sheet;
|
|
2746
|
-
}
|
|
2747
|
-
get readonly() {
|
|
2748
|
-
return this._options.readonly;
|
|
2749
|
-
}
|
|
2750
|
-
get bounds() {
|
|
2751
|
-
return {
|
|
2752
|
-
rows: this._sheet.rows.length,
|
|
2753
|
-
columns: this._sheet.columns.length
|
|
2754
|
-
};
|
|
2755
|
-
}
|
|
2756
|
-
get functions() {
|
|
2757
|
-
const hfFunctions = this._graph.hf.getRegisteredFunctionNames().map((name) => defaultFunctions.find((fn) => fn.name === name) ?? {
|
|
2758
|
-
name
|
|
2763
|
+
this._hf.updateConfig({
|
|
2764
|
+
context: this.context
|
|
2759
2765
|
});
|
|
2760
|
-
const echoFunctions = this._functions.map((fn) => ({
|
|
2761
|
-
name: fn.binding
|
|
2762
|
-
}));
|
|
2763
|
-
return [
|
|
2764
|
-
...hfFunctions,
|
|
2765
|
-
...echoFunctions
|
|
2766
|
-
];
|
|
2767
2766
|
}
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
/**
|
|
2772
|
-
* Initialize sheet and engine.
|
|
2773
|
-
*/
|
|
2774
|
-
async initialize() {
|
|
2775
|
-
log3("initialize", {
|
|
2776
|
-
id: this.id
|
|
2777
|
-
}, {
|
|
2778
|
-
F: __dxlog_file4,
|
|
2779
|
-
L: 142,
|
|
2780
|
-
S: this,
|
|
2781
|
-
C: (f, a) => f(...a)
|
|
2782
|
-
});
|
|
2783
|
-
invariant2(!this.initialized, "Already initialized.", {
|
|
2784
|
-
F: __dxlog_file4,
|
|
2785
|
-
L: 143,
|
|
2786
|
-
S: this,
|
|
2787
|
-
A: [
|
|
2788
|
-
"!this.initialized",
|
|
2789
|
-
"'Already initialized.'"
|
|
2790
|
-
]
|
|
2791
|
-
});
|
|
2792
|
-
this._ctx = new Context(void 0, {
|
|
2793
|
-
F: __dxlog_file4,
|
|
2794
|
-
L: 144
|
|
2795
|
-
});
|
|
2796
|
-
if (!this._sheet.rows.length) {
|
|
2797
|
-
this._insertIndices(this._sheet.rows, 0, this._options.rows, DEFAULT_ROWS);
|
|
2798
|
-
}
|
|
2799
|
-
if (!this._sheet.columns.length) {
|
|
2800
|
-
this._insertIndices(this._sheet.columns, 0, this._options.columns, DEFAULT_COLUMNS);
|
|
2801
|
-
}
|
|
2802
|
-
this.reset();
|
|
2803
|
-
const unsubscribe = this._graph.update.on(() => this.update.emit());
|
|
2804
|
-
this._ctx.onDispose(unsubscribe);
|
|
2805
|
-
if (this._space) {
|
|
2806
|
-
const { Filter } = await import("@dxos/client/echo");
|
|
2807
|
-
const { FunctionType } = await import("@dxos/plugin-script/types");
|
|
2808
|
-
const query = this._space?.db.query(Filter.schema(FunctionType));
|
|
2809
|
-
const unsubscribe2 = query.subscribe(({ objects }) => {
|
|
2810
|
-
this._functions = objects.filter((fn) => fn.binding);
|
|
2811
|
-
this.update.emit();
|
|
2812
|
-
});
|
|
2813
|
-
this._ctx.onDispose(unsubscribe2);
|
|
2814
|
-
}
|
|
2815
|
-
return this;
|
|
2767
|
+
// TODO(burdon): Remove.
|
|
2768
|
+
get hf() {
|
|
2769
|
+
return this._hf;
|
|
2816
2770
|
}
|
|
2817
|
-
|
|
2818
|
-
log3("
|
|
2771
|
+
refresh() {
|
|
2772
|
+
log3("refresh", {
|
|
2819
2773
|
id: this.id
|
|
2820
2774
|
}, {
|
|
2821
|
-
F:
|
|
2822
|
-
L:
|
|
2775
|
+
F: __dxlog_file3,
|
|
2776
|
+
L: 152,
|
|
2823
2777
|
S: this,
|
|
2824
2778
|
C: (f, a) => f(...a)
|
|
2825
2779
|
});
|
|
2826
|
-
|
|
2827
|
-
await this._ctx.dispose();
|
|
2828
|
-
this._ctx = void 0;
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
/**
|
|
2832
|
-
* Update engine.
|
|
2833
|
-
* NOTE: This resets the undo history.
|
|
2834
|
-
* @deprecated
|
|
2835
|
-
*/
|
|
2836
|
-
reset() {
|
|
2837
|
-
this._graph.hf.clearSheet(this._sheetId);
|
|
2838
|
-
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
2839
|
-
const { column, row } = addressFromIndex(this._sheet, key);
|
|
2840
|
-
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
2841
|
-
value = this.mapFormulaBindingToFormula(this.mapFormulaBindingFromId(this.mapFormulaIndicesToRefs(value)));
|
|
2842
|
-
}
|
|
2843
|
-
this._graph.hf.setCellContents({
|
|
2844
|
-
sheet: this._sheetId,
|
|
2845
|
-
row,
|
|
2846
|
-
col: column
|
|
2847
|
-
}, value);
|
|
2848
|
-
});
|
|
2849
|
-
}
|
|
2850
|
-
/**
|
|
2851
|
-
* Recalculate formulas.
|
|
2852
|
-
* NOTE: This resets the undo history.
|
|
2853
|
-
* https://hyperformula.handsontable.com/guide/volatile-functions.html#volatile-actions
|
|
2854
|
-
* @deprecated
|
|
2855
|
-
*/
|
|
2856
|
-
// TODO(burdon): Remove.
|
|
2857
|
-
recalculate() {
|
|
2858
|
-
this._graph.hf.rebuildAndRecalculate();
|
|
2859
|
-
}
|
|
2860
|
-
insertRows(i, n = 1) {
|
|
2861
|
-
this._insertIndices(this._sheet.rows, i, n, DEFAULT_ROWS);
|
|
2862
|
-
this.reset();
|
|
2780
|
+
this.update.emit();
|
|
2863
2781
|
}
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2782
|
+
getFunctions({ standard = true, echo = true } = {}) {
|
|
2783
|
+
return [
|
|
2784
|
+
...standard ? this._hf.getRegisteredFunctionNames().map((name) => defaultFunctions.find((fn) => fn.name === name) ?? {
|
|
2785
|
+
name
|
|
2786
|
+
}) : [],
|
|
2787
|
+
...echo ? this._functions.map((fn) => ({
|
|
2788
|
+
name: fn.binding
|
|
2789
|
+
})) : []
|
|
2790
|
+
];
|
|
2867
2791
|
}
|
|
2868
|
-
//
|
|
2869
|
-
// Undoable actions.
|
|
2870
|
-
// TODO(burdon): Group undoable methods; consistently update hf/sheet.
|
|
2871
|
-
//
|
|
2872
2792
|
/**
|
|
2873
|
-
*
|
|
2793
|
+
* Get or create cell representing a sheet.
|
|
2874
2794
|
*/
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2795
|
+
// TODO(burdon): Async (open node).
|
|
2796
|
+
// The graph should be an extensible factory that plugins extend with model constructors.
|
|
2797
|
+
// This would enable on-the-fly instantiation of new models when then are referenced.
|
|
2798
|
+
// E.g., Cross-object reference would be stored as "ObjectId!A1"
|
|
2799
|
+
// The graph would then load the object and create a ComputeNode (model) of the appropriate type.
|
|
2800
|
+
getOrCreateNode(name) {
|
|
2801
|
+
invariant(name.length, void 0, {
|
|
2802
|
+
F: __dxlog_file3,
|
|
2803
|
+
L: 176,
|
|
2804
|
+
S: this,
|
|
2805
|
+
A: [
|
|
2806
|
+
"name.length",
|
|
2807
|
+
""
|
|
2808
|
+
]
|
|
2889
2809
|
});
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
row: address.row,
|
|
2902
|
-
column: address.col
|
|
2903
|
-
});
|
|
2904
|
-
this._sheet.cells[idx] = {
|
|
2905
|
-
value: newValue
|
|
2906
|
-
};
|
|
2907
|
-
}
|
|
2908
|
-
}
|
|
2909
|
-
}
|
|
2910
|
-
}
|
|
2911
|
-
// TODO(burdon): Display undo/redo state.
|
|
2912
|
-
undo() {
|
|
2913
|
-
if (this._graph.hf.isThereSomethingToUndo()) {
|
|
2914
|
-
this._graph.hf.undo();
|
|
2915
|
-
this.update.emit();
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
redo() {
|
|
2919
|
-
if (this._graph.hf.isThereSomethingToRedo()) {
|
|
2920
|
-
this._graph.hf.redo();
|
|
2810
|
+
if (!this._hf.doesSheetExist(name)) {
|
|
2811
|
+
log3.info("created node", {
|
|
2812
|
+
space: this._space?.id,
|
|
2813
|
+
name
|
|
2814
|
+
}, {
|
|
2815
|
+
F: __dxlog_file3,
|
|
2816
|
+
L: 178,
|
|
2817
|
+
S: this,
|
|
2818
|
+
C: (f, a) => f(...a)
|
|
2819
|
+
});
|
|
2820
|
+
this._hf.addSheet(name);
|
|
2921
2821
|
this.update.emit();
|
|
2922
2822
|
}
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
/**
|
|
2932
|
-
* Get value as a string for editing.
|
|
2933
|
-
*/
|
|
2934
|
-
getCellText(cell) {
|
|
2935
|
-
const value = this.getCellValue(cell);
|
|
2936
|
-
if (value == null) {
|
|
2937
|
-
return void 0;
|
|
2938
|
-
}
|
|
2939
|
-
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
2940
|
-
return this.mapFormulaBindingFromId(this.mapFormulaIndicesToRefs(value));
|
|
2941
|
-
} else {
|
|
2942
|
-
return String(value);
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
|
-
/**
|
|
2946
|
-
* Get array of raw values from sheet.
|
|
2947
|
-
*/
|
|
2948
|
-
getCellValues(range) {
|
|
2949
|
-
return this._iterRange(range, (cell) => this.getCellValue(cell));
|
|
2950
|
-
}
|
|
2951
|
-
/**
|
|
2952
|
-
* Gets the regular or computed value from the engine.
|
|
2953
|
-
*/
|
|
2954
|
-
getValue(cell) {
|
|
2955
|
-
const value = this._graph.hf.getCellValue(toSimpleCellAddress(this._sheetId, cell));
|
|
2956
|
-
if (value instanceof DetailedCellError) {
|
|
2957
|
-
return value.toString();
|
|
2958
|
-
}
|
|
2959
|
-
return value;
|
|
2960
|
-
}
|
|
2961
|
-
/**
|
|
2962
|
-
* Get value type.
|
|
2963
|
-
*/
|
|
2964
|
-
getValueType(cell) {
|
|
2965
|
-
const addr = toSimpleCellAddress(this._sheetId, cell);
|
|
2966
|
-
const type = this._graph.hf.getCellValueDetailedType(addr);
|
|
2967
|
-
return typeMap[type];
|
|
2968
|
-
}
|
|
2969
|
-
/**
|
|
2970
|
-
* Sets the value, updating the sheet and engine.
|
|
2971
|
-
*/
|
|
2972
|
-
setValue(cell, value) {
|
|
2973
|
-
if (this._options.readonly) {
|
|
2974
|
-
throw new ReadonlyException();
|
|
2975
|
-
}
|
|
2976
|
-
let refresh = false;
|
|
2977
|
-
if (cell.row >= this._sheet.rows.length) {
|
|
2978
|
-
this._insertIndices(this._sheet.rows, cell.row, 1, DEFAULT_ROWS);
|
|
2979
|
-
refresh = true;
|
|
2980
|
-
}
|
|
2981
|
-
if (cell.column >= this._sheet.columns.length) {
|
|
2982
|
-
this._insertIndices(this._sheet.columns, cell.column, 1, DEFAULT_COLUMNS);
|
|
2983
|
-
refresh = true;
|
|
2984
|
-
}
|
|
2985
|
-
if (refresh) {
|
|
2986
|
-
this.reset();
|
|
2987
|
-
}
|
|
2988
|
-
this._graph.hf.setCellContents({
|
|
2989
|
-
sheet: this._sheetId,
|
|
2990
|
-
row: cell.row,
|
|
2991
|
-
col: cell.column
|
|
2992
|
-
}, [
|
|
2993
|
-
[
|
|
2994
|
-
typeof value === "string" && value.charAt(0) === "=" ? this.mapFormulaBindingToFormula(value) : value
|
|
2823
|
+
const sheetId = this._hf.getSheetId(name);
|
|
2824
|
+
invariant(sheetId !== void 0, void 0, {
|
|
2825
|
+
F: __dxlog_file3,
|
|
2826
|
+
L: 184,
|
|
2827
|
+
S: this,
|
|
2828
|
+
A: [
|
|
2829
|
+
"sheetId !== undefined",
|
|
2830
|
+
""
|
|
2995
2831
|
]
|
|
2996
|
-
]);
|
|
2997
|
-
const idx = addressToIndex(this._sheet, cell);
|
|
2998
|
-
if (value === void 0 || value === null) {
|
|
2999
|
-
delete this._sheet.cells[idx];
|
|
3000
|
-
} else {
|
|
3001
|
-
if (typeof value === "string" && value.charAt(0) === "=") {
|
|
3002
|
-
value = this.mapFormulaBindingToId(this.mapFormulaRefsToIndices(value));
|
|
3003
|
-
}
|
|
3004
|
-
this._sheet.cells[idx] = {
|
|
3005
|
-
value
|
|
3006
|
-
};
|
|
3007
|
-
}
|
|
3008
|
-
}
|
|
3009
|
-
/**
|
|
3010
|
-
* Sets values from a simple map.
|
|
3011
|
-
*/
|
|
3012
|
-
setValues(values) {
|
|
3013
|
-
Object.entries(values).forEach(([key, { value }]) => {
|
|
3014
|
-
this.setValue(addressFromA1Notation(key), value);
|
|
3015
2832
|
});
|
|
2833
|
+
const node = new ComputeNode(this, sheetId);
|
|
2834
|
+
this._nodes.set(sheetId, node);
|
|
2835
|
+
return node;
|
|
3016
2836
|
}
|
|
3017
2837
|
/**
|
|
3018
|
-
*
|
|
2838
|
+
* Map bound value to custom function invocation.
|
|
2839
|
+
* E.g., "HELLO(...args)" => "EDGE("HELLO", ...args)".
|
|
3019
2840
|
*/
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
for (let row = rowRange[0]; row <= rowRange[1]; row++) {
|
|
3032
|
-
const rowCells = [];
|
|
3033
|
-
for (let column = columnRange[0]; column <= columnRange[1]; column++) {
|
|
3034
|
-
const value = cb({
|
|
3035
|
-
row,
|
|
3036
|
-
column
|
|
3037
|
-
});
|
|
3038
|
-
if (value !== void 0) {
|
|
3039
|
-
rowCells.push(value);
|
|
2841
|
+
mapFormulaToNative(formula) {
|
|
2842
|
+
return formula.replace(/['"]?([ \w]+)['"]?!/, (_match, name) => {
|
|
2843
|
+
if (name) {
|
|
2844
|
+
const objects = this._hf.getSheetNames().map((name2) => {
|
|
2845
|
+
const id = getSheetId(name2);
|
|
2846
|
+
return id ? this._space?.db.getObjectById(id) : void 0;
|
|
2847
|
+
}).filter(nonNullable2);
|
|
2848
|
+
for (const obj of objects) {
|
|
2849
|
+
if (obj.name === name || obj.title === name) {
|
|
2850
|
+
return `${createSheetName(obj.id)}!`;
|
|
2851
|
+
}
|
|
3040
2852
|
}
|
|
3041
2853
|
}
|
|
3042
|
-
|
|
3043
|
-
}
|
|
3044
|
-
return rows;
|
|
3045
|
-
}
|
|
3046
|
-
/**
|
|
3047
|
-
*
|
|
3048
|
-
*/
|
|
3049
|
-
// TODO(burdon): Insert indices into sheet.
|
|
3050
|
-
_insertIndices(indices, i, n, max) {
|
|
3051
|
-
if (i + n > max) {
|
|
3052
|
-
throw new RangeException(i + n);
|
|
3053
|
-
}
|
|
3054
|
-
const idx = createIndices(n);
|
|
3055
|
-
indices.splice(i, 0, ...idx);
|
|
3056
|
-
}
|
|
3057
|
-
// TODO(burdon): Delete index.
|
|
3058
|
-
_deleteIndices(indices, i, n) {
|
|
3059
|
-
throw new Error("Not implemented");
|
|
3060
|
-
}
|
|
3061
|
-
// TODO(burdon): Move. Cannot use fractional without changing. Switch back to using unique IDs?
|
|
3062
|
-
_moveIndices(indices, i, j, n) {
|
|
3063
|
-
throw new Error("Not implemented");
|
|
3064
|
-
}
|
|
3065
|
-
//
|
|
3066
|
-
// Indices.
|
|
3067
|
-
//
|
|
3068
|
-
/**
|
|
3069
|
-
* E.g., "HELLO()" => "EDGE("HELLO")".
|
|
3070
|
-
*/
|
|
3071
|
-
mapFormulaBindingToFormula(formula) {
|
|
3072
|
-
return formula.replace(/([a-zA-Z0-9]+)\((.*)\)/g, (match, binding, args) => {
|
|
2854
|
+
return `${name}!`;
|
|
2855
|
+
}).replace(/(\w+)\((.*)\)/g, (match, binding, args) => {
|
|
3073
2856
|
const fn = this._functions.find((fn2) => fn2.binding === binding);
|
|
3074
2857
|
if (!fn) {
|
|
3075
2858
|
return match;
|
|
3076
2859
|
}
|
|
3077
2860
|
if (args.trim() === "") {
|
|
3078
|
-
return
|
|
2861
|
+
return `${CUSTOM_FUNCTION}("${binding}")`;
|
|
2862
|
+
} else {
|
|
2863
|
+
return `${CUSTOM_FUNCTION}("${binding}", ${args})`;
|
|
3079
2864
|
}
|
|
3080
|
-
return `EDGE("${binding}", ${args})`;
|
|
3081
2865
|
});
|
|
3082
2866
|
}
|
|
3083
2867
|
/**
|
|
3084
|
-
*
|
|
2868
|
+
* Map from binding to fully qualified ECHO ID (to store).
|
|
2869
|
+
* E.g., HELLO() => spaceId:objectId()
|
|
3085
2870
|
*/
|
|
3086
|
-
|
|
3087
|
-
return formula.replace(/
|
|
3088
|
-
if (
|
|
3089
|
-
return
|
|
2871
|
+
mapFunctionBindingToId(formula) {
|
|
2872
|
+
return formula.replace(/(\w+)\((.*)\)/g, (match, binding, args) => {
|
|
2873
|
+
if (binding === CUSTOM_FUNCTION || defaultFunctions.find((fn2) => fn2.name === binding)) {
|
|
2874
|
+
return match;
|
|
2875
|
+
}
|
|
2876
|
+
const fn = this._functions.find((fn2) => fn2.binding === binding);
|
|
2877
|
+
if (fn) {
|
|
2878
|
+
const id = fullyQualifiedId(fn);
|
|
2879
|
+
return `${id}(${args})`;
|
|
2880
|
+
} else {
|
|
2881
|
+
return match;
|
|
3090
2882
|
}
|
|
3091
|
-
return `${binding}(${args.slice(2)})`;
|
|
3092
|
-
});
|
|
3093
|
-
}
|
|
3094
|
-
/**
|
|
3095
|
-
* Map from binding to fully qualified ECHO ID.
|
|
3096
|
-
*/
|
|
3097
|
-
mapFormulaBindingToId(formula) {
|
|
3098
|
-
return this._options.mapFormulaBindingToId(this._functions)(formula);
|
|
3099
|
-
}
|
|
3100
|
-
/**
|
|
3101
|
-
* Map from fully qualified ECHO ID to binding.
|
|
3102
|
-
*/
|
|
3103
|
-
mapFormulaBindingFromId(formula) {
|
|
3104
|
-
return this._options.mapFormulaBindingFromId(this._functions)(formula);
|
|
3105
|
-
}
|
|
3106
|
-
/**
|
|
3107
|
-
* Map from A1 notation to indices.
|
|
3108
|
-
*/
|
|
3109
|
-
mapFormulaRefsToIndices(formula) {
|
|
3110
|
-
invariant2(formula.charAt(0) === "=", void 0, {
|
|
3111
|
-
F: __dxlog_file4,
|
|
3112
|
-
L: 475,
|
|
3113
|
-
S: this,
|
|
3114
|
-
A: [
|
|
3115
|
-
"formula.charAt(0) === '='",
|
|
3116
|
-
""
|
|
3117
|
-
]
|
|
3118
|
-
});
|
|
3119
|
-
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
3120
|
-
return addressToIndex(this._sheet, addressFromA1Notation(match));
|
|
3121
|
-
});
|
|
3122
|
-
}
|
|
3123
|
-
/**
|
|
3124
|
-
* Map from indices to A1 notation.
|
|
3125
|
-
*/
|
|
3126
|
-
mapFormulaIndicesToRefs(formula) {
|
|
3127
|
-
invariant2(formula.charAt(0) === "=", void 0, {
|
|
3128
|
-
F: __dxlog_file4,
|
|
3129
|
-
L: 485,
|
|
3130
|
-
S: this,
|
|
3131
|
-
A: [
|
|
3132
|
-
"formula.charAt(0) === '='",
|
|
3133
|
-
""
|
|
3134
|
-
]
|
|
3135
|
-
});
|
|
3136
|
-
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
3137
|
-
return addressToA1Notation(addressFromIndex(this._sheet, idx));
|
|
3138
2883
|
});
|
|
3139
2884
|
}
|
|
3140
|
-
//
|
|
3141
|
-
// Values
|
|
3142
|
-
//
|
|
3143
2885
|
/**
|
|
3144
|
-
*
|
|
3145
|
-
*
|
|
3146
|
-
* NOTE: TODAY() is number of FULL days since nullDate. It will typically be -1 days from NOW().
|
|
2886
|
+
* Map from fully qualified ECHO ID to binding (from store).
|
|
2887
|
+
* E.g., spaceId:objectId() => HELLO()
|
|
3147
2888
|
*/
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
return this._graph.hf.numberToDateTime(num);
|
|
3154
|
-
}
|
|
3155
|
-
toDate(num) {
|
|
3156
|
-
return this._graph.hf.numberToDate(num);
|
|
3157
|
-
}
|
|
3158
|
-
toTime(num) {
|
|
3159
|
-
return this._graph.hf.numberToTime(num);
|
|
3160
|
-
}
|
|
3161
|
-
};
|
|
3162
|
-
|
|
3163
|
-
// packages/plugins/plugin-sheet/src/components/ComputeGraph/custom.ts
|
|
3164
|
-
import { FunctionArgumentType } from "hyperformula";
|
|
3165
|
-
import { getDeep } from "@dxos/util";
|
|
3166
|
-
var parseNumberString = (str) => {
|
|
3167
|
-
return parseFloat(str.replace(/[^\d.]/g, ""));
|
|
3168
|
-
};
|
|
3169
|
-
var CustomPlugin = class extends FunctionPluginAsync {
|
|
3170
|
-
test(ast, state) {
|
|
3171
|
-
const handler = async () => {
|
|
3172
|
-
return Math.random();
|
|
3173
|
-
};
|
|
3174
|
-
return this.runAsyncFunction(ast, state, handler);
|
|
3175
|
-
}
|
|
3176
|
-
crypto(ast, state) {
|
|
3177
|
-
const handler = async (_currency) => {
|
|
3178
|
-
const currency = (_currency || "USD").toUpperCase();
|
|
3179
|
-
const result = await fetch(`https://api.coindesk.com/v1/bpi/currentprice/${currency}.json`);
|
|
3180
|
-
const data = await result.json();
|
|
3181
|
-
const rate = getDeep(data, [
|
|
3182
|
-
"bpi",
|
|
3183
|
-
currency,
|
|
3184
|
-
"rate"
|
|
3185
|
-
]);
|
|
3186
|
-
if (!rate) {
|
|
3187
|
-
return NaN;
|
|
2889
|
+
mapFunctionBindingFromId(formula) {
|
|
2890
|
+
return formula.replace(/(\w+):([a-zA-Z0-9]+)\((.*)\)/g, (match, spaceId, objectId, args) => {
|
|
2891
|
+
const id = `${spaceId}:${objectId}`;
|
|
2892
|
+
if (id.length !== OBJECT_ID_LENGTH) {
|
|
2893
|
+
return match;
|
|
3188
2894
|
}
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
}
|
|
3195
|
-
};
|
|
3196
|
-
CustomPlugin.implementedFunctions = {
|
|
3197
|
-
TEST: {
|
|
3198
|
-
method: "test",
|
|
3199
|
-
parameters: [],
|
|
3200
|
-
isVolatile: true
|
|
3201
|
-
},
|
|
3202
|
-
CRYPTO: {
|
|
3203
|
-
method: "crypto",
|
|
3204
|
-
parameters: [
|
|
3205
|
-
{
|
|
3206
|
-
argumentType: FunctionArgumentType.STRING,
|
|
3207
|
-
optionalArg: true
|
|
2895
|
+
const fn = this._functions.find((fn2) => fullyQualifiedId(fn2) === id);
|
|
2896
|
+
if (fn?.binding) {
|
|
2897
|
+
return `${fn.binding}(${args})`;
|
|
2898
|
+
} else {
|
|
2899
|
+
return match;
|
|
3208
2900
|
}
|
|
3209
|
-
|
|
3210
|
-
isVolatile: true
|
|
2901
|
+
});
|
|
3211
2902
|
}
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
2903
|
+
async _open() {
|
|
2904
|
+
if (this._space) {
|
|
2905
|
+
const query = this._space.db.query(Filter2.schema(FunctionType2));
|
|
2906
|
+
const unsubscribe = query.subscribe(({ objects }) => {
|
|
2907
|
+
this._functions = objects.filter(({ binding }) => binding);
|
|
2908
|
+
this.update.emit();
|
|
2909
|
+
});
|
|
2910
|
+
this._ctx.onDispose(unsubscribe);
|
|
2911
|
+
}
|
|
3221
2912
|
}
|
|
3222
2913
|
};
|
|
3223
2914
|
|
|
3224
2915
|
export {
|
|
3225
|
-
|
|
3226
|
-
CustomPlugin,
|
|
3227
|
-
CustomPluginTranslations,
|
|
3228
|
-
createComputeGraph,
|
|
2916
|
+
ComputeNode,
|
|
3229
2917
|
defaultFunctions,
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
addressToIndex,
|
|
3237
|
-
addressFromIndex,
|
|
3238
|
-
rangeFromIndex,
|
|
3239
|
-
closest,
|
|
3240
|
-
compareIndexPositions,
|
|
3241
|
-
SheetModel
|
|
2918
|
+
defaultOptions,
|
|
2919
|
+
createSheetName,
|
|
2920
|
+
getSheetId,
|
|
2921
|
+
createComputeGraphRegistry,
|
|
2922
|
+
ComputeGraphRegistry,
|
|
2923
|
+
ComputeGraph
|
|
3242
2924
|
};
|
|
3243
|
-
//# sourceMappingURL=chunk-
|
|
2925
|
+
//# sourceMappingURL=chunk-D6KU5MI7.mjs.map
|