@dxos/plugin-sheet 0.6.14-main.7bd9c89 → 0.6.14-staging.9e90729

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.
Files changed (208) hide show
  1. package/dist/lib/browser/{SheetContainer-AKWROARP.mjs → SheetContainer-JBB7W52Y.mjs} +42 -52
  2. package/dist/lib/browser/SheetContainer-JBB7W52Y.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-GSV5QNLD.mjs → chunk-2ZK3YMZG.mjs} +248 -33
  4. package/dist/lib/browser/{chunk-GSV5QNLD.mjs.map → chunk-2ZK3YMZG.mjs.map} +4 -4
  5. package/dist/lib/browser/{chunk-BWN5DZWZ.mjs → chunk-3QWIMZZJ.mjs} +2 -11
  6. package/dist/lib/browser/chunk-3QWIMZZJ.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-FGMFOW6U.mjs → chunk-XXDHBYZQ.mjs} +553 -668
  8. package/dist/lib/browser/chunk-XXDHBYZQ.mjs.map +7 -0
  9. package/dist/lib/browser/{graph-M4IQ76QX.mjs → compute-graph-ZQKB6QVP.mjs} +4 -2
  10. package/dist/lib/browser/index.mjs +57 -14
  11. package/dist/lib/browser/index.mjs.map +4 -4
  12. package/dist/lib/browser/meta.json +1 -1
  13. package/dist/lib/browser/types.mjs +1 -1
  14. package/dist/lib/node/{SheetContainer-N5IQGEFL.cjs → SheetContainer-L37HUFCF.cjs} +44 -58
  15. package/dist/lib/node/SheetContainer-L37HUFCF.cjs.map +7 -0
  16. package/dist/lib/node/{chunk-53BMSUIK.cjs → chunk-7AWAC3R3.cjs} +517 -645
  17. package/dist/lib/node/chunk-7AWAC3R3.cjs.map +7 -0
  18. package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-QNFMTK3X.cjs} +252 -28
  19. package/dist/lib/node/{chunk-5XPK2V4A.cjs.map → chunk-QNFMTK3X.cjs.map} +4 -4
  20. package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-V7E5JZBD.cjs} +5 -14
  21. package/dist/lib/node/chunk-V7E5JZBD.cjs.map +7 -0
  22. package/dist/lib/node/{graph-Q3N2X26H.cjs → compute-graph-RJB6OVW6.cjs} +21 -19
  23. package/dist/lib/node/compute-graph-RJB6OVW6.cjs.map +7 -0
  24. package/dist/lib/node/index.cjs +66 -27
  25. package/dist/lib/node/index.cjs.map +4 -4
  26. package/dist/lib/node/meta.json +1 -1
  27. package/dist/lib/node/types.cjs +6 -6
  28. package/dist/lib/node/types.cjs.map +1 -1
  29. package/dist/lib/node-esm/{SheetContainer-46PBMF2E.mjs → SheetContainer-CLKFEM35.mjs} +42 -52
  30. package/dist/lib/node-esm/SheetContainer-CLKFEM35.mjs.map +7 -0
  31. package/dist/lib/node-esm/{chunk-T3PRH7QS.mjs → chunk-3JYJEOCF.mjs} +553 -668
  32. package/dist/lib/node-esm/chunk-3JYJEOCF.mjs.map +7 -0
  33. package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs → chunk-JBTORSST.mjs} +247 -33
  34. package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs.map → chunk-JBTORSST.mjs.map} +4 -4
  35. package/dist/lib/node-esm/{chunk-WFDTY3IC.mjs → chunk-SPQFLYC2.mjs} +2 -11
  36. package/dist/lib/node-esm/chunk-SPQFLYC2.mjs.map +7 -0
  37. package/dist/lib/node-esm/{graph-SMPUMOV2.mjs → compute-graph-VKRG526N.mjs} +4 -2
  38. package/dist/lib/node-esm/index.mjs +57 -14
  39. package/dist/lib/node-esm/index.mjs.map +4 -4
  40. package/dist/lib/node-esm/meta.json +1 -1
  41. package/dist/lib/node-esm/types.mjs +1 -1
  42. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  43. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +3 -1
  44. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
  45. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  46. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
  47. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  48. package/dist/types/src/components/RangeList/RangeList.d.ts +9 -0
  49. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -0
  50. package/dist/types/src/components/RangeList/index.d.ts +2 -0
  51. package/dist/types/src/components/RangeList/index.d.ts.map +1 -0
  52. package/dist/types/src/components/SheetContext/SheetContext.d.ts +7 -5
  53. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  54. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  55. package/dist/types/src/components/index.d.ts +1 -0
  56. package/dist/types/src/components/index.d.ts.map +1 -1
  57. package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +1 -0
  58. package/dist/types/src/{graph → compute-graph}/compute-graph.d.ts +1 -1
  59. package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -0
  60. package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +1 -0
  61. package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +1 -0
  62. package/dist/types/src/compute-graph/compute-node.d.ts.map +1 -0
  63. package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -0
  64. package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -0
  65. package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +1 -0
  66. package/dist/types/src/compute-graph/functions/index.d.ts.map +1 -0
  67. package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +1 -0
  68. package/dist/types/src/compute-graph/index.d.ts.map +1 -0
  69. package/dist/types/src/compute-graph/testing/index.d.ts.map +1 -0
  70. package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +1 -0
  71. package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +1 -0
  72. package/dist/types/src/compute-graph/util.d.ts.map +1 -0
  73. package/dist/types/src/defs/index.d.ts +1 -1
  74. package/dist/types/src/defs/index.d.ts.map +1 -1
  75. package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -1
  76. package/dist/types/src/defs/types.d.ts +6 -0
  77. package/dist/types/src/defs/types.d.ts.map +1 -1
  78. package/dist/types/src/defs/util.d.ts +2 -6
  79. package/dist/types/src/defs/util.d.ts.map +1 -1
  80. package/dist/types/src/extensions/compute.d.ts +1 -1
  81. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  82. package/dist/types/src/extensions/editor/extension.d.ts +23 -3
  83. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
  84. package/dist/types/src/index.d.ts +1 -1
  85. package/dist/types/src/index.d.ts.map +1 -1
  86. package/dist/types/src/integrations/index.d.ts +2 -0
  87. package/dist/types/src/integrations/index.d.ts.map +1 -0
  88. package/dist/types/src/integrations/thread-ranges.d.ts +8 -0
  89. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -0
  90. package/dist/types/src/model/index.d.ts +1 -1
  91. package/dist/types/src/model/index.d.ts.map +1 -1
  92. package/dist/types/src/model/sheet-model.d.ts +1 -1
  93. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  94. package/dist/types/src/{hooks → model}/useSheetModel.d.ts +1 -1
  95. package/dist/types/src/model/useSheetModel.d.ts.map +1 -0
  96. package/dist/types/src/serializer.d.ts +4 -0
  97. package/dist/types/src/serializer.d.ts.map +1 -0
  98. package/dist/types/src/testing/testing.d.ts +1 -1
  99. package/dist/types/src/testing/testing.d.ts.map +1 -1
  100. package/dist/types/src/translations.d.ts +6 -0
  101. package/dist/types/src/translations.d.ts.map +1 -1
  102. package/dist/types/src/types.d.ts +4 -30
  103. package/dist/types/src/types.d.ts.map +1 -1
  104. package/package.json +43 -50
  105. package/src/SheetPlugin.tsx +23 -10
  106. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +19 -2
  107. package/src/components/FunctionEditor/FunctionEditor.tsx +5 -5
  108. package/src/components/GridSheet/GridSheet.stories.tsx +3 -1
  109. package/src/components/GridSheet/GridSheet.tsx +114 -19
  110. package/src/components/GridSheet/SheetCellEditor.stories.tsx +1 -1
  111. package/src/components/GridSheet/util.ts +17 -7
  112. package/src/components/RangeList/RangeList.tsx +38 -0
  113. package/src/components/RangeList/index.ts +5 -0
  114. package/src/components/SheetContainer/SheetContainer.stories.tsx +1 -1
  115. package/src/components/SheetContext/SheetContext.tsx +43 -20
  116. package/src/components/Toolbar/Toolbar.tsx +34 -35
  117. package/src/components/index.ts +1 -0
  118. package/src/{graph → compute-graph}/compute-graph.stories.tsx +2 -1
  119. package/src/{graph → compute-graph}/compute-graph.ts +5 -2
  120. package/src/{graph → compute-graph}/compute-node.ts +2 -3
  121. package/src/defs/index.ts +1 -1
  122. package/src/defs/sheet-range-types.ts +1 -0
  123. package/src/defs/types.ts +6 -1
  124. package/src/defs/util.ts +3 -19
  125. package/src/extensions/compute.stories.tsx +2 -2
  126. package/src/extensions/compute.ts +2 -2
  127. package/src/extensions/editor/extension.test.ts +1 -1
  128. package/src/extensions/editor/extension.ts +48 -23
  129. package/src/index.ts +2 -2
  130. package/src/integrations/index.ts +5 -0
  131. package/src/integrations/thread-ranges.ts +101 -0
  132. package/src/model/index.ts +1 -1
  133. package/src/model/sheet-model.test.ts +1 -1
  134. package/src/model/sheet-model.ts +13 -8
  135. package/src/{hooks → model}/useSheetModel.ts +1 -1
  136. package/src/serializer.ts +27 -0
  137. package/src/testing/testing.tsx +1 -1
  138. package/src/translations.ts +6 -0
  139. package/src/types.ts +3 -1
  140. package/dist/lib/browser/SheetContainer-AKWROARP.mjs.map +0 -7
  141. package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +0 -7
  142. package/dist/lib/browser/chunk-FGMFOW6U.mjs.map +0 -7
  143. package/dist/lib/node/SheetContainer-N5IQGEFL.cjs.map +0 -7
  144. package/dist/lib/node/chunk-53BMSUIK.cjs.map +0 -7
  145. package/dist/lib/node/chunk-NZARD7UP.cjs.map +0 -7
  146. package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
  147. package/dist/lib/node-esm/SheetContainer-46PBMF2E.mjs.map +0 -7
  148. package/dist/lib/node-esm/chunk-T3PRH7QS.mjs.map +0 -7
  149. package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +0 -7
  150. package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
  151. package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
  152. package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
  153. package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
  154. package/dist/types/src/graph/compute-node.d.ts.map +0 -1
  155. package/dist/types/src/graph/functions/async-function.d.ts.map +0 -1
  156. package/dist/types/src/graph/functions/edge-function.d.ts.map +0 -1
  157. package/dist/types/src/graph/functions/function-defs.d.ts.map +0 -1
  158. package/dist/types/src/graph/functions/index.d.ts.map +0 -1
  159. package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
  160. package/dist/types/src/graph/index.d.ts.map +0 -1
  161. package/dist/types/src/graph/testing/index.d.ts.map +0 -1
  162. package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
  163. package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
  164. package/dist/types/src/graph/util.d.ts.map +0 -1
  165. package/dist/types/src/hooks/hooks.stories.d.ts +0 -6
  166. package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
  167. package/dist/types/src/hooks/index.d.ts +0 -4
  168. package/dist/types/src/hooks/index.d.ts.map +0 -1
  169. package/dist/types/src/hooks/threads.d.ts +0 -8
  170. package/dist/types/src/hooks/threads.d.ts.map +0 -1
  171. package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
  172. package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
  173. package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
  174. package/dist/types/src/model/decorations.d.ts +0 -26
  175. package/dist/types/src/model/decorations.d.ts.map +0 -1
  176. package/src/hooks/hooks.stories.tsx +0 -53
  177. package/src/hooks/index.ts +0 -7
  178. package/src/hooks/threads.ts +0 -147
  179. package/src/hooks/useComputeGraph.ts +0 -28
  180. package/src/model/decorations.ts +0 -66
  181. /package/dist/lib/browser/{graph-M4IQ76QX.mjs.map → compute-graph-ZQKB6QVP.mjs.map} +0 -0
  182. /package/dist/lib/node-esm/{graph-SMPUMOV2.mjs.map → compute-graph-VKRG526N.mjs.map} +0 -0
  183. /package/dist/types/src/{graph → compute-graph}/compute-graph-registry.d.ts +0 -0
  184. /package/dist/types/src/{graph → compute-graph}/compute-graph.stories.d.ts +0 -0
  185. /package/dist/types/src/{graph → compute-graph}/compute-graph.test.d.ts +0 -0
  186. /package/dist/types/src/{graph → compute-graph}/compute-node.d.ts +0 -0
  187. /package/dist/types/src/{graph → compute-graph}/functions/async-function.d.ts +0 -0
  188. /package/dist/types/src/{graph → compute-graph}/functions/edge-function.d.ts +0 -0
  189. /package/dist/types/src/{graph → compute-graph}/functions/function-defs.d.ts +0 -0
  190. /package/dist/types/src/{graph → compute-graph}/functions/index.d.ts +0 -0
  191. /package/dist/types/src/{graph → compute-graph}/hyperformula.test.d.ts +0 -0
  192. /package/dist/types/src/{graph → compute-graph}/index.d.ts +0 -0
  193. /package/dist/types/src/{graph → compute-graph}/testing/index.d.ts +0 -0
  194. /package/dist/types/src/{graph → compute-graph}/testing/test-builder.d.ts +0 -0
  195. /package/dist/types/src/{graph → compute-graph}/testing/test-plugin.d.ts +0 -0
  196. /package/dist/types/src/{graph → compute-graph}/util.d.ts +0 -0
  197. /package/src/{graph → compute-graph}/compute-graph-registry.ts +0 -0
  198. /package/src/{graph → compute-graph}/compute-graph.test.ts +0 -0
  199. /package/src/{graph → compute-graph}/functions/async-function.ts +0 -0
  200. /package/src/{graph → compute-graph}/functions/edge-function.ts +0 -0
  201. /package/src/{graph → compute-graph}/functions/function-defs.ts +0 -0
  202. /package/src/{graph → compute-graph}/functions/index.ts +0 -0
  203. /package/src/{graph → compute-graph}/hyperformula.test.ts +0 -0
  204. /package/src/{graph → compute-graph}/index.ts +0 -0
  205. /package/src/{graph → compute-graph}/testing/index.ts +0 -0
  206. /package/src/{graph → compute-graph}/testing/test-builder.ts +0 -0
  207. /package/src/{graph → compute-graph}/testing/test-plugin.ts +0 -0
  208. /package/src/{graph → compute-graph}/util.ts +0 -0
