@dxos/plugin-sheet 0.6.14-main.7bd9c89 → 0.6.14-main.8b352a0
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-AKWROARP.mjs → SheetContainer-R65IDJHN.mjs} +54 -58
- package/dist/lib/browser/SheetContainer-R65IDJHN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BWN5DZWZ.mjs → chunk-5KVQ5IPW.mjs} +3 -12
- package/dist/lib/browser/chunk-5KVQ5IPW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FGMFOW6U.mjs → chunk-I2DKJ72A.mjs} +570 -669
- package/dist/lib/browser/chunk-I2DKJ72A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GSV5QNLD.mjs → chunk-KCYJSOFB.mjs} +252 -33
- package/dist/lib/browser/chunk-KCYJSOFB.mjs.map +7 -0
- package/dist/lib/browser/{graph-M4IQ76QX.mjs → compute-graph-SJT67236.mjs} +4 -2
- package/dist/lib/browser/index.mjs +62 -20
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{SheetContainer-N5IQGEFL.cjs → SheetContainer-6BO4C5X2.cjs} +52 -62
- package/dist/lib/node/SheetContainer-6BO4C5X2.cjs.map +7 -0
- package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-2XJ5I4UF.cjs} +6 -15
- package/dist/lib/node/chunk-2XJ5I4UF.cjs.map +7 -0
- package/dist/lib/node/{chunk-53BMSUIK.cjs → chunk-DEPJHN47.cjs} +534 -646
- package/dist/lib/node/chunk-DEPJHN47.cjs.map +7 -0
- package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-JF5XNTF3.cjs} +257 -28
- package/dist/lib/node/chunk-JF5XNTF3.cjs.map +7 -0
- package/dist/lib/node/{graph-Q3N2X26H.cjs → compute-graph-AQBDL7HO.cjs} +21 -19
- package/dist/lib/node/compute-graph-AQBDL7HO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +70 -31
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +6 -6
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{SheetContainer-46PBMF2E.mjs → SheetContainer-MJXC5E3P.mjs} +54 -58
- package/dist/lib/node-esm/SheetContainer-MJXC5E3P.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-T3PRH7QS.mjs → chunk-25V7WY4R.mjs} +570 -669
- package/dist/lib/node-esm/chunk-25V7WY4R.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WFDTY3IC.mjs → chunk-5TXLF6PL.mjs} +3 -12
- package/dist/lib/node-esm/chunk-5TXLF6PL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs → chunk-XBEHKYO7.mjs} +251 -33
- package/dist/lib/node-esm/chunk-XBEHKYO7.mjs.map +7 -0
- package/dist/lib/node-esm/{graph-SMPUMOV2.mjs → compute-graph-FRCKXEYK.mjs} +4 -2
- package/dist/lib/node-esm/index.mjs +62 -20
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types.mjs +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +3 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts +1 -2
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts +7 -0
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/components/RangeList/index.d.ts +2 -0
- package/dist/types/src/components/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +6 -3
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +7 -5
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/{graph → compute-graph}/compute-graph.d.ts +1 -1
- package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/compute-graph/functions/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/compute-graph/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +1 -0
- package/dist/types/src/compute-graph/util.d.ts.map +1 -0
- package/dist/types/src/defs/index.d.ts +1 -1
- package/dist/types/src/defs/index.d.ts.map +1 -1
- package/dist/types/src/defs/sheet-range-types.d.ts +1 -1
- package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/defs/types.d.ts +6 -0
- package/dist/types/src/defs/types.d.ts.map +1 -1
- package/dist/types/src/defs/util.d.ts +2 -6
- package/dist/types/src/defs/util.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts +23 -3
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/index.d.ts +2 -0
- package/dist/types/src/integrations/index.d.ts.map +1 -0
- package/dist/types/src/integrations/thread-ranges.d.ts +7 -0
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +1 -1
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +1 -1
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/{hooks → model}/useSheetModel.d.ts +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/serializer.d.ts +4 -0
- package/dist/types/src/serializer.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +1 -1
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +13 -3
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +4 -30
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +43 -50
- package/src/SheetPlugin.tsx +25 -12
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +19 -2
- package/src/components/FunctionEditor/FunctionEditor.tsx +5 -5
- package/src/components/GridSheet/GridSheet.stories.tsx +3 -1
- package/src/components/GridSheet/GridSheet.tsx +118 -22
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +1 -1
- package/src/components/GridSheet/util.ts +24 -14
- package/src/components/RangeList/RangeList.tsx +53 -0
- package/src/components/RangeList/index.ts +5 -0
- package/src/components/SheetContainer/SheetContainer.stories.tsx +3 -3
- package/src/components/SheetContainer/SheetContainer.tsx +10 -4
- package/src/components/SheetContext/SheetContext.tsx +43 -20
- package/src/components/Toolbar/Toolbar.tsx +44 -41
- package/src/components/index.ts +1 -0
- package/src/{graph → compute-graph}/compute-graph.stories.tsx +2 -1
- package/src/{graph → compute-graph}/compute-graph.ts +5 -2
- package/src/{graph → compute-graph}/compute-node.ts +2 -3
- package/src/defs/index.ts +1 -1
- package/src/defs/sheet-range-types.ts +5 -4
- package/src/defs/types.ts +6 -1
- package/src/defs/util.ts +3 -19
- package/src/extensions/compute.stories.tsx +2 -2
- package/src/extensions/compute.ts +2 -2
- package/src/extensions/editor/extension.test.ts +1 -1
- package/src/extensions/editor/extension.ts +48 -23
- package/src/index.ts +2 -2
- package/src/integrations/index.ts +5 -0
- package/src/integrations/thread-ranges.ts +101 -0
- package/src/model/index.ts +1 -1
- package/src/model/sheet-model.test.ts +1 -1
- package/src/model/sheet-model.ts +13 -8
- package/src/{hooks → model}/useSheetModel.ts +1 -1
- package/src/serializer.ts +27 -0
- package/src/testing/testing.tsx +1 -1
- package/src/translations.ts +13 -3
- package/src/types.ts +4 -2
- package/dist/lib/browser/SheetContainer-AKWROARP.mjs.map +0 -7
- package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FGMFOW6U.mjs.map +0 -7
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-N5IQGEFL.cjs.map +0 -7
- package/dist/lib/node/chunk-53BMSUIK.cjs.map +0 -7
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +0 -7
- package/dist/lib/node/chunk-NZARD7UP.cjs.map +0 -7
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-46PBMF2E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-T3PRH7QS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +0 -7
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/graph/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/graph/util.d.ts.map +0 -1
- package/dist/types/src/hooks/hooks.stories.d.ts +0 -6
- package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -4
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/threads.d.ts +0 -8
- package/dist/types/src/hooks/threads.d.ts.map +0 -1
- package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
- package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
- package/dist/types/src/model/decorations.d.ts +0 -26
- package/dist/types/src/model/decorations.d.ts.map +0 -1
- package/src/hooks/hooks.stories.tsx +0 -53
- package/src/hooks/index.ts +0 -7
- package/src/hooks/threads.ts +0 -147
- package/src/hooks/useComputeGraph.ts +0 -28
- package/src/model/decorations.ts +0 -66
- /package/dist/lib/browser/{graph-M4IQ76QX.mjs.map → compute-graph-SJT67236.mjs.map} +0 -0
- /package/dist/lib/node-esm/{graph-SMPUMOV2.mjs.map → compute-graph-FRCKXEYK.mjs.map} +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph-registry.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph.stories.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-graph.test.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/compute-node.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/async-function.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/edge-function.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/function-defs.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/functions/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/hyperformula.test.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/index.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/test-builder.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/testing/test-plugin.d.ts +0 -0
- /package/dist/types/src/{graph → compute-graph}/util.d.ts +0 -0
- /package/src/{graph → compute-graph}/compute-graph-registry.ts +0 -0
- /package/src/{graph → compute-graph}/compute-graph.test.ts +0 -0
- /package/src/{graph → compute-graph}/functions/async-function.ts +0 -0
- /package/src/{graph → compute-graph}/functions/edge-function.ts +0 -0
- /package/src/{graph → compute-graph}/functions/function-defs.ts +0 -0
- /package/src/{graph → compute-graph}/functions/index.ts +0 -0
- /package/src/{graph → compute-graph}/hyperformula.test.ts +0 -0
- /package/src/{graph → compute-graph}/index.ts +0 -0
- /package/src/{graph → compute-graph}/testing/index.ts +0 -0
- /package/src/{graph → compute-graph}/testing/test-builder.ts +0 -0
- /package/src/{graph → compute-graph}/testing/test-plugin.ts +0 -0
- /package/src/{graph → compute-graph}/util.ts +0 -0
|
@@ -1,21 +1,218 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
SheetType
|
|
4
|
+
} from "./chunk-5TXLF6PL.mjs";
|
|
2
5
|
|
|
3
|
-
// packages/plugins/plugin-sheet/src/graph/compute-graph.ts
|
|
6
|
+
// packages/plugins/plugin-sheet/src/compute-graph/compute-graph.ts
|
|
4
7
|
import { Event as Event2 } from "@dxos/async";
|
|
5
8
|
import { Filter as Filter2, fullyQualifiedId } from "@dxos/client/echo";
|
|
6
9
|
import { Resource as Resource2 } from "@dxos/context";
|
|
7
10
|
import { getTypename } from "@dxos/echo-schema";
|
|
8
|
-
import { invariant } from "@dxos/invariant";
|
|
11
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
9
12
|
import { PublicKey } from "@dxos/keys";
|
|
10
13
|
import { log as log3 } from "@dxos/log";
|
|
11
14
|
import { FunctionType as FunctionType2 } from "@dxos/plugin-script/types";
|
|
12
15
|
import { nonNullable as nonNullable2 } from "@dxos/util";
|
|
13
16
|
import { ExportedCellChange } from "#hyperformula";
|
|
14
17
|
|
|
15
|
-
// packages/plugins/plugin-sheet/src/graph/compute-node.ts
|
|
18
|
+
// packages/plugins/plugin-sheet/src/compute-graph/compute-node.ts
|
|
16
19
|
import { Event } from "@dxos/async";
|
|
17
20
|
import { Resource } from "@dxos/context";
|
|
18
21
|
import { DetailedCellError } from "#hyperformula";
|
|
22
|
+
|
|
23
|
+
// packages/plugins/plugin-sheet/src/defs/sheet-range-types.ts
|
|
24
|
+
var alignKey = "alignment";
|
|
25
|
+
var commentKey = "comment";
|
|
26
|
+
var styleKey = "style";
|
|
27
|
+
var cellClassNameForRange = ({ key, value }) => {
|
|
28
|
+
switch (key) {
|
|
29
|
+
case alignKey:
|
|
30
|
+
switch (value) {
|
|
31
|
+
case "start":
|
|
32
|
+
return "text-start";
|
|
33
|
+
case "center":
|
|
34
|
+
return "text-center";
|
|
35
|
+
case "end":
|
|
36
|
+
return "text-end";
|
|
37
|
+
default:
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
case commentKey:
|
|
41
|
+
return "bg-gridComment";
|
|
42
|
+
case styleKey:
|
|
43
|
+
switch (value) {
|
|
44
|
+
case "highlight":
|
|
45
|
+
return "bg-gridHighlight";
|
|
46
|
+
default:
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
default:
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// packages/plugins/plugin-sheet/src/defs/types.ts
|
|
55
|
+
import { invariant } from "@dxos/invariant";
|
|
56
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/defs/types.ts";
|
|
57
|
+
var DEFAULT_ROWS = 50;
|
|
58
|
+
var DEFAULT_COLUMNS = 26;
|
|
59
|
+
var MAX_ROWS = 500;
|
|
60
|
+
var MAX_COLUMNS = 26 * 2;
|
|
61
|
+
var RANGE_NOTATION = /^[A-Z]+[0-9]+(:[A-Z]+[0-9]+)?$/;
|
|
62
|
+
var isFormula = (value) => typeof value === "string" && value.charAt(0) === "=";
|
|
63
|
+
var posEquals = (a, b) => {
|
|
64
|
+
return a?.col === b?.col && a?.row === b?.row;
|
|
65
|
+
};
|
|
66
|
+
var columnLetter = (col) => {
|
|
67
|
+
invariant(col < MAX_COLUMNS, `Invalid column: ${col}`, {
|
|
68
|
+
F: __dxlog_file,
|
|
69
|
+
L: 31,
|
|
70
|
+
S: void 0,
|
|
71
|
+
A: [
|
|
72
|
+
"col < MAX_COLUMNS",
|
|
73
|
+
"`Invalid column: ${col}`"
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
|
|
77
|
+
};
|
|
78
|
+
var addressToA1Notation = ({ col, row }) => {
|
|
79
|
+
return `${columnLetter(col)}${row + 1}`;
|
|
80
|
+
};
|
|
81
|
+
var addressFromA1Notation = (ref) => {
|
|
82
|
+
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
83
|
+
invariant(match, `Invalid notation: ${ref}`, {
|
|
84
|
+
F: __dxlog_file,
|
|
85
|
+
L: 45,
|
|
86
|
+
S: void 0,
|
|
87
|
+
A: [
|
|
88
|
+
"match",
|
|
89
|
+
"`Invalid notation: ${ref}`"
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
row: parseInt(match[2], 10) - 1,
|
|
94
|
+
col: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
var rangeToA1Notation = (range) => {
|
|
98
|
+
return [
|
|
99
|
+
range?.from && addressToA1Notation(range?.from),
|
|
100
|
+
range?.to && addressToA1Notation(range?.to)
|
|
101
|
+
].filter(Boolean).join(":");
|
|
102
|
+
};
|
|
103
|
+
var inRange = (range, cell) => {
|
|
104
|
+
if (!range) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
const { from, to } = range;
|
|
108
|
+
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
if (!from || !to) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
const { col: c1, row: r1 } = from;
|
|
115
|
+
const { col: c2, row: r2 } = to;
|
|
116
|
+
const cMin = Math.min(c1, c2);
|
|
117
|
+
const cMax = Math.max(c1, c2);
|
|
118
|
+
const rMin = Math.min(r1, r2);
|
|
119
|
+
const rMax = Math.max(r1, r2);
|
|
120
|
+
const { col, row } = cell;
|
|
121
|
+
return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// packages/plugins/plugin-sheet/src/defs/util.ts
|
|
125
|
+
import { randomBytes } from "@dxos/crypto";
|
|
126
|
+
import { create } from "@dxos/echo-schema";
|
|
127
|
+
var ApiError = class extends Error {
|
|
128
|
+
};
|
|
129
|
+
var ReadonlyException = class extends ApiError {
|
|
130
|
+
};
|
|
131
|
+
var RangeException = class extends ApiError {
|
|
132
|
+
constructor(n) {
|
|
133
|
+
super();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var createIndex = (length = 8) => {
|
|
137
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
138
|
+
const charactersLength = characters.length;
|
|
139
|
+
const randomBuffer = randomBytes(length);
|
|
140
|
+
return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
|
|
141
|
+
};
|
|
142
|
+
var createIndices = (length) => Array.from({
|
|
143
|
+
length
|
|
144
|
+
}).map(() => createIndex());
|
|
145
|
+
var insertIndices = (indices, i, n, max) => {
|
|
146
|
+
if (i + n > max) {
|
|
147
|
+
throw new RangeException(i + n);
|
|
148
|
+
}
|
|
149
|
+
const idx = createIndices(n);
|
|
150
|
+
indices.splice(i, 0, ...idx);
|
|
151
|
+
};
|
|
152
|
+
var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}) => {
|
|
153
|
+
if (!sheet.rows.length) {
|
|
154
|
+
insertIndices(sheet.rows, 0, rows, MAX_ROWS);
|
|
155
|
+
}
|
|
156
|
+
if (!sheet.columns.length) {
|
|
157
|
+
insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var createSheet = ({ name, cells, ...size } = {}) => {
|
|
161
|
+
const sheet = create(SheetType, {
|
|
162
|
+
name,
|
|
163
|
+
cells: {},
|
|
164
|
+
rows: [],
|
|
165
|
+
columns: [],
|
|
166
|
+
rowMeta: {},
|
|
167
|
+
columnMeta: {},
|
|
168
|
+
ranges: [],
|
|
169
|
+
threads: []
|
|
170
|
+
});
|
|
171
|
+
initialize(sheet, size);
|
|
172
|
+
if (cells) {
|
|
173
|
+
Object.entries(cells).forEach(([key, { value }]) => {
|
|
174
|
+
const idx = addressToIndex(sheet, addressFromA1Notation(key));
|
|
175
|
+
sheet.cells[idx] = {
|
|
176
|
+
value
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return sheet;
|
|
181
|
+
};
|
|
182
|
+
var addressToIndex = (sheet, cell) => {
|
|
183
|
+
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
184
|
+
};
|
|
185
|
+
var addressFromIndex = (sheet, idx) => {
|
|
186
|
+
const [column, row] = idx.split("@");
|
|
187
|
+
return {
|
|
188
|
+
col: sheet.columns.indexOf(column),
|
|
189
|
+
row: sheet.rows.indexOf(row)
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
var rangeToIndex = (sheet, range) => {
|
|
193
|
+
return [
|
|
194
|
+
range.from,
|
|
195
|
+
range.to ?? range.from
|
|
196
|
+
].map((cell) => addressToIndex(sheet, cell)).join(":");
|
|
197
|
+
};
|
|
198
|
+
var rangeFromIndex = (sheet, idx) => {
|
|
199
|
+
const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
|
|
200
|
+
return {
|
|
201
|
+
from,
|
|
202
|
+
to
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
var compareIndexPositions = (sheet, indexA, indexB) => {
|
|
206
|
+
const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
|
|
207
|
+
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
208
|
+
if (rowA !== rowB) {
|
|
209
|
+
return rowA - rowB;
|
|
210
|
+
} else {
|
|
211
|
+
return columnA - columnB;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// packages/plugins/plugin-sheet/src/compute-graph/compute-node.ts
|
|
19
216
|
var ComputeNode = class extends Resource {
|
|
20
217
|
constructor(_graph, sheetId) {
|
|
21
218
|
super();
|
|
@@ -41,7 +238,7 @@ var ComputeNode = class extends Resource {
|
|
|
41
238
|
return value;
|
|
42
239
|
}
|
|
43
240
|
setValue(cell, value) {
|
|
44
|
-
const mappedValue =
|
|
241
|
+
const mappedValue = isFormula(value) ? this._graph.mapFormulaToNative(value) : value;
|
|
45
242
|
this._graph.hf.setCellContents({
|
|
46
243
|
sheet: this.sheetId,
|
|
47
244
|
row: cell.row,
|
|
@@ -57,12 +254,12 @@ var ComputeNode = class extends Resource {
|
|
|
57
254
|
}
|
|
58
255
|
};
|
|
59
256
|
|
|
60
|
-
// packages/plugins/plugin-sheet/src/graph/functions/async-function.ts
|
|
257
|
+
// packages/plugins/plugin-sheet/src/compute-graph/functions/async-function.ts
|
|
61
258
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
62
259
|
import { debounce } from "@dxos/async";
|
|
63
260
|
import { log } from "@dxos/log";
|
|
64
261
|
import { CellError, ErrorType, EmptyValue, FunctionPlugin } from "#hyperformula";
|
|
65
|
-
var
|
|
262
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/compute-graph/functions/async-function.ts";
|
|
66
263
|
var defaultFunctionContextOptions = {
|
|
67
264
|
defaultTtl: 5e3,
|
|
68
265
|
debounceDelay: 200,
|
|
@@ -136,7 +333,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
136
333
|
cell,
|
|
137
334
|
value: value2
|
|
138
335
|
}, {
|
|
139
|
-
F:
|
|
336
|
+
F: __dxlog_file2,
|
|
140
337
|
L: 143,
|
|
141
338
|
S: this,
|
|
142
339
|
C: (f, a) => f(...a)
|
|
@@ -150,7 +347,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
150
347
|
cell,
|
|
151
348
|
err
|
|
152
349
|
}, {
|
|
153
|
-
F:
|
|
350
|
+
F: __dxlog_file2,
|
|
154
351
|
L: 147,
|
|
155
352
|
S: this,
|
|
156
353
|
C: (f, a) => f(...a)
|
|
@@ -170,7 +367,7 @@ var FunctionContext = class _FunctionContext {
|
|
|
170
367
|
args,
|
|
171
368
|
cache: value
|
|
172
369
|
}, {
|
|
173
|
-
F:
|
|
370
|
+
F: __dxlog_file2,
|
|
174
371
|
L: 155,
|
|
175
372
|
S: this,
|
|
176
373
|
C: (f, a) => f(...a)
|
|
@@ -194,7 +391,7 @@ var AsyncFunctionPlugin = class extends FunctionPlugin {
|
|
|
194
391
|
}
|
|
195
392
|
};
|
|
196
393
|
|
|
197
|
-
// packages/plugins/plugin-sheet/src/graph/functions/edge-function.ts
|
|
394
|
+
// packages/plugins/plugin-sheet/src/compute-graph/functions/edge-function.ts
|
|
198
395
|
import { effect } from "@preact/signals-core";
|
|
199
396
|
import { Filter, getMeta } from "@dxos/client/echo";
|
|
200
397
|
import { log as log2 } from "@dxos/log";
|
|
@@ -202,7 +399,7 @@ import { getUserFunctionUrlInMetadata } from "@dxos/plugin-script/edge";
|
|
|
202
399
|
import { FunctionType } from "@dxos/plugin-script/types";
|
|
203
400
|
import { nonNullable } from "@dxos/util";
|
|
204
401
|
import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "#hyperformula";
|
|
205
|
-
var
|
|
402
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/compute-graph/functions/edge-function.ts";
|
|
206
403
|
var EDGE_FUNCTION_NAME = "DX";
|
|
207
404
|
var FUNCTION_TTL = 1e4;
|
|
208
405
|
var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
@@ -219,7 +416,7 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
219
416
|
log2.info("Function not found", {
|
|
220
417
|
binding
|
|
221
418
|
}, {
|
|
222
|
-
F:
|
|
419
|
+
F: __dxlog_file3,
|
|
223
420
|
L: 41,
|
|
224
421
|
S: this,
|
|
225
422
|
C: (f, a) => f(...a)
|
|
@@ -231,7 +428,7 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
|
|
|
231
428
|
log2.info("function changed", {
|
|
232
429
|
fn
|
|
233
430
|
}, {
|
|
234
|
-
F:
|
|
431
|
+
F: __dxlog_file3,
|
|
235
432
|
L: 47,
|
|
236
433
|
S: this,
|
|
237
434
|
C: (f, a) => f(...a)
|
|
@@ -314,7 +511,7 @@ var EdgeFunctionPluginTranslations = {
|
|
|
314
511
|
}
|
|
315
512
|
};
|
|
316
513
|
|
|
317
|
-
// packages/plugins/plugin-sheet/src/graph/functions/function-defs.ts
|
|
514
|
+
// packages/plugins/plugin-sheet/src/compute-graph/functions/function-defs.ts
|
|
318
515
|
var defaultFunctions = [
|
|
319
516
|
// Array
|
|
320
517
|
{
|
|
@@ -2688,8 +2885,8 @@ var defaultFunctions = [
|
|
|
2688
2885
|
}
|
|
2689
2886
|
];
|
|
2690
2887
|
|
|
2691
|
-
// packages/plugins/plugin-sheet/src/graph/compute-graph.ts
|
|
2692
|
-
var
|
|
2888
|
+
// packages/plugins/plugin-sheet/src/compute-graph/compute-graph.ts
|
|
2889
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/compute-graph/compute-graph.ts";
|
|
2693
2890
|
var OBJECT_ID_LENGTH = 60;
|
|
2694
2891
|
var createSheetName = ({ type, id }) => `${type}@${id}`;
|
|
2695
2892
|
var parseSheetName = (name) => {
|
|
@@ -2757,9 +2954,9 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2757
2954
|
// E.g., Cross-object reference would be stored as "ObjectId!A1"
|
|
2758
2955
|
// The graph would then load the object and create a ComputeNode (model) of the appropriate type.
|
|
2759
2956
|
getOrCreateNode(name) {
|
|
2760
|
-
|
|
2761
|
-
F:
|
|
2762
|
-
L:
|
|
2957
|
+
invariant2(name.length, void 0, {
|
|
2958
|
+
F: __dxlog_file4,
|
|
2959
|
+
L: 120,
|
|
2763
2960
|
S: this,
|
|
2764
2961
|
A: [
|
|
2765
2962
|
"name.length",
|
|
@@ -2767,21 +2964,21 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2767
2964
|
]
|
|
2768
2965
|
});
|
|
2769
2966
|
if (!this._hf.doesSheetExist(name)) {
|
|
2770
|
-
log3
|
|
2967
|
+
log3("created node", {
|
|
2771
2968
|
space: this._space?.id,
|
|
2772
2969
|
sheet: name
|
|
2773
2970
|
}, {
|
|
2774
|
-
F:
|
|
2775
|
-
L:
|
|
2971
|
+
F: __dxlog_file4,
|
|
2972
|
+
L: 122,
|
|
2776
2973
|
S: this,
|
|
2777
2974
|
C: (f, a) => f(...a)
|
|
2778
2975
|
});
|
|
2779
2976
|
this._hf.addSheet(name);
|
|
2780
2977
|
}
|
|
2781
2978
|
const sheetId = this._hf.getSheetId(name);
|
|
2782
|
-
|
|
2783
|
-
F:
|
|
2784
|
-
L:
|
|
2979
|
+
invariant2(sheetId !== void 0, void 0, {
|
|
2980
|
+
F: __dxlog_file4,
|
|
2981
|
+
L: 127,
|
|
2785
2982
|
S: this,
|
|
2786
2983
|
A: [
|
|
2787
2984
|
"sheetId !== undefined",
|
|
@@ -2794,7 +2991,7 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2794
2991
|
}
|
|
2795
2992
|
/**
|
|
2796
2993
|
* Map bound value to custom function invocation.
|
|
2797
|
-
* E.g., "HELLO(...args)" => "
|
|
2994
|
+
* E.g., "HELLO(...args)" => "DX("HELLO", ...args)".
|
|
2798
2995
|
*/
|
|
2799
2996
|
mapFormulaToNative(formula) {
|
|
2800
2997
|
return formula.replace(/['"]?([ \w]+)['"]?!/, (_match, name) => {
|
|
@@ -2881,13 +3078,13 @@ var ComputeGraph = class extends Resource2 {
|
|
|
2881
3078
|
}
|
|
2882
3079
|
};
|
|
2883
3080
|
|
|
2884
|
-
// packages/plugins/plugin-sheet/src/graph/compute-graph-registry.ts
|
|
3081
|
+
// packages/plugins/plugin-sheet/src/compute-graph/compute-graph-registry.ts
|
|
2885
3082
|
import defaultsDeep2 from "lodash.defaultsdeep";
|
|
2886
3083
|
import { Resource as Resource3 } from "@dxos/context";
|
|
2887
|
-
import { invariant as
|
|
3084
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2888
3085
|
import { log as log4 } from "@dxos/log";
|
|
2889
3086
|
import { HyperFormula } from "#hyperformula";
|
|
2890
|
-
var
|
|
3087
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/compute-graph/compute-graph-registry.ts";
|
|
2891
3088
|
var defaultOptions = {
|
|
2892
3089
|
licenseKey: "gpl-v3"
|
|
2893
3090
|
};
|
|
@@ -2917,7 +3114,7 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
2917
3114
|
log4("create graph", {
|
|
2918
3115
|
space: space.id
|
|
2919
3116
|
}, {
|
|
2920
|
-
F:
|
|
3117
|
+
F: __dxlog_file5,
|
|
2921
3118
|
L: 69,
|
|
2922
3119
|
S: this,
|
|
2923
3120
|
C: (f, a) => f(...a)
|
|
@@ -2927,8 +3124,8 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
2927
3124
|
return graph;
|
|
2928
3125
|
}
|
|
2929
3126
|
createGraph(space) {
|
|
2930
|
-
|
|
2931
|
-
F:
|
|
3127
|
+
invariant3(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`, {
|
|
3128
|
+
F: __dxlog_file5,
|
|
2932
3129
|
L: 77,
|
|
2933
3130
|
S: this,
|
|
2934
3131
|
A: [
|
|
@@ -2950,6 +3147,27 @@ var ComputeGraphRegistry = class extends Resource3 {
|
|
|
2950
3147
|
};
|
|
2951
3148
|
|
|
2952
3149
|
export {
|
|
3150
|
+
alignKey,
|
|
3151
|
+
cellClassNameForRange,
|
|
3152
|
+
DEFAULT_ROWS,
|
|
3153
|
+
DEFAULT_COLUMNS,
|
|
3154
|
+
MAX_ROWS,
|
|
3155
|
+
MAX_COLUMNS,
|
|
3156
|
+
RANGE_NOTATION,
|
|
3157
|
+
isFormula,
|
|
3158
|
+
addressToA1Notation,
|
|
3159
|
+
addressFromA1Notation,
|
|
3160
|
+
rangeToA1Notation,
|
|
3161
|
+
inRange,
|
|
3162
|
+
ReadonlyException,
|
|
3163
|
+
insertIndices,
|
|
3164
|
+
initialize,
|
|
3165
|
+
createSheet,
|
|
3166
|
+
addressToIndex,
|
|
3167
|
+
addressFromIndex,
|
|
3168
|
+
rangeToIndex,
|
|
3169
|
+
rangeFromIndex,
|
|
3170
|
+
compareIndexPositions,
|
|
2953
3171
|
ComputeNode,
|
|
2954
3172
|
defaultFunctionContextOptions,
|
|
2955
3173
|
FunctionContext,
|
|
@@ -2965,4 +3183,4 @@ export {
|
|
|
2965
3183
|
defaultPlugins,
|
|
2966
3184
|
ComputeGraphRegistry
|
|
2967
3185
|
};
|
|
2968
|
-
//# sourceMappingURL=chunk-
|
|
3186
|
+
//# sourceMappingURL=chunk-XBEHKYO7.mjs.map
|