@marimo-team/islands 0.23.12-dev14 → 0.23.12-dev19

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.
@@ -35997,7 +35997,7 @@ ${d}`,
35997
35997
  return Logger.warn("Failed to get version from mount config"), null;
35998
35998
  }
35999
35999
  }
36000
- marimoVersionAtom = atom(getVersionFromMountConfig() || "0.23.12-dev14");
36000
+ marimoVersionAtom = atom(getVersionFromMountConfig() || "0.23.12-dev19");
36001
36001
  showCodeInRunModeAtom = atom(true);
36002
36002
  atom(null);
36003
36003
  var import_compiler_runtime = require_compiler_runtime();
package/dist/main.js CHANGED
@@ -26,7 +26,7 @@ import { $ as reducer, B as safeExtractSetUIElementMessageBuffers, Bn as CircleA
26
26
  import { __tla as __tla_1 } from "./chunk-5FQGJX7Z-BbqSm5gU.js";
27
27
  import { o as useSize, s as Root$1, u as createLucideIcon } from "./dist--2Bqjvs0.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$1, 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-Bv-XlYiv.js";
29
- import { $ as contextAwarePanelOpen, $t as $fae977aafc393c5c$export$6b862160d295c8e, A as prettifyRowCount, At as SELECT_COLUMN_ID, B as DatePicker, Bt as TabsContent, C as downloadSizeLimitAtom, Ct as DelayMount, D as ErrorState, Dt as loadTableAndRawData, E as EmptyState, Et as getPageIndexForRow, F as ContextMenuSeparator, Ft as Maps, G as CommandEmpty, Gt as ChartLoadingState, H as Combobox, Ht as TabsTrigger, I as ContextMenuTrigger, It as dateToLocalISODate, J as CommandList, Jt as RenderTextWithLinks, K as CommandInput, Kt as LazyVegaEmbed, L as useInternalStateWithSync, Lt as dateToLocalISODateTime, M as ContextMenu, Mt as toFieldTypes, N as ContextMenuContent, Nt as getMimeValues, O as LoadingState, Ot as loadTableData, P as ContextMenuItem, Pt as isNullishFilter, Q as PANEL_TYPES, Qt as $fae977aafc393c5c$export$588937bcd60ade55, R as useSelectList, Rt as dateToLocalISOTime, S as Filenames, St as ColumnChartSpecModel, T as ColumnPreviewContainer, Tt as usePrevious$1, U as ComboboxItem, Ut as ChartErrorState, V as DateRangePicker, Vt as TabsList, W as Command, Wt as ChartInfoState, X as smartMatch, Xt as HtmlOutput, Y as CommandSeparator, Yt as Kbd, Z as ContextAwarePanelItem, Zt as EmotionCacheProvider, _ as ADD_PRINTING_CLASS, _t as NAMELESS_COLUMN_PREFIX, an as Ellipsis, at as Toggle, b as downloadHTMLAsImage, bt as renderCellValue, c as Slide, cn as ChevronsUpDown, d as RadioGroupItem, dn as ChevronsDownUp, dt as Table, en as TextWrap, et as contextAwarePanelOwner, f as JsonOutput, fn as ChevronLeft, ft as TableBody, g as InstallPackageButton, gt as TableRow, h as DataTable, ht as TableHeader, it as slotsController, j as getColumnCountForDisplay, jt as TOO_MANY_ROWS, k as prettifyRowColumnCount, kt as INDEX_COLUMN_NAME, l as Switch, ln as ChevronsRight, lt as Fill, m as OutputRenderer, mt as TableHead, n as marimoVersionAtom, nn as Funnel, nt as isCellAwareAtom, o as SLIDE_TYPE_OPTIONS_BY_VALUE, on as Download, p as OutputArea, pn as ArrowDownWideNarrow, pt as TableCell, q as CommandItem, qt as useOverflowDetection, r as showCodeInRunModeAtom, rn as EyeOff, rt as SlotNames, sn as Code, t as useNotebookCodeAvailable, tn as GripHorizontal, tt as contextAwarePanelType, u as RadioGroup, un as ChevronsLeft, ut as Provider$1, v as downloadBlob, vt as generateColumns, w as ColumnName, wt as useIntersectionObserver, x as Progress, xt as ColumnChartContext, y as downloadByURL, yt as inferFieldTypes, z as CompactChipRow, zt as Tabs, __tla as __tla_2 } from "./code-visibility-D7qOrRxp.js";
29
+ import { $ as contextAwarePanelOpen, $t as $fae977aafc393c5c$export$6b862160d295c8e, A as prettifyRowCount, At as SELECT_COLUMN_ID, B as DatePicker, Bt as TabsContent, C as downloadSizeLimitAtom, Ct as DelayMount, D as ErrorState, Dt as loadTableAndRawData, E as EmptyState, Et as getPageIndexForRow, F as ContextMenuSeparator, Ft as Maps, G as CommandEmpty, Gt as ChartLoadingState, H as Combobox, Ht as TabsTrigger, I as ContextMenuTrigger, It as dateToLocalISODate, J as CommandList, Jt as RenderTextWithLinks, K as CommandInput, Kt as LazyVegaEmbed, L as useInternalStateWithSync, Lt as dateToLocalISODateTime, M as ContextMenu, Mt as toFieldTypes, N as ContextMenuContent, Nt as getMimeValues, O as LoadingState, Ot as loadTableData, P as ContextMenuItem, Pt as isNullishFilter, Q as PANEL_TYPES, Qt as $fae977aafc393c5c$export$588937bcd60ade55, R as useSelectList, Rt as dateToLocalISOTime, S as Filenames, St as ColumnChartSpecModel, T as ColumnPreviewContainer, Tt as usePrevious$1, U as ComboboxItem, Ut as ChartErrorState, V as DateRangePicker, Vt as TabsList, W as Command, Wt as ChartInfoState, X as smartMatch, Xt as HtmlOutput, Y as CommandSeparator, Yt as Kbd, Z as ContextAwarePanelItem, Zt as EmotionCacheProvider, _ as ADD_PRINTING_CLASS, _t as NAMELESS_COLUMN_PREFIX, an as Ellipsis, at as Toggle, b as downloadHTMLAsImage, bt as renderCellValue, c as Slide, cn as ChevronsUpDown, d as RadioGroupItem, dn as ChevronsDownUp, dt as Table, en as TextWrap, et as contextAwarePanelOwner, f as JsonOutput, fn as ChevronLeft, ft as TableBody, g as InstallPackageButton, gt as TableRow, h as DataTable, ht as TableHeader, it as slotsController, j as getColumnCountForDisplay, jt as TOO_MANY_ROWS, k as prettifyRowColumnCount, kt as INDEX_COLUMN_NAME, l as Switch, ln as ChevronsRight, lt as Fill, m as OutputRenderer, mt as TableHead, n as marimoVersionAtom, nn as Funnel, nt as isCellAwareAtom, o as SLIDE_TYPE_OPTIONS_BY_VALUE, on as Download, p as OutputArea, pn as ArrowDownWideNarrow, pt as TableCell, q as CommandItem, qt as useOverflowDetection, r as showCodeInRunModeAtom, rn as EyeOff, rt as SlotNames, sn as Code, t as useNotebookCodeAvailable, tn as GripHorizontal, tt as contextAwarePanelType, u as RadioGroup, un as ChevronsLeft, ut as Provider$1, v as downloadBlob, vt as generateColumns, w as ColumnName, wt as useIntersectionObserver, x as Progress, xt as ColumnChartContext, y as downloadByURL, yt as inferFieldTypes, z as CompactChipRow, zt as Tabs, __tla as __tla_2 } from "./code-visibility-BY8oNoME.js";
30
30
  import { c as Calendar, i as createReducerAndAtoms, n as useOnUnmount, o as ToggleLeft, t as useOnMount } from "./useLifecycle-AHlswLw-.js";
31
31
  import { t as Check } from "./check-C9OoNtR4.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-Dq_j3Rxw.js";
@@ -97,7 +97,7 @@ let __tla = Promise.all([
97
97
  }
98
98
  })()
99
99
  ]).then(async () => {
100
- var _e2, _WidgetDefRegistry_instances, t_fn, _a, _e3, _t2, _n2, _b, _e4, _c, _e5, _t3, _ModelManager_instances, n_fn, _d, _e6, _e7, _t4, _n3, _r, _i, _f, _e_instances, a_fn, o_fn, s_fn, _c2, _e8, _t5, _n4, _r2, _i2, _a2, _o2, _s, _MatplotlibRenderer_instances, c_fn, l_fn, u_fn, _d2, _f2, _p, _m, _h, _g, __, _v, _y, _b2, _x, _S, _C, _w, _g2, _h2;
100
+ var _e2, _WidgetDefRegistry_instances, t_fn, _a, _e3, _t2, _n2, _b, _e4, _c, _e5, _t3, _ModelManager_instances, n_fn, _d, _e6, _e7, _t4, _n3, _r, _i, _f, _e_instances, a_fn, o_fn, s_fn, c_fn, _l, _e8, _t5, _n4, _r2, _i2, _a2, _o2, _s, _MatplotlibRenderer_instances, c_fn2, l_fn, u_fn, _d2, _f2, _p, _m, _h, _g, __, _v, _y, _b2, _x, _S, _C, _w, _g2, _h2;
101
101
  var defaultIconDimensions = Object.freeze({
102
102
  left: 0,
103
103
  top: 0,
@@ -3700,7 +3700,8 @@ let __tla = Promise.all([
3700
3700
  __privateAdd(this, _i, {});
3701
3701
  __publicField(this, _e6, {
3702
3702
  updateAndEmitDiffs: (e) => __privateMethod(this, _e_instances, o_fn).call(this, e),
3703
- emitCustomMessage: (e, r) => __privateMethod(this, _e_instances, s_fn).call(this, e, r)
3703
+ reemitState: () => __privateMethod(this, _e_instances, s_fn).call(this),
3704
+ emitCustomMessage: (e, r) => __privateMethod(this, _e_instances, c_fn).call(this, e, r)
3704
3705
  });
3705
3706
  __publicField(this, "widget_manager", {
3706
3707
  async get_model(r) {
@@ -3709,7 +3710,7 @@ let __tla = Promise.all([
3709
3710
  return c;
3710
3711
  }
3711
3712
  });
3712
- __privateAdd(this, _c2, debounce_default(() => {
3713
+ __privateAdd(this, _l, debounce_default(() => {
3713
3714
  let e = __privateGet(this, _i)[__privateGet(this, _e7)];
3714
3715
  if (e) for (let r of e) try {
3715
3716
  r();
@@ -3744,7 +3745,7 @@ let __tla = Promise.all([
3744
3745
  __privateSet(this, _n3, {
3745
3746
  ...__privateGet(this, _n3),
3746
3747
  [e]: r
3747
- }), __privateGet(this, _t4).set(e, r), __privateMethod(this, _e_instances, a_fn).call(this, `change:${e}`, r), __privateGet(this, _c2).call(this);
3748
+ }), __privateGet(this, _t4).set(e, r), __privateMethod(this, _e_instances, a_fn).call(this, `change:${e}`, r), __privateGet(this, _l).call(this);
3748
3749
  }
3749
3750
  save_changes() {
3750
3751
  if (__privateGet(this, _t4).size === 0) return;
@@ -3767,14 +3768,17 @@ let __tla = Promise.all([
3767
3768
  let c = r;
3768
3769
  __privateGet(this, _n3)[c] !== e[c] && this.set(c, e[c]);
3769
3770
  });
3770
- }, s_fn = function(e, r = []) {
3771
+ }, s_fn = function() {
3772
+ for (let [e, r] of Object.entries(__privateGet(this, _n3))) __privateMethod(this, _e_instances, a_fn).call(this, `change:${e}`, r);
3773
+ __privateGet(this, _l).call(this);
3774
+ }, c_fn = function(e, r = []) {
3771
3775
  let c = __privateGet(this, _i)["msg:custom"];
3772
3776
  if (c) for (let l of c) try {
3773
3777
  l(e.content, r);
3774
3778
  } catch (e2) {
3775
3779
  Logger.error("Error emitting event", e2);
3776
3780
  }
3777
- }, _c2 = new WeakMap(), __publicField(_f, "_modelManager", MODEL_MANAGER), _f);
3781
+ }, _l = new WeakMap(), __publicField(_f, "_modelManager", MODEL_MANAGER), _f);
3778
3782
  async function handleWidgetMessage(e, r) {
3779
3783
  let c = r.model_id, l = r.message, u = ("buffers" in l ? l.buffers : []).map(base64ToDataView);
3780
3784
  switch (l.method) {
@@ -8084,7 +8088,7 @@ let __tla = Promise.all([
8084
8088
  async function runAnyWidgetModule(e, r, c, l, u) {
8085
8089
  l.innerHTML = "";
8086
8090
  try {
8087
- await (await BINDING_MANAGER.getOrCreate(c).bind(e, r))(l, u);
8091
+ await (await BINDING_MANAGER.getOrCreate(c).bind(e, r))(l, u), getMarimoInternal(r).reemitState();
8088
8092
  } catch (e2) {
8089
8093
  Logger.error("Error rendering anywidget", e2), l.classList.add("text-error"), l.innerHTML = `Error rendering anywidget: ${prettyError(e2)}`;
8090
8094
  }
@@ -10645,7 +10649,7 @@ ${indent(e)}
10645
10649
  return r.length === 0 ? [] : r.map(([e2, r2]) => new FunctionArg(e2, r2));
10646
10650
  }
10647
10651
  function generateAltairChart(e, r) {
10648
- var _a3, _b3, _c3;
10652
+ var _a3, _b3, _c2;
10649
10653
  let c = new FunctionCall("alt.Chart", [
10650
10654
  new Variable(r)
10651
10655
  ], true);
@@ -10669,7 +10673,7 @@ ${indent(e)}
10669
10673
  }
10670
10674
  if (e.resolve) {
10671
10675
  let r2 = e.resolve, l2 = {};
10672
- ((_b3 = r2.axis) == null ? void 0 : _b3.x) && (l2.x = new Literal(r2.axis.x)), ((_c3 = r2.axis) == null ? void 0 : _c3.y) && (l2.y = new Literal(r2.axis.y)), c = c.chain("resolve_scale", l2);
10676
+ ((_b3 = r2.axis) == null ? void 0 : _b3.x) && (l2.x = new Literal(r2.axis.x)), ((_c2 = r2.axis) == null ? void 0 : _c2.y) && (l2.y = new Literal(r2.axis.y)), c = c.chain("resolve_scale", l2);
10673
10677
  }
10674
10678
  let l = {};
10675
10679
  for (let r2 of [
@@ -11650,14 +11654,14 @@ ${c}
11650
11654
  defaultValue: f
11651
11655
  }), r[1] = c, r[2] = l, r[3] = f, r[4] = p) : p = r[4], p;
11652
11656
  }, BinFields = (e) => {
11653
- var _a3, _b3, _c3, _d3;
11657
+ var _a3, _b3, _c2, _d3;
11654
11658
  let r = (0, import_compiler_runtime$68.c)(10), { fieldName: c } = e, l = useFormContext(), u;
11655
11659
  r[0] === l.control ? u = r[1] : (u = {
11656
11660
  control: l.control
11657
11661
  }, r[0] = l.control, r[1] = u);
11658
11662
  let d = useWatch(u);
11659
11663
  if (!((_b3 = (_a3 = d[c]) == null ? void 0 : _a3.bin) == null ? void 0 : _b3.binned)) return null;
11660
- let f = !Number.isNaN((_d3 = (_c3 = d[c]) == null ? void 0 : _c3.bin) == null ? void 0 : _d3.step), p = `${c}.bin.step`, m;
11664
+ let f = !Number.isNaN((_d3 = (_c2 = d[c]) == null ? void 0 : _c2.bin) == null ? void 0 : _d3.step), p = `${c}.bin.step`, m;
11661
11665
  r[2] === p ? m = r[3] : (m = (0, import_jsx_runtime.jsx)(NumberField$1, {
11662
11666
  fieldName: p,
11663
11667
  label: "Bin step",
@@ -11872,7 +11876,7 @@ ${c}
11872
11876
  }), r[7] = c, r[8] = f, r[9] = p) : p = r[9], p;
11873
11877
  };
11874
11878
  const XAxis = () => {
11875
- var _a3, _b3, _c3, _d3, _e9, _f3, _g3;
11879
+ var _a3, _b3, _c2, _d3, _e9, _f3, _g3;
11876
11880
  let e = (0, import_compiler_runtime$67.c)(22), r = useFormContext(), c;
11877
11881
  e[0] === r.control ? c = e[1] : (c = {
11878
11882
  control: r.control
@@ -11902,7 +11906,7 @@ ${c}
11902
11906
  label: "Time Resolution"
11903
11907
  }), e[11] = d, e[12] = v);
11904
11908
  let y;
11905
- e[13] !== m || e[14] !== ((_c3 = (_b3 = l.general) == null ? void 0 : _b3.xColumn) == null ? void 0 : _c3.sort) || e[15] !== d ? (y = isNonCountField(d) && m && (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
11909
+ e[13] !== m || e[14] !== ((_c2 = (_b3 = l.general) == null ? void 0 : _b3.xColumn) == null ? void 0 : _c2.sort) || e[15] !== d ? (y = isNonCountField(d) && m && (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
11906
11910
  children: [
11907
11911
  (0, import_jsx_runtime.jsx)(SortField, {
11908
11912
  fieldName: "general.xColumn.sort",
@@ -11925,14 +11929,14 @@ ${c}
11925
11929
  ]
11926
11930
  }), e[17] = g, e[18] = _, e[19] = v, e[20] = y, e[21] = b) : b = e[21], b;
11927
11931
  }, YAxis = () => {
11928
- var _a3, _b3, _c3;
11932
+ var _a3, _b3, _c2;
11929
11933
  let e = (0, import_compiler_runtime$67.c)(29), r = useFormContext(), c;
11930
11934
  e[0] === r.control ? c = e[1] : (c = {
11931
11935
  control: r.control
11932
11936
  }, e[0] = r.control, e[1] = c);
11933
11937
  let l = useWatch(c), u = useChartFormContext(), d = (_a3 = l.general) == null ? void 0 : _a3.yColumn, f = d == null ? void 0 : d.field, p;
11934
11938
  e[2] === f ? p = e[3] : (p = isFieldSet(f), e[2] = f, e[3] = p);
11935
- let m = p, h = (_c3 = (_b3 = l.general) == null ? void 0 : _b3.xColumn) == null ? void 0 : _c3.field, g;
11939
+ let m = p, h = (_c2 = (_b3 = l.general) == null ? void 0 : _b3.xColumn) == null ? void 0 : _c2.field, g;
11936
11940
  e[4] === h ? g = e[5] : (g = isFieldSet(h), e[4] = h, e[5] = g);
11937
11941
  let _ = g, v;
11938
11942
  e[6] === d ? v = e[7] : (v = getColumnDataTypes(d), e[6] = d, e[7] = v);
@@ -12364,14 +12368,14 @@ ${c}
12364
12368
  }
12365
12369
  var import_compiler_runtime$65 = require_compiler_runtime();
12366
12370
  const HeatmapForm = () => {
12367
- var _a3, _b3, _c3, _d3;
12371
+ var _a3, _b3, _c2, _d3;
12368
12372
  let e = (0, import_compiler_runtime$65.c)(17), r = useFormContext(), c;
12369
12373
  e[0] === r.control ? c = e[1] : (c = {
12370
12374
  control: r.control
12371
12375
  }, e[0] = r.control, e[1] = c);
12372
12376
  let l = useWatch(c), u = (_b3 = (_a3 = l.general) == null ? void 0 : _a3.xColumn) == null ? void 0 : _b3.field, d;
12373
12377
  e[2] === u ? d = e[3] : (d = isFieldSet(u), e[2] = u, e[3] = d);
12374
- let f = d, p = (_d3 = (_c3 = l.general) == null ? void 0 : _c3.yColumn) == null ? void 0 : _d3.field, m;
12378
+ let f = d, p = (_d3 = (_c2 = l.general) == null ? void 0 : _c2.yColumn) == null ? void 0 : _d3.field, m;
12375
12379
  e[4] === p ? m = e[5] : (m = isFieldSet(p), e[4] = p, e[5] = m);
12376
12380
  let h = m, g;
12377
12381
  e[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (g = (0, import_jsx_runtime.jsx)(XAxis, {}), e[6] = g) : g = e[6];
@@ -12410,12 +12414,12 @@ ${c}
12410
12414
  };
12411
12415
  var import_compiler_runtime$64 = require_compiler_runtime();
12412
12416
  const PieForm = () => {
12413
- var _a3, _b3, _c3;
12417
+ var _a3, _b3, _c2;
12414
12418
  let e = (0, import_compiler_runtime$64.c)(25), r = useFormContext(), { fields: c } = useChartFormContext(), l;
12415
12419
  e[0] === r.control ? l = e[1] : (l = {
12416
12420
  control: r.control
12417
12421
  }, e[0] = r.control, e[1] = l);
12418
- let u = useWatch(l), d = (_a3 = u.general) == null ? void 0 : _a3.colorByColumn, f = (_c3 = (_b3 = u.general) == null ? void 0 : _b3.yColumn) == null ? void 0 : _c3.selectedDataType;
12422
+ let u = useWatch(l), d = (_a3 = u.general) == null ? void 0 : _a3.colorByColumn, f = (_c2 = (_b3 = u.general) == null ? void 0 : _b3.yColumn) == null ? void 0 : _c2.selectedDataType;
12419
12423
  (f === "" || !f) && (f = "string");
12420
12424
  let p;
12421
12425
  e[2] === d ? p = e[3] : (p = (d == null ? void 0 : d.type) ? convertDataTypeToSelectable(d.type) : "string", e[2] = d, e[3] = p);
@@ -24419,7 +24423,7 @@ ${c}
24419
24423
  });
24420
24424
  __privateSet(this, _t5, e), __privateSet(this, _n4, r.state), e.tabIndex = -1, e.role = "application", e.className = "relative inline-block select-none outline-hidden";
24421
24425
  let c = document.createElement("canvas");
24422
- c.className = "block cursor-crosshair", __privateMethod(this, _MatplotlibRenderer_instances, c_fn).call(this, c), c.style.touchAction = "none", e.append(c), __privateSet(this, _e8, c), c.addEventListener("pointerdown", __privateGet(this, _x), {
24426
+ 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), {
24423
24427
  signal: r.signal
24424
24428
  }), c.addEventListener("pointermove", __privateGet(this, _S), {
24425
24429
  signal: r.signal
@@ -24435,7 +24439,7 @@ ${c}
24435
24439
  let r = __privateGet(this, _n4);
24436
24440
  __privateSet(this, _n4, e);
24437
24441
  let c = false;
24438
- if ((e.width !== r.width || e.height !== r.height) && (__privateMethod(this, _MatplotlibRenderer_instances, c_fn).call(this), c = true), e.chartBase64 !== __privateGet(this, _s)) {
24442
+ if ((e.width !== r.width || e.height !== r.height) && (__privateMethod(this, _MatplotlibRenderer_instances, c_fn2).call(this), c = true), e.chartBase64 !== __privateGet(this, _s)) {
24439
24443
  __privateMethod(this, _MatplotlibRenderer_instances, u_fn).call(this, e.chartBase64);
24440
24444
  return;
24441
24445
  }
@@ -24446,12 +24450,12 @@ ${c}
24446
24450
  }
24447
24451
  (c || e.selectionColor !== r.selectionColor || e.selectionOpacity !== r.selectionOpacity || e.strokeWidth !== r.strokeWidth) && __privateGet(this, _d2).call(this);
24448
24452
  }
24449
- }, _e8 = new WeakMap(), _t5 = new WeakMap(), _n4 = new WeakMap(), _r2 = new WeakMap(), _i2 = new WeakMap(), _a2 = new WeakMap(), _o2 = new WeakMap(), _s = new WeakMap(), _MatplotlibRenderer_instances = new WeakSet(), c_fn = function(e = __privateGet(this, _e8)) {
24453
+ }, _e8 = new WeakMap(), _t5 = new WeakMap(), _n4 = new WeakMap(), _r2 = new WeakMap(), _i2 = new WeakMap(), _a2 = new WeakMap(), _o2 = new WeakMap(), _s = new WeakMap(), _MatplotlibRenderer_instances = new WeakSet(), c_fn2 = function(e = __privateGet(this, _e8)) {
24450
24454
  let r = globalThis.devicePixelRatio ?? 1, { width: c, height: l } = __privateGet(this, _n4);
24451
24455
  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}`;
