@marimo-team/islands 0.19.8-dev4 → 0.19.8-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.
Files changed (122) hide show
  1. package/dist/{Combination-Bg-xN8JV.js → Combination-BTMrlhzT.js} +11 -10
  2. package/dist/{ConnectedDataExplorerComponent-DewsKLl2.js → ConnectedDataExplorerComponent-BAeQ8DWw.js} +11 -11
  3. package/dist/{ImageComparisonComponent-Bijp8beW.js → ImageComparisonComponent-DkEXPki_.js} +2 -2
  4. package/dist/{any-language-editor-DZc6NCTp.js → any-language-editor-D0UQItkS.js} +6 -6
  5. package/dist/{architectureDiagram-VXUJARFQ--NkyBn9Y.js → architectureDiagram-VXUJARFQ-DPPYVq8H.js} +4 -4
  6. package/dist/assets/__vite-browser-external-6-UwTyQC.js +1 -0
  7. package/dist/assets/{worker-SqntmiwV.js → worker-D3e5wDxM.js} +4 -4
  8. package/dist/{blockDiagram-VD42YOAC-DEZZaTW0.js → blockDiagram-VD42YOAC-BA5N05Y9.js} +4 -4
  9. package/dist/{button-BWvsJ2Wr.js → button-Cy0ElmIm.js} +2 -2
  10. package/dist/{c4Diagram-YG6GDRKO-Bj7hwWCO.js → c4Diagram-YG6GDRKO-DJLzuGJJ.js} +3 -3
  11. package/dist/{channel-B_QrFrGg.js → channel-Dob5kWXR.js} +1 -1
  12. package/dist/{check-CM_kewwn.js → check-DkNR52Mm.js} +1 -1
  13. package/dist/{chunk-5FQGJX7Z-D5VFKHmt.js → chunk-5FQGJX7Z-BEb20Lzt.js} +3 -3
  14. package/dist/{chunk-ABZYJK2D-SZPYmRzN.js → chunk-ABZYJK2D-BXTC53mt.js} +1 -1
  15. package/dist/{chunk-ATLVNIR6-BI_WwH1o.js → chunk-ATLVNIR6-BJDjUR_c.js} +1 -1
  16. package/dist/{chunk-B4BG7PRW-BlI9Gm1l.js → chunk-B4BG7PRW-DzmUUpfH.js} +4 -4
  17. package/dist/{chunk-DI55MBZ5-BXxemMn5.js → chunk-DI55MBZ5-gTd3J8Tu.js} +4 -4
  18. package/dist/{chunk-EXTU4WIE-CzWtDV99.js → chunk-EXTU4WIE-DyoOs5QX.js} +1 -1
  19. package/dist/{chunk-JA3XYJ7Z-DQ-2ARfa.js → chunk-JA3XYJ7Z-BGnAIbOP.js} +2 -2
  20. package/dist/{chunk-JZLCHNYA-CVfjf2vv.js → chunk-JZLCHNYA-CIRgweVQ.js} +4 -4
  21. package/dist/{chunk-N4CR4FBY-BCZvQ7Jq.js → chunk-N4CR4FBY-DKSvXAIS.js} +5 -5
  22. package/dist/{chunk-QN33PNHL-DY_2Q2zl.js → chunk-QN33PNHL-B6zC8BTi.js} +1 -1
  23. package/dist/{chunk-QXUST7PY-BMCjAVR_.js → chunk-QXUST7PY-C7750n_u.js} +5 -5
  24. package/dist/{chunk-S3R3BYOJ-Ddu0H4Qa.js → chunk-S3R3BYOJ-CBkH6JZZ.js} +1 -1
  25. package/dist/{chunk-TZMSLE5B-C2wVlbMl.js → chunk-TZMSLE5B-DObGL7xi.js} +1 -1
  26. package/dist/{classDiagram-2ON5EDUG-D-g7zbyO.js → classDiagram-2ON5EDUG-B9pkKjjc.js} +9 -9
  27. package/dist/{classDiagram-v2-WZHVMYZB-C7v5zNRD.js → classDiagram-v2-WZHVMYZB-CRhhA0tV.js} +9 -9
  28. package/dist/{click-outside-container-BCN5BtVO.js → click-outside-container-DNfggvIW.js} +1 -1
  29. package/dist/{code-block-37QAKDTI-eUgXqGNG.js → code-block-37QAKDTI-u5kgjqmr.js} +2 -2
  30. package/dist/{compiler-runtime-DHFVbq0b.js → compiler-runtime-B_OLMU9S.js} +1 -1
  31. package/dist/{copy-B59Bw3-w.js → copy-DRaXIb_a.js} +3 -3
  32. package/dist/{dagre-6UL2VRFP-DKIPL74O.js → dagre-6UL2VRFP-C2C2XxsB.js} +6 -6
  33. package/dist/{data-grid-overlay-editor-COyFwFmE.js → data-grid-overlay-editor-BXqtz1ia.js} +4 -4
  34. package/dist/{diagram-PSM6KHXK-CVTrAZaP.js → diagram-PSM6KHXK-DHBY-94p.js} +5 -5
  35. package/dist/{diagram-QEK2KX5R-BqHBzu3x.js → diagram-QEK2KX5R-CgMshOwn.js} +3 -3
  36. package/dist/{diagram-S2PKOQOG-CJD6owcg.js → diagram-S2PKOQOG-F1KPva3Y.js} +3 -3
  37. package/dist/{dist-Co5PD8Fb.js → dist-BBYTEAvO.js} +1 -1
  38. package/dist/{erDiagram-Q2GNP2WA-CqOceSf9.js → erDiagram-Q2GNP2WA-18gGng8V.js} +9 -9
  39. package/dist/{error-banner-C7KLpECd.js → error-banner-D2zjeN_a.js} +5 -5
  40. package/dist/{esm-D4WO8J3G.js → esm-CgRNPmz8.js} +6 -6
  41. package/dist/{flowDiagram-NV44I4VS-K7-DUifo.js → flowDiagram-NV44I4VS-iHFiHYe0.js} +9 -9
  42. package/dist/{ganttDiagram-JELNMOA3-BwUFY9Nu.js → ganttDiagram-JELNMOA3-D7GixxiF.js} +2 -2
  43. package/dist/{gitGraphDiagram-NY62KEGX-CjGRtLb1.js → gitGraphDiagram-NY62KEGX-CJFHytRK.js} +2 -2
  44. package/dist/{glide-data-editor-C3T7HsLi.js → glide-data-editor-BYwb17Bf.js} +13 -13
  45. package/dist/{infoDiagram-WHAUD3N6-DNhmDn-6.js → infoDiagram-WHAUD3N6-B5Lkh3A9.js} +2 -2
  46. package/dist/{journeyDiagram-XKPGCS4Q-BOdK47P8.js → journeyDiagram-XKPGCS4Q-CV_9R9iP.js} +2 -2
  47. package/dist/{kanban-definition-3W4ZIXB7-A0JC9d0g.js → kanban-definition-3W4ZIXB7-Dp21D5Ym.js} +6 -6
  48. package/dist/{katex-DJyOeQ91.js → katex-CX2BKujk.js} +1 -1
  49. package/dist/{katex-Dm9nZf6A.js → katex-Db0k5oV_.js} +1 -1
  50. package/dist/{label-C4PtQcza.js → label-CxU5JNBW.js} +6 -6
  51. package/dist/main.js +270 -206
  52. package/dist/mermaid-4DMBBIKO-BhDCqnO1.js +6 -0
  53. package/dist/{mermaid-Bqp2Xw99.js → mermaid-B__BZSXU.js} +39 -39
  54. package/dist/{mhchem-BqdXeZVX.js → mhchem-w1tkUnWr.js} +1 -1
  55. package/dist/{mindmap-definition-VGOIOE7T-CS6nKN_L.js → mindmap-definition-VGOIOE7T-B_5mfdYp.js} +8 -8
  56. package/dist/{number-overlay-editor-Bz_bDJQb.js → number-overlay-editor-D-4WQAGX.js} +2 -2
  57. package/dist/{pieDiagram-ADFJNKIX-DSa60Grk.js → pieDiagram-ADFJNKIX-B-DGEopK.js} +3 -3
  58. package/dist/{quadrantDiagram-AYHSOK5B-CFnMbP2J.js → quadrantDiagram-AYHSOK5B-M_yRSIZn.js} +1 -1
  59. package/dist/{react-DdA8EBol.js → react-Bs6Z0kvn.js} +1 -1
  60. package/dist/{react-dom-DJW8xUDg.js → react-dom-CqtLRVZP.js} +2 -2
  61. package/dist/{react-plotly-jVjTu07w.js → react-plotly-BuRa9xtI.js} +1 -1
  62. package/dist/{react-vega-DgHpnZ04.js → react-vega-3WcLHYC7.js} +2 -2
  63. package/dist/{react-vega-CjiPWyw0.js → react-vega-DLFvGrpJ.js} +1 -1
  64. package/dist/{requirementDiagram-UZGBJVZJ-ytLQrFTk.js → requirementDiagram-UZGBJVZJ-9Wt82hOZ.js} +8 -8
  65. package/dist/{sankeyDiagram-TZEHDZUN-KQqXDoky.js → sankeyDiagram-TZEHDZUN-x_aTXZeN.js} +1 -1
  66. package/dist/{sequenceDiagram-WL72ISMW-ByLI04T5.js → sequenceDiagram-WL72ISMW-CXXmJqiQ.js} +3 -3
  67. package/dist/{slides-component-BVjvNo92.js → slides-component-Dp-y50K9.js} +4 -4
  68. package/dist/{spec-Dmb1KfK3.js → spec-HoYHAQo2.js} +6 -6
  69. package/dist/{stateDiagram-FKZM4ZOC-Dfz8vBbP.js → stateDiagram-FKZM4ZOC-CiSKS_Mx.js} +9 -9
  70. package/dist/{stateDiagram-v2-4FDKWEC3-DRYoLdT5.js → stateDiagram-v2-4FDKWEC3-A43Itnjp.js} +9 -9
  71. package/dist/style.css +1 -1
  72. package/dist/{timeline-definition-IT6M3QCI-CO48XU1B.js → timeline-definition-IT6M3QCI-DR26eWb4.js} +1 -1
  73. package/dist/{types-CzEZ3EWT.js → types-Bb-6p8hv.js} +8 -8
  74. package/dist/{useAsyncData-BjNwqCfS.js → useAsyncData-Dyq3DyOF.js} +3 -3
  75. package/dist/{useDeepCompareMemoize-CfoxVor3.js → useDeepCompareMemoize-CMGprt3H.js} +5 -5
  76. package/dist/{useIframeCapabilities-BBO_R0ww.js → useIframeCapabilities-DurI5SJh.js} +2 -2
  77. package/dist/{useTheme-BYG2SH8J.js → useTheme-SlKl8MlS.js} +5 -6
  78. package/dist/{vega-component-rDX7xwxH.js → vega-component-DU3aSp4m.js} +10 -10
  79. package/dist/{xychartDiagram-PRI3JC2R-CUIfjNVD.js → xychartDiagram-PRI3JC2R-BcVxCRox.js} +4 -4
  80. package/dist/{zod-DITCj31F.js → zod-bjADtMKr.js} +3 -3
  81. package/package.json +18 -18
  82. package/src/components/app-config/ai-config.tsx +11 -2
  83. package/src/components/app-config/user-config-form.tsx +0 -54
  84. package/src/components/chat/acp/__tests__/state.test.ts +69 -0
  85. package/src/components/chat/acp/state.ts +6 -6
  86. package/src/components/chat/chat-panel.tsx +47 -30
  87. package/src/components/data-table/__tests__/data-table.test.tsx +94 -2
  88. package/src/components/editor/actions/useCellActionButton.tsx +14 -1
  89. package/src/components/editor/cell/CreateCellButton.tsx +2 -1
  90. package/src/components/editor/cell/code/cell-editor.tsx +12 -0
  91. package/src/components/editor/database/__tests__/__snapshots__/as-code.test.ts.snap +15 -0
  92. package/src/components/editor/database/__tests__/as-code.test.ts +8 -0
  93. package/src/components/editor/database/as-code.ts +3 -0
  94. package/src/components/editor/database/schemas.ts +9 -0
  95. package/src/components/editor/renderers/cell-array.tsx +2 -1
  96. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +12 -0
  97. package/src/components/pages/gallery-page.tsx +37 -6
  98. package/src/core/MarimoApp.tsx +12 -8
  99. package/src/core/ai/context/providers/file.ts +1 -1
  100. package/src/core/cells/__tests__/cells.test.ts +120 -0
  101. package/src/core/cells/__tests__/session.test.ts +37 -1
  102. package/src/core/cells/cells.ts +14 -0
  103. package/src/core/cells/session.ts +20 -8
  104. package/src/core/codemirror/language/languages/markdown.ts +7 -0
  105. package/src/core/config/feature-flag.tsx +0 -4
  106. package/src/core/dom/uiregistry.ts +4 -1
  107. package/src/core/run-app.tsx +11 -4
  108. package/src/core/static/__tests__/files.test.ts +195 -1
  109. package/src/core/static/files.ts +39 -9
  110. package/src/plugins/core/registerReactComponent.tsx +9 -1
  111. package/src/plugins/impl/__tests__/DataTablePlugin.test.tsx +164 -0
  112. package/src/plugins/impl/anywidget/AnyWidgetPlugin.tsx +7 -1
  113. package/src/utils/__tests__/blob.test.ts +3 -3
  114. package/src/utils/__tests__/id-tree.test.ts +22 -7
  115. package/src/utils/__tests__/mime-types.test.ts +8 -10
  116. package/src/utils/__tests__/url-parser.test.ts +22 -0
  117. package/src/utils/blob.ts +14 -27
  118. package/src/utils/id-tree.tsx +11 -19
  119. package/src/utils/mime-types.ts +5 -5
  120. package/src/utils/url-parser.ts +1 -1
  121. package/dist/assets/__vite-browser-external-DRa9CT_O.js +0 -1
  122. package/dist/mermaid-4DMBBIKO-o3xNphpD.js +0 -6
