@marimo-team/frontend 0.19.3-dev10 → 0.19.3-dev12

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-DlWF5OMa.js";import{t as Ne}from"./react-BGmjiNul.js";import{C as ke,Kr as ze,M as Ce,ei as Se,fn as Oe,ti as n,__tla as Ae}from"./cells-DU3EySUd.js";import"./react-dom-C9fstfnp.js";import{t as se}from"./compiler-runtime-DeeZ7FnK.js";import"./tooltip-CrRUCOBw.js";import{f as ie}from"./hotkeys-uKX61F1_.js";import{v as Ie}from"./utils-CJJIceVn.js";import{t as Me}from"./constants-Bkp4R3bQ.js";import"./config-Ba3eeYri.js";import{t as Le}from"./jsx-runtime-DN_bIXfG.js";import{t as z}from"./button-DuYGqRtX.js";import{t as le}from"./cn-C1rgT0yh.js";import"./dist-CAcX026F.js";import{n as Pe,__tla as Ee}from"./JsonOutput--AuyEErr.js";import"./cjs-Bj40p_Np.js";import"./main-CwSdzVhm.js";import"./useNonce-EAuSVK-5.js";import{r as Re}from"./requests-C0HaHO6a.js";import{t as me}from"./createLucideIcon-CW2xpJ57.js";import{d as De,__tla as He}from"./layout-BTiWDrbh.js";import{n as Ve,t as qe,__tla as Te}from"./LazyAnyLanguageCodeMirror-jpEDlD0M.js";import"./download-PR1bF3g_.js";import"./markdown-renderer-BSrbBHwX.js";import{u as Ge}from"./toDate-5JckKRQn.js";import{t as Ke,__tla as Ue}from"./cell-editor-Cdtc1m3g.js";import{t as Be}from"./play-BJDBXApx.js";import{t as Fe}from"./spinner-C1czjtp7.js";import"./dist-HGZzCB0y.js";import"./dist-CVj-_Iiz.js";import"./dist-BVf1IY4_.js";import"./dist-Cq_4nPfh.js";import"./dist-RKnr9SNh.js";import{r as Je}from"./useTheme-DfP1CWaW.js";import"./Combination-D1TsGrBC.js";import{t as C}from"./tooltip-CvjcEpZC.js";import"./dates-CdsE1R40.js";import"./popover-DtnzNVk-.js";import"./vega-loader.browser-C8wT63Va.js";import"./defaultLocale-BLUna9fQ.js";import"./defaultLocale-DzliDDTm.js";import"./purify.es-N-2faAGj.js";import{__tla as Qe}from"./chunk-OGVTOU66-CjNLT2C3.js";import"./katex-AwOI3EvM.js";import"./marked.esm-CHnOtnr3.js";import"./es-CEE_7T0w.js";import{o as We}from"./focus-CtlWIiQr.js";import{a as Xe}from"./renderShortcut-D0Pei-OA.js";import"./esm-B3JckBtM.js";import{n as Ye,r as Ze,t as ne}from"./react-resizable-panels.browser.esm-BqxQegSf.js";import"./name-cell-input-CmuWqgFR.js";import"./Inputs-DmoeP8nh.js";import{__tla as $e}from"./loro_wasm_bg-CghhyG7y.js";import"./ws-itdlXHqs.js";import"./dist-BRZzJw_5.js";import"./dist-P7JHert4.js";import"./dist-CoiWxjLF.js";import"./dist-cVYW_wBR.js";import"./dist-BAmo7Mv9.js";import"./dist-3oAtECdQ.js";import"./dist-D6Pwf0VF.js";import"./dist-D9HMoxdZ.js";import"./dist-JtCdI6tY.js";import"./esm-CCqLcax5.js";import{a as et,i as tt,t as rt}from"./kiosk-mode-BnTZR6mM.js";let ce,ot=Promise.all([(()=>{try{return Ae}catch{}})(),(()=>{try{return Ee}catch{}})(),(()=>{try{return He}catch{}})(),(()=>{try{return Te}catch{}})(),(()=>{try{return Ue}catch{}})(),(()=>{try{return Qe}catch{}})(),(()=>{try{return $e}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),fe=15;const T=ze("marimo:scratchpadHistory:v1",[],Oe),ue=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,fe))});var t=oe(Le(),1),_e={hide_code:!1,disabled:!1};const ve=()=>{var re;let e=(0,he.c)(60),s=Ce(),[i]=Ie(),{theme:m}=Je(),c=(0,q.useRef)(null),G=We(),{createNewCell:K,updateCellCode:d}=ke(),{sendRunScratchpad:p}=Re(),S=tt(),U=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(ue),f=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 u=V(A),I;e[4]!==r||e[5]!==K||e[6]!==G?(I=()=>{r.trim()&&K({code:r,before:!1,cellId:G??"__end__"})},e[4]=r,e[5]=K,e[6]=G,e[7]=I):I=e[7];let Q=V(I),M;e[8]!==p||e[9]!==d?(M=()=>{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]=M):M=e[10];let W=V(M),L;e[11]!==h||e[12]!==d?(L=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]=L):L=e[13];let X=V(L),[Y,ge]=(0,q.useState)(),P;e[14]!==X||e[15]!==f||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:f.map((o,k)=>(0,t.jsx)("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>X(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]=X,e[15]=f,e[16]=a,e[17]=m,e[18]=P):P=e[18];let Z=P,E;e[19]!==W||e[20]!==Q||e[21]!==u||e[22]!==f.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:Xe("cell.run"),children:(0,t.jsx)(z,{"data-testid":"scratchpad-run-button",onClick:u,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:W,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:Q,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:f.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]=W,e[20]=Q,e[21]=u,e[22]=f.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]!==u||e[33]!==Y||e[34]!==m||e[35]!==i?(_=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Ke,{theme:m,showPlaceholder:!1,id:n,code:r,config:_e,status:"idle",serializedEditorState:null,runCell:u,userConfig:i,editorViewRef:c,setEditorView:D,hidden:!1,showHiddenCode:ie.NOOP,languageAdapter:Y,setLanguageAdapter:ge})}),e[31]=r,e[32]=u,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:Me.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]!==U||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]},U)}),e[54]=S,e[55]=U,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-DlWF5OMa.js";import{t as Ne}from"./react-BGmjiNul.js";import{C as ke,Kr as ze,M as Ce,ei as Se,fn as Oe,ti as n,__tla as Ae}from"./cells-DU3EySUd.js";import"./react-dom-C9fstfnp.js";import{t as se}from"./compiler-runtime-DeeZ7FnK.js";import"./tooltip-CrRUCOBw.js";import{f as ie}from"./hotkeys-uKX61F1_.js";import{v as Ie}from"./utils-CJJIceVn.js";import{t as Me}from"./constants-Bkp4R3bQ.js";import"./config-Ba3eeYri.js";import{t as Le}from"./jsx-runtime-DN_bIXfG.js";import{t as z}from"./button-DuYGqRtX.js";import{t as le}from"./cn-C1rgT0yh.js";import"./dist-CAcX026F.js";import{n as Pe,__tla as Ee}from"./JsonOutput--AuyEErr.js";import"./cjs-Bj40p_Np.js";import"./main-CwSdzVhm.js";import"./useNonce-EAuSVK-5.js";import{r as Re}from"./requests-C0HaHO6a.js";import{t as me}from"./createLucideIcon-CW2xpJ57.js";import{d as De,__tla as He}from"./layout-BTiWDrbh.js";import{n as Ve,t as qe,__tla as Te}from"./LazyAnyLanguageCodeMirror-jpEDlD0M.js";import"./download-PR1bF3g_.js";import"./markdown-renderer-BSrbBHwX.js";import{u as Ge}from"./toDate-5JckKRQn.js";import{t as Ke,__tla as Ue}from"./cell-editor-CQcpZLQc.js";import{t as Be}from"./play-BJDBXApx.js";import{t as Fe}from"./spinner-C1czjtp7.js";import"./dist-HGZzCB0y.js";import"./dist-CVj-_Iiz.js";import"./dist-BVf1IY4_.js";import"./dist-Cq_4nPfh.js";import"./dist-RKnr9SNh.js";import{r as Je}from"./useTheme-DfP1CWaW.js";import"./Combination-D1TsGrBC.js";import{t as C}from"./tooltip-CvjcEpZC.js";import"./dates-CdsE1R40.js";import"./popover-DtnzNVk-.js";import"./vega-loader.browser-C8wT63Va.js";import"./defaultLocale-BLUna9fQ.js";import"./defaultLocale-DzliDDTm.js";import"./purify.es-N-2faAGj.js";import{__tla as Qe}from"./chunk-OGVTOU66-CjNLT2C3.js";import"./katex-AwOI3EvM.js";import"./marked.esm-CHnOtnr3.js";import"./es-CEE_7T0w.js";import{o as We}from"./focus-CtlWIiQr.js";import{a as Xe}from"./renderShortcut-D0Pei-OA.js";import"./esm-B3JckBtM.js";import{n as Ye,r as Ze,t as ne}from"./react-resizable-panels.browser.esm-BqxQegSf.js";import"./name-cell-input-CmuWqgFR.js";import"./Inputs-DmoeP8nh.js";import{__tla as $e}from"./loro_wasm_bg-CghhyG7y.js";import"./ws-itdlXHqs.js";import"./dist-BRZzJw_5.js";import"./dist-P7JHert4.js";import"./dist-CoiWxjLF.js";import"./dist-cVYW_wBR.js";import"./dist-BAmo7Mv9.js";import"./dist-3oAtECdQ.js";import"./dist-D6Pwf0VF.js";import"./dist-D9HMoxdZ.js";import"./dist-JtCdI6tY.js";import"./esm-CCqLcax5.js";import{a as et,i as tt,t as rt}from"./kiosk-mode-BnTZR6mM.js";let ce,ot=Promise.all([(()=>{try{return Ae}catch{}})(),(()=>{try{return Ee}catch{}})(),(()=>{try{return He}catch{}})(),(()=>{try{return Te}catch{}})(),(()=>{try{return Ue}catch{}})(),(()=>{try{return Qe}catch{}})(),(()=>{try{return $e}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),fe=15;const T=ze("marimo:scratchpadHistory:v1",[],Oe),ue=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,fe))});var t=oe(Le(),1),_e={hide_code:!1,disabled:!1};const ve=()=>{var re;let e=(0,he.c)(60),s=Ce(),[i]=Ie(),{theme:m}=Je(),c=(0,q.useRef)(null),G=We(),{createNewCell:K,updateCellCode:d}=ke(),{sendRunScratchpad:p}=Re(),S=tt(),U=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(ue),f=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 u=V(A),I;e[4]!==r||e[5]!==K||e[6]!==G?(I=()=>{r.trim()&&K({code:r,before:!1,cellId:G??"__end__"})},e[4]=r,e[5]=K,e[6]=G,e[7]=I):I=e[7];let Q=V(I),M;e[8]!==p||e[9]!==d?(M=()=>{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]=M):M=e[10];let W=V(M),L;e[11]!==h||e[12]!==d?(L=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]=L):L=e[13];let X=V(L),[Y,ge]=(0,q.useState)(),P;e[14]!==X||e[15]!==f||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:f.map((o,k)=>(0,t.jsx)("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>X(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]=X,e[15]=f,e[16]=a,e[17]=m,e[18]=P):P=e[18];let Z=P,E;e[19]!==W||e[20]!==Q||e[21]!==u||e[22]!==f.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:Xe("cell.run"),children:(0,t.jsx)(z,{"data-testid":"scratchpad-run-button",onClick:u,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:W,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:Q,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:f.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]=W,e[20]=Q,e[21]=u,e[22]=f.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]!==u||e[33]!==Y||e[34]!==m||e[35]!==i?(_=(0,t.jsx)("div",{className:"flex-1 overflow-auto",children:(0,t.jsx)(Ke,{theme:m,showPlaceholder:!1,id:n,code:r,config:_e,status:"idle",serializedEditorState:null,runCell:u,userConfig:i,editorViewRef:c,setEditorView:D,hidden:!1,showHiddenCode:ie.NOOP,languageAdapter:Y,setLanguageAdapter:ge})}),e[31]=r,e[32]=u,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:Me.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]!==U||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]},U)}),e[54]=S,e[55]=U,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-DNg7_e7t.js"></script>
69
+ <script type="module" crossorigin src="./assets/index-qglXvdF9.js"></script>
70
70
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-BW0IMuFq.js">
71
71
  <link rel="modulepreload" crossorigin href="./assets/hotkeys-uKX61F1_.js">
