@marimo-team/islands 0.25.3-dev21 → 0.25.3-dev24

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.
@@ -135,7 +135,7 @@ function F(e) {
135
135
  }
136
136
  //#endregion
137
137
  //#region src/components/editor/boundary/ErrorBoundary.tsx
138
- var I = (0, T.lazy)(() => import("./feedback-button-DVgw4Y7F.js").then((e) => ({ default: e.FeedbackModal }))), L = (e) => {
138
+ var I = (0, T.lazy)(() => import("./feedback-button-BL7Ed1J3.js").then((e) => ({ default: e.FeedbackModal }))), L = (e) => {
139
139
  let t = (0, w.c)(2), n;
140
140
  return t[0] === e.children ? n = t[1] : (n = /* @__PURE__ */ (0, j.jsx)(O, {
141
141
  FallbackComponent: R,
@@ -18,7 +18,7 @@ function x() {
18
18
  return e.warn("Failed to get version from mount config"), null;
19
19
  }
20
20
  }
21
- var S = x() || "0.25.3-dev21", C = u(S), w = u(!0);
21
+ var S = x() || "0.25.3-dev24", C = u(S), w = u(!0);
22
22
  u(null);
23
23
  //#endregion
24
24
  //#region src/core/wasm/state.ts
@@ -12,7 +12,7 @@ import { t as lt } from "./check-BMKBBrdc.js";
12
12
  import { A as ut, C as dt, M as ft, O as pt, S as mt, _ as ht, b as gt, c as _t, d as vt, g as yt, h as bt, i as xt, l as St, m as Ct, n as wt, p as Tt, s as Et, t as Dt, u as Ot, v as kt, y as At } from "./select-DemoKT4G.js";
13
13
  import { $ as jt, $t as Mt, A as Nt, At as Pt, B as Ft, Bt as It, Ct as Lt, D as Rt, Dt as zt, E as Bt, Et as Vt, F as Ht, Ft as Ut, G as Wt, Gt, H as Kt, Ht as qt, I as Jt, It as Yt, J as Xt, Jt as Zt, Kt as Qt, L as $t, Lt as en, M as tn, Mt as nn, N as rn, Nt as an, O as on, Ot as sn, P as cn, Pt as ln, Q as un, Qt as dn, R as fn, Rt as pn, S as mn, St as hn, T as gn, Tt as _n, U as vn, Ut as yn, V as bn, Vt as xn, W as Sn, Wt as Cn, X as wn, Xt as Tn, Y as En, Yt as Dn, Z as On, Zt as kn, _ as An, _n as jn, _t as Mn, a as Nn, at as Pn, b as Fn, bt as In, cn as Ln, ct as Rn, d as zn, dn as Bn, dt as Vn, et as Hn, f as Un, fn as Wn, ft as Gn, gn as Kn, gt as qn, h as Jn, hn as Yn, ht as Xn, i as Zn, in as Qn, it as $n, j as er, jt as tr, k as nr, kt as rr, l as ir, lt as ar, mn as or, mt as sr, n as cr, nn as lr, nt as ur, o as dr, on as fr, ot as pr, pn as mr, pt as hr, qt as gr, rn as _r, rt as vr, s as yr, sn as br, st as xr, t as Sr, tn as Cr, tt as wr, u as Tr, un as Er, vn as Dr, vt as Or, w as kr, wt as Ar, x as jr, xt as Mr, y as Nr, yt as Pr, z as Fr, zt as Ir } from "./dropdown-menu-DHP9P4VE.js";
14
14
  import { a as Lr, c as Rr, d as zr, i as Br, l as Vr, n as Hr, o as Ur, r as Wr, t as Gr, v as Kr, x as qr, y as Jr } from "./toDate-B5mIgxwZ.js";
15
- import { n as Yr, t as Xr } from "./ErrorBoundary-ttSr7_91.js";
15
+ import { n as Yr, t as Xr } from "./ErrorBoundary-LHjDFqXG.js";
16
16
  import { t as Zr } from "./clsx-CoeGtWvn.js";
17
17
  import { t as Qr } from "./react-dom-DUmH0GXv.js";
18
18
  import { t as $r } from "./jsx-runtime-3BD1kT0s.js";
@@ -2,7 +2,7 @@ import { a as e } from "./rolldown-runtime-Cb76FRpK.js";
2
2
  import { t } from "./react-sHtZdjeP.js";
3
3
  import { t as n } from "./react-dom-DUmH0GXv.js";
4
4
  import { c as r, l as i, u as a } from "./data-grid-types-BH_r7g7l.js";
5
- import { a as o, i as s, n as c, r as l } from "./glide-data-editor-CSYHMRDu.js";
5
+ import { a as o, i as s, n as c, r as l } from "./glide-data-editor-DPjObn47.js";
6
6
  //#region ../node_modules/.pnpm/@glideapps+glide-data-grid@6.0.4-alpha24_lodash@4.17.21_marked@15.0.12_react-dom@19.3.0_aca11a353ce3b112922852200b9c160f/node_modules/@glideapps/glide-data-grid/dist/esm/internal/data-grid-overlay-editor/data-grid-overlay-editor-style.js
7
7
  var u = /* @__PURE__ */ e(t(), 1), d = /* @__PURE__ */ e(n(), 1), f = /*#__PURE__*/ o("div")({
8
8
  name: "DataGridOverlayEditorStyle",
@@ -5,12 +5,12 @@ import { t as i } from "./compiler-runtime-CldRdSsv.js";
5
5
  import { t as a } from "./copy-icon-BgUO8jsi.js";
6
6
  import { Dt as o, G as s, It as c, K as l, Rt as u, V as d, dn as f, h as p, i as m, n as h } from "./error-entries-Damuuclv.js";
7
7
  import { b as g } from "./select-DemoKT4G.js";
8
- import { n as ee, t as te } from "./globals-Fpiwkv4D.js";
8
+ import { n as ee, t as te } from "./globals-DOHFyDcV.js";
9
9
  import { t as _ } from "./jsx-runtime-3BD1kT0s.js";
10
10
  import { C as v, _ as ne, i as y } from "./useTheme-BhQvec43.js";
11
11
  import { a as re, i as ie, n as ae, r as oe } from "./dialog-Cc479ZEH.js";
12
12
  import { t as se } from "./useAsyncData-BD534XmW.js";
13
- import { t as ce } from "./code-visibility-DPm4oWK1.js";
13
+ import { t as ce } from "./code-visibility-HTfE7PV1.js";
14
14
  //#region src/components/ui/skeleton.tsx
15
15
  var b = /* @__PURE__ */ e(r(), 1), x = i(), S = _(), le = (e) => {
16
16
  let n = (0, x.c)(8), r, i;
@@ -6,7 +6,7 @@ import { i as s, n as c, r as l } from "./copy-icon-BgUO8jsi.js";
6
6
  import { C as u, c as d, i as f, n as p, s as m, t as h, x as g } from "./select-DemoKT4G.js";
7
7
  import { d as _, h as v, i as y, l as b, n as x, o as S, s as C, t as w, u as T } from "./dropdown-menu-DHP9P4VE.js";
8
8
  import { c as E, d as D, l as O, n as k, o as A, s as ee, t as j, u as te } from "./glide-utils-DM9zBO4W.js";
9
- import { n as ne, t as re } from "./ErrorBoundary-ttSr7_91.js";
9
+ import { n as ne, t as re } from "./ErrorBoundary-LHjDFqXG.js";
10
10
  import { t as M } from "./react-dom-DUmH0GXv.js";
11
11
  import { t as N } from "./jsx-runtime-3BD1kT0s.js";
12
12
  import { t as ie } from "./label-DoysmLMW.js";
@@ -7062,7 +7062,7 @@ function rs(e, t, n, r, i) {
7062
7062
  }
7063
7063
  //#endregion
7064
7064
  //#region ../node_modules/.pnpm/@glideapps+glide-data-grid@6.0.4-alpha24_lodash@4.17.21_marked@15.0.12_react-dom@19.3.0_aca11a353ce3b112922852200b9c160f/node_modules/@glideapps/glide-data-grid/dist/esm/data-editor/data-editor.js
7065
- var is = /* @__PURE__ */ e(_r(), 1), as = /* @__PURE__ */ e(xr(), 1), os = K.lazy(async () => await import("./data-grid-overlay-editor-vxQ4E6k1.js")), ss = 0;
7065
+ var is = /* @__PURE__ */ e(_r(), 1), as = /* @__PURE__ */ e(xr(), 1), os = K.lazy(async () => await import("./data-grid-overlay-editor-UR0x91Ij.js")), ss = 0;
7066
7066
  function cs(e) {
7067
7067
  return (0, is.default)((0, as.default)((0, as.default)(e).filter((e) => e.span !== void 0).map((e) => (0, Za.default)((e.span?.[0] ?? 0) + 1, (e.span?.[1] ?? 0) + 1))));
7068
7068
  }
@@ -9293,7 +9293,7 @@ function Vs(e, t, n, r, i) {
9293
9293
  }
9294
9294
  //#endregion
9295
9295
  //#region ../node_modules/.pnpm/@glideapps+glide-data-grid@6.0.4-alpha24_lodash@4.17.21_marked@15.0.12_react-dom@19.3.0_aca11a353ce3b112922852200b9c160f/node_modules/@glideapps/glide-data-grid/dist/esm/cells/number-cell.js
9296
- var Hs = K.lazy(async () => await import("./number-overlay-editor-BOjqsq7D.js")), Us = {
9296
+ var Hs = K.lazy(async () => await import("./number-overlay-editor-B3cSnrr6.js")), Us = {
9297
9297
  getAccessibilityString: (e) => e.data?.toString() ?? "",
9298
9298
  kind: W.Number,
9299
9299
  needsHover: (e) => e.hoverEffect === !0,
@@ -1,6 +1,6 @@
1
1
  import { h as e } from "./tooltip-CtBZ5q8p.js";
2
2
  import { _ as t } from "./useTheme-BhQvec43.js";
3
- import { r as n } from "./code-visibility-DPm4oWK1.js";
3
+ import { r as n } from "./code-visibility-HTfE7PV1.js";
4
4
  var r = e("triangle-alert", [
5
5
  ["path", {
6
6
  d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
package/dist/main.js CHANGED
@@ -7,7 +7,7 @@ import { C as w, F as T, G as E, I as D, J as O, K as k, L as A, P as j, R as M,
7
7
  import { a as oe, d as se, f as ce, h as V, i as le, n as ue, o as de, r as fe, t as pe } from "./tooltip-CtBZ5q8p.js";
8
8
  import { $t as me, At as he, B as ge, Bt as _e, D as ve, Dt as ye, E as be, Et as xe, Ft as Se, Gt as Ce, J as we, Jt as Te, Kt as Ee, M as De, Mt as Oe, N as ke, O as Ae, Ot as je, Q as Me, R as Ne, S as Pe, Ut as Fe, V as Ie, Vt as Le, W as Re, Y as ze, Yt as Be, Z as Ve, _ as He, b as Ue, bt as We, cn as Ge, dt as Ke, en as qe, f as Je, fn as Ye, ft as Xe, g as Ze, gn as Qe, gt as $e, h as et, hn as tt, ht as nt, in as rt, j as it, jt as at, k as ot, kt as st, ln as ct, m as lt, nn as ut, nt as dt, o as ft, p as pt, pn as mt, q as ht, qt as gt, rt as _t, s as vt, sn as yt, st as bt, tn as xt, u as St, un as Ct, ut as wt, v as Tt, wt as Et, y as Dt, z as Ot, zt as kt } from "./error-entries-Damuuclv.js";
9
9
  import { D as At, E as jt, O as Mt, S as Nt, T as Pt, _ as Ft, a as It, c as Lt, d as Rt, f as zt, g as Bt, h as Vt, i as Ht, l as Ut, m as Wt, n as Gt, o as Kt, p as qt, r as Jt, s as Yt, t as Xt, u as Zt, v as Qt, w as $t, x as en, y as tn } from "./spec-BJzgmvVa.js";
10
- import { $t as nn, A as rn, At as an, B as on, Bt as sn, C as cn, Ct as ln, D as un, Dt as dn, E as fn, Et as pn, F as mn, Ft as hn, G as gn, Gt as _n, H as vn, Ht as yn, I as bn, It as xn, J as Sn, Jt as Cn, K as wn, Kt as Tn, L as En, Lt as Dn, M as On, Mt as kn, N as An, Nt as jn, O as Mn, Ot as Nn, P as Pn, Pt as Fn, Qt as In, R as Ln, Rt as Rn, S as zn, St as Bn, T as Vn, Tt as Hn, U as Un, Ut as Wn, V as Gn, Vt as Kn, W as qn, Wt as Jn, X as Yn, Xt as Xn, Y as Zn, Yt as Qn, Zt as $n, _ as er, _t as tr, an as nr, at as rr, b as ir, c as ar, cn as or, ct as sr, d as cr, dn as lr, dt as ur, en as dr, et as fr, f as pr, fn as mr, ft as hr, g as gr, gt as _r, h as vr, hn as yr, ht as br, in as xr, it as Sr, j as Cr, jt as wr, k as Tr, kt as Er, ln as Dr, lt as Or, m as kr, mn as Ar, mt as jr, nn as Mr, nt as Nr, ot as Pr, p as Fr, pn as Ir, pt as Lr, q as Rr, qt as zr, r as Br, rn as Vr, rt as Hr, sn as Ur, st as Wr, t as Gr, tn as Kr, tt as qr, u as Jr, un as Yr, ut as Xr, v as Zr, vt as Qr, w as $r, wt as ei, x as ti, y as ni, yt as ri, z as ii, zt as ai } from "./common-CeebhhhO.js";
10
+ import { $t as nn, A as rn, At as an, B as on, Bt as sn, C as cn, Ct as ln, D as un, Dt as dn, E as fn, Et as pn, F as mn, Ft as hn, G as gn, Gt as _n, H as vn, Ht as yn, I as bn, It as xn, J as Sn, Jt as Cn, K as wn, Kt as Tn, L as En, Lt as Dn, M as On, Mt as kn, N as An, Nt as jn, O as Mn, Ot as Nn, P as Pn, Pt as Fn, Qt as In, R as Ln, Rt as Rn, S as zn, St as Bn, T as Vn, Tt as Hn, U as Un, Ut as Wn, V as Gn, Vt as Kn, W as qn, Wt as Jn, X as Yn, Xt as Xn, Y as Zn, Yt as Qn, Zt as $n, _ as er, _t as tr, an as nr, at as rr, b as ir, c as ar, cn as or, ct as sr, d as cr, dn as lr, dt as ur, en as dr, et as fr, f as pr, fn as mr, ft as hr, g as gr, gt as _r, h as vr, hn as yr, ht as br, in as xr, it as Sr, j as Cr, jt as wr, k as Tr, kt as Er, ln as Dr, lt as Or, m as kr, mn as Ar, mt as jr, nn as Mr, nt as Nr, ot as Pr, p as Fr, pn as Ir, pt as Lr, q as Rr, qt as zr, r as Br, rn as Vr, rt as Hr, sn as Ur, st as Wr, t as Gr, tn as Kr, tt as qr, u as Jr, un as Yr, ut as Xr, v as Zr, vt as Qr, w as $r, wt as ei, x as ti, y as ni, yt as ri, z as ii, zt as ai } from "./common-1pRFQo1N.js";
11
11
  import { c as oi, i as si, n as ci, o as li, t as ui } from "./useLifecycle-BGWzTwHK.js";
12
12
  import { t as di } from "./check-BMKBBrdc.js";
13
13
  import { A as fi, C as pi, D as mi, E as hi, M as gi, O as _i, S as vi, T as yi, a as bi, b as xi, c as Si, i as Ci, k as wi, l as Ti, n as Ei, o as Di, r as Oi, s as ki, t as Ai, w as ji, x as Mi } from "./select-DemoKT4G.js";
@@ -15,8 +15,8 @@ import { $ as Ni, C as Pi, Et as Fi, J as Ii, K as Li, R as Ri, S as zi, U as Bi
15
15
  import { C as ua, _ as da, a as fa, b as pa, c as ma, f as ha, h as ga, m as _a, p as va, s as ya, u as ba, x as xa, y as Sa } from "./toDate-B5mIgxwZ.js";
16
16
  import { a as Ca, c as wa, d as Ta, f as Ea, i as Da, l as Oa, n as ka, o as Aa, r as ja, s as Ma, t as Na } from "./process-output-CTPTtxXB.js";
17
17
  import { a as Pa, c as Fa, d as Ia, i as La, l as Ra, r as za, u as Ba } from "./glide-utils-DM9zBO4W.js";
18
- import { n as Va, t as Ha } from "./ErrorBoundary-ttSr7_91.js";
19
- import { n as Ua, t as Wa } from "./globals-Fpiwkv4D.js";
18
+ import { n as Va, t as Ha } from "./ErrorBoundary-LHjDFqXG.js";
19
+ import { n as Ua, t as Wa } from "./globals-DOHFyDcV.js";
20
20
  import { t as Ga } from "./react-dom-DUmH0GXv.js";
21
21
  import { t as Ka } from "./jsx-runtime-3BD1kT0s.js";
22
22
  import { A as qa, B as Ja, C as H, Ct as Ya, Dt as Xa, Et as Za, F as Qa, G as $a, H as eo, I as to, J as no, K as ro, L as U, N as W, O as io, Ot as ao, P as G, Q as oo, R as so, S as co, St as lo, T as uo, Tt as fo, W as po, _ as mo, a as ho, b as go, bt as _o, c as vo, d as yo, et as bo, f as xo, g as So, h as Co, i as wo, j as To, k as Eo, m as Do, n as Oo, o as ko, p as Ao, pt as jo, r as Mo, s as No, tt as Po, u as Fo, v as Io, vt as Lo, w as K, wt as Ro, x as zo, xt as Bo, y as Vo, z as Ho } from "./use-restore-focus-CKjfFjLM.js";
@@ -39,7 +39,7 @@ import { t as Ms } from "./useAsyncData-BD534XmW.js";
39
39
  import { i as Ns, n as Ps, r as Fs } from "./formats-X4mMQWzX.js";
40
40
  import { M as Is, N as Ls } from "./vega-loader.browser-DNST6uVf.js";
41
41
  import { a as Rs, n as zs } from "./loader-BQOfjTIJ.js";
42
- import { c as Bs, d as Vs, i as Hs, l as Us, o as Ws, s as Gs, t as Ks, u as qs } from "./code-visibility-DPm4oWK1.js";
42
+ import { c as Bs, d as Vs, i as Hs, l as Us, o as Ws, s as Gs, t as Ks, u as qs } from "./code-visibility-HTfE7PV1.js";
43
43
  import { t as Js } from "./useDeepCompareMemoize-C72_RNsu.js";
44
44
  import { t as Ys } from "./esm-D2gTsXEV.js";
45
45
  //#region ../node_modules/.pnpm/iconify-icon@2.3.0/node_modules/iconify-icon/dist/iconify-icon.mjs
@@ -10533,7 +10533,7 @@ function VC(e, t) {
10533
10533
  }
10534
10534
  //#endregion
10535
10535
  //#region src/plugins/impl/DataEditorPlugin.tsx
10536
- var HC = J.lazy(() => import("./glide-data-editor-CSYHMRDu.js").then((e) => e.t)), UC = wS("marimo-data-editor", { cssStyles: [qS] }).withData(G({
10536
+ var HC = J.lazy(() => import("./glide-data-editor-DPjObn47.js").then((e) => e.t)), UC = wS("marimo-data-editor", { cssStyles: [qS] }).withData(G({
10537
10537
  initialValue: G({ edits: H(G({
10538
10538
  rowIdx: W(),
10539
10539
  columnId: U(),
@@ -30107,7 +30107,7 @@ function OR(e) {
30107
30107
  }
30108
30108
  //#endregion
30109
30109
  //#region src/components/editor/renderers/slides-layout/slides-layout.tsx
30110
- var kR = J.lazy(() => import("./reveal-component-Brpo7CP8.js")), AR = (e) => {
30110
+ var kR = J.lazy(() => import("./reveal-component-CFFzSsPX.js")), AR = (e) => {
30111
30111
  let t = (0, X.c)(33), { layout: n, setLayout: r, cells: i, mode: a } = e, o = ns(da), s = a === "read" || o, c = ns(He) > 1, [l, u] = (0, J.useState)(null), d;
30112
30112
  t[0] !== i || t[1] !== n ? (d = EP(i, n), t[0] = i, t[1] = n, t[2] = d) : d = t[2];
30113
30113
  let { slideCells: f, skippedIds: p, noOutputIds: m, slideTypes: h, startCellIndex: g } = d, _;
@@ -1,6 +1,6 @@
1
1
  import { a as e } from "./rolldown-runtime-Cb76FRpK.js";
2
2
  import { t } from "./react-sHtZdjeP.js";
3
- import { a as n } from "./glide-data-editor-CSYHMRDu.js";
3
+ import { a as n } from "./glide-data-editor-DPjObn47.js";
4
4
  //#region ../node_modules/.pnpm/@glideapps+glide-data-grid@6.0.4-alpha24_lodash@4.17.21_marked@15.0.12_react-dom@19.3.0_aca11a353ce3b112922852200b9c160f/node_modules/@glideapps/glide-data-grid/dist/esm/internal/data-grid-overlay-editor/private/number-overlay-editor-style.js
5
5
  var r = /* @__PURE__ */ e(t()), i = /*#__PURE__*/ n("div")({
6
6
  name: "NumberOverlayEditorStyle",
@@ -4,14 +4,14 @@ import { t as o } from "./react-sHtZdjeP.js";
4
4
  import { t as s } from "./compiler-runtime-CldRdSsv.js";
5
5
  import { h as c, t as l } from "./tooltip-CtBZ5q8p.js";
6
6
  import { O as u } from "./error-entries-Damuuclv.js";
7
- import { $ as d, Q as f, Z as p, an as m, i as h, l as g, ln as _, n as v, on as y, r as b, t as x, u as S } from "./common-CeebhhhO.js";
7
+ import { $ as d, Q as f, Z as p, an as m, i as h, l as g, ln as _, n as v, on as y, r as b, t as x, u as S } from "./common-1pRFQo1N.js";
8
8
  import { M as C } from "./select-DemoKT4G.js";
9
9
  import { q as ee } from "./dropdown-menu-DHP9P4VE.js";
10
10
  import { _ as w } from "./toDate-B5mIgxwZ.js";
11
11
  import { t as T } from "./jsx-runtime-3BD1kT0s.js";
12
12
  import { X as E } from "./use-restore-focus-CKjfFjLM.js";
13
13
  import { A as D, C as O, b as k } from "./useTheme-BhQvec43.js";
14
- import { a as A, n as te, t as ne } from "./code-visibility-DPm4oWK1.js";
14
+ import { a as A, n as te, t as ne } from "./code-visibility-HTfE7PV1.js";
15
15
  /* empty css */
16
16
  var j = c("sticky-note", [["path", {
17
17
  d: "M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.25.3-dev21",
3
+ "version": "0.25.3-dev24",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -3,7 +3,7 @@
3
3
  import { describe, expect, it } from "vitest";
4
4
  import type { NotebookEvent } from "../events";
5
5
  import type { Resource } from "../resources/resource";
6
- import { createStream, type Stream, type StreamState } from "../stream";
6
+ import { createStream } from "../stream";
7
7
  import { fixtureEvents } from "./fixtures";
8
8
 
9
9
  interface CellIds {
@@ -54,17 +54,15 @@ const revisions: Resource<Revisions> = {
54
54
  },
55
55
  };
56
56
 
57
- interface Resources {
58
- cells: CellIds;
59
- revisions: Revisions;
57
+ function createTestStream() {
58
+ return createStream({ cells, revisions });
60
59
  }
61
- type State = StreamState<Resources>;
62
60
 
63
61
  function replay(
64
- stream: Stream<Resources>,
62
+ stream: ReturnType<typeof createTestStream>,
65
63
  events: readonly NotebookEvent[],
66
- from: State = stream.initial,
67
- ): State {
64
+ from = stream.initial,
65
+ ) {
68
66
  return events.reduce((state, event) => stream.reduce(state, event), from);
69
67
  }
70
68
 
@@ -77,7 +75,7 @@ if (cellEvent?.event !== "cell") {
77
75
 
78
76
  describe("notebook stream", () => {
79
77
  it("reads the snapshot, goes live at ready, and rebuilds after reset", () => {
80
- const stream = createStream({ cells, revisions });
78
+ const stream = createTestStream();
81
79
  const partial = replay(stream, snapshot.slice(0, ready));
82
80
  expect(partial).toMatchObject({
83
81
  phase: "snapshot",
@@ -105,7 +103,7 @@ describe("notebook stream", () => {
105
103
  });
106
104
 
107
105
  it("keeps resource state by reference when an event does not apply", () => {
108
- const stream = createStream({ cells, revisions });
106
+ const stream = createTestStream();
109
107
  const state = replay(stream, snapshot);
110
108
  const runtime = snapshot.find((event) => event.event === "runtime");
111
109
  const unhandled = stream.reduce(state, { ...runtime!, id: "100" });
@@ -121,7 +119,7 @@ describe("notebook stream", () => {
121
119
  });
122
120
 
123
121
  it("clears resources when its notebook is removed and ignores other notebooks", () => {
124
- const stream = createStream({ cells, revisions });
122
+ const stream = createTestStream();
125
123
  const state = replay(stream, snapshot);
126
124
  const time = "2026-10-01T09:30:00Z";
127
125
  expect(
@@ -141,7 +139,7 @@ describe("notebook stream", () => {
141
139
  });
142
140
 
143
141
  it("rejects objects from another notebook", () => {
144
- const stream = createStream({ cells, revisions });
142
+ const stream = createTestStream();
145
143
  const state = replay(stream, snapshot.slice(0, ready));
146
144
  const notebook = snapshot[0];
147
145
  if (notebook.event !== "notebook") {
@@ -162,7 +160,7 @@ describe("notebook stream", () => {
162
160
  });
163
161
 
164
162
  it("records each live event's cursor and resumes in place", () => {
165
- const stream = createStream({ cells, revisions });
163
+ const stream = createTestStream();
166
164
  const partial = replay(stream, snapshot.slice(0, ready));
167
165
  expect(stream.resume(partial)).toEqual({
168
166
  ...stream.initial,
@@ -195,7 +193,7 @@ describe("notebook stream", () => {
195
193
  });
196
194
 
197
195
  it("requires a cursor on live events other than reset and notifications", () => {
198
- const stream = createStream({ cells, revisions });
196
+ const stream = createTestStream();
199
197
  const state = replay(stream, snapshot);
200
198
  expect(() => stream.reduce(state, cellEvent)).toThrow("cursor");
201
199
  expect(
@@ -27,7 +27,7 @@ interface PendingDocument {
27
27
  * A snapshot's records are pending until `ready`. A live revision is pending
28
28
  * from its first cell until its `document` event.
29
29
  */
30
- export interface DocumentState {
30
+ interface DocumentState {
31
31
  readonly current: Document | null;
32
32
  readonly pending: PendingDocument | null;
33
33
  }
@@ -2,36 +2,24 @@
2
2
 
3
3
  import type * as Protocol from "../protocol";
4
4
 
5
- /** An event name from the protocol. */
6
- export type EventName = Protocol.EventOutput["event"];
7
-
8
- /** The decoded event with the given name. */
9
- export type EventOf<Name extends EventName> = Extract<
10
- Protocol.EventOutput,
11
- { event: Name }
12
- >;
13
-
14
5
  /**
15
6
  * Events the stream handles itself.
16
7
  *
17
8
  * They identify the notebook, discard state, or carry a native
18
9
  * notification. Resources do not receive them.
19
10
  */
20
- export type StreamEventName =
21
- | "reset"
22
- | "notebook"
23
- | "notebook.removed"
24
- | "marimo";
11
+ type StreamEventName = "reset" | "notebook" | "notebook.removed" | "marimo";
25
12
 
26
13
  /** Events a resource may handle. `ready` marks the end of the snapshot. */
27
- export type ResourceEventName = Exclude<EventName, StreamEventName>;
28
-
29
- /** `snapshot` until `ready` arrives and `live` after it. */
30
- export type StreamPhase = "snapshot" | "live";
14
+ export type ResourceEvent = Exclude<
15
+ Protocol.EventOutput,
16
+ { event: StreamEventName }
17
+ >;
31
18
 
32
19
  /** What a handler may know about the stream beyond the event. */
33
20
  export interface HandlerContext {
34
- readonly phase: StreamPhase;
21
+ /** `snapshot` until `ready` arrives and `live` after it. */
22
+ readonly phase: "snapshot" | "live";
35
23
  }
36
24
 
37
25
  /**
@@ -39,10 +27,10 @@ export interface HandlerContext {
39
27
  *
40
28
  * A handler returns `state` when the event does not apply to it.
41
29
  */
42
- export type EventHandlers<State> = {
43
- readonly [Name in ResourceEventName]?: (
30
+ type EventHandlers<State> = {
31
+ readonly [Name in ResourceEvent["event"]]?: (
44
32
  state: State,
45
- event: EventOf<Name>,
33
+ event: Extract<ResourceEvent, { event: Name }>,
46
34
  context: HandlerContext,
47
35
  ) => State;
48
36
  };
@@ -3,15 +3,13 @@
3
3
  import type { NotebookEvent } from "./events";
4
4
  import type * as Protocol from "./protocol";
5
5
  import type {
6
- EventOf,
7
6
  HandlerContext,
8
7
  Resource,
9
- ResourceEventName,
10
- StreamPhase,
8
+ ResourceEvent,
11
9
  } from "./resources/resource";
12
10
 
13
11
  /** A resource for each entry of a state map under the same name. */
14
- export type Resources<States> = {
12
+ type Resources<States> = {
15
13
  readonly [Name in keyof States]: Resource<States[Name]>;
16
14
  };
17
15
 
@@ -21,8 +19,8 @@ export type Resources<States> = {
21
19
  * Holds the phase, the notebook identity, the resume cursor, and the state
22
20
  * of each resource.
23
21
  */
24
- export interface StreamState<States> {
25
- readonly phase: StreamPhase;
22
+ interface StreamState<States> {
23
+ readonly phase: HandlerContext["phase"];
26
24
  /**
27
25
  * The notebook the stream describes.
28
26
  *
@@ -40,7 +38,7 @@ export interface StreamState<States> {
40
38
  }
41
39
 
42
40
  /** A reducer over the events of one notebook stream. */
43
- export interface Stream<States> {
41
+ interface Stream<States> {
44
42
  readonly initial: StreamState<States>;
45
43
  /**
46
44
  * Apply one event.
@@ -71,7 +69,7 @@ const UNCURSORED = new Set<NotebookEvent["event"]>([
71
69
  * Undefined for objects that do not name one.
72
70
  */
73
71
  function notebookIdOf(
74
- event: EventOf<ResourceEventName>,
72
+ event: ResourceEvent,
75
73
  ): Protocol.NotebookIdOutput | undefined {
76
74
  switch (event.event) {
77
75
  case "document":
@@ -127,7 +125,7 @@ export function createStream<States extends object>(
127
125
 
128
126
  function fanOut(
129
127
  state: StreamState<States>,
130
- event: EventOf<ResourceEventName>,
128
+ event: ResourceEvent,
131
129
  ): StreamState<States> {
132
130
  const context: HandlerContext = { phase: state.phase };
133
131
  let next = state.resources;
package/src/utils/once.ts CHANGED
@@ -2,36 +2,36 @@
2
2
 
3
3
  import { arrayShallowEquals } from "./arrays";
4
4
 
5
- // oxlint-disable-next-line typescript/no-explicit-any
6
- export function once<T extends (...args: any[]) => any>(fn: T): T {
7
- let result: ReturnType<T>;
5
+ export function once<F extends (...args: never[]) => unknown>(fn: F): F;
6
+ export function once<Args extends unknown[], Result, This>(
7
+ fn: (this: This, ...args: Args) => Result,
8
+ ): (this: This, ...args: Args) => Result {
9
+ let result: Result;
8
10
  let called = false;
9
- return function (
10
- this: ThisParameterType<T>,
11
- ...args: Parameters<T>
12
- ): ReturnType<T> {
11
+ return function (this: This, ...args: Args): Result {
13
12
  if (!called) {
14
13
  called = true;
15
- result = fn.apply(this, args) as ReturnType<T>;
14
+ result = fn.apply(this, args);
16
15
  }
17
16
  return result;
18
- } as T;
17
+ };
19
18
  }
20
19
 
21
- // oxlint-disable-next-line typescript/no-explicit-any
22
- export function memoizeLastValue<T extends (...args: any[]) => any>(fn: T): T {
23
- let result: ReturnType<T>;
24
- let lastArgs: Parameters<T> | undefined;
20
+ export function memoizeLastValue<F extends (...args: never[]) => unknown>(
21
+ fn: F,
22
+ ): F;
23
+ export function memoizeLastValue<Args extends unknown[], Result, This>(
24
+ fn: (this: This, ...args: Args) => Result,
25
+ ): (this: This, ...args: Args) => Result {
26
+ let result: Result;
27
+ let lastArgs: Args | undefined;
25
28
  let lastError: unknown;
26
29
  let hasError = false;
27
30
 
28
- return function (
29
- this: ThisParameterType<T>,
30
- ...args: Parameters<T>
31
- ): ReturnType<T> {
31
+ return function (this: This, ...args: Args): Result {
32
32
  if (lastArgs === undefined || !arrayShallowEquals(args, lastArgs)) {
33
33
  try {
34
- result = fn.apply(this, args) as ReturnType<T>;
34
+ result = fn.apply(this, args);
35
35
  hasError = false;
36
36
  lastError = undefined;
37
37
  } catch (error) {
@@ -45,5 +45,5 @@ export function memoizeLastValue<T extends (...args: any[]) => any>(fn: T): T {
45
45
  throw lastError;
46
46
  }
47
47
  return result;
48
- } as T;
48
+ };
49
49
  }