24452
24456
  }, l_fn = function(e) {
24453
24457
  e.aborted || matchMedia(`(resolution: ${globalThis.devicePixelRatio ?? 1}dppx)`).addEventListener("change", () => {
24454
- __privateMethod(this, _MatplotlibRenderer_instances, c_fn).call(this), __privateGet(this, _d2).call(this), __privateMethod(this, _MatplotlibRenderer_instances, l_fn).call(this, e);
24458
+ __privateMethod(this, _MatplotlibRenderer_instances, c_fn2).call(this), __privateGet(this, _d2).call(this), __privateMethod(this, _MatplotlibRenderer_instances, l_fn).call(this, e);
24455
24459
  }, {
24456
24460
  once: true,
24457
24461
  signal: e
@@ -29882,8 +29886,8 @@ ${c}
29882
29886
  }
29883
29887
  }
29884
29888
  findDOMNode() {
29885
- var _a3, _b3, _c3;
29886
- return ((_a3 = this.props) == null ? void 0 : _a3.nodeRef) ? (_c3 = (_b3 = this.props) == null ? void 0 : _b3.nodeRef) == null ? void 0 : _c3.current : l.default.findDOMNode(this);
29889
+ var _a3, _b3, _c2;
29890
+ return ((_a3 = this.props) == null ? void 0 : _a3.nodeRef) ? (_c2 = (_b3 = this.props) == null ? void 0 : _b3.nodeRef) == null ? void 0 : _c2.current : l.default.findDOMNode(this);
29887
29891
  }
29888
29892
  render() {
29889
29893
  return r.cloneElement(r.Children.only(this.props.children), {
@@ -36217,7 +36221,7 @@ ${c}
36217
36221
  function _temp2$2(e) {
36218
36222
  e.target === e.currentTarget && e.key === "Enter" && (e.preventDefault(), e.stopPropagation(), e.currentTarget.click());
36219
36223
  }
36220
- var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-4A9WA6g8.js"));
36224
+ var LazySlidesComponent = import_react.lazy(() => import("./reveal-component-BR6oU-3V.js"));
36221
36225
  const SlidesLayoutRenderer = ({ layout: e, setLayout: r, cells: c, mode: l }) => {
36222
36226
  var _a3;
36223
36227
  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), [
@@ -9,7 +9,7 @@ import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
9
9
  import { lt as kioskModeAtom } from "./html-to-image-Di0mtt6O.js";
10
10
  import "./chunk-5FQGJX7Z-BbqSm5gU.js";
11
11
  import { u as createLucideIcon } from "./dist--2Bqjvs0.js";
12
- import { a as DEFAULT_SLIDE_TYPE, c as Slide, ct as PanelResizeHandle, i as DEFAULT_DECK_TRANSITION, in as Expand, ot as Panel, rn as EyeOff, s as SlideSidebar, sn as Code, st as PanelGroup, t as useNotebookCodeAvailable } from "./code-visibility-D7qOrRxp.js";
12
+ import { a as DEFAULT_SLIDE_TYPE, c as Slide, ct as PanelResizeHandle, i as DEFAULT_DECK_TRANSITION, in as Expand, ot as Panel, rn as EyeOff, s as SlideSidebar, sn as Code, st as PanelGroup, t as useNotebookCodeAvailable } from "./code-visibility-BY8oNoME.js";
13
13
  import { X as useDebouncedCallback } from "./input-CbEz_aj_.js";
14
14
  import "./toDate-D-l5s8nn.js";
15
15
  import "./react-dom-BTJzcVJ9.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.23.12-dev14",
3
+ "version": "0.23.12-dev19",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -11,7 +11,7 @@ import type { IPluginProps } from "@/plugins/types";
11
11
  import { prettyError } from "@/utils/errors";
12
12
  import { Logger } from "@/utils/Logger";
13
13
  import { ErrorBanner } from "../common/error-banner";
14
- import { MODEL_MANAGER, type Model } from "./model";
14
+ import { getMarimoInternal, MODEL_MANAGER, type Model } from "./model";
15
15
  import type { ModelState, WidgetModelId } from "./types";
16
16
  import { BINDING_MANAGER, WIDGET_DEF_REGISTRY } from "./widget-binding";
17
17
 
@@ -178,6 +178,9 @@ async function runAnyWidgetModule<T extends AnyWidgetState>(
178
178
  const binding = BINDING_MANAGER.getOrCreate(modelId);
179
179
  const render = await binding.bind(widgetDef, model);
180
180
  await render(el, signal);
181
+ // Replay current model values so render listeners observe hydrated state
182
+ // even if backend updates arrived before listeners were attached.
183
+ getMarimoInternal(model).reemitState();
181
184
  } catch (error) {
182
185
  Logger.error("Error rendering anywidget", error);
183
186
  el.classList.add("text-error");
@@ -115,4 +115,38 @@ describe("LoadedSlot", () => {
115
115
  expect(newMockWidget.render).toHaveBeenCalled();
116
116
  });
117
117
  });
118
+
119
+ it("should hydrate view state even when listener attaches late", async () => {
120
+ mockModel = new Model(
121
+ { count: 8 },
122
+ {
123
+ sendUpdate: vi.fn().mockResolvedValue(undefined),
124
+ sendCustomMessage: vi.fn().mockResolvedValue(undefined),
125
+ },
126
+ );
127
+ MODEL_MANAGER.set(modelId, mockModel);
128
+
129
+ const lateListenerWidget = {
130
+ initialize: vi.fn(),
131
+ render: vi.fn(({ model, el }) => {
132
+ // Simulate a widget view that starts with a local default and
133
+ // relies on change events for hydration.
134
+ el.textContent = "count is 5";
135
+ const onCount = () => {
136
+ el.textContent = `count is ${model.get("count")}`;
137
+ };
138
+ model.on("change:count", onCount);
139
+ return () => model.off("change:count", onCount);
140
+ }),
141
+ };
142
+
143
+ const { container } = render(
144
+ <LoadedSlot {...mockProps} widget={lateListenerWidget} />,
145
+ );
146
+
147
+ await waitFor(() => {
148
+ expect(lateListenerWidget.render).toHaveBeenCalled();
149
+ expect(container.textContent).toContain("count is 8");
150
+ });
151
+ });
118
152
  });
@@ -272,6 +272,25 @@ describe("Model", () => {
272
272
  });
273
273
  });