@@ -0,0 +1,164 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { TooltipProvider } from "@radix-ui/react-tooltip";
4
+ import { act, render, screen, waitFor } from "@testing-library/react";
5
+ import { Provider } from "jotai";
6
+ import { beforeAll, describe, expect, it, vi } from "vitest";
7
+ import type { DownloadAsArgs } from "@/components/data-table/schemas";
8
+ import type { FieldTypesWithExternalType } from "@/components/data-table/types";
9
+ import { store } from "@/core/state/jotai";
10
+ import {
11
+ type GetDataUrl,
12
+ type GetRowIds,
13
+ LoadingDataTableComponent,
14
+ } from "../DataTablePlugin";
15
+
16
+ beforeAll(() => {
17
+ global.ResizeObserver = class ResizeObserver {
18
+ observe() {
19
+ // do nothing
20
+ }
21
+ unobserve() {
22
+ // do nothing
23
+ }
24
+ disconnect() {
25
+ // do nothing
26
+ }
27
+ };
28
+ });
29
+
30
+ describe("LoadingDataTableComponent", () => {
31
+ /**
32
+ * Regression test for https://github.com/marimo-team/marimo/issues/8023
33
+ *
34
+ * When a table is replaced via mo.output.replace() with updated data,
35
+ * but the initial page data (unsorted first page) hasn't changed,
36
+ * the useAsyncData hook's deps may all remain the same.
37
+ * Previously, the `search` function reference was memoized on
38
+ * [plugin.functions, hostElement] and wouldn't change on reset(),
39
+ * so the useAsyncData effect wouldn't re-fire.
40
+ *
41
+ * The fix adds a resetNonce to the functionMethods memo deps,
42
+ * so when the plugin is reset (table instance changes), the search
43
+ * function reference changes, triggering useAsyncData to re-fetch.
44
+ *
45
+ * This test verifies that when the search function reference changes
46
+ * (simulating reset()), the component re-fetches data even if
47
+ * props.data hasn't changed.
48
+ */
49
+ it("should refetch data when search function reference changes", async () => {
50
+ const host = document.createElement("div");
51
+ const setValue = vi.fn();
52
+
53
+ // The initial page data string - identical for both renders.
54
+ // This simulates the case where only a row on page 2 changed,
55
+ // so the first page data is the same.
56
+ const initialPageData = JSON.stringify([
57
+ { id: 1, status: "pending", value: 10 },
58
+ { id: 2, status: "pending", value: 20 },
59
+ { id: 3, status: "pending", value: 30 },
60
+ ]);
61
+
62
+ const searchResult = {
63
+ data: [
64
+ { id: 1, status: "pending", value: 10 },
65
+ { id: 2, status: "pending", value: 20 },
66
+ { id: 3, status: "pending", value: 30 },
67
+ ],
68
+ total_rows: 4,
69
+ cell_styles: null,
70
+ cell_hover_texts: null,
71
+ };
72
+
73
+ const searchFn1 = vi.fn().mockResolvedValue(searchResult);
74
+ const searchFn2 = vi.fn().mockResolvedValue(searchResult);
75
+
76
+ const fieldTypes: FieldTypesWithExternalType = [
77
+ ["id", ["integer", "integer"]],
78
+ ["status", ["string", "string"]],
79
+ ["value", ["integer", "integer"]],
80
+ ];
81
+
82
+ const commonProps = {
83
+ label: null,
84
+ totalRows: 4,
85
+ pagination: true,
86
+ pageSize: 3,
87
+ selection: "single" as const,
88
+ showDownload: false,
89
+ showFilters: false,
90
+ showColumnSummaries: false as const,
91
+ showDataTypes: false,
92
+ showPageSizeSelector: false,
93
+ showColumnExplorer: false,
94
+ showRowExplorer: false,
95
+ showChartBuilder: false,
96
+ rowHeaders: [] as FieldTypesWithExternalType,
97
+ fieldTypes,
98
+ totalColumns: 3,
99
+ maxColumns: "all" as const,
100
+ hasStableRowId: false,
101
+ lazy: false,
102
+ host,
103
+ enableSearch: true,
104
+ value: [] as (number | string | { rowId: string; columnName?: string })[],
105
+ setValue,
106
+ download_as: vi.fn() as DownloadAsArgs,
107
+ get_column_summaries: vi.fn().mockResolvedValue({
108
+ data: null,
109
+ stats: {},
110
+ bin_values: {},
111
+ value_counts: {},
112
+ show_charts: false,
113
+ }),
114
+ get_data_url: vi.fn() as GetDataUrl,
115
+ get_row_ids: vi.fn() as GetRowIds,
116
+ };
117
+
118
+ const Wrapper = ({ children }: { children: React.ReactNode }) => (
119
+ <Provider store={store}>
120
+ <TooltipProvider>{children}</TooltipProvider>
121
+ </Provider>
122
+ );
123
+
124
+ // Render with first search function
125
+ const { rerender } = render(
126
+ <Wrapper>
127
+ <LoadingDataTableComponent
128
+ {...commonProps}
129
+ data={initialPageData}
130
+ search={searchFn1}
131
+ />
132
+ </Wrapper>,
133
+ );
134
+
135
+ // Wait for the table to render with data
136
+ await waitFor(() => {
137
+ expect(screen.getAllByRole("row").length).toBeGreaterThan(1);
138
+ });
139
+
140
+ // Search was called on initial load (fire-and-forget for canShowInitialPage)
141
+ expect(searchFn1).toHaveBeenCalled();
142
+
143
+ // Now rerender with the same data but a NEW search function reference.
144
+ // This simulates what happens after reset() when resetNonce increments
145
+ // and functionMethods is recreated.
146
+ await act(async () => {
147
+ rerender(
148
+ <Wrapper>
149
+ <LoadingDataTableComponent
150
+ {...commonProps}
151
+ data={initialPageData}
152
+ search={searchFn2}
153
+ />
154
+ </Wrapper>,
155
+ );
156
+ });
157
+
158
+ // The new search function should be called because the search
159
+ // dependency changed in useAsyncData.
160
+ await waitFor(() => {
161
+ expect(searchFn2).toHaveBeenCalled();
162
+ });
163
+ });
164
+ });
@@ -8,6 +8,8 @@ import useEvent from "react-use-event-hook";
8
8
  import { z } from "zod";
