@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.
Files changed (36) hide show
  1. package/dist/chunks/EmbedPublishPage-hx1xoAhI.js +149 -0
  2. package/dist/chunks/{UiKitPage-CTZtLwJ0.js → UiKitPage-BOunq6mr.js} +12 -11
  3. package/dist/chunks/WorkspaceRoutes-CTFTWu3L.js +57731 -0
  4. package/dist/chunks/{dashboard-nvFBzpZv.js → dashboard-upmiawx5.js} +216 -215
  5. package/dist/chunks/{index-Cr-IOgdC.js → index-CBvevwfT.js} +9 -8
  6. package/dist/chunks/status-bar-action-DiXhfcj3.js +30254 -0
  7. package/dist/dashboard.js +2 -2
  8. package/dist/index.js +139 -228
  9. package/dist/site-widget.js +292 -0
  10. package/dist/studio.css +46 -6
  11. package/package.json +7 -2
  12. package/src/api.ts +4 -0
  13. package/src/chat/ChangeCard.tsx +11 -6
  14. package/src/chat/ChatMessage.tsx +27 -2
  15. package/src/chat/ChatPanel.tsx +12 -2
  16. package/src/chat/ChatProvider.tsx +40 -3
  17. package/src/chat/Composer.tsx +92 -6
  18. package/src/chat/DocLink.tsx +31 -0
  19. package/src/chat/DocListCard.tsx +3 -3
  20. package/src/chat/PointerChip.tsx +139 -0
  21. package/src/chat/chat-context.ts +80 -1
  22. package/src/chat/icons.tsx +20 -0
  23. package/src/chat/session-expiry.ts +13 -5
  24. package/src/chrome/OpenSiteButton.tsx +33 -25
  25. package/src/index.css +9 -1
  26. package/src/pages/EmbedChatPage.tsx +25 -1
  27. package/src/pages/EmbedPublishPage.tsx +279 -84
  28. package/src/pages/GithubConnectPage.tsx +44 -19
  29. package/src/pages/SelectRepositoriesLink.tsx +30 -0
  30. package/src/pages/SettingsGeneralPage.tsx +2 -0
  31. package/src/pages/SettingsGithubPage.tsx +8 -3
  32. package/src/pages/host-env.ts +7 -2
  33. package/src/site-pointer.ts +271 -0
  34. package/src/site-widget.tsx +391 -0
  35. package/src/site.tsx +11 -7
  36. package/dist/chunks/WorkspaceRoutes-DyRVES9t.js +0 -87308
