@marimo-team/islands 0.25.3-dev440 → 0.25.3-dev442

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.
@@ -148,7 +148,7 @@ function L(e) {
148
148
  }
149
149
  //#endregion
150
150
  //#region src/components/editor/boundary/ErrorBoundary.tsx
151
- var R = (0, T.lazy)(() => import("./feedback-button-DDw8qIfP.js").then((e) => ({ default: e.FeedbackModal }))), z = (e) => {
151
+ var R = (0, T.lazy)(() => import("./feedback-button-fTeumvLO.js").then((e) => ({ default: e.FeedbackModal }))), z = (e) => {
152
152
  let t = (0, w.c)(2), n;
153
153
  return t[0] === e.children ? n = t[1] : (n = /* @__PURE__ */ (0, N.jsx)(O, {
154
154
  FallbackComponent: B,
@@ -14,7 +14,7 @@ function y() {
14
14
  return e.warn("Failed to get version from mount config"), null;
15
15
  }
16
16
  }
17
- var b = y() || "0.25.3-dev440", x = s(b), S = s(!0);
17
+ var b = y() || "0.25.3-dev442", x = s(b), S = s(!0);
18
18
  s(null);
19
19
  //#endregion
20
20
  //#region src/core/wasm/state.ts
@@ -33,7 +33,7 @@ import { o as xa } from "./dist-DNkrY12t.js";
33
33
  import { a as Sa, i as Ca, n as wa, o as Ta, r as Ea, t as Da } from "./dialog-rgayPemF.js";
34
34
  import { t as Oa } from "./useAsyncData-P5-Oovhq.js";
35
35
  import { n as W, t as G } from "./objectWithoutPropertiesLoose-BRDcTsfB.js";
36
- import { n as ka, t as Aa } from "./ErrorBoundary-BmvTbIKd.js";
36
+ import { n as ka, t as Aa } from "./ErrorBoundary-B_hGxYfn.js";
37
37
  import { W as ja, n as Ma } from "./vega-loader.browser-Co9gYE8Z.js";
38
38
  import { a as Na, n as Pa, r as Fa, t as Ia } from "./loader-Bin_dutt.js";
39
39
  import { t as La } from "./useIframeCapabilities-HTZiVlGV.js";
@@ -2,7 +2,7 @@ import { a as e } from "./rolldown-runtime-BPCzCO3I.js";
2
2
  import { t } from "./react-Bgs_wQh3.js";
3
3
  import { t as n } from "./react-dom-DdqGVp5N.js";
4
4
  import { c as r, l as i, u as a } from "./data-grid-types-DIX_pCco.js";
5
- import { a as o, i as s, n as c, r as l } from "./glide-data-editor-B6_KvoZ3.js";
5
+ import { a as o, i as s, n as c, r as l } from "./glide-data-editor-CmgFgZPU.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.1_57c124ac5a994dbbf13fd11838cf9ba9/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",
@@ -4,13 +4,13 @@ import { t as r } from "./react-Bgs_wQh3.js";
4
4
  import { t as i } from "./compiler-runtime-C5KHtL5D.js";
5
5
  import { t as a } from "./copy-icon-CDvvlY90.js";
6
6
  import { D as o, E as s, F as c, G as l, N as u, Yt as d, en as f, i as p, n as m } from "./error-entries-CNB7O2yS.js";
7
- import { n as h, t as ee } from "./globals-CmfHIWMY.js";
7
+ import { n as h, t as ee } from "./globals-D5aEY9Bf.js";
8
8
  import { r as g } from "./assertNever-DOTNJ2Y4.js";
9
9
  import { t as _ } from "./jsx-runtime-D8btoEHk.js";
10
10
  import { Rt as v, St as te, m as y } from "./use-restore-focus-BLj45Ibw.js";
11
11
  import { a as ne, i as re, n as ie, r as ae } from "./dialog-rgayPemF.js";
12
12
  import { t as oe } from "./useAsyncData-P5-Oovhq.js";
13
- import { t as se } from "./code-visibility-DrVy3Nt1.js";
13
+ import { t as se } from "./code-visibility-CfcaPeDp.js";
14
14
  //#region src/components/ui/skeleton.tsx
15
15
  var b = /* @__PURE__ */ e(r(), 1), x = i(), S = _(), ce = (e) => {
16
16
  let n = (0, x.c)(8), r, i;
@@ -14,7 +14,7 @@ import { t as F } from "./jsx-runtime-D8btoEHk.js";
14
14
  import { d as ae, r as I } from "./use-restore-focus-BLj45Ibw.js";
15
15
  import { t as oe } from "./useEvent-BoN7U38T.js";
16
16
  import { n as L, t as se } from "./objectWithoutPropertiesLoose-BRDcTsfB.js";
17
- import { t as ce } from "./ErrorBoundary-BmvTbIKd.js";
17
+ import { t as ce } from "./ErrorBoundary-B_hGxYfn.js";
18
18
  import { A as le, C as ue, D as de, E as fe, F as pe, I as me, L as he, M as ge, N as R, O as z, P as _e, R as ve, S as ye, T as be, _ as xe, a as Se, b as B, c as Ce, d as we, f as V, g as Te, h as Ee, i as De, j as H, k as Oe, l as ke, m as Ae, n as je, o as Me, p as Ne, r as U, s as Pe, t as Fe, u as Ie, v as Le, w as Re, x as ze, y as Be, z as Ve } from "./data-grid-types-DIX_pCco.js";
19
19
  //#region ../node_modules/.pnpm/@emotion+memoize@0.9.0/node_modules/@emotion/memoize/dist/emotion-memoize.esm.js
20
20
  function He(e) {
@@ -7061,7 +7061,7 @@ function ds(e, t, n, r, i) {
7061
7061
  }
7062
7062
  //#endregion
7063
7063
  //#region ../node_modules/.pnpm/@glideapps+glide-data-grid@6.0.4-alpha24_lodash@4.17.21_marked@15.0.12_react-dom@19.3.1_57c124ac5a994dbbf13fd11838cf9ba9/node_modules/@glideapps/glide-data-grid/dist/esm/data-editor/data-editor.js
7064
- var fs = /* @__PURE__ */ e(Tr(), 1), ps = /* @__PURE__ */ e(kr(), 1), ms = W.lazy(async () => await import("./data-grid-overlay-editor-CtqDeMah.js")), hs = 0;
7064
+ var fs = /* @__PURE__ */ e(Tr(), 1), ps = /* @__PURE__ */ e(kr(), 1), ms = W.lazy(async () => await import("./data-grid-overlay-editor-BtD0R-rP.js")), hs = 0;
7065
7065
  function gs(e) {
7066
7066
  return (0, fs.default)((0, ps.default)((0, ps.default)(e).filter((e) => e.span !== void 0).map((e) => (0, ao.default)((e.span?.[0] ?? 0) + 1, (e.span?.[1] ?? 0) + 1))));
7067
7067
  }
@@ -9284,7 +9284,7 @@ function Ys(e, t, n, r, i) {
9284
9284
  }
9285
9285
  //#endregion
9286
9286
  //#region ../node_modules/.pnpm/@glideapps+glide-data-grid@6.0.4-alpha24_lodash@4.17.21_marked@15.0.12_react-dom@19.3.1_57c124ac5a994dbbf13fd11838cf9ba9/node_modules/@glideapps/glide-data-grid/dist/esm/cells/number-cell.js
9287
- var Xs = W.lazy(async () => await import("./number-overlay-editor-DvKc0Woa.js")), Zs = {
9287
+ var Xs = W.lazy(async () => await import("./number-overlay-editor-D8Uvv7Rs.js")), Zs = {
9288
9288
  getAccessibilityString: (e) => e.data?.toString() ?? "",
9289
9289
  kind: U.Number,
9290
9290
  needsHover: (e) => e.hoverEffect === !0,
@@ -1,6 +1,6 @@
1
1
  import { h as e } from "./tooltip-CiJ919pg.js";
2
2
  import { St as t } from "./use-restore-focus-BLj45Ibw.js";
3
- import { r as n } from "./code-visibility-DrVy3Nt1.js";
3
+ import { r as n } from "./code-visibility-CfcaPeDp.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
@@ -6,7 +6,7 @@ import { i as x, n as S, r as C, t as w } from "./copy-icon-CDvvlY90.js";
6
6
  import { B as T, Bt as E, Ct as D, E as O, F as k, Ft as A, I as j, It as M, L as N, Lt as P, M as F, Mt as I, O as L, Ot as R, P as z, R as B, Rt as ee, St as te, Ut as ne, Vt as re, Wt as ie, X as ae, Z as oe, _ as se, _t as ce, a as le, at as ue, b as de, bt as fe, c as pe, ct as me, dt as he, i as ge, it as _e, j as ve, kt as ye, lt as be, mt as xe, n as Se, o as Ce, ot as we, q as Te, rt as Ee, ut as De, vt as Oe, yt as ke, z as Ae, zt as je } from "./html-to-image-B0UiwmMu.js";
7
7
  import { a as Me, f as Ne, h as Pe, i as Fe, m as Ie, n as Le, o as Re, r as ze, t as Be } from "./tooltip-CiJ919pg.js";
8
8
  import { D as Ve, E as He, S as Ue, T as We, _ as Ge, a as Ke, c as qe, d as Je, f as Ye, g as Xe, h as Ze, i as Qe, l as $e, m as et, n as tt, o as nt, p as rt, r as it, s as at, t as ot, u as st, v as ct, w as lt, x as ut, y as dt } from "./spec-6shN7lEe.js";
9
- import { $t as ft, A as pt, At as mt, B as ht, Bt as gt, C as _t, Cn as vt, Ct as yt, D as bt, Dn as xt, Dt as St, E as Ct, En as wt, Et as Tt, F as Et, Ft as Dt, G as Ot, Gt as kt, H as At, Ht as jt, I as Mt, It as Nt, J as Pt, Jt as Ft, K as It, Kt as Lt, L as Rt, Lt as zt, M as Bt, Mt as Vt, N as Ht, Nt as Ut, O as Wt, On as Gt, Ot as Kt, P as qt, Pt as Jt, Qt as Yt, R as Xt, Rt as Zt, S as Qt, Sn as $t, T as en, Tn as tn, Tt as nn, U as rn, Ut as an, V as on, Vt as sn, W as cn, Wt as ln, X as un, Xt as dn, Y as fn, Yt as pn, Z as mn, Zt as hn, _ as gn, _n, _t as vn, an as yn, at as bn, b as xn, bt as Sn, c as Cn, cn as wn, ct as Tn, d as En, dn as Dn, dt as On, en as kn, f as An, fn as jn, ft as Mn, g as Nn, gn as Pn, gt as Fn, h as In, hn as Ln, ht as Rn, in as zn, it as Bn, j as Vn, jt as Hn, k as Un, kn as Wn, kt as Gn, ln as Kn, lt as qn, m as Jn, mn as Yn, mt as Xn, nn as Zn, nt as Qn, on as $n, ot as er, p as tr, pn as nr, pt as rr, q as ir, qt as ar, r as or, rn as sr, rt as cr, sn as lr, st as ur, t as dr, tn as fr, tt as pr, u as mr, un as hr, ut as gr, v as _r, vn as vr, vt as yr, w as br, wn as xr, wt as Sr, x as Cr, xn as wr, y as Tr, yn as Er, yt as Dr, z as Or, zt as kr } from "./common-DolvV945.js";
9
+ import { $t as ft, A as pt, At as mt, B as ht, Bt as gt, C as _t, Cn as vt, Ct as yt, D as bt, Dn as xt, Dt as St, E as Ct, En as wt, Et as Tt, F as Et, Ft as Dt, G as Ot, Gt as kt, H as At, Ht as jt, I as Mt, It as Nt, J as Pt, Jt as Ft, K as It, Kt as Lt, L as Rt, Lt as zt, M as Bt, Mt as Vt, N as Ht, Nt as Ut, O as Wt, On as Gt, Ot as Kt, P as qt, Pt as Jt, Qt as Yt, R as Xt, Rt as Zt, S as Qt, Sn as $t, T as en, Tn as tn, Tt as nn, U as rn, Ut as an, V as on, Vt as sn, W as cn, Wt as ln, X as un, Xt as dn, Y as fn, Yt as pn, Z as mn, Zt as hn, _ as gn, _n, _t as vn, an as yn, at as bn, b as xn, bt as Sn, c as Cn, cn as wn, ct as Tn, d as En, dn as Dn, dt as On, en as kn, f as An, fn as jn, ft as Mn, g as Nn, gn as Pn, gt as Fn, h as In, hn as Ln, ht as Rn, in as zn, it as Bn, j as Vn, jt as Hn, k as Un, kn as Wn, kt as Gn, ln as Kn, lt as qn, m as Jn, mn as Yn, mt as Xn, nn as Zn, nt as Qn, on as $n, ot as er, p as tr, pn as nr, pt as rr, q as ir, qt as ar, r as or, rn as sr, rt as cr, sn as lr, st as ur, t as dr, tn as fr, tt as pr, u as mr, un as hr, ut as gr, v as _r, vn as vr, vt as yr, w as br, wn as xr, wt as Sr, x as Cr, xn as wr, y as Tr, yn as Er, yt as Dr, z as Or, zt as kr } from "./common-DT7Dfm5X.js";
10
10
  import { a as Ar, n as jr, s as Mr, t as Nr } from "./useLifecycle-mKiMNa4V.js";
11
11
  import { t as Pr } from "./check-CApwK1fD.js";
12
12
  import { A as Fr, C as Ir, D as Lr, M as Rr, O as zr, a as Br, c as Vr, d as Hr, i as Ur, k as Wr, l as Gr, n as Kr, o as qr, r as Jr, s as Yr, t as Xr, w as Zr, x as Qr } from "./select-PQHWLm64.js";
@@ -16,7 +16,7 @@ import { At as Bi, B as Vi, Dt as Hi, E as Ui, Ft as Wi, G as Gi, Ht as Ki, J as
16
16
  import { a as Oa, d as ka, i as Aa, n as ja, o as Ma, r as Na, s as Pa, t as Fa, u as Ia } from "./process-output-3Epq3rw6.js";
17
17
  import { t as La } from "./pencil-BC7pOv9g.js";
18
18
  import { a as Ra, c as za, d as Ba, f as Va, i as Ha, l as Ua, r as Wa } from "./glide-utils-D1McS0Pn.js";
19
- import { n as Ga, t as Ka } from "./globals-CmfHIWMY.js";
19
+ import { n as Ga, t as Ka } from "./globals-D5aEY9Bf.js";
20
20
  import { a as qa, i as Ja, n as Ya, r as Xa, s as Za, t as Qa } from "./assertNever-DOTNJ2Y4.js";
21
21
  import { t as $a } from "./react-dom-DdqGVp5N.js";
22
22
  import { t as eo } from "./jsx-runtime-D8btoEHk.js";
@@ -40,10 +40,10 @@ import { n as Zs, t as Qs } from "./esm-Bwp_FHP0.js";
40
40
  import { p as $s } from "./dist-DpYpG8Yc.js";
41
41
  import { t as ec } from "./useAsyncData-P5-Oovhq.js";
42
42
  import { n as tc, r as nc, t as rc } from "./useDeepCompareMemoize-CDhinwm7.js";
43
- import { t as ic } from "./ErrorBoundary-BmvTbIKd.js";
43
+ import { t as ic } from "./ErrorBoundary-B_hGxYfn.js";
44
44
  import { G as ac, W as oc } from "./vega-loader.browser-Co9gYE8Z.js";
45
45
  import { a as sc, n as cc } from "./loader-Bin_dutt.js";
46
- import { a as lc, c as uc, i as dc, l as fc, o as pc, s as mc, t as hc } from "./code-visibility-DrVy3Nt1.js";
46
+ import { a as lc, c as uc, i as dc, l as fc, o as pc, s as mc, t as hc } from "./code-visibility-CfcaPeDp.js";
47
47
  import { t as gc } from "./esm-B9n0caHs.js";
48
48
  //#region ../node_modules/.pnpm/iconify-icon@2.3.0/node_modules/iconify-icon/dist/iconify-icon.mjs
49
49
  var _c = Object.freeze({
@@ -8586,7 +8586,7 @@ function zx(e, t, n, r = lx) {
8586
8586
  }
8587
8587
  //#endregion
8588
8588
  //#region src/core/notebook/document/sync.ts
8589
- var Bx = 6e4, Vx = 1e4, Hx = 3, Ux = 400;
8589
+ var Bx = 6e4, Vx = 1e4, Hx = 3, Ux = 100;
8590
8590
  function Wx(e, t) {
8591
8591
  return new Promise((n, r) => {
8592
8592
  let i = () => r(t.reason);
@@ -8623,11 +8623,10 @@ function Kx({ store: e, documentAtom: t, backendAtom: n, state: r, signal: i })
8623
8623
  try {
8624
8624
  let i = e.get(t);
8625
8625
  if (s && (e.get(n) !== s.backend || i && i.revision.notebook_id !== s.submission.notebookId) && s.controller.abort(/* @__PURE__ */ Error("The notebook changed during synchronization")), c || l) return;
8626
- f();
8627
8626
  let o = e.get(r.changesAtom);
8628
- o === null || e.get(n) === null ? e.set(a, { status: "unavailable" }) : o.length === 0 ? (e.set(r.submitAtom), e.set(a, { status: "idle" })) : (e.set(a, { status: "pending" }), u = setTimeout(() => {
8627
+ o === null || e.get(n) === null ? (f(), e.set(a, { status: "unavailable" })) : o.length === 0 ? (f(), e.set(r.submitAtom), e.set(a, { status: "idle" })) : u === void 0 && (u = setTimeout(() => {
8629
8628
  v().catch(() => void 0);
8630
- }, Ux));
8629
+ }, Ux), e.set(a, { status: "pending" }));
8631
8630
  } finally {
8632
8631
  d = !1;
8633
8632
  }
@@ -12965,7 +12964,7 @@ function mO(e, t) {
12965
12964
  }
12966
12965
  //#endregion
12967
12966
  //#region src/plugins/impl/DataEditorPlugin.tsx
12968
- var hO = J.lazy(() => import("./glide-data-editor-B6_KvoZ3.js").then((e) => e.t)), gO = XE("marimo-data-editor", { cssStyles: [yD, bD] }).withData(W({
12967
+ var hO = J.lazy(() => import("./glide-data-editor-CmgFgZPU.js").then((e) => e.t)), gO = XE("marimo-data-editor", { cssStyles: [yD, bD] }).withData(W({
12969
12968
  initialValue: W({ edits: V(W({
12970
12969
  rowIdx: G(),
12971
12970
  columnId: K(),
@@ -32688,7 +32687,7 @@ function _U(e) {
32688
32687
  }
32689
32688
  //#endregion
32690
32689
  //#region src/components/editor/renderers/slides-layout/slides-layout.tsx
32691
- var vU = J.lazy(() => import("./reveal-component-Cb25blSt.js")), yU = (e) => {
32690
+ var vU = J.lazy(() => import("./reveal-component-CCWiXeRT.js")), yU = (e) => {
32692
32691
  let t = (0, X.c)(33), { layout: n, setLayout: r, cells: i, mode: a } = e, o = To(zs), s = a === "read" || o, c = To(ua) > 1, [l, u] = (0, J.useState)(null), d;
32693
32692
  t[0] !== i || t[1] !== n ? (d = hz(i, n), t[0] = i, t[1] = n, t[2] = d) : d = t[2];
32694
32693
  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-BPCzCO3I.js";
2
2
  import { t } from "./react-Bgs_wQh3.js";
3
- import { a as n } from "./glide-data-editor-B6_KvoZ3.js";
3
+ import { a as n } from "./glide-data-editor-CmgFgZPU.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.1_57c124ac5a994dbbf13fd11838cf9ba9/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",
@@ -3,7 +3,7 @@ import { g as t, h as n, i as r, m as i, t as a } from "./button-qQhINE7z.js";
3
3
  import { t as o } from "./react-Bgs_wQh3.js";
4
4
  import { t as s } from "./compiler-runtime-C5KHtL5D.js";
5
5
  import { h as c, t as l } from "./tooltip-CiJ919pg.js";
6
- import { $ as u, Cn as d, Q as f, bn as p, cn as m, et as h, i as g, l as _, n as v, r as y, t as b, u as x, yn as S } from "./common-DolvV945.js";
6
+ import { $ as u, Cn as d, Q as f, bn as p, cn as m, et as h, i as g, l as _, n as v, r as y, t as b, u as x, yn as S } from "./common-DT7Dfm5X.js";
7
7
  import { M as C } from "./select-PQHWLm64.js";
8
8
  import { X as ee } from "./dropdown-menu-B12Nf3Zf.js";
9
9
  import { Nt as w } from "./error-entries-CNB7O2yS.js";
@@ -11,7 +11,7 @@ import { t as T } from "./jsx-runtime-D8btoEHk.js";
11
11
  import { Rt as E, Vt as D, f as O, i as k } from "./use-restore-focus-BLj45Ibw.js";
12
12
  import { t as A } from "./useEvent-BoN7U38T.js";
13
13
  import { o as te } from "./static-state-CWXd6dYX.js";
14
- import { n as ne, t as re } from "./code-visibility-DrVy3Nt1.js";
14
+ import { n as ne, t as re } from "./code-visibility-CfcaPeDp.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-dev440",
3
+ "version": "0.25.3-dev442",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -3,7 +3,7 @@
3
3
  import { vi } from "vitest";
4
4
  import { test } from "./scenario-fixture";
5
5
 
6
- test("closing a session before the debounce prevents submission", async ({
6
+ test("closing a session before the scheduled send prevents submission", async ({
7
7
  expect,
8
8
  session: { user, notebook, controller },
9
9
  }) => {
@@ -246,7 +246,7 @@ describe("document synchronization", () => {
246
246
  expect(value()?.code).toBe("local");
247
247
 
248
248
  store.set(backendAtom, backend);
249
- await vi.advanceTimersByTimeAsync(400);
249
+ await vi.advanceTimersByTimeAsync(100);
250
250
  expect(sent).toHaveBeenCalledOnce();
251
251
  });
252
252
  });
@@ -4,23 +4,36 @@ import { vi } from "vitest";
4
4
  import { document } from "./fixtures";
5
5
  import { test } from "./scenario-fixture";
6
6
 
7
- test("waits for a pause in typing before sending the latest edit", async ({
7
+ test("batches from the first edit and sends further typing on host confirmation", async ({
8
8
  expect,
9
9
  session: { user, host, notebook },
10
10
  }) => {
11
- user.changeCode("c3", "first");
12
- await vi.advanceTimersByTimeAsync(300);
13
- user.changeCode("c3", "latest");
14
- await vi.advanceTimersByTimeAsync(399);
11
+ user.changeCode("c3", "x");
12
+ await vi.advanceTimersByTimeAsync(99);
13
+ user.changeCode("c3", "x =");
15
14
  expect(notebook.edit).not.toHaveBeenCalled();
16
15
  await vi.advanceTimersByTimeAsync(1);
17
16
  expect(notebook.edit).toHaveBeenCalledOnce();
18
17
  const request = await host.nextRequest();
19
18
  request.process();
19
+ expect(host.document().cells.get("c3")?.code).toBe("x =");
20
20
  request.deliverResponse();
21
+
22
+ user.changeCode("c3", "x = 1");
23
+ await vi.advanceTimersByTimeAsync(150);
24
+ user.changeCode("c3", "x = 12");
25
+ expect(notebook.edit).toHaveBeenCalledOnce();
21
26
  host.deliverDocument();
22
- await expect(user.sync()).resolves.toEqual(host.document().revision);
23
- expect(host.document().cells.get("c3")?.code).toBe("latest");
27
+ await vi.advanceTimersByTimeAsync(0);
28
+ expect(notebook.edit).toHaveBeenCalledTimes(2);
29
+ const next = await host.nextRequest();
30
+ next.process();
31
+ next.deliverResponse();
32
+ host.deliverDocument();
33
+ await vi.advanceTimersByTimeAsync(0);
34
+ expect(host.document().cells.get("c3")?.code).toBe("x = 12");
35
+ expect(user.status()).toEqual({ status: "idle" });
36
+ expect(vi.getTimerCount()).toBe(0);
24
37
  });
25
38
 
26
39
  test.for(["response", "document"] as const)(
@@ -42,7 +42,7 @@ interface Submission {
42
42
  const RETRY_WINDOW_MS = 60_000;
43
43
  const REQUEST_TIMEOUT_MS = 10_000;
44
44
  const MAX_ATTEMPTS = 3;
45
- const DEBOUNCE_MS = 400;
45
+ const BATCH_WINDOW_MS = 100;
46
46
 
47
47
  function abortable<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {
48
48
  return new Promise((resolve, reject) => {
@@ -133,19 +133,21 @@ export function createDocumentSync({
133
133
  if (running || failure) {
134
134
  return;
135
135
  }
136
- clearTimer();
137
136
  const changes = store.get(state.changesAtom);
138
137
  if (changes === null || store.get(backendAtom) === null) {
138
+ clearTimer();
139
139
  store.set(statusAtom, { status: "unavailable" });
140
140
  } else if (changes.length === 0) {
141
+ clearTimer();
141
142
  // Release unsent reversals instead of keeping an invisible override.
142
143
  store.set(state.submitAtom);
143
144
  store.set(statusAtom, { status: "idle" });
144
- } else {
145
- store.set(statusAtom, { status: "pending" });
145
+ } else if (timer === undefined) {
146
+ // Only the first batch waits. The drain sends later edits on confirmation.
146
147
  timer = setTimeout(() => {
147
148
  void flush().catch(() => undefined);
148
- }, DEBOUNCE_MS);
149
+ }, BATCH_WINDOW_MS);
150
+ store.set(statusAtom, { status: "pending" });
149
151
  }
150
152
  } finally {
151
153
  refreshing = false;