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