@marimo-team/islands 0.19.5-dev4 → 0.19.5-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-D5KcOOzu.js → ConnectedDataExplorerComponent-DjQ_E5BA.js} +3 -3
- package/dist/assets/__vite-browser-external-DRa9CT_O.js +1 -0
- package/dist/assets/{worker-BR7KVExK.js → worker-SqntmiwV.js} +2 -2
- package/dist/{glide-data-editor-DsVDCmV2.js → glide-data-editor-zEomQJ3U.js} +2 -2
- package/dist/main.js +280 -237
- package/dist/{mermaid-DZjjc-kI.js → mermaid-D7wtYc6C.js} +2 -2
- package/dist/{spec-B1PGDiGh.js → spec-Cif4tBMJ.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{types-CbQF8CBX.js → types-BQOP2pRy.js} +1 -1
- package/dist/{useAsyncData-TLXJC7yx.js → useAsyncData-kqbhbSuf.js} +1 -1
- package/dist/{useDeepCompareMemoize-DVnEG7jx.js → useDeepCompareMemoize-B2QEm3jo.js} +1 -1
- package/dist/{useTheme-BllQjRdW.js → useTheme-CVr6Gb_R.js} +4 -1
- package/dist/{vega-component-B2QrGnW8.js → vega-component-DAeU1_cV.js} +3 -3
- package/package.json +1 -1
- package/src/__mocks__/requests.ts +1 -0
- package/src/components/app-config/user-config-form.tsx +34 -1
- package/src/components/chat/chat-panel.tsx +1 -1
- package/src/components/data-table/cell-utils.ts +10 -0
- package/src/components/editor/Output.tsx +21 -14
- package/src/components/editor/actions/useNotebookActions.tsx +44 -12
- package/src/components/editor/cell/cell-actions.tsx +6 -1
- package/src/components/editor/controls/Controls.tsx +1 -8
- package/src/components/editor/file-tree/file-explorer.tsx +4 -2
- package/src/components/editor/file-tree/file-viewer.tsx +9 -6
- package/src/components/editor/navigation/navigation.ts +39 -1
- package/src/components/editor/renderMimeIcon.tsx +2 -0
- package/src/core/codemirror/language/panel/panel.tsx +3 -0
- package/src/core/codemirror/language/panel/sql.tsx +6 -2
- package/src/core/config/config-schema.ts +5 -1
- package/src/core/config/config.ts +4 -0
- package/src/core/config/feature-flag.tsx +2 -0
- package/src/core/export/__tests__/hooks.test.ts +120 -1
- package/src/core/export/hooks.ts +41 -7
- package/src/core/islands/bridge.ts +1 -0
- package/src/core/lsp/__tests__/transport.test.ts +149 -0
- package/src/core/lsp/transport.ts +48 -0
- package/src/core/network/requests-lazy.ts +1 -0
- package/src/core/network/requests-network.ts +9 -0
- package/src/core/network/requests-static.ts +1 -0
- package/src/core/network/requests-toasting.tsx +1 -0
- package/src/core/network/types.ts +2 -0
- package/src/core/wasm/bridge.ts +1 -0
- package/src/css/app/Cell.css +0 -2
- package/src/plugins/layout/TexPlugin.tsx +7 -5
- package/src/utils/__tests__/download.test.tsx +96 -0
- package/src/utils/download.ts +54 -0
- package/src/utils/filenames.ts +3 -0
- package/dist/assets/__vite-browser-external-CgHmDpAZ.js +0 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { withLoadingToast } from "../download";
|
|
4
|
+
|
|
5
|
+
// Mock the toast module
|
|
6
|
+
const mockDismiss = vi.fn();
|
|
7
|
+
vi.mock("@/components/ui/use-toast", () => ({
|
|
8
|
+
toast: vi.fn(() => ({
|
|
9
|
+
dismiss: mockDismiss,
|
|
10
|
+
})),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
// Mock the Spinner component
|
|
14
|
+
vi.mock("@/components/icons/spinner", () => ({
|
|
15
|
+
Spinner: () => "MockSpinner",
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
import { toast } from "@/components/ui/use-toast";
|
|
19
|
+
|
|
20
|
+
describe("withLoadingToast", () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
vi.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("should show a loading toast and dismiss on success", async () => {
|
|
26
|
+
const result = await withLoadingToast("Loading...", async () => {
|
|
27
|
+
return "success";
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
expect(toast).toHaveBeenCalledTimes(1);
|
|
31
|
+
expect(toast).toHaveBeenCalledWith({
|
|
32
|
+
title: "Loading...",
|
|
33
|
+
});
|
|
34
|
+
expect(mockDismiss).toHaveBeenCalledTimes(1);
|
|
35
|
+
expect(result).toBe("success");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should dismiss toast and rethrow on error", async () => {
|
|
39
|
+
const error = new Error("Operation failed");
|
|
40
|
+
|
|
41
|
+
await expect(
|
|
42
|
+
withLoadingToast("Loading...", async () => {
|
|
43
|
+
throw error;
|
|
44
|
+
}),
|
|
45
|
+
).rejects.toThrow("Operation failed");
|
|
46
|
+
|
|
47
|
+
expect(toast).toHaveBeenCalledTimes(1);
|
|
48
|
+
expect(mockDismiss).toHaveBeenCalledTimes(1);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should return the value from the async function", async () => {
|
|
52
|
+
const expectedValue = { data: "test", count: 42 };
|
|
53
|
+
|
|
54
|
+
const result = await withLoadingToast("Processing...", async () => {
|
|
55
|
+
return expectedValue;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
expect(result).toEqual(expectedValue);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should handle void functions", async () => {
|
|
62
|
+
let sideEffect = false;
|
|
63
|
+
|
|
64
|
+
await withLoadingToast("Saving...", async () => {
|
|
65
|
+
sideEffect = true;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
expect(sideEffect).toBe(true);
|
|
69
|
+
expect(mockDismiss).toHaveBeenCalledTimes(1);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("should use the provided title in the toast", async () => {
|
|
73
|
+
const customTitle = "Downloading PDF...";
|
|
74
|
+
|
|
75
|
+
await withLoadingToast(customTitle, async () => "done");
|
|
76
|
+
|
|
77
|
+
expect(toast).toHaveBeenCalledWith(
|
|
78
|
+
expect.objectContaining({
|
|
79
|
+
title: customTitle,
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("should wait for the async function to complete", async () => {
|
|
85
|
+
const events: string[] = [];
|
|
86
|
+
|
|
87
|
+
await withLoadingToast("Loading...", async () => {
|
|
88
|
+
events.push("start");
|
|
89
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
90
|
+
events.push("end");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
expect(events).toEqual(["start", "end"]);
|
|
94
|
+
expect(mockDismiss).toHaveBeenCalledTimes(1);
|
|
95
|
+
});
|
|
96
|
+
});
|
package/src/utils/download.ts
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import { toPng } from "html-to-image";
|
|
3
3
|
import { toast } from "@/components/ui/use-toast";
|
|
4
|
+
import { getRequestClient } from "@/core/network/requests";
|
|
4
5
|
import { Filenames } from "@/utils/filenames";
|
|
6
|
+
import { Paths } from "@/utils/paths";
|
|
7
|
+
import { prettyError } from "./errors";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Show a loading toast while an async operation is in progress.
|
|
11
|
+
* Automatically dismisses the toast when the operation completes or fails.
|
|
12
|
+
*/
|
|
13
|
+
export async function withLoadingToast<T>(
|
|
14
|
+
title: string,
|
|
15
|
+
fn: () => Promise<T>,
|
|
16
|
+
): Promise<T> {
|
|
17
|
+
const loadingToast = toast({
|
|
18
|
+
title,
|
|
19
|
+
});
|
|
20
|
+
try {
|
|
21
|
+
const result = await fn();
|
|
22
|
+
loadingToast.dismiss();
|
|
23
|
+
return result;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
loadingToast.dismiss();
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
5
29
|
|
|
6
30
|
export async function downloadHTMLAsImage(
|
|
7
31
|
element: HTMLElement,
|
|
@@ -45,3 +69,33 @@ export function downloadBlob(blob: Blob, filename: string) {
|
|
|
45
69
|
downloadByURL(url, filename);
|
|
46
70
|
URL.revokeObjectURL(url);
|
|
47
71
|
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Download the current notebook as a PDF file.
|
|
75
|
+
*
|
|
76
|
+
* WebPDF only requires Chromium to be installed.
|
|
77
|
+
* Standard PDF requires Pandoc & TeX (~few GBs) but is of higher quality.
|
|
78
|
+
*/
|
|
79
|
+
export async function downloadAsPDF(opts: {
|
|
80
|
+
filename: string;
|
|
81
|
+
webpdf: boolean;
|
|
82
|
+
}) {
|
|
83
|
+
const client = getRequestClient();
|
|
84
|
+
const { filename, webpdf } = opts;
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
const pdfBlob = await client.exportAsPDF({
|
|
88
|
+
webpdf,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const filenameWithoutPath = Paths.basename(filename);
|
|
92
|
+
downloadBlob(pdfBlob, Filenames.toPDF(filenameWithoutPath));
|
|
93
|
+
} catch (error) {
|
|
94
|
+
toast({
|
|
95
|
+
title: "Failed to download",
|
|
96
|
+
description: prettyError(error),
|
|
97
|
+
variant: "danger",
|
|
98
|
+
});
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
package/src/utils/filenames.ts
CHANGED
|
@@ -9,6 +9,9 @@ export const Filenames = {
|
|
|
9
9
|
toPNG: (filename: string): string => {
|
|
10
10
|
return Filenames.replace(filename, "png");
|
|
11
11
|
},
|
|
12
|
+
toPDF: (filename: string): string => {
|
|
13
|
+
return Filenames.replace(filename, "pdf");
|
|
14
|
+
},
|
|
12
15
|
toPY: (filename: string): string => {
|
|
13
16
|
return Filenames.replace(filename, "py");
|
|
14
17
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./worker-BR7KVExK.js";var t=e(((e,t)=>{t.exports={}}));export default t();
|