@marimo-team/frontend 0.14.18-dev9 → 0.15.1-dev10
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/assets/{ConnectedDataExplorerComponent-B6NVG7Fy.js → ConnectedDataExplorerComponent-BvA88co5.js} +1 -1
- package/dist/assets/{ImageComparisonComponent-3KcZa9Ym.js → ImageComparisonComponent-DMstqRhm.js} +1 -1
- package/dist/assets/{VegaLite-CtkqxS0X.js → VegaLite-Mesl0wXW.js} +1 -1
- package/dist/assets/{_baseEach-CjvI0y7T.js → _baseEach-4LREA2xJ.js} +1 -1
- package/dist/assets/_baseMap-C6LNFWWn.js +1 -0
- package/dist/assets/{_baseUniq-Ds9S94xv.js → _baseUniq-C4wq7Gz_.js} +1 -1
- package/dist/assets/{_createAggregator-Bqe-A14O.js → _createAggregator-Di1sij95.js} +1 -1
- package/dist/assets/{any-language-editor-CGmtjfJH.js → any-language-editor-CNdroSlJ.js} +1 -1
- package/dist/assets/architectureDiagram-KFL7JDKH-BxXZfRHj.js +36 -0
- package/dist/assets/blockDiagram-ZYB65J3Q-8mg_ND0j.js +122 -0
- package/dist/assets/{c4Diagram-6F6E4RAY-CvGMgd-R.js → c4Diagram-AAMF2YG6-BH1zFYgt.js} +1 -1
- package/dist/assets/channel-B3CCoyYy.js +1 -0
- package/dist/assets/{chunk-353BL4L5-BJhgRHK-.js → chunk-ANTBXLJU-wUIE1C6t.js} +1 -1
- package/dist/assets/{chunk-AACKK3MU-tA3KIhd1.js → chunk-FHKO5MBM-BnGig1B_.js} +1 -1
- package/dist/assets/{chunk-E2GYISFI-uWIZ1Jhx.js → chunk-GLLZNHP4-BeuHRwGr.js} +1 -1
- package/dist/assets/{chunk-SZ463SBG-DHkdo7UI.js → chunk-JBRWN2VN-BEuqVuwn.js} +4 -4
- package/dist/assets/{chunk-OW32GOEJ-B-QB95S1.js → chunk-LXBSTHXV-DIaccDrz.js} +6 -6
- package/dist/assets/{chunk-SKB7J2MH-DPsXY34k.js → chunk-NRVI72HA-I0EqNhLo.js} +1 -1
- package/dist/assets/{chunk-67H74DCK-BWX3D-qq.js → chunk-OMD6QJNC-DBDKfLns.js} +1 -1
- package/dist/assets/{chunk-BFAMUDN2-CY30V5X_.js → chunk-WVR4S24B-D9vksrD4.js} +1 -1
- package/dist/assets/{circle-play-DvNUYBOa.js → circle-play-Xdbicaqg.js} +1 -1
- package/dist/assets/classDiagram-3BZAVTQC-CLXskjCP.js +1 -0
- package/dist/assets/classDiagram-v2-QTMF73CY-CLXskjCP.js +1 -0
- package/dist/assets/clone-BCc-guNO.js +1 -0
- package/dist/assets/common-keywords-Dg3Y2cJS.js +1 -0
- package/dist/assets/{compile-yfBBBvDb.js → compile-D-SKgFzl.js} +1 -1
- package/dist/assets/cytoscape.esm-UcEO6FGL.js +325 -0
- package/dist/assets/{dagre-JOIXM2OF-CGKrq8GI.js → dagre-2BBEFEWP-Dj4VJDXi.js} +1 -1
- package/dist/assets/{data-grid-overlay-editor-BeUIwx4E.js → data-grid-overlay-editor-BHUr5Xhc.js} +1 -1
- package/dist/assets/{diagram-VMROVX33-BAO1guE0.js → diagram-4IRLE6MV-9wayoyRN.js} +1 -1
- package/dist/assets/diagram-GUPCWM2R-5NhVlGLr.js +24 -0
- package/dist/assets/{diagram-ZTM2IBQH-B4LQUmZH.js → diagram-RP2FKANI-CNBOj37W.js} +1 -1
- package/dist/assets/duckdb-keywords-CFYiiNsB.js +1 -0
- package/dist/assets/edit-page-D8Xj7wsn.js +163 -0
- package/dist/assets/{erDiagram-3M52JZNH-D3kcrriI.js → erDiagram-HZWUO2LU-KEjz95KS.js} +1 -1
- package/dist/assets/flowDiagram-THRYKUMA-9PtbKpm0.js +162 -0
- package/dist/assets/ganttDiagram-WV7ZQ7D5-CFXRYmNt.js +267 -0
- package/dist/assets/{gitGraphDiagram-GW3U2K7C-Q9Tu2K8y.js → gitGraphDiagram-OJR772UL-hFrAcG26.js} +1 -1
- package/dist/assets/{glide-data-editor-ceB8jin-.js → glide-data-editor-HLSiEHg4.js} +11 -11
- package/dist/assets/{graph-mQaQlEC0.js → graph-iTnwmAye.js} +1 -1
- package/dist/assets/{home-page-DfH28tMw.js → home-page-DzRg-dzP.js} +2 -2
- package/dist/assets/{index-Cs6LYSt0.js → index-B3l0i9L2.js} +1 -1
- package/dist/assets/{index-Cd25JFtC.js → index-BA1eBtgJ.js} +1 -1
- package/dist/assets/{index-DZeLh41D.js → index-BMCpi_hV.js} +1 -1
- package/dist/assets/index-BRPMSgmu.css +1 -0
- package/dist/assets/index-Bj_MIGqG.js +68 -0
- package/dist/assets/{index-Bbz-vY_t.js → index-BlHS2xQv.js} +1 -1
- package/dist/assets/{index-j8KhNyAD.js → index-BzQQnlIk.js} +1 -1
- package/dist/assets/{index-Bl0C1eEM.js → index-BzZRHBMs.js} +1 -1
- package/dist/assets/{index-BS0ZXaCb.js → index-CEoUSuyW.js} +1 -1
- package/dist/assets/{index-DF_6z97_.js → index-CJRYE40I.js} +1 -1
- package/dist/assets/{index-CbFuBnKK.js → index-CQ7rf4K7.js} +1 -1
- package/dist/assets/{index-BbKaEGro.js → index-Cl5g0z7j.js} +1 -1
- package/dist/assets/{index-6r7UeFlf.js → index-Cni7Zj6s.js} +1 -1
- package/dist/assets/{index-D1qx1y0C.js → index-CrltF-5r.js} +1 -1
- package/dist/assets/{index-ynTLoSgO.js → index-CswmrBaY.js} +1 -1
- package/dist/assets/{index-Cz8VHSaF.js → index-D1rqBcHl.js} +1 -1
- package/dist/assets/{index-Bh4jjeua.js → index-DApZsb--.js} +1 -1
- package/dist/assets/{index-DdiulcY3.js → index-DNVhZM1y.js} +1 -1
- package/dist/assets/{index-CoLaKlH0.js → index-DWJwqJmD.js} +1 -1
- package/dist/assets/{index-CKe-VV4U.js → index-DmunXcbP.js} +1 -1
- package/dist/assets/index-WZpn7zIz.js +528 -0
- package/dist/assets/infoDiagram-6WOFNB3A-BvitCnlF.js +2 -0
- package/dist/assets/{journeyDiagram-EWQZEKCU-DHnUk6vv.js → journeyDiagram-FFXJYRFH-BEiF2rN9.js} +4 -4
- package/dist/assets/{kanban-definition-ZSS6B67P-G4X25rf5.js → kanban-definition-KOZQBZVT-BZZVRqX0.js} +1 -1
- package/dist/assets/{layout-Ovgg_XTL.js → layout-2hUFrdoK.js} +1 -1
- package/dist/assets/{linear-DT2F5lCA.js → linear-DM7ygpKu.js} +1 -1
- package/dist/assets/links-BJFGdYRd.js +17 -0
- package/dist/assets/mermaid-CxGPSzDz.js +211 -0
- package/dist/assets/min-DS87IVOa.js +1 -0
- package/dist/assets/{mindmap-definition-6CBA2TL7-DNdqOjtw.js → mindmap-definition-LNHGMQRG-C7yfXmRD.js} +1 -1
- package/dist/assets/{number-overlay-editor-BNl24tu6.js → number-overlay-editor-qOf48nx-.js} +2 -2
- package/dist/assets/pieDiagram-DBDJKBY4-CRluUHH0.js +30 -0
- package/dist/assets/{quadrantDiagram-2OG54O6I--dNkbIMK.js → quadrantDiagram-YPSRARAO-FZO2_Kyx.js} +1 -1
- package/dist/assets/{react-plotly-bwK_a_t1.js → react-plotly-BV6Vu1ZC.js} +1 -1
- package/dist/assets/{requirementDiagram-QOLK2EJ7-28ZDvOK8.js → requirementDiagram-EGVEC5DT-CFEV56bq.js} +1 -1
- package/dist/assets/{run-page-CJW1v8wr.js → run-page-BiiAHZuC.js} +1 -1
- package/dist/assets/{sankeyDiagram-4UZDY2LN-XAKiDU7c.js → sankeyDiagram-HRAUVNP4-cf6xzlF-.js} +2 -2
- package/dist/assets/{sequenceDiagram-SKLFT4DO-DDCNXI_B.js → sequenceDiagram-WFGC7UMF-CEIC5fba.js} +6 -6
- package/dist/assets/{slides-component-2aF-KcfL.js → slides-component-BXl359nW.js} +1 -1
- package/dist/assets/sortBy-Dv7jjKnm.js +1 -0
- package/dist/assets/{stateDiagram-MI5ZYTHO-D1_v1n0T.js → stateDiagram-UUKSUZ4H-DLvG9b91.js} +1 -1
- package/dist/assets/stateDiagram-v2-EYPG3UTE-Z_xESMay.js +1 -0
- package/dist/assets/storage-B47VVzw1.js +26 -0
- package/dist/assets/{terminal-BmZY9sKi.js → terminal-2p_4lGQJ.js} +1 -1
- package/dist/assets/time-OI-T4MiC.js +1 -0
- package/dist/assets/{timeline-definition-MYPXXCX6-BLXFJK2J.js → timeline-definition-3HZDQTIS-Da1Ro9aI.js} +1 -1
- package/dist/assets/{tracing-DAOqNENE.js → tracing-CRxB69vv.js} +2 -2
- package/dist/assets/{trash-DJ39k3RZ.js → trash-DM7Eop-E.js} +1 -1
- package/dist/assets/{treemap-75Q7IDZK-CRVQqKgI.js → treemap-75Q7IDZK-DaZTYidc.js} +1 -1
- package/dist/assets/{vega-component-C-duuyA7.js → vega-component-D1rpMJYI.js} +1 -1
- package/dist/assets/xychartDiagram-FDP5SA34-COsO2s8u.js +7 -0
- package/dist/index.html +2 -2
- package/package.json +11 -6
- package/src/README.md +18 -0
- package/src/__mocks__/common.ts +160 -0
- package/src/__mocks__/notebook.ts +76 -0
- package/src/__mocks__/requests.ts +72 -0
- package/src/__mocks__/tracebacks.ts +32 -0
- package/src/__tests__/CellStatus.test.tsx +263 -0
- package/src/__tests__/__snapshots__/CellStatus.test.tsx.snap +523 -0
- package/src/__tests__/chat-utils.test.ts +234 -0
- package/src/__tests__/lru.test.ts +74 -0
- package/src/__tests__/main.test.tsx +174 -0
- package/src/__tests__/setup.ts +17 -0
- package/src/__tests__/test-helpers.ts +24 -0
- package/src/assets/circle-check.ico +0 -0
- package/src/assets/circle-play.ico +0 -0
- package/src/assets/circle-x.ico +0 -0
- package/src/assets/gradient.png +0 -0
- package/src/assets/icon-16x16.png +0 -0
- package/src/assets/icon-32x32.png +0 -0
- package/src/assets/noise.png +0 -0
- package/src/components/ai/ai-model-dropdown.tsx +405 -0
- package/src/components/ai/ai-provider-icon.tsx +54 -0
- package/src/components/app-config/ai-config.tsx +855 -0
- package/src/components/app-config/app-config-button.tsx +100 -0
- package/src/components/app-config/app-config-form.tsx +307 -0
- package/src/components/app-config/common.tsx +48 -0
- package/src/components/app-config/constants.ts +13 -0
- package/src/components/app-config/incorrect-model-id.tsx +43 -0
- package/src/components/app-config/is-overridden.tsx +119 -0
- package/src/components/app-config/optional-features.tsx +251 -0
- package/src/components/app-config/state.ts +18 -0
- package/src/components/app-config/user-config-form.tsx +1361 -0
- package/src/components/audio/audio-recorder.tsx +63 -0
- package/src/components/buttons/clear-button.tsx +23 -0
- package/src/components/buttons/undo-button.tsx +35 -0
- package/src/components/chat/chat-panel.tsx +720 -0
- package/src/components/chat/markdown-renderer.tsx +217 -0
- package/src/components/chat/reasoning-accordion.tsx +50 -0
- package/src/components/chat/tool-call-accordion.tsx +118 -0
- package/src/components/data-table/SearchBar.tsx +66 -0
- package/src/components/data-table/TableActions.tsx +183 -0
- package/src/components/data-table/__tests__/__snapshots__/chart-spec-model.test.ts.snap +1079 -0
- package/src/components/data-table/__tests__/chart-spec-model.test.ts +707 -0
- package/src/components/data-table/__tests__/column_formatting.test.ts +115 -0
- package/src/components/data-table/__tests__/columns.test.tsx +341 -0
- package/src/components/data-table/__tests__/data-table.test.tsx +60 -0
- package/src/components/data-table/__tests__/pagination.test.tsx +152 -0
- package/src/components/data-table/__tests__/types.test.ts +44 -0
- package/src/components/data-table/__tests__/url-detector.test.tsx +169 -0
- package/src/components/data-table/__tests__/useColumnPinning.test.ts +76 -0
- package/src/components/data-table/cell-selection/__tests__/feature.test.ts +187 -0
- package/src/components/data-table/cell-selection/feature.ts +123 -0
- package/src/components/data-table/cell-selection/types.ts +49 -0
- package/src/components/data-table/cell-styling/feature.ts +40 -0
- package/src/components/data-table/cell-styling/types.ts +26 -0
- package/src/components/data-table/charts/README.md +65 -0
- package/src/components/data-table/charts/__tests__/__snapshots__/spec-snapshot.test.ts.snap +47 -0
- package/src/components/data-table/charts/__tests__/altair-generator.test.ts +425 -0
- package/src/components/data-table/charts/__tests__/renderer.test.ts +20 -0
- package/src/components/data-table/charts/__tests__/spec-snapshot.test.ts +83 -0
- package/src/components/data-table/charts/__tests__/spec.test.ts +997 -0
- package/src/components/data-table/charts/__tests__/storage.test.ts +103 -0
- package/src/components/data-table/charts/chart-spec/altair-generator.ts +162 -0
- package/src/components/data-table/charts/chart-spec/encodings.ts +173 -0
- package/src/components/data-table/charts/chart-spec/spec.ts +345 -0
- package/src/components/data-table/charts/chart-spec/tooltips.ts +168 -0
- package/src/components/data-table/charts/chart-spec/types.ts +77 -0
- package/src/components/data-table/charts/charts.tsx +492 -0
- package/src/components/data-table/charts/components/chart-items.tsx +369 -0
- package/src/components/data-table/charts/components/chart-states.tsx +37 -0
- package/src/components/data-table/charts/components/form-fields.tsx +872 -0
- package/src/components/data-table/charts/components/layouts.tsx +118 -0
- package/src/components/data-table/charts/constants.ts +159 -0
- package/src/components/data-table/charts/context.ts +20 -0
- package/src/components/data-table/charts/forms/common-chart.tsx +202 -0
- package/src/components/data-table/charts/forms/heatmap.tsx +44 -0
- package/src/components/data-table/charts/forms/pie.tsx +70 -0
- package/src/components/data-table/charts/lazy-chart.tsx +56 -0
- package/src/components/data-table/charts/schemas.ts +140 -0
- package/src/components/data-table/charts/storage.ts +88 -0
- package/src/components/data-table/charts/types.ts +124 -0
- package/src/components/data-table/column-explorer-panel/column-explorer.tsx +227 -0
- package/src/components/data-table/column-formatting/feature.ts +247 -0
- package/src/components/data-table/column-formatting/types.ts +54 -0
- package/src/components/data-table/column-header.tsx +672 -0
- package/src/components/data-table/column-summary/chart-skeleton.tsx +57 -0
- package/src/components/data-table/column-summary/chart-spec-model.tsx +916 -0
- package/src/components/data-table/column-summary/column-summary.tsx +166 -0
- package/src/components/data-table/column-summary/legacy-chart-spec.ts +242 -0
- package/src/components/data-table/column-summary/utils.ts +142 -0
- package/src/components/data-table/column-wrapping/feature.ts +62 -0
- package/src/components/data-table/column-wrapping/types.ts +29 -0
- package/src/components/data-table/columns.tsx +528 -0
- package/src/components/data-table/copy-column/feature.ts +27 -0
- package/src/components/data-table/copy-column/types.ts +19 -0
- package/src/components/data-table/data-table.tsx +298 -0
- package/src/components/data-table/date-popover.tsx +146 -0
- package/src/components/data-table/download-actions.tsx +186 -0
- package/src/components/data-table/filter-pills.tsx +120 -0
- package/src/components/data-table/filters.ts +202 -0
- package/src/components/data-table/focus-row/feature.ts +41 -0
- package/src/components/data-table/focus-row/types.ts +32 -0
- package/src/components/data-table/header-items.tsx +295 -0
- package/src/components/data-table/hooks/use-column-pinning.ts +51 -0
- package/src/components/data-table/hooks/use-panel-ownership.ts +98 -0
- package/src/components/data-table/loading-table.tsx +56 -0
- package/src/components/data-table/mime-cell.tsx +68 -0
- package/src/components/data-table/pagination.tsx +329 -0
- package/src/components/data-table/range-focus/__tests__/atoms.test.ts +907 -0
- package/src/components/data-table/range-focus/__tests__/utils.test.ts +316 -0
- package/src/components/data-table/range-focus/atoms.ts +380 -0
- package/src/components/data-table/range-focus/cell-selection-indicator.tsx +37 -0
- package/src/components/data-table/range-focus/provider.tsx +13 -0
- package/src/components/data-table/range-focus/use-cell-range-selection.ts +119 -0
- package/src/components/data-table/range-focus/use-scroll-into-view.ts +46 -0
- package/src/components/data-table/range-focus/utils.ts +105 -0
- package/src/components/data-table/renderers.tsx +247 -0
- package/src/components/data-table/row-viewer-panel/__tests__/filter-rows.test.ts +82 -0
- package/src/components/data-table/row-viewer-panel/__tests__/row-viewer.test.tsx +58 -0
- package/src/components/data-table/row-viewer-panel/row-viewer.tsx +371 -0
- package/src/components/data-table/types.ts +81 -0
- package/src/components/data-table/uniformSample.tsx +19 -0
- package/src/components/data-table/url-detector.tsx +111 -0
- package/src/components/data-table/utils.ts +46 -0
- package/src/components/databases/display.tsx +66 -0
- package/src/components/databases/engine-variable.tsx +51 -0
- package/src/components/databases/icon.tsx +91 -0
- package/src/components/databases/icons/clickhouse.svg +1 -0
- package/src/components/databases/icons/databricks.svg +1 -0
- package/src/components/databases/icons/datafusion.png +0 -0
- package/src/components/databases/icons/duckdb.svg +1 -0
- package/src/components/databases/icons/googlebigquery.svg +1 -0
- package/src/components/databases/icons/iceberg.png +0 -0
- package/src/components/databases/icons/motherduck.svg +9 -0
- package/src/components/databases/icons/mysql.svg +1 -0
- package/src/components/databases/icons/postgresql.svg +1 -0
- package/src/components/databases/icons/redshift.svg +1 -0
- package/src/components/databases/icons/snowflake.svg +1 -0
- package/src/components/databases/icons/spark.svg +1 -0
- package/src/components/databases/icons/sqlalchemy.svg +1 -0
- package/src/components/databases/icons/sqlite.svg +1 -0
- package/src/components/databases/icons/timeplus.svg +17 -0
- package/src/components/databases/icons/trino.svg +1 -0
- package/src/components/datasets/icons.tsx +55 -0
- package/src/components/datasources/__tests__/install-package-button.test.tsx +85 -0
- package/src/components/datasources/__tests__/utils.test.ts +171 -0
- package/src/components/datasources/column-preview.tsx +269 -0
- package/src/components/datasources/components.tsx +100 -0
- package/src/components/datasources/datasources.tsx +799 -0
- package/src/components/datasources/install-package-button.tsx +46 -0
- package/src/components/datasources/utils.ts +62 -0
- package/src/components/debug/indicator.tsx +19 -0
- package/src/components/debugger/debugger-code.css +3 -0
- package/src/components/debugger/debugger-code.tsx +222 -0
- package/src/components/dependency-graph/custom-node.tsx +89 -0
- package/src/components/dependency-graph/dependency-graph-minimap.tsx +197 -0
- package/src/components/dependency-graph/dependency-graph-tree.tsx +181 -0
- package/src/components/dependency-graph/dependency-graph.css +17 -0
- package/src/components/dependency-graph/dependency-graph.tsx +66 -0
- package/src/components/dependency-graph/elements.ts +185 -0
- package/src/components/dependency-graph/panels.tsx +279 -0
- package/src/components/dependency-graph/types.ts +21 -0
- package/src/components/dependency-graph/utils/changes.ts +54 -0
- package/src/components/dependency-graph/utils/layout.ts +45 -0
- package/src/components/dependency-graph/utils/useFitToViewOnDimensionChange.ts +25 -0
- package/src/components/editor/Cell.tsx +1175 -0
- package/src/components/editor/Disconnected.tsx +72 -0
- package/src/components/editor/Output.tsx +462 -0
- package/src/components/editor/RecoveryButton.tsx +161 -0
- package/src/components/editor/SortableCell.tsx +161 -0
- package/src/components/editor/__tests__/data-attributes.test.tsx +173 -0
- package/src/components/editor/__tests__/dynamic-favicon.test.tsx +183 -0
- package/src/components/editor/actions/name-cell-input.tsx +137 -0
- package/src/components/editor/actions/types.ts +53 -0
- package/src/components/editor/actions/useCellActionButton.tsx +422 -0
- package/src/components/editor/actions/useConfigActions.tsx +182 -0
- package/src/components/editor/actions/useCopyNotebook.tsx +41 -0
- package/src/components/editor/actions/useHideAllMarkdownCode.ts +53 -0
- package/src/components/editor/actions/useNotebookActions.tsx +556 -0
- package/src/components/editor/actions/useRestartKernel.tsx +36 -0
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +379 -0
- package/src/components/editor/ai/add-cell-with-ai.tsx +428 -0
- package/src/components/editor/ai/ai-completion-editor.tsx +261 -0
- package/src/components/editor/ai/completion-handlers.tsx +91 -0
- package/src/components/editor/ai/completion-utils.ts +95 -0
- package/src/components/editor/ai/merge-editor.css +9 -0
- package/src/components/editor/alerts/connecting-alert.tsx +46 -0
- package/src/components/editor/alerts/floating-alert.tsx +47 -0
- package/src/components/editor/alerts/stdin-blocking-alert.tsx +61 -0
- package/src/components/editor/app-container.tsx +53 -0
- package/src/components/editor/boundary/ErrorBoundary.tsx +41 -0
- package/src/components/editor/cell/CellStatus.tsx +371 -0
- package/src/components/editor/cell/CreateCellButton.tsx +132 -0
- package/src/components/editor/cell/DeleteButton.tsx +58 -0
- package/src/components/editor/cell/PendingDeleteConfirmation.tsx +126 -0
- package/src/components/editor/cell/RunButton.tsx +109 -0
- package/src/components/editor/cell/StopButton.tsx +36 -0
- package/src/components/editor/cell/TinyCode.css +10 -0
- package/src/components/editor/cell/TinyCode.tsx +53 -0
- package/src/components/editor/cell/cell-actions.tsx +185 -0
- package/src/components/editor/cell/cell-context-menu.tsx +243 -0
- package/src/components/editor/cell/cell-status.css +21 -0
- package/src/components/editor/cell/code/cell-editor.tsx +546 -0
- package/src/components/editor/cell/code/icons.tsx +31 -0
- package/src/components/editor/cell/code/language-toggle.tsx +140 -0
- package/src/components/editor/cell/collapse.tsx +100 -0
- package/src/components/editor/cell/toolbar.tsx +89 -0
- package/src/components/editor/cell/useAddCell.ts +29 -0
- package/src/components/editor/cell/useDeleteCell.tsx +89 -0
- package/src/components/editor/cell/useRunCells.ts +86 -0
- package/src/components/editor/cell/useShouldShowInterrupt.ts +26 -0
- package/src/components/editor/cell/useSplitCell.tsx +41 -0
- package/src/components/editor/chrome/components/contribute-snippet-button.tsx +138 -0
- package/src/components/editor/chrome/components/feedback-button.tsx +105 -0
- package/src/components/editor/chrome/panels/__tests__/write-secret-modal.test.ts +43 -0
- package/src/components/editor/chrome/panels/constants.ts +2 -0
- package/src/components/editor/chrome/panels/context-aware-panel/atoms.ts +28 -0
- package/src/components/editor/chrome/panels/context-aware-panel/context-aware-panel.tsx +167 -0
- package/src/components/editor/chrome/panels/datasources-panel.tsx +6 -0
- package/src/components/editor/chrome/panels/dependency-graph-panel.tsx +23 -0
- package/src/components/editor/chrome/panels/documentation-panel.tsx +29 -0
- package/src/components/editor/chrome/panels/empty-state.tsx +28 -0
- package/src/components/editor/chrome/panels/error-panel.tsx +35 -0
- package/src/components/editor/chrome/panels/file-explorer-panel.tsx +33 -0
- package/src/components/editor/chrome/panels/logs-panel.tsx +97 -0
- package/src/components/editor/chrome/panels/outline/floating-outline.tsx +129 -0
- package/src/components/editor/chrome/panels/outline/useActiveOutline.tsx +172 -0
- package/src/components/editor/chrome/panels/outline-panel.css +6 -0
- package/src/components/editor/chrome/panels/outline-panel.tsx +39 -0
- package/src/components/editor/chrome/panels/packages-panel.tsx +635 -0
- package/src/components/editor/chrome/panels/packages-state.ts +5 -0
- package/src/components/editor/chrome/panels/scratchpad-panel.tsx +8 -0
- package/src/components/editor/chrome/panels/secrets-panel.tsx +155 -0
- package/src/components/editor/chrome/panels/snippets-panel.css +11 -0
- package/src/components/editor/chrome/panels/snippets-panel.tsx +230 -0
- package/src/components/editor/chrome/panels/tracing-panel.tsx +28 -0
- package/src/components/editor/chrome/panels/variable-panel.tsx +31 -0
- package/src/components/editor/chrome/panels/write-secret-modal.tsx +190 -0
- package/src/components/editor/chrome/state.ts +102 -0
- package/src/components/editor/chrome/types.ts +133 -0
- package/src/components/editor/chrome/wrapper/__tests__/minimap-state.test.ts +209 -0
- package/src/components/editor/chrome/wrapper/__tests__/storage.test.ts +41 -0
- package/src/components/editor/chrome/wrapper/app-chrome.css +22 -0
- package/src/components/editor/chrome/wrapper/app-chrome.tsx +256 -0
- package/src/components/editor/chrome/wrapper/footer-item.tsx +43 -0
- package/src/components/editor/chrome/wrapper/footer-items/ai-status.tsx +47 -0
- package/src/components/editor/chrome/wrapper/footer-items/backend-status.tsx +111 -0
- package/src/components/editor/chrome/wrapper/footer-items/copilot-status.tsx +125 -0
- package/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx +185 -0
- package/src/components/editor/chrome/wrapper/footer-items/minimap-status.tsx +21 -0
- package/src/components/editor/chrome/wrapper/footer-items/rtc-status.tsx +65 -0
- package/src/components/editor/chrome/wrapper/footer-items/runtime-settings.tsx +370 -0
- package/src/components/editor/chrome/wrapper/footer.tsx +90 -0
- package/src/components/editor/chrome/wrapper/minimap-state.ts +164 -0
- package/src/components/editor/chrome/wrapper/minimap.tsx +443 -0
- package/src/components/editor/chrome/wrapper/panels.tsx +10 -0
- package/src/components/editor/chrome/wrapper/sidebar.tsx +100 -0
- package/src/components/editor/chrome/wrapper/storage.ts +56 -0
- package/src/components/editor/chrome/wrapper/utils.ts +8 -0
- package/src/components/editor/code/readonly-python-code.tsx +160 -0
- package/src/components/editor/columns/__tests__/storage.test.ts +104 -0
- package/src/components/editor/columns/cell-column.tsx +105 -0
- package/src/components/editor/columns/sortable-column.tsx +175 -0
- package/src/components/editor/columns/storage.ts +56 -0
- package/src/components/editor/common.ts +20 -0
- package/src/components/editor/controls/Controls.tsx +225 -0
- package/src/components/editor/controls/command-palette-button.tsx +27 -0
- package/src/components/editor/controls/command-palette.tsx +210 -0
- package/src/components/editor/controls/keyboard-shortcuts.tsx +309 -0
- package/src/components/editor/controls/notebook-menu-dropdown.tsx +157 -0
- package/src/components/editor/controls/shutdown-button.tsx +70 -0
- package/src/components/editor/database/__tests__/__snapshots__/as-code.test.ts.snap +659 -0
- package/src/components/editor/database/__tests__/as-code.test.ts +598 -0
- package/src/components/editor/database/__tests__/secrets.test.ts +38 -0
- package/src/components/editor/database/add-database-form.tsx +395 -0
- package/src/components/editor/database/as-code.ts +786 -0
- package/src/components/editor/database/form-renderers.tsx +211 -0
- package/src/components/editor/database/schemas.ts +485 -0
- package/src/components/editor/database/secrets.ts +25 -0
- package/src/components/editor/documentation.css +139 -0
- package/src/components/editor/dynamic-favicon.tsx +126 -0
- package/src/components/editor/errors/auto-fix.tsx +61 -0
- package/src/components/editor/file-tree/__tests__/requesting-tree.test.ts +321 -0
- package/src/components/editor/file-tree/file-explorer.tsx +679 -0
- package/src/components/editor/file-tree/file-viewer.tsx +283 -0
- package/src/components/editor/file-tree/renderers.tsx +83 -0
- package/src/components/editor/file-tree/requesting-tree.tsx +228 -0
- package/src/components/editor/file-tree/state.tsx +26 -0
- package/src/components/editor/file-tree/types.ts +118 -0
- package/src/components/editor/file-tree/upload.tsx +101 -0
- package/src/components/editor/header/app-header.tsx +28 -0
- package/src/components/editor/header/filename-form.tsx +27 -0
- package/src/components/editor/header/filename-input.css +21 -0
- package/src/components/editor/header/filename-input.tsx +244 -0
- package/src/components/editor/header/status.tsx +72 -0
- package/src/components/editor/inputs/Inputs.css +118 -0
- package/src/components/editor/inputs/Inputs.styles.ts +66 -0
- package/src/components/editor/inputs/Inputs.tsx +34 -0
- package/src/components/editor/kiosk-mode.tsx +25 -0
- package/src/components/editor/links/cell-link-list.tsx +74 -0
- package/src/components/editor/links/cell-link.tsx +128 -0
- package/src/components/editor/navigation/__tests__/clipboard.test.ts +466 -0
- package/src/components/editor/navigation/__tests__/navigation.test.ts +1771 -0
- package/src/components/editor/navigation/__tests__/selection.test.ts +194 -0
- package/src/components/editor/navigation/clipboard.ts +205 -0
- package/src/components/editor/navigation/focus-utils.ts +48 -0
- package/src/components/editor/navigation/multi-cell-action-toolbar.tsx +499 -0
- package/src/components/editor/navigation/navigation.ts +704 -0
- package/src/components/editor/navigation/selection.ts +114 -0
- package/src/components/editor/navigation/state.ts +5 -0
- package/src/components/editor/navigation/vim-bindings.test.ts +109 -0
- package/src/components/editor/navigation/vim-bindings.ts +90 -0
- package/src/components/editor/notebook-banner.tsx +75 -0
- package/src/components/editor/output/CalloutOutput.styles.ts +22 -0
- package/src/components/editor/output/CalloutOutput.tsx +19 -0
- package/src/components/editor/output/ConsoleOutput.tsx +276 -0
- package/src/components/editor/output/EmotionCacheProvider.tsx +32 -0
- package/src/components/editor/output/HtmlOutput.tsx +25 -0
- package/src/components/editor/output/ImageOutput.tsx +25 -0
- package/src/components/editor/output/JsonOutput.tsx +424 -0
- package/src/components/editor/output/MarimoErrorOutput.tsx +511 -0
- package/src/components/editor/output/MarimoTracebackOutput.tsx +233 -0
- package/src/components/editor/output/Outputs.css +102 -0
- package/src/components/editor/output/TextOutput.tsx +42 -0
- package/src/components/editor/output/VideoOutput.tsx +11 -0
- package/src/components/editor/output/__tests__/ansi.test.ts +39 -0
- package/src/components/editor/output/__tests__/json-output.test.ts +269 -0
- package/src/components/editor/output/__tests__/traceback.test.tsx +105 -0
- package/src/components/editor/output/useWrapText.ts +14 -0
- package/src/components/editor/package-alert.tsx +596 -0
- package/src/components/editor/renderMimeIcon.tsx +38 -0
- package/src/components/editor/renderers/CellArray.tsx +352 -0
- package/src/components/editor/renderers/cells-renderer.tsx +96 -0
- package/src/components/editor/renderers/grid-layout/grid-layout.tsx +650 -0
- package/src/components/editor/renderers/grid-layout/plugin.tsx +146 -0
- package/src/components/editor/renderers/grid-layout/styles.css +31 -0
- package/src/components/editor/renderers/grid-layout/types.ts +89 -0
- package/src/components/editor/renderers/layout-select.tsx +86 -0
- package/src/components/editor/renderers/plugins.ts +31 -0
- package/src/components/editor/renderers/slides-layout/plugin.tsx +31 -0
- package/src/components/editor/renderers/slides-layout/slides-layout.tsx +74 -0
- package/src/components/editor/renderers/slides-layout/types.ts +12 -0
- package/src/components/editor/renderers/types.ts +75 -0
- package/src/components/editor/renderers/vertical-layout/__tests__/useDelayVisibility.test.ts +87 -0
- package/src/components/editor/renderers/vertical-layout/__tests__/useFocusFirstEditor.test.ts +123 -0
- package/src/components/editor/renderers/vertical-layout/__tests__/vertical-layout.test.ts +173 -0
- package/src/components/editor/renderers/vertical-layout/sidebar/__tests__/sidebar.test.tsx +56 -0
- package/src/components/editor/renderers/vertical-layout/sidebar/sheet-sidebar.tsx +32 -0
- package/src/components/editor/renderers/vertical-layout/sidebar/sidebar-slot.tsx +10 -0
- package/src/components/editor/renderers/vertical-layout/sidebar/sidebar.css +20 -0
- package/src/components/editor/renderers/vertical-layout/sidebar/sidebar.tsx +30 -0
- package/src/components/editor/renderers/vertical-layout/sidebar/state.ts +46 -0
- package/src/components/editor/renderers/vertical-layout/sidebar/toggle.tsx +25 -0
- package/src/components/editor/renderers/vertical-layout/sidebar/wrapped-with-sidebar.tsx +38 -0
- package/src/components/editor/renderers/vertical-layout/useDelayVisibility.ts +32 -0
- package/src/components/editor/renderers/vertical-layout/useFocusFirstEditor.ts +107 -0
- package/src/components/editor/renderers/vertical-layout/vertical-layout-wrapper.tsx +46 -0
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +451 -0
- package/src/components/editor/stdin-blocking-alert.tsx +83 -0
- package/src/components/export/export-output-button.tsx +14 -0
- package/src/components/find-replace/find-replace.tsx +293 -0
- package/src/components/forms/__tests__/form-utils.test.ts +104 -0
- package/src/components/forms/form-utils.ts +90 -0
- package/src/components/forms/form.tsx +817 -0
- package/src/components/forms/options.ts +59 -0
- package/src/components/forms/switchable-multi-select.tsx +134 -0
- package/src/components/home/components.tsx +189 -0
- package/src/components/home/state.ts +30 -0
- package/src/components/icons/copy-icon.tsx +59 -0
- package/src/components/icons/github-copilot.tsx +17 -0
- package/src/components/icons/large-spinner.tsx +39 -0
- package/src/components/icons/loading-ellipsis.tsx +46 -0
- package/src/components/icons/multi-icon.css +9 -0
- package/src/components/icons/multi-icon.tsx +30 -0
- package/src/components/icons/spinner.tsx +38 -0
- package/src/components/layout/toolbar.tsx +26 -0
- package/src/components/modal/ImperativeModal.tsx +187 -0
- package/src/components/pages/edit-page.tsx +37 -0
- package/src/components/pages/home-page.tsx +514 -0
- package/src/components/pages/run-page.tsx +55 -0
- package/src/components/scratchpad/scratchpad-history.ts +28 -0
- package/src/components/scratchpad/scratchpad.tsx +280 -0
- package/src/components/shortcuts/renderShortcut.tsx +208 -0
- package/src/components/slides/slides-component.tsx +132 -0
- package/src/components/slides/slides.css +100 -0
- package/src/components/sort/SortableCellsProvider.tsx +242 -0
- package/src/components/static-html/share-modal.tsx +181 -0
- package/src/components/static-html/static-banner.tsx +164 -0
- package/src/components/terminal/terminal.tsx +110 -0
- package/src/components/terminal/xterm.css +3 -0
- package/src/components/tracing/tracing-spec.ts +118 -0
- package/src/components/tracing/tracing.test.tsx +66 -0
- package/src/components/tracing/tracing.tsx +410 -0
- package/src/components/ui/accordion.tsx +70 -0
- package/src/components/ui/alert-dialog.tsx +176 -0
- package/src/components/ui/alert.tsx +64 -0
- package/src/components/ui/aria-popover.tsx +43 -0
- package/src/components/ui/badge.tsx +41 -0
- package/src/components/ui/button.tsx +156 -0
- package/src/components/ui/calendar.tsx +231 -0
- package/src/components/ui/card.tsx +83 -0
- package/src/components/ui/checkbox.tsx +33 -0
- package/src/components/ui/combobox.tsx +278 -0
- package/src/components/ui/command.tsx +165 -0
- package/src/components/ui/context-menu.tsx +193 -0
- package/src/components/ui/date-input.tsx +127 -0
- package/src/components/ui/date-picker.tsx +188 -0
- package/src/components/ui/dialog.tsx +155 -0
- package/src/components/ui/draggable-popover.tsx +68 -0
- package/src/components/ui/dropdown-menu.tsx +190 -0
- package/src/components/ui/field.tsx +90 -0
- package/src/components/ui/form.tsx +224 -0
- package/src/components/ui/fullscreen.tsx +38 -0
- package/src/components/ui/input.tsx +208 -0
- package/src/components/ui/kbd.tsx +22 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/links.tsx +23 -0
- package/src/components/ui/menu-items.tsx +101 -0
- package/src/components/ui/native-select.tsx +39 -0
- package/src/components/ui/navigation.tsx +154 -0
- package/src/components/ui/number-field.tsx +99 -0
- package/src/components/ui/popover.tsx +63 -0
- package/src/components/ui/progress.tsx +28 -0
- package/src/components/ui/radio-group.tsx +44 -0
- package/src/components/ui/range-slider.tsx +102 -0
- package/src/components/ui/scroll-area.tsx +47 -0
- package/src/components/ui/select.tsx +167 -0
- package/src/components/ui/sheet.tsx +143 -0
- package/src/components/ui/skeleton.tsx +16 -0
- package/src/components/ui/slider.tsx +80 -0
- package/src/components/ui/switch.tsx +54 -0
- package/src/components/ui/table.tsx +122 -0
- package/src/components/ui/tabs.tsx +55 -0
- package/src/components/ui/textarea.tsx +104 -0
- package/src/components/ui/toast.tsx +133 -0
- package/src/components/ui/toaster.tsx +30 -0
- package/src/components/ui/toggle.tsx +49 -0
- package/src/components/ui/tooltip.tsx +87 -0
- package/src/components/ui/typography.tsx +207 -0
- package/src/components/ui/use-restore-focus.ts +28 -0
- package/src/components/ui/use-toast.ts +224 -0
- package/src/components/utils/delay-mount.tsx +81 -0
- package/src/components/utils/lazy-mount.tsx +24 -0
- package/src/components/variables/common.tsx +37 -0
- package/src/components/variables/variables-table.tsx +335 -0
- package/src/core/MarimoApp.tsx +103 -0
- package/src/core/ai/__tests__/model-registry.test.ts +357 -0
- package/src/core/ai/chat-utils.ts +71 -0
- package/src/core/ai/config.ts +76 -0
- package/src/core/ai/context/__tests__/registry.test.ts +516 -0
- package/src/core/ai/context/context.ts +16 -0
- package/src/core/ai/context/providers/__tests__/__snapshots__/tables.test.ts.snap +291 -0
- package/src/core/ai/context/providers/__tests__/__snapshots__/variable.test.ts.snap +378 -0
- package/src/core/ai/context/providers/__tests__/tables.test.ts +271 -0
- package/src/core/ai/context/providers/__tests__/variable.test.ts +312 -0
- package/src/core/ai/context/providers/common.ts +7 -0
- package/src/core/ai/context/providers/tables.ts +208 -0
- package/src/core/ai/context/providers/variable.ts +72 -0
- package/src/core/ai/context/registry.ts +180 -0
- package/src/core/ai/ids/__tests__/ids.test.ts +193 -0
- package/src/core/ai/ids/ids.ts +71 -0
- package/src/core/ai/model-registry.ts +158 -0
- package/src/core/ai/state.ts +58 -0
- package/src/core/alerts/state.ts +75 -0
- package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +1312 -0
- package/src/core/cells/__tests__/add-missing-import.test.ts +78 -0
- package/src/core/cells/__tests__/cell.test.ts +193 -0
- package/src/core/cells/__tests__/cells.test.ts +2664 -0
- package/src/core/cells/__tests__/collapseConsoleOutputs.test.ts +239 -0
- package/src/core/cells/__tests__/focus.test.ts +271 -0
- package/src/core/cells/__tests__/ids.test.ts +90 -0
- package/src/core/cells/__tests__/names.test.ts +62 -0
- package/src/core/cells/__tests__/pending-delete-service.test.tsx +202 -0
- package/src/core/cells/__tests__/runs.test.ts +453 -0
- package/src/core/cells/__tests__/session.test.ts +757 -0
- package/src/core/cells/__tests__/utils.test.ts +428 -0
- package/src/core/cells/actions.ts +21 -0
- package/src/core/cells/add-missing-import.ts +114 -0
- package/src/core/cells/cell.ts +243 -0
- package/src/core/cells/cells.ts +1751 -0
- package/src/core/cells/collapseConsoleOutputs.tsx +133 -0
- package/src/core/cells/effects.ts +42 -0
- package/src/core/cells/focus.ts +128 -0
- package/src/core/cells/ids.ts +124 -0
- package/src/core/cells/logs.ts +114 -0
- package/src/core/cells/names.ts +107 -0
- package/src/core/cells/outline.ts +30 -0
- package/src/core/cells/outputs.ts +34 -0
- package/src/core/cells/pending-delete-service.ts +183 -0
- package/src/core/cells/runs.ts +196 -0
- package/src/core/cells/scrollCellIntoView.ts +133 -0
- package/src/core/cells/session.ts +281 -0
- package/src/core/cells/types.ts +128 -0
- package/src/core/cells/utils.ts +141 -0
- package/src/core/codemirror/__tests__/__snapshots__/setup.test.ts.snap +216 -0
- package/src/core/codemirror/__tests__/extensions.test.ts +117 -0
- package/src/core/codemirror/__tests__/format.test.ts +227 -0
- package/src/core/codemirror/__tests__/setup.test.ts +178 -0
- package/src/core/codemirror/ai/request.ts +72 -0
- package/src/core/codemirror/ai/resources.ts +90 -0
- package/src/core/codemirror/cells/extensions.ts +387 -0
- package/src/core/codemirror/cells/state.ts +32 -0
- package/src/core/codemirror/cells/traceback-decorations.ts +111 -0
- package/src/core/codemirror/cm.ts +272 -0
- package/src/core/codemirror/compat/__tests__/jupyter.test.ts +136 -0
- package/src/core/codemirror/compat/jupyter.tsx +244 -0
- package/src/core/codemirror/completion/Autocompleter.ts +172 -0
- package/src/core/codemirror/completion/__tests__/hints.test.ts +84 -0
- package/src/core/codemirror/completion/__tests__/keymap.test.ts +44 -0
- package/src/core/codemirror/completion/completer.ts +58 -0
- package/src/core/codemirror/completion/hints.ts +143 -0
- package/src/core/codemirror/completion/keymap.ts +70 -0
- package/src/core/codemirror/completion/utils.ts +18 -0
- package/src/core/codemirror/completion/variable-completions.ts +100 -0
- package/src/core/codemirror/config/extension.ts +63 -0
- package/src/core/codemirror/config/types.ts +10 -0
- package/src/core/codemirror/copilot/__tests__/copilot.test.ts +260 -0
- package/src/core/codemirror/copilot/__tests__/getCodes.test.ts +209 -0
- package/src/core/codemirror/copilot/__tests__/trim-utils.test.ts +291 -0
- package/src/core/codemirror/copilot/client.ts +123 -0
- package/src/core/codemirror/copilot/copilot-config.tsx +285 -0
- package/src/core/codemirror/copilot/extension.ts +285 -0
- package/src/core/codemirror/copilot/getCodes.ts +130 -0
- package/src/core/codemirror/copilot/language-server.ts +255 -0
- package/src/core/codemirror/copilot/state.ts +66 -0
- package/src/core/codemirror/copilot/trim-utils.ts +33 -0
- package/src/core/codemirror/copilot/types.ts +41 -0
- package/src/core/codemirror/editing/__tests__/commands.test.ts +106 -0
- package/src/core/codemirror/editing/__tests__/debugging.test.ts +193 -0
- package/src/core/codemirror/editing/commands.ts +25 -0
- package/src/core/codemirror/editing/debugging.ts +58 -0
- package/src/core/codemirror/editing/extensions.ts +4 -0
- package/src/core/codemirror/extensions.ts +95 -0
- package/src/core/codemirror/facet.ts +19 -0
- package/src/core/codemirror/find-replace/__tests__/navigate.test.ts +695 -0
- package/src/core/codemirror/find-replace/extension.ts +41 -0
- package/src/core/codemirror/find-replace/navigate.ts +221 -0
- package/src/core/codemirror/find-replace/query.ts +31 -0
- package/src/core/codemirror/find-replace/search-highlight.ts +148 -0
- package/src/core/codemirror/find-replace/state.ts +167 -0
- package/src/core/codemirror/format.ts +120 -0
- package/src/core/codemirror/go-to-definition/__tests__/commands.test.ts +205 -0
- package/src/core/codemirror/go-to-definition/commands.ts +80 -0
- package/src/core/codemirror/go-to-definition/extension.ts +23 -0
- package/src/core/codemirror/go-to-definition/underline.ts +223 -0
- package/src/core/codemirror/go-to-definition/utils.ts +126 -0
- package/src/core/codemirror/keymaps/__tests__/keymaps.test.ts +43 -0
- package/src/core/codemirror/keymaps/__tests__/vimrc.test.ts +121 -0
- package/src/core/codemirror/keymaps/keymaps.ts +163 -0
- package/src/core/codemirror/keymaps/vim.ts +360 -0
- package/src/core/codemirror/keymaps/vimrc.ts +149 -0
- package/src/core/codemirror/language/LanguageAdapters.ts +23 -0
- package/src/core/codemirror/language/__tests__/ast.test.ts +124 -0
- package/src/core/codemirror/language/__tests__/extension.test.ts +260 -0
- package/src/core/codemirror/language/__tests__/indentOneTab.test.ts +31 -0
- package/src/core/codemirror/language/__tests__/markdown.test.ts +495 -0
- package/src/core/codemirror/language/__tests__/sql.test.ts +1640 -0
- package/src/core/codemirror/language/__tests__/utils.test.ts +166 -0
- package/src/core/codemirror/language/commands.ts +59 -0
- package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +163 -0
- package/src/core/codemirror/language/embedded/embedded-python.ts +131 -0
- package/src/core/codemirror/language/embedded/latex.ts +257 -0
- package/src/core/codemirror/language/extension.ts +322 -0
- package/src/core/codemirror/language/languages/markdown.ts +261 -0
- package/src/core/codemirror/language/languages/python.ts +329 -0
- package/src/core/codemirror/language/languages/sql/completion-sources.tsx +99 -0
- package/src/core/codemirror/language/languages/sql/completion-store.ts +191 -0
- package/src/core/codemirror/language/languages/sql/sql.ts +545 -0
- package/src/core/codemirror/language/languages/sql/utils.ts +42 -0
- package/src/core/codemirror/language/metadata.ts +71 -0
- package/src/core/codemirror/language/panel/markdown.tsx +63 -0
- package/src/core/codemirror/language/panel/panel.tsx +197 -0
- package/src/core/codemirror/language/panel/sql.tsx +132 -0
- package/src/core/codemirror/language/types.ts +41 -0
- package/src/core/codemirror/language/utils/ast.ts +84 -0
- package/src/core/codemirror/language/utils/indentOneTab.ts +9 -0
- package/src/core/codemirror/language/utils/quotes.ts +18 -0
- package/src/core/codemirror/language/utils.ts +78 -0
- package/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts +860 -0
- package/src/core/codemirror/lsp/federated-lsp.ts +235 -0
- package/src/core/codemirror/lsp/lens.ts +130 -0
- package/src/core/codemirror/lsp/notebook-lsp.ts +604 -0
- package/src/core/codemirror/lsp/transports.ts +31 -0
- package/src/core/codemirror/lsp/types.ts +55 -0
- package/src/core/codemirror/lsp/utils.ts +11 -0
- package/src/core/codemirror/markdown/__tests__/commands.test.ts +522 -0
- package/src/core/codemirror/markdown/commands.ts +478 -0
- package/src/core/codemirror/markdown/completions.ts +273 -0
- package/src/core/codemirror/markdown/extension.ts +106 -0
- package/src/core/codemirror/misc/__tests__/dnd.test.ts +111 -0
- package/src/core/codemirror/misc/__tests__/paste.test.ts +239 -0
- package/src/core/codemirror/misc/dnd.ts +48 -0
- package/src/core/codemirror/misc/paste.ts +181 -0
- package/src/core/codemirror/placeholder/__tests__/extensions.test.ts +132 -0
- package/src/core/codemirror/placeholder/extensions.ts +99 -0
- package/src/core/codemirror/react-dom/createPanel.tsx +39 -0
- package/src/core/codemirror/reactive-references/__tests__/analyzer.test.ts +1222 -0
- package/src/core/codemirror/reactive-references/analyzer.ts +608 -0
- package/src/core/codemirror/reactive-references/extension.ts +154 -0
- package/src/core/codemirror/readonly/__tests__/extension.test.ts +55 -0
- package/src/core/codemirror/readonly/extension.ts +187 -0
- package/src/core/codemirror/rtc/extension.ts +450 -0
- package/src/core/codemirror/rtc/loro/awareness.ts +496 -0
- package/src/core/codemirror/rtc/loro/colors.ts +38 -0
- package/src/core/codemirror/rtc/loro/sync.ts +159 -0
- package/src/core/codemirror/theme/__tests__/light.test.ts +136 -0
- package/src/core/codemirror/theme/dark.ts +50 -0
- package/src/core/codemirror/theme/light.ts +58 -0
- package/src/core/codemirror/types.ts +5 -0
- package/src/core/codemirror/utils.ts +103 -0
- package/src/core/codemirror/vim/cursor-visibility.ts +58 -0
- package/src/core/config/__tests__/config-schema.test.ts +232 -0
- package/src/core/config/capabilities.ts +15 -0
- package/src/core/config/config-schema.ts +296 -0
- package/src/core/config/config.ts +113 -0
- package/src/core/config/feature-flag.tsx +58 -0
- package/src/core/config/if-capability.tsx +19 -0
- package/src/core/config/widths.ts +5 -0
- package/src/core/constants.ts +52 -0
- package/src/core/datasets/__tests__/all-tables.test.ts +466 -0
- package/src/core/datasets/__tests__/data-source.test.ts +461 -0
- package/src/core/datasets/data-source-connections.ts +334 -0
- package/src/core/datasets/engines.ts +11 -0
- package/src/core/datasets/request-registry.ts +34 -0
- package/src/core/datasets/state.ts +143 -0
- package/src/core/datasets/types.ts +38 -0
- package/src/core/debugger/state.ts +10 -0
- package/src/core/documentation/state.ts +13 -0
- package/src/core/dom/__tests__/htmlUtils.test.ts +22 -0
- package/src/core/dom/__tests__/outline.test.ts +370 -0
- package/src/core/dom/defineCustomElement.ts +23 -0
- package/src/core/dom/events.ts +94 -0
- package/src/core/dom/htmlUtils.ts +75 -0
- package/src/core/dom/outline.ts +123 -0
- package/src/core/dom/ui-element.css +8 -0
- package/src/core/dom/ui-element.ts +249 -0
- package/src/core/dom/uiregistry.ts +209 -0
- package/src/core/edit-app.tsx +189 -0
- package/src/core/errors/__tests__/errors.test.ts +62 -0
- package/src/core/errors/__tests__/utils.test.ts +108 -0
- package/src/core/errors/errors.ts +96 -0
- package/src/core/errors/state.ts +44 -0
- package/src/core/errors/utils.ts +67 -0
- package/src/core/export/hooks.ts +60 -0
- package/src/core/functions/FunctionRegistry.ts +18 -0
- package/src/core/hotkeys/__tests__/hotkeys.test.ts +74 -0
- package/src/core/hotkeys/__tests__/shortcuts.test.ts +166 -0
- package/src/core/hotkeys/actions.ts +38 -0
- package/src/core/hotkeys/hotkeys.ts +523 -0
- package/src/core/hotkeys/shortcuts.ts +146 -0
- package/src/core/islands/__tests__/parse.test.ts +89 -0
- package/src/core/islands/bridge.ts +196 -0
- package/src/core/islands/components/output-wrapper.tsx +154 -0
- package/src/core/islands/components/web-components.tsx +120 -0
- package/src/core/islands/islands.css +14 -0
- package/src/core/islands/main.ts +200 -0
- package/src/core/islands/parse.ts +161 -0
- package/src/core/islands/state.ts +30 -0
- package/src/core/islands/toast.ts +41 -0
- package/src/core/islands/utils.ts +5 -0
- package/src/core/islands/worker/controller.ts +52 -0
- package/src/core/islands/worker/worker.tsx +178 -0
- package/src/core/kernel/RuntimeState.ts +94 -0
- package/src/core/kernel/__tests__/RuntimeState.test.ts +57 -0
- package/src/core/kernel/__tests__/handlers.test.ts +61 -0
- package/src/core/kernel/__tests__/session.test.ts +10 -0
- package/src/core/kernel/handlers.ts +159 -0
- package/src/core/kernel/messages.ts +54 -0
- package/src/core/kernel/queryParamHandlers.ts +39 -0
- package/src/core/kernel/session.ts +50 -0
- package/src/core/layout/layout.ts +99 -0
- package/src/core/layout/useTogglePresenting.ts +50 -0
- package/src/core/meta/globals.ts +25 -0
- package/src/core/meta/state.ts +25 -0
- package/src/core/mime.ts +9 -0
- package/src/core/mode.ts +80 -0
- package/src/core/network/DeferredRequestRegistry.ts +71 -0
- package/src/core/network/__tests__/DeferredRequestRegistry.test.ts +37 -0
- package/src/core/network/__tests__/api.test.ts +80 -0
- package/src/core/network/api.ts +145 -0
- package/src/core/network/auth.ts +13 -0
- package/src/core/network/connection.ts +33 -0
- package/src/core/network/requests-network.ts +398 -0
- package/src/core/network/requests-static.ts +88 -0
- package/src/core/network/requests-toasting.ts +91 -0
- package/src/core/network/requests.ts +24 -0
- package/src/core/network/resolve.ts +17 -0
- package/src/core/network/types.ts +188 -0
- package/src/core/packages/toast-components.tsx +88 -0
- package/src/core/packages/useInstallPackage.ts +46 -0
- package/src/core/rtc/state.ts +20 -0
- package/src/core/run-app.tsx +69 -0
- package/src/core/runtime/__tests__/config.test.ts +173 -0
- package/src/core/runtime/__tests__/createWsUrl.test.ts +61 -0
- package/src/core/runtime/__tests__/runtime.test.ts +603 -0
- package/src/core/runtime/config.ts +49 -0
- package/src/core/runtime/runtime.ts +277 -0
- package/src/core/runtime/types.ts +7 -0
- package/src/core/runtime/utils.ts +9 -0
- package/src/core/saving/file-state.ts +15 -0
- package/src/core/saving/filename.ts +55 -0
- package/src/core/saving/save-component.tsx +274 -0
- package/src/core/saving/state.ts +51 -0
- package/src/core/saving/useAutoSave.ts +68 -0
- package/src/core/secrets/request-registry.ts +16 -0
- package/src/core/slots/slots.ts +9 -0
- package/src/core/state/__tests__/jotai.test.ts +25 -0
- package/src/core/state/jotai.ts +69 -0
- package/src/core/state/observable.ts +23 -0
- package/src/core/static/__tests__/download-html.test.ts +41 -0
- package/src/core/static/__tests__/files.test.ts +494 -0
- package/src/core/static/__tests__/virtual-file-tracker.test.ts +92 -0
- package/src/core/static/download-html.ts +59 -0
- package/src/core/static/files.ts +150 -0
- package/src/core/static/static-state.ts +19 -0
- package/src/core/static/types.ts +8 -0
- package/src/core/static/virtual-file-tracker.ts +83 -0
- package/src/core/variables/__tests__/state.test.ts +148 -0
- package/src/core/variables/state.ts +81 -0
- package/src/core/variables/types.ts +22 -0
- package/src/core/vscode/vscode-bindings.ts +176 -0
- package/src/core/wasm/PyodideLoader.tsx +72 -0
- package/src/core/wasm/__tests__/router.test.ts +57 -0
- package/src/core/wasm/__tests__/share.test.ts +35 -0
- package/src/core/wasm/__tests__/state.test.ts +124 -0
- package/src/core/wasm/__tests__/store.test.ts +55 -0
- package/src/core/wasm/bridge.ts +622 -0
- package/src/core/wasm/router.ts +39 -0
- package/src/core/wasm/rpc.ts +32 -0
- package/src/core/wasm/share.ts +15 -0
- package/src/core/wasm/state.ts +21 -0
- package/src/core/wasm/store.ts +122 -0
- package/src/core/wasm/utils.ts +12 -0
- package/src/core/wasm/worker/bootstrap.ts +223 -0
- package/src/core/wasm/worker/constants.ts +2 -0
- package/src/core/wasm/worker/fs.ts +90 -0
- package/src/core/wasm/worker/getController.ts +16 -0
- package/src/core/wasm/worker/getFS.ts +9 -0
- package/src/core/wasm/worker/getMarimoWheel.ts +15 -0
- package/src/core/wasm/worker/getPyodideVersion.ts +10 -0
- package/src/core/wasm/worker/message-buffer.ts +32 -0
- package/src/core/wasm/worker/save-worker.ts +107 -0
- package/src/core/wasm/worker/tracer.ts +7 -0
- package/src/core/wasm/worker/types.ts +97 -0
- package/src/core/wasm/worker/worker.ts +375 -0
- package/src/core/websocket/StaticWebsocket.ts +61 -0
- package/src/core/websocket/connection-utils.ts +59 -0
- package/src/core/websocket/types.ts +43 -0
- package/src/core/websocket/useMarimoWebSocket.tsx +386 -0
- package/src/core/websocket/useWebSocket.tsx +88 -0
- package/src/css/admonition.css +127 -0
- package/src/css/app/App.css +77 -0
- package/src/css/app/Cell.css +433 -0
- package/src/css/app/Header.css +25 -0
- package/src/css/app/codemirror-completions.css +308 -0
- package/src/css/app/codemirror.css +136 -0
- package/src/css/app/fonts.css +50 -0
- package/src/css/app/print.css +86 -0
- package/src/css/app/reset.css +18 -0
- package/src/css/codehilite.css +354 -0
- package/src/css/common.css +45 -0
- package/src/css/globals.css +176 -0
- package/src/css/index.css +10 -0
- package/src/css/katex-fonts.css +214 -0
- package/src/css/katex.min.css +1183 -0
- package/src/css/md-tooltip.css +52 -0
- package/src/css/md.css +365 -0
- package/src/css/progress.css +93 -0
- package/src/css/table.css +45 -0
- package/src/custom.d.ts +24 -0
- package/src/fonts/Fira_Mono/FiraMono-Bold.ttf +0 -0
- package/src/fonts/Fira_Mono/FiraMono-Medium.ttf +0 -0
- package/src/fonts/Fira_Mono/FiraMono-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_AMS-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_AMS-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_AMS-Regular.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Caligraphic-Bold.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Caligraphic-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Fraktur-Bold.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Fraktur-Bold.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Fraktur-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Fraktur-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-Bold.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-Bold.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-Bold.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-BoldItalic.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-BoldItalic.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-Italic.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-Italic.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-Italic.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Main-Regular.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Math-BoldItalic.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Math-BoldItalic.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Math-Italic.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Math-Italic.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Math-Italic.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_SansSerif-Bold.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_SansSerif-Bold.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_SansSerif-Italic.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_SansSerif-Italic.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_SansSerif-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_SansSerif-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Script-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Script-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Script-Regular.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Size1-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Size1-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Size1-Regular.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Size2-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Size2-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Size2-Regular.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Size3-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Size3-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Size3-Regular.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Size4-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Size4-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Size4-Regular.woff2 +0 -0
- package/src/fonts/KaTeX/KaTeX_Typewriter-Regular.ttf +0 -0
- package/src/fonts/KaTeX/KaTeX_Typewriter-Regular.woff +0 -0
- package/src/fonts/KaTeX/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/src/fonts/Lora/Lora-Italic-VariableFont_wght.ttf +0 -0
- package/src/fonts/Lora/Lora-VariableFont_wght.ttf +0 -0
- package/src/fonts/Lora/static/Lora-Bold.ttf +0 -0
- package/src/fonts/Lora/static/Lora-BoldItalic.ttf +0 -0
- package/src/fonts/Lora/static/Lora-Italic.ttf +0 -0
- package/src/fonts/Lora/static/Lora-Medium.ttf +0 -0
- package/src/fonts/Lora/static/Lora-MediumItalic.ttf +0 -0
- package/src/fonts/Lora/static/Lora-Regular.ttf +0 -0
- package/src/fonts/Lora/static/Lora-SemiBold.ttf +0 -0
- package/src/fonts/Lora/static/Lora-SemiBoldItalic.ttf +0 -0
- package/src/fonts/PT_Sans/PTSans-Bold.ttf +0 -0
- package/src/fonts/PT_Sans/PTSans-BoldItalic.ttf +0 -0
- package/src/fonts/PT_Sans/PTSans-Italic.ttf +0 -0
- package/src/fonts/PT_Sans/PTSans-Regular.ttf +0 -0
- package/src/hooks/__tests__/useBoolean.test.tsx +33 -0
- package/src/hooks/__tests__/useDebounce.test.tsx +182 -0
- package/src/hooks/__tests__/useEffectSkipFirstRender.test.tsx +42 -0
- package/src/hooks/__tests__/useEventListener.test.tsx +148 -0
- package/src/hooks/__tests__/useInternalStateWithSync.test.tsx +76 -0
- package/src/hooks/__tests__/useInterval.test.tsx +70 -0
- package/src/hooks/__tests__/usePackageMetadata.test.tsx +219 -0
- package/src/hooks/__tests__/useResizeHandle.test.tsx +240 -0
- package/src/hooks/__tests__/useResizeObserver.test.tsx +86 -0
- package/src/hooks/__tests__/useTimer.test.tsx +62 -0
- package/src/hooks/debug.ts +116 -0
- package/src/hooks/useAsyncData.ts +392 -0
- package/src/hooks/useAudioRecorder.ts +89 -0
- package/src/hooks/useAutoGrowInputProps.ts +56 -0
- package/src/hooks/useBoolean.ts +26 -0
- package/src/hooks/useCellRenderCount.ts +15 -0
- package/src/hooks/useDebounce.ts +95 -0
- package/src/hooks/useDeepCompareMemoize.ts +22 -0
- package/src/hooks/useEffectSkipFirstRender.ts +24 -0
- package/src/hooks/useElapsedTime.ts +25 -0
- package/src/hooks/useEvent.ts +2 -0
- package/src/hooks/useEventListener.ts +68 -0
- package/src/hooks/useHotkey.ts +77 -0
- package/src/hooks/useInternalStateWithSync.ts +26 -0
- package/src/hooks/useInterval.ts +49 -0
- package/src/hooks/useIsDragging.tsx +39 -0
- package/src/hooks/useLifecycle.ts +20 -0
- package/src/hooks/useLocalStorage.ts +22 -0
- package/src/hooks/useNonce.ts +9 -0
- package/src/hooks/usePackageMetadata.ts +52 -0
- package/src/hooks/useRecentCommands.ts +25 -0
- package/src/hooks/useResizeHandle.ts +110 -0
- package/src/hooks/useResizeObserver.ts +101 -0
- package/src/hooks/useScript.ts +90 -0
- package/src/hooks/useSelectAllContent.ts +42 -0
- package/src/hooks/useTimer.ts +48 -0
- package/src/main.tsx +20 -0
- package/src/mount.tsx +331 -0
- package/src/plugins/core/BadPlugin.tsx +72 -0
- package/src/plugins/core/RenderHTML.tsx +136 -0
- package/src/plugins/core/__test__/RenderHTML.test.ts +146 -0
- package/src/plugins/core/builder.ts +59 -0
- package/src/plugins/core/registerReactComponent.tsx +535 -0
- package/src/plugins/core/rpc.ts +55 -0
- package/src/plugins/core/sidebar-element.tsx +104 -0
- package/src/plugins/impl/ButtonPlugin.tsx +95 -0
- package/src/plugins/impl/CheckboxPlugin.tsx +56 -0
- package/src/plugins/impl/CodeEditorPlugin.tsx +119 -0
- package/src/plugins/impl/DataEditorPlugin.tsx +181 -0
- package/src/plugins/impl/DataTablePlugin.tsx +948 -0
- package/src/plugins/impl/DatePickerPlugin.tsx +74 -0
- package/src/plugins/impl/DateRangePlugin.tsx +82 -0
- package/src/plugins/impl/DateTimePickerPlugin.tsx +76 -0
- package/src/plugins/impl/DictPlugin.tsx +80 -0
- package/src/plugins/impl/DropdownPlugin.tsx +102 -0
- package/src/plugins/impl/FileBrowserPlugin.tsx +500 -0
- package/src/plugins/impl/FileUploadPlugin.tsx +302 -0
- package/src/plugins/impl/FormPlugin.tsx +294 -0
- package/src/plugins/impl/MicrophonePlugin.tsx +58 -0
- package/src/plugins/impl/MultiselectPlugin.tsx +207 -0
- package/src/plugins/impl/NumberPlugin.tsx +84 -0
- package/src/plugins/impl/RadioPlugin.tsx +77 -0
- package/src/plugins/impl/RangeSliderPlugin.tsx +163 -0
- package/src/plugins/impl/RefreshPlugin.tsx +158 -0
- package/src/plugins/impl/SearchableSelect.tsx +122 -0
- package/src/plugins/impl/SliderPlugin.tsx +166 -0
- package/src/plugins/impl/SwitchPlugin.tsx +48 -0
- package/src/plugins/impl/TabsPlugin.tsx +83 -0
- package/src/plugins/impl/TextAreaPlugin.tsx +131 -0
- package/src/plugins/impl/TextInputPlugin.tsx +169 -0
- package/src/plugins/impl/__tests__/DateTimePickerPlugin.test.tsx +45 -0
- package/src/plugins/impl/__tests__/DropdownPlugin.test.tsx +178 -0
- package/src/plugins/impl/__tests__/MultiSelectPlugin.test.ts +41 -0
- package/src/plugins/impl/__tests__/NumberPlugin.test.tsx +144 -0
- package/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx +269 -0
- package/src/plugins/impl/anywidget/__tests__/AnyWidgetPlugin.test.tsx +181 -0
- package/src/plugins/impl/anywidget/__tests__/model.test.ts +370 -0
- package/src/plugins/impl/anywidget/model.ts +314 -0
- package/src/plugins/impl/chat/ChatPlugin.tsx +98 -0
- package/src/plugins/impl/chat/chat-ui.tsx +713 -0
- package/src/plugins/impl/chat/types.ts +39 -0
- package/src/plugins/impl/code/LazyAnyLanguageCodeMirror.tsx +6 -0
- package/src/plugins/impl/code/any-language-editor.tsx +68 -0
- package/src/plugins/impl/common/error-banner.tsx +111 -0
- package/src/plugins/impl/common/intent.ts +18 -0
- package/src/plugins/impl/common/labeled.tsx +69 -0
- package/src/plugins/impl/data-editor/__tests__/data-utils.test.ts +876 -0
- package/src/plugins/impl/data-editor/__tests__/glide-utils.test.ts +452 -0
- package/src/plugins/impl/data-editor/components.tsx +179 -0
- package/src/plugins/impl/data-editor/data-utils.ts +123 -0
- package/src/plugins/impl/data-editor/glide-data-editor.tsx +651 -0
- package/src/plugins/impl/data-editor/glide-utils.ts +200 -0
- package/src/plugins/impl/data-editor/themes.ts +49 -0
- package/src/plugins/impl/data-editor/types.ts +44 -0
- package/src/plugins/impl/data-explorer/ConnectedDataExplorerComponent.tsx +268 -0
- package/src/plugins/impl/data-explorer/DataExplorerPlugin.tsx +31 -0
- package/src/plugins/impl/data-explorer/components/column-summary.tsx +174 -0
- package/src/plugins/impl/data-explorer/components/icons.tsx +30 -0
- package/src/plugins/impl/data-explorer/components/query-form.tsx +296 -0
- package/src/plugins/impl/data-explorer/encoding.ts +107 -0
- package/src/plugins/impl/data-explorer/functions/function.ts +83 -0
- package/src/plugins/impl/data-explorer/functions/types.ts +32 -0
- package/src/plugins/impl/data-explorer/marks.ts +21 -0
- package/src/plugins/impl/data-explorer/queries/field-suggestion.ts +65 -0
- package/src/plugins/impl/data-explorer/queries/histograms.ts +41 -0
- package/src/plugins/impl/data-explorer/queries/queries.ts +204 -0
- package/src/plugins/impl/data-explorer/queries/removeUndefined.ts +11 -0
- package/src/plugins/impl/data-explorer/queries/types.ts +54 -0
- package/src/plugins/impl/data-explorer/queries/utils.ts +85 -0
- package/src/plugins/impl/data-explorer/spec.ts +28 -0
- package/src/plugins/impl/data-explorer/state/reducer.ts +92 -0
- package/src/plugins/impl/data-explorer/state/types.ts +28 -0
- package/src/plugins/impl/data-frames/DataFramePlugin.tsx +303 -0
- package/src/plugins/impl/data-frames/forms/__tests__/__snapshots__/form.test.tsx.snap +1600 -0
- package/src/plugins/impl/data-frames/forms/__tests__/form.test.tsx +67 -0
- package/src/plugins/impl/data-frames/forms/context.ts +13 -0
- package/src/plugins/impl/data-frames/forms/datatype-icon.tsx +43 -0
- package/src/plugins/impl/data-frames/forms/renderers.tsx +518 -0
- package/src/plugins/impl/data-frames/panel.tsx +308 -0
- package/src/plugins/impl/data-frames/schema.ts +211 -0
- package/src/plugins/impl/data-frames/types.ts +91 -0
- package/src/plugins/impl/data-frames/utils/__tests__/getUpdatedColumnTypes.test.ts +191 -0
- package/src/plugins/impl/data-frames/utils/__tests__/operators.test.ts +116 -0
- package/src/plugins/impl/data-frames/utils/getUpdatedColumnTypes.ts +67 -0
- package/src/plugins/impl/data-frames/utils/operators.ts +202 -0
- package/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx +39 -0
- package/src/plugins/impl/multiselectFilterFn.tsx +22 -0
- package/src/plugins/impl/panel/PanelPlugin.tsx +266 -0
- package/src/plugins/impl/panel/__tests__/utils.test.ts +119 -0
- package/src/plugins/impl/panel/utils.ts +104 -0
- package/src/plugins/impl/plotly/PlotlyPlugin.tsx +300 -0
- package/src/plugins/impl/plotly/__tests__/parse-from-template.test.ts +73 -0
- package/src/plugins/impl/plotly/mapbox.css +359 -0
- package/src/plugins/impl/plotly/parse-from-template.ts +58 -0
- package/src/plugins/impl/plotly/plotly.css +280 -0
- package/src/plugins/impl/vega/VegaPlugin.tsx +40 -0
- package/src/plugins/impl/vega/__tests__/__snapshots__/make-selectable.test.ts.snap +1210 -0
- package/src/plugins/impl/vega/__tests__/encodings.test.ts +172 -0
- package/src/plugins/impl/vega/__tests__/loader.test.ts +73 -0
- package/src/plugins/impl/vega/__tests__/make-selectable.test.ts +575 -0
- package/src/plugins/impl/vega/__tests__/params.test.ts +52 -0
- package/src/plugins/impl/vega/__tests__/resolve-data.test.ts +236 -0
- package/src/plugins/impl/vega/__tests__/vega.test.ts +603 -0
- package/src/plugins/impl/vega/batched.ts +41 -0
- package/src/plugins/impl/vega/encodings.ts +111 -0
- package/src/plugins/impl/vega/fix-relative-url.ts +15 -0
- package/src/plugins/impl/vega/formats.ts +25 -0
- package/src/plugins/impl/vega/loader.ts +320 -0
- package/src/plugins/impl/vega/make-selectable.ts +248 -0
- package/src/plugins/impl/vega/marks.ts +36 -0
- package/src/plugins/impl/vega/params.ts +192 -0
- package/src/plugins/impl/vega/resolve-data.ts +101 -0
- package/src/plugins/impl/vega/types.ts +32 -0
- package/src/plugins/impl/vega/utils.ts +46 -0
- package/src/plugins/impl/vega/vega-component.tsx +271 -0
- package/src/plugins/impl/vega/vega-loader.ts +53 -0
- package/src/plugins/impl/vega/vega.css +31 -0
- package/src/plugins/layout/AccordionPlugin.tsx +63 -0
- package/src/plugins/layout/CalloutPlugin.tsx +34 -0
- package/src/plugins/layout/DownloadPlugin.tsx +136 -0
- package/src/plugins/layout/ImageComparisonPlugin.tsx +35 -0
- package/src/plugins/layout/JsonOutputPlugin.tsx +47 -0
- package/src/plugins/layout/LazyPlugin.tsx +98 -0
- package/src/plugins/layout/MimeRenderPlugin.tsx +45 -0
- package/src/plugins/layout/NavigationMenuPlugin.tsx +219 -0
- package/src/plugins/layout/ProgressPlugin.tsx +175 -0
- package/src/plugins/layout/RoutesPlugin.tsx +81 -0
- package/src/plugins/layout/StatPlugin.tsx +100 -0
- package/src/plugins/layout/TexPlugin.tsx +102 -0
- package/src/plugins/layout/__test__/ProgressPlugin.test.ts +26 -0
- package/src/plugins/layout/carousel/CarouselPlugin.tsx +48 -0
- package/src/plugins/layout/mermaid/MermaidPlugin.tsx +26 -0
- package/src/plugins/layout/mermaid/mermaid.tsx +94 -0
- package/src/plugins/layout/navigation-menu.css +37 -0
- package/src/plugins/plugins.ts +116 -0
- package/src/plugins/stateless-plugin.ts +29 -0
- package/src/plugins/types.ts +82 -0
- package/src/stories/__fixtures__/vega.ts +225 -0
- package/src/stories/accordion.stories.tsx +100 -0
- package/src/stories/alert-dialog.mdx +42 -0
- package/src/stories/app-chrome.stories.tsx +26 -0
- package/src/stories/button.stories.tsx +90 -0
- package/src/stories/callout.stories.tsx +73 -0
- package/src/stories/cell-status.stories.tsx +145 -0
- package/src/stories/cell.stories.tsx +336 -0
- package/src/stories/checkbox.stories.tsx +44 -0
- package/src/stories/colors.stories.tsx +156 -0
- package/src/stories/combobox.stories.tsx +133 -0
- package/src/stories/context-menu.mdx +23 -0
- package/src/stories/data-explorer.stories.tsx +30 -0
- package/src/stories/data-table.stories.tsx +130 -0
- package/src/stories/dataframe.stories.tsx +46 -0
- package/src/stories/debugger.stories.tsx +34 -0
- package/src/stories/dialog.stories.tsx +80 -0
- package/src/stories/dropdown-menu.mdx +159 -0
- package/src/stories/editor-inputs.stories.tsx +47 -0
- package/src/stories/editor.stories.tsx +91 -0
- package/src/stories/file-upload.stories.tsx +103 -0
- package/src/stories/form-wrapper.stories.tsx +147 -0
- package/src/stories/input.stories.tsx +56 -0
- package/src/stories/label.mdx +9 -0
- package/src/stories/log-viewer.stories.tsx +74 -0
- package/src/stories/number-field.mdx +17 -0
- package/src/stories/number-field.stories.tsx +41 -0
- package/src/stories/progress-component.stories.tsx +74 -0
- package/src/stories/progress.stories.tsx +33 -0
- package/src/stories/radio-group.mdx +54 -0
- package/src/stories/select-native.stories.tsx +49 -0
- package/src/stories/select.stories.tsx +92 -0
- package/src/stories/slider.stories.tsx +27 -0
- package/src/stories/stat.stories.tsx +123 -0
- package/src/stories/switch.mdx +20 -0
- package/src/stories/switchable-multi-select.stories.tsx +31 -0
- package/src/stories/tabs.mdx +59 -0
- package/src/stories/textarea.stories.tsx +58 -0
- package/src/stories/theme.stories.tsx +111 -0
- package/src/stories/tooltip.mdx +32 -0
- package/src/stories/typography.stories.tsx +80 -0
- package/src/stories/variables.stories.tsx +58 -0
- package/src/stories/vega.stories.tsx +57 -0
- package/src/theme/ThemeProvider.tsx +32 -0
- package/src/theme/namespace.tsx +23 -0
- package/src/theme/useTheme.ts +89 -0
- package/src/utils/Deferred.ts +20 -0
- package/src/utils/Logger.ts +91 -0
- package/src/utils/__tests__/Deferred.test.ts +38 -0
- package/src/utils/__tests__/arrays.test.ts +130 -0
- package/src/utils/__tests__/batch-requests.test.ts +60 -0
- package/src/utils/__tests__/blob.test.ts +52 -0
- package/src/utils/__tests__/cell-urls.test.ts +92 -0
- package/src/utils/__tests__/createReducer.test.ts +184 -0
- package/src/utils/__tests__/data-views.test.ts +112 -0
- package/src/utils/__tests__/dates.test.ts +188 -0
- package/src/utils/__tests__/edit-distance.test.ts +302 -0
- package/src/utils/__tests__/errors.test.ts +54 -0
- package/src/utils/__tests__/filenames.test.ts +30 -0
- package/src/utils/__tests__/id-tree.test.ts +1994 -0
- package/src/utils/__tests__/json-parser.test.ts +79 -0
- package/src/utils/__tests__/local-storage.test.ts +77 -0
- package/src/utils/__tests__/lru.test.ts +74 -0
- package/src/utils/__tests__/maps.test.ts +91 -0
- package/src/utils/__tests__/math.test.ts +29 -0
- package/src/utils/__tests__/multi-map.test.ts +295 -0
- package/src/utils/__tests__/numbers.test.ts +76 -0
- package/src/utils/__tests__/path.test.ts +170 -0
- package/src/utils/__tests__/pluralize.test.ts +47 -0
- package/src/utils/__tests__/routes.test.ts +134 -0
- package/src/utils/__tests__/sets.test.ts +41 -0
- package/src/utils/__tests__/shallow-compare.test.ts +55 -0
- package/src/utils/__tests__/strings.test.ts +68 -0
- package/src/utils/__tests__/time.test.ts +61 -0
- package/src/utils/__tests__/timed-cache.test.ts +142 -0
- package/src/utils/__tests__/timeout.test.ts +153 -0
- package/src/utils/__tests__/traceback.test.ts +34 -0
- package/src/utils/__tests__/url.test.ts +100 -0
- package/src/utils/__tests__/urls.test.ts +10 -0
- package/src/utils/__tests__/versions.test.ts +63 -0
- package/src/utils/__tests__/waitForWs.test.ts +76 -0
- package/src/utils/arrays.ts +75 -0
- package/src/utils/assertExists.ts +12 -0
- package/src/utils/assertNever.ts +20 -0
- package/src/utils/batch-requests.ts +28 -0
- package/src/utils/blob.ts +45 -0
- package/src/utils/cell-urls.ts +31 -0
- package/src/utils/cn.ts +8 -0
- package/src/utils/copy.ts +17 -0
- package/src/utils/createReducer.ts +137 -0
- package/src/utils/data-views.ts +54 -0
- package/src/utils/dates.ts +145 -0
- package/src/utils/dereference.ts +10 -0
- package/src/utils/download.ts +47 -0
- package/src/utils/edit-distance.ts +141 -0
- package/src/utils/errors.ts +63 -0
- package/src/utils/events.ts +85 -0
- package/src/utils/fileToBase64.ts +30 -0
- package/src/utils/filenames.ts +29 -0
- package/src/utils/functions.ts +24 -0
- package/src/utils/id-tree.tsx +1032 -0
- package/src/utils/idle.ts +19 -0
- package/src/utils/invariant.ts +37 -0
- package/src/utils/json/__tests__/base64.test.ts +100 -0
- package/src/utils/json/base64.ts +51 -0
- package/src/utils/json/json-parser.ts +65 -0
- package/src/utils/lazy.ts +30 -0
- package/src/utils/links.ts +11 -0
- package/src/utils/localStorage.ts +132 -0
- package/src/utils/lru.ts +68 -0
- package/src/utils/maps.ts +65 -0
- package/src/utils/math.ts +6 -0
- package/src/utils/mergeRefs.ts +14 -0
- package/src/utils/multi-map.ts +71 -0
- package/src/utils/numbers.ts +124 -0
- package/src/utils/objects.ts +105 -0
- package/src/utils/once.ts +17 -0
- package/src/utils/pathUtils.test.ts +113 -0
- package/src/utils/pathUtils.ts +76 -0
- package/src/utils/paths.ts +67 -0
- package/src/utils/pluralize.ts +35 -0
- package/src/utils/python-poet/__tests__/poet.test.ts +286 -0
- package/src/utils/python-poet/poet.ts +196 -0
- package/src/utils/reload-safe.ts +15 -0
- package/src/utils/repl.ts +23 -0
- package/src/utils/routes.ts +36 -0
- package/src/utils/scroll.ts +38 -0
- package/src/utils/sets.ts +30 -0
- package/src/utils/shallow-compare.ts +30 -0
- package/src/utils/staticImplements.ts +7 -0
- package/src/utils/strings.ts +64 -0
- package/src/utils/time.ts +39 -0
- package/src/utils/timed-cache.ts +52 -0
- package/src/utils/timeout.ts +42 -0
- package/src/utils/traceback.ts +104 -0
- package/src/utils/tracer.ts +106 -0
- package/src/utils/typed.ts +17 -0
- package/src/utils/url.ts +12 -0
- package/src/utils/urls.ts +33 -0
- package/src/utils/uuid.ts +8 -0
- package/src/utils/versions.ts +66 -0
- package/src/utils/vitals.ts +30 -0
- package/src/utils/waitForWs.ts +31 -0
- package/dist/assets/_baseMap-DI8H5mdU.js +0 -1
- package/dist/assets/architectureDiagram-SUXI7LT5-BEcV3kj8.js +0 -36
- package/dist/assets/blockDiagram-6J76NXCF-BUxeo5Pp.js +0 -122
- package/dist/assets/channel-BgIIdDsO.js +0 -1
- package/dist/assets/classDiagram-M3E45YP4-CocoijMx.js +0 -1
- package/dist/assets/classDiagram-v2-YAWTLIQI-CocoijMx.js +0 -1
- package/dist/assets/clone-CkywUQE5.js +0 -1
- package/dist/assets/cytoscape.esm-CzSnbbKZ.js +0 -325
- package/dist/assets/diagram-5UYTHUR4-CaEJdB-c.js +0 -24
- package/dist/assets/edit-page-0aVIqkPG.js +0 -163
- package/dist/assets/flowDiagram-KYDEHFYC-COI3Wlzg.js +0 -162
- package/dist/assets/ganttDiagram-EK5VF46D-T8K8LZXH.js +0 -267
- package/dist/assets/index-BlxPam9h.css +0 -1
- package/dist/assets/index-DPzEQsyf.js +0 -518
- package/dist/assets/infoDiagram-LHK5PUON-DIh9EeeW.js +0 -2
- package/dist/assets/links-Co7kZnDQ.js +0 -17
- package/dist/assets/mermaid-sbM5kvPX.js +0 -207
- package/dist/assets/min-ClcSmngt.js +0 -1
- package/dist/assets/pieDiagram-NIOCPIFQ-ClBSTDHM.js +0 -30
- package/dist/assets/sortBy-BPqL9Az6.js +0 -1
- package/dist/assets/stateDiagram-v2-5AN5P6BG-Ch96oS1p.js +0 -1
- package/dist/assets/storage-6bL26f8J.js +0 -26
- package/dist/assets/time--ds3HCGk.js +0 -1
- package/dist/assets/xychartDiagram-H2YORKM3-tbgrOMTu.js +0 -7
|
@@ -0,0 +1,2664 @@
|
|
|
1
|
+
/* Copyright 2024 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { python } from "@codemirror/lang-python";
|
|
4
|
+
import { EditorState } from "@codemirror/state";
|
|
5
|
+
import { EditorView } from "@codemirror/view";
|
|
6
|
+
import {
|
|
7
|
+
afterAll,
|
|
8
|
+
beforeAll,
|
|
9
|
+
beforeEach,
|
|
10
|
+
describe,
|
|
11
|
+
expect,
|
|
12
|
+
it,
|
|
13
|
+
vi,
|
|
14
|
+
} from "vitest";
|
|
15
|
+
import type { CellHandle } from "@/components/editor/Cell";
|
|
16
|
+
import { CellId } from "@/core/cells/ids";
|
|
17
|
+
import { foldAllBulk, unfoldAllBulk } from "@/core/codemirror/editing/commands";
|
|
18
|
+
import { adaptiveLanguageConfiguration } from "@/core/codemirror/language/extension";
|
|
19
|
+
import { OverridingHotkeyProvider } from "@/core/hotkeys/hotkeys";
|
|
20
|
+
import type { OutputMessage } from "@/core/kernel/messages";
|
|
21
|
+
import { type CollapsibleTree, MultiColumn } from "@/utils/id-tree";
|
|
22
|
+
import type { Seconds } from "@/utils/time";
|
|
23
|
+
import {
|
|
24
|
+
exportedForTesting,
|
|
25
|
+
flattenTopLevelNotebookCells,
|
|
26
|
+
type NotebookState,
|
|
27
|
+
SETUP_CELL_ID,
|
|
28
|
+
} from "../cells";
|
|
29
|
+
import {
|
|
30
|
+
focusAndScrollCellIntoView,
|
|
31
|
+
scrollToBottom,
|
|
32
|
+
scrollToTop,
|
|
33
|
+
} from "../scrollCellIntoView";
|
|
34
|
+
import type { CellData } from "../types";
|
|
35
|
+
|
|
36
|
+
vi.mock("@/core/codemirror/editing/commands", () => ({
|
|
37
|
+
foldAllBulk: vi.fn(),
|
|
38
|
+
unfoldAllBulk: vi.fn(),
|
|
39
|
+
}));
|
|
40
|
+
vi.mock("../scrollCellIntoView", async (importOriginal) => {
|
|
41
|
+
const actual = await importOriginal();
|
|
42
|
+
return {
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
...(actual as any),
|
|
45
|
+
scrollToTop: vi.fn(),
|
|
46
|
+
scrollToBottom: vi.fn(),
|
|
47
|
+
focusAndScrollCellIntoView: vi.fn(),
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const FIRST_COLUMN = 0;
|
|
52
|
+
const SECOND_COLUMN = 1;
|
|
53
|
+
|
|
54
|
+
const { initialNotebookState, reducer, createActions } = exportedForTesting;
|
|
55
|
+
|
|
56
|
+
function formatCells(notebook: NotebookState) {
|
|
57
|
+
const { cellIds, cellData } = notebook;
|
|
58
|
+
const wrap = (text: string) => {
|
|
59
|
+
return `\n${text}\n`;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const printCell = (cell: CellData) => {
|
|
63
|
+
return `[${cell.id}] '${cell.code}'`;
|
|
64
|
+
};
|
|
65
|
+
const printCells = (cellsId: CellId[]) => {
|
|
66
|
+
const cells = cellsId.map((cellId) => cellData[cellId]);
|
|
67
|
+
return cells.map((cell) => printCell(cell)).join("\n\n");
|
|
68
|
+
};
|
|
69
|
+
const printColumn = (column: CollapsibleTree<CellId>, columnIdx: number) => {
|
|
70
|
+
return `> col ${columnIdx}\n${printCells(column.inOrderIds)}`;
|
|
71
|
+
};
|
|
72
|
+
const columns = cellIds.getColumns();
|
|
73
|
+
if (columns.length > 1) {
|
|
74
|
+
return wrap(columns.map(printColumn).join("\n\n"));
|
|
75
|
+
}
|
|
76
|
+
return wrap(printCells(cellIds.inOrderIds));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function createEditor(content: string) {
|
|
80
|
+
const state = EditorState.create({
|
|
81
|
+
doc: content,
|
|
82
|
+
extensions: [
|
|
83
|
+
python(),
|
|
84
|
+
adaptiveLanguageConfiguration({
|
|
85
|
+
cellId: "cell1" as CellId,
|
|
86
|
+
completionConfig: {
|
|
87
|
+
activate_on_typing: true,
|
|
88
|
+
copilot: false,
|
|
89
|
+
codeium_api_key: null,
|
|
90
|
+
},
|
|
91
|
+
hotkeys: new OverridingHotkeyProvider({}),
|
|
92
|
+
placeholderType: "marimo-import",
|
|
93
|
+
lspConfig: {},
|
|
94
|
+
}),
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const view = new EditorView({
|
|
99
|
+
state,
|
|
100
|
+
parent: document.body,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return view;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
describe("cell reducer", () => {
|
|
107
|
+
let state: NotebookState;
|
|
108
|
+
let cells: ReturnType<typeof flattenTopLevelNotebookCells>;
|
|
109
|
+
let firstCellId: CellId;
|
|
110
|
+
|
|
111
|
+
const actions = createActions((action) => {
|
|
112
|
+
state = reducer(state, action);
|
|
113
|
+
for (const [cellId, handle] of Object.entries(state.cellHandles)) {
|
|
114
|
+
if (!handle.current) {
|
|
115
|
+
const view = createEditor(state.cellData[cellId as CellId].code);
|
|
116
|
+
const handle: CellHandle = {
|
|
117
|
+
editorView: view,
|
|
118
|
+
editorViewOrNull: view,
|
|
119
|
+
};
|
|
120
|
+
state.cellHandles[cellId as CellId] = { current: handle };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
cells = flattenTopLevelNotebookCells(state);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
let i = 0;
|
|
127
|
+
const originalCreate = CellId.create.bind(CellId);
|
|
128
|
+
|
|
129
|
+
beforeAll(() => {
|
|
130
|
+
CellId.create = () => {
|
|
131
|
+
return `${i++}` as CellId;
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
beforeEach(() => {
|
|
136
|
+
i = 0;
|
|
137
|
+
|
|
138
|
+
state = initialNotebookState();
|
|
139
|
+
state.cellIds = MultiColumn.from([]);
|
|
140
|
+
actions.createNewCell({ cellId: "__end__", before: false });
|
|
141
|
+
firstCellId = state.cellIds.inOrderIds[0];
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
afterAll(() => {
|
|
145
|
+
CellId.create = originalCreate;
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("can add a cell after another cell", () => {
|
|
149
|
+
actions.createNewCell({
|
|
150
|
+
cellId: firstCellId,
|
|
151
|
+
before: false,
|
|
152
|
+
});
|
|
153
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
154
|
+
"
|
|
155
|
+
[0] ''
|
|
156
|
+
|
|
157
|
+
[1] ''
|
|
158
|
+
"
|
|
159
|
+
`);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("can add a cell to the end with code", () => {
|
|
163
|
+
actions.createNewCell({
|
|
164
|
+
cellId: "__end__",
|
|
165
|
+
code: "import numpy as np",
|
|
166
|
+
before: false,
|
|
167
|
+
});
|
|
168
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
169
|
+
"
|
|
170
|
+
[0] ''
|
|
171
|
+
|
|
172
|
+
[1] 'import numpy as np'
|
|
173
|
+
"
|
|
174
|
+
`);
|
|
175
|
+
|
|
176
|
+
// Cell should be added to the end and edited
|
|
177
|
+
expect(cells[1].code).toBe("import numpy as np");
|
|
178
|
+
expect(cells[1].edited).toBe(true);
|
|
179
|
+
expect(cells[1].lastCodeRun).toBe(null);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("can add a cell before another cell", () => {
|
|
183
|
+
actions.createNewCell({
|
|
184
|
+
cellId: firstCellId,
|
|
185
|
+
before: true,
|
|
186
|
+
});
|
|
187
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
188
|
+
"
|
|
189
|
+
[1] ''
|
|
190
|
+
|
|
191
|
+
[0] ''
|
|
192
|
+
"
|
|
193
|
+
`);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("can delete a Python cell and undo delete", () => {
|
|
197
|
+
actions.createNewCell({
|
|
198
|
+
cellId: firstCellId,
|
|
199
|
+
before: false,
|
|
200
|
+
});
|
|
201
|
+
actions.deleteCell({
|
|
202
|
+
cellId: firstCellId,
|
|
203
|
+
});
|
|
204
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
205
|
+
"
|
|
206
|
+
[1] ''
|
|
207
|
+
"
|
|
208
|
+
`);
|
|
209
|
+
|
|
210
|
+
// undo
|
|
211
|
+
actions.undoDeleteCell();
|
|
212
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
213
|
+
"
|
|
214
|
+
[2] ''
|
|
215
|
+
|
|
216
|
+
[1] ''
|
|
217
|
+
"
|
|
218
|
+
`);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("can delete a SQL cell and undo delete", () => {
|
|
222
|
+
actions.createNewCell({
|
|
223
|
+
cellId: firstCellId,
|
|
224
|
+
before: false,
|
|
225
|
+
code: `df = mo.sql("""SELECT * FROM table""")`,
|
|
226
|
+
});
|
|
227
|
+
const newCellId = state.cellIds.getColumns()[0].atOrThrow(1);
|
|
228
|
+
actions.deleteCell({
|
|
229
|
+
cellId: newCellId,
|
|
230
|
+
});
|
|
231
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
232
|
+
"
|
|
233
|
+
[0] ''
|
|
234
|
+
"
|
|
235
|
+
`);
|
|
236
|
+
|
|
237
|
+
// undo
|
|
238
|
+
actions.undoDeleteCell();
|
|
239
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
240
|
+
"
|
|
241
|
+
[0] ''
|
|
242
|
+
|
|
243
|
+
[2] 'df = mo.sql("""SELECT * FROM table""")'
|
|
244
|
+
"
|
|
245
|
+
`);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("can delete a Markdown cell and undo delete", () => {
|
|
249
|
+
const text = "The quick brown fox jumps over the lazy dog.";
|
|
250
|
+
actions.createNewCell({
|
|
251
|
+
cellId: firstCellId,
|
|
252
|
+
before: false,
|
|
253
|
+
code: `mo.md(r"""${text}""")`,
|
|
254
|
+
});
|
|
255
|
+
const newCellId = state.cellIds.getColumns()[0].atOrThrow(1);
|
|
256
|
+
actions.deleteCell({
|
|
257
|
+
cellId: newCellId,
|
|
258
|
+
});
|
|
259
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
260
|
+
"
|
|
261
|
+
[0] ''
|
|
262
|
+
"
|
|
263
|
+
`);
|
|
264
|
+
|
|
265
|
+
// undo
|
|
266
|
+
actions.undoDeleteCell();
|
|
267
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
268
|
+
"
|
|
269
|
+
[0] ''
|
|
270
|
+
|
|
271
|
+
[2] 'mo.md(r"""The quick brown fox jumps over the lazy dog.""")'
|
|
272
|
+
"
|
|
273
|
+
`);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it("can update a cell", () => {
|
|
277
|
+
actions.updateCellCode({
|
|
278
|
+
cellId: firstCellId,
|
|
279
|
+
code: "import numpy as np",
|
|
280
|
+
formattingChange: false,
|
|
281
|
+
});
|
|
282
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
283
|
+
"
|
|
284
|
+
[0] 'import numpy as np'
|
|
285
|
+
"
|
|
286
|
+
`);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("can move a cell", () => {
|
|
290
|
+
actions.createNewCell({
|
|
291
|
+
cellId: firstCellId,
|
|
292
|
+
before: false,
|
|
293
|
+
});
|
|
294
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
295
|
+
"
|
|
296
|
+
[0] ''
|
|
297
|
+
|
|
298
|
+
[1] ''
|
|
299
|
+
"
|
|
300
|
+
`);
|
|
301
|
+
|
|
302
|
+
// move first cell to the end
|
|
303
|
+
actions.moveCell({
|
|
304
|
+
cellId: firstCellId,
|
|
305
|
+
before: false,
|
|
306
|
+
});
|
|
307
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
308
|
+
"
|
|
309
|
+
[1] ''
|
|
310
|
+
|
|
311
|
+
[0] ''
|
|
312
|
+
"
|
|
313
|
+
`);
|
|
314
|
+
|
|
315
|
+
// move it back
|
|
316
|
+
actions.moveCell({
|
|
317
|
+
cellId: firstCellId,
|
|
318
|
+
before: true,
|
|
319
|
+
});
|
|
320
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
321
|
+
"
|
|
322
|
+
[0] ''
|
|
323
|
+
|
|
324
|
+
[1] ''
|
|
325
|
+
"
|
|
326
|
+
`);
|
|
327
|
+
|
|
328
|
+
// Add a column breakpoint to test left/right movement
|
|
329
|
+
actions.addColumnBreakpoint({ cellId: "1" as CellId });
|
|
330
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
331
|
+
"
|
|
332
|
+
> col 0
|
|
333
|
+
[0] ''
|
|
334
|
+
|
|
335
|
+
> col 1
|
|
336
|
+
[1] ''
|
|
337
|
+
"
|
|
338
|
+
`);
|
|
339
|
+
|
|
340
|
+
// Move cell right
|
|
341
|
+
actions.moveCell({
|
|
342
|
+
cellId: firstCellId,
|
|
343
|
+
direction: "right",
|
|
344
|
+
});
|
|
345
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
346
|
+
"
|
|
347
|
+
> col 0
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
> col 1
|
|
351
|
+
[0] ''
|
|
352
|
+
|
|
353
|
+
[1] ''
|
|
354
|
+
"
|
|
355
|
+
`);
|
|
356
|
+
|
|
357
|
+
// Move cell left
|
|
358
|
+
actions.moveCell({
|
|
359
|
+
cellId: firstCellId,
|
|
360
|
+
direction: "left",
|
|
361
|
+
});
|
|
362
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
363
|
+
"
|
|
364
|
+
> col 0
|
|
365
|
+
[0] ''
|
|
366
|
+
|
|
367
|
+
> col 1
|
|
368
|
+
[1] ''
|
|
369
|
+
"
|
|
370
|
+
`);
|
|
371
|
+
|
|
372
|
+
// Try to move cell left when it's already in leftmost column (should noop)
|
|
373
|
+
actions.moveCell({
|
|
374
|
+
cellId: firstCellId,
|
|
375
|
+
direction: "left",
|
|
376
|
+
});
|
|
377
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
378
|
+
"
|
|
379
|
+
> col 0
|
|
380
|
+
[0] ''
|
|
381
|
+
|
|
382
|
+
> col 1
|
|
383
|
+
[1] ''
|
|
384
|
+
"
|
|
385
|
+
`);
|
|
386
|
+
|
|
387
|
+
// Try to move cell right when it's already in rightmost column (should noop)
|
|
388
|
+
actions.moveCell({
|
|
389
|
+
cellId: "1" as CellId,
|
|
390
|
+
direction: "right",
|
|
391
|
+
});
|
|
392
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
393
|
+
"
|
|
394
|
+
> col 0
|
|
395
|
+
[0] ''
|
|
396
|
+
|
|
397
|
+
> col 1
|
|
398
|
+
[1] ''
|
|
399
|
+
"
|
|
400
|
+
`);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it("can drag and drop a cell", () => {
|
|
404
|
+
actions.createNewCell({
|
|
405
|
+
cellId: firstCellId,
|
|
406
|
+
before: false,
|
|
407
|
+
});
|
|
408
|
+
actions.createNewCell({
|
|
409
|
+
cellId: "1" as CellId,
|
|
410
|
+
before: false,
|
|
411
|
+
});
|
|
412
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
413
|
+
"
|
|
414
|
+
[0] ''
|
|
415
|
+
|
|
416
|
+
[1] ''
|
|
417
|
+
|
|
418
|
+
[2] ''
|
|
419
|
+
"
|
|
420
|
+
`);
|
|
421
|
+
|
|
422
|
+
// drag first cell to the end
|
|
423
|
+
actions.dropCellOverCell({
|
|
424
|
+
cellId: firstCellId,
|
|
425
|
+
overCellId: "2" as CellId,
|
|
426
|
+
});
|
|
427
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
428
|
+
"
|
|
429
|
+
[1] ''
|
|
430
|
+
|
|
431
|
+
[2] ''
|
|
432
|
+
|
|
433
|
+
[0] ''
|
|
434
|
+
"
|
|
435
|
+
`);
|
|
436
|
+
|
|
437
|
+
// drag it back to the middle
|
|
438
|
+
actions.dropCellOverCell({
|
|
439
|
+
cellId: firstCellId,
|
|
440
|
+
overCellId: "2" as CellId,
|
|
441
|
+
});
|
|
442
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
443
|
+
"
|
|
444
|
+
[1] ''
|
|
445
|
+
|
|
446
|
+
[0] ''
|
|
447
|
+
|
|
448
|
+
[2] ''
|
|
449
|
+
"
|
|
450
|
+
`);
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
it("can run cell and receive cell messages", () => {
|
|
454
|
+
// HAPPY PATH
|
|
455
|
+
/////////////////
|
|
456
|
+
// Initial state
|
|
457
|
+
let cell = cells[0];
|
|
458
|
+
expect(cell.status).toBe("idle");
|
|
459
|
+
expect(cell.lastCodeRun).toBe(null);
|
|
460
|
+
expect(cell.edited).toBe(false);
|
|
461
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
462
|
+
|
|
463
|
+
// Update code
|
|
464
|
+
actions.updateCellCode({
|
|
465
|
+
cellId: firstCellId,
|
|
466
|
+
code: "import marimo as mo",
|
|
467
|
+
formattingChange: false,
|
|
468
|
+
});
|
|
469
|
+
cell = cells[0];
|
|
470
|
+
expect(cell.status).toBe("idle");
|
|
471
|
+
expect(cell.lastCodeRun).toBe(null);
|
|
472
|
+
expect(cell.edited).toBe(true);
|
|
473
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
474
|
+
|
|
475
|
+
// Prepare for run
|
|
476
|
+
actions.prepareForRun({
|
|
477
|
+
cellId: firstCellId,
|
|
478
|
+
});
|
|
479
|
+
cell = cells[0];
|
|
480
|
+
expect(cell.status).toBe("queued");
|
|
481
|
+
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
482
|
+
expect(cell.edited).toBe(false);
|
|
483
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
484
|
+
|
|
485
|
+
// Receive queued messages
|
|
486
|
+
actions.handleCellMessage({
|
|
487
|
+
cell_id: firstCellId,
|
|
488
|
+
output: undefined,
|
|
489
|
+
console: null,
|
|
490
|
+
status: "queued",
|
|
491
|
+
stale_inputs: null,
|
|
492
|
+
timestamp: new Date(10).getTime() as Seconds,
|
|
493
|
+
});
|
|
494
|
+
cell = cells[0];
|
|
495
|
+
expect(cell.status).toBe("queued");
|
|
496
|
+
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
497
|
+
expect(cell.edited).toBe(false);
|
|
498
|
+
expect(cell.runElapsedTimeMs).toBe(null);
|
|
499
|
+
expect(cell.runStartTimestamp).toBe(null);
|
|
500
|
+
expect(cell.lastRunStartTimestamp).toBe(null);
|
|
501
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
502
|
+
|
|
503
|
+
// Receive running messages
|
|
504
|
+
actions.handleCellMessage({
|
|
505
|
+
cell_id: firstCellId,
|
|
506
|
+
output: undefined,
|
|
507
|
+
console: null,
|
|
508
|
+
status: "running",
|
|
509
|
+
stale_inputs: null,
|
|
510
|
+
timestamp: new Date(20).getTime() as Seconds,
|
|
511
|
+
});
|
|
512
|
+
cell = cells[0];
|
|
513
|
+
expect(cell.status).toBe("running");
|
|
514
|
+
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
515
|
+
expect(cell.edited).toBe(false);
|
|
516
|
+
expect(cell.runElapsedTimeMs).toBe(null);
|
|
517
|
+
expect(cell.runStartTimestamp).toBe(20);
|
|
518
|
+
expect(cell.lastRunStartTimestamp).toBe(20);
|
|
519
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
520
|
+
|
|
521
|
+
// Console messages shouldn't transition status
|
|
522
|
+
actions.handleCellMessage({
|
|
523
|
+
cell_id: firstCellId,
|
|
524
|
+
output: undefined,
|
|
525
|
+
console: {
|
|
526
|
+
channel: "stdout",
|
|
527
|
+
mimetype: "text/plain",
|
|
528
|
+
data: "hello!",
|
|
529
|
+
timestamp: 0,
|
|
530
|
+
},
|
|
531
|
+
status: undefined,
|
|
532
|
+
stale_inputs: null,
|
|
533
|
+
timestamp: new Date(22).getTime() as Seconds,
|
|
534
|
+
});
|
|
535
|
+
cell = cells[0];
|
|
536
|
+
expect(cell.status).toBe("running");
|
|
537
|
+
expect(cell.edited).toBe(false);
|
|
538
|
+
expect(cell.runElapsedTimeMs).toBe(null);
|
|
539
|
+
expect(cell.runStartTimestamp).toBe(20);
|
|
540
|
+
expect(cell.lastRunStartTimestamp).toBe(20);
|
|
541
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
542
|
+
|
|
543
|
+
// Receive output messages
|
|
544
|
+
actions.handleCellMessage({
|
|
545
|
+
cell_id: firstCellId,
|
|
546
|
+
output: {
|
|
547
|
+
channel: "output",
|
|
548
|
+
mimetype: "text/plain",
|
|
549
|
+
data: "ok",
|
|
550
|
+
timestamp: 0,
|
|
551
|
+
},
|
|
552
|
+
console: {
|
|
553
|
+
channel: "stdout",
|
|
554
|
+
mimetype: "text/plain",
|
|
555
|
+
data: "hello!",
|
|
556
|
+
timestamp: 0,
|
|
557
|
+
},
|
|
558
|
+
status: "idle",
|
|
559
|
+
stale_inputs: null,
|
|
560
|
+
timestamp: new Date(33).getTime() as Seconds,
|
|
561
|
+
});
|
|
562
|
+
cell = cells[0];
|
|
563
|
+
expect(cell.status).toBe("idle");
|
|
564
|
+
expect(cell.edited).toBe(false);
|
|
565
|
+
expect(cell.runElapsedTimeMs).toBe(13_000);
|
|
566
|
+
expect(cell.runStartTimestamp).toBe(null);
|
|
567
|
+
expect(cell.lastRunStartTimestamp).toBe(20);
|
|
568
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
569
|
+
|
|
570
|
+
// EDITING BACK AND FORTH
|
|
571
|
+
/////////////////
|
|
572
|
+
// Update code again
|
|
573
|
+
actions.updateCellCode({
|
|
574
|
+
cellId: firstCellId,
|
|
575
|
+
code: "import marimo as mo\nimport numpy",
|
|
576
|
+
formattingChange: false,
|
|
577
|
+
});
|
|
578
|
+
cell = cells[0];
|
|
579
|
+
expect(cell.status).toBe("idle");
|
|
580
|
+
expect(cell.edited).toBe(true);
|
|
581
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
582
|
+
|
|
583
|
+
// Update code should be unedited
|
|
584
|
+
actions.updateCellCode({
|
|
585
|
+
cellId: firstCellId,
|
|
586
|
+
code: "import marimo as mo",
|
|
587
|
+
formattingChange: false,
|
|
588
|
+
});
|
|
589
|
+
cell = cells[0];
|
|
590
|
+
expect(cell.edited).toBe(false);
|
|
591
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
592
|
+
|
|
593
|
+
// Update code should be edited again
|
|
594
|
+
actions.updateCellCode({
|
|
595
|
+
cellId: firstCellId,
|
|
596
|
+
code: "import marimo as mo\nimport numpy",
|
|
597
|
+
formattingChange: false,
|
|
598
|
+
});
|
|
599
|
+
cell = cells[0];
|
|
600
|
+
expect(cell.status).toBe("idle");
|
|
601
|
+
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
602
|
+
expect(cell.edited).toBe(true);
|
|
603
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
604
|
+
|
|
605
|
+
// ERROR RESPONSE
|
|
606
|
+
/////////////////
|
|
607
|
+
// Prepare for run
|
|
608
|
+
actions.prepareForRun({
|
|
609
|
+
cellId: firstCellId,
|
|
610
|
+
});
|
|
611
|
+
cell = cells[0];
|
|
612
|
+
expect(cell.output).not.toBe(null); // keep old output
|
|
613
|
+
// Queue
|
|
614
|
+
actions.handleCellMessage({
|
|
615
|
+
cell_id: firstCellId,
|
|
616
|
+
output: undefined,
|
|
617
|
+
console: null,
|
|
618
|
+
status: "queued",
|
|
619
|
+
stale_inputs: null,
|
|
620
|
+
timestamp: new Date(40).getTime() as Seconds,
|
|
621
|
+
});
|
|
622
|
+
cell = cells[0];
|
|
623
|
+
expect(cell.output).not.toBe(null); // keep old output
|
|
624
|
+
// Running
|
|
625
|
+
actions.handleCellMessage({
|
|
626
|
+
cell_id: firstCellId,
|
|
627
|
+
output: undefined,
|
|
628
|
+
console: null,
|
|
629
|
+
status: "running",
|
|
630
|
+
stale_inputs: null,
|
|
631
|
+
timestamp: new Date(50).getTime() as Seconds,
|
|
632
|
+
});
|
|
633
|
+
cell = cells[0];
|
|
634
|
+
expect(cell.output).not.toBe(null); // keep old output
|
|
635
|
+
// Receive error
|
|
636
|
+
actions.handleCellMessage({
|
|
637
|
+
cell_id: firstCellId,
|
|
638
|
+
output: {
|
|
639
|
+
channel: "marimo-error",
|
|
640
|
+
mimetype: "application/vnd.marimo+error",
|
|
641
|
+
data: [
|
|
642
|
+
{ type: "exception", exception_type: "ValueError", msg: "Oh no!" },
|
|
643
|
+
],
|
|
644
|
+
timestamp: 0,
|
|
645
|
+
},
|
|
646
|
+
console: null,
|
|
647
|
+
status: "idle",
|
|
648
|
+
stale_inputs: null,
|
|
649
|
+
timestamp: new Date(61).getTime() as Seconds,
|
|
650
|
+
});
|
|
651
|
+
cell = cells[0];
|
|
652
|
+
expect(cell.output).not.toBe(null); // keep old output
|
|
653
|
+
expect(cell.status).toBe("idle");
|
|
654
|
+
expect(cell.lastCodeRun).toBe("import marimo as mo\nimport numpy");
|
|
655
|
+
expect(cell.edited).toBe(false);
|
|
656
|
+
expect(cell.runElapsedTimeMs).toBe(11_000);
|
|
657
|
+
expect(cell.runStartTimestamp).toBe(null);
|
|
658
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
659
|
+
|
|
660
|
+
// INTERRUPT RESPONSE
|
|
661
|
+
/////////////////
|
|
662
|
+
// Prepare for run
|
|
663
|
+
actions.prepareForRun({
|
|
664
|
+
cellId: firstCellId,
|
|
665
|
+
});
|
|
666
|
+
cell = cells[0];
|
|
667
|
+
expect(cell.output).not.toBe(null); // keep old output
|
|
668
|
+
// Queue
|
|
669
|
+
actions.handleCellMessage({
|
|
670
|
+
cell_id: firstCellId,
|
|
671
|
+
output: undefined,
|
|
672
|
+
console: null,
|
|
673
|
+
status: "queued",
|
|
674
|
+
stale_inputs: null,
|
|
675
|
+
timestamp: new Date(40).getTime() as Seconds,
|
|
676
|
+
});
|
|
677
|
+
cell = cells[0];
|
|
678
|
+
expect(cell.output).not.toBe(null); // keep old output
|
|
679
|
+
// Running
|
|
680
|
+
actions.handleCellMessage({
|
|
681
|
+
cell_id: firstCellId,
|
|
682
|
+
output: undefined,
|
|
683
|
+
console: null,
|
|
684
|
+
status: "running",
|
|
685
|
+
stale_inputs: null,
|
|
686
|
+
timestamp: new Date(50).getTime() as Seconds,
|
|
687
|
+
});
|
|
688
|
+
cell = cells[0];
|
|
689
|
+
expect(cell.output).not.toBe(null); // keep old output
|
|
690
|
+
// Receive error
|
|
691
|
+
actions.handleCellMessage({
|
|
692
|
+
cell_id: firstCellId,
|
|
693
|
+
output: {
|
|
694
|
+
channel: "marimo-error",
|
|
695
|
+
mimetype: "application/vnd.marimo+error",
|
|
696
|
+
data: [{ type: "interruption" }],
|
|
697
|
+
timestamp: 0,
|
|
698
|
+
},
|
|
699
|
+
console: null,
|
|
700
|
+
status: "idle",
|
|
701
|
+
stale_inputs: null,
|
|
702
|
+
timestamp: new Date(61).getTime() as Seconds,
|
|
703
|
+
});
|
|
704
|
+
cell = cells[0];
|
|
705
|
+
expect(cell.status).toBe("idle");
|
|
706
|
+
expect(cell.lastCodeRun).toBe(cell.code);
|
|
707
|
+
expect(cell.edited).toBe(false);
|
|
708
|
+
expect(cell.runElapsedTimeMs).toBe(11_000);
|
|
709
|
+
expect(cell.runStartTimestamp).toBe(null);
|
|
710
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
it("errors reset status to idle", () => {
|
|
714
|
+
// Initial state
|
|
715
|
+
let cell = cells[0];
|
|
716
|
+
expect(cell.status).toBe("idle");
|
|
717
|
+
expect(cell.lastCodeRun).toBe(null);
|
|
718
|
+
expect(cell.edited).toBe(false);
|
|
719
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
720
|
+
|
|
721
|
+
// Update code
|
|
722
|
+
actions.updateCellCode({
|
|
723
|
+
cellId: firstCellId,
|
|
724
|
+
code: "import marimo as mo",
|
|
725
|
+
formattingChange: false,
|
|
726
|
+
});
|
|
727
|
+
cell = cells[0];
|
|
728
|
+
expect(cell.status).toBe("idle");
|
|
729
|
+
expect(cell.lastCodeRun).toBe(null);
|
|
730
|
+
expect(cell.edited).toBe(true);
|
|
731
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
732
|
+
|
|
733
|
+
// Prepare for run
|
|
734
|
+
actions.prepareForRun({
|
|
735
|
+
cellId: firstCellId,
|
|
736
|
+
});
|
|
737
|
+
cell = cells[0];
|
|
738
|
+
expect(cell.status).toBe("queued");
|
|
739
|
+
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
740
|
+
expect(cell.edited).toBe(false);
|
|
741
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
742
|
+
|
|
743
|
+
// ERROR RESPONSE
|
|
744
|
+
//
|
|
745
|
+
// should reset status to idle
|
|
746
|
+
/////////////////
|
|
747
|
+
// Prepare for run
|
|
748
|
+
actions.prepareForRun({
|
|
749
|
+
cellId: firstCellId,
|
|
750
|
+
});
|
|
751
|
+
cell = cells[0];
|
|
752
|
+
// Receive error
|
|
753
|
+
actions.handleCellMessage({
|
|
754
|
+
cell_id: firstCellId,
|
|
755
|
+
output: {
|
|
756
|
+
channel: "marimo-error",
|
|
757
|
+
mimetype: "application/vnd.marimo+error",
|
|
758
|
+
data: [
|
|
759
|
+
{ type: "exception", exception_type: "SyntaxError", msg: "Oh no!" },
|
|
760
|
+
],
|
|
761
|
+
timestamp: 0,
|
|
762
|
+
},
|
|
763
|
+
console: null,
|
|
764
|
+
stale_inputs: null,
|
|
765
|
+
timestamp: new Date(61).getTime() as Seconds,
|
|
766
|
+
});
|
|
767
|
+
cell = cells[0];
|
|
768
|
+
expect(cell.status).toBe("idle");
|
|
769
|
+
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
770
|
+
expect(cell.edited).toBe(false);
|
|
771
|
+
expect(cell.runElapsedTimeMs).toBe(null);
|
|
772
|
+
expect(cell.runStartTimestamp).toBe(null);
|
|
773
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
774
|
+
});
|
|
775
|
+
|
|
776
|
+
it("can run a stale cell", () => {
|
|
777
|
+
// Update code of first cell
|
|
778
|
+
actions.updateCellCode({
|
|
779
|
+
cellId: firstCellId,
|
|
780
|
+
code: "import marimo as mo",
|
|
781
|
+
formattingChange: false,
|
|
782
|
+
});
|
|
783
|
+
// Add cell
|
|
784
|
+
actions.createNewCell({
|
|
785
|
+
cellId: firstCellId,
|
|
786
|
+
before: false,
|
|
787
|
+
});
|
|
788
|
+
const secondCell = cells[1].id;
|
|
789
|
+
// Update code
|
|
790
|
+
actions.updateCellCode({
|
|
791
|
+
code: "mo.slider()",
|
|
792
|
+
cellId: secondCell,
|
|
793
|
+
formattingChange: false,
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
// Prepare for run
|
|
797
|
+
actions.prepareForRun({
|
|
798
|
+
cellId: secondCell,
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
// Receive queued messages
|
|
802
|
+
actions.handleCellMessage({
|
|
803
|
+
cell_id: secondCell,
|
|
804
|
+
output: undefined,
|
|
805
|
+
console: null,
|
|
806
|
+
status: "queued",
|
|
807
|
+
stale_inputs: null,
|
|
808
|
+
timestamp: new Date(10).getTime() as Seconds,
|
|
809
|
+
});
|
|
810
|
+
let cell = cells[1];
|
|
811
|
+
expect(cell.status).toBe("queued");
|
|
812
|
+
expect(cell.lastCodeRun).toBe("mo.slider()");
|
|
813
|
+
expect(cell.edited).toBe(false);
|
|
814
|
+
expect(cell.runElapsedTimeMs).toBe(null);
|
|
815
|
+
expect(cell.runStartTimestamp).toBe(null);
|
|
816
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
817
|
+
|
|
818
|
+
// Receive stale message
|
|
819
|
+
actions.handleCellMessage({
|
|
820
|
+
cell_id: secondCell,
|
|
821
|
+
output: undefined,
|
|
822
|
+
console: null,
|
|
823
|
+
status: undefined,
|
|
824
|
+
stale_inputs: true,
|
|
825
|
+
timestamp: new Date(20).getTime() as Seconds,
|
|
826
|
+
});
|
|
827
|
+
cell = cells[1];
|
|
828
|
+
expect(cell.status).toBe("queued");
|
|
829
|
+
expect(cell.lastCodeRun).toBe("mo.slider()");
|
|
830
|
+
expect(cell.edited).toBe(false);
|
|
831
|
+
expect(cell.runElapsedTimeMs).toBe(null);
|
|
832
|
+
expect(cell.runStartTimestamp).toBe(null);
|
|
833
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
it("can format code and update cell", () => {
|
|
837
|
+
const firstCellId = cells[0].id;
|
|
838
|
+
actions.updateCellCode({
|
|
839
|
+
cellId: firstCellId,
|
|
840
|
+
code: "import marimo as mo",
|
|
841
|
+
formattingChange: false,
|
|
842
|
+
});
|
|
843
|
+
let cell = cells[0];
|
|
844
|
+
expect(cell.status).toBe("idle");
|
|
845
|
+
expect(cell.lastCodeRun).toBe(null);
|
|
846
|
+
expect(cell.edited).toBe(true);
|
|
847
|
+
|
|
848
|
+
// Run
|
|
849
|
+
actions.prepareForRun({
|
|
850
|
+
cellId: firstCellId,
|
|
851
|
+
});
|
|
852
|
+
actions.handleCellMessage({
|
|
853
|
+
cell_id: firstCellId,
|
|
854
|
+
output: {
|
|
855
|
+
channel: "output",
|
|
856
|
+
mimetype: "text/plain",
|
|
857
|
+
data: "ok",
|
|
858
|
+
timestamp: 0,
|
|
859
|
+
},
|
|
860
|
+
console: {
|
|
861
|
+
channel: "stdout",
|
|
862
|
+
mimetype: "text/plain",
|
|
863
|
+
data: "hello!",
|
|
864
|
+
timestamp: 0,
|
|
865
|
+
},
|
|
866
|
+
status: "idle",
|
|
867
|
+
stale_inputs: null,
|
|
868
|
+
timestamp: new Date(33).getTime() as Seconds,
|
|
869
|
+
});
|
|
870
|
+
|
|
871
|
+
// Check steady state
|
|
872
|
+
cell = cells[0];
|
|
873
|
+
expect(cell.status).toBe("idle");
|
|
874
|
+
expect(cell.edited).toBe(false);
|
|
875
|
+
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
876
|
+
|
|
877
|
+
// Format code
|
|
878
|
+
actions.updateCellCode({
|
|
879
|
+
cellId: firstCellId,
|
|
880
|
+
code: "import marimo as mo",
|
|
881
|
+
formattingChange: true,
|
|
882
|
+
});
|
|
883
|
+
cell = cells[0];
|
|
884
|
+
expect(cell.status).toBe("idle");
|
|
885
|
+
expect(cell.lastCodeRun).toBe("import marimo as mo");
|
|
886
|
+
expect(cell.edited).toBe(false);
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
it("can update a cells config", () => {
|
|
890
|
+
const firstCellId = cells[0].id;
|
|
891
|
+
let cell = cells[0];
|
|
892
|
+
// Starts empty
|
|
893
|
+
expect(cell.config).toEqual({
|
|
894
|
+
disabled: false,
|
|
895
|
+
hide_code: false,
|
|
896
|
+
column: null,
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
actions.updateCellConfig({
|
|
900
|
+
cellId: firstCellId,
|
|
901
|
+
config: { disabled: true },
|
|
902
|
+
});
|
|
903
|
+
cell = cells[0];
|
|
904
|
+
expect(cell.config.disabled).toBe(true);
|
|
905
|
+
|
|
906
|
+
// Revert
|
|
907
|
+
actions.updateCellConfig({
|
|
908
|
+
cellId: firstCellId,
|
|
909
|
+
config: { disabled: false },
|
|
910
|
+
});
|
|
911
|
+
cell = cells[0];
|
|
912
|
+
expect(cell.config.disabled).toBe(false);
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
it("can run a stopped cell", () => {
|
|
916
|
+
// Update code of first cell
|
|
917
|
+
actions.updateCellCode({
|
|
918
|
+
cellId: firstCellId,
|
|
919
|
+
code: "mo.md('This has an ancestor that was stopped')",
|
|
920
|
+
formattingChange: false,
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
// Prepare for run
|
|
924
|
+
actions.prepareForRun({
|
|
925
|
+
cellId: firstCellId,
|
|
926
|
+
});
|
|
927
|
+
|
|
928
|
+
// Receive queued messages
|
|
929
|
+
actions.handleCellMessage({
|
|
930
|
+
cell_id: firstCellId,
|
|
931
|
+
output: undefined,
|
|
932
|
+
console: null,
|
|
933
|
+
status: "queued",
|
|
934
|
+
stale_inputs: null,
|
|
935
|
+
timestamp: new Date(10).getTime() as Seconds,
|
|
936
|
+
});
|
|
937
|
+
let cell = cells[0];
|
|
938
|
+
expect(cell.status).toBe("queued");
|
|
939
|
+
expect(cell.lastCodeRun).toBe(
|
|
940
|
+
"mo.md('This has an ancestor that was stopped')",
|
|
941
|
+
);
|
|
942
|
+
expect(cell.edited).toBe(false);
|
|
943
|
+
expect(cell.runElapsedTimeMs).toBe(null);
|
|
944
|
+
expect(cell.runStartTimestamp).toBe(null);
|
|
945
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
946
|
+
|
|
947
|
+
// Receive idle message
|
|
948
|
+
actions.handleCellMessage({
|
|
949
|
+
cell_id: firstCellId,
|
|
950
|
+
output: undefined,
|
|
951
|
+
console: null,
|
|
952
|
+
status: "idle",
|
|
953
|
+
stale_inputs: null,
|
|
954
|
+
timestamp: new Date(20).getTime() as Seconds,
|
|
955
|
+
});
|
|
956
|
+
cell = cells[0];
|
|
957
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
958
|
+
|
|
959
|
+
// Receive stop output
|
|
960
|
+
actions.handleCellMessage({
|
|
961
|
+
cell_id: firstCellId,
|
|
962
|
+
output: {
|
|
963
|
+
channel: "marimo-error",
|
|
964
|
+
mimetype: "application/vnd.marimo+error",
|
|
965
|
+
data: [
|
|
966
|
+
{
|
|
967
|
+
msg: "This cell wasn't run because an ancestor was stopped with `mo.stop`: ",
|
|
968
|
+
raising_cell: "2" as CellId,
|
|
969
|
+
type: "ancestor-stopped",
|
|
970
|
+
},
|
|
971
|
+
],
|
|
972
|
+
timestamp: new Date(20).getTime() as Seconds,
|
|
973
|
+
},
|
|
974
|
+
console: null,
|
|
975
|
+
status: "idle",
|
|
976
|
+
stale_inputs: null,
|
|
977
|
+
timestamp: new Date(20).getTime() as Seconds,
|
|
978
|
+
});
|
|
979
|
+
cell = cells[0];
|
|
980
|
+
expect(cell.status).toBe("idle");
|
|
981
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
982
|
+
expect((cell.output?.data as any)[0].msg).toBe(
|
|
983
|
+
"This cell wasn't run because an ancestor was stopped with `mo.stop`: ",
|
|
984
|
+
);
|
|
985
|
+
expect(cell.stopped).toBe(true);
|
|
986
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
987
|
+
|
|
988
|
+
// Receive queued message
|
|
989
|
+
actions.handleCellMessage({
|
|
990
|
+
cell_id: firstCellId,
|
|
991
|
+
output: undefined,
|
|
992
|
+
console: null,
|
|
993
|
+
status: "queued",
|
|
994
|
+
stale_inputs: null,
|
|
995
|
+
timestamp: new Date(30).getTime() as Seconds,
|
|
996
|
+
});
|
|
997
|
+
cell = cells[0];
|
|
998
|
+
expect(cell.status).toBe("queued");
|
|
999
|
+
expect(cell.stopped).toBe(true);
|
|
1000
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1001
|
+
|
|
1002
|
+
// Receive running message
|
|
1003
|
+
actions.handleCellMessage({
|
|
1004
|
+
cell_id: firstCellId,
|
|
1005
|
+
output: undefined,
|
|
1006
|
+
console: null,
|
|
1007
|
+
status: "running",
|
|
1008
|
+
stale_inputs: null,
|
|
1009
|
+
timestamp: new Date(40).getTime() as Seconds,
|
|
1010
|
+
});
|
|
1011
|
+
cell = cells[0];
|
|
1012
|
+
expect(cell.status).toBe("running");
|
|
1013
|
+
expect(cell.stopped).toBe(false);
|
|
1014
|
+
expect(cell.output).toBe(null);
|
|
1015
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
it("can initialize stdin", () => {
|
|
1019
|
+
const STDOUT: OutputMessage = {
|
|
1020
|
+
channel: "stdout",
|
|
1021
|
+
mimetype: "text/plain",
|
|
1022
|
+
data: "hello!",
|
|
1023
|
+
timestamp: 1,
|
|
1024
|
+
};
|
|
1025
|
+
const STD_IN_1: OutputMessage = {
|
|
1026
|
+
channel: "stdin",
|
|
1027
|
+
mimetype: "text/plain",
|
|
1028
|
+
data: "what is your name?",
|
|
1029
|
+
timestamp: 2,
|
|
1030
|
+
};
|
|
1031
|
+
const STD_IN_2: OutputMessage = {
|
|
1032
|
+
channel: "stdin",
|
|
1033
|
+
mimetype: "text/plain",
|
|
1034
|
+
data: "how old are you?",
|
|
1035
|
+
timestamp: 3,
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
// Initial state
|
|
1039
|
+
let cell = cells[0];
|
|
1040
|
+
expect(cell.status).toBe("idle");
|
|
1041
|
+
expect(cell.consoleOutputs).toEqual([]);
|
|
1042
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1043
|
+
|
|
1044
|
+
// Prepare for run
|
|
1045
|
+
actions.prepareForRun({
|
|
1046
|
+
cellId: firstCellId,
|
|
1047
|
+
});
|
|
1048
|
+
cell = cells[0];
|
|
1049
|
+
expect(cell.status).toBe("queued");
|
|
1050
|
+
expect(cell.consoleOutputs).toEqual([]);
|
|
1051
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1052
|
+
|
|
1053
|
+
// Receive queued messages
|
|
1054
|
+
actions.handleCellMessage({
|
|
1055
|
+
cell_id: firstCellId,
|
|
1056
|
+
output: undefined,
|
|
1057
|
+
console: null,
|
|
1058
|
+
status: "queued",
|
|
1059
|
+
stale_inputs: null,
|
|
1060
|
+
timestamp: new Date(10).getTime() as Seconds,
|
|
1061
|
+
});
|
|
1062
|
+
cell = cells[0];
|
|
1063
|
+
expect(cell.status).toBe("queued");
|
|
1064
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1065
|
+
|
|
1066
|
+
// Receive running messages
|
|
1067
|
+
actions.handleCellMessage({
|
|
1068
|
+
cell_id: firstCellId,
|
|
1069
|
+
output: undefined,
|
|
1070
|
+
console: null,
|
|
1071
|
+
status: "running",
|
|
1072
|
+
stale_inputs: null,
|
|
1073
|
+
timestamp: new Date(20).getTime() as Seconds,
|
|
1074
|
+
});
|
|
1075
|
+
cell = cells[0];
|
|
1076
|
+
expect(cell.status).toBe("running");
|
|
1077
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1078
|
+
|
|
1079
|
+
// Add console
|
|
1080
|
+
actions.handleCellMessage({
|
|
1081
|
+
cell_id: firstCellId,
|
|
1082
|
+
output: undefined,
|
|
1083
|
+
console: STDOUT,
|
|
1084
|
+
status: undefined,
|
|
1085
|
+
stale_inputs: null,
|
|
1086
|
+
timestamp: new Date(22).getTime() as Seconds,
|
|
1087
|
+
});
|
|
1088
|
+
cell = cells[0];
|
|
1089
|
+
expect(cell.status).toBe("running");
|
|
1090
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1091
|
+
|
|
1092
|
+
cell = cells[0];
|
|
1093
|
+
expect(cell.consoleOutputs).toEqual([STDOUT]);
|
|
1094
|
+
expect(cell.status).toBe("running");
|
|
1095
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1096
|
+
|
|
1097
|
+
// Ask via stdin
|
|
1098
|
+
actions.handleCellMessage({
|
|
1099
|
+
cell_id: firstCellId,
|
|
1100
|
+
output: undefined,
|
|
1101
|
+
console: STD_IN_1,
|
|
1102
|
+
status: undefined,
|
|
1103
|
+
stale_inputs: null,
|
|
1104
|
+
timestamp: new Date(22).getTime() as Seconds,
|
|
1105
|
+
});
|
|
1106
|
+
cell = cells[0];
|
|
1107
|
+
expect(cell.consoleOutputs).toEqual([STDOUT, STD_IN_1]);
|
|
1108
|
+
expect(cell.status).toBe("running");
|
|
1109
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1110
|
+
|
|
1111
|
+
// Response to stdin
|
|
1112
|
+
actions.setStdinResponse({
|
|
1113
|
+
response: "Marimo!",
|
|
1114
|
+
cellId: firstCellId,
|
|
1115
|
+
outputIndex: 1,
|
|
1116
|
+
});
|
|
1117
|
+
cell = cells[0];
|
|
1118
|
+
expect(cell.consoleOutputs).toEqual([
|
|
1119
|
+
STDOUT,
|
|
1120
|
+
{
|
|
1121
|
+
...STD_IN_1,
|
|
1122
|
+
response: "Marimo!",
|
|
1123
|
+
},
|
|
1124
|
+
]);
|
|
1125
|
+
expect(cell.status).toBe("running");
|
|
1126
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1127
|
+
|
|
1128
|
+
// Ask via stdin, again
|
|
1129
|
+
actions.handleCellMessage({
|
|
1130
|
+
cell_id: firstCellId,
|
|
1131
|
+
output: undefined,
|
|
1132
|
+
console: STD_IN_2,
|
|
1133
|
+
status: undefined,
|
|
1134
|
+
stale_inputs: null,
|
|
1135
|
+
timestamp: new Date(22).getTime() as Seconds,
|
|
1136
|
+
});
|
|
1137
|
+
cell = cells[0];
|
|
1138
|
+
expect(cell.consoleOutputs).toEqual([
|
|
1139
|
+
STDOUT,
|
|
1140
|
+
{ ...STD_IN_1, response: "Marimo!" },
|
|
1141
|
+
STD_IN_2,
|
|
1142
|
+
]);
|
|
1143
|
+
expect(cell.status).toBe("running");
|
|
1144
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1145
|
+
|
|
1146
|
+
// Interrupt, so we respond with ""
|
|
1147
|
+
actions.handleCellMessage({
|
|
1148
|
+
cell_id: firstCellId,
|
|
1149
|
+
output: {
|
|
1150
|
+
channel: "marimo-error",
|
|
1151
|
+
mimetype: "application/vnd.marimo+error",
|
|
1152
|
+
data: [{ type: "interruption" }],
|
|
1153
|
+
timestamp: 0,
|
|
1154
|
+
},
|
|
1155
|
+
console: null,
|
|
1156
|
+
status: "idle",
|
|
1157
|
+
stale_inputs: null,
|
|
1158
|
+
timestamp: new Date(61).getTime() as Seconds,
|
|
1159
|
+
});
|
|
1160
|
+
cell = cells[0];
|
|
1161
|
+
expect(cell.status).toBe("idle");
|
|
1162
|
+
expect(cell.consoleOutputs).toEqual([
|
|
1163
|
+
STDOUT,
|
|
1164
|
+
{ ...STD_IN_1, response: "Marimo!" },
|
|
1165
|
+
{ ...STD_IN_2, response: "" },
|
|
1166
|
+
]);
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1169
|
+
it("can receive console when the cell is idle and will clear when starts again", () => {
|
|
1170
|
+
const OLD_STDOUT: OutputMessage = {
|
|
1171
|
+
channel: "stdout",
|
|
1172
|
+
mimetype: "text/plain",
|
|
1173
|
+
data: "hello!",
|
|
1174
|
+
timestamp: 1,
|
|
1175
|
+
};
|
|
1176
|
+
const STDOUT: OutputMessage = {
|
|
1177
|
+
channel: "stdin",
|
|
1178
|
+
mimetype: "text/plain",
|
|
1179
|
+
data: "hello again!",
|
|
1180
|
+
timestamp: 2,
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
// Initial state
|
|
1184
|
+
let cell = cells[0];
|
|
1185
|
+
expect(cell.status).toBe("idle");
|
|
1186
|
+
expect(cell.consoleOutputs).toEqual([]);
|
|
1187
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1188
|
+
|
|
1189
|
+
// Add console
|
|
1190
|
+
actions.handleCellMessage({
|
|
1191
|
+
cell_id: firstCellId,
|
|
1192
|
+
output: undefined,
|
|
1193
|
+
console: [OLD_STDOUT],
|
|
1194
|
+
status: undefined,
|
|
1195
|
+
stale_inputs: null,
|
|
1196
|
+
timestamp: new Date(1).getTime() as Seconds,
|
|
1197
|
+
});
|
|
1198
|
+
|
|
1199
|
+
// Prepare for run
|
|
1200
|
+
actions.prepareForRun({
|
|
1201
|
+
cellId: firstCellId,
|
|
1202
|
+
});
|
|
1203
|
+
cell = cells[0];
|
|
1204
|
+
expect(cell.status).toBe("queued");
|
|
1205
|
+
expect(cell.consoleOutputs).toEqual([OLD_STDOUT]); // Old stays there until it starts running
|
|
1206
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1207
|
+
|
|
1208
|
+
// Receive queued messages
|
|
1209
|
+
actions.handleCellMessage({
|
|
1210
|
+
cell_id: firstCellId,
|
|
1211
|
+
output: undefined,
|
|
1212
|
+
console: null,
|
|
1213
|
+
status: "queued",
|
|
1214
|
+
stale_inputs: null,
|
|
1215
|
+
timestamp: new Date(10).getTime() as Seconds,
|
|
1216
|
+
});
|
|
1217
|
+
cell = cells[0];
|
|
1218
|
+
expect(cell.status).toBe("queued");
|
|
1219
|
+
expect(cell.consoleOutputs).toEqual([OLD_STDOUT]); // Old stays there until it starts running
|
|
1220
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1221
|
+
|
|
1222
|
+
// Receive running messages
|
|
1223
|
+
actions.handleCellMessage({
|
|
1224
|
+
cell_id: firstCellId,
|
|
1225
|
+
output: undefined,
|
|
1226
|
+
console: [], // Backend sends an empty array to clearu
|
|
1227
|
+
status: "running",
|
|
1228
|
+
stale_inputs: null,
|
|
1229
|
+
timestamp: new Date(20).getTime() as Seconds,
|
|
1230
|
+
});
|
|
1231
|
+
cell = cells[0];
|
|
1232
|
+
expect(cell.status).toBe("running");
|
|
1233
|
+
expect(cell.consoleOutputs).toEqual([]);
|
|
1234
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1235
|
+
|
|
1236
|
+
// Add console
|
|
1237
|
+
actions.handleCellMessage({
|
|
1238
|
+
cell_id: firstCellId,
|
|
1239
|
+
output: undefined,
|
|
1240
|
+
console: [STDOUT],
|
|
1241
|
+
status: "idle",
|
|
1242
|
+
stale_inputs: null,
|
|
1243
|
+
timestamp: new Date(22).getTime() as Seconds,
|
|
1244
|
+
});
|
|
1245
|
+
cell = cells[0];
|
|
1246
|
+
expect(cell.consoleOutputs).toEqual([STDOUT]);
|
|
1247
|
+
expect(cell.status).toBe("idle");
|
|
1248
|
+
expect(cell).toMatchSnapshot(); // snapshot everything as a catch all
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
it("can send a cell to the top", () => {
|
|
1252
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1253
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1254
|
+
actions.sendToTop({ cellId: "2" as CellId });
|
|
1255
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1256
|
+
"
|
|
1257
|
+
[2] ''
|
|
1258
|
+
|
|
1259
|
+
[0] ''
|
|
1260
|
+
|
|
1261
|
+
[1] ''
|
|
1262
|
+
"
|
|
1263
|
+
`);
|
|
1264
|
+
});
|
|
1265
|
+
|
|
1266
|
+
it("can send a cell to the bottom", () => {
|
|
1267
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1268
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1269
|
+
actions.sendToBottom({ cellId: firstCellId });
|
|
1270
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1271
|
+
"
|
|
1272
|
+
[1] ''
|
|
1273
|
+
|
|
1274
|
+
[2] ''
|
|
1275
|
+
|
|
1276
|
+
[0] ''
|
|
1277
|
+
"
|
|
1278
|
+
`);
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1281
|
+
it("can focus cells", () => {
|
|
1282
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1283
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1284
|
+
|
|
1285
|
+
actions.focusCell({ cellId: "1" as CellId, where: "before" });
|
|
1286
|
+
expect(focusAndScrollCellIntoView).toHaveBeenCalledWith(
|
|
1287
|
+
expect.objectContaining({
|
|
1288
|
+
cellId: "0" as CellId,
|
|
1289
|
+
}),
|
|
1290
|
+
);
|
|
1291
|
+
|
|
1292
|
+
actions.focusTopCell();
|
|
1293
|
+
expect(scrollToTop).toHaveBeenCalled();
|
|
1294
|
+
|
|
1295
|
+
actions.focusBottomCell();
|
|
1296
|
+
expect(scrollToBottom).toHaveBeenCalled();
|
|
1297
|
+
});
|
|
1298
|
+
|
|
1299
|
+
it("can update cell name", () => {
|
|
1300
|
+
actions.updateCellName({ cellId: firstCellId, name: "Test Cell" });
|
|
1301
|
+
expect(state.cellData[firstCellId].name).toBe("Test Cell");
|
|
1302
|
+
});
|
|
1303
|
+
|
|
1304
|
+
it("can set cell IDs and codes", () => {
|
|
1305
|
+
const newIds = ["3", "4", "5"] as CellId[];
|
|
1306
|
+
const newCodes = ["code1", "code2", "code3"];
|
|
1307
|
+
|
|
1308
|
+
actions.setCellIds({ cellIds: newIds });
|
|
1309
|
+
expect(state.cellIds.atOrThrow(FIRST_COLUMN).topLevelIds).toEqual(newIds);
|
|
1310
|
+
|
|
1311
|
+
// When codeIsStale is false, lastCodeRun should match code
|
|
1312
|
+
actions.setCellCodes({
|
|
1313
|
+
codes: newCodes,
|
|
1314
|
+
ids: newIds,
|
|
1315
|
+
codeIsStale: false,
|
|
1316
|
+
});
|
|
1317
|
+
newIds.forEach((id, index) => {
|
|
1318
|
+
expect(state.cellData[id].code).toBe(newCodes[index]);
|
|
1319
|
+
expect(state.cellData[id].lastCodeRun).toBe(newCodes[index]);
|
|
1320
|
+
expect(state.cellData[id].edited).toBe(false);
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
// When codeIsStale is true, lastCodeRun should not change
|
|
1324
|
+
const staleCodes = ["stale1", "stale2", "stale3"];
|
|
1325
|
+
actions.setCellCodes({
|
|
1326
|
+
codes: staleCodes,
|
|
1327
|
+
ids: newIds,
|
|
1328
|
+
codeIsStale: true,
|
|
1329
|
+
});
|
|
1330
|
+
newIds.forEach((id, index) => {
|
|
1331
|
+
expect(state.cellData[id].code).toBe(staleCodes[index]);
|
|
1332
|
+
expect(state.cellData[id].lastCodeRun).toBe(newCodes[index]);
|
|
1333
|
+
expect(state.cellData[id].edited).toBe(true);
|
|
1334
|
+
});
|
|
1335
|
+
});
|
|
1336
|
+
|
|
1337
|
+
it("can can add a new cell with/without stale code", () => {
|
|
1338
|
+
actions.setCellCodes({
|
|
1339
|
+
codes: ["new code"],
|
|
1340
|
+
ids: ["2"] as CellId[],
|
|
1341
|
+
codeIsStale: false,
|
|
1342
|
+
});
|
|
1343
|
+
|
|
1344
|
+
expect(state.cellData["2" as CellId].code).toBe("new code");
|
|
1345
|
+
expect(state.cellData["2" as CellId].edited).toBe(false);
|
|
1346
|
+
expect(state.cellData["2" as CellId].lastCodeRun).toBe("new code");
|
|
1347
|
+
|
|
1348
|
+
actions.setCellCodes({
|
|
1349
|
+
codes: ["new code 2"],
|
|
1350
|
+
ids: ["9"] as CellId[],
|
|
1351
|
+
codeIsStale: true,
|
|
1352
|
+
});
|
|
1353
|
+
|
|
1354
|
+
expect(state.cellData["9" as CellId].code).toBe("new code 2");
|
|
1355
|
+
expect(state.cellData["9" as CellId].edited).toBe(true);
|
|
1356
|
+
expect(state.cellData["9" as CellId].lastCodeRun).toBe(null);
|
|
1357
|
+
});
|
|
1358
|
+
|
|
1359
|
+
it("can partial update cell codes", () => {
|
|
1360
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1361
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1362
|
+
|
|
1363
|
+
expect(state.cellIds.inOrderIds).toEqual(["0", "1", "2"]);
|
|
1364
|
+
expect(state.cellData["0" as CellId].code).toBe("");
|
|
1365
|
+
expect(state.cellData["1" as CellId].code).toBe("");
|
|
1366
|
+
expect(state.cellData["2" as CellId].code).toBe("");
|
|
1367
|
+
|
|
1368
|
+
// Update cell 1
|
|
1369
|
+
actions.setCellCodes({
|
|
1370
|
+
codes: ["new code 2"],
|
|
1371
|
+
ids: ["1"] as CellId[],
|
|
1372
|
+
codeIsStale: false,
|
|
1373
|
+
});
|
|
1374
|
+
|
|
1375
|
+
expect(state.cellIds.inOrderIds).toEqual(["0", "1", "2"]);
|
|
1376
|
+
expect(state.cellData["0" as CellId].code).toBe("");
|
|
1377
|
+
expect(state.cellData["1" as CellId].code).toBe("new code 2");
|
|
1378
|
+
expect(state.cellData["1" as CellId].edited).toBe(false);
|
|
1379
|
+
expect(state.cellData["2" as CellId].code).toBe("");
|
|
1380
|
+
});
|
|
1381
|
+
|
|
1382
|
+
it("can set cell codes with new cell ids, while preserving the old cell data", () => {
|
|
1383
|
+
actions.setCellCodes({
|
|
1384
|
+
codes: ["code1", "code2", "code3"],
|
|
1385
|
+
ids: ["3", "4", "5"] as CellId[],
|
|
1386
|
+
codeIsStale: false,
|
|
1387
|
+
});
|
|
1388
|
+
expect(state.cellData["3" as CellId].code).toBe("code1");
|
|
1389
|
+
expect(state.cellData["4" as CellId].code).toBe("code2");
|
|
1390
|
+
expect(state.cellData["5" as CellId].code).toBe("code3");
|
|
1391
|
+
|
|
1392
|
+
// Update with some new cell ids and some old cell ids
|
|
1393
|
+
actions.setCellIds({ cellIds: ["1", "2", "3", "4"] as CellId[] });
|
|
1394
|
+
actions.setCellCodes({
|
|
1395
|
+
codes: ["new1", "new2", "code1", "code2"],
|
|
1396
|
+
ids: ["1", "2", "3", "4"] as CellId[],
|
|
1397
|
+
codeIsStale: false,
|
|
1398
|
+
});
|
|
1399
|
+
expect(state.cellData["1" as CellId].code).toBe("new1");
|
|
1400
|
+
expect(state.cellData["2" as CellId].code).toBe("new2");
|
|
1401
|
+
expect(state.cellData["3" as CellId].code).toBe("code1");
|
|
1402
|
+
expect(state.cellData["4" as CellId].code).toBe("code2");
|
|
1403
|
+
expect(state.cellIds.inOrderIds).toEqual(["1", "2", "3", "4"]);
|
|
1404
|
+
// Cell 5 data is preserved (possibly used for tracing), but it's not in the cellIds
|
|
1405
|
+
expect(state.cellData["5" as CellId]).not.toBeUndefined();
|
|
1406
|
+
});
|
|
1407
|
+
|
|
1408
|
+
it("can fold and unfold all cells", () => {
|
|
1409
|
+
actions.foldAll();
|
|
1410
|
+
expect(foldAllBulk).toHaveBeenCalled();
|
|
1411
|
+
|
|
1412
|
+
actions.unfoldAll();
|
|
1413
|
+
expect(unfoldAllBulk).toHaveBeenCalled();
|
|
1414
|
+
});
|
|
1415
|
+
|
|
1416
|
+
it("can clear logs", () => {
|
|
1417
|
+
state.cellLogs = [
|
|
1418
|
+
{ level: "stderr", message: "log1", timestamp: 0, cellId: firstCellId },
|
|
1419
|
+
{ level: "stderr", message: "log1", timestamp: 0, cellId: firstCellId },
|
|
1420
|
+
];
|
|
1421
|
+
actions.clearLogs();
|
|
1422
|
+
expect(state.cellLogs).toEqual([]);
|
|
1423
|
+
});
|
|
1424
|
+
|
|
1425
|
+
it("can collapse and expand cells", () => {
|
|
1426
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1427
|
+
actions.createNewCell({
|
|
1428
|
+
cellId: "1" as CellId,
|
|
1429
|
+
before: false,
|
|
1430
|
+
code: "# Header",
|
|
1431
|
+
});
|
|
1432
|
+
actions.createNewCell({
|
|
1433
|
+
cellId: "2" as CellId,
|
|
1434
|
+
before: false,
|
|
1435
|
+
code: "## Subheader",
|
|
1436
|
+
});
|
|
1437
|
+
|
|
1438
|
+
const id = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(1);
|
|
1439
|
+
state.cellRuntime[id] = {
|
|
1440
|
+
...state.cellRuntime[id],
|
|
1441
|
+
outline: {
|
|
1442
|
+
items: [{ name: "Header", level: 1, by: { id: "header" } }],
|
|
1443
|
+
},
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
actions.collapseCell({ cellId: id });
|
|
1447
|
+
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(id)).toBe(true);
|
|
1448
|
+
|
|
1449
|
+
actions.expandCell({ cellId: id });
|
|
1450
|
+
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(id)).toBe(false);
|
|
1451
|
+
});
|
|
1452
|
+
|
|
1453
|
+
it("can collapse and expand all cells in multiple columns", () => {
|
|
1454
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1455
|
+
actions.createNewCell({
|
|
1456
|
+
cellId: "1" as CellId,
|
|
1457
|
+
before: false,
|
|
1458
|
+
code: "# First Column Header",
|
|
1459
|
+
});
|
|
1460
|
+
actions.createNewCell({
|
|
1461
|
+
cellId: "2" as CellId,
|
|
1462
|
+
before: false,
|
|
1463
|
+
code: "## First Column Subheader",
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1466
|
+
actions.addColumnBreakpoint({ cellId: "2" as CellId });
|
|
1467
|
+
|
|
1468
|
+
actions.createNewCell({
|
|
1469
|
+
cellId: "3" as CellId,
|
|
1470
|
+
before: false,
|
|
1471
|
+
code: "# Second Column Header",
|
|
1472
|
+
});
|
|
1473
|
+
actions.createNewCell({
|
|
1474
|
+
cellId: "4" as CellId,
|
|
1475
|
+
before: false,
|
|
1476
|
+
code: "## Second Column Subheader",
|
|
1477
|
+
});
|
|
1478
|
+
|
|
1479
|
+
const firstColumnHeaderId = state.cellIds
|
|
1480
|
+
.atOrThrow(FIRST_COLUMN)
|
|
1481
|
+
.atOrThrow(1);
|
|
1482
|
+
state.cellRuntime[firstColumnHeaderId] = {
|
|
1483
|
+
...state.cellRuntime[firstColumnHeaderId],
|
|
1484
|
+
outline: {
|
|
1485
|
+
items: [
|
|
1486
|
+
{ name: "First Column Header", level: 1, by: { id: "header" } },
|
|
1487
|
+
],
|
|
1488
|
+
},
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
const secondColumnHeaderId = state.cellIds
|
|
1492
|
+
.atOrThrow(SECOND_COLUMN)
|
|
1493
|
+
.atOrThrow(0);
|
|
1494
|
+
state.cellRuntime[secondColumnHeaderId] = {
|
|
1495
|
+
...state.cellRuntime[secondColumnHeaderId],
|
|
1496
|
+
outline: {
|
|
1497
|
+
items: [
|
|
1498
|
+
{ name: "Second Column Header", level: 1, by: { id: "header" } },
|
|
1499
|
+
],
|
|
1500
|
+
},
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
actions.collapseAllCells();
|
|
1504
|
+
expect(
|
|
1505
|
+
state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(firstColumnHeaderId),
|
|
1506
|
+
).toBe(true);
|
|
1507
|
+
expect(
|
|
1508
|
+
state.cellIds.atOrThrow(SECOND_COLUMN).isCollapsed(secondColumnHeaderId),
|
|
1509
|
+
).toBe(true);
|
|
1510
|
+
|
|
1511
|
+
actions.expandAllCells();
|
|
1512
|
+
expect(
|
|
1513
|
+
state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(firstColumnHeaderId),
|
|
1514
|
+
).toBe(false);
|
|
1515
|
+
expect(
|
|
1516
|
+
state.cellIds.atOrThrow(SECOND_COLUMN).isCollapsed(secondColumnHeaderId),
|
|
1517
|
+
).toBe(false);
|
|
1518
|
+
});
|
|
1519
|
+
|
|
1520
|
+
it("can collapse and expand nested cells in one call", () => {
|
|
1521
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1522
|
+
actions.createNewCell({
|
|
1523
|
+
cellId: "1" as CellId,
|
|
1524
|
+
before: false,
|
|
1525
|
+
code: "# Header",
|
|
1526
|
+
});
|
|
1527
|
+
actions.createNewCell({
|
|
1528
|
+
cellId: "2" as CellId,
|
|
1529
|
+
before: false,
|
|
1530
|
+
code: "## Subheader",
|
|
1531
|
+
});
|
|
1532
|
+
actions.createNewCell({
|
|
1533
|
+
cellId: "3" as CellId,
|
|
1534
|
+
before: false,
|
|
1535
|
+
code: "### Subsubheader",
|
|
1536
|
+
});
|
|
1537
|
+
|
|
1538
|
+
const headerId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(1);
|
|
1539
|
+
state.cellRuntime[headerId] = {
|
|
1540
|
+
...state.cellRuntime[headerId],
|
|
1541
|
+
outline: {
|
|
1542
|
+
items: [{ name: "Header", level: 1, by: { id: "header" } }],
|
|
1543
|
+
},
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
const subheaderId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(2);
|
|
1547
|
+
state.cellRuntime[subheaderId] = {
|
|
1548
|
+
...state.cellRuntime[subheaderId],
|
|
1549
|
+
outline: {
|
|
1550
|
+
items: [{ name: "Subheader", level: 2, by: { id: "subheader" } }],
|
|
1551
|
+
},
|
|
1552
|
+
};
|
|
1553
|
+
|
|
1554
|
+
// Check if both the parent and child are collapsed
|
|
1555
|
+
actions.collapseAllCells();
|
|
1556
|
+
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(headerId)).toBe(
|
|
1557
|
+
true,
|
|
1558
|
+
);
|
|
1559
|
+
actions.expandCell({ cellId: headerId });
|
|
1560
|
+
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(subheaderId)).toBe(
|
|
1561
|
+
true,
|
|
1562
|
+
);
|
|
1563
|
+
actions.collapseCell({ cellId: headerId });
|
|
1564
|
+
|
|
1565
|
+
// Check if both the parent and child are expanded
|
|
1566
|
+
actions.expandAllCells();
|
|
1567
|
+
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(headerId)).toBe(
|
|
1568
|
+
false,
|
|
1569
|
+
);
|
|
1570
|
+
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(subheaderId)).toBe(
|
|
1571
|
+
false,
|
|
1572
|
+
);
|
|
1573
|
+
});
|
|
1574
|
+
|
|
1575
|
+
it("can show hidden cells", () => {
|
|
1576
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1577
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1578
|
+
actions.collapseCell({ cellId: firstCellId });
|
|
1579
|
+
|
|
1580
|
+
actions.showCellIfHidden({ cellId: "1" as CellId });
|
|
1581
|
+
expect(state.cellIds.atOrThrow(FIRST_COLUMN).isCollapsed(firstCellId)).toBe(
|
|
1582
|
+
false,
|
|
1583
|
+
);
|
|
1584
|
+
});
|
|
1585
|
+
|
|
1586
|
+
it("can split and undo split cells", () => {
|
|
1587
|
+
actions.createNewCell({
|
|
1588
|
+
cellId: firstCellId,
|
|
1589
|
+
before: false,
|
|
1590
|
+
code: "line1\nline2",
|
|
1591
|
+
});
|
|
1592
|
+
const nextCellId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(1);
|
|
1593
|
+
|
|
1594
|
+
const originalCellCount = state.cellIds.atOrThrow(FIRST_COLUMN).length;
|
|
1595
|
+
// Move cursor to the second line
|
|
1596
|
+
const editor = state.cellHandles[nextCellId].current?.editorView;
|
|
1597
|
+
if (!editor) {
|
|
1598
|
+
throw new Error("Editor not found");
|
|
1599
|
+
}
|
|
1600
|
+
editor.dispatch({ selection: { anchor: 5, head: 5 } });
|
|
1601
|
+
actions.splitCell({ cellId: nextCellId });
|
|
1602
|
+
expect(state.cellIds.atOrThrow(FIRST_COLUMN).length).toBe(
|
|
1603
|
+
originalCellCount + 1,
|
|
1604
|
+
);
|
|
1605
|
+
expect(state.cellData[nextCellId].code).toBe("line1");
|
|
1606
|
+
expect(
|
|
1607
|
+
state.cellData[state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(2)].code,
|
|
1608
|
+
).toBe("line2");
|
|
1609
|
+
|
|
1610
|
+
actions.undoSplitCell({ cellId: nextCellId, snapshot: "line1\nline2" });
|
|
1611
|
+
expect(state.cellIds.atOrThrow(FIRST_COLUMN).length).toBe(
|
|
1612
|
+
originalCellCount,
|
|
1613
|
+
);
|
|
1614
|
+
expect(state.cellData[nextCellId].code).toBe("line1\nline2");
|
|
1615
|
+
});
|
|
1616
|
+
|
|
1617
|
+
it("can handle multiple console outputs", () => {
|
|
1618
|
+
const STDOUT1: OutputMessage = {
|
|
1619
|
+
channel: "stdout",
|
|
1620
|
+
mimetype: "text/plain",
|
|
1621
|
+
data: "output1",
|
|
1622
|
+
timestamp: 1,
|
|
1623
|
+
};
|
|
1624
|
+
const STDOUT2: OutputMessage = {
|
|
1625
|
+
channel: "stdout",
|
|
1626
|
+
mimetype: "text/plain",
|
|
1627
|
+
data: "output2",
|
|
1628
|
+
timestamp: 2,
|
|
1629
|
+
};
|
|
1630
|
+
|
|
1631
|
+
actions.handleCellMessage({
|
|
1632
|
+
cell_id: firstCellId,
|
|
1633
|
+
output: undefined,
|
|
1634
|
+
console: [STDOUT1, STDOUT2],
|
|
1635
|
+
status: "running",
|
|
1636
|
+
stale_inputs: null,
|
|
1637
|
+
timestamp: new Date(20).getTime() as Seconds,
|
|
1638
|
+
});
|
|
1639
|
+
|
|
1640
|
+
const cell = cells[0];
|
|
1641
|
+
expect(cell.consoleOutputs).toEqual([STDOUT1, STDOUT2]);
|
|
1642
|
+
});
|
|
1643
|
+
|
|
1644
|
+
it("can add a column breakpoint", () => {
|
|
1645
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1646
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1647
|
+
actions.createNewCell({ cellId: "2" as CellId, before: false });
|
|
1648
|
+
|
|
1649
|
+
expect(state.cellIds.getColumns().length).toBe(1);
|
|
1650
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1651
|
+
"
|
|
1652
|
+
[0] ''
|
|
1653
|
+
|
|
1654
|
+
[1] ''
|
|
1655
|
+
|
|
1656
|
+
[2] ''
|
|
1657
|
+
|
|
1658
|
+
[3] ''
|
|
1659
|
+
"
|
|
1660
|
+
`);
|
|
1661
|
+
|
|
1662
|
+
actions.addColumnBreakpoint({ cellId: "2" as CellId });
|
|
1663
|
+
|
|
1664
|
+
expect(state.cellIds.getColumns().length).toBe(2);
|
|
1665
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1666
|
+
"
|
|
1667
|
+
> col 0
|
|
1668
|
+
[0] ''
|
|
1669
|
+
|
|
1670
|
+
[1] ''
|
|
1671
|
+
|
|
1672
|
+
> col 1
|
|
1673
|
+
[2] ''
|
|
1674
|
+
|
|
1675
|
+
[3] ''
|
|
1676
|
+
"
|
|
1677
|
+
`);
|
|
1678
|
+
|
|
1679
|
+
// Check that the cells are in the correct columns
|
|
1680
|
+
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual(["0", "1"]);
|
|
1681
|
+
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual(["2", "3"]);
|
|
1682
|
+
});
|
|
1683
|
+
|
|
1684
|
+
it("cannot add a column breakpoint before the first cell", () => {
|
|
1685
|
+
expect(state.cellIds.getColumns().length).toBe(1);
|
|
1686
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1687
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1688
|
+
actions.addColumnBreakpoint({ cellId: firstCellId });
|
|
1689
|
+
expect(state.cellIds.getColumns().length).toBe(1);
|
|
1690
|
+
});
|
|
1691
|
+
|
|
1692
|
+
it("can delete a column", () => {
|
|
1693
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1694
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1695
|
+
actions.createNewCell({ cellId: "2" as CellId, before: false });
|
|
1696
|
+
actions.addColumnBreakpoint({ cellId: "2" as CellId });
|
|
1697
|
+
|
|
1698
|
+
expect(state.cellIds.getColumns().length).toBe(2);
|
|
1699
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1700
|
+
"
|
|
1701
|
+
> col 0
|
|
1702
|
+
[0] ''
|
|
1703
|
+
|
|
1704
|
+
[1] ''
|
|
1705
|
+
|
|
1706
|
+
> col 1
|
|
1707
|
+
[2] ''
|
|
1708
|
+
|
|
1709
|
+
[3] ''
|
|
1710
|
+
"
|
|
1711
|
+
`);
|
|
1712
|
+
|
|
1713
|
+
const columnId = state.cellIds.atOrThrow(0).id;
|
|
1714
|
+
actions.deleteColumn({ columnId: columnId });
|
|
1715
|
+
|
|
1716
|
+
expect(state.cellIds.getColumns().length).toBe(1);
|
|
1717
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1718
|
+
"
|
|
1719
|
+
[2] ''
|
|
1720
|
+
|
|
1721
|
+
[3] ''
|
|
1722
|
+
|
|
1723
|
+
[0] ''
|
|
1724
|
+
|
|
1725
|
+
[1] ''
|
|
1726
|
+
"
|
|
1727
|
+
`);
|
|
1728
|
+
|
|
1729
|
+
// Check that all cells are now in the remaining column
|
|
1730
|
+
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual([
|
|
1731
|
+
"2",
|
|
1732
|
+
"3",
|
|
1733
|
+
"0",
|
|
1734
|
+
"1",
|
|
1735
|
+
]);
|
|
1736
|
+
});
|
|
1737
|
+
|
|
1738
|
+
it("deleting the last column does nothing", () => {
|
|
1739
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1740
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1741
|
+
|
|
1742
|
+
const initialState = { ...state };
|
|
1743
|
+
|
|
1744
|
+
actions.deleteColumn({ columnId: initialState.cellIds.atOrThrow(0).id });
|
|
1745
|
+
|
|
1746
|
+
// State should not change
|
|
1747
|
+
expect(state).toEqual(initialState);
|
|
1748
|
+
});
|
|
1749
|
+
|
|
1750
|
+
it("can drop a cell over another cell", () => {
|
|
1751
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1752
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1753
|
+
actions.createNewCell({ cellId: "2" as CellId, before: false });
|
|
1754
|
+
|
|
1755
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1756
|
+
"
|
|
1757
|
+
[0] ''
|
|
1758
|
+
|
|
1759
|
+
[1] ''
|
|
1760
|
+
|
|
1761
|
+
[2] ''
|
|
1762
|
+
|
|
1763
|
+
[3] ''
|
|
1764
|
+
"
|
|
1765
|
+
`);
|
|
1766
|
+
|
|
1767
|
+
actions.dropCellOverCell({
|
|
1768
|
+
cellId: "0" as CellId,
|
|
1769
|
+
overCellId: "3" as CellId,
|
|
1770
|
+
});
|
|
1771
|
+
|
|
1772
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1773
|
+
"
|
|
1774
|
+
[1] ''
|
|
1775
|
+
|
|
1776
|
+
[2] ''
|
|
1777
|
+
|
|
1778
|
+
[3] ''
|
|
1779
|
+
|
|
1780
|
+
[0] ''
|
|
1781
|
+
"
|
|
1782
|
+
`);
|
|
1783
|
+
});
|
|
1784
|
+
|
|
1785
|
+
it("can drop a cell over a new column", () => {
|
|
1786
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1787
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1788
|
+
|
|
1789
|
+
expect(state.cellIds.getColumns().length).toBe(1);
|
|
1790
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1791
|
+
"
|
|
1792
|
+
[0] ''
|
|
1793
|
+
|
|
1794
|
+
[1] ''
|
|
1795
|
+
|
|
1796
|
+
[2] ''
|
|
1797
|
+
"
|
|
1798
|
+
`);
|
|
1799
|
+
|
|
1800
|
+
actions.dropOverNewColumn({ cellId: "1" as CellId });
|
|
1801
|
+
|
|
1802
|
+
expect(state.cellIds.getColumns().length).toBe(2);
|
|
1803
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1804
|
+
"
|
|
1805
|
+
> col 0
|
|
1806
|
+
[0] ''
|
|
1807
|
+
|
|
1808
|
+
[2] ''
|
|
1809
|
+
|
|
1810
|
+
> col 1
|
|
1811
|
+
[1] ''
|
|
1812
|
+
"
|
|
1813
|
+
`);
|
|
1814
|
+
|
|
1815
|
+
// Check that the cells are in the correct columns
|
|
1816
|
+
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual(["0", "2"]);
|
|
1817
|
+
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual(["1"]);
|
|
1818
|
+
});
|
|
1819
|
+
|
|
1820
|
+
it("can drop a column over another column", () => {
|
|
1821
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1822
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1823
|
+
actions.createNewCell({ cellId: "2" as CellId, before: false });
|
|
1824
|
+
actions.addColumnBreakpoint({ cellId: "2" as CellId });
|
|
1825
|
+
|
|
1826
|
+
expect(state.cellIds.getColumns().length).toBe(2);
|
|
1827
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1828
|
+
"
|
|
1829
|
+
> col 0
|
|
1830
|
+
[0] ''
|
|
1831
|
+
|
|
1832
|
+
[1] ''
|
|
1833
|
+
|
|
1834
|
+
> col 1
|
|
1835
|
+
[2] ''
|
|
1836
|
+
|
|
1837
|
+
[3] ''
|
|
1838
|
+
"
|
|
1839
|
+
`);
|
|
1840
|
+
|
|
1841
|
+
const columnId0 = state.cellIds.atOrThrow(0).id;
|
|
1842
|
+
const columnId1 = state.cellIds.atOrThrow(1).id;
|
|
1843
|
+
expect(columnId0).not.toBe(columnId1);
|
|
1844
|
+
actions.moveColumn({ column: columnId1, overColumn: columnId0 });
|
|
1845
|
+
|
|
1846
|
+
expect(state.cellIds.getColumns().length).toBe(2);
|
|
1847
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1848
|
+
"
|
|
1849
|
+
> col 0
|
|
1850
|
+
[2] ''
|
|
1851
|
+
|
|
1852
|
+
[3] ''
|
|
1853
|
+
|
|
1854
|
+
> col 1
|
|
1855
|
+
[0] ''
|
|
1856
|
+
|
|
1857
|
+
[1] ''
|
|
1858
|
+
"
|
|
1859
|
+
`);
|
|
1860
|
+
|
|
1861
|
+
// Check that the columns have swapped positions
|
|
1862
|
+
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual(["2", "3"]);
|
|
1863
|
+
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual(["0", "1"]);
|
|
1864
|
+
});
|
|
1865
|
+
|
|
1866
|
+
it("can compact columns", () => {
|
|
1867
|
+
// Create initial state with 3 columns, including an empty one
|
|
1868
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
1869
|
+
actions.createNewCell({ cellId: "1" as CellId, before: false });
|
|
1870
|
+
actions.addColumnBreakpoint({ cellId: "1" as CellId });
|
|
1871
|
+
actions.addColumnBreakpoint({ cellId: "2" as CellId });
|
|
1872
|
+
actions.dropOverNewColumn({ cellId: "2" as CellId });
|
|
1873
|
+
|
|
1874
|
+
expect(state.cellIds.getColumns().length).toBe(4);
|
|
1875
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1876
|
+
"
|
|
1877
|
+
> col 0
|
|
1878
|
+
[0] ''
|
|
1879
|
+
|
|
1880
|
+
> col 1
|
|
1881
|
+
[1] ''
|
|
1882
|
+
|
|
1883
|
+
> col 2
|
|
1884
|
+
|
|
1885
|
+
|
|
1886
|
+
> col 3
|
|
1887
|
+
[2] ''
|
|
1888
|
+
"
|
|
1889
|
+
`);
|
|
1890
|
+
|
|
1891
|
+
// Check initial column structure
|
|
1892
|
+
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual(["0"]);
|
|
1893
|
+
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual(["1"]);
|
|
1894
|
+
expect(state.cellIds.getColumns()[2].topLevelIds).toEqual([]);
|
|
1895
|
+
expect(state.cellIds.getColumns()[3].topLevelIds).toEqual(["2"]);
|
|
1896
|
+
|
|
1897
|
+
// Compact columns
|
|
1898
|
+
actions.compactColumns();
|
|
1899
|
+
|
|
1900
|
+
expect(state.cellIds.getColumns().length).toBe(3);
|
|
1901
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
1902
|
+
"
|
|
1903
|
+
> col 0
|
|
1904
|
+
[0] ''
|
|
1905
|
+
|
|
1906
|
+
> col 1
|
|
1907
|
+
[1] ''
|
|
1908
|
+
|
|
1909
|
+
> col 2
|
|
1910
|
+
[2] ''
|
|
1911
|
+
"
|
|
1912
|
+
`);
|
|
1913
|
+
|
|
1914
|
+
// Check compacted column structure
|
|
1915
|
+
expect(state.cellIds.getColumns()[0].topLevelIds).toEqual(["0"]);
|
|
1916
|
+
expect(state.cellIds.getColumns()[1].topLevelIds).toEqual(["1"]);
|
|
1917
|
+
expect(state.cellIds.getColumns()[2].topLevelIds).toEqual(["2"]);
|
|
1918
|
+
});
|
|
1919
|
+
|
|
1920
|
+
it("can clear output of a single cell", () => {
|
|
1921
|
+
// Set up initial state with output
|
|
1922
|
+
actions.handleCellMessage({
|
|
1923
|
+
cell_id: firstCellId,
|
|
1924
|
+
output: {
|
|
1925
|
+
channel: "output",
|
|
1926
|
+
mimetype: "text/plain",
|
|
1927
|
+
data: "test output",
|
|
1928
|
+
timestamp: 0,
|
|
1929
|
+
},
|
|
1930
|
+
console: {
|
|
1931
|
+
channel: "stdout",
|
|
1932
|
+
mimetype: "text/plain",
|
|
1933
|
+
data: "console output",
|
|
1934
|
+
timestamp: 0,
|
|
1935
|
+
},
|
|
1936
|
+
status: "idle",
|
|
1937
|
+
stale_inputs: null,
|
|
1938
|
+
timestamp: new Date(33).getTime() as Seconds,
|
|
1939
|
+
});
|
|
1940
|
+
|
|
1941
|
+
// Verify initial state has output
|
|
1942
|
+
let cell = cells[0];
|
|
1943
|
+
expect(cell.output).not.toBeNull();
|
|
1944
|
+
expect(cell.consoleOutputs.length).toBe(1);
|
|
1945
|
+
|
|
1946
|
+
// Clear output
|
|
1947
|
+
actions.clearCellOutput({ cellId: firstCellId });
|
|
1948
|
+
|
|
1949
|
+
// Verify output is cleared
|
|
1950
|
+
cell = cells[0];
|
|
1951
|
+
expect(cell.output).toBeNull();
|
|
1952
|
+
expect(cell.consoleOutputs).toEqual([]);
|
|
1953
|
+
});
|
|
1954
|
+
|
|
1955
|
+
it("can clear console output of a single cell", () => {
|
|
1956
|
+
// Set up initial state with output
|
|
1957
|
+
actions.handleCellMessage({
|
|
1958
|
+
cell_id: firstCellId,
|
|
1959
|
+
output: {
|
|
1960
|
+
channel: "output",
|
|
1961
|
+
mimetype: "text/plain",
|
|
1962
|
+
data: "test output",
|
|
1963
|
+
timestamp: 0,
|
|
1964
|
+
},
|
|
1965
|
+
console: {
|
|
1966
|
+
channel: "stdout",
|
|
1967
|
+
mimetype: "text/plain",
|
|
1968
|
+
data: "console output",
|
|
1969
|
+
timestamp: 0,
|
|
1970
|
+
},
|
|
1971
|
+
status: "idle",
|
|
1972
|
+
stale_inputs: null,
|
|
1973
|
+
timestamp: new Date(33).getTime() as Seconds,
|
|
1974
|
+
});
|
|
1975
|
+
|
|
1976
|
+
// Add a stdin console output that should be preserved
|
|
1977
|
+
actions.handleCellMessage({
|
|
1978
|
+
cell_id: firstCellId,
|
|
1979
|
+
console: {
|
|
1980
|
+
channel: "stdin",
|
|
1981
|
+
mimetype: "text/plain",
|
|
1982
|
+
data: "stdin prompt",
|
|
1983
|
+
timestamp: 0,
|
|
1984
|
+
},
|
|
1985
|
+
status: "idle",
|
|
1986
|
+
stale_inputs: null,
|
|
1987
|
+
timestamp: new Date(34).getTime() as Seconds,
|
|
1988
|
+
});
|
|
1989
|
+
|
|
1990
|
+
// Verify initial state has output and console outputs
|
|
1991
|
+
let cell = cells[0];
|
|
1992
|
+
expect(cell.output).not.toBeNull();
|
|
1993
|
+
expect(cell.consoleOutputs.length).toBe(2);
|
|
1994
|
+
|
|
1995
|
+
// Clear console output
|
|
1996
|
+
actions.clearCellConsoleOutput({ cellId: firstCellId });
|
|
1997
|
+
|
|
1998
|
+
// Verify only console output is cleared, but stdin is preserved
|
|
1999
|
+
cell = cells[0];
|
|
2000
|
+
expect(cell.output).not.toBeNull(); // Output should remain
|
|
2001
|
+
expect(cell.consoleOutputs.length).toBe(1);
|
|
2002
|
+
expect(cell.consoleOutputs[0].channel).toBe("stdin");
|
|
2003
|
+
expect(cell.consoleOutputs[0].data).toBe("stdin prompt");
|
|
2004
|
+
});
|
|
2005
|
+
|
|
2006
|
+
it("can clear output of all cells", () => {
|
|
2007
|
+
// Create multiple cells with output
|
|
2008
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2009
|
+
const secondCellId = state.cellIds.atOrThrow(FIRST_COLUMN).atOrThrow(1);
|
|
2010
|
+
|
|
2011
|
+
// Add output to both cells
|
|
2012
|
+
const outputMessage = {
|
|
2013
|
+
output: {
|
|
2014
|
+
channel: "output",
|
|
2015
|
+
mimetype: "text/plain",
|
|
2016
|
+
data: "test output",
|
|
2017
|
+
timestamp: 0,
|
|
2018
|
+
},
|
|
2019
|
+
console: {
|
|
2020
|
+
channel: "stdout",
|
|
2021
|
+
mimetype: "text/plain",
|
|
2022
|
+
data: "console output",
|
|
2023
|
+
timestamp: 0,
|
|
2024
|
+
},
|
|
2025
|
+
status: "idle",
|
|
2026
|
+
stale_inputs: null,
|
|
2027
|
+
timestamp: new Date(33).getTime() as Seconds,
|
|
2028
|
+
} as const;
|
|
2029
|
+
|
|
2030
|
+
actions.handleCellMessage({
|
|
2031
|
+
...outputMessage,
|
|
2032
|
+
cell_id: firstCellId,
|
|
2033
|
+
});
|
|
2034
|
+
actions.handleCellMessage({
|
|
2035
|
+
...outputMessage,
|
|
2036
|
+
cell_id: secondCellId,
|
|
2037
|
+
});
|
|
2038
|
+
|
|
2039
|
+
// Verify initial state has output
|
|
2040
|
+
expect(state.cellRuntime[firstCellId].output).not.toBeNull();
|
|
2041
|
+
expect(state.cellRuntime[firstCellId].consoleOutputs.length).toBe(1);
|
|
2042
|
+
expect(state.cellRuntime[secondCellId].output).not.toBeNull();
|
|
2043
|
+
expect(state.cellRuntime[secondCellId].consoleOutputs.length).toBe(1);
|
|
2044
|
+
|
|
2045
|
+
// Clear all outputs
|
|
2046
|
+
actions.clearAllCellOutputs();
|
|
2047
|
+
|
|
2048
|
+
// Verify all outputs are cleared
|
|
2049
|
+
expect(state.cellRuntime[firstCellId].output).toBeNull();
|
|
2050
|
+
expect(state.cellRuntime[firstCellId].consoleOutputs).toEqual([]);
|
|
2051
|
+
expect(state.cellRuntime[secondCellId].output).toBeNull();
|
|
2052
|
+
expect(state.cellRuntime[secondCellId].consoleOutputs).toEqual([]);
|
|
2053
|
+
});
|
|
2054
|
+
|
|
2055
|
+
it("skips creating new cell if code exists and skipIfCodeExists is true", () => {
|
|
2056
|
+
// Add initial cell with code
|
|
2057
|
+
actions.updateCellCode({
|
|
2058
|
+
cellId: firstCellId,
|
|
2059
|
+
code: "import numpy as np",
|
|
2060
|
+
formattingChange: false,
|
|
2061
|
+
});
|
|
2062
|
+
|
|
2063
|
+
// Try to create new cell with same code and skipIfCodeExists
|
|
2064
|
+
actions.createNewCell({
|
|
2065
|
+
cellId: "__end__",
|
|
2066
|
+
code: "import numpy as np",
|
|
2067
|
+
before: false,
|
|
2068
|
+
skipIfCodeExists: true,
|
|
2069
|
+
});
|
|
2070
|
+
|
|
2071
|
+
// Should still only have one cell
|
|
2072
|
+
expect(state.cellIds.inOrderIds.length).toBe(1);
|
|
2073
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2074
|
+
"
|
|
2075
|
+
[0] 'import numpy as np'
|
|
2076
|
+
"
|
|
2077
|
+
`);
|
|
2078
|
+
|
|
2079
|
+
// Verify we can still add cell with different code
|
|
2080
|
+
actions.createNewCell({
|
|
2081
|
+
cellId: "__end__",
|
|
2082
|
+
code: "import pandas as pd",
|
|
2083
|
+
before: false,
|
|
2084
|
+
skipIfCodeExists: true,
|
|
2085
|
+
});
|
|
2086
|
+
|
|
2087
|
+
expect(state.cellIds.inOrderIds.length).toBe(2);
|
|
2088
|
+
expect(formatCells(state)).toMatchInlineSnapshot(`
|
|
2089
|
+
"
|
|
2090
|
+
[0] 'import numpy as np'
|
|
2091
|
+
|
|
2092
|
+
[1] 'import pandas as pd'
|
|
2093
|
+
"
|
|
2094
|
+
`);
|
|
2095
|
+
});
|
|
2096
|
+
|
|
2097
|
+
it("can create and update a setup cell", () => {
|
|
2098
|
+
// Create the setup cell
|
|
2099
|
+
actions.upsertSetupCell({ code: "# Setup code" });
|
|
2100
|
+
|
|
2101
|
+
// Check that setup cell was created
|
|
2102
|
+
expect(state.cellData[SETUP_CELL_ID].id).toBe(SETUP_CELL_ID);
|
|
2103
|
+
expect(state.cellData[SETUP_CELL_ID].name).toBe("setup");
|
|
2104
|
+
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Setup code");
|
|
2105
|
+
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
|
|
2106
|
+
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
|
|
2107
|
+
|
|
2108
|
+
// Update the setup cell
|
|
2109
|
+
actions.upsertSetupCell({ code: "# Updated setup code" });
|
|
2110
|
+
|
|
2111
|
+
// Check that the same setup cell was updated, not duplicated
|
|
2112
|
+
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Updated setup code");
|
|
2113
|
+
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
|
|
2114
|
+
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
|
|
2115
|
+
});
|
|
2116
|
+
|
|
2117
|
+
it("can delete and undelete the setup cell", () => {
|
|
2118
|
+
// Create the setup cell
|
|
2119
|
+
actions.upsertSetupCell({ code: "# Setup code" });
|
|
2120
|
+
|
|
2121
|
+
// Check that setup cell was created
|
|
2122
|
+
expect(state.cellData[SETUP_CELL_ID].id).toBe(SETUP_CELL_ID);
|
|
2123
|
+
expect(state.cellData[SETUP_CELL_ID].name).toBe("setup");
|
|
2124
|
+
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Setup code");
|
|
2125
|
+
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
|
|
2126
|
+
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
|
|
2127
|
+
|
|
2128
|
+
// Delete the setup cell
|
|
2129
|
+
actions.deleteCell({ cellId: SETUP_CELL_ID });
|
|
2130
|
+
|
|
2131
|
+
// Check that setup cell was deleted
|
|
2132
|
+
expect(state.cellData[SETUP_CELL_ID]).toBeDefined(); // we keep old state
|
|
2133
|
+
expect(state.cellIds.inOrderIds).not.toContain(SETUP_CELL_ID);
|
|
2134
|
+
|
|
2135
|
+
// Undo delete the setup cell
|
|
2136
|
+
actions.undoDeleteCell();
|
|
2137
|
+
|
|
2138
|
+
// Check that setup cell was restored
|
|
2139
|
+
expect(state.cellData[SETUP_CELL_ID].id).toBe(SETUP_CELL_ID);
|
|
2140
|
+
expect(state.cellData[SETUP_CELL_ID].name).toBe("setup");
|
|
2141
|
+
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Setup code");
|
|
2142
|
+
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
|
|
2143
|
+
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
|
|
2144
|
+
});
|
|
2145
|
+
|
|
2146
|
+
it("can clear all outputs", () => {
|
|
2147
|
+
// Add a cell and give it output
|
|
2148
|
+
actions.createNewCell({
|
|
2149
|
+
cellId: firstCellId,
|
|
2150
|
+
before: false,
|
|
2151
|
+
});
|
|
2152
|
+
|
|
2153
|
+
const cell1Id = cells[0].id;
|
|
2154
|
+
const cell2Id = cells[1].id;
|
|
2155
|
+
|
|
2156
|
+
// Manually set output for the cells
|
|
2157
|
+
state.cellRuntime[cell1Id].output = {
|
|
2158
|
+
channel: "output",
|
|
2159
|
+
mimetype: "text/plain",
|
|
2160
|
+
data: "output1",
|
|
2161
|
+
timestamp: 0 as Seconds,
|
|
2162
|
+
};
|
|
2163
|
+
state.cellRuntime[cell2Id].output = {
|
|
2164
|
+
channel: "output",
|
|
2165
|
+
mimetype: "text/plain",
|
|
2166
|
+
data: "output2",
|
|
2167
|
+
timestamp: 0 as Seconds,
|
|
2168
|
+
};
|
|
2169
|
+
|
|
2170
|
+
actions.clearAllCellOutputs();
|
|
2171
|
+
|
|
2172
|
+
expect(state.cellRuntime[cell1Id].output).toBeNull();
|
|
2173
|
+
expect(state.cellRuntime[cell2Id].output).toBeNull();
|
|
2174
|
+
});
|
|
2175
|
+
|
|
2176
|
+
describe("moveToNextCell", () => {
|
|
2177
|
+
let cell1Id: CellId;
|
|
2178
|
+
let cell2Id: CellId;
|
|
2179
|
+
let cell3Id: CellId;
|
|
2180
|
+
|
|
2181
|
+
beforeEach(() => {
|
|
2182
|
+
// Create a few cells to work with
|
|
2183
|
+
actions.createNewCell({ cellId: "__end__", before: false });
|
|
2184
|
+
actions.createNewCell({ cellId: "__end__", before: false });
|
|
2185
|
+
|
|
2186
|
+
cell1Id = state.cellIds.inOrderIds[0];
|
|
2187
|
+
cell2Id = state.cellIds.inOrderIds[1];
|
|
2188
|
+
cell3Id = state.cellIds.inOrderIds[2];
|
|
2189
|
+
});
|
|
2190
|
+
|
|
2191
|
+
it("creates new cell when moving after last cell with noCreate=false", () => {
|
|
2192
|
+
const initialCellCount = state.cellIds.inOrderIds.length;
|
|
2193
|
+
|
|
2194
|
+
actions.moveToNextCell({
|
|
2195
|
+
cellId: cell3Id,
|
|
2196
|
+
before: false,
|
|
2197
|
+
noCreate: false,
|
|
2198
|
+
});
|
|
2199
|
+
|
|
2200
|
+
expect(state.cellIds.inOrderIds.length).toBe(initialCellCount + 1);
|
|
2201
|
+
});
|
|
2202
|
+
|
|
2203
|
+
it("creates new cell when moving before first cell with noCreate=false", () => {
|
|
2204
|
+
const initialCellCount = state.cellIds.inOrderIds.length;
|
|
2205
|
+
|
|
2206
|
+
actions.moveToNextCell({
|
|
2207
|
+
cellId: cell1Id,
|
|
2208
|
+
before: true,
|
|
2209
|
+
noCreate: false,
|
|
2210
|
+
});
|
|
2211
|
+
|
|
2212
|
+
expect(state.cellIds.inOrderIds.length).toBe(initialCellCount + 1);
|
|
2213
|
+
});
|
|
2214
|
+
|
|
2215
|
+
it("does not create new cell when moving after last cell with noCreate=true", () => {
|
|
2216
|
+
const initialCellCount = state.cellIds.inOrderIds.length;
|
|
2217
|
+
const initialState = { ...state };
|
|
2218
|
+
|
|
2219
|
+
actions.moveToNextCell({
|
|
2220
|
+
cellId: cell3Id,
|
|
2221
|
+
before: false,
|
|
2222
|
+
noCreate: true,
|
|
2223
|
+
});
|
|
2224
|
+
|
|
2225
|
+
// Should not create a new cell
|
|
2226
|
+
expect(state.cellIds.inOrderIds.length).toBe(initialCellCount);
|
|
2227
|
+
// Should not crash or throw an error
|
|
2228
|
+
expect(state.cellIds.inOrderIds).toEqual(initialState.cellIds.inOrderIds);
|
|
2229
|
+
});
|
|
2230
|
+
|
|
2231
|
+
it("does not create new cell when moving before first cell with noCreate=true", () => {
|
|
2232
|
+
const initialCellCount = state.cellIds.inOrderIds.length;
|
|
2233
|
+
const initialState = { ...state };
|
|
2234
|
+
|
|
2235
|
+
actions.moveToNextCell({ cellId: cell1Id, before: true, noCreate: true });
|
|
2236
|
+
|
|
2237
|
+
// Should not create a new cell
|
|
2238
|
+
expect(state.cellIds.inOrderIds.length).toBe(initialCellCount);
|
|
2239
|
+
// Should not crash or throw an error
|
|
2240
|
+
expect(state.cellIds.inOrderIds).toEqual(initialState.cellIds.inOrderIds);
|
|
2241
|
+
});
|
|
2242
|
+
|
|
2243
|
+
it("focuses next cell when moving within bounds", () => {
|
|
2244
|
+
const focusSpy = vi.mocked(focusAndScrollCellIntoView);
|
|
2245
|
+
focusSpy.mockClear();
|
|
2246
|
+
|
|
2247
|
+
actions.moveToNextCell({
|
|
2248
|
+
cellId: cell1Id,
|
|
2249
|
+
before: false,
|
|
2250
|
+
noCreate: true,
|
|
2251
|
+
});
|
|
2252
|
+
|
|
2253
|
+
expect(focusSpy).toHaveBeenCalledWith({
|
|
2254
|
+
cellId: cell2Id,
|
|
2255
|
+
cell: state.cellHandles[cell2Id],
|
|
2256
|
+
isCodeHidden: false,
|
|
2257
|
+
codeFocus: "top",
|
|
2258
|
+
variableName: undefined,
|
|
2259
|
+
});
|
|
2260
|
+
});
|
|
2261
|
+
|
|
2262
|
+
it("focuses previous cell when moving backward within bounds", () => {
|
|
2263
|
+
const focusSpy = vi.mocked(focusAndScrollCellIntoView);
|
|
2264
|
+
focusSpy.mockClear();
|
|
2265
|
+
|
|
2266
|
+
actions.moveToNextCell({ cellId: cell2Id, before: true, noCreate: true });
|
|
2267
|
+
|
|
2268
|
+
expect(focusSpy).toHaveBeenCalledWith({
|
|
2269
|
+
cellId: cell1Id,
|
|
2270
|
+
cell: state.cellHandles[cell1Id],
|
|
2271
|
+
isCodeHidden: false,
|
|
2272
|
+
codeFocus: "bottom",
|
|
2273
|
+
variableName: undefined,
|
|
2274
|
+
});
|
|
2275
|
+
});
|
|
2276
|
+
|
|
2277
|
+
it("does not move focus from scratch cell", () => {
|
|
2278
|
+
const focusSpy = vi.mocked(focusAndScrollCellIntoView);
|
|
2279
|
+
focusSpy.mockClear();
|
|
2280
|
+
const initialState = { ...state };
|
|
2281
|
+
|
|
2282
|
+
actions.moveToNextCell({
|
|
2283
|
+
cellId: "__scratch__" as CellId,
|
|
2284
|
+
before: false,
|
|
2285
|
+
noCreate: false,
|
|
2286
|
+
});
|
|
2287
|
+
|
|
2288
|
+
expect(focusSpy).not.toHaveBeenCalled();
|
|
2289
|
+
expect(state.cellIds.inOrderIds).toEqual(initialState.cellIds.inOrderIds);
|
|
2290
|
+
});
|
|
2291
|
+
});
|
|
2292
|
+
|
|
2293
|
+
describe("untouched cells functionality", () => {
|
|
2294
|
+
it("starts with empty untouchedNewCells set", () => {
|
|
2295
|
+
expect(state.untouchedNewCells).toEqual(new Set());
|
|
2296
|
+
});
|
|
2297
|
+
|
|
2298
|
+
it("can create a new cell with hideCode option", () => {
|
|
2299
|
+
const initialCellCount = state.cellIds.inOrderIds.length;
|
|
2300
|
+
|
|
2301
|
+
actions.createNewCell({
|
|
2302
|
+
cellId: "__end__",
|
|
2303
|
+
before: false,
|
|
2304
|
+
hideCode: true,
|
|
2305
|
+
});
|
|
2306
|
+
|
|
2307
|
+
expect(state.cellIds.inOrderIds.length).toBe(initialCellCount + 1);
|
|
2308
|
+
const newCellId =
|
|
2309
|
+
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
2310
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
2311
|
+
});
|
|
2312
|
+
|
|
2313
|
+
it("does not add cell to untouchedNewCells when hideCode is false", () => {
|
|
2314
|
+
actions.createNewCell({
|
|
2315
|
+
cellId: "__end__",
|
|
2316
|
+
before: false,
|
|
2317
|
+
hideCode: false,
|
|
2318
|
+
});
|
|
2319
|
+
|
|
2320
|
+
const newCellId =
|
|
2321
|
+
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
2322
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
2323
|
+
});
|
|
2324
|
+
|
|
2325
|
+
it("does not add cell to untouchedNewCells when hideCode is undefined", () => {
|
|
2326
|
+
actions.createNewCell({
|
|
2327
|
+
cellId: "__end__",
|
|
2328
|
+
before: false,
|
|
2329
|
+
});
|
|
2330
|
+
|
|
2331
|
+
const newCellId =
|
|
2332
|
+
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
2333
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
2334
|
+
});
|
|
2335
|
+
|
|
2336
|
+
it("can mark a cell as touched", () => {
|
|
2337
|
+
// Create a cell with hideCode
|
|
2338
|
+
actions.createNewCell({
|
|
2339
|
+
cellId: "__end__",
|
|
2340
|
+
before: false,
|
|
2341
|
+
hideCode: true,
|
|
2342
|
+
});
|
|
2343
|
+
|
|
2344
|
+
const newCellId =
|
|
2345
|
+
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
2346
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
2347
|
+
|
|
2348
|
+
// Mark it as touched
|
|
2349
|
+
actions.markTouched({ cellId: newCellId });
|
|
2350
|
+
|
|
2351
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
2352
|
+
});
|
|
2353
|
+
|
|
2354
|
+
it("markTouched is idempotent", () => {
|
|
2355
|
+
// Create a cell with hideCode
|
|
2356
|
+
actions.createNewCell({
|
|
2357
|
+
cellId: "__end__",
|
|
2358
|
+
before: false,
|
|
2359
|
+
hideCode: true,
|
|
2360
|
+
});
|
|
2361
|
+
|
|
2362
|
+
const newCellId =
|
|
2363
|
+
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
2364
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
2365
|
+
|
|
2366
|
+
// Mark it as touched multiple times
|
|
2367
|
+
actions.markTouched({ cellId: newCellId });
|
|
2368
|
+
actions.markTouched({ cellId: newCellId });
|
|
2369
|
+
actions.markTouched({ cellId: newCellId });
|
|
2370
|
+
|
|
2371
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
2372
|
+
});
|
|
2373
|
+
|
|
2374
|
+
it("can mark a non-existent cell as touched without error", () => {
|
|
2375
|
+
const nonExistentCellId = "non-existent" as CellId;
|
|
2376
|
+
|
|
2377
|
+
expect(() => {
|
|
2378
|
+
actions.markTouched({ cellId: nonExistentCellId });
|
|
2379
|
+
}).not.toThrow();
|
|
2380
|
+
|
|
2381
|
+
expect(state.untouchedNewCells.has(nonExistentCellId)).toBe(false);
|
|
2382
|
+
});
|
|
2383
|
+
|
|
2384
|
+
it("can handle multiple untouched cells", () => {
|
|
2385
|
+
// Create multiple cells with hideCode
|
|
2386
|
+
actions.createNewCell({
|
|
2387
|
+
cellId: "__end__",
|
|
2388
|
+
before: false,
|
|
2389
|
+
hideCode: true,
|
|
2390
|
+
});
|
|
2391
|
+
actions.createNewCell({
|
|
2392
|
+
cellId: "__end__",
|
|
2393
|
+
before: false,
|
|
2394
|
+
hideCode: true,
|
|
2395
|
+
});
|
|
2396
|
+
actions.createNewCell({
|
|
2397
|
+
cellId: "__end__",
|
|
2398
|
+
before: false,
|
|
2399
|
+
hideCode: false,
|
|
2400
|
+
});
|
|
2401
|
+
|
|
2402
|
+
const cellIds = state.cellIds.inOrderIds;
|
|
2403
|
+
const cell1Id = cellIds[cellIds.length - 3];
|
|
2404
|
+
const cell2Id = cellIds[cellIds.length - 2];
|
|
2405
|
+
const cell3Id = cellIds[cellIds.length - 1];
|
|
2406
|
+
|
|
2407
|
+
expect(state.untouchedNewCells.has(cell1Id)).toBe(true);
|
|
2408
|
+
expect(state.untouchedNewCells.has(cell2Id)).toBe(true);
|
|
2409
|
+
expect(state.untouchedNewCells.has(cell3Id)).toBe(false);
|
|
2410
|
+
|
|
2411
|
+
// Mark one as touched
|
|
2412
|
+
actions.markTouched({ cellId: cell1Id });
|
|
2413
|
+
|
|
2414
|
+
expect(state.untouchedNewCells.has(cell1Id)).toBe(false);
|
|
2415
|
+
expect(state.untouchedNewCells.has(cell2Id)).toBe(true);
|
|
2416
|
+
expect(state.untouchedNewCells.has(cell3Id)).toBe(false);
|
|
2417
|
+
});
|
|
2418
|
+
|
|
2419
|
+
it("preserves untouched state when cells are moved", () => {
|
|
2420
|
+
// Create cells with hideCode
|
|
2421
|
+
actions.createNewCell({
|
|
2422
|
+
cellId: "__end__",
|
|
2423
|
+
before: false,
|
|
2424
|
+
hideCode: true,
|
|
2425
|
+
});
|
|
2426
|
+
actions.createNewCell({
|
|
2427
|
+
cellId: "__end__",
|
|
2428
|
+
before: false,
|
|
2429
|
+
hideCode: true,
|
|
2430
|
+
});
|
|
2431
|
+
|
|
2432
|
+
const cellIds = state.cellIds.inOrderIds;
|
|
2433
|
+
const cell1Id = cellIds[cellIds.length - 2];
|
|
2434
|
+
const cell2Id = cellIds[cellIds.length - 1];
|
|
2435
|
+
|
|
2436
|
+
expect(state.untouchedNewCells.has(cell1Id)).toBe(true);
|
|
2437
|
+
expect(state.untouchedNewCells.has(cell2Id)).toBe(true);
|
|
2438
|
+
|
|
2439
|
+
// Move cell1 to the end
|
|
2440
|
+
actions.moveCell({
|
|
2441
|
+
cellId: cell1Id,
|
|
2442
|
+
before: false,
|
|
2443
|
+
});
|
|
2444
|
+
|
|
2445
|
+
// Both cells should still be untouched
|
|
2446
|
+
expect(state.untouchedNewCells.has(cell1Id)).toBe(true);
|
|
2447
|
+
expect(state.untouchedNewCells.has(cell2Id)).toBe(true);
|
|
2448
|
+
});
|
|
2449
|
+
|
|
2450
|
+
it("does not remove untouched state when cell is deleted", () => {
|
|
2451
|
+
// We could implement this, but it doesn't actually affect downstream behavior.
|
|
2452
|
+
// It is easier to leave it, so `undo` works as expected.
|
|
2453
|
+
|
|
2454
|
+
// Create a cell with hideCode
|
|
2455
|
+
actions.createNewCell({
|
|
2456
|
+
cellId: "__end__",
|
|
2457
|
+
before: false,
|
|
2458
|
+
hideCode: true,
|
|
2459
|
+
});
|
|
2460
|
+
|
|
2461
|
+
const newCellId =
|
|
2462
|
+
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
2463
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
2464
|
+
|
|
2465
|
+
// Delete the cell
|
|
2466
|
+
actions.deleteCell({ cellId: newCellId });
|
|
2467
|
+
|
|
2468
|
+
// Does not actually remove untouched state
|
|
2469
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
2470
|
+
});
|
|
2471
|
+
|
|
2472
|
+
it("restores untouched state when cell deletion is undone", () => {
|
|
2473
|
+
// Create a cell with hideCode
|
|
2474
|
+
actions.createNewCell({
|
|
2475
|
+
cellId: "__end__",
|
|
2476
|
+
before: false,
|
|
2477
|
+
hideCode: true,
|
|
2478
|
+
});
|
|
2479
|
+
|
|
2480
|
+
const newCellId =
|
|
2481
|
+
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
2482
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
2483
|
+
|
|
2484
|
+
// Delete the cell
|
|
2485
|
+
actions.deleteCell({ cellId: newCellId });
|
|
2486
|
+
// Still exists in untouchedNewCells
|
|
2487
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
2488
|
+
|
|
2489
|
+
// Undo the deletion
|
|
2490
|
+
actions.undoDeleteCell();
|
|
2491
|
+
|
|
2492
|
+
// The cell should be restored but no longer untouched
|
|
2493
|
+
// (this is expected behavior - undoing doesn't restore untouched state)
|
|
2494
|
+
const restoredCellId =
|
|
2495
|
+
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
2496
|
+
expect(state.untouchedNewCells.has(restoredCellId)).toBe(false);
|
|
2497
|
+
});
|
|
2498
|
+
|
|
2499
|
+
it("untouched cell behavior with hide_code config", () => {
|
|
2500
|
+
// Create a cell with hideCode and hide_code config
|
|
2501
|
+
actions.createNewCell({
|
|
2502
|
+
cellId: "__end__",
|
|
2503
|
+
before: false,
|
|
2504
|
+
hideCode: true,
|
|
2505
|
+
});
|
|
2506
|
+
|
|
2507
|
+
const newCellId =
|
|
2508
|
+
state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
|
|
2509
|
+
|
|
2510
|
+
// Update the cell config to hide code
|
|
2511
|
+
actions.updateCellConfig({
|
|
2512
|
+
cellId: newCellId,
|
|
2513
|
+
config: { hide_code: true },
|
|
2514
|
+
});
|
|
2515
|
+
|
|
2516
|
+
// Cell should be untouched and have hide_code config
|
|
2517
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(true);
|
|
2518
|
+
expect(state.cellData[newCellId].config.hide_code).toBe(true);
|
|
2519
|
+
|
|
2520
|
+
// Code should not be hidden because cell is untouched
|
|
2521
|
+
expect(exportedForTesting.isCellCodeHidden(state, newCellId)).toBe(false);
|
|
2522
|
+
|
|
2523
|
+
// Mark as touched
|
|
2524
|
+
actions.markTouched({ cellId: newCellId });
|
|
2525
|
+
|
|
2526
|
+
// Now code should be hidden
|
|
2527
|
+
expect(state.untouchedNewCells.has(newCellId)).toBe(false);
|
|
2528
|
+
expect(exportedForTesting.isCellCodeHidden(state, newCellId)).toBe(true);
|
|
2529
|
+
});
|
|
2530
|
+
});
|
|
2531
|
+
|
|
2532
|
+
describe("releaseCellAtoms", () => {
|
|
2533
|
+
it("atom families cache atoms until explicitly removed", () => {
|
|
2534
|
+
const { cellDataAtom, cellRuntimeAtom, cellHandleAtom } =
|
|
2535
|
+
exportedForTesting;
|
|
2536
|
+
|
|
2537
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2538
|
+
const newCellId = state.cellIds.inOrderIds[1];
|
|
2539
|
+
|
|
2540
|
+
const dataAtom1 = cellDataAtom(newCellId);
|
|
2541
|
+
const runtimeAtom1 = cellRuntimeAtom(newCellId);
|
|
2542
|
+
const handleAtom1 = cellHandleAtom(newCellId);
|
|
2543
|
+
|
|
2544
|
+
// accesses return cached atoms (same reference)
|
|
2545
|
+
const dataAtom2 = cellDataAtom(newCellId);
|
|
2546
|
+
const runtimeAtom2 = cellRuntimeAtom(newCellId);
|
|
2547
|
+
const handleAtom2 = cellHandleAtom(newCellId);
|
|
2548
|
+
|
|
2549
|
+
expect(dataAtom2).toBe(dataAtom1);
|
|
2550
|
+
expect(runtimeAtom2).toBe(runtimeAtom1);
|
|
2551
|
+
expect(handleAtom2).toBe(handleAtom1);
|
|
2552
|
+
});
|
|
2553
|
+
|
|
2554
|
+
it("cleans up atom family cache when cells are deleted", () => {
|
|
2555
|
+
const { cellDataAtom, cellRuntimeAtom, cellHandleAtom } =
|
|
2556
|
+
exportedForTesting;
|
|
2557
|
+
|
|
2558
|
+
actions.createNewCell({ cellId: firstCellId, before: false });
|
|
2559
|
+
const newCellId = state.cellIds.inOrderIds[1];
|
|
2560
|
+
|
|
2561
|
+
// Access to create cache entries
|
|
2562
|
+
const dataAtom1 = cellDataAtom(newCellId);
|
|
2563
|
+
const runtimeAtom1 = cellRuntimeAtom(newCellId);
|
|
2564
|
+
const handleAtom1 = cellHandleAtom(newCellId);
|
|
2565
|
+
|
|
2566
|
+
// Triggers purge
|
|
2567
|
+
actions.deleteCell({ cellId: newCellId });
|
|
2568
|
+
|
|
2569
|
+
// Access again (should be new instances after cleanup)
|
|
2570
|
+
const dataAtom2 = cellDataAtom(newCellId);
|
|
2571
|
+
const runtimeAtom2 = cellRuntimeAtom(newCellId);
|
|
2572
|
+
const handleAtom2 = cellHandleAtom(newCellId);
|
|
2573
|
+
|
|
2574
|
+
expect(dataAtom2).not.toBe(dataAtom1);
|
|
2575
|
+
expect(runtimeAtom2).not.toBe(runtimeAtom1);
|
|
2576
|
+
expect(handleAtom2).not.toBe(handleAtom1);
|
|
2577
|
+
});
|
|
2578
|
+
});
|
|
2579
|
+
});
|
|
2580
|
+
|
|
2581
|
+
describe("isCellCodeHidden", () => {
|
|
2582
|
+
const state = initialNotebookState();
|
|
2583
|
+
const firstCellId = state.cellIds.inOrderIds[0];
|
|
2584
|
+
|
|
2585
|
+
it("returns false when hide_code is false and cell is not untouched", () => {
|
|
2586
|
+
const testCellId = "test-cell" as CellId;
|
|
2587
|
+
const testState: NotebookState = {
|
|
2588
|
+
...state,
|
|
2589
|
+
cellData: {
|
|
2590
|
+
...state.cellData,
|
|
2591
|
+
[testCellId]: {
|
|
2592
|
+
...state.cellData[firstCellId],
|
|
2593
|
+
id: testCellId,
|
|
2594
|
+
config: { hide_code: false, disabled: false, column: null },
|
|
2595
|
+
},
|
|
2596
|
+
},
|
|
2597
|
+
untouchedNewCells: new Set(),
|
|
2598
|
+
};
|
|
2599
|
+
|
|
2600
|
+
expect(exportedForTesting.isCellCodeHidden(testState, testCellId)).toBe(
|
|
2601
|
+
false,
|
|
2602
|
+
);
|
|
2603
|
+
});
|
|
2604
|
+
|
|
2605
|
+
it("returns true when hide_code is true and cell is not untouched", () => {
|
|
2606
|
+
const testCellId = "test-cell" as CellId;
|
|
2607
|
+
const testState: NotebookState = {
|
|
2608
|
+
...state,
|
|
2609
|
+
cellData: {
|
|
2610
|
+
...state.cellData,
|
|
2611
|
+
[testCellId]: {
|
|
2612
|
+
...state.cellData[firstCellId],
|
|
2613
|
+
id: testCellId,
|
|
2614
|
+
config: { hide_code: true, disabled: false, column: null },
|
|
2615
|
+
},
|
|
2616
|
+
},
|
|
2617
|
+
untouchedNewCells: new Set(),
|
|
2618
|
+
};
|
|
2619
|
+
|
|
2620
|
+
expect(exportedForTesting.isCellCodeHidden(testState, testCellId)).toBe(
|
|
2621
|
+
true,
|
|
2622
|
+
);
|
|
2623
|
+
});
|
|
2624
|
+
|
|
2625
|
+
it("returns false when hide_code is true but cell is untouched", () => {
|
|
2626
|
+
const testCellId = "test-cell" as CellId;
|
|
2627
|
+
const testState: NotebookState = {
|
|
2628
|
+
...state,
|
|
2629
|
+
cellData: {
|
|
2630
|
+
...state.cellData,
|
|
2631
|
+
[testCellId]: {
|
|
2632
|
+
...state.cellData[firstCellId],
|
|
2633
|
+
id: testCellId,
|
|
2634
|
+
config: { hide_code: true, disabled: false, column: null },
|
|
2635
|
+
},
|
|
2636
|
+
},
|
|
2637
|
+
untouchedNewCells: new Set([testCellId]),
|
|
2638
|
+
};
|
|
2639
|
+
|
|
2640
|
+
expect(exportedForTesting.isCellCodeHidden(testState, testCellId)).toBe(
|
|
2641
|
+
false,
|
|
2642
|
+
);
|
|
2643
|
+
});
|
|
2644
|
+
|
|
2645
|
+
it("returns false when hide_code is false and cell is untouched", () => {
|
|
2646
|
+
const testCellId = "test-cell" as CellId;
|
|
2647
|
+
const testState: NotebookState = {
|
|
2648
|
+
...state,
|
|
2649
|
+
cellData: {
|
|
2650
|
+
...state.cellData,
|
|
2651
|
+
[testCellId]: {
|
|
2652
|
+
...state.cellData[firstCellId],
|
|
2653
|
+
id: testCellId,
|
|
2654
|
+
config: { hide_code: false, disabled: false, column: null },
|
|
2655
|
+
},
|
|
2656
|
+
},
|
|
2657
|
+
untouchedNewCells: new Set([testCellId]),
|
|
2658
|
+
};
|
|
2659
|
+
|
|
2660
|
+
expect(exportedForTesting.isCellCodeHidden(testState, testCellId)).toBe(
|
|
2661
|
+
false,
|
|
2662
|
+
);
|
|
2663
|
+
});
|
|
2664
|
+
});
|