@@ -0,0 +1,292 @@
1
+ import { jsxs as p, jsx as n, Fragment as N } from "react/jsx-runtime";
2
+ import { useRef as f, useState as k, useLayoutEffect as O, useEffect as m } from "react";
3
+ import { c as z, a as T, p as W, l as _, P as B, S as D, m as H, T as M, E as V, C as G, b as U, d as j, e as J, u as q, D as I, f as E, i as S, g as y, h as K, j as Y } from "./chunks/status-bar-action-DiXhfcj3.js";
4
+ import { E as Q } from "./chunks/EmbedPublishPage-hx1xoAhI.js";
5
+ const t = "backmatter-devbar";
6
+ function be({
7
+ doc: e,
8
+ branch: o,
9
+ tree: r,
10
+ exiting: c,
11
+ onExit: u,
12
+ onDocChanged: s,
13
+ onSessionExpired: b,
14
+ proxyPath: x = "/api/backmatter/cms",
15
+ version: i
16
+ }) {
17
+ const l = f(b);
18
+ l.current = b, k(() => (z({
19
+ baseUrl: x.replace(/\/+$/, ""),
20
+ credentials: "same-origin",
21
+ dev: !1,
22
+ version: i,
23
+ onUnauthorized: ({
24
+ status: a
25
+ }) => {
26
+ var h;
27
+ a === 401 && ((h = l.current) == null || h.call(l));
28
+ }
29
+ }), !0)), O(() => T(document.documentElement, W(_).className), []);
30
+ const [d, g] = k(!1), [w, v] = k(!1), [C, P] = k(0), A = e ? `${e.type}/${e.slug}` : "No document";
31
+ function R() {
32
+ s == null || s();
33
+ }
34
+ m(() => {
35
+ function a(h) {
36
+ J(h) === "chat" && (h.preventDefault(), v(!1), g((L) => !L));
37
+ }
38
+ return document.addEventListener("keydown", a, !0), () => document.removeEventListener("keydown", a, !0);
39
+ }, []);
40
+ const F = /* @__PURE__ */ p("footer", { "aria-label": "Backmatter", className: t, style: oe, children: [
41
+ /* @__PURE__ */ n("span", { style: ae, children: A }),
42
+ /* @__PURE__ */ n($, { children: "Preview" }),
43
+ o ? /* @__PURE__ */ n($, { children: o }) : null,
44
+ r ? /* @__PURE__ */ n($, { children: "draft" }) : null,
45
+ /* @__PURE__ */ p("button", { type: "button", className: `${t}-btn${w ? ` ${t}-on` : ""}`, "aria-pressed": w, disabled: !e, onClick: () => {
46
+ g(!1), v((a) => !a);
47
+ }, children: [
48
+ /* @__PURE__ */ n(B, {}),
49
+ /* @__PURE__ */ p("span", { children: [
50
+ "Publish",
51
+ C ? ` ${C}` : ""
52
+ ] })
53
+ ] }),
54
+ /* @__PURE__ */ p("button", { type: "button", className: `${t}-btn ${t}-agent${d ? ` ${t}-on` : ""}`, "aria-pressed": d, "aria-keyshortcuts": "Meta+J Control+J", disabled: !e, onClick: () => {
55
+ v(!1), g((a) => !a);
56
+ }, children: [
57
+ /* @__PURE__ */ n(D, {}),
58
+ /* @__PURE__ */ n("span", { children: "Agent" }),
59
+ /* @__PURE__ */ p("kbd", { children: [
60
+ H(),
61
+ "J"
62
+ ] })
63
+ ] }),
64
+ /* @__PURE__ */ n("button", { type: "button", "aria-label": "Exit preview", disabled: c, onClick: u, style: re, children: "Exit" })
65
+ ] });
66
+ return /* @__PURE__ */ p(N, { children: [
67
+ /* @__PURE__ */ n("style", { children: le }),
68
+ e ? /* @__PURE__ */ n(M, { children: /* @__PURE__ */ n(V, { children: /* @__PURE__ */ p(G, { workspaceId: e.workspaceId, pointer: !0, children: [
69
+ /* @__PURE__ */ n(X, { doc: e }),
70
+ /* @__PURE__ */ n(Z, { onDocChanged: R }),
71
+ /* @__PURE__ */ n(ee, { open: d }),
72
+ /* @__PURE__ */ n(te, { onClose: () => g(!1) }),
73
+ /* @__PURE__ */ n(ne, { doc: e }),
74
+ /* @__PURE__ */ n(U, { children: d ? /* @__PURE__ */ n(j, { site: !0 }) : null })
75
+ ] }) }) }) : null,
76
+ e ? /* @__PURE__ */ n("div", { "data-backmatter-panel": "", hidden: !w, style: se, children: /* @__PURE__ */ n(Q, { workspaceId: e.workspaceId, onStatus: ({
77
+ changeCount: a
78
+ }) => P(a), onPublished: () => {
79
+ v(!1), P(0), R();
80
+ } }) }) : null,
81
+ F
82
+ ] });
83
+ }
84
+ function X({
85
+ doc: e
86
+ }) {
87
+ const {
88
+ setFocus: o
89
+ } = q();
90
+ return m(() => {
91
+ o({
92
+ docRef: {
93
+ locale: e.locale,
94
+ type: e.type,
95
+ slug: e.slug
96
+ },
97
+ frontmatter: {},
98
+ body: "",
99
+ selection: null
100
+ });
101
+ }, [e.locale, e.type, e.slug, o]), null;
102
+ }
103
+ function Z({
104
+ onDocChanged: e
105
+ }) {
106
+ const o = f(e);
107
+ return o.current = e, m(() => {
108
+ function r() {
109
+ o.current();
110
+ }
111
+ return window.addEventListener(I, r), () => window.removeEventListener(I, r);
112
+ }, []), null;
113
+ }
114
+ function ee({
115
+ open: e
116
+ }) {
117
+ const {
118
+ dispatch: o
119
+ } = E();
120
+ return m(() => {
121
+ o({
122
+ type: e ? "open" : "close"
123
+ }), e && requestAnimationFrame(() => {
124
+ window.dispatchEvent(new Event("backmatter:chat-focus"));
125
+ });
126
+ }, [e, o]), null;
127
+ }
128
+ function te({
129
+ onClose: e
130
+ }) {
131
+ const {
132
+ panel: o
133
+ } = E(), r = o.mode, c = f(r), u = f(e);
134
+ return u.current = e, m(() => {
135
+ const s = S(c.current);
136
+ c.current = r, s && !S(r) && u.current();
137
+ }, [r]), null;
138
+ }
139
+ function ne({
140
+ doc: e
141
+ }) {
142
+ const {
143
+ addPointer: o,
144
+ panel: r
145
+ } = E(), c = S(r.mode), u = f(c), s = f(e);
146
+ return u.current = c, s.current = e, m(() => {
147
+ const b = K(document, {
148
+ bar: () => document.querySelector(`.${t}`),
149
+ ignore: (i) => !(i instanceof Element) || i.closest("[data-backmatter-panel]") ? !0 : i.closest("iframe") !== null,
150
+ onGrab: (i) => {
151
+ const l = Y(s.current, i);
152
+ l && o(l);
153
+ },
154
+ onEscape: () => {
155
+ window.dispatchEvent(new CustomEvent(y, {
156
+ detail: {
157
+ on: !1
158
+ }
159
+ }));
160
+ }
161
+ });
162
+ function x(i) {
163
+ var d;
164
+ ((d = i.detail) == null ? void 0 : d.on) && u.current ? b.arm() : b.disarm();
165
+ }
166
+ return window.addEventListener(y, x), () => {
167
+ window.removeEventListener(y, x), b.dispose();
168
+ };
169
+ }, [o]), null;
170
+ }
171
+ function $({
172
+ children: e
173
+ }) {
174
+ return /* @__PURE__ */ n("span", { style: ie, children: e });
175
+ }
176
+ const oe = {
177
+ position: "fixed",
178
+ right: "max(16px, env(safe-area-inset-right, 0px))",
179
+ bottom: 0,
180
+ zIndex: 2147483e3,
181
+ isolation: "isolate",
182
+ display: "flex",
183
+ alignItems: "center",
184
+ gap: 2,
185
+ width: "max-content",
186
+ maxWidth: "calc(100vw - 32px)",
187
+ minHeight: 36,
188
+ padding: "0 6px 0 10px",
189
+ boxSizing: "border-box",
190
+ border: "1px solid #e4e4e7",
191
+ borderRadius: "12px 12px 0 0",
192
+ background: "#ffffff",
193
+ color: "#71717a",
194
+ boxShadow: "0 10px 28px rgba(24, 24, 27, 0.12), 0 1px 2px rgba(24, 24, 27, 0.06)",
195
+ font: '12px/1 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',
196
+ WebkitFontSmoothing: "antialiased"
197
+ }, re = {
198
+ border: 0,
199
+ borderRadius: 8,
200
+ background: "transparent",
201
+ color: "#18181b",
202
+ font: "inherit",
203
+ cursor: "pointer",
204
+ padding: "0 8px",
205
+ minHeight: 28
206
+ }, ae = {
207
+ fontWeight: 600,
208
+ color: "#18181b",
209
+ maxWidth: 200,
210
+ overflow: "hidden",
211
+ textOverflow: "ellipsis",
212
+ whiteSpace: "nowrap",
213
+ padding: "0 6px"
214
+ }, ie = {
215
+ color: "#71717a",
216
+ fontSize: 12,
217
+ margin: 0,
218
+ padding: "0 6px",
219
+ maxWidth: 140,
220
+ overflow: "hidden",
221
+ textOverflow: "ellipsis",
222
+ whiteSpace: "nowrap"
223
+ }, se = {
224
+ position: "fixed",
225
+ right: "max(16px, env(safe-area-inset-right, 0px))",
226
+ bottom: "calc(env(safe-area-inset-bottom, 0px) + 48px)",
227
+ zIndex: 2147483001,
228
+ width: "min(320px, calc(100vw - 32px))",
229
+ maxHeight: "min(420px, calc(100vh - 80px))",
230
+ overflow: "auto",
231
+ border: "1px solid #e4e4e7",
232
+ borderRadius: 10,
233
+ background: "#ffffff",
234
+ boxShadow: "0 16px 40px rgba(24, 24, 27, 0.14), 0 2px 8px rgba(24, 24, 27, 0.06)"
235
+ }, le = `
236
+ @keyframes backmatter-devbar-in {
237
+ from { opacity: 0; transform: translateY(10px) scale(0.98); }
238
+ to { opacity: 1; transform: none; }
239
+ }
240
+ .${t} { animation: backmatter-devbar-in 240ms cubic-bezier(0.23, 1, 0.32, 1) both; }
241
+ @media (prefers-reduced-motion: reduce) {
242
+ .${t} { animation: none; }
243
+ }
244
+ .${t}-btn {
245
+ display: inline-flex;
246
+ align-items: center;
247
+ gap: 6px;
248
+ height: 26px;
249
+ margin-inline: 4px;
250
+ padding: 0 8px;
251
+ border: 1px solid #e4e4e7;
252
+ border-radius: 6px;
253
+ background: #ffffff;
254
+ color: #18181b;
255
+ font-size: 11px;
256
+ font-weight: 500;
257
+ line-height: 1;
258
+ cursor: pointer;
259
+ }
260
+ .${t}-agent kbd {
261
+ font-family: Geist Mono, ui-monospace, SFMono-Regular, Menlo, monospace;
262
+ font-size: 11px;
263
+ font-weight: 400;
264
+ opacity: 0.7;
265
+ }
266
+ .${t} button.${t}-on,
267
+ .${t} button.${t}-on:hover:not(:disabled) {
268
+ background: #18181b;
269
+ border-color: #18181b;
270
+ color: #fafafa;
271
+ }
272
+ @media (hover: hover) {
273
+ .${t} button:hover:not(:disabled) { background: #f4f4f5; }
274
+ .${t} button.${t}-btn:hover:not(:disabled) {
275
+ background: rgba(24, 24, 27, 0.05);
276
+ }
277
+ .${t} button.${t}-on:hover:not(:disabled) {
278
+ background: #18181b;
279
+ }
280
+ }
281
+ .${t} button:focus-visible { outline: 2px solid #18181b; outline-offset: 2px; }
282
+ .${t} button:disabled { cursor: default; opacity: 0.5; }
283
+ html.backmatter-pointing, html.backmatter-pointing * { cursor: crosshair !important; }
284
+ html.backmatter-pointing .${t},
285
+ html.backmatter-pointing .${t} *,
286
+ html.backmatter-pointing [data-backmatter-panel],
287
+ html.backmatter-pointing [data-backmatter-panel] * { cursor: pointer !important; }
288
+ html.backmatter-pointing .${t} button:disabled { cursor: default !important; }
289
+ `;
290
+ export {
291
+ be as SiteWidget
292
+ };