72
72
  <link rel="modulepreload" crossorigin href="./assets/defaultLocale-BLUna9fQ.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/frontend",
3
- "version": "0.19.3-dev10",
3
+ "version": "0.19.3-dev12",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -64,6 +64,7 @@ import { getCurrentLanguageAdapter } from "./language/commands";
64
64
  import { adaptiveLanguageConfiguration } from "./language/extension";
65
65
  import { dndBundle } from "./misc/dnd";
66
66
  import { pasteBundle } from "./misc/paste";
67
+ import { stringsAutoCloseBraces } from "./misc/string-braces";
67
68
  import { reactiveReferencesBundle } from "./reactive-references/extension";
68
69
  import { darkTheme } from "./theme/dark";
69
70
  import { lightTheme } from "./theme/light";
@@ -203,6 +204,7 @@ export const basicBundle = (opts: CodeMirrorSetupOpts): Extension[] => {
203
204
  hintTooltip(lspConfig),
204
205
  copilotBundle(completionConfig),
205
206
  foldGutter(),
207
+ stringsAutoCloseBraces(),
206
208
  closeBrackets(),
207
209
  completionKeymap(),
208
210
  // to avoid clash with charDeleteBackward keymap
@@ -0,0 +1,200 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { python } from "@codemirror/lang-python";
4
+ import { EditorState } from "@codemirror/state";
5
+ import { EditorView } from "@codemirror/view";
6
+ import { afterEach, describe, expect, it } from "vitest";
7
+ import { stringBraceInputHandler } from "../string-braces";
8
+
9
+ function createEditor(
10
+ initialContent: string,
11
+ cursorPosition: number,
12
+ ): EditorView {
13
+ const state = EditorState.create({
14
+ doc: initialContent,
15
+ selection: { anchor: cursorPosition },
16
+ extensions: [python()],
17
+ });
18
+
19
+ const view = new EditorView({
20
+ state,
21
+ parent: document.body,
22
+ });
23
+
24
+ return view;
25
+ }
26
+
27
+ describe("string brace auto-closing", () => {
28
+ let view: EditorView;
29
+
30
+ afterEach(() => {
31
+ if (view) {
32
+ view.destroy();
33
+ if (document.body.contains(view.dom)) {
34
+ view.dom.remove();
35
+ }
36
+ }
37
+ });
38
+
39
+ it("should auto-close braces in f-strings", () => {
40
+ view = createEditor('f"hello ', 8);
41
+ const result = stringBraceInputHandler(view, 8, 8, "{");
42
+
43
+ expect(result).toBe(true);
44
+ expect(view.state.doc.toString()).toBe('f"hello {}');
45
+ expect(view.state.selection.main.head).toBe(9);
46
+ });
47
+
48
+ it("should auto-close braces in regular double-quoted strings", () => {
49
+ view = createEditor('"hello ', 7);
50
+ const result = stringBraceInputHandler(view, 7, 7, "{");
51
+
52
+ expect(result).toBe(true);
53
+ expect(view.state.doc.toString()).toBe('"hello {}');
54
+ expect(view.state.selection.main.head).toBe(8);
55
+ });
56
+
57
+ it("should auto-close braces in rf-strings", () => {
58
+ view = createEditor('rf"hello ', 9);
59
+ const result = stringBraceInputHandler(view, 9, 9, "{");
60
+
61
+ expect(result).toBe(true);
62
+ expect(view.state.doc.toString()).toBe('rf"hello {}');
63
+ expect(view.state.selection.main.head).toBe(10);
64
+ });
65
+
66
+ it("should auto-close braces in fr-strings", () => {
67
+ view = createEditor('fr"hello ', 9);
68
+ const result = stringBraceInputHandler(view, 9, 9, "{");
69
+
70
+ expect(result).toBe(true);
71
+ expect(view.state.doc.toString()).toBe('fr"hello {}');
72
+ expect(view.state.selection.main.head).toBe(10);
73
+ });
74
+
75
+ it("should auto-close braces in single-quoted strings", () => {
76
+ view = createEditor("'hello ", 7);
77
+ const result = stringBraceInputHandler(view, 7, 7, "{");
78
+
79
+ expect(result).toBe(true);
80
+ expect(view.state.doc.toString()).toBe("'hello {}");
81
+ expect(view.state.selection.main.head).toBe(8);
82
+ });
83
+
84
+ it("should auto-close braces in uppercase F-strings", () => {
85
+ view = createEditor('F"hello ', 8);
86
+ const result = stringBraceInputHandler(view, 8, 8, "{");
87
+
88
+ expect(result).toBe(true);
89
+ expect(view.state.doc.toString()).toBe('F"hello {}');
90
+ expect(view.state.selection.main.head).toBe(9);
91
+ });
92
+
93
+ it("should auto-close braces in raw strings without f/t", () => {
94
+ view = createEditor('r"hello ', 8);
95
+ const result = stringBraceInputHandler(view, 8, 8, "{");
96
+
97
+ expect(result).toBe(true);
98
+ expect(view.state.doc.toString()).toBe('r"hello {}');
99
+ expect(view.state.selection.main.head).toBe(9);
100
+ });
101
+
102
+ // Handled by other CodeMirror handler(s)
103
+ it("should NOT auto-close braces outside strings", () => {
104
+ view = createEditor("x = ", 4);
105
+ const result = stringBraceInputHandler(view, 4, 4, "{");
106
+
107
+ expect(result).toBe(false);
108
+ expect(view.state.doc.toString()).toBe("x = ");
109
+ });
110
+
111
+ it("should NOT auto-close braces when typing other characters", () => {
112
+ view = createEditor('f"hello ', 8);
113
+ const result = stringBraceInputHandler(view, 8, 8, "a");
114
+
115
+ expect(result).toBe(false);
116
+ expect(view.state.doc.toString()).toBe('f"hello ');
117
+ });
118
+
119
+ it("should handle braces at the start of string", () => {
120
+ view = createEditor('f"', 2);
121
+ const result = stringBraceInputHandler(view, 2, 2, "{");
122
+
123
+ expect(result).toBe(true);
124
+ expect(view.state.doc.toString()).toBe('f"{}');
125
+ expect(view.state.selection.main.head).toBe(3);
126
+ });
127
+
128
+ it("should handle braces in the middle of string content", () => {
129
+ view = createEditor('f"hello world ', 14);
130
+ const result = stringBraceInputHandler(view, 14, 14, "{");
131
+
132
+ expect(result).toBe(true);
133
+ expect(view.state.doc.toString()).toBe('f"hello world {}');
134
+ expect(view.state.selection.main.head).toBe(15);
135
+ });
136
+
137
+ it("should handle multiple braces in string", () => {
138
+ view = createEditor('f"hello {} world', 16);
139
+ const result = stringBraceInputHandler(view, 16, 16, "{");
140
+
141
+ expect(result).toBe(true);
142
+ expect(view.state.doc.toString()).toBe('f"hello {} world{}');
143
+ expect(view.state.selection.main.head).toBe(17);
144
+ });
145
+
146
+ it("should handle empty string", () => {
147
+ view = createEditor('f""', 2);
148
+ const result = stringBraceInputHandler(view, 2, 2, "{");
149
+
150
+ expect(result).toBe(true);
151
+ expect(view.state.doc.toString()).toBe('f"{}"');
152
+ expect(view.state.selection.main.head).toBe(3);
153
+ });
154
+
155
+ it("should auto-close braces in triple-quoted strings", () => {
156
+ view = createEditor('"""hello ', 9);
157
+ const result = stringBraceInputHandler(view, 9, 9, "{");
158
+
159
+ expect(result).toBe(true);
160
+ expect(view.state.doc.toString()).toBe('"""hello {}');
161
+ expect(view.state.selection.main.head).toBe(10);
162
+ });
163
+
164
+ it("should auto-close braces in triple-quoted f-strings", () => {
165
+ view = createEditor('f"""hello ', 10);
166
+ const result = stringBraceInputHandler(view, 10, 10, "{");
167
+
168
+ expect(result).toBe(true);
169
+ expect(view.state.doc.toString()).toBe('f"""hello {}');
170
+ expect(view.state.selection.main.head).toBe(11);
171
+ });
172
+
173
+ it("should auto-close braces in triple single-quoted strings", () => {
174
+ view = createEditor("'''hello ", 9);
175
+ const result = stringBraceInputHandler(view, 9, 9, "{");
176
+
177
+ expect(result).toBe(true);
178
+ expect(view.state.doc.toString()).toBe("'''hello {}");
179
+ expect(view.state.selection.main.head).toBe(10);
180
+ });
181
+
182
+ it("should auto-close braces in triple single-quoted f-strings", () => {
183
+ view = createEditor("f'''hello ", 10);
184
+ const result = stringBraceInputHandler(view, 10, 10, "{");
185
+
186
+ expect(result).toBe(true);
187
+ expect(view.state.doc.toString()).toBe("f'''hello {}");
188
+ expect(view.state.selection.main.head).toBe(11);
189
+ });
190
+
191
+ it("should NOT auto-close braces when text is selected", () => {
192
+ view = createEditor('f"hello world"', 8);
193
+ // User has selected "world" (from position 8 to 13)
194
+ const result = stringBraceInputHandler(view, 8, 13, "{");
195
+
196
+ expect(result).toBe(false);
197
+ // Document should remain unchanged since we return false
198
+ expect(view.state.doc.toString()).toBe('f"hello world"');
199
+ });
200
+ });
@@ -0,0 +1,37 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+ import { syntaxTree } from "@codemirror/language";
3
+ import type { Extension } from "@codemirror/state";
4
+ import { EditorView } from "@codemirror/view";
5
+
6
+ export function stringBraceInputHandler(
7
+ view: EditorView,
8
+ from: number,
9
+ to: number,
10
+ text: string,
11
+ ): boolean {
12
+ if (text !== "{") {
13
+ return false;
14
+ }
15
+
16
+ if (from !== to) {
17
+ return false;
18
+ }
19
+
20
+ const tree = syntaxTree(view.state);
21
+ const node = tree.resolveInner(from, -1);
22
+
23
+ if (!node?.type.name.includes("String")) {
24
+ return false;
25
+ }
26
+
27
+ view.dispatch({
28
+ changes: { from, to, insert: "{}" },
29
+ selection: { anchor: from + 1 },
30
+ userEvent: "input.type",
31
+ });
32
+ return true;
33
+ }
34
+
35
+ export function stringsAutoCloseBraces(): Extension {
36
+ return EditorView.inputHandler.of(stringBraceInputHandler);
37
+ }