@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.
Files changed (217) hide show
  1. package/dist/lib/browser/{SheetContainer-AKWROARP.mjs → SheetContainer-R65IDJHN.mjs} +54 -58
  2. package/dist/lib/browser/SheetContainer-R65IDJHN.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-BWN5DZWZ.mjs → chunk-5KVQ5IPW.mjs} +3 -12
  4. package/dist/lib/browser/chunk-5KVQ5IPW.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-FGMFOW6U.mjs → chunk-I2DKJ72A.mjs} +570 -669
  6. package/dist/lib/browser/chunk-I2DKJ72A.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-GSV5QNLD.mjs → chunk-KCYJSOFB.mjs} +252 -33
  8. package/dist/lib/browser/chunk-KCYJSOFB.mjs.map +7 -0
  9. package/dist/lib/browser/{graph-M4IQ76QX.mjs → compute-graph-SJT67236.mjs} +4 -2
  10. package/dist/lib/browser/index.mjs +62 -20
  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-6BO4C5X2.cjs} +52 -62
  15. package/dist/lib/node/SheetContainer-6BO4C5X2.cjs.map +7 -0
  16. package/dist/lib/node/{chunk-NZARD7UP.cjs → chunk-2XJ5I4UF.cjs} +6 -15
  17. package/dist/lib/node/chunk-2XJ5I4UF.cjs.map +7 -0
  18. package/dist/lib/node/{chunk-53BMSUIK.cjs → chunk-DEPJHN47.cjs} +534 -646
  19. package/dist/lib/node/chunk-DEPJHN47.cjs.map +7 -0
  20. package/dist/lib/node/{chunk-5XPK2V4A.cjs → chunk-JF5XNTF3.cjs} +257 -28
  21. package/dist/lib/node/chunk-JF5XNTF3.cjs.map +7 -0
  22. package/dist/lib/node/{graph-Q3N2X26H.cjs → compute-graph-AQBDL7HO.cjs} +21 -19
  23. package/dist/lib/node/compute-graph-AQBDL7HO.cjs.map +7 -0
  24. package/dist/lib/node/index.cjs +70 -31
  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-MJXC5E3P.mjs} +54 -58
  30. package/dist/lib/node-esm/SheetContainer-MJXC5E3P.mjs.map +7 -0
  31. package/dist/lib/node-esm/{chunk-T3PRH7QS.mjs → chunk-25V7WY4R.mjs} +570 -669
  32. package/dist/lib/node-esm/chunk-25V7WY4R.mjs.map +7 -0
  33. package/dist/lib/node-esm/{chunk-WFDTY3IC.mjs → chunk-5TXLF6PL.mjs} +3 -12
  34. package/dist/lib/node-esm/chunk-5TXLF6PL.mjs.map +7 -0
  35. package/dist/lib/node-esm/{chunk-5WPZCXNS.mjs → chunk-XBEHKYO7.mjs} +251 -33
  36. package/dist/lib/node-esm/chunk-XBEHKYO7.mjs.map +7 -0
  37. package/dist/lib/node-esm/{graph-SMPUMOV2.mjs → compute-graph-FRCKXEYK.mjs} +4 -2
  38. package/dist/lib/node-esm/index.mjs +62 -20
  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 +1 -2
  48. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  49. package/dist/types/src/components/RangeList/RangeList.d.ts +7 -0
  50. package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -0
  51. package/dist/types/src/components/RangeList/index.d.ts +2 -0
  52. package/dist/types/src/components/RangeList/index.d.ts.map +1 -0
  53. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +6 -3
  54. package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +1 -1
  55. package/dist/types/src/components/SheetContext/SheetContext.d.ts +7 -5
  56. package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
  57. package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -1
  58. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  59. package/dist/types/src/components/index.d.ts +5 -2
  60. package/dist/types/src/components/index.d.ts.map +1 -1
  61. package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +1 -0
  62. package/dist/types/src/{graph → compute-graph}/compute-graph.d.ts +1 -1
  63. package/dist/types/src/compute-graph/compute-graph.d.ts.map +1 -0
  64. package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +1 -0
  65. package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +1 -0
  66. package/dist/types/src/compute-graph/compute-node.d.ts.map +1 -0
  67. package/dist/types/src/compute-graph/functions/async-function.d.ts.map +1 -0
  68. package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +1 -0
  69. package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +1 -0
  70. package/dist/types/src/compute-graph/functions/index.d.ts.map +1 -0
  71. package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +1 -0
  72. package/dist/types/src/compute-graph/index.d.ts.map +1 -0
  73. package/dist/types/src/compute-graph/testing/index.d.ts.map +1 -0
  74. package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +1 -0
  75. package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +1 -0
  76. package/dist/types/src/compute-graph/util.d.ts.map +1 -0
  77. package/dist/types/src/defs/index.d.ts +1 -1
  78. package/dist/types/src/defs/index.d.ts.map +1 -1
  79. package/dist/types/src/defs/sheet-range-types.d.ts +1 -1
  80. package/dist/types/src/defs/sheet-range-types.d.ts.map +1 -1
  81. package/dist/types/src/defs/types.d.ts +6 -0
  82. package/dist/types/src/defs/types.d.ts.map +1 -1
  83. package/dist/types/src/defs/util.d.ts +2 -6
  84. package/dist/types/src/defs/util.d.ts.map +1 -1
  85. package/dist/types/src/extensions/compute.d.ts +1 -1
  86. package/dist/types/src/extensions/compute.d.ts.map +1 -1
  87. package/dist/types/src/extensions/editor/extension.d.ts +23 -3
  88. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
  89. package/dist/types/src/index.d.ts +1 -1
  90. package/dist/types/src/index.d.ts.map +1 -1
  91. package/dist/types/src/integrations/index.d.ts +2 -0
  92. package/dist/types/src/integrations/index.d.ts.map +1 -0
  93. package/dist/types/src/integrations/thread-ranges.d.ts +7 -0
  94. package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -0
  95. package/dist/types/src/model/index.d.ts +1 -1
  96. package/dist/types/src/model/index.d.ts.map +1 -1
  97. package/dist/types/src/model/sheet-model.d.ts +1 -1
  98. package/dist/types/src/model/sheet-model.d.ts.map +1 -1
  99. package/dist/types/src/{hooks → model}/useSheetModel.d.ts +1 -1
  100. package/dist/types/src/model/useSheetModel.d.ts.map +1 -0
  101. package/dist/types/src/serializer.d.ts +4 -0
  102. package/dist/types/src/serializer.d.ts.map +1 -0
  103. package/dist/types/src/testing/testing.d.ts +1 -1
  104. package/dist/types/src/testing/testing.d.ts.map +1 -1
  105. package/dist/types/src/translations.d.ts +13 -3
  106. package/dist/types/src/translations.d.ts.map +1 -1
  107. package/dist/types/src/types.d.ts +4 -30
  108. package/dist/types/src/types.d.ts.map +1 -1
  109. package/package.json +43 -50
  110. package/src/SheetPlugin.tsx +25 -12
  111. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +19 -2
  112. package/src/components/FunctionEditor/FunctionEditor.tsx +5 -5
  113. package/src/components/GridSheet/GridSheet.stories.tsx +3 -1
  114. package/src/components/GridSheet/GridSheet.tsx +118 -22
  115. package/src/components/GridSheet/SheetCellEditor.stories.tsx +1 -1
  116. package/src/components/GridSheet/util.ts +24 -14
  117. package/src/components/RangeList/RangeList.tsx +53 -0
  118. package/src/components/RangeList/index.ts +5 -0
  119. package/src/components/SheetContainer/SheetContainer.stories.tsx +3 -3
  120. package/src/components/SheetContainer/SheetContainer.tsx +10 -4
  121. package/src/components/SheetContext/SheetContext.tsx +43 -20
  122. package/src/components/Toolbar/Toolbar.tsx +44 -41
  123. package/src/components/index.ts +1 -0
  124. package/src/{graph → compute-graph}/compute-graph.stories.tsx +2 -1
  125. package/src/{graph → compute-graph}/compute-graph.ts +5 -2
  126. package/src/{graph → compute-graph}/compute-node.ts +2 -3
  127. package/src/defs/index.ts +1 -1
  128. package/src/defs/sheet-range-types.ts +5 -4
  129. package/src/defs/types.ts +6 -1
  130. package/src/defs/util.ts +3 -19
  131. package/src/extensions/compute.stories.tsx +2 -2
  132. package/src/extensions/compute.ts +2 -2
  133. package/src/extensions/editor/extension.test.ts +1 -1
  134. package/src/extensions/editor/extension.ts +48 -23
  135. package/src/index.ts +2 -2
  136. package/src/integrations/index.ts +5 -0
  137. package/src/integrations/thread-ranges.ts +101 -0
  138. package/src/model/index.ts +1 -1
  139. package/src/model/sheet-model.test.ts +1 -1
  140. package/src/model/sheet-model.ts +13 -8
  141. package/src/{hooks → model}/useSheetModel.ts +1 -1
  142. package/src/serializer.ts +27 -0
  143. package/src/testing/testing.tsx +1 -1
  144. package/src/translations.ts +13 -3
  145. package/src/types.ts +4 -2
  146. package/dist/lib/browser/SheetContainer-AKWROARP.mjs.map +0 -7
  147. package/dist/lib/browser/chunk-BWN5DZWZ.mjs.map +0 -7
  148. package/dist/lib/browser/chunk-FGMFOW6U.mjs.map +0 -7
  149. package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +0 -7
  150. package/dist/lib/node/SheetContainer-N5IQGEFL.cjs.map +0 -7
  151. package/dist/lib/node/chunk-53BMSUIK.cjs.map +0 -7
  152. package/dist/lib/node/chunk-5XPK2V4A.cjs.map +0 -7
  153. package/dist/lib/node/chunk-NZARD7UP.cjs.map +0 -7
  154. package/dist/lib/node/graph-Q3N2X26H.cjs.map +0 -7
  155. package/dist/lib/node-esm/SheetContainer-46PBMF2E.mjs.map +0 -7
  156. package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +0 -7
  157. package/dist/lib/node-esm/chunk-T3PRH7QS.mjs.map +0 -7
  158. package/dist/lib/node-esm/chunk-WFDTY3IC.mjs.map +0 -7
  159. package/dist/types/src/graph/compute-graph-registry.d.ts.map +0 -1
  160. package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
  161. package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
  162. package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
  163. package/dist/types/src/graph/compute-node.d.ts.map +0 -1
  164. package/dist/types/src/graph/functions/async-function.d.ts.map +0 -1
  165. package/dist/types/src/graph/functions/edge-function.d.ts.map +0 -1
  166. package/dist/types/src/graph/functions/function-defs.d.ts.map +0 -1
  167. package/dist/types/src/graph/functions/index.d.ts.map +0 -1
  168. package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
  169. package/dist/types/src/graph/index.d.ts.map +0 -1
  170. package/dist/types/src/graph/testing/index.d.ts.map +0 -1
  171. package/dist/types/src/graph/testing/test-builder.d.ts.map +0 -1
  172. package/dist/types/src/graph/testing/test-plugin.d.ts.map +0 -1
  173. package/dist/types/src/graph/util.d.ts.map +0 -1
  174. package/dist/types/src/hooks/hooks.stories.d.ts +0 -6
  175. package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
  176. package/dist/types/src/hooks/index.d.ts +0 -4
  177. package/dist/types/src/hooks/index.d.ts.map +0 -1
  178. package/dist/types/src/hooks/threads.d.ts +0 -8
  179. package/dist/types/src/hooks/threads.d.ts.map +0 -1
  180. package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
  181. package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
  182. package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
  183. package/dist/types/src/model/decorations.d.ts +0 -26
  184. package/dist/types/src/model/decorations.d.ts.map +0 -1
  185. package/src/hooks/hooks.stories.tsx +0 -53
  186. package/src/hooks/index.ts +0 -7
  187. package/src/hooks/threads.ts +0 -147
  188. package/src/hooks/useComputeGraph.ts +0 -28
  189. package/src/model/decorations.ts +0 -66
  190. /package/dist/lib/browser/{graph-M4IQ76QX.mjs.map → compute-graph-SJT67236.mjs.map} +0 -0
  191. /package/dist/lib/node-esm/{graph-SMPUMOV2.mjs.map → compute-graph-FRCKXEYK.mjs.map} +0 -0
  192. /package/dist/types/src/{graph → compute-graph}/compute-graph-registry.d.ts +0 -0
  193. /package/dist/types/src/{graph → compute-graph}/compute-graph.stories.d.ts +0 -0
  194. /package/dist/types/src/{graph → compute-graph}/compute-graph.test.d.ts +0 -0
  195. /package/dist/types/src/{graph → compute-graph}/compute-node.d.ts +0 -0
  196. /package/dist/types/src/{graph → compute-graph}/functions/async-function.d.ts +0 -0
  197. /package/dist/types/src/{graph → compute-graph}/functions/edge-function.d.ts +0 -0
  198. /package/dist/types/src/{graph → compute-graph}/functions/function-defs.d.ts +0 -0
  199. /package/dist/types/src/{graph → compute-graph}/functions/index.d.ts +0 -0
  200. /package/dist/types/src/{graph → compute-graph}/hyperformula.test.d.ts +0 -0
  201. /package/dist/types/src/{graph → compute-graph}/index.d.ts +0 -0
  202. /package/dist/types/src/{graph → compute-graph}/testing/index.d.ts +0 -0
  203. /package/dist/types/src/{graph → compute-graph}/testing/test-builder.d.ts +0 -0
  204. /package/dist/types/src/{graph → compute-graph}/testing/test-plugin.d.ts +0 -0
  205. /package/dist/types/src/{graph → compute-graph}/util.d.ts +0 -0
  206. /package/src/{graph → compute-graph}/compute-graph-registry.ts +0 -0
  207. /package/src/{graph → compute-graph}/compute-graph.test.ts +0 -0
  208. /package/src/{graph → compute-graph}/functions/async-function.ts +0 -0
  209. /package/src/{graph → compute-graph}/functions/edge-function.ts +0 -0
  210. /package/src/{graph → compute-graph}/functions/function-defs.ts +0 -0
  211. /package/src/{graph → compute-graph}/functions/index.ts +0 -0
  212. /package/src/{graph → compute-graph}/hyperformula.test.ts +0 -0
  213. /package/src/{graph → compute-graph}/index.ts +0 -0
  214. /package/src/{graph → compute-graph}/testing/index.ts +0 -0
  215. /package/src/{graph → compute-graph}/testing/test-builder.ts +0 -0
  216. /package/src/{graph → compute-graph}/testing/test-plugin.ts +0 -0
  217. /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 = typeof value === "string" && value.charAt(0) === "=" ? this._graph.mapFormulaToNative(value) : value;
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 __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/functions/async-function.ts";
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: __dxlog_file,
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: __dxlog_file,
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: __dxlog_file,
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 __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/functions/edge-function.ts";
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: __dxlog_file2,
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: __dxlog_file2,
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 __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/compute-graph.ts";
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
- invariant(name.length, void 0, {
2761
- F: __dxlog_file3,
2762
- L: 117,
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.info("created node", {
2967
+ log3("created node", {
2771
2968
  space: this._space?.id,
2772
2969
  sheet: name
2773
2970
  }, {
2774
- F: __dxlog_file3,
2775
- L: 119,
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
- invariant(sheetId !== void 0, void 0, {
2783
- F: __dxlog_file3,
2784
- L: 124,
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)" => "EDGE("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 invariant2 } from "@dxos/invariant";
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 __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/graph/compute-graph-registry.ts";
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: __dxlog_file4,
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
- invariant2(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`, {
2931
- F: __dxlog_file4,
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-5WPZCXNS.mjs.map
3186
+ //# sourceMappingURL=chunk-XBEHKYO7.mjs.map