@marimo-team/frontend 0.20.5-dev83 → 0.20.5-dev87

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 (48) hide show
  1. package/dist/assets/{JsonOutput-BRjuq1Jw.js → JsonOutput-DjokO226.js} +1 -1
  2. package/dist/assets/{LazyAnyLanguageCodeMirror-CwbmGJrl.js → LazyAnyLanguageCodeMirror-Cqo8_z2X.js} +2 -2
  3. package/dist/assets/{RenderHTML-B0MiHkXS.js → RenderHTML-ncKzTdNN.js} +1 -1
  4. package/dist/assets/{add-cell-with-ai-BC41mi_U.js → add-cell-with-ai-Bl1TJ3Bp.js} +1 -1
  5. package/dist/assets/{agent-panel-CXdo6rmq.js → agent-panel-DFVcMxMV.js} +1 -1
  6. package/dist/assets/{ai-model-dropdown-V-_6L1Ri.js → ai-model-dropdown-DxpOlTBW.js} +1 -1
  7. package/dist/assets/{any-language-editor-BsZ7S7c3.js → any-language-editor-TJ9GwX4u.js} +1 -1
  8. package/dist/assets/{app-config-button-bSfCHsrZ.js → app-config-button-zy3OAtTs.js} +1 -1
  9. package/dist/assets/{cell-editor-BphfP1AG.js → cell-editor-CSaoLcvI.js} +1 -1
  10. package/dist/assets/{chat-display-Dv9VfU7V.js → chat-display-CWCYGDhk.js} +1 -1
  11. package/dist/assets/{chat-panel-BMoo_OFn.js → chat-panel-CYOmGmIc.js} +1 -1
  12. package/dist/assets/{column-preview-DBQzaLrY.js → column-preview-UqRUB1pJ.js} +1 -1
  13. package/dist/assets/{command-palette-D-iipine.js → command-palette-CQFQWyFs.js} +1 -1
  14. package/dist/assets/{common-Msb-h79F.js → common-D7Sae5Jl.js} +1 -1
  15. package/dist/assets/{context-aware-panel-CaZEaV8C.js → context-aware-panel-DScGcWey.js} +1 -1
  16. package/dist/assets/copy-BvFGCBvy.js +1 -0
  17. package/dist/assets/{copy-icon-Cu7az85f.js → copy-icon-HTFh4odu.js} +1 -1
  18. package/dist/assets/{dependency-graph-panel-RAEDBSLL.js → dependency-graph-panel-Cg4IqU-y.js} +1 -1
  19. package/dist/assets/{documentation-panel-B5ZS7rdM.js → documentation-panel-D5CHwsu6.js} +1 -1
  20. package/dist/assets/{edit-page-CfrFWBII.js → edit-page-BQEJKlvv.js} +7 -7
  21. package/dist/assets/{file-explorer-panel-DiJOGwKe.js → file-explorer-panel-DclnBp04.js} +1 -1
  22. package/dist/assets/{glide-data-editor-UlfiEtnp.js → glide-data-editor-caCB-p9t.js} +1 -1
  23. package/dist/assets/{home-page-2mWoP4xq.js → home-page-Cz5JcEtF.js} +1 -1
  24. package/dist/assets/{hooks-ChoVWWrC.js → hooks-BOa-vQTI.js} +1 -1
  25. package/dist/assets/{index-D3l50M_C.js → index-lo-_Mee6.js} +4 -4
  26. package/dist/assets/{layout-OuSaBBrA.js → layout-BOEBdVW9.js} +3 -3
  27. package/dist/assets/{markdown-renderer-D2_DEfz5.js → markdown-renderer-DwRjZSV8.js} +1 -1
  28. package/dist/assets/{packages-panel-BGH4NaYQ.js → packages-panel-CPHdKpTu.js} +1 -1
  29. package/dist/assets/{panels-Z0QtbAii.js → panels-BfLG6GHU.js} +1 -1
  30. package/dist/assets/{readonly-python-code-YmScI7wz.js → readonly-python-code-Cyn1aSna.js} +1 -1
  31. package/dist/assets/{run-page-D5R165Vz.js → run-page-lC8nyJai.js} +1 -1
  32. package/dist/assets/{scratchpad-panel-Dx0D4qLp.js → scratchpad-panel-B1HOh6tu.js} +1 -1
  33. package/dist/assets/{secrets-panel-DbkurO8B.js → secrets-panel-Bd4T4aNP.js} +1 -1
  34. package/dist/assets/{session-panel-D2vq8N6n.js → session-panel-3pPZOei4.js} +1 -1
  35. package/dist/assets/{snippets-panel-BReCSuHT.js → snippets-panel-DVBJJk2i.js} +1 -1
  36. package/dist/assets/{terminal-D3Lu-b1F.js → terminal-D7RRO5NO.js} +1 -1
  37. package/dist/assets/{useBoolean-DbIYzMhl.js → useBoolean-COWWzCBr.js} +1 -1
  38. package/dist/assets/{useCellActionButton-5K5fLTMd.js → useCellActionButton-DFS0hpsU.js} +1 -1
  39. package/dist/assets/{useDependencyPanelTab-CVeDMlz5.js → useDependencyPanelTab-Dakjo7fJ.js} +1 -1
  40. package/dist/assets/{useNotebookActions-CFogiTi9.js → useNotebookActions-CtiT4Mzf.js} +1 -1
  41. package/dist/index.html +14 -14
  42. package/package.json +1 -1
  43. package/src/components/editor/cell/cell-context-menu.tsx +2 -6
  44. package/src/components/editor/output/console/ConsoleOutput.tsx +51 -2
  45. package/src/components/editor/output/console/__tests__/ConsoleOutput.test.tsx +94 -3
  46. package/src/utils/__tests__/copy.test.ts +129 -0
  47. package/src/utils/copy.ts +43 -0
  48. package/dist/assets/copy-f2iEg0yL.js +0 -1
