@backmatter/studio 0.0.14 → 0.0.15

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 { U as nt, aj as ye, ak as rt, P as _, al as st, p as it, am as at, an as Ne, ao as Ce, ap as Ie, aq as ot, ar as lt, N as qe, as as ct, at as ie, ad as J, W as ze, au as ut, av as Fe, ae as dt, ag as re, a7 as Q, a8 as Z, V as ae, aw as ft, Q as z, ax as ht, G as ve, ay as ee, af as pt, az as gt, aA as mt, aB as xt, f as yt, aC as vt, a3 as bt, aD as wt, aE as kt, w as St, B as Et, F as Rt, aF as _t, aG as Ot, aH as Tt, H as Pt, aI as Lt, R as jt, I as At, J as Ut, K as Nt, L as F, M as Ct, O as It } from "./WorkspaceRoutes-Dt7JvEWT.js";
6
+ import { U as nt, aj as ye, ak as rt, P as _, al as st, p as it, am as at, an as Ne, ao as Ce, ap as Ie, aq as ot, ar as lt, N as qe, as as ct, at as ie, ad as J, W as ze, au as ut, av as Fe, ae as dt, ag as re, a7 as Q, a8 as Z, V as ae, aw as ft, Q as z, ax as ht, G as ve, ay as ee, af as pt, az as gt, aA as mt, aB as xt, f as yt, aC as vt, a3 as bt, aD as wt, aE as kt, w as St, B as Et, F as Rt, aF as _t, aG as Ot, aH as Tt, H as Pt, aI as Lt, R as jt, I as At, J as Ut, K as Nt, L as F, M as Ct, O as It } from "./WorkspaceRoutes-BTZ1Ah4F.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-fYeVEf4-.js").then((e) => ({
1704
+ const Sr = et(() => import("./UiKitApp-BDsrXN12.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 { aJ as Bt, aK as Bs, aL as a0, aM as ct, aN as xt, aO as ea, aP as Gn, aQ as Is, aR as Ls, aS as Ds, aT as La, aU as Ps, aV as Os, aW as Le, aX as qs } from "./WorkspaceRoutes-Dt7JvEWT.js";
4
+ import { aJ as Bt, aK as Bs, aL as a0, aM as ct, aN as xt, aO as ea, aP as Gn, aQ as Is, aR as Ls, aS as Ds, aT as La, aU as Ps, aV as Os, aW as Le, aX as qs } from "./WorkspaceRoutes-BTZ1Ah4F.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-BuY2aGkO.js";
2
- import { z as t, A as f } from "./chunks/WorkspaceRoutes-Dt7JvEWT.js";
1
+ import { A as a, i as s } from "./chunks/dashboard-FT7dm5wi.js";
2
+ import { z as t, A as f } from "./chunks/WorkspaceRoutes-BTZ1Ah4F.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 u } from "react/jsx-runtime";
2
- import { useLayoutEffect as oe, useEffect as f, useRef as Q, useState as h, useMemo as se } from "react";
3
- import { i as X, T as ce, E as le, C as ue, a as de, b as xe, u as me, D as _, c as Y, d as I, e as fe, f as Z, g as G, h as pe, p as E, j as C, k as he, l as ge, m as S, r as we, n as be, s as ye, o as ve, q as ke, t as qe, v as ze, w as Ee, B as Ce, x as Ne, S as Se, y as Re, z as ee, A as U, F as Pe, G as Le, H as Ue, R as je, I as Te, J as Me, K as $e, L as R, N as K, M as De, O as Fe, P as H, Q as Oe } from "./chunks/WorkspaceRoutes-Dt7JvEWT.js";
4
- import { U as lt } from "./chunks/WorkspaceRoutes-Dt7JvEWT.js";
2
+ import { useLayoutEffect as ae, useEffect as f, useRef as Q, useState as h, useMemo as se } from "react";
3
+ import { i as X, T as ce, E as le, C as ue, a as de, b as xe, u as me, D as _, c as Y, d as I, e as fe, f as Z, g as G, h as pe, p as E, j as C, k as he, l as ge, m as S, r as we, n as be, s as ye, o as ve, q as ke, t as qe, v as ze, w as Ee, B as Ce, x as Ne, S as Se, y as Re, z as ee, A as U, F as Pe, G as Le, H as Ue, R as je, I as Te, J as Me, K as $e, L as R, N as K, M as De, O as Fe, P as H, Q as Oe } from "./chunks/WorkspaceRoutes-BTZ1Ah4F.js";
4
+ import { U as lt } from "./chunks/WorkspaceRoutes-BTZ1Ah4F.js";
5
5
  import { u as Ae, S as Be } from "./chunks/define-studio-BYtYDGLX.js";
6
6
  import { d as dt } from "./chunks/define-studio-BYtYDGLX.js";
7
7
  const P = {
@@ -15,14 +15,14 @@ function _e(e) {
15
15
  }
16
16
  const Ie = [P.accent, P.accentHover, P.focus];
17
17
  function Ge() {
18
- var n, o;
19
- const e = (o = (n = Ae().theme) == null ? void 0 : n.accent) == null ? void 0 : o.trim();
20
- return oe(() => {
18
+ var n, a;
19
+ const e = (a = (n = Ae().theme) == null ? void 0 : n.accent) == null ? void 0 : a.trim();
20
+ return ae(() => {
21
21
  if (!e) return;
22
- const a = document.documentElement, i = Ie.map(_e).filter((s) => !!s);
23
- for (const s of i) a.style.setProperty(s, e);
22
+ const o = document.documentElement, i = Ie.map(_e).filter((s) => !!s);
23
+ for (const s of i) o.style.setProperty(s, e);
24
24
  return () => {
25
- for (const s of i) a.style.removeProperty(s);
25
+ for (const s of i) o.style.removeProperty(s);
26
26
  };
27
27
  }, [e]), null;
28
28
  }
@@ -46,35 +46,35 @@ function He() {
46
46
  const { setFocus: e } = me();
47
47
  return f(() => {
48
48
  const n = y();
49
- function o(a) {
50
- if (!n || a.origin !== n) return;
51
- const i = a.data;
49
+ function a(o) {
50
+ if (!n || o.origin !== n) return;
51
+ const i = o.data;
52
52
  if ((i == null ? void 0 : i.type) !== "backmatter:focus") return;
53
53
  const s = i.doc;
54
- !(s != null && s.locale) || !s.type || !s.slug || e({
55
- docRef: { locale: s.locale, type: s.type, slug: s.slug },
54
+ !(s != null && s.type) || !s.slug || e({
55
+ docRef: { type: s.type, slug: s.slug },
56
56
  frontmatter: {},
57
57
  body: "",
58
58
  selection: null
59
59
  });
60
60
  }
61
- return window.addEventListener("message", o), n && window.parent.postMessage({ type: "backmatter:chat-ready" }, n), () => window.removeEventListener("message", o);
61
+ return window.addEventListener("message", a), n && window.parent.postMessage({ type: "backmatter:chat-ready" }, n), () => window.removeEventListener("message", a);
62
62
  }, [e]), f(() => {
63
63
  const n = y();
64
- function o(a) {
65
- const i = a.detail;
64
+ function a(o) {
65
+ const i = o.detail;
66
66
  !n || !(i != null && i.docRef) || window.parent.postMessage({ type: "backmatter:doc-changed", doc: i.docRef }, n);
67
67
  }
68
- return window.addEventListener(_, o), () => window.removeEventListener(_, o);
68
+ return window.addEventListener(_, a), () => window.removeEventListener(_, a);
69
69
  }, []), null;
70
70
  }
71
71
  function Ve() {
72
72
  const { addPointer: e } = Y();
73
73
  return f(() => {
74
74
  const n = y();
75
- function o(a) {
76
- if (!n || a.origin !== n || a.source !== window.parent) return;
77
- const i = a.data;
75
+ function a(o) {
76
+ if (!n || o.origin !== n || o.source !== window.parent) return;
77
+ const i = o.data;
78
78
  if ((i == null ? void 0 : i.type) !== "backmatter:pointer-grab") return;
79
79
  const s = fe(
80
80
  i.doc ?? {},
@@ -82,17 +82,17 @@ function Ve() {
82
82
  );
83
83
  s && e(s);
84
84
  }
85
- return window.addEventListener("message", o), () => window.removeEventListener("message", o);
85
+ return window.addEventListener("message", a), () => window.removeEventListener("message", a);
86
86
  }, [e]), null;
87
87
  }
88
88
  function We() {
89
- const { panel: e, dispatch: n } = Y(), o = e.mode, a = Q(o);
89
+ const { panel: e, dispatch: n } = Y(), a = e.mode, o = Q(a);
90
90
  return f(() => {
91
91
  const i = y();
92
92
  if (!i || window.parent === window) return;
93
- const s = I(a.current);
94
- a.current = o, s && !I(o) && window.parent.postMessage({ type: "backmatter:chat-closed" }, i);
95
- }, [o]), f(() => {
93
+ const s = I(o.current);
94
+ o.current = a, s && !I(a) && window.parent.postMessage({ type: "backmatter:chat-closed" }, i);
95
+ }, [a]), f(() => {
96
96
  const i = y();
97
97
  function s(p) {
98
98
  var m;
@@ -113,7 +113,7 @@ function V() {
113
113
  }
114
114
  }
115
115
  function L(e) {
116
- return `${e.locale}/${e.type}/${e.slug}`;
116
+ return `${e.type}/${e.slug}`;
117
117
  }
118
118
  const Qe = {
119
119
  modified: "modified",
@@ -124,10 +124,10 @@ const Qe = {
124
124
  function Xe({
125
125
  workspaceId: e,
126
126
  onStatus: n,
127
- onPublished: o
127
+ onPublished: a
128
128
  }) {
129
129
  f(() => X(), []);
130
- const [a, i] = h(null), [s, p] = h("viewer"), [m, w] = h(""), [c, g] = h(null), [N, j] = h(null), [v, T] = h(!1), [k, M] = h(null);
130
+ const [o, i] = h(null), [s, p] = h("viewer"), [m, w] = h(""), [c, g] = h(null), [N, j] = h(null), [v, T] = h(!1), [k, M] = h(null);
131
131
  f(() => {
132
132
  let r = !1;
133
133
  return Z(e).then((l) => {
@@ -167,14 +167,13 @@ function Xe({
167
167
  r = !0, window.clearInterval(b);
168
168
  };
169
169
  }, [e]);
170
- const d = (a == null ? void 0 : a.changes) ?? [], ne = G(a), z = ye(ne, ze(s)), $ = se(() => d.filter((r) => r.status === "conflict"), [d]), re = pe(d);
170
+ const d = (o == null ? void 0 : o.changes) ?? [], ne = G(o), z = ye(ne, ze(s)), $ = se(() => d.filter((r) => r.status === "conflict"), [d]), re = pe(d);
171
171
  async function D(r, l) {
172
172
  const b = `${L(r)}:${l}`;
173
173
  M(b), g(null);
174
174
  try {
175
- await we(e, r.locale, r.type, r.slug, l), be({
175
+ await we(e, r.type, r.slug, l), be({
176
176
  workspaceId: e,
177
- locale: r.locale,
178
177
  type: r.type,
179
178
  slug: r.slug,
180
179
  status: l === "theirs" ? "clean" : "modified"
@@ -192,7 +191,7 @@ function Xe({
192
191
  T(!0), g(null), j(null);
193
192
  try {
194
193
  const l = await ve(e, m);
195
- w(""), ke(e, l.files), o == null || o();
194
+ w(""), ke(e, l.files), a == null || a();
196
195
  const b = V();
197
196
  b && window.parent !== window && window.parent.postMessage({
198
197
  type: "backmatter:published"
@@ -204,7 +203,7 @@ function Xe({
204
203
  }
205
204
  }
206
205
  }
207
- const ae = (a == null ? void 0 : a.currentBranch) ?? "main";
206
+ const oe = (o == null ? void 0 : o.currentBranch) ?? "main";
208
207
  return $.length > 0 ? /* @__PURE__ */ u("div", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", children: [
209
208
  /* @__PURE__ */ t("p", { ...E(C.groupLabel), children: "Resolve conflicts" }),
210
209
  /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x37zpob x111yfic", children: "Pick a side for each file. Commit stays blocked until every conflict is resolved." }),
@@ -224,7 +223,7 @@ function Xe({
224
223
  ] }, l);
225
224
  }) })
226
225
  ] }) : /* @__PURE__ */ u("form", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", onSubmit: (r) => void ie(r), children: [
227
- /* @__PURE__ */ t("p", { ...E(C.groupLabel), children: d.length === 0 ? "Nothing to publish" : `${d.length} ${d.length === 1 ? "file" : "files"} → ${ae}` }),
226
+ /* @__PURE__ */ t("p", { ...E(C.groupLabel), children: d.length === 0 ? "Nothing to publish" : `${d.length} ${d.length === 1 ? "file" : "files"} → ${oe}` }),
228
227
  N ? /* @__PURE__ */ t(he, { failure: N }) : null,
229
228
  d.length > 0 ? /* @__PURE__ */ t("ul", { className: "x1ghz6dp x1717udv xe8uvvx xctk3hg x1odjw0f x1kbliiw", children: d.map((r) => {
230
229
  const l = ge(N, `${r.type}/${r.slug}`).length > 0;
@@ -255,13 +254,13 @@ function Xe({
255
254
  const W = "backmatter:enter-at", Ye = 1e4;
256
255
  function te(e, n) {
257
256
  if (typeof window > "u") return !1;
258
- const o = !!(window.top && window.top !== window);
259
- if (Ne(o) === "parent")
257
+ const a = !!(window.top && window.top !== window);
258
+ if (Ne(a) === "parent")
260
259
  return window.parent.postMessage({
261
260
  type: Se
262
261
  }, window.location.origin), !0;
263
- const a = Number(window.sessionStorage.getItem(W) ?? 0);
264
- return Date.now() - a < Ye ? !1 : (window.sessionStorage.setItem(W, String(Date.now())), window.location.assign(Re(n, {
262
+ const o = Number(window.sessionStorage.getItem(W) ?? 0);
263
+ return Date.now() - o < Ye ? !1 : (window.sessionStorage.setItem(W, String(Date.now())), window.location.assign(Re(n, {
265
264
  workspaceId: e,
266
265
  returnUrl: window.location.href
267
266
  })), !0);
@@ -276,21 +275,21 @@ function Ze(e) {
276
275
  version: e.version,
277
276
  dashboardUrl: n,
278
277
  onUnauthorized: ({
279
- status: o
278
+ status: a
280
279
  }) => {
281
- o === 401 && te(e.workspaceId, n);
280
+ a === 401 && te(e.workspaceId, n);
282
281
  }
283
282
  }), U();
284
283
  }
285
- function ot(e) {
286
- const n = e.basePath ?? "/backmatter", [o] = h(() => Ze(e));
284
+ function at(e) {
285
+ const n = e.basePath ?? "/backmatter", [a] = h(() => Ze(e));
287
286
  return /* @__PURE__ */ t(Be, { definition: e.studio, children: /* @__PURE__ */ u(Ee, { children: [
288
287
  /* @__PURE__ */ t(Ge, {}),
289
288
  /* @__PURE__ */ t(Ce, { basename: n, children: /* @__PURE__ */ t(et, { ...e }) })
290
289
  ] }) });
291
290
  }
292
291
  function et(e) {
293
- const n = Pe(), o = e.dashboardUrl ?? "https://dash.backmatter.app", [a, i] = h("loading");
292
+ const n = Pe(), a = e.dashboardUrl ?? "https://dash.backmatter.app", [o, i] = h("loading");
294
293
  if (f(() => {
295
294
  let m = !1;
296
295
  const w = U().onUnauthorized;
@@ -302,7 +301,7 @@ function et(e) {
302
301
  }), Le().then(async (c) => {
303
302
  if (m) return;
304
303
  if (!(c != null && c.user)) {
305
- te(e.workspaceId, o) || i("unauthorized");
304
+ te(e.workspaceId, a) || i("unauthorized");
306
305
  return;
307
306
  }
308
307
  const {
@@ -320,8 +319,8 @@ function et(e) {
320
319
  }), () => {
321
320
  m = !0;
322
321
  };
323
- }, [e.workspaceId, o]), a === "loading") return /* @__PURE__ */ t(Ue, {});
324
- if (a === "outdated")
322
+ }, [e.workspaceId, a]), o === "loading") return /* @__PURE__ */ t(Ue, {});
323
+ if (o === "outdated")
325
324
  return /* @__PURE__ */ u(J, { title: "This site's editor is out of date", children: [
326
325
  "Update ",
327
326
  /* @__PURE__ */ t("code", { children: "@backmatter/studio" }),
@@ -329,7 +328,7 @@ function et(e) {
329
328
  /* @__PURE__ */ t("code", { children: "@backmatter/next" }),
330
329
  " on the site, then reload."
331
330
  ] });
332
- if (a === "unauthorized")
331
+ if (o === "unauthorized")
333
332
  return /* @__PURE__ */ u(J, { title: "Could not start editing", children: [
334
333
  "The site did not receive a session from the dashboard. Check that this site's origin is listed in the workspace settings and that ",
335
334
  /* @__PURE__ */ t("code", { children: "/api/backmatter" }),
@@ -339,10 +338,10 @@ function et(e) {
339
338
  if (s != null && s[1])
340
339
  return /* @__PURE__ */ t(Ke, { workspaceId: decodeURIComponent(s[1]) });
341
340
  const p = n.pathname.match(/^\/embed\/publish\/([^/]+)\/?$/);
342
- return p != null && p[1] ? /* @__PURE__ */ t(Xe, { workspaceId: decodeURIComponent(p[1]) }) : /* @__PURE__ */ t(je, { user: a.user, children: /* @__PURE__ */ t(Te, { children: /* @__PURE__ */ t(Me, { userId: a.user.id, email: a.user.email, onLogout: () => {
343
- tt(e.previewEntryPath ?? "/api/backmatter/preview", o);
341
+ return p != null && p[1] ? /* @__PURE__ */ t(Xe, { workspaceId: decodeURIComponent(p[1]) }) : /* @__PURE__ */ t(je, { user: o.user, children: /* @__PURE__ */ t(Te, { children: /* @__PURE__ */ t(Me, { userId: o.user.id, email: o.user.email, onLogout: () => {
342
+ tt(e.previewEntryPath ?? "/api/backmatter/preview", a);
344
343
  }, children: /* @__PURE__ */ u($e, { children: [
345
- /* @__PURE__ */ t(R, { path: "/", element: /* @__PURE__ */ t(K, { to: `/${a.slug}`, replace: !0 }) }),
344
+ /* @__PURE__ */ t(R, { path: "/", element: /* @__PURE__ */ t(K, { to: `/${o.slug}`, replace: !0 }) }),
346
345
  /* @__PURE__ */ t(R, { path: "/workspaces/:workspaceId/*", element: /* @__PURE__ */ t(De, {}) }),
347
346
  Fe(),
348
347
  /* @__PURE__ */ t(R, { path: "*", element: /* @__PURE__ */ t(K, { to: "/", replace: !0 }) })
@@ -368,7 +367,7 @@ function J({
368
367
  ] }) });
369
368
  }
370
369
  export {
371
- ot as SiteStudio,
370
+ at as SiteStudio,
372
371
  lt as apiUrl,
373
372
  te as bounceToEnter,
374
373
  Ze as configureSiteStudio,