@marimo-team/frontend 0.19.10-dev12 → 0.19.10-dev13

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.
@@ -1 +1 @@
1
- import{s as oe}from"./chunk-LvLJmgfZ.js";import{d as be,l as ye,n as V,p as ae,u as we}from"./useEvent-BhXAndur.js";import{t as Ne}from"./react-Bj1aDYRI.js";import{N as ke,Xr as ze,ai as n,gn as Ce,ii as Se,w as Oe,__tla as Ae}from"./cells-mohhX6EY.js";import"./react-dom-CSu739Rf.js";import{t as se}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-DxKBXCGp.js";import{f as ie}from"./hotkeys-BHHWjLlp.js";import{y as Ie}from"./utils-YqBXNpsM.js";import{t as Le}from"./constants-B6Cb__3x.js";import{t as Me}from"./jsx-runtime-ZmTK25f3.js";import{t as z}from"./button-CZ3Cs4qb.js";import{t as le}from"./cn-BKtXLv3a.js";import"./dist-DxWb3aMV.js";import{n as Pe,__tla as Ee}from"./JsonOutput-Dxvq5055.js";import"./cjs-CH5Rj0g8.js";import"./main-U5Goe76G.js";import"./useNonce-CS26E0hA.js";import{r as Re}from"./requests-B4FYHTZl.js";import{t as me}from"./createLucideIcon-BCdY6lG5.js";import{d as De,__tla as He}from"./layout-D6XqXgk-.js";import{n as Ve,t as qe,__tla as Te}from"./LazyAnyLanguageCodeMirror-BTO7DS3k.js";import"./download-BIF7X-oN.js";import"./markdown-renderer-CfUQ6yJN.js";import{u as Ge}from"./toDate-DETS9bBd.js";import{t as Ue,__tla as Xe}from"./cell-editor-CV3Xrd-v.js";import{t as Be}from"./play-GLWQQs7F.js";import{t as Fe}from"./spinner-DA8-7wQv.js";import"./dist-MyTWYTLd.js";import"./dist-LUpffRIq.js";import"./dist-PzrizfuL.js";import"./dist-BNkRH34W.js";import"./dist-maX8rbyb.js";import"./session-BOFn9QrD.js";import{r as Je}from"./useTheme-DQozhcp1.js";import"./Combination-BAEdC-rz.js";import{t as C}from"./tooltip-CMQz28hC.js";import"./dates-CrvjILe3.js";import"./popover-CH1FzjxU.js";import"./vega-loader.browser-DXARUlxo.js";import"./defaultLocale-JieDVWC_.js";import"./defaultLocale-BLne0bXb.js";import"./purify.es-DZrAQFIu.js";import{__tla as Ke}from"./chunk-5FQGJX7Z-DPlx2kjA.js";import"./katex-CDLTCvjQ.js";import"./html-to-image-BeNaGPxI.js";import{o as Qe}from"./focus-BV1s_tyC.js";import{a as We}from"./renderShortcut-BckyRbYt.js";import"./esm-BqiVbELQ.js";import{n as Ye,r as Ze,t as ne}from"./react-resizable-panels.browser.esm-Da3ksQXL.js";import"./name-cell-input-ccPNGTHi.js";import{n as $e,r as et}from"./panel-context-HhzMRtZm.js";import"./Inputs-GV-aQbOR.js";import{__tla as tt}from"./loro_wasm_bg-DzFUi5p_.js";import"./ws-DcVtI9Wj.js";import"./dist-BP9zs-JA.js";import"./dist-BHxWJlYy.js";import"./dist-C0vFollF.js";import"./dist-CShMY7yu.js";import"./dist-D_DbFqxl.js";import"./dist-DDhEwFtR.js";import"./dist-DKmfcej2.js";import"./dist-K8bI26Ke.js";import"./dist-dnoBqBf0.js";import"./esm-BeuExXY6.js";import{t as rt}from"./kiosk-mode-DbwzuAqk.js";let ce,ot=Promise.all([(()=>{try{return Ae}catch{}})(),(()=>{try{return Ee}catch{}})(),(()=>{try{return He}catch{}})(),(()=>{try{return Te}catch{}})(),(()=>{try{return Xe}catch{}})(),(()=>{try{return Ke}catch{}})(),(()=>{try{return tt}catch{}})()]).then(async()=>{var de=me("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),pe=me("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),he=se(),q=oe(Ne(),1),ue=15;const T=ze("marimo:scratchpadHistory:v1",[],Ce),fe=ae(!1),xe=ae(null,(e,s,i)=>{if(i=i.trim(),!i)return;let m=e(T);s(T,[i,...m.filter(c=>c!==i)].slice(0,ue))});var t=oe(Me(),1),_e={hide_code:!1,disabled:!1};const ve=()=>{var re;let e=(0,he.c)(60),s=ke(),[i]=Ie(),{theme:m}=Je(),c=(0,q.useRef)(null),G=Qe(),{createNewCell:U,updateCellCode:d}=Oe(),{sendRunScratchpad:p}=Re(),S=$e(),X=et(),l=s.cellRuntime[n],B=l==null?void 0:l.output,O=l==null?void 0:l.status,F=l==null?void 0:l.consoleOutputs,r=((re=s.cellData.__scratch__)==null?void 0:re.code)??"",J=be(xe),[a,h]=ye(fe),u=we(T),A;e[0]!==J||e[1]!==r||e[2]!==p?(A=()=>{p({code:r}),J(r)},e[0]=J,e[1]=r,e[2]=p,e[3]=A):A=e[3];let f=V(A),I;e[4]!==r||e[5]!==U||e[6]!==G?(I=()=>{r.trim()&&U({code:r,before:!1,cellId:G??"__end__"})},e[4]=r,e[5]=U,e[6]=G,e[7]=I):I=e[7];let K=V(I),L;e[8]!==p||e[9]!==d?(L=()=>{d({cellId:n,code:"",formattingChange:!1}),p({code:""});let o=c.current;o&&o.dispatch({changes:{from:0,to:o.state.doc.length,insert:""}})},e[8]=p,e[9]=d,e[10]=L):L=e[10];let Q=V(L),M;e[11]!==h||e[12]!==d?(M=o=>{h(!1),d({cellId:n,code:o,formattingChange:!1});let k=c.current;k&&k.dispatch({changes:{from:0,to:k.state.doc.length,insert:o}})},e[11]=h,e[12]=d,e[13]=M):M=e[13];let W=V(M),[Y,ge]=(0,q.useState)(),P;e[14]!==W||e[15]!==u||e[16]!==a||e[17]!==m?(P=()=>a?(0,t.jsx)("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:(0,t.jsx)("div",{className:"overflow-auto flex flex-col gap-3",children:u.map((o,k)=>(0,t.jsx)("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>W(o),children:(0,t.jsx)(q.Suspense,{children:(0,t.jsx)(qe,{language:"python",theme:m,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:o.trim(),editable:!1,readOnly:!0})})},k))})}):null,e[14]=W,e[15]=u,e[16]=a,e[17]=m,e[18]=P):P=e[18];let Z=P,E;e[19]!==Q||e[20]!==K||e[21]!==f||e[22]!==u.length||e[23]!==a||e[24]!==h||e[25]!==O?(E=()=>(0,t.jsxs)("div",{className:"flex items-center shrink-0 border-b",children:[(0,t.jsx)(C,{content:We("cell.run"),children:(0,t.jsx)(z,{"data-testid":"scratchpad-run-button",onClick:f,disabled:a,variant:"text",size:"xs",children:(0,t.jsx)(Be,{color:"var(--grass-11)",size:16})})}),(0,t.jsx)(C,{content:"Clear code and outputs",children:(0,t.jsx)(z,{disabled:a,size:"xs",variant:"text",onClick:Q,children:(0,t.jsx)(de,{size:16})})}),(0,t.jsx)(rt,{children:(0,t.jsx)(C,{content:"Insert code",children:(0,t.jsx)(z,{disabled:a,size:"xs",variant:"text",onClick:K,children:(0,t.jsx)(Ve,{size:16})})})}),(O==="running"||O==="queued")&&(0,t.jsx)(Fe,{className:"inline",size:"small"}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(C,{content:"Toggle history",children:(0,t.jsx)(z,{size:"xs",variant:"text",className:le(a&&"bg-(--sky-3) rounded-none"),onClick:()=>h(!a),disabled:u.length===0,children:(0,t.jsx)(pe,{size:16})})}),(0,t.jsx)(C,{content:(0,t.jsx)("span",{className:"block max-w-prose",children:"Use this scratchpad to experiment with code without restrictions on variable names. Variables defined here aren't saved to notebook memory, and the code is not saved in the notebook file."}),children:(0,t.jsx)(z,{size:"xs",variant:"text",children:(0,t.jsx)(Ge,{size:16})})})]}),e[19]=Q,e[20]=K,e[21]=f,e[22]=u.length,e[23]=a,e[24]=h,e[25]=O,e[26]=E):E=e[26];let $=E,je=S==="vertical",R;e[27]===Symbol.for("react.memo_cache_sentinel")?(R=Se.create(n),e[27]=R):R=e[27];let x;e[28]===$?x=e[29]:(x=$(),e[28]=$,e[29]=x);let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=o=>{c.current=o},e[30]=D):D=e[30];let _;e[31]!==r||e[32]!==f||e[33]!==Y||e[34]!==m||e[35]!==i?(_=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Ue,{theme:m,showPlaceholder:!1,id:n,code:r,config:_e,status:"idle",serializedEditorState:null,runCell:f,userConfig:i,editorViewRef:c,setEditorView:D,hidden:!1,showHiddenCode:ie.NOOP,languageAdapter:Y,setLanguageAdapter:ge})}),e[31]=r,e[32]=f,e[33]=Y,e[34]=m,e[35]=i,e[36]=_):_=e[36];let v;e[37]===Z?v=e[38]:(v=Z(),e[37]=Z,e[38]=v);let g;e[39]!==v||e[40]!==x||e[41]!==_?(g=(0,t.jsx)(ne,{defaultSize:40,minSize:20,maxSize:70,children:(0,t.jsxs)("div",{className:"h-full flex flex-col overflow-hidden relative",children:[x,_,v]})}),e[39]=v,e[40]=x,e[41]=_,e[42]=g):g=e[42];let ee=je?"h-1":"w-1",j;e[43]===ee?j=e[44]:(j=le("bg-border hover:bg-primary/50 transition-colors",ee),e[43]=ee,e[44]=j);let b;e[45]===j?b=e[46]:(b=(0,t.jsx)(Ze,{className:j}),e[45]=j,e[46]=b);let y;e[47]===B?y=e[48]:(y=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Pe,{allowExpand:!1,output:B,className:Le.outputArea,cellId:n,stale:!1,loading:!1})}),e[47]=B,e[48]=y);let w;e[49]===F?w=e[50]:(w=(0,t.jsx)("div",{className:"overflow-auto shrink-0 max-h-[50%]",children:(0,t.jsx)(De,{consoleOutputs:F,className:"overflow-auto",stale:!1,cellName:"_",onSubmitDebugger:ie.NOOP,cellId:n,debuggerActive:!1})}),e[49]=F,e[50]=w);let N;e[51]!==y||e[52]!==w?(N=(0,t.jsx)(ne,{defaultSize:60,minSize:20,children:(0,t.jsxs)("div",{className:"h-full flex flex-col divide-y overflow-hidden",children:[y,w]})}),e[51]=y,e[52]=w,e[53]=N):N=e[53];let H;return e[54]!==S||e[55]!==X||e[56]!==g||e[57]!==b||e[58]!==N?(H=(0,t.jsx)("div",{className:"flex flex-col h-full overflow-hidden",id:R,children:(0,t.jsxs)(Ye,{direction:S,className:"h-full",children:[g,b,N]},X)}),e[54]=S,e[55]=X,e[56]=g,e[57]=b,e[58]=N,e[59]=H):H=e[59],H};let te;te=se(),ce=()=>{let e=(0,te.c)(1),s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(ve,{}),e[0]=s):s=e[0],s}});export{ot as __tla,ce as default};
1
+ import{s as oe}from"./chunk-LvLJmgfZ.js";import{d as be,l as ye,n as V,p as ae,u as we}from"./useEvent-BhXAndur.js";import{t as Ne}from"./react-Bj1aDYRI.js";import{N as ke,Xr as ze,ai as n,gn as Ce,ii as Se,w as Oe,__tla as Ae}from"./cells-mohhX6EY.js";import"./react-dom-CSu739Rf.js";import{t as se}from"./compiler-runtime-B3qBwwSJ.js";import"./tooltip-DxKBXCGp.js";import{f as ie}from"./hotkeys-BHHWjLlp.js";import{y as Ie}from"./utils-YqBXNpsM.js";import{t as Le}from"./constants-B6Cb__3x.js";import{t as Me}from"./jsx-runtime-ZmTK25f3.js";import{t as z}from"./button-CZ3Cs4qb.js";import{t as le}from"./cn-BKtXLv3a.js";import"./dist-DxWb3aMV.js";import{n as Pe,__tla as Ee}from"./JsonOutput-Dxvq5055.js";import"./cjs-CH5Rj0g8.js";import"./main-U5Goe76G.js";import"./useNonce-CS26E0hA.js";import{r as Re}from"./requests-B4FYHTZl.js";import{t as me}from"./createLucideIcon-BCdY6lG5.js";import{d as De,__tla as He}from"./layout-D6XqXgk-.js";import{n as Ve,t as qe,__tla as Te}from"./LazyAnyLanguageCodeMirror-BTO7DS3k.js";import"./download-BIF7X-oN.js";import"./markdown-renderer-CfUQ6yJN.js";import{u as Ge}from"./toDate-DETS9bBd.js";import{t as Ue,__tla as Xe}from"./cell-editor-Q6J6jxxd.js";import{t as Be}from"./play-GLWQQs7F.js";import{t as Fe}from"./spinner-DA8-7wQv.js";import"./dist-MyTWYTLd.js";import"./dist-LUpffRIq.js";import"./dist-PzrizfuL.js";import"./dist-BNkRH34W.js";import"./dist-maX8rbyb.js";import"./session-BOFn9QrD.js";import{r as Je}from"./useTheme-DQozhcp1.js";import"./Combination-BAEdC-rz.js";import{t as C}from"./tooltip-CMQz28hC.js";import"./dates-CrvjILe3.js";import"./popover-CH1FzjxU.js";import"./vega-loader.browser-DXARUlxo.js";import"./defaultLocale-JieDVWC_.js";import"./defaultLocale-BLne0bXb.js";import"./purify.es-DZrAQFIu.js";import{__tla as Ke}from"./chunk-5FQGJX7Z-DPlx2kjA.js";import"./katex-CDLTCvjQ.js";import"./html-to-image-BeNaGPxI.js";import{o as Qe}from"./focus-BV1s_tyC.js";import{a as We}from"./renderShortcut-BckyRbYt.js";import"./esm-BqiVbELQ.js";import{n as Ye,r as Ze,t as ne}from"./react-resizable-panels.browser.esm-Da3ksQXL.js";import"./name-cell-input-ccPNGTHi.js";import{n as $e,r as et}from"./panel-context-HhzMRtZm.js";import"./Inputs-GV-aQbOR.js";import{__tla as tt}from"./loro_wasm_bg-DzFUi5p_.js";import"./ws-DcVtI9Wj.js";import"./dist-BP9zs-JA.js";import"./dist-BHxWJlYy.js";import"./dist-C0vFollF.js";import"./dist-CShMY7yu.js";import"./dist-D_DbFqxl.js";import"./dist-DDhEwFtR.js";import"./dist-DKmfcej2.js";import"./dist-K8bI26Ke.js";import"./dist-dnoBqBf0.js";import"./esm-BeuExXY6.js";import{t as rt}from"./kiosk-mode-DbwzuAqk.js";let ce,ot=Promise.all([(()=>{try{return Ae}catch{}})(),(()=>{try{return Ee}catch{}})(),(()=>{try{return He}catch{}})(),(()=>{try{return Te}catch{}})(),(()=>{try{return Xe}catch{}})(),(()=>{try{return Ke}catch{}})(),(()=>{try{return tt}catch{}})()]).then(async()=>{var de=me("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),pe=me("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),he=se(),q=oe(Ne(),1),ue=15;const T=ze("marimo:scratchpadHistory:v1",[],Ce),fe=ae(!1),xe=ae(null,(e,s,i)=>{if(i=i.trim(),!i)return;let m=e(T);s(T,[i,...m.filter(c=>c!==i)].slice(0,ue))});var t=oe(Me(),1),_e={hide_code:!1,disabled:!1};const ve=()=>{var re;let e=(0,he.c)(60),s=ke(),[i]=Ie(),{theme:m}=Je(),c=(0,q.useRef)(null),G=Qe(),{createNewCell:U,updateCellCode:d}=Oe(),{sendRunScratchpad:p}=Re(),S=$e(),X=et(),l=s.cellRuntime[n],B=l==null?void 0:l.output,O=l==null?void 0:l.status,F=l==null?void 0:l.consoleOutputs,r=((re=s.cellData.__scratch__)==null?void 0:re.code)??"",J=be(xe),[a,h]=ye(fe),u=we(T),A;e[0]!==J||e[1]!==r||e[2]!==p?(A=()=>{p({code:r}),J(r)},e[0]=J,e[1]=r,e[2]=p,e[3]=A):A=e[3];let f=V(A),I;e[4]!==r||e[5]!==U||e[6]!==G?(I=()=>{r.trim()&&U({code:r,before:!1,cellId:G??"__end__"})},e[4]=r,e[5]=U,e[6]=G,e[7]=I):I=e[7];let K=V(I),L;e[8]!==p||e[9]!==d?(L=()=>{d({cellId:n,code:"",formattingChange:!1}),p({code:""});let o=c.current;o&&o.dispatch({changes:{from:0,to:o.state.doc.length,insert:""}})},e[8]=p,e[9]=d,e[10]=L):L=e[10];let Q=V(L),M;e[11]!==h||e[12]!==d?(M=o=>{h(!1),d({cellId:n,code:o,formattingChange:!1});let k=c.current;k&&k.dispatch({changes:{from:0,to:k.state.doc.length,insert:o}})},e[11]=h,e[12]=d,e[13]=M):M=e[13];let W=V(M),[Y,ge]=(0,q.useState)(),P;e[14]!==W||e[15]!==u||e[16]!==a||e[17]!==m?(P=()=>a?(0,t.jsx)("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:(0,t.jsx)("div",{className:"overflow-auto flex flex-col gap-3",children:u.map((o,k)=>(0,t.jsx)("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>W(o),children:(0,t.jsx)(q.Suspense,{children:(0,t.jsx)(qe,{language:"python",theme:m,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:o.trim(),editable:!1,readOnly:!0})})},k))})}):null,e[14]=W,e[15]=u,e[16]=a,e[17]=m,e[18]=P):P=e[18];let Z=P,E;e[19]!==Q||e[20]!==K||e[21]!==f||e[22]!==u.length||e[23]!==a||e[24]!==h||e[25]!==O?(E=()=>(0,t.jsxs)("div",{className:"flex items-center shrink-0 border-b",children:[(0,t.jsx)(C,{content:We("cell.run"),children:(0,t.jsx)(z,{"data-testid":"scratchpad-run-button",onClick:f,disabled:a,variant:"text",size:"xs",children:(0,t.jsx)(Be,{color:"var(--grass-11)",size:16})})}),(0,t.jsx)(C,{content:"Clear code and outputs",children:(0,t.jsx)(z,{disabled:a,size:"xs",variant:"text",onClick:Q,children:(0,t.jsx)(de,{size:16})})}),(0,t.jsx)(rt,{children:(0,t.jsx)(C,{content:"Insert code",children:(0,t.jsx)(z,{disabled:a,size:"xs",variant:"text",onClick:K,children:(0,t.jsx)(Ve,{size:16})})})}),(O==="running"||O==="queued")&&(0,t.jsx)(Fe,{className:"inline",size:"small"}),(0,t.jsx)("div",{className:"flex-1"}),(0,t.jsx)(C,{content:"Toggle history",children:(0,t.jsx)(z,{size:"xs",variant:"text",className:le(a&&"bg-(--sky-3) rounded-none"),onClick:()=>h(!a),disabled:u.length===0,children:(0,t.jsx)(pe,{size:16})})}),(0,t.jsx)(C,{content:(0,t.jsx)("span",{className:"block max-w-prose",children:"Use this scratchpad to experiment with code without restrictions on variable names. Variables defined here aren't saved to notebook memory, and the code is not saved in the notebook file."}),children:(0,t.jsx)(z,{size:"xs",variant:"text",children:(0,t.jsx)(Ge,{size:16})})})]}),e[19]=Q,e[20]=K,e[21]=f,e[22]=u.length,e[23]=a,e[24]=h,e[25]=O,e[26]=E):E=e[26];let $=E,je=S==="vertical",R;e[27]===Symbol.for("react.memo_cache_sentinel")?(R=Se.create(n),e[27]=R):R=e[27];let x;e[28]===$?x=e[29]:(x=$(),e[28]=$,e[29]=x);let D;e[30]===Symbol.for("react.memo_cache_sentinel")?(D=o=>{c.current=o},e[30]=D):D=e[30];let _;e[31]!==r||e[32]!==f||e[33]!==Y||e[34]!==m||e[35]!==i?(_=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Ue,{theme:m,showPlaceholder:!1,id:n,code:r,config:_e,status:"idle",serializedEditorState:null,runCell:f,userConfig:i,editorViewRef:c,setEditorView:D,hidden:!1,showHiddenCode:ie.NOOP,languageAdapter:Y,setLanguageAdapter:ge})}),e[31]=r,e[32]=f,e[33]=Y,e[34]=m,e[35]=i,e[36]=_):_=e[36];let v;e[37]===Z?v=e[38]:(v=Z(),e[37]=Z,e[38]=v);let g;e[39]!==v||e[40]!==x||e[41]!==_?(g=(0,t.jsx)(ne,{defaultSize:40,minSize:20,maxSize:70,children:(0,t.jsxs)("div",{className:"h-full flex flex-col overflow-hidden relative",children:[x,_,v]})}),e[39]=v,e[40]=x,e[41]=_,e[42]=g):g=e[42];let ee=je?"h-1":"w-1",j;e[43]===ee?j=e[44]:(j=le("bg-border hover:bg-primary/50 transition-colors",ee),e[43]=ee,e[44]=j);let b;e[45]===j?b=e[46]:(b=(0,t.jsx)(Ze,{className:j}),e[45]=j,e[46]=b);let y;e[47]===B?y=e[48]:(y=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Pe,{allowExpand:!1,output:B,className:Le.outputArea,cellId:n,stale:!1,loading:!1})}),e[47]=B,e[48]=y);let w;e[49]===F?w=e[50]:(w=(0,t.jsx)("div",{className:"overflow-auto shrink-0 max-h-[50%]",children:(0,t.jsx)(De,{consoleOutputs:F,className:"overflow-auto",stale:!1,cellName:"_",onSubmitDebugger:ie.NOOP,cellId:n,debuggerActive:!1})}),e[49]=F,e[50]=w);let N;e[51]!==y||e[52]!==w?(N=(0,t.jsx)(ne,{defaultSize:60,minSize:20,children:(0,t.jsxs)("div",{className:"h-full flex flex-col divide-y overflow-hidden",children:[y,w]})}),e[51]=y,e[52]=w,e[53]=N):N=e[53];let H;return e[54]!==S||e[55]!==X||e[56]!==g||e[57]!==b||e[58]!==N?(H=(0,t.jsx)("div",{className:"flex flex-col h-full overflow-hidden",id:R,children:(0,t.jsxs)(Ye,{direction:S,className:"h-full",children:[g,b,N]},X)}),e[54]=S,e[55]=X,e[56]=g,e[57]=b,e[58]=N,e[59]=H):H=e[59],H};let te;te=se(),ce=()=>{let e=(0,te.c)(1),s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(ve,{}),e[0]=s):s=e[0],s}});export{ot as __tla,ce as default};
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-D2cGPbeg.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-DHn5aPae.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-D2MJg03u.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/clsx-D8GwTfvk.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/cn-BKtXLv3a.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.19.10-dev12",
3
+ "version": "0.19.10-dev13",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -140,6 +140,24 @@ def _(
140
140
  expect(extractCells(input)).toEqual(["x = a + b + c"]);
141
141
  });
