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