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