@@ -1,19 +1,214 @@
1
- // packages/plugins/plugin-sheet/src/graph/compute-graph.ts
1
+ import {
2
+ SheetType
3
+ } from "./chunk-3QWIMZZJ.mjs";
4
+
5
+ // packages/plugins/plugin-sheet/src/compute-graph/compute-graph.ts
2
6
  import { Event as Event2 } from "@dxos/async";
3
7
  import { Filter as Filter2, fullyQualifiedId } from "@dxos/client/echo";
4
8
  import { Resource as Resource2 } from "@dxos/context";
5
9
  import { getTypename } from "@dxos/echo-schema";
6
- import { invariant } from "@dxos/invariant";
10
+ import { invariant as invariant2 } from "@dxos/invariant";
7
11
  import { PublicKey } from "@dxos/keys";
8
12
  import { log as log3 } from "@dxos/log";
9
13
  import { FunctionType as FunctionType2 } from "@dxos/plugin-script/types";
10
14
  import { nonNullable as nonNullable2 } from "@dxos/util";
11
15
  import { ExportedCellChange } from "#hyperformula";
12
16
 
13
- // packages/plugins/plugin-sheet/src/graph/compute-node.ts
17
+ // packages/plugins/plugin-sheet/src/compute-graph/compute-node.ts
14
18
  import { Event } from "@dxos/async";
