@marimo-team/frontend 0.23.16-dev22 → 0.23.16-dev24

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 (55) hide show
  1. package/dist/assets/{JsonOutput-BoDVlAbV.js → JsonOutput-BG5T3DG2.js} +3 -3
  2. package/dist/assets/{add-cell-with-ai-CI-OMQ6o.js → add-cell-with-ai-BBAhBpT1.js} +1 -1
  3. package/dist/assets/{add-connection-dialog-wLF3on0N.js → add-connection-dialog-DFD5BLGa.js} +1 -1
  4. package/dist/assets/{agent-panel-BnWKBlgm.js → agent-panel-TJGdsxOX.js} +1 -1
  5. package/dist/assets/{ai-model-dropdown-JakbdGqy.js → ai-model-dropdown-BMS30HMu.js} +1 -1
  6. package/dist/assets/{app-config-button-CJthjCbw.js → app-config-button-Cankwixh.js} +1 -1
  7. package/dist/assets/{cell-editor-g_X3FLOk.js → cell-editor-sBYL591r.js} +1 -1
  8. package/dist/assets/{chat-display-5IKsJo5G.js → chat-display-ZB0n2r4U.js} +1 -1
  9. package/dist/assets/{chat-panel-T0aeOGBD.js → chat-panel-BKqRvvhb.js} +1 -1
  10. package/dist/assets/{chat-ui-Bmpv2cR-.js → chat-ui-B3Pz1Tc4.js} +1 -1
  11. package/dist/assets/{column-preview-BYiduGzU.js → column-preview-CSVQtCQS.js} +1 -1
  12. package/dist/assets/{command-palette-jBZ38N6a.js → command-palette-DiUt8L1K.js} +1 -1
  13. package/dist/assets/{dependency-graph-panel-98TlJ5y7.js → dependency-graph-panel-rRXAafZ4.js} +1 -1
  14. package/dist/assets/download-Benw6kUY.js +9 -0
  15. package/dist/assets/{edit-page-DB-NYT_3.js → edit-page-CxNNXB4Y.js} +5 -5
  16. package/dist/assets/{file-explorer-panel-8_ps5wdU.js → file-explorer-panel-C9I7XP84.js} +1 -1
  17. package/dist/assets/{form-B5UJtZJr.js → form-DrCvDcRK.js} +1 -1
  18. package/dist/assets/{home-page-IUw94a9S.js → home-page-DwtZlFRD.js} +1 -1
  19. package/dist/assets/{index-BS2Sunf3.js → index-DK7_phcn.js} +21 -21
  20. package/dist/assets/{layout-CyjXUY2w.js → layout-Cdpz2zk4.js} +5 -5
  21. package/dist/assets/{packages-panel-CsjyKddU.js → packages-panel-kj52vQTZ.js} +1 -1
  22. package/dist/assets/{pair-with-agent-modal-nwd26aKZ.js → pair-with-agent-modal-BUtnUuiE.js} +1 -1
  23. package/dist/assets/{panels-B8l1VE0-.js → panels-Bs7O_Hac.js} +1 -1
  24. package/dist/assets/{readonly-python-code-BqcMp63O.js → readonly-python-code-3UXLXM0g.js} +1 -1
  25. package/dist/assets/{reveal-component-D2zYX2Tk.js → reveal-component-DTcc6OYd.js} +1 -1
  26. package/dist/assets/{run-page-B74_5nDW.js → run-page-BgzVSOZh.js} +1 -1
  27. package/dist/assets/{scratchpad-panel-BASwTNGO.js → scratchpad-panel-XnaU8Prb.js} +1 -1
  28. package/dist/assets/{session-panel-DO-4U6Ry.js → session-panel-Cs9YKkJc.js} +1 -1
  29. package/dist/assets/{skeleton-DuUCup3W.js → skeleton-BOtI6k5P.js} +1 -1
  30. package/dist/assets/{state-D2ccy8VQ.js → state-Dj8qTUAp.js} +1 -1
  31. package/dist/assets/switch-OVajJBPR.js +1 -0
  32. package/dist/assets/{useCellActionButton-BhCYWOKS.js → useCellActionButton-Bglkc3w8.js} +1 -1
  33. package/dist/assets/{useDependencyPanelTab-CAI77Oxj.js → useDependencyPanelTab-DjhiptCs.js} +1 -1
  34. package/dist/assets/useNotebookActions-Bj0q_nkr.js +12 -0
  35. package/dist/index.html +8 -8
  36. package/package.json +1 -1
  37. package/src/__mocks__/requests.ts +20 -4
  38. package/src/components/editor/actions/__tests__/pdf-export.test.ts +0 -4
  39. package/src/components/editor/actions/pdf-export.ts +1 -4
  40. package/src/components/editor/actions/useNotebookActions.tsx +7 -13
  41. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +1 -1
  42. package/src/components/static-html/share-modal.tsx +1 -1
  43. package/src/core/network/__tests__/api.test.ts +42 -0
  44. package/src/core/network/__tests__/requests-network.test.ts +1 -0
  45. package/src/core/network/api.ts +27 -0
  46. package/src/core/network/requests-network.ts +5 -5
  47. package/src/core/network/types.ts +15 -4
  48. package/src/core/static/download-html.ts +5 -14
  49. package/src/core/wasm/bridge.ts +3 -2
  50. package/src/core/wasm/worker/types.ts +5 -2
  51. package/src/utils/__tests__/download.test.tsx +24 -1
  52. package/src/utils/download.ts +11 -6
  53. package/dist/assets/download-CnYLah74.js +0 -9
  54. package/dist/assets/switch-Drt3XC71.js +0 -1
  55. package/dist/assets/useNotebookActions-IfA6VBEA.js +0 -12
@@ -0,0 +1,12 @@
1
+ import{s as Se}from"./chunk-LvLJmgfZ.js";import{d as R,i as Wt,l as St,p as At,u as N}from"./useEvent-D91BmmQi.js";import{t as _t}from"./react-Bj1aDYRI.js";import{Bn as Dt,Dn as Et,Dr as It,E as Ae,Ht as Pt,Ii as Lt,Ji as ke,On as Tt,Sr as Ot,T as Ht,_r as Rt,g as $t,ji as Bt,jn as qt,jt as _e,kn as Ft,m as De,t as Ut,ti as Yt,vr as Ee,wn as Vt,y as Kt,yr as Gt}from"./cells-D9tCNe6o.js";import{t as z}from"./compiler-runtime-B3qBwwSJ.js";import{n as Jt,r as Xt,x as Qt}from"./ai-model-dropdown-BMS30HMu.js";import{g as $,n as Zt}from"./useEventListener-C0195JsF.js";import{t as Ie}from"./objects-BlG0ZrO0.js";import{C as ea,r as ta}from"./utils-BWBBpCkT.js";import{n as v,t as Pe}from"./constants-CDyU_g2F.js";import{M as ee,O as aa,T as Le,j as Te,k as na,v as Oe}from"./config-B-Q7J_6d.js";import{c as oa}from"./readonly-python-code-3UXLXM0g.js";import{t as sa}from"./cn-DYvqRARy.js";import{t as ra}from"./jsx-runtime-Blw4afVn.js";import{o as la}from"./alert-dialog-Bb8Lz8ko.js";import{a as ia,c as da,i as ca,n as ha,r as ma,s as ua,t as pa}from"./select-BP75_5jJ.js";import{Lt as fa}from"./JsonOutput-BG5T3DG2.js";import{f as xa,l as He,n as ba,o as Re,r as ya,s as ka,t as wa}from"./download-Benw6kUY.js";import{t as ja}from"./tooltip-4bZlU7jl.js";import{r as ga,t as P}from"./button-DDGiD1NW.js";import{i as va,t as we}from"./strings--BknHX9C.js";import{r as L}from"./requests-9-v2bhoi.js";import{t as k}from"./createLucideIcon-w-Qo9n0R.js";import{F as Ca,I as Na,L as za,R as $e,a as Be,d as Ma,i as qe,u as Fe}from"./layout-Cdpz2zk4.js";import{t as Ue}from"./check-rzLRd0j9.js";import{r as Wa}from"./useCellActionButton-Bglkc3w8.js";import{t as Sa}from"./code-B2aKtXoe.js";import{t as Aa}from"./copy-3iHFdt22.js";import{t as Ye}from"./eye-off-BOZA7gbn.js";import{t as Ve}from"./external-link-BOlXZUla.js";import{t as te}from"./file-CJH9JNGH.js";import{u as _a}from"./form-DrCvDcRK.js";import{n as Da,r as Ea,t as Ia}from"./youtube-OwaksuQt.js";import{i as Pa,n as Ke}from"./add-connection-dialog-DFD5BLGa.js";import{t as La}from"./house-DS0r7dNZ.js";import{t as Ta}from"./image-5XI2VU-q.js";import{t as Oa}from"./link-CHdiBDr5.js";import{r as Ha}from"./input-JxFwu-3G.js";import{t as Ra}from"./settings-D_PiwXwo.js";import{t as $a}from"./sparkles-DUCpRFlS.js";import{y as Ba}from"./textarea-BQE_pb7P.js";import{t as qa}from"./square-DFICx2Qv.js";import{t as Ge}from"./triangle-alert-BL4YVsPy.js";import{t as W}from"./use-toast-BwJoaaDM.js";import{n as Je,t as Fa}from"./paths-BKO-pHK6.js";import{o as Ua}from"./session-BmukRjSi.js";import{n as ae}from"./copy-Bxb1_Gtw.js";import{t as Xe}from"./copy-icon-neDQUo4Q.js";import{r as Ya}from"./useRunCells-BpMmDGqa.js";import{a as Qe,c as Ze,i as Va,n as et,r as tt}from"./dialog-BCVepWLJ.js";import{n as ne}from"./ImperativeModal-fY-ZfT0b.js";import{r as Ka,t as at}from"./share-852X_cqy.js";import{a as Ga}from"./cell-link-D1nZ5myN.js";import{n as nt}from"./useAsyncData-Bg5iAViP.js";import{a as Ja}from"./renderShortcut-Bl8_FVn8.js";import{t as Xa}from"./icons-CIPE8AIY.js";import{i as Qa,n as ot}from"./error-entries-CmfGHGq1.js";import{t as Za}from"./pair-with-agent-modal-BUtnUuiE.js";import{t as en}from"./github-_JH-0hIO.js";import{n as st}from"./marimo-icons-C_nFooxr.js";import{t as tn}from"./links-CZr5bjvo.js";import{i as an,n as rt,t as je}from"./skeleton-BOtI6k5P.js";import{t as lt}from"./types-Da7lA5YC.js";var nn=k("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),on=k("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),it=k("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),dt=k("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),ct=k("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),sn=k("fast-forward",[["path",{d:"M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z",key:"b19h5q"}],["path",{d:"M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z",key:"h7h5ge"}]]),rn=k("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]),ln=k("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),ht=k("message-circle-question-mark",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),dn=k("notebook",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]]),cn=k("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),mt=k("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),hn=k("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),mn=k("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),ut=k("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),un=z(),T=Se(_t(),1);function ge(e,t){let n=(0,un.c)(11),o;n[0]===t?o=n[1]:(o=new Bt(t),n[0]=t,n[1]=o);let s=o,l;n[2]!==e||n[3]!==s?(l=()=>s.get(e),n[2]=e,n[3]=s,n[4]=l):l=n[4];let[r,d]=(0,T.useState)(l),i;n[5]!==e||n[6]!==s?(i=x=>{d(x),s.set(e,x)},n[5]=e,n[6]=s,n[7]=i):i=n[7];let c=i,h;return n[8]!==c||n[9]!==r?(h=[r,c],n[8]=c,n[9]=r,n[10]=h):h=n[10],h}function pn(e,t){return{...e,Binaries:{...e.Binaries,Browser:t}}}function fn(e,t,n,o){return{marimo:e,Locale:n||void 0,Binaries:{Browser:t},"Environment Collection Error":o}}function ve(e,t){let n=Math.max(2,...Array.from(t.matchAll(/`+/g),s=>s[0].length)),o="`".repeat(n+1);return`${o}${e}
2
+ ${t}
3
+ ${o}`}function xn(e,t){let n=e.includes("?")?"&":"?",o=[],s=e,l=0;for(let[r,d]of Object.entries(t)){if(d.length===0)continue;let i=`${r}=${encodeURIComponent(d)}`,c=`${s}${l===0?n:"&"}${i}`;if(c.length>6e3){o.push(r);continue}s=c,l+=1}return{url:s,omitted:o}}function Ce(e,t){return["<details>",`<summary>${we.htmlEscape(e)??""}</summary>`,"",t,"","</details>"].join(`
4
+ `)}function bn(e){return Ce("Environment",ve("json",JSON.stringify(e,null,2)))}function pt(e){return Ce("Errors",ve("text",e.map(ot).join(`
5
+
6
+ ---
7
+
8
+ `)))}function yn(e){return Ce("Code",ve("python",e))}var ft=z(),a=Se(ra(),1),kn=Zt,xt=e=>{let t=(0,ft.c)(16),{content:n}=e,[o,s]=(0,T.useState)(!1),l=!o&&"max-h-24 overflow-hidden",r;t[0]===l?r=t[1]:(r=sa("text-xs bg-muted rounded p-2 overflow-x-auto whitespace-pre-wrap",l),t[0]=l,t[1]=r);let d;t[2]!==n||t[3]!==r?(d=(0,a.jsx)("pre",{className:r,children:n}),t[2]=n,t[3]=r,t[4]=d):d=t[4];let i;t[5]===o?i=t[6]:(i=!o&&(0,a.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10 rounded-b bg-gradient-to-b from-transparent to-muted"}),t[5]=o,t[6]=i);let c;t[7]!==d||t[8]!==i?(c=(0,a.jsxs)("div",{className:"relative",children:[d,i]}),t[7]=d,t[8]=i,t[9]=c):c=t[9];let h;t[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>s(jn),t[10]=h):h=t[10];let x=o?"Show less":"Show more",m;t[11]===x?m=t[12]:(m=(0,a.jsx)(P,{type:"button",variant:"link",size:"xs",className:"self-start",onClick:h,children:x}),t[11]=x,t[12]=m);let b;return t[13]!==c||t[14]!==m?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[c,m]}),t[13]=c,t[14]=m,t[15]=b):b=t[15],b};const wn=e=>{let t=(0,ft.c)(6),{children:n}=e,{openModal:o,closeModal:s}=ne(),l;t[0]!==s||t[1]!==o?(l=()=>o((0,a.jsx)(bt,{onClose:s})),t[0]=s,t[1]=o,t[2]=l):l=t[2];let r;return t[3]!==n||t[4]!==l?(r=(0,a.jsx)(kn,{onClick:l,children:n}),t[3]=n,t[4]=l,t[5]=r):r=t[5],r},bt=()=>{let{getEnvironmentInfo:e,readCode:t}=L(),n=nt(async()=>e(),[e]),o=N(Kt),s=(0,T.useMemo)(()=>Qa(Wt),[o]),l=Ma(o.cellIds.inOrderIds.map(u=>o.cellData[u])),r=N(Lt),d=N(Oe),i=r!==null&&l&&d.state===Le.OPEN,c=i?void 0:r===null?"Save the notebook first.":l?"Connect the notebook to include its source.":"Notebook source is hidden in this view.",[h,x]=ge("marimo:issue-report:include-errors",!1),[m,b]=ge("marimo:issue-report:include-code",!1),f=n.data?pn(n.data,navigator.userAgent):n.status==="error"?fn(oa(),navigator.userAgent,navigator.language,"Server environment information unavailable"):void 0,y=nt(async()=>{if(!m||!i)return;let{contents:u}=await t();return u},[m,i,t]),{url:w,omitted:j}=(0,T.useMemo)(()=>{if(!f)return{url:v.bugReportUrl,omitted:[]};let u={env:bn(f)};return h&&s.length>0&&(u["bug-description"]=pt(s)),m&&y.data&&(u["reproduction-code"]=yn(y.data)),xn(v.bugReportUrl,u)},[f,s,h,m,y.data]),g=j.map(u=>u==="bug-description"?"errors":u==="reproduction-code"?"code":u).join(", ");return(0,a.jsxs)(et,{className:"w-[540px] max-w-[90vw]",children:[(0,a.jsxs)(Qe,{children:[(0,a.jsx)(Ze,{children:"Report an issue"}),(0,a.jsx)(tt,{children:"Open a GitHub bug report prefilled with your environment, and optionally your current errors and notebook code. Nothing is uploaded automatically; review the details before posting."})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 max-h-[60vh] overflow-y-auto",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsx)(P,{type:"button",variant:"default",size:"xs",asChild:!0,className:"self-start",children:(0,a.jsxs)("a",{href:w,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)(Ve,{className:"w-4 h-4 mr-2"}),"Open GitHub issue"]})}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(_e,{id:"issue-include-errors",checked:h,disabled:s.length===0,onCheckedChange:u=>x(u===!0),"aria-label":"Include errors"}),(0,a.jsx)("label",{htmlFor:"issue-include-errors",children:"Include errors"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(_e,{id:"issue-include-code",checked:m,disabled:!i,onCheckedChange:u=>b(u===!0),"aria-label":"Include notebook code"}),(0,a.jsx)("label",{htmlFor:"issue-include-code",children:"Include notebook code"})]}),c&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground ml-6",children:c}),m&&y.status==="error"&&(0,a.jsx)("span",{className:"text-xs text-(--red-11) ml-6",children:"Notebook source could not be loaded."})]})]}),g?(0,a.jsxs)("div",{className:"flex items-start gap-2 text-xs text-(--yellow-11)",children:[(0,a.jsx)(Ge,{className:"w-3.5 h-3.5 shrink-0 mt-0.5"}),(0,a.jsxs)("span",{children:["Too large to prefill and left out of the link: ",g,". Paste them into the issue manually."]})]}):(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Your environment is always included."})]}),n.status==="pending"&&(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading environment details\u2026"}),(0,a.jsx)(je,{className:"h-4 w-full"}),(0,a.jsx)(je,{className:"h-4 w-3/4"}),(0,a.jsx)(je,{className:"h-4 w-1/2"})]}),n.status==="error"&&(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,a.jsx)(Ge,{className:"w-4 h-4 text-(--yellow-11) shrink-0"}),(0,a.jsx)("span",{children:"Server environment information unavailable"}),(0,a.jsx)(P,{type:"button",variant:"link",size:"xs",onClick:()=>n.refetch(),children:"Retry"})]}),f&&(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Environment details"}),(0,a.jsx)(Xe,{className:"w-3.5 h-3.5",value:JSON.stringify(f,null,2),ariaLabel:"Copy environment JSON",toastTitle:"Environment details copied"})]}),(0,a.jsx)(xt,{content:JSON.stringify(f,null,2)})]}),f&&s.length>0&&(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"Errors"}),(0,a.jsx)(Xe,{className:"w-3.5 h-3.5",value:pt(s),ariaLabel:"Copy errors",toastTitle:"Errors copied"})]}),(0,a.jsx)(xt,{content:s.map(ot).join(`
9
+
10
+ ---
11
+
12
+ `)})]}),f&&s.length===0&&(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"No errors detected."}),(0,a.jsx)("div",{className:"border-t pt-3",children:(0,a.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Other feedback? Take our"," ",(0,a.jsx)("a",{href:v.feedbackForm,target:"_blank",rel:"noreferrer",className:"underline",children:"two-minute survey"})," ","or chat with us on"," ",(0,a.jsx)("a",{href:v.discordLink,target:"_blank",rel:"noreferrer",className:"underline",children:"Discord"}),"."]})})]})]})};function jn(e){return!e}var yt=z(),oe="https://static.marimo.app";const gn=e=>{let t=(0,yt.c)(25),{onClose:n}=e,[o,s]=(0,T.useState)(""),{exportAsHTML:l}=L(),r=`${o}-${Math.random().toString(36).slice(2,6)}`,d=`${oe}/static/${r}`,i;t[0]!==l||t[1]!==n||t[2]!==r?(i=async u=>{u.preventDefault(),n();let{contents:H}=await l({download:!1,includeCode:!0,files:Ca.INSTANCE.filenames()}),S=W({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${oe}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:H,path:r})}).catch(()=>{S.dismiss(),W({title:"Error uploading static page",description:(0,a.jsxs)("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",(0,a.jsx)("a",{href:v.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),S.dismiss(),W({title:"Static page uploaded!",description:(0,a.jsxs)("div",{children:["The URL has been copied to your clipboard.",(0,a.jsx)("br",{}),"You can share it with anyone."]})})},t[0]=l,t[1]=n,t[2]=r,t[3]=i):i=t[3];let c;t[4]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(Ze,{children:"Share static notebook"}),t[4]=c):c=t[4];let h;t[5]===Symbol.for("react.memo_cache_sentinel")?(h=(0,a.jsxs)(Qe,{children:[c,(0,a.jsxs)(tt,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",(0,a.jsx)("a",{href:oe,target:"_blank",children:oe}),"."]})]}),t[5]=h):h=t[5];let x;t[6]===Symbol.for("react.memo_cache_sentinel")?(x=u=>{s(u.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,""))},t[6]=x):x=t[6];let m;t[7]===o?m=t[8]:(m=(0,a.jsx)(Ha,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:x,required:!0,autoComplete:"off"}),t[7]=o,t[8]=m);let b;t[9]===d?b=t[10]:(b=(0,a.jsxs)("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(vn,{text:d}),(0,a.jsx)("span",{className:"text-primary",children:d})]})]}),t[9]=d,t[10]=b);let f;t[11]!==m||t[12]!==b?(f=(0,a.jsxs)("div",{className:"flex flex-col gap-6 py-4",children:[m,b]}),t[11]=m,t[12]=b,t[13]=f):f=t[13];let y;t[14]===n?y=t[15]:(y=(0,a.jsx)(P,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=y);let w;t[16]===d?w=t[17]:(w=(0,a.jsx)(P,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await ae(d)},children:"Create"}),t[16]=d,t[17]=w);let j;t[18]!==y||t[19]!==w?(j=(0,a.jsxs)(Va,{children:[y,w]}),t[18]=y,t[19]=w,t[20]=j):j=t[20];let g;return t[21]!==i||t[22]!==j||t[23]!==f?(g=(0,a.jsx)(et,{className:"w-fit",children:(0,a.jsxs)("form",{onSubmit:i,children:[h,f,j]})}),t[21]=i,t[22]=j,t[23]=f,t[24]=g):g=t[24],g};var vn=e=>{let t=(0,yt.c)(8),[n,o]=T.useState(!1),s;t[0]===e.text?s=t[1]:(s=ga.stopPropagation(async c=>{c.preventDefault(),await ae(e.text),o(!0),setTimeout(()=>o(!1),2e3)}),t[0]=e.text,t[1]=s);let l=s,r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,a.jsx)(Aa,{size:14,strokeWidth:1.5}),t[2]=r):r=t[2];let d;t[3]===l?d=t[4]:(d=(0,a.jsx)(P,{"data-testid":"copy-static-notebook-url-button",onClick:l,size:"xs",variant:"secondary",children:r}),t[3]=l,t[4]=d);let i;return t[5]!==n||t[6]!==d?(i=(0,a.jsx)(ja,{content:"Copied!",open:n,children:d}),t[5]=n,t[6]=d,t[7]=i):i=t[7],i},Cn=z();function Nn(){let e=document.getElementsByClassName(Pe.outputArea);for(let t of e){let n=t.getBoundingClientRect();if(n.bottom>0&&n.top<window.innerHeight){let o=ke.findElement(t);if(!o){$.warn("Could not find HTMLCellId for visible output area",t);continue}return{cellId:ke.parse(o.id)}}}return $.warn("No visible output area found for scroll anchor"),null}function zn(e){if(!e){$.warn("No scroll anchor provided to restore scroll position");return}let t=document.getElementById(ke.create(e.cellId));if(!t){$.warn("Could not find cell element to restore scroll position",e.cellId);return}if(!t.querySelector(`.${Pe.outputArea}`)){$.warn("Could not find output area to restore scroll position",e.cellId);return}t.scrollIntoView({block:"start",behavior:"auto"})}function kt(){let e=(0,Cn.c)(2),t=R(Te),n;return e[0]===t?n=e[1]:(n=()=>{let o=Nn();t(s=>({mode:na(s.mode),cellAnchor:(o==null?void 0:o.cellId)??null})),requestAnimationFrame(()=>{requestAnimationFrame(()=>{zn(o)})})},e[0]=t,e[1]=n),n}const wt=At(!1);var Mn=z();const Wn=()=>{let e=(0,Mn.c)(7),{selectedLayout:t}=Be(),{setLayoutView:n}=qe();if(ee()&&!Dt("wasm_layouts"))return null;let o;e[0]===n?o=e[1]:(o=d=>n(d),e[0]=n,e[1]=o);let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(ua,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:(0,a.jsx)(da,{placeholder:"Select a view"})}),e[2]=s):s=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(ha,{children:(0,a.jsxs)(ma,{children:[(0,a.jsx)(ia,{children:"View as"}),lt.map(An)]})}),e[3]=l):l=e[3];let r;return e[4]!==t||e[5]!==o?(r=(0,a.jsxs)(pa,{"data-testid":"layout-select",value:t,onValueChange:o,children:[s,l]}),e[4]=t,e[5]=o,e[6]=r):r=e[6],r};function Sn(e){return(0,a.jsx)(jt(e),{className:"h-4 w-4"})}function jt(e){switch(e){case"vertical":return ln;case"grid":return Ea;case"slides":return mt;default:return va(e),qa}}function gt(e){return we.startCase(e)}function An(e){return(0,a.jsx)(ca,{value:e,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 leading-5",children:[Sn(e),(0,a.jsx)("span",{children:gt(e)})]})},e)}async function _n(e){let{preset:t,downloadPDF:n}=e;await n({webpdf:!1,preset:t,includeInputs:!0,rasterServer:"static"})}var Dn=z();function En(e){let t=(0,Dn.c)(5),{openPrompt:n,closeModal:o}=ne(),{sendCopy:s}=L(),l;return t[0]!==o||t[1]!==n||t[2]!==s||t[3]!==e?(l=()=>{if(!e)return null;let r=Fa.guessDeliminator(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${Je.basename(e)}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:d=>{let i=r.join(Je.dirname(e),d);s({source:e,destination:i}).then(()=>{o(),W({title:"Notebook copied",description:"A copy of the notebook has been created."}),tn(i)})}})},t[0]=o,t[1]=n,t[2]=s,t[3]=e,t[4]=l):l=t[4],l}var In=z();function vt(){let e=(0,In.c)(4),{openConfirm:t}=ne(),n=R(Oe),{sendRestart:o}=L(),s;return e[0]!==t||e[1]!==o||e[2]!==n?(s=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:(0,a.jsx)(la,{onClick:async()=>{n({state:Le.CLOSING}),await o(),Ka()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=o,e[2]=n,e[3]=s):s=e[3],s}var Pn=z(),Ln=new Pt,Tn=e=>Ln.isSupported(e)?"markdown":"code";const Ct=()=>{let e=(0,Pn.c)(3),{updateCellConfig:t}=Ae(),{saveCellConfig:n}=L(),o;return e[0]!==n||e[1]!==t?(o=async(s,l)=>{let r=De(),d={};for(let c of r.cellIds.inOrderIds){let h=r.cellData[c];h===void 0||h.config.hide_code===s||Tn(h.code)===l&&(d[c]={hide_code:s})}let i=Ie.entries(d);if(i.length!==0){await n({configs:d});for(let[c,h]of i)t({cellId:c,config:h})}},e[0]=n,e[1]=t,e[2]=o):o=e[2],o};var On=z(),O=e=>{e==null||e.preventDefault(),e==null||e.stopPropagation()};function Hn(){var ze,Me,We;let e=(0,On.c)(56),t=Ga(),{openModal:n,closeModal:o}=ne(),{toggleApplication:s}=Et(),{selectedPanel:l}=Tt(),[r]=St(Te),d=N(aa),i=Ct(),[c]=ea(),h=N(Vt),x=N(ta),{updateCellConfig:m,undoDeleteCell:b,clearAllCellOutputs:f,addSetupCellIfDoesntExist:y,collapseAllCells:w,expandAllCells:j}=Ae(),g=vt(),u=Ya(),H=En(t),S=R(wt),re=R(Jt),{handleClick:le}=Xt(),ie=R(Qt),{exportAsIPYNB:de,exportAsMarkdown:ce,readCode:A,saveCellConfig:he,updateCellOutputs:_}=L(),D=an(),me=N($t),ue=N(Ut),pe=N(Ht),{selectedLayout:B}=Be(),{setLayoutView:fe}=qe(),q=kt(),F=((ze=c.sharing)==null?void 0:ze.html)??!0,U=((Me=c.sharing)==null?void 0:Me.wasm)??!0,Y=((We=c.sharing)==null?void 0:We.molab)??!0,Ne=!ee(),xe=B==="slides",Nt=no,zt=ao,V;e[0]!==t||e[1]!==D||e[2]!==_?(V=async p=>{let{preset:C,title:M}=p;if(!t){se();return}await He(M,async ye=>{await rt({takeScreenshots:()=>D({progress:ye}),updateCellOutputs:_}),await _n({preset:C,downloadPDF:ba})})},e[0]=t,e[1]=D,e[2]=_,e[3]=V):V=e[3];let E=V,K;e[4]===E?K=e[5]:(K=async()=>{if(Ne){await E({preset:"document",title:"Downloading Document PDF..."});return}let p=new Event("export-beforeprint"),C=new Event("export-afterprint");window.dispatchEvent(p),setTimeout(to,0),setTimeout(()=>window.dispatchEvent(C),0)},e[4]=E,e[5]=K);let G=K,J;e[6]!==de||e[7]!==t||e[8]!==D||e[9]!==_?(J=async()=>{if(!t){se();return}await He("Downloading IPYNB...",async p=>{await rt({takeScreenshots:()=>D({progress:p}),updateCellOutputs:_}),Re(await de({download:!1}))})},e[6]=de,e[7]=t,e[8]=D,e[9]=_,e[10]=J):J=e[10];let be=J,X;e[11]===Symbol.for("react.memo_cache_sentinel")?(X=(0,a.jsx)(fa,{size:14,strokeWidth:1.5}),e[11]=X):X=e[11];let Q;e[12]===Symbol.for("react.memo_cache_sentinel")?(Q=(0,a.jsx)($e,{size:14,strokeWidth:1.5}),e[12]=Q):Q=e[12];let I;e[13]===t?I=e[14]:(I=async()=>{if(!t){se();return}await Fe({includeCode:!0})},e[13]=t,e[14]=I);let Z;return e[15]!==y||e[16]!==x||e[17]!==ue||e[18]!==h||e[19]!==f||e[20]!==o||e[21]!==w||e[22]!==H||e[23]!==E||e[24]!==j||e[25]!==ce||e[26]!==t||e[27]!==G||e[28]!==be||e[29]!==me||e[30]!==xe||e[31]!==d||e[32]!==n||e[33]!==le||e[34]!==A||e[35]!==g||e[36]!==u||e[37]!==he||e[38]!==B||e[39]!==l||e[40]!==i||e[41]!==S||e[42]!==ie||e[43]!==fe||e[44]!==re||e[45]!==F||e[46]!==Y||e[47]!==U||e[48]!==I||e[49]!==s||e[50]!==q||e[51]!==b||e[52]!==pe||e[53]!==m||e[54]!==r.mode?(Z=[{icon:X,label:"Download",handle:O,dropdown:[{icon:Q,label:"Download as HTML",handle:I},{icon:(0,a.jsx)($e,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{if(!t){se();return}await Fe({includeCode:!1})}},{icon:(0,a.jsx)(Xa,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{Re(await ce({download:!1}))}},{icon:(0,a.jsx)(dn,{size:14,strokeWidth:1.5}),label:"Download as ipynb",handle:be},{icon:(0,a.jsx)(Sa,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{let p=await A();ya(new Blob([p.contents],{type:"text/plain"}),xa.toPY(document.title))}},{divider:!0,icon:(0,a.jsx)(Ta,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:r.mode!=="present",tooltip:r.mode==="present"?void 0:(0,a.jsxs)("span",{children:["Only available in app view. ",(0,a.jsx)("br",{}),"Toggle with: ",Ja("global.hideCode",!1)]}),handle:eo},xe?{divider:!0,icon:(0,a.jsx)(te,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:O,dropdown:[{icon:(0,a.jsx)(te,{size:14,strokeWidth:1.5}),label:"Document Layout",handle:G},{icon:(0,a.jsx)(te,{size:14,strokeWidth:1.5}),label:"Slides Layout",rightElement:zt(!0),hidden:!Ne,handle:async()=>{await E({preset:"slides",title:"Downloading Slides PDF..."})}}]}:{divider:!0,icon:(0,a.jsx)(te,{size:14,strokeWidth:1.5}),label:"Download as PDF",handle:G}]},{icon:(0,a.jsx)($a,{size:14,strokeWidth:1.5}),label:"Pair with an agent",hidden:ee(),handle:async()=>{n((0,a.jsx)(Za,{onClose:o}))}},{icon:(0,a.jsx)(hn,{size:14,strokeWidth:1.5}),label:"Share",handle:O,hidden:!F&&!U&&!Y,dropdown:[{icon:(0,a.jsx)(_a,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",hidden:!F,handle:async()=>{n((0,a.jsx)(gn,{onClose:o}))}},{icon:(0,a.jsx)(Oa,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!U,handle:async()=>{await ae(at({code:(await A()).contents})),W({title:"Copied",description:"Link copied to clipboard."})}},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"Create molab notebook",hidden:!Y,handle:async()=>{let p=at({code:(await A()).contents,baseUrl:`${v.molab}/new`});window.open(p,"_blank")}}]},{icon:(0,a.jsx)(cn,{size:14,strokeWidth:1.5}),label:"Helper panel",redundant:!0,handle:O,dropdown:Ft.flatMap(p=>{let C=p.type==="ai"&&!x;if(qt({panel:p,capabilities:h,aiEnabled:x})&&!C)return[];let{type:M,Icon:ye,additionalKeywords:Mt}=p;return{label:we.startCase(M),rightElement:Nt(l===M),icon:(0,a.jsx)(ye,{size:14,strokeWidth:1.5}),handle:()=>{if(C){le("ai","ai-features");return}s(M)},additionalKeywords:Mt}})},{icon:(0,a.jsx)(mt,{size:14,strokeWidth:1.5}),label:"Present as",handle:O,dropdown:[{icon:r.mode==="present"?(0,a.jsx)(Ba,{size:14,strokeWidth:1.5}):(0,a.jsx)(Na,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{q()}},...lt.map((p,C)=>{let M=jt(p);return{divider:C===0,label:gt(p),icon:(0,a.jsx)(M,{size:14,strokeWidth:1.5}),rightElement:(0,a.jsx)("div",{className:"w-8 flex justify-end",children:B===p&&(0,a.jsx)(Ue,{size:14})}),handle:()=>{fe(p),r.mode==="edit"&&q()}}})]},{icon:(0,a.jsx)(rn,{size:14,strokeWidth:1.5}),label:"Duplicate notebook",hidden:!t||ee(),handle:H},{icon:(0,a.jsx)(it,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!t,handle:async()=>{await ae((await A()).contents),W({title:"Copied",description:"Code copied to clipboard."})}},{icon:(0,a.jsx)(Wa,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!me||d,handle:async()=>{let p=Yt(De());await he({configs:Ie.fromEntries(p.map(Zn))});for(let C of p)m({cellId:C,config:{disabled:!1}})}},{divider:!0,icon:(0,a.jsx)(ct,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{y({})}},{icon:(0,a.jsx)(Gt,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n((0,a.jsx)(Ke,{onClose:o}))}},{icon:(0,a.jsx)(Pa,{size:14,strokeWidth:1.5}),label:"Add remote storage",handle:()=>{n((0,a.jsx)(Ke,{defaultTab:"storage",onClose:o}))}},{icon:(0,a.jsx)(ut,{size:14,strokeWidth:1.5}),label:pe,hidden:!ue||d,handle:()=>{b()}},{icon:(0,a.jsx)(mn,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:g,additionalKeywords:["reset","reload","restart"]},{icon:(0,a.jsx)(sn,{size:14,strokeWidth:1.5}),label:"Re-run all cells",redundant:!0,hotkey:"global.runAll",handle:async()=>{u()}},{icon:(0,a.jsx)(Ot,{size:14,strokeWidth:1.5}),label:"Clear all outputs",redundant:!0,handle:()=>{f()}},{icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Show all code",hotkey:"global.showAllCode",handle:()=>i(!1,"code"),redundant:!0},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Hide all code",hotkey:"global.hideAllCode",handle:()=>i(!0,"code"),redundant:!0},{icon:(0,a.jsx)(Ee,{size:14,strokeWidth:1.5}),label:"Show all markdown code",hotkey:"global.showAllMarkdownCode",handle:()=>i(!1,"markdown"),redundant:!0},{icon:(0,a.jsx)(Ye,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",hotkey:"global.hideAllMarkdownCode",handle:()=>i(!0,"markdown"),redundant:!0},{icon:(0,a.jsx)(on,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:w,redundant:!0},{icon:(0,a.jsx)(nn,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:j,redundant:!0},{divider:!0,icon:(0,a.jsx)(dt,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>S(Qn)},{icon:(0,a.jsx)(za,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>ie(Xn)},{icon:(0,a.jsx)(Ra,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>re(Jn),redundant:!0,additionalKeywords:["preferences","options","configuration"]},{icon:(0,a.jsx)(ht,{size:14,strokeWidth:1.5}),label:"Report an issue",additionalKeywords:["feedback","bug","issue","report","diagnostics"],handle:()=>n((0,a.jsx)(bt,{onClose:o}))},{icon:(0,a.jsx)(Ve,{size:14,strokeWidth:1.5}),label:"Resources",handle:O,dropdown:[{icon:(0,a.jsx)(It,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Gn},{icon:(0,a.jsx)(en,{className:"h-3.5 w-3.5"}),label:"GitHub",handle:Kn},{icon:(0,a.jsx)(Da,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Vn},{icon:(0,a.jsx)(Ia,{className:"h-3.5 w-3.5"}),label:"YouTube",handle:Yn},{icon:(0,a.jsx)(Rt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Un}]},{divider:!0,icon:(0,a.jsx)(La,{size:14,strokeWidth:1.5}),label:"Open home",hidden:!location.search.includes("file"),handle:Fn},{icon:(0,a.jsx)(st,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:qn}].filter(Bn).map(Rn),e[15]=y,e[16]=x,e[17]=ue,e[18]=h,e[19]=f,e[20]=o,e[21]=w,e[22]=H,e[23]=E,e[24]=j,e[25]=ce,e[26]=t,e[27]=G,e[28]=be,e[29]=me,e[30]=xe,e[31]=d,e[32]=n,e[33]=le,e[34]=A,e[35]=g,e[36]=u,e[37]=he,e[38]=B,e[39]=l,e[40]=i,e[41]=S,e[42]=ie,e[43]=fe,e[44]=re,e[45]=F,e[46]=Y,e[47]=U,e[48]=I,e[49]=s,e[50]=q,e[51]=b,e[52]=pe,e[53]=m,e[54]=r.mode,e[55]=Z):Z=e[55],Z}function Rn(e){return e.dropdown?{...e,dropdown:e.dropdown.filter($n)}:e}function $n(e){return!e.hidden}function Bn(e){return!e.hidden}function qn(){let e=Ua();window.open(e,"_blank")}function Fn(){let e=document.baseURI.split("?")[0];window.open(e,"_blank","noopener")}function Un(){window.open(v.releasesPage,"_blank")}function Yn(){window.open(v.youtube,"_blank")}function Vn(){window.open(v.discordLink,"_blank")}function Kn(){window.open(v.githubPage,"_blank")}function Gn(){window.open(v.docsPage,"_blank")}function Jn(e){return!e}function Xn(e){return!e}function Qn(e){return!e}function Zn(e){return[e,{disabled:!1}]}async function eo(){let e=document.getElementById("App");e&&await ka({element:e,filename:document.title,prepare:wa})}function to(){return window.print()}function ao(e){return e?(0,a.jsx)("span",{className:"ml-3 shrink-0 rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700",children:"Recommended"}):null}function no(e){return(0,a.jsx)("div",{className:"w-8 flex justify-end",children:e&&(0,a.jsx)(Ue,{size:14})})}function se(){W({title:"Error",description:"Notebooks must be named to be exported.",variant:"danger"})}export{wt as a,ge as c,ct as d,dt as f,Wn as i,ut as l,Ct as n,kt as o,it as p,vt as r,wn as s,Hn as t,ht as u};
package/dist/index.html CHANGED
@@ -66,7 +66,7 @@
66
66
  <marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
67
67
  <!-- /TODO -->
68
68
  <title>{{ title }}</title>
69
- <script type="module" crossorigin src="./assets/index-BS2Sunf3.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-DK7_phcn.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-TXkS1QI3.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/objects-BlG0ZrO0.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
@@ -180,7 +180,7 @@
180
180
  <link rel="modulepreload" crossorigin href="./assets/field-BsxD35VE.js">
181
181
  <link rel="modulepreload" crossorigin href="./assets/popover-Bcz1Zikb.js">
182
182
  <link rel="modulepreload" crossorigin href="./assets/errors-PgHhDa-M.js">
183
- <link rel="modulepreload" crossorigin href="./assets/download-CnYLah74.js">
183
+ <link rel="modulepreload" crossorigin href="./assets/download-Benw6kUY.js">
184
184
  <link rel="modulepreload" crossorigin href="./assets/table-CH2plyy9.js">
185
185
  <link rel="modulepreload" crossorigin href="./assets/useIframeCapabilities-j6fR_dBA.js">
186
186
  <link rel="modulepreload" crossorigin href="./assets/error-banner-BSxEOIn2.js">
@@ -201,18 +201,18 @@
201
201
  <link rel="modulepreload" crossorigin href="./assets/plus-AgXtozBz.js">
202
202
  <link rel="modulepreload" crossorigin href="./assets/trash-2-72W0TZ3L.js">
203
203
  <link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-Z-MD3n3J.js">
204
- <link rel="modulepreload" crossorigin href="./assets/JsonOutput-BoDVlAbV.js">
204
+ <link rel="modulepreload" crossorigin href="./assets/JsonOutput-BG5T3DG2.js">
205
205
  <link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-iDRxid4h.js">
206
206
  <link rel="modulepreload" crossorigin href="./assets/square-function-DNNRTPQJ.js">
207
207
  <link rel="modulepreload" crossorigin href="./assets/spec-C7opZZRp.js">
208
- <link rel="modulepreload" crossorigin href="./assets/column-preview-BYiduGzU.js">
208
+ <link rel="modulepreload" crossorigin href="./assets/column-preview-CSVQtCQS.js">
209
209
  <link rel="modulepreload" crossorigin href="./assets/icons-CIPE8AIY.js">
210
210
  <link rel="modulepreload" crossorigin href="./assets/radio-group-CdR34W0K.js">
211
211
  <link rel="modulepreload" crossorigin href="./assets/floating-outline-BWk7h_Uf.js">
212
- <link rel="modulepreload" crossorigin href="./assets/switch-Drt3XC71.js">
212
+ <link rel="modulepreload" crossorigin href="./assets/switch-OVajJBPR.js">
213
213
  <link rel="modulepreload" crossorigin href="./assets/objectWithoutPropertiesLoose-CboCOq4o.js">
214
214
  <link rel="modulepreload" crossorigin href="./assets/esm-B30N1GS0.js">
215
- <link rel="modulepreload" crossorigin href="./assets/readonly-python-code-BqcMp63O.js">
215
+ <link rel="modulepreload" crossorigin href="./assets/readonly-python-code-3UXLXM0g.js">
216
216
  <link rel="modulepreload" crossorigin href="./assets/file-headphone-DAu6VO6j.js">
217
217
  <link rel="modulepreload" crossorigin href="./assets/file-CJH9JNGH.js">
218
218
  <link rel="modulepreload" crossorigin href="./assets/image-5XI2VU-q.js">
@@ -223,11 +223,11 @@
223
223
  <link rel="modulepreload" crossorigin href="./assets/memoize-Tp7rARFe.js">
224
224
  <link rel="modulepreload" crossorigin href="./assets/get-C-qh_et5.js">
225
225
  <link rel="modulepreload" crossorigin href="./assets/_baseSet-CsW0tABf.js">
226
- <link rel="modulepreload" crossorigin href="./assets/state-D2ccy8VQ.js">
226
+ <link rel="modulepreload" crossorigin href="./assets/state-Dj8qTUAp.js">
227
227
  <link rel="modulepreload" crossorigin href="./assets/label-CqjrpwRC.js">
228
228
  <link rel="modulepreload" crossorigin href="./assets/textarea-BQE_pb7P.js">
229
229
  <link rel="modulepreload" crossorigin href="./assets/refresh-ccw-sLaKP2vj.js">
230
- <link rel="modulepreload" crossorigin href="./assets/form-B5UJtZJr.js">
230
+ <link rel="modulepreload" crossorigin href="./assets/form-DrCvDcRK.js">
231
231
  <link rel="modulepreload" crossorigin href="./assets/renderShortcut-Bl8_FVn8.js">
232
232
  <link rel="modulepreload" crossorigin href="./assets/useBoolean-CFj86iac.js">
233
233
  <link rel="modulepreload" crossorigin href="./assets/useDeepCompareMemoize-CSMoa-ga.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.23.16-dev22",
3
+ "version": "0.23.16-dev24",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -64,10 +64,26 @@ export const MockRequestClient = {
64
64
  getWorkspaceFiles: vi.fn().mockResolvedValue({ files: [] }),
65
65
  getRunningNotebooks: vi.fn().mockResolvedValue({ files: [] }),
66
66
  shutdownSession: vi.fn().mockResolvedValue({}),
67
- exportAsHTML: vi.fn().mockResolvedValue({ html: "" }),
68
- exportAsIPYNB: vi.fn().mockResolvedValue(""),
69
- exportAsMarkdown: vi.fn().mockResolvedValue({ markdown: "" }),
70
- exportAsPDF: vi.fn().mockResolvedValue(new Blob()),
67
+ exportAsHTML: vi.fn().mockResolvedValue({
68
+ contents: "",
69
+ filename: "notebook.html",
70
+ mediaType: "text/html; charset=utf-8",
71
+ }),
72
+ exportAsIPYNB: vi.fn().mockResolvedValue({
73
+ contents: "",
74
+ filename: "notebook.ipynb",
75
+ mediaType: "text/plain; charset=utf-8",
76
+ }),
77
+ exportAsMarkdown: vi.fn().mockResolvedValue({
78
+ contents: "",
79
+ filename: "notebook.md",
80
+ mediaType: "text/plain; charset=utf-8",
81
+ }),
82
+ exportAsPDF: vi.fn().mockResolvedValue({
83
+ contents: new Blob(),
84
+ filename: "notebook.pdf",
85
+ mediaType: "application/pdf",
86
+ }),
71
87
  autoExportAsHTML: vi.fn().mockResolvedValue({}),
72
88
  autoExportAsMarkdown: vi.fn().mockResolvedValue({}),
73
89
  autoExportAsIPYNB: vi.fn().mockResolvedValue({}),
@@ -8,13 +8,11 @@ describe("runServerSidePDFDownload", () => {
8
8
  const downloadPDF = vi.fn().mockResolvedValue(undefined);
9
9
 
10
10
  await runServerSidePDFDownload({
11
- filename: "slides.py",
12
11
  preset: "document",
13
12
  downloadPDF,
14
13
  });
15
14
 
16
15
  expect(downloadPDF).toHaveBeenCalledWith({
17
- filename: "slides.py",
18
16
  webpdf: false,
19
17
  preset: "document",
20
18
  includeInputs: true,
@@ -26,13 +24,11 @@ describe("runServerSidePDFDownload", () => {
26
24
  const downloadPDF = vi.fn().mockResolvedValue(undefined);
27
25
 
28
26
  await runServerSidePDFDownload({
29
- filename: "slides.py",
30
27
  preset: "slides",
31
28
  downloadPDF,
32
29
  });
33
30
 
34
31
  expect(downloadPDF).toHaveBeenCalledWith({
35
- filename: "slides.py",
36
32
  webpdf: false,
37
33
  preset: "slides",
38
34
  includeInputs: true,
@@ -2,7 +2,6 @@
2
2
 
3
3
  type Preset = "document" | "slides";
4
4
  type DownloadPDF = (opts: {
5
- filename: string;
6
5
  webpdf: boolean;
7
6
  preset: Preset;
8
7
  includeInputs: boolean;
@@ -10,14 +9,12 @@ type DownloadPDF = (opts: {
10
9
  }) => Promise<void>;
11
10
 
12
11
  export async function runServerSidePDFDownload(opts: {
13
- filename: string;
14
12
  preset: Preset;
15
13
  downloadPDF: DownloadPDF;
16
14
  }): Promise<void> {
17
- const { filename, preset, downloadPDF } = opts;
15
+ const { preset, downloadPDF } = opts;
18
16
 
19
17
  await downloadPDF({
20
- filename,
21
18
  webpdf: false,
22
19
  preset,
23
20
  includeInputs: true,
@@ -83,6 +83,7 @@ import {
83
83
  ADD_PRINTING_CLASS,
84
84
  downloadAsPDF,
85
85
  downloadBlob,
86
+ downloadExportedFile,
86
87
  downloadHTMLAsImage,
87
88
  withLoadingToast,
88
89
  } from "@/utils/download";
@@ -197,7 +198,6 @@ export function useNotebookActions() {
197
198
  updateCellOutputs,
198
199
  });
199
200
  await runServerSidePDFDownload({
200
- filename,
201
201
  preset,
202
202
  downloadPDF: downloadAsPDF,
203
203
  });
@@ -231,11 +231,8 @@ export function useNotebookActions() {
231
231
  takeScreenshots: () => takeScreenshots({ progress }),
232
232
  updateCellOutputs,
233
233
  });
234
- const ipynb = await exportAsIPYNB({ download: false });
235
- downloadBlob(
236
- new Blob([ipynb], { type: "application/x-ipynb+json" }),
237
- Filenames.toIPYNB(document.title),
238
- );
234
+ const exportedFile = await exportAsIPYNB({ download: false });
235
+ downloadExportedFile(exportedFile);
239
236
  };
240
237
 
241
238
  await withLoadingToast("Downloading IPYNB...", runDownload);
@@ -255,7 +252,7 @@ export function useNotebookActions() {
255
252
  toastNotebookMustBeNamed();
256
253
  return;
257
254
  }
258
- await downloadAsHTML({ filename, includeCode: true });
255
+ await downloadAsHTML({ includeCode: true });
259
256
  },
260
257
  },
261
258
  {
@@ -266,7 +263,7 @@ export function useNotebookActions() {
266
263
  toastNotebookMustBeNamed();
267
264
  return;
268
265
  }
269
- await downloadAsHTML({ filename, includeCode: false });
266
+ await downloadAsHTML({ includeCode: false });
270
267
  },
271
268
  },
272
269
  {
@@ -275,11 +272,8 @@ export function useNotebookActions() {
275
272
  ),
276
273
  label: "Download as Markdown",
277
274
  handle: async () => {
278
- const md = await exportAsMarkdown({ download: false });
279
- downloadBlob(
280
- new Blob([md], { type: "text/plain" }),
281
- Filenames.toMarkdown(document.title),
282
- );
275
+ const exportedFile = await exportAsMarkdown({ download: false });
276
+ downloadExportedFile(exportedFile);
283
277
  },
284
278
  },
285
279
  {
@@ -202,7 +202,7 @@ const ActionButtons: React.FC<{
202
202
  if (!app) {
203
203
  return;
204
204
  }
205
- await downloadAsHTML({ filename: document.title, includeCode: true });
205
+ await downloadAsHTML({ includeCode: true });
206
206
  };
207
207
 
208
208
  const handleDownloadAsPython = async () => {
@@ -40,7 +40,7 @@ export const ShareStaticNotebookModal: React.FC<{
40
40
  e.preventDefault();
41
41
 
42
42
  onClose();
43
- const html = await exportAsHTML({
43
+ const { contents: html } = await exportAsHTML({
44
44
  download: false,
45
45
  includeCode: true,
46
46
  files: VirtualFileTracker.INSTANCE.filenames(),
@@ -94,4 +94,46 @@ describe("API", () => {
94
94
  }),
95
95
  ).rejects.toBeInstanceOf(HTTPError);
96
96
  });
97
+
98
+ it("preserves export metadata from response headers", async () => {
99
+ const response = new Response("markdown", {
100
+ headers: {
101
+ "Content-Disposition":
102
+ "attachment; filename*=UTF-8''r%C3%A9sum%C3%A9.qmd",
103
+ "Content-Type": "text/plain; charset=utf-8",
104
+ },
105
+ });
106
+
107
+ await expect(
108
+ API.handleExportResponse({ data: "markdown", response }),
109
+ ).resolves.toEqual({
110
+ contents: "markdown",
111
+ filename: "résumé.qmd",
112
+ mediaType: "text/plain; charset=utf-8",
113
+ });
114
+ });
115
+
116
+ it("rejects export responses without a filename", async () => {
117
+ await expect(
118
+ API.handleExportResponse({
119
+ data: "markdown",
120
+ response: new Response(null, {
121
+ headers: { "Content-Type": "text/plain" },
122
+ }),
123
+ }),
124
+ ).rejects.toThrow("Export response is missing a filename");
125
+ });
126
+
127
+ it("rejects export responses without a media type", async () => {
128
+ await expect(
129
+ API.handleExportResponse({
130
+ data: "markdown",
131
+ response: new Response(null, {
132
+ headers: {
133
+ "Content-Disposition": "attachment; filename*=UTF-8''notebook.md",
134
+ },
135
+ }),
136
+ }),
137
+ ).rejects.toThrow("Export response is missing a media type");
138
+ });
97
139
  });
@@ -22,6 +22,7 @@ vi.mock("../api", async () => {
22
22
  return {
23
23
  ...actual,
24
24
  API: {
25
+ handleExportResponse: vi.fn((response) => response.data),
25
26
  handleResponse: vi.fn((response) => response.data),
26
27
  handleResponseReturnNull: vi.fn(() => null),
27
28
  },
@@ -6,6 +6,7 @@ import { Logger } from "../../utils/Logger";
6
6
  import { Strings } from "../../utils/strings";
7
7
  import { getRuntimeManager } from "../runtime/config";
8
8
  import type { RuntimeManager } from "../runtime/runtime";
9
+ import type { ExportedFile } from "./types";
9
10
 
10
11
  function getBaseUriWithoutQueryParams(): string {
11
12
  // Remove query params and hash
@@ -15,6 +16,15 @@ function getBaseUriWithoutQueryParams(): string {
15
16
  return url.toString();
16
17
  }
17
18
 
19
+ function getExportFilename(response: Response): string {
20
+ const contentDisposition = response.headers.get("Content-Disposition");
21
+ const match = contentDisposition?.match(/filename\*=UTF-8''([^;]+)/i);
22
+ if (!match) {
23
+ throw new Error("Export response is missing a filename");
24
+ }
25
+ return decodeURIComponent(match[1]);
26
+ }
27
+
18
28
  /**
19
29
  * Wrapper around fetch that adds XSRF token and session ID to the request and
20
30
  * strong types.
@@ -119,6 +129,23 @@ export const API = {
119
129
  }
120
130
  return Promise.resolve(response.data as T);
121
131
  },
132
+ handleExportResponse: async <T extends BlobPart>(response: {
133
+ data?: T | undefined;
134
+ error?: Record<string, unknown>;
135
+ response: Response;
136
+ }): Promise<ExportedFile<T>> => {
137
+ const contents = await API.handleResponse<T>(response);
138
+ const mediaType = response.response.headers.get("Content-Type");
139
+ if (!mediaType) {
140
+ throw new Error("Export response is missing a media type");
141
+ }
142
+
143
+ return {
144
+ contents,
145
+ filename: getExportFilename(response.response),
146
+ mediaType,
147
+ };
148
+ },
122
149
  handleResponseReturnNull: (response: {
123
150
  error?: Record<string, unknown>;
124
151
  response: Response;
@@ -22,7 +22,7 @@ function multipartInit(formData: FormData) {
22
22
  };
23
23
  }
24
24
 
25
- const { handleResponse, handleResponseReturnNull } = API;
25
+ const { handleExportResponse, handleResponse, handleResponseReturnNull } = API;
26
26
 
27
27
  export function createNetworkRequests(): EditRequests & RunRequests {
28
28
  const getClient = once(() => {
@@ -415,7 +415,7 @@ export function createNetworkRequests(): EditRequests & RunRequests {
415
415
  parseAs: "text",
416
416
  params: getParams(),
417
417
  })
418
- .then(handleResponse);
418
+ .then(handleExportResponse);
419
419
  },
420
420
  exportAsMarkdown: async (request) => {
421
421
  return getClient()
@@ -424,7 +424,7 @@ export function createNetworkRequests(): EditRequests & RunRequests {
424
424
  parseAs: "text",
425
425
  params: getParams(),
426
426
  })
427
- .then(handleResponse);
427
+ .then(handleExportResponse);
428
428
  },
429
429
  exportAsIPYNB: async (request) => {
430
430
  return getClient()
@@ -433,7 +433,7 @@ export function createNetworkRequests(): EditRequests & RunRequests {
433
433
  parseAs: "text",
434
434
  params: getParams(),
435
435
  })
436
- .then(handleResponse);
436
+ .then(handleExportResponse);
437
437
  },
438
438
  exportAsPDF: async (request) => {
439
439
  return getClient()
@@ -442,7 +442,7 @@ export function createNetworkRequests(): EditRequests & RunRequests {
442
442
  parseAs: "blob",
443
443
  params: getParams(),
444
444
  })
445
- .then(handleResponse);
445
+ .then(handleExportResponse);
446
446
  },
447
447
  autoExportAsHTML: async (request) => {
448
448
  return getClient()
@@ -23,6 +23,13 @@ export type ExportAsIPYNBRequest = schemas["ExportAsIPYNBRequest"];
23
23
  export type ExportAsScriptRequest = schemas["ExportAsScriptRequest"];
24
24
  export type ExportAsPDFRequest = schemas["ExportAsPDFRequest"];
25
25
  export type UpdateCellOutputsRequest = schemas["UpdateCellOutputsRequest"];
26
+
27
+ export interface ExportedFile<T extends BlobPart = BlobPart> {
28
+ contents: T;
29
+ filename: string;
30
+ mediaType: string;
31
+ }
32
+
26
33
  export type FileCopyRequest = schemas["FileCopyRequest"];
27
34
  export type FileCopyResponse = schemas["FileCopyResponse"];
28
35
  export type FileCreateRequest = schemas["FileCreateRequest"];
@@ -205,10 +212,14 @@ export interface EditRequests {
205
212
  request: ShutdownSessionRequest,
206
213
  ) => Promise<RunningNotebooksResponse>;
207
214
  // Export requests
208
- exportAsHTML: (request: ExportAsHTMLRequest) => Promise<string>;
209
- exportAsIPYNB: (request: ExportAsIPYNBRequest) => Promise<string>;
210
- exportAsMarkdown: (request: ExportAsMarkdownRequest) => Promise<string>;
211
- exportAsPDF: (request: ExportAsPDFRequest) => Promise<Blob>;
215
+ exportAsHTML: (request: ExportAsHTMLRequest) => Promise<ExportedFile<string>>;
216
+ exportAsIPYNB: (
217
+ request: ExportAsIPYNBRequest,
218
+ ) => Promise<ExportedFile<string>>;
219
+ exportAsMarkdown: (
220
+ request: ExportAsMarkdownRequest,
221
+ ) => Promise<ExportedFile<string>>;
222
+ exportAsPDF: (request: ExportAsPDFRequest) => Promise<ExportedFile<Blob>>;
212
223
  autoExportAsHTML: (request: ExportAsHTMLRequest) => Promise<null>;
213
224
  autoExportAsMarkdown: (request: ExportAsMarkdownRequest) => Promise<null>;
214
225
  autoExportAsIPYNB: (request: ExportAsIPYNBRequest) => Promise<null>;
@@ -1,31 +1,22 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
- import { downloadBlob } from "@/utils/download";
4
- import { Filenames } from "@/utils/filenames";
5
- import { Paths } from "@/utils/paths";
3
+ import { downloadExportedFile } from "@/utils/download";
6
4
  import { getRequestClient } from "../network/requests";
7
5
  import { VirtualFileTracker } from "./virtual-file-tracker";
8
6
 
9
7
  /**
10
8
  * Downloads the current notebook as an HTML file.
11
9
  */
12
- export async function downloadAsHTML(opts: {
13
- filename: string;
14
- includeCode: boolean;
15
- }) {
10
+ export async function downloadAsHTML(opts: { includeCode: boolean }) {
16
11
  const client = getRequestClient();
17
- const { filename, includeCode } = opts;
18
- const html = await client.exportAsHTML({
12
+ const { includeCode } = opts;
13
+ const exportedFile = await client.exportAsHTML({
19
14
  download: true,
20
15
  includeCode: includeCode,
21
16
  files: VirtualFileTracker.INSTANCE.filenames(),
22
17
  });
23
- const filenameWithoutPath = Paths.basename(filename) ?? "notebook.py";
24
18
 
25
- downloadBlob(
26
- new Blob([html], { type: "text/html" }),
27
- Filenames.toHTML(filenameWithoutPath),
28
- );
19
+ downloadExportedFile(exportedFile);
29
20
  }
30
21
 
31
22
  function updateAssetUrl(existingUrl: string, assetBaseUrl: string) {
@@ -19,6 +19,7 @@ import type {
19
19
  EnvironmentInfo,
20
20
  ExportAsHTMLRequest,
21
21
  ExportAsMarkdownRequest,
22
+ ExportedFile,
22
23
  FileCopyResponse,
23
24
  FileCreateResponse,
24
25
  FileDeleteResponse,
@@ -520,7 +521,7 @@ export class PyodideBridge implements RunRequests, EditRequests {
520
521
  functionName: "export_html",
521
522
  payload: request,
522
523
  });
523
- return response as string;
524
+ return response as ExportedFile<string>;
524
525
  };
525
526
 
526
527
  exportAsMarkdown: EditRequests["exportAsMarkdown"] = async (
@@ -530,7 +531,7 @@ export class PyodideBridge implements RunRequests, EditRequests {
530
531
  functionName: "export_markdown",
531
532
  payload: request,
532
533
  });
533
- return response as string;
534
+ return response as ExportedFile<string>;
534
535
  };
535
536
 
536
537
  previewDatasetColumn: EditRequests["previewDatasetColumn"] = async (
@@ -12,6 +12,7 @@ import type {
12
12
  EnvironmentInfo,
13
13
  ExportAsHTMLRequest,
14
14
  ExportAsMarkdownRequest,
15
+ ExportedFile,
15
16
  FileCopyRequest,
16
17
  FileCopyResponse,
17
18
  FileCreateRequest,
@@ -96,8 +97,10 @@ export interface RawBridge {
96
97
  load_packages(request: string): Promise<string>;
97
98
  read_file(request: string): Promise<string>;
98
99
  set_interrupt_buffer(request: Uint8Array): Promise<string>;
99
- export_html(request: ExportAsHTMLRequest): Promise<string>;
100
- export_markdown(request: ExportAsMarkdownRequest): Promise<string>;
100
+ export_html(request: ExportAsHTMLRequest): Promise<ExportedFile<string>>;
101
+ export_markdown(
102
+ request: ExportAsMarkdownRequest,
103
+ ): Promise<ExportedFile<string>>;
101
104
  }
102
105
 
103
106
  export type BridgePayload<T extends keyof RawBridge> = T extends keyof RawBridge
@@ -8,6 +8,7 @@ import {
8
8
  downloadAsPDF,
9
9
  downloadByURL,
10
10
  downloadCellOutputAsImage,
11
+ downloadExportedFile,
11
12
  downloadHTMLAsImage,
12
13
  getImageDataUrlForCell,
13
14
  withLoadingToast,
@@ -195,7 +196,6 @@ describe("downloadAsPDF", () => {
195
196
 
196
197
  await expect(
197
198
  downloadAsPDF({
198
- filename: "path/to/notebook.py",
199
199
  webpdf: false,
200
200
  preset: "slides",
201
201
  }),
@@ -572,6 +572,7 @@ describe("downloadByURL", () => {
572
572
 
573
573
  afterEach(() => {
574
574
  vi.restoreAllMocks();
575
+ vi.unstubAllGlobals();
575
576
  });
576
577
 
577
578
  it("should create anchor, set attributes, click, and remove", () => {
@@ -583,4 +584,26 @@ describe("downloadByURL", () => {
583
584
  expect(mockAnchor.click).toHaveBeenCalled();
584
585
  expect(mockAnchor.remove).toHaveBeenCalled();
585
586
  });
587
+
588
+ it("downloads an exported file with its returned metadata", async () => {
589
+ let downloadedBlob: Blob | undefined;
590
+ vi.stubGlobal("URL", {
591
+ createObjectURL: vi.fn((blob: Blob) => {
592
+ downloadedBlob = blob;
593
+ return "blob:export";
594
+ }),
595
+ revokeObjectURL: vi.fn(),
596
+ });
597
+
598
+ downloadExportedFile({
599
+ contents: "notebook",
600
+ filename: "résumé.qmd",
601
+ mediaType: "text/plain; charset=utf-8",
602
+ });
603
+
604
+ expect(downloadedBlob?.type).toBe("text/plain; charset=utf-8");
605
+ expect(await downloadedBlob?.text()).toBe("notebook");
606
+ expect(mockAnchor.download).toBe("résumé.qmd");
607
+ expect(URL.revokeObjectURL).toHaveBeenCalledWith("blob:export");
608
+ });
586
609
  });