@marimo-team/islands 0.26.1-dev1 → 0.26.1-dev101
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-BJBdnd0O.js} +23 -23
- package/dist/{ErrorBoundary-CnVR4XMW.js → ErrorBoundary-CykWjxjc.js} +7 -7
- package/dist/{Plot-BHJLG4xm.js → Plot-gpsi2L3q.js} +76911 -88182
- package/dist/{abnfDiagram-VCTEODGH-BbZOIueZ.js → abnfDiagram-VCTEODGH-Ba0MYVW8.js} +2 -2
- package/dist/{any-language-editor-yG-YmLaK.js → any-language-editor-BNe8do3C.js} +5 -5
- package/dist/{architectureDiagram-5GKGNRK7-qjLjxapm.js → architectureDiagram-5GKGNRK7-7MqAehef.js} +1 -1
- package/dist/{assertNever-DywGMo-S.js → assertNever-5vhHGKOK.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-BbJTFtyC.js} +586 -585
- package/dist/{check-jchHMCfs.js → check-DUIc04aK.js} +1 -1
- package/dist/{chunk-IMKFNOWR-BzDY1_I7.js → chunk-IMKFNOWR-CAWA0HGB.js} +1 -1
- package/dist/{chunk-SHT3W25Y-DbHsMKdo.js → chunk-SHT3W25Y-BIwVQjG5.js} +1 -1
- package/dist/{chunk-SVP7TREG-CtwnwAE6.js → chunk-SVP7TREG-Cux251TB.js} +1 -1
- package/dist/{chunk-TICWLB2K-C5Z5QMbO.js → chunk-TICWLB2K-DJVQ6khO.js} +1 -1
- package/dist/circle-question-mark-evCnVIut.js +19 -0
- package/dist/{classDiagram-ZZMXUADV-B8E5Hn78.js → classDiagram-ZZMXUADV-Cwve77ev.js} +2 -2
- package/dist/{classDiagram-v2-VYDZK3BY-DeGsK9bT.js → classDiagram-v2-VYDZK3BY-BAeHKXmD.js} +2 -2
- package/dist/{code-visibility-Cs-o5weM.js → code-visibility-0-chGN-9.js} +18 -18
- package/dist/{common-C92_m-1k.js → common-C_oC5BhT.js} +6124 -6068
- package/dist/{copy-icon-BI7vZHEW.js → copy-icon-CmNLxT5_.js} +3 -3
- package/dist/{createReducer-DdSLRfBT.js → createReducer-BUQhgLOI.js} +6 -6
- package/dist/{cynefinDiagram-5FMLGOSQ-NDedRwsw.js → cynefinDiagram-5FMLGOSQ-t4eEkPJh.js} +1 -1
- package/dist/{dagre-GXQ25YYZ-De0sSZO7.js → dagre-GXQ25YYZ-IuZuI28B.js} +1 -1
- package/dist/{data-grid-overlay-editor-D32Gn15n.js → data-grid-overlay-editor-PREeXtCk.js} +5 -5
- package/dist/{data-grid-types-DIX_pCco.js → data-grid-types-DBNnjiYJ.js} +2 -2
- package/dist/{diagram-S7CK7UJ4-wBtVl61y.js → diagram-S7CK7UJ4-D8R5Q_ok.js} +1 -1
- package/dist/{diagram-UQ7AKVKN-CKWE3c1T.js → diagram-UQ7AKVKN-BGuMPsr-.js} +1 -1
- package/dist/{diagram-VX7I27RA-D2Ac5198.js → diagram-VX7I27RA-BkTtpO8P.js} +1 -1
- package/dist/{diagram-Z3DM3KII-CYaFOQcI.js → diagram-Z3DM3KII-C0__Mxfm.js} +1 -1
- package/dist/{dialog-Ic6dh09m.js → dialog-BvjfalZ9.js} +28 -28
- 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-D0DeN-aL.js} +2108 -2108
- package/dist/{ebnfDiagram-PWID7BFC-Ds7f42dj.js → ebnfDiagram-PWID7BFC-CSESPZoz.js} +2 -2
- package/dist/{erDiagram-RLTQ6QDP-b58Sz2Mc.js → erDiagram-RLTQ6QDP-DsDTtabH.js} +1 -1
- package/dist/{error-banner-CJVLr5_a.js → error-banner-CXLjTW24.js} +75 -80
- package/dist/{error-entries-BKlEsuk4.js → error-entries-DhZotdzQ.js} +1033 -867
- package/dist/{esm-B9n0caHs.js → esm-DY8dGAjJ.js} +23 -23
- package/dist/{esm-Bwp_FHP0.js → esm-Dw2ZydG_.js} +3 -3
- package/dist/{config-qTaTHnpE.js → export-context-CkgZeARR.js} +79 -68
- package/dist/{feedback-button-HXizISwe.js → feedback-button-BR9wcyCI.js} +123 -123
- package/dist/{flowDiagram-HODETNUW-BH9U7VZK.js → flowDiagram-HODETNUW-qxDPYbfV.js} +2 -2
- package/dist/{formats-BLNFWWhV.js → formats-CcQrzFo8.js} +3 -3
- package/dist/{glide-data-editor-Cha2TqyF.js → glide-data-editor-C-8SS0aB.js} +90 -90
- package/dist/{glide-utils-Cn2_NadX.js → glide-utils-CD8BaFTm.js} +4 -4
- package/dist/{globals-C4qZtAQ0.js → globals-DdJFuSRA.js} +3 -3
- package/dist/{html-to-image-CNM0ZSFD.js → html-to-image-B8erjaaD.js} +24154 -24055
- package/dist/{infoDiagram-27XIBGKW-xbjwrcNi.js → infoDiagram-27XIBGKW-B5hq8RM_.js} +1 -1
- package/dist/{ishikawaDiagram-5VMMS53U-DKtukhGS.js → ishikawaDiagram-5VMMS53U-DkHc_9ET.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-BEhlkZBb.js → kanban-definition-UXKFOSKX-CqkTFXmU.js} +1 -1
- package/dist/{loader-Bin_dutt.js → loader-CGrYn73j.js} +422 -374
- package/dist/main.js +9013 -8824
- package/dist/{mermaid-D1CZDNoB.js → mermaid-pmVHDUQA.js} +35 -35
- package/dist/{mindmap-definition-YA3MSWOX-DQcnJPcV.js → mindmap-definition-YA3MSWOX-D6cNa__z.js} +1 -1
- package/dist/{number-overlay-editor-BVmdbAY7.js → number-overlay-editor-CVKX9zwo.js} +3 -3
- package/dist/{pegDiagram-XKGWAZYB-BFQuPYfI.js → pegDiagram-XKGWAZYB-CmWJX_s1.js} +2 -2
- package/dist/{pencil-DVYzq-iR.js → pencil-CxMgOe04.js} +1 -1
- package/dist/{pieDiagram-E7YTZNPT-l7aqNrem.js → pieDiagram-E7YTZNPT-CAQAxHah.js} +1 -1
- package/dist/{process-output-DthYR2Te.js → process-output-C-2_O5Ry.js} +4 -4
- package/dist/{railroadDiagram-O6MQD6OU-6R3C1lwQ.js → railroadDiagram-O6MQD6OU-jlSsiQg3.js} +2 -2
- package/dist/{requirementDiagram-BXWQKSXE-DdWYu8fn.js → requirementDiagram-BXWQKSXE-DkDjfPhn.js} +1 -1
- package/dist/{reveal-component-B8gTDFli.js → reveal-component-CEMAeVrc.js} +1017 -1017
- package/dist/{select-CDUxhHZg.js → select-CEnB18uc.js} +364 -364
- package/dist/{sequenceDiagram-WJ2MYXX4-Dzp0dgRc.js → sequenceDiagram-WJ2MYXX4-DLywsGCW.js} +1 -1
- package/dist/{spec-ZAt4P01J.js → spec-Dz-Avv1m.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-BGnTUhFJ.js → stateDiagram-D77RDMKH-DUmlKwYU.js} +2 -2
- package/dist/{stateDiagram-v2-MP3YSRHH-DsJbmDf1.js → stateDiagram-v2-MP3YSRHH-D646KiXs.js} +2 -2
- package/dist/static-state-iw0PrHK4.js +57 -0
- package/dist/style.css +1 -1
- package/dist/{swimlanes-42K2YHIH-Bd4Bzh9r.js → swimlanes-42K2YHIH-L7B1GphF.js} +1 -1
- package/dist/{swimlanesDiagram-VR7AAH4N-BlY12Jf6.js → swimlanesDiagram-VR7AAH4N-DEu2wxtC.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-DDPyx1yG.js} +1 -1
- package/dist/toDate-BZg-byuO.js +13 -0
- package/dist/{toast-U3NpO2x3.js → toast-BTjH6fIf.js} +197 -197
- package/dist/{tooltip-UzJukb3F.js → tooltip-DyLdBIM4.js} +81 -81
- package/dist/{use-restore-focus-DaTVz6S6.js → use-restore-focus-DJ_-uSn_.js} +2006 -1997
- package/dist/{useDateFormatter-LQNtoXyh.js → useDateFormatter-HpKD0jEC.js} +2 -2
- package/dist/{useDeepCompareMemoize-CmNbQ9TT.js → useDeepCompareMemoize-CHx-NxMl.js} +1 -1
- package/dist/{useIframeCapabilities-HTZiVlGV.js → useIframeCapabilities-_0KX0nu_.js} +1 -1
- package/dist/{useLifecycle-DTMczKkf.js → useLifecycle-tPpAt-OE.js} +2 -2
- package/dist/{vega-component-ZTdbCcwI.js → vega-component-BzNDFvQf.js} +212 -208
- package/dist/{vennDiagram-4TSXK5OY-BJ7vqDmn.js → vennDiagram-4TSXK5OY-CRwWeb7g.js} +1 -1
- package/dist/{wardleyDiagram-VM6X3IG4-D5kWacsn.js → wardleyDiagram-VM6X3IG4-DVlG9eoq.js} +1 -1
- package/dist/{xychartDiagram-S5SC5T6Z-gr15Ws_z.js → xychartDiagram-S5SC5T6Z-CM32AISp.js} +1 -1
- package/package.json +4 -5
- 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/app-config/__tests__/add-model-discovery.test.tsx +30 -0
- package/src/components/app-config/ai-config.tsx +5 -3
- package/src/components/app-config/user-config-form.tsx +1 -1
- 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/__tests__/send-error-report-button.test.tsx +240 -93
- package/src/components/editor/errors/auto-fix.tsx +8 -7
- package/src/components/editor/errors/send-error-report-button.tsx +139 -41
- 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/keymaps/__tests__/keymaps.test.ts +51 -2
- package/src/core/codemirror/keymaps/vim.ts +30 -1
- 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/dom/__tests__/uiregistry.test.ts +27 -0
- package/src/core/dom/uiregistry.ts +9 -7
- 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 +7 -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/backend.ts +4 -1
- 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 +10 -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 +24 -20
- package/src/core/transports/static.ts +3 -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/core/__test__/trusted-url.test.ts +53 -1
- package/src/plugins/core/trusted-url.ts +59 -1
- package/src/plugins/impl/TextInputPlugin.tsx +2 -1
- package/src/plugins/impl/__test__/text-labels.test.tsx +46 -1
- package/src/plugins/impl/plotly/PlotlyPlugin.tsx +11 -4
- package/src/plugins/impl/plotly/__tests__/PlotlyPlugin.test.tsx +51 -1
- package/src/plugins/impl/plotly/__tests__/legacy-mapbox.test.ts +132 -0
- package/src/plugins/impl/plotly/__tests__/selection.test.ts +14 -35
- package/src/plugins/impl/plotly/legacy-mapbox.ts +130 -0
- package/src/plugins/impl/plotly/maplibre.css +216 -0
- package/src/plugins/impl/vega/__tests__/resolve-data.test.ts +147 -2
- package/src/plugins/impl/vega/loader.ts +49 -2
- package/src/plugins/impl/vega/vega-component.tsx +3 -0
- 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/dist/static-state-C4bAlKTU.js +0 -68
- package/src/core/variables/__tests__/state.test.ts +0 -148
- package/src/plugins/impl/plotly/mapbox.css +0 -359
- package/src/utils/lazy.ts +0 -35
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { act, renderHook } from "@testing-library/react";
|
|
4
|
+
import { atom, createStore, Provider } from "jotai";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
import { describe, expect, it, vi } from "vitest";
|
|
7
|
+
import { atomFamily, selectAtom } from "jotai/utils";
|
|
8
|
+
import { createKeyedAtomHook } from "../create-keyed-atom-hook";
|
|
9
|
+
import { createKeyedSelectorHook } from "../create-keyed-selector-hook";
|
|
10
|
+
|
|
11
|
+
function setup(kind: "selector" | "family") {
|
|
12
|
+
const source = atom(
|
|
13
|
+
new Map([
|
|
14
|
+
["a", 1],
|
|
15
|
+
["b", 2],
|
|
16
|
+
]),
|
|
17
|
+
);
|
|
18
|
+
const store = createStore();
|
|
19
|
+
const wrapper = ({ children }: { children: ReactNode }) => (
|
|
20
|
+
<Provider store={store}>{children}</Provider>
|
|
21
|
+
);
|
|
22
|
+
const select = vi.fn((state: Map<string, number>, key: string) =>
|
|
23
|
+
state.get(key),
|
|
24
|
+
);
|
|
25
|
+
const useEntry =
|
|
26
|
+
kind === "selector"
|
|
27
|
+
? createKeyedSelectorHook(source, select)
|
|
28
|
+
: createKeyedAtomHook(
|
|
29
|
+
atomFamily((key: string) =>
|
|
30
|
+
selectAtom(source, (state) => select(state, key)),
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
return { source, store, wrapper, select, useEntry };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe.each(["selector", "family"] as const)("keyed hooks (%s)", (kind) => {
|
|
37
|
+
it("isolates renders while observing changes and removal of its own entry", () => {
|
|
38
|
+
const { source, store, wrapper, useEntry } = setup(kind);
|
|
39
|
+
const renders = vi.fn();
|
|
40
|
+
const { result } = renderHook(
|
|
41
|
+
() => {
|
|
42
|
+
renders();
|
|
43
|
+
return useEntry("a");
|
|
44
|
+
},
|
|
45
|
+
{ wrapper },
|
|
46
|
+
);
|
|
47
|
+
renders.mockClear();
|
|
48
|
+
|
|
49
|
+
act(() =>
|
|
50
|
+
store.set(
|
|
51
|
+
source,
|
|
52
|
+
new Map([
|
|
53
|
+
["a", 1],
|
|
54
|
+
["b", 3],
|
|
55
|
+
]),
|
|
56
|
+
),
|
|
57
|
+
);
|
|
58
|
+
expect(renders).not.toHaveBeenCalled();
|
|
59
|
+
expect(result.current).toBe(1);
|
|
60
|
+
|
|
61
|
+
act(() =>
|
|
62
|
+
store.set(
|
|
63
|
+
source,
|
|
64
|
+
new Map([
|
|
65
|
+
["a", 4],
|
|
66
|
+
["b", 3],
|
|
67
|
+
]),
|
|
68
|
+
),
|
|
69
|
+
);
|
|
70
|
+
expect(result.current).toBe(4);
|
|
71
|
+
expect(renders).toHaveBeenCalledTimes(1);
|
|
72
|
+
|
|
73
|
+
act(() => store.set(source, new Map([["b", 3]])));
|
|
74
|
+
expect(result.current).toBeUndefined();
|
|
75
|
+
expect(renders).toHaveBeenCalledTimes(2);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("keeps the selector stable on rerender and switches keys without stale reads", () => {
|
|
79
|
+
const { source, store, wrapper, select, useEntry } = setup(kind);
|
|
80
|
+
const renders = vi.fn();
|
|
81
|
+
const { result, rerender } = renderHook(
|
|
82
|
+
({ id }) => {
|
|
83
|
+
renders();
|
|
84
|
+
return useEntry(id);
|
|
85
|
+
},
|
|
86
|
+
{ wrapper, initialProps: { id: "a" } },
|
|
87
|
+
);
|
|
88
|
+
select.mockClear();
|
|
89
|
+
rerender({ id: "a" });
|
|
90
|
+
expect(select).not.toHaveBeenCalled();
|
|
91
|
+
|
|
92
|
+
rerender({ id: "b" });
|
|
93
|
+
expect(result.current).toBe(2);
|
|
94
|
+
select.mockClear();
|
|
95
|
+
renders.mockClear();
|
|
96
|
+
act(() =>
|
|
97
|
+
store.set(
|
|
98
|
+
source,
|
|
99
|
+
new Map([
|
|
100
|
+
["a", 9],
|
|
101
|
+
["b", 2],
|
|
102
|
+
]),
|
|
103
|
+
),
|
|
104
|
+
);
|
|
105
|
+
expect(renders).not.toHaveBeenCalled();
|
|
106
|
+
expect(select.mock.calls.map(([, key]) => key)).toEqual(["b"]);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("releases the source subscription and stops selecting after unmount", () => {
|
|
110
|
+
const { source, store, wrapper, select, useEntry } = setup(kind);
|
|
111
|
+
const dispose = vi.fn();
|
|
112
|
+
source.onMount = () => dispose;
|
|
113
|
+
const { unmount } = renderHook(() => useEntry("a"), { wrapper });
|
|
114
|
+
select.mockClear();
|
|
115
|
+
unmount();
|
|
116
|
+
expect(dispose).toHaveBeenCalledTimes(1);
|
|
117
|
+
act(() => store.set(source, new Map([["a", 3]])));
|
|
118
|
+
expect(select).not.toHaveBeenCalled();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("uses the current Provider store without sharing values between stores", () => {
|
|
122
|
+
const { source, store, wrapper, useEntry } = setup(kind);
|
|
123
|
+
const otherStore = createStore();
|
|
124
|
+
otherStore.set(source, new Map([["a", 7]]));
|
|
125
|
+
const first = renderHook(() => useEntry("a"), { wrapper });
|
|
126
|
+
const second = renderHook(() => useEntry("a"), {
|
|
127
|
+
wrapper: ({ children }) => (
|
|
128
|
+
<Provider store={otherStore}>{children}</Provider>
|
|
129
|
+
),
|
|
130
|
+
});
|
|
131
|
+
expect(first.result.current).toBe(1);
|
|
132
|
+
expect(second.result.current).toBe(7);
|
|
133
|
+
act(() => store.set(source, new Map([["a", 9]])));
|
|
134
|
+
expect(first.result.current).toBe(9);
|
|
135
|
+
expect(second.result.current).toBe(7);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { type Atom, atom } from "jotai/vanilla";
|
|
4
|
+
import { selectAtom } from "jotai/utils";
|
|
5
|
+
import { arrayShallowEquals } from "@/utils/arrays";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Select cheap, immutable inputs before computing a view. Selectors still run
|
|
9
|
+
* when the source changes; derive runs only when a selected input changes.
|
|
10
|
+
* Return primitives or shared references, not newly allocated objects, in the
|
|
11
|
+
* tuple. Create once (or inside an atomFamily), never during render.
|
|
12
|
+
*/
|
|
13
|
+
export function atomWithSelectedInputs<
|
|
14
|
+
State,
|
|
15
|
+
const Inputs extends readonly unknown[],
|
|
16
|
+
View,
|
|
17
|
+
>(
|
|
18
|
+
source: Atom<State>,
|
|
19
|
+
select: (state: State) => Inputs,
|
|
20
|
+
derive: (inputs: Inputs) => View,
|
|
21
|
+
): Atom<View> {
|
|
22
|
+
const inputs = selectAtom(source, select, arrayShallowEquals);
|
|
23
|
+
return atom((get) => derive(get(inputs)));
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { type Atom, useAtomValue } from "jotai";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Define at module scope. Each mount keeps its atom until the key changes;
|
|
8
|
+
* React owns subscription cleanup. Accepts atom families or atom factories.
|
|
9
|
+
* Family cache eviction remains the owner's responsibility.
|
|
10
|
+
*/
|
|
11
|
+
export function createKeyedAtomHook<Key, Value>(
|
|
12
|
+
createAtom: (key: Key) => Atom<Value>,
|
|
13
|
+
) {
|
|
14
|
+
return function useKeyedAtom(key: Key): Value {
|
|
15
|
+
const selected = useMemo(() => createAtom(key), [key]);
|
|
16
|
+
return useAtomValue(selected);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import type { Atom } from "jotai";
|
|
4
|
+
import { selectAtom } from "jotai/utils";
|
|
5
|
+
import { createKeyedAtomHook } from "./create-keyed-atom-hook";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Define at module scope to subscribe to one keyed slice of immutable state.
|
|
9
|
+
*
|
|
10
|
+
* The selector should return a primitive or a structurally shared value.
|
|
11
|
+
* Each mounted hook owns its atom; no global key cache needs eviction.
|
|
12
|
+
* This isolates renders, but selectors still run when the source changes:
|
|
13
|
+
* reducers must preserve state identity for no-op actions.
|
|
14
|
+
*/
|
|
15
|
+
export function createKeyedSelectorHook<State, Key, Slice>(
|
|
16
|
+
source: Atom<State>,
|
|
17
|
+
select: (state: State, key: Key) => Slice,
|
|
18
|
+
) {
|
|
19
|
+
return createKeyedAtomHook((key: Key) =>
|
|
20
|
+
selectAtom(source, (state) => select(state, key)),
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -350,16 +350,13 @@ describe("storage state", () => {
|
|
|
350
350
|
});
|
|
351
351
|
});
|
|
352
352
|
|
|
353
|
-
describe("
|
|
353
|
+
describe("removeNamespacesForVariables", () => {
|
|
354
354
|
it("should keep namespaces whose variable is still in scope", () => {
|
|
355
355
|
const ns1 = makeNamespace({ name: variableName("var_a") });
|
|
356
356
|
const ns2 = makeNamespace({ name: variableName("var_b") });
|
|
357
357
|
actions.setNamespaces({ namespaces: [ns1, ns2] });
|
|
358
358
|
|
|
359
|
-
actions.
|
|
360
|
-
variableName("var_a"),
|
|
361
|
-
variableName("var_b"),
|
|
362
|
-
]);
|
|
359
|
+
actions.removeNamespacesForVariables(new Set(["unrelated"]));
|
|
363
360
|
|
|
364
361
|
expect(state.namespaces).toEqual([ns1, ns2]);
|
|
365
362
|
});
|
|
@@ -369,17 +366,17 @@ describe("storage state", () => {
|
|
|
369
366
|
const ns2 = makeNamespace({ name: variableName("var_b") });
|
|
370
367
|
actions.setNamespaces({ namespaces: [ns1, ns2] });
|
|
371
368
|
|
|
372
|
-
actions.
|
|
369
|
+
actions.removeNamespacesForVariables(new Set(["var_b"]));
|
|
373
370
|
|
|
374
371
|
expect(state.namespaces).toEqual([ns1]);
|
|
375
372
|
});
|
|
376
373
|
|
|
377
|
-
it("should remove
|
|
374
|
+
it("should remove namespaces for each removed binding", () => {
|
|
378
375
|
const ns1 = makeNamespace({ name: variableName("var_a") });
|
|
379
376
|
const ns2 = makeNamespace({ name: variableName("var_b") });
|
|
380
377
|
actions.setNamespaces({ namespaces: [ns1, ns2] });
|
|
381
378
|
|
|
382
|
-
actions.
|
|
379
|
+
actions.removeNamespacesForVariables(new Set(["var_a", "var_b"]));
|
|
383
380
|
|
|
384
381
|
expect(state.namespaces).toEqual([]);
|
|
385
382
|
});
|
|
@@ -395,7 +392,7 @@ describe("storage state", () => {
|
|
|
395
392
|
entries: [entry],
|
|
396
393
|
});
|
|
397
394
|
|
|
398
|
-
actions.
|
|
395
|
+
actions.removeNamespacesForVariables(new Set(["ns"]));
|
|
399
396
|
|
|
400
397
|
// Namespace removed, but entries remain (they are keyed independently)
|
|
401
398
|
expect(state.namespaces).toEqual([]);
|
|
@@ -5,7 +5,6 @@ import { useCallback, useRef, useState } from "react";
|
|
|
5
5
|
import { useAsyncData } from "@/hooks/useAsyncData";
|
|
6
6
|
import { createReducerAndAtoms } from "@/utils/createReducer";
|
|
7
7
|
import type { NotificationMessageData } from "../kernel/messages";
|
|
8
|
-
import type { VariableName } from "../variables/types";
|
|
9
8
|
import {
|
|
10
9
|
ListStorageEntries,
|
|
11
10
|
type StorageEntriesResult,
|
|
@@ -97,13 +96,11 @@ const {
|
|
|
97
96
|
};
|
|
98
97
|
},
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
});
|
|
106
|
-
return { ...state, namespaces };
|
|
99
|
+
removeNamespacesForVariables: (state, removed: ReadonlySet<string>) => {
|
|
100
|
+
const namespaces = state.namespaces.filter((ns) => !removed.has(ns.name));
|
|
101
|
+
return namespaces.length === state.namespaces.length
|
|
102
|
+
? state
|
|
103
|
+
: { ...state, namespaces };
|
|
107
104
|
},
|
|
108
105
|
});
|
|
109
106
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { createNotebookReducer, NotebookEvents } from "@marimo-team/client";
|
|
4
4
|
import type * as Protocol from "@marimo-team/client/protocol";
|
|
5
5
|
import { afterEach, assert, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { runId } from "@/__tests__/branded";
|
|
6
7
|
import type { NotebookBackend } from "../../notebook/replica";
|
|
7
8
|
import { document as documentResource } from "../../notebook/replica/resources/document";
|
|
8
9
|
import { executions } from "../../notebook/replica/resources/executions";
|
|
@@ -108,9 +109,9 @@ describe("static notebook backend", () => {
|
|
|
108
109
|
it("delivers embedded results as completed executions after the document", async () => {
|
|
109
110
|
const source = snapshot();
|
|
110
111
|
const cell = source.cells[0];
|
|
111
|
-
const execution: Protocol.
|
|
112
|
+
const execution: Protocol.ExecutionOutput = {
|
|
112
113
|
id: "embedded:result",
|
|
113
|
-
run_id: "embedded:run",
|
|
114
|
+
run_id: runId("embedded:run"),
|
|
114
115
|
runtime_id: "embedded",
|
|
115
116
|
caused_by_id: null,
|
|
116
117
|
cell_id: cell.id,
|
|
@@ -205,25 +206,28 @@ describe("static notebook backend", () => {
|
|
|
205
206
|
expect(events.at(-1)).toEqual({ event: "ready", id: "static", data: {} });
|
|
206
207
|
});
|
|
207
208
|
|
|
208
|
-
it.each([
|
|
209
|
-
"
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
209
|
+
it.each([
|
|
210
|
+
["edit", (client) => client.edit([])],
|
|
211
|
+
["emit", (client) => client.emit({ type: "example.message", data: null })],
|
|
212
|
+
["save", (client) => client.save()],
|
|
213
|
+
] satisfies [
|
|
214
|
+
string,
|
|
215
|
+
(client: ReturnType<NotebookBackend["notebook"]>) => Promise<unknown>,
|
|
216
|
+
][])("rejects direct %s commands", async (_operation, send) => {
|
|
217
|
+
const backend = createStaticNotebookBackend(snapshot());
|
|
218
|
+
const client = backend.notebook(snapshot().notebook.id);
|
|
219
|
+
const result = await send(client);
|
|
220
|
+
expect(result).toEqual({
|
|
221
|
+
ok: false,
|
|
222
|
+
status: 501,
|
|
223
|
+
problem: {
|
|
224
|
+
type: "urn:marimo:problem:unsupported-operation",
|
|
225
|
+
title: "Unsupported operation",
|
|
217
226
|
status: 501,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
detail: "Static notebooks do not support mutations",
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
);
|
|
227
|
+
detail: "Static notebooks do not support mutations",
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
});
|
|
227
231
|
|
|
228
232
|
it("respects cancellation before opening, during delivery, and for commands", async () => {
|
|
229
233
|
const backend = createStaticNotebookBackend(snapshot());
|
|
@@ -10,14 +10,14 @@ import type { NotebookBackend } from "../notebook/replica";
|
|
|
10
10
|
export interface StaticNotebookSnapshot {
|
|
11
11
|
readonly notebook: Omit<Protocol.Notebook, "operations">;
|
|
12
12
|
readonly document: Protocol.Document;
|
|
13
|
-
readonly cells: readonly Protocol.
|
|
13
|
+
readonly cells: readonly Protocol.CellOutput[];
|
|
14
14
|
/** What the cells last produced, as completed executions and their outputs. */
|
|
15
15
|
readonly results: readonly StaticResult[];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** A completed execution and the output it showed, if it set one. */
|
|
19
19
|
export interface StaticResult {
|
|
20
|
-
readonly execution: Protocol.
|
|
20
|
+
readonly execution: Protocol.ExecutionOutput;
|
|
21
21
|
readonly output: Protocol.Output | null;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -178,6 +178,7 @@ export function createStaticNotebookBackend(
|
|
|
178
178
|
};
|
|
179
179
|
return {
|
|
180
180
|
edit: (_changes, options) => unsupported(options),
|
|
181
|
+
emit: (_event, options) => unsupported(options),
|
|
181
182
|
save: unsupported,
|
|
182
183
|
run: unsupported,
|
|
183
184
|
input: (_inputId, _reply, options) => unsupported(options),
|
|
@@ -1,81 +1,86 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
3
|
+
import type { CellAnalysis } from "@marimo-team/client/protocol";
|
|
4
|
+
import { atom, useAtomValue } from "jotai";
|
|
5
|
+
import type { CellId } from "../cells/ids";
|
|
6
|
+
import {
|
|
7
|
+
activeNotebookReplicaAtom,
|
|
8
|
+
confirmedDocumentAtom,
|
|
9
|
+
notebookAnalysisAtom,
|
|
10
|
+
} from "../session/active-notebook";
|
|
11
|
+
import { Objects } from "@/utils/objects";
|
|
12
|
+
import type { VariableName, Variables } from "./types";
|
|
6
13
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
/** Null until the host has analyzed a revision of this notebook. */
|
|
15
|
+
const declaredVariablesAtom = atom((get): Variables | null => {
|
|
16
|
+
const analysis = get(notebookAnalysisAtom);
|
|
17
|
+
if (analysis === null) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
10
20
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
for (const variable of variables) {
|
|
22
|
-
newVariables[variable.name] = {
|
|
23
|
-
...oldVariables[variable.name],
|
|
24
|
-
...variable,
|
|
25
|
-
};
|
|
21
|
+
const declarations: Variables = Object.create(null);
|
|
22
|
+
const cells = Objects.entries<CellId, CellAnalysis>(analysis.cells);
|
|
23
|
+
for (const [cellId, cell] of cells) {
|
|
24
|
+
for (const name of cell.defs as VariableName[]) {
|
|
25
|
+
const variable = (declarations[name] ??= {
|
|
26
|
+
name,
|
|
27
|
+
declaredBy: [],
|
|
28
|
+
usedBy: [],
|
|
29
|
+
});
|
|
30
|
+
variable.declaredBy.push(cellId);
|
|
26
31
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
for (const variable of variables) {
|
|
32
|
-
newVariables[variable.name] = {
|
|
33
|
-
...newVariables[variable.name],
|
|
34
|
-
...variable,
|
|
35
|
-
};
|
|
32
|
+
}
|
|
33
|
+
for (const [cellId, cell] of cells) {
|
|
34
|
+
for (const name of cell.refs as VariableName[]) {
|
|
35
|
+
declarations[name]?.usedBy.push(cellId);
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
}
|
|
38
|
+
return declarations;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const variableBindingsAtom = atom((get) => {
|
|
42
|
+
const replica = get(activeNotebookReplicaAtom);
|
|
43
|
+
return replica && get(replica.shownDocumentAtom)
|
|
44
|
+
? get(replica.executionsAtom).variables
|
|
45
|
+
: null;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const analysisMatchesDocumentAtom = atom((get) => {
|
|
49
|
+
const document = get(confirmedDocumentAtom);
|
|
50
|
+
return (
|
|
51
|
+
document !== null &&
|
|
52
|
+
get(notebookAnalysisAtom)?.document_etag === document.revision.etag
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const EMPTY: Variables = Object.freeze(Object.create(null));
|
|
57
|
+
|
|
58
|
+
export const variablesAtom = atom((get): Variables => {
|
|
59
|
+
const declarations = get(declaredVariablesAtom);
|
|
60
|
+
const bindings = get(variableBindingsAtom);
|
|
61
|
+
if (!bindings?.size) {
|
|
62
|
+
return declarations ?? EMPTY;
|
|
63
|
+
}
|
|
64
|
+
const current = get(analysisMatchesDocumentAtom);
|
|
65
|
+
const variables: Variables = Object.assign(Object.create(null), declarations);
|
|
66
|
+
for (const [cellId, items] of bindings) {
|
|
67
|
+
for (const item of items.values()) {
|
|
68
|
+
const name = item.name as VariableName;
|
|
69
|
+
const declaration = declarations?.[name];
|
|
70
|
+
const owner = declaration?.declaredBy.includes(cellId)
|
|
71
|
+
? declaration
|
|
72
|
+
: undefined;
|
|
73
|
+
if (current && declaration && !owner) {
|
|
50
74
|
continue;
|
|
51
75
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
value,
|
|
56
|
-
dataType: dataType,
|
|
76
|
+
variables[name] = {
|
|
77
|
+
...(owner ?? { name, declaredBy: current ? [] : [cellId], usedBy: [] }),
|
|
78
|
+
dataType: item.type,
|
|
79
|
+
value: item.preview,
|
|
57
80
|
};
|
|
58
81
|
}
|
|
59
|
-
|
|
60
|
-
|
|
82
|
+
}
|
|
83
|
+
return variables;
|
|
61
84
|
});
|
|
62
85
|
|
|
63
|
-
/**
|
|
64
|
-
* React hook to get the variables state.
|
|
65
|
-
*/
|
|
66
86
|
export const useVariables = () => useAtomValue(variablesAtom);
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* React hook to get the variables actions.
|
|
70
|
-
*/
|
|
71
|
-
export function useVariablesActions() {
|
|
72
|
-
return useActions();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export { variablesAtom };
|
|
76
|
-
|
|
77
|
-
export const exportedForTesting = {
|
|
78
|
-
reducer,
|
|
79
|
-
createActions,
|
|
80
|
-
initialState,
|
|
81
|
-
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { TypedString } from "@/utils/typed";
|
|
4
4
|
import type { CellId } from "../cells/ids";
|
|
5
5
|
|
|
6
|
-
export type VariableName =
|
|
6
|
+
export type VariableName = TypedString<"VariableName">;
|
|
7
7
|
|
|
8
8
|
export interface Variable {
|
|
9
9
|
name: VariableName;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { isInVscodeExtension } from "../is-in-vscode";
|
|
4
|
+
|
|
5
|
+
afterEach(() => {
|
|
6
|
+
document.body.removeAttribute("data-vscode-theme-kind");
|
|
7
|
+
vi.restoreAllMocks();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
describe("isInVscodeExtension", () => {
|
|
11
|
+
it("detects an ordinary browser", () => {
|
|
12
|
+
expect(isInVscodeExtension()).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it.each([
|
|
16
|
+
"vscode-light",
|
|
17
|
+
"vscode-dark",
|
|
18
|
+
"vscode-high-contrast",
|
|
19
|
+
"vscode-high-contrast-light",
|
|
20
|
+
])("detects %s on the first call", (theme) => {
|
|
21
|
+
document.body.setAttribute("data-vscode-theme-kind", theme);
|
|
22
|
+
expect(isInVscodeExtension()).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("observes attribute changes without scanning the document", () => {
|
|
26
|
+
const query = vi.spyOn(document, "querySelector");
|
|
27
|
+
const queryAll = vi.spyOn(document, "querySelectorAll");
|
|
28
|
+
expect(isInVscodeExtension()).toBe(false);
|
|
29
|
+
document.body.setAttribute("data-vscode-theme-kind", "vscode-dark");
|
|
30
|
+
expect(isInVscodeExtension()).toBe(true);
|
|
31
|
+
document.body.removeAttribute("data-vscode-theme-kind");
|
|
32
|
+
expect(isInVscodeExtension()).toBe(false);
|
|
33
|
+
expect(query).not.toHaveBeenCalled();
|
|
34
|
+
expect(queryAll).not.toHaveBeenCalled();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* Whether the current environment is in the VSCode extension
|
|
5
5
|
*/
|
|
6
6
|
export function isInVscodeExtension(): boolean {
|
|
7
|
-
//
|
|
8
|
-
return document.
|
|
7
|
+
// VS Code adds this attribute to the body before loading webview scripts.
|
|
8
|
+
return document.body?.hasAttribute("data-vscode-theme-kind") ?? false;
|
|
9
9
|
}
|
|
@@ -107,7 +107,15 @@ vi.mock("@/core/wasm/store", () => ({
|
|
|
107
107
|
// Import after all mocks are set up
|
|
108
108
|
import { store } from "@/core/state/jotai";
|
|
109
109
|
import { initialModeAtom } from "@/core/mode";
|
|
110
|
-
import
|
|
110
|
+
import {
|
|
111
|
+
createNotebookReplica,
|
|
112
|
+
createReplicaFrame,
|
|
113
|
+
type NotebookReplica,
|
|
114
|
+
} from "@/core/notebook/replica";
|
|
115
|
+
import { MockExecutions } from "@/__mocks__/executions";
|
|
116
|
+
import { mockAnimationFrames } from "@/__mocks__/animation-frames";
|
|
117
|
+
import { fixtureMessages } from "@/core/notebook/replica/__tests__/fixtures";
|
|
118
|
+
import { notebookIsRunningAtom } from "@/core/executions";
|
|
111
119
|
import { activeNotebookReplicaAtom } from "@/core/session/active-notebook";
|
|
112
120
|
import { fallbackFileStore, notebookFileStore } from "../store";
|
|
113
121
|
import { getWasmWorkerName, PyodideBridge } from "../bridge";
|
|
@@ -524,3 +532,67 @@ it("signals an interrupt once across pending, completed, and lost-reply retries"
|
|
|
524
532
|
store.set(initialModeAtom, undefined);
|
|
525
533
|
}
|
|
526
534
|
});
|
|
535
|
+
|
|
536
|
+
it("cancels a received running event before the display frame catches up", async () => {
|
|
537
|
+
vi.clearAllMocks();
|
|
538
|
+
const advanceFrame = mockAnimationFrames();
|
|
539
|
+
store.set(initialModeAtom, "read");
|
|
540
|
+
rpcListeners.initialized();
|
|
541
|
+
mockNotebookSubscribe.mockResolvedValue(undefined);
|
|
542
|
+
mockNotebookUnsubscribe.mockResolvedValue(undefined);
|
|
543
|
+
const backend = await PyodideBridge.INSTANCE.createNotebookBackend();
|
|
544
|
+
const replica = createNotebookReplica(store);
|
|
545
|
+
store.set(activeNotebookReplicaAtom, replica);
|
|
546
|
+
const lifetime = new AbortController();
|
|
547
|
+
const frame = createReplicaFrame(store, replica, { signal: lifetime.signal });
|
|
548
|
+
const disconnect = replica.connect(backend, { onNotification: vi.fn() });
|
|
549
|
+
const buffer = workerState.interruptBuffer!;
|
|
550
|
+
buffer[0] = 0;
|
|
551
|
+
try {
|
|
552
|
+
await vi.waitFor(() =>
|
|
553
|
+
expect(mockNotebookSubscribe).toHaveBeenCalledOnce(),
|
|
554
|
+
);
|
|
555
|
+
const [{ id }] = mockNotebookSubscribe.mock.calls[0];
|
|
556
|
+
const receive = (event: unknown) =>
|
|
557
|
+
rpcListeners.notebookEvent({ id, event: JSON.stringify(event) });
|
|
558
|
+
fixtureMessages("notebook-events.sse").forEach(receive);
|
|
559
|
+
advanceFrame();
|
|
560
|
+
const before = store.get(frame.executionsAtom);
|
|
561
|
+
const run = {
|
|
562
|
+
id: "run-cancel-before-frame",
|
|
563
|
+
notebook_id: "n1",
|
|
564
|
+
runtime_id: "r1",
|
|
565
|
+
origin: { kind: "code", code: "pass" },
|
|
566
|
+
created_at: "2026-10-01T09:20:00Z",
|
|
567
|
+
state: { status: "running", started_at: "2026-10-01T09:20:11Z" },
|
|
568
|
+
};
|
|
569
|
+
receive({ event: "run", id: "1000", data: { run } });
|
|
570
|
+
receive({
|
|
571
|
+
event: "execution",
|
|
572
|
+
id: "1001",
|
|
573
|
+
data: { execution: { ...MockExecutions.running("c1"), run_id: run.id } },
|
|
574
|
+
});
|
|
575
|
+
expect(store.get(notebookIsRunningAtom)).toBe(true);
|
|
576
|
+
expect(store.get(frame.executionsAtom)).toBe(before);
|
|
577
|
+
expect(buffer[0]).toBe(0);
|
|
578
|
+
mockNotebookCall.mockImplementationOnce(async () => {
|
|
579
|
+
expect(buffer[0]).toBe(2);
|
|
580
|
+
return { status: 202, body: run };
|
|
581
|
+
});
|
|
582
|
+
expect((await backend.notebook("n1").cancel({ runId: run.id })).ok).toBe(
|
|
583
|
+
true,
|
|
584
|
+
);
|
|
585
|
+
expect(buffer[0]).toBe(2);
|
|
586
|
+
expect(store.get(frame.executionsAtom)).toBe(before);
|
|
587
|
+
advanceFrame();
|
|
588
|
+
expect(store.get(frame.executionsAtom)).toBe(
|
|
589
|
+
store.get(replica.executionsAtom),
|
|
590
|
+
);
|
|
591
|
+
} finally {
|
|
592
|
+
lifetime.abort();
|
|
593
|
+
disconnect();
|
|
594
|
+
buffer[0] = 0;
|
|
595
|
+
store.set(activeNotebookReplicaAtom, null);
|
|
596
|
+
store.set(initialModeAtom, undefined);
|
|
597
|
+
}
|
|
598
|
+
});
|