15
19
  import { Resource } from "@dxos/context";
16
20
  import { DetailedCellError } from "#hyperformula";
21
+
22
+ // packages/plugins/plugin-sheet/src/defs/sheet-range-types.ts
23
+ var cellClassNameForRange = ({ key, value }) => {
24
+ switch (key) {
25
+ case "align":
26
+ switch (value) {
27
+ case "start":
28
+ return "text-start";
29
+ case "center":
30
+ return "text-center";
31
+ case "end":
32
+ return "text-end";
33
+ default:
34
+ return void 0;
35
+ }
36
+ case "comment":
37
+ return "bg-gridComment";
38
+ case "style":
39
+ switch (value) {
40
+ case "highlight":
41
+ return "bg-gridHighlight";
42
+ default:
43
+ return void 0;
44
+ }
45
+ default:
46
+ return void 0;
47
+ }
48
+ };
49
+
50
+ // packages/plugins/plugin-sheet/src/defs/types.ts
51
+ import { invariant } from "@dxos/invariant";
52
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/defs/types.ts";
53
+ var DEFAULT_ROWS = 50;
54
+ var DEFAULT_COLUMNS = 26;
55
+ var MAX_ROWS = 500;
56
+ var MAX_COLUMNS = 26 * 2;
57
+ var RANGE_NOTATION = /^[A-Z]+[0-9]+(:[A-Z]+[0-9]+)?$/;
58
+ var isFormula = (value) => typeof value === "string" && value.charAt(0) === "=";
59
+ var posEquals = (a, b) => {
60
+ return a?.col === b?.col && a?.row === b?.row;
61
+ };
62
+ var columnLetter = (col) => {
63
+ invariant(col < MAX_COLUMNS, `Invalid column: ${col}`, {
64
+ F: __dxlog_file,
65
+ L: 31,
66
+ S: void 0,
67
+ A: [
68
+ "col < MAX_COLUMNS",
69
+ "`Invalid column: ${col}`"
70
+ ]
71
+ });
72
+ return (col >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(col / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + col % 26);
73
+ };
74
+ var addressToA1Notation = ({ col, row }) => {
75
+ return `${columnLetter(col)}${row + 1}`;
76
+ };
77
+ var addressFromA1Notation = (ref) => {
78
+ const match = ref.match(/([A-Z]+)(\d+)/);
79
+ invariant(match, `Invalid notation: ${ref}`, {
80
+ F: __dxlog_file,
81
+ L: 45,
82
+ S: void 0,
83
+ A: [
84
+ "match",
85
+ "`Invalid notation: ${ref}`"
86
+ ]
87
+ });
88
+ return {
89
+ row: parseInt(match[2], 10) - 1,
90
+ col: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
91
+ };
92
+ };
93
+ var rangeToA1Notation = (range) => {
94
+ return [
95
+ range?.from && addressToA1Notation(range?.from),
96
+ range?.to && addressToA1Notation(range?.to)
97
+ ].filter(Boolean).join(":");
98
+ };
99
+ var inRange = (range, cell) => {
100
+ if (!range) {
101
+ return false;
102
+ }
103
+ const { from, to } = range;
104
+ if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
105
+ return true;
106
+ }
107
+ if (!from || !to) {
108
+ return false;
109
+ }
110
+ const { col: c1, row: r1 } = from;
111
+ const { col: c2, row: r2 } = to;
112
+ const cMin = Math.min(c1, c2);
113
+ const cMax = Math.max(c1, c2);
114
+ const rMin = Math.min(r1, r2);
115
+ const rMax = Math.max(r1, r2);
116
+ const { col, row } = cell;
117
+ return col >= cMin && col <= cMax && row >= rMin && row <= rMax;
118
+ };
119
+
120
+ // packages/plugins/plugin-sheet/src/defs/util.ts
121
+ import { randomBytes } from "@dxos/crypto";
122
+ import { create } from "@dxos/echo-schema";
123
+ var ApiError = class extends Error {
124
+ };
125
+ var ReadonlyException = class extends ApiError {
126
+ };
127
+ var RangeException = class extends ApiError {
128
+ constructor(n) {
129
+ super();
130
+ }
131
+ };
132
+ var createIndex = (length = 8) => {
133
+ const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
134
+ const charactersLength = characters.length;
135
+ const randomBuffer = randomBytes(length);
136
+ return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join("");
137
+ };
138
+ var createIndices = (length) => Array.from({
139
+ length
140
+ }).map(() => createIndex());
141
+ var insertIndices = (indices, i, n, max) => {
142
+ if (i + n > max) {
143
+ throw new RangeException(i + n);
144
+ }
145
+ const idx = createIndices(n);
146
+ indices.splice(i, 0, ...idx);
147
+ };
148
+ var initialize = (sheet, { rows = DEFAULT_ROWS, columns = DEFAULT_COLUMNS } = {}) => {
149
+ if (!sheet.rows.length) {
150
+ insertIndices(sheet.rows, 0, rows, MAX_ROWS);
151
+ }
152
+ if (!sheet.columns.length) {
153
+ insertIndices(sheet.columns, 0, columns, MAX_COLUMNS);
154
+ }
155
+ };
156
+ var createSheet = ({ name, cells, ...size } = {}) => {
157
+ const sheet = create(SheetType, {
158
+ name,
159
+ cells: {},
160
+ rows: [],
161
+ columns: [],
162
+ rowMeta: {},
163
+ columnMeta: {},
164
+ ranges: [],
165
+ threads: []
166
+ });
167
+ initialize(sheet, size);
168
+ if (cells) {
169
+ Object.entries(cells).forEach(([key, { value }]) => {
170
+ const idx = addressToIndex(sheet, addressFromA1Notation(key));
171
+ sheet.cells[idx] = {
172
+ value
173
+ };
174
+ });
175
+ }
176
+ return sheet;
177
+ };
178
+ var addressToIndex = (sheet, cell) => {
179
+ return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
180
+ };
181
+ var addressFromIndex = (sheet, idx) => {
182
+ const [column, row] = idx.split("@");
183
+ return {
184
+ col: sheet.columns.indexOf(column),
185
+ row: sheet.rows.indexOf(row)
186
+ };
187
+ };
188
+ var rangeToIndex = (sheet, range) => {
189
+ return [
190
+ range.from,
191
+ range.to ?? range.from
192
+ ].map((cell) => addressToIndex(sheet, cell)).join(":");
193
+ };
194
+ var rangeFromIndex = (sheet, idx) => {
195
+ const [from, to] = idx.split(":").map((index) => addressFromIndex(sheet, index));
196
+ return {
197
+ from,
198
+ to
199
+ };
200
+ };
201
+ var compareIndexPositions = (sheet, indexA, indexB) => {
202
+ const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
203
+ const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
204
+ if (rowA !== rowB) {
205
+ return rowA - rowB;
206
+ } else {
207
+ return columnA - columnB;
208
+ }
209
+ };
210
+
211
+ // packages/plugins/plugin-sheet/src/compute-graph/compute-node.ts
17
212
  var ComputeNode = class extends Resource {
18
213
  constructor(_graph, sheetId) {
19
214
  super();
@@ -39,7 +234,7 @@ var ComputeNode = class extends Resource {
39
234
  return value;
40
235
  }
41
236
  setValue(cell, value) {
42
- const mappedValue = typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value;
237
+ const mappedValue = isFormula(value) ? this._graph.mapFormulaToNative(value) : value;
43
238
  this._graph.hf.setCellContents({
44
239
  sheet: this.sheetId,
45
240
  row: cell.row,
@@ -55,12 +250,12 @@ var ComputeNode = class extends Resource {
55
250
  }
56
251
  };
57
252
 
58
- // packages/plugins/plugin-sheet/src/graph/functions/async-function.ts
253
+ // packages/plugins/plugin-sheet/src/compute-graph/functions/async-function.ts
59
254
  import defaultsDeep from "lodash.defaultsdeep";
60
255
  import { debounce } from "@dxos/async";
61
256
  import { log } from "@dxos/log";
62
257
  import { CellError, ErrorType, EmptyValue, FunctionPlugin } from "#hyperformula";
63
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/functions/async-function.ts";
258
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/compute-graph/functions/async-function.ts";
64
259
  var defaultFunctionContextOptions = {
65
260
  defaultTtl: 5e3,
66
261
  debounceDelay: 200,
@@ -134,7 +329,7 @@ var FunctionContext = class _FunctionContext {
134
329
  cell,
135
330
  value: value2
136
331
  }, {
137
- F: __dxlog_file,
332
+ F: __dxlog_file2,
138
333
  L: 143,
139
334
  S: this,
140
335
  C: (f, a) => f(...a)
@@ -148,7 +343,7 @@ var FunctionContext = class _FunctionContext {
148
343
  cell,
149
344
  err
150
345
  }, {
151
- F: __dxlog_file,
346
+ F: __dxlog_file2,
152
347
  L: 147,
153
348
  S: this,
154
349
  C: (f, a) => f(...a)
@@ -168,7 +363,7 @@ var FunctionContext = class _FunctionContext {
168
363
  args,
169
364
  cache: value
170
365
  }, {
171
- F: __dxlog_file,
366
+ F: __dxlog_file2,
172
367
  L: 155,
173
368
  S: this,
174
369
  C: (f, a) => f(...a)
@@ -192,7 +387,7 @@ var AsyncFunctionPlugin = class extends FunctionPlugin {
192
387
  }
193
388
  };
194
389
 
195
- // packages/plugins/plugin-sheet/src/graph/functions/edge-function.ts
390
+ // packages/plugins/plugin-sheet/src/compute-graph/functions/edge-function.ts
196
391
  import { effect } from "@preact/signals-core";
197
392
  import { Filter, getMeta } from "@dxos/client/echo";
198
393
  import { log as log2 } from "@dxos/log";
@@ -200,7 +395,7 @@ import { getUserFunctionUrlInMetadata } from "@dxos/plugin-script/edge";
200
395
  import { FunctionType } from "@dxos/plugin-script/types";
201
396
  import { nonNullable } from "@dxos/util";
202
397
  import { CellError as CellError2, ErrorType as ErrorType2, FunctionArgumentType } from "#hyperformula";
203
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/functions/edge-function.ts";
398
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/compute-graph/functions/edge-function.ts";
204
399
  var EDGE_FUNCTION_NAME = "DX";
205
400
  var FUNCTION_TTL = 1e4;
206
401
  var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
@@ -217,7 +412,7 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
217
412
  log2.info("Function not found", {
218
413
  binding
219
414
  }, {
220
- F: __dxlog_file2,
415
+ F: __dxlog_file3,
221
416
  L: 41,
222
417
  S: this,
223
418
  C: (f, a) => f(...a)
@@ -229,7 +424,7 @@ var EdgeFunctionPlugin = class extends AsyncFunctionPlugin {
229
424
  log2.info("function changed", {
230
425
  fn
231
426
  }, {
232
- F: __dxlog_file2,
427
+ F: __dxlog_file3,
233
428
  L: 47,
234
429
  S: this,
235
430
  C: (f, a) => f(...a)
@@ -312,7 +507,7 @@ var EdgeFunctionPluginTranslations = {
312
507
  }
313
508
  };
314
509
 
315
- // packages/plugins/plugin-sheet/src/graph/functions/function-defs.ts
510
+ // packages/plugins/plugin-sheet/src/compute-graph/functions/function-defs.ts
316
511
  var defaultFunctions = [
317
512
  // Array
318
513
  {
@@ -2686,8 +2881,8 @@ var defaultFunctions = [
2686
2881
  }
2687
2882
  ];
2688
2883
 
2689
- // packages/plugins/plugin-sheet/src/graph/compute-graph.ts
2690
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/compute-graph.ts";
2884
+ // packages/plugins/plugin-sheet/src/compute-graph/compute-graph.ts
2885
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/compute-graph/compute-graph.ts";
2691
2886
  var OBJECT_ID_LENGTH = 60;
2692
2887
  var createSheetName = ({ type, id }) => `${type}@${id}`;
2693
2888
  var parseSheetName = (name) => {
@@ -2755,9 +2950,9 @@ var ComputeGraph = class extends Resource2 {
2755
2950
  // E.g., Cross-object reference would be stored as "ObjectId!A1"
2756
2951
  // The graph would then load the object and create a ComputeNode (model) of the appropriate type.
2757
2952
  getOrCreateNode(name) {
2758
- invariant(name.length, void 0, {
2759
- F: __dxlog_file3,
2760
- L: 117,
2953
+ invariant2(name.length, void 0, {
2954
+ F: __dxlog_file4,
2955
+ L: 120,
2761
2956
  S: this,
2762
2957
  A: [
2763
2958
  "name.length",
@@ -2765,21 +2960,21 @@ var ComputeGraph = class extends Resource2 {
2765
2960
  ]
2766
2961
  });
2767
2962
  if (!this._hf.doesSheetExist(name)) {
2768
- log3.info("created node", {
2963
+ log3("created node", {
2769
2964
  space: this._space?.id,
2770
2965
  sheet: name
2771
2966
  }, {
2772
- F: __dxlog_file3,
2773
- L: 119,
2967
+ F: __dxlog_file4,
2968
+ L: 122,
2774
2969
  S: this,
2775
2970
  C: (f, a) => f(...a)
2776
2971
  });
2777
2972
  this._hf.addSheet(name);
2778
2973
  }
2779
2974
  const sheetId = this._hf.getSheetId(name);
2780
- invariant(sheetId !== void 0, void 0, {
2781
- F: __dxlog_file3,
2782
- L: 124,
2975
+ invariant2(sheetId !== void 0, void 0, {
2976
+ F: __dxlog_file4,
2977
+ L: 127,
2783
2978
  S: this,
2784
2979
  A: [
2785
2980
  "sheetId !== undefined",
@@ -2792,7 +2987,7 @@ var ComputeGraph = class extends Resource2 {
2792
2987
  }
2793
2988
  /**
2794
2989
  * Map bound value to custom function invocation.
2795
- * E.g., "HELLO(...args)" => "EDGE("HELLO", ...args)".
2990
+ * E.g., "HELLO(...args)" => "DX("HELLO", ...args)".
2796
2991
  */
2797
2992
  mapFormulaToNative(formula) {
2798
2993
  return formula.replace(/['"]?([ \w]+)['"]?!/, (_match, name) => {
@@ -2879,13 +3074,13 @@ var ComputeGraph = class extends Resource2 {
2879
3074
  }
2880
3075
  };
2881
3076
 
2882
- // packages/plugins/plugin-sheet/src/graph/compute-graph-registry.ts
3077
+ // packages/plugins/plugin-sheet/src/compute-graph/compute-graph-registry.ts
2883
3078
  import defaultsDeep2 from "lodash.defaultsdeep";
2884
3079
  import { Resource as Resource3 } from "@dxos/context";
2885
- import { invariant as invariant2 } from "@dxos/invariant";
3080
+ import { invariant as invariant3 } from "@dxos/invariant";
2886
3081
  import { log as log4 } from "@dxos/log";
2887
3082
  import { HyperFormula } from "#hyperformula";
2888
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/compute-graph-registry.ts";
3083
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/compute-graph/compute-graph-registry.ts";
2889
3084
  var defaultOptions = {
2890
3085
  licenseKey: "gpl-v3"
2891
3086
  };
@@ -2915,7 +3110,7 @@ var ComputeGraphRegistry = class extends Resource3 {
2915
3110
  log4("create graph", {
2916
3111
  space: space.id
2917
3112
  }, {
2918
- F: __dxlog_file4,
3113
+ F: __dxlog_file5,
2919
3114
  L: 69,
2920
3115
  S: this,
2921
3116
  C: (f, a) => f(...a)
@@ -2925,8 +3120,8 @@ var ComputeGraphRegistry = class extends Resource3 {
2925
3120
  return graph;
2926
3121
  }
2927
3122
  createGraph(space) {
2928
- invariant2(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`, {
2929
- F: __dxlog_file4,
3123
+ invariant3(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`, {
3124
+ F: __dxlog_file5,
2930
3125
  L: 77,
2931
3126
  S: this,
2932
3127
  A: [
@@ -2948,6 +3143,26 @@ var ComputeGraphRegistry = class extends Resource3 {
2948
3143
  };
2949
3144
 
2950
3145
  export {
3146
+ cellClassNameForRange,
3147
+ DEFAULT_ROWS,
3148
+ DEFAULT_COLUMNS,
3149
+ MAX_ROWS,
3150
+ MAX_COLUMNS,
3151
+ RANGE_NOTATION,
3152
+ isFormula,
3153
+ addressToA1Notation,
3154
+ addressFromA1Notation,
3155
+ rangeToA1Notation,
3156
+ inRange,
3157
+ ReadonlyException,
3158
+ insertIndices,
3159
+ initialize,
3160
+ createSheet,
3161
+ addressToIndex,
3162
+ addressFromIndex,
3163
+ rangeToIndex,
3164
+ rangeFromIndex,
3165
+ compareIndexPositions,
2951
3166
  ComputeNode,
2952
3167
  defaultFunctionContextOptions,
2953
3168
  FunctionContext,
@@ -2963,4 +3178,4 @@ export {
2963
3178
  defaultPlugins,
2964
3179
  ComputeGraphRegistry
2965
3180
  };
2966
- //# sourceMappingURL=chunk-GSV5QNLD.mjs.map
3181
+ //# sourceMappingURL=chunk-2ZK3YMZG.mjs.map