9
9
  import { MarimoIncomingMessageEvent } from "@/core/dom/events";
10
10
  import { asRemoteURL } from "@/core/runtime/config";
11
+ import { resolveVirtualFileURL } from "@/core/static/files";
12
+ import { isStaticNotebook } from "@/core/static/static-state";
11
13
  import { useAsyncData } from "@/hooks/useAsyncData";
12
14
  import { useDeepCompareMemoize } from "@/hooks/useDeepCompareMemoize";
13
15
  import {
@@ -93,7 +95,11 @@ const AnyWidgetSlot = (
93
95
  error,
94
96
  refetch,
95
97
  } = useAsyncData(async () => {
96
- const url = asRemoteURL(jsUrl).toString();
98
+ let url = asRemoteURL(jsUrl).toString();
99
+ // In static notebooks, resolve virtual files to blob URLs for import()
100
+ if (isStaticNotebook()) {
101
+ url = resolveVirtualFileURL(url);
102
+ }
97
103
  return await import(/* @vite-ignore */ url);
98
104
  // Re-render on jsHash change (which is a hash of the contents of the file)
99
105
  // instead of a jsUrl change because URLs may change without the contents
@@ -20,7 +20,7 @@ describe("Blob serialization and deserialization", () => {
20
20
 
21
21
  test("deserializeBlob should deserialize a base64 string to a Blob", async () => {
22
22
  const serialized = await serializeBlob(testBlob);
23
- const deserialized = await deserializeBlob(serialized);
23
+ const deserialized = deserializeBlob(serialized);
24
24
  expect(deserialized).toBeDefined();
25
25
  expect(deserialized.size).toBe(testBlob.size);
26
26
  expect(deserialized.type).toBe(testBlob.type);
@@ -28,7 +28,7 @@ describe("Blob serialization and deserialization", () => {
28
28
 
29
29
  test("deserialized Blob should contain the original content", async () => {
30
30
  const serialized = await serializeBlob(testBlob);
31
- const deserialized = await deserializeBlob(serialized);
31
+ const deserialized = deserializeBlob(serialized);
32
32
  const reader = new FileReader();
33
33
  // eslint-disable-next-line unicorn/prefer-blob-reading-methods
34
34
  reader.readAsText(deserialized);
@@ -45,7 +45,7 @@ describe("Blob serialization and deserialization", () => {
45
45
  type: "image/png",
46
46
  });
47
47
  const serialized = await serializeBlob(imageBlob);
48
- const deserialized = await deserializeBlob(serialized);
48
+ const deserialized = deserializeBlob(serialized);
49
49
  expect(deserialized).toBeDefined();
50
50
  expect(deserialized.size).toBe(imageBlob.size);
51
51
  expect(deserialized.type).toBe(imageBlob.type);
@@ -214,16 +214,19 @@ describe("CollapsibleTree", () => {
214
214
  `);
215
215
  });
216
216
 
217
- it("fails to expand", () => {
217
+ it("fails to expand when node not found", () => {
218
218
  expect(() => tree.expand("five")).toThrowErrorMatchingInlineSnapshot(
219
219
  "[Error: Node five not found in tree. Valid ids: one,two,three,four]",
220
220
  );
221
- expect(() => {
222
- tree.expand("one");
223
- tree.expand("one");
224
- }).toThrowErrorMatchingInlineSnapshot(
225
- "[Error: Node one is already expanded]",
226
- );
221
+ });
222
+
223
+ it("expand on already expanded node is a no-op", () => {
224
+ // Expanding an already expanded node should return the same tree (no-op)
225
+ const result = tree.expand("one");
226
+ expect(result).toBe(tree);
227
+ // Can call multiple times without error
228
+ const result2 = tree.expand("one");
229
+ expect(result2).toBe(tree);
227
230
  });
228
231
 
229
232
  it("moves nodes correctly", () => {
@@ -378,6 +381,18 @@ describe("CollapsibleTree", () => {
378
381
  `);
379
382
  });
380
383
 
384
+ it("can delete non-collapsed nodes without throwing", () => {
385
+ // Deleting a non-collapsed node should not throw
386
+ // (previously this would throw "Node is already expanded" internally)
387
+ const result = tree.deleteAtIndex(1);
388
+ expect(result.toString()).toMatchInlineSnapshot(`
389
+ "one
390
+ three
391
+ four
392
+ "
393
+ `);
394
+ });
395
+
381
396
  it("fails to delete nodes", () => {
382
397
  expect(() => tree.deleteAtIndex(5)).toThrowErrorMatchingInlineSnapshot(
383
398
  "[Error: Node at index 5 not found in tree]",
@@ -132,7 +132,7 @@ describe("mime-types", () => {
132
132
 
133
133
  describe("sortByPrecedence", () => {
134
134
  it("should sort entries by precedence order", () => {
135
- const entries: Array<[MimeType, string]> = [
135
+ const entries: [MimeType, string][] = [
136
136
  ["text/plain", "plain"],
137
137
  ["text/html", "html"],
138
138
  ["image/png", "png"],
@@ -151,7 +151,7 @@ describe("mime-types", () => {
151
151
  });
152
152
 
153
153
  it("should place unknown mime types at the end", () => {
154
- const entries: Array<[MimeType, string]> = [
154
+ const entries: [MimeType, string][] = [
155
155
  ["text/plain", "plain"],
156
156
  ["text/html", "html"],
157
157
  ["application/json", "json"],
@@ -173,7 +173,7 @@ describe("mime-types", () => {
173
173
  });
174
174
 
175
175
  it("should handle empty precedence", () => {
176
- const entries: Array<[MimeType, string]> = [
176
+ const entries: [MimeType, string][] = [
177
177
  ["text/plain", "plain"],
178
178
  ["text/html", "html"],
179
179
  ];
@@ -184,7 +184,7 @@ describe("mime-types", () => {
184
184
  });
185
185
 
186
186
  it("should not mutate original array", () => {
187
- const entries: Array<[MimeType, string]> = [
187
+ const entries: [MimeType, string][] = [
188
188
  ["text/plain", "plain"],
189
189
  ["text/html", "html"],
190
190
  ];
@@ -198,7 +198,7 @@ describe("mime-types", () => {
198
198
 
199
199
  describe("processMimeBundle", () => {
200
200
  it("should filter and sort mime entries", () => {
201
- const entries: Array<[MimeType, string]> = [
201
+ const entries: [MimeType, string][] = [
202
202
  ["text/plain", "plain"],
203
203
  ["text/html", "html"],
204
204
  ["image/png", "png"],
@@ -226,7 +226,7 @@ describe("mime-types", () => {
226
226
  });
227
227
 
228
228
  it("should use default config when not provided", () => {
229
- const entries: Array<[MimeType, string]> = [
229
+ const entries: [MimeType, string][] = [
230
230
  ["text/html", "html"],
231
231
  ["image/png", "png"],
232
232
  ["text/markdown", "md"],
@@ -240,9 +240,7 @@ describe("mime-types", () => {
240
240
 
241
241
  it("should preserve data associated with mime types", () => {
242
242
  const htmlData = { content: "<h1>Hello</h1>" };
243
- const entries: Array<[MimeType, typeof htmlData]> = [
244
- ["text/html", htmlData],
245
- ];
243
+ const entries: [MimeType, typeof htmlData][] = [["text/html", htmlData]];
246
244
 
247
245
  const result = processMimeBundle(entries);
248
246
 
@@ -250,7 +248,7 @@ describe("mime-types", () => {
250
248
  });
251
249
 
252
250
  it("should sort by precedence after filtering", () => {
253
- const entries: Array<[MimeType, string]> = [
251
+ const entries: [MimeType, string][] = [
254
252
  ["text/plain", "plain"],
255
253
  ["text/markdown", "md"],
256
254
  ["text/html", "html"],
@@ -76,4 +76,26 @@ describe("parseContent", () => {
76
76
  url: "https://avatars.githubusercontent.com/u/123",
77
77
  });
78
78
  });
79
+
80
+ it("preserves newlines between URLs", () => {
81
+ const parts = parseContent("https://marimo.io\nhttps://github.com\n");
82
+ expect(parts).toEqual([
83
+ { type: "url", url: "https://marimo.io" },
84
+ { type: "text", value: "\n" },
85
+ { type: "url", url: "https://github.com" },
86
+ { type: "text", value: "\n" },
87
+ ]);
88
+ });
89
+
90
+ it("preserves whitespace in mixed content", () => {
91
+ const parts = parseContent(
92
+ "Line 1: https://marimo.io\nLine 2: https://github.com",
93
+ );
94
+ expect(parts).toEqual([
95
+ { type: "text", value: "Line 1: " },
96
+ { type: "url", url: "https://marimo.io" },
97
+ { type: "text", value: "\nLine 2: " },
98
+ { type: "url", url: "https://github.com" },
99
+ ]);
100
+ });
79
101
  });
package/src/utils/blob.ts CHANGED
@@ -14,32 +14,19 @@ export function serializeBlob<T>(blob: Blob): Promise<DataURLString> {
14
14
  });
15
15
  }
16
16
 
17
- export function deserializeBlob(serializedBlob: DataURLString): Promise<Blob> {
18
- return new Promise((resolve, reject) => {
19
- try {
20
- // Extract the base64 data from the data URL
21
- const [prefix, base64Data] = serializedBlob.split(",", 2);
22
- const mimeType = /^data:(.+);base64$/.exec(prefix)?.[1];
23
- // Decode the base64 string
24
- const binaryString = atob(base64Data);
25
- // Convert the binary string to an array buffer
26
- const len = binaryString.length;
27
- const bytes = new Uint8Array(len);
28
- for (let i = 0; i < len; i++) {
29
- bytes[i] = binaryString.charCodeAt(i);
30
- }
31
- // Create a new Blob from the array buffer
32
- const blob = new Blob([bytes], { type: mimeType });
33
- resolve(blob);
34
- } catch (error) {
35
- reject(ensureError(error));
36
- }
37
- });
38
- }
39
-
40
- function ensureError(error: unknown): Error {
41
- if (error instanceof Error) {
42
- return error;
17
+ export function deserializeBlob(serializedBlob: DataURLString): Blob {
18
+ // Extract the base64 data from the data URL
19
+ const [prefix, base64Data] = serializedBlob.split(",", 2);
20
+ const mimeType = /^data:(.+);base64$/.exec(prefix)?.[1];
21
+ // Decode the base64 string
22
+ const binaryString = atob(base64Data);
23
+ // Convert the binary string to an array buffer
24
+ const len = binaryString.length;
25
+ const bytes = new Uint8Array(len);
26
+ for (let i = 0; i < len; i++) {
27
+ bytes[i] = binaryString.charCodeAt(i);
43
28
  }
44
- return new Error(`${error}`);
29
+ // Create a new Blob from the array buffer
30
+ const blob = new Blob([bytes], { type: mimeType });
31
+ return blob;
45
32
  }
@@ -360,7 +360,8 @@ export class CollapsibleTree<T> {
360
360
  }
361
361
 
362
362
  /**
363
- * Expand a node and all of its children
363
+ * Expand a node and all of its children.
364
+ * If the node is already expanded, returns the same tree (no-op).
364
365
  */
365
366
  expand(id: T): CollapsibleTree<T> {
366
367
  const nodeIndex = this.nodes.findIndex((n) => n.value === id);
@@ -373,7 +374,8 @@ export class CollapsibleTree<T> {
373
374
  let nodes = [...this.nodes];
374
375
  const node = nodes[nodeIndex];
375
376
  if (!node.isCollapsed) {
376
- throw new Error(`Node ${id} is already expanded`);
377
+ // Already expanded, no-op
378
+ return this;
377
379
  }
378
380
 
379
381
  nodes[nodeIndex] = new TreeNode(node.value, false, []);
@@ -495,13 +497,9 @@ export class CollapsibleTree<T> {
495
497
  */
496
498
  deleteAtIndex(idx: number): CollapsibleTree<T> {
497
499
  const id = this.atOrThrow(idx);
498
- let tree = this.withNodes(this.nodes);
499
- try {
500
- tree = tree.expand(id);
501
- } catch {
502
- // Don't care if its not expanded
503
- }
504
- return this.withNodes(arrayDelete(tree.nodes, idx));
500
+ // Expand the node first (if collapsed) to bring children back to top level
501
+ const tree = this.expand(id);
502
+ return tree.withNodes(arrayDelete(tree.nodes, idx));
505
503
  }
506
504
 
507
505
  delete(id: T): CollapsibleTree<T> {
@@ -524,16 +522,10 @@ export class CollapsibleTree<T> {
524
522
  if (found.length === 0) {
525
523
  return this;
526
524
  }
527
- let result = this.withNodes(this.nodes);
528
- for (const node of found) {
529
- try {
530
- result = result.expand(node);
531
- } catch {
532
- // Don't care if its the last node and its not expanded
533
- }
534
- }
535
-
536
- return result;
525
+ return found.reduce<CollapsibleTree<T>>(
526
+ (acc, node) => acc.expand(node),
527
+ this,
528
+ );
537
529
  }
538
530
 
539
531
  /**
@@ -26,7 +26,7 @@ export interface MimeTypeConfig {
26
26
  */
27
27
  export interface ProcessedMimeTypes<T> {
28
28
  /** The filtered and sorted mime entries */
29
- entries: Array<[MimeType, T]>;
29
+ entries: [MimeType, T][];
30
30
  /** Mime types that were hidden by rules */
31
31
  hidden: MimeType[];
32
32
  }
@@ -146,9 +146,9 @@ export function applyHidingRules(
146
146
  * Mime types not in the map are placed at the end, preserving their original order.
147
147
  */
148
148
  export function sortByPrecedence<T>(
149
- entries: Array<[MimeType, T]>,
149
+ entries: [MimeType, T][],
150
150
  precedence: ReadonlyMap<MimeType, number>,
151
- ): Array<[MimeType, T]> {
151
+ ): [MimeType, T][] {
152
152
  const unknownPrecedence = precedence.size;
153
153
 
154
154
  return [...entries].sort((a, b) => {
@@ -162,7 +162,7 @@ export function sortByPrecedence<T>(
162
162
  * Main entry point: processes mime entries by applying hiding rules and sorting.
163
163
  */
164
164
  export function processMimeBundle<T>(
165
- entries: Array<[MimeType, T]>,
165
+ entries: [MimeType, T][],
166
166
  config: MimeTypeConfig = getDefaultMimeConfig(),
167
167
  ): ProcessedMimeTypes<T> {
168
168
  if (entries.length === 0) {
@@ -176,6 +176,6 @@ export function processMimeBundle<T>(
176
176
 
177
177
  return {
178
178
  entries: sortedEntries,
179
- hidden: Array.from(hidden),
179
+ hidden: [...hidden],
180
180
  };
181
181
  }
@@ -19,7 +19,7 @@ export function parseContent(text: string): ContentPart[] {
19
19
  return [{ type: "image", url: text }];
20
20
  }
21
21
 
22
- const parts = text.split(urlRegex).filter((part) => part.trim() !== "");
22
+ const parts = text.split(urlRegex).filter((part) => part !== "");
23
23
  return parts.map((part) => {
24
24
  const isUrl = urlRegex.test(part);
25
25
  if (isUrl) {
@@ -1 +0,0 @@
1
- import{t as e}from"./worker-SqntmiwV.js";var t=e(((e,t)=>{t.exports={}}));export default t();
@@ -1,6 +0,0 @@
1
- import "./react-DdA8EBol.js";
2
- import { a as tt } from "./chunk-5FQGJX7Z-D5VFKHmt.js";
3
- import "./jsx-runtime-CTBg5pdT.js";
4
- export {
5
- tt as Mermaid
6
- };