@dxos/plugin-sheet 0.12.0-next-73daef452f1464b62efdbca75fb0067c1066f264 → 0.14.0
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/PLUGIN.mdl +142 -10
- package/dist/lib/Sheet.mjs +8 -10
- package/dist/lib/Sheet.mjs.map +1 -1
- package/dist/lib/SheetCapabilities.mjs.map +1 -1
- package/dist/lib/SheetOperation.mjs +1 -1
- package/dist/lib/SheetOperation.mjs.map +1 -1
- package/dist/lib/SheetRange.mjs.map +1 -1
- package/dist/lib/SheetUtil.mjs.map +1 -1
- package/dist/lib/capabilities.browser.mjs +85 -0
- package/dist/lib/capabilities.browser.mjs.map +1 -0
- package/dist/lib/capabilities.mjs +36 -12
- package/dist/lib/capabilities.mjs.map +1 -1
- package/dist/lib/capabilities.node.mjs +35 -9
- package/dist/lib/capabilities.node.mjs.map +1 -1
- package/dist/lib/capabilities.tauri.mjs +85 -0
- package/dist/lib/capabilities.tauri.mjs.map +1 -0
- package/dist/lib/capabilities.workerd.mjs +2 -13
- package/dist/lib/capabilities.workerd.mjs.map +1 -1
- package/dist/lib/chunk-PLUGIN.mjs +6 -0
- package/dist/lib/chunk-PLUGIN.mjs.map +1 -0
- package/dist/lib/chunk-RangeList.mjs +33 -31
- package/dist/lib/chunk-RangeList.mjs.map +1 -1
- package/dist/lib/chunk-SheetArticle.mjs +8 -14
- package/dist/lib/chunk-SheetArticle.mjs.map +1 -1
- package/dist/lib/chunk-compute-graph-registry.mjs +1 -1
- package/dist/lib/chunk-create.mjs +2 -2
- package/dist/lib/chunk-create.mjs.map +1 -1
- package/dist/lib/chunk-markdown-extension.mjs +11 -2
- package/dist/lib/chunk-markdown-extension.mjs.map +1 -1
- package/dist/lib/chunk-operation-handler.mjs +1 -1
- package/dist/lib/chunk-react-surface.mjs +3 -3
- package/dist/lib/chunk-react-surface.mjs.map +1 -1
- package/dist/lib/chunk-scroll-to-anchor.mjs.map +1 -1
- package/dist/lib/chunk-thread-ranges.mjs +2 -2
- package/dist/lib/chunk-thread-ranges.mjs.map +1 -1
- package/dist/lib/chunk-undo-mappings.mjs +1 -1
- package/dist/lib/components.mjs +310 -60
- package/dist/lib/components.mjs.map +1 -1
- package/dist/lib/containers.mjs.map +1 -1
- package/dist/lib/index.mjs +1 -3
- package/dist/lib/meta.mjs +5 -1
- package/dist/lib/meta.mjs.map +1 -1
- package/dist/lib/node.mjs.map +1 -1
- package/dist/lib/operations.mjs.map +1 -1
- package/dist/lib/translations.mjs.map +1 -1
- package/dist/types/src/SheetPlugin.workerd.test.d.ts +2 -0
- package/dist/types/src/SheetPlugin.workerd.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/browser.d.ts +15 -0
- package/dist/types/src/capabilities/gen/browser.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/node.d.ts.map +1 -1
- package/dist/types/src/capabilities/gen/tauri.d.ts +15 -0
- package/dist/types/src/capabilities/gen/tauri.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/workerd.d.ts +2 -2
- package/dist/types/src/capabilities/gen/workerd.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/index.d.ts +2 -2
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts +8 -8
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/index.d.ts +1 -1
- package/dist/types/src/components/Sheet/index.d.ts.map +1 -1
- package/dist/types/src/components/SheetContent/SheetContent.d.ts.map +1 -1
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts +1 -1
- package/dist/types/src/components/SheetContent/index.d.ts +1 -1
- package/dist/types/src/components/SheetContent/index.d.ts.map +1 -1
- package/dist/types/src/components/SheetContent/util.d.ts +1 -1
- package/dist/types/src/components/SheetContent/util.d.ts.map +1 -1
- package/dist/types/src/components/SheetRoot/SheetContext.d.ts +1 -1
- package/dist/types/src/components/SheetRoot/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/SheetRoot/SheetRoot.d.ts +1 -1
- package/dist/types/src/components/SheetRoot/SheetRoot.d.ts.map +1 -1
- package/dist/types/src/components/SheetRoot/index.d.ts +2 -2
- package/dist/types/src/components/SheetRoot/index.d.ts.map +1 -1
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetStatusbar/index.d.ts +1 -1
- package/dist/types/src/components/SheetStatusbar/index.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +3 -3
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/index.d.ts +1 -1
- package/dist/types/src/components/SheetToolbar/index.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +3 -3
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +3 -12
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/RangeList/RangeList.d.ts +2 -1
- package/dist/types/src/containers/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/containers/RangeList/index.d.ts +1 -1
- package/dist/types/src/containers/RangeList/index.d.ts.map +1 -1
- package/dist/types/src/containers/SheetArticle/SheetArticle.d.ts +1 -1
- package/dist/types/src/containers/SheetArticle/SheetArticle.d.ts.map +1 -1
- package/dist/types/src/containers/SheetArticle/SheetArticle.stories.d.ts +1 -1
- package/dist/types/src/containers/SheetArticle/SheetArticle.stories.d.ts.map +1 -1
- package/dist/types/src/containers/SheetArticle/index.d.ts +1 -1
- package/dist/types/src/containers/SheetArticle/index.d.ts.map +1 -1
- package/dist/types/src/containers/index.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/index.d.ts +1 -1
- package/dist/types/src/extensions/editor/index.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +2 -2
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/index.d.ts +1 -1
- package/dist/types/src/integrations/index.d.ts.map +1 -1
- package/dist/types/src/model/index.d.ts +2 -2
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/skills/index.d.ts +1 -1
- package/dist/types/src/skills/index.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -2
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts.map +1 -1
- package/dist/types/src/types/SheetOperation.d.ts +2 -2
- package/dist/types/src/types/SheetOperation.d.ts.map +1 -1
- package/dist/types/src/types/SheetRange.d.ts +2 -2
- package/dist/types/src/types/SheetRange.d.ts.map +1 -1
- package/dist/types/src/types/SheetUtil.d.ts +1 -1
- package/dist/types/src/types/SheetUtil.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +6 -6
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dx.config.ts +5 -1
- package/package.json +60 -54
- package/src/SheetPlugin.workerd.test.ts +21 -0
- package/src/capabilities/gen/browser.ts +99 -0
- package/src/capabilities/gen/node.ts +17 -13
- package/src/capabilities/gen/tauri.ts +99 -0
- package/src/capabilities/gen/workerd.ts +5 -31
- package/src/capabilities/index.ts +19 -15
- package/src/capabilities/markdown-extension.ts +1 -1
- package/src/capabilities/react-surface.ts +2 -2
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -1
- package/src/components/ComputeGraph/compute-graph.stories.tsx +10 -12
- package/src/components/ComputeGraph/index.ts +2 -2
- package/src/components/Sheet/Sheet.tsx +8 -8
- package/src/components/Sheet/index.ts +1 -1
- package/src/components/SheetContent/SheetCellEditor.stories.tsx +1 -1
- package/src/components/SheetContent/SheetContent.stories.tsx +6 -6
- package/src/components/SheetContent/SheetContent.tsx +48 -47
- package/src/components/SheetContent/index.ts +1 -1
- package/src/components/SheetContent/util.ts +1 -1
- package/src/components/SheetRoot/SheetContext.ts +1 -1
- package/src/components/SheetRoot/SheetRoot.tsx +5 -14
- package/src/components/SheetRoot/index.ts +2 -2
- package/src/components/SheetStatusbar/SheetStatusbar.tsx +19 -20
- package/src/components/SheetStatusbar/index.ts +1 -1
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +1 -1
- package/src/components/SheetToolbar/SheetToolbar.tsx +13 -17
- package/src/components/SheetToolbar/align.ts +4 -4
- package/src/components/SheetToolbar/index.ts +1 -1
- package/src/components/SheetToolbar/style.ts +4 -4
- package/src/components/SheetToolbar/useToolbarState.ts +4 -21
- package/src/components/index.ts +3 -3
- package/src/containers/RangeList/RangeList.tsx +41 -43
- package/src/containers/RangeList/index.ts +1 -1
- package/src/containers/SheetArticle/SheetArticle.stories.tsx +4 -4
- package/src/containers/SheetArticle/SheetArticle.tsx +11 -11
- package/src/containers/SheetArticle/index.ts +1 -1
- package/src/containers/index.ts +2 -2
- package/src/extensions/compute.stories.tsx +6 -6
- package/src/extensions/editor/index.ts +1 -1
- package/src/extensions/editor/sheet-extension.test.ts +1 -1
- package/src/extensions/editor/sheet-extension.ts +1 -1
- package/src/extensions/index.ts +2 -2
- package/src/index.ts +1 -3
- package/src/integrations/index.ts +1 -1
- package/src/integrations/thread-ranges.ts +2 -2
- package/src/meta.ts +1 -1
- package/src/model/index.ts +2 -2
- package/src/model/sheet-model.test.ts +2 -2
- package/src/model/useSheetModel.ts +1 -1
- package/src/operations/create.ts +2 -2
- package/src/operations/index.ts +7 -7
- package/src/operations/node.ts +6 -6
- package/src/operations/scroll-to-anchor.ts +1 -1
- package/src/playwright/sheet.spec.ts +4 -2
- package/src/plugin.test.ts +2 -2
- package/src/skills/index.ts +1 -1
- package/src/testing/index.ts +2 -2
- package/src/translations.ts +2 -2
- package/src/types/Sheet.ts +9 -11
- package/src/types/SheetCapabilities.ts +1 -1
- package/src/types/SheetOperation.ts +4 -2
- package/src/types/SheetRange.ts +2 -2
- package/src/types/SheetUtil.ts +1 -1
- package/src/types/index.ts +6 -6
- package/dist/lib/chunk-extensions.mjs +0 -246
- package/dist/lib/chunk-extensions.mjs.map +0 -1
package/PLUGIN.mdl
CHANGED
|
@@ -15,9 +15,10 @@ Each extension is defined in the Appendix or resolved via its URI.
|
|
|
15
15
|
|-------------|--------------------------------|
|
|
16
16
|
| `type` | `org.dxos.mdl.type@1.0` |
|
|
17
17
|
| `feat` | `org.dxos.mdl.feat@1.0` |
|
|
18
|
-
| `
|
|
18
|
+
| `scenario` | `org.dxos.mdl.scenario@1.0` |
|
|
19
19
|
| `component` | `org.dxos.mdl.component@1.0` |
|
|
20
|
-
| `op` | `org.dxos.mdl.op@1.
|
|
20
|
+
| `op` | `org.dxos.mdl.op@1.1` |
|
|
21
|
+
| `test` | `org.dxos.mdl.test@1.0` |
|
|
21
22
|
|
|
22
23
|
## Types
|
|
23
24
|
|
|
@@ -111,6 +112,7 @@ component RangeList
|
|
|
111
112
|
|
|
112
113
|
```mdl
|
|
113
114
|
op insertAxis
|
|
115
|
+
key: org.dxos.operation.sheet.insertAxis
|
|
114
116
|
desc: Inserts one or more rows or columns at the given index in the sheet model.
|
|
115
117
|
input:
|
|
116
118
|
model: SheetModel
|
|
@@ -123,6 +125,7 @@ op insertAxis
|
|
|
123
125
|
|
|
124
126
|
```mdl
|
|
125
127
|
op dropAxis
|
|
128
|
+
key: org.dxos.operation.sheet.dropAxis
|
|
126
129
|
desc: Removes a row or column by axis index, returning data needed to restore it (undo).
|
|
127
130
|
input:
|
|
128
131
|
model: SheetModel
|
|
@@ -134,6 +137,7 @@ op dropAxis
|
|
|
134
137
|
|
|
135
138
|
```mdl
|
|
136
139
|
op restoreAxis
|
|
140
|
+
key: org.dxos.operation.sheet.restoreAxis
|
|
137
141
|
desc: Restores a previously dropped row or column (undo of dropAxis).
|
|
138
142
|
input:
|
|
139
143
|
model: SheetModel
|
|
@@ -148,6 +152,7 @@ op restoreAxis
|
|
|
148
152
|
|
|
149
153
|
```mdl
|
|
150
154
|
op scrollToAnchor
|
|
155
|
+
key: org.dxos.operation.sheet.scrollToAnchor
|
|
151
156
|
desc: Programmatically scrolls and highlights a cell range in an active grid instance.
|
|
152
157
|
input:
|
|
153
158
|
subject: string # attendable ID of the target sheet
|
|
@@ -157,6 +162,41 @@ op scrollToAnchor
|
|
|
157
162
|
effects: [ui:scroll]
|
|
158
163
|
```
|
|
159
164
|
|
|
165
|
+
Agent-facing skill operations (not previously documented here — found in `src/types/SheetOperation.ts`):
|
|
166
|
+
|
|
167
|
+
```mdl
|
|
168
|
+
op create
|
|
169
|
+
key: org.dxos.operation.sheet.create
|
|
170
|
+
desc: Creates a new Sheet and adds it to the space.
|
|
171
|
+
input:
|
|
172
|
+
name?: string
|
|
173
|
+
rows?: number # default 50
|
|
174
|
+
columns?: number # default 26
|
|
175
|
+
output: { id: string } # DXN of the created sheet
|
|
176
|
+
effects: [echo:write]
|
|
177
|
+
requires: [Database.Service]
|
|
178
|
+
|
|
179
|
+
op getRange
|
|
180
|
+
key: org.dxos.operation.sheet.getRange
|
|
181
|
+
desc: Reads cell values from a sheet as a 2D array. Omit `range` for the entire occupied area.
|
|
182
|
+
input:
|
|
183
|
+
sheet: Ref<Sheet>
|
|
184
|
+
range?: string # A1 notation, e.g. "A1:C5"
|
|
185
|
+
output: { values: any[][], range: string }
|
|
186
|
+
effects: [echo:read]
|
|
187
|
+
requires: [Database.Service]
|
|
188
|
+
|
|
189
|
+
op setRange
|
|
190
|
+
key: org.dxos.operation.sheet.setRange
|
|
191
|
+
desc: Sets multiple cell values in a sheet at once, keyed by A1 address.
|
|
192
|
+
input:
|
|
193
|
+
sheet: Ref<Sheet>
|
|
194
|
+
cells: Record<string, any> # e.g. { "A1": "Name", "B1": 42, "C1": "=A1+B1" }
|
|
195
|
+
output: void
|
|
196
|
+
effects: [echo:write]
|
|
197
|
+
requires: [Database.Service]
|
|
198
|
+
```
|
|
199
|
+
|
|
160
200
|
## Features
|
|
161
201
|
|
|
162
202
|
```mdl
|
|
@@ -235,7 +275,7 @@ feat F-7: Anchor Navigation
|
|
|
235
275
|
## Acceptance
|
|
236
276
|
|
|
237
277
|
```mdl
|
|
238
|
-
|
|
278
|
+
scenario T-1: Create sheet and enter a value
|
|
239
279
|
given: a new Sheet is created in a space
|
|
240
280
|
when: user types "42" into cell A1
|
|
241
281
|
then:
|
|
@@ -244,7 +284,7 @@ test T-1: Create sheet and enter a value
|
|
|
244
284
|
```
|
|
245
285
|
|
|
246
286
|
```mdl
|
|
247
|
-
|
|
287
|
+
scenario T-2: Formula evaluation
|
|
248
288
|
given: A1 = 10, A2 = 20
|
|
249
289
|
when: user enters "=A1+A2" in A3
|
|
250
290
|
then:
|
|
@@ -253,7 +293,7 @@ test T-2: Formula evaluation
|
|
|
253
293
|
```
|
|
254
294
|
|
|
255
295
|
```mdl
|
|
256
|
-
|
|
296
|
+
scenario T-3: Insert and drop row
|
|
257
297
|
given: a Sheet with values in rows 1 and 2
|
|
258
298
|
when: op:insertAxis runs with axis=row, index=1
|
|
259
299
|
then:
|
|
@@ -267,7 +307,7 @@ test T-3: Insert and drop row
|
|
|
267
307
|
```
|
|
268
308
|
|
|
269
309
|
```mdl
|
|
270
|
-
|
|
310
|
+
scenario T-4: Range formatting
|
|
271
311
|
given: a Sheet open in SheetArticle
|
|
272
312
|
when: user applies "highlight" style to range B2:C4
|
|
273
313
|
then:
|
|
@@ -276,7 +316,7 @@ test T-4: Range formatting
|
|
|
276
316
|
```
|
|
277
317
|
|
|
278
318
|
```mdl
|
|
279
|
-
|
|
319
|
+
scenario T-5: Real-time collaboration
|
|
280
320
|
given: two peers have the same Sheet open
|
|
281
321
|
when: peer A sets cell D5 to "hello"
|
|
282
322
|
then:
|
|
@@ -284,7 +324,7 @@ test T-5: Real-time collaboration
|
|
|
284
324
|
```
|
|
285
325
|
|
|
286
326
|
```mdl
|
|
287
|
-
|
|
327
|
+
scenario T-6: Scroll to anchor
|
|
288
328
|
given: a SheetArticle is mounted with attendableId "sheet-1"
|
|
289
329
|
when: op:scrollToAnchor runs with subject="sheet-1", cursor="E10"
|
|
290
330
|
then:
|
|
@@ -294,6 +334,98 @@ test T-6: Scroll to anchor
|
|
|
294
334
|
|
|
295
335
|
---
|
|
296
336
|
|
|
337
|
+
## QA
|
|
338
|
+
|
|
339
|
+
Executable tests. Each step carries a human instruction (`do`) and, where the step maps to an
|
|
340
|
+
invocable operation, an agent binding (`invoke`). Report failures by test and step number.
|
|
341
|
+
|
|
342
|
+
```mdl
|
|
343
|
+
test QA-1: Create a sheet, set values, evaluate a formula, read back
|
|
344
|
+
desc: The core spreadsheet round-trip — create, set cells (including a formula), read the
|
|
345
|
+
evaluated result back.
|
|
346
|
+
actors: agent
|
|
347
|
+
covers: [F-1.1, F-1.2, F-2.1, F-2.3, T-1, T-2]
|
|
348
|
+
status: unverified
|
|
349
|
+
given:
|
|
350
|
+
- an identity exists
|
|
351
|
+
- space: a space is open
|
|
352
|
+
- root: the space's root collection — [op:create] takes no target and files the Sheet
|
|
353
|
+
there via its default parent (`DefaultParent.add`), so the test cannot choose a different one
|
|
354
|
+
- no Sheet named "QA Sheet" exists — ABORT rather than reusing one this test did not create
|
|
355
|
+
steps:
|
|
356
|
+
- name: Create the sheet
|
|
357
|
+
do: In the navtree, click + on a collection and choose Sheet. Name it "QA Sheet".
|
|
358
|
+
invoke: [op:create] { name: "QA Sheet" }
|
|
359
|
+
capture: created
|
|
360
|
+
expect: a Sheet named "QA Sheet" now exists
|
|
361
|
+
assert: return !!$created.id
|
|
362
|
+
|
|
363
|
+
- name: Place it in the root collection
|
|
364
|
+
do: (no separate gesture — the navtree create action places it)
|
|
365
|
+
expect: "QA Sheet" appears as a row under the space's root collection
|
|
366
|
+
note: |
|
|
367
|
+
NO `invoke` — [op:create] places the sheet in the space itself, so a following
|
|
368
|
+
`space.addObject` is redundant. `$created.id` is a DXN string, not an object;
|
|
369
|
+
resolve it (`db.getObjectById` on the DXN's last segment) before any step that
|
|
370
|
+
needs the live Sheet.
|
|
371
|
+
|
|
372
|
+
- name: Resolve the sheet and set values
|
|
373
|
+
do: Click cell A1 and type "10", Enter. Click A2 and type "20", Enter. Click A3 and type
|
|
374
|
+
"=A1+A2", Enter.
|
|
375
|
+
invoke: [op:setRange] { sheet: space.db.makeRef($created.id), cells: { A1: 10, A2: 20, A3: "=A1+A2" } }
|
|
376
|
+
expect: A1 shows 10, A2 shows 20, and A3 shows 30 (evaluated by HyperFormula)
|
|
377
|
+
note: |
|
|
378
|
+
`sheet` is a `Ref` and `op:create` returns only `{ id }` (a DXN string) — `db.makeRef`
|
|
379
|
+
builds the `Ref` straight from that DXN, no load needed; `Ref.make` needs a live object,
|
|
380
|
+
which nothing captured here has.
|
|
381
|
+
|
|
382
|
+
- name: Read the range back
|
|
383
|
+
do: (agent-only — confirm the evaluated values)
|
|
384
|
+
invoke: [op:getRange] { sheet: space.db.makeRef($created.id), range: "A1:A3" }
|
|
385
|
+
expect: A3 renders 30 in the grid
|
|
386
|
+
assert: |
|
|
387
|
+
// getRange returns STORED cell content, not the evaluated result — A3 comes back as
|
|
388
|
+
// the formula string. Judge the evaluated value in the UI (`expect`), not here.
|
|
389
|
+
return $result.values.flat().slice(0, 2).join(',') === '10,20';
|
|
390
|
+
after:
|
|
391
|
+
- name: Delete the sheet
|
|
392
|
+
do: Right-click "QA Sheet" in the navtree and choose Delete.
|
|
393
|
+
invoke: org.dxos.operation.space.removeObjects { objects: [space.db.getObjectById($created.id.split('/').pop())] }
|
|
394
|
+
expect: the row leaves the navtree and its plank closes if it was open
|
|
395
|
+
note: |
|
|
396
|
+
No `target` — `op:create` calls `DefaultParent.add({ object })` with no target, so the
|
|
397
|
+
Sheet lands in the space's root collection; omitting `target` here lets `removeObjects`
|
|
398
|
+
default to that same collection rather than a different one.
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
```mdl
|
|
402
|
+
test QA-2: Build a budget and watch its totals recompute
|
|
403
|
+
desc: The demo path — create a sheet, type a small table, total it with SUM, and change a value.
|
|
404
|
+
actors: human
|
|
405
|
+
covers: [F-1.1, F-2.1, F-2.3, T-1, T-2]
|
|
406
|
+
status: passing # 2026-10-09, recorded by autocue/budget.mjs
|
|
407
|
+
given:
|
|
408
|
+
- an identity exists, on a fresh profile
|
|
409
|
+
- space: the default space is open on its Home
|
|
410
|
+
steps:
|
|
411
|
+
- name: Create a sheet
|
|
412
|
+
do: Click "Add to space" and choose Sheet.
|
|
413
|
+
expect: an empty grid opens in a new plank
|
|
414
|
+
- name: Enter a header row and four rows of costs
|
|
415
|
+
do: |
|
|
416
|
+
From A1, type "Item", "Q1", "Q2" with Tab between cells and Enter at the end, then four rows:
|
|
417
|
+
Hosting 120 140, Design 80 95, Marketing 60 75, Support 40 45.
|
|
418
|
+
expect: the values fill A1:C5, numbers right-aligned
|
|
419
|
+
- name: Total each quarter with SUM
|
|
420
|
+
do: In A6 type "Total", then "=SUM(B2:B5)" in B6 and "=SUM(C2:C5)" in C6.
|
|
421
|
+
expect: B6 shows 300 and C6 shows 355
|
|
422
|
+
- name: Change a cost and watch the total update
|
|
423
|
+
do: Click B2, type "200" and press Enter.
|
|
424
|
+
expect: B6 updates to 380 without any other action
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
297
429
|
## Appendix: Extension Definitions
|
|
298
430
|
|
|
299
431
|
```mdl
|
|
@@ -318,8 +450,8 @@ ext feat
|
|
|
318
450
|
```
|
|
319
451
|
|
|
320
452
|
```mdl
|
|
321
|
-
ext
|
|
322
|
-
uri: org.dxos.mdl.
|
|
453
|
+
ext scenario
|
|
454
|
+
uri: org.dxos.mdl.scenario@1.0
|
|
323
455
|
desc: An acceptance scenario expressed as given / when / then steps.
|
|
324
456
|
fields:
|
|
325
457
|
given?: Step | Step[]
|
package/dist/lib/Sheet.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
|
|
2
2
|
import { addressToIndex, initialize, mapFormulaRefsToIndices } from "./SheetUtil.mjs";
|
|
3
|
-
import { Annotation, DXN, Obj, Type } from "@dxos/echo";
|
|
3
|
+
import { Annotation, Collection, DXN, Obj, Type } from "@dxos/echo";
|
|
4
4
|
import { addressFromA1Notation, isFormula } from "@dxos/compute-hyperformula/types";
|
|
5
5
|
import * as Skill from "@dxos/compute/Skill";
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
7
|
-
import { FormInputAnnotation } from "@dxos/echo/Annotation";
|
|
8
|
-
import { CollectionItemAnnotation } from "@dxos/schema";
|
|
9
7
|
//#region src/types/Sheet.ts
|
|
10
8
|
var Sheet_exports = /* @__PURE__ */ __exportAll({
|
|
11
9
|
CellValue: () => CellValue,
|
|
@@ -25,16 +23,16 @@ var Range = Schema.Struct({
|
|
|
25
23
|
var RowColumnMeta = Schema.Struct({ size: Schema.optional(Schema.Number) });
|
|
26
24
|
var Sheet = class extends Type.makeObject(DXN.make("org.dxos.type.sheet", "0.1.0"))(Schema.Struct({
|
|
27
25
|
name: Schema.optional(Schema.String),
|
|
28
|
-
cells: Schema.Record(Schema.String, CellValue).pipe(FormInputAnnotation.set(false)),
|
|
29
|
-
rows: Schema.Array(Schema.String).pipe(FormInputAnnotation.set(false)),
|
|
30
|
-
columns: Schema.Array(Schema.String).pipe(FormInputAnnotation.set(false)),
|
|
31
|
-
rowMeta: Schema.Record(Schema.String, RowColumnMeta).pipe(FormInputAnnotation.set(false)),
|
|
32
|
-
columnMeta: Schema.Record(Schema.String, RowColumnMeta).pipe(FormInputAnnotation.set(false)),
|
|
33
|
-
ranges: Schema.Array(Range).pipe(FormInputAnnotation.set(false))
|
|
26
|
+
cells: Schema.Record(Schema.String, CellValue).pipe(Annotation.FormInputAnnotation.set(false)),
|
|
27
|
+
rows: Schema.Array(Schema.String).pipe(Annotation.FormInputAnnotation.set(false)),
|
|
28
|
+
columns: Schema.Array(Schema.String).pipe(Annotation.FormInputAnnotation.set(false)),
|
|
29
|
+
rowMeta: Schema.Record(Schema.String, RowColumnMeta).pipe(Annotation.FormInputAnnotation.set(false)),
|
|
30
|
+
columnMeta: Schema.Record(Schema.String, RowColumnMeta).pipe(Annotation.FormInputAnnotation.set(false)),
|
|
31
|
+
ranges: Schema.Array(Range).pipe(Annotation.FormInputAnnotation.set(false))
|
|
34
32
|
}).pipe(Annotation.IconAnnotation.set({
|
|
35
33
|
icon: "ph--grid-nine--regular",
|
|
36
34
|
hue: "indigo"
|
|
37
|
-
}), Skill.SkillsAnnotation.set([SKILL_KEY]),
|
|
35
|
+
}), Skill.SkillsAnnotation.set([SKILL_KEY]), Annotation.UserType.set({ tags: [Collection.ItemTag] }))) {};
|
|
38
36
|
var make = ({ name, cells = {}, ...size } = {}) => {
|
|
39
37
|
const sheet = Obj.make(Sheet, {
|
|
40
38
|
name,
|
package/dist/lib/Sheet.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sheet.mjs","names":[],"sources":["../../src/types/Sheet.ts"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { addressFromA1Notation, isFormula } from '@dxos/compute-hyperformula/types';\nimport * as Skill from '@dxos/compute/Skill';\nimport { Annotation, DXN, Obj, Type } from '@dxos/echo';\
|
|
1
|
+
{"version":3,"file":"Sheet.mjs","names":[],"sources":["../../src/types/Sheet.ts"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport { addressFromA1Notation, isFormula } from '@dxos/compute-hyperformula/types';\nimport * as Skill from '@dxos/compute/Skill';\nimport { Annotation, Collection, DXN, Obj, Type } from '@dxos/echo';\n\nimport { addressToIndex, initialize, mapFormulaRefsToIndices } from './SheetUtil.ts';\n\nexport const SKILL_KEY = 'org.dxos.skill.sheet';\n\nexport type SheetSize = {\n rows: number;\n columns: number;\n};\n\nexport const CellValue = Schema.Struct({\n // TODO(burdon): How to store dates (datetime, date, time), percentages, etc.\n // Consider import/export; natural access for other plugins. Special handling for currency (precision).\n // TODO(burdon): Automerge (long string) or short string or number.\n value: Schema.Any,\n});\n\nexport type CellValue = Schema.Schema.Type<typeof CellValue>;\n\n// TODO(burdon): IMPORTANT: Reconcile with Field definition.\nexport const Range = Schema.Struct({\n range: Schema.String,\n key: Schema.String,\n value: Schema.String,\n});\n\nexport type Range = Schema.Schema.Type<typeof Range>;\n\n// TODO(burdon): Visibility, locked, frozen, etc.\nexport const RowColumnMeta = Schema.Struct({\n size: Schema.optional(Schema.Number),\n});\n\n// TODO(burdon): Reconcile col/column (across packages).\n// TODO(burdon): Index to all updates when rows/columns are inserted/deleted.\nexport class Sheet extends Type.makeObject<Sheet>(DXN.make('org.dxos.type.sheet', '0.1.0'))(\n Schema.Struct({\n name: Schema.optional(Schema.String),\n\n // Sparse map of cells referenced by index.\n cells: Schema.Record(Schema.String, CellValue).pipe(Annotation.FormInputAnnotation.set(false)),\n\n // Ordered row indices.\n rows: Schema.Array(Schema.String).pipe(Annotation.FormInputAnnotation.set(false)),\n\n // Ordered column indices.\n columns: Schema.Array(Schema.String).pipe(Annotation.FormInputAnnotation.set(false)),\n\n // Row metadata referenced by index.\n rowMeta: Schema.Record(Schema.String, RowColumnMeta).pipe(Annotation.FormInputAnnotation.set(false)),\n\n // Column metadata referenced by index.\n columnMeta: Schema.Record(Schema.String, RowColumnMeta).pipe(Annotation.FormInputAnnotation.set(false)),\n\n // Cell formatting referenced by indexed range.\n ranges: Schema.Array(Range).pipe(Annotation.FormInputAnnotation.set(false)),\n }).pipe(\n Annotation.IconAnnotation.set({ icon: 'ph--grid-nine--regular', hue: 'indigo' }),\n Skill.SkillsAnnotation.set([SKILL_KEY]),\n Annotation.UserType.set({ tags: [Collection.ItemTag] }),\n ),\n) {}\n\nexport type SheetProps = {\n name?: string;\n cells?: Record<string, CellValue>;\n} & Partial<SheetSize>;\n\nexport const make = ({ name, cells = {}, ...size }: SheetProps = {}) => {\n const sheet = Obj.make(Sheet, { name, cells: {}, rows: [], columns: [], rowMeta: {}, columnMeta: {}, ranges: [] });\n\n // Initialize and set cells within Obj.update to satisfy change context requirements.\n Obj.update(sheet, (sheet) => {\n initialize(sheet, size);\n\n if (cells) {\n Object.entries(cells).forEach(([key, { value }]) => {\n const idx = addressToIndex(sheet, addressFromA1Notation(key));\n if (isFormula(value)) {\n value = mapFormulaRefsToIndices(sheet, value);\n }\n\n sheet.cells[idx] = { value };\n });\n }\n });\n\n return sheet;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAcA,IAAa,YAAY;AAOzB,IAAa,YAAY,OAAO,OAAO,EAIrC,OAAO,OAAO,IAChB,CAAC;AAKD,IAAa,QAAQ,OAAO,OAAO;CACjC,OAAO,OAAO;CACd,KAAK,OAAO;CACZ,OAAO,OAAO;AAChB,CAAC;AAKD,IAAa,gBAAgB,OAAO,OAAO,EACzC,MAAM,OAAO,SAAS,OAAO,MAAM,EACrC,CAAC;AAID,IAAa,QAAb,cAA2B,KAAK,WAAkB,IAAI,KAAK,uBAAuB,OAAO,CAAC,CAAC,CACzF,OAAO,OAAO;CACZ,MAAM,OAAO,SAAS,OAAO,MAAM;CAGnC,OAAO,OAAO,OAAO,OAAO,QAAQ,SAAS,CAAC,CAAC,KAAK,WAAW,oBAAo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;CAEL,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetCapabilities.mjs","names":[],"sources":["../../src/types/SheetCapabilities.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Capability from '@dxos/app-framework/Capability';\nimport { type ComputeGraphRegistry as ComputeGraphRegistryType } from '@dxos/compute-hyperformula';\nimport { type DxGridElement, type GridContentProps } from '@dxos/react-ui-grid';\n\nimport { meta } from '#meta';\n\nimport * as Sheet from './Sheet';\n\nexport type GridEntry = { grid: DxGridElement; setActiveRefs: (refs: GridContentProps['activeRefs']) => void };\n\nexport type GridRegistry = {\n register: (attendableId: string, grid: DxGridElement, setActiveRefs: GridEntry['setActiveRefs']) => void;\n unregister: (attendableId: string) => void;\n get: (attendableId: string) => GridEntry | undefined;\n};\n\nexport const ComputeGraphRegistry = Capability.makeSingleton<ComputeGraphRegistryType>()(\n `${meta.profile.key}.capability.computeGraphRegistry`,\n);\n\n/** Registry of active grid instances keyed by attendable ID. */\nexport const GridInstances = Capability.makeSingleton<GridRegistry>()(`${meta.profile.key}.capability.gridInstances`);\n\n// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.\nconst ActionAxis = Schema.Union([Schema.Literal('row'), Schema.Literal('col')]);\n\nexport namespace SheetAction {\n export const RestoreAxis = Schema.Struct({\n axis: ActionAxis,\n axisIndex: Schema.String,\n index: Schema.Number,\n axisMeta: Sheet.RowColumnMeta,\n values: Schema.Array(Schema.Any),\n });\n\n export type RestoreAxis = Schema.Schema.Type<typeof RestoreAxis>;\n}\n"],"mappings":";;;;;;;;;;;AAsBA,IAAa,uBAAuB,WAAW,cAAwC,CAAC,CACtF,GAAG,KAAK,QAAQ,IAAI,iCACtB;;AAGA,IAAa,gBAAgB,WAAW,cAA4B,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,0BAA0B;AAGpH,IAAM,aAAa,OAAO,MAAM,CAAC,OAAO,QAAQ,KAAK,GAAG,OAAO,QAAQ,KAAK,CAAC,CAAC;AAEvE,IAAU;CAAV,SAAA,cAAA;CACQ,aAAA,cAAc,OAAO,OAAO;EACvC,MAAM;EACN,WAAW,OAAO;EAClB,OAAO,OAAO;EACd,UAAU;EACV,QAAQ,OAAO,MAAM,OAAO,GAAG;CACjC,CAAC;AAGH,EAAA,CAAA,gBAAA,cAAA,CAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"SheetCapabilities.mjs","names":[],"sources":["../../src/types/SheetCapabilities.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Capability from '@dxos/app-framework/Capability';\nimport { type ComputeGraphRegistry as ComputeGraphRegistryType } from '@dxos/compute-hyperformula';\nimport { type DxGridElement, type GridContentProps } from '@dxos/react-ui-grid';\n\nimport { meta } from '#meta';\n\nimport * as Sheet from './Sheet.ts';\n\nexport type GridEntry = { grid: DxGridElement; setActiveRefs: (refs: GridContentProps['activeRefs']) => void };\n\nexport type GridRegistry = {\n register: (attendableId: string, grid: DxGridElement, setActiveRefs: GridEntry['setActiveRefs']) => void;\n unregister: (attendableId: string) => void;\n get: (attendableId: string) => GridEntry | undefined;\n};\n\nexport const ComputeGraphRegistry = Capability.makeSingleton<ComputeGraphRegistryType>()(\n `${meta.profile.key}.capability.computeGraphRegistry`,\n);\n\n/** Registry of active grid instances keyed by attendable ID. */\nexport const GridInstances = Capability.makeSingleton<GridRegistry>()(`${meta.profile.key}.capability.gridInstances`);\n\n// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.\nconst ActionAxis = Schema.Union([Schema.Literal('row'), Schema.Literal('col')]);\n\nexport namespace SheetAction {\n export const RestoreAxis = Schema.Struct({\n axis: ActionAxis,\n axisIndex: Schema.String,\n index: Schema.Number,\n axisMeta: Sheet.RowColumnMeta,\n values: Schema.Array(Schema.Any),\n });\n\n export type RestoreAxis = Schema.Schema.Type<typeof RestoreAxis>;\n}\n"],"mappings":";;;;;;;;;;;AAsBA,IAAa,uBAAuB,WAAW,cAAwC,CAAC,CACtF,GAAG,KAAK,QAAQ,IAAI,iCACtB;;AAGA,IAAa,gBAAgB,WAAW,cAA4B,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,0BAA0B;AAGpH,IAAM,aAAa,OAAO,MAAM,CAAC,OAAO,QAAQ,KAAK,GAAG,OAAO,QAAQ,KAAK,CAAC,CAAC;AAEvE,IAAU;CAAV,SAAA,cAAA;CACQ,aAAA,cAAc,OAAO,OAAO;EACvC,MAAM;EACN,WAAW,OAAO;EAClB,OAAO,OAAO;EACd,UAAU;EACV,QAAQ,OAAO,MAAM,OAAO,GAAG;CACjC,CAAC;AAGH,EAAA,CAAA,gBAAA,cAAA,CAAA,EAAA"}
|
|
@@ -78,7 +78,7 @@ var Create = Operation.make({
|
|
|
78
78
|
columns: Schema.optional(Schema.Number).annotate({ description: "Initial number of columns (default 26)." })
|
|
79
79
|
}),
|
|
80
80
|
output: Schema.Struct({ id: Schema.String.annotate({ description: "The DXN of the created sheet." }) }),
|
|
81
|
-
services: [Database.Service]
|
|
81
|
+
services: [Capability.Service, Database.Service]
|
|
82
82
|
});
|
|
83
83
|
var GetValues = Operation.make({
|
|
84
84
|
meta: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetOperation.mjs","names":[],"sources":["../../src/types/SheetOperation.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Capability from '@dxos/app-framework/Capability';\nimport * as Operation from '@dxos/compute/Operation';\nimport { Database, Ref } from '@dxos/echo';\nimport { DXN } from '@dxos/keys';\n\nimport * as Sheet from './Sheet';\n\n// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.\nconst Axis = Schema.Union([Schema.Literal('row'), Schema.Literal('col')]);\n\nexport const InsertAxis = Operation.make({\n meta: { key: DXN.make('org.dxos.operation.sheet.insertAxis'), name: 'Insert Axis', icon: 'ph--plus--regular' },\n input: Schema.Struct({\n model: Schema.Any,\n axis: Axis,\n index: Schema.Number,\n count: Schema.optional(Schema.Number),\n }),\n output: Schema.Void,\n});\n\nexport const DropAxisOutput = Schema.Struct({\n axis: Axis.annotate({ description: 'The axis type (row or col).' }),\n axisIndex: Schema.String.annotate({ description: 'The dropped axis index.' }),\n index: Schema.Number.annotate({ description: 'The position the axis was at.' }),\n axisMeta: Schema.Any.annotate({ description: 'The row/column metadata.' }),\n values: Schema.Array(Schema.Any).annotate({ description: 'The cell values that were dropped.' }),\n});\n\nexport type DropAxisOutput = Schema.Schema.Type<typeof DropAxisOutput>;\n\nexport const DropAxis = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.dropAxis'),\n name: 'Drop Axis',\n icon: 'ph--trash--regular',\n },\n input: Schema.Struct({\n model: Schema.Any,\n axis: Axis,\n axisIndex: Schema.String,\n }),\n output: DropAxisOutput,\n});\n\nexport const ScrollToAnchor = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.scrollToAnchor'),\n name: 'Scroll To Anchor',\n icon: 'ph--anchor-simple--regular',\n },\n services: [Capability.Service],\n input: Schema.Struct({\n subject: Schema.String.annotate({ description: 'Attendable ID of the sheet.' }),\n cursor: Schema.String.annotate({ description: 'Cell range coordinates.' }),\n id: Schema.optional(Schema.Any.annotate({ description: 'Active refs for highlighting.' })),\n }),\n output: Schema.Void,\n});\n\nexport const Create = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.create'),\n name: 'Create',\n description: 'Creates a new sheet and adds it to the space.',\n icon: 'ph--grid-nine--regular',\n },\n input: Schema.Struct({\n name: Schema.optional(Schema.String).annotate({ description: 'Display name for the sheet.' }),\n rows: Schema.optional(Schema.Number).annotate({ description: 'Initial number of rows (default 50).' }),\n columns: Schema.optional(Schema.Number).annotate({ description: 'Initial number of columns (default 26).' }),\n }),\n output: Schema.Struct({\n id: Schema.String.annotate({ description: 'The DXN of the created sheet.' }),\n }),\n services: [Database.Service],\n});\n\nexport const GetValues = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.getRange'),\n name: 'Get Range Values',\n description: 'Returns cell values from a sheet as a 2D array. Defaults to the entire occupied area.',\n icon: 'ph--table--regular',\n },\n input: Schema.Struct({\n sheet: Ref.Ref(Sheet.Sheet).annotate({ description: 'The sheet to read from.' }),\n range: Schema.optional(Schema.String).annotate({\n description: 'Range in A1 notation (e.g. \"A1:C5\"). Omit to return the entire occupied area.',\n }),\n }),\n output: Schema.Struct({\n values: Schema.Array(Schema.Array(Schema.Any)).annotate({\n description:\n '2D array of cell values indexed [row][col]. Empty cells are null. Formulas are shown in A1 notation.',\n }),\n range: Schema.String.annotate({ description: 'The A1 range actually returned (e.g. \"A1:E5\").' }),\n }),\n services: [Database.Service],\n});\n\nexport const SetValues = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.setRange'),\n name: 'Set Range Values',\n description: 'Sets multiple cell values in a sheet at once.',\n icon: 'ph--pencil--regular',\n },\n input: Schema.Struct({\n sheet: Ref.Ref(Sheet.Sheet).annotate({ description: 'The sheet to write to.' }),\n cells: Schema.Record(Schema.String, Schema.Any).annotate({\n description: 'Map of A1 address to value (e.g. { \"A1\": \"Name\", \"B1\": 42, \"C1\": \"=A1+B1\" }).',\n }),\n }),\n output: Schema.Void,\n services: [Database.Service],\n});\n\n/**\n * Restore a dropped axis (inverse of DropAxis).\n */\nexport const RestoreAxis = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.restoreAxis'),\n name: 'Restore Axis',\n icon: 'ph--clock-counter-clockwise--regular',\n },\n input: Schema.Struct({\n model: Schema.Any.annotate({ description: 'The sheet model.' }),\n axis: Axis.annotate({ description: 'The axis type (row or col).' }),\n axisIndex: Schema.String.annotate({ description: 'The axis index to restore.' }),\n index: Schema.Number.annotate({ description: 'The position to restore at.' }),\n axisMeta: Schema.Any.annotate({ description: 'The row/column metadata.' }),\n values: Schema.Array(Schema.Any).annotate({ description: 'The cell values to restore.' }),\n }),\n output: Schema.Void,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,IAAM,OAAO,OAAO,MAAM,CAAC,OAAO,QAAQ,KAAK,GAAG,OAAO,QAAQ,KAAK,CAAC,CAAC;AAExE,IAAa,aAAa,UAAU,KAAK;CACvC,MAAM;EAAE,KAAK,MAAI,KAAK,qCAAqC;EAAG,MAAM;EAAe,MAAM;CAAoB;CAC7G,OAAO,OAAO,OAAO;EACnB,OAAO,OAAO;EACd,MAAM;EACN,OAAO,OAAO;EACd,OAAO,OAAO,SAAS,OAAO,MAAM;CACtC,CAAC;CACD,QAAQ,OAAO;AACjB,CAAC;AAED,IAAa,iBAAiB,OAAO,OAAO;CAC1C,MAAM,KAAK,SAAS,EAAE,aAAa,8BAA8B,CAAC;CAClE,WAAW,OAAO,OAAO,SAAS,EAAE,aAAa,0BAA0B,CAAC;CAC5E,OAAO,OAAO,OAAO,SAAS,EAAE,aAAa,gCAAgC,CAAC;CAC9E,UAAU,OAAO,IAAI,SAAS,EAAE,aAAa,2BAA2B,CAAC;CACzE,QAAQ,OAAO,MAAM,OAAO,GAAG,CAAC,CAAC,SAAS,EAAE,aAAa,qCAAqC,CAAC;AACjG,CAAC;AAID,IAAa,WAAW,UAAU,KAAK;CACrC,MAAM;EACJ,KAAK,MAAI,KAAK,mCAAmC;EACjD,MAAM;EACN,MAAM;CACR;CACA,OAAO,OAAO,OAAO;EACnB,OAAO,OAAO;EACd,MAAM;EACN,WAAW,OAAO;CACpB,CAAC;CACD,QAAQ;AACV,CAAC;AAED,IAAa,iBAAiB,UAAU,KAAK;CAC3C,MAAM;EACJ,KAAK,MAAI,KAAK,yCAAyC;EACvD,MAAM;EACN,MAAM;CACR;CACA,UAAU,CAAC,WAAW,OAAO;CAC7B,OAAO,OAAO,OAAO;EACnB,SAAS,OAAO,OAAO,SAAS,EAAE,aAAa,8BAA8B,CAAC;EAC9E,QAAQ,OAAO,OAAO,SAAS,EAAE,aAAa,0BAA0B,CAAC;EACzE,IAAI,OAAO,SAAS,OAAO,IAAI,SAAS,EAAE,aAAa,gCAAgC,CAAC,CAAC;CAC3F,CAAC;CACD,QAAQ,OAAO;AACjB,CAAC;AAED,IAAa,SAAS,UAAU,KAAK;CACnC,MAAM;EACJ,KAAK,MAAI,KAAK,iCAAiC;EAC/C,MAAM;EACN,aAAa;EACb,MAAM;CACR;CACA,OAAO,OAAO,OAAO;EACnB,MAAM,OAAO,SAAS,OAAO,MAAM,CAAC,CAAC,SAAS,EAAE,aAAa,8BAA8B,CAAC;EAC5F,MAAM,OAAO,SAAS,OAAO,MAAM,CAAC,CAAC,SAAS,EAAE,aAAa,uCAAuC,CAAC;EACrG,SAAS,OAAO,SAAS,OAAO,MAAM,CAAC,CAAC,SAAS,EAAE,aAAa,0CAA0C,CAAC;CAC7G,CAAC;CACD,QAAQ,OAAO,OAAO,EACpB,IAAI,OAAO,OAAO,SAAS,EAAE,aAAa,gCAAgC,CAAC,EAC7E,CAAC;
|
|
1
|
+
{"version":3,"file":"SheetOperation.mjs","names":[],"sources":["../../src/types/SheetOperation.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Capability from '@dxos/app-framework/Capability';\nimport * as Operation from '@dxos/compute/Operation';\nimport { Database, Ref } from '@dxos/echo';\nimport { DXN } from '@dxos/keys';\n\nimport * as Sheet from './Sheet.ts';\n\n// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.\nconst Axis = Schema.Union([Schema.Literal('row'), Schema.Literal('col')]);\n\nexport const InsertAxis = Operation.make({\n meta: { key: DXN.make('org.dxos.operation.sheet.insertAxis'), name: 'Insert Axis', icon: 'ph--plus--regular' },\n input: Schema.Struct({\n model: Schema.Any,\n axis: Axis,\n index: Schema.Number,\n count: Schema.optional(Schema.Number),\n }),\n output: Schema.Void,\n});\n\nexport const DropAxisOutput = Schema.Struct({\n axis: Axis.annotate({ description: 'The axis type (row or col).' }),\n axisIndex: Schema.String.annotate({ description: 'The dropped axis index.' }),\n index: Schema.Number.annotate({ description: 'The position the axis was at.' }),\n axisMeta: Schema.Any.annotate({ description: 'The row/column metadata.' }),\n values: Schema.Array(Schema.Any).annotate({ description: 'The cell values that were dropped.' }),\n});\n\nexport type DropAxisOutput = Schema.Schema.Type<typeof DropAxisOutput>;\n\nexport const DropAxis = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.dropAxis'),\n name: 'Drop Axis',\n icon: 'ph--trash--regular',\n },\n input: Schema.Struct({\n model: Schema.Any,\n axis: Axis,\n axisIndex: Schema.String,\n }),\n output: DropAxisOutput,\n});\n\nexport const ScrollToAnchor = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.scrollToAnchor'),\n name: 'Scroll To Anchor',\n icon: 'ph--anchor-simple--regular',\n },\n services: [Capability.Service],\n input: Schema.Struct({\n subject: Schema.String.annotate({ description: 'Attendable ID of the sheet.' }),\n cursor: Schema.String.annotate({ description: 'Cell range coordinates.' }),\n id: Schema.optional(Schema.Any.annotate({ description: 'Active refs for highlighting.' })),\n }),\n output: Schema.Void,\n});\n\nexport const Create = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.create'),\n name: 'Create',\n description: 'Creates a new sheet and adds it to the space.',\n icon: 'ph--grid-nine--regular',\n },\n input: Schema.Struct({\n name: Schema.optional(Schema.String).annotate({ description: 'Display name for the sheet.' }),\n rows: Schema.optional(Schema.Number).annotate({ description: 'Initial number of rows (default 50).' }),\n columns: Schema.optional(Schema.Number).annotate({ description: 'Initial number of columns (default 26).' }),\n }),\n output: Schema.Struct({\n id: Schema.String.annotate({ description: 'The DXN of the created sheet.' }),\n }),\n // The capability manager carries the `DefaultParent` rule that files the sheet into the root\n // collection; an undeclared service is not provided, so without it the sheet is never filed.\n services: [Capability.Service, Database.Service],\n});\n\nexport const GetValues = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.getRange'),\n name: 'Get Range Values',\n description: 'Returns cell values from a sheet as a 2D array. Defaults to the entire occupied area.',\n icon: 'ph--table--regular',\n },\n input: Schema.Struct({\n sheet: Ref.Ref(Sheet.Sheet).annotate({ description: 'The sheet to read from.' }),\n range: Schema.optional(Schema.String).annotate({\n description: 'Range in A1 notation (e.g. \"A1:C5\"). Omit to return the entire occupied area.',\n }),\n }),\n output: Schema.Struct({\n values: Schema.Array(Schema.Array(Schema.Any)).annotate({\n description:\n '2D array of cell values indexed [row][col]. Empty cells are null. Formulas are shown in A1 notation.',\n }),\n range: Schema.String.annotate({ description: 'The A1 range actually returned (e.g. \"A1:E5\").' }),\n }),\n services: [Database.Service],\n});\n\nexport const SetValues = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.setRange'),\n name: 'Set Range Values',\n description: 'Sets multiple cell values in a sheet at once.',\n icon: 'ph--pencil--regular',\n },\n input: Schema.Struct({\n sheet: Ref.Ref(Sheet.Sheet).annotate({ description: 'The sheet to write to.' }),\n cells: Schema.Record(Schema.String, Schema.Any).annotate({\n description: 'Map of A1 address to value (e.g. { \"A1\": \"Name\", \"B1\": 42, \"C1\": \"=A1+B1\" }).',\n }),\n }),\n output: Schema.Void,\n services: [Database.Service],\n});\n\n/**\n * Restore a dropped axis (inverse of DropAxis).\n */\nexport const RestoreAxis = Operation.make({\n meta: {\n key: DXN.make('org.dxos.operation.sheet.restoreAxis'),\n name: 'Restore Axis',\n icon: 'ph--clock-counter-clockwise--regular',\n },\n input: Schema.Struct({\n model: Schema.Any.annotate({ description: 'The sheet model.' }),\n axis: Axis.annotate({ description: 'The axis type (row or col).' }),\n axisIndex: Schema.String.annotate({ description: 'The axis index to restore.' }),\n index: Schema.Number.annotate({ description: 'The position to restore at.' }),\n axisMeta: Schema.Any.annotate({ description: 'The row/column metadata.' }),\n values: Schema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Aa,YAAY,UAAU,KAAK;CACtC,MAAM;EACJ,KAAK,MAAI,KAAK,mCAAmC;EACjD,MAAM;EACN,aAAa;EACb,MAAM;CACR;CACA,OAAO,OAAO,OAAO;EACnB,OAAO,IAAI,IAAI,KAAW,CAAC,CAAC,SAAS,EAAE,aAAa,yBAAyB,CAAC;EAC9E,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,GAAG,CAAC,CAAC,SAAS,EACvD,aAAa,0FACf,CAAC;CACH,CAAC;CACD,QAAQ,OAAO;CACf,UAAU,CAAC,SAAS,OAAO;AAC7B,CAAC;;;;AAKD,IAAa,cAAc,UAAU,KAAK;CACxC,MAAM;EACJ,KAAK,MAAI,KAAK,sCAAsC;EACpD,MAAM;EACN,MAAM;CACR;CACA,OAAO,OAAO,OAAO;EACnB,OAAO,OAAO,IAAI,SAAS,EAAE,aAAa,mBAAmB,CAAC;EAC9D,MAAM,KAAK,SAAS,EAAE,aAAa,8BAA8B,CAAC;EAClE,WAAW,OAAO,OAAO,SAAS,EAAE,aAAa,6BAA6B,CAAC;EAC/E,OAAO,OAAO,OAAO,SAAS,EAAE,aAAa,8BAA8B,CAAC;EAC5E,UAAU,OAAO,IAAI,SAAS,EAAE,aAAa,2BAA2B,CAAC;EACzE,QAAQ,OAAO,MAAM,OAAO,GAAG,CAAC,CAAC,SAAS,EAAE,aAAa,8BAA8B,CAAC;CAC1F,CAAC;CACD,QAAQ,OAAO;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetRange.mjs","names":[],"sources":["../../src/types/SheetRange.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type ClassNameValue } from '@dxos/
|
|
1
|
+
{"version":3,"file":"SheetRange.mjs","names":[],"sources":["../../src/types/SheetRange.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type ClassNameValue } from '@dxos/ui-types';\n\nimport type * as Sheet from '../types/Sheet.ts';\n\nexport const alignKey = 'alignment';\nexport type AlignKey = typeof alignKey;\nexport type AlignValue = 'start' | 'center' | 'end';\n\nexport const commentKey = 'comment';\nexport type CommentKey = typeof commentKey;\nexport type CommentValue = string;\n\nexport const styleKey = 'style';\nexport type StyleKey = typeof styleKey;\nexport type StyleValue = 'highlight' | 'softwrap';\n\n// TODO(burdon): Reconcile with plugin-table.\nexport const cellClassNameForRange = ({ key, value }: Sheet.Sheet['ranges'][number]): ClassNameValue => {\n switch (key) {\n case alignKey:\n switch (value) {\n case 'start':\n return 'text-start';\n case 'center':\n return 'text-center';\n case 'end':\n return 'text-end';\n default:\n return undefined;\n }\n\n case commentKey:\n return 'bg-grid-comment';\n\n case styleKey:\n switch (value) {\n case 'highlight':\n return 'bg-grid-highlight!';\n case 'softwrap':\n return 'whitespace-normal!';\n default:\n return undefined;\n }\n\n default:\n return undefined;\n }\n};\n"],"mappings":";;;;;;;;AAQA,IAAa,WAAW;AAIxB,IAAa,aAAa;AAI1B,IAAa,WAAW;AAKxB,IAAa,yBAAyB,EAAE,KAAK,YAA2D;CACtG,QAAQ,KAAR;EACE,KAAK,UACH,QAAQ,OAAR;GACE,KAAK,SACH,OAAO;GACT,KAAK,UACH,OAAO;GACT,KAAK,OACH,OAAO;GACT,SACE;EACJ;EAEF,KAAK,YACH,OAAO;EAET,KAAK,UACH,QAAQ,OAAR;GACE,KAAK,aACH,OAAO;GACT,KAAK,YACH,OAAO;GACT,SACE;EACJ;EAEF,SACE;CACJ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetUtil.mjs","names":[],"sources":["../../src/types/SheetUtil.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n type CellAddress,\n type CellRange,\n type CompleteCellRange,\n addressFromA1Notation,\n addressToA1Notation,\n isFormula,\n} from '@dxos/compute-hyperformula/types';\nimport { randomBytes } from '@dxos/crypto/random';\nimport { type Obj } from '@dxos/echo';\nimport { assertArgument } from '@dxos/invariant';\n\nimport type * as Sheet from '../types/Sheet';\n\nexport const MAX_ROWS = 500;\nexport const MAX_COLS = 676; // 26^2;\n\nexport const DEFAULT_ROWS = 50;\nexport const DEFAULT_COLS = 26;\n\n// TODO(burdon): Factor out from dxos/protocols to new common package.\nexport class ApiError extends Error {}\n\nexport class ReadonlyException extends ApiError {}\n\nexport class RangeException extends ApiError {\n constructor(n: number) {\n super();\n }\n}\n\n/**\n * With a string length of 8, the chance of a collision is 0.02% for a sheet with 10,000 strings.\n */\nexport const createIndex = (length = 8): string => {\n const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charactersLength = characters.length;\n const randomBuffer = randomBytes(length);\n return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join('');\n};\n\nexport const createIndices = (length: number): string[] => Array.from({ length }).map(() => createIndex());\n\nexport const insertIndices = (indices: string[], i: number, n: number, max: number) => {\n if (i + n > max) {\n throw new RangeException(i + n);\n }\n\n const idx = createIndices(n);\n indices.splice(i, 0, ...idx);\n return idx;\n};\n\nexport const initialize = (\n sheet: Obj.Mutable<Sheet.Sheet>,\n { rows = DEFAULT_ROWS, columns = DEFAULT_COLS }: Partial<Sheet.SheetSize> = {},\n) => {\n if (!sheet.rows.length) {\n insertIndices(sheet.rows, 0, rows, MAX_ROWS);\n }\n if (!sheet.columns.length) {\n insertIndices(sheet.columns, 0, columns, MAX_COLS);\n }\n};\n\n/**\n * E.g., \"A1\" => \"CA2@CB3\".\n */\nexport const addressToIndex = (sheet: Sheet.Sheet, cell: CellAddress): string => {\n return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;\n};\n\n/**\n * E.g., \"CA2@CB3\" => \"A1\".\n */\nexport const addressFromIndex = (sheet: Sheet.Sheet, idx: string): CellAddress => {\n const [column, row] = idx.split('@');\n return {\n col: sheet.columns.indexOf(column),\n row: sheet.rows.indexOf(row),\n };\n};\n\n/**\n * E.g., \"A1:B2\" => \"CA2@CB3:CC4@CD5\".\n */\nexport const rangeToIndex = (sheet: Sheet.Sheet, range: CellRange): string => {\n return [range.from, range.to ?? range.from].map((cell) => addressToIndex(sheet, cell)).join(':');\n};\n\n/**\n * E.g., \"CA2@CB3:CC4@CD5\" => \"A1:B2\".\n */\nexport const rangeFromIndex = (sheet: Sheet.Sheet, idx: string): CompleteCellRange => {\n const [from, to] = idx.split(':').map((index) => addressFromIndex(sheet, index));\n return { from, to };\n};\n\n/**\n * Compares the positions of two cell indexes in a sheet.\n * Sorts primarily by row, then by column if rows are equal.\n */\nexport const compareIndexPositions = (sheet: Sheet.Sheet, indexA: string, indexB: string): number => {\n const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);\n const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);\n\n // Sort by row first, then by column.\n if (rowA !== rowB) {\n return rowA - rowB;\n } else {\n return columnA - columnB;\n }\n};\n\n// TODO(burdon): Tests.\n\n/**\n * Map from A1 notation to indices.\n */\nexport const mapFormulaRefsToIndices = (sheet: Sheet.Sheet, formula: string): string => {\n assertArgument(isFormula(formula), 'formula');\n return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {\n const cell = addressFromA1Notation(match);\n // Skip tokens whose parsed address falls outside the sheet bounds or is negative — they are\n // function names (e.g. LOG10, ATAN2) or malformed refs (e.g. A0 → row -1) rather than valid\n // cell references.\n if (cell.col < 0 || cell.row < 0 || cell.col >= sheet.columns.length || cell.row >= sheet.rows.length) {\n return match;\n }\n return addressToIndex(sheet, cell);\n });\n};\n\n/**\n * Map from indices to A1 notation.\n */\nexport const mapFormulaIndicesToRefs = (sheet: Sheet.Sheet, formula: string): string => {\n assertArgument(isFormula(formula), 'formula');\n return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {\n return addressToA1Notation(addressFromIndex(sheet, idx));\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,IAAa,WAAW;AACxB,IAAa,WAAW;AAExB,IAAa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MAAM,MAAM,MAAM,MAAM,MAAM,IAAI,CAAC,CAAC,KAAK,SAAS,eAAe,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG;AACjG;;;;AAKA,IAAa,kBAAkB,OAAoB,QAAmC;CACpF,MAAM,CAAC,MAAM,MAAM,IAAI,MAAM,GAAG,CAAC,CAAC,KAAK,UAAU,iBAAiB,OAAO,KAAK,CAAC;CAC/E,OAAO;EAAE;EAAM;CAAG;AACpB;;;;;AAMA,IAAa,yBAAyB,OAAoB,QAAgB,WAA2B;CACnG,MAAM,EAAE,KAAK,MAAM,KAAK,YAAY,iBAAiB,OAAO,MAAM;CAClE,MAAM,EAAE,KAAK,MAAM,KAAK,YAAY,iBAAiB,OAAO,MAAM;CAGlE,IAAI,SAAS,MACX,OAAO,OAAO;MAEd,OAAO,UAAU;AAErB;;;;AAOA,IAAa,2BAA2B,OAAoB,YAA4B;CACtF,eAAe,UAAU,OAAO,GAAG,SAAS;CAC5C,OAAO,QAAQ,QAAQ,yBAAyB,UAAU;EACxD,MAAM,OAAO,sBAAsB,KAAK;EAIxC,IAAI,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK,KAAK,OAAO,MAAM,QAAQ,UAAU,KAAK,OAAO,MAAM,KAAK,QAC7F,OAAO;EAET,OAAO,eAAe,OAAO,IAAI;CACnC,CAAC;AACH;;;;AAKA,IAAa,2BAA2B,OAAoB,YAA4B;CACtF,eAAe,UAAU,OAAO,GAAG,SAAS;CAC5C,OAAO,QAAQ,QAAQ,mCAAmC,QAAQ;EAChE,OAAO,oBAAoB,iBAAiB,OAAO,GAAG,CAAC;CACzD,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"SheetUtil.mjs","names":[],"sources":["../../src/types/SheetUtil.ts"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n type CellAddress,\n type CellRange,\n type CompleteCellRange,\n addressFromA1Notation,\n addressToA1Notation,\n isFormula,\n} from '@dxos/compute-hyperformula/types';\nimport { randomBytes } from '@dxos/crypto/random';\nimport { type Obj } from '@dxos/echo';\nimport { assertArgument } from '@dxos/invariant';\n\nimport type * as Sheet from '../types/Sheet.ts';\n\nexport const MAX_ROWS = 500;\nexport const MAX_COLS = 676; // 26^2;\n\nexport const DEFAULT_ROWS = 50;\nexport const DEFAULT_COLS = 26;\n\n// TODO(burdon): Factor out from dxos/protocols to new common package.\nexport class ApiError extends Error {}\n\nexport class ReadonlyException extends ApiError {}\n\nexport class RangeException extends ApiError {\n constructor(n: number) {\n super();\n }\n}\n\n/**\n * With a string length of 8, the chance of a collision is 0.02% for a sheet with 10,000 strings.\n */\nexport const createIndex = (length = 8): string => {\n const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charactersLength = characters.length;\n const randomBuffer = randomBytes(length);\n return Array.from(randomBuffer, (byte) => characters[byte % charactersLength]).join('');\n};\n\nexport const createIndices = (length: number): string[] => Array.from({ length }).map(() => createIndex());\n\nexport const insertIndices = (indices: string[], i: number, n: number, max: number) => {\n if (i + n > max) {\n throw new RangeException(i + n);\n }\n\n const idx = createIndices(n);\n indices.splice(i, 0, ...idx);\n return idx;\n};\n\nexport const initialize = (\n sheet: Obj.Mutable<Sheet.Sheet>,\n { rows = DEFAULT_ROWS, columns = DEFAULT_COLS }: Partial<Sheet.SheetSize> = {},\n) => {\n if (!sheet.rows.length) {\n insertIndices(sheet.rows, 0, rows, MAX_ROWS);\n }\n if (!sheet.columns.length) {\n insertIndices(sheet.columns, 0, columns, MAX_COLS);\n }\n};\n\n/**\n * E.g., \"A1\" => \"CA2@CB3\".\n */\nexport const addressToIndex = (sheet: Sheet.Sheet, cell: CellAddress): string => {\n return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;\n};\n\n/**\n * E.g., \"CA2@CB3\" => \"A1\".\n */\nexport const addressFromIndex = (sheet: Sheet.Sheet, idx: string): CellAddress => {\n const [column, row] = idx.split('@');\n return {\n col: sheet.columns.indexOf(column),\n row: sheet.rows.indexOf(row),\n };\n};\n\n/**\n * E.g., \"A1:B2\" => \"CA2@CB3:CC4@CD5\".\n */\nexport const rangeToIndex = (sheet: Sheet.Sheet, range: CellRange): string => {\n return [range.from, range.to ?? range.from].map((cell) => addressToIndex(sheet, cell)).join(':');\n};\n\n/**\n * E.g., \"CA2@CB3:CC4@CD5\" => \"A1:B2\".\n */\nexport const rangeFromIndex = (sheet: Sheet.Sheet, idx: string): CompleteCellRange => {\n const [from, to] = idx.split(':').map((index) => addressFromIndex(sheet, index));\n return { from, to };\n};\n\n/**\n * Compares the positions of two cell indexes in a sheet.\n * Sorts primarily by row, then by column if rows are equal.\n */\nexport const compareIndexPositions = (sheet: Sheet.Sheet, indexA: string, indexB: string): number => {\n const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);\n const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);\n\n // Sort by row first, then by column.\n if (rowA !== rowB) {\n return rowA - rowB;\n } else {\n return columnA - columnB;\n }\n};\n\n// TODO(burdon): Tests.\n\n/**\n * Map from A1 notation to indices.\n */\nexport const mapFormulaRefsToIndices = (sheet: Sheet.Sheet, formula: string): string => {\n assertArgument(isFormula(formula), 'formula');\n return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {\n const cell = addressFromA1Notation(match);\n // Skip tokens whose parsed address falls outside the sheet bounds or is negative — they are\n // function names (e.g. LOG10, ATAN2) or malformed refs (e.g. A0 → row -1) rather than valid\n // cell references.\n if (cell.col < 0 || cell.row < 0 || cell.col >= sheet.columns.length || cell.row >= sheet.rows.length) {\n return match;\n }\n return addressToIndex(sheet, cell);\n });\n};\n\n/**\n * Map from indices to A1 notation.\n */\nexport const mapFormulaIndicesToRefs = (sheet: Sheet.Sheet, formula: string): string => {\n assertArgument(isFormula(formula), 'formula');\n return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {\n return addressToA1Notation(addressFromIndex(sheet, idx));\n });\n};\n"],"mappings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
+
import * as Capability from "@dxos/app-framework/Capability";
|
|
4
|
+
import * as AppCapability from "@dxos/app-toolkit/AppCapability";
|
|
5
|
+
import { translations } from "#translations";
|
|
6
|
+
import { SheetCapabilities, SheetEvents } from "#types";
|
|
7
|
+
import * as Capabilities from "@dxos/app-framework/Capabilities";
|
|
8
|
+
import * as ClientCapabilities from "@dxos/plugin-client/ClientCapabilities";
|
|
9
|
+
import * as MarkdownCapabilities from "@dxos/plugin-markdown/MarkdownCapabilities";
|
|
10
|
+
import * as MarkdownEvents from "@dxos/plugin-markdown/MarkdownEvents";
|
|
11
|
+
import * as SpaceCapability from "@dxos/plugin-space/SpaceCapability";
|
|
12
|
+
import * as AppCapabilities from "@dxos/app-toolkit/AppCapabilities";
|
|
13
|
+
import { meta } from "#meta";
|
|
14
|
+
//#region src/capabilities/gen/browser.ts
|
|
15
|
+
var AnchorSort = AppCapability.anchorSort(() => import("./chunk-anchor-sort.mjs"), {
|
|
16
|
+
requires: [AppCapabilities.AppGraph],
|
|
17
|
+
activatesOn: SheetEvents.Start
|
|
18
|
+
});
|
|
19
|
+
var CommentConfig = AppCapability.commentConfig(() => import("./chunk-comment-config.mjs"), {
|
|
20
|
+
activatesOn: SheetEvents.Start,
|
|
21
|
+
environments: [
|
|
22
|
+
"browser",
|
|
23
|
+
"node",
|
|
24
|
+
"tauri"
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
var ComputeGraphRegistry = Capability.lazyModule("ComputeGraphRegistry", {
|
|
28
|
+
requires: [ClientCapabilities.Client, Capabilities.ProcessManagerRuntime],
|
|
29
|
+
provides: [SheetCapabilities.ComputeGraphRegistry],
|
|
30
|
+
environments: [
|
|
31
|
+
"browser",
|
|
32
|
+
"node",
|
|
33
|
+
"tauri"
|
|
34
|
+
]
|
|
35
|
+
}, () => import("./chunk-compute-graph-registry.mjs"));
|
|
36
|
+
var CreateObject = SpaceCapability.createObject(() => import("./chunk-create-object.mjs"), { environments: [
|
|
37
|
+
"browser",
|
|
38
|
+
"node",
|
|
39
|
+
"tauri"
|
|
40
|
+
] });
|
|
41
|
+
var Markdown = Capability.lazyModule("MarkdownExtension", {
|
|
42
|
+
requires: [SheetCapabilities.ComputeGraphRegistry],
|
|
43
|
+
provides: [MarkdownCapabilities.ExtensionProvider],
|
|
44
|
+
activatesOn: MarkdownEvents.Start,
|
|
45
|
+
environments: [
|
|
46
|
+
"browser",
|
|
47
|
+
"node",
|
|
48
|
+
"tauri"
|
|
49
|
+
]
|
|
50
|
+
}, () => import("./chunk-markdown-extension.mjs"));
|
|
51
|
+
var OperationHandler = AppCapability.operationHandler(() => import("./chunk-operation-handler.mjs"), { activatesOn: ActivationEvents.Idle });
|
|
52
|
+
var ReactSurface = AppCapability.surface(() => import("./chunk-react-surface.mjs"), { roles: [
|
|
53
|
+
"org.dxos.role.article",
|
|
54
|
+
"org.dxos.role.objectProperties",
|
|
55
|
+
"org.dxos.role.section"
|
|
56
|
+
] });
|
|
57
|
+
var Schema = AppCapability.schema(() => import("./chunk-schema.mjs"));
|
|
58
|
+
var SheetState = Capability.lazyModule("SheetState", {
|
|
59
|
+
provides: [SheetCapabilities.GridInstances],
|
|
60
|
+
activatesOn: SheetEvents.Start
|
|
61
|
+
}, () => import("./chunk-state.mjs"));
|
|
62
|
+
var SkillDefinition = AppCapability.skillDefinition(() => import("./chunk-skill-definition.mjs"), { environments: [
|
|
63
|
+
"browser",
|
|
64
|
+
"node",
|
|
65
|
+
"tauri"
|
|
66
|
+
] });
|
|
67
|
+
var UndoMappings = AppCapability.undoMappings(() => import("./chunk-undo-mappings.mjs"), {
|
|
68
|
+
activatesOn: SheetEvents.Start,
|
|
69
|
+
environments: [
|
|
70
|
+
"browser",
|
|
71
|
+
"node",
|
|
72
|
+
"tauri"
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
var Translations = AppCapability.translations(translations);
|
|
76
|
+
var PluginAsset = AppCapability.pluginAsset({
|
|
77
|
+
pluginId: meta.profile.key,
|
|
78
|
+
path: "PLUGIN.mdl",
|
|
79
|
+
content: PLUGIN_default,
|
|
80
|
+
mimeType: "application/x-mdl"
|
|
81
|
+
});
|
|
82
|
+
//#endregion
|
|
83
|
+
export { AnchorSort, CommentConfig, ComputeGraphRegistry, CreateObject, Markdown, OperationHandler, PluginAsset, ReactSurface, Schema, SheetState, SkillDefinition, Translations, UndoMappings };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=capabilities.browser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.browser.mjs","names":[],"sources":["../../src/capabilities/gen/browser.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// GENERATED by dx-plugin — do not edit. Sliced from ../index.ts for the 'browser' condition.\n\nimport * as ActivationEvents from '@dxos/app-framework/ActivationEvents';\nimport * as Capabilities from '@dxos/app-framework/Capabilities';\nimport * as Capability from '@dxos/app-framework/Capability';\nimport * as AppCapabilities from '@dxos/app-toolkit/AppCapabilities';\nimport * as AppCapability from '@dxos/app-toolkit/AppCapability';\nimport * as ClientCapabilities from '@dxos/plugin-client/ClientCapabilities';\nimport * as MarkdownCapabilities from '@dxos/plugin-markdown/MarkdownCapabilities';\nimport * as MarkdownEvents from '@dxos/plugin-markdown/MarkdownEvents';\nimport * as SpaceCapability from '@dxos/plugin-space/SpaceCapability';\n\nimport { meta } from '#meta';\nimport { translations } from '#translations';\nimport { SheetCapabilities, SheetEvents } from '#types';\n\nimport pluginSpec from '../../../PLUGIN.mdl?raw';\n\n// Ordering-only: registers the sort comparator once the app graph exists; the body reads\n// nothing else.\nexport const AnchorSort = AppCapability.anchorSort(() => import('../anchor-sort.ts'), {\n requires: [AppCapabilities.AppGraph],\n activatesOn: SheetEvents.Start,\n});\n\nexport const CommentConfig = AppCapability.commentConfig(() => import('../comment-config.ts'), {\n activatesOn: SheetEvents.Start,\n environments: ['browser', 'node', 'tauri'],\n});\n\nexport const ComputeGraphRegistry = Capability.lazyModule(\n 'ComputeGraphRegistry',\n {\n // Headless: formulas evaluate in a markdown document with no sheet surface ever rendered, so\n // gating this on the sheet's own start conflates \"the sheet UI is on screen\" with \"compute\n // graphs exist\". Ungated (hence idle) it also becomes pullable by the consumers that need it\n // earlier, which a start-gated provider is not.\n requires: [ClientCapabilities.Client, Capabilities.ProcessManagerRuntime],\n provides: [SheetCapabilities.ComputeGraphRegistry],\n // Needs a client, which headless hosts (EDGE) do not provide.\n environments: ['browser', 'node', 'tauri'],\n },\n () => import('../compute-graph-registry.ts'),\n);\n\nexport const CreateObject = SpaceCapability.createObject(() => import('../create-object.ts'), {\n environments: ['browser', 'node', 'tauri'],\n});\n\nexport const Markdown = Capability.lazyModule(\n 'MarkdownExtension',\n {\n // The provider callbacks read the registry, so it must be in place when this activates.\n requires: [SheetCapabilities.ComputeGraphRegistry],\n provides: [MarkdownCapabilities.ExtensionProvider],\n activatesOn: MarkdownEvents.Start,\n // Follows its required registry, which headless hosts (EDGE) do not provide.\n environments: ['browser', 'node', 'tauri'],\n },\n () => import('../markdown-extension.ts'),\n);\n\nexport const OperationHandler = AppCapability.operationHandler(() => import('../operation-handler.ts'), {\n activatesOn: ActivationEvents.Idle,\n});\n\nexport const ReactSurface = AppCapability.surface(() => import('../react-surface.ts'), {\n roles: ['org.dxos.role.article', 'org.dxos.role.objectProperties', 'org.dxos.role.section'],\n});\n\nexport const Schema = AppCapability.schema(() => import('../schema.ts'));\n\nexport const SheetState = Capability.lazyModule(\n 'SheetState',\n { provides: [SheetCapabilities.GridInstances], activatesOn: SheetEvents.Start },\n () => import('../state.ts'),\n);\n\nexport const SkillDefinition = AppCapability.skillDefinition(() => import('../skill-definition.ts'), {\n environments: ['browser', 'node', 'tauri'],\n});\n\nexport const UndoMappings = AppCapability.undoMappings(() => import('../undo-mappings.ts'), {\n activatesOn: SheetEvents.Start,\n environments: ['browser', 'node', 'tauri'],\n});\n\nexport const Translations = AppCapability.translations(translations);\n\nexport const PluginAsset = AppCapability.pluginAsset({\n pluginId: meta.profile.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AAe,cAAc,mBAAmB,OAAO,8BAAwB;CAC1F,aAAa,YAAY;CACzB,cAAc;EAAC;EAAW;EAAQ;CAAO;AAC3C,CAAC;AAED,IAAa,eAAe,cAAc,aAAa,YAAY;AAEnE,IAAa,cAAc,cAAc,YAAY;CACnD,UAAU,KAAK,QAAQ;CACvB,MAAM;CACN,SAAS;CACT,UAAU;AACZ,CAAC"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
+
import { t as PLUGIN_default } from "./chunk-PLUGIN.mjs";
|
|
1
2
|
import * as ActivationEvents from "@dxos/app-framework/ActivationEvents";
|
|
2
|
-
import * as Capabilities from "@dxos/app-framework/Capabilities";
|
|
3
3
|
import * as Capability from "@dxos/app-framework/Capability";
|
|
4
4
|
import * as AppCapability from "@dxos/app-toolkit/AppCapability";
|
|
5
|
+
import { translations } from "#translations";
|
|
6
|
+
import { SheetCapabilities, SheetEvents } from "#types";
|
|
7
|
+
import * as Capabilities from "@dxos/app-framework/Capabilities";
|
|
5
8
|
import * as ClientCapabilities from "@dxos/plugin-client/ClientCapabilities";
|
|
6
9
|
import * as MarkdownCapabilities from "@dxos/plugin-markdown/MarkdownCapabilities";
|
|
7
10
|
import * as MarkdownEvents from "@dxos/plugin-markdown/MarkdownEvents";
|
|
8
|
-
import { translations } from "#translations";
|
|
9
|
-
import { SheetCapabilities, SheetEvents } from "#types";
|
|
10
11
|
import * as SpaceCapability from "@dxos/plugin-space/SpaceCapability";
|
|
11
12
|
import * as AppCapabilities from "@dxos/app-toolkit/AppCapabilities";
|
|
12
13
|
import { meta } from "#meta";
|
|
13
|
-
//#region PLUGIN.mdl?raw
|
|
14
|
-
var PLUGIN_default = "---\nid: org.dxos.plugin.sheet\nname: SheetPlugin\nversion: 0.1.0\n---\n\nSpreadsheet plugin for `DXOS` Composer — a full-featured grid backed by ECHO for local-first, real-time collaborative data entry, formula evaluation, and structured data display.\n\n## Extensions\n\nThe following extension dialects are used in this document.\nEach extension is defined in the Appendix or resolved via its URI.\n\n| Term | URI |\n|-------------|--------------------------------|\n| `type` | `org.dxos.mdl.type@1.0` |\n| `feat` | `org.dxos.mdl.feat@1.0` |\n| `test` | `org.dxos.mdl.test@1.0` |\n| `component` | `org.dxos.mdl.component@1.0` |\n| `op` | `org.dxos.mdl.op@1.0` |\n\n## Types\n\n```mdl\ntype CellValue\n fields:\n value: any # scalar: string | number | boolean | formula string\n```\n\n```mdl\ntype RowColumnMeta\n fields:\n size?: number # pixel width/height; absent means default\n```\n\n```mdl\ntype Range\n fields:\n range: string # A1-notation range (e.g. \"A1:C3\")\n key: string # formatting key: alignment | comment | style\n value: string # formatting value (e.g. \"center\", \"highlight\")\n```\n\n```mdl\ntype Axis\n literals: row | col\n```\n\n```mdl\ntype Sheet\n typename: org.dxos.type.sheet\n fields:\n name?: string\n cells: Map<string, CellValue> # sparse map keyed by internal cell index\n rows: string[] # ordered row indices\n columns: string[] # ordered column indices\n rowMeta: Map<string, RowColumnMeta>\n columnMeta: Map<string, RowColumnMeta>\n ranges: Range[] # range-based formatting annotations\n```\n\n## Components\n\n```mdl\ncomponent SheetArticle\n desc: Primary spreadsheet view rendered inside an article or section role surface.\n props:\n subject: Sheet\n attendableId: string\n space: Space\n registry: ComputeGraphRegistry\n state:\n selected?: CellAddress\n activeRefs?: GridContentProps['activeRefs']\n slots:\n toolbar?: ReactNode\n actions:\n selectCell(address: CellAddress)\n editCell(address: CellAddress, value: any)\n insertRow(index: number)\n insertColumn(index: number)\n dropRow(axisIndex: string)\n dropColumn(axisIndex: string)\n layout: |\n ┌───────────────────────────────────┐\n │ [toolbar slot] │\n ├───┬───┬───┬───┬───────────────────┤\n │ │ A │ B │ C │ … column header │\n ├───┼───┼───┼───┤ │\n │ 1 │ │ │ │ cell grid │\n ├───┼───┼───┼───┤ │\n │ 2 │ │ │ │ │\n │ … │ │ │ │ │\n └───┴───┴───┴───┴───────────────────┘\n```\n\n```mdl\ncomponent RangeList\n desc: Object-properties panel listing named ranges and formatting annotations on a Sheet.\n props:\n sheet: Sheet\n state:\n selected?: Range\n actions:\n addRange(range: Range)\n removeRange(range: Range)\n updateRange(range: Range)\n```\n\n## Operations\n\n```mdl\nop insertAxis\n desc: Inserts one or more rows or columns at the given index in the sheet model.\n input:\n model: SheetModel\n axis: Axis\n index: number\n count?: number # defaults to 1\n output: void\n effects: [echo:write]\n```\n\n```mdl\nop dropAxis\n desc: Removes a row or column by axis index, returning data needed to restore it (undo).\n input:\n model: SheetModel\n axis: Axis\n axisIndex: string\n output: DropAxisOutput # axis, axisIndex, index, axisMeta, values\n effects: [echo:write]\n```\n\n```mdl\nop restoreAxis\n desc: Restores a previously dropped row or column (undo of dropAxis).\n input:\n model: SheetModel\n axis: Axis\n axisIndex: string # original axis index to restore\n index: number # original position\n axisMeta: RowColumnMeta\n values: any[] # cell values to re-insert\n output: void\n effects: [echo:write]\n```\n\n```mdl\nop scrollToAnchor\n desc: Programmatically scrolls and highlights a cell range in an active grid instance.\n input:\n subject: string # attendable ID of the target sheet\n cursor: string # A1-notation cell or range\n ref?: any # active refs for highlight overlay\n output: void\n effects: [ui:scroll]\n```\n\n## Features\n\n```mdl\nfeat F-1: Sheet Object\n\n req F-1.1: A Sheet is an ECHO object with typename org.dxos.type.sheet persisted in the user's space.\n req F-1.2: Cells are stored in a sparse map keyed by internal row/column indices.\n req F-1.3: Row and column order is maintained via ordered index arrays; insertion/deletion preserves existing cell references.\n req F-1.4: Range-based formatting annotations are stored as a flat array on the Sheet object.\n```\n\n```mdl\nfeat F-2: Formula Evaluation\n\n req F-2.1: Formulas are prefixed with \"=\" and evaluated by the HyperFormula engine via the ComputeGraph.\n req F-2.2: Over 400 built-in functions are available (arithmetic, statistical, text, date/time, financial, logical).\n req F-2.3:\n when: a cell value changes\n then: all dependent formula cells are recomputed reactively\n req F-2.4: Cell references in stored formulas are translated to internal indices; A1-notation is converted on read/write.\n```\n\n```mdl\nfeat F-3: Row and Column Management\n\n req F-3.1:\n when: op:insertAxis is called\n then: a new row or column is inserted at the specified index; existing cells shift accordingly\n\n req F-3.2:\n when: op:dropAxis is called\n then: the row or column is removed and undo data returned; op:restoreAxis reverses the operation\n\n req F-3.3: Row and column sizes are persisted in rowMeta/columnMeta; absent size means default grid size.\n```\n\n```mdl\nfeat F-4: Cell Formatting\n\n req F-4.1: Ranges support alignment values: start | center | end.\n req F-4.2: Ranges support comment annotations displayed as a visual overlay on the cell.\n req F-4.3: Ranges support style values: highlight | softwrap.\n req F-4.4: RangeList in the object-properties surface allows users to view and manage range annotations.\n```\n\n```mdl\nfeat F-5: Collaborative Editing\n\n req F-5.1: All cell edits are written through ECHO and replicated to peers in real time.\n req F-5.2:\n when: a peer writes a cell value\n then: the local grid re-renders with the updated value without full reload\n\n req F-5.3: ComputeGraphRegistry manages per-space HyperFormula instances so all peers share the same formula graph.\n```\n\n```mdl\nfeat F-6: Markdown Integration\n\n req F-6.1: SheetPlugin contributes a CodeMirror extension to plugin-markdown via MarkdownCapabilities.ExtensionProvider.\n req F-6.2:\n when: the extension is active in a document that belongs to a space\n then: formula references inside Markdown fenced code blocks resolve against the space's ComputeGraph\n```\n\n```mdl\nfeat F-7: Anchor Navigation\n\n req F-7.1:\n when: op:scrollToAnchor is invoked with a sheet attendable ID and cursor\n then: the corresponding SheetArticle scrolls to the target cell and applies the active-ref highlight\n\n req F-7.2: AnchorSort contributes a sort comparator so sheet anchors appear in canonical order in navigation menus.\n```\n\n## Acceptance\n\n```mdl\ntest T-1: Create sheet and enter a value\n given: a new Sheet is created in a space\n when: user types \"42\" into cell A1\n then:\n - Sheet.cells contains an entry for the A1 index with value 42\n - grid displays \"42\" in the A1 cell\n```\n\n```mdl\ntest T-2: Formula evaluation\n given: A1 = 10, A2 = 20\n when: user enters \"=A1+A2\" in A3\n then:\n - A3 displays 30\n - changing A1 to 15 causes A3 to update to 35\n```\n\n```mdl\ntest T-3: Insert and drop row\n given: a Sheet with values in rows 1 and 2\n when: op:insertAxis runs with axis=row, index=1\n then:\n - a blank row is inserted between existing rows 1 and 2\n - existing cell references remain valid\n\n when: op:dropAxis runs on the inserted row\n then:\n - the row is removed\n - op:restoreAxis re-inserts the row with its original values\n```\n\n```mdl\ntest T-4: Range formatting\n given: a Sheet open in SheetArticle\n when: user applies \"highlight\" style to range B2:C4\n then:\n - Sheet.ranges contains an entry with range=\"B2:C4\", key=\"style\", value=\"highlight\"\n - cells in B2:C4 render with the highlight background class\n```\n\n```mdl\ntest T-5: Real-time collaboration\n given: two peers have the same Sheet open\n when: peer A sets cell D5 to \"hello\"\n then:\n - peer B's grid displays \"hello\" in D5 without reload\n```\n\n```mdl\ntest T-6: Scroll to anchor\n given: a SheetArticle is mounted with attendableId \"sheet-1\"\n when: op:scrollToAnchor runs with subject=\"sheet-1\", cursor=\"E10\"\n then:\n - the grid scrolls so that E10 is visible\n - E10 is highlighted via activeRefs\n```\n\n---\n\n## Appendix: Extension Definitions\n\n```mdl\next type\n uri: org.dxos.mdl.type@1.0\n desc: A named data structure with typed fields and optional literals.\n fields:\n desc?: Prose\n fields?: FieldMap\n literals?: UnionList\n extends?: TypeRef[]\n```\n\n```mdl\next feat\n uri: org.dxos.mdl.feat@1.0\n desc: A named feature grouping one or more requirements.\n fields:\n desc?: Prose\n req: RequirementList\n nesting: self\n```\n\n```mdl\next test\n uri: org.dxos.mdl.test@1.0\n desc: An acceptance scenario expressed as given / when / then steps.\n fields:\n given?: Step | Step[]\n when?: Step | Step[]\n then: Step | Step[]\n tags?: TagList\n```\n\n```mdl\next component\n uri: org.dxos.mdl.component@1.0\n desc: A UI component with props, internal state, slots, actions, and events.\n fields:\n desc?: Prose\n props?: FieldMap\n state?: FieldMap\n slots?: FieldMap\n actions?: ActionMap\n emits?: EventMap\n layout?: CodeBlock\n```\n\n```mdl\next op\n uri: org.dxos.mdl.op@1.0\n desc: |\n A named operation with typed inputs, outputs, and declared errors.\n Pure ops have no effects or requires. Effectful ops declare both.\n fields:\n desc?: Prose\n input?: FieldMap\n output?: TypeExpr\n errors?: ErrorMap\n effects?: EffectList\n requires?: ServiceList\n note?: Prose\n```\n";
|
|
15
|
-
//#endregion
|
|
16
14
|
//#region src/capabilities/index.ts
|
|
17
15
|
var AnchorSort = AppCapability.anchorSort(() => import("./chunk-anchor-sort.mjs"), {
|
|
18
16
|
requires: [AppCapabilities.AppGraph],
|
|
@@ -20,17 +18,35 @@ var AnchorSort = AppCapability.anchorSort(() => import("./chunk-anchor-sort.mjs"
|
|
|
20
18
|
});
|
|
21
19
|
var CommentConfig = AppCapability.commentConfig(() => import("./chunk-comment-config.mjs"), {
|
|
22
20
|
activatesOn: SheetEvents.Start,
|
|
23
|
-
environments: [
|
|
21
|
+
environments: [
|
|
22
|
+
"browser",
|
|
23
|
+
"node",
|
|
24
|
+
"tauri"
|
|
25
|
+
]
|
|
24
26
|
});
|
|
25
27
|
var ComputeGraphRegistry = Capability.lazyModule("ComputeGraphRegistry", {
|
|
26
28
|
requires: [ClientCapabilities.Client, Capabilities.ProcessManagerRuntime],
|
|
27
|
-
provides: [SheetCapabilities.ComputeGraphRegistry]
|
|
29
|
+
provides: [SheetCapabilities.ComputeGraphRegistry],
|
|
30
|
+
environments: [
|
|
31
|
+
"browser",
|
|
32
|
+
"node",
|
|
33
|
+
"tauri"
|
|
34
|
+
]
|
|
28
35
|
}, () => import("./chunk-compute-graph-registry.mjs"));
|
|
29
|
-
var CreateObject = SpaceCapability.createObject(() => import("./chunk-create-object.mjs"), { environments: [
|
|
36
|
+
var CreateObject = SpaceCapability.createObject(() => import("./chunk-create-object.mjs"), { environments: [
|
|
37
|
+
"browser",
|
|
38
|
+
"node",
|
|
39
|
+
"tauri"
|
|
40
|
+
] });
|
|
30
41
|
var Markdown = Capability.lazyModule("MarkdownExtension", {
|
|
31
42
|
requires: [SheetCapabilities.ComputeGraphRegistry],
|
|
32
43
|
provides: [MarkdownCapabilities.ExtensionProvider],
|
|
33
|
-
activatesOn: MarkdownEvents.Start
|
|
44
|
+
activatesOn: MarkdownEvents.Start,
|
|
45
|
+
environments: [
|
|
46
|
+
"browser",
|
|
47
|
+
"node",
|
|
48
|
+
"tauri"
|
|
49
|
+
]
|
|
34
50
|
}, () => import("./chunk-markdown-extension.mjs"));
|
|
35
51
|
var OperationHandler = AppCapability.operationHandler(() => import("./chunk-operation-handler.mjs"), { activatesOn: ActivationEvents.Idle });
|
|
36
52
|
var ReactSurface = AppCapability.surface(() => import("./chunk-react-surface.mjs"), { roles: [
|
|
@@ -43,10 +59,18 @@ var SheetState = Capability.lazyModule("SheetState", {
|
|
|
43
59
|
provides: [SheetCapabilities.GridInstances],
|
|
44
60
|
activatesOn: SheetEvents.Start
|
|
45
61
|
}, () => import("./chunk-state.mjs"));
|
|
46
|
-
var SkillDefinition = AppCapability.skillDefinition(() => import("./chunk-skill-definition.mjs"), { environments: [
|
|
62
|
+
var SkillDefinition = AppCapability.skillDefinition(() => import("./chunk-skill-definition.mjs"), { environments: [
|
|
63
|
+
"browser",
|
|
64
|
+
"node",
|
|
65
|
+
"tauri"
|
|
66
|
+
] });
|
|
47
67
|
var UndoMappings = AppCapability.undoMappings(() => import("./chunk-undo-mappings.mjs"), {
|
|
48
68
|
activatesOn: SheetEvents.Start,
|
|
49
|
-
environments: [
|
|
69
|
+
environments: [
|
|
70
|
+
"browser",
|
|
71
|
+
"node",
|
|
72
|
+
"tauri"
|
|
73
|
+
]
|
|
50
74
|
});
|
|
51
75
|
var Translations = AppCapability.translations(translations);
|
|
52
76
|
var PluginAsset = AppCapability.pluginAsset({
|