@backmatter/studio 0.0.9 → 0.0.11

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.
@@ -3,7 +3,7 @@ var Xe = (e, t, n) => t in e ? Ke(e, t, { enumerable: !0, configurable: !0, writ
3
3
  var D = (e, t, n) => Xe(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsxs as k, jsx as o, Fragment as be } from "react/jsx-runtime";
5
5
  import { useRef as Ye, useCallback as Qe, useSyncExternalStore as Ze, useState as w, useEffect as V, lazy as et, Suspense as tt } from "react";
6
- import { O as nt, ag as ye, ah as rt, K as _, ai as st, p as it, aj as at, ak as Ne, al as Ce, am as Ie, an as ot, ao as lt, N as qe, ap as ct, aq as ie, aa as J, Q as ze, ar as ut, as as Fe, ab as dt, ad as re, a4 as Q, a5 as Z, P as ae, at as ft, M as z, au as ht, z as ve, av as ee, ac as pt, aw as gt, ax as mt, ay as xt, f as yt, az as vt, a0 as bt, aA as wt, aB as kt, q as St, B as Et, y as Rt, aC as _t, aD as Ot, aE as Tt, A as Pt, aF as Lt, R as At, F as jt, G as Ut, H as Nt, I as F, L as Ct, J as It } from "./WorkspaceRoutes-BKKEkAq7.js";
6
+ import { O as nt, ag as ye, ah as rt, K as _, ai as st, p as it, aj as at, ak as Ne, al as Ce, am as Ie, an as ot, ao as lt, N as qe, ap as ct, aq as ie, aa as J, Q as ze, ar as ut, as as Fe, ab as dt, ad as re, a4 as Q, a5 as Z, P as ae, at as ft, M as z, au as ht, z as ve, av as ee, ac as pt, aw as gt, ax as mt, ay as xt, f as yt, az as vt, a0 as bt, aA as wt, aB as kt, q as St, B as Et, y as Rt, aC as _t, aD as Ot, aE as Tt, A as Pt, aF as Lt, R as At, F as jt, G as Ut, H as Nt, I as F, L as Ct, J as It } from "./WorkspaceRoutes-Dzpaj8ov.js";
7
7
  const te = /* @__PURE__ */ Object.create(null), W = (e) => {
8
8
  var t, n;
9
9
  return ((t = globalThis.process) == null ? void 0 : t.env) || ((n = globalThis.Deno) == null ? void 0 : n.env.toObject()) || globalThis.__env__ || (e ? te : globalThis);
@@ -1701,7 +1701,7 @@ function kr(e) {
1701
1701
  const t = e.replace(/\/$/, "") || "/";
1702
1702
  return t === "/__ui" || /^\/__ui\/[^/]+$/.test(t);
1703
1703
  }
1704
- const Sr = et(() => import("./UiKitApp-b8qFsmA-.js").then((e) => ({
1704
+ const Sr = et(() => import("./UiKitApp-Cu0CS1NU.js").then((e) => ({
1705
1705
  default: e.UiKitApp
1706
1706
  })));
1707
1707
  function Pr() {
@@ -1,7 +1,7 @@
1
1
  var Rs = Object.defineProperty;
2
2
  var Es = (r, e, t) => e in r ? Rs(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
3
  var M = (r, e, t) => Es(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { aG as Bt, aH as Bs, aI as a0, aJ as ct, aK as xt, aL as ea, aM as Gn, aN as Is, aO as Ls, aP as Ds, aQ as La, aR as Ps, aS as Os, aT as Le, aU as qs } from "./WorkspaceRoutes-BKKEkAq7.js";
4
+ import { aG as Bt, aH as Bs, aI as a0, aJ as ct, aK as xt, aL as ea, aM as Gn, aN as Is, aO as Ls, aP as Ds, aQ as La, aR as Ps, aS as Os, aT as Le, aU as qs } from "./WorkspaceRoutes-Dzpaj8ov.js";
5
5
  function Fs() {
6
6
  return {
7
7
  enter: {
package/dist/dashboard.js CHANGED
@@ -1,5 +1,5 @@
1
- import { A as a, i as s } from "./chunks/dashboard-BNUcbYU0.js";
2
- import { w as t, x as f } from "./chunks/WorkspaceRoutes-BKKEkAq7.js";
1
+ import { A as a, i as s } from "./chunks/dashboard-kWmpeuAP.js";
2
+ import { w as t, x as f } from "./chunks/WorkspaceRoutes-Dzpaj8ov.js";
3
3
  export {
4
4
  a as DashboardApp,
5
5
  t as configureStudio,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as t, jsxs as d } from "react/jsx-runtime";
2
2
  import { useLayoutEffect as re, useEffect as f, useRef as W, useState as g, useMemo as oe } from "react";
3
- import { i as J, T as ae, E as se, C as ce, a as le, b as de, u as ue, D as A, c as X, d as B, e as xe, f as Y, g as G, h as me, p as z, j as C, k as N, r as fe, n as he, s as pe, l as ge, m as we, o as be, q as ye, B as ve, t as ke, S as qe, v as Ee, w as Q, x as P, y as ze, z as Ce, A as Ne, R as Se, F as Re, G as Le, H as Pe, I as S, N as I, L as Ue, J as je, K as F, M as Te } from "./chunks/WorkspaceRoutes-BKKEkAq7.js";
4
- import { O as ot } from "./chunks/WorkspaceRoutes-BKKEkAq7.js";
3
+ import { i as J, T as ae, E as se, C as ce, a as le, b as de, u as ue, D as A, c as X, d as B, e as xe, f as Y, g as G, h as me, p as z, j as C, k as N, r as fe, n as he, s as pe, l as ge, m as we, o as be, q as ye, B as ve, t as ke, S as qe, v as Ee, w as Q, x as P, y as ze, z as Ce, A as Ne, R as Se, F as Re, G as Le, H as Pe, I as S, N as I, L as Ue, J as je, K as F, M as Te } from "./chunks/WorkspaceRoutes-Dzpaj8ov.js";
4
+ import { O as ot } from "./chunks/WorkspaceRoutes-Dzpaj8ov.js";
5
5
  import { u as Me, S as _e } from "./chunks/define-studio-BYtYDGLX.js";
6
6
  import { d as st } from "./chunks/define-studio-BYtYDGLX.js";
7
7
  const R = {
@@ -29204,6 +29204,11 @@ function Vu(e, t) {
29204
29204
  }
29205
29205
  const ei = "backmatter-preview-frame";
29206
29206
  function xL() {
29207
+ if (typeof navigator > "u") return Promise.resolve(void 0);
29208
+ const e = navigator.userAgentData;
29209
+ return e != null && e.getHighEntropyValues ? e.getHighEntropyValues(["platformVersion"]).then((t) => t.platformVersion) : Promise.resolve(void 0);
29210
+ }
29211
+ function vL() {
29207
29212
  return typeof navigator > "u" ? Ev : Vu(navigator.userAgent);
29208
29213
  }
29209
29214
  function pm(e) {
@@ -29215,10 +29220,10 @@ function pm(e) {
29215
29220
  if (Number.isFinite(n) && n >= 0) return n;
29216
29221
  }
29217
29222
  }
29218
- return xL();
29223
+ return vL();
29219
29224
  }
29220
29225
  const Rv = "oklch(0.56 0.21 295)";
29221
- function vL({
29226
+ function wL({
29222
29227
  active: e,
29223
29228
  radius: t
29224
29229
  }) {
@@ -29229,10 +29234,8 @@ function vL({
29229
29234
  return;
29230
29235
  }
29231
29236
  const s = navigator.userAgent;
29232
- i(Vu(s));
29233
- const a = navigator.userAgentData;
29234
- a != null && a.getHighEntropyValues && a.getHighEntropyValues(["platformVersion"]).then((u) => {
29235
- i(Vu(s, u.platformVersion));
29237
+ i(Vu(s)), xL().then((a) => {
29238
+ a !== void 0 && i(Vu(s, a));
29236
29239
  });
29237
29240
  }, [t]), Cn(() => {
29238
29241
  const s = n.current, a = r.current;
@@ -29245,7 +29248,7 @@ function vL({
29245
29248
  { duration: 700, delay: 180, easing: vo }
29246
29249
  );
29247
29250
  }, [e]), /* @__PURE__ */ V(At, { children: [
29248
- /* @__PURE__ */ k("style", { children: wL }),
29251
+ /* @__PURE__ */ k("style", { children: kL }),
29249
29252
  /* @__PURE__ */ k(
29250
29253
  "div",
29251
29254
  {
@@ -29259,7 +29262,7 @@ function vL({
29259
29262
  )
29260
29263
  ] });
29261
29264
  }
29262
- const wL = `
29265
+ const kL = `
29263
29266
  .${ei} {
29264
29267
  position: fixed;
29265
29268
  inset: 0;
@@ -29287,11 +29290,11 @@ const wL = `
29287
29290
  opacity: 1;
29288
29291
  }
29289
29292
  }
29290
- `, T = "backmatter-devbar", kL = "/api/backmatter/preview", SL = 10, EL = 360;
29293
+ `, T = "backmatter-devbar", SL = "/api/backmatter/preview", EL = 10, CL = 360;
29291
29294
  function hm(e, t) {
29292
29295
  return `${e}:${t.trim().toLowerCase()}`;
29293
29296
  }
29294
- function CL({
29297
+ function RL({
29295
29298
  label: e,
29296
29299
  branch: t,
29297
29300
  tree: n,
@@ -29302,7 +29305,7 @@ function CL({
29302
29305
  changeCount: a,
29303
29306
  lineDiff: u,
29304
29307
  activity: l = null,
29305
- previewEntryPath: c = kL,
29308
+ previewEntryPath: c = SL,
29306
29309
  siteMode: f = "preview",
29307
29310
  frame: p = !1,
29308
29311
  frameRadius: d,
@@ -29387,7 +29390,7 @@ function CL({
29387
29390
  return document.addEventListener("pointerdown", X), () => document.removeEventListener("pointerdown", X);
29388
29391
  }, [Z]), Cn(() => {
29389
29392
  const X = D.current, se = A.current;
29390
- !X || !se || Z !== "settings" || AL(X, se);
29393
+ !X || !se || Z !== "settings" || ML(X, se);
29391
29394
  }, [Z, I, ut]), Cn(() => {
29392
29395
  if (!C) return;
29393
29396
  const X = z.current;
@@ -29401,7 +29404,7 @@ function CL({
29401
29404
  };
29402
29405
  }, [s, C, ut, I]), Oe(() => {
29403
29406
  function X(se) {
29404
- if (!_L(se.composedPath()[0] ?? null)) {
29407
+ if (!OL(se.composedPath()[0] ?? null)) {
29405
29408
  if ((se.metaKey || se.ctrlKey) && se.key === ".") {
29406
29409
  se.preventDefault(), ae.current.toggleHidden();
29407
29410
  return;
@@ -29556,7 +29559,7 @@ function CL({
29556
29559
  s && v(), O((X) => X === "page" ? null : "page");
29557
29560
  }
29558
29561
  const Xe = !!o || We === "live" && !y, Et = !r || a <= 0, tt = /* @__PURE__ */ k(
29559
- RL,
29562
+ IL,
29560
29563
  {
29561
29564
  mode: We,
29562
29565
  disabled: Xe,
@@ -29578,7 +29581,7 @@ function CL({
29578
29581
  tt,
29579
29582
  /* @__PURE__ */ k("span", { className: `${T}-steps`, children: l.steps.map((X, se) => /* @__PURE__ */ V("span", { className: `${T}-step`, children: [
29580
29583
  se > 0 ? /* @__PURE__ */ k("span", { className: `${T}-dash`, "aria-hidden": !0, children: "—" }) : null,
29581
- /* @__PURE__ */ k(PL, { state: X.state }),
29584
+ /* @__PURE__ */ k(_L, { state: X.state }),
29582
29585
  /* @__PURE__ */ k("span", { children: X.label })
29583
29586
  ] }, `${X.label}:${se}`)) })
29584
29587
  ] }) : (l == null ? void 0 : l.type) === "published" ? gt = /* @__PURE__ */ V(At, { children: [
@@ -29605,7 +29608,7 @@ function CL({
29605
29608
  ] }) : gt = /* @__PURE__ */ V(At, { children: [
29606
29609
  tt,
29607
29610
  /* @__PURE__ */ k(
29608
- qL,
29611
+ BL,
29609
29612
  {
29610
29613
  label: e,
29611
29614
  doc: r,
@@ -29627,7 +29630,7 @@ function CL({
29627
29630
  }
29628
29631
  ),
29629
29632
  /* @__PURE__ */ k(
29630
- IL,
29633
+ TL,
29631
29634
  {
29632
29635
  buttonRef: z,
29633
29636
  open: s,
@@ -29637,7 +29640,7 @@ function CL({
29637
29640
  }
29638
29641
  ),
29639
29642
  /* @__PURE__ */ k(
29640
- OL,
29643
+ $L,
29641
29644
  {
29642
29645
  buttonRef: A,
29643
29646
  open: Z === "settings",
@@ -29646,7 +29649,7 @@ function CL({
29646
29649
  )
29647
29650
  ] });
29648
29651
  const vt = /* @__PURE__ */ V(At, { children: [
29649
- /* @__PURE__ */ k("style", { children: ZL }),
29652
+ /* @__PURE__ */ k("style", { children: WL }),
29650
29653
  /* @__PURE__ */ V(
29651
29654
  "div",
29652
29655
  {
@@ -29655,7 +29658,7 @@ function CL({
29655
29658
  "data-mode": We,
29656
29659
  "data-branch": t || void 0,
29657
29660
  children: [
29658
- p ? /* @__PURE__ */ k(vL, { active: We === "preview", radius: d }) : null,
29661
+ p ? /* @__PURE__ */ k(wL, { active: We === "preview", radius: d }) : null,
29659
29662
  /* @__PURE__ */ V(
29660
29663
  "footer",
29661
29664
  {
@@ -29684,7 +29687,7 @@ function CL({
29684
29687
  }
29685
29688
  ),
29686
29689
  /* @__PURE__ */ k(
29687
- $L,
29690
+ AL,
29688
29691
  {
29689
29692
  open: Z === "settings",
29690
29693
  pane: Pe,
@@ -29711,7 +29714,7 @@ function CL({
29711
29714
  }
29712
29715
  ),
29713
29716
  t ? /* @__PURE__ */ k(
29714
- BL,
29717
+ VL,
29715
29718
  {
29716
29719
  branch: t,
29717
29720
  tree: n,
@@ -29727,11 +29730,17 @@ function CL({
29727
29730
  )
29728
29731
  ] });
29729
29732
  return /* @__PURE__ */ V("div", { ref: Y, className: `${T}-host`, "data-backmatter-devbar": "", children: [
29730
- /* @__PURE__ */ k("style", { children: HL }),
29731
- U ? ia(vt, U) : /* @__PURE__ */ k("template", { shadowrootmode: "open", children: vt })
29733
+ /* @__PURE__ */ k("style", { children: ZL }),
29734
+ U ? ia(vt, U) : /* @__PURE__ */ k(
29735
+ "template",
29736
+ {
29737
+ shadowrootmode: "open",
29738
+ children: vt
29739
+ }
29740
+ )
29732
29741
  ] });
29733
29742
  }
29734
- function RL({
29743
+ function IL({
29735
29744
  mode: e,
29736
29745
  disabled: t,
29737
29746
  buttonRef: n,
@@ -29751,7 +29760,7 @@ function RL({
29751
29760
  disabled: t,
29752
29761
  onClick: r,
29753
29762
  children: [
29754
- /* @__PURE__ */ k(TL, { exit: o }),
29763
+ /* @__PURE__ */ k(PL, { exit: o }),
29755
29764
  o ? "Exit preview" : "Enter preview"
29756
29765
  ]
29757
29766
  }
@@ -29783,7 +29792,7 @@ function mm({
29783
29792
  }
29784
29793
  );
29785
29794
  }
29786
- function IL({
29795
+ function TL({
29787
29796
  buttonRef: e,
29788
29797
  open: t,
29789
29798
  count: n,
@@ -29813,13 +29822,13 @@ function IL({
29813
29822
  }
29814
29823
  );
29815
29824
  }
29816
- function TL({ exit: e }) {
29825
+ function PL({ exit: e }) {
29817
29826
  return e ? /* @__PURE__ */ k("svg", { className: `${T}-mark`, width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": !0, children: /* @__PURE__ */ k("path", { d: "M3 3l6 6M9 3 3 9", stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round" }) }) : /* @__PURE__ */ V("svg", { className: `${T}-mark`, width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": !0, children: [
29818
29827
  /* @__PURE__ */ k("circle", { cx: "6", cy: "6", r: "3.25", stroke: "currentColor", strokeWidth: "1.25" }),
29819
29828
  /* @__PURE__ */ k("circle", { cx: "6", cy: "6", r: "1.35", fill: "currentColor" })
29820
29829
  ] });
29821
29830
  }
29822
- function PL({ state: e }) {
29831
+ function _L({ state: e }) {
29823
29832
  return e === "done" ? /* @__PURE__ */ k("span", { className: `${T}-done`, "aria-hidden": !0, children: "✓" }) : e === "active" ? /* @__PURE__ */ k("span", { className: `${T}-spin`, "aria-hidden": !0 }) : /* @__PURE__ */ k("span", { className: `${T}-ring`, "aria-hidden": !0 });
29824
29833
  }
29825
29834
  function Hl(e, t = {}) {
@@ -29838,12 +29847,12 @@ function Hl(e, t = {}) {
29838
29847
  );
29839
29848
  });
29840
29849
  }
29841
- function _L(e) {
29850
+ function OL(e) {
29842
29851
  if (!(e instanceof HTMLElement)) return !1;
29843
29852
  const t = e.tagName;
29844
29853
  return t === "INPUT" || t === "TEXTAREA" || t === "SELECT" ? !0 : e.isContentEditable;
29845
29854
  }
29846
- function OL({
29855
+ function $L({
29847
29856
  buttonRef: e,
29848
29857
  open: t,
29849
29858
  onClick: n
@@ -29862,7 +29871,7 @@ function OL({
29862
29871
  }
29863
29872
  );
29864
29873
  }
29865
- function $L({
29874
+ function AL({
29866
29875
  open: e,
29867
29876
  pane: t,
29868
29877
  hostName: n,
@@ -29908,18 +29917,18 @@ function $L({
29908
29917
  E ? /* @__PURE__ */ k("span", { className: `${T}-settings-place`, children: E }) : null
29909
29918
  ] }),
29910
29919
  /* @__PURE__ */ V("div", { className: `${T}-settings-row`, children: [
29911
- /* @__PURE__ */ k(NL, {}),
29920
+ /* @__PURE__ */ k(zL, {}),
29912
29921
  /* @__PURE__ */ k("span", { children: "Highlight editable blocks" }),
29913
29922
  /* @__PURE__ */ k(gm, { on: i, label: "Highlight editable blocks", onClick: () => u(!i) })
29914
29923
  ] }),
29915
29924
  /* @__PURE__ */ V("div", { className: `${T}-settings-row`, children: [
29916
- /* @__PURE__ */ k(zL, {}),
29925
+ /* @__PURE__ */ k(DL, {}),
29917
29926
  /* @__PURE__ */ k("span", { children: "Preview when Agent edits" }),
29918
29927
  /* @__PURE__ */ k(gm, { on: s, label: "Preview when Agent edits", onClick: () => l(!s) })
29919
29928
  ] }),
29920
29929
  /* @__PURE__ */ k("div", { className: `${T}-settings-rule` }),
29921
29930
  a ? /* @__PURE__ */ V("button", { type: "button", className: `${T}-settings-action`, onClick: p, children: [
29922
- /* @__PURE__ */ k(DL, {}),
29931
+ /* @__PURE__ */ k(LL, {}),
29923
29932
  /* @__PURE__ */ k("span", { children: "Open in dashboard" }),
29924
29933
  /* @__PURE__ */ V("kbd", { className: `${T}-kbd`, children: [
29925
29934
  v,
@@ -29932,12 +29941,12 @@ function $L({
29932
29941
  r ? /* @__PURE__ */ k("span", { className: `${T}-settings-email`, children: r }) : null
29933
29942
  ] }) : null,
29934
29943
  /* @__PURE__ */ V("button", { type: "button", className: `${T}-settings-action`, onClick: c, children: [
29935
- /* @__PURE__ */ k(LL, {}),
29944
+ /* @__PURE__ */ k(jL, {}),
29936
29945
  /* @__PURE__ */ k("span", { children: "Keyboard shortcuts" }),
29937
29946
  /* @__PURE__ */ k("kbd", { className: `${T}-kbd`, children: "?" })
29938
29947
  ] }),
29939
29948
  /* @__PURE__ */ V("button", { type: "button", className: `${T}-settings-action`, "aria-keyshortcuts": "Meta+. Control+.", onClick: d, children: [
29940
- /* @__PURE__ */ k(jL, {}),
29949
+ /* @__PURE__ */ k(FL, {}),
29941
29950
  /* @__PURE__ */ k("span", { children: "Hide toolbar" }),
29942
29951
  /* @__PURE__ */ V("kbd", { className: `${T}-kbd`, children: [
29943
29952
  v,
@@ -29947,7 +29956,7 @@ function $L({
29947
29956
  m ? /* @__PURE__ */ V(At, { children: [
29948
29957
  /* @__PURE__ */ k("div", { className: `${T}-settings-rule` }),
29949
29958
  /* @__PURE__ */ V("button", { type: "button", className: `${T}-settings-action`, onClick: m, children: [
29950
- /* @__PURE__ */ k(FL, {}),
29959
+ /* @__PURE__ */ k(qL, {}),
29951
29960
  /* @__PURE__ */ k("span", { children: "Sign out" }),
29952
29961
  y ? /* @__PURE__ */ k("span", { className: `${T}-settings-email`, children: y }) : null
29953
29962
  ] })
@@ -29975,44 +29984,44 @@ function gm({ on: e, label: t, onClick: n }) {
29975
29984
  }
29976
29985
  );
29977
29986
  }
29978
- function AL(e, t) {
29987
+ function ML(e, t) {
29979
29988
  const n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
29980
29989
  e.style.setProperty("--menu-right", `${Math.max(0, n.right - r.right)}px`);
29981
29990
  }
29982
- function ML(e, t) {
29983
- const n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), o = Math.min(EL, window.innerWidth - 32);
29991
+ function NL(e, t) {
29992
+ const n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), o = Math.min(CL, window.innerWidth - 32);
29984
29993
  let s = r.left + r.width / 2 - n.left - o / 2;
29985
29994
  const a = 16, u = a - n.left, l = window.innerWidth - a - o - n.left;
29986
29995
  e.style.setProperty("--menu-x", `${Math.max(u, Math.min(s, l))}px`);
29987
29996
  }
29988
- function NL() {
29997
+ function zL() {
29989
29998
  return /* @__PURE__ */ V("svg", { className: `${T}-settings-icon`, width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": !0, children: [
29990
29999
  /* @__PURE__ */ k("path", { d: "M3 3h4.2v4.2H3zM8.8 3H13v4.2H8.8zM3 8.8h4.2V13H3z", fill: "none", stroke: "currentColor", strokeWidth: "1.3" }),
29991
30000
  /* @__PURE__ */ k("path", { d: "M8.8 10.2h4.2", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round", strokeDasharray: "1.4 1.5" })
29992
30001
  ] });
29993
30002
  }
29994
- function zL() {
30003
+ function DL() {
29995
30004
  return /* @__PURE__ */ V("svg", { className: `${T}-settings-icon`, width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": !0, children: [
29996
30005
  /* @__PURE__ */ k("path", { d: "M1.6 8S4 3.8 8 3.8 14.4 8 14.4 8 12 12.2 8 12.2 1.6 8 1.6 8Z", fill: "none", stroke: "currentColor", strokeWidth: "1.3" }),
29997
30006
  /* @__PURE__ */ k("circle", { cx: "8", cy: "8", r: "1.8", fill: "none", stroke: "currentColor", strokeWidth: "1.3" })
29998
30007
  ] });
29999
30008
  }
30000
- function DL() {
30009
+ function LL() {
30001
30010
  return /* @__PURE__ */ k("svg", { className: `${T}-settings-icon`, width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": !0, children: /* @__PURE__ */ k("path", { d: "M2.5 2.5h4.2v4.2H2.5zM9.3 2.5h4.2v4.2H9.3zM2.5 9.3h4.2v4.2H2.5zM9.3 9.3h4.2v4.2H9.3z", fill: "none", stroke: "currentColor", strokeWidth: "1.3" }) });
30002
30011
  }
30003
- function LL() {
30012
+ function jL() {
30004
30013
  return /* @__PURE__ */ V("svg", { className: `${T}-settings-icon`, width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": !0, children: [
30005
30014
  /* @__PURE__ */ k("rect", { x: "1.8", y: "3.6", width: "12.4", height: "8.8", rx: "1.4", fill: "none", stroke: "currentColor", strokeWidth: "1.3" }),
30006
30015
  /* @__PURE__ */ k("path", { d: "M4 6.2h.1M6.4 6.2h.1M8.8 6.2h.1M11.2 6.2h.1M4.8 8.4h6.4", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
30007
30016
  ] });
30008
30017
  }
30009
- function jL() {
30018
+ function FL() {
30010
30019
  return /* @__PURE__ */ V("svg", { className: `${T}-settings-icon`, width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": !0, children: [
30011
30020
  /* @__PURE__ */ k("path", { d: "M2 8s2.2-3.6 6-3.6S14 8 14 8s-2.2 3.6-6 3.6S2 8 2 8Z", fill: "none", stroke: "currentColor", strokeWidth: "1.3" }),
30012
30021
  /* @__PURE__ */ k("path", { d: "M3 13 13 3", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
30013
30022
  ] });
30014
30023
  }
30015
- function FL() {
30024
+ function qL() {
30016
30025
  return /* @__PURE__ */ V("svg", { className: `${T}-settings-icon`, width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": !0, children: [
30017
30026
  /* @__PURE__ */ k("path", { d: "M6.5 3.2H3.8v9.6h2.7", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" }),
30018
30027
  /* @__PURE__ */ k("path", { d: "M7 8h6.2M11 5.4 13.6 8 11 10.6", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round", strokeLinejoin: "round" })
@@ -30030,7 +30039,7 @@ function ym(e) {
30030
30039
  const t = typeof matchMedia == "function" && matchMedia("(prefers-color-scheme: dark)").matches, n = pL(e, t) === "dark", r = document.documentElement;
30031
30040
  r.dataset.theme = n ? "dark" : "light", r.style.colorScheme = e === "system" ? "light dark" : n ? "dark" : "light", r.classList.toggle("dark", n), r.classList.toggle("light", !n);
30032
30041
  }
30033
- function qL({
30042
+ function BL({
30034
30043
  label: e,
30035
30044
  doc: t,
30036
30045
  dashboardHref: n,
@@ -30048,7 +30057,7 @@ function qL({
30048
30057
  }, [o]), Cn(() => {
30049
30058
  const $ = E.current;
30050
30059
  if (!o || !r || !$) return;
30051
- const z = () => ML(r, $);
30060
+ const z = () => NL(r, $);
30052
30061
  return z(), window.addEventListener("resize", z), () => window.removeEventListener("resize", z);
30053
30062
  }, [o, r]);
30054
30063
  const _ = He(
@@ -30057,7 +30066,7 @@ function qL({
30057
30066
  const F = ++R.current, U = y.trim(), B = hm(t.workspaceId, U);
30058
30067
  z ? h(!0) : A != null && A.silent || p(!0), S2(t.workspaceId, {
30059
30068
  q: U || void 0,
30060
- limit: SL,
30069
+ limit: EL,
30061
30070
  offset: $,
30062
30071
  current: t
30063
30072
  }).then((Y) => {
@@ -30167,7 +30176,7 @@ function qL({
30167
30176
  N && r ? ia(N, r) : null
30168
30177
  ] });
30169
30178
  }
30170
- function BL({
30179
+ function VL({
30171
30180
  branch: e,
30172
30181
  tree: t,
30173
30182
  workspaceId: n,
@@ -30192,7 +30201,7 @@ function BL({
30192
30201
  v = !0;
30193
30202
  };
30194
30203
  }, [i, n, a, e]), !i || !o) return null;
30195
- const x = a ? VL(a.map((v) => ({ key: v, label: v })), m) : null;
30204
+ const x = a ? UL(a.map((v) => ({ key: v, label: v })), m) : null;
30196
30205
  return ia(
30197
30206
  /* @__PURE__ */ k("div", { id: y, role: "menu", "aria-label": "Branches", className: `${T}-menu ${T}-page-menu`, children: n ? /* @__PURE__ */ k(
30198
30207
  Iv,
@@ -30217,7 +30226,7 @@ function BL({
30217
30226
  s();
30218
30227
  return;
30219
30228
  }
30220
- h(!0), p(null), UL({
30229
+ h(!0), p(null), HL({
30221
30230
  workspaceId: n,
30222
30231
  branch: v.label,
30223
30232
  tree: t,
@@ -30276,11 +30285,11 @@ function Iv({
30276
30285
  function Tv() {
30277
30286
  return /* @__PURE__ */ k("svg", { className: `${T}-chevron`, width: "10", height: "10", viewBox: "0 0 12 12", fill: "none", "aria-hidden": !0, children: /* @__PURE__ */ k("path", { d: "M2.5 4.5 6 8l3.5-3.5", stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round" }) });
30278
30287
  }
30279
- function VL(e, t) {
30288
+ function UL(e, t) {
30280
30289
  const n = t.trim().toLowerCase();
30281
30290
  return n ? e.filter((r) => r.label.toLowerCase().includes(n)) : [...e];
30282
30291
  }
30283
- async function UL(e) {
30292
+ async function HL(e) {
30284
30293
  const t = e.checkout ?? y2, n = e.ticket ?? g2, r = e.assign ?? ((s) => location.assign(s));
30285
30294
  await t(e.workspaceId, e.branch);
30286
30295
  let o;
@@ -30297,7 +30306,7 @@ async function UL(e) {
30297
30306
  const i = e.previewEntryPath.includes("?") ? "&" : "?";
30298
30307
  r(`${e.previewEntryPath}${i}ticket=${encodeURIComponent(o.ticket)}`);
30299
30308
  }
30300
- const HL = `
30309
+ const ZL = `
30301
30310
  .${T}-host {
30302
30311
  position: absolute;
30303
30312
  width: 0;
@@ -30316,7 +30325,7 @@ html.backmatter-blocks [data-backmatter-block] {
30316
30325
  outline: 1.5px solid oklch(0.56 0.21 295);
30317
30326
  outline-offset: 2px;
30318
30327
  }
30319
- `, ZL = `
30328
+ `, WL = `
30320
30329
  .${T}-root {
30321
30330
  --preview: ${Rv};
30322
30331
  --preview-hover: oklch(0.50 0.20 295);
@@ -30924,17 +30933,17 @@ html.backmatter-blocks [data-backmatter-block] {
30924
30933
  :host(.${T}-pointing) .${T},
30925
30934
  :host(.${T}-pointing) .${T} * { cursor: pointer !important; }
30926
30935
  :host(.${T}-pointing) .${T} button:disabled { cursor: default !important; }
30927
- `, WL = {
30936
+ `, KL = {
30928
30937
  x17w6cid: "x145rjjm x17w6cid",
30929
30938
  $$css: !0
30930
30939
  };
30931
- function KL(e, t) {
30940
+ function YL(e, t) {
30932
30941
  const n = (t == null ? void 0 : t.split(/\s+/).filter(Boolean)) ?? [];
30933
30942
  return n.length > 0 && e.classList.add(...n), () => {
30934
30943
  n.length > 0 && e.classList.remove(...n);
30935
30944
  };
30936
30945
  }
30937
- function sj({
30946
+ function aj({
30938
30947
  doc: e,
30939
30948
  branch: t,
30940
30949
  tree: n,
@@ -30964,7 +30973,7 @@ function sj({
30964
30973
  var z;
30965
30974
  $ === 401 && ((z = b.current) == null || z.call(b));
30966
30975
  }
30967
- }), !0)), Cn(() => KL(document.documentElement, Mt(WL).className), []);
30976
+ }), !0)), Cn(() => YL(document.documentElement, Mt(KL).className), []);
30968
30977
  const [y, x] = le(!1), [v, E] = le(!1), [w, g] = le(0), [R, C] = le(null), _ = e ? `${e.type}/${e.slug}` : "No document", M = He(($) => {
30969
30978
  C($);
30970
30979
  }, []);
@@ -30986,17 +30995,17 @@ function sj({
30986
30995
  }
30987
30996
  return document.addEventListener("pointerdown", $), () => document.removeEventListener("pointerdown", $);
30988
30997
  }, [v]);
30989
- const N = /* @__PURE__ */ k(CL, { label: _, branch: t, tree: n, doc: e, siteMode: r, exiting: o, chatOpen: y, publishOpen: v, changeCount: w, previewEntryPath: c, onExit: i, onEnterPreview: s, frame: !!f, frameRadius: p, onToggleChat: () => x(($) => !$), onTogglePublish: () => E(($) => !$), dashboardHref: h, onSignOut: m, onPublishAnchor: M });
30998
+ const N = /* @__PURE__ */ k(RL, { label: _, branch: t, tree: n, doc: e, siteMode: r, exiting: o, chatOpen: y, publishOpen: v, changeCount: w, previewEntryPath: c, onExit: i, onEnterPreview: s, frame: !!f, frameRadius: p, onToggleChat: () => x(($) => !$), onTogglePublish: () => E(($) => !$), dashboardHref: h, onSignOut: m, onPublishAnchor: M });
30990
30999
  return /* @__PURE__ */ V(At, { children: [
30991
31000
  e ? /* @__PURE__ */ k(sk, { children: /* @__PURE__ */ k(N2, { children: /* @__PURE__ */ V(hz, { workspaceId: e.workspaceId, pointer: !0, children: [
30992
- /* @__PURE__ */ k(YL, { doc: e }),
30993
- /* @__PURE__ */ k(JL, { onDocChanged: D }),
30994
- /* @__PURE__ */ k(GL, { open: y }),
30995
- /* @__PURE__ */ k(XL, { onClose: () => x(!1) }),
30996
- /* @__PURE__ */ k(QL, { doc: e }),
31001
+ /* @__PURE__ */ k(JL, { doc: e }),
31002
+ /* @__PURE__ */ k(GL, { onDocChanged: D }),
31003
+ /* @__PURE__ */ k(XL, { open: y }),
31004
+ /* @__PURE__ */ k(QL, { onClose: () => x(!1) }),
31005
+ /* @__PURE__ */ k(ej, { doc: e }),
30997
31006
  /* @__PURE__ */ k(mz, { children: y ? /* @__PURE__ */ k(H4, { site: !0 }) : null })
30998
31007
  ] }) }) }) : null,
30999
- e && v ? /* @__PURE__ */ k("div", { "data-backmatter-panel": "", style: ej(R), children: /* @__PURE__ */ k(Q4, { workspaceId: e.workspaceId, onStatus: ({
31008
+ e && v ? /* @__PURE__ */ k("div", { "data-backmatter-panel": "", style: tj(R), children: /* @__PURE__ */ k(Q4, { workspaceId: e.workspaceId, onStatus: ({
31000
31009
  changeCount: $
31001
31010
  }) => g($), onPublished: () => {
31002
31011
  E(!1), g(0), D();
@@ -31004,7 +31013,7 @@ function sj({
31004
31013
  N
31005
31014
  ] });
31006
31015
  }
31007
- function YL({
31016
+ function JL({
31008
31017
  doc: e
31009
31018
  }) {
31010
31019
  const {
@@ -31023,7 +31032,7 @@ function YL({
31023
31032
  });
31024
31033
  }, [e.locale, e.type, e.slug, t]), null;
31025
31034
  }
31026
- function JL({
31035
+ function GL({
31027
31036
  onDocChanged: e
31028
31037
  }) {
31029
31038
  const t = Ee(e);
@@ -31034,7 +31043,7 @@ function JL({
31034
31043
  return window.addEventListener(Du, n), () => window.removeEventListener(Du, n);
31035
31044
  }, []), null;
31036
31045
  }
31037
- function GL({
31046
+ function XL({
31038
31047
  open: e
31039
31048
  }) {
31040
31049
  const {
@@ -31048,7 +31057,7 @@ function GL({
31048
31057
  });
31049
31058
  }, [e, t]), null;
31050
31059
  }
31051
- function XL({
31060
+ function QL({
31052
31061
  onClose: e
31053
31062
  }) {
31054
31063
  const {
@@ -31059,7 +31068,7 @@ function XL({
31059
31068
  r.current = n, i && !ra(n) && o.current();
31060
31069
  }, [n]), null;
31061
31070
  }
31062
- function QL({
31071
+ function ej({
31063
31072
  doc: e
31064
31073
  }) {
31065
31074
  const {
@@ -31093,7 +31102,7 @@ function QL({
31093
31102
  };
31094
31103
  }, [t]), null;
31095
31104
  }
31096
- function ej(e) {
31105
+ function tj(e) {
31097
31106
  const t = e ? Math.max(16, window.innerWidth - e.right) : 16, n = e ? Math.max(52, window.innerHeight - e.top + 8) : 52;
31098
31107
  return {
31099
31108
  position: "fixed",
@@ -31110,5 +31119,5 @@ function ej(e) {
31110
31119
  };
31111
31120
  }
31112
31121
  export {
31113
- sj as SiteWidget
31122
+ aj as SiteWidget
31114
31123
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backmatter/studio",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "The Backmatter editing surface: document editor, AI chat, publish. Mounted on your site or hosted on the dashboard.",
5
5
  "type": "module",
6
6
  "publishConfig": {
package/src/api.ts CHANGED
@@ -501,7 +501,7 @@ export function notifyTreeChanged(detail?: TreeChangeDetail) {
501
501
  );
502
502
  }
503
503
 
504
- /** Branch HEAD moved (teammate push, pull, commit); clean docs should reload. */
504
+ /** Branch HEAD moved (teammate push, pull, commit). Clean docs reload their fields. The preview frame stays up. */
505
505
  export function notifyHeadChanged() {
506
506
  window.dispatchEvent(new Event("backmatter:head-changed"));
507
507
  }
@@ -35,9 +35,11 @@ import { replicaStore } from "../replica/instance";
35
35
  import { useReplicaSession } from "../replica/ReplicaProvider";
36
36
  import { useReplicaState } from "../replica/useReplica";
37
37
  import { useWorkspaceNav } from "./WorkspaceNavContext";
38
+ import { branchHeadMoved } from "./branch-head";
38
39
  import { commitTriggerDisabled, statusBarAction } from "./status-bar-action";
39
40
 
40
41
  const hover = "@media (hover: hover)";
42
+ /** Status bar only. The preview frame follows HEAD on its SSE stream, not on this poll. */
41
43
  const POLL_MS = 8000;
42
44
 
43
45
  export const STATUS_LABEL: Record<ChangeStatus, string> = {
@@ -181,7 +183,8 @@ export function WorkspaceStatusBar({ workspaceId }: { workspaceId: string }) {
181
183
  const [resolvingKey, setResolvingKey] = useState<string | null>(null);
182
184
  const [message, setMessage] = useState("");
183
185
  const [error, setError] = useState<string | null>(null);
184
- // HEAD identity from the last poll so we can announce "HEAD moved".
186
+ // Commit sha from the last poll. A new sha means HEAD moved. The preview
187
+ // iframe does not reload for that; its page follows the SSE head event.
185
188
  const lastHead = useRef<string | null | undefined>(undefined);
186
189
 
187
190
  async function reloadGit() {
@@ -195,11 +198,9 @@ export function WorkspaceStatusBar({ workspaceId }: { workspaceId: string }) {
195
198
  } else {
196
199
  setError(null);
197
200
  }
198
- const headKey = next.head ? `${next.head.sha}:${next.head.updatedAt}` : null;
199
- if (lastHead.current !== undefined && lastHead.current !== headKey) {
200
- notifyHeadChanged();
201
- }
202
- lastHead.current = headKey;
201
+ const nextSha = next.head?.sha ?? null;
202
+ if (branchHeadMoved(lastHead.current, nextSha)) notifyHeadChanged();
203
+ lastHead.current = nextSha;
203
204
  } catch (err) {
204
205
  setError(err instanceof Error ? err.message : "Git status failed");
205
206
  }