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