@marimo-team/islands 0.26.1-dev6 → 0.26.1-dev60
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-DtwVgVpX.js → ConnectedDataExplorerComponent-yQVBQBUW.js} +16 -16
- package/dist/{ErrorBoundary-CLLMEsVD.js → ErrorBoundary-BdXvplK4.js} +19 -19
- package/dist/{abnfDiagram-VCTEODGH-BbZOIueZ.js → abnfDiagram-VCTEODGH-Ck_lXwQR.js} +2 -2
- package/dist/{any-language-editor-yG-YmLaK.js → any-language-editor-Cx4idbgX.js} +5 -5
- package/dist/{architectureDiagram-5GKGNRK7-qjLjxapm.js → architectureDiagram-5GKGNRK7-XeVhic7Z.js} +1 -1
- package/dist/{assertNever-DywGMo-S.js → assertNever-473SFxLt.js} +14 -14
- package/dist/{button-qQhINE7z.js → button-Z2R2272J.js} +34 -31
- package/dist/{capabilities-DKqMqBzm.js → capabilities-ba3Dyv8n.js} +1 -1
- package/dist/{chat-ui-D5YPIONI.js → chat-ui-D1mRz9h6.js} +113 -113
- package/dist/{check-jchHMCfs.js → check-DmTIavbZ.js} +1 -1
- package/dist/{chunk-IMKFNOWR-BzDY1_I7.js → chunk-IMKFNOWR-DdQni67K.js} +1 -1
- package/dist/{chunk-SHT3W25Y-DbHsMKdo.js → chunk-SHT3W25Y-BdK-vMct.js} +1 -1
- package/dist/{chunk-SVP7TREG-CtwnwAE6.js → chunk-SVP7TREG-cpFZk4Ca.js} +1 -1
- package/dist/{chunk-TICWLB2K-C5Z5QMbO.js → chunk-TICWLB2K-DDgQFRgT.js} +1 -1
- package/dist/{classDiagram-ZZMXUADV-B8E5Hn78.js → classDiagram-ZZMXUADV-DeojX9X4.js} +2 -2
- package/dist/{classDiagram-v2-VYDZK3BY-DeGsK9bT.js → classDiagram-v2-VYDZK3BY-DPfTAiQ6.js} +2 -2
- package/dist/{code-visibility-D8sNdSZw.js → code-visibility-BSe8efVJ.js} +28 -28
- package/dist/{common-C1vcGVta.js → common-D4UcPNCP.js} +5102 -5055
- package/dist/{config-qTaTHnpE.js → config-D-lhQq-h.js} +31 -32
- package/dist/{copy-icon-BI7vZHEW.js → copy-icon-DuxRkh7T.js} +3 -3
- package/dist/{createReducer-DdSLRfBT.js → createReducer-D3pBhIVD.js} +2 -2
- package/dist/{cynefinDiagram-5FMLGOSQ-NDedRwsw.js → cynefinDiagram-5FMLGOSQ-DyY9TvuI.js} +1 -1
- package/dist/{dagre-GXQ25YYZ-De0sSZO7.js → dagre-GXQ25YYZ-BPCOgtKg.js} +1 -1
- package/dist/{data-grid-overlay-editor-DbZ4Cn8Q.js → data-grid-overlay-editor-j_uScboj.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-wBtVl61y.js → diagram-S7CK7UJ4-KaF-C6kd.js} +1 -1
- package/dist/{diagram-UQ7AKVKN-CKWE3c1T.js → diagram-UQ7AKVKN-DkeqoSvK.js} +1 -1
- package/dist/{diagram-VX7I27RA-D2Ac5198.js → diagram-VX7I27RA-DExolTAf.js} +1 -1
- package/dist/{diagram-Z3DM3KII-CYaFOQcI.js → diagram-Z3DM3KII-BioFuBF3.js} +1 -1
- package/dist/{dialog-Ic6dh09m.js → dialog-CvyFEwby.js} +32 -32
- package/dist/{dist-BvZpdAuG.js → dist-6B1_Ttbh.js} +1 -1
- package/dist/{dist-D1D56-GS.js → dist-B28poF32.js} +2 -2
- package/dist/{dist-BozTF_gH.js → dist-BBZ7lnMw.js} +2 -2
- package/dist/{dist-BfrgytDR.js → dist-BD8ZKF5t.js} +3 -3
- package/dist/{dist-DNkrY12t.js → dist-BG-7Qpaj.js} +3 -3
- package/dist/{dist-D92tYjLc.js → dist-BIaGGUbU.js} +13 -11
- package/dist/{dist-BagHbFqG.js → dist-BR5PU2Ph.js} +3 -3
- package/dist/{dist-DpYpG8Yc.js → dist-BidYR5m4.js} +3 -3
- package/dist/{dist-D95Cd4xm.js → dist-BkGYCvFX.js} +3 -3
- package/dist/{dist-DneeBk3K.js → dist-BmEyXT7K.js} +2 -2
- package/dist/{dist-BdUitvVW.js → dist-Bt0Wt6m9.js} +2 -2
- package/dist/{dist-CEomphG1.js → dist-CG2Sl0D4.js} +2 -2
- package/dist/{dist-BMz__bo5.js → dist-CQfpgadU.js} +3 -3
- package/dist/{dist-BreKIQqQ.js → dist-CVOPvfzN.js} +3 -3
- package/dist/{dist-BEcpQbZa.js → dist-Cm0iCeQQ.js} +3 -3
- package/dist/{dist-CDVvitRS.js → dist-Cnc14jEq.js} +2 -2
- package/dist/{dist-ChcBm3jk.js → dist-D3KPC38e.js} +4 -4
- package/dist/{dist-B1qu3Bez.js → dist-D7BXk27E.js} +3 -3
- package/dist/{dist-BsE4gQHj.js → dist-D9Qhvxvg.js} +1 -1
- package/dist/{dist-OmeAz0fR.js → dist-DJKajXDB.js} +3 -3
- package/dist/{dist-ObeTgSmf.js → dist-DYbNRTYG.js} +4 -4
- package/dist/{dist-Cshl6jBw.js → dist-DhtDWnzK.js} +2 -2
- package/dist/{dist-BunZKA_9.js → dist-_x2Jks2R.js} +2 -2
- package/dist/{dist-MggMo7OR.js → dist-m0MWV-aw.js} +1 -1
- package/dist/{dist-TGSwzj8a.js → dist-pPbYNVjd.js} +4 -4
- package/dist/{dropdown-menu-Dhv4fcNl.js → dropdown-menu-BiXHfje7.js} +2568 -2568
- package/dist/{ebnfDiagram-PWID7BFC-Ds7f42dj.js → ebnfDiagram-PWID7BFC-BSb9k1ed.js} +2 -2
- package/dist/{erDiagram-RLTQ6QDP-b58Sz2Mc.js → erDiagram-RLTQ6QDP-PWA30a_r.js} +1 -1
- package/dist/{error-banner-CJVLr5_a.js → error-banner-B9HQMSaH.js} +35 -35
- package/dist/{error-entries-BKlEsuk4.js → error-entries-P6Qpq6wP.js} +1032 -867
- package/dist/{esm-B9n0caHs.js → esm-DY8dGAjJ.js} +23 -23
- package/dist/{esm-Bwp_FHP0.js → esm-Dw2ZydG_.js} +3 -3
- package/dist/{feedback-button-CjWyhzBQ.js → feedback-button-DRcg_ZBP.js} +123 -123
- package/dist/{flowDiagram-HODETNUW-BH9U7VZK.js → flowDiagram-HODETNUW-BPtD__Zz.js} +2 -2
- package/dist/{formats-BLNFWWhV.js → formats-BF95BoCT.js} +3 -3
- package/dist/{glide-data-editor-B0vlSuQn.js → glide-data-editor-DkKBZmyu.js} +43 -43
- package/dist/{glide-utils-Ze_7l_91.js → glide-utils-iHKKQPJ8.js} +3 -3
- package/dist/{globals-_GdM0yI_.js → globals-D-LCkcIG.js} +3 -3
- package/dist/{html-to-image-CNM0ZSFD.js → html-to-image-DhrFZL7t.js} +24150 -24028
- package/dist/{infoDiagram-27XIBGKW-xbjwrcNi.js → infoDiagram-27XIBGKW-SJuilBEE.js} +1 -1
- package/dist/{ishikawaDiagram-5VMMS53U-DKtukhGS.js → ishikawaDiagram-5VMMS53U-DjzyxMr8.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-BEhlkZBb.js → kanban-definition-UXKFOSKX-D2_qopGt.js} +1 -1
- package/dist/{loader-Bin_dutt.js → loader-qPmiRXZd.js} +1 -1
- package/dist/main.js +8860 -8741
- package/dist/{mermaid-D1CZDNoB.js → mermaid-DcowNmCx.js} +35 -35
- package/dist/{mindmap-definition-YA3MSWOX-DQcnJPcV.js → mindmap-definition-YA3MSWOX-pEra10M0.js} +1 -1
- package/dist/{number-overlay-editor-C9qcz20o.js → number-overlay-editor-xQbbd1Ku.js} +1 -1
- package/dist/{pegDiagram-XKGWAZYB-BFQuPYfI.js → pegDiagram-XKGWAZYB-CHOPKVOf.js} +2 -2
- package/dist/{pencil-DVYzq-iR.js → pencil-FAv6JUvp.js} +1 -1
- package/dist/{pieDiagram-E7YTZNPT-l7aqNrem.js → pieDiagram-E7YTZNPT-yGDhsyEN.js} +1 -1
- package/dist/{process-output-DthYR2Te.js → process-output-CBPqVQBu.js} +4 -4
- package/dist/{railroadDiagram-O6MQD6OU-6R3C1lwQ.js → railroadDiagram-O6MQD6OU-CeKEPdyc.js} +2 -2
- package/dist/{requirementDiagram-BXWQKSXE-DdWYu8fn.js → requirementDiagram-BXWQKSXE-DSAbAzKe.js} +1 -1
- package/dist/{reveal-component-CGGipwgt.js → reveal-component-DUTEhLsR.js} +1018 -1018
- package/dist/{select-CDUxhHZg.js → select-BszV-bbI.js} +135 -135
- package/dist/{sequenceDiagram-WJ2MYXX4-Dzp0dgRc.js → sequenceDiagram-WJ2MYXX4-DVhWj_9H.js} +1 -1
- package/dist/{spec-ZAt4P01J.js → spec-CRfw-lOm.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-BGnTUhFJ.js → stateDiagram-D77RDMKH-CDQ2MltG.js} +2 -2
- package/dist/{stateDiagram-v2-MP3YSRHH-DsJbmDf1.js → stateDiagram-v2-MP3YSRHH-BQmvwBaz.js} +2 -2
- package/dist/{static-state-C4bAlKTU.js → static-state-BtDNJuc2.js} +7 -7
- package/dist/style.css +1 -1
- package/dist/{swimlanes-42K2YHIH-Bd4Bzh9r.js → swimlanes-42K2YHIH-DLOUTCEL.js} +1 -1
- package/dist/{swimlanesDiagram-VR7AAH4N-BlY12Jf6.js → swimlanesDiagram-VR7AAH4N-BVKrkNJ6.js} +2 -2
- package/dist/{swiper-component-DTdNB9wg.js → swiper-component-B2O8hF7b.js} +2 -2
- package/dist/{timeline-definition-24CTP7MA-m0LanyCH.js → timeline-definition-24CTP7MA-Cb2JoCSd.js} +1 -1
- package/dist/{toast-U3NpO2x3.js → toast-QsOAIPfq.js} +166 -166
- package/dist/{tooltip-UzJukb3F.js → tooltip-BQZ-Bm6h.js} +65 -65
- package/dist/{use-restore-focus-DaTVz6S6.js → use-restore-focus-DT1TZACX.js} +1885 -1877
- package/dist/{useDateFormatter-LQNtoXyh.js → useDateFormatter-D3gyMY-g.js} +2 -2
- package/dist/{useDeepCompareMemoize-CmNbQ9TT.js → useDeepCompareMemoize-CO6rO5Mq.js} +1 -1
- package/dist/{useIframeCapabilities-HTZiVlGV.js → useIframeCapabilities-_0KX0nu_.js} +1 -1
- package/dist/{useLifecycle-DTMczKkf.js → useLifecycle-C9UTzCY8.js} +2 -2
- package/dist/{vega-component-ZTdbCcwI.js → vega-component-i5lZ23n7.js} +19 -19
- package/dist/{vennDiagram-4TSXK5OY-BJ7vqDmn.js → vennDiagram-4TSXK5OY-Cm3EcCcP.js} +1 -1
- package/dist/{wardleyDiagram-VM6X3IG4-D5kWacsn.js → wardleyDiagram-VM6X3IG4-DjlUs2CC.js} +1 -1
- package/dist/{xychartDiagram-S5SC5T6Z-gr15Ws_z.js → xychartDiagram-S5SC5T6Z-DxNDul9l.js} +1 -1
- package/package.json +3 -3
- package/src/__mocks__/animation-frames.ts +31 -0
- package/src/__mocks__/executions.ts +51 -23
- package/src/__mocks__/intersection-observer.ts +45 -0
- package/src/__mocks__/notebook.ts +1 -1
- package/src/__tests__/branded.ts +4 -0
- package/src/__tests__/notebook-analysis.ts +48 -0
- package/src/__tests__/render-tracker.ts +15 -0
- package/src/__tests__/setup.ts +3 -0
- package/src/components/data-table/__tests__/export-actions.test.tsx +79 -0
- package/src/components/data-table/export-actions.tsx +64 -19
- package/src/components/data-table/schemas.ts +1 -0
- package/src/components/databases/engine-variable.tsx +2 -2
- package/src/components/dependency-graph/panels.tsx +2 -2
- package/src/components/editor/__tests__/cell-renders.test.tsx +116 -0
- package/src/components/editor/actions/__tests__/name-cell-input.test.tsx +1 -1
- package/src/components/editor/actions/useCellActionButton.tsx +2 -8
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +28 -61
- package/src/components/editor/cell/CreateCellButton.tsx +69 -40
- package/src/components/editor/cell/__tests__/CreateCellButton.test.tsx +49 -0
- package/src/components/editor/cell/__tests__/cell-context-menu.test.tsx +126 -0
- package/src/components/editor/cell/__tests__/useRunCells.test.tsx +5 -5
- package/src/components/editor/cell/cell-context-menu.tsx +202 -111
- package/src/components/editor/cell/code/__tests__/code-placeholder.test.tsx +40 -0
- package/src/components/editor/cell/code/cell-editor.tsx +49 -108
- package/src/components/editor/cell/code/code-placeholder.css +61 -11
- package/src/components/editor/cell/code/code-placeholder.tsx +52 -27
- package/src/components/editor/cell/collapse.tsx +6 -3
- package/src/components/editor/cell/useSplitCell.tsx +2 -2
- package/src/components/editor/chrome/panels/__tests__/secrets-panel.test.tsx +57 -0
- package/src/components/editor/chrome/panels/secrets-panel.tsx +36 -9
- package/src/components/editor/chrome/panels/secrets-utils.ts +20 -0
- package/src/components/editor/chrome/wrapper/__tests__/document-sync-status.test.tsx +5 -2
- package/src/components/editor/chrome/wrapper/__tests__/pending-ai-cells.test.tsx +6 -10
- package/src/components/editor/errors/auto-fix.tsx +8 -7
- package/src/components/editor/header/status.tsx +5 -2
- package/src/components/editor/navigation/__tests__/navigation.test.ts +3 -16
- package/src/components/editor/navigation/focus-utils.ts +20 -8
- package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +3 -11
- package/src/components/editor/navigation/navigation.ts +2 -2
- package/src/components/editor/notebook-cell.tsx +15 -24
- package/src/components/editor/output/MarimoTracebackOutput.tsx +2 -2
- package/src/components/editor/output/console/ConsoleOutput.tsx +77 -50
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +28 -0
- package/src/components/editor/renderers/cells-renderer.tsx +3 -2
- package/src/components/editor/renderers/vertical-layout/__tests__/useFocusFirstEditor.test.ts +6 -9
- package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +2 -5
- package/src/components/find-replace/find-replace.tsx +3 -7
- package/src/components/icons/__tests__/large-spinner.test.tsx +5 -4
- package/src/components/scratchpad/scratchpad.tsx +2 -2
- package/src/components/tracing/tracing-keyboard.test.tsx +4 -3
- package/src/components/ui/__tests__/button-shortcut.test.tsx +22 -0
- package/src/components/ui/__tests__/fullscreen.test.tsx +83 -1
- package/src/components/ui/button.tsx +5 -1
- package/src/components/ui/fullscreen.tsx +43 -89
- package/src/components/variables/__tests__/variables-table.test.tsx +1 -2
- package/src/core/MarimoApp.tsx +1 -1
- package/src/core/__tests__/MarimoApp.test.tsx +147 -0
- package/src/core/ai/__tests__/staged-cells.test.ts +6 -39
- package/src/core/ai/context/providers/__tests__/error.test.ts +6 -3
- package/src/core/ai/staged-cells.ts +8 -35
- package/src/core/ai/tools/__tests__/edit-notebook-tool.test.ts +15 -13
- package/src/core/ai/tools/edit-notebook-tool.ts +13 -8
- package/src/core/cells/__tests__/actions.test.ts +2 -2
- package/src/core/cells/__tests__/add-missing-import.test.ts +14 -9
- package/src/core/cells/__tests__/arrange.test.ts +1 -1
- package/src/core/cells/__tests__/cell-editor-view.test.ts +44 -0
- package/src/core/cells/__tests__/cells.test.ts +0 -1
- package/src/core/cells/__tests__/focus.test.ts +1 -7
- package/src/core/cells/__tests__/harness.ts +9 -8
- package/src/core/cells/__tests__/layout.test.ts +1 -1
- package/src/core/cells/__tests__/pending-delete-service.test.tsx +121 -11
- package/src/core/cells/__tests__/runs.test.ts +14 -14
- package/src/core/cells/__tests__/utils.test.ts +3 -2
- package/src/core/cells/actions.ts +6 -6
- package/src/core/cells/add-missing-import.ts +2 -3
- package/src/core/cells/cells.ts +40 -27
- package/src/core/cells/document.ts +1 -2
- package/src/core/cells/execution-console.ts +10 -5
- package/src/core/cells/focus.ts +1 -1
- package/src/core/cells/ids.ts +2 -4
- package/src/core/cells/pending-delete-service.ts +97 -85
- package/src/core/cells/runs.ts +7 -5
- package/src/core/cells/scrollCellIntoView.ts +4 -14
- package/src/core/cells/session.ts +8 -5
- package/src/core/cells/utils.ts +0 -13
- package/src/core/codemirror/__tests__/cell-documents.test.ts +79 -0
- package/src/core/codemirror/__tests__/debounced-editor-update.test.ts +72 -0
- package/src/core/codemirror/__tests__/editor-mount-scheduler.test.ts +75 -105
- package/src/core/codemirror/__tests__/format.test.ts +85 -63
- package/src/core/codemirror/__tests__/setup.test.ts +61 -1
- package/src/core/codemirror/__tests__/use-lazy-editor-mount.test.tsx +198 -0
- package/src/core/codemirror/cell-documents.ts +132 -0
- package/src/core/codemirror/cells/debugger-decorations.ts +22 -18
- package/src/core/codemirror/cells/line-timing-decorations.ts +13 -11
- package/src/core/codemirror/cells/traceback-decorations.ts +10 -11
- package/src/core/codemirror/code-lens/__tests__/entities.test.ts +7 -11
- package/src/core/codemirror/code-lens/__tests__/extension.test.ts +38 -12
- package/src/core/codemirror/code-lens/__tests__/perf.test.ts +7 -9
- package/src/core/codemirror/code-lens/extension.ts +21 -13
- package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +9 -14
- package/src/core/codemirror/copilot/getCodes.ts +3 -14
- package/src/core/codemirror/debounced-editor-update.ts +41 -0
- package/src/core/codemirror/editor-mount-scheduler.ts +41 -48
- package/src/core/codemirror/extensions.ts +2 -2
- package/src/core/codemirror/find-replace/__tests__/navigate.test.ts +42 -16
- package/src/core/codemirror/find-replace/__tests__/search-highlight.test.ts +30 -0
- package/src/core/codemirror/find-replace/__tests__/unmounted-cells.test.ts +145 -0
- package/src/core/codemirror/find-replace/navigate.ts +88 -129
- package/src/core/codemirror/find-replace/search-highlight.ts +3 -1
- package/src/core/codemirror/find-replace/state.ts +7 -2
- package/src/core/codemirror/format.ts +25 -31
- package/src/core/codemirror/go-to-definition/__tests__/underline.test.ts +58 -0
- package/src/core/codemirror/go-to-definition/__tests__/utils.test.ts +24 -44
- package/src/core/codemirror/go-to-definition/extension.ts +9 -7
- package/src/core/codemirror/go-to-definition/underline.ts +39 -48
- package/src/core/codemirror/language/__tests__/sql.test.ts +36 -0
- package/src/core/codemirror/language/cell-code.ts +7 -0
- package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +2 -18
- package/src/core/codemirror/language/languages/sql/sql.ts +3 -0
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +25 -0
- package/src/core/codemirror/lsp/notebook-lsp.ts +6 -16
- package/src/core/codemirror/placeholder/extensions.ts +26 -24
- package/src/core/codemirror/reactive-references/__tests__/extension.test.ts +54 -0
- package/src/core/codemirror/reactive-references/extension.ts +30 -21
- package/src/core/codemirror/use-lazy-editor-mount.ts +70 -0
- package/src/core/codemirror/utils.ts +2 -6
- package/src/core/datasets/__tests__/data-source.test.ts +15 -17
- package/src/core/datasets/data-source-connections.ts +8 -11
- package/src/core/datasets/state.ts +7 -12
- package/src/core/executions/__tests__/atoms.test.ts +211 -5
- package/src/core/executions/__tests__/freshness.test.ts +65 -56
- package/src/core/executions/__tests__/interrupt.test.ts +5 -3
- package/src/core/executions/__tests__/output-lifecycle.test.ts +95 -7
- package/src/core/executions/__tests__/output.test.ts +5 -3
- package/src/core/executions/__tests__/run.test.ts +4 -4
- package/src/core/executions/__tests__/select.test.ts +108 -69
- package/src/core/executions/atoms.ts +248 -83
- package/src/core/executions/freshness.ts +7 -7
- package/src/core/executions/hooks.ts +15 -59
- package/src/core/executions/index.ts +2 -0
- package/src/core/executions/output.ts +49 -35
- package/src/core/executions/select.ts +90 -37
- package/src/core/export/__tests__/hooks.test.ts +1 -1
- package/src/core/islands/__tests__/bridge.test.ts +1 -1
- package/src/core/islands/bootstrap.ts +7 -7
- package/src/core/islands/bridge.ts +1 -1
- package/src/core/meta/__tests__/code-visibility.test.tsx +3 -2
- package/src/core/notebook/document/__tests__/codemirror.test.ts +8 -6
- package/src/core/notebook/document/__tests__/draft.test.ts +56 -58
- package/src/core/notebook/document/__tests__/fixtures.ts +8 -7
- package/src/core/notebook/document/__tests__/hooks.test.tsx +39 -35
- package/src/core/notebook/document/__tests__/lifecycle-scenarios.test.ts +8 -5
- package/src/core/notebook/document/__tests__/model.test.ts +8 -5
- package/src/core/notebook/document/__tests__/protocol-fixtures.ts +2 -2
- package/src/core/notebook/document/__tests__/recovery-scenarios.test.ts +37 -32
- package/src/core/notebook/document/__tests__/scenarios.test.ts +49 -45
- package/src/core/notebook/document/__tests__/state.test.ts +59 -56
- package/src/core/notebook/document/__tests__/submission.test.ts +15 -12
- package/src/core/notebook/document/__tests__/test-host.ts +3 -2
- package/src/core/notebook/document/__tests__/user.ts +7 -3
- package/src/core/notebook/document/draft.ts +29 -11
- package/src/core/notebook/document/state.ts +7 -6
- package/src/core/notebook/replica/__tests__/document.test.ts +9 -5
- package/src/core/notebook/replica/__tests__/executions.test.ts +90 -25
- package/src/core/notebook/replica/__tests__/fixtures.ts +6 -2
- package/src/core/notebook/replica/__tests__/frame.test.ts +206 -0
- package/src/core/notebook/replica/__tests__/once-per-frame.test.ts +95 -0
- package/src/core/notebook/replica/__tests__/replica.test.ts +53 -9
- package/src/core/notebook/replica/__tests__/results.test.ts +27 -29
- package/src/core/notebook/replica/execution-state.ts +2 -2
- package/src/core/notebook/replica/frame.ts +54 -0
- package/src/core/notebook/replica/index.ts +1 -0
- package/src/core/notebook/replica/once-per-frame.ts +60 -0
- package/src/core/notebook/replica/replica.ts +27 -6
- package/src/core/notebook/replica/resources/analysis.ts +1 -1
- package/src/core/notebook/replica/resources/document.ts +9 -8
- package/src/core/notebook/replica/resources/executions.ts +197 -78
- package/src/core/notebook/replica/resources/results.ts +8 -14
- package/src/core/saving/__tests__/document.test.tsx +1 -1
- package/src/core/saving/__tests__/state.test.ts +2 -2
- package/src/core/session/__tests__/useNotebookReplica.hook.test.tsx +55 -9
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +230 -12
- package/src/core/session/active-notebook.ts +4 -1
- package/src/core/session/useNotebookReplica.ts +15 -2
- package/src/core/session/useNotebookSession.tsx +38 -46
- package/src/core/state/__tests__/atom-with-selected-inputs.test.ts +48 -0
- package/src/core/state/__tests__/create-keyed-selector-hook.test.tsx +137 -0
- package/src/core/state/atom-with-selected-inputs.ts +24 -0
- package/src/core/state/create-keyed-atom-hook.ts +18 -0
- package/src/core/state/create-keyed-selector-hook.ts +22 -0
- package/src/core/storage/__tests__/state.test.ts +6 -9
- package/src/core/storage/state.ts +5 -8
- package/src/core/transports/__tests__/static.test.ts +3 -2
- package/src/core/transports/static.ts +2 -2
- package/src/core/variables/state.ts +73 -68
- package/src/core/variables/types.ts +2 -2
- package/src/core/vscode/__tests__/is-in-vscode.test.ts +36 -0
- package/src/core/vscode/is-in-vscode.ts +2 -2
- package/src/core/wasm/__tests__/bridge.test.ts +73 -1
- package/src/core/wasm/bridge.ts +5 -4
- package/src/plugins/impl/TextInputPlugin.tsx +2 -1
- package/src/plugins/impl/__test__/text-labels.test.tsx +46 -1
- package/src/utils/__tests__/lazy.test.tsx +33 -0
- package/src/utils/__tests__/shared-intersection-observer.test.ts +49 -0
- package/src/utils/__tests__/shared-resource.test.ts +107 -0
- package/src/utils/arrays.ts +4 -1
- package/src/utils/lazy.tsx +74 -0
- package/src/utils/shared-intersection-observer.ts +53 -0
- package/src/utils/shared-resource.ts +59 -0
- package/src/core/variables/__tests__/state.test.ts +0 -148
- package/src/utils/lazy.ts +0 -35
|
@@ -15,12 +15,17 @@ import {
|
|
|
15
15
|
viewDocument,
|
|
16
16
|
} from "../draft";
|
|
17
17
|
import { cell, CONFIG, document, withCells } from "./fixtures";
|
|
18
|
+
import { cellId } from "@/__tests__/branded";
|
|
19
|
+
|
|
20
|
+
const C1 = cellId("c1");
|
|
21
|
+
const C2 = cellId("c2");
|
|
22
|
+
const C3 = cellId("c3");
|
|
18
23
|
|
|
19
24
|
const confirmed = document();
|
|
20
25
|
|
|
21
26
|
function edits(...steps: Parameters<typeof editCell>[3][]): Draft {
|
|
22
27
|
return steps.reduce(
|
|
23
|
-
(draft, edit) => editCell(confirmed, draft,
|
|
28
|
+
(draft, edit) => editCell(confirmed, draft, C1, edit),
|
|
24
29
|
EMPTY_DRAFT,
|
|
25
30
|
);
|
|
26
31
|
}
|
|
@@ -31,7 +36,7 @@ describe("editCell", () => {
|
|
|
31
36
|
{ code: "a", config: { hide_code: true } },
|
|
32
37
|
{ name: "n", config: { column: 1, hide_code: undefined } },
|
|
33
38
|
);
|
|
34
|
-
expect(viewDocument(confirmed, draft).cells.get(
|
|
39
|
+
expect(viewDocument(confirmed, draft).cells.get(C1)).toEqual({
|
|
35
40
|
id: "c1",
|
|
36
41
|
code: "a",
|
|
37
42
|
name: "n",
|
|
@@ -42,7 +47,7 @@ describe("editCell", () => {
|
|
|
42
47
|
it("keeps a reversal to the confirmed value as a draft", () => {
|
|
43
48
|
const draft = edits({ code: "local" }, { code: "x = 1" });
|
|
44
49
|
const remote = withCells(confirmed, { c1: cell("c1", "earlier edit") });
|
|
45
|
-
expect(viewDocument(remote, draft).cells.get(
|
|
50
|
+
expect(viewDocument(remote, draft).cells.get(C1)?.code).toBe("x = 1");
|
|
46
51
|
});
|
|
47
52
|
|
|
48
53
|
it("accepts empty strings, false and null while ignoring undefined", () => {
|
|
@@ -53,7 +58,7 @@ describe("editCell", () => {
|
|
|
53
58
|
config: { column: null, disabled: false, hide_code: undefined },
|
|
54
59
|
},
|
|
55
60
|
);
|
|
56
|
-
expect(viewDocument(confirmed, draft).cells.get(
|
|
61
|
+
expect(viewDocument(confirmed, draft).cells.get(C1)).toEqual({
|
|
57
62
|
id: "c1",
|
|
58
63
|
code: "",
|
|
59
64
|
name: "_",
|
|
@@ -64,27 +69,23 @@ describe("editCell", () => {
|
|
|
64
69
|
|
|
65
70
|
describe("createCell and deleteCell", () => {
|
|
66
71
|
it("fills protocol defaults and places the cell in the view", () => {
|
|
67
|
-
const atEnd = createCell(EMPTY_DRAFT, { id:
|
|
68
|
-
const after = createCell(
|
|
69
|
-
EMPTY_DRAFT,
|
|
70
|
-
{ id: "c3", code: "3" },
|
|
71
|
-
{ after: "c1" },
|
|
72
|
-
);
|
|
72
|
+
const atEnd = createCell(EMPTY_DRAFT, { id: C3, code: "3" });
|
|
73
|
+
const after = createCell(EMPTY_DRAFT, { id: C3, code: "3" }, { after: C1 });
|
|
73
74
|
const before = createCell(
|
|
74
75
|
EMPTY_DRAFT,
|
|
75
|
-
{ id:
|
|
76
|
-
{ before:
|
|
76
|
+
{ id: C3, code: "3" },
|
|
77
|
+
{ before: C1 },
|
|
77
78
|
);
|
|
78
79
|
const orphan = createCell(
|
|
79
80
|
EMPTY_DRAFT,
|
|
80
|
-
{ id:
|
|
81
|
-
{ after: "gone" },
|
|
81
|
+
{ id: C3, code: "3" },
|
|
82
|
+
{ after: cellId("gone") },
|
|
82
83
|
);
|
|
83
84
|
expect(viewDocument(confirmed, atEnd).order).toEqual(["c1", "c2", "c3"]);
|
|
84
85
|
expect(viewDocument(confirmed, after).order).toEqual(["c1", "c3", "c2"]);
|
|
85
86
|
expect(viewDocument(confirmed, before).order).toEqual(["c3", "c1", "c2"]);
|
|
86
87
|
expect(viewDocument(confirmed, orphan).order).toEqual(["c1", "c2", "c3"]);
|
|
87
|
-
expect(viewDocument(confirmed, atEnd).cells.get(
|
|
88
|
+
expect(viewDocument(confirmed, atEnd).cells.get(C3)).toEqual({
|
|
88
89
|
id: "c3",
|
|
89
90
|
code: "3",
|
|
90
91
|
name: "_",
|
|
@@ -93,25 +94,22 @@ describe("createCell and deleteCell", () => {
|
|
|
93
94
|
});
|
|
94
95
|
|
|
95
96
|
it("forgets a created cell when it is deleted", () => {
|
|
96
|
-
const draft = deleteCell(
|
|
97
|
-
createCell(EMPTY_DRAFT, { id: "c3", code: "" }),
|
|
98
|
-
"c3",
|
|
99
|
-
);
|
|
97
|
+
const draft = deleteCell(createCell(EMPTY_DRAFT, { id: C3, code: "" }), C3);
|
|
100
98
|
expect(toChanges(confirmed, draft)).toEqual([]);
|
|
101
99
|
expect(viewDocument(confirmed, draft).order).toEqual(["c1", "c2"]);
|
|
102
100
|
});
|
|
103
101
|
|
|
104
102
|
it("restores a deleted cell as an edit at the requested place", () => {
|
|
105
|
-
const deleted = deleteCell(EMPTY_DRAFT,
|
|
106
|
-
const back = { id:
|
|
103
|
+
const deleted = deleteCell(EMPTY_DRAFT, C1);
|
|
104
|
+
const back = { id: C1, code: "back" };
|
|
107
105
|
const put = {
|
|
108
106
|
kind: "replace_cell",
|
|
109
107
|
base_etag: "c1-etag",
|
|
110
108
|
cell: { ...back, name: "_", config: CONFIG },
|
|
111
109
|
};
|
|
112
|
-
const inPlace = restoreCell(confirmed, deleted, back, { before:
|
|
113
|
-
const moved = restoreCell(confirmed, deleted, back, { after:
|
|
114
|
-
expect(viewDocument(confirmed, inPlace).cells.get(
|
|
110
|
+
const inPlace = restoreCell(confirmed, deleted, back, { before: C2 });
|
|
111
|
+
const moved = restoreCell(confirmed, deleted, back, { after: C2 });
|
|
112
|
+
expect(viewDocument(confirmed, inPlace).cells.get(C1)?.code).toBe("back");
|
|
115
113
|
expect(viewDocument(confirmed, inPlace).order).toEqual(["c1", "c2"]);
|
|
116
114
|
expect(toChanges(confirmed, inPlace)).toEqual([put]);
|
|
117
115
|
expect(viewDocument(confirmed, moved).order).toEqual(["c2", "c1"]);
|
|
@@ -122,10 +120,10 @@ describe("createCell and deleteCell", () => {
|
|
|
122
120
|
});
|
|
123
121
|
|
|
124
122
|
it("recreates a cell whose deletion is in flight once the host removes it", () => {
|
|
125
|
-
const sent = deleteCell(EMPTY_DRAFT,
|
|
126
|
-
const back = { id:
|
|
127
|
-
const draft = restoreCell(confirmed, sent, back, { before:
|
|
128
|
-
expect(viewDocument(confirmed, draft).cells.get(
|
|
123
|
+
const sent = deleteCell(EMPTY_DRAFT, C1);
|
|
124
|
+
const back = { id: C1, code: "back" };
|
|
125
|
+
const draft = restoreCell(confirmed, sent, back, { before: C2 }, sent);
|
|
126
|
+
expect(viewDocument(confirmed, draft).cells.get(C1)?.code).toBe("back");
|
|
129
127
|
expect(viewDocument(confirmed, draft).order).toEqual(["c1", "c2"]);
|
|
130
128
|
|
|
131
129
|
const removed = withCells(confirmed, { c1: null });
|
|
@@ -172,7 +170,7 @@ describe("viewDocument", () => {
|
|
|
172
170
|
}),
|
|
173
171
|
c2: cell("c2", "remote too"),
|
|
174
172
|
},
|
|
175
|
-
[
|
|
173
|
+
[C2, C1],
|
|
176
174
|
);
|
|
177
175
|
expect(viewDocument(remote, draft)).toEqual({
|
|
178
176
|
order: ["c2", "c1"],
|
|
@@ -180,13 +178,13 @@ describe("viewDocument", () => {
|
|
|
180
178
|
[
|
|
181
179
|
"c1",
|
|
182
180
|
{
|
|
183
|
-
id:
|
|
181
|
+
id: C1,
|
|
184
182
|
code: "local",
|
|
185
183
|
name: "renamed",
|
|
186
184
|
config: { ...CONFIG, disabled: true, hide_code: true },
|
|
187
185
|
},
|
|
188
186
|
],
|
|
189
|
-
["c2", remote.cells.get(
|
|
187
|
+
["c2", remote.cells.get(C2)],
|
|
190
188
|
]),
|
|
191
189
|
});
|
|
192
190
|
});
|
|
@@ -199,10 +197,10 @@ describe("toChanges", () => {
|
|
|
199
197
|
const hidden = withCells(confirmed, {
|
|
200
198
|
c1: cell("c1", "", { code: null }),
|
|
201
199
|
});
|
|
202
|
-
const created = createCell(EMPTY_DRAFT, { id:
|
|
203
|
-
const draft = editCell(hidden, created,
|
|
200
|
+
const created = createCell(EMPTY_DRAFT, { id: C3, code: "" });
|
|
201
|
+
const draft = editCell(hidden, created, C1, edit);
|
|
204
202
|
expect(toChanges(hidden, draft)).toBeNull();
|
|
205
|
-
expect(viewDocument(hidden, draft).cells.get(
|
|
203
|
+
expect(viewDocument(hidden, draft).cells.get(C1)?.code).toBeNull();
|
|
206
204
|
},
|
|
207
205
|
);
|
|
208
206
|
|
|
@@ -212,7 +210,7 @@ describe("toChanges", () => {
|
|
|
212
210
|
const hidden = withCells(confirmed, {
|
|
213
211
|
c1: cell("c1", "", { code: null }),
|
|
214
212
|
});
|
|
215
|
-
const draft = editCell(hidden, EMPTY_DRAFT,
|
|
213
|
+
const draft = editCell(hidden, EMPTY_DRAFT, C1, {
|
|
216
214
|
name: "renamed",
|
|
217
215
|
code,
|
|
218
216
|
});
|
|
@@ -231,10 +229,10 @@ describe("toChanges", () => {
|
|
|
231
229
|
c1: cell("c1", "", { code: null }),
|
|
232
230
|
c2: cell("c2", "", { code: null }),
|
|
233
231
|
});
|
|
234
|
-
expect(toChanges(hidden, deleteCell(EMPTY_DRAFT,
|
|
232
|
+
expect(toChanges(hidden, deleteCell(EMPTY_DRAFT, C1))).toEqual([
|
|
235
233
|
{ kind: "delete_cell", id: "c1", base_etag: "c1-etag" },
|
|
236
234
|
]);
|
|
237
|
-
expect(toChanges(hidden, setOrder(EMPTY_DRAFT, [
|
|
235
|
+
expect(toChanges(hidden, setOrder(EMPTY_DRAFT, [C2, C1]))).toEqual([
|
|
238
236
|
{ kind: "set_order", base_etag: "order-1", order: ["c2", "c1"] },
|
|
239
237
|
]);
|
|
240
238
|
});
|
|
@@ -255,22 +253,22 @@ describe("toChanges", () => {
|
|
|
255
253
|
{
|
|
256
254
|
kind: "replace_cell",
|
|
257
255
|
base_etag: "c1-etag-2",
|
|
258
|
-
cell: { id:
|
|
256
|
+
cell: { id: C1, code: "local", name: "renamed", config: CONFIG },
|
|
259
257
|
},
|
|
260
258
|
]);
|
|
261
259
|
});
|
|
262
260
|
|
|
263
261
|
it("places a cell before another creation with one order change", () => {
|
|
264
|
-
let draft = createCell(EMPTY_DRAFT, { id:
|
|
265
|
-
draft = createCell(draft, { id: "c4", code: "4" }, { before:
|
|
262
|
+
let draft = createCell(EMPTY_DRAFT, { id: C3, code: "3" });
|
|
263
|
+
draft = createCell(draft, { id: cellId("c4"), code: "4" }, { before: C3 });
|
|
266
264
|
expect(toChanges(confirmed, draft)).toEqual([
|
|
267
265
|
{
|
|
268
266
|
kind: "create_cell",
|
|
269
|
-
cell: { id:
|
|
267
|
+
cell: { id: C3, code: "3", name: "_", config: CONFIG },
|
|
270
268
|
},
|
|
271
269
|
{
|
|
272
270
|
kind: "create_cell",
|
|
273
|
-
cell: { id: "c4", code: "4", name: "_", config: CONFIG },
|
|
271
|
+
cell: { id: cellId("c4"), code: "4", name: "_", config: CONFIG },
|
|
274
272
|
},
|
|
275
273
|
{
|
|
276
274
|
kind: "set_order",
|
|
@@ -280,29 +278,29 @@ describe("toChanges", () => {
|
|
|
280
278
|
]);
|
|
281
279
|
});
|
|
282
280
|
|
|
283
|
-
it.each([{ after:
|
|
281
|
+
it.each([{ after: C2 }, { before: C2 }])(
|
|
284
282
|
"appends when the placement anchor was deleted earlier in the request: %o",
|
|
285
283
|
(placement) => {
|
|
286
|
-
let draft = deleteCell(EMPTY_DRAFT,
|
|
287
|
-
draft = createCell(draft, { id:
|
|
284
|
+
let draft = deleteCell(EMPTY_DRAFT, C2);
|
|
285
|
+
draft = createCell(draft, { id: C3, code: "3" }, placement);
|
|
288
286
|
expect(toChanges(confirmed, draft)).toEqual([
|
|
289
287
|
{ kind: "delete_cell", id: "c2", base_etag: "c2-etag" },
|
|
290
288
|
{
|
|
291
289
|
kind: "create_cell",
|
|
292
|
-
cell: { id:
|
|
290
|
+
cell: { id: C3, code: "3", name: "_", config: CONFIG },
|
|
293
291
|
},
|
|
294
292
|
]);
|
|
295
293
|
},
|
|
296
294
|
);
|
|
297
295
|
|
|
298
296
|
it("creates, deletes, then sets the reconciled order", () => {
|
|
299
|
-
let draft = setOrder(EMPTY_DRAFT, [
|
|
300
|
-
draft = createCell(draft, { id:
|
|
301
|
-
draft = deleteCell(draft,
|
|
297
|
+
let draft = setOrder(EMPTY_DRAFT, [C2, C1]);
|
|
298
|
+
draft = createCell(draft, { id: C3, code: "3" }, { after: C2 });
|
|
299
|
+
draft = deleteCell(draft, C1);
|
|
302
300
|
expect(toChanges(confirmed, draft)).toEqual([
|
|
303
301
|
{
|
|
304
302
|
kind: "create_cell",
|
|
305
|
-
cell: { id:
|
|
303
|
+
cell: { id: C3, code: "3", name: "_", config: CONFIG },
|
|
306
304
|
},
|
|
307
305
|
{ kind: "delete_cell", id: "c1", base_etag: "c1-etag" },
|
|
308
306
|
{ kind: "set_order", base_etag: "order-1", order: ["c2", "c3"] },
|
|
@@ -316,7 +314,7 @@ describe("acknowledge", () => {
|
|
|
316
314
|
code: "sent",
|
|
317
315
|
config: { hide_code: true, column: 1 },
|
|
318
316
|
});
|
|
319
|
-
const later = editCell(confirmed, sent,
|
|
317
|
+
const later = editCell(confirmed, sent, C1, {
|
|
320
318
|
code: "typed more",
|
|
321
319
|
config: { column: 2 },
|
|
322
320
|
});
|
|
@@ -324,7 +322,7 @@ describe("acknowledge", () => {
|
|
|
324
322
|
c1: cell("c1", "remote", { config: { ...CONFIG, column: 1 } }),
|
|
325
323
|
});
|
|
326
324
|
expect(
|
|
327
|
-
viewDocument(remote, acknowledge(later, sent)).cells.get(
|
|
325
|
+
viewDocument(remote, acknowledge(later, sent)).cells.get(C1),
|
|
328
326
|
).toEqual({
|
|
329
327
|
id: "c1",
|
|
330
328
|
code: "typed more",
|
|
@@ -334,22 +332,22 @@ describe("acknowledge", () => {
|
|
|
334
332
|
});
|
|
335
333
|
|
|
336
334
|
it("turns an accepted creation into an edit of only the fields changed since", () => {
|
|
337
|
-
const sent = createCell(EMPTY_DRAFT, { id:
|
|
338
|
-
const later = editCell(confirmed, sent,
|
|
335
|
+
const sent = createCell(EMPTY_DRAFT, { id: C3, code: "3" });
|
|
336
|
+
const later = editCell(confirmed, sent, C3, { name: "named" });
|
|
339
337
|
const remote = withCells(confirmed, { c3: cell("c3", "remote code") });
|
|
340
338
|
expect(toChanges(remote, acknowledge(later, sent))).toEqual([
|
|
341
339
|
{
|
|
342
340
|
kind: "replace_cell",
|
|
343
341
|
base_etag: "c3-etag",
|
|
344
|
-
cell: { id:
|
|
342
|
+
cell: { id: C3, code: "remote code", name: "named", config: CONFIG },
|
|
345
343
|
},
|
|
346
344
|
]);
|
|
347
345
|
});
|
|
348
346
|
|
|
349
347
|
it("releases an accepted order but preserves a subsequent reorder", () => {
|
|
350
|
-
const sent = setOrder(EMPTY_DRAFT, [
|
|
351
|
-
const later = setOrder(sent, [
|
|
352
|
-
const remote = withCells(confirmed, {}, [
|
|
348
|
+
const sent = setOrder(EMPTY_DRAFT, [C2, C1]);
|
|
349
|
+
const later = setOrder(sent, [C1, C2]);
|
|
350
|
+
const remote = withCells(confirmed, {}, [C2, C1]);
|
|
353
351
|
expect(toChanges(remote, acknowledge(sent, sent))).toEqual([]);
|
|
354
352
|
expect(toChanges(remote, acknowledge(later, sent))).toEqual([
|
|
355
353
|
{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import { cellId } from "@/__tests__/branded";
|
|
3
4
|
import type { Document } from "../../replica/resources/document";
|
|
4
5
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
5
6
|
|
|
@@ -11,12 +12,12 @@ export const CONFIG: Protocol.CellConfig = {
|
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
export function cell(
|
|
14
|
-
id:
|
|
15
|
+
id: string,
|
|
15
16
|
code: string,
|
|
16
|
-
overrides: Partial<Protocol.
|
|
17
|
-
): Protocol.
|
|
17
|
+
overrides: Partial<Protocol.CellOutput> = {},
|
|
18
|
+
): Protocol.CellOutput {
|
|
18
19
|
return {
|
|
19
|
-
id,
|
|
20
|
+
id: cellId(id),
|
|
20
21
|
notebook_id: "n1",
|
|
21
22
|
code,
|
|
22
23
|
name: "_",
|
|
@@ -52,15 +53,15 @@ export function document(notebookId: Protocol.NotebookId = "n1"): Document {
|
|
|
52
53
|
/** The document with some cells replaced or removed and the order updated. */
|
|
53
54
|
export function withCells(
|
|
54
55
|
base: Document,
|
|
55
|
-
changes: Record<
|
|
56
|
+
changes: Record<string, Protocol.CellOutput | null>,
|
|
56
57
|
order?: readonly Protocol.CellId[],
|
|
57
58
|
): Document {
|
|
58
59
|
const cells = new Map(base.cells);
|
|
59
60
|
for (const [id, next] of Object.entries(changes)) {
|
|
60
61
|
if (next === null) {
|
|
61
|
-
cells.delete(id);
|
|
62
|
+
cells.delete(cellId(id));
|
|
62
63
|
} else {
|
|
63
|
-
cells.set(id, next);
|
|
64
|
+
cells.set(cellId(id), next);
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
const nextOrder = order
|
|
@@ -17,6 +17,10 @@ import {
|
|
|
17
17
|
import { createDocumentModel, DocumentProvider } from "..";
|
|
18
18
|
import { cell, CONFIG, document, withCells } from "./fixtures";
|
|
19
19
|
import { type FakeEdit, fakeBackend } from "../../replica/__tests__/fixtures";
|
|
20
|
+
import { cellId } from "@/__tests__/branded";
|
|
21
|
+
|
|
22
|
+
const C1 = cellId("c1");
|
|
23
|
+
const C2 = cellId("c2");
|
|
20
24
|
|
|
21
25
|
const lifetimes: AbortController[] = [];
|
|
22
26
|
|
|
@@ -65,13 +69,13 @@ describe("document hooks", () => {
|
|
|
65
69
|
const { store, source, wrapper, controller } = setup(document(), edit);
|
|
66
70
|
const { result, unmount } = renderHook(
|
|
67
71
|
() => ({
|
|
68
|
-
code: useNotebookCellCode(
|
|
72
|
+
code: useNotebookCellCode(C1),
|
|
69
73
|
edit: useNotebookDocumentEdit(),
|
|
70
74
|
sync: useNotebookDocumentSync(),
|
|
71
75
|
}),
|
|
72
76
|
{ wrapper, reactStrictMode: true },
|
|
73
77
|
);
|
|
74
|
-
act(() => result.current.edit((tx) => tx.setCode(
|
|
78
|
+
act(() => result.current.edit((tx) => tx.setCode(C1, "local")));
|
|
75
79
|
expect(result.current.sync.status).toEqual({ status: "pending" });
|
|
76
80
|
const { flush, retry } = result.current.sync;
|
|
77
81
|
await act(async () => {
|
|
@@ -87,7 +91,7 @@ describe("document hooks", () => {
|
|
|
87
91
|
retry,
|
|
88
92
|
});
|
|
89
93
|
expect(result.current.code).toBe("local");
|
|
90
|
-
act(() => result.current.edit((tx) => tx.setCode(
|
|
94
|
+
act(() => result.current.edit((tx) => tx.setCode(C1, "next")));
|
|
91
95
|
await act(async () => {
|
|
92
96
|
const rejected = (async () => {
|
|
93
97
|
await expect(flush()).rejects.toThrow("session ended");
|
|
@@ -108,9 +112,9 @@ describe("document hooks", () => {
|
|
|
108
112
|
const { result } = renderHook(
|
|
109
113
|
() => {
|
|
110
114
|
const value = {
|
|
111
|
-
code: useNotebookCellCode(
|
|
112
|
-
name: useNotebookCellName(
|
|
113
|
-
config: useNotebookCellConfig(
|
|
115
|
+
code: useNotebookCellCode(C1),
|
|
116
|
+
name: useNotebookCellName(C1),
|
|
117
|
+
config: useNotebookCellConfig(C1),
|
|
114
118
|
order: useNotebookCellOrder(),
|
|
115
119
|
};
|
|
116
120
|
seen(value);
|
|
@@ -123,10 +127,10 @@ describe("document hooks", () => {
|
|
|
123
127
|
|
|
124
128
|
act(() =>
|
|
125
129
|
edit((tx) => {
|
|
126
|
-
tx.setCode(
|
|
127
|
-
tx.setName(
|
|
128
|
-
tx.updateConfig(
|
|
129
|
-
tx.setOrder([
|
|
130
|
+
tx.setCode(C1, "edited");
|
|
131
|
+
tx.setName(C1, "renamed");
|
|
132
|
+
tx.updateConfig(C1, { hide_code: true });
|
|
133
|
+
tx.setOrder([C2, C1]);
|
|
130
134
|
}),
|
|
131
135
|
);
|
|
132
136
|
|
|
@@ -146,8 +150,8 @@ describe("document hooks", () => {
|
|
|
146
150
|
expect(() =>
|
|
147
151
|
act(() =>
|
|
148
152
|
edit((tx) => {
|
|
149
|
-
tx.setCode(
|
|
150
|
-
tx.deleteCell("missing");
|
|
153
|
+
tx.setCode(C1, "rolled back");
|
|
154
|
+
tx.deleteCell(cellId("missing"));
|
|
151
155
|
}),
|
|
152
156
|
),
|
|
153
157
|
).toThrow("does not exist");
|
|
@@ -162,15 +166,15 @@ describe("document hooks", () => {
|
|
|
162
166
|
const onOrder = vi.fn();
|
|
163
167
|
const onEdit = vi.fn();
|
|
164
168
|
function Code() {
|
|
165
|
-
onCode(useNotebookCellCode(
|
|
169
|
+
onCode(useNotebookCellCode(C1));
|
|
166
170
|
return null;
|
|
167
171
|
}
|
|
168
172
|
function Name() {
|
|
169
|
-
onName(useNotebookCellName(
|
|
173
|
+
onName(useNotebookCellName(C1));
|
|
170
174
|
return null;
|
|
171
175
|
}
|
|
172
176
|
function Config() {
|
|
173
|
-
onConfig(useNotebookCellConfig(
|
|
177
|
+
onConfig(useNotebookCellConfig(C1));
|
|
174
178
|
return null;
|
|
175
179
|
}
|
|
176
180
|
function Order() {
|
|
@@ -199,7 +203,7 @@ describe("document hooks", () => {
|
|
|
199
203
|
);
|
|
200
204
|
clear();
|
|
201
205
|
|
|
202
|
-
act(() => edit((tx) => tx.setCode(
|
|
206
|
+
act(() => edit((tx) => tx.setCode(C1, "local")));
|
|
203
207
|
expect(onCode).toHaveBeenCalledWith("local");
|
|
204
208
|
expect(onName).not.toHaveBeenCalled();
|
|
205
209
|
expect(onConfig).not.toHaveBeenCalled();
|
|
@@ -207,7 +211,7 @@ describe("document hooks", () => {
|
|
|
207
211
|
expect(onEdit).not.toHaveBeenCalled();
|
|
208
212
|
clear();
|
|
209
213
|
|
|
210
|
-
act(() => edit((tx) => tx.setCode(
|
|
214
|
+
act(() => edit((tx) => tx.setCode(C2, "other")));
|
|
211
215
|
expect(
|
|
212
216
|
[onCode, onName, onConfig, onOrder, onEdit].map((fn) => fn.mock.calls),
|
|
213
217
|
).toEqual([[], [], [], [], []]);
|
|
@@ -232,8 +236,8 @@ describe("document hooks", () => {
|
|
|
232
236
|
|
|
233
237
|
act(() =>
|
|
234
238
|
edit((tx) => {
|
|
235
|
-
tx.updateConfig(
|
|
236
|
-
tx.setOrder([
|
|
239
|
+
tx.updateConfig(C1, { disabled: true });
|
|
240
|
+
tx.setOrder([C2, C1]);
|
|
237
241
|
}),
|
|
238
242
|
);
|
|
239
243
|
expect(onConfig).toHaveBeenCalledWith({ ...CONFIG, disabled: true });
|
|
@@ -250,14 +254,14 @@ describe("document hooks", () => {
|
|
|
250
254
|
code: useNotebookCellCode(id),
|
|
251
255
|
edit: useNotebookDocumentEdit(),
|
|
252
256
|
}),
|
|
253
|
-
{ wrapper, initialProps:
|
|
257
|
+
{ wrapper, initialProps: C1 },
|
|
254
258
|
);
|
|
255
259
|
const edit = result.current.edit;
|
|
256
|
-
rerender(
|
|
260
|
+
rerender(C2);
|
|
257
261
|
expect(result.current).toEqual({ code: "y = 2", edit });
|
|
258
|
-
act(() => edit((tx) => tx.setCode(
|
|
262
|
+
act(() => edit((tx) => tx.setCode(C1, "old subscription")));
|
|
259
263
|
expect(result.current).toEqual({ code: "y = 2", edit });
|
|
260
|
-
act(() => edit((tx) => tx.setCode(
|
|
264
|
+
act(() => edit((tx) => tx.setCode(C2, "new subscription")));
|
|
261
265
|
expect(result.current).toEqual({ code: "new subscription", edit });
|
|
262
266
|
});
|
|
263
267
|
|
|
@@ -266,9 +270,9 @@ describe("document hooks", () => {
|
|
|
266
270
|
const { result } = renderHook(
|
|
267
271
|
() => ({
|
|
268
272
|
order: useNotebookCellOrder(),
|
|
269
|
-
code: useNotebookCellCode(
|
|
270
|
-
name: useNotebookCellName(
|
|
271
|
-
config: useNotebookCellConfig(
|
|
273
|
+
code: useNotebookCellCode(C1),
|
|
274
|
+
name: useNotebookCellName(C1),
|
|
275
|
+
config: useNotebookCellConfig(C1),
|
|
272
276
|
edit: useNotebookDocumentEdit(),
|
|
273
277
|
}),
|
|
274
278
|
{ wrapper },
|
|
@@ -292,7 +296,7 @@ describe("document hooks", () => {
|
|
|
292
296
|
order: ["c1", "c2"],
|
|
293
297
|
edit,
|
|
294
298
|
});
|
|
295
|
-
act(() => edit((tx) => tx.setCode(
|
|
299
|
+
act(() => edit((tx) => tx.setCode(C1, "")));
|
|
296
300
|
expect(result.current.code).toBe("");
|
|
297
301
|
act(() => store.set(source, null));
|
|
298
302
|
expect(result.current).toEqual({ ...absent, order: null });
|
|
@@ -300,8 +304,8 @@ describe("document hooks", () => {
|
|
|
300
304
|
expect(result.current.code).toBe("");
|
|
301
305
|
act(() =>
|
|
302
306
|
edit((tx) => {
|
|
303
|
-
tx.deleteCell(
|
|
304
|
-
tx.deleteCell(
|
|
307
|
+
tx.deleteCell(C1);
|
|
308
|
+
tx.deleteCell(C2);
|
|
305
309
|
}),
|
|
306
310
|
);
|
|
307
311
|
expect(result.current).toEqual({ ...absent, order: [] });
|
|
@@ -310,19 +314,19 @@ describe("document hooks", () => {
|
|
|
310
314
|
it("preserves drafts across Strict Mode remounts until the session ends", () => {
|
|
311
315
|
const { wrapper, controller, detached } = setup();
|
|
312
316
|
const useProbe = () => ({
|
|
313
|
-
code: useNotebookCellCode(
|
|
317
|
+
code: useNotebookCellCode(C1),
|
|
314
318
|
edit: useNotebookDocumentEdit(),
|
|
315
319
|
});
|
|
316
320
|
const first = renderHook(useProbe, { wrapper, reactStrictMode: true });
|
|
317
321
|
const edit = first.result.current.edit;
|
|
318
|
-
act(() => edit((tx) => tx.setCode(
|
|
322
|
+
act(() => edit((tx) => tx.setCode(C1, "strict mode edit")));
|
|
319
323
|
expect(first.result.current.code).toBe("strict mode edit");
|
|
320
324
|
first.unmount();
|
|
321
325
|
expect(detached).not.toHaveBeenCalled();
|
|
322
326
|
|
|
323
327
|
const second = renderHook(useProbe, { wrapper, reactStrictMode: true });
|
|
324
328
|
expect(second.result.current.code).toBe("strict mode edit");
|
|
325
|
-
act(() => edit((tx) => tx.setCode(
|
|
329
|
+
act(() => edit((tx) => tx.setCode(C1, "same session")));
|
|
326
330
|
expect(second.result.current.code).toBe("same session");
|
|
327
331
|
second.unmount();
|
|
328
332
|
controller.abort();
|
|
@@ -342,7 +346,7 @@ describe("document hooks", () => {
|
|
|
342
346
|
const seen = vi.fn();
|
|
343
347
|
function Probe() {
|
|
344
348
|
seen({
|
|
345
|
-
code: useNotebookCellCode(
|
|
349
|
+
code: useNotebookCellCode(C1),
|
|
346
350
|
edit: useNotebookDocumentEdit(),
|
|
347
351
|
});
|
|
348
352
|
return null;
|
|
@@ -357,7 +361,7 @@ describe("document hooks", () => {
|
|
|
357
361
|
const { rerender } = render(tree(first));
|
|
358
362
|
const oldEdit: ReturnType<typeof useNotebookDocumentEdit> =
|
|
359
363
|
seen.mock.calls.at(-1)![0].edit;
|
|
360
|
-
act(() => oldEdit((tx) => tx.setCode(
|
|
364
|
+
act(() => oldEdit((tx) => tx.setCode(C1, "first draft")));
|
|
361
365
|
rerender(tree(second));
|
|
362
366
|
act(() => first.controller.abort());
|
|
363
367
|
expect(first.detached).toHaveBeenCalledOnce();
|
|
@@ -367,7 +371,7 @@ describe("document hooks", () => {
|
|
|
367
371
|
} = seen.mock.calls.at(-1)![0];
|
|
368
372
|
expect(latest.code).toBe("second source");
|
|
369
373
|
expect(latest.edit).not.toBe(oldEdit);
|
|
370
|
-
act(() => latest.edit((tx) => tx.setCode(
|
|
374
|
+
act(() => latest.edit((tx) => tx.setCode(C1, "second draft")));
|
|
371
375
|
expect(seen.mock.calls.at(-1)![0].code).toBe("second draft");
|
|
372
376
|
const stale = vi.fn();
|
|
373
377
|
oldEdit(stale);
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import { vi } from "vitest";
|
|
4
4
|
import { test } from "./scenario-fixture";
|
|
5
|
+
import { cellId } from "@/__tests__/branded";
|
|
6
|
+
|
|
7
|
+
const C3 = cellId("c3");
|
|
5
8
|
|
|
6
9
|
test("closing a session before the scheduled send prevents submission", async ({
|
|
7
10
|
expect,
|
|
8
11
|
session: { user, notebook, controller },
|
|
9
12
|
}) => {
|
|
10
|
-
user.changeCode(
|
|
13
|
+
user.changeCode(C3, "local");
|
|
11
14
|
const reason = new Error("Editing session ended");
|
|
12
15
|
controller.abort(reason);
|
|
13
16
|
await vi.advanceTimersByTimeAsync(1000);
|
|
@@ -20,7 +23,7 @@ test("closing a session before a queued flush starts prevents submission", async
|
|
|
20
23
|
expect,
|
|
21
24
|
session: { user, notebook, controller },
|
|
22
25
|
}) => {
|
|
23
|
-
user.changeCode(
|
|
26
|
+
user.changeCode(C3, "local");
|
|
24
27
|
const flushed = user.sync();
|
|
25
28
|
const reason = new Error("Editing session ended");
|
|
26
29
|
controller.abort(reason);
|
|
@@ -32,7 +35,7 @@ test("closing a session before a queued flush starts prevents submission", async
|
|
|
32
35
|
test.for(["request", "confirmation", "retry"] as const)(
|
|
33
36
|
"closing a session during %s stops synchronization",
|
|
34
37
|
async (phase, { expect, session: { user, host, notebook, controller } }) => {
|
|
35
|
-
user.changeCode(
|
|
38
|
+
user.changeCode(C3, "local");
|
|
36
39
|
const flushed = user.sync();
|
|
37
40
|
const request = await host.nextRequest();
|
|
38
41
|
if (phase === "confirmation") {
|
|
@@ -49,9 +52,9 @@ test.for(["request", "confirmation", "retry"] as const)(
|
|
|
49
52
|
expect(request.signal.aborted).toBe(true);
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
host.changeCell("c1", { code: "later" });
|
|
55
|
+
host.changeCell(cellId("c1"), { code: "later" });
|
|
53
56
|
host.deliverSnapshot();
|
|
54
|
-
user.changeCode(
|
|
57
|
+
user.changeCode(C3, "after closing");
|
|
55
58
|
await vi.advanceTimersByTimeAsync(1000);
|
|
56
59
|
expect(notebook.edit).toHaveBeenCalledOnce();
|
|
57
60
|
expect(vi.getTimerCount()).toBe(0);
|
|
@@ -10,6 +10,9 @@ import type { Document } from "../../replica/resources/document";
|
|
|
10
10
|
import { createDocumentModel } from "../model";
|
|
11
11
|
import { type FakeEdit, fakeBackend } from "../../replica/__tests__/fixtures";
|
|
12
12
|
import { cell, document, withCells } from "./fixtures";
|
|
13
|
+
import { cellId } from "@/__tests__/branded";
|
|
14
|
+
|
|
15
|
+
const C1 = cellId("c1");
|
|
13
16
|
|
|
14
17
|
function response(confirmed: Document): ResultOf<"notebook.edit"> {
|
|
15
18
|
return {
|
|
@@ -72,9 +75,9 @@ function setup({ connected = true } = {}) {
|
|
|
72
75
|
controller,
|
|
73
76
|
unmounted,
|
|
74
77
|
edit: (code: string) =>
|
|
75
|
-
store.set(model.editAtom, (tx) => tx.setCode(
|
|
78
|
+
store.set(model.editAtom, (tx) => tx.setCode(C1, code)),
|
|
76
79
|
status: () => store.get(model.syncStatusAtom),
|
|
77
|
-
value: () => store.get(model.documentAtom)?.cells.get(
|
|
80
|
+
value: () => store.get(model.documentAtom)?.cells.get(C1),
|
|
78
81
|
};
|
|
79
82
|
}
|
|
80
83
|
|
|
@@ -98,7 +101,7 @@ describe("document synchronization", () => {
|
|
|
98
101
|
shownDocumentAtom: source,
|
|
99
102
|
backendAtom: atom(fakeBackend({ edit })),
|
|
100
103
|
});
|
|
101
|
-
store.set(model.editAtom, (tx) => tx.setCode(
|
|
104
|
+
store.set(model.editAtom, (tx) => tx.setCode(C1, "local"));
|
|
102
105
|
await expect(model.flush()).rejects.toThrow("not started");
|
|
103
106
|
expect(store.get(model.documentAtom)).toBeNull();
|
|
104
107
|
expect(store.get(model.syncStatusAtom)).toEqual({ status: "unavailable" });
|
|
@@ -150,7 +153,7 @@ describe("document synchronization", () => {
|
|
|
150
153
|
const next = new AbortController();
|
|
151
154
|
lifetimes.push(next);
|
|
152
155
|
model.start({ signal: next.signal });
|
|
153
|
-
expect(store.get(model.documentAtom)?.cells.get(
|
|
156
|
+
expect(store.get(model.documentAtom)?.cells.get(C1)?.code).toBe("x = 1");
|
|
154
157
|
});
|
|
155
158
|
|
|
156
159
|
it("starts again without the drafts of a stopped run", () => {
|
|
@@ -164,7 +167,7 @@ describe("document synchronization", () => {
|
|
|
164
167
|
lifetimes.push(next);
|
|
165
168
|
model.start({ signal: next.signal });
|
|
166
169
|
expect(value()?.code).toBe("x = 1");
|
|
167
|
-
store.set(model.editAtom, (tx) => tx.setCode(
|
|
170
|
+
store.set(model.editAtom, (tx) => tx.setCode(C1, "restarted"));
|
|
168
171
|
expect(value()?.code).toBe("restarted");
|
|
169
172
|
});
|
|
170
173
|
|
|
@@ -20,8 +20,8 @@ export function protocolFixture(name: string): unknown {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function initialDocument(): Document {
|
|
23
|
-
const cells = new Map<Protocol.CellId, Protocol.
|
|
24
|
-
let revision: Protocol.
|
|
23
|
+
const cells = new Map<Protocol.CellId, Protocol.CellOutput>();
|
|
24
|
+
let revision: Protocol.DocumentOutput | undefined;
|
|
25
25
|
for (const event of fixtureEvents("notebook-events.sse")) {
|
|
26
26
|
if (event.event === "ready") {
|
|
27
27
|
break;
|