@voltro/plugin-chat 0.89.2 → 0.90.0
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/CHANGELOG.md +1822 -0
- package/README.md +16 -507
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/dist/components.js +160 -149
- package/dist/index.d.ts +66 -1
- package/dist/index.js +93 -66
- package/dist/inspect.js +25 -24
- package/dist/messageLinks.js +29 -0
- package/dist/rpc.d.ts +14 -0
- package/dist/rpc.js +22 -2
- package/dist/server.d.ts +3 -0
- package/dist/server.js +6 -5
- package/dist/service.js +596 -509
- package/dist/strategies.d.ts +34 -0
- package/dist/voice.js +76 -0
- package/dist/web.d.ts +49 -4
- package/dist/web.js +11 -10
- package/package.json +17 -17
package/dist/components.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { chatMessageSegments as e } from "./messageLinks.js";
|
|
2
|
+
import { insertMentionDraft as t, mentionDraftToken as n } from "./mentionDraft.js";
|
|
3
|
+
import { useEffect as r, useId as i, useLayoutEffect as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
4
|
+
import { Button as l, ExternalLink as u, Textarea as d } from "@voltro/ui-shadcn";
|
|
5
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
5
6
|
// src/components.tsx
|
|
6
|
-
var
|
|
7
|
+
var h = {
|
|
7
8
|
en: {
|
|
8
9
|
title: "Chat",
|
|
9
10
|
empty: "No messages yet. Start the conversation.",
|
|
@@ -44,35 +45,35 @@ var f = {
|
|
|
44
45
|
media: "Bild",
|
|
45
46
|
openMedia: "Bild öffnen"
|
|
46
47
|
}
|
|
47
|
-
},
|
|
48
|
-
let
|
|
49
|
-
return
|
|
50
|
-
let t =
|
|
48
|
+
}, g = ({ message: e, author: t, labels: n, locale: i, position: a, total: o, onHeight: c, onReport: u, onOpenMedia: d, onFocused: f, selfId: g }) => {
|
|
49
|
+
let v = s(null);
|
|
50
|
+
return r(() => {
|
|
51
|
+
let t = v.current;
|
|
51
52
|
if (!t) return;
|
|
52
53
|
let n = () => {
|
|
53
54
|
let n = Math.ceil(t.getBoundingClientRect().height);
|
|
54
|
-
n > 0 &&
|
|
55
|
+
n > 0 && c(e.id, n);
|
|
55
56
|
};
|
|
56
57
|
if (n(), typeof ResizeObserver > "u") return;
|
|
57
58
|
let r = new ResizeObserver(n);
|
|
58
59
|
return r.observe(t), () => r.disconnect();
|
|
59
|
-
}, [e.id,
|
|
60
|
-
ref:
|
|
60
|
+
}, [e.id, c]), /* @__PURE__ */ m("li", {
|
|
61
|
+
ref: v,
|
|
61
62
|
tabIndex: 0,
|
|
62
63
|
"data-message-id": e.id,
|
|
63
64
|
"aria-posinset": a,
|
|
64
|
-
"aria-setsize":
|
|
65
|
-
onFocus: () =>
|
|
65
|
+
"aria-setsize": o,
|
|
66
|
+
onFocus: () => f(e.id),
|
|
66
67
|
className: "min-w-0 space-y-2 border-b border-border px-4 py-4 outline-offset-[-2px] focus-visible:outline-2 focus-visible:outline-ring",
|
|
67
68
|
children: [
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ m("div", {
|
|
69
70
|
className: "flex flex-wrap items-baseline gap-x-3 gap-y-1 text-sm",
|
|
70
71
|
children: [
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ p("span", {
|
|
72
73
|
className: "break-words font-medium",
|
|
73
|
-
children: e.authorId === null || !t ?
|
|
74
|
+
children: e.authorId === null || !t ? n.unknown : t.displayName
|
|
74
75
|
}),
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
+
/* @__PURE__ */ p("time", {
|
|
76
77
|
dateTime: new Date(e.createdAt).toISOString(),
|
|
77
78
|
className: "text-muted-foreground tabular-nums",
|
|
78
79
|
children: new Intl.DateTimeFormat(i, {
|
|
@@ -80,53 +81,61 @@ var f = {
|
|
|
80
81
|
timeStyle: "short"
|
|
81
82
|
}).format(e.createdAt)
|
|
82
83
|
}),
|
|
83
|
-
e.editedAt === null ? null : /* @__PURE__ */
|
|
84
|
+
e.editedAt === null ? null : /* @__PURE__ */ p("span", {
|
|
84
85
|
className: "text-muted-foreground",
|
|
85
|
-
children:
|
|
86
|
+
children: n.edited
|
|
86
87
|
})
|
|
87
88
|
]
|
|
88
89
|
}),
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
+
/* @__PURE__ */ p("p", {
|
|
90
91
|
className: "max-w-prose whitespace-pre-wrap break-words text-sm leading-relaxed",
|
|
91
|
-
children: e.deletedAt === null ?
|
|
92
|
+
children: e.deletedAt === null ? /* @__PURE__ */ p(_, {
|
|
93
|
+
body: e.body,
|
|
94
|
+
locale: i
|
|
95
|
+
}) : n.deleted
|
|
92
96
|
}),
|
|
93
|
-
e.kind === "media" && e.deletedAt === null ? /* @__PURE__ */
|
|
97
|
+
e.kind === "media" && e.deletedAt === null ? /* @__PURE__ */ p("p", {
|
|
94
98
|
className: "text-sm text-muted-foreground",
|
|
95
|
-
children:
|
|
99
|
+
children: n.media ?? h.en.media
|
|
96
100
|
}) : null,
|
|
97
|
-
e.kind === "media" && e.deletedAt === null &&
|
|
101
|
+
e.kind === "media" && e.deletedAt === null && d ? /* @__PURE__ */ p(l, {
|
|
98
102
|
type: "button",
|
|
99
103
|
variant: "outline",
|
|
100
104
|
size: "sm",
|
|
101
|
-
onClick: () =>
|
|
102
|
-
children:
|
|
105
|
+
onClick: () => d(e.id),
|
|
106
|
+
children: n.openMedia ?? h.en.openMedia
|
|
103
107
|
}) : null,
|
|
104
|
-
e.flagged ? /* @__PURE__ */
|
|
108
|
+
e.flagged ? /* @__PURE__ */ p("p", {
|
|
105
109
|
className: "text-sm text-muted-foreground",
|
|
106
|
-
children:
|
|
110
|
+
children: n.flagged
|
|
107
111
|
}) : null,
|
|
108
|
-
|
|
112
|
+
u && e.deletedAt === null && (g === void 0 || e.authorId !== g) ? /* @__PURE__ */ p(l, {
|
|
109
113
|
type: "button",
|
|
110
114
|
variant: "ghost",
|
|
111
115
|
size: "sm",
|
|
112
|
-
onClick: () =>
|
|
113
|
-
children:
|
|
116
|
+
onClick: () => u(e.id),
|
|
117
|
+
children: n.report
|
|
114
118
|
}) : null
|
|
115
119
|
]
|
|
116
120
|
});
|
|
117
|
-
},
|
|
118
|
-
|
|
121
|
+
}, _ = ({ body: t, locale: n }) => /* @__PURE__ */ p(f, { children: e(t).map((e, t) => e.kind === "text" ? e.text : /* @__PURE__ */ p(u, {
|
|
122
|
+
href: e.href,
|
|
123
|
+
locale: n.startsWith("de") ? "de" : "en",
|
|
124
|
+
className: "underline underline-offset-2",
|
|
125
|
+
children: e.text
|
|
126
|
+
}, t)) }), v = ({ messages: e, authors: t, labels: n = h.en, locale: i = "en", loading: a = !1, onReport: l, onOpenMedia: u, selfId: d }) => {
|
|
127
|
+
let f = s(null), [m, _] = c({
|
|
119
128
|
top: 0,
|
|
120
129
|
height: 480
|
|
121
|
-
}), [
|
|
130
|
+
}), [v, y] = c(() => /* @__PURE__ */ new Map()), [b, x] = c(null), S = o(() => [...e].sort((e, t) => e.createdAt - t.createdAt || (e.id < t.id ? -1 : +(e.id > t.id))), [e]), C = o(() => new Map(t.map((e) => [e.subjectId, e])), [t]), w = o(() => (e, t) => y((n) => {
|
|
122
131
|
if (n.get(e) === t) return n;
|
|
123
132
|
let r = new Map(n);
|
|
124
133
|
return r.set(e, t), r;
|
|
125
134
|
}), []);
|
|
126
|
-
|
|
127
|
-
let e =
|
|
135
|
+
r(() => {
|
|
136
|
+
let e = f.current;
|
|
128
137
|
if (!e) return;
|
|
129
|
-
let t = () =>
|
|
138
|
+
let t = () => _({
|
|
130
139
|
top: e.scrollTop,
|
|
131
140
|
height: e.clientHeight || 480
|
|
132
141
|
});
|
|
@@ -134,54 +143,55 @@ var f = {
|
|
|
134
143
|
let n = new ResizeObserver(t);
|
|
135
144
|
return n.observe(e), () => n.disconnect();
|
|
136
145
|
}, []);
|
|
137
|
-
let
|
|
138
|
-
for (let e of
|
|
139
|
-
let
|
|
140
|
-
return
|
|
141
|
-
let
|
|
142
|
-
(a >=
|
|
146
|
+
let T = [0];
|
|
147
|
+
for (let e of S) T.push(T[T.length - 1] + (v.get(e.id) ?? 112));
|
|
148
|
+
let E = [], D = 0;
|
|
149
|
+
return S.forEach((e, t) => {
|
|
150
|
+
let r = T[t], a = T[t + 1];
|
|
151
|
+
(a >= m.top - 336 && r <= m.top + m.height + 336 || e.id === b) && (r > D && E.push(/* @__PURE__ */ p("li", {
|
|
143
152
|
"aria-hidden": "true",
|
|
144
153
|
role: "presentation",
|
|
145
|
-
style: { height:
|
|
146
|
-
}, `space-${e.id}`)),
|
|
154
|
+
style: { height: r - D }
|
|
155
|
+
}, `space-${e.id}`)), E.push(/* @__PURE__ */ p(g, {
|
|
147
156
|
message: e,
|
|
148
|
-
author: e.authorId === null ? void 0 :
|
|
149
|
-
labels:
|
|
157
|
+
author: e.authorId === null ? void 0 : C.get(e.authorId),
|
|
158
|
+
labels: n,
|
|
150
159
|
locale: i,
|
|
151
160
|
position: t + 1,
|
|
152
|
-
total:
|
|
153
|
-
onHeight:
|
|
154
|
-
onFocused:
|
|
161
|
+
total: S.length,
|
|
162
|
+
onHeight: w,
|
|
163
|
+
onFocused: x,
|
|
155
164
|
onReport: l,
|
|
156
|
-
onOpenMedia:
|
|
157
|
-
|
|
158
|
-
|
|
165
|
+
onOpenMedia: u,
|
|
166
|
+
selfId: d
|
|
167
|
+
}, e.id)), D = a);
|
|
168
|
+
}), T.at(-1) > D && E.push(/* @__PURE__ */ p("li", {
|
|
159
169
|
"aria-hidden": "true",
|
|
160
170
|
role: "presentation",
|
|
161
|
-
style: { height:
|
|
162
|
-
}, "space-end")), /* @__PURE__ */
|
|
163
|
-
ref:
|
|
171
|
+
style: { height: T.at(-1) - D }
|
|
172
|
+
}, "space-end")), /* @__PURE__ */ p("div", {
|
|
173
|
+
ref: f,
|
|
164
174
|
tabIndex: 0,
|
|
165
|
-
"aria-label":
|
|
166
|
-
"aria-busy":
|
|
175
|
+
"aria-label": n.title,
|
|
176
|
+
"aria-busy": a,
|
|
167
177
|
className: "max-h-[min(60dvh,40rem)] min-h-48 overflow-y-auto rounded-md border border-border",
|
|
168
|
-
onScroll: (e) =>
|
|
178
|
+
onScroll: (e) => _({
|
|
169
179
|
top: e.currentTarget.scrollTop,
|
|
170
180
|
height: e.currentTarget.clientHeight || 480
|
|
171
181
|
}),
|
|
172
182
|
onBlur: (e) => {
|
|
173
|
-
e.currentTarget.contains(e.relatedTarget) ||
|
|
183
|
+
e.currentTarget.contains(e.relatedTarget) || x(null);
|
|
174
184
|
},
|
|
175
|
-
children:
|
|
185
|
+
children: S.length === 0 ? /* @__PURE__ */ p("p", {
|
|
176
186
|
className: "px-4 py-8 text-sm text-muted-foreground",
|
|
177
|
-
role:
|
|
178
|
-
children:
|
|
179
|
-
}) : /* @__PURE__ */
|
|
187
|
+
role: a ? "status" : void 0,
|
|
188
|
+
children: a ? n.loading : n.empty
|
|
189
|
+
}) : /* @__PURE__ */ p("ol", {
|
|
180
190
|
className: "m-0 list-none p-0",
|
|
181
|
-
children:
|
|
191
|
+
children: E
|
|
182
192
|
})
|
|
183
193
|
});
|
|
184
|
-
},
|
|
194
|
+
}, y = {
|
|
185
195
|
en: {
|
|
186
196
|
typing: "is typing…",
|
|
187
197
|
peopleTyping: "players are typing…",
|
|
@@ -192,16 +202,16 @@ var f = {
|
|
|
192
202
|
peopleTyping: "Spieler schreiben…",
|
|
193
203
|
someoneTyping: "Jemand schreibt…"
|
|
194
204
|
}
|
|
195
|
-
},
|
|
205
|
+
}, b = ({ subjects: e, authors: t, labels: n = y.en, locale: r = "en" }) => {
|
|
196
206
|
let i = [...new Set(e.slice(0, 128))], a = i.length === 1 ? t.find((e) => e.subjectId === i[0]) : void 0, o = i.length === 0 ? "" : i.length > 1 ? `${new Intl.NumberFormat(r).format(i.length)} ${n.peopleTyping}` : a ? `${a.displayName} ${n.typing}` : n.someoneTyping;
|
|
197
|
-
return /* @__PURE__ */
|
|
207
|
+
return /* @__PURE__ */ p("p", {
|
|
198
208
|
role: "status",
|
|
199
209
|
"aria-live": "polite",
|
|
200
210
|
"aria-atomic": "true",
|
|
201
211
|
className: "min-h-5 break-words text-sm text-muted-foreground",
|
|
202
212
|
children: o
|
|
203
213
|
});
|
|
204
|
-
},
|
|
214
|
+
}, x = {
|
|
205
215
|
en: {
|
|
206
216
|
title: "Mention a player",
|
|
207
217
|
empty: "No matching players on this page.",
|
|
@@ -216,56 +226,56 @@ var f = {
|
|
|
216
226
|
more: "Weitere Personen laden",
|
|
217
227
|
help: "Mit Tab oder Pfeil nach unten eine Person wählen. Escape schließt Vorschläge."
|
|
218
228
|
}
|
|
219
|
-
},
|
|
220
|
-
let T =
|
|
229
|
+
}, S = ({ value: e, onChange: r, onSend: o, onTyping: u, mentionCandidates: f, mentionLabels: g = x.en, mentionsLoading: _ = !1, onLoadMoreMentions: v, pending: y = !1, disabled: b = !1, error: S, labels: C = h.en, maxBodyLength: w = 2e3 }) => {
|
|
230
|
+
let T = i(), E = [...e].length, D = b || y || !e.trim() || E > w, O = s(null), k = s(null), [A, j] = c({
|
|
221
231
|
start: 0,
|
|
222
232
|
end: 0
|
|
223
|
-
}), [M, N] =
|
|
233
|
+
}), [M, N] = c(!1), [P, F] = c(!1), I = s(null), L = !b && !y && M && !P && f !== void 0 ? n(e, A.start, A.end) : null, R = L === null || _ ? [] : f.slice(0, 128).filter((n, r, i) => i.findIndex((e) => e.subjectId === n.subjectId) === r && n.displayName.normalize("NFKC").toLowerCase().startsWith(L.prefix.normalize("NFKC").toLowerCase()) && t(e, L, n.displayName, w) !== null).slice(0, 8), z = (e) => j({
|
|
224
234
|
start: e.selectionStart,
|
|
225
235
|
end: e.selectionEnd
|
|
226
236
|
});
|
|
227
|
-
|
|
228
|
-
let
|
|
229
|
-
|
|
230
|
-
start:
|
|
231
|
-
end:
|
|
232
|
-
})) :
|
|
233
|
-
}, [
|
|
234
|
-
let B =
|
|
235
|
-
return
|
|
236
|
-
B.current =
|
|
237
|
-
}),
|
|
238
|
-
(
|
|
237
|
+
a(() => {
|
|
238
|
+
let t = I.current;
|
|
239
|
+
t && t.body === e ? (I.current = null, O.current?.focus(), O.current?.setSelectionRange(t.caret, t.caret), j({
|
|
240
|
+
start: t.caret,
|
|
241
|
+
end: t.caret
|
|
242
|
+
})) : t && (I.current = null);
|
|
243
|
+
}, [e]);
|
|
244
|
+
let B = s(u);
|
|
245
|
+
return a(() => {
|
|
246
|
+
B.current = u;
|
|
247
|
+
}), a(() => {
|
|
248
|
+
(b || y || !e.trim()) && B.current?.(!1);
|
|
239
249
|
}, [
|
|
240
|
-
x,
|
|
241
250
|
b,
|
|
242
|
-
|
|
243
|
-
|
|
251
|
+
y,
|
|
252
|
+
e
|
|
253
|
+
]), a(() => () => {
|
|
244
254
|
B.current?.(!1);
|
|
245
|
-
}, []), /* @__PURE__ */
|
|
255
|
+
}, []), /* @__PURE__ */ m("form", {
|
|
246
256
|
className: "space-y-3",
|
|
247
|
-
"aria-busy":
|
|
257
|
+
"aria-busy": y,
|
|
248
258
|
onBlur: (e) => {
|
|
249
259
|
e.currentTarget.contains(e.relatedTarget) || (N(!1), F(!0));
|
|
250
260
|
},
|
|
251
261
|
onKeyDown: (e) => {
|
|
252
262
|
e.key === "Escape" && L && (e.preventDefault(), F(!0), O.current?.focus());
|
|
253
263
|
},
|
|
254
|
-
onSubmit: (
|
|
255
|
-
|
|
264
|
+
onSubmit: (t) => {
|
|
265
|
+
t.preventDefault(), D || (B.current?.(!1), o(e));
|
|
256
266
|
},
|
|
257
267
|
children: [
|
|
258
|
-
/* @__PURE__ */
|
|
268
|
+
/* @__PURE__ */ p("label", {
|
|
259
269
|
htmlFor: T,
|
|
260
270
|
className: "block text-sm font-medium",
|
|
261
271
|
children: C.draft
|
|
262
272
|
}),
|
|
263
|
-
/* @__PURE__ */
|
|
273
|
+
/* @__PURE__ */ p(d, {
|
|
264
274
|
ref: O,
|
|
265
275
|
id: T,
|
|
266
|
-
value:
|
|
276
|
+
value: e,
|
|
267
277
|
rows: 3,
|
|
268
|
-
readOnly:
|
|
278
|
+
readOnly: b || y,
|
|
269
279
|
"aria-describedby": `${T}-count${L ? ` ${T}-mention-help` : ""}`,
|
|
270
280
|
...L ? { "aria-controls": `${T}-mentions` } : {},
|
|
271
281
|
onFocus: (e) => {
|
|
@@ -278,63 +288,63 @@ var f = {
|
|
|
278
288
|
},
|
|
279
289
|
onBlur: () => B.current?.(!1),
|
|
280
290
|
onChange: (e) => {
|
|
281
|
-
if (!
|
|
291
|
+
if (!b && !y) {
|
|
282
292
|
let t = e.target.value;
|
|
283
|
-
z(e.target), F(!1),
|
|
293
|
+
z(e.target), F(!1), r(t), B.current?.(t.trim().length > 0);
|
|
284
294
|
}
|
|
285
295
|
}
|
|
286
296
|
}),
|
|
287
|
-
L ? /* @__PURE__ */
|
|
297
|
+
L ? /* @__PURE__ */ m("div", {
|
|
288
298
|
ref: k,
|
|
289
299
|
id: `${T}-mentions`,
|
|
290
300
|
role: "group",
|
|
291
301
|
"aria-labelledby": `${T}-mention-title`,
|
|
292
302
|
className: "space-y-2 rounded-md border border-border p-3",
|
|
293
303
|
children: [
|
|
294
|
-
/* @__PURE__ */
|
|
304
|
+
/* @__PURE__ */ p("p", {
|
|
295
305
|
id: `${T}-mention-title`,
|
|
296
306
|
className: "text-sm font-medium",
|
|
297
307
|
children: g.title
|
|
298
308
|
}),
|
|
299
|
-
/* @__PURE__ */
|
|
309
|
+
/* @__PURE__ */ p("p", {
|
|
300
310
|
id: `${T}-mention-help`,
|
|
301
311
|
className: "text-sm text-muted-foreground",
|
|
302
312
|
children: g.help
|
|
303
313
|
}),
|
|
304
|
-
|
|
314
|
+
_ ? /* @__PURE__ */ p("p", {
|
|
305
315
|
role: "status",
|
|
306
316
|
className: "text-sm text-muted-foreground",
|
|
307
317
|
children: g.loading
|
|
308
|
-
}) : R.length === 0 ? /* @__PURE__ */
|
|
318
|
+
}) : R.length === 0 ? /* @__PURE__ */ p("p", {
|
|
309
319
|
role: "status",
|
|
310
320
|
className: "text-sm text-muted-foreground",
|
|
311
321
|
children: g.empty
|
|
312
322
|
}) : null,
|
|
313
|
-
/* @__PURE__ */
|
|
323
|
+
/* @__PURE__ */ p("div", {
|
|
314
324
|
className: "flex flex-wrap gap-2",
|
|
315
|
-
children: R.map((
|
|
325
|
+
children: R.map((n) => /* @__PURE__ */ p(l, {
|
|
316
326
|
type: "button",
|
|
317
327
|
variant: "outline",
|
|
318
328
|
className: "max-w-full whitespace-normal break-words",
|
|
319
329
|
onClick: () => {
|
|
320
|
-
let
|
|
321
|
-
|
|
330
|
+
let i = t(e, L, n.displayName, w);
|
|
331
|
+
b || y || !i || (I.current = i, F(!0), r(i.body), B.current?.(!0));
|
|
322
332
|
},
|
|
323
|
-
children:
|
|
324
|
-
},
|
|
333
|
+
children: n.displayName
|
|
334
|
+
}, n.subjectId))
|
|
325
335
|
}),
|
|
326
|
-
|
|
336
|
+
v ? /* @__PURE__ */ p(l, {
|
|
327
337
|
type: "button",
|
|
328
338
|
variant: "ghost",
|
|
329
|
-
disabled:
|
|
330
|
-
onClick:
|
|
339
|
+
disabled: _,
|
|
340
|
+
onClick: v,
|
|
331
341
|
children: g.more
|
|
332
342
|
}) : null
|
|
333
343
|
]
|
|
334
344
|
}) : null,
|
|
335
|
-
/* @__PURE__ */
|
|
345
|
+
/* @__PURE__ */ m("div", {
|
|
336
346
|
className: "flex flex-wrap items-center justify-between gap-3",
|
|
337
|
-
children: [/* @__PURE__ */
|
|
347
|
+
children: [/* @__PURE__ */ m("span", {
|
|
338
348
|
id: `${T}-count`,
|
|
339
349
|
className: "text-sm text-muted-foreground tabular-nums",
|
|
340
350
|
children: [
|
|
@@ -342,25 +352,25 @@ var f = {
|
|
|
342
352
|
" / ",
|
|
343
353
|
w
|
|
344
354
|
]
|
|
345
|
-
}), /* @__PURE__ */
|
|
355
|
+
}), /* @__PURE__ */ p(l, {
|
|
346
356
|
type: "submit",
|
|
347
357
|
"aria-disabled": D,
|
|
348
|
-
children:
|
|
358
|
+
children: y ? C.sending : C.send
|
|
349
359
|
})]
|
|
350
360
|
}),
|
|
351
|
-
S === void 0 ? null : /* @__PURE__ */
|
|
361
|
+
S === void 0 ? null : /* @__PURE__ */ p("p", {
|
|
352
362
|
role: "alert",
|
|
353
363
|
className: "text-sm text-destructive",
|
|
354
364
|
children: C.failed
|
|
355
365
|
})
|
|
356
366
|
]
|
|
357
367
|
});
|
|
358
|
-
},
|
|
368
|
+
}, C = ({ channels: e, selectedId: t, onSelect: n, unread: r = [], labels: i = h.en, disabled: a = !1 }) => /* @__PURE__ */ p("nav", {
|
|
359
369
|
"aria-label": i.choose,
|
|
360
370
|
className: "flex flex-wrap gap-2",
|
|
361
371
|
children: e.map((e) => {
|
|
362
372
|
let o = r.find((t) => t.channelId === e.id);
|
|
363
|
-
return /* @__PURE__ */
|
|
373
|
+
return /* @__PURE__ */ m(l, {
|
|
364
374
|
type: "button",
|
|
365
375
|
variant: t === e.id ? "default" : "outline",
|
|
366
376
|
"aria-current": t === e.id ? "page" : void 0,
|
|
@@ -369,7 +379,7 @@ var f = {
|
|
|
369
379
|
a || n(e.id);
|
|
370
380
|
},
|
|
371
381
|
className: "max-w-full whitespace-normal break-words",
|
|
372
|
-
children: [e.name || i.title, o && (o.count > 0 || o.truncated) ? /* @__PURE__ */
|
|
382
|
+
children: [e.name || i.title, o && (o.count > 0 || o.truncated) ? /* @__PURE__ */ m("span", {
|
|
373
383
|
className: "tabular-nums",
|
|
374
384
|
children: [
|
|
375
385
|
" · ",
|
|
@@ -381,51 +391,52 @@ var f = {
|
|
|
381
391
|
}) : null]
|
|
382
392
|
}, e.id);
|
|
383
393
|
})
|
|
384
|
-
}),
|
|
385
|
-
let
|
|
386
|
-
return /* @__PURE__ */
|
|
387
|
-
"aria-labelledby":
|
|
394
|
+
}), w = ({ scopeKey: e, dataScopeKey: t, channelId: n, messages: r, authors: a, labels: o = h.en, locale: s, loading: c = !1, onReport: u, onOpenMedia: d, selfId: f, canLoadOlder: g = !1, onLoadOlder: _, typing: C, typingLabels: w, ...T }) => {
|
|
395
|
+
let E = i(), D = e === t;
|
|
396
|
+
return /* @__PURE__ */ m("section", {
|
|
397
|
+
"aria-labelledby": E,
|
|
388
398
|
className: "min-w-0 space-y-4",
|
|
389
399
|
children: [
|
|
390
|
-
/* @__PURE__ */
|
|
391
|
-
id:
|
|
400
|
+
/* @__PURE__ */ p("h2", {
|
|
401
|
+
id: E,
|
|
392
402
|
className: "text-lg font-semibold",
|
|
393
403
|
children: o.title
|
|
394
404
|
}),
|
|
395
|
-
|
|
405
|
+
g && _ ? /* @__PURE__ */ p(l, {
|
|
396
406
|
type: "button",
|
|
397
407
|
variant: "outline",
|
|
398
|
-
"aria-disabled":
|
|
408
|
+
"aria-disabled": c || !D,
|
|
399
409
|
onClick: () => {
|
|
400
|
-
!
|
|
410
|
+
!c && D && _();
|
|
401
411
|
},
|
|
402
412
|
children: o.older
|
|
403
413
|
}) : null,
|
|
404
|
-
/* @__PURE__ */
|
|
405
|
-
messages:
|
|
406
|
-
authors:
|
|
414
|
+
/* @__PURE__ */ p(v, {
|
|
415
|
+
messages: D ? r.filter((e) => e.channelId === n) : [],
|
|
416
|
+
authors: D ? a : [],
|
|
407
417
|
labels: o,
|
|
408
418
|
locale: s,
|
|
409
|
-
loading:
|
|
410
|
-
onReport:
|
|
411
|
-
onOpenMedia:
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
419
|
+
loading: c || !D,
|
|
420
|
+
onReport: D ? u : void 0,
|
|
421
|
+
onOpenMedia: D ? d : void 0,
|
|
422
|
+
selfId: f
|
|
423
|
+
}, `messages:${e}:${n}`),
|
|
424
|
+
/* @__PURE__ */ p(b, {
|
|
425
|
+
subjects: D && C?.channelId === n && C.status === "live" ? C.subjects : [],
|
|
426
|
+
authors: D ? a : [],
|
|
427
|
+
labels: w ?? (s?.startsWith("de") ? y.de : y.en),
|
|
417
428
|
locale: s
|
|
418
429
|
}),
|
|
419
|
-
/* @__PURE__ */
|
|
420
|
-
...
|
|
421
|
-
value:
|
|
430
|
+
/* @__PURE__ */ p(S, {
|
|
431
|
+
...T,
|
|
432
|
+
value: D ? T.value : "",
|
|
422
433
|
labels: o,
|
|
423
|
-
mentionCandidates:
|
|
424
|
-
mentionLabels:
|
|
425
|
-
onLoadMoreMentions:
|
|
426
|
-
disabled:
|
|
427
|
-
},
|
|
434
|
+
mentionCandidates: D ? T.mentionCandidates : void 0,
|
|
435
|
+
mentionLabels: T.mentionLabels ?? (s?.startsWith("de") ? x.de : x.en),
|
|
436
|
+
onLoadMoreMentions: D ? T.onLoadMoreMentions : void 0,
|
|
437
|
+
disabled: T.disabled || !D
|
|
438
|
+
}, `composer:${e}:${n}`)
|
|
428
439
|
]
|
|
429
440
|
});
|
|
430
441
|
};
|
|
431
|
-
export {
|
|
442
|
+
export { C as ChannelTabs, w as ChatPanel, S as Composer, v as MessageList, b as TypingIndicator, h as chatLabels, x as chatMentionLabels, y as chatTypingLabels };
|
package/dist/index.d.ts
CHANGED
|
@@ -213,7 +213,7 @@ export declare const chatMembersTable: Table<"_voltro_chat_members", FieldDefini
|
|
|
213
213
|
readonly tenantId: ColumnBuilder<string, "text", boolean>;
|
|
214
214
|
readonly channelId: ColumnBuilder<string, "text", boolean>;
|
|
215
215
|
readonly subjectId: ColumnBuilder<string, "text", boolean>;
|
|
216
|
-
readonly role: ColumnBuilder<"
|
|
216
|
+
readonly role: ColumnBuilder<"owner" | "member" | "mod", "text", boolean>;
|
|
217
217
|
readonly mutedUntil: ColumnBuilder<Date | null, "timestamp", boolean>;
|
|
218
218
|
readonly lastReadAt: ColumnBuilder<Date, "timestamp", boolean>;
|
|
219
219
|
readonly lastReadId: ColumnBuilder<string | null, "text", boolean>;
|
|
@@ -343,6 +343,8 @@ export declare interface ChatOptions {
|
|
|
343
343
|
readonly mediaUrlTtlSec?: number;
|
|
344
344
|
readonly rateLimit?: RedisStoreOptions;
|
|
345
345
|
readonly now?: () => number;
|
|
346
|
+
/** Voice chat signalling for a third-party SFU (`liveKitVoiceProvider`, `devVoiceProvider`). */
|
|
347
|
+
readonly voice?: ChatVoiceOptions;
|
|
346
348
|
}
|
|
347
349
|
|
|
348
350
|
export declare type ChatOriginal = typeof ChatOriginalSchema.Type;
|
|
@@ -502,6 +504,44 @@ declare const ChatUnreadSchema: Schema.Struct<{
|
|
|
502
504
|
readonly truncated: Schema.Boolean;
|
|
503
505
|
}>;
|
|
504
506
|
|
|
507
|
+
export declare interface ChatVoiceGrant {
|
|
508
|
+
/** The provider's room name for this channel. */
|
|
509
|
+
readonly room: string;
|
|
510
|
+
/** The player's identity in the voice room (their subject ID). */
|
|
511
|
+
readonly identity: string;
|
|
512
|
+
readonly canPublish: boolean;
|
|
513
|
+
readonly ttlSeconds: number;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export declare interface ChatVoiceJoin extends ChatVoiceTicket {
|
|
517
|
+
readonly provider: string;
|
|
518
|
+
readonly room: string;
|
|
519
|
+
readonly canPublish: boolean;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export declare interface ChatVoiceOptions {
|
|
523
|
+
readonly provider: ChatVoiceProvider;
|
|
524
|
+
/** Token lifetime (default 600 s, 30 to 3600). The client asks again to stay longer. */
|
|
525
|
+
readonly ttlSeconds?: number | undefined;
|
|
526
|
+
/** The provider room for a channel (default `<tenantId>:<channelId>`). */
|
|
527
|
+
readonly room?: ((input: {
|
|
528
|
+
readonly tenantId: string;
|
|
529
|
+
readonly channelId: string;
|
|
530
|
+
}) => string) | undefined;
|
|
531
|
+
readonly now?: (() => number) | undefined;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export declare interface ChatVoiceProvider {
|
|
535
|
+
readonly name: string;
|
|
536
|
+
readonly mint: (grant: ChatVoiceGrant) => Effect.Effect<ChatVoiceTicket, unknown>;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export declare interface ChatVoiceTicket {
|
|
540
|
+
readonly url: string;
|
|
541
|
+
readonly token: string;
|
|
542
|
+
readonly expiresAt: number;
|
|
543
|
+
}
|
|
544
|
+
|
|
505
545
|
export declare interface CreateChatChannelInput {
|
|
506
546
|
readonly tenantId: string;
|
|
507
547
|
readonly kind: typeof CHANNEL_KINDS[number];
|
|
@@ -547,6 +587,17 @@ export declare const dataStoreChat: (store: DataStore, options: ResolvedChatOpti
|
|
|
547
587
|
}) => Effect.Effect<void, ChatError>;
|
|
548
588
|
archiveMatch: (subject: Subject, input: ArchiveMatchInput) => Effect.Effect<ChatChannel, ChatError>;
|
|
549
589
|
exportSubject: (target: PluginPrivacyTarget) => Effect.Effect<unknown, ChatError, never>;
|
|
590
|
+
/** Account merge inside the coordinator's transaction. The guest's messages, evidence, media
|
|
591
|
+
* and mentions name the target (the same person keeps their history). Its memberships move; a
|
|
592
|
+
* channel both are in keeps the target's row, with the higher of the two roles. A direct
|
|
593
|
+
* conversation with someone becomes the target's conversation with them: re-keyed to the new
|
|
594
|
+
* pair, or folded into the one the target already has with that person. */
|
|
595
|
+
mergeSubject: (context: {
|
|
596
|
+
readonly store: DataStore;
|
|
597
|
+
readonly tenantId: string;
|
|
598
|
+
readonly sourceId: string;
|
|
599
|
+
readonly targetId: string;
|
|
600
|
+
}) => Effect.Effect<void, ChatError, never>;
|
|
550
601
|
eraseSubject: (input: PluginPrivacyTarget) => Effect.Effect<void, ChatError, never>;
|
|
551
602
|
};
|
|
552
603
|
|
|
@@ -557,6 +608,12 @@ export declare interface DeleteChatInput {
|
|
|
557
608
|
readonly baseVersion: number;
|
|
558
609
|
}
|
|
559
610
|
|
|
611
|
+
/** Development stub: an unsigned, readable token for a local fake SFU. Never for production. */
|
|
612
|
+
export declare const devVoiceProvider: (options?: {
|
|
613
|
+
readonly url?: string;
|
|
614
|
+
readonly now?: () => number;
|
|
615
|
+
}) => ChatVoiceProvider;
|
|
616
|
+
|
|
560
617
|
export declare interface EditChatInput {
|
|
561
618
|
readonly messageId: string;
|
|
562
619
|
readonly baseVersion: number;
|
|
@@ -571,6 +628,14 @@ declare const fixedChatRateBudgets: (input: ChatRateInput) => {
|
|
|
571
628
|
/** Composition over the existing moderation provider, not another classifier. */
|
|
572
629
|
declare const keywordChatModeration: (input: ChatModerationInput) => Effect.Effect<ChatModerationResult, ChatError>;
|
|
573
630
|
|
|
631
|
+
/** LiveKit access tokens: an HS256 JWT with a `video` grant, signed with the API secret. */
|
|
632
|
+
export declare const liveKitVoiceProvider: (options: {
|
|
633
|
+
readonly url: string;
|
|
634
|
+
readonly apiKey: string;
|
|
635
|
+
readonly apiSecret: string;
|
|
636
|
+
readonly now?: () => number;
|
|
637
|
+
}) => ChatVoiceProvider;
|
|
638
|
+
|
|
574
639
|
/** Exact Name#Tag claims from Players; Chat still admits every result against its channel. */
|
|
575
640
|
declare const playerChatMentions: (input: ChatMentionInput) => Effect.Effect<ReadonlyArray<string>, ChatError>;
|
|
576
641
|
|