274
274
 
275
+ describe("reemitState", () => {
276
+ it("should emit change events for current values without state changes", async () => {
277
+ const onFoo = vi.fn();
278
+ const onBar = vi.fn();
279
+ const onAny = vi.fn();
280
+
281
+ model.on("change:foo", onFoo);
282
+ model.on("change:bar", onBar);
283
+ model.on("change", onAny);
284
+
285
+ getMarimoInternal(model).reemitState();
286
+ await TestUtils.nextTick();
287
+
288
+ expect(onFoo).toHaveBeenCalledWith("test");
289
+ expect(onBar).toHaveBeenCalledWith(123);
290
+ expect(onAny).toHaveBeenCalledTimes(1);
291
+ });
292
+ });
293
+
275
294
  describe("emitCustomMessage", () => {
276
295
  it("should handle custom messages", () => {
277
296
  const callback = vi.fn();
@@ -112,6 +112,10 @@ interface MarimoInternalApi<T extends ModelState> {
112
112
  * Update model state and emit change events for any differences.
113
113
  */
114
114
  updateAndEmitDiffs: (value: T) => void;
115
+ /**
116
+ * Re-emit current state as change events.
117
+ */
118
+ reemitState: () => void;
115
119
  /**
116
120
  * Emit a custom message to listeners.
117
121
  */
@@ -160,6 +164,7 @@ export class Model<T extends ModelState> implements AnyModel<T> {
160
164
  */
161
165
  [marimoSymbol]: MarimoInternalApi<T> = {
162
166
  updateAndEmitDiffs: (value: T) => this.#updateAndEmitDiffs(value),
167
+ reemitState: () => this.#reemitState(),
163
168
  emitCustomMessage: (
164
169
  message: Extract<AnyWidgetMessage, { method: "custom" }>,
165
170
  buffers?: readonly DataView[],
@@ -269,6 +274,16 @@ export class Model<T extends ModelState> implements AnyModel<T> {
269
274
  });
270
275
  }
271
276
 
277
+ #reemitState() {
278
+ for (const [key, value] of Object.entries(this.#data) as [
279
+ keyof T & string,
280
+ T[keyof T],
281
+ ][]) {
282
+ this.#emit(`change:${key}`, value);
283
+ }
284
+ this.#emitAnyChange();
285
+ }
286
+
272
287
  /**
273
288
  * When receiving a message from the backend.
274
289
  * We want to notify all listeners with `msg:custom`