@marimo-team/islands 0.24.1-dev30 → 0.24.1-dev32

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.
@@ -36337,7 +36337,7 @@ ${d}`,
36337
36337
  return Logger.warn("Failed to get version from mount config"), null;
36338
36338
  }
36339
36339
  }
36340
- marimoVersionAtom = atom(getVersionFromMountConfig() || "0.24.1-dev30");
36340
+ marimoVersionAtom = atom(getVersionFromMountConfig() || "0.24.1-dev32");
36341
36341
  showCodeInRunModeAtom = atom(true);
36342
36342
  atom(null);
36343
36343
  var import_compiler_runtime = require_compiler_runtime();
package/dist/main.js CHANGED
@@ -26,7 +26,7 @@ import { $ as notebookOutline, $t as isUninstantiated, A as ChevronDownIcon, An
26
26
  import { __tla as __tla_1 } from "./chunk-5FQGJX7Z-BRZ_XYUw.js";
27
27
  import { o as useSize, s as Root$1, u as createLucideIcon } from "./dist-j30bBjjN.js";
28
28
  import { A as SquareFunction, C as DEFAULT_COLOR_SCHEME, D as SCALE_TYPE_DESCRIPTIONS, E as EMPTY_VALUE$1, O as TIME_UNIT_DESCRIPTIONS, S as DEFAULT_AGGREGATION, T as DEFAULT_TIME_UNIT, _ as AGGREGATION_TYPE_DESCRIPTIONS, a as AGGREGATION_FNS, b as COLOR_SCHEMES, c as COLOR_BY_FIELDS, d as NONE_VALUE, f as SELECTABLE_DATA_TYPES, g as TIME_UNITS, h as STRING_AGGREGATION_FNS, i as convertDataTypeToSelectable, j as ChartColumn, k as escapeFieldName, l as COMBINED_TIME_UNITS, m as SORT_TYPES, n as createSpecWithoutData, o as BIN_AGGREGATION, p as SINGLE_TIME_UNITS, r as isFieldSet, s as CHART_TYPES, t as augmentSpecWithData, u as ChartType, v as AGGREGATION_TYPE_ICON, w as DEFAULT_MAX_BINS_FACET, x as COUNT_FIELD, y as CHART_TYPE_ICON } from "./spec-DR1CyTOo.js";
29
- import { $ as CommandSeparator, $t as Kbd, A as ErrorState, At as getPageIndexForRow, B as ContextMenuTrigger, Bt as dateToLocalISODate, C as downloadHTMLAsImage, Ct as inferFieldTypes, D as ColumnName, Dt as DelayMount, E as downloadSizeLimitAtom, Et as ColumnChartSpecModel, F as getUserColumnVisibilityCounts, Ft as TOO_MANY_ROWS, G as DateRangePicker, Gt as TabsList, H as useSelectList, Ht as dateToLocalISOTime, I as ContextMenu, It as toFieldTypes, J as Command, Jt as ChartInfoState, K as Combobox, Kt as TabsTrigger, L as ContextMenuContent, Lt as getMimeValues, M as prettifyRowColumnCount, Mt as loadTableData, N as prettifyRowCount, Nt as INDEX_COLUMN_NAME, O as ColumnPreviewContainer, Ot as useIntersectionObserver, P as getColumnCountForDisplay, Pt as SELECT_COLUMN_ID, Q as CommandList, Qt as RenderTextWithLinks, R as ContextMenuItem, Rt as isNullishFilter, S as downloadExportedFile, St as generateColumns, T as Filenames, Tt as ColumnChartContext, U as CompactChipRow, Ut as Tabs, V as useInternalStateWithSync, Vt as dateToLocalISODateTime, W as DatePicker, Wt as TabsContent, X as CommandInput, Xt as LazyVegaEmbed, Y as CommandEmpty, Yt as ChartLoadingState, Z as CommandItem, Zt as useOverflowDetection, _ as DataTable, _n as ChevronLeft, _t as TableCell, an as TextWrap, at as contextAwarePanelType, b as downloadBlob, bt as TableRow, c as SLIDE_TYPE_OPTIONS_BY_VALUE, cn as EyeOff, ct as slotsController, d as Switch, dn as Download, en as HtmlOutput, et as smartMatch, f as RadioGroup, fn as Code, g as OutputRenderer, gn as ChevronsDownUp, gt as TableBody, h as OutputArea, hn as ChevronsLeft, ht as Table, i as showCodeInRunModeAtom, in as $fae977aafc393c5c$export$6b862160d295c8e, it as contextAwarePanelOwner, j as LoadingState, jt as loadTableAndRawData, k as EmptyState, kt as usePrevious$1, lt as Toggle, m as JsonOutput, mn as ChevronsRight, mt as Provider$1, n as useNotebookCodeAvailable, nn as safeLocale, nt as PANEL_TYPES, on as GripHorizontal, ot as isCellAwareAtom, p as RadioGroupItem, pn as ChevronsUpDown, pt as Fill, q as ComboboxItem, qt as ChartErrorState, r as marimoVersionAtom, rn as $fae977aafc393c5c$export$588937bcd60ade55, rt as contextAwarePanelOpen, sn as Funnel, st as SlotNames, t as cellDomProps, tn as EmotionCacheProvider, tt as ContextAwarePanelItem, u as Slide, un as Ellipsis, v as InstallPackageButton, vn as ArrowDownWideNarrow, vt as TableHead, w as Progress, wt as renderCellValue, x as downloadByURL, xt as NAMELESS_COLUMN_PREFIX, y as ADD_PRINTING_CLASS, yt as TableHeader, z as ContextMenuSeparator, zt as Maps, __tla as __tla_2 } from "./common-Cy9zypnG.js";
29
+ import { $ as CommandSeparator, $t as Kbd, A as ErrorState, At as getPageIndexForRow, B as ContextMenuTrigger, Bt as dateToLocalISODate, C as downloadHTMLAsImage, Ct as inferFieldTypes, D as ColumnName, Dt as DelayMount, E as downloadSizeLimitAtom, Et as ColumnChartSpecModel, F as getUserColumnVisibilityCounts, Ft as TOO_MANY_ROWS, G as DateRangePicker, Gt as TabsList, H as useSelectList, Ht as dateToLocalISOTime, I as ContextMenu, It as toFieldTypes, J as Command, Jt as ChartInfoState, K as Combobox, Kt as TabsTrigger, L as ContextMenuContent, Lt as getMimeValues, M as prettifyRowColumnCount, Mt as loadTableData, N as prettifyRowCount, Nt as INDEX_COLUMN_NAME, O as ColumnPreviewContainer, Ot as useIntersectionObserver, P as getColumnCountForDisplay, Pt as SELECT_COLUMN_ID, Q as CommandList, Qt as RenderTextWithLinks, R as ContextMenuItem, Rt as isNullishFilter, S as downloadExportedFile, St as generateColumns, T as Filenames, Tt as ColumnChartContext, U as CompactChipRow, Ut as Tabs, V as useInternalStateWithSync, Vt as dateToLocalISODateTime, W as DatePicker, Wt as TabsContent, X as CommandInput, Xt as LazyVegaEmbed, Y as CommandEmpty, Yt as ChartLoadingState, Z as CommandItem, Zt as useOverflowDetection, _ as DataTable, _n as ChevronLeft, _t as TableCell, an as TextWrap, at as contextAwarePanelType, b as downloadBlob, bt as TableRow, c as SLIDE_TYPE_OPTIONS_BY_VALUE, cn as EyeOff, ct as slotsController, d as Switch, dn as Download, en as HtmlOutput, et as smartMatch, f as RadioGroup, fn as Code, g as OutputRenderer, gn as ChevronsDownUp, gt as TableBody, h as OutputArea, hn as ChevronsLeft, ht as Table, i as showCodeInRunModeAtom, in as $fae977aafc393c5c$export$6b862160d295c8e, it as contextAwarePanelOwner, j as LoadingState, jt as loadTableAndRawData, k as EmptyState, kt as usePrevious$1, lt as Toggle, m as JsonOutput, mn as ChevronsRight, mt as Provider$1, n as useNotebookCodeAvailable, nn as safeLocale, nt as PANEL_TYPES, on as GripHorizontal, ot as isCellAwareAtom, p as RadioGroupItem, pn as ChevronsUpDown, pt as Fill, q as ComboboxItem, qt as ChartErrorState, r as marimoVersionAtom, rn as $fae977aafc393c5c$export$588937bcd60ade55, rt as contextAwarePanelOpen, sn as Funnel, st as SlotNames, t as cellDomProps, tn as EmotionCacheProvider, tt as ContextAwarePanelItem, u as Slide, un as Ellipsis, v as InstallPackageButton, vn as ArrowDownWideNarrow, vt as TableHead, w as Progress, wt as renderCellValue, x as downloadByURL, xt as NAMELESS_COLUMN_PREFIX, y as ADD_PRINTING_CLASS, yt as TableHeader, z as ContextMenuSeparator, zt as Maps, __tla as __tla_2 } from "./common-nFz87Uyp.js";
30
30
  import { c as Calendar, i as createReducerAndAtoms, n as useOnUnmount, o as ToggleLeft, t as useOnMount } from "./useLifecycle-Bw4wRj_O.js";
31
31
  import { t as Check } from "./check-58HHfHKy.js";
32
32
  import { A as Icon, C as logNever, D as $18f2051aff69b9bf$export$a54013f0d02a8f82, E as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7, F as createCollection, I as X, M as clamp$2, N as usePrevious$2, P as useDirection, R as ChevronDown, S as assertNever, a as SelectGroup, c as SelectSeparator, d as NativeSelect, i as SelectContent, j as Trigger$1, l as SelectTrigger, n as capitalize, o as SelectItem, r as Select, s as SelectLabel, t as Strings, u as SelectValue, w as $a916eb452884faea$export$b7a616150fdb9f44 } from "./strings-DMLVGXRo.js";
@@ -97,7 +97,7 @@ let __tla = Promise.all([
97
97
  }
98
98
  })()
99
99
  ]).then(async () => {
100
- var _a, _e2, _t2, _n2, _r, _i, _e_instances, a_fn, o_fn, s_fn, _c, _b, _e3, _WidgetDefRegistry_instances, t_fn, _c2, _e4, _t3, _n3, _r2, _i2, _a2, _o2, _e_instances2, s_fn2, c_fn, _d, _e5, _t4, _n4, _r3, _i3, _a3, _o3, _s, _c3, _l, _u, _d2, _f, _p, _WidgetRuntime_instances, m_fn, h_fn, g_fn, __fn, v_fn, y_fn, b_fn, x_fn, _e6, _e7, _t5, _n5, _instances, r_fn, _f2, _e8, _t6, _n6, _r4, _i4, _a4, _o4, _s2, _MatplotlibRenderer_instances, c_fn2, l_fn, u_fn, _d3, _f3, _p2, _m, _h, _g, __, _v, _y, _b2, _x, _S, _C, _w, _g2, _h2;
100
+ var _a, _e2, _t2, _n2, _r, _i, _e_instances, a_fn, o_fn, s_fn, _c, _b, _e3, _WidgetDefRegistry_instances, t_fn, _c2, _e4, _t3, _n3, _r2, _i2, _a2, _o2, _e_instances2, s_fn2, c_fn, _d, _e5, _t4, _n4, _r3, _i3, _a3, _o3, _s, _c3, _l, _u, _d2, _f, _p, _WidgetRuntime_instances, m_fn, h_fn, g_fn, __fn, v_fn, y_fn, b_fn, x_fn, _e6, _e7, _t5, _n5, _instances, r_fn, _f2, _e8, _t6, _n6, _r4, _i4, _a4, _o4, _s2, _c4, _MatplotlibRenderer_instances, l_fn, u_get, _d3, f_fn, p_fn, _m, _h, _g, __, _v, _y, _b2, _x, _S, _C, _w, _T, _E, _D, _g2, _h2;
101
101
  var defaultIconDimensions = Object.freeze({
102
102
  left: 0,
103
103
  top: 0,
@@ -11500,7 +11500,7 @@ ${indent(e)}
11500
11500
  return r.length === 0 ? [] : r.map(([e2, r2]) => new FunctionArg(e2, r2));
11501
11501
  }
11502
11502
  function generateAltairChart(e, r) {
11503
- var _a5, _b3, _c4;
11503
+ var _a5, _b3, _c5;
11504
11504
  let c = new FunctionCall("alt.Chart", [
11505
11505
  new Variable(r)
11506
11506
  ], true);
@@ -11524,7 +11524,7 @@ ${indent(e)}
11524
11524
  }
11525
11525
  if (e.resolve) {
11526
11526
  let r2 = e.resolve, l2 = {};
11527
- ((_b3 = r2.axis) == null ? void 0 : _b3.x) && (l2.x = new Literal(r2.axis.x)), ((_c4 = r2.axis) == null ? void 0 : _c4.y) && (l2.y = new Literal(r2.axis.y)), c = c.chain("resolve_scale", l2);
11527
+ ((_b3 = r2.axis) == null ? void 0 : _b3.x) && (l2.x = new Literal(r2.axis.x)), ((_c5 = r2.axis) == null ? void 0 : _c5.y) && (l2.y = new Literal(r2.axis.y)), c = c.chain("resolve_scale", l2);
11528
11528
  }
11529
11529
  let l = {};
11530
11530
  for (let r2 of [
@@ -13942,14 +13942,14 @@ ${c}
13942
13942
  defaultValue: f
13943
13943
  }), r[1] = c, r[2] = l, r[3] = f, r[4] = p) : p = r[4], p;
13944
13944
  }, BinFields = (e) => {
13945
- var _a5, _b3, _c4, _d4;
13945
+ var _a5, _b3, _c5, _d4;
13946
13946
  let r = (0, import_compiler_runtime$68.c)(10), { fieldName: c } = e, l = useFormContext(), u;
13947
13947
  r[0] === l.control ? u = r[1] : (u = {
13948
13948
  control: l.control
13949
13949
  }, r[0] = l.control, r[1] = u);
13950
13950
  let d = useWatch(u);
13951
13951
  if (!((_b3 = (_a5 = d[c]) == null ? void 0 : _a5.bin) == null ? void 0 : _b3.binned)) return null;
13952
- let f = !Number.isNaN((_d4 = (_c4 = d[c]) == null ? void 0 : _c4.bin) == null ? void 0 : _d4.step), p = `${c}.bin.step`, m;
13952
+ let f = !Number.isNaN((_d4 = (_c5 = d[c]) == null ? void 0 : _c5.bin) == null ? void 0 : _d4.step), p = `${c}.bin.step`, m;
13953
13953
  r[2] === p ? m = r[3] : (m = (0, import_jsx_runtime.jsx)(NumberField$1, {
13954
13954
  fieldName: p,
13955
13955
  label: "Bin step",
@@ -14164,7 +14164,7 @@ ${c}
14164
14164
  }), r[7] = c, r[8] = f, r[9] = p) : p = r[9], p;
14165
14165
  };
14166
14166
  const XAxis = () => {
14167
- var _a5, _b3, _c4, _d4, _e9, _f4, _g3;
14167
+ var _a5, _b3, _c5, _d4, _e9, _f3, _g3;
14168
14168
  let e = (0, import_compiler_runtime$67.c)(22), r = useFormContext(), c;
14169
14169
  e[0] === r.control ? c = e[1] : (c = {
14170
14170
  control: r.control
@@ -14194,7 +14194,7 @@ ${c}
14194
14194
  label: "Time Resolution"
14195
14195
  }), e[11] = d, e[12] = v);
14196
14196
  let y;
14197
- e[13] !== m || e[14] !== ((_c4 = (_b3 = l.general) == null ? void 0 : _b3.xColumn) == null ? void 0 : _c4.sort) || e[15] !== d ? (y = isNonCountField(d) && m && (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
14197
+ e[13] !== m || e[14] !== ((_c5 = (_b3 = l.general) == null ? void 0 : _b3.xColumn) == null ? void 0 : _c5.sort) || e[15] !== d ? (y = isNonCountField(d) && m && (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
14198
14198
  children: [
14199
14199
  (0, import_jsx_runtime.jsx)(SortField, {
14200
14200
  fieldName: "general.xColumn.sort",
@@ -14205,7 +14205,7 @@ ${c}
14205
14205
  fieldName: "xAxis"
14206
14206
  })
14207
14207
  ]
14208
- }), e[13] = m, e[14] = (_g3 = (_f4 = l.general) == null ? void 0 : _f4.xColumn) == null ? void 0 : _g3.sort, e[15] = d, e[16] = y) : y = e[16];
14208
+ }), e[13] = m, e[14] = (_g3 = (_f3 = l.general) == null ? void 0 : _f3.xColumn) == null ? void 0 : _g3.sort, e[15] = d, e[16] = y) : y = e[16];
14209
14209
  let b;
14210
14210
  return e[17] !== g || e[18] !== _ || e[19] !== v || e[20] !== y ? (b = (0, import_jsx_runtime.jsxs)(FieldSection, {
14211
14211
  children: [
@@ -14217,14 +14217,14 @@ ${c}
14217
14217
  ]
14218
14218
  }), e[17] = g, e[18] = _, e[19] = v, e[20] = y, e[21] = b) : b = e[21], b;
14219
14219
  }, YAxis = () => {
14220
- var _a5, _b3, _c4;
14220
+ var _a5, _b3, _c5;
14221
14221
  let e = (0, import_compiler_runtime$67.c)(29), r = useFormContext(), c;
14222
14222
  e[0] === r.control ? c = e[1] : (c = {
14223
14223
  control: r.control
14224
14224
  }, e[0] = r.control, e[1] = c);
14225
14225
  let l = useWatch(c), u = useChartFormContext(), d = (_a5 = l.general) == null ? void 0 : _a5.yColumn, f = d == null ? void 0 : d.field, p;
14226
14226
  e[2] === f ? p = e[3] : (p = isFieldSet(f), e[2] = f, e[3] = p);
14227
- let m = p, h = (_c4 = (_b3 = l.general) == null ? void 0 : _b3.xColumn) == null ? void 0 : _c4.field, g;
14227
+ let m = p, h = (_c5 = (_b3 = l.general) == null ? void 0 : _b3.xColumn) == null ? void 0 : _c5.field, g;
14228
14228
  e[4] === h ? g = e[5] : (g = isFieldSet(h), e[4] = h, e[5] = g);
14229
14229
  let _ = g, v;
14230
14230
  e[6] === d ? v = e[7] : (v = getColumnDataTypes(d), e[6] = d, e[7] = v);
@@ -14656,14 +14656,14 @@ ${c}
14656
14656
  }
14657
14657
  var import_compiler_runtime$65 = require_compiler_runtime();
14658
14658
  const HeatmapForm = () => {
14659
- var _a5, _b3, _c4, _d4;
14659
+ var _a5, _b3, _c5, _d4;
14660
14660
  let e = (0, import_compiler_runtime$65.c)(17), r = useFormContext(), c;
14661
14661
  e[0] === r.control ? c = e[1] : (c = {
14662
14662
  control: r.control
14663
14663
  }, e[0] = r.control, e[1] = c);
14664
14664
  let l = useWatch(c), u = (_b3 = (_a5 = l.general) == null ? void 0 : _a5.xColumn) == null ? void 0 : _b3.field, d;
14665
14665
  e[2] === u ? d = e[3] : (d = isFieldSet(u), e[2] = u, e[3] = d);
14666
- let f = d, p = (_d4 = (_c4 = l.general) == null ? void 0 : _c4.yColumn) == null ? void 0 : _d4.field, m;
14666
+ let f = d, p = (_d4 = (_c5 = l.general) == null ? void 0 : _c5.yColumn) == null ? void 0 : _d4.field, m;
14667
14667
  e[4] === p ? m = e[5] : (m = isFieldSet(p), e[4] = p, e[5] = m);
14668
14668
  let h = m, g;
14669
14669
  e[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (g = (0, import_jsx_runtime.jsx)(XAxis, {}), e[6] = g) : g = e[6];
@@ -14702,12 +14702,12 @@ ${c}
14702
14702
  };
14703
14703
  var import_compiler_runtime$64 = require_compiler_runtime();
14704
14704
  const PieForm = () => {
14705
- var _a5, _b3, _c4;
14705
+ var _a5, _b3, _c5;
14706
14706
  let e = (0, import_compiler_runtime$64.c)(25), r = useFormContext(), { fields: c } = useChartFormContext(), l;
14707
14707
  e[0] === r.control ? l = e[1] : (l = {
14708
14708
  control: r.control
14709
14709
  }, e[0] = r.control, e[1] = l);
14710
- let u = useWatch(l), d = (_a5 = u.general) == null ? void 0 : _a5.colorByColumn, f = (_c4 = (_b3 = u.general) == null ? void 0 : _b3.yColumn) == null ? void 0 : _c4.selectedDataType;
14710
+ let u = useWatch(l), d = (_a5 = u.general) == null ? void 0 : _a5.colorByColumn, f = (_c5 = (_b3 = u.general) == null ? void 0 : _b3.yColumn) == null ? void 0 : _c5.selectedDataType;
14711
14711
  (f === "" || !f) && (f = "string");
14712
14712
  let p;
14713
14713
  e[2] === d ? p = e[3] : (p = (d == null ? void 0 : d.type) ? convertDataTypeToSelectable(d.type) : "string", e[2] = d, e[3] = p);
@@ -26245,13 +26245,17 @@ ${c}
26245
26245
  __privateAdd(this, _a4, null);
26246
26246
  __privateAdd(this, _o4, 0);
26247
26247
  __privateAdd(this, _s2, "");
26248
+ __privateAdd(this, _c4, 1);
26248
26249
  __privateAdd(this, _d3, () => {
26250
+ (globalThis.devicePixelRatio ?? 1) !== __privateGet(this, _c4) && (__privateMethod(this, _MatplotlibRenderer_instances, l_fn).call(this), __privateGet(this, _h).call(this));
26251
+ });
26252
+ __privateAdd(this, _m, () => {
26249
26253
  let e = __privateGet(this, _a4);
26250
26254
  if (!e) return;
26251
26255
  let r = __privateGet(this, _e8).getContext("2d");
26252
26256
  if (!r) return;
26253
- let c = __privateGet(this, _n6), l = __privateGet(this, _r4), u = globalThis.devicePixelRatio ?? 1;
26254
- if (r.setTransform(u, 0, 0, u, 0, 0), r.clearRect(0, 0, c.width, c.height), r.drawImage(e, 0, 0, c.width, c.height), l.type === "box") {
26257
+ let c = __privateGet(this, _n6), l = __privateGet(this, _r4), u = __privateGet(this, _MatplotlibRenderer_instances, u_get);
26258
+ if (r.setTransform(u.x, 0, 0, u.y, 0, 0), r.clearRect(0, 0, c.width, c.height), r.drawImage(e, 0, 0, c.width, c.height), l.type === "box") {
26255
26259
  let e2 = Math.min(l.start.x, l.end.x), u2 = Math.min(l.start.y, l.end.y), d = Math.abs(l.end.x - l.start.x), f = Math.abs(l.end.y - l.start.y);
26256
26260
  r.save(), r.fillStyle = c.selectionColor, r.globalAlpha = c.selectionOpacity, r.fillRect(e2, u2, d, f), r.restore(), r.strokeStyle = c.selectionColor, r.lineWidth = c.strokeWidth, r.strokeRect(e2, u2, d, f);
26257
26261
  }
@@ -26261,17 +26265,17 @@ ${c}
26261
26265
  r.closePath(), r.save(), r.fillStyle = c.selectionColor, r.globalAlpha = c.selectionOpacity, r.fill("evenodd"), r.restore(), r.strokeStyle = c.selectionColor, r.lineWidth = c.strokeWidth, r.stroke();
26262
26266
  }
26263
26267
  });
26264
- __privateAdd(this, _f3, () => {
26265
- cancelAnimationFrame(__privateGet(this, _i4)), __privateSet(this, _i4, requestAnimationFrame(__privateGet(this, _d3)));
26268
+ __privateAdd(this, _h, () => {
26269
+ cancelAnimationFrame(__privateGet(this, _i4)), __privateSet(this, _i4, requestAnimationFrame(__privateGet(this, _m)));
26266
26270
  });
26267
- __privateAdd(this, _p2, (e) => {
26271
+ __privateAdd(this, _g, (e) => {
26268
26272
  let r = __privateGet(this, _e8).getBoundingClientRect(), c = __privateGet(this, _n6).width / r.width, l = __privateGet(this, _n6).height / r.height;
26269
26273
  return {
26270
26274
  x: (e.clientX - r.left) * c,
26271
26275
  y: (e.clientY - r.top) * l
26272
26276
  };
26273
26277
  });
26274
- __privateAdd(this, _m, (e, r) => {
26278
+ __privateAdd(this, __, (e, r) => {
26275
26279
  let c = pixelToData(e, __privateGet(this, _n6)), l = pixelToData(r, __privateGet(this, _n6));
26276
26280
  __privateGet(this, _n6).setValue({
26277
26281
  type: "box",
@@ -26284,7 +26288,7 @@ ${c}
26284
26288
  }
26285
26289
  });
26286
26290
  });
26287
- __privateAdd(this, _h, (e) => {
26291
+ __privateAdd(this, _v, (e) => {
26288
26292
  if (e.length >= 3) {
26289
26293
  let r = e.map((e2) => {
26290
26294
  let r2 = pixelToData(e2, __privateGet(this, _n6));
@@ -26300,19 +26304,19 @@ ${c}
26300
26304
  });
26301
26305
  }
26302
26306
  });
26303
- __privateAdd(this, _g, () => {
26307
+ __privateAdd(this, _y, () => {
26304
26308
  __privateSet(this, _r4, {
26305
26309
  type: "idle"
26306
26310
  }), __privateGet(this, _n6).setValue({
26307
26311
  has_selection: false
26308
- }), __privateGet(this, _f3).call(this);
26312
+ }), __privateGet(this, _h).call(this);
26309
26313
  });
26310
- __privateAdd(this, __, () => __privateGet(this, _r4).type !== "idle");
26311
- __privateAdd(this, _v, (e) => {
26314
+ __privateAdd(this, _b2, () => __privateGet(this, _r4).type !== "idle");
26315
+ __privateAdd(this, _x, (e) => {
26312
26316
  let r = __privateGet(this, _r4);
26313
26317
  return r.type === "box" ? isPointInBox(e, r.start, r.end) : r.type === "lasso" ? pointInPolygon(e, r.points) : false;
26314
26318
  });
26315
- __privateAdd(this, _y, (e) => {
26319
+ __privateAdd(this, _S, (e) => {
26316
26320
  let [r, c, l, u] = __privateGet(this, _n6).axesPixelBounds;
26317
26321
  if (!(e.x >= r && e.x <= l && e.y >= c && e.y <= u)) {
26318
26322
  __privateGet(this, _e8).style.cursor = "default";
@@ -26326,17 +26330,17 @@ ${c}
26326
26330
  return;
26327
26331
  }
26328
26332
  }
26329
- if (__privateGet(this, __).call(this) && __privateGet(this, _v).call(this, e)) {
26333
+ if (__privateGet(this, _b2).call(this) && __privateGet(this, _x).call(this, e)) {
26330
26334
  __privateGet(this, _e8).style.cursor = "move";
26331
26335
  return;
26332
26336
  }
26333
26337
  __privateGet(this, _e8).style.cursor = "crosshair";
26334
26338
  });
26335
- __privateAdd(this, _b2, (e) => {
26339
+ __privateAdd(this, _C, (e) => {
26336
26340
  if (!e || !("has_selection" in e) || !e.has_selection) {
26337
26341
  __privateGet(this, _r4).type !== "idle" && (__privateSet(this, _r4, {
26338
26342
  type: "idle"
26339
- }), __privateGet(this, _f3).call(this));
26343
+ }), __privateGet(this, _h).call(this));
26340
26344
  return;
26341
26345
  }
26342
26346
  if (e.type === "box") {
@@ -26361,11 +26365,11 @@ ${c}
26361
26365
  }, __privateGet(this, _n6))),
26362
26366
  action: null
26363
26367
  });
26364
- __privateGet(this, _f3).call(this);
26368
+ __privateGet(this, _h).call(this);
26365
26369
  });
26366
- __privateAdd(this, _x, (e) => {
26370
+ __privateAdd(this, _w, (e) => {
26367
26371
  __privateGet(this, _e8).setPointerCapture(e.pointerId), __privateGet(this, _t6).focus();
26368
- let r = __privateGet(this, _p2).call(this, e), c = __privateGet(this, _r4);
26372
+ let r = __privateGet(this, _g).call(this, e), c = __privateGet(this, _r4);
26369
26373
  if (e.shiftKey) {
26370
26374
  if (!isInAxes(r, __privateGet(this, _n6))) return;
26371
26375
  __privateSet(this, _r4, {
@@ -26376,7 +26380,7 @@ ${c}
26376
26380
  action: {
26377
26381
  type: "drawing"
26378
26382
  }
26379
- }), __privateGet(this, _f3).call(this);
26383
+ }), __privateGet(this, _h).call(this);
26380
26384
  return;
26381
26385
  }
26382
26386
  if (c.type === "box" && c.action === null) {
@@ -26397,7 +26401,7 @@ ${c}
26397
26401
  return;
26398
26402
  }
26399
26403
  }
26400
- if (__privateGet(this, __).call(this) && __privateGet(this, _v).call(this, r)) {
26404
+ if (__privateGet(this, _b2).call(this) && __privateGet(this, _x).call(this, r)) {
26401
26405
  c.type === "box" ? __privateSet(this, _r4, {
26402
26406
  type: "box",
26403
26407
  start: c.start,
@@ -26416,7 +26420,7 @@ ${c}
26416
26420
  });
26417
26421
  return;
26418
26422
  }
26419
- if (__privateGet(this, __).call(this) && __privateGet(this, _g).call(this), !isInAxes(r, __privateGet(this, _n6))) return;
26423
+ if (__privateGet(this, _b2).call(this) && __privateGet(this, _y).call(this), !isInAxes(r, __privateGet(this, _n6))) return;
26420
26424
  let l = clampToAxes(r, __privateGet(this, _n6));
26421
26425
  __privateSet(this, _r4, {
26422
26426
  type: "box",
@@ -26425,21 +26429,21 @@ ${c}
26425
26429
  action: {
26426
26430
  type: "drawing"
26427
26431
  }
26428
- }), __privateGet(this, _f3).call(this);
26432
+ }), __privateGet(this, _h).call(this);
26429
26433
  });
26430
- __privateAdd(this, _S, (e) => {
26431
- let r = __privateGet(this, _p2).call(this, e), c = __privateGet(this, _r4), l = __privateGet(this, _n6);
26434
+ __privateAdd(this, _T, (e) => {
26435
+ let r = __privateGet(this, _g).call(this, e), c = __privateGet(this, _r4), l = __privateGet(this, _n6);
26432
26436
  if (c.type === "idle" || c.action === null) {
26433
- __privateGet(this, _y).call(this, r);
26437
+ __privateGet(this, _S).call(this, r);
26434
26438
  return;
26435
26439
  }
26436
26440
  if (c.type === "lasso" && c.action.type === "drawing") {
26437
- c.points.push(clampToAxes(r, l)), __privateGet(this, _f3).call(this);
26441
+ c.points.push(clampToAxes(r, l)), __privateGet(this, _h).call(this);
26438
26442
  return;
26439
26443
  }
26440
26444
  if (c.type === "box" && c.action.type === "drawing") {
26441
26445
  let e2 = clampToAxes(r, l);
26442
- c.end = e2, __privateGet(this, _f3).call(this), l.debounce || __privateGet(this, _m).call(this, c.start, e2);
26446
+ c.end = e2, __privateGet(this, _h).call(this), l.debounce || __privateGet(this, __).call(this, c.start, e2);
26443
26447
  return;
26444
26448
  }
26445
26449
  if (c.type === "box" && c.action.type === "resizing") {
@@ -26447,7 +26451,7 @@ ${c}
26447
26451
  c.start = u, c.end = {
26448
26452
  x: d ?? e2.x,
26449
26453
  y: f ?? e2.y
26450
- }, __privateGet(this, _f3).call(this), l.debounce || __privateGet(this, _m).call(this, c.start, c.end);
26454
+ }, __privateGet(this, _h).call(this), l.debounce || __privateGet(this, __).call(this, c.start, c.end);
26451
26455
  return;
26452
26456
  }
26453
26457
  if (c.type === "box" && c.action.type === "dragging") {
@@ -26460,7 +26464,7 @@ ${c}
26460
26464
  }, c.end = {
26461
26465
  x: c.end.x + p,
26462
26466
  y: c.end.y + m
26463
- }, __privateGet(this, _f3).call(this), l.debounce || __privateGet(this, _m).call(this, c.start, c.end);
26467
+ }, __privateGet(this, _h).call(this), l.debounce || __privateGet(this, __).call(this, c.start, c.end);
26464
26468
  return;
26465
26469
  }
26466
26470
  if (c.type === "lasso" && c.action.type === "dragging") {
@@ -26473,77 +26477,87 @@ ${c}
26473
26477
  x: c.points[e3].x + p,
26474
26478
  y: c.points[e3].y + m
26475
26479
  };
26476
- __privateGet(this, _f3).call(this), l.debounce || __privateGet(this, _h).call(this, c.points);
26480
+ __privateGet(this, _h).call(this), l.debounce || __privateGet(this, _v).call(this, c.points);
26477
26481
  }
26478
26482
  });
26479
- __privateAdd(this, _C, (e) => {
26483
+ __privateAdd(this, _E, (e) => {
26480
26484
  var _a5, _b3;
26481
26485
  __privateGet(this, _e8).releasePointerCapture(e.pointerId);
26482
26486
  let r = __privateGet(this, _r4), c = __privateGet(this, _n6);
26483
26487
  if (r.type === "lasso" && ((_a5 = r.action) == null ? void 0 : _a5.type) === "drawing") {
26484
- r.points.length >= 3 ? (r.action = null, __privateGet(this, _h).call(this, r.points)) : (__privateSet(this, _r4, {
26488
+ r.points.length >= 3 ? (r.action = null, __privateGet(this, _v).call(this, r.points)) : (__privateSet(this, _r4, {
26485
26489
  type: "idle"
26486
26490
  }), __privateGet(this, _n6).setValue({
26487
26491
  has_selection: false
26488
- })), __privateGet(this, _f3).call(this);
26492
+ })), __privateGet(this, _h).call(this);
26489
26493
  return;
26490
26494
  }
26491
26495
  if (r.type === "lasso" && ((_b3 = r.action) == null ? void 0 : _b3.type) === "dragging") {
26492
- r.action = null, c.debounce && __privateGet(this, _h).call(this, r.points);
26496
+ r.action = null, c.debounce && __privateGet(this, _v).call(this, r.points);
26493
26497
  return;
26494
26498
  }
26495
- r.type === "box" && r.action !== null && (r.action = null, c.debounce && __privateGet(this, _m).call(this, r.start, r.end));
26499
+ r.type === "box" && r.action !== null && (r.action = null, c.debounce && __privateGet(this, __).call(this, r.start, r.end));
26496
26500
  });
26497
- __privateAdd(this, _w, (e) => {
26501
+ __privateAdd(this, _D, (e) => {
26498
26502
  var _a5;
26499
26503
  if (e.key === "Escape") {
26500
26504
  let e2 = __privateGet(this, _r4);
26501
26505
  if (e2.type === "idle") return;
26502
26506
  ((_a5 = e2.action) == null ? void 0 : _a5.type) === "drawing" ? (__privateSet(this, _r4, {
26503
26507
  type: "idle"
26504
- }), __privateGet(this, _f3).call(this)) : __privateGet(this, _g).call(this);
26508
+ }), __privateGet(this, _h).call(this)) : __privateGet(this, _y).call(this);
26505
26509
  }
26506
26510
  });
26507
26511
  __privateSet(this, _t6, e), __privateSet(this, _n6, r.state), e.tabIndex = -1, e.role = "application", e.className = "relative inline-block select-none outline-hidden";
26508
26512
  let c = document.createElement("canvas");
26509
- c.className = "block cursor-crosshair", __privateMethod(this, _MatplotlibRenderer_instances, c_fn2).call(this, c), c.style.touchAction = "none", e.append(c), __privateSet(this, _e8, c), c.addEventListener("pointerdown", __privateGet(this, _x), {
26513
+ c.className = "block cursor-crosshair", __privateMethod(this, _MatplotlibRenderer_instances, l_fn).call(this, c), c.style.touchAction = "none", e.append(c), __privateSet(this, _e8, c), c.addEventListener("pointerdown", __privateGet(this, _w), {
26510
26514
  signal: r.signal
26511
- }), c.addEventListener("pointermove", __privateGet(this, _S), {
26515
+ }), c.addEventListener("pointermove", __privateGet(this, _T), {
26512
26516
  signal: r.signal
26513
- }), c.addEventListener("pointerup", __privateGet(this, _C), {
26517
+ }), c.addEventListener("pointerup", __privateGet(this, _E), {
26514
26518
  signal: r.signal
26515
- }), e.addEventListener("keydown", __privateGet(this, _w), {
26519
+ }), e.addEventListener("keydown", __privateGet(this, _D), {
26516
26520
  signal: r.signal
26517
- }), __privateMethod(this, _MatplotlibRenderer_instances, l_fn).call(this, r.signal), r.signal.addEventListener("abort", () => {
26521
+ }), __privateMethod(this, _MatplotlibRenderer_instances, f_fn).call(this, r.signal), window.addEventListener("resize", __privateGet(this, _d3), {
26522
+ signal: r.signal
26523
+ }), r.signal.addEventListener("abort", () => {
26518
26524
  cancelAnimationFrame(__privateGet(this, _i4)), __privateGet(this, _e8).remove();
26519
- }), __privateMethod(this, _MatplotlibRenderer_instances, u_fn).call(this, __privateGet(this, _n6).chartBase64), __privateGet(this, _b2).call(this, __privateGet(this, _n6).value);
26525
+ }), __privateMethod(this, _MatplotlibRenderer_instances, p_fn).call(this, __privateGet(this, _n6).chartBase64), __privateGet(this, _C).call(this, __privateGet(this, _n6).value);
26520
26526
  }
26521
26527
  update(e) {
26522
26528
  let r = __privateGet(this, _n6);
26523
26529
  __privateSet(this, _n6, e);
26524
26530
  let c = false;
26525
- if ((e.width !== r.width || e.height !== r.height) && (__privateMethod(this, _MatplotlibRenderer_instances, c_fn2).call(this), c = true), e.chartBase64 !== __privateGet(this, _s2)) {
26526
- __privateMethod(this, _MatplotlibRenderer_instances, u_fn).call(this, e.chartBase64), __privateGet(this, _b2).call(this, e.value);
26531
+ if ((e.width !== r.width || e.height !== r.height) && (__privateMethod(this, _MatplotlibRenderer_instances, l_fn).call(this), c = true), e.chartBase64 !== __privateGet(this, _s2)) {
26532
+ __privateMethod(this, _MatplotlibRenderer_instances, p_fn).call(this, e.chartBase64), __privateGet(this, _C).call(this, e.value);
26527
26533
  return;
26528
26534
  }
26529
26535
  let l = __privateGet(this, _r4).type !== "idle" && __privateGet(this, _r4).action !== null;
26530
26536
  if (e.value !== r.value && !l) {
26531
- __privateGet(this, _b2).call(this, e.value);
26537
+ __privateGet(this, _C).call(this, e.value);
26532
26538
  return;
26533
26539
  }
26534
- (c || e.selectionColor !== r.selectionColor || e.selectionOpacity !== r.selectionOpacity || e.strokeWidth !== r.strokeWidth) && __privateGet(this, _d3).call(this);
26540
+ (c || e.selectionColor !== r.selectionColor || e.selectionOpacity !== r.selectionOpacity || e.strokeWidth !== r.strokeWidth) && __privateGet(this, _m).call(this);
26535
26541
  }
26536
- }, _e8 = new WeakMap(), _t6 = new WeakMap(), _n6 = new WeakMap(), _r4 = new WeakMap(), _i4 = new WeakMap(), _a4 = new WeakMap(), _o4 = new WeakMap(), _s2 = new WeakMap(), _MatplotlibRenderer_instances = new WeakSet(), c_fn2 = function(e = __privateGet(this, _e8)) {
26537
- let r = globalThis.devicePixelRatio ?? 1, { width: c, height: l } = __privateGet(this, _n6);
26542
+ }, _e8 = new WeakMap(), _t6 = new WeakMap(), _n6 = new WeakMap(), _r4 = new WeakMap(), _i4 = new WeakMap(), _a4 = new WeakMap(), _o4 = new WeakMap(), _s2 = new WeakMap(), _c4 = new WeakMap(), _MatplotlibRenderer_instances = new WeakSet(), l_fn = function(e = __privateGet(this, _e8)) {
26543
+ let r = globalThis.devicePixelRatio ?? 1;
26544
+ __privateSet(this, _c4, r);
26545
+ let { width: c, height: l } = __privateGet(this, _n6);
26538
26546
  e.width = c * r, e.height = l * r, e.style.width = `${c}px`, e.style.maxWidth = "100%", e.style.height = "auto", e.style.aspectRatio = `${c} / ${l}`;
26539
- }, l_fn = function(e) {
26547
+ }, u_get = function() {
26548
+ let { width: e, height: r } = __privateGet(this, _n6), c = globalThis.devicePixelRatio ?? 1;
26549
+ return {
26550
+ x: e > 0 ? __privateGet(this, _e8).width / e : c,
26551
+ y: r > 0 ? __privateGet(this, _e8).height / r : c
26552
+ };
26553
+ }, _d3 = new WeakMap(), f_fn = function(e) {
26540
26554
  e.aborted || matchMedia(`(resolution: ${globalThis.devicePixelRatio ?? 1}dppx)`).addEventListener("change", () => {
26541
- __privateMethod(this, _MatplotlibRenderer_instances, c_fn2).call(this), __privateGet(this, _d3).call(this), __privateMethod(this, _MatplotlibRenderer_instances, l_fn).call(this, e);
26555
+ __privateGet(this, _d3).call(this), __privateMethod(this, _MatplotlibRenderer_instances, f_fn).call(this, e);
26542
26556
  }, {
26543
26557
  once: true,
26544
26558
  signal: e
26545
26559
  });
26546
- }, u_fn = function(e) {
26560
+ }, p_fn = function(e) {
26547
26561
  __privateSet(this, _s2, e), __privateWrapper(this, _o4)._++;
26548
26562
  let r = __privateGet(this, _o4);
26549
26563
  __privateSet(this, _r4, {
@@ -26551,14 +26565,14 @@ ${c}
26551
26565
  }), __privateSet(this, _a4, null);
26552
26566
  let c = __privateGet(this, _e8).getContext("2d");
26553
26567
  if (c) {
26554
- let e2 = globalThis.devicePixelRatio ?? 1;
26555
- c.setTransform(e2, 0, 0, e2, 0, 0), c.clearRect(0, 0, __privateGet(this, _n6).width, __privateGet(this, _n6).height);
26568
+ let e2 = __privateGet(this, _MatplotlibRenderer_instances, u_get);
26569
+ c.setTransform(e2.x, 0, 0, e2.y, 0, 0), c.clearRect(0, 0, __privateGet(this, _n6).width, __privateGet(this, _n6).height);
26556
26570
  }
26557
26571
  let l = new Image();
26558
26572
  l.onload = () => {
26559
- r === __privateGet(this, _o4) && (__privateSet(this, _a4, l), __privateGet(this, _d3).call(this));
26573
+ r === __privateGet(this, _o4) && (__privateSet(this, _a4, l), __privateGet(this, _m).call(this));
26560
26574
  }, l.src = e;
26561
- }, _d3 = new WeakMap(), _f3 = new WeakMap(), _p2 = new WeakMap(), _m = new WeakMap(), _h = new WeakMap(), _g = new WeakMap(), __ = new WeakMap(), _v = new WeakMap(), _y = new WeakMap(), _b2 = new WeakMap(), _x = new WeakMap(), _S = new WeakMap(), _C = new WeakMap(), _w = new WeakMap(), _g2), import_compiler_runtime$36 = require_compiler_runtime(), MatplotlibPlugin = class {
26575
+ }, _m = new WeakMap(), _h = new WeakMap(), _g = new WeakMap(), __ = new WeakMap(), _v = new WeakMap(), _y = new WeakMap(), _b2 = new WeakMap(), _x = new WeakMap(), _S = new WeakMap(), _C = new WeakMap(), _w = new WeakMap(), _T = new WeakMap(), _E = new WeakMap(), _D = new WeakMap(), _g2), import_compiler_runtime$36 = require_compiler_runtime(), MatplotlibPlugin = class {
26562
26576
  constructor() {
26563
26577
  __publicField(this, "tagName", "marimo-matplotlib");
26564
26578
  __publicField(this, "validator", object({
@@ -31968,8 +31982,8 @@ ${c}
31968
31982
  }
31969
31983
  }
31970
31984
  findDOMNode() {
31971
- var _a5, _b3, _c4;
31972
- return ((_a5 = this.props) == null ? void 0 : _a5.nodeRef) ? (_c4 = (_b3 = this.props) == null ? void 0 : _b3.nodeRef) == null ? void 0 : _c4.current : l.default.findDOMNode(this);
31985
+ var _a5, _b3, _c5;
31986
+ return ((_a5 = this.props) == null ? void 0 : _a5.nodeRef) ? (_c5 = (_b3 = this.props) == null ? void 0 : _b3.nodeRef) == null ? void 0 : _c5.current : l.default.findDOMNode(this);
31973
31987
  }
31974
31988
  render() {
31975
31989
  return r.cloneElement(r.Children.only(this.props.children), {
@@ -38307,7 +38321,7 @@ ${c}
38307
38321
  function _temp2$2(e) {
38308
38322
  e.target === e.currentTarget && e.key === "Enter" && (e.preventDefault(), e.stopPropagation(), e.currentTarget.click());
38309
38323
  }
38310
- var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-2JQ2YfIT.js"));
38324
+ var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-BfdtFvyL.js"));
38311
38325
  const SlidesLayoutRenderer = ({ layout: e, setLayout: r, cells: c, mode: l }) => {
38312
38326
  var _a5;
38313
38327
  let u = useAtomValue(kioskModeAtom), d = l === "read" || u, f = useAtomValue(numColumnsAtom) > 1, [p, m] = (0, import_react.useState)(null), { slideCells: h, skippedIds: g, noOutputIds: _, slideTypes: v, startCellIndex: y } = (0, import_react.useMemo)(() => computeSlideCellsInfo(c, e), [
@@ -40498,13 +40512,13 @@ ${c}
40498
40512
  });
40499
40513
  }
40500
40514
  async startApps() {
40501
- var _a5, _b3, _c4, _d4;
40515
+ var _a5, _b3, _c5, _d4;
40502
40516
  let e = parseMarimoIslandApps(this.root, {
40503
40517
  materialize: false
40504
40518
  }), r = e.length === 1;
40505
40519
  Logger.debug(`Starting sessions for ${e.length} app(s):`, e.map((e2) => `${e2.id} (${e2.cells.length} cells)`));
40506
40520
  let c = (_b3 = e.length === 1 && !((_a5 = e[0]) == null ? void 0 : _a5.payloadBacked) ? getMarimoExportContext() : void 0) == null ? void 0 : _b3.notebookCode, l = r ? e[0] : void 0, u = l ? c || createMarimoFile(l) : void 0;
40507
- if (l && ((_c4 = this.session) == null ? void 0 : _c4.appId) === l.id && this.session.code === u) {
40521
+ if (l && ((_c5 = this.session) == null ? void 0 : _c5.appId) === l.id && this.session.code === u) {
40508
40522
  parseMarimoIslandApps(this.root);
40509
40523
  return;
40510
40524
  }
@@ -9,7 +9,7 @@ import { t as require_compiler_runtime } from "./compiler-runtime-DsR6imPN.js";
9
9
  import { ut as outputIsStale } from "./html-to-image-BzT-fb14.js";
10
10
  import "./chunk-5FQGJX7Z-BRZ_XYUw.js";
11
11
  import { u as createLucideIcon } from "./dist-j30bBjjN.js";
12
- import { a as DEFAULT_DECK_TRANSITION, cn as EyeOff, dt as PanelGroup, fn as Code, ft as PanelResizeHandle, l as SlideSidebar, ln as Expand, n as useNotebookCodeAvailable, o as DEFAULT_DECK_VERTICAL_ALIGN, s as DEFAULT_SLIDE_TYPE, t as cellDomProps, u as Slide, ut as Panel } from "./common-Cy9zypnG.js";
12
+ import { a as DEFAULT_DECK_TRANSITION, cn as EyeOff, dt as PanelGroup, fn as Code, ft as PanelResizeHandle, l as SlideSidebar, ln as Expand, n as useNotebookCodeAvailable, o as DEFAULT_DECK_VERTICAL_ALIGN, s as DEFAULT_SLIDE_TYPE, t as cellDomProps, u as Slide, ut as Panel } from "./common-nFz87Uyp.js";
13
13
  import { R as ChevronDown } from "./strings-DMLVGXRo.js";
14
14
  import { X as useDebouncedCallback } from "./input-CqV2ZPgL.js";
15
15
  import { v as kioskModeAtom } from "./toDate-CjUYDkFI.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.24.1-dev30",
3
+ "version": "0.24.1-dev32",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -190,6 +190,62 @@ describe("isInAxes", () => {
190
190
  });
191
191
  });
192
192
 
193
+ // A 100x100 chart whose axes fill the whole figure.
194
+ function createState(): MatplotlibState {
195
+ return {
196
+ ...LINEAR_AXES,
197
+ axesPixelBounds: [0, 0, 100, 100],
198
+ yBounds: [0, 10],
199
+ chartBase64: "first",
200
+ width: 100,
201
+ height: 100,
202
+ selectionColor: "blue",
203
+ selectionOpacity: 0.15,
204
+ strokeWidth: 2,
205
+ debounce: false,
206
+ value: { has_selection: false },
207
+ setValue: vi.fn(),
208
+ };
209
+ }
210
+
211
+ // jsdom has no matchMedia, no animation frames and no canvas context.
212
+ function stubBrowser(ctx: Partial<CanvasRenderingContext2D> | null = null) {
213
+ vi.stubGlobal(
214
+ "matchMedia",
215
+ vi.fn(() => ({ addEventListener: vi.fn() })),
216
+ );
217
+ const requestAnimationFrame = vi.fn(() => 1);
218
+ vi.stubGlobal("requestAnimationFrame", requestAnimationFrame);
219
+ vi.stubGlobal("cancelAnimationFrame", vi.fn());
220
+ vi.spyOn(HTMLCanvasElement.prototype, "getContext").mockReturnValue(
221
+ ctx as CanvasRenderingContext2D | null,
222
+ );
223
+ return { requestAnimationFrame };
224
+ }
225
+
226
+ // jsdom does not fetch images; resolve them synchronously instead.
227
+ function stubSyncImage() {
228
+ vi.stubGlobal(
229
+ "Image",
230
+ class {
231
+ onload: (() => void) | null = null;
232
+ set src(_value: string) {
233
+ this.onload?.();
234
+ }
235
+ },
236
+ );
237
+ }
238
+
239
+ function createRecordingContext() {
240
+ return {
241
+ setTransform: vi.fn(),
242
+ clearRect: vi.fn(),
243
+ drawImage: vi.fn(),
244
+ save: vi.fn(),
245
+ restore: vi.fn(),
246
+ };
247
+ }
248
+
193
249
  describe("MatplotlibRenderer", () => {
194
250
  afterEach(() => {
195
251
  vi.unstubAllGlobals();
@@ -197,36 +253,14 @@ describe("MatplotlibRenderer", () => {
197
253
  });
198
254
 
199
255
  it("restores a new selection when the chart changes", () => {
200
- vi.stubGlobal(
201
- "matchMedia",
202
- vi.fn(() => ({ addEventListener: vi.fn() })),
203
- );
204
- vi.stubGlobal(
205
- "requestAnimationFrame",
206
- vi.fn(() => 1),
207
- );
208
- vi.stubGlobal("cancelAnimationFrame", vi.fn());
209
- vi.spyOn(HTMLCanvasElement.prototype, "getContext").mockReturnValue(null);
256
+ stubBrowser();
210
257
 
211
258
  const value = {
212
259
  type: "box",
213
260
  has_selection: true,
214
261
  data: { x_min: 2, x_max: 4, y_min: 2, y_max: 4 },
215
262
  } as const;
216
- const state: MatplotlibState = {
217
- ...LINEAR_AXES,
218
- axesPixelBounds: [0, 0, 100, 100],
219
- yBounds: [0, 10],
220
- chartBase64: "first",
221
- width: 100,
222
- height: 100,
223
- selectionColor: "blue",
224
- selectionOpacity: 0.15,
225
- strokeWidth: 2,
226
- debounce: false,
227
- value: { has_selection: false },
228
- setValue: vi.fn(),
229
- };
263
+ const state = createState();
230
264
  const container = document.createElement("div");
231
265
  const controller = new AbortController();
232
266
  const renderer = new MatplotlibRenderer(container, {
@@ -252,4 +286,130 @@ describe("MatplotlibRenderer", () => {
252
286
  expect(canvas.style.cursor).toBe("move");
253
287
  controller.abort();
254
288
  });
289
+
290
+ // Safari only fires resize on zoom, not the resolution query (#10625).
291
+ it("re-syncs the backing store on resize, without matchMedia firing", () => {
292
+ stubBrowser();
293
+ vi.stubGlobal("devicePixelRatio", 2);
294
+
295
+ const container = document.createElement("div");
296
+ const controller = new AbortController();
297
+ new MatplotlibRenderer(container, {
298
+ state: createState(),
299
+ signal: controller.signal,
300
+ });
301
+ const canvas = container.querySelector("canvas");
302
+ expect(canvas?.width).toBe(200);
303
+
304
+ vi.stubGlobal("devicePixelRatio", 1);
305
+ window.dispatchEvent(new Event("resize"));
306
+
307
+ expect(canvas?.width).toBe(100);
308
+ controller.abort();
309
+ });
310
+
311
+ // Re-sizing clears the buffer a frame before the repaint, so an over-eager
312
+ // guard flickers. 700 * 1.1 is the case a truncating comparison misses.
313
+ it("leaves the backing store alone when resize fires at an unchanged DPR", () => {
314
+ const { requestAnimationFrame } = stubBrowser();
315
+ vi.stubGlobal("devicePixelRatio", 1.1);
316
+
317
+ const container = document.createElement("div");
318
+ const controller = new AbortController();
319
+ new MatplotlibRenderer(container, {
320
+ state: { ...createState(), width: 700 },
321
+ signal: controller.signal,
322
+ });
323
+ const canvas = container.querySelector("canvas");
324
+ expect(canvas?.width).toBe(770);
325
+
326
+ requestAnimationFrame.mockClear();
327
+ window.dispatchEvent(new Event("resize"));
328
+
329
+ expect(canvas?.width).toBe(770);
330
+ expect(requestAnimationFrame).not.toHaveBeenCalled();
331
+ controller.abort();
332
+ });
333
+
334
+ it("draws with the backing-store scale, not the current devicePixelRatio", () => {
335
+ const ctx = createRecordingContext();
336
+ stubBrowser(ctx);
337
+ stubSyncImage();
338
+ vi.stubGlobal("devicePixelRatio", 2);
339
+
340
+ const state = createState();
341
+ const container = document.createElement("div");
342
+ const controller = new AbortController();
343
+ const renderer = new MatplotlibRenderer(container, {
344
+ state,
345
+ signal: controller.signal,
346
+ });
347
+ expect(container.querySelector("canvas")?.width).toBe(200);
348
+
349
+ // Zoom with nothing re-syncing the buffer: it still holds the old DPR, so
350
+ // the redraw must too, or the image lands scaled by dpr_new / dpr_old.
351
+ vi.stubGlobal("devicePixelRatio", 1);
352
+ ctx.setTransform.mockClear();
353
+ renderer.update({ ...state, strokeWidth: 4 });
354
+
355
+ expect(ctx.setTransform.mock.calls).toEqual([[2, 0, 0, 2, 0, 0]]);
356
+ expect(ctx.drawImage).toHaveBeenLastCalledWith(
357
+ expect.anything(),
358
+ 0,
359
+ 0,
360
+ 100,
361
+ 100,
362
+ );
363
+ controller.abort();
364
+ });
365
+
366
+ it("clears the whole backing store when a re-run swaps the chart", () => {
367
+ const ctx = createRecordingContext();
368
+ stubBrowser(ctx);
369
+ vi.stubGlobal("devicePixelRatio", 2);
370
+
371
+ const state = createState();
372
+ const container = document.createElement("div");
373
+ const controller = new AbortController();
374
+ const renderer = new MatplotlibRenderer(container, {
375
+ state,
376
+ signal: controller.signal,
377
+ });
378
+
379
+ vi.stubGlobal("devicePixelRatio", 1);
380
+ ctx.setTransform.mockClear();
381
+ ctx.clearRect.mockClear();
382
+ renderer.update({ ...state, chartBase64: "second" });
383
+
384
+ // A stale scale here would leave the outer 3/4 of the buffer unwiped.
385
+ expect(ctx.setTransform.mock.calls).toEqual([[2, 0, 0, 2, 0, 0]]);
386
+ expect(ctx.clearRect.mock.calls).toEqual([[0, 0, 100, 100]]);
387
+ controller.abort();
388
+ });
389
+
390
+ it("scales each axis by its own backing-store ratio", () => {
391
+ const ctx = createRecordingContext();
392
+ stubBrowser(ctx);
393
+ stubSyncImage();
394
+ // canvas.width/height are integers, so this truncates the two dimensions
395
+ // by different fractions: 150 * 1.25 -> 187 (0.5 lost), 500 * 1.25 -> 625
396
+ // (exact). One shared, width-derived scale would under-cover the buffer
397
+ // vertically and leave its bottom rows unwiped.
398
+ vi.stubGlobal("devicePixelRatio", 1.25);
399
+
400
+ const state = { ...createState(), width: 150, height: 500 };
401
+ const container = document.createElement("div");
402
+ const controller = new AbortController();
403
+ new MatplotlibRenderer(container, { state, signal: controller.signal });
404
+
405
+ const canvas = container.querySelector("canvas");
406
+ expect(canvas?.width).toBe(187);
407
+ expect(canvas?.height).toBe(625);
408
+ // The pre-load clear and the draw each set up their own transform.
409
+ const transform = [187 / 150, 0, 0, 625 / 500, 0, 0];
410
+ const rect = [0, 0, 150, 500];
411
+ expect(ctx.setTransform.mock.calls).toEqual([transform, transform]);
412
+ expect(ctx.clearRect.mock.calls).toEqual([rect, rect]);
413
+ controller.abort();
414
+ });
255
415
  });
@@ -281,6 +281,8 @@ export class MatplotlibRenderer {
281
281
  #image: HTMLImageElement | null = null;
282
282
  #imageGeneration = 0;
283
283
  #currentChartBase64 = "";
284
+ /** The devicePixelRatio the canvas buffer was last sized with. */
285
+ #backingDpr = 1;
284
286
 
285
287
  constructor(
286
288
  container: HTMLDivElement,
@@ -317,8 +319,12 @@ export class MatplotlibRenderer {
317
319
  });
318
320
 
319
321
  // Watch for devicePixelRatio changes (e.g. browser zoom, moving between
320
- // displays). matchMedia fires exactly once per DPR transition.
322
+ // displays). matchMedia fires exactly once per DPR transition, but Safari
323
+ // doesn't re-evaluate the query on zoom — it only fires resize (#10625).
321
324
  this.#watchDevicePixelRatio(options.signal);
325
+ window.addEventListener("resize", this.#syncForDevicePixelRatio, {
326
+ signal: options.signal,
327
+ });
322
328
 
323
329
  // Clean up on abort
324
330
  options.signal.addEventListener("abort", () => {
@@ -334,6 +340,7 @@ export class MatplotlibRenderer {
334
340
  /** Set the canvas buffer + CSS size to match current logical size and DPR. */
335
341
  #syncCanvasSize(canvas: HTMLCanvasElement = this.#canvas): void {
336
342
  const dpr = globalThis.devicePixelRatio ?? 1;
343
+ this.#backingDpr = dpr;
337
344
  const { width, height } = this.#state;
338
345
  canvas.width = width * dpr;
339
346
  canvas.height = height * dpr;
@@ -343,6 +350,33 @@ export class MatplotlibRenderer {
343
350
  canvas.style.aspectRatio = `${width} / ${height}`;
344
351
  }
345
352
 
353
+ /**
354
+ * Scale to draw at, read back from the buffer rather than from
355
+ * `devicePixelRatio`, so sizing and drawing cannot disagree (#10625).
356
+ * Per-axis: `canvas.width`/`height` are integers, so a fractional DPR
357
+ * truncates each dimension by a different fraction of a device pixel.
358
+ */
359
+ get #backingScale(): { x: number; y: number } {
360
+ const { width, height } = this.#state;
361
+ const dpr = globalThis.devicePixelRatio ?? 1;
362
+ return {
363
+ x: width > 0 ? this.#canvas.width / width : dpr,
364
+ y: height > 0 ? this.#canvas.height / height : dpr,
365
+ };
366
+ }
367
+
368
+ /**
369
+ * Re-size the buffer when the DPR changed. resize fires far more often than
370
+ * the DPR moves, and `canvas.width` truncates, so compare ratios directly.
371
+ */
372
+ #syncForDevicePixelRatio = (): void => {
373
+ if ((globalThis.devicePixelRatio ?? 1) === this.#backingDpr) {
374
+ return;
375
+ }
376
+ this.#syncCanvasSize();
377
+ this.#scheduleRedraw();
378
+ };
379
+
346
380
  /**
347
381
  * Observe devicePixelRatio changes via matchMedia. Each listener fires once
348
382
  * per transition, so we re-register after every change.
@@ -355,8 +389,7 @@ export class MatplotlibRenderer {
355
389
  `(resolution: ${globalThis.devicePixelRatio ?? 1}dppx)`,
356
390
  );
357
391
  const onChange = () => {
358
- this.#syncCanvasSize();
359
- this.#drawCanvas();
392
+ this.#syncForDevicePixelRatio();
360
393
  // Re-register for the next DPR transition
361
394
  this.#watchDevicePixelRatio(signal);
362
395
  };
@@ -416,8 +449,8 @@ export class MatplotlibRenderer {
416
449
  this.#image = null;
417
450
  const ctx = this.#canvas.getContext("2d");
418
451
  if (ctx) {
419
- const dpr = globalThis.devicePixelRatio ?? 1;
420
- ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
452
+ const scale = this.#backingScale;
453
+ ctx.setTransform(scale.x, 0, 0, scale.y, 0, 0);
421
454
  ctx.clearRect(0, 0, this.#state.width, this.#state.height);
422
455
  }
423
456
 
@@ -447,8 +480,8 @@ export class MatplotlibRenderer {
447
480
  const ix = this.#interaction;
448
481
 
449
482
  // Scale for HiDPI: all coordinates remain in logical pixels
450
- const dpr = globalThis.devicePixelRatio ?? 1;
451
- ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
483
+ const scale = this.#backingScale;
484
+ ctx.setTransform(scale.x, 0, 0, scale.y, 0, 0);
452
485
 
453
486
  // Clear and draw the base image
454
487
  ctx.clearRect(0, 0, s.width, s.height);