@marimo-team/frontend 0.23.11-dev23 → 0.23.11-dev25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CellStatus-oqY4_K7w.js → CellStatus-C52PsPYN.js} +1 -1
- package/dist/assets/{JsonOutput-BgU0YoWq.js → JsonOutput-e5KwGs-t.js} +11 -11
- package/dist/assets/{MarimoErrorOutput-BFyl9bRJ.js → MarimoErrorOutput-tWmQZh0O.js} +1 -1
- package/dist/assets/{RenderHTML-C2nKleMH.js → RenderHTML-CdzAncjW.js} +1 -1
- package/dist/assets/{RunButton-BGvQlTfT.js → RunButton-D1RSmpE5.js} +1 -1
- package/dist/assets/{add-cell-with-ai-D1HMdh52.js → add-cell-with-ai-r88BQwnl.js} +1 -1
- package/dist/assets/{add-connection-dialog-CYdyYsKy.js → add-connection-dialog-BqArtkaF.js} +1 -1
- package/dist/assets/{agent-panel-C3fnscrX.js → agent-panel-BFnSCM0u.js} +1 -1
- package/dist/assets/{ai-model-dropdown-BUVX-tXn.js → ai-model-dropdown-CKfMxi81.js} +1 -1
- package/dist/assets/{app-config-button-9PxT1i98.js → app-config-button-DgAKqCJQ.js} +1 -1
- package/dist/assets/{cell-editor-KKuNgpaD.js → cell-editor-vk3YgY2w.js} +1 -1
- package/dist/assets/{cell-link-Bia8_3oN.js → cell-link-BBWAKZ--.js} +1 -1
- package/dist/assets/{cells-a44D37GV.js → cells-D3EcEVTz.js} +1 -1
- package/dist/assets/{chat-display-DEePQXjB.js → chat-display-C9WoxE6U.js} +1 -1
- package/dist/assets/{chat-panel-CgoxbsMi.js → chat-panel-CFM1k9PV.js} +1 -1
- package/dist/assets/{chat-ui-D2QkwjKU.js → chat-ui-LkKFatRU.js} +1 -1
- package/dist/assets/{column-preview-DSb2IIj-.js → column-preview-93mkKGs1.js} +1 -1
- package/dist/assets/{command-palette-CN7OBmHG.js → command-palette-BIVH2C6k.js} +1 -1
- package/dist/assets/{common-C9NNLp8D.js → common-Dc5W1wzl.js} +1 -1
- package/dist/assets/{components-Cu0sIUo1.js → components-CdfRUEBW.js} +1 -1
- package/dist/assets/config-B00Uc1a3.js +1 -0
- package/dist/assets/{datasource-DzsjHMRs.js → datasource-BtJgopUR.js} +1 -1
- package/dist/assets/{dependency-graph-panel-DQV9lki5.js → dependency-graph-panel-TQ0py-Kw.js} +1 -1
- package/dist/assets/{documentation-panel-DqxqRAu4.js → documentation-panel-LHZLKLAd.js} +1 -1
- package/dist/assets/{download-YFYBUFlh.js → download-CYrhtDVp.js} +1 -1
- package/dist/assets/{edit-page-_lMTxldP.js → edit-page-CdXZP-AI.js} +4 -4
- package/dist/assets/{error-panel-B8lKHH0-.js → error-panel-CxcsWY8O.js} +1 -1
- package/dist/assets/{file-explorer-panel-BhxWVmmA.js → file-explorer-panel-Ix3_ncoS.js} +1 -1
- package/dist/assets/{file-icons-BEjw_TZq.js → file-icons-CM-BO4Tc.js} +1 -1
- package/dist/assets/{file-name-input-CDf2Ifpx.js → file-name-input-JcnL59-O.js} +1 -1
- package/dist/assets/{floating-outline-Db29DekO.js → floating-outline-DRRP5I8p.js} +1 -1
- package/dist/assets/{focus-Ptvt4Jk-.js → focus-EuWjxeHB.js} +1 -1
- package/dist/assets/{form-DMjMUXw1.js → form-BAAziqSH.js} +1 -1
- package/dist/assets/{globals-ehK_eQQa.js → globals-CBDJBT8O.js} +1 -1
- package/dist/assets/{home-page-CaZNGTTU.js → home-page-CV0Wger5.js} +1 -1
- package/dist/assets/{hooks-CvOsTpNH.js → hooks-CA6IH5Ny.js} +1 -1
- package/dist/assets/{html-to-image-B6hPo7Eh.js → html-to-image-BMbVLGQG.js} +1 -1
- package/dist/assets/{index-DW5V-tbG.js → index-DUE0RSxW.js} +21 -21
- package/dist/assets/{kiosk-mode-DULVbKXR.js → kiosk-mode-CHJ9OWcf.js} +1 -1
- package/dist/assets/{layout-CrjtGZlj.js → layout-Cpt95A_u.js} +3 -3
- package/dist/assets/{logs-panel-Vl7f5pTV.js → logs-panel-DqMjHSxY.js} +1 -1
- package/dist/assets/{markdown-renderer-DhkuKp0Y.js → markdown-renderer-Ctc_BAzL.js} +1 -1
- package/dist/assets/{name-cell-input-mLsE_Em-.js → name-cell-input-BUA6sZsk.js} +1 -1
- package/dist/assets/{outline-panel-B6UQJ1mr.js → outline-panel-BTxBvW3K.js} +1 -1
- package/dist/assets/{packages-panel-J5zHBH5Z.js → packages-panel-CH6Jiyqt.js} +1 -1
- package/dist/assets/{pair-with-agent-modal-DHxMYnfm.js → pair-with-agent-modal-CuwM9PX2.js} +1 -1
- package/dist/assets/{panels-DL9ZPvBQ.js → panels-C8IhLmTn.js} +1 -1
- package/dist/assets/{process-output-CelpjiMS.js → process-output-BD4gjuXh.js} +1 -1
- package/dist/assets/{radio-group-CCf-GEZ7.js → radio-group-D-Tbwbga.js} +1 -1
- package/dist/assets/{readonly-python-code-O2up8HDP.js → readonly-python-code-CD37Ktr_.js} +1 -1
- package/dist/assets/{reveal-component-DuIVIgwS.js → reveal-component-BaXkFbob.js} +1 -1
- package/dist/assets/{run-page-IO7tlMDF.js → run-page-N0uXBlRc.js} +1 -1
- package/dist/assets/{scratchpad-panel-DhudwLmZ.js → scratchpad-panel-B5qpYDCP.js} +1 -1
- package/dist/assets/{session-panel-B4I5vfLW.js → session-panel-BQbOiXTu.js} +1 -1
- package/dist/assets/{snippets-panel-Ct52Tbg4.js → snippets-panel-ngIQdZN-.js} +1 -1
- package/dist/assets/{state-BCiRPPap.js → state-XBSJaDlj.js} +1 -1
- package/dist/assets/{state-BahT9g5s.js → state-a26U8Amw.js} +1 -1
- package/dist/assets/{switch-qhCyy6_O.js → switch-LzzmbPXe.js} +1 -1
- package/dist/assets/{terminal-CnBPQSEu.js → terminal-zt3j3xY6.js} +1 -1
- package/dist/assets/{textarea-D1Q7dFo2.js → textarea-CIkM9ejr.js} +1 -1
- package/dist/assets/{tracing-B4lWMNEs.js → tracing-CvzDXfBi.js} +1 -1
- package/dist/assets/{tracing-panel-CzmHnTzf.js → tracing-panel-BSIiB4nQ.js} +2 -2
- package/dist/assets/{tree-actions-DwvEEjdS.js → tree-actions-DOImIbet.js} +1 -1
- package/dist/assets/{useBoolean-D0taClF7.js → useBoolean-BqfyqCpr.js} +1 -1
- package/dist/assets/{useCellActionButton-B8YCBRJi.js → useCellActionButton-D_GS6qfF.js} +1 -1
- package/dist/assets/{useDeleteCell-CTDjqdn7.js → useDeleteCell-R0cnbneF.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-DRjdcyD3.js → useDependencyPanelTab-1hFXraYl.js} +1 -1
- package/dist/assets/{useNotebookActions-Bkh6zqQr.js → useNotebookActions-CIfVqZq5.js} +1 -1
- package/dist/assets/{useRunCells-BRYGWDtj.js → useRunCells-DnS-CoD3.js} +1 -1
- package/dist/assets/{useSplitCell-iFrd3L8H.js → useSplitCell-BZ8UVfk6.js} +1 -1
- package/dist/assets/{vega-component-DG1sZbd1.js → vega-component-C8hpClBL.js} +1 -1
- package/dist/index.html +26 -26
- package/package.json +1 -1
- package/src/components/data-table/__tests__/columns.test.tsx +20 -0
- package/src/components/data-table/columns.tsx +16 -1
- package/src/components/data-table/filters/types.ts +1 -0
- package/src/components/data-table/renderers.tsx +5 -1
- package/src/components/editor/header/__tests__/status.test.tsx +0 -4
- package/src/components/editor/header/status.tsx +2 -3
- package/src/core/websocket/__tests__/useMarimoKernelConnection.test.ts +0 -13
- package/src/core/websocket/types.ts +0 -1
- package/src/core/websocket/useMarimoKernelConnection.tsx +0 -14
- package/src/plugins/impl/DataTablePlugin.tsx +8 -0
- package/dist/assets/config-Fh_0wwfW.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as m}from"./chunk-LvLJmgfZ.js";import{n as p}from"./useEvent-D91BmmQi.js";import{D as d,St as f,f as u}from"./cells-
|
|
1
|
+
import{s as m}from"./chunk-LvLJmgfZ.js";import{n as p}from"./useEvent-D91BmmQi.js";import{D as d,St as f,f as u}from"./cells-D3EcEVTz.js";import{t as c}from"./compiler-runtime-B3qBwwSJ.js";import{t as C}from"./jsx-runtime-PbYoItBR.js";import{r as h}from"./useDeleteCell-R0cnbneF.js";import{t as v}from"./use-toast-BH8bU9Xf.js";var x=c(),S=m(C(),1);function b(){let t=(0,x.c)(3),{splitCell:i,undoSplitCell:r}=d(),o;return t[0]!==i||t[1]!==r?(o=s=>{let l=u(s.cellId);if(!l)return;let a=f(l);i(s);let{dismiss:n}=v({title:"Cell split",action:(0,S.jsx)(h,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{r({...s,snapshot:a}),e()},children:"Undo"})}),e=n},t[0]=i,t[1]=r,t[2]=o):o=t[2],p(o)}export{b as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as Z}from"./chunk-LvLJmgfZ.js";import{n as C}from"./useEvent-D91BmmQi.js";import{t as Y}from"./react-Bj1aDYRI.js";import"./react-dom-CSu739Rf.js";import{t as tt}from"./compiler-runtime-B3qBwwSJ.js";import{t as et}from"./debounce-OiXznToA.js";import{_,d as V}from"./useEventListener-BfYriKqt.js";import{n as H}from"./config-Fh_0wwfW.js";import{t as nt}from"./cn-X2M2usMq.js";import{t as rt}from"./jsx-runtime-PbYoItBR.js";import"./fullscreen-6ovMHcQN.js";import{t as at}from"./tooltip-CWSr2PfE.js";import{r as it}from"./button-Db07tdz7.js";import{d as N}from"./arrays-DWxvyYxP.js";import{u as ot}from"./toDate-DCE7d2fN.js";import"./session-DF0gSADo.js";import{r as lt}from"./useTheme-BcDiZbxe.js";import{t as ct}from"./isValid-Cgon0fXK.js";import{a as st,r as mt,t as pt}from"./utils-TBIUapDT.js";import{n as ut}from"./vega-loader.browser-BJ9oKrvH.js";import{t as ft}from"./react-vega-DfkRLfna.js";import"./defaultLocale-CuYNS33t.js";import"./defaultLocale-CGfP-Ye3.js";import{r as dt,t as ht}from"./alert-DcAz54bD.js";import{n as gt}from"./error-banner-B4PMmgPV.js";import{t as yt}from"./formats-R75YbjP_.js";import{n as vt}from"./useAsyncData-CT1LpOBD.js";import{t as F}from"./useDeepCompareMemoize-zUHU--0D.js";import{t as kt}from"./semaphore-FlZezxaf.js";var bt=tt(),S=Z(Y(),1);function wt(t){return t.data&&"url"in t.data&&(t.data.url=H(t.data.url).href),t}const u={arc:"arc",area:"area",bar:"bar",image:"image",line:"line",point:"point",rect:"rect",rule:"rule",text:"text",tick:"tick",trail:"trail",circle:"circle",square:"square",geoshape:"geoshape"};var W=new Set(["boxplot","errorband","errorbar"]);const x={getMarkType(t){let e=typeof t=="string"?t:t.type;if(W.has(e))throw Error("Not supported");return e},isInteractive(t){let e=typeof t=="string"?t:t.type;return!W.has(e)},makeClickable(t){let e=typeof t=="string"?t:t.type;return e in u?typeof t=="string"?{type:t,cursor:"pointer",tooltip:!0}:{...t,type:e,cursor:"pointer",tooltip:!0}:t},getOpacity(t){return typeof t=="string"?null:"opacity"in t&&typeof t.opacity=="number"?t.opacity:null}},v={point(t){return t==null?"select_point":`select_point_${t}`},interval(t){return t==null?"select_interval":`select_interval_${t}`},legendSelection(t){return`legend_selection_${t}`},binColoring(t){return t==null?"bin_coloring":`bin_coloring_${t}`},HIGHLIGHT:"highlight",PAN_ZOOM:"pan_zoom",hasPoint(t){return t.some(e=>e.startsWith("select_point"))},hasInterval(t){return t.some(e=>e.startsWith("select_interval"))},hasLegend(t){return t.some(e=>e.startsWith("legend_selection"))},hasPanZoom(t){return t.some(e=>e.startsWith("pan_zoom"))},isBinColoring(t){return t.startsWith("bin_coloring")}},j={highlight(){return{name:v.HIGHLIGHT,select:{type:"point",on:"mouseover"}}},interval(t,e){return{name:v.interval(e),select:{type:"interval",encodings:D(t),mark:{fill:"#669EFF",fillOpacity:.07,stroke:"#669EFF",strokeOpacity:.4},on:"[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",translate:"[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]"}}},point(t,e){return{name:v.point(e),select:{type:"point",encodings:D(t),on:"click[!event.metaKey]"}}},binColoring(t){return{name:v.binColoring(t),select:{type:"point",on:"click[!event.metaKey]"}}},legend(t){return{name:v.legendSelection(t),select:{type:"point",fields:[t]},bind:"legend"}},panZoom(){return{name:v.PAN_ZOOM,bind:"scales",select:{type:"interval",on:"[mousedown[event.metaKey], window:mouseup] > window:mousemove!",translate:"[mousedown[event.metaKey], window:mouseup] > window:mousemove!",zoom:"wheel![event.metaKey]"}}}};function D(t){switch(x.getMarkType(t.mark)){case u.image:case u.trail:return;case u.area:case u.arc:return["color"];case u.bar:{let e=St(t);return e==="horizontal"?["y"]:e==="vertical"?["x"]:void 0}case u.circle:case u.geoshape:case u.line:case u.point:case u.rect:case u.rule:case u.square:case u.text:case u.tick:return["x","y"]}}function P(t){return"params"in t&&t.params&&t.params.length>0?N(t.params.filter(e=>e==null?!1:"select"in e&&e.select!==void 0).map(e=>e.name)):"layer"in t?N(t.layer.flatMap(P)):"vconcat"in t?N(t.vconcat.flatMap(P)):"hconcat"in t?N(t.hconcat.flatMap(P)):[]}function St(t){var a,i;if(!t||!("mark"in t))return;let e=(a=t.encoding)==null?void 0:a.x,n=(i=t.encoding)==null?void 0:i.y;if(e&&"type"in e&&e.type==="nominal")return"vertical";if(n&&"type"in n&&n.type==="nominal"||e&&"aggregate"in e)return"horizontal";if(n&&"aggregate"in n)return"vertical"}function xt(t){if(!t.encoding)return[];let e=[];for(let n of Object.values(t.encoding))n&&typeof n=="object"&&"bin"in n&&n.bin&&"field"in n&&typeof n.field=="string"&&e.push(n.field);return e}function G(t){if(!t||!("encoding"in t))return[];let{encoding:e}=t;return e?Object.entries(e).flatMap(n=>{let[a,i]=n;return!i||!At.has(a)?[]:"field"in i&&typeof i.field=="string"?[i.field]:"condition"in i&&i.condition&&typeof i.condition=="object"&&"field"in i.condition&&i.condition.field&&typeof i.condition.field=="string"?[i.condition.field]:[]}):[]}var At=new Set(["color","fill","fillOpacity","opacity","shape","size"]);function $(t,e,n,a){let i=n.filter(o=>v.isBinColoring(o)),r={and:(i.length>0?i:n).map(o=>({param:o}))};if(t==="opacity"){let o=x.getOpacity(a)||1;return{...e,opacity:{condition:{test:r,value:o},value:o/5}}}else return e}function _t(t){if(!("select"in t)||!t.select)return JSON.stringify(t);let e=t.select;if(typeof e=="string")return JSON.stringify({type:e,bind:t.bind});let n={type:e.type,encodings:"encodings"in e&&e.encodings?[...e.encodings].toSorted():void 0,fields:"fields"in e&&e.fields?[...e.fields].toSorted():void 0,bind:t.bind};return JSON.stringify(n)}function q(t){let e=E(t);if(e.length===0)return t;let n=jt(e);return n.length===0?t:{...L(K(t,new Set(n.map(a=>a.name))),n.map(a=>a.name)),params:[...t.params||[],...n]}}function E(t){let e=[];if("vconcat"in t&&Array.isArray(t.vconcat))for(let n of t.vconcat)e.push(...E(n));else if("hconcat"in t&&Array.isArray(t.hconcat))for(let n of t.hconcat)e.push(...E(n));else{if("layer"in t)return[];"mark"in t&&"params"in t&&t.params&&t.params.length>0&&e.push({params:t.params})}return e}function jt(t){if(t.length===0)return[];let e=new Map,n=t.length;for(let{params:i}of t){let r=new Set;for(let o of i){let s=_t(o);r.has(s)||(r.add(s),e.has(s)||e.set(s,{count:0,param:o}),e.get(s).count++)}}let a=[];for(let[,{count:i,param:r}]of e)i===n&&a.push(r);return a}function K(t,e){if("vconcat"in t&&Array.isArray(t.vconcat))return{...t,vconcat:t.vconcat.map(n=>K(n,e))};if("hconcat"in t&&Array.isArray(t.hconcat))return{...t,hconcat:t.hconcat.map(n=>K(n,e))};if("mark"in t&&"params"in t&&t.params){let n=t.params,a=[];for(let i of n){if(!i||typeof i!="object"||!("name"in i)){a.push(i);continue}e.has(i.name)||a.push(i)}if(a.length===0){let{params:i,...r}=t;return r}return{...t,params:a}}return t}function L(t,e){return"vconcat"in t&&Array.isArray(t.vconcat)?{...t,vconcat:t.vconcat.map(n=>L(n,e))}:"hconcat"in t&&Array.isArray(t.hconcat)?{...t,hconcat:t.hconcat.map(n=>L(n,e))}:"layer"in t?t:"mark"in t&&x.isInteractive(t.mark)?{...t,mark:x.makeClickable(t.mark),encoding:$("opacity",t.encoding||{},e,t.mark)}:t}function T(t,e){var s,h;let{chartSelection:n=!0,fieldSelection:a=!0}=e;if(!n&&!a)return t;(s=t.params)!=null&&s.some(l=>l.bind==="legend")&&(a=!1);let i=(h=t.params)==null?void 0:h.some(l=>!l.bind);i&&(n=!1);let r="vconcat"in t||"hconcat"in t;if(i&&r)return t;if("vconcat"in t){let l=t.vconcat.map(m=>"mark"in m?T(m,{chartSelection:n,fieldSelection:a}):m);return q({...t,vconcat:l})}if("hconcat"in t){let l=t.hconcat.map(m=>"mark"in m?T(m,{chartSelection:n,fieldSelection:a}):m);return q({...t,hconcat:l})}if("layer"in t){let l=t.params&&t.params.length>0,m=a!==!1&&!l,k=[];if(m){let p=t.layer.flatMap(f=>"mark"in f?G(f):[]);k=[...new Set(p)],Array.isArray(a)&&(k=k.filter(f=>a.includes(f)))}let w=t.layer.map((p,f)=>{if(!("mark"in p))return p;let g=p;if(f===0&&k.length>0){let O=k.map(M=>j.legend(M));g={...g,params:[...g.params||[],...O]}}return g=z(g,n,f),g=J(g),f===0&&(g=B(g)),g});return{...t,layer:w}}if(!("mark"in t)||!x.isInteractive(t.mark))return t;let o=t;return o=Ot(o,a),o=z(o,n,void 0),o=J(o),o=B(o),o}function Ot(t,e){if(e===!1)return t;let n=G(t);Array.isArray(e)&&(n=n.filter(r=>e.includes(r)));let a=n.map(r=>j.legend(r)),i=[...t.params||[],...a];return{...t,params:i}}function z(t,e,n){if(e===!1)return t;let a;try{a=x.getMarkType(t.mark)}catch{return t}if(a==="geoshape")return t;let i=xt(t),r=e===!0?i.length>0?["point"]:Mt(a):[e];if(!r||r.length===0)return t;let o=r.map(h=>h==="interval"?j.interval(t,n):j.point(t,n)),s=[...t.params||[],...o];return i.length>0&&r.includes("point")&&s.push(j.binColoring(n)),{...t,params:s}}function B(t){let e;try{e=x.getMarkType(t.mark)}catch{}if(e==="geoshape")return t;let n=t.params||[];return n.some(a=>a.bind==="scales")?t:{...t,params:[...n,j.panZoom()]}}function J(t){let e="encoding"in t?t.encoding:void 0,n=t.params||[],a=n.map(i=>i.name);return n.length===0||!x.isInteractive(t.mark)?t:{...t,mark:x.makeClickable(t.mark),encoding:$("opacity",e||{},a,t.mark)}}function Mt(t){switch(t){case"arc":case"area":return["point"];case"text":case"bar":return["point","interval"];case"line":return;default:return["point","interval"]}}var Nt=5;async function Pt(t){if(!t)return t;let e="datasets"in t?{...t.datasets}:{},n=new kt(Nt),a=async r=>{if(!r)return r;if("layer"in r){let l=await Promise.all(r.layer.map(a));r={...r,layer:l}}if("hconcat"in r){let l=await Promise.all(r.hconcat.map(a));r={...r,hconcat:l}}if("vconcat"in r){let l=await Promise.all(r.vconcat.map(a));r={...r,vconcat:l}}if("spec"in r&&(r={...r,spec:await a(r.spec)}),!r.data||!("url"in r.data))return r;let o;try{o=H(r.data.url)}catch{return r}let s=r.data.format,h=await n.run(()=>st(o.href,s));return e[o.pathname]=h,{...r,data:{name:o.pathname}}},i=await a(t);return Object.keys(e).length===0?i:{...i,datasets:e}}var d=Z(rt(),1);ut("arrow",yt);var It=t=>{let e=(0,bt.c)(12),{value:n,setValue:a,chartSelection:i,fieldSelection:r,spec:o,embedOptions:s}=t,h,l;e[0]===o?(h=e[1],l=e[2]):(h=async()=>Pt(o),l=[o],e[0]=o,e[1]=h,e[2]=l);let{data:m,error:k}=vt(h,l);if(k){let p;return e[3]===k?p=e[4]:(p=(0,d.jsx)(gt,{error:k}),e[3]=k,e[4]=p),p}if(!m)return null;let w;return e[5]!==i||e[6]!==s||e[7]!==r||e[8]!==m||e[9]!==a||e[10]!==n?(w=(0,d.jsx)(Ct,{value:n,setValue:a,chartSelection:i,fieldSelection:r,spec:m,embedOptions:s}),e[5]=i,e[6]=s,e[7]=r,e[8]=m,e[9]=a,e[10]=n,e[11]=w):w=e[11],w},Ct=({value:t,setValue:e,chartSelection:n,fieldSelection:a,spec:i,embedOptions:r})=>{let{theme:o}=lt(),s=(0,S.useRef)(null),h=(0,S.useRef)(void 0),[l,m]=(0,S.useState)(),k=(0,S.useMemo)(()=>r&&"actions"in r?r.actions:{source:!1,compiled:!1},[r]),w=F(i),p=(0,S.useMemo)(()=>T(wt(w),{chartSelection:n,fieldSelection:a}),[w,n,a]),f=(0,S.useMemo)(()=>P(p),[p]),g=C(c=>{e({...t,...c})}),O=(0,S.useMemo)(()=>et((c,y)=>{_.debug("[Vega signal]",c,y);let b=V.mapValues(y,Kt);b=V.mapValues(b,Et),g({[c]:b})},100),[g]),M=F(f),I=(0,S.useMemo)(()=>M.reduce((c,y)=>(v.PAN_ZOOM===y||v.isBinColoring(y)||c.push({signalName:y,handler:(b,X)=>O(b,X)}),c),[]),[M,O]),R=C(c=>{_.error(c),_.debug(p),m(c)}),Q=C(c=>{_.debug("[Vega view] created",c),h.current=c,m(void 0)}),U=()=>{let c=[];return v.hasPoint(f)&&c.push(["Point selection","click to select a point; hold shift for multi-select"]),v.hasInterval(f)&&c.push(["Interval selection","click and drag to select an interval"]),v.hasLegend(f)&&c.push(["Legend selection","click to select a legend item; hold shift for multi-select"]),v.hasPanZoom(f)&&c.push(["Pan","hold the meta key and drag"],["Zoom","hold the meta key and scroll"]),c.length===0?null:(0,d.jsx)(at,{delayDuration:300,side:"left",content:(0,d.jsx)("div",{className:"text-xs flex flex-col",children:c.map((y,b)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("span",{className:"font-bold tracking-wide",children:[y[0],":"]})," ",y[1]]},b))}),children:(0,d.jsx)(ot,{className:"absolute bottom-1 right-0 m-2 h-4 w-4 cursor-help text-muted-foreground hover:text-foreground"})})},A=ft({ref:s,spec:p,options:{theme:o==="dark"?"dark":void 0,actions:k,mode:"vega-lite",tooltip:mt.call,renderer:"canvas"},onError:R,onEmbed:Q});return(0,S.useEffect)(()=>(I.forEach(({signalName:c,handler:y})=>{try{A==null||A.view.addSignalListener(c,y)}catch(b){_.error(b)}}),()=>{I.forEach(({signalName:c,handler:y})=>{try{A==null||A.view.removeSignalListener(c,y)}catch(b){_.error(b)}})}),[A,I]),(0,d.jsxs)(d.Fragment,{children:[l&&(0,d.jsxs)(ht,{variant:"destructive",children:[(0,d.jsx)(dt,{children:l.message}),(0,d.jsx)("div",{className:"text-md",children:l.stack})]}),(0,d.jsxs)("div",{className:nt("relative"),onPointerDown:it.stopPropagation(),children:[(0,d.jsx)("div",{ref:s,"data-container-width":pt(p)}),U()]})]})};function Et(t){return t instanceof Set?[...t]:t}function Kt(t){return Array.isArray(t)?t.map(e=>e instanceof Date&&ct(e)?new Date(e).getTime():e):t}var Lt=It;export{Lt as default};
|
|
1
|
+
import{s as Z}from"./chunk-LvLJmgfZ.js";import{n as C}from"./useEvent-D91BmmQi.js";import{t as Y}from"./react-Bj1aDYRI.js";import"./react-dom-CSu739Rf.js";import{t as tt}from"./compiler-runtime-B3qBwwSJ.js";import{t as et}from"./debounce-OiXznToA.js";import{_,d as V}from"./useEventListener-BfYriKqt.js";import{n as H}from"./config-B00Uc1a3.js";import{t as nt}from"./cn-X2M2usMq.js";import{t as rt}from"./jsx-runtime-PbYoItBR.js";import"./fullscreen-6ovMHcQN.js";import{t as at}from"./tooltip-CWSr2PfE.js";import{r as it}from"./button-Db07tdz7.js";import{d as N}from"./arrays-DWxvyYxP.js";import{u as ot}from"./toDate-DCE7d2fN.js";import"./session-DF0gSADo.js";import{r as lt}from"./useTheme-BcDiZbxe.js";import{t as ct}from"./isValid-Cgon0fXK.js";import{a as st,r as mt,t as pt}from"./utils-TBIUapDT.js";import{n as ut}from"./vega-loader.browser-BJ9oKrvH.js";import{t as ft}from"./react-vega-DfkRLfna.js";import"./defaultLocale-CuYNS33t.js";import"./defaultLocale-CGfP-Ye3.js";import{r as dt,t as ht}from"./alert-DcAz54bD.js";import{n as gt}from"./error-banner-B4PMmgPV.js";import{t as yt}from"./formats-R75YbjP_.js";import{n as vt}from"./useAsyncData-CT1LpOBD.js";import{t as F}from"./useDeepCompareMemoize-zUHU--0D.js";import{t as kt}from"./semaphore-FlZezxaf.js";var bt=tt(),S=Z(Y(),1);function wt(t){return t.data&&"url"in t.data&&(t.data.url=H(t.data.url).href),t}const u={arc:"arc",area:"area",bar:"bar",image:"image",line:"line",point:"point",rect:"rect",rule:"rule",text:"text",tick:"tick",trail:"trail",circle:"circle",square:"square",geoshape:"geoshape"};var W=new Set(["boxplot","errorband","errorbar"]);const x={getMarkType(t){let e=typeof t=="string"?t:t.type;if(W.has(e))throw Error("Not supported");return e},isInteractive(t){let e=typeof t=="string"?t:t.type;return!W.has(e)},makeClickable(t){let e=typeof t=="string"?t:t.type;return e in u?typeof t=="string"?{type:t,cursor:"pointer",tooltip:!0}:{...t,type:e,cursor:"pointer",tooltip:!0}:t},getOpacity(t){return typeof t=="string"?null:"opacity"in t&&typeof t.opacity=="number"?t.opacity:null}},v={point(t){return t==null?"select_point":`select_point_${t}`},interval(t){return t==null?"select_interval":`select_interval_${t}`},legendSelection(t){return`legend_selection_${t}`},binColoring(t){return t==null?"bin_coloring":`bin_coloring_${t}`},HIGHLIGHT:"highlight",PAN_ZOOM:"pan_zoom",hasPoint(t){return t.some(e=>e.startsWith("select_point"))},hasInterval(t){return t.some(e=>e.startsWith("select_interval"))},hasLegend(t){return t.some(e=>e.startsWith("legend_selection"))},hasPanZoom(t){return t.some(e=>e.startsWith("pan_zoom"))},isBinColoring(t){return t.startsWith("bin_coloring")}},j={highlight(){return{name:v.HIGHLIGHT,select:{type:"point",on:"mouseover"}}},interval(t,e){return{name:v.interval(e),select:{type:"interval",encodings:D(t),mark:{fill:"#669EFF",fillOpacity:.07,stroke:"#669EFF",strokeOpacity:.4},on:"[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]",translate:"[mousedown[!event.metaKey], mouseup] > mousemove[!event.metaKey]"}}},point(t,e){return{name:v.point(e),select:{type:"point",encodings:D(t),on:"click[!event.metaKey]"}}},binColoring(t){return{name:v.binColoring(t),select:{type:"point",on:"click[!event.metaKey]"}}},legend(t){return{name:v.legendSelection(t),select:{type:"point",fields:[t]},bind:"legend"}},panZoom(){return{name:v.PAN_ZOOM,bind:"scales",select:{type:"interval",on:"[mousedown[event.metaKey], window:mouseup] > window:mousemove!",translate:"[mousedown[event.metaKey], window:mouseup] > window:mousemove!",zoom:"wheel![event.metaKey]"}}}};function D(t){switch(x.getMarkType(t.mark)){case u.image:case u.trail:return;case u.area:case u.arc:return["color"];case u.bar:{let e=St(t);return e==="horizontal"?["y"]:e==="vertical"?["x"]:void 0}case u.circle:case u.geoshape:case u.line:case u.point:case u.rect:case u.rule:case u.square:case u.text:case u.tick:return["x","y"]}}function P(t){return"params"in t&&t.params&&t.params.length>0?N(t.params.filter(e=>e==null?!1:"select"in e&&e.select!==void 0).map(e=>e.name)):"layer"in t?N(t.layer.flatMap(P)):"vconcat"in t?N(t.vconcat.flatMap(P)):"hconcat"in t?N(t.hconcat.flatMap(P)):[]}function St(t){var a,i;if(!t||!("mark"in t))return;let e=(a=t.encoding)==null?void 0:a.x,n=(i=t.encoding)==null?void 0:i.y;if(e&&"type"in e&&e.type==="nominal")return"vertical";if(n&&"type"in n&&n.type==="nominal"||e&&"aggregate"in e)return"horizontal";if(n&&"aggregate"in n)return"vertical"}function xt(t){if(!t.encoding)return[];let e=[];for(let n of Object.values(t.encoding))n&&typeof n=="object"&&"bin"in n&&n.bin&&"field"in n&&typeof n.field=="string"&&e.push(n.field);return e}function G(t){if(!t||!("encoding"in t))return[];let{encoding:e}=t;return e?Object.entries(e).flatMap(n=>{let[a,i]=n;return!i||!At.has(a)?[]:"field"in i&&typeof i.field=="string"?[i.field]:"condition"in i&&i.condition&&typeof i.condition=="object"&&"field"in i.condition&&i.condition.field&&typeof i.condition.field=="string"?[i.condition.field]:[]}):[]}var At=new Set(["color","fill","fillOpacity","opacity","shape","size"]);function $(t,e,n,a){let i=n.filter(o=>v.isBinColoring(o)),r={and:(i.length>0?i:n).map(o=>({param:o}))};if(t==="opacity"){let o=x.getOpacity(a)||1;return{...e,opacity:{condition:{test:r,value:o},value:o/5}}}else return e}function _t(t){if(!("select"in t)||!t.select)return JSON.stringify(t);let e=t.select;if(typeof e=="string")return JSON.stringify({type:e,bind:t.bind});let n={type:e.type,encodings:"encodings"in e&&e.encodings?[...e.encodings].toSorted():void 0,fields:"fields"in e&&e.fields?[...e.fields].toSorted():void 0,bind:t.bind};return JSON.stringify(n)}function q(t){let e=E(t);if(e.length===0)return t;let n=jt(e);return n.length===0?t:{...L(K(t,new Set(n.map(a=>a.name))),n.map(a=>a.name)),params:[...t.params||[],...n]}}function E(t){let e=[];if("vconcat"in t&&Array.isArray(t.vconcat))for(let n of t.vconcat)e.push(...E(n));else if("hconcat"in t&&Array.isArray(t.hconcat))for(let n of t.hconcat)e.push(...E(n));else{if("layer"in t)return[];"mark"in t&&"params"in t&&t.params&&t.params.length>0&&e.push({params:t.params})}return e}function jt(t){if(t.length===0)return[];let e=new Map,n=t.length;for(let{params:i}of t){let r=new Set;for(let o of i){let s=_t(o);r.has(s)||(r.add(s),e.has(s)||e.set(s,{count:0,param:o}),e.get(s).count++)}}let a=[];for(let[,{count:i,param:r}]of e)i===n&&a.push(r);return a}function K(t,e){if("vconcat"in t&&Array.isArray(t.vconcat))return{...t,vconcat:t.vconcat.map(n=>K(n,e))};if("hconcat"in t&&Array.isArray(t.hconcat))return{...t,hconcat:t.hconcat.map(n=>K(n,e))};if("mark"in t&&"params"in t&&t.params){let n=t.params,a=[];for(let i of n){if(!i||typeof i!="object"||!("name"in i)){a.push(i);continue}e.has(i.name)||a.push(i)}if(a.length===0){let{params:i,...r}=t;return r}return{...t,params:a}}return t}function L(t,e){return"vconcat"in t&&Array.isArray(t.vconcat)?{...t,vconcat:t.vconcat.map(n=>L(n,e))}:"hconcat"in t&&Array.isArray(t.hconcat)?{...t,hconcat:t.hconcat.map(n=>L(n,e))}:"layer"in t?t:"mark"in t&&x.isInteractive(t.mark)?{...t,mark:x.makeClickable(t.mark),encoding:$("opacity",t.encoding||{},e,t.mark)}:t}function T(t,e){var s,h;let{chartSelection:n=!0,fieldSelection:a=!0}=e;if(!n&&!a)return t;(s=t.params)!=null&&s.some(l=>l.bind==="legend")&&(a=!1);let i=(h=t.params)==null?void 0:h.some(l=>!l.bind);i&&(n=!1);let r="vconcat"in t||"hconcat"in t;if(i&&r)return t;if("vconcat"in t){let l=t.vconcat.map(m=>"mark"in m?T(m,{chartSelection:n,fieldSelection:a}):m);return q({...t,vconcat:l})}if("hconcat"in t){let l=t.hconcat.map(m=>"mark"in m?T(m,{chartSelection:n,fieldSelection:a}):m);return q({...t,hconcat:l})}if("layer"in t){let l=t.params&&t.params.length>0,m=a!==!1&&!l,k=[];if(m){let p=t.layer.flatMap(f=>"mark"in f?G(f):[]);k=[...new Set(p)],Array.isArray(a)&&(k=k.filter(f=>a.includes(f)))}let w=t.layer.map((p,f)=>{if(!("mark"in p))return p;let g=p;if(f===0&&k.length>0){let O=k.map(M=>j.legend(M));g={...g,params:[...g.params||[],...O]}}return g=z(g,n,f),g=J(g),f===0&&(g=B(g)),g});return{...t,layer:w}}if(!("mark"in t)||!x.isInteractive(t.mark))return t;let o=t;return o=Ot(o,a),o=z(o,n,void 0),o=J(o),o=B(o),o}function Ot(t,e){if(e===!1)return t;let n=G(t);Array.isArray(e)&&(n=n.filter(r=>e.includes(r)));let a=n.map(r=>j.legend(r)),i=[...t.params||[],...a];return{...t,params:i}}function z(t,e,n){if(e===!1)return t;let a;try{a=x.getMarkType(t.mark)}catch{return t}if(a==="geoshape")return t;let i=xt(t),r=e===!0?i.length>0?["point"]:Mt(a):[e];if(!r||r.length===0)return t;let o=r.map(h=>h==="interval"?j.interval(t,n):j.point(t,n)),s=[...t.params||[],...o];return i.length>0&&r.includes("point")&&s.push(j.binColoring(n)),{...t,params:s}}function B(t){let e;try{e=x.getMarkType(t.mark)}catch{}if(e==="geoshape")return t;let n=t.params||[];return n.some(a=>a.bind==="scales")?t:{...t,params:[...n,j.panZoom()]}}function J(t){let e="encoding"in t?t.encoding:void 0,n=t.params||[],a=n.map(i=>i.name);return n.length===0||!x.isInteractive(t.mark)?t:{...t,mark:x.makeClickable(t.mark),encoding:$("opacity",e||{},a,t.mark)}}function Mt(t){switch(t){case"arc":case"area":return["point"];case"text":case"bar":return["point","interval"];case"line":return;default:return["point","interval"]}}var Nt=5;async function Pt(t){if(!t)return t;let e="datasets"in t?{...t.datasets}:{},n=new kt(Nt),a=async r=>{if(!r)return r;if("layer"in r){let l=await Promise.all(r.layer.map(a));r={...r,layer:l}}if("hconcat"in r){let l=await Promise.all(r.hconcat.map(a));r={...r,hconcat:l}}if("vconcat"in r){let l=await Promise.all(r.vconcat.map(a));r={...r,vconcat:l}}if("spec"in r&&(r={...r,spec:await a(r.spec)}),!r.data||!("url"in r.data))return r;let o;try{o=H(r.data.url)}catch{return r}let s=r.data.format,h=await n.run(()=>st(o.href,s));return e[o.pathname]=h,{...r,data:{name:o.pathname}}},i=await a(t);return Object.keys(e).length===0?i:{...i,datasets:e}}var d=Z(rt(),1);ut("arrow",yt);var It=t=>{let e=(0,bt.c)(12),{value:n,setValue:a,chartSelection:i,fieldSelection:r,spec:o,embedOptions:s}=t,h,l;e[0]===o?(h=e[1],l=e[2]):(h=async()=>Pt(o),l=[o],e[0]=o,e[1]=h,e[2]=l);let{data:m,error:k}=vt(h,l);if(k){let p;return e[3]===k?p=e[4]:(p=(0,d.jsx)(gt,{error:k}),e[3]=k,e[4]=p),p}if(!m)return null;let w;return e[5]!==i||e[6]!==s||e[7]!==r||e[8]!==m||e[9]!==a||e[10]!==n?(w=(0,d.jsx)(Ct,{value:n,setValue:a,chartSelection:i,fieldSelection:r,spec:m,embedOptions:s}),e[5]=i,e[6]=s,e[7]=r,e[8]=m,e[9]=a,e[10]=n,e[11]=w):w=e[11],w},Ct=({value:t,setValue:e,chartSelection:n,fieldSelection:a,spec:i,embedOptions:r})=>{let{theme:o}=lt(),s=(0,S.useRef)(null),h=(0,S.useRef)(void 0),[l,m]=(0,S.useState)(),k=(0,S.useMemo)(()=>r&&"actions"in r?r.actions:{source:!1,compiled:!1},[r]),w=F(i),p=(0,S.useMemo)(()=>T(wt(w),{chartSelection:n,fieldSelection:a}),[w,n,a]),f=(0,S.useMemo)(()=>P(p),[p]),g=C(c=>{e({...t,...c})}),O=(0,S.useMemo)(()=>et((c,y)=>{_.debug("[Vega signal]",c,y);let b=V.mapValues(y,Kt);b=V.mapValues(b,Et),g({[c]:b})},100),[g]),M=F(f),I=(0,S.useMemo)(()=>M.reduce((c,y)=>(v.PAN_ZOOM===y||v.isBinColoring(y)||c.push({signalName:y,handler:(b,X)=>O(b,X)}),c),[]),[M,O]),R=C(c=>{_.error(c),_.debug(p),m(c)}),Q=C(c=>{_.debug("[Vega view] created",c),h.current=c,m(void 0)}),U=()=>{let c=[];return v.hasPoint(f)&&c.push(["Point selection","click to select a point; hold shift for multi-select"]),v.hasInterval(f)&&c.push(["Interval selection","click and drag to select an interval"]),v.hasLegend(f)&&c.push(["Legend selection","click to select a legend item; hold shift for multi-select"]),v.hasPanZoom(f)&&c.push(["Pan","hold the meta key and drag"],["Zoom","hold the meta key and scroll"]),c.length===0?null:(0,d.jsx)(at,{delayDuration:300,side:"left",content:(0,d.jsx)("div",{className:"text-xs flex flex-col",children:c.map((y,b)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("span",{className:"font-bold tracking-wide",children:[y[0],":"]})," ",y[1]]},b))}),children:(0,d.jsx)(ot,{className:"absolute bottom-1 right-0 m-2 h-4 w-4 cursor-help text-muted-foreground hover:text-foreground"})})},A=ft({ref:s,spec:p,options:{theme:o==="dark"?"dark":void 0,actions:k,mode:"vega-lite",tooltip:mt.call,renderer:"canvas"},onError:R,onEmbed:Q});return(0,S.useEffect)(()=>(I.forEach(({signalName:c,handler:y})=>{try{A==null||A.view.addSignalListener(c,y)}catch(b){_.error(b)}}),()=>{I.forEach(({signalName:c,handler:y})=>{try{A==null||A.view.removeSignalListener(c,y)}catch(b){_.error(b)}})}),[A,I]),(0,d.jsxs)(d.Fragment,{children:[l&&(0,d.jsxs)(ht,{variant:"destructive",children:[(0,d.jsx)(dt,{children:l.message}),(0,d.jsx)("div",{className:"text-md",children:l.stack})]}),(0,d.jsxs)("div",{className:nt("relative"),onPointerDown:it.stopPropagation(),children:[(0,d.jsx)("div",{ref:s,"data-container-width":pt(p)}),U()]})]})};function Et(t){return t instanceof Set?[...t]:t}function Kt(t){return Array.isArray(t)?t.map(e=>e instanceof Date&&ct(e)?new Date(e).getTime():e):t}var Lt=It;export{Lt 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-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-DUE0RSxW.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-y72bE5iF.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/chunk-LvLJmgfZ.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/react-Bj1aDYRI.js">
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
<link rel="modulepreload" crossorigin href="./assets/DeferredRequestRegistry-CiquRdvU.js">
|
|
105
105
|
<link rel="modulepreload" crossorigin href="./assets/constants-B9JJ72XE.js">
|
|
106
106
|
<link rel="modulepreload" crossorigin href="./assets/session-DF0gSADo.js">
|
|
107
|
-
<link rel="modulepreload" crossorigin href="./assets/config-
|
|
107
|
+
<link rel="modulepreload" crossorigin href="./assets/config-B00Uc1a3.js">
|
|
108
108
|
<link rel="modulepreload" crossorigin href="./assets/requests-KshNNAOp.js">
|
|
109
109
|
<link rel="modulepreload" crossorigin href="./assets/useLifecycle-Baf35rp4.js">
|
|
110
110
|
<link rel="modulepreload" crossorigin href="./assets/useNonce-0SWz6w4W.js">
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
<link rel="modulepreload" crossorigin href="./assets/debounce-OiXznToA.js">
|
|
134
134
|
<link rel="modulepreload" crossorigin href="./assets/database-zap-CO_HxsuW.js">
|
|
135
135
|
<link rel="modulepreload" crossorigin href="./assets/main-DmhaVp6Y.js">
|
|
136
|
-
<link rel="modulepreload" crossorigin href="./assets/cells-
|
|
136
|
+
<link rel="modulepreload" crossorigin href="./assets/cells-D3EcEVTz.js">
|
|
137
137
|
<link rel="modulepreload" crossorigin href="./assets/ErrorBoundary-clTdAaK7.js">
|
|
138
138
|
<link rel="modulepreload" crossorigin href="./assets/kbd-BCXa3Ocm.js">
|
|
139
139
|
<link rel="modulepreload" crossorigin href="./assets/useInstallPackage-BaCdyZWe.js">
|
|
@@ -147,38 +147,38 @@
|
|
|
147
147
|
<link rel="modulepreload" crossorigin href="./assets/usePress-mjvipKvz.js">
|
|
148
148
|
<link rel="modulepreload" crossorigin href="./assets/input-DiAad2nt.js">
|
|
149
149
|
<link rel="modulepreload" crossorigin href="./assets/ImperativeModal-CEtvKaPt.js">
|
|
150
|
-
<link rel="modulepreload" crossorigin href="./assets/cell-link-
|
|
150
|
+
<link rel="modulepreload" crossorigin href="./assets/cell-link-BBWAKZ--.js">
|
|
151
151
|
<link rel="modulepreload" crossorigin href="./assets/multi-map-DDbeVHF9.js">
|
|
152
152
|
<link rel="modulepreload" crossorigin href="./assets/alert-DcAz54bD.js">
|
|
153
153
|
<link rel="modulepreload" crossorigin href="./assets/chevron-right-C7RH0Nc7.js">
|
|
154
154
|
<link rel="modulepreload" crossorigin href="./assets/dropdown-menu-BYGDVBcE.js">
|
|
155
155
|
<link rel="modulepreload" crossorigin href="./assets/links-DK7te6sJ.js">
|
|
156
|
-
<link rel="modulepreload" crossorigin href="./assets/useRunCells-
|
|
156
|
+
<link rel="modulepreload" crossorigin href="./assets/useRunCells-DnS-CoD3.js">
|
|
157
157
|
<link rel="modulepreload" crossorigin href="./assets/copy-DlC1PYY-.js">
|
|
158
158
|
<link rel="modulepreload" crossorigin href="./assets/copy-CFO636Td.js">
|
|
159
159
|
<link rel="modulepreload" crossorigin href="./assets/copy-icon-C8Cq0-V0.js">
|
|
160
|
-
<link rel="modulepreload" crossorigin href="./assets/RenderHTML-
|
|
161
|
-
<link rel="modulepreload" crossorigin href="./assets/datasource-
|
|
162
|
-
<link rel="modulepreload" crossorigin href="./assets/state-
|
|
160
|
+
<link rel="modulepreload" crossorigin href="./assets/RenderHTML-CdzAncjW.js">
|
|
161
|
+
<link rel="modulepreload" crossorigin href="./assets/datasource-BtJgopUR.js">
|
|
162
|
+
<link rel="modulepreload" crossorigin href="./assets/state-a26U8Amw.js">
|
|
163
163
|
<link rel="modulepreload" crossorigin href="./assets/package-Cxwiscky.js">
|
|
164
164
|
<link rel="modulepreload" crossorigin href="./assets/sparkles-DctOjjEz.js">
|
|
165
|
-
<link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-
|
|
165
|
+
<link rel="modulepreload" crossorigin href="./assets/MarimoErrorOutput-tWmQZh0O.js">
|
|
166
166
|
<link rel="modulepreload" crossorigin href="./assets/eye-off-6RDlHoCz.js">
|
|
167
167
|
<link rel="modulepreload" crossorigin href="./assets/refresh-cw-hZ_ibJIl.js">
|
|
168
|
-
<link rel="modulepreload" crossorigin href="./assets/tree-actions-
|
|
168
|
+
<link rel="modulepreload" crossorigin href="./assets/tree-actions-DOImIbet.js">
|
|
169
169
|
<link rel="modulepreload" crossorigin href="./assets/spinner-BlJOg2gb.js">
|
|
170
|
-
<link rel="modulepreload" crossorigin href="./assets/html-to-image-
|
|
171
|
-
<link rel="modulepreload" crossorigin href="./assets/focus-
|
|
170
|
+
<link rel="modulepreload" crossorigin href="./assets/html-to-image-BMbVLGQG.js">
|
|
171
|
+
<link rel="modulepreload" crossorigin href="./assets/focus-EuWjxeHB.js">
|
|
172
172
|
<link rel="modulepreload" crossorigin href="./assets/useAsyncData-CT1LpOBD.js">
|
|
173
173
|
<link rel="modulepreload" crossorigin href="./assets/LazyAnyLanguageCodeMirror-Cjh82vPC.js">
|
|
174
174
|
<link rel="modulepreload" crossorigin href="./assets/micromark-factory-space-P--XWZhg.js">
|
|
175
175
|
<link rel="modulepreload" crossorigin href="./assets/chunk-5FQGJX7Z-D-AUn5sP.js">
|
|
176
|
-
<link rel="modulepreload" crossorigin href="./assets/markdown-renderer-
|
|
176
|
+
<link rel="modulepreload" crossorigin href="./assets/markdown-renderer-Ctc_BAzL.js">
|
|
177
177
|
<link rel="modulepreload" crossorigin href="./assets/command-Dzjey1r-.js">
|
|
178
178
|
<link rel="modulepreload" crossorigin href="./assets/field-DIHN6mSK.js">
|
|
179
179
|
<link rel="modulepreload" crossorigin href="./assets/popover-D1IutFqN.js">
|
|
180
180
|
<link rel="modulepreload" crossorigin href="./assets/errors-48KFPvCp.js">
|
|
181
|
-
<link rel="modulepreload" crossorigin href="./assets/download-
|
|
181
|
+
<link rel="modulepreload" crossorigin href="./assets/download-CYrhtDVp.js">
|
|
182
182
|
<link rel="modulepreload" crossorigin href="./assets/table-BEAxH5RS.js">
|
|
183
183
|
<link rel="modulepreload" crossorigin href="./assets/useIframeCapabilities-CJXRJK5V.js">
|
|
184
184
|
<link rel="modulepreload" crossorigin href="./assets/error-banner-B4PMmgPV.js">
|
|
@@ -198,36 +198,36 @@
|
|
|
198
198
|
<link rel="modulepreload" crossorigin href="./assets/plus-Dvg5FyTi.js">
|
|
199
199
|
<link rel="modulepreload" crossorigin href="./assets/trash-2-CjPoUZCP.js">
|
|
200
200
|
<link rel="modulepreload" crossorigin href="./assets/react-resizable-panels.browser.esm-CgWOEYeG.js">
|
|
201
|
-
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-
|
|
201
|
+
<link rel="modulepreload" crossorigin href="./assets/JsonOutput-e5KwGs-t.js">
|
|
202
202
|
<link rel="modulepreload" crossorigin href="./assets/chart-no-axes-column-DVEV2j1H.js">
|
|
203
203
|
<link rel="modulepreload" crossorigin href="./assets/square-function-CPbVtjKW.js">
|
|
204
204
|
<link rel="modulepreload" crossorigin href="./assets/spec-RgR7OB72.js">
|
|
205
|
-
<link rel="modulepreload" crossorigin href="./assets/column-preview-
|
|
205
|
+
<link rel="modulepreload" crossorigin href="./assets/column-preview-93mkKGs1.js">
|
|
206
206
|
<link rel="modulepreload" crossorigin href="./assets/icons-D3YFXNmD.js">
|
|
207
|
-
<link rel="modulepreload" crossorigin href="./assets/radio-group-
|
|
208
|
-
<link rel="modulepreload" crossorigin href="./assets/floating-outline-
|
|
207
|
+
<link rel="modulepreload" crossorigin href="./assets/radio-group-D-Tbwbga.js">
|
|
208
|
+
<link rel="modulepreload" crossorigin href="./assets/floating-outline-DRRP5I8p.js">
|
|
209
209
|
<link rel="modulepreload" crossorigin href="./assets/objectWithoutPropertiesLoose-Msf1n32r.js">
|
|
210
210
|
<link rel="modulepreload" crossorigin href="./assets/esm-DSv-aO_T.js">
|
|
211
|
-
<link rel="modulepreload" crossorigin href="./assets/readonly-python-code-
|
|
211
|
+
<link rel="modulepreload" crossorigin href="./assets/readonly-python-code-CD37Ktr_.js">
|
|
212
212
|
<link rel="modulepreload" crossorigin href="./assets/file-headphone-D2bGq0xX.js">
|
|
213
213
|
<link rel="modulepreload" crossorigin href="./assets/file-ZPWSptQF.js">
|
|
214
214
|
<link rel="modulepreload" crossorigin href="./assets/image-CzV694oU.js">
|
|
215
|
-
<link rel="modulepreload" crossorigin href="./assets/file-icons-
|
|
216
|
-
<link rel="modulepreload" crossorigin href="./assets/switch-
|
|
215
|
+
<link rel="modulepreload" crossorigin href="./assets/file-icons-CM-BO4Tc.js">
|
|
216
|
+
<link rel="modulepreload" crossorigin href="./assets/switch-LzzmbPXe.js">
|
|
217
217
|
<link rel="modulepreload" crossorigin href="./assets/events-BRbNg7Li.js">
|
|
218
|
-
<link rel="modulepreload" crossorigin href="./assets/globals-
|
|
218
|
+
<link rel="modulepreload" crossorigin href="./assets/globals-CBDJBT8O.js">
|
|
219
219
|
<link rel="modulepreload" crossorigin href="./assets/share-CDUcBp99.js">
|
|
220
220
|
<link rel="modulepreload" crossorigin href="./assets/blob-dGUJ3Bw8.js">
|
|
221
221
|
<link rel="modulepreload" crossorigin href="./assets/memoize-Tp7rARFe.js">
|
|
222
222
|
<link rel="modulepreload" crossorigin href="./assets/get-C-qh_et5.js">
|
|
223
223
|
<link rel="modulepreload" crossorigin href="./assets/_baseSet-CsW0tABf.js">
|
|
224
|
-
<link rel="modulepreload" crossorigin href="./assets/state-
|
|
224
|
+
<link rel="modulepreload" crossorigin href="./assets/state-XBSJaDlj.js">
|
|
225
225
|
<link rel="modulepreload" crossorigin href="./assets/label-BbRibkug.js">
|
|
226
|
-
<link rel="modulepreload" crossorigin href="./assets/textarea-
|
|
226
|
+
<link rel="modulepreload" crossorigin href="./assets/textarea-CIkM9ejr.js">
|
|
227
227
|
<link rel="modulepreload" crossorigin href="./assets/refresh-ccw-AYso5mC6.js">
|
|
228
|
-
<link rel="modulepreload" crossorigin href="./assets/form-
|
|
228
|
+
<link rel="modulepreload" crossorigin href="./assets/form-BAAziqSH.js">
|
|
229
229
|
<link rel="modulepreload" crossorigin href="./assets/renderShortcut-BV7Qf4L2.js">
|
|
230
|
-
<link rel="modulepreload" crossorigin href="./assets/useBoolean-
|
|
230
|
+
<link rel="modulepreload" crossorigin href="./assets/useBoolean-BqfyqCpr.js">
|
|
231
231
|
<link rel="modulepreload" crossorigin href="./assets/useDeepCompareMemoize-zUHU--0D.js">
|
|
232
232
|
<link rel="modulepreload" crossorigin href="./assets/types-D9gLS68B.js">
|
|
233
233
|
<link rel="modulepreload" crossorigin href="./assets/semaphore-FlZezxaf.js">
|
package/package.json
CHANGED
|
@@ -1082,3 +1082,23 @@ describe("renderCellValue with datetime values", () => {
|
|
|
1082
1082
|
});
|
|
1083
1083
|
});
|
|
1084
1084
|
});
|
|
1085
|
+
|
|
1086
|
+
test("column_widths sets fixed size and meta.width", () => {
|
|
1087
|
+
const cols = generateColumns({
|
|
1088
|
+
rowHeaders: [],
|
|
1089
|
+
selection: null,
|
|
1090
|
+
fieldTypes: [
|
|
1091
|
+
["a", ["number", "int64"]],
|
|
1092
|
+
["b", ["string", "str"]],
|
|
1093
|
+
],
|
|
1094
|
+
columnWidths: { a: 120 },
|
|
1095
|
+
});
|
|
1096
|
+
const a = cols.find((c) => c.id === "a");
|
|
1097
|
+
const b = cols.find((c) => c.id === "b");
|
|
1098
|
+
expect(a?.size).toBe(120);
|
|
1099
|
+
expect(a?.minSize).toBe(120);
|
|
1100
|
+
expect(a?.maxSize).toBe(120);
|
|
1101
|
+
expect(a?.meta?.width).toBe(120);
|
|
1102
|
+
expect(b?.size).toBeUndefined();
|
|
1103
|
+
expect(b?.meta?.width).toBeUndefined();
|
|
1104
|
+
});
|
|
@@ -118,6 +118,7 @@ export function generateColumns<T>({
|
|
|
118
118
|
showDataTypes,
|
|
119
119
|
calculateTopKRows,
|
|
120
120
|
fractionDigitsByColumn,
|
|
121
|
+
columnWidths,
|
|
121
122
|
}: {
|
|
122
123
|
rowHeaders: FieldTypesWithExternalType;
|
|
123
124
|
selection: DataTableSelection;
|
|
@@ -129,6 +130,7 @@ export function generateColumns<T>({
|
|
|
129
130
|
showDataTypes?: boolean;
|
|
130
131
|
calculateTopKRows?: CalculateTopKRows;
|
|
131
132
|
fractionDigitsByColumn?: Record<string, number>;
|
|
133
|
+
columnWidths?: Record<string, number>;
|
|
132
134
|
}): ColumnDef<T>[] {
|
|
133
135
|
// Row-headers are typically index columns
|
|
134
136
|
const rowHeadersSet = new Set(rowHeaders.map(([columnName]) => columnName));
|
|
@@ -311,7 +313,20 @@ export function generateColumns<T>({
|
|
|
311
313
|
// Can only sort if key is defined
|
|
312
314
|
// For example, unnamed index columns, won't be sortable
|
|
313
315
|
enableSorting: !!key,
|
|
314
|
-
meta:
|
|
316
|
+
meta: {
|
|
317
|
+
...getMeta(key),
|
|
318
|
+
width: columnWidths?.[key],
|
|
319
|
+
},
|
|
320
|
+
// size seeds the width before measurement; minSize/maxSize pin
|
|
321
|
+
// getSize() to the fixed width so the per-paint measurement writeback
|
|
322
|
+
// cannot drift the header width or sticky-pin offsets.
|
|
323
|
+
...(columnWidths?.[key] !== undefined
|
|
324
|
+
? {
|
|
325
|
+
size: columnWidths[key],
|
|
326
|
+
minSize: columnWidths[key],
|
|
327
|
+
maxSize: columnWidths[key],
|
|
328
|
+
}
|
|
329
|
+
: {}),
|
|
315
330
|
}),
|
|
316
331
|
);
|
|
317
332
|
|
|
@@ -141,6 +141,7 @@ export const DataTableBody = <TData,>({
|
|
|
141
141
|
const renderCells = (cells: Cell<TData, unknown>[]) => {
|
|
142
142
|
return cells.map((cell) => {
|
|
143
143
|
const { className, style: pinningstyle } = getPinningStyles(cell.column);
|
|
144
|
+
const fixedWidth = cell.column.columnDef.meta?.width;
|
|
144
145
|
const style = Object.assign(
|
|
145
146
|
{},
|
|
146
147
|
cell.getUserStyling?.() || {},
|
|
@@ -153,7 +154,8 @@ export const DataTableBody = <TData,>({
|
|
|
153
154
|
{...getCellDomProps(cell.id)}
|
|
154
155
|
key={cell.id}
|
|
155
156
|
className={cn(
|
|
156
|
-
"whitespace-pre truncate
|
|
157
|
+
"whitespace-pre truncate outline-hidden border-r border-r-border/75",
|
|
158
|
+
!fixedWidth && "max-w-[300px]",
|
|
157
159
|
cell.column.getColumnWrapping &&
|
|
158
160
|
cell.column.getColumnWrapping?.() === "wrap" &&
|
|
159
161
|
COLUMN_WRAPPING_STYLES,
|
|
@@ -297,6 +299,7 @@ function getPinningStyles<TData>(
|
|
|
297
299
|
isPinned === "left" && column.getIsLastColumn("left");
|
|
298
300
|
const isFirstRightPinnedColumn =
|
|
299
301
|
isPinned === "right" && column.getIsFirstColumn("right");
|
|
302
|
+
const fixedWidth = column.columnDef.meta?.width;
|
|
300
303
|
|
|
301
304
|
return {
|
|
302
305
|
className: cn(isPinned && "bg-inherit", "shadow-r z-10"),
|
|
@@ -313,6 +316,7 @@ function getPinningStyles<TData>(
|
|
|
313
316
|
position: isPinned ? "sticky" : "relative",
|
|
314
317
|
zIndex: isPinned ? 1 : 0,
|
|
315
318
|
width: column.getSize(),
|
|
319
|
+
...(fixedWidth ? { minWidth: fixedWidth, maxWidth: fixedWidth } : {}),
|
|
316
320
|
},
|
|
317
321
|
};
|
|
318
322
|
}
|
|
@@ -67,10 +67,6 @@ describe("StatusOverlay disconnect indicator", () => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
it.each([
|
|
70
|
-
[
|
|
71
|
-
WebSocketClosedReason.MALFORMED_QUERY,
|
|
72
|
-
"the kernel did not recognize a request; please file a bug with marimo",
|
|
73
|
-
],
|
|
74
70
|
[
|
|
75
71
|
WebSocketClosedReason.KERNEL_STARTUP_ERROR,
|
|
76
72
|
"Failed to start kernel sandbox",
|
|
@@ -22,9 +22,8 @@ export const StatusOverlay: React.FC<{
|
|
|
22
22
|
const { mode } = useAtomValue(viewStateAtom);
|
|
23
23
|
const isClosed = connection.state === WebSocketState.CLOSED;
|
|
24
24
|
const isOpen = connection.state === WebSocketState.OPEN;
|
|
25
|
-
// Only KERNEL_DISCONNECTED is recoverable by a retry.
|
|
26
|
-
//
|
|
27
|
-
// fail the same way.
|
|
25
|
+
// Only KERNEL_DISCONNECTED is recoverable by a retry. KERNEL_STARTUP_ERROR
|
|
26
|
+
// would deterministically fail the same way.
|
|
28
27
|
const canReconnect =
|
|
29
28
|
isClosed && connection.code === WebSocketClosedReason.KERNEL_DISCONNECTED;
|
|
30
29
|
|
|
@@ -32,7 +32,6 @@ describe("classifyCloseEvent", () => {
|
|
|
32
32
|
|
|
33
33
|
describe("terminal closes (server-initiated)", () => {
|
|
34
34
|
it.each([
|
|
35
|
-
"MARIMO_WRONG_KERNEL_ID",
|
|
36
35
|
"MARIMO_NO_FILE_KEY",
|
|
37
36
|
"MARIMO_NO_SESSION_ID",
|
|
38
37
|
"MARIMO_NO_SESSION",
|
|
@@ -49,18 +48,6 @@ describe("classifyCloseEvent", () => {
|
|
|
49
48
|
}
|
|
50
49
|
});
|
|
51
50
|
|
|
52
|
-
it("MARIMO_MALFORMED_QUERY → terminal but does NOT close transport", () => {
|
|
53
|
-
const decision = classify("MARIMO_MALFORMED_QUERY");
|
|
54
|
-
expect(decision.kind).toBe("terminal");
|
|
55
|
-
expect(decision.status).toMatchObject({
|
|
56
|
-
state: WebSocketState.CLOSED,
|
|
57
|
-
code: WebSocketClosedReason.MALFORMED_QUERY,
|
|
58
|
-
});
|
|
59
|
-
if (decision.kind === "terminal") {
|
|
60
|
-
expect(decision.closeTransport).toBe(false);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
51
|
it("MARIMO_KERNEL_STARTUP_ERROR → terminal + closeTransport", () => {
|
|
65
52
|
const decision = classify("MARIMO_KERNEL_STARTUP_ERROR");
|
|
66
53
|
expect(decision.kind).toBe("terminal");
|
|
@@ -82,12 +82,10 @@ const SUPPORTS_LAZY_KERNELS = true;
|
|
|
82
82
|
// (marimo/_server/api/endpoints/ws_endpoint.py and ws/*.py). Keep in sync with
|
|
83
83
|
// the backend literals.
|
|
84
84
|
export type CloseReason =
|
|
85
|
-
| "MARIMO_WRONG_KERNEL_ID"
|
|
86
85
|
| "MARIMO_NO_FILE_KEY"
|
|
87
86
|
| "MARIMO_NO_SESSION_ID"
|
|
88
87
|
| "MARIMO_NO_SESSION"
|
|
89
88
|
| "MARIMO_SHUTDOWN"
|
|
90
|
-
| "MARIMO_MALFORMED_QUERY"
|
|
91
89
|
| "MARIMO_KERNEL_STARTUP_ERROR"
|
|
92
90
|
| typeof TRANSPORT_EXHAUSTED_REASON;
|
|
93
91
|
|
|
@@ -107,7 +105,6 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {
|
|
|
107
105
|
reason: "kernel not found",
|
|
108
106
|
},
|
|
109
107
|
};
|
|
110
|
-
case "MARIMO_WRONG_KERNEL_ID":
|
|
111
108
|
case "MARIMO_NO_FILE_KEY":
|
|
112
109
|
case "MARIMO_NO_SESSION_ID":
|
|
113
110
|
case "MARIMO_NO_SESSION":
|
|
@@ -121,17 +118,6 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {
|
|
|
121
118
|
},
|
|
122
119
|
closeTransport: true,
|
|
123
120
|
};
|
|
124
|
-
case "MARIMO_MALFORMED_QUERY":
|
|
125
|
-
return {
|
|
126
|
-
kind: "terminal",
|
|
127
|
-
status: {
|
|
128
|
-
state: WebSocketState.CLOSED,
|
|
129
|
-
code: WebSocketClosedReason.MALFORMED_QUERY,
|
|
130
|
-
reason:
|
|
131
|
-
"the kernel did not recognize a request; please file a bug with marimo",
|
|
132
|
-
},
|
|
133
|
-
closeTransport: false,
|
|
134
|
-
};
|
|
135
121
|
case "MARIMO_KERNEL_STARTUP_ERROR":
|
|
136
122
|
return {
|
|
137
123
|
kind: "terminal",
|
|
@@ -195,6 +195,7 @@ interface Data<T> {
|
|
|
195
195
|
hiddenColumns?: string[];
|
|
196
196
|
textJustifyColumns?: Record<string, "left" | "center" | "right">;
|
|
197
197
|
wrappedColumns?: string[];
|
|
198
|
+
columnWidths?: Record<string, number>;
|
|
198
199
|
headerTooltip?: Record<string, string>;
|
|
199
200
|
totalColumns: number;
|
|
200
201
|
maxColumns: number | "all";
|
|
@@ -274,6 +275,9 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")
|
|
|
274
275
|
.record(z.string(), z.enum(["left", "center", "right"]))
|
|
275
276
|
.optional(),
|
|
276
277
|
wrappedColumns: z.array(z.string()).optional(),
|
|
278
|
+
columnWidths: z
|
|
279
|
+
.record(z.string(), z.number().int().positive())
|
|
280
|
+
.optional(),
|
|
277
281
|
headerTooltip: z.record(z.string(), z.string()).optional(),
|
|
278
282
|
fieldTypes: columnToFieldTypesSchema.nullish(),
|
|
279
283
|
totalColumns: z.number(),
|
|
@@ -848,6 +852,7 @@ const DataTableComponent = ({
|
|
|
848
852
|
hiddenColumns,
|
|
849
853
|
textJustifyColumns,
|
|
850
854
|
wrappedColumns,
|
|
855
|
+
columnWidths,
|
|
851
856
|
headerTooltip,
|
|
852
857
|
totalColumns,
|
|
853
858
|
get_row_ids,
|
|
@@ -935,6 +940,7 @@ const DataTableComponent = ({
|
|
|
935
940
|
const memoizedRowHeaders = useDeepCompareMemoize(rowHeaders);
|
|
936
941
|
const memoizedTextJustifyColumns = useDeepCompareMemoize(textJustifyColumns);
|
|
937
942
|
const memoizedWrappedColumns = useDeepCompareMemoize(wrappedColumns);
|
|
943
|
+
const memoizedColumnWidths = useDeepCompareMemoize(columnWidths);
|
|
938
944
|
const memoizedChartSpecModel = useDeepCompareMemoize(chartSpecModel);
|
|
939
945
|
const fractionDigitsByColumn = useDeepCompareMemoize(computedFractionDigits);
|
|
940
946
|
const shownColumns = memoizedClampedFieldTypes.length;
|
|
@@ -953,6 +959,7 @@ const DataTableComponent = ({
|
|
|
953
959
|
fieldTypes: memoizedClampedFieldTypes,
|
|
954
960
|
textJustifyColumns: memoizedTextJustifyColumns,
|
|
955
961
|
wrappedColumns: memoizedWrappedColumns,
|
|
962
|
+
columnWidths: memoizedColumnWidths,
|
|
956
963
|
headerTooltip: headerTooltip,
|
|
957
964
|
// Only show data types if they are explicitly set
|
|
958
965
|
showDataTypes: showDataTypes,
|
|
@@ -967,6 +974,7 @@ const DataTableComponent = ({
|
|
|
967
974
|
memoizedClampedFieldTypes,
|
|
968
975
|
memoizedTextJustifyColumns,
|
|
969
976
|
memoizedWrappedColumns,
|
|
977
|
+
memoizedColumnWidths,
|
|
970
978
|
headerTooltip,
|
|
971
979
|
calculate_top_k_rows,
|
|
972
980
|
fractionDigitsByColumn,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var S=Object.defineProperty;var g=(t,e,r)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var m=(t,e,r)=>g(t,typeof e!="symbol"?e+"":e,r);import{i as O,l as y,n as C,o as A,p as i,u as P}from"./useEvent-D91BmmQi.js";import{t as I}from"./compiler-runtime-B3qBwwSJ.js";import{_ as c}from"./useEventListener-BfYriKqt.js";import{t as _}from"./invariant-C2E8KCbD.js";import{t as D}from"./utils-BGFUZat2.js";import{r as h}from"./constants-B9JJ72XE.js";import{t as k}from"./Deferred-CfyqLOPG.js";import{t as R}from"./session-DF0gSADo.js";function L(){return typeof document<"u"&&document.querySelector("marimo-wasm")!==null}const a={NOT_STARTED:"NOT_STARTED",CONNECTING:"CONNECTING",OPEN:"OPEN",CLOSING:"CLOSING",CLOSED:"CLOSED"},b={KERNEL_DISCONNECTED:"KERNEL_DISCONNECTED",MALFORMED_QUERY:"MALFORMED_QUERY",KERNEL_STARTUP_ERROR:"KERNEL_STARTUP_ERROR"},o=i({state:a.NOT_STARTED});function v(){return A(o,t=>t.state===a.OPEN)}const H=i(t=>t(o).state===a.CONNECTING);i(t=>t(o).state===a.OPEN);const W=i(t=>{let e=t(o);return e.state===a.OPEN||e.state===a.NOT_STARTED}),G=i(t=>t(o).state===a.CLOSED),M=i(t=>t(o).state===a.NOT_STARTED);function $(t){return t===a.CLOSED}function z(t){return t===a.CONNECTING}function F(t){return t===a.OPEN}function j(t){return t===a.CLOSING}function p(t){return t===a.NOT_STARTED}function K(t){return t===a.CLOSED||t===a.CLOSING||t===a.CONNECTING}function B(t){switch(t){case a.CLOSED:return"App disconnected";case a.CONNECTING:return"Connecting to a runtime ...";case a.CLOSING:return"App disconnecting...";case a.OPEN:return"";case a.NOT_STARTED:return"Click to connect to a runtime";default:return""}}function Q(t){if(typeof t!="object"||!t||Array.isArray(t))return!1;for(let e of Object.values(t))if(typeof e!="string")return!1;return!0}function x(t){if(typeof t!="object"||!t||Array.isArray(t))return!1;let e=t;return!(!Q(e.files)||e.modelNotifications!==void 0&&!Array.isArray(e.modelNotifications))}function f(){let t=typeof window>"u"?void 0:window.__MARIMO_STATIC__;return x(t)?t:void 0}function w(){return f()!==void 0}function q(){let t=f();return _(t!==void 0,"Not a static notebook"),t.files}function Y(){var t;return(t=f())==null?void 0:t.modelNotifications}var V=class{constructor(t,e=!1){m(this,"initialHealthyCheck",new k);this.config=t,this.lazy=e;try{new URL(this.config.url)}catch(r){throw Error(`Invalid runtime URL: ${this.config.url}. ${r instanceof Error?r.message:"Unknown error"}`,{cause:r})}this.lazy||this.init()}get isLazy(){return this.lazy}get httpURL(){return new URL(this.config.url)}get isSameOrigin(){return this.httpURL.origin===window.location.origin}get isServerless(){return L()||D()||w()}formatHttpURL({path:t="",searchParams:e,restrictToKnownQueryParams:r=!0}){let n=this.httpURL,s=new URLSearchParams(window.location.search);if(e)for(let[u,l]of e.entries())n.searchParams.set(u,l);for(let[u,l]of s.entries())r&&!Object.values(h).includes(u)||n.searchParams.set(u,l);return n.pathname=`${n.pathname.replace(/\/$/,"")}/${t.replace(/^\//,"")}`,n.hash="",n}formatWsURL(t,e){let r=this.formatHttpURL({path:t,searchParams:e,restrictToKnownQueryParams:!1});return!this.isSameOrigin&&this.config.authToken&&r.searchParams.set(h.accessToken,this.config.authToken),J(r.toString())}getWsURL(t){let e=new URL(this.config.url),r=new URLSearchParams(e.search);return new URLSearchParams(window.location.search).forEach((n,s)=>{r.has(s)||r.set(s,n)}),r.set(h.sessionId,t),this.formatWsURL("/ws",r)}getWsSyncURL(t){let e=new URL(this.config.url),r=new URLSearchParams(e.search);return new URLSearchParams(window.location.search).forEach((n,s)=>{r.has(s)||r.set(s,n)}),r.set(h.sessionId,t),this.formatWsURL("/ws_sync",r)}getTerminalWsURL(){return this.formatWsURL("/terminal/ws")}getLSPURL(t){if(t==="copilot"){let e=this.formatWsURL(`/lsp/${t}`),r=e.searchParams.get(h.accessToken);return e.search="",r&&e.searchParams.set(h.accessToken,r),e}return this.formatWsURL(`/lsp/${t}`)}getAiURL(t){return this.formatHttpURL({path:`/api/ai/${t}`})}healthURL(){return this.formatHttpURL({path:"/health"})}async fetchHealth(){try{return await fetch(this.healthURL().toString())}catch(t){return c.error(`Failed to check health: ${t instanceof Error?t.message:"Unknown error"}`,{cause:t}),null}}async reconcileFromHealth(){if(this.isServerless)return!0;let t=await this.fetchHealth();if(!t)return!1;if(t.redirected){c.debug(`Runtime redirected to ${t.url}`);let e=new URL(t.url);e.pathname=e.pathname.replace(/\/health$/,""),this.config.url=e.toString()}return t.ok&&this.setDOMBaseUri(this.config.url),t.ok}async probeHealth(){var t;return this.isServerless?!0:((t=await this.fetchHealth())==null?void 0:t.ok)??!1}setDOMBaseUri(t){t=t.split("?",1)[0],t.endsWith("/")||(t+="/");let e=document.querySelector("base");e?e.setAttribute("href",t):(e=document.createElement("base"),e.setAttribute("href",t),document.head.append(e))}async init(t){c.debug("Initializing runtime...");let e=0;for(;!await this.reconcileFromHealth();){if(e>=25){c.error("Failed to connect after 25 retries"),this.initialHealthyCheck.reject(Error("Failed to connect after 25 retries"));return}if(!(t!=null&&t.disableRetryDelay)){let r=Math.min(100*1.2**e,2e3);await new Promise(n=>setTimeout(n,r))}e++}c.debug("Runtime is healthy"),this.initialHealthyCheck.resolve()}async waitForHealthy(){return this.initialHealthyCheck.promise}headers(){let t={"Marimo-Session-Id":R(),"Marimo-Server-Token":this.config.serverToken??"","x-runtime-url":this.httpURL.toString()};return this.config.authToken&&(t.Authorization=`Bearer ${this.config.authToken}`),t}sessionHeaders(){return{"Marimo-Session-Id":R()}}};function J(t){if(!t.startsWith("http")){c.warn(`URL must start with http: ${t}`);let e=new URL(t);return e.protocol="ws",e}return new URL(t.replace(/^http/,"ws"))}var X=I();function Z(){let t=new URL(document.baseURI);return t.search="",t.hash="",t.toString()}const E={lazy:!0,url:Z()},N=i(E);var T=i(t=>{let e=t(N);return new V(e,e.lazy)});function d(){return P(T)}function tt(){let t=(0,X.c)(4),e=d(),[r,n]=y(o),s;return t[0]!==r.state||t[1]!==e||t[2]!==n?(s=async()=>{p(r.state)?(n({state:a.CONNECTING}),await e.init()):c.log("Runtime already started or starting...")},t[0]=r.state,t[1]=e,t[2]=n,t[3]=s):s=t[3],C(s)}function U(){return O.get(T)}function et(t){if(t.startsWith("http"))return new URL(t);let e=U().httpURL.toString();return e.startsWith("blob:")&&(e=e.replace("blob:","")),new URL(t,e)}export{b as C,v as S,L as T,W as _,tt as a,H as b,q as c,$ as d,j as f,p as g,K as h,N as i,w as l,z as m,et as n,d as o,F as p,U as r,Y as s,E as t,B as u,o as v,a as w,M as x,G as y};
|