@marimo-team/islands 0.25.2-dev99 → 0.25.3-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/{ConnectedDataExplorerComponent-BZmqc_F0.js → ConnectedDataExplorerComponent-CNMliVzw.js} +15 -15
- package/dist/{ErrorBoundary-CXkr_IcB.js → ErrorBoundary-BsqSMK9Y.js} +12 -12
- package/dist/{ImageComparisonComponent-Cpfz30OZ.js → ImageComparisonComponent-uU8FSKZE.js} +3 -3
- package/dist/{Plot-CTyjbQDT.js → Plot-DdYOe1UK.js} +2 -2
- package/dist/{abnfDiagram-VCTEODGH-C_Lmaa2j.js → abnfDiagram-VCTEODGH-D-Ez91gV.js} +3 -3
- package/dist/{any-language-editor-BFzqhOBR.js → any-language-editor-DZ_YTVus.js} +7 -7
- package/dist/{architectureDiagram-5GKGNRK7-BKMataHB.js → architectureDiagram-5GKGNRK7-CTpcNtO8.js} +5 -5
- package/dist/assets/__vite-browser-external-BXYkiFsk.js +1 -0
- package/dist/assets/worker-HPY9fbhz.js +114 -0
- package/dist/{blockDiagram-I7D4REHJ-BeHOjyDk.js → blockDiagram-I7D4REHJ-Cg25UrxT.js} +9 -9
- package/dist/{button-BtsM2UqM.js → button-CvjkwdSk.js} +5 -5
- package/dist/{c4Diagram-7LVT6UL2-Bao10t_O.js → c4Diagram-7LVT6UL2-BxFgrnNV.js} +7 -7
- package/dist/{capabilities-A5jrzjCJ.js → capabilities-CQ5IjhzL.js} +1 -1
- package/dist/{channel-BxCkvUgE.js → channel-CPObtJXj.js} +1 -1
- package/dist/{chat-ui-CwOWzoSO.js → chat-ui-0lKdOoQ3.js} +1588 -1396
- package/dist/{check-CNP79M3A.js → check-EDwSwP89.js} +1 -1
- package/dist/{chunk-4HAMMTFA-CH7Gpamd.js → chunk-4HAMMTFA-D4eFPyFh.js} +5 -5
- package/dist/{chunk-75Z2AOVW-AI7CvgKn.js → chunk-75Z2AOVW-D7gxIs2Q.js} +1 -1
- package/dist/{chunk-DU6HZSFF-BSvuTkX4.js → chunk-DU6HZSFF-BwiyaNpg.js} +1 -1
- package/dist/{chunk-F27PBJKO-CLshwT9T.js → chunk-F27PBJKO-ufseIn5y.js} +1 -1
- package/dist/{chunk-GMAD6QVW-wnHcn-lH.js → chunk-GMAD6QVW-BhaJx0X3.js} +3 -3
- package/dist/{chunk-GVQU2GXP-7O2p8hut.js → chunk-GVQU2GXP-Cwbt-lF0.js} +2 -2
- package/dist/{chunk-IMKFNOWR-Bu0Vh_Yi.js → chunk-IMKFNOWR-DGxi-zeo.js} +5 -5
- package/dist/{chunk-L3NEJ4N5-B9_Alrxb.js → chunk-L3NEJ4N5-n-zgIVSy.js} +5 -5
- package/dist/{chunk-OSK3NFVY-PeQPH2fD.js → chunk-OSK3NFVY-DXa-Cxbn.js} +6 -6
- package/dist/{chunk-P2QGCYS3-D9twiFuU.js → chunk-P2QGCYS3-B_Zd3-X0.js} +1 -1
- package/dist/{chunk-POPQ4Y6H-BUiNs18s.js → chunk-POPQ4Y6H-hYOXbYH_.js} +1 -1
- package/dist/{chunk-PWAF6VOD-D8S9NPCy.js → chunk-PWAF6VOD-CQw5qATZ.js} +1 -1
- package/dist/{chunk-SHT3W25Y-B2dyNZ31.js → chunk-SHT3W25Y-CV9J3rAB.js} +7 -7
- package/dist/{chunk-SVP7TREG-D7UPvB10.js → chunk-SVP7TREG-BL-9Fqgg.js} +2 -2
- package/dist/{chunk-TICWLB2K-BNaGoadd.js → chunk-TICWLB2K-Cu_XMjDM.js} +5 -5
- package/dist/{chunk-YOKDWASO-DrWbKnxA.js → chunk-YOKDWASO-DPZk8vhS.js} +6 -6
- package/dist/classDiagram-ZZMXUADV-BXXV13Hq.js +30 -0
- package/dist/classDiagram-v2-VYDZK3BY-B7FXJ1Cp.js +30 -0
- package/dist/{code-visibility-pPjYsRTH.js → code-visibility-CXQvUXHT.js} +18 -18
- package/dist/{common-CkvBp0B4.js → common-CuD-CAC-.js} +6128 -7136
- package/dist/{compiler-runtime-Cj8ZWiNS.js → compiler-runtime-CldRdSsv.js} +2 -2
- package/dist/{copy-icon-BY7jgcaV.js → copy-icon-Ft7t9bqz.js} +6 -6
- package/dist/{cynefinDiagram-5FMLGOSQ-CCDn4Z9e.js → cynefinDiagram-5FMLGOSQ-CH96rwba.js} +3 -3
- package/dist/{dagre-GXQ25YYZ-BJiUO_SV.js → dagre-GXQ25YYZ-BD3PmpFY.js} +10 -10
- package/dist/{data-grid-overlay-editor-L6ELxFAh.js → data-grid-overlay-editor-DgeyYmC1.js} +7 -7
- package/dist/{data-grid-types-BucVmDDp.js → data-grid-types-BH_r7g7l.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-BZfxFNRR.js → diagram-S7CK7UJ4-BsSJJldB.js} +4 -4
- package/dist/{diagram-UQ7AKVKN-1xcsiIMg.js → diagram-UQ7AKVKN-muQtNZc4.js} +3 -3
- package/dist/{diagram-VSXAHHWV-DPAWJ9Nw.js → diagram-VSXAHHWV-BJWcVVJY.js} +2 -2
- package/dist/{diagram-VX7I27RA-DmRsnHYY.js → diagram-VX7I27RA-CdhuZAqR.js} +5 -5
- package/dist/{diagram-Z3DM3KII--b49ryKx.js → diagram-Z3DM3KII-BD8mXjOj.js} +3 -3
- package/dist/{dialog-CmExhUDI.js → dialog-CEBFZNyc.js} +6 -6
- package/dist/{dist-CcyKTBTF.js → dist-DpBpA_n1.js} +2 -2
- package/dist/{dropdown-menu-Cz4TdOJh.js → dropdown-menu-CP_qCYHC.js} +139 -139
- package/dist/{ebnfDiagram-PWID7BFC-rSwVyh4y.js → ebnfDiagram-PWID7BFC-BIN1sweE.js} +3 -3
- package/dist/{erDiagram-RLTQ6QDP-Bfd3iAoC.js → erDiagram-RLTQ6QDP-Ctp5cfoN.js} +12 -12
- package/dist/{error-banner-D30nA9nE.js → error-banner-D-WCIiMt.js} +16 -11
- package/dist/{cells-DZi0ioak.js → error-entries-DSvFWT_M.js} +6171 -5075
- package/dist/{esm-DAVrGVKP.js → esm-AMFssoNp.js} +4 -4
- package/dist/{feedback-button-D-pV0Qji.js → feedback-button-DZMj9PF3.js} +119 -120
- package/dist/flowDiagram-HODETNUW-3EfLrlFb.js +16 -0
- package/dist/{formats-DhhbdyAH.js → formats-CeOmU1MU.js} +6 -6
- package/dist/{ganttDiagram-EL5Y4UJY-B4m_YsKa.js → ganttDiagram-EL5Y4UJY-BQT16JSc.js} +2 -2
- package/dist/{gitGraphDiagram-WWUBYQGX-QRBbvWXh.js → gitGraphDiagram-WWUBYQGX-D5nSIzdE.js} +2 -2
- package/dist/{glide-data-editor-D6CfYwdr.js → glide-data-editor-g_L8FLAC.js} +60 -60
- package/dist/{glide-utils-BVJ4fkxX.js → glide-utils-DJyqh0EM.js} +4 -4
- package/dist/{globals-BwK9YGrX.js → globals-CYGlmBXb.js} +3 -3
- package/dist/{highlighted-body-KPVGNVTW-Ad3MKZ18.js → highlighted-body-KPVGNVTW-zwjq21tf.js} +4 -4
- package/dist/{html-to-image-Cn1_16-x.js → html-to-image-B8s5SgGm.js} +37 -37
- package/dist/{infoDiagram-27XIBGKW-DVQFYvhg.js → infoDiagram-27XIBGKW-DipQoHxl.js} +2 -2
- package/dist/{ishikawaDiagram-5VMMS53U-viPND-nm.js → ishikawaDiagram-5VMMS53U-DgFMjSGz.js} +3 -3
- package/dist/{journeyDiagram-3NMN7TZE-BeeJdJo3.js → journeyDiagram-3NMN7TZE-BaLqn-dZ.js} +2 -2
- package/dist/{jsx-runtime-DgDPJV9S.js → jsx-runtime-3BD1kT0s.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-Dcl_ECO9.js → kanban-definition-UXKFOSKX-w1ACVjgl.js} +9 -9
- package/dist/{katex-BNCmKUol.js → katex-BIdZGsyO.js} +141 -116
- package/dist/{label-DQO1jFjf.js → label-BDKF3Afc.js} +10 -10
- package/dist/{loader-Cm-ATtou.js → loader-BQOfjTIJ.js} +1 -1
- package/dist/main.js +623 -590
- package/dist/{mermaid-BfhcnSj-.js → mermaid-CHo49Yv-.js} +56 -56
- package/dist/mermaid-HWGCJPDP-ByCsZnYF.js +2 -0
- package/dist/{mhchem-BEc7A1or.js → mhchem-CdWPJK6g.js} +1 -1
- package/dist/{mindmap-definition-YA3MSWOX-BdxxhF-5.js → mindmap-definition-YA3MSWOX-CrT0KSfX.js} +11 -11
- package/dist/{number-overlay-editor-tMylyldi.js → number-overlay-editor-9VRv-pdj.js} +5 -5
- package/dist/{pegDiagram-XKGWAZYB-Du5p2s0w.js → pegDiagram-XKGWAZYB-BqvywNJA.js} +3 -3
- package/dist/{pieDiagram-E7YTZNPT-DJg-SOIq.js → pieDiagram-E7YTZNPT-BfxJ_XCc.js} +3 -3
- package/dist/{process-output-CUG57KRp.js → process-output-CKRXyszb.js} +5 -5
- package/dist/{quadrantDiagram-AXDQQJYC-keLfFx9f.js → quadrantDiagram-AXDQQJYC-Ccw0xMjN.js} +1 -1
- package/dist/{railroadDiagram-O6MQD6OU-C0ojm-6_.js → railroadDiagram-O6MQD6OU-8vFLVTPu.js} +3 -3
- package/dist/{react-dom-BUgJ-ab_.js → react-dom-DUmH0GXv.js} +29 -21
- package/dist/{react-ofJbxM4x.js → react-sHtZdjeP.js} +103 -94
- package/dist/{react-vega-ewj7q_U5.js → react-vega-BED0DjiB.js} +3 -3
- package/dist/{requirementDiagram-BXWQKSXE-CNwNBmI3.js → requirementDiagram-BXWQKSXE-a_MxGvxe.js} +11 -11
- package/dist/{reveal-component-LXUMcqWX.js → reveal-component-C87mv9Mn.js} +906 -878
- package/dist/{sankeyDiagram-P5KCCOFB-Bh4EsJox.js → sankeyDiagram-P5KCCOFB-ELvOcnZH.js} +1 -1
- package/dist/{select-Bs-nmvm6.js → select-BButFi-d.js} +11 -11
- package/dist/{sequenceDiagram-WJ2MYXX4-DQaW5qBG.js → sequenceDiagram-WJ2MYXX4-CXFMnxGh.js} +4 -4
- package/dist/{spec-DVsoMvYT.js → spec-BwarBpUJ.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-BDa515QC.js → stateDiagram-D77RDMKH-DQeA_CwI.js} +13 -13
- package/dist/stateDiagram-v2-MP3YSRHH-BxxQucm1.js +30 -0
- package/dist/style.css +1 -1
- package/dist/{swimlanes-42K2YHIH-M4IdGi8J.js → swimlanes-42K2YHIH-Do6L-cYg.js} +10 -10
- package/dist/swimlanesDiagram-VR7AAH4N-DUzPvSVU.js +30 -0
- package/dist/{swiper-component-CpN-hewZ.js → swiper-component-DKntyn8p.js} +5 -5
- package/dist/{timeline-definition-24CTP7MA-DH-kvakg.js → timeline-definition-24CTP7MA-D3c46WM5.js} +3 -3
- package/dist/{toDate-vEi5kTfY.js → toDate-vIXljnsr.js} +43 -42
- package/dist/{toast-DfEpJedt.js → toast-B9UMEi8u.js} +9 -9
- package/dist/{tooltip-CuNWg2ay.js → tooltip-BO1REbqs.js} +7 -7
- package/dist/{use-restore-focus-kmgwrL8q.js → use-restore-focus-BEM7sFWl.js} +2042 -1827
- package/dist/{use-vega-container-remeasure-4DwJbPWu.js → use-vega-container-remeasure-Bz4PZMtt.js} +2 -2
- package/dist/{useAsyncData-rkAlR_vh.js → useAsyncData-Deh5kszT.js} +3 -3
- package/dist/{useDateFormatter-C-tz65rD.js → useDateFormatter-D8XruNGG.js} +4 -4
- package/dist/{useDeepCompareMemoize-BlHFBj5_.js → useDeepCompareMemoize-DXwzRINI.js} +2 -2
- package/dist/{useIframeCapabilities-C1Bt04Iz.js → useIframeCapabilities-DBETvvPl.js} +2 -2
- package/dist/{useLifecycle-B68iY077.js → useLifecycle-j7D9uD1o.js} +6 -6
- package/dist/{useTheme-BwSgeAFb.js → useTheme-CRnjkku0.js} +7 -7
- package/dist/{vega-component-C-bPttRN.js → vega-component-DTG6zxaY.js} +14 -14
- package/dist/{vega-embed-container-sSR5hAsy.js → vega-embed-container-BNHE18G9.js} +5 -5
- package/dist/{vennDiagram-4TSXK5OY-d5g7XeiI.js → vennDiagram-4TSXK5OY-BSZD8JcZ.js} +3 -3
- package/dist/{wardleyDiagram-VM6X3IG4-BfX3bSzR.js → wardleyDiagram-VM6X3IG4-48cUWkfA.js} +3 -3
- package/dist/{xychartDiagram-S5SC5T6Z-C1QsLZg7.js → xychartDiagram-S5SC5T6Z-CswYgYeu.js} +5 -5
- package/package.json +25 -22
- package/src/__tests__/fixtures/{pair-preview.ts → pair-config.ts} +3 -2
- package/src/__tests__/host-imports.test.ts +100 -0
- package/src/__tests__/mount.test.ts +8 -8
- package/src/components/data-table/__tests__/column_formatting.test.ts +30 -0
- package/src/components/data-table/__tests__/columns.test.tsx +70 -0
- package/src/components/data-table/__tests__/context-menu.test.ts +176 -0
- package/src/components/data-table/__tests__/date-filter-inputs.test.tsx +24 -1
- package/src/components/data-table/__tests__/export-actions.test.tsx +329 -6
- package/src/components/data-table/column-formatting/feature.ts +20 -1
- package/src/components/data-table/columns.tsx +25 -18
- package/src/components/data-table/context-menu.tsx +125 -26
- package/src/components/data-table/date-filter-inputs.tsx +15 -42
- package/src/components/data-table/export-actions.tsx +192 -116
- package/src/components/data-table/schemas.ts +14 -36
- package/src/components/data-table/utils.ts +18 -0
- package/src/components/editor/Output.tsx +9 -2
- package/src/components/editor/actions/__tests__/pair-with-agent-commands.test.ts +80 -252
- package/src/components/editor/actions/__tests__/pair-with-agent-modal.test.tsx +186 -34
- package/src/components/editor/actions/pair-with-agent-commands.ts +42 -51
- package/src/components/editor/actions/pair-with-agent-modal.tsx +96 -36
- package/src/components/editor/chrome/panels/error-panel.tsx +1 -0
- package/src/components/editor/chrome/wrapper/__tests__/attachment-status.test.tsx +372 -0
- package/src/components/editor/chrome/wrapper/footer-item.tsx +32 -24
- package/src/components/editor/chrome/wrapper/footer-items/attachment-status.tsx +237 -0
- package/src/components/editor/chrome/wrapper/footer.tsx +2 -0
- package/src/components/editor/controls/__tests__/notebook-menu-dropdown.test.tsx +4 -3
- package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +548 -0
- package/src/components/editor/errors/send-error-report-button.tsx +69 -0
- package/src/components/editor/output/MarimoErrorOutput.tsx +21 -5
- package/src/components/editor/output/MarimoTracebackOutput.tsx +35 -20
- package/src/components/editor/output/__tests__/ansi-reduce.test.ts +18 -0
- package/src/components/editor/output/ansi-reduce.ts +6 -0
- package/src/components/editor/output/console/ConsoleOutput.tsx +5 -3
- package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +18 -0
- package/src/components/storage/__tests__/storage-file-viewer.test.tsx +2 -1
- package/src/core/attachments/__tests__/toast.test.tsx +58 -0
- package/src/core/attachments/state.ts +21 -0
- package/src/core/attachments/toast.ts +15 -0
- package/src/core/cells/__tests__/cells.test.ts +52 -0
- package/src/core/cells/__tests__/document-roundtrip.test.ts +16 -0
- package/src/core/cells/__tests__/error-report.test.ts +139 -0
- package/src/core/cells/__tests__/session.test.ts +50 -1
- package/src/core/cells/error-report.ts +63 -0
- package/src/core/cells/session.ts +28 -1
- package/src/core/codemirror/copilot/__tests__/completion-integration.test.ts +447 -0
- package/src/core/codemirror/copilot/__tests__/inline-completion.test.ts +395 -0
- package/src/core/codemirror/copilot/__tests__/language-server.test.ts +511 -2
- package/src/core/codemirror/copilot/__tests__/rpc-cancellation.test.ts +201 -0
- package/src/core/codemirror/copilot/extension.ts +22 -11
- package/src/core/codemirror/copilot/language-server.ts +109 -60
- package/src/core/codemirror/language/__tests__/sql.test.ts +4 -3
- package/src/core/codemirror/language/embedded/__tests__/embedded-python.test.ts +138 -26
- package/src/core/codemirror/language/embedded/embedded-python.ts +47 -13
- package/src/core/codemirror/language/embedded/latex.ts +20 -13
- package/src/core/config/pair.ts +5 -3
- package/src/core/datasets/__tests__/data-source-discovery.test.ts +18 -11
- package/src/core/host/AGENTS.md +6 -0
- package/src/core/host/__tests__/protocol.test.ts +214 -0
- package/src/core/host/protocol.ts +1943 -0
- package/src/core/islands/__tests__/bootstrap.test.ts +26 -0
- package/src/core/islands/bootstrap.ts +1 -0
- package/src/core/islands/bridge.ts +2 -2
- package/src/core/kernel/messages.ts +4 -7
- package/src/core/network/__tests__/api.test.ts +114 -1
- package/src/core/network/api.ts +3 -2
- package/src/core/wasm/bridge.ts +2 -2
- package/src/core/wasm/worker/types.ts +2 -2
- package/src/core/websocket/__tests__/useMarimoKernelConnection.hook.test.tsx +193 -0
- package/src/core/websocket/useMarimoKernelConnection.tsx +9 -0
- package/src/css/katex-css.test.ts +1 -1
- package/src/css/katex.min.css +6 -1
- package/src/hooks/__tests__/useEventListener.test.tsx +45 -1
- package/src/hooks/useEventListener.ts +6 -1
- package/src/mount.tsx +3 -3
- package/src/plugins/impl/NumberPlugin.tsx +20 -3
- package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +84 -0
- package/src/plugins/impl/__tests__/NumberPlugin.test.tsx +159 -1
- package/src/utils/__tests__/dates.test.ts +116 -0
- package/src/utils/dates.ts +94 -0
- package/dist/assets/__vite-browser-external-BqAtzd2P.js +0 -1
- package/dist/assets/worker-Bf8dt6S-.js +0 -109
- package/dist/classDiagram-ZZMXUADV-Bbo2n384.js +0 -30
- package/dist/classDiagram-v2-VYDZK3BY-xR8cGP0r.js +0 -30
- package/dist/error-entries-BovkFYNy.js +0 -56
- package/dist/flowDiagram-HODETNUW-D7IBKS12.js +0 -16
- package/dist/mermaid-HWGCJPDP-DYCzSILp.js +0 -2
- package/dist/stateDiagram-v2-MP3YSRHH-ChNddepZ.js +0 -30
- package/dist/swimlanesDiagram-VR7AAH4N-FUSwmzEp.js +0 -30
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import NodeFs from "node:fs";
|
|
4
|
+
import NodeUrl from "node:url";
|
|
5
|
+
import { describe, expect, expectTypeOf, it } from "vitest";
|
|
6
|
+
import * as Protocol from "../protocol";
|
|
7
|
+
|
|
8
|
+
const fixtures = new NodeUrl.URL(
|
|
9
|
+
"../../../../../protocols/host/fixtures/",
|
|
10
|
+
import.meta.url,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
function readFixture(name: string): unknown {
|
|
14
|
+
return JSON.parse(
|
|
15
|
+
NodeFs.readFileSync(new NodeUrl.URL(name, fixtures), "utf8"),
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const records = {
|
|
20
|
+
"record.json": Protocol.HostRecord,
|
|
21
|
+
"cell.json": Protocol.Cell,
|
|
22
|
+
"analysis.json": Protocol.Analysis,
|
|
23
|
+
"diagnostic.json": Protocol.Error,
|
|
24
|
+
"edit.json": Protocol.EditRequest,
|
|
25
|
+
"edit-conflict-request.json": Protocol.EditRequest,
|
|
26
|
+
"edit-response.json": Protocol.EditResponse,
|
|
27
|
+
"execution-restored.json": Protocol.Execution,
|
|
28
|
+
"run-cells-request.json": Protocol.RunRequest,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
describe("host protocol fixtures", () => {
|
|
32
|
+
it.each(Object.entries(records))("parses %s unchanged", (name, schema) => {
|
|
33
|
+
const input = readFixture(name);
|
|
34
|
+
const original = structuredClone(input);
|
|
35
|
+
expect(schema.parse(input)).toEqual(original);
|
|
36
|
+
expect(input).toEqual(original);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it.each(NodeFs.readdirSync(new NodeUrl.URL("problems/", fixtures)))(
|
|
40
|
+
"parses problem %s",
|
|
41
|
+
(name) => {
|
|
42
|
+
const input = readFixture(`problems/${name}`);
|
|
43
|
+
expect(Protocol.Problem.parse(input)).toEqual(input);
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
it.each(NodeFs.readdirSync(fixtures).filter((name) => name.endsWith(".sse")))(
|
|
48
|
+
"parses events in %s unchanged",
|
|
49
|
+
(name) => {
|
|
50
|
+
const stream = NodeFs.readFileSync(
|
|
51
|
+
new NodeUrl.URL(name, fixtures),
|
|
52
|
+
"utf8",
|
|
53
|
+
);
|
|
54
|
+
let count = 0;
|
|
55
|
+
for (const frame of stream.split(/\r?\n\r?\n/)) {
|
|
56
|
+
const event = /^event: (.+)$/m.exec(frame)?.[1];
|
|
57
|
+
if (!event && !/^data:/m.test(frame)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const data = frame
|
|
61
|
+
.split(/\r?\n/)
|
|
62
|
+
.filter((line) => line.startsWith("data:"))
|
|
63
|
+
.map((line) => line.slice(5).trimStart())
|
|
64
|
+
.join("\n");
|
|
65
|
+
const id = /^id: (.+)$/m.exec(frame)?.[1];
|
|
66
|
+
const payload: unknown = JSON.parse(data);
|
|
67
|
+
const input = { event, data: payload, ...(id ? { id } : {}) };
|
|
68
|
+
const original = structuredClone(input);
|
|
69
|
+
expect(Protocol.Event.parse(input)).toEqual(original);
|
|
70
|
+
expect(input).toEqual(original);
|
|
71
|
+
count += 1;
|
|
72
|
+
}
|
|
73
|
+
expect(count).toBeGreaterThan(0);
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe("host protocol bindings", () => {
|
|
79
|
+
it("preserves native marimo payloads without interpreting them", () => {
|
|
80
|
+
expectTypeOf<Protocol.MarimoEvent["data"]["marimo"]>().toBeUnknown();
|
|
81
|
+
const input = {
|
|
82
|
+
event: "marimo",
|
|
83
|
+
id: "42",
|
|
84
|
+
data: {
|
|
85
|
+
marimo: {
|
|
86
|
+
future_payload: { value: Number.NaN },
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
expect(Protocol.Event.parse(input)).toEqual(input);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("accepts additive fields and preserves arbitrary notebook settings", () => {
|
|
94
|
+
const cell = Protocol.Cell.parse(readFixture("cell.json"));
|
|
95
|
+
const input = {
|
|
96
|
+
...cell,
|
|
97
|
+
future: { enabled: true },
|
|
98
|
+
config: { ...cell.config, future: 42 },
|
|
99
|
+
};
|
|
100
|
+
const original = structuredClone(input);
|
|
101
|
+
expect(Protocol.Cell.parse(input)).toEqual(cell);
|
|
102
|
+
expect(input).toEqual(original);
|
|
103
|
+
|
|
104
|
+
const { document } = Protocol.EditResponse.parse(
|
|
105
|
+
readFixture("edit-response.json"),
|
|
106
|
+
);
|
|
107
|
+
const configured = {
|
|
108
|
+
...document,
|
|
109
|
+
app_config: { extension: { values: [1, null, false] } },
|
|
110
|
+
};
|
|
111
|
+
expect(Protocol.Document.parse(configured)).toEqual(configured);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("applies the defaults declared for cell inputs", () => {
|
|
115
|
+
expect(
|
|
116
|
+
Protocol.CellInput.parse({ id: "c3", code: "x = 1", config: {} }),
|
|
117
|
+
).toEqual({
|
|
118
|
+
id: "c3",
|
|
119
|
+
code: "x = 1",
|
|
120
|
+
name: "_",
|
|
121
|
+
config: {
|
|
122
|
+
column: null,
|
|
123
|
+
disabled: false,
|
|
124
|
+
hide_code: false,
|
|
125
|
+
expand_output: false,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it.each(["run_id", "runtime_id", "caused_by"] as const)(
|
|
131
|
+
"requires the nullable execution field %s",
|
|
132
|
+
(field) => {
|
|
133
|
+
const execution = Protocol.Execution.parse(
|
|
134
|
+
readFixture("execution-restored.json"),
|
|
135
|
+
);
|
|
136
|
+
const missing = Object.fromEntries(
|
|
137
|
+
Object.entries(execution).filter(([key]) => key !== field),
|
|
138
|
+
);
|
|
139
|
+
expect(Protocol.Execution.safeParse(missing).success).toBe(false);
|
|
140
|
+
expect(
|
|
141
|
+
Protocol.Execution.safeParse({ ...execution, [field]: null }).success,
|
|
142
|
+
).toBe(true);
|
|
143
|
+
},
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
it("preserves snapshot metadata omissions and validates live timestamps", () => {
|
|
147
|
+
const cell = Protocol.Cell.parse(readFixture("cell.json"));
|
|
148
|
+
expect(Protocol.CellMessage.parse({ cell })).toEqual({ cell });
|
|
149
|
+
const message = { cell, time: "2026-01-01T12:00:00+05:30" };
|
|
150
|
+
expect(Protocol.CellMessage.parse(message)).toEqual(message);
|
|
151
|
+
for (const time of [
|
|
152
|
+
null,
|
|
153
|
+
"yesterday",
|
|
154
|
+
"2026-02-30T12:00:00Z",
|
|
155
|
+
"2026-01-01T12:00:00",
|
|
156
|
+
]) {
|
|
157
|
+
expect(Protocol.CellMessage.safeParse({ cell, time }).success).toBe(
|
|
158
|
+
false,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("rejects invalid cell fields without coercing their values", () => {
|
|
164
|
+
const cell = Protocol.Cell.parse(readFixture("cell.json"));
|
|
165
|
+
for (const patch of [
|
|
166
|
+
{ id: "" },
|
|
167
|
+
{ code: 42 },
|
|
168
|
+
{ etag: 42 },
|
|
169
|
+
{ version: "2" },
|
|
170
|
+
{ version: 0 },
|
|
171
|
+
{ version: 1.5 },
|
|
172
|
+
{ config: { ...cell.config, disabled: "false" } },
|
|
173
|
+
]) {
|
|
174
|
+
expect(Protocol.Cell.safeParse({ ...cell, ...patch }).success).toBe(
|
|
175
|
+
false,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
const result = Protocol.Cell.safeParse({ ...cell, code: 42 });
|
|
179
|
+
expect(result.success).toBe(false);
|
|
180
|
+
if (result.success) {
|
|
181
|
+
throw new Error("Expected an invalid cell");
|
|
182
|
+
}
|
|
183
|
+
expect(result.error.issues).toEqual([
|
|
184
|
+
expect.objectContaining({ path: ["code"], code: "invalid_type" }),
|
|
185
|
+
]);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("requires the fields of the selected change kind", () => {
|
|
189
|
+
const change = { kind: "delete_cell", id: "c3", base_etag: "*" };
|
|
190
|
+
expect(Protocol.Change.parse(change)).toEqual(change);
|
|
191
|
+
expect(
|
|
192
|
+
Protocol.Change.safeParse({ kind: "delete_cell", id: "c3" }).success,
|
|
193
|
+
).toBe(false);
|
|
194
|
+
expect(
|
|
195
|
+
Protocol.Change.safeParse({ ...change, kind: "unknown" }).success,
|
|
196
|
+
).toBe(false);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("requires custom payloads while allowing any JSON value", () => {
|
|
200
|
+
for (const data of [
|
|
201
|
+
null,
|
|
202
|
+
false,
|
|
203
|
+
42,
|
|
204
|
+
"text",
|
|
205
|
+
{ nested: [1, null, false] },
|
|
206
|
+
]) {
|
|
207
|
+
const custom = { type: "example.event", data };
|
|
208
|
+
expect(Protocol.Custom.parse(custom)).toEqual(custom);
|
|
209
|
+
}
|
|
210
|
+
expect(Protocol.Custom.safeParse({ type: "example.event" }).success).toBe(
|
|
211
|
+
false,
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
});
|