@marimo-team/frontend 0.16.0-dev96986 → 0.16.0
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-BErMbWvG.js +19 -0
- package/dist/assets/{ImageComparisonComponent-SX7fDaTK.js → ImageComparisonComponent-fTHv1Ih0.js} +1 -1
- package/dist/assets/{VegaLite-MJUW3b7C.js → VegaLite-Bdi-TyfY.js} +1 -1
- package/dist/assets/_baseEach-CNBxBxvS.js +1 -0
- package/dist/assets/_baseMap-D1WHjKrd.js +1 -0
- package/dist/assets/_baseUniq-CCgDNtZb.js +1 -0
- package/dist/assets/{_createAggregator-ZRm2b6Zm.js → _createAggregator-DcD0kTA5.js} +1 -1
- package/dist/assets/{agent-panel-BBd11wNX.js → agent-panel-Crv430aI.js} +57 -76
- package/dist/assets/{any-language-editor-DwAaEQfS.js → any-language-editor-CQh552Wu.js} +1 -1
- package/dist/assets/{architectureDiagram-W76B3OCA-BJmVXUoW.js → architectureDiagram-W76B3OCA-BAJeBxzt.js} +1 -1
- package/dist/assets/{between-horizontal-start-KiwU-a3C.js → between-horizontal-start-Boxgxbt_.js} +1 -1
- package/dist/assets/{blockDiagram-QIGZ2CNN-DzxZjE7B.js → blockDiagram-QIGZ2CNN-CL-1svEK.js} +1 -1
- package/dist/assets/{c4Diagram-FPNF74CW-DjmldG_J.js → c4Diagram-FPNF74CW-BbEqbCTl.js} +1 -1
- package/dist/assets/channel-_2eNSz0n.js +1 -0
- package/dist/assets/chat-panel-CXh5Wl6C.js +3 -0
- package/dist/assets/{chunk-4BX2VUAB-EUTQThiZ.js → chunk-4BX2VUAB-C--8TXeE.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-DZAiDJxy.js → chunk-55IACEB6-Bj00HDqq.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-Bd0Czs-J.js → chunk-FMBD7UC4-C-lhB6hN.js} +1 -1
- package/dist/assets/{chunk-K7UQS3LO-DEKMIknX.js → chunk-K7UQS3LO-B-pGTXPt.js} +1 -1
- package/dist/assets/{chunk-QN33PNHL-E0jwHU_n.js → chunk-QN33PNHL-DqUzGhvm.js} +1 -1
- package/dist/assets/{chunk-QZHKN3VN-BzaIHJbq.js → chunk-QZHKN3VN-TntJHfSk.js} +1 -1
- package/dist/assets/{chunk-TVAH2DTR-CZFYvqnm.js → chunk-TVAH2DTR-HUJb1psV.js} +1 -1
- package/dist/assets/{chunk-TZMSLE5B-BNqnFjtv.js → chunk-TZMSLE5B-BK3C__t3.js} +1 -1
- package/dist/assets/{circle-play-D3J_mYrF.js → circle-play-DBLOv1Yu.js} +1 -1
- package/dist/assets/classDiagram-KNZD7YFC-BGmh9POF.js +1 -0
- package/dist/assets/classDiagram-v2-RKCZMP56-BGmh9POF.js +1 -0
- package/dist/assets/{clear-button-ifzRuAR3.js → clear-button-BeoFbEKH.js} +1 -1
- package/dist/assets/clone-BFDSPAj3.js +1 -0
- package/dist/assets/{command-palette-D2fdVSET.js → command-palette-CXZiSv0I.js} +1 -1
- package/dist/assets/{common-Ku-cF_2J.js → common-C7oJcmCT.js} +1 -1
- package/dist/assets/{compile-BgZlHW1c.js → compile-7L0MwhyI.js} +1 -1
- package/dist/assets/{cose-bilkent-S5V4N54A-CVM83SqK.js → cose-bilkent-S5V4N54A-BMkGLcVC.js} +1 -1
- package/dist/assets/{dagre-5GWH7T2D-ouQPkxT3.js → dagre-5GWH7T2D-BJtRienS.js} +1 -1
- package/dist/assets/{data-grid-overlay-editor-B47j5GJJ.js → data-grid-overlay-editor-DBkmGtNs.js} +1 -1
- package/dist/assets/datasources-panel-B7FbYLiy.js +1 -0
- package/dist/assets/{dependency-graph-panel-CZC_B7pK.js → dependency-graph-panel-DEdOxp2X.js} +1 -1
- package/dist/assets/{diagram-N5W7TBWH-CQ817ZdR.js → diagram-N5W7TBWH-CmECY3nb.js} +1 -1
- package/dist/assets/{diagram-QEK2KX5R-DOK_psUO.js → diagram-QEK2KX5R-DMOVSNKD.js} +1 -1
- package/dist/assets/{diagram-S2PKOQOG-CVljmOW8.js → diagram-S2PKOQOG-BiJ96PNQ.js} +1 -1
- package/dist/assets/{documentation-panel-C7yIvGg1.js → documentation-panel-xULhaEv3.js} +1 -1
- package/dist/assets/edit-page-BrYda9VE.js +129 -0
- package/dist/assets/{ellipsis-vertical-C7FjlUsY.js → ellipsis-vertical-BBqXIlc2.js} +1 -1
- package/dist/assets/{empty-state-DIOGM_CU.js → empty-state-B3dA3G5P.js} +1 -1
- package/dist/assets/{erDiagram-AWTI2OKA-DYu8cEdc.js → erDiagram-AWTI2OKA-MP1DiFRo.js} +1 -1
- package/dist/assets/{error-panel-Ddb8RkFG.js → error-panel-Cc1sv-Ag.js} +1 -1
- package/dist/assets/file-explorer-panel-Bw59Kva1.js +1 -0
- package/dist/assets/{flowDiagram-PVAE7QVJ-CmvW5iTb.js → flowDiagram-PVAE7QVJ-BX7caPp7.js} +1 -1
- package/dist/assets/{ganttDiagram-OWAHRB6G-BaKQlCaT.js → ganttDiagram-OWAHRB6G-B462g4Yf.js} +4 -4
- package/dist/assets/{gitGraphDiagram-NY62KEGX-CWO24eP6.js → gitGraphDiagram-NY62KEGX-CGgvZ9-9.js} +1 -1
- package/dist/assets/{glide-data-editor-CNDLEJ9a.js → glide-data-editor-C0gUFZON.js} +11 -11
- package/dist/assets/{graph-BZKTtxsc.js → graph-CHRVBzY5.js} +1 -1
- package/dist/assets/home-page-Fb2osjys.js +9 -0
- package/dist/assets/{index-zrSUQXha.js → index-BVgAenPd.js} +1 -1
- package/dist/assets/{index-Brf2DwUM.js → index-BY93Ejhl.js} +1 -1
- package/dist/assets/{index-CerjupfZ.js → index-C-8WADat.js} +1 -1
- package/dist/assets/{index-DZhOPkOB.js → index-C-GhZ7ti.js} +1 -1
- package/dist/assets/{index-CZaurnA9.js → index-C1v_Z9et.js} +1 -1
- package/dist/assets/{index-0XOUPdwT.js → index-C4Tn5NvJ.js} +1 -1
- package/dist/assets/{index-B_d_JZGI.js → index-C77h_TXN.js} +1 -1
- package/dist/assets/{index-BJVyzkx5.js → index-CQDrxQ0j.js} +1 -1
- package/dist/assets/{index-DFrGFNW1.js → index-CWMgowgL.js} +1 -1
- package/dist/assets/{index-DmgwT3sx.js → index-Clbi_Yaq.js} +1 -1
- package/dist/assets/{index-D-tZfElD.js → index-CpTPJo4k.js} +1 -1
- package/dist/assets/index-Cx0bsY1w.css +1 -0
- package/dist/assets/{index-DkntzpX4.js → index-D1vmG6DS.js} +1 -1
- package/dist/assets/{index-D3PqGupX.js → index-D9UKkrr2.js} +1 -1
- package/dist/assets/{index-BgXbBA39.js → index-DEQvTChO.js} +1 -1
- package/dist/assets/index-DKEudB02.js +578 -0
- package/dist/assets/{index-DCkzth56.js → index-DRMm6SNo.js} +1 -1
- package/dist/assets/{index-WXJFkQHg.js → index-DoRmcrKM.js} +1 -1
- package/dist/assets/{index-qE8lHQ-N.js → index-lYa_leQE.js} +1 -1
- package/dist/assets/{index-CXrWwFX6.js → index-vmICa5KN.js} +1 -1
- package/dist/assets/{index-BH7f3aiU.js → index-z9bohSQJ.js} +1 -1
- package/dist/assets/infoDiagram-STP46IZ2-CVyrdLc8.js +2 -0
- package/dist/assets/{isEmpty-D1t7Gran.js → isEmpty-DU_ogP_D.js} +1 -1
- package/dist/assets/{journeyDiagram-BIP6EPQ6-D4Rp6H_h.js → journeyDiagram-BIP6EPQ6-C6EgLP_Q.js} +1 -1
- package/dist/assets/{kanban-definition-6OIFK2YF-DFt9DftA.js → kanban-definition-6OIFK2YF-BXzYO1yj.js} +1 -1
- package/dist/assets/{layout-D8WXi2_g.js → layout-jihVw5-i.js} +1 -1
- package/dist/assets/{linear-BwY8e5hA.js → linear-C4blANlC.js} +1 -1
- package/dist/assets/links-D59GIweI.js +7 -0
- package/dist/assets/{logs-panel-Dxiyt7dO.js → logs-panel-D401qzZh.js} +1 -1
- package/dist/assets/{markdown-renderer-VDu-NBKB.js → markdown-renderer-Cd9eYyaL.js} +20 -20
- package/dist/assets/{mermaid-B-O-Puyi.js → mermaid-BEVuRz_O.js} +1 -1
- package/dist/assets/{mermaid.core-BFFCqfOn.js → mermaid.core-CaSnaLH0.js} +4 -4
- package/dist/assets/min-DUMu_zeK.js +1 -0
- package/dist/assets/{mindmap-definition-Q6HEUPPD-kyvIY8Dg.js → mindmap-definition-Q6HEUPPD-BXUM5MT2.js} +1 -1
- package/dist/assets/{number-overlay-editor-GjLB2UK4.js → number-overlay-editor-4uWXGlPG.js} +1 -1
- package/dist/assets/outline-panel-DIzkvm2I.js +1 -0
- package/dist/assets/{packages-panel-nfXB-bKW.js → packages-panel-CJL0MVlj.js} +1 -1
- package/dist/assets/{pieDiagram-ADFJNKIX-D8JFQcWR.js → pieDiagram-ADFJNKIX-Dxt5PVNo.js} +1 -1
- package/dist/assets/{quadrantDiagram-LMRXKWRM-Nf8GzxXG.js → quadrantDiagram-LMRXKWRM-D4pUaA31.js} +1 -1
- package/dist/assets/{react-plotly-CnW9p7ZA.js → react-plotly-cJZ0VWBq.js} +1 -1
- package/dist/assets/{requirementDiagram-4UW4RH46-CCUxF8BZ.js → requirementDiagram-4UW4RH46-DVRTjgas.js} +1 -1
- package/dist/assets/{run-page-Bl4p3AbZ.js → run-page-BUEnMC9w.js} +1 -1
- package/dist/assets/{sankeyDiagram-GR3RE2ED-Sr8kDwP1.js → sankeyDiagram-GR3RE2ED-CVFnD9C-.js} +1 -1
- package/dist/assets/{scratchpad-panel-Ja1Mu-W3.js → scratchpad-panel-BIgRENkI.js} +1 -1
- package/dist/assets/{secrets-panel-B-3fcSyP.js → secrets-panel-xY5-V_BD.js} +1 -1
- package/dist/assets/{sequenceDiagram-C3RYC4MD-CBJ152Q3.js → sequenceDiagram-C3RYC4MD-_lY4ZN_S.js} +1 -1
- package/dist/assets/{slides-component-C-LoGC1U.css → slides-component-DMjQomc3.css} +1 -1
- package/dist/assets/{slides-component-DGtsVP5o.js → slides-component-Xjymwj7X.js} +1 -1
- package/dist/assets/snippets-panel-CTPYW41n.js +1 -0
- package/dist/assets/sortBy-BNZKwiq_.js +1 -0
- package/dist/assets/{state-B_RCHTH5.js → state-C4NiC9tO.js} +1 -1
- package/dist/assets/{stateDiagram-KXAO66HF-BlBFSAZr.js → stateDiagram-KXAO66HF-Da0JQWCn.js} +1 -1
- package/dist/assets/stateDiagram-v2-UMBNRL4Z-D5lYZOOt.js +1 -0
- package/dist/assets/storage-CMdLzB_c.js +26 -0
- package/dist/assets/{terminal-CATzv5Hd.js → terminal-BPwTkXae.js} +1 -1
- package/dist/assets/{time-CsYqILfB.js → time-Dv5_Ouz_.js} +1 -1
- package/dist/assets/{timeline-definition-XQNQX7LJ-CGrhjuAs.js → timeline-definition-XQNQX7LJ-Dxh5Zu2e.js} +1 -1
- package/dist/assets/tracing-BCIurUfa.js +2 -0
- package/dist/assets/{tracing-panel-DmzqPUtc.js → tracing-panel-DAzrzNmm.js} +2 -2
- package/dist/assets/{trash-rxdjLzkf.js → trash-Dc6DSjz_.js} +1 -1
- package/dist/assets/{tree-C2Ul1h1C.js → tree-jheoerAX.js} +1 -1
- package/dist/assets/{treemap-75Q7IDZK-N9hyUpyj.js → treemap-75Q7IDZK-IgpxeGaf.js} +27 -27
- package/dist/assets/variable-panel-DYAiLBmF.js +1 -0
- package/dist/assets/{vega-component-CR_MHOBT.js → vega-component-BpfpiPKI.js} +1 -1
- package/dist/assets/worker-X5rxzQGQ.js +1 -0
- package/dist/assets/{xychartDiagram-6GGTOJPD-jdLZsMb2.js → xychartDiagram-6GGTOJPD-CmNigJ31.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +2 -3
- package/src/components/app-config/user-config-form.tsx +1 -46
- package/src/components/chat/acp/__tests__/__snapshots__/prompt.test.ts.snap +43 -62
- package/src/components/chat/acp/__tests__/atoms.test.ts +1 -1
- package/src/components/chat/acp/__tests__/state.test.ts +36 -36
- package/src/components/chat/acp/agent-panel.tsx +27 -24
- package/src/components/chat/acp/blocks.tsx +6 -6
- package/src/components/chat/acp/prompt.ts +43 -62
- package/src/components/chat/chat-panel.tsx +1 -5
- package/src/components/chat/markdown-renderer.tsx +10 -6
- package/src/components/chat/tool-call-accordion.tsx +20 -52
- package/src/components/data-table/SearchBar.tsx +7 -8
- package/src/components/data-table/__tests__/column_formatting.test.ts +35 -50
- package/src/components/data-table/__tests__/data-table.test.tsx +1 -39
- package/src/components/data-table/charts/components/form-fields.tsx +37 -41
- package/src/components/data-table/charts/forms/common-chart.tsx +2 -2
- package/src/components/data-table/column-explorer-panel/column-explorer.tsx +2 -5
- package/src/components/data-table/column-formatting/feature.ts +29 -62
- package/src/components/data-table/column-formatting/types.ts +0 -1
- package/src/components/data-table/column-header.tsx +1 -3
- package/src/components/data-table/column-summary/chart-spec-model.tsx +7 -24
- package/src/components/data-table/column-summary/column-summary.tsx +9 -18
- package/src/components/data-table/columns.tsx +18 -42
- package/src/components/data-table/data-table.tsx +2 -10
- package/src/components/data-table/date-popover.tsx +75 -85
- package/src/components/data-table/filter-pills.tsx +9 -14
- package/src/components/data-table/header-items.tsx +1 -5
- package/src/components/data-table/pagination.tsx +13 -20
- package/src/components/data-table/renderers.tsx +0 -28
- package/src/components/data-table/row-viewer-panel/row-viewer.tsx +8 -10
- package/src/components/datasources/column-preview.tsx +2 -6
- package/src/components/datasources/datasources.tsx +12 -8
- package/src/components/editor/ai/transport/chat-transport.tsx +1 -4
- package/src/components/editor/cell/CellStatus.tsx +20 -23
- package/src/components/editor/cell/CreateCellButton.tsx +4 -3
- package/src/components/editor/cell/code/language-toggle.tsx +4 -3
- package/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx +28 -39
- package/src/components/editor/controls/notebook-menu-dropdown.tsx +2 -4
- package/src/components/editor/file-tree/requesting-tree.tsx +8 -14
- package/src/components/editor/renderers/CellArray.tsx +4 -3
- package/src/components/editor/renderers/slides-layout/slides-layout.tsx +3 -3
- package/src/components/editor/renderers/slides-layout/types.ts +0 -1
- package/src/components/pages/home-page.tsx +1 -4
- package/src/components/slides/slides-component.tsx +1 -1
- package/src/components/slides/slides.css +0 -6
- package/src/components/terminal/theme.tsx +0 -1
- package/src/components/tracing/tracing-spec.ts +4 -5
- package/src/components/ui/range-slider.tsx +2 -4
- package/src/components/ui/slider.tsx +1 -3
- package/src/components/variables/variables-table.tsx +0 -3
- package/src/core/MarimoApp.tsx +6 -9
- package/src/core/ai/context/__tests__/registry.test.ts +4 -6
- package/src/core/ai/context/providers/cell-output.ts +2 -3
- package/src/core/ai/context/providers/error.ts +1 -3
- package/src/core/ai/context/providers/file.ts +2 -7
- package/src/core/ai/context/providers/tables.ts +2 -3
- package/src/core/ai/context/providers/variable.ts +4 -6
- package/src/core/cells/logs.ts +1 -1
- package/src/core/codemirror/find-replace/search-highlight.ts +1 -3
- package/src/core/codemirror/language/LanguageAdapters.ts +3 -9
- package/src/core/codemirror/lsp/notebook-lsp.ts +2 -8
- package/src/core/codemirror/readonly/__tests__/extension.test.ts +1 -1
- package/src/core/codemirror/rtc/loro/awareness.ts +17 -52
- package/src/core/codemirror/rtc/loro/sync.ts +4 -12
- package/src/core/config/config-schema.ts +0 -1
- package/src/core/config/config.ts +0 -4
- package/src/core/hotkeys/hotkeys.ts +4 -8
- package/src/core/islands/components/web-components.tsx +10 -13
- package/src/core/kernel/RuntimeState.ts +1 -4
- package/src/core/kernel/messages.ts +2 -2
- package/src/core/network/DeferredRequestRegistry.ts +4 -16
- package/src/core/runtime/runtime.ts +4 -5
- package/src/core/wasm/bridge.ts +1 -5
- package/src/core/wasm/store.ts +1 -4
- package/src/core/wasm/worker/message-buffer.ts +2 -3
- package/src/core/websocket/types.ts +16 -22
- package/src/hooks/useTimer.ts +5 -8
- package/src/plugins/core/registerReactComponent.tsx +10 -16
- package/src/plugins/impl/DataTablePlugin.tsx +0 -4
- package/src/plugins/impl/RangeSliderPlugin.tsx +3 -5
- package/src/plugins/impl/SliderPlugin.tsx +1 -3
- package/src/plugins/impl/anywidget/model.ts +5 -16
- package/src/plugins/impl/data-editor/types.ts +5 -7
- package/src/plugins/impl/data-explorer/components/column-summary.tsx +13 -20
- package/src/plugins/impl/panel/utils.ts +4 -6
- package/src/plugins/layout/StatPlugin.tsx +1 -4
- package/src/plugins/plugins.ts +0 -2
- package/src/utils/__tests__/dates.test.ts +24 -45
- package/src/utils/__tests__/numbers.test.ts +30 -42
- package/src/utils/dates.ts +10 -15
- package/src/utils/edit-distance.ts +6 -8
- package/src/utils/errors.ts +1 -1
- package/src/utils/id-tree.tsx +10 -21
- package/src/utils/localStorage.ts +4 -13
- package/src/utils/numbers.ts +11 -11
- package/src/utils/once.ts +0 -32
- package/src/utils/paths.ts +1 -4
- package/src/utils/pluralize.ts +5 -12
- package/src/utils/python-poet/poet.ts +15 -30
- package/src/utils/time.ts +1 -5
- package/dist/assets/ConnectedDataExplorerComponent-CNLoZkWr.js +0 -19
- package/dist/assets/_baseEach-9_logFrf.js +0 -1
- package/dist/assets/_baseMap-NzEbKt5c.js +0 -1
- package/dist/assets/_baseUniq-C5LFcyNC.js +0 -1
- package/dist/assets/channel-DHcKBVM4.js +0 -1
- package/dist/assets/chat-panel-DgJZr0eS.js +0 -3
- package/dist/assets/classDiagram-KNZD7YFC-D-xwLnlX.js +0 -1
- package/dist/assets/classDiagram-v2-RKCZMP56-D-xwLnlX.js +0 -1
- package/dist/assets/clone-CSxIll62.js +0 -1
- package/dist/assets/datasources-panel-Bt41Zir-.js +0 -1
- package/dist/assets/edit-page-CyTMQV2u.js +0 -129
- package/dist/assets/file-explorer-panel-Oy9DbyFP.js +0 -1
- package/dist/assets/home-page-Bvwppn9N.js +0 -9
- package/dist/assets/index-DadI618h.css +0 -1
- package/dist/assets/index-PmY0x4Zd.js +0 -578
- package/dist/assets/infoDiagram-STP46IZ2-CAuVVehw.js +0 -2
- package/dist/assets/links-4B6ldZ5P.js +0 -7
- package/dist/assets/min-DtVSfYKl.js +0 -1
- package/dist/assets/outline-panel-CMJjOoN7.js +0 -1
- package/dist/assets/snippets-panel-ClNnwKBM.js +0 -1
- package/dist/assets/sortBy-D47H6Vyl.js +0 -1
- package/dist/assets/stateDiagram-v2-UMBNRL4Z-DbA-iToo.js +0 -1
- package/dist/assets/storage-BNcWOH3-.js +0 -26
- package/dist/assets/tracing-DUbJtOyq.js +0 -2
- package/dist/assets/variable-panel-BbgupOdG.js +0 -1
- package/dist/assets/worker-fHbtoWvT.js +0 -1
- package/src/components/data-table/cell-hover-template/feature.ts +0 -14
- package/src/components/data-table/cell-hover-template/types.ts +0 -11
- package/src/core/i18n/__tests__/locale-provider.test.tsx +0 -176
- package/src/core/i18n/locale-provider.tsx +0 -35
- package/src/core/i18n/with-locale.tsx +0 -12
- package/src/hooks/useFormatting.ts +0 -97
- package/src/plugins/layout/OutlinePlugin.tsx +0 -69
- package/src/utils/__tests__/once.test.ts +0 -187
|
@@ -12,10 +12,7 @@ interface Storage<T> {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export class TypedLocalStorage<T> implements Storage<T> {
|
|
15
|
-
private defaultValue: T
|
|
16
|
-
constructor(defaultValue: T) {
|
|
17
|
-
this.defaultValue = defaultValue;
|
|
18
|
-
}
|
|
15
|
+
constructor(private defaultValue: T) {}
|
|
19
16
|
|
|
20
17
|
get(key: string): T {
|
|
21
18
|
try {
|
|
@@ -36,16 +33,10 @@ export class TypedLocalStorage<T> implements Storage<T> {
|
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
export class ZodLocalStorage<T> implements Storage<T> {
|
|
39
|
-
private schema: ZodType<T, ZodTypeDef, unknown>;
|
|
40
|
-
private getDefaultValue: () => T;
|
|
41
|
-
|
|
42
36
|
constructor(
|
|
43
|
-
schema: ZodType<T, ZodTypeDef, unknown>,
|
|
44
|
-
getDefaultValue: () => T,
|
|
45
|
-
) {
|
|
46
|
-
this.schema = schema;
|
|
47
|
-
this.getDefaultValue = getDefaultValue;
|
|
48
|
-
}
|
|
37
|
+
private schema: ZodType<T, ZodTypeDef, unknown>,
|
|
38
|
+
private getDefaultValue: () => T,
|
|
39
|
+
) {}
|
|
49
40
|
|
|
50
41
|
get(key: string): T {
|
|
51
42
|
try {
|
package/src/utils/numbers.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Copyright 2024 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
export function prettyNumber(value: unknown
|
|
3
|
+
export function prettyNumber(value: unknown): string {
|
|
4
4
|
if (value === undefined || value === null) {
|
|
5
5
|
return "";
|
|
6
6
|
}
|
|
@@ -18,7 +18,7 @@ export function prettyNumber(value: unknown, locale: string): string {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
if (typeof value === "number" || typeof value === "bigint") {
|
|
21
|
-
return value.toLocaleString(
|
|
21
|
+
return value.toLocaleString(undefined, {
|
|
22
22
|
minimumFractionDigits: 0,
|
|
23
23
|
maximumFractionDigits: 2,
|
|
24
24
|
});
|
|
@@ -45,9 +45,9 @@ function scientificSpecialCase(value: number): string | null {
|
|
|
45
45
|
export function prettyScientificNumber(
|
|
46
46
|
value: number,
|
|
47
47
|
opts: {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
48
|
+
// Default to false
|
|
49
|
+
shouldRound?: boolean;
|
|
50
|
+
} = {},
|
|
51
51
|
): string {
|
|
52
52
|
// Handle special cases first
|
|
53
53
|
const specialCase = scientificSpecialCase(value);
|
|
@@ -58,7 +58,7 @@ export function prettyScientificNumber(
|
|
|
58
58
|
// Determine if the number should be in scientific notation
|
|
59
59
|
const absValue = Math.abs(value);
|
|
60
60
|
if (absValue < 1e-2 || absValue >= 1e6) {
|
|
61
|
-
return new Intl.NumberFormat(
|
|
61
|
+
return new Intl.NumberFormat(undefined, {
|
|
62
62
|
minimumFractionDigits: 1,
|
|
63
63
|
maximumFractionDigits: 1,
|
|
64
64
|
notation: "scientific",
|
|
@@ -67,18 +67,18 @@ export function prettyScientificNumber(
|
|
|
67
67
|
.toLowerCase();
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const { shouldRound
|
|
70
|
+
const { shouldRound } = opts;
|
|
71
71
|
|
|
72
72
|
if (shouldRound) {
|
|
73
73
|
// Number has an integer part, format with 2 decimal places
|
|
74
|
-
return new Intl.NumberFormat(
|
|
74
|
+
return new Intl.NumberFormat(undefined, {
|
|
75
75
|
minimumFractionDigits: 0,
|
|
76
76
|
maximumFractionDigits: 2,
|
|
77
77
|
}).format(value);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// Don't round
|
|
81
|
-
return value.toLocaleString(
|
|
81
|
+
return value.toLocaleString(undefined, {
|
|
82
82
|
minimumFractionDigits: 0,
|
|
83
83
|
maximumFractionDigits: 100,
|
|
84
84
|
});
|
|
@@ -104,14 +104,14 @@ const prefixes = {
|
|
|
104
104
|
"-24": "y",
|
|
105
105
|
};
|
|
106
106
|
|
|
107
|
-
export function prettyEngineeringNumber(value: number
|
|
107
|
+
export function prettyEngineeringNumber(value: number): string {
|
|
108
108
|
// Handle special cases first
|
|
109
109
|
const specialCase = scientificSpecialCase(value);
|
|
110
110
|
if (specialCase !== null) {
|
|
111
111
|
return specialCase;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const [mant, exp] = new Intl.NumberFormat(
|
|
114
|
+
const [mant, exp] = new Intl.NumberFormat("en-us", {
|
|
115
115
|
notation: "engineering",
|
|
116
116
|
maximumSignificantDigits: 3,
|
|
117
117
|
})
|
package/src/utils/once.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/* Copyright 2024 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
-
import { arrayShallowEquals } from "./arrays";
|
|
4
|
-
|
|
5
3
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
4
|
export function once<T extends (...args: any[]) => any>(fn: T): T {
|
|
7
5
|
let result: ReturnType<T>;
|
|
@@ -17,33 +15,3 @@ export function once<T extends (...args: any[]) => any>(fn: T): T {
|
|
|
17
15
|
return result;
|
|
18
16
|
} as T;
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
export function memoizeLastValue<T extends (...args: any[]) => any>(fn: T): T {
|
|
23
|
-
let result: ReturnType<T>;
|
|
24
|
-
let lastArgs: Parameters<T> | undefined;
|
|
25
|
-
let lastError: unknown;
|
|
26
|
-
let hasError = false;
|
|
27
|
-
|
|
28
|
-
return function (
|
|
29
|
-
this: ThisParameterType<T>,
|
|
30
|
-
...args: Parameters<T>
|
|
31
|
-
): ReturnType<T> {
|
|
32
|
-
if (lastArgs === undefined || !arrayShallowEquals(args, lastArgs)) {
|
|
33
|
-
try {
|
|
34
|
-
result = fn.apply(this, args) as ReturnType<T>;
|
|
35
|
-
hasError = false;
|
|
36
|
-
lastError = undefined;
|
|
37
|
-
} catch (error) {
|
|
38
|
-
hasError = true;
|
|
39
|
-
lastError = error;
|
|
40
|
-
}
|
|
41
|
-
lastArgs = args;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (hasError) {
|
|
45
|
-
throw lastError;
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
} as T;
|
|
49
|
-
}
|
package/src/utils/paths.ts
CHANGED
|
@@ -32,10 +32,7 @@ export const Paths = {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export class PathBuilder {
|
|
35
|
-
public readonly deliminator:
|
|
36
|
-
constructor(deliminator: "/" | "\\") {
|
|
37
|
-
this.deliminator = deliminator;
|
|
38
|
-
}
|
|
35
|
+
constructor(public readonly deliminator: "/" | "\\") {}
|
|
39
36
|
|
|
40
37
|
static guessDeliminator(path: string): PathBuilder {
|
|
41
38
|
return path.includes("/") ? new PathBuilder("/") : new PathBuilder("\\");
|
package/src/utils/pluralize.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
/* Copyright 2024 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
export class PluralWord {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.singular = singular;
|
|
9
|
-
this._plural = _plural;
|
|
10
|
-
}
|
|
4
|
+
constructor(
|
|
5
|
+
public singular: string,
|
|
6
|
+
public _plural?: string,
|
|
7
|
+
) {}
|
|
11
8
|
|
|
12
9
|
public pluralize(count: number) {
|
|
13
10
|
return count === 1 ? this.singular : this.plural;
|
|
@@ -19,11 +16,7 @@ export class PluralWord {
|
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
export class PluralWords {
|
|
22
|
-
private words: PluralWord[]
|
|
23
|
-
|
|
24
|
-
constructor(words: PluralWord[]) {
|
|
25
|
-
this.words = words;
|
|
26
|
-
}
|
|
19
|
+
constructor(private words: PluralWord[]) {}
|
|
27
20
|
|
|
28
21
|
static of(...words: Array<PluralWord | string>) {
|
|
29
22
|
return new PluralWords(
|
|
@@ -25,10 +25,7 @@ function asString(value: string | PythonCode): string {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export class Variable implements PythonCode {
|
|
28
|
-
name: string
|
|
29
|
-
constructor(name: string) {
|
|
30
|
-
this.name = name;
|
|
31
|
-
}
|
|
28
|
+
constructor(public name: string) {}
|
|
32
29
|
|
|
33
30
|
toCode(): string {
|
|
34
31
|
return this.name;
|
|
@@ -41,12 +38,10 @@ interface LiteralOptions {
|
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
export class Literal implements PythonCode {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.opts = opts;
|
|
49
|
-
}
|
|
41
|
+
constructor(
|
|
42
|
+
public readonly value: unknown,
|
|
43
|
+
public readonly opts: LiteralOptions = {},
|
|
44
|
+
) {}
|
|
50
45
|
|
|
51
46
|
static from(value: unknown, opts: LiteralOptions = {}): Literal {
|
|
52
47
|
return new Literal(value, opts);
|
|
@@ -119,13 +114,10 @@ export class Literal implements PythonCode {
|
|
|
119
114
|
}
|
|
120
115
|
|
|
121
116
|
export class VariableDeclaration implements PythonCode {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.name = name;
|
|
127
|
-
this.value = value;
|
|
128
|
-
}
|
|
117
|
+
constructor(
|
|
118
|
+
public name: string,
|
|
119
|
+
public value: string | PythonCode,
|
|
120
|
+
) {}
|
|
129
121
|
|
|
130
122
|
toCode(): string {
|
|
131
123
|
const right = asString(this.value);
|
|
@@ -137,13 +129,10 @@ export class VariableDeclaration implements PythonCode {
|
|
|
137
129
|
}
|
|
138
130
|
|
|
139
131
|
export class FunctionArg implements PythonCode {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
this.name = name;
|
|
145
|
-
this.value = value;
|
|
146
|
-
}
|
|
132
|
+
constructor(
|
|
133
|
+
public name: string,
|
|
134
|
+
public value: string | PythonCode,
|
|
135
|
+
) {}
|
|
147
136
|
|
|
148
137
|
toCode(): string {
|
|
149
138
|
return `${this.name}=${asString(this.value)}`;
|
|
@@ -152,16 +141,12 @@ export class FunctionArg implements PythonCode {
|
|
|
152
141
|
|
|
153
142
|
export class FunctionCall implements PythonCode {
|
|
154
143
|
private args: PythonCode[];
|
|
155
|
-
public name: string;
|
|
156
|
-
public multiLine: boolean;
|
|
157
144
|
|
|
158
145
|
constructor(
|
|
159
|
-
name: string,
|
|
146
|
+
public name: string,
|
|
160
147
|
args: PythonCode[] | Record<string, PythonCode>,
|
|
161
|
-
multiLine = false,
|
|
148
|
+
public multiLine = false,
|
|
162
149
|
) {
|
|
163
|
-
this.name = name;
|
|
164
|
-
this.multiLine = multiLine;
|
|
165
150
|
this.args = objectToArgs(args);
|
|
166
151
|
}
|
|
167
152
|
|
package/src/utils/time.ts
CHANGED
|
@@ -5,8 +5,6 @@ export type Milliseconds = number & { __type__: "milliseconds" };
|
|
|
5
5
|
export type Seconds = number & { __type__: "seconds" };
|
|
6
6
|
|
|
7
7
|
export class Time {
|
|
8
|
-
private readonly ms: Milliseconds;
|
|
9
|
-
|
|
10
8
|
static fromMilliseconds(ms: Milliseconds): Time;
|
|
11
9
|
static fromMilliseconds(ms: Milliseconds | null): Time | null;
|
|
12
10
|
static fromMilliseconds(ms: Milliseconds | null): Time | null {
|
|
@@ -29,9 +27,7 @@ export class Time {
|
|
|
29
27
|
return new Time(Date.now() as Milliseconds);
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
private constructor(ms: Milliseconds) {
|
|
33
|
-
this.ms = ms;
|
|
34
|
-
}
|
|
30
|
+
private constructor(private readonly ms: Milliseconds) {}
|
|
35
31
|
|
|
36
32
|
toMilliseconds(): Milliseconds {
|
|
37
33
|
return this.ms;
|