@@ -0,0 +1,129 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { copyImageToClipboard, isSafari } from "../copy";
4
+
5
+ describe("isSafari", () => {
6
+ afterEach(() => {
7
+ vi.restoreAllMocks();
8
+ });
9
+
10
+ it("returns true for Safari on macOS", () => {
11
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue(
12
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15",
13
+ );
14
+ expect(isSafari()).toBe(true);
15
+ });
16
+
17
+ it("returns true for Safari on iOS", () => {
18
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue(
19
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1",
20
+ );
21
+ expect(isSafari()).toBe(true);
22
+ });
23
+
24
+ it("returns false for Chrome", () => {
25
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue(
26
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
27
+ );
28
+ expect(isSafari()).toBe(false);
29
+ });
30
+
31
+ it("returns false for Chrome on iOS (CriOS)", () => {
32
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue(
33
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/120.0.0.0 Mobile/15E148 Safari/604.1",
34
+ );
35
+ expect(isSafari()).toBe(false);
36
+ });
37
+
38
+ it("returns false for Firefox on iOS (FxiOS)", () => {
39
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue(
40
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/120.0 Mobile/15E148 Safari/604.1",
41
+ );
42
+ expect(isSafari()).toBe(false);
43
+ });
44
+
45
+ it("returns false for Edge on iOS (EdgiOS)", () => {
46
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue(
47
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) EdgiOS/120.0.0.0 Mobile/15E148 Safari/604.1",
48
+ );
49
+ expect(isSafari()).toBe(false);
50
+ });
51
+
52
+ it("returns false for Firefox on desktop", () => {
53
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue(
54
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:120.0) Gecko/20100101 Firefox/120.0",
55
+ );
56
+ expect(isSafari()).toBe(false);
57
+ });
58
+ });
59
+
60
+ describe("copyImageToClipboard", () => {
61
+ let writeMock: ReturnType<typeof vi.fn>;
62
+ let clipboardItemSpy: ReturnType<typeof vi.fn>;
63
+
64
+ beforeEach(() => {
65
+ writeMock = vi.fn().mockResolvedValue(undefined);
66
+ Object.assign(navigator, {
67
+ clipboard: { write: writeMock },
68
+ });
69
+
70
+ // ClipboardItem is not available in jsdom, so we mock it
71
+ clipboardItemSpy = vi.fn().mockImplementation((data) => ({ data }));
72
+ vi.stubGlobal("ClipboardItem", clipboardItemSpy);
73
+ });
74
+
75
+ afterEach(() => {
76
+ vi.restoreAllMocks();
77
+ vi.unstubAllGlobals();
78
+ });
79
+
80
+ it("uses blob type from response on non-Safari browsers", async () => {
81
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue(
82
+ "Mozilla/5.0 Chrome/120.0.0.0 Safari/537.36",
83
+ );
84
+
85
+ const fakeBlob = new Blob(["fake"], { type: "image/jpeg" });
86
+ vi.spyOn(globalThis, "fetch").mockResolvedValue(
87
+ new Response(fakeBlob, {
88
+ headers: { "Content-Type": "image/jpeg" },
89
+ }),
90
+ );
91
+
92
+ await copyImageToClipboard("https://example.com/image.jpg");
93
+
94
+ expect(writeMock).toHaveBeenCalledOnce();
95
+ // Non-Safari path: awaits blob, uses blob.type as key
96
+ const arg = clipboardItemSpy.mock.calls[0][0];
97
+ expect(arg).toHaveProperty("image/jpeg");
98
+ expect(arg["image/jpeg"].type).toBe("image/jpeg");
99
+ });
100
+
101
+ it("uses image/png on Safari", async () => {
102
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue(
103
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15",
104
+ );
105
+
106
+ const fakeBlob = new Blob(["fake"], { type: "image/png" });
107
+ vi.spyOn(globalThis, "fetch").mockResolvedValue(new Response(fakeBlob));
108
+
109
+ await copyImageToClipboard("https://example.com/image.png");
110
+
111
+ expect(writeMock).toHaveBeenCalledOnce();
112
+ // Safari path: uses "image/png" key with a Promise<Blob>
113
+ expect(clipboardItemSpy).toHaveBeenCalledWith({
114
+ "image/png": expect.any(Promise),
115
+ });
116
+ });
117
+
118
+ it("propagates fetch errors", async () => {
119
+ vi.spyOn(navigator, "userAgent", "get").mockReturnValue(
120
+ "Mozilla/5.0 Chrome/120.0.0.0 Safari/537.36",
121
+ );
122
+
123
+ vi.spyOn(globalThis, "fetch").mockRejectedValue(new Error("Network error"));
124
+
125
+ await expect(
126
+ copyImageToClipboard("https://example.com/image.png"),
127
+ ).rejects.toThrow("Network error");
128
+ });
129
+ });
package/src/utils/copy.ts CHANGED
@@ -21,3 +21,46 @@ export async function copyToClipboard(text: string) {
21
21
  window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
22
22
  });
