@marimo-team/islands 0.25.3-dev170 → 0.25.3-dev175
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ConnectedDataExplorerComponent-BbSXV-Xa.js → ConnectedDataExplorerComponent-Le_OBfmt.js} +9 -9
- package/dist/{ErrorBoundary-NE86qEWZ.js → ErrorBoundary-DNvcAIsP.js} +8 -8
- package/dist/{abnfDiagram-VCTEODGH-D7n07nXf.js → abnfDiagram-VCTEODGH-Tf1ghyQQ.js} +2 -2
- package/dist/{any-language-editor-3E24SnCV.js → any-language-editor-BVFHDDQ3.js} +4 -4
- package/dist/{architectureDiagram-5GKGNRK7-D6CjRib5.js → architectureDiagram-5GKGNRK7-xlnbTG0T.js} +1 -1
- package/dist/{chat-ui-CC7GekpG.js → chat-ui-X-cWrL9u.js} +1218 -1218
- package/dist/{check-SpOMoCLP.js → check-C9Mp9eCK.js} +1 -1
- package/dist/{chunk-IMKFNOWR-6dtPz7uS.js → chunk-IMKFNOWR-Cmd4a5jy.js} +1 -1
- package/dist/{chunk-SHT3W25Y-BwnFNKDA.js → chunk-SHT3W25Y-mSNp-WpO.js} +1 -1
- package/dist/{chunk-SVP7TREG-D2eV4vBJ.js → chunk-SVP7TREG-CWC49D8X.js} +1 -1
- package/dist/{chunk-TICWLB2K-BDs4-_-r.js → chunk-TICWLB2K-De9FINtG.js} +1 -1
- package/dist/{classDiagram-ZZMXUADV-DCJnf_8v.js → classDiagram-ZZMXUADV-DweTkYdp.js} +2 -2
- package/dist/{classDiagram-v2-VYDZK3BY-BOmSzPBD.js → classDiagram-v2-VYDZK3BY-A6MR2TiE.js} +2 -2
- package/dist/{code-visibility-Bzvc6ajl.js → code-visibility-CH1lmM1h.js} +5 -5
- package/dist/{common-Ciw4zkh2.js → common-DIrS1UR9.js} +1081 -1085
- package/dist/{copy-icon-C1trdvVt.js → copy-icon-De584pZ4.js} +2 -2
- package/dist/{cynefinDiagram-5FMLGOSQ-Bln_Soky.js → cynefinDiagram-5FMLGOSQ-BSvo5le-.js} +1 -1
- package/dist/{dagre-GXQ25YYZ-D-nf7WzW.js → dagre-GXQ25YYZ-tXRQslO6.js} +1 -1
- package/dist/{data-grid-overlay-editor-AQREmxI7.js → data-grid-overlay-editor-DFLZvFK0.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-PsgSMkY2.js → diagram-S7CK7UJ4-r3t5VtwI.js} +1 -1
- package/dist/{diagram-UQ7AKVKN-DfwfUuSw.js → diagram-UQ7AKVKN-qgbC8YnT.js} +1 -1
- package/dist/{diagram-VX7I27RA-C9_e-oMc.js → diagram-VX7I27RA-CiHxEwtp.js} +1 -1
- package/dist/{diagram-Z3DM3KII-CWLa5tuY.js → diagram-Z3DM3KII-D95u15Ev.js} +1 -1
- package/dist/{dialog-DgeqyrEZ.js → dialog-DVRfQuhD.js} +24 -24
- package/dist/{dist-F8Ep36rk.js → dist-B1M0bGO3.js} +1 -1
- package/dist/{dist-D6d86eNJ.js → dist-BA13RJj5.js} +1 -1
- package/dist/{dist-Bvs24R_E.js → dist-BJtmSgcE.js} +48 -48
- package/dist/{dist-CN_BeG2I.js → dist-Ba2VIn1K.js} +53 -53
- package/dist/{dist-PXYI_yuP.js → dist-Bj4bmwUm.js} +12 -12
- package/dist/{dist-DoE4XJBC.js → dist-BmS-ZGjl.js} +8626 -8626
- package/dist/{dist-BorMD-uX.js → dist-Bzogh7CW.js} +87 -87
- package/dist/{dist-CN8zI-XC.js → dist-CThPVKaP.js} +1385 -1382
- package/dist/{dist-DiDibOYr.js → dist-CTi5FTiV.js} +87 -87
- package/dist/{dist-diIx5qJW.js → dist-Ck_C32ye.js} +2 -2
- package/dist/{dist-BLfKmR-l.js → dist-D1fnFp1J.js} +1 -1
- package/dist/{dist-OR1OnN-y.js → dist-D3x9__Fu.js} +46 -46
- package/dist/{dist-BMQf5zIS.js → dist-D7mrh5sO.js} +36 -36
- package/dist/{dist-CSJ0MDRw.js → dist-D9Q3xjiP.js} +1 -1
- package/dist/{dist-BuaRHxOc.js → dist-DP60Ubh8.js} +2 -2
- package/dist/{dist-CSbh1PNP.js → dist-DTv9KkpW.js} +12 -12
- package/dist/{dist-D-wwqlzJ.js → dist-DVVwOfrD.js} +109 -109
- package/dist/{dist-C8fAKSH1.js → dist-DYXM73-k.js} +36 -36
- package/dist/{dist-DBtSl3sf.js → dist-DjeybPOb.js} +1 -1
- package/dist/{dist-CrSP_H1M.js → dist-DtGn9N4h.js} +197 -197
- package/dist/{dist-CLdpGQVr.js → dist-KN80qWCP.js} +2 -2
- package/dist/{dist-Cg7gzw-a.js → dist-O0qFpEJh.js} +56 -56
- package/dist/{dist-CkTTIdBe.js → dist-OUle2RT7.js} +207 -207
- package/dist/{dist-BK4Oj99o.js → dist-T5rh6JvL.js} +1 -1
- package/dist/{dropdown-menu-B6ftyzOg.js → dropdown-menu-DCMbbQ35.js} +691 -691
- package/dist/{ebnfDiagram-PWID7BFC-B1QRM58v.js → ebnfDiagram-PWID7BFC-P7e4bryK.js} +2 -2
- package/dist/{erDiagram-RLTQ6QDP-DJK_FqvW.js → erDiagram-RLTQ6QDP-CUHZcmRj.js} +1 -1
- package/dist/{error-banner-D40pmfQQ.js → error-banner-DxJ3s8YO.js} +57 -57
- package/dist/{error-entries-DgK3wUJR.js → error-entries-mpoD5t79.js} +4985 -5006
- package/dist/{esm-D2gTsXEV.js → esm-Bbw_Njjx.js} +575 -575
- package/dist/{esm-AMFssoNp.js → esm-mDQNEFe_.js} +354 -354
- package/dist/{feedback-button-8a6SETmT.js → feedback-button-DL0DJ-LB.js} +30 -30
- package/dist/{flowDiagram-HODETNUW-Uxc25XSJ.js → flowDiagram-HODETNUW-BGZ95AzI.js} +2 -2
- package/dist/{formats-DQCyPd5Z.js → formats-DI7HEVv7.js} +1 -1
- package/dist/{glide-data-editor-B70oke_v.js → glide-data-editor-n4wnx19S.js} +10 -10
- package/dist/{glide-utils-Dz_F4pAY.js → glide-utils-D98laidb.js} +2 -2
- package/dist/{globals-Cxd5hNlI.js → globals-NCsYyjpB.js} +3 -3
- package/dist/{html-to-image-D4yG5Ru0.js → html-to-image-BoZthB4P.js} +467 -458
- package/dist/{infoDiagram-27XIBGKW-DmjxqwL0.js → infoDiagram-27XIBGKW-BF0YX70D.js} +1 -1
- package/dist/{ishikawaDiagram-5VMMS53U-NgCLHqQi.js → ishikawaDiagram-5VMMS53U-_itsAAn-.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-CZaG-iam.js → kanban-definition-UXKFOSKX-VNW2Beqh.js} +1 -1
- package/dist/{label-D9_-zSg-.js → label-Qvw1E97W.js} +1 -1
- package/dist/main.js +8257 -6606
- package/dist/{mermaid-CSvw7c71.js → mermaid-CZ6FrClS.js} +35 -35
- package/dist/{mindmap-definition-YA3MSWOX-DJYQBDH_.js → mindmap-definition-YA3MSWOX-DR4ripvd.js} +1 -1
- package/dist/{number-overlay-editor-ChK-SKUk.js → number-overlay-editor-rlvo4mo3.js} +1 -1
- package/dist/{pegDiagram-XKGWAZYB-CHKO_dAe.js → pegDiagram-XKGWAZYB-CFr3XlGl.js} +2 -2
- package/dist/{pieDiagram-E7YTZNPT-DVevbMAo.js → pieDiagram-E7YTZNPT-j91XYSLY.js} +1 -1
- package/dist/{process-output-DxvBAeL3.js → process-output-DLS4Mqg_.js} +4 -4
- package/dist/{railroadDiagram-O6MQD6OU-Detj1kcB.js → railroadDiagram-O6MQD6OU-Cd47ZV9E.js} +2 -2
- package/dist/{requirementDiagram-BXWQKSXE-BLFD0T_Z.js → requirementDiagram-BXWQKSXE-eJH6gLtX.js} +1 -1
- package/dist/{reveal-component-CXMXeDZD.js → reveal-component-BJfmRUzb.js} +9 -9
- package/dist/{select-CkF_GBxO.js → select-2KOiReNY.js} +324 -324
- package/dist/{sequenceDiagram-WJ2MYXX4-BZBgatQV.js → sequenceDiagram-WJ2MYXX4-DdfFEIrm.js} +1 -1
- package/dist/{spec-Mnkn3XEr.js → spec-h69nC3SI.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-4BZW9-6_.js → stateDiagram-D77RDMKH-DkjDvip8.js} +2 -2
- package/dist/{stateDiagram-v2-MP3YSRHH-C4sKC8Iq.js → stateDiagram-v2-MP3YSRHH-DBHACnOo.js} +2 -2
- package/dist/{swimlanes-42K2YHIH-SL5yeGe2.js → swimlanes-42K2YHIH-ogImlOmp.js} +1 -1
- package/dist/{swimlanesDiagram-VR7AAH4N-DqPmAYUv.js → swimlanesDiagram-VR7AAH4N-D6x-zsci.js} +2 -2
- package/dist/{timeline-definition-24CTP7MA-BfXUMWkq.js → timeline-definition-24CTP7MA-DQpLtsHD.js} +1 -1
- package/dist/{toDate-TMubKIVL.js → toDate-CDzoofJo.js} +2 -2
- package/dist/{toast-Btbve3Lm.js → toast-B5t9o6s_.js} +47 -47
- package/dist/{tooltip-CJ4Rqasp.js → tooltip-s4zZxwKe.js} +67 -67
- package/dist/{use-restore-focus-CmGwRNId.js → use-restore-focus-BgDTd2tc.js} +1 -1
- package/dist/{useAsyncData-DjMGFzFy.js → useAsyncData-Bn8SxUqM.js} +1 -1
- package/dist/{useDateFormatter-eCL_SdeG.js → useDateFormatter-D3Tkfzej.js} +2 -2
- package/dist/{useDeepCompareMemoize-BQR5TJot.js → useDeepCompareMemoize-CC2tnPCk.js} +1 -1
- package/dist/{useLifecycle-C_GvKWbQ.js → useLifecycle-BJlxHqWa.js} +2 -2
- package/dist/{useTheme-Bns2gJZ6.js → useTheme-DMfQYmlG.js} +85 -85
- package/dist/{vega-component-BsVptuhz.js → vega-component-CovWHi60.js} +7 -7
- package/dist/{vennDiagram-4TSXK5OY-CH65znGa.js → vennDiagram-4TSXK5OY-BD-SL_vq.js} +1 -1
- package/dist/{wardleyDiagram-VM6X3IG4-z9pWKb2_.js → wardleyDiagram-VM6X3IG4-BDgJV4ah.js} +1 -1
- package/dist/{xychartDiagram-S5SC5T6Z-MxyaWjjq.js → xychartDiagram-S5SC5T6Z-1hIHN6Rl.js} +1 -1
- package/package.json +1 -1
- package/src/__mocks__/document.tsx +54 -0
- package/src/__mocks__/notebook.ts +2 -1
- package/src/__mocks__/requests.ts +0 -2
- package/src/components/chat/chat-panel.tsx +3 -3
- package/src/components/datasources/__tests__/column-preview.test.tsx +6 -8
- package/src/components/datasources/column-preview.tsx +4 -8
- package/src/components/datasources/datasources.tsx +4 -3
- package/src/components/dependency-graph/minimap-content.tsx +2 -6
- package/src/components/dependency-graph/panels.tsx +2 -1
- package/src/components/editor/__tests__/Output.test.tsx +50 -32
- package/src/components/editor/__tests__/data-attributes.test.tsx +22 -11
- package/src/components/editor/__tests__/output-persistence.test.tsx +6 -1
- package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +69 -0
- package/src/components/editor/actions/name-cell-input.tsx +4 -3
- package/src/components/editor/actions/useCellActionButton.tsx +20 -26
- package/src/components/editor/actions/useNotebookActions.tsx +13 -18
- package/src/components/editor/actions/useSetCodeVisibility.ts +10 -11
- package/src/components/editor/actions/useSetOutputsExpanded.ts +13 -18
- package/src/components/editor/cell/CreateCellButton.tsx +5 -9
- package/src/components/editor/cell/__tests__/StagedAICell.test.tsx +3 -1
- package/src/components/editor/cell/code/cell-editor.tsx +13 -20
- package/src/components/editor/cell/useAddCell.ts +4 -8
- package/src/components/editor/cell/useDeleteCell.tsx +10 -36
- package/src/components/editor/cell/useRunCells.ts +2 -5
- package/src/components/editor/cell/useSplitCell.tsx +2 -1
- package/src/components/editor/chrome/panels/logs-panel.tsx +2 -1
- package/src/components/editor/chrome/panels/snippets-panel.tsx +5 -11
- package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +3 -1
- package/src/components/editor/columns/sortable-column.tsx +1 -1
- package/src/components/editor/connections/components.tsx +4 -9
- package/src/components/editor/controls/Controls.tsx +1 -1
- package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +9 -3
- package/src/components/editor/documentation.css +34 -11
- package/src/components/editor/errors/auto-fix.tsx +4 -8
- package/src/components/editor/file-tree/file-explorer.tsx +3 -7
- package/src/components/editor/links/__tests__/cell-link.test.tsx +3 -1
- package/src/components/editor/links/cell-link.tsx +2 -1
- package/src/components/editor/navigation/__tests__/clipboard.test.ts +60 -38
- package/src/components/editor/navigation/__tests__/navigation.test.ts +73 -64
- package/src/components/editor/navigation/clipboard.ts +12 -11
- package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +11 -20
- package/src/components/editor/navigation/navigation.ts +20 -28
- package/src/components/editor/notebook-cell.tsx +7 -10
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +125 -69
- package/src/components/editor/renderers/cell-array.tsx +10 -17
- package/src/components/markdown/markdown-renderer.tsx +4 -8
- package/src/components/pages/edit-page.tsx +32 -17
- package/src/components/scratchpad/scratchpad.test.tsx +3 -1
- package/src/components/scratchpad/scratchpad.tsx +4 -7
- package/src/components/slides/__tests__/minimap-actions.test.tsx +9 -25
- package/src/components/slides/minimap.tsx +7 -3
- package/src/components/slides/slide-cell-view.tsx +3 -3
- package/src/components/sort/SortableCellsProvider.tsx +2 -1
- package/src/core/ai/__tests__/staged-cells.test.ts +18 -20
- package/src/core/ai/staged-cells.ts +8 -16
- package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +2 -2
- package/src/core/ai/tools/__tests__/run-cells-tool.test.ts +2 -2
- package/src/core/ai/tools/base.ts +2 -2
- package/src/core/ai/tools/edit-notebook-tool.ts +13 -21
- package/src/core/cells/__tests__/actions.test.ts +474 -34
- package/src/core/cells/__tests__/add-missing-import.test.ts +7 -8
- package/src/core/cells/__tests__/cells.test.ts +251 -861
- package/src/core/cells/__tests__/document.test.ts +42 -38
- package/src/core/cells/__tests__/notebook-outline.test.ts +7 -1
- package/src/core/cells/__tests__/outputs.test.tsx +71 -53
- package/src/core/cells/actions.ts +391 -3
- package/src/core/cells/add-missing-import.ts +46 -42
- package/src/core/cells/cells.ts +73 -444
- package/src/core/cells/document.ts +38 -6
- package/src/core/cells/outputs.ts +12 -28
- package/src/core/codemirror/cells/extensions.ts +6 -6
- package/src/core/codemirror/cells/state.ts +1 -1
- package/src/core/codemirror/keymaps/vim.ts +2 -2
- package/src/core/edit-app.tsx +20 -25
- package/src/core/islands/__tests__/bootstrap.test.ts +56 -0
- package/src/core/islands/__tests__/bridge.test.ts +42 -0
- package/src/core/islands/bootstrap.ts +24 -1
- package/src/core/islands/bridge.ts +46 -5
- package/src/core/kernel/__tests__/handlers.test.ts +7 -153
- package/src/core/kernel/handlers.ts +18 -59
- package/src/core/network/__tests__/requests-lazy.test.ts +1 -3
- package/src/core/network/requests-lazy.ts +0 -2
- package/src/core/network/requests-network.ts +0 -16
- package/src/core/network/requests-static.ts +0 -2
- package/src/core/network/requests-toasting.tsx +0 -2
- package/src/core/network/types.ts +0 -7
- package/src/core/notebook/document/__tests__/codemirror.test.ts +5 -0
- package/src/core/notebook/document/__tests__/draft.test.ts +41 -0
- package/src/core/notebook/document/__tests__/state.test.ts +21 -0
- package/src/core/notebook/document/draft.ts +35 -5
- package/src/core/notebook/document/index.ts +1 -0
- package/src/core/notebook/document/state.ts +6 -2
- package/src/core/run-app.tsx +1 -7
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +0 -6
- package/src/core/session/useNotebookSession.tsx +28 -35
- package/src/core/wasm/bridge.ts +0 -16
- package/src/css/globals.css +56 -22
- package/src/stories/runtime-story.tsx +22 -15
|
@@ -29,7 +29,12 @@ import {
|
|
|
29
29
|
type NotebookState,
|
|
30
30
|
notebookReducer,
|
|
31
31
|
} from "../cells";
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
applyDocument,
|
|
34
|
+
flushDocument,
|
|
35
|
+
followDocument,
|
|
36
|
+
withDocumentSave,
|
|
37
|
+
} from "../document";
|
|
33
38
|
import { type CellId, SCRATCH_CELL_ID } from "../ids";
|
|
34
39
|
|
|
35
40
|
vi.mock("../../rtc/state", async (importOriginal) => ({
|
|
@@ -102,9 +107,10 @@ describe("applyDocument", () => {
|
|
|
102
107
|
expect(state.cellData[a]).toMatchObject({
|
|
103
108
|
code: "a = 1",
|
|
104
109
|
name: "_",
|
|
105
|
-
edited:
|
|
110
|
+
edited: true,
|
|
106
111
|
lastCodeRun: null,
|
|
107
112
|
});
|
|
113
|
+
expect(state.cellData[b].edited).toBe(false);
|
|
108
114
|
expect(state.cellRuntime[a]).toBeDefined();
|
|
109
115
|
expect(state.cellHandles[a]).toBeDefined();
|
|
110
116
|
expect(state.cellData[SCRATCH_CELL_ID]).toBeDefined();
|
|
@@ -185,7 +191,7 @@ describe("applyDocument", () => {
|
|
|
185
191
|
expect(next.cellData[a]).toMatchObject({
|
|
186
192
|
name: "renamed",
|
|
187
193
|
config: { hide_code: true },
|
|
188
|
-
edited:
|
|
194
|
+
edited: true,
|
|
189
195
|
});
|
|
190
196
|
});
|
|
191
197
|
|
|
@@ -277,45 +283,14 @@ describe("documentEditMiddleware", () => {
|
|
|
277
283
|
store.set(activeDocumentModelAtom, null);
|
|
278
284
|
});
|
|
279
285
|
|
|
280
|
-
it("
|
|
281
|
-
actions.createNewCell({
|
|
282
|
-
cellId: c,
|
|
283
|
-
before: false,
|
|
284
|
-
code: "d = 1",
|
|
285
|
-
newCellId: d,
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
expect(calls.map((call) => call[0])).toEqual(["createCell"]);
|
|
289
|
-
expect(calls[0][1]).toMatchObject({ id: d, code: "d = 1" });
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it("creates a cell elsewhere and sets the order", () => {
|
|
293
|
-
actions.createNewCell({ cellId: a, before: true, newCellId: d });
|
|
294
|
-
|
|
295
|
-
expect(calls.map((call) => call[0])).toEqual(["createCell", "setOrder"]);
|
|
296
|
-
expect(calls[1][1]).toEqual([d, a, b, c]);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it("deletes a cell", () => {
|
|
300
|
-
actions.deleteCell({ cellId: b });
|
|
301
|
-
|
|
302
|
-
expect(calls).toEqual([["deleteCell", b]]);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it("writes code, name, and config", () => {
|
|
286
|
+
it("writes code", () => {
|
|
306
287
|
actions.updateCellCode({
|
|
307
288
|
cellId: a,
|
|
308
289
|
code: "a = 2",
|
|
309
290
|
formattingChange: false,
|
|
310
291
|
});
|
|
311
|
-
actions.updateCellName({ cellId: a, name: "first" });
|
|
312
|
-
actions.updateCellConfig({ cellId: a, config: { hide_code: true } });
|
|
313
292
|
|
|
314
|
-
expect(calls).toEqual([
|
|
315
|
-
["setCode", a, "a = 2"],
|
|
316
|
-
["setName", a, "first"],
|
|
317
|
-
["updateConfig", a, { hide_code: true }],
|
|
318
|
-
]);
|
|
293
|
+
expect(calls).toEqual([["setCode", a, "a = 2"]]);
|
|
319
294
|
});
|
|
320
295
|
|
|
321
296
|
it("sets the order when a cell moves", () => {
|
|
@@ -349,9 +324,14 @@ describe("documentEditMiddleware", () => {
|
|
|
349
324
|
expect(calls).toEqual([["updateConfig", c, { column: null }]]);
|
|
350
325
|
});
|
|
351
326
|
|
|
352
|
-
it("ignores the kernel's
|
|
327
|
+
it("ignores the document and the kernel's run state", () => {
|
|
353
328
|
actions.prepareForRun({ cellId: a });
|
|
354
|
-
actions.
|
|
329
|
+
actions.setLastRun({
|
|
330
|
+
lastCodeRun: { [a]: "a = 0" },
|
|
331
|
+
lastExecutionTime: {},
|
|
332
|
+
});
|
|
333
|
+
actions.resetCellRuntimes();
|
|
334
|
+
actions.reconcileDocument(documentOf([cell(a)]));
|
|
355
335
|
|
|
356
336
|
expect(calls).toEqual([]);
|
|
357
337
|
});
|
|
@@ -367,6 +347,30 @@ describe("documentEditMiddleware", () => {
|
|
|
367
347
|
});
|
|
368
348
|
});
|
|
369
349
|
|
|
350
|
+
describe("followDocument", () => {
|
|
351
|
+
it("reconciles the document now and on each change, until aborted", () => {
|
|
352
|
+
const documentAtom = atom<EditableDocument | null>(null);
|
|
353
|
+
const reconcile = vi.fn();
|
|
354
|
+
const controller = new AbortController();
|
|
355
|
+
|
|
356
|
+
followDocument({
|
|
357
|
+
store,
|
|
358
|
+
model: { documentAtom },
|
|
359
|
+
reconcile,
|
|
360
|
+
signal: controller.signal,
|
|
361
|
+
});
|
|
362
|
+
expect(reconcile).not.toHaveBeenCalled();
|
|
363
|
+
|
|
364
|
+
const first = documentOf([cell(a)]);
|
|
365
|
+
store.set(documentAtom, first);
|
|
366
|
+
expect(reconcile).toHaveBeenCalledWith(first);
|
|
367
|
+
|
|
368
|
+
controller.abort();
|
|
369
|
+
store.set(documentAtom, documentOf([cell(b)]));
|
|
370
|
+
expect(reconcile).toHaveBeenCalledOnce();
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
|
|
370
374
|
describe("flushing before host commands", () => {
|
|
371
375
|
const model = {
|
|
372
376
|
syncStatusAtom: atom<DocumentSyncStatus>({ status: "idle" }),
|
|
@@ -4,6 +4,7 @@ import { createStore } from "jotai";
|
|
|
4
4
|
import { describe, expect, it, vi } from "vitest";
|
|
5
5
|
import { MockNotebook } from "@/__mocks__/notebook";
|
|
6
6
|
import { cellId } from "@/__tests__/branded";
|
|
7
|
+
import { CONFIG } from "@/core/notebook/document/__tests__/fixtures";
|
|
7
8
|
import {
|
|
8
9
|
createNotebookActions,
|
|
9
10
|
notebookAtom,
|
|
@@ -84,7 +85,12 @@ describe("notebookOutline", () => {
|
|
|
84
85
|
items: [...secondOutline.items, ...firstOutline.items],
|
|
85
86
|
});
|
|
86
87
|
|
|
87
|
-
actions.
|
|
88
|
+
actions.reconcileDocument({
|
|
89
|
+
order: [first],
|
|
90
|
+
cells: new Map([
|
|
91
|
+
[first, { id: first, code: "x = 1", name: "_", config: CONFIG }],
|
|
92
|
+
]),
|
|
93
|
+
});
|
|
88
94
|
expect(store.get(notebookOutline)).toEqual(firstOutline);
|
|
89
95
|
});
|
|
90
96
|
|
|
@@ -2,116 +2,134 @@
|
|
|
2
2
|
|
|
3
3
|
import { act, renderHook } from "@testing-library/react";
|
|
4
4
|
import { createStore, Provider } from "jotai";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { notebookAtom } from "@/core/cells/cells";
|
|
5
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
6
|
+
import { mockDocumentModel } from "@/__mocks__/document";
|
|
8
7
|
import { CellId } from "@/core/cells/ids";
|
|
8
|
+
import { DocumentProvider } from "@/core/notebook/document";
|
|
9
|
+
import {
|
|
10
|
+
cell,
|
|
11
|
+
CONFIG,
|
|
12
|
+
document as documentOf,
|
|
13
|
+
withCells,
|
|
14
|
+
} from "@/core/notebook/document/__tests__/fixtures";
|
|
9
15
|
import { type AppMode, viewStateAtom } from "@/core/mode";
|
|
10
16
|
import { useExpandedConsoleOutput, useExpandedOutput } from "../outputs";
|
|
11
17
|
|
|
12
|
-
const
|
|
18
|
+
const stops: Array<() => void> = [];
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
for (const stop of stops.splice(0)) {
|
|
22
|
+
stop();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
17
25
|
|
|
18
26
|
function setup(opts: { mode: AppMode; expandOutput?: boolean }) {
|
|
19
27
|
const cellId = CellId.create();
|
|
20
28
|
const store = createStore();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
const { model, stop } = mockDocumentModel(
|
|
30
|
+
store,
|
|
31
|
+
withCells(
|
|
32
|
+
documentOf(),
|
|
33
|
+
{
|
|
34
|
+
c1: null,
|
|
35
|
+
c2: null,
|
|
36
|
+
[cellId]: cell(cellId, "", {
|
|
37
|
+
config: { ...CONFIG, expand_output: opts.expandOutput ?? false },
|
|
38
|
+
}),
|
|
26
39
|
},
|
|
27
|
-
|
|
40
|
+
[cellId],
|
|
41
|
+
),
|
|
28
42
|
);
|
|
43
|
+
stops.push(stop);
|
|
29
44
|
store.set(viewStateAtom, { mode: opts.mode, cellAnchor: null });
|
|
30
45
|
|
|
31
|
-
const {
|
|
32
|
-
|
|
33
|
-
|
|
46
|
+
const wrapper = ({ children }: { children: React.ReactNode }) => (
|
|
47
|
+
<Provider store={store}>
|
|
48
|
+
<DocumentProvider model={model}>{children}</DocumentProvider>
|
|
49
|
+
</Provider>
|
|
50
|
+
);
|
|
51
|
+
const expanded = () =>
|
|
52
|
+
store.get(model.documentAtom)?.cells.get(cellId)?.config.expand_output;
|
|
34
53
|
|
|
35
|
-
return { cellId, store,
|
|
54
|
+
return { cellId, store, wrapper, expanded };
|
|
36
55
|
}
|
|
37
56
|
|
|
38
|
-
const configOf = (store: ReturnType<typeof createStore>, cellId: CellId) =>
|
|
39
|
-
store.get(notebookAtom).cellData[cellId].config;
|
|
40
|
-
|
|
41
57
|
describe("useExpandedOutput", () => {
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
vi.clearAllMocks();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
58
|
it("reads the initial state from the cell's expand_output config", () => {
|
|
47
|
-
|
|
48
|
-
expect(
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
const collapsed = setup({ mode: "edit" });
|
|
60
|
+
expect(
|
|
61
|
+
renderHook(() => useExpandedOutput(collapsed.cellId), {
|
|
62
|
+
wrapper: collapsed.wrapper,
|
|
63
|
+
}).result.current[0],
|
|
64
|
+
).toBe(false);
|
|
65
|
+
|
|
66
|
+
const expanded = setup({ mode: "edit", expandOutput: true });
|
|
67
|
+
expect(
|
|
68
|
+
renderHook(() => useExpandedOutput(expanded.cellId), {
|
|
69
|
+
wrapper: expanded.wrapper,
|
|
70
|
+
}).result.current[0],
|
|
71
|
+
).toBe(true);
|
|
51
72
|
});
|
|
52
73
|
|
|
53
74
|
it("persists the toggle to the cell's config in edit mode", () => {
|
|
54
|
-
const { cellId,
|
|
75
|
+
const { cellId, wrapper, expanded } = setup({ mode: "edit" });
|
|
76
|
+
const { result } = renderHook(() => useExpandedOutput(cellId), {
|
|
77
|
+
wrapper,
|
|
78
|
+
});
|
|
55
79
|
|
|
56
80
|
act(() => result.current[1](true));
|
|
57
81
|
|
|
58
82
|
expect(result.current[0]).toBe(true);
|
|
59
|
-
expect(
|
|
60
|
-
expect(saveCellConfig).toHaveBeenCalledWith({
|
|
61
|
-
configs: { [cellId]: { expand_output: true } },
|
|
62
|
-
});
|
|
83
|
+
expect(expanded()).toBe(true);
|
|
63
84
|
});
|
|
64
85
|
|
|
65
86
|
it("collapses by clearing the config", () => {
|
|
66
|
-
const { cellId,
|
|
87
|
+
const { cellId, wrapper, expanded } = setup({
|
|
67
88
|
mode: "edit",
|
|
68
89
|
expandOutput: true,
|
|
69
90
|
});
|
|
91
|
+
const { result } = renderHook(() => useExpandedOutput(cellId), {
|
|
92
|
+
wrapper,
|
|
93
|
+
});
|
|
70
94
|
|
|
71
95
|
act(() => result.current[1](false));
|
|
72
96
|
|
|
73
97
|
expect(result.current[0]).toBe(false);
|
|
74
|
-
expect(
|
|
75
|
-
expect(saveCellConfig).toHaveBeenCalledWith({
|
|
76
|
-
configs: { [cellId]: { expand_output: false } },
|
|
77
|
-
});
|
|
98
|
+
expect(expanded()).toBe(false);
|
|
78
99
|
});
|
|
79
100
|
|
|
80
101
|
it("keeps the toggle in memory outside of edit mode", () => {
|
|
81
|
-
const { cellId,
|
|
102
|
+
const { cellId, wrapper, expanded } = setup({ mode: "read" });
|
|
103
|
+
const { result } = renderHook(() => useExpandedOutput(cellId), {
|
|
104
|
+
wrapper,
|
|
105
|
+
});
|
|
82
106
|
|
|
83
107
|
act(() => result.current[1](true));
|
|
84
108
|
|
|
85
109
|
expect(result.current[0]).toBe(true);
|
|
86
110
|
// Cell configs are read-only outside of edit mode.
|
|
87
|
-
expect(
|
|
88
|
-
expect(saveCellConfig).not.toHaveBeenCalled();
|
|
111
|
+
expect(expanded()).toBe(false);
|
|
89
112
|
});
|
|
90
113
|
|
|
91
114
|
it("still honors expand_output outside of edit mode", () => {
|
|
92
|
-
const {
|
|
115
|
+
const { cellId, wrapper } = setup({ mode: "read", expandOutput: true });
|
|
116
|
+
const { result } = renderHook(() => useExpandedOutput(cellId), {
|
|
117
|
+
wrapper,
|
|
118
|
+
});
|
|
93
119
|
expect(result.current[0]).toBe(true);
|
|
94
120
|
});
|
|
95
121
|
|
|
96
122
|
// `expand_output` covers the cell's output area only. Console output is
|
|
97
123
|
// clamped independently and stays an in-memory, per-session toggle.
|
|
98
124
|
it("does not touch the config when console output is expanded", () => {
|
|
99
|
-
const cellId =
|
|
100
|
-
const store = createStore();
|
|
101
|
-
store.set(
|
|
102
|
-
notebookAtom,
|
|
103
|
-
MockNotebook.notebookState({ cellData: { [cellId]: {} } }),
|
|
104
|
-
);
|
|
105
|
-
store.set(viewStateAtom, { mode: "edit", cellAnchor: null });
|
|
106
|
-
|
|
125
|
+
const { cellId, wrapper, expanded } = setup({ mode: "edit" });
|
|
107
126
|
const { result } = renderHook(() => useExpandedConsoleOutput(cellId), {
|
|
108
|
-
wrapper
|
|
127
|
+
wrapper,
|
|
109
128
|
});
|
|
110
129
|
|
|
111
130
|
act(() => result.current[1](true));
|
|
112
131
|
|
|
113
132
|
expect(result.current[0]).toBe(true);
|
|
114
|
-
expect(
|
|
115
|
-
expect(saveCellConfig).not.toHaveBeenCalled();
|
|
133
|
+
expect(expanded()).toBe(false);
|
|
116
134
|
});
|
|
117
135
|
});
|