@marimo-team/islands 0.25.1-dev4 → 0.25.1-dev40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ConnectedDataExplorerComponent-KVhjDMSe.js → ConnectedDataExplorerComponent-CwMXfDQR.js} +3 -3
- package/dist/{ErrorBoundary-pV36lYEK.js → ErrorBoundary-CAJO-M56.js} +1 -1
- package/dist/{ImageComparisonComponent-Dlm5aWnH.js → ImageComparisonComponent-Cpfz30OZ.js} +51 -52
- package/dist/{abnfDiagram-VCTEODGH-CpN0FRda.js → abnfDiagram-VCTEODGH-AFhOQTt8.js} +3 -3
- package/dist/{architectureDiagram-5GKGNRK7-DDyj5SRB.js → architectureDiagram-5GKGNRK7-BngksAAQ.js} +5 -5
- package/dist/{blockDiagram-I7D4REHJ-BbXEXJRu.js → blockDiagram-I7D4REHJ-CvBmppdy.js} +9 -9
- package/dist/{c4Diagram-7LVT6UL2-DcLsbQmR.js → c4Diagram-7LVT6UL2-EceL4_jH.js} +7 -7
- package/dist/{cells-B5-y5EY3.js → cells-Cv93oav_.js} +3 -3
- package/dist/{channel-B5XnTarr.js → channel-z7HZXHwv.js} +1 -1
- package/dist/{chat-ui-HJZsTl7o.js → chat-ui-DLSF8a04.js} +4 -4
- package/dist/{chunk-4HAMMTFA-D2qv8E0X.js → chunk-4HAMMTFA-BPTTOOC5.js} +5 -5
- package/dist/{chunk-75Z2AOVW-5_HsvXwr.js → chunk-75Z2AOVW-C4AOleKf.js} +1 -1
- package/dist/{chunk-DU6HZSFF-BUgAHvnM.js → chunk-DU6HZSFF-1TwWR6gh.js} +1 -1
- package/dist/{chunk-F27PBJKO-DHmYWZXr.js → chunk-F27PBJKO-DMI1PBe4.js} +1 -1
- package/dist/{chunk-GMAD6QVW-Czynz8aA.js → chunk-GMAD6QVW-vStrMz2P.js} +3 -3
- package/dist/{chunk-GVQU2GXP-yQEdulRS.js → chunk-GVQU2GXP-2HwWgs4u.js} +2 -2
- package/dist/{chunk-IMKFNOWR-BfwTebD0.js → chunk-IMKFNOWR-UOVZuZVn.js} +5 -5
- package/dist/{chunk-L3NEJ4N5-DwRWnDDK.js → chunk-L3NEJ4N5-RhC7i0I2.js} +5 -5
- package/dist/{chunk-OSK3NFVY-BBKU_Ign.js → chunk-OSK3NFVY-CZV09N-U.js} +6 -6
- package/dist/{chunk-P2QGCYS3-C0iGU29N.js → chunk-P2QGCYS3-0TAWai9C.js} +1 -1
- package/dist/{chunk-POPQ4Y6H-BCbS3Ozc.js → chunk-POPQ4Y6H-Cc3_56GX.js} +1 -1
- package/dist/{chunk-PWAF6VOD-CTFCL0jI.js → chunk-PWAF6VOD-lNxB9k8z.js} +1 -1
- package/dist/{chunk-SHT3W25Y-BspJEJ5H.js → chunk-SHT3W25Y-CrEPyWy1.js} +7 -7
- package/dist/{chunk-SVP7TREG-DX3rFNTe.js → chunk-SVP7TREG-uIyyySp6.js} +2 -2
- package/dist/{chunk-TICWLB2K-fVF7Uujg.js → chunk-TICWLB2K-DdXM3eg6.js} +5 -5
- package/dist/classDiagram-ZZMXUADV-BiATbBE4.js +30 -0
- package/dist/classDiagram-v2-VYDZK3BY-JnH97GYw.js +30 -0
- package/dist/{code-visibility-CgZS2a3W.js → code-visibility-XU9RAJNV.js} +2 -2
- package/dist/{common-DnMDPPaW.js → common-C0fbrgB8.js} +13 -13
- package/dist/{cynefinDiagram-5FMLGOSQ-CFQrqzSX.js → cynefinDiagram-5FMLGOSQ-zknaAsGy.js} +3 -3
- package/dist/{dagre-GXQ25YYZ-xHNAUTyG.js → dagre-GXQ25YYZ-BhMOoMGJ.js} +10 -10
- package/dist/{data-grid-overlay-editor-hHYgD_Sm.js → data-grid-overlay-editor-BnhbJgoq.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-Bt1rPbAx.js → diagram-S7CK7UJ4-V5-Z-EDY.js} +4 -4
- package/dist/{diagram-UQ7AKVKN-D1sq5FoZ.js → diagram-UQ7AKVKN-qw8AjDal.js} +3 -3
- package/dist/{diagram-VSXAHHWV-BKpmG23x.js → diagram-VSXAHHWV-CR7BJygZ.js} +2 -2
- package/dist/{diagram-VX7I27RA-BMwGFVD6.js → diagram-VX7I27RA-DfuqFb1E.js} +5 -5
- package/dist/{diagram-Z3DM3KII--KLDR9Pl.js → diagram-Z3DM3KII-DpWwlYZB.js} +3 -3
- package/dist/{dist-BaHjhkpZ.js → dist-CcyKTBTF.js} +1 -1
- package/dist/{ebnfDiagram-PWID7BFC-WnG4cvSQ.js → ebnfDiagram-PWID7BFC-C20OnNMZ.js} +3 -3
- package/dist/{erDiagram-RLTQ6QDP-DhzKiYHc.js → erDiagram-RLTQ6QDP-DBXLWO9v.js} +12 -12
- package/dist/{error-entries-Bkbpx0T0.js → error-entries-DLl0XqoW.js} +1 -1
- package/dist/{feedback-button-CvKssdG_.js → feedback-button-B0QSkbSp.js} +4 -4
- package/dist/flowDiagram-HODETNUW-DL52nMkt.js +16 -0
- package/dist/{formats-C8rLgZT9.js → formats-Cl_67ghI.js} +1 -1
- package/dist/{ganttDiagram-EL5Y4UJY-DbzEBLbl.js → ganttDiagram-EL5Y4UJY-cRRaDt88.js} +2 -2
- package/dist/{gitGraphDiagram-WWUBYQGX-BMf0iKi1.js → gitGraphDiagram-WWUBYQGX-Pox5k9-Y.js} +2 -2
- package/dist/{glide-data-editor-Ohetlgag.js → glide-data-editor-ymIQdwrb.js} +3 -3
- package/dist/{globals-CPNNcOJI.js → globals-B0S3-e_D.js} +1 -1
- package/dist/{html-to-image-BAgJOlSW.js → html-to-image-CGVgroef.js} +2 -2
- package/dist/{infoDiagram-27XIBGKW-BagtCX_5.js → infoDiagram-27XIBGKW-ntpxMfrq.js} +2 -2
- package/dist/{ishikawaDiagram-5VMMS53U-DByDehYy.js → ishikawaDiagram-5VMMS53U-BllIlHE5.js} +3 -3
- package/dist/{journeyDiagram-3NMN7TZE-D2LcKDUO.js → journeyDiagram-3NMN7TZE-EPJDPlt0.js} +2 -2
- package/dist/{kanban-definition-UXKFOSKX-BxwkbBI_.js → kanban-definition-UXKFOSKX-GYtNMjtS.js} +9 -9
- package/dist/{katex-C6D4cX_N.js → katex-BNCmKUol.js} +983 -1120
- package/dist/{loader-D2W4oM-3.js → loader-DEZSzvma.js} +253 -248
- package/dist/main.js +72 -69
- package/dist/{mermaid-DPNuhemn.js → mermaid-Dnzoxjt1.js} +49 -49
- package/dist/{mhchem-DWCF06w9.js → mhchem-BEc7A1or.js} +1 -1
- package/dist/{mindmap-definition-YA3MSWOX-Cgvojw3y.js → mindmap-definition-YA3MSWOX-Cth76xgH.js} +11 -11
- package/dist/{number-overlay-editor-CHWg5gGO.js → number-overlay-editor-DB3HJDI1.js} +1 -1
- package/dist/{pegDiagram-XKGWAZYB-DahHhYyN.js → pegDiagram-XKGWAZYB-Cu4uOXii.js} +3 -3
- package/dist/{pieDiagram-E7YTZNPT-CCtX0oCK.js → pieDiagram-E7YTZNPT-Bh3eDa9s.js} +3 -3
- package/dist/{process-output-zDX4jbhd.js → process-output-CGfg-JmZ.js} +2 -2
- package/dist/{quadrantDiagram-AXDQQJYC-DftINo6g.js → quadrantDiagram-AXDQQJYC--kqzFC3w.js} +1 -1
- package/dist/{railroadDiagram-O6MQD6OU-Du5NsPUb.js → railroadDiagram-O6MQD6OU-DG-M6Rnc.js} +3 -3
- package/dist/{react-vega-5AcMW8gG.js → react-vega-ewj7q_U5.js} +1 -1
- package/dist/{requirementDiagram-BXWQKSXE-0pmmxL6_.js → requirementDiagram-BXWQKSXE-DCwsThh0.js} +11 -11
- package/dist/{reveal-component-BujcZI2B.js → reveal-component-CfTzIkA2.js} +3 -3
- package/dist/{sankeyDiagram-P5KCCOFB-CDKR5TJH.js → sankeyDiagram-P5KCCOFB-BdzhT0BM.js} +1 -1
- package/dist/{sequenceDiagram-WJ2MYXX4-DB-ChWwU.js → sequenceDiagram-WJ2MYXX4-CbXB1_PU.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-orN6AwMx.js → stateDiagram-D77RDMKH-A-Zf3Sb2.js} +13 -13
- package/dist/stateDiagram-v2-MP3YSRHH-D9YMnUGx.js +30 -0
- package/dist/style.css +1 -1
- package/dist/{swimlanes-42K2YHIH-BkSDcqDT.js → swimlanes-42K2YHIH-B_pMf0J4.js} +10 -10
- package/dist/swimlanesDiagram-VR7AAH4N-Ctgy-yGP.js +30 -0
- package/dist/{timeline-definition-24CTP7MA-BuqJUIRZ.js → timeline-definition-24CTP7MA-DTXFjTTM.js} +3 -3
- package/dist/{vega-component-CNf5gcrm.js → vega-component-tFOzgarw.js} +4 -4
- package/dist/{vega-embed-container-CbnTccZi.js → vega-embed-container-sSR5hAsy.js} +2 -2
- package/dist/{vega-loader.browser-D95WfUcj.js → vega-loader.browser-DNST6uVf.js} +2 -2
- package/dist/{vennDiagram-4TSXK5OY-CTUlJ2PK.js → vennDiagram-4TSXK5OY-BPHjZo0R.js} +3 -3
- package/dist/{wardleyDiagram-VM6X3IG4-3evLUb0M.js → wardleyDiagram-VM6X3IG4-6fTLYBuD.js} +3 -3
- package/dist/{xychartDiagram-S5SC5T6Z-DL2E3K8-.js → xychartDiagram-S5SC5T6Z-BYjwjrzE.js} +5 -5
- package/package.json +1 -2
- package/src/__mocks__/common.ts +3 -3
- package/src/__tests__/CellStatus.test.tsx +1 -1
- package/src/__tests__/setup.ts +7 -7
- package/src/components/app-config/ai-config.tsx +2 -0
- package/src/components/app-config/optional-features.tsx +1 -1
- package/src/components/chat/chat-panel.tsx +19 -8
- package/src/components/data-table/charts/__tests__/chart-panel.test.tsx +286 -0
- package/src/components/data-table/charts/charts.tsx +26 -13
- package/src/components/data-table/column-summary/chart-spec-model.tsx +4 -4
- package/src/components/dependency-graph/elements.ts +2 -2
- package/src/components/editor/__tests__/package-alert.test.tsx +140 -0
- package/src/components/editor/actions/__tests__/pair-with-agent.test.tsx +107 -0
- package/src/components/editor/actions/pair-with-agent.tsx +119 -0
- package/src/components/editor/actions/useNotebookActions.tsx +2 -1
- package/src/components/editor/ai/add-cell-with-ai.tsx +2 -0
- package/src/components/editor/ai/staged-cell-submission.ts +2 -2
- package/src/components/editor/ai/transport/chat-transport.tsx +1 -1
- package/src/components/editor/chrome/components/contribute-snippet-button.tsx +6 -1
- package/src/components/editor/connections/database/as-code.ts +44 -44
- package/src/components/editor/connections/storage/as-code.ts +3 -3
- package/src/components/editor/file-tree/requesting-tree.tsx +16 -13
- package/src/components/editor/navigation/clipboard.ts +2 -2
- package/src/components/editor/notebook-cell.tsx +2 -2
- package/src/components/editor/output/MarimoTracebackOutput.tsx +1 -1
- package/src/components/editor/output/VideoOutput.tsx +1 -1
- package/src/components/editor/output/ansi-reduce.ts +21 -17
- package/src/components/editor/output/console/ConsoleOutput.tsx +3 -3
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +59 -0
- package/src/components/editor/output/console/text-rendering.tsx +3 -1
- package/src/components/editor/package-alert.tsx +20 -7
- package/src/components/home/components.tsx +1 -0
- package/src/components/pages/run-page.tsx +1 -0
- package/src/components/slides/__tests__/minimap-actions.test.tsx +7 -7
- package/src/components/slides/__tests__/minimap.test.ts +12 -12
- package/src/components/slides/__tests__/slide-scroll-hint.test.tsx +8 -8
- package/src/components/static-html/share-modal.tsx +2 -1
- package/src/components/static-html/static-banner.tsx +2 -2
- package/src/components/ui/links.tsx +6 -1
- package/src/components/ui/typography.tsx +16 -8
- package/src/core/ai/context/__tests__/registry.test.ts +31 -28
- package/src/core/ai/context/providers/cell-output.ts +8 -8
- package/src/core/ai/context/providers/datasource.ts +10 -7
- package/src/core/ai/context/providers/error.ts +7 -7
- package/src/core/ai/context/providers/file.ts +8 -8
- package/src/core/ai/context/providers/tables.ts +7 -7
- package/src/core/ai/context/providers/variable.ts +7 -7
- package/src/core/ai/context/registry.ts +18 -18
- package/src/core/ai/ids/ids.ts +5 -5
- package/src/core/ai/model-registry.ts +12 -9
- package/src/core/ai/staged-cells.ts +6 -6
- package/src/core/ai/tools/base.ts +6 -6
- package/src/core/ai/tools/edit-notebook-tool.ts +6 -6
- package/src/core/ai/tools/registry.ts +4 -4
- package/src/core/ai/tools/run-cells-tool.ts +7 -7
- package/src/core/ai/tools/sample-tool.ts +6 -6
- package/src/core/cells/__tests__/cells.test.ts +27 -0
- package/src/core/cells/cells.ts +2 -1
- package/src/core/codemirror/cells/debugger-decorations.ts +13 -7
- package/src/core/codemirror/cells/line-timing-decorations.ts +9 -9
- package/src/core/codemirror/cells/traceback-decorations.ts +7 -4
- package/src/core/codemirror/code-lens/extension.ts +13 -13
- package/src/core/codemirror/copilot/__tests__/language-server.test.ts +6 -6
- package/src/core/codemirror/copilot/__tests__/transport.test.ts +12 -12
- package/src/core/codemirror/copilot/language-server.ts +13 -13
- package/src/core/codemirror/copilot/transport.ts +1 -1
- package/src/core/codemirror/find-replace/search-highlight.ts +5 -5
- package/src/core/codemirror/go-to-definition/underline.ts +3 -3
- package/src/core/codemirror/keymaps/vim.ts +3 -3
- package/src/core/codemirror/language/languages/markdown.ts +8 -8
- package/src/core/codemirror/language/languages/python.ts +7 -7
- package/src/core/codemirror/language/languages/sql/completion-builder.ts +5 -5
- package/src/core/codemirror/language/languages/sql/completion-store.ts +4 -4
- package/src/core/codemirror/language/languages/sql/sql.ts +21 -21
- package/src/core/codemirror/lsp/__tests__/transports.test.ts +10 -10
- package/src/core/codemirror/lsp/federated-lsp.ts +29 -27
- package/src/core/codemirror/lsp/notebook-lsp.ts +21 -21
- package/src/core/codemirror/misc/__tests__/dnd.test.ts +10 -10
- package/src/core/codemirror/misc/__tests__/paste.test.ts +7 -4
- package/src/core/codemirror/reactive-references/extension.ts +3 -3
- package/src/core/codemirror/rtc/loro/awareness.ts +12 -12
- package/src/core/codemirror/rtc/loro/sync.ts +5 -5
- package/src/core/codemirror/vim/cursor-visibility.ts +3 -3
- package/src/core/dom/ui-element.ts +5 -5
- package/src/core/dom/uiregistry.ts +10 -10
- package/src/core/hotkeys/hotkeys.ts +9 -9
- package/src/core/islands/__tests__/bridge.test.ts +4 -4
- package/src/core/islands/__tests__/test-utils.tsx +4 -4
- package/src/core/islands/bridge.ts +85 -82
- package/src/core/islands/components/web-components.tsx +7 -7
- package/src/core/islands/worker/__tests__/controller.test.ts +1 -1
- package/src/core/islands/worker/controller.ts +6 -3
- package/src/core/islands/worker-factory.ts +2 -2
- package/src/core/kernel/RuntimeState.ts +4 -4
- package/src/core/lsp/__tests__/transport.test.ts +19 -19
- package/src/core/lsp/transport.ts +5 -5
- package/src/core/network/CachingRequestRegistry.ts +2 -2
- package/src/core/network/DeferredRequestRegistry.ts +4 -4
- package/src/core/runtime/runtime.ts +25 -20
- package/src/core/static/virtual-file-tracker.ts +5 -5
- package/src/core/wasm/__tests__/bridge.test.ts +2 -2
- package/src/core/wasm/bridge.ts +130 -126
- package/src/core/wasm/router.ts +5 -5
- package/src/core/wasm/store.ts +4 -4
- package/src/core/wasm/worker/bootstrap.ts +8 -5
- package/src/core/wasm/worker/message-buffer.ts +3 -3
- package/src/core/websocket/transports/__tests__/ws.test.ts +8 -8
- package/src/core/websocket/transports/basic.ts +15 -8
- package/src/core/websocket/transports/sse.ts +7 -7
- package/src/core/websocket/transports/transport.ts +3 -3
- package/src/core/websocket/transports/ws.ts +9 -7
- package/src/css/globals.css +18 -21
- package/src/css/katex.min.css +260 -241
- package/src/hooks/__tests__/useOverflowDetection.test.tsx +5 -5
- package/src/hooks/__tests__/useResizeObserver.test.tsx +12 -12
- package/src/plugins/core/registerReactComponent.tsx +5 -5
- package/src/plugins/core/sidebar-element.tsx +2 -2
- package/src/plugins/impl/ButtonPlugin.tsx +3 -3
- package/src/plugins/impl/CheckboxPlugin.tsx +3 -3
- package/src/plugins/impl/CodeEditorPlugin.tsx +3 -3
- package/src/plugins/impl/DatePickerPlugin.tsx +3 -3
- package/src/plugins/impl/DateRangePlugin.tsx +3 -3
- package/src/plugins/impl/DateTimePickerPlugin.tsx +3 -3
- package/src/plugins/impl/DictPlugin.tsx +3 -3
- package/src/plugins/impl/DropdownPlugin.tsx +3 -3
- package/src/plugins/impl/FileUploadPlugin.tsx +3 -3
- package/src/plugins/impl/MatrixPlugin.tsx +4 -4
- package/src/plugins/impl/MicrophonePlugin.tsx +3 -3
- package/src/plugins/impl/MultiselectPlugin.tsx +3 -3
- package/src/plugins/impl/NumberPlugin.tsx +3 -3
- package/src/plugins/impl/RadioPlugin.tsx +9 -5
- package/src/plugins/impl/RangeSliderPlugin.tsx +3 -3
- package/src/plugins/impl/RefreshPlugin.tsx +3 -3
- package/src/plugins/impl/SliderPlugin.tsx +3 -3
- package/src/plugins/impl/SwitchPlugin.tsx +3 -3
- package/src/plugins/impl/TabsPlugin.tsx +3 -3
- package/src/plugins/impl/TextAreaPlugin.tsx +3 -3
- package/src/plugins/impl/TextInputPlugin.tsx +3 -3
- package/src/plugins/impl/__tests__/MatrixPlugin.test.tsx +2 -2
- package/src/plugins/impl/anywidget/model.ts +10 -10
- package/src/plugins/impl/anywidget/registry.ts +12 -9
- package/src/plugins/impl/anywidget/runtime.ts +11 -9
- package/src/plugins/impl/anywidget/widget-binding.ts +6 -6
- package/src/plugins/impl/image-comparison/ImageComparisonComponent.tsx +7 -6
- package/src/plugins/impl/matplotlib/MatplotlibPlugin.tsx +3 -3
- package/src/plugins/impl/matplotlib/__tests__/matplotlib-renderer.test.ts +2 -2
- package/src/plugins/impl/matplotlib/matplotlib-renderer.ts +2 -2
- package/src/plugins/impl/mpl-interactive/mpl-websocket-shim.ts +10 -10
- package/src/plugins/impl/panel/utils.ts +5 -5
- package/src/plugins/impl/plotly/PlotlyPlugin.tsx +3 -3
- package/src/plugins/impl/vega/VegaPlugin.tsx +3 -3
- package/src/plugins/impl/vega/__tests__/use-vega-container-remeasure.test.ts +7 -7
- package/src/plugins/impl/vega/__tests__/utils.test.ts +16 -1
- package/src/plugins/impl/vega/__tests__/vega.test.ts +37 -0
- package/src/plugins/impl/vega/loader.ts +23 -1
- package/src/plugins/impl/vega/utils.ts +5 -4
- package/src/plugins/layout/AccordionPlugin.tsx +3 -3
- package/src/plugins/layout/CalloutPlugin.tsx +3 -3
- package/src/plugins/layout/ImageComparisonPlugin.tsx +5 -3
- package/src/plugins/layout/JsonOutputPlugin.tsx +3 -3
- package/src/plugins/layout/MimeRenderPlugin.tsx +3 -3
- package/src/plugins/layout/NavigationMenuPlugin.tsx +3 -3
- package/src/plugins/layout/OutlinePlugin.tsx +3 -3
- package/src/plugins/layout/ProgressPlugin.tsx +3 -3
- package/src/plugins/layout/RoutesPlugin.tsx +6 -8
- package/src/plugins/layout/StatPlugin.tsx +3 -3
- package/src/plugins/layout/TexPlugin.tsx +3 -3
- package/src/plugins/layout/carousel/CarouselPlugin.tsx +4 -4
- package/src/plugins/layout/mermaid/MermaidPlugin.tsx +3 -3
- package/src/utils/Deferred.ts +6 -6
- package/src/utils/async-capture-tracker.ts +10 -7
- package/src/utils/errors.ts +5 -5
- package/src/utils/id-tree.tsx +83 -80
- package/src/utils/lru.ts +1 -1
- package/src/utils/multi-map.ts +14 -12
- package/src/utils/paths.ts +6 -6
- package/src/utils/pluralize.ts +3 -3
- package/src/utils/progress.ts +6 -6
- package/src/utils/python-poet/poet.ts +14 -14
- package/src/utils/routes.ts +4 -2
- package/src/utils/semaphore.ts +6 -6
- package/src/utils/storage/storage.ts +6 -6
- package/src/utils/storage/typed.ts +16 -12
- package/src/utils/time.ts +9 -9
- package/src/utils/timed-cache.ts +4 -4
- package/src/utils/tracer.ts +9 -6
- package/dist/classDiagram-ZZMXUADV-Fe-V14Sc.js +0 -30
- package/dist/classDiagram-v2-VYDZK3BY-xTDg7lOs.js +0 -30
- package/dist/flowDiagram-HODETNUW-6dMdB8pR.js +0 -16
- package/dist/katex-DFBiSucW.js +0 -21840
- package/dist/stateDiagram-v2-MP3YSRHH-o05_rJN8.js +0 -30
- package/dist/swimlanesDiagram-VR7AAH4N-D_nFQfRc.js +0 -30
package/src/utils/id-tree.tsx
CHANGED
|
@@ -28,7 +28,7 @@ export class TreeNode<T> {
|
|
|
28
28
|
public isCollapsed: boolean;
|
|
29
29
|
public children: TreeNode<T>[];
|
|
30
30
|
|
|
31
|
-
constructor(value: T, isCollapsed: boolean, children: TreeNode<T>[]) {
|
|
31
|
+
public constructor(value: T, isCollapsed: boolean, children: TreeNode<T>[]) {
|
|
32
32
|
this.value = value;
|
|
33
33
|
this.isCollapsed = isCollapsed;
|
|
34
34
|
this.children = children;
|
|
@@ -38,7 +38,7 @@ export class TreeNode<T> {
|
|
|
38
38
|
* Recursively count the number of nodes in the tree
|
|
39
39
|
*/
|
|
40
40
|
@Memoize()
|
|
41
|
-
geDescendantCount(): number {
|
|
41
|
+
public geDescendantCount(): number {
|
|
42
42
|
let count = 0;
|
|
43
43
|
const stack = [...this.children];
|
|
44
44
|
|
|
@@ -57,7 +57,7 @@ export class TreeNode<T> {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
@Memoize()
|
|
60
|
-
getDescendants(): T[] {
|
|
60
|
+
public getDescendants(): T[] {
|
|
61
61
|
const result: T[] = [];
|
|
62
62
|
const stack = [...this.children];
|
|
63
63
|
|
|
@@ -76,7 +76,7 @@ export class TreeNode<T> {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
@Memoize()
|
|
79
|
-
get inOrderIds(): T[] {
|
|
79
|
+
public get inOrderIds(): T[] {
|
|
80
80
|
const result: T[] = [];
|
|
81
81
|
|
|
82
82
|
// Use depth-first traversal to preserve logical document order
|
|
@@ -94,14 +94,14 @@ export class TreeNode<T> {
|
|
|
94
94
|
return result;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
toString(): string {
|
|
97
|
+
public toString(): string {
|
|
98
98
|
if (this.isCollapsed) {
|
|
99
99
|
return `${this.value} (collapsed)`;
|
|
100
100
|
}
|
|
101
101
|
return String(this.value);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
equals(other: TreeNode<T>): boolean {
|
|
104
|
+
public equals(other: TreeNode<T>): boolean {
|
|
105
105
|
return this.value === other.value;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -117,7 +117,7 @@ export class CollapsibleTree<T> {
|
|
|
117
117
|
this.id = id;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
static from<T>(ids: T[]): CollapsibleTree<T> {
|
|
120
|
+
public static from<T>(ids: T[]): CollapsibleTree<T> {
|
|
121
121
|
const id = `tree_${uniqueId++}` as CellColumnId;
|
|
122
122
|
return new CollapsibleTree(
|
|
123
123
|
ids.map((id) => new TreeNode(id, false, [])),
|
|
@@ -128,7 +128,7 @@ export class CollapsibleTree<T> {
|
|
|
128
128
|
/**
|
|
129
129
|
* Create a new tree from ids, preserving structure from previous tree if possible
|
|
130
130
|
*/
|
|
131
|
-
static fromWithPreviousShape<T>(
|
|
131
|
+
public static fromWithPreviousShape<T>(
|
|
132
132
|
ids: T[],
|
|
133
133
|
previousTree?: CollapsibleTree<T>,
|
|
134
134
|
): CollapsibleTree<T> {
|
|
@@ -163,31 +163,31 @@ export class CollapsibleTree<T> {
|
|
|
163
163
|
return newTree;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
withNodes(nodes: TreeNode<T>[]): CollapsibleTree<T> {
|
|
166
|
+
public withNodes(nodes: TreeNode<T>[]): CollapsibleTree<T> {
|
|
167
167
|
return new CollapsibleTree(nodes, this.id);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
@Memoize()
|
|
171
|
-
get topLevelIds(): T[] {
|
|
171
|
+
public get topLevelIds(): T[] {
|
|
172
172
|
return this.nodes.map((n) => n.value);
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
@Memoize()
|
|
176
|
-
get inOrderIds(): T[] {
|
|
176
|
+
public get inOrderIds(): T[] {
|
|
177
177
|
return this.nodes.flatMap((n) => [n.value, ...n.inOrderIds]);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
@Memoize()
|
|
181
|
-
get idSet(): Set<T> {
|
|
181
|
+
public get idSet(): Set<T> {
|
|
182
182
|
return new Set(this.inOrderIds);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
get length(): number {
|
|
185
|
+
public get length(): number {
|
|
186
186
|
return this.nodes.length;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
@Memoize()
|
|
190
|
-
get _nodeMap(): Map<T, TreeNode<T>> {
|
|
190
|
+
public get _nodeMap(): Map<T, TreeNode<T>> {
|
|
191
191
|
const result = new Map<T, TreeNode<T>>();
|
|
192
192
|
for (const node of this.nodes) {
|
|
193
193
|
result.set(node.value, node);
|
|
@@ -200,7 +200,7 @@ export class CollapsibleTree<T> {
|
|
|
200
200
|
*
|
|
201
201
|
* Only works for the top-level nodes
|
|
202
202
|
*/
|
|
203
|
-
getDescendants(id: T): T[] {
|
|
203
|
+
public getDescendants(id: T): T[] {
|
|
204
204
|
const node = this._nodeMap.get(id);
|
|
205
205
|
if (!node) {
|
|
206
206
|
Logger.warn(
|
|
@@ -216,7 +216,7 @@ export class CollapsibleTree<T> {
|
|
|
216
216
|
*
|
|
217
217
|
* Only works for the top-level nodes
|
|
218
218
|
*/
|
|
219
|
-
isCollapsed(id: T): boolean {
|
|
219
|
+
public isCollapsed(id: T): boolean {
|
|
220
220
|
const node = this._nodeMap.get(id);
|
|
221
221
|
if (!node) {
|
|
222
222
|
Logger.warn(
|
|
@@ -230,7 +230,7 @@ export class CollapsibleTree<T> {
|
|
|
230
230
|
/**
|
|
231
231
|
* Get the index of the given node, or throw
|
|
232
232
|
*/
|
|
233
|
-
indexOfOrThrow(id: T): CellIndex {
|
|
233
|
+
public indexOfOrThrow(id: T): CellIndex {
|
|
234
234
|
const index = this.nodes.findIndex((n) => n.value === id);
|
|
235
235
|
if (index === -1) {
|
|
236
236
|
throw new Error(
|
|
@@ -244,14 +244,14 @@ export class CollapsibleTree<T> {
|
|
|
244
244
|
* Get the top level nodes in the given range.
|
|
245
245
|
* This does not include descendants.
|
|
246
246
|
*/
|
|
247
|
-
slice(start: number, end: number): T[] {
|
|
247
|
+
public slice(start: number, end: number): T[] {
|
|
248
248
|
return this.nodes.slice(start, end).map((n) => n.value);
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
/**
|
|
252
252
|
* Move the given node to the front
|
|
253
253
|
*/
|
|
254
|
-
moveToFront(id: T): CollapsibleTree<T> {
|
|
254
|
+
public moveToFront(id: T): CollapsibleTree<T> {
|
|
255
255
|
const index = this.indexOfOrThrow(id);
|
|
256
256
|
return this.withNodes(arrayMove(this.nodes, index, 0));
|
|
257
257
|
}
|
|
@@ -259,7 +259,7 @@ export class CollapsibleTree<T> {
|
|
|
259
259
|
/**
|
|
260
260
|
* Move the given node to the back
|
|
261
261
|
*/
|
|
262
|
-
moveToBack(id: T): CollapsibleTree<T> {
|
|
262
|
+
public moveToBack(id: T): CollapsibleTree<T> {
|
|
263
263
|
const index = this.indexOfOrThrow(id);
|
|
264
264
|
return this.withNodes(arrayMove(this.nodes, index, this.nodes.length - 1));
|
|
265
265
|
}
|
|
@@ -268,7 +268,7 @@ export class CollapsibleTree<T> {
|
|
|
268
268
|
* Collapse everything past the given node @param id
|
|
269
269
|
* until @param until or the end of the tree
|
|
270
270
|
*/
|
|
271
|
-
collapse(id: T, until: T | undefined): CollapsibleTree<T> {
|
|
271
|
+
public collapse(id: T, until: T | undefined): CollapsibleTree<T> {
|
|
272
272
|
const nodeIndex = this.nodes.findIndex((n) => n.value === id);
|
|
273
273
|
if (nodeIndex === -1) {
|
|
274
274
|
throw new Error(
|
|
@@ -307,7 +307,7 @@ export class CollapsibleTree<T> {
|
|
|
307
307
|
* Only works for the top-level nodes
|
|
308
308
|
* Does not collapse the children of already collapsed nodes
|
|
309
309
|
*/
|
|
310
|
-
collapseAll(
|
|
310
|
+
public collapseAll(
|
|
311
311
|
collapseRanges: ({ id: T; until: T | undefined } | null)[],
|
|
312
312
|
): CollapsibleTree<T> {
|
|
313
313
|
const nodes = [...this.nodes];
|
|
@@ -363,7 +363,7 @@ export class CollapsibleTree<T> {
|
|
|
363
363
|
* Expand a node and all of its children.
|
|
364
364
|
* If the node is already expanded, returns the same tree (no-op).
|
|
365
365
|
*/
|
|
366
|
-
expand(id: T): CollapsibleTree<T> {
|
|
366
|
+
public expand(id: T): CollapsibleTree<T> {
|
|
367
367
|
const nodeIndex = this.nodes.findIndex((n) => n.value === id);
|
|
368
368
|
if (nodeIndex === -1) {
|
|
369
369
|
throw new Error(
|
|
@@ -387,7 +387,7 @@ export class CollapsibleTree<T> {
|
|
|
387
387
|
/**
|
|
388
388
|
* Expand all collapsed nodes in the tree, including nested ones
|
|
389
389
|
*/
|
|
390
|
-
expandAll(): CollapsibleTree<T> {
|
|
390
|
+
public expandAll(): CollapsibleTree<T> {
|
|
391
391
|
let nodes = [...this.nodes];
|
|
392
392
|
let nodeIndex = 0;
|
|
393
393
|
|
|
@@ -411,21 +411,21 @@ export class CollapsibleTree<T> {
|
|
|
411
411
|
/**
|
|
412
412
|
* Move a node from one index to another
|
|
413
413
|
*/
|
|
414
|
-
move(fromIdx: number, toIdx: number): CollapsibleTree<T> {
|
|
414
|
+
public move(fromIdx: number, toIdx: number): CollapsibleTree<T> {
|
|
415
415
|
return this.withNodes(arrayMove(this.nodes, fromIdx, toIdx));
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
/**
|
|
419
419
|
* Get the node at the given index
|
|
420
420
|
*/
|
|
421
|
-
at(index: number): T | undefined {
|
|
421
|
+
public at(index: number): T | undefined {
|
|
422
422
|
return this.nodes.at(index)?.value;
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
/**
|
|
426
426
|
* Get the node at the given index
|
|
427
427
|
*/
|
|
428
|
-
atOrThrow(index: number): T {
|
|
428
|
+
public atOrThrow(index: number): T {
|
|
429
429
|
const node = this.nodes.at(index);
|
|
430
430
|
if (node === undefined) {
|
|
431
431
|
throw new Error(`Node at index ${index} not found in tree`);
|
|
@@ -436,21 +436,21 @@ export class CollapsibleTree<T> {
|
|
|
436
436
|
/**
|
|
437
437
|
* Get the first node, or throw
|
|
438
438
|
*/
|
|
439
|
-
first(): T {
|
|
439
|
+
public first(): T {
|
|
440
440
|
return this.atOrThrow(0);
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
/**
|
|
444
444
|
* Get the last node, or throw
|
|
445
445
|
*/
|
|
446
|
-
last(): T {
|
|
446
|
+
public last(): T {
|
|
447
447
|
return this.atOrThrow(this.nodes.length - 1);
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
/**
|
|
451
451
|
* Get the next node after the given node, does not wrap.
|
|
452
452
|
*/
|
|
453
|
-
after(id: T): T | undefined {
|
|
453
|
+
public after(id: T): T | undefined {
|
|
454
454
|
const index = this.indexOfOrThrow(id);
|
|
455
455
|
if (index === this.nodes.length - 1) {
|
|
456
456
|
return undefined;
|
|
@@ -461,7 +461,7 @@ export class CollapsibleTree<T> {
|
|
|
461
461
|
/**
|
|
462
462
|
* Get the previous node before the given node, does not wrap.
|
|
463
463
|
*/
|
|
464
|
-
before(id: T): T | undefined {
|
|
464
|
+
public before(id: T): T | undefined {
|
|
465
465
|
const index = this.indexOfOrThrow(id);
|
|
466
466
|
if (index === 0) {
|
|
467
467
|
return undefined;
|
|
@@ -472,7 +472,7 @@ export class CollapsibleTree<T> {
|
|
|
472
472
|
/**
|
|
473
473
|
* Insert a node at the given index
|
|
474
474
|
*/
|
|
475
|
-
insert(id: T, index: number): CollapsibleTree<T> {
|
|
475
|
+
public insert(id: T, index: number): CollapsibleTree<T> {
|
|
476
476
|
return this.withNodes(
|
|
477
477
|
arrayInsert(this.nodes, index, new TreeNode(id, false, [])),
|
|
478
478
|
);
|
|
@@ -481,28 +481,28 @@ export class CollapsibleTree<T> {
|
|
|
481
481
|
/**
|
|
482
482
|
* Insert a node at the end
|
|
483
483
|
*/
|
|
484
|
-
insertAtEnd(id: T): CollapsibleTree<T> {
|
|
484
|
+
public insertAtEnd(id: T): CollapsibleTree<T> {
|
|
485
485
|
return this.insert(id, this.nodes.length);
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
/**
|
|
489
489
|
* Insert a node at the start
|
|
490
490
|
*/
|
|
491
|
-
insertAtStart(id: T): CollapsibleTree<T> {
|
|
491
|
+
public insertAtStart(id: T): CollapsibleTree<T> {
|
|
492
492
|
return this.insert(id, 0);
|
|
493
493
|
}
|
|
494
494
|
|
|
495
495
|
/**
|
|
496
496
|
* Delete a node, expand if it was collapsed
|
|
497
497
|
*/
|
|
498
|
-
deleteAtIndex(idx: number): CollapsibleTree<T> {
|
|
498
|
+
public deleteAtIndex(idx: number): CollapsibleTree<T> {
|
|
499
499
|
const id = this.atOrThrow(idx);
|
|
500
500
|
// Expand the node first (if collapsed) to bring children back to top level
|
|
501
501
|
const tree = this.expand(id);
|
|
502
502
|
return tree.withNodes(arrayDelete(tree.nodes, idx));
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
-
delete(id: T): CollapsibleTree<T> {
|
|
505
|
+
public delete(id: T): CollapsibleTree<T> {
|
|
506
506
|
const index = this.indexOfOrThrow(id);
|
|
507
507
|
return this.deleteAtIndex(index);
|
|
508
508
|
}
|
|
@@ -510,14 +510,14 @@ export class CollapsibleTree<T> {
|
|
|
510
510
|
/**
|
|
511
511
|
* Get the number of nodes in the tree, not-including the given node
|
|
512
512
|
*/
|
|
513
|
-
getCount(id: T): number {
|
|
513
|
+
public getCount(id: T): number {
|
|
514
514
|
return this._nodeMap.get(id)?.geDescendantCount() ?? 0;
|
|
515
515
|
}
|
|
516
516
|
|
|
517
517
|
/**
|
|
518
518
|
* Find and expand the node and all of its children
|
|
519
519
|
*/
|
|
520
|
-
findAndExpandDeep(id: T): CollapsibleTree<T> {
|
|
520
|
+
public findAndExpandDeep(id: T): CollapsibleTree<T> {
|
|
521
521
|
const found = this.find(id);
|
|
522
522
|
if (found.length === 0) {
|
|
523
523
|
return this;
|
|
@@ -532,7 +532,7 @@ export class CollapsibleTree<T> {
|
|
|
532
532
|
* Find a node, returning the path to it
|
|
533
533
|
* With the last element being the node itself
|
|
534
534
|
*/
|
|
535
|
-
find(id: T): T[] {
|
|
535
|
+
public find(id: T): T[] {
|
|
536
536
|
// We need to recursively find the node
|
|
537
537
|
function findNode(nodes: TreeNode<T>[], path: T[]): T[] {
|
|
538
538
|
for (const node of nodes) {
|
|
@@ -555,7 +555,7 @@ export class CollapsibleTree<T> {
|
|
|
555
555
|
* @param id the id of the node to split at
|
|
556
556
|
* @returns a tuple of the left and right trees
|
|
557
557
|
*/
|
|
558
|
-
split(id: T): [CollapsibleTree<T>, CollapsibleTree<T> | undefined] {
|
|
558
|
+
public split(id: T): [CollapsibleTree<T>, CollapsibleTree<T> | undefined] {
|
|
559
559
|
const index = this.nodes.findIndex((n) => n.value === id);
|
|
560
560
|
if (index === -1) {
|
|
561
561
|
throw new Error(`Node ${id} not found in tree`);
|
|
@@ -570,14 +570,14 @@ export class CollapsibleTree<T> {
|
|
|
570
570
|
return [left, right];
|
|
571
571
|
}
|
|
572
572
|
|
|
573
|
-
equals(other: CollapsibleTree<T>): boolean {
|
|
573
|
+
public equals(other: CollapsibleTree<T>): boolean {
|
|
574
574
|
return (
|
|
575
575
|
this.nodes.length === other.nodes.length &&
|
|
576
576
|
this.nodes.every((n, i) => n.value === other.nodes[i].value)
|
|
577
577
|
);
|
|
578
578
|
}
|
|
579
579
|
|
|
580
|
-
toString(): string {
|
|
580
|
+
public toString(): string {
|
|
581
581
|
let depth = 0;
|
|
582
582
|
let result = "";
|
|
583
583
|
const asString = (nodes: TreeNode<T>[]) => {
|
|
@@ -596,7 +596,7 @@ export class CollapsibleTree<T> {
|
|
|
596
596
|
export class MultiColumn<T> {
|
|
597
597
|
private readonly columns: readonly CollapsibleTree<T>[];
|
|
598
598
|
|
|
599
|
-
constructor(columns: readonly CollapsibleTree<T>[]) {
|
|
599
|
+
public constructor(columns: readonly CollapsibleTree<T>[]) {
|
|
600
600
|
this.columns = columns;
|
|
601
601
|
|
|
602
602
|
// Ensure there is always at least one column
|
|
@@ -605,7 +605,7 @@ export class MultiColumn<T> {
|
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
|
|
608
|
-
static from<T>(idsList: T[][]): MultiColumn<T> {
|
|
608
|
+
public static from<T>(idsList: T[][]): MultiColumn<T> {
|
|
609
609
|
return new MultiColumn(idsList.map((ids) => CollapsibleTree.from(ids)));
|
|
610
610
|
}
|
|
611
611
|
|
|
@@ -613,7 +613,7 @@ export class MultiColumn<T> {
|
|
|
613
613
|
* Create a new MultiColumn from idsList,
|
|
614
614
|
* attempting to preserve structure from previous MultiColumn if possible.
|
|
615
615
|
*/
|
|
616
|
-
static fromWithPreviousShape<T>(
|
|
616
|
+
public static fromWithPreviousShape<T>(
|
|
617
617
|
idsList: T[],
|
|
618
618
|
previousShape: MultiColumn<T>,
|
|
619
619
|
): MultiColumn<T> {
|
|
@@ -649,14 +649,14 @@ export class MultiColumn<T> {
|
|
|
649
649
|
}
|
|
650
650
|
|
|
651
651
|
@Memoize()
|
|
652
|
-
isEmpty(): boolean {
|
|
652
|
+
public isEmpty(): boolean {
|
|
653
653
|
if (this.columns.length === 0) {
|
|
654
654
|
return true;
|
|
655
655
|
}
|
|
656
656
|
return this.columns.every((c) => c.nodes.length === 0);
|
|
657
657
|
}
|
|
658
658
|
|
|
659
|
-
static fromIdsAndColumns<T>(
|
|
659
|
+
public static fromIdsAndColumns<T>(
|
|
660
660
|
idAndColumns: [T, number | undefined | null][],
|
|
661
661
|
): MultiColumn<T> {
|
|
662
662
|
// If column is undefined, use the previous column
|
|
@@ -682,11 +682,11 @@ export class MultiColumn<T> {
|
|
|
682
682
|
}
|
|
683
683
|
|
|
684
684
|
@Memoize()
|
|
685
|
-
get topLevelIds(): T[][] {
|
|
685
|
+
public get topLevelIds(): T[][] {
|
|
686
686
|
return this.columns.map((c) => c.topLevelIds);
|
|
687
687
|
}
|
|
688
688
|
|
|
689
|
-
get iterateTopLevelIds(): Iterable<T> {
|
|
689
|
+
public get iterateTopLevelIds(): Iterable<T> {
|
|
690
690
|
const columns = this.columns;
|
|
691
691
|
|
|
692
692
|
function* iter() {
|
|
@@ -701,33 +701,33 @@ export class MultiColumn<T> {
|
|
|
701
701
|
}
|
|
702
702
|
|
|
703
703
|
@Memoize()
|
|
704
|
-
get inOrderIds(): T[] {
|
|
704
|
+
public get inOrderIds(): T[] {
|
|
705
705
|
return this.columns.flatMap((c) => c.inOrderIds);
|
|
706
706
|
}
|
|
707
707
|
|
|
708
|
-
get colLength(): number {
|
|
708
|
+
public get colLength(): number {
|
|
709
709
|
return this.columns.length;
|
|
710
710
|
}
|
|
711
711
|
|
|
712
712
|
@Memoize()
|
|
713
|
-
get idLength(): number {
|
|
713
|
+
public get idLength(): number {
|
|
714
714
|
return this.columns.reduce((acc, c) => acc + c.nodes.length, 0);
|
|
715
715
|
}
|
|
716
716
|
|
|
717
717
|
@Memoize()
|
|
718
|
-
get _columnMap(): Map<CellColumnId, CollapsibleTree<T>> {
|
|
718
|
+
public get _columnMap(): Map<CellColumnId, CollapsibleTree<T>> {
|
|
719
719
|
return new Map(this.columns.map((c) => [c.id, c]));
|
|
720
720
|
}
|
|
721
721
|
|
|
722
|
-
at(idx: number): CollapsibleTree<T> | undefined {
|
|
722
|
+
public at(idx: number): CollapsibleTree<T> | undefined {
|
|
723
723
|
return this.columns[idx];
|
|
724
724
|
}
|
|
725
725
|
|
|
726
|
-
get(columnId: CellColumnId): CollapsibleTree<T> | undefined {
|
|
726
|
+
public get(columnId: CellColumnId): CollapsibleTree<T> | undefined {
|
|
727
727
|
return this._columnMap.get(columnId);
|
|
728
728
|
}
|
|
729
729
|
|
|
730
|
-
atOrThrow(idx: number): CollapsibleTree<T> {
|
|
730
|
+
public atOrThrow(idx: number): CollapsibleTree<T> {
|
|
731
731
|
const column = this.columns[idx];
|
|
732
732
|
if (!column) {
|
|
733
733
|
throw new Error(`Column ${idx} not found`);
|
|
@@ -735,28 +735,31 @@ export class MultiColumn<T> {
|
|
|
735
735
|
return column;
|
|
736
736
|
}
|
|
737
737
|
|
|
738
|
-
hasOnlyOneColumn(): boolean {
|
|
738
|
+
public hasOnlyOneColumn(): boolean {
|
|
739
739
|
return this.columns.length === 1;
|
|
740
740
|
}
|
|
741
741
|
|
|
742
|
-
getColumns(): readonly CollapsibleTree<T>[] {
|
|
742
|
+
public getColumns(): readonly CollapsibleTree<T>[] {
|
|
743
743
|
return this.columns;
|
|
744
744
|
}
|
|
745
745
|
|
|
746
|
-
hasOnlyOneId(): boolean {
|
|
746
|
+
public hasOnlyOneId(): boolean {
|
|
747
747
|
return this.idLength === 1;
|
|
748
748
|
}
|
|
749
749
|
|
|
750
750
|
@Memoize()
|
|
751
|
-
getColumnIds(): CellColumnId[] {
|
|
751
|
+
public getColumnIds(): CellColumnId[] {
|
|
752
752
|
return this.columns.map((c) => c.id);
|
|
753
753
|
}
|
|
754
754
|
|
|
755
|
-
indexOf(column: CollapsibleTree<T>): number {
|
|
755
|
+
public indexOf(column: CollapsibleTree<T>): number {
|
|
756
756
|
return this.columns.indexOf(column);
|
|
757
757
|
}
|
|
758
758
|
|
|
759
|
-
addColumn(
|
|
759
|
+
public addColumn(
|
|
760
|
+
columnId: CellColumnId,
|
|
761
|
+
initialIds: T[] = [],
|
|
762
|
+
): MultiColumn<T> {
|
|
760
763
|
return new MultiColumn(
|
|
761
764
|
this.columns.flatMap((c) => {
|
|
762
765
|
if (c.id === columnId) {
|
|
@@ -767,7 +770,7 @@ export class MultiColumn<T> {
|
|
|
767
770
|
);
|
|
768
771
|
}
|
|
769
772
|
|
|
770
|
-
insertBreakpoint(cellId: T): MultiColumn<T> {
|
|
773
|
+
public insertBreakpoint(cellId: T): MultiColumn<T> {
|
|
771
774
|
const column = this.findWithId(cellId);
|
|
772
775
|
const [left, right] = column.split(cellId);
|
|
773
776
|
const newColumns = this.columns.flatMap((c) => {
|
|
@@ -779,7 +782,7 @@ export class MultiColumn<T> {
|
|
|
779
782
|
return new MultiColumn(newColumns);
|
|
780
783
|
}
|
|
781
784
|
|
|
782
|
-
delete(columnId: CellColumnId): MultiColumn<T> {
|
|
785
|
+
public delete(columnId: CellColumnId): MultiColumn<T> {
|
|
783
786
|
// Move cells to preceding column
|
|
784
787
|
// If its the first column, move the cells to the next column
|
|
785
788
|
|
|
@@ -801,7 +804,7 @@ export class MultiColumn<T> {
|
|
|
801
804
|
return new MultiColumn(columns);
|
|
802
805
|
}
|
|
803
806
|
|
|
804
|
-
mergeAllColumns(): MultiColumn<T> {
|
|
807
|
+
public mergeAllColumns(): MultiColumn<T> {
|
|
805
808
|
if (this.columns.length <= 1) {
|
|
806
809
|
return this;
|
|
807
810
|
}
|
|
@@ -811,7 +814,7 @@ export class MultiColumn<T> {
|
|
|
811
814
|
return new MultiColumn([firstColumn.withNodes(nodes)]);
|
|
812
815
|
}
|
|
813
816
|
|
|
814
|
-
moveWithinColumn(
|
|
817
|
+
public moveWithinColumn(
|
|
815
818
|
col: CellColumnId,
|
|
816
819
|
fromIdx: CellIndex,
|
|
817
820
|
toIdx: CellIndex,
|
|
@@ -821,7 +824,7 @@ export class MultiColumn<T> {
|
|
|
821
824
|
});
|
|
822
825
|
}
|
|
823
826
|
|
|
824
|
-
moveAcrossColumns(
|
|
827
|
+
public moveAcrossColumns(
|
|
825
828
|
fromCol: CellColumnId,
|
|
826
829
|
fromId: T,
|
|
827
830
|
toCol: CellColumnId,
|
|
@@ -868,7 +871,7 @@ export class MultiColumn<T> {
|
|
|
868
871
|
* @throws Error if any cellId is not found in any column.
|
|
869
872
|
* If targetId is among the moved cells, cells are inserted at the end of the target column.
|
|
870
873
|
*/
|
|
871
|
-
moveCellsRelativeTo(
|
|
874
|
+
public moveCellsRelativeTo(
|
|
872
875
|
cellIds: T[],
|
|
873
876
|
targetId: T,
|
|
874
877
|
position: "before" | "after",
|
|
@@ -922,7 +925,7 @@ export class MultiColumn<T> {
|
|
|
922
925
|
return new MultiColumn(columnsWithRemovals);
|
|
923
926
|
}
|
|
924
927
|
|
|
925
|
-
indexOfOrThrow(id: CellColumnId): number {
|
|
928
|
+
public indexOfOrThrow(id: CellColumnId): number {
|
|
926
929
|
const index = this.columns.findIndex((c) => c.id === id);
|
|
927
930
|
if (index === -1) {
|
|
928
931
|
throw new Error(
|
|
@@ -932,7 +935,7 @@ export class MultiColumn<T> {
|
|
|
932
935
|
return index;
|
|
933
936
|
}
|
|
934
937
|
|
|
935
|
-
moveColumn(
|
|
938
|
+
public moveColumn(
|
|
936
939
|
fromCol: CellColumnId,
|
|
937
940
|
toCol: CellColumnId | "_left_" | "_right_",
|
|
938
941
|
): MultiColumn<T> {
|
|
@@ -951,7 +954,7 @@ export class MultiColumn<T> {
|
|
|
951
954
|
return new MultiColumn(arrayMove([...this.columns], fromIdx, toIdx));
|
|
952
955
|
}
|
|
953
956
|
|
|
954
|
-
moveToNewColumn(cellId: T): MultiColumn<T> {
|
|
957
|
+
public moveToNewColumn(cellId: T): MultiColumn<T> {
|
|
955
958
|
const fromColumn = this.findWithId(cellId);
|
|
956
959
|
|
|
957
960
|
// Create new columns array with the cell removed from its original column
|
|
@@ -967,7 +970,7 @@ export class MultiColumn<T> {
|
|
|
967
970
|
return new MultiColumn([...columns, newColumn]);
|
|
968
971
|
}
|
|
969
972
|
|
|
970
|
-
findWithId(id: T): CollapsibleTree<T> {
|
|
973
|
+
public findWithId(id: T): CollapsibleTree<T> {
|
|
971
974
|
const found = this.columns.find((c) => {
|
|
972
975
|
return c.inOrderIds.includes(id);
|
|
973
976
|
});
|
|
@@ -987,7 +990,7 @@ export class MultiColumn<T> {
|
|
|
987
990
|
* @returns new MultiColumn with the transformed column
|
|
988
991
|
* If the column was not updated, we return the object.
|
|
989
992
|
*/
|
|
990
|
-
transformWithCellId(
|
|
993
|
+
public transformWithCellId(
|
|
991
994
|
id: T,
|
|
992
995
|
fn: (tree: CollapsibleTree<T>) => CollapsibleTree<T>,
|
|
993
996
|
): MultiColumn<T> {
|
|
@@ -1012,15 +1015,15 @@ export class MultiColumn<T> {
|
|
|
1012
1015
|
return new MultiColumn(columns);
|
|
1013
1016
|
}
|
|
1014
1017
|
|
|
1015
|
-
setupCellExists(): boolean {
|
|
1018
|
+
public setupCellExists(): boolean {
|
|
1016
1019
|
return this.columns.some((c) => c.topLevelIds.includes(SETUP_CELL_ID as T));
|
|
1017
1020
|
}
|
|
1018
1021
|
|
|
1019
|
-
insertId(id: T, col: CellColumnId, index: CellIndex): MultiColumn<T> {
|
|
1022
|
+
public insertId(id: T, col: CellColumnId, index: CellIndex): MultiColumn<T> {
|
|
1020
1023
|
return this.transform(col, (c) => c.insert(id, index));
|
|
1021
1024
|
}
|
|
1022
1025
|
|
|
1023
|
-
deleteById(cellId: T): MultiColumn<T> {
|
|
1026
|
+
public deleteById(cellId: T): MultiColumn<T> {
|
|
1024
1027
|
return this.transformWithCellId(cellId, (c) => c.delete(cellId));
|
|
1025
1028
|
}
|
|
1026
1029
|
|
|
@@ -1030,7 +1033,7 @@ export class MultiColumn<T> {
|
|
|
1030
1033
|
* cells to their previous positions. Placements are sorted by
|
|
1031
1034
|
* (columnId, index) so insert order keeps indices valid.
|
|
1032
1035
|
*/
|
|
1033
|
-
placeCells(
|
|
1036
|
+
public placeCells(
|
|
1034
1037
|
placements: Array<{ id: T; columnId: CellColumnId; index: CellIndex }>,
|
|
1035
1038
|
): MultiColumn<T> {
|
|
1036
1039
|
if (placements.length === 0) {
|
|
@@ -1052,7 +1055,7 @@ export class MultiColumn<T> {
|
|
|
1052
1055
|
return result;
|
|
1053
1056
|
}
|
|
1054
1057
|
|
|
1055
|
-
compact(): MultiColumn<T> {
|
|
1058
|
+
public compact(): MultiColumn<T> {
|
|
1056
1059
|
// Don't compact if there's only one column
|
|
1057
1060
|
if (this.columns.length === 1) {
|
|
1058
1061
|
return this;
|
|
@@ -1070,7 +1073,7 @@ export class MultiColumn<T> {
|
|
|
1070
1073
|
/**
|
|
1071
1074
|
* Transform the column with the given column id
|
|
1072
1075
|
*/
|
|
1073
|
-
transform(
|
|
1076
|
+
public transform(
|
|
1074
1077
|
columnId: CellColumnId,
|
|
1075
1078
|
fn: (tree: CollapsibleTree<T>) => CollapsibleTree<T>,
|
|
1076
1079
|
): MultiColumn<T> {
|
|
@@ -1101,7 +1104,7 @@ export class MultiColumn<T> {
|
|
|
1101
1104
|
* @param fn The function to transform each column
|
|
1102
1105
|
* @returns A new MultiColumn if any changes were made, otherwise this
|
|
1103
1106
|
*/
|
|
1104
|
-
transformAll(
|
|
1107
|
+
public transformAll(
|
|
1105
1108
|
fn: (tree: CollapsibleTree<T>) => CollapsibleTree<T>,
|
|
1106
1109
|
): MultiColumn<T> {
|
|
1107
1110
|
let didChange = false;
|
package/src/utils/lru.ts
CHANGED
|
@@ -11,7 +11,7 @@ export class LRUCache<K, V> {
|
|
|
11
11
|
private cache = new Map<K, V>();
|
|
12
12
|
private options: LRUCacheOptions<K, V>;
|
|
13
13
|
|
|
14
|
-
constructor(maxSize: number, options: LRUCacheOptions<K, V> = {}) {
|
|
14
|
+
public constructor(maxSize: number, options: LRUCacheOptions<K, V> = {}) {
|
|
15
15
|
this.maxSize = maxSize;
|
|
16
16
|
this.options = options;
|
|
17
17
|
}
|