23
23
  }
24
+
25
+ /**
26
+ * Returns true if the current browser is Safari.
27
+ *
28
+ * Safari requires special handling for clipboard operations because it
29
+ * drops the user-activation context during async operations like fetch.
30
+ */
31
+ export function isSafari(): boolean {
32
+ const ua = navigator.userAgent;
33
+ // Safari includes "Safari" but not "Chrome"/"Chromium" in its UA string.
34
+ // iOS in-app browsers (CriOS, FxiOS, EdgiOS) also include "Safari"
35
+ // but are excluded by checking for their specific tokens.
36
+ return (
37
+ /safari/i.test(ua) && !/chrome|chromium|crios|fxios|edgios|opios/i.test(ua)
38
+ );
39
+ }
40
+
41
+ /**
42
+ * Copies an image to the clipboard from a URL.
43
+ *
44
+ * On Safari, the ClipboardItem is constructed synchronously with a
45
+ * Promise<Blob> to preserve the user-activation context, which Safari
46
+ * drops during async operations like fetch. This means we must assume
47
+ * the MIME type (image/png) since we can't inspect the response first.
48
+ *
49
+ * On other browsers, we await the fetch and use the actual MIME type.
50
+ */
51
+ export async function copyImageToClipboard(imageSrc: string): Promise<void> {
52
+ let item: ClipboardItem;
53
+ if (isSafari()) {
54
+ // Safari drops user-activation context during await, so we must
55
+ // construct the ClipboardItem synchronously with a Promise<Blob>.
56
+ item = new ClipboardItem({
57
+ "image/png": fetch(imageSrc).then((response) => response.blob()),
58
+ });
59
+ } else {
60
+ const response = await fetch(imageSrc);
61
+ const blob = await response.blob();
62
+ item = new ClipboardItem({ [blob.type]: blob });
63
+ }
64
+
65
+ await navigator.clipboard.write([item]);
66
+ }
@@ -1 +0,0 @@
1
- import{m as r}from"./useEventListener-BGihH8bs.js";async function a(o){if(navigator.clipboard===void 0){r.warn("navigator.clipboard is not supported"),window.prompt("Copy to clipboard: Ctrl+C, Enter",o);return}await navigator.clipboard.writeText(o).catch(async()=>{r.warn("Failed to copy to clipboard using navigator.clipboard"),window.prompt("Copy to clipboard: Ctrl+C, Enter",o)})}export{a as t};