142
142
 
143
+ it("preserves return statements inside nested functions", () => {
144
+ const input = `
145
+ @app.cell
146
+ def _(mo, px):
147
+ def make_fig():
148
+ data = {'category': ['foo', 'bar'], 'value': [10, 20]}
149
+ fig = px.bar(data, x='category', y='value')
150
+ return fig
151
+
152
+ fig = make_fig()
153
+ mo.ui.plotly(fig)
154
+ return
155
+ `;
156
+ expect(extractCells(input)).toEqual([
157
+ "def make_fig():\n data = {'category': ['foo', 'bar'], 'value': [10, 20]}\n fig = px.bar(data, x='category', y='value')\n return fig\n\nfig = make_fig()\nmo.ui.plotly(fig)",
158
+ ]);
159
+ });
160
+
143
161
  it("handles cells with config", () => {
144
162
  const input = `
145
163
  @app.cell(hide_code=True, column=2)
@@ -42,6 +42,7 @@ export function extractCells(text: string): string[] {
42
42
  let inMultilineArgs = false;
43
43
  let inMultilineReturn = false;
44
44
  let parenCount = 0;
45
+ let cellBaseIndent: number | null = null;
45
46
 
46
47
  // Pre-compile regex patterns
47
48
  const leadingParenRegex = /\(/g;
@@ -55,19 +56,16 @@ export function extractCells(text: string): string[] {
55
56
  );
56
57
  }
57
58
 
59
+ function getIndent(line: string): number {
60
+ const match = line.match(/^\s*/);
61
+ return match ? match[0].length : 0;
62
+ }
63
+
58
64
  function finalizeCellIfNeeded() {
59
65
  if (currentCell.length === 0) {
60
66
  return;
61
67
  }
62
68
 
63
- // Remove trailing returns
64
- while (
65
- currentCell.length > 0 &&
66
- currentCell[currentCell.length - 1].trim().startsWith("return")
67
- ) {
68
- currentCell.pop();
69
- }
70
-
71
69
  // Only add non-empty cells
72
70
  if (currentCell.some((l) => l.trim() !== "")) {
73
71
  cells.push(dedent(currentCell.join("\n")));
@@ -88,6 +86,7 @@ export function extractCells(text: string): string[] {
88
86
  finalizeCellIfNeeded();
89
87
  inCell = true;
90
88
  skipLines = 1; // Skip the def line
89
+ cellBaseIndent = null;
91
90
  continue;
92
91
  }
93
92
 
@@ -125,8 +124,13 @@ export function extractCells(text: string): string[] {
125
124
  continue;
126
125
  }
127
126
 
128
- // Handle return statements
129
- if (trimmed.startsWith("return")) {
127
+ // Detect base indentation of cell body from first content line
128
+ if (cellBaseIndent === null && trimmed) {
129
+ cellBaseIndent = getIndent(line);
130
+ }
131
+
132
+ // Handle return statements — only strip cell-level returns
133
+ if (trimmed.startsWith("return") && getIndent(line) === cellBaseIndent) {
130
134
  if (trimmed.includes("(") && !trimmed.endsWith(")")) {
131
135
  inMultilineReturn = true;
132
136
  parenCount = countParens(trimmed);