@backmatter/studio 0.0.8 → 0.0.9
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.
- package/dist/chunks/UiKitApp-b8qFsmA-.js +2401 -0
- package/dist/chunks/WorkspaceRoutes-BKKEkAq7.js +90126 -0
- package/dist/chunks/{dashboard-bNp6AbKE.js → dashboard-BNUcbYU0.js} +380 -382
- package/dist/chunks/{index-DoDE-hwB.js → index-laWAz5_p.js} +111 -112
- package/dist/dashboard.js +2 -2
- package/dist/index.js +287 -146
- package/dist/site-widget.css +1615 -0
- package/dist/site-widget.js +30896 -630
- package/dist/studio.css +268 -67
- package/package.json +4 -4
- package/src/App.tsx +12 -29
- package/src/api.ts +55 -0
- package/src/chat/ChangeCard.tsx +2 -0
- package/src/chat/ChatMessage.tsx +73 -62
- package/src/chat/ChatPanel.tsx +110 -15
- package/src/chat/DocListCard.tsx +2 -0
- package/src/chat/LiveStatus.tsx +78 -8
- package/src/chat/Reveal.tsx +34 -0
- package/src/chat/Shimmer.tsx +65 -23
- package/src/chat/chat-helpers.ts +35 -0
- package/src/chat/motion.ts +73 -0
- package/src/chat/useStickToBottom.ts +129 -14
- package/src/chrome/ContentExplorerSidebar.tsx +23 -8
- package/src/chrome/content-tree-visibility.ts +55 -0
- package/src/devbar-state.ts +125 -0
- package/src/index.css +3 -131
- package/src/pages/CliAuthorizePage.tsx +61 -28
- package/src/pages/MediaGalleryPage.tsx +74 -11
- package/src/pages/MediaLightbox.tsx +93 -1
- package/src/pages/SettingsUsagePage.tsx +23 -1
- package/src/pages/media-grid.ts +13 -0
- package/src/pages/ui-kit/UiKitApp.tsx +164 -0
- package/src/pages/ui-kit/buttons.tsx +30 -0
- package/src/pages/ui-kit/catalog.tsx +41 -0
- package/src/pages/ui-kit/colors.tsx +95 -0
- package/src/pages/ui-kit/devbar.tsx +160 -0
- package/src/pages/ui-kit/feedback.tsx +39 -0
- package/src/pages/ui-kit/fields.tsx +47 -0
- package/src/pages/ui-kit/lists.tsx +19 -0
- package/src/pages/ui-kit/overlays.tsx +39 -0
- package/src/pages/ui-kit/path.ts +9 -0
- package/src/pages/ui-kit/sections.tsx +32 -0
- package/src/pages/ui-kit/surfaces.tsx +121 -0
- package/src/pages/ui-kit/topic.tsx +112 -0
- package/src/pages/ui-kit/topics.ts +71 -0
- package/src/pages/ui-kit/type.tsx +55 -0
- package/src/preview-frame-radius.ts +51 -0
- package/src/preview-frame.tsx +93 -49
- package/src/shell-resets.css +155 -0
- package/src/site-bar.tsx +1791 -425
- package/src/site-dashboard-href.ts +21 -0
- package/src/site-devbar-overlay-inject.ts +15 -0
- package/src/site-devbar-overlay.css +217 -0
- package/src/site-pointer.ts +1 -1
- package/src/site-publish-menu.tsx +33 -0
- package/src/site-widget-styles.ts +7 -0
- package/src/site-widget.tsx +61 -21
- package/src/studio-prose-ui.css +39 -0
- package/src/theme/ThemeProvider.tsx +4 -1
- package/src/workspace-path.ts +10 -6
- package/dist/chunks/EmbedPublishPage-CtIlaeGO.js +0 -149
- package/dist/chunks/UiKitPage-DcnSQ-Hf.js +0 -173
- package/dist/chunks/WorkspaceRoutes-DVpUOaMV.js +0 -59550
- package/dist/chunks/status-bar-action-C0fsAWvD.js +0 -30618
- package/src/pages/UiKitPage.tsx +0 -331
package/dist/dashboard.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as a, i as s } from "./chunks/dashboard-
|
|
2
|
-
import { w as t,
|
|
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";
|
|
3
3
|
export {
|
|
4
4
|
a as DashboardApp,
|
|
5
5
|
t as configureStudio,
|
package/dist/index.js
CHANGED
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useLayoutEffect as
|
|
3
|
-
import { i as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { E as ne } from "./chunks/EmbedPublishPage-CtIlaeGO.js";
|
|
9
|
-
const p = {
|
|
1
|
+
import { jsx as t, jsxs as d } from "react/jsx-runtime";
|
|
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";
|
|
5
|
+
import { u as Me, S as _e } from "./chunks/define-studio-BYtYDGLX.js";
|
|
6
|
+
import { d as st } from "./chunks/define-studio-BYtYDGLX.js";
|
|
7
|
+
const R = {
|
|
10
8
|
accent: "var(--x11n7hvk)",
|
|
11
9
|
accentHover: "var(--x1vnpaut)",
|
|
12
10
|
focus: "var(--x1nzi8h4)"
|
|
13
11
|
};
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
return (
|
|
17
|
-
}
|
|
18
|
-
const
|
|
19
|
-
function
|
|
20
|
-
var
|
|
21
|
-
const e = (
|
|
22
|
-
return
|
|
12
|
+
function $e(e) {
|
|
13
|
+
const n = /^var\((--[^,)]+)/.exec(e);
|
|
14
|
+
return (n == null ? void 0 : n[1]) ?? null;
|
|
15
|
+
}
|
|
16
|
+
const De = [R.accent, R.accentHover, R.focus];
|
|
17
|
+
function Oe() {
|
|
18
|
+
var n, a;
|
|
19
|
+
const e = (a = (n = Me().theme) == null ? void 0 : n.accent) == null ? void 0 : a.trim();
|
|
20
|
+
return re(() => {
|
|
23
21
|
if (!e) return;
|
|
24
|
-
const
|
|
25
|
-
for (const
|
|
22
|
+
const o = document.documentElement, r = De.map($e).filter((s) => !!s);
|
|
23
|
+
for (const s of r) o.style.setProperty(s, e);
|
|
26
24
|
return () => {
|
|
27
|
-
for (const
|
|
25
|
+
for (const s of r) o.style.removeProperty(s);
|
|
28
26
|
};
|
|
29
27
|
}, [e]), null;
|
|
30
28
|
}
|
|
31
|
-
function
|
|
32
|
-
return
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */
|
|
29
|
+
function Ae({ workspaceId: e }) {
|
|
30
|
+
return f(() => J(), []), /* @__PURE__ */ t(ae, { children: /* @__PURE__ */ t(se, { children: /* @__PURE__ */ t(ce, { workspaceId: e, startOpen: !0, pointer: !0, children: /* @__PURE__ */ d(le, { children: [
|
|
31
|
+
/* @__PURE__ */ t(Be, {}),
|
|
32
|
+
/* @__PURE__ */ t(Ge, {}),
|
|
33
|
+
/* @__PURE__ */ t(Ie, {}),
|
|
34
|
+
/* @__PURE__ */ t(de, { fill: !0 })
|
|
37
35
|
] }) }) }) });
|
|
38
36
|
}
|
|
39
|
-
function
|
|
37
|
+
function y() {
|
|
40
38
|
if (!document.referrer) return "";
|
|
41
39
|
try {
|
|
42
40
|
return new URL(document.referrer).origin;
|
|
@@ -44,164 +42,307 @@ function f() {
|
|
|
44
42
|
return "";
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
|
-
function
|
|
48
|
-
const { setFocus: e } =
|
|
49
|
-
return
|
|
50
|
-
const
|
|
51
|
-
function
|
|
52
|
-
if (!
|
|
53
|
-
const
|
|
54
|
-
if ((
|
|
55
|
-
const
|
|
56
|
-
!(
|
|
57
|
-
docRef: { locale:
|
|
45
|
+
function Be() {
|
|
46
|
+
const { setFocus: e } = ue();
|
|
47
|
+
return f(() => {
|
|
48
|
+
const n = y();
|
|
49
|
+
function a(o) {
|
|
50
|
+
if (!n || o.origin !== n) return;
|
|
51
|
+
const r = o.data;
|
|
52
|
+
if ((r == null ? void 0 : r.type) !== "backmatter:focus") return;
|
|
53
|
+
const s = r.doc;
|
|
54
|
+
!(s != null && s.locale) || !s.type || !s.slug || e({
|
|
55
|
+
docRef: { locale: s.locale, type: s.type, slug: s.slug },
|
|
58
56
|
frontmatter: {},
|
|
59
57
|
body: "",
|
|
60
58
|
selection: null
|
|
61
59
|
});
|
|
62
60
|
}
|
|
63
|
-
return window.addEventListener("message",
|
|
64
|
-
}, [e]),
|
|
65
|
-
const
|
|
66
|
-
function
|
|
67
|
-
const
|
|
68
|
-
!
|
|
61
|
+
return window.addEventListener("message", a), n && window.parent.postMessage({ type: "backmatter:chat-ready" }, n), () => window.removeEventListener("message", a);
|
|
62
|
+
}, [e]), f(() => {
|
|
63
|
+
const n = y();
|
|
64
|
+
function a(o) {
|
|
65
|
+
const r = o.detail;
|
|
66
|
+
!n || !(r != null && r.docRef) || window.parent.postMessage({ type: "backmatter:doc-changed", doc: r.docRef }, n);
|
|
69
67
|
}
|
|
70
|
-
return window.addEventListener(
|
|
68
|
+
return window.addEventListener(A, a), () => window.removeEventListener(A, a);
|
|
71
69
|
}, []), null;
|
|
72
70
|
}
|
|
73
|
-
function
|
|
74
|
-
const { addPointer: e } =
|
|
75
|
-
return
|
|
76
|
-
const
|
|
77
|
-
function
|
|
78
|
-
if (!
|
|
79
|
-
const
|
|
80
|
-
if ((
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
function Ge() {
|
|
72
|
+
const { addPointer: e } = X();
|
|
73
|
+
return f(() => {
|
|
74
|
+
const n = y();
|
|
75
|
+
function a(o) {
|
|
76
|
+
if (!n || o.origin !== n || o.source !== window.parent) return;
|
|
77
|
+
const r = o.data;
|
|
78
|
+
if ((r == null ? void 0 : r.type) !== "backmatter:pointer-grab") return;
|
|
79
|
+
const s = xe(
|
|
80
|
+
r.doc ?? {},
|
|
81
|
+
r.grab
|
|
84
82
|
);
|
|
85
|
-
|
|
83
|
+
s && e(s);
|
|
86
84
|
}
|
|
87
|
-
return window.addEventListener("message",
|
|
85
|
+
return window.addEventListener("message", a), () => window.removeEventListener("message", a);
|
|
88
86
|
}, [e]), null;
|
|
89
87
|
}
|
|
90
|
-
function
|
|
91
|
-
const { panel: e, dispatch:
|
|
92
|
-
return
|
|
93
|
-
const
|
|
94
|
-
if (!
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
}, [
|
|
98
|
-
const
|
|
99
|
-
function
|
|
100
|
-
var
|
|
101
|
-
!
|
|
88
|
+
function Ie() {
|
|
89
|
+
const { panel: e, dispatch: n } = X(), a = e.mode, o = W(a);
|
|
90
|
+
return f(() => {
|
|
91
|
+
const r = y();
|
|
92
|
+
if (!r || window.parent === window) return;
|
|
93
|
+
const s = B(o.current);
|
|
94
|
+
o.current = a, s && !B(a) && window.parent.postMessage({ type: "backmatter:chat-closed" }, r);
|
|
95
|
+
}, [a]), f(() => {
|
|
96
|
+
const r = y();
|
|
97
|
+
function s(h) {
|
|
98
|
+
var m;
|
|
99
|
+
!r || h.origin !== r || ((m = h.data) == null ? void 0 : m.type) === "backmatter:chat-open" && (n({ type: "open" }), requestAnimationFrame(() => {
|
|
102
100
|
window.dispatchEvent(new Event("backmatter:chat-focus"));
|
|
103
101
|
}));
|
|
104
102
|
}
|
|
105
|
-
return window.addEventListener("message",
|
|
106
|
-
}, [
|
|
103
|
+
return window.addEventListener("message", s), () => window.removeEventListener("message", s);
|
|
104
|
+
}, [n]), null;
|
|
105
|
+
}
|
|
106
|
+
const Fe = 8e3;
|
|
107
|
+
function K() {
|
|
108
|
+
if (!document.referrer) return "";
|
|
109
|
+
try {
|
|
110
|
+
return new URL(document.referrer).origin;
|
|
111
|
+
} catch {
|
|
112
|
+
return "";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function Ke(e) {
|
|
116
|
+
if (!(e instanceof Error)) return "Commit failed";
|
|
117
|
+
const n = e;
|
|
118
|
+
return n.code === "conflict" ? "Resolve conflicts before committing" : n.code === "nothing_to_commit" ? "Nothing to commit" : n.code === "validation" ? e.message.replace(/^validation:\s*/, "Validation failed: ") : n.code === "github_not_bound" ? "Connect GitHub first" : e.message;
|
|
119
|
+
}
|
|
120
|
+
function L(e) {
|
|
121
|
+
return `${e.locale}/${e.type}/${e.slug}`;
|
|
122
|
+
}
|
|
123
|
+
const He = {
|
|
124
|
+
modified: "modified",
|
|
125
|
+
added: "new",
|
|
126
|
+
conflict: "conflict",
|
|
127
|
+
deleted: "deleted"
|
|
128
|
+
};
|
|
129
|
+
function Ve({
|
|
130
|
+
workspaceId: e,
|
|
131
|
+
onStatus: n,
|
|
132
|
+
onPublished: a
|
|
133
|
+
}) {
|
|
134
|
+
f(() => J(), []);
|
|
135
|
+
const [o, r] = g(null), [s, h] = g("viewer"), [m, w] = g(""), [c, p] = g(null), [v, U] = g(!1), [k, j] = g(null);
|
|
136
|
+
f(() => {
|
|
137
|
+
let i = !1;
|
|
138
|
+
return Y(e).then((l) => {
|
|
139
|
+
i || h(l.workspace.role);
|
|
140
|
+
}).catch(() => {
|
|
141
|
+
i || p("Could not load this workspace");
|
|
142
|
+
}), () => {
|
|
143
|
+
i = !0;
|
|
144
|
+
};
|
|
145
|
+
}, [e]);
|
|
146
|
+
const q = W(n);
|
|
147
|
+
q.current = n, f(() => {
|
|
148
|
+
let i = !1;
|
|
149
|
+
const l = () => {
|
|
150
|
+
N(e).then((x) => {
|
|
151
|
+
var O;
|
|
152
|
+
if (i) return;
|
|
153
|
+
r(x);
|
|
154
|
+
const _ = x.changes.length, $ = G(x);
|
|
155
|
+
(O = q.current) == null || O.call(q, {
|
|
156
|
+
changeCount: _,
|
|
157
|
+
conflictCount: $
|
|
158
|
+
});
|
|
159
|
+
const D = K();
|
|
160
|
+
!D || window.parent === window || window.parent.postMessage({
|
|
161
|
+
type: "backmatter:git",
|
|
162
|
+
changeCount: _,
|
|
163
|
+
conflictCount: $
|
|
164
|
+
}, D);
|
|
165
|
+
}).catch((x) => {
|
|
166
|
+
i || p(x instanceof Error ? x.message : "Git status failed");
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
l();
|
|
170
|
+
const b = window.setInterval(l, Fe);
|
|
171
|
+
return () => {
|
|
172
|
+
i = !0, window.clearInterval(b);
|
|
173
|
+
};
|
|
174
|
+
}, [e]);
|
|
175
|
+
const u = (o == null ? void 0 : o.changes) ?? [], ee = G(o), E = pe(ee, be(s)), T = oe(() => u.filter((i) => i.status === "conflict"), [u]), te = me(u);
|
|
176
|
+
async function M(i, l) {
|
|
177
|
+
const b = `${L(i)}:${l}`;
|
|
178
|
+
j(b), p(null);
|
|
179
|
+
try {
|
|
180
|
+
await fe(e, i.locale, i.type, i.slug, l), he({
|
|
181
|
+
workspaceId: e,
|
|
182
|
+
locale: i.locale,
|
|
183
|
+
type: i.type,
|
|
184
|
+
slug: i.slug,
|
|
185
|
+
status: l === "theirs" ? "clean" : "modified"
|
|
186
|
+
});
|
|
187
|
+
const x = await N(e);
|
|
188
|
+
r(x);
|
|
189
|
+
} catch (x) {
|
|
190
|
+
p(x instanceof Error ? x.message : "Resolve failed");
|
|
191
|
+
} finally {
|
|
192
|
+
j(null);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function ne(i) {
|
|
196
|
+
if (i.preventDefault(), !(v || E !== "commit" || u.length === 0)) {
|
|
197
|
+
U(!0), p(null);
|
|
198
|
+
try {
|
|
199
|
+
const l = await ge(e, m);
|
|
200
|
+
w(""), we(e, l.files), a == null || a();
|
|
201
|
+
const b = K();
|
|
202
|
+
b && window.parent !== window && window.parent.postMessage({
|
|
203
|
+
type: "backmatter:published"
|
|
204
|
+
}, b), r(await N(e));
|
|
205
|
+
} catch (l) {
|
|
206
|
+
p(Ke(l));
|
|
207
|
+
} finally {
|
|
208
|
+
U(!1);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const ie = (o == null ? void 0 : o.currentBranch) ?? "main";
|
|
213
|
+
return T.length > 0 ? /* @__PURE__ */ d("div", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", children: [
|
|
214
|
+
/* @__PURE__ */ t("p", { ...z(C.groupLabel), children: "Resolve conflicts" }),
|
|
215
|
+
/* @__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." }),
|
|
216
|
+
c ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x1trrqm4", children: c }) : null,
|
|
217
|
+
/* @__PURE__ */ t("ul", { className: "x1ghz6dp x1717udv xe8uvvx x1odjw0f x1kbliiw xq3t0pi", children: T.map((i) => {
|
|
218
|
+
const l = L(i);
|
|
219
|
+
return /* @__PURE__ */ d("li", { className: "x78zum5 xdt5ytf xpw8yq9 x1l8q8zy x1om5956 x1ar5oo6 x10qp4ay", children: [
|
|
220
|
+
/* @__PURE__ */ d("span", { className: "xeuugli x98rzlu xb3r6kr xlyipyv xuxw1ft", children: [
|
|
221
|
+
i.type,
|
|
222
|
+
"/",
|
|
223
|
+
i.slug
|
|
224
|
+
] }),
|
|
225
|
+
/* @__PURE__ */ d("div", { className: "x78zum5 xpw8yq9", children: [
|
|
226
|
+
/* @__PURE__ */ t("button", { type: "button", disabled: k !== null, onClick: () => void M(i, "mine"), className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x1j0qoeq x13oidi x1hb2obb xqjzbou x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60", children: k === `${l}:mine` ? "Keeping…" : "Keep mine" }),
|
|
227
|
+
/* @__PURE__ */ t("button", { type: "button", disabled: k !== null, onClick: () => void M(i, "theirs"), className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x13oidi x1hb2obb x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60 x1nf6o4h x1trrqm4", children: k === `${l}:theirs` ? "Taking…" : "Take theirs" })
|
|
228
|
+
] })
|
|
229
|
+
] }, l);
|
|
230
|
+
}) })
|
|
231
|
+
] }) : /* @__PURE__ */ d("form", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", onSubmit: (i) => void ne(i), children: [
|
|
232
|
+
/* @__PURE__ */ t("p", { ...z(C.groupLabel), children: u.length === 0 ? "Nothing to publish" : `${u.length} ${u.length === 1 ? "file" : "files"} → ${ie}` }),
|
|
233
|
+
u.length > 0 ? /* @__PURE__ */ t("ul", { className: "x1ghz6dp x1717udv xe8uvvx xctk3hg x1odjw0f x1kbliiw", children: u.map((i) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ d("div", { className: "x78zum5 x6s0dn4 x3smv4v x1rz828m x1ghz6dp x1obou79 x1l8q8zy x1om5956 x1ar5oo6 x10qp4ay x111yfic", children: [
|
|
234
|
+
/* @__PURE__ */ d("span", { className: "xeuugli x98rzlu xb3r6kr xlyipyv xuxw1ft", children: [
|
|
235
|
+
i.type,
|
|
236
|
+
"/",
|
|
237
|
+
i.slug
|
|
238
|
+
] }),
|
|
239
|
+
/* @__PURE__ */ t("span", { ...z(C.itemMeta), children: He[i.status] })
|
|
240
|
+
] }) }, L(i))) }) : null,
|
|
241
|
+
u.length > 0 ? /* @__PURE__ */ t("div", { ...z(C.separator) }) : null,
|
|
242
|
+
u.length > 0 ? /* @__PURE__ */ d("div", { className: "x78zum5 xdt5ytf x1qjc9v5 x1ndbd79 x173sf5p x1l7y7l0 xreod0t", children: [
|
|
243
|
+
/* @__PURE__ */ t("input", { value: m, onChange: (i) => w(i.target.value), placeholder: te, "aria-label": "Commit message", autoComplete: "off", spellCheck: !1, "data-no-ring": !0, "data-1p-ignore": !0, "data-lpignore": !0, disabled: v || E !== "commit", className: "xh8yej3 x9f619 xe0p6wg x1l8q8zy x1om5956 xmkeg23 x1y0btm7 x1j0qoeq x13oidi xawfm1v xqjzbou x1vrk1b5 x1a2a7pz x1uvtmcs x1t8xw5s xk2swo9 xk0mbs4 x9ecp23" }),
|
|
244
|
+
c ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x10qp4ay x1trrqm4 xnjsko4 x18d9i69", children: c }) : null,
|
|
245
|
+
E === "blocked" ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x37zpob x111yfic", children: "Writers cannot publish" }) : /* @__PURE__ */ t("button", { type: "submit", disabled: v || E !== "commit", className: "x78zum5 xh8yej3 x6s0dn4 xl56j7k x1fgtraw x161b3w3 xmkeg23 x1y0btm7 x14aomtw x13oidi xrb6rkd xfja90d x10qp4ay xk50ysn xuxw1ft x1ypdohk x2q2s9b x1dih85f xk0mbs4 x1s07b3s xd3so5o x784prv x9v5kkp x1yxvn1h x13iak60 xb93eig", children: v ? "Committing…" : "Commit & push" })
|
|
246
|
+
] }) : c ? /* @__PURE__ */ t("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x1trrqm4", children: c }) : null
|
|
247
|
+
] });
|
|
107
248
|
}
|
|
108
|
-
const
|
|
109
|
-
function
|
|
249
|
+
const H = "backmatter:enter-at", We = 1e4;
|
|
250
|
+
function Z(e, n) {
|
|
110
251
|
if (typeof window > "u") return !1;
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
252
|
+
const a = !!(window.top && window.top !== window);
|
|
253
|
+
if (ke(a) === "parent")
|
|
113
254
|
return window.parent.postMessage({
|
|
114
|
-
type:
|
|
255
|
+
type: qe
|
|
115
256
|
}, window.location.origin), !0;
|
|
116
|
-
const
|
|
117
|
-
return Date.now() -
|
|
257
|
+
const o = Number(window.sessionStorage.getItem(H) ?? 0);
|
|
258
|
+
return Date.now() - o < We ? !1 : (window.sessionStorage.setItem(H, String(Date.now())), window.location.assign(Ee(n, {
|
|
118
259
|
workspaceId: e,
|
|
119
260
|
returnUrl: window.location.href
|
|
120
261
|
})), !0);
|
|
121
262
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
124
|
-
return
|
|
263
|
+
function Je(e) {
|
|
264
|
+
const n = e.dashboardUrl ?? "https://dash.backmatter.app";
|
|
265
|
+
return Q({
|
|
125
266
|
baseUrl: e.proxyPath ?? "/api/backmatter/cms",
|
|
126
267
|
publicApiUrl: e.apiUrl,
|
|
127
268
|
credentials: "same-origin",
|
|
128
269
|
dev: !1,
|
|
129
270
|
version: e.version,
|
|
130
|
-
dashboardUrl:
|
|
271
|
+
dashboardUrl: n,
|
|
131
272
|
onUnauthorized: ({
|
|
132
|
-
status:
|
|
273
|
+
status: a
|
|
133
274
|
}) => {
|
|
134
|
-
|
|
275
|
+
a === 401 && Z(e.workspaceId, n);
|
|
135
276
|
}
|
|
136
|
-
}),
|
|
277
|
+
}), P();
|
|
137
278
|
}
|
|
138
|
-
function
|
|
139
|
-
const
|
|
140
|
-
return /* @__PURE__ */
|
|
141
|
-
/* @__PURE__ */
|
|
142
|
-
/* @__PURE__ */
|
|
279
|
+
function nt(e) {
|
|
280
|
+
const n = e.basePath ?? "/backmatter", [a] = g(() => Je(e));
|
|
281
|
+
return /* @__PURE__ */ t(_e, { definition: e.studio, children: /* @__PURE__ */ d(ye, { children: [
|
|
282
|
+
/* @__PURE__ */ t(Oe, {}),
|
|
283
|
+
/* @__PURE__ */ t(ve, { basename: n, children: /* @__PURE__ */ t(Xe, { ...e }) })
|
|
143
284
|
] }) });
|
|
144
285
|
}
|
|
145
|
-
function
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
-
let
|
|
149
|
-
const
|
|
150
|
-
return
|
|
151
|
-
...
|
|
152
|
-
onUnauthorized: (
|
|
153
|
-
|
|
286
|
+
function Xe(e) {
|
|
287
|
+
const n = ze(), a = e.dashboardUrl ?? "https://dash.backmatter.app", [o, r] = g("loading");
|
|
288
|
+
if (f(() => {
|
|
289
|
+
let m = !1;
|
|
290
|
+
const w = P().onUnauthorized;
|
|
291
|
+
return Q({
|
|
292
|
+
...P(),
|
|
293
|
+
onUnauthorized: (c) => {
|
|
294
|
+
c.status === 426 ? r("outdated") : w == null || w(c);
|
|
154
295
|
}
|
|
155
|
-
}),
|
|
156
|
-
if (
|
|
157
|
-
if (!(
|
|
158
|
-
|
|
296
|
+
}), Ce().then(async (c) => {
|
|
297
|
+
if (m) return;
|
|
298
|
+
if (!(c != null && c.user)) {
|
|
299
|
+
Z(e.workspaceId, a) || r("unauthorized");
|
|
159
300
|
return;
|
|
160
301
|
}
|
|
161
302
|
const {
|
|
162
|
-
workspace:
|
|
163
|
-
} = await
|
|
164
|
-
|
|
303
|
+
workspace: p
|
|
304
|
+
} = await Y(e.workspaceId);
|
|
305
|
+
m || r({
|
|
165
306
|
user: {
|
|
166
|
-
id:
|
|
167
|
-
email:
|
|
307
|
+
id: c.user.id,
|
|
308
|
+
email: c.user.email
|
|
168
309
|
},
|
|
169
|
-
slug:
|
|
310
|
+
slug: p.slug
|
|
170
311
|
});
|
|
171
312
|
}).catch(() => {
|
|
172
|
-
|
|
313
|
+
m || r((c) => c === "outdated" ? c : "unauthorized");
|
|
173
314
|
}), () => {
|
|
174
|
-
|
|
315
|
+
m = !0;
|
|
175
316
|
};
|
|
176
|
-
}, [e.workspaceId,
|
|
177
|
-
if (
|
|
178
|
-
return /* @__PURE__ */
|
|
317
|
+
}, [e.workspaceId, a]), o === "loading") return /* @__PURE__ */ t(Ne, {});
|
|
318
|
+
if (o === "outdated")
|
|
319
|
+
return /* @__PURE__ */ d(V, { title: "This site's editor is out of date", children: [
|
|
179
320
|
"Update ",
|
|
180
|
-
/* @__PURE__ */
|
|
321
|
+
/* @__PURE__ */ t("code", { children: "@backmatter/studio" }),
|
|
181
322
|
" and ",
|
|
182
|
-
/* @__PURE__ */
|
|
323
|
+
/* @__PURE__ */ t("code", { children: "@backmatter/next" }),
|
|
183
324
|
" on the site, then reload."
|
|
184
325
|
] });
|
|
185
|
-
if (
|
|
186
|
-
return /* @__PURE__ */
|
|
326
|
+
if (o === "unauthorized")
|
|
327
|
+
return /* @__PURE__ */ d(V, { title: "Could not start editing", children: [
|
|
187
328
|
"The site did not receive a session from the dashboard. Check that this site's origin is listed in the workspace settings and that ",
|
|
188
|
-
/* @__PURE__ */
|
|
329
|
+
/* @__PURE__ */ t("code", { children: "/api/backmatter" }),
|
|
189
330
|
" routes are deployed."
|
|
190
331
|
] });
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
193
|
-
return /* @__PURE__ */
|
|
194
|
-
const
|
|
195
|
-
return
|
|
196
|
-
|
|
197
|
-
}, children: /* @__PURE__ */
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
|
|
201
|
-
/* @__PURE__ */
|
|
332
|
+
const s = n.pathname.match(/^\/embed\/chat\/([^/]+)\/?$/);
|
|
333
|
+
if (s != null && s[1])
|
|
334
|
+
return /* @__PURE__ */ t(Ae, { workspaceId: decodeURIComponent(s[1]) });
|
|
335
|
+
const h = n.pathname.match(/^\/embed\/publish\/([^/]+)\/?$/);
|
|
336
|
+
return h != null && h[1] ? /* @__PURE__ */ t(Ve, { workspaceId: decodeURIComponent(h[1]) }) : /* @__PURE__ */ t(Se, { user: o.user, children: /* @__PURE__ */ t(Re, { children: /* @__PURE__ */ t(Le, { userId: o.user.id, email: o.user.email, onLogout: () => {
|
|
337
|
+
Ye(e.previewEntryPath ?? "/api/backmatter/preview", a);
|
|
338
|
+
}, children: /* @__PURE__ */ d(Pe, { children: [
|
|
339
|
+
/* @__PURE__ */ t(S, { path: "/", element: /* @__PURE__ */ t(I, { to: `/${o.slug}`, replace: !0 }) }),
|
|
340
|
+
/* @__PURE__ */ t(S, { path: "/workspaces/:workspaceId/*", element: /* @__PURE__ */ t(Ue, {}) }),
|
|
341
|
+
je(),
|
|
342
|
+
/* @__PURE__ */ t(S, { path: "*", element: /* @__PURE__ */ t(I, { to: "/", replace: !0 }) })
|
|
202
343
|
] }) }) }) });
|
|
203
344
|
}
|
|
204
|
-
async function
|
|
345
|
+
async function Ye(e, n) {
|
|
205
346
|
try {
|
|
206
347
|
await fetch(e, {
|
|
207
348
|
method: "POST",
|
|
@@ -209,23 +350,23 @@ async function he(e, t) {
|
|
|
209
350
|
});
|
|
210
351
|
} catch {
|
|
211
352
|
}
|
|
212
|
-
|
|
353
|
+
Te.wipe(), window.location.assign(n);
|
|
213
354
|
}
|
|
214
|
-
function
|
|
355
|
+
function V({
|
|
215
356
|
title: e,
|
|
216
|
-
children:
|
|
357
|
+
children: n
|
|
217
358
|
}) {
|
|
218
|
-
return /* @__PURE__ */
|
|
219
|
-
/* @__PURE__ */
|
|
220
|
-
/* @__PURE__ */
|
|
359
|
+
return /* @__PURE__ */ t("div", { className: "x1ov3xa9 xrvj5dj x1ku5rj1 x1t7e3gq", children: /* @__PURE__ */ d("div", { className: "x78zum5 xdt5ytf x1ndbd79 xq2pcee x1t7e3gq x4pepcl x1d0qn7y", children: [
|
|
360
|
+
/* @__PURE__ */ t(F, { size: "lg", weight: "medium", children: e }),
|
|
361
|
+
/* @__PURE__ */ t(F, { tone: "muted", children: n })
|
|
221
362
|
] }) });
|
|
222
363
|
}
|
|
223
364
|
export {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
365
|
+
nt as SiteStudio,
|
|
366
|
+
ot as apiUrl,
|
|
367
|
+
Z as bounceToEnter,
|
|
368
|
+
Je as configureSiteStudio,
|
|
369
|
+
Q as configureStudio,
|
|
370
|
+
st as defineStudio,
|
|
371
|
+
P as studioConfig
|
|
231
372
|
};
|