@backmatter/studio 0.0.2 → 0.0.4
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/EmbedPublishPage-hx1xoAhI.js +149 -0
- package/dist/chunks/{UiKitPage-CTZtLwJ0.js → UiKitPage-BOunq6mr.js} +12 -11
- package/dist/chunks/WorkspaceRoutes-CTFTWu3L.js +57731 -0
- package/dist/chunks/{dashboard-nvFBzpZv.js → dashboard-upmiawx5.js} +216 -215
- package/dist/chunks/{index-Cr-IOgdC.js → index-CBvevwfT.js} +9 -8
- package/dist/chunks/status-bar-action-DiXhfcj3.js +30254 -0
- package/dist/dashboard.js +2 -2
- package/dist/index.js +139 -228
- package/dist/site-widget.js +292 -0
- package/dist/studio.css +46 -6
- package/package.json +7 -2
- package/src/api.ts +4 -0
- package/src/chat/ChangeCard.tsx +11 -6
- package/src/chat/ChatMessage.tsx +27 -2
- package/src/chat/ChatPanel.tsx +12 -2
- package/src/chat/ChatProvider.tsx +40 -3
- package/src/chat/Composer.tsx +92 -6
- package/src/chat/DocLink.tsx +31 -0
- package/src/chat/DocListCard.tsx +3 -3
- package/src/chat/PointerChip.tsx +139 -0
- package/src/chat/chat-context.ts +80 -1
- package/src/chat/icons.tsx +20 -0
- package/src/chat/session-expiry.ts +13 -5
- package/src/chrome/OpenSiteButton.tsx +33 -25
- package/src/index.css +9 -1
- package/src/pages/EmbedChatPage.tsx +25 -1
- package/src/pages/EmbedPublishPage.tsx +279 -84
- package/src/pages/GithubConnectPage.tsx +44 -19
- package/src/pages/SelectRepositoriesLink.tsx +30 -0
- package/src/pages/SettingsGeneralPage.tsx +2 -0
- package/src/pages/SettingsGithubPage.tsx +8 -3
- package/src/pages/host-env.ts +7 -2
- package/src/site-pointer.ts +271 -0
- package/src/site-widget.tsx +391 -0
- package/src/site.tsx +11 -7
- package/dist/chunks/WorkspaceRoutes-DyRVES9t.js +0 -87308
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsxs as l, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as k, useState as u, useRef as H, useMemo as O } from "react";
|
|
3
|
+
import { k as P, n as U, o as K, q as F, p as g, r as y, s as q, t as V, v as J, w as Q, x as X, y as Y, z as Z } from "./status-bar-action-DiXhfcj3.js";
|
|
4
|
+
const I = 8e3;
|
|
5
|
+
function T() {
|
|
6
|
+
if (!document.referrer) return "";
|
|
7
|
+
try {
|
|
8
|
+
return new URL(document.referrer).origin;
|
|
9
|
+
} catch {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function ee(t) {
|
|
14
|
+
if (!(t instanceof Error)) return "Commit failed";
|
|
15
|
+
const o = t;
|
|
16
|
+
return o.code === "conflict" ? "Resolve conflicts before committing" : o.code === "nothing_to_commit" ? "Nothing to commit" : o.code === "validation" ? t.message.replace(/^validation:\s*/, "Validation failed: ") : o.code === "github_not_bound" ? "Connect GitHub first" : t.message;
|
|
17
|
+
}
|
|
18
|
+
function w(t) {
|
|
19
|
+
return `${t.locale}/${t.type}/${t.slug}`;
|
|
20
|
+
}
|
|
21
|
+
const te = {
|
|
22
|
+
modified: "modified",
|
|
23
|
+
added: "new",
|
|
24
|
+
conflict: "conflict",
|
|
25
|
+
deleted: "deleted"
|
|
26
|
+
};
|
|
27
|
+
function ae({
|
|
28
|
+
workspaceId: t,
|
|
29
|
+
onStatus: o,
|
|
30
|
+
onPublished: b
|
|
31
|
+
}) {
|
|
32
|
+
k(() => P(), []);
|
|
33
|
+
const [r, v] = u(null), [G, A] = u("viewer"), [z, C] = u(""), [x, c] = u(null), [d, N] = u(!1), [p, j] = u(null);
|
|
34
|
+
k(() => {
|
|
35
|
+
let e = !1;
|
|
36
|
+
return U(t).then((n) => {
|
|
37
|
+
e || A(n.workspace.role);
|
|
38
|
+
}).catch(() => {
|
|
39
|
+
e || c("Could not load this workspace");
|
|
40
|
+
}), () => {
|
|
41
|
+
e = !0;
|
|
42
|
+
};
|
|
43
|
+
}, [t]);
|
|
44
|
+
const f = H(o);
|
|
45
|
+
f.current = o, k(() => {
|
|
46
|
+
let e = !1;
|
|
47
|
+
const n = () => {
|
|
48
|
+
q(t).then((a) => {
|
|
49
|
+
var _;
|
|
50
|
+
if (e) return;
|
|
51
|
+
v(a);
|
|
52
|
+
const L = a.changes.length, M = K(a);
|
|
53
|
+
(_ = f.current) == null || _.call(f, {
|
|
54
|
+
changeCount: L,
|
|
55
|
+
conflictCount: M
|
|
56
|
+
});
|
|
57
|
+
const R = T();
|
|
58
|
+
!R || window.parent === window || window.parent.postMessage({
|
|
59
|
+
type: "backmatter:git",
|
|
60
|
+
changeCount: L,
|
|
61
|
+
conflictCount: M
|
|
62
|
+
}, R);
|
|
63
|
+
}).catch((a) => {
|
|
64
|
+
e || c(a instanceof Error ? a.message : "Git status failed");
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
n();
|
|
68
|
+
const m = window.setInterval(n, I);
|
|
69
|
+
return () => {
|
|
70
|
+
e = !0, window.clearInterval(m);
|
|
71
|
+
};
|
|
72
|
+
}, [t]);
|
|
73
|
+
const s = (r == null ? void 0 : r.changes) ?? [], B = K(r), h = Q(B, Z(G)), E = O(() => s.filter((e) => e.status === "conflict"), [s]), S = F(s);
|
|
74
|
+
async function $(e, n) {
|
|
75
|
+
const m = `${w(e)}:${n}`;
|
|
76
|
+
j(m), c(null);
|
|
77
|
+
try {
|
|
78
|
+
await V(t, e.locale, e.type, e.slug, n), J({
|
|
79
|
+
workspaceId: t,
|
|
80
|
+
locale: e.locale,
|
|
81
|
+
type: e.type,
|
|
82
|
+
slug: e.slug,
|
|
83
|
+
status: n === "theirs" ? "clean" : "modified"
|
|
84
|
+
});
|
|
85
|
+
const a = await q(t);
|
|
86
|
+
v(a);
|
|
87
|
+
} catch (a) {
|
|
88
|
+
c(a instanceof Error ? a.message : "Resolve failed");
|
|
89
|
+
} finally {
|
|
90
|
+
j(null);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function W(e) {
|
|
94
|
+
if (e.preventDefault(), !(d || h !== "commit" || s.length === 0)) {
|
|
95
|
+
N(!0), c(null);
|
|
96
|
+
try {
|
|
97
|
+
const n = await X(t, z);
|
|
98
|
+
C(""), Y(t, n.files), b == null || b();
|
|
99
|
+
const m = T();
|
|
100
|
+
m && window.parent !== window && window.parent.postMessage({
|
|
101
|
+
type: "backmatter:published"
|
|
102
|
+
}, m), v(await q(t));
|
|
103
|
+
} catch (n) {
|
|
104
|
+
c(ee(n));
|
|
105
|
+
} finally {
|
|
106
|
+
N(!1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const D = (r == null ? void 0 : r.currentBranch) ?? "main";
|
|
111
|
+
return E.length > 0 ? /* @__PURE__ */ l("div", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", children: [
|
|
112
|
+
/* @__PURE__ */ i("p", { ...g(y.groupLabel), children: "Resolve conflicts" }),
|
|
113
|
+
/* @__PURE__ */ i("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x37zpob x111yfic", children: "Pick a side for each file. Commit stays blocked until every conflict is resolved." }),
|
|
114
|
+
x ? /* @__PURE__ */ i("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x1trrqm4", children: x }) : null,
|
|
115
|
+
/* @__PURE__ */ i("ul", { className: "x1ghz6dp x1717udv xe8uvvx x1odjw0f x1kbliiw xq3t0pi", children: E.map((e) => {
|
|
116
|
+
const n = w(e);
|
|
117
|
+
return /* @__PURE__ */ l("li", { className: "x78zum5 xdt5ytf xpw8yq9 x1l8q8zy x1om5956 x1ar5oo6 x10qp4ay", children: [
|
|
118
|
+
/* @__PURE__ */ l("span", { className: "xeuugli x98rzlu xb3r6kr xlyipyv xuxw1ft", children: [
|
|
119
|
+
e.type,
|
|
120
|
+
"/",
|
|
121
|
+
e.slug
|
|
122
|
+
] }),
|
|
123
|
+
/* @__PURE__ */ l("div", { className: "x78zum5 xpw8yq9", children: [
|
|
124
|
+
/* @__PURE__ */ i("button", { type: "button", disabled: p !== null, onClick: () => void $(e, "mine"), className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x1j0qoeq x13oidi x1hb2obb xqjzbou x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60", children: p === `${n}:mine` ? "Keeping…" : "Keep mine" }),
|
|
125
|
+
/* @__PURE__ */ i("button", { type: "button", disabled: p !== null, onClick: () => void $(e, "theirs"), className: "xxk0z11 x1l8q8zy xmkeg23 x1y0btm7 x13oidi x1hb2obb x10qp4ay x1ypdohk xk0mbs4 x1s07b3s x784prv x9v5kkp x1yxvn1h x13iak60 x1nf6o4h x1trrqm4", children: p === `${n}:theirs` ? "Taking…" : "Take theirs" })
|
|
126
|
+
] })
|
|
127
|
+
] }, n);
|
|
128
|
+
}) })
|
|
129
|
+
] }) : /* @__PURE__ */ l("form", { className: "x78zum5 xdt5ytf xmqd7ac x1hb2obb xqjzbou", onSubmit: (e) => void W(e), children: [
|
|
130
|
+
/* @__PURE__ */ i("p", { ...g(y.groupLabel), children: s.length === 0 ? "Nothing to publish" : `${s.length} ${s.length === 1 ? "file" : "files"} → ${D}` }),
|
|
131
|
+
s.length > 0 ? /* @__PURE__ */ i("ul", { className: "x1ghz6dp x1717udv xe8uvvx xctk3hg x1odjw0f x1kbliiw", children: s.map((e) => /* @__PURE__ */ i("li", { children: /* @__PURE__ */ l("div", { className: "x78zum5 x6s0dn4 x3smv4v x1rz828m x1ghz6dp x1obou79 x1l8q8zy x1om5956 x1ar5oo6 x10qp4ay x111yfic", children: [
|
|
132
|
+
/* @__PURE__ */ l("span", { className: "xeuugli x98rzlu xb3r6kr xlyipyv xuxw1ft", children: [
|
|
133
|
+
e.type,
|
|
134
|
+
"/",
|
|
135
|
+
e.slug
|
|
136
|
+
] }),
|
|
137
|
+
/* @__PURE__ */ i("span", { ...g(y.itemMeta), children: te[e.status] })
|
|
138
|
+
] }) }, w(e))) }) : null,
|
|
139
|
+
s.length > 0 ? /* @__PURE__ */ i("div", { ...g(y.separator) }) : null,
|
|
140
|
+
s.length > 0 ? /* @__PURE__ */ l("div", { className: "x78zum5 xdt5ytf x1qjc9v5 x1ndbd79 x173sf5p x1l7y7l0 xreod0t", children: [
|
|
141
|
+
/* @__PURE__ */ i("input", { value: z, onChange: (e) => C(e.target.value), placeholder: S, "aria-label": "Commit message", autoComplete: "off", spellCheck: !1, "data-no-ring": !0, "data-1p-ignore": !0, "data-lpignore": !0, disabled: d || h !== "commit", className: "xh8yej3 x9f619 xe0p6wg x1l8q8zy x1om5956 xmkeg23 x1y0btm7 x1j0qoeq x13oidi xawfm1v xqjzbou x1vrk1b5 x1a2a7pz x1uvtmcs x1t8xw5s xk2swo9 xk0mbs4 x9ecp23" }),
|
|
142
|
+
x ? /* @__PURE__ */ i("p", { className: "x1ghz6dp x10qp4ay x1trrqm4 xnjsko4 x18d9i69", children: x }) : null,
|
|
143
|
+
h === "blocked" ? /* @__PURE__ */ i("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x37zpob x111yfic", children: "Writers cannot publish" }) : /* @__PURE__ */ i("button", { type: "submit", disabled: d || h !== "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: d ? "Committing…" : "Commit & push" })
|
|
144
|
+
] }) : x ? /* @__PURE__ */ i("p", { className: "x1ghz6dp x173sf5p xq98a72 x10qp4ay x1trrqm4", children: x }) : null
|
|
145
|
+
] });
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
ae as E
|
|
149
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { useState as y } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { B as c, A as S, p as z } from "./status-bar-action-DiXhfcj3.js";
|
|
4
|
+
import { u as N, T as l, B as p, S as m, P as o, F as x, I as b, a as w, b as $, c as L, d as g, e as h } from "./WorkspaceRoutes-CTFTWu3L.js";
|
|
5
|
+
import { L as q, a as k } from "./dashboard-upmiawx5.js";
|
|
6
|
+
const B = ["primary", "secondary", "ghost", "danger"];
|
|
6
7
|
function V() {
|
|
7
8
|
const {
|
|
8
9
|
preference: s,
|
|
9
10
|
resolved: r,
|
|
10
11
|
setPreference: u
|
|
11
|
-
} =
|
|
12
|
+
} = N(), [f, v] = y("en");
|
|
12
13
|
return /* @__PURE__ */ i("div", { className: "x1ov3xa9 x1uedy8c xvueqy4 xm8shrt x198e4go", children: [
|
|
13
14
|
/* @__PURE__ */ i("header", { className: "x78zum5 x1a02dak x1cy8zhl x1qughib x11cgr9k x1y5o9j5", children: [
|
|
14
15
|
/* @__PURE__ */ i("div", { children: [
|
|
@@ -33,10 +34,10 @@ function V() {
|
|
|
33
34
|
/* @__PURE__ */ i(m, { gap: "lg", children: [
|
|
34
35
|
/* @__PURE__ */ i("section", { className: "x78zum5 xdt5ytf x3smv4v", children: [
|
|
35
36
|
/* @__PURE__ */ e(n, { children: "Buttons" }),
|
|
36
|
-
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(m, { gap: "md", children:
|
|
37
|
+
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(m, { gap: "md", children: B.map((a) => /* @__PURE__ */ i(T, { label: a, children: [
|
|
37
38
|
/* @__PURE__ */ e(c, { variant: a, children: a }),
|
|
38
39
|
/* @__PURE__ */ e(c, { variant: a, disabled: !0, children: "disabled" }),
|
|
39
|
-
/* @__PURE__ */ e(
|
|
40
|
+
/* @__PURE__ */ e(S, { variant: a, to: "/__ui", children: "link" })
|
|
40
41
|
] }, a)) }) })
|
|
41
42
|
] }),
|
|
42
43
|
/* @__PURE__ */ i("section", { className: "x78zum5 xdt5ytf x3smv4v", children: [
|
|
@@ -44,14 +45,14 @@ function V() {
|
|
|
44
45
|
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ i(m, { children: [
|
|
45
46
|
/* @__PURE__ */ e(x, { label: "Text", hint: "Functional note under the field.", children: /* @__PURE__ */ e(b, { defaultValue: "Ada Lovelace", autoComplete: "off", spellCheck: !1 }) }),
|
|
46
47
|
/* @__PURE__ */ e(x, { label: "Disabled", children: /* @__PURE__ */ e(b, { defaultValue: "Locked", disabled: !0 }) }),
|
|
47
|
-
/* @__PURE__ */ e(x, { label: "Select", children: /* @__PURE__ */ e(
|
|
48
|
+
/* @__PURE__ */ e(x, { label: "Select", children: /* @__PURE__ */ e(w, { "aria-label": "Locale", value: f, onValueChange: (a) => v(a ?? "en"), options: [{
|
|
48
49
|
value: "en",
|
|
49
50
|
label: "English (en)"
|
|
50
51
|
}, {
|
|
51
52
|
value: "da",
|
|
52
53
|
label: "Dansk (da)"
|
|
53
54
|
}] }) }),
|
|
54
|
-
/* @__PURE__ */ e(x, { label: "Body (mono)", children: /* @__PURE__ */ e(
|
|
55
|
+
/* @__PURE__ */ e(x, { label: "Body (mono)", children: /* @__PURE__ */ e($, { mono: !0, rows: 4, defaultValue: `---
|
|
55
56
|
title: Hello
|
|
56
57
|
---
|
|
57
58
|
|
|
@@ -75,7 +76,7 @@ Paragraph.` }) })
|
|
|
75
76
|
/* @__PURE__ */ i("section", { className: "x78zum5 xdt5ytf x3smv4v", children: [
|
|
76
77
|
/* @__PURE__ */ e(n, { children: "List + page chrome" }),
|
|
77
78
|
/* @__PURE__ */ i(o, { children: [
|
|
78
|
-
/* @__PURE__ */ e(
|
|
79
|
+
/* @__PURE__ */ e(L, { kicker: /* @__PURE__ */ e(p, { to: "/__ui", children: "← Kit" }), title: "Documents", description: "Sample page header with action.", action: /* @__PURE__ */ e(c, { children: "New" }) }),
|
|
79
80
|
/* @__PURE__ */ i(q, { children: [
|
|
80
81
|
/* @__PURE__ */ e(k, { to: "/__ui", title: "hello-world", meta: "en", trailing: "modified" }),
|
|
81
82
|
/* @__PURE__ */ e(k, { to: "/__ui", title: "about", meta: "da", trailing: "new" })
|
|
@@ -115,7 +116,7 @@ function n({
|
|
|
115
116
|
}) {
|
|
116
117
|
return /* @__PURE__ */ e(l, { as: "h2", size: "xs", tone: "muted", weight: "semibold", children: s });
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
+
function T({
|
|
119
120
|
label: s,
|
|
120
121
|
children: r
|
|
121
122
|
}) {
|
|
@@ -129,7 +130,7 @@ function t({
|
|
|
129
130
|
fill: r
|
|
130
131
|
}) {
|
|
131
132
|
return /* @__PURE__ */ i("div", { className: "x78zum5 xdt5ytf x3smv4v", children: [
|
|
132
|
-
/* @__PURE__ */ e("div", { ...
|
|
133
|
+
/* @__PURE__ */ e("div", { ...z(d.chip, r) }),
|
|
133
134
|
/* @__PURE__ */ e(l, { size: "xs", tone: "muted", mono: !0, children: s })
|
|
134
135
|
] });
|
|
135
136
|
}
|