@marimo-team/islands 0.19.7-dev42 → 0.19.7-dev43

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/main.js CHANGED
@@ -73168,7 +73168,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
73168
73168
  return Logger.warn("Failed to get version from mount config"), null;
73169
73169
  }
73170
73170
  }
73171
- const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.7-dev42"), showCodeInRunModeAtom = atom(true);
73171
+ const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.7-dev43"), showCodeInRunModeAtom = atom(true);
73172
73172
  atom(null);
73173
73173
  var import_compiler_runtime$88 = require_compiler_runtime();
73174
73174
  function useKeydownOnElement(e, r) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.19.7-dev42",
3
+ "version": "0.19.7-dev43",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -401,13 +401,30 @@ describe("downloadCellOutputAsImage", () => {
401
401
  vi.restoreAllMocks();
402
402
  });
403
403
 
404
- it("should return early if element not found", async () => {
404
+ it("should show error toast if element not found", async () => {
405
405
  await downloadCellOutputAsImage("nonexistent" as CellId, "test");
406
406
 
407
407
  expect(toPng).not.toHaveBeenCalled();
408
408
  expect(Logger.error).toHaveBeenCalledWith(
409
409
  "Output element not found for cell nonexistent",
410
410
  );
411
+ expect(toast).toHaveBeenCalledWith({
412
+ title: "Failed to download PNG",
413
+ description: expect.any(String),
414
+ variant: "danger",
415
+ });
416
+ });
417
+
418
+ it("should show error toast if toPng fails", async () => {
419
+ vi.mocked(toPng).mockRejectedValue(new Error("Screenshot failed"));
420
+
421
+ await downloadCellOutputAsImage("cell-1" as CellId, "result");
422
+
423
+ expect(toast).toHaveBeenCalledWith({
424
+ title: "Failed to download PNG",
425
+ description: expect.stringContaining("Screenshot failed"),
426
+ variant: "danger",
427
+ });
411
428
  });
412
429
 
413
430
  it("should download cell output as image", async () => {
@@ -100,11 +100,19 @@ export async function downloadCellOutputAsImage(
100
100
  cellId: CellId,
101
101
  filename: string,
102
102
  ) {
103
- const dataUrl = await getImageDataUrlForCell(cellId);
104
- if (!dataUrl) {
105
- return;
103
+ try {
104
+ const dataUrl = await getImageDataUrlForCell(cellId);
105
+ if (!dataUrl) {
106
+ throw new Error("Failed to get image data URL");
107
+ }
108
+ downloadByURL(dataUrl, Filenames.toPNG(filename));
109
+ } catch (error) {
110
+ toast({
111
+ title: "Failed to download PNG",
112
+ description: prettyError(error),
113
+ variant: "danger",
114
+ });
106
115
  }
107
- downloadByURL(dataUrl, Filenames.toPNG(filename));
108
116
  }
109
117
 
110
118
  export const ADD_PRINTING_CLASS = (): (() => void) => {