@commentkit/comment-kit 0.7.0 → 0.7.1

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 (45) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/angular.es.js +2 -2
  3. package/dist/comment-kit.es.js +5 -5
  4. package/dist/demo.es.js +4 -3
  5. package/dist/headless.es.js +3 -3
  6. package/dist/preact.es.js +2 -2
  7. package/dist/qwik.qwik.mjs +2 -2
  8. package/dist/react.es.js +2 -2
  9. package/dist/shared/{annotation-toolbar-B9SxYqoF.js → annotation-toolbar-cGC1p-SP.js} +379 -379
  10. package/dist/shared/attachment-refresh-CzQFXHkL.js +94 -0
  11. package/dist/shared/{button-group-Cl9CrvvU.js → button-group-CWdKaOlC.js} +14 -16
  12. package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
  13. package/dist/shared/{comment-drawing-canvas-Dzb5YoFw.js → comment-drawing-canvas-DdXlMgbF.js} +2 -2
  14. package/dist/shared/{comment-utils-BycYTSxA.js → comment-icon-Dg9ZWpz-.js} +29 -23
  15. package/dist/shared/comment-image-lightbox-B7iHjnAz.js +190 -0
  16. package/dist/shared/comment-images-content-D7YNUgo5.js +214 -0
  17. package/dist/shared/{comment-kit-core-BaSuMzp9.js → comment-kit-core-C862uNAm.js} +998 -778
  18. package/dist/shared/{comment-kit-ui-CzfdAZs2.js → comment-kit-ui-0vd-DY4S.js} +5206 -5410
  19. package/dist/shared/{comment-screenshot-annotator-C7X-_bm6.js → comment-screenshot-annotator-DcaSSuWB.js} +5 -5
  20. package/dist/shared/{comment-screenshot-overlay-wIrZrcRy.js → comment-screenshot-overlay-D_nFoJmM.js} +6 -5
  21. package/dist/shared/{dev-export-panel-FwFVdady.js → dev-export-panel-pWBlhlse.js} +7 -7
  22. package/dist/shared/dev-grab-eQ9EgEGY.js +210 -0
  23. package/dist/shared/{element-selector-BhJm-NSs.js → element-selector-DC-_XJ0k.js} +311 -272
  24. package/dist/shared/{mount-ui--ijs8pWT.js → mount-ui-B68j8r6I.js} +4 -4
  25. package/dist/shared/{pusher-ipHMJnO_.js → pusher-C1FHQGXV.js} +1 -1
  26. package/dist/shared/realtime-Diqz7G_y.js +317 -0
  27. package/dist/shared/realtime-recovery-DJ_adc-H.js +135 -0
  28. package/dist/shared/{shadow-root-C5v-T8lQ.js → shadow-root-CrO75sED.js} +1 -1
  29. package/dist/shared/{styles-D3yMtaec.js → styles-C9Jwvm0Q.js} +1 -1
  30. package/dist/shared/useRender-D1z_X_BY.js +5 -0
  31. package/dist/shared/{validation-C7QG8j7Z.js → validation-D-8u4M7I.js} +14 -1
  32. package/dist/shared/{websocket-manager-DhLWh3Jr.js → websocket-manager-CFak_YHy.js} +148 -89
  33. package/dist/solid.es.js +2 -2
  34. package/dist/svelte.es.js +2 -2
  35. package/dist/types/core/api-client.d.ts +8 -1
  36. package/dist/types/core/comment-kit-core.d.ts +9 -0
  37. package/dist/types/core/types.d.ts +35 -0
  38. package/dist/types/core/websocket-manager.d.ts +12 -0
  39. package/dist/types/core/write-access.d.ts +9 -0
  40. package/dist/vue.es.js +2 -2
  41. package/docs/api-reference.md +6 -0
  42. package/package.json +3 -2
  43. package/dist/shared/comment-image-lightbox-BPYJT1sB.js +0 -183
  44. package/dist/shared/dev-grab-DDqg0LQf.js +0 -203
  45. package/dist/shared/realtime-Dk41VwKg.js +0 -302
@@ -1,302 +0,0 @@
1
- import { t as e } from "./websocket-manager-DhLWh3Jr.js";
2
- import { a as t, c as n, i as r, o as i, s as a } from "./validation-C7QG8j7Z.js";
3
- import { i as o } from "./comment-kit-core-BaSuMzp9.js";
4
- import { o as s } from "./dom-Bhf4WFtY.js";
5
- var c = o.ID, l = o.CONTENT, u = o.NAME, d = o.EMAIL, f = o.PAGE, p = o.EMOJI, m = o.ONLINE_USERS, h = o.REACTION_COUNT, g = 33, _ = 1e3, v = o.CURSOR_EMITS_PER_SEC;
6
- function y(e) {
7
- let t = e.config.realtime, n = t?.maxRenderedCursors;
8
- return {
9
- cursors: t?.cursors !== !1,
10
- presence: t?.presence !== !1,
11
- maxRenderedCursors: typeof n == "number" && Number.isFinite(n) && n >= 0 ? Math.min(Math.floor(n), m) : o.RENDERED_CURSORS
12
- };
13
- }
14
- var b = /* @__PURE__ */ new Set([
15
- "pin",
16
- "highlight",
17
- "drawing"
18
- ]), x = /* @__PURE__ */ new Set([
19
- "open",
20
- "resolved",
21
- "complete"
22
- ]), S = /* @__PURE__ */ new Set([
23
- "low",
24
- "medium",
25
- "high",
26
- "urgent"
27
- ]), C = /* @__PURE__ */ new Set([
28
- "path",
29
- "line",
30
- "rectangle",
31
- "circle",
32
- "text"
33
- ]);
34
- function w(e, t) {
35
- return a(e, t);
36
- }
37
- function T(e) {
38
- return w(e, c);
39
- }
40
- function E(e) {
41
- if (!w(e, d)) return !1;
42
- let t = e.trim(), n = t.indexOf("@");
43
- return n > 0 && n === t.lastIndexOf("@") && n < t.length - 1 && !/\s/.test(t);
44
- }
45
- function D(e) {
46
- return i(e) && T(e.id) && w(e.name, u) && E(e.email) && n(e.avatar, f) && n(e.organizationId, c);
47
- }
48
- function O(e) {
49
- return {
50
- id: e.id.trim(),
51
- name: e.name.trim(),
52
- email: e.email.trim(),
53
- ...e.avatar ? { avatar: e.avatar.trim() } : {},
54
- ...e.organizationId ? { organizationId: e.organizationId.trim() } : {}
55
- };
56
- }
57
- function k(e) {
58
- if (!Array.isArray(e)) return null;
59
- let t = [], n = /* @__PURE__ */ new Set();
60
- for (let r of e) {
61
- if (t.length >= m) break;
62
- if (!D(r)) continue;
63
- let e = O(r);
64
- n.has(e.id) || (n.add(e.id), t.push(e));
65
- }
66
- return t;
67
- }
68
- function A(e) {
69
- return i(e) ? t(e.x) && t(e.y) : !1;
70
- }
71
- function j(e) {
72
- return i(e) && w(e.url, f) && w(e.path, f) && w(e.title, f);
73
- }
74
- function M(e) {
75
- return i(e) && z(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= h && typeof e.reacted == "boolean";
76
- }
77
- function N(e, t) {
78
- if (Array.isArray(e)) return e.filter(M).map((e) => {
79
- if (!Array.isArray(e.userIds)) return e;
80
- let n = e.userIds.filter(T);
81
- return {
82
- ...e,
83
- userIds: n,
84
- reacted: !!t && n.includes(t)
85
- };
86
- });
87
- }
88
- function P(e, t) {
89
- return {
90
- ...e,
91
- replies: Array.isArray(e.replies) ? e.replies.flatMap((e) => {
92
- let n = I(e, t);
93
- return n ? [n] : [];
94
- }) : [],
95
- ...e.reactions === void 0 ? {} : { reactions: N(e.reactions, t) }
96
- };
97
- }
98
- function F(e, t) {
99
- return !i(e) || !T(e.id) || !b.has(e.type) || !w(e.content, l) || !A(e.position) || !x.has(e.status) || !S.has(e.priority) || !D(e.author) || !T(e.userId) || !w(e.createdAt, f) || !w(e.updatedAt, f) || !j(e.page) || !Array.isArray(e.replies) || !Array.isArray(e.attachments) ? null : P(structuredClone(e), t);
100
- }
101
- function I(e, t) {
102
- if (!i(e) || !T(e.id) || !w(e.content, l) || !D(e.author) || !w(e.createdAt, f)) return null;
103
- let n = structuredClone(e);
104
- return n.reactions &&= N(n.reactions, t), n;
105
- }
106
- function L(e) {
107
- return !i(e) || !D(e.user) || !r(e.x) || e.x < 0 || e.x > 100 || !r(e.y) || e.y < 0 || e.y > 100 || !w(e.page, f) ? null : {
108
- x: e.x,
109
- y: e.y,
110
- page: e.page.trim(),
111
- user: O(e.user)
112
- };
113
- }
114
- function R(e) {
115
- return i(e) ? w(e.type, o.DRAWING_TYPE) && C.has(e.type) && w(e.stroke, o.COLOR) && r(e.strokeWidth) && e.strokeWidth >= 0 && w(e.fill, o.COLOR) && n(e.d, o.DRAWING_PATH_DATA) && n(e.text, o.DRAWING_TEXT) && (e.x === void 0 || r(e.x)) && (e.y === void 0 || r(e.y)) && (e.width === void 0 || r(e.width)) && (e.height === void 0 || r(e.height)) : !1;
116
- }
117
- function z(e) {
118
- return w(e, p);
119
- }
120
- function B(e) {
121
- try {
122
- e();
123
- } catch {}
124
- }
125
- function V(e, t) {
126
- return e.wsManager === t;
127
- }
128
- function H(e, t) {
129
- e.setState({ comments: e.getState().comments.map((e) => e.id === t.id ? t : e) });
130
- }
131
- function U(t, n) {
132
- if (t.config.features?.realtime === !1 || !t.config.reverb?.host || !t.config.reverb?.key) return;
133
- if (n.wsManager) {
134
- for (let e of n.wsUnsubscribers) B(e);
135
- n.wsUnsubscribers = [], W(n);
136
- try {
137
- n.wsManager.destroy();
138
- } catch {}
139
- n.wsManager = null;
140
- }
141
- let r = t.config.baseUrl || "https://api.commentkit.dev/api", a = t.getState().currentUser, o = y(t);
142
- try {
143
- n.wsManager = new e({
144
- key: t.config.reverb.key,
145
- wsHost: t.config.reverb.host,
146
- wsPort: t.config.reverb.port ?? 443,
147
- forceTLS: (t.config.reverb.scheme ?? "wss") === "wss",
148
- /* v8 ignore next -- projectId always provided in config */
149
- projectId: t.config.projectId || "",
150
- apiKey: t.config.apiKey,
151
- authEndpoint: `${r}/broadcasting/auth`,
152
- userEmail: a?.email,
153
- userInfo: a ? {
154
- id: a.id,
155
- name: a.name,
156
- email: a.email
157
- } : void 0
158
- });
159
- } catch (e) {
160
- t.setState({ connectionStatus: "error" }), t.handleError(e);
161
- return;
162
- }
163
- let c = n.wsUnsubscribers, l = n.wsManager;
164
- c.push(l.on("connected", () => {
165
- V(n, l) && (t.setState({ connectionStatus: "connected" }), n.wsManager?.requestPresence());
166
- })), c.push(l.on("disconnected", () => {
167
- V(n, l) && t.setState({ connectionStatus: "disconnected" });
168
- })), c.push(l.on("reconnecting", () => {
169
- V(n, l) && t.setState({ connectionStatus: "connecting" });
170
- })), c.push(l.on("error", () => {
171
- V(n, l) && t.setState({ connectionStatus: "error" });
172
- })), c.push(l.on("comment:resolved", (e) => {
173
- if (!V(n, l)) return;
174
- let r = F(e, t.getState().currentUser?.id);
175
- r && (H(t, r), t.emit("comment:resolved", r));
176
- })), c.push(l.on("comment:completed", (e) => {
177
- if (!V(n, l)) return;
178
- let r = F(e, t.getState().currentUser?.id);
179
- r && (H(t, r), t.emit("comment:completed", r));
180
- })), c.push(l.on("comment:created", (e) => {
181
- if (!V(n, l)) return;
182
- let r = F(e, t.getState().currentUser?.id);
183
- if (!r) return;
184
- let i = t.getState().activeBranch;
185
- i && r.branch !== i || t.getState().comments.find((e) => e.id === r.id) || (t.setState({ comments: [...t.getState().comments, r] }), t.emit("comment:created", r));
186
- })), c.push(l.on("comment:updated", (e) => {
187
- if (!V(n, l)) return;
188
- let r = F(e, t.getState().currentUser?.id);
189
- r && (H(t, r), t.emit("comment:updated", r));
190
- })), c.push(l.on("comment:deleted", (e) => {
191
- if (!V(n, l) || !i(e) || !T(e.id)) return;
192
- let r = e.id.trim();
193
- t.setState({
194
- comments: t.getState().comments.filter((e) => e.id !== r),
195
- selectedComment: t.getState().selectedComment?.id === r ? null : t.getState().selectedComment
196
- }), t.emit("comment:deleted", { id: r });
197
- })), c.push(l.on("reply:added", (e) => {
198
- if (!V(n, l) || !i(e) || !T(e.commentId)) return;
199
- let r = I(e.reply, t.getState().currentUser?.id);
200
- if (!r) return;
201
- let a = e.commentId.trim(), o = t.getState().comments.map((e) => e.id !== a || e.replies.some((e) => e.id === r.id) ? e : {
202
- ...e,
203
- status: "open",
204
- resolvedAt: void 0,
205
- completedAt: void 0,
206
- replies: [...e.replies, r]
207
- });
208
- t.setState({ comments: o });
209
- let s = o.find((e) => e.id === a);
210
- s && t.emit("comment:updated", s);
211
- }));
212
- let u = (e, t, n) => {
213
- let r = (e ?? []).filter((e) => z(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= h), i = r.findIndex((e) => e.emoji === t);
214
- if (i !== -1) {
215
- let e = r[i];
216
- r[i] = n ? {
217
- ...e,
218
- reacted: !0
219
- } : {
220
- ...e,
221
- count: Math.min(e.count + 1, h),
222
- reacted: e.reacted
223
- };
224
- } else r.push({
225
- emoji: t,
226
- count: 1,
227
- reacted: n
228
- });
229
- return r;
230
- }, d = (e, t, n) => (e ?? []).filter((e) => z(e.emoji) && Number.isInteger(e.count) && e.count > 0 && e.count <= h).map((e) => e.emoji === t ? {
231
- ...e,
232
- count: n ? e.count : e.count - 1,
233
- reacted: !n && e.reacted
234
- } : e).filter((e) => e.count > 0), f = (e, r) => {
235
- if (!V(n, l) || !i(e) || !T(e.commentId) || !z(e.emoji) || !T(e.userId)) return;
236
- let a = e.commentId.trim(), o = T(e.replyId) ? e.replyId.trim() : null, s = e.emoji.trim(), c = e.userId.trim() === t.getState().currentUser?.id;
237
- t.setState({ comments: t.getState().comments.map((e) => e.id === a ? o === null ? {
238
- ...e,
239
- reactions: r(e.reactions, s, c)
240
- } : {
241
- ...e,
242
- replies: e.replies.map((e) => e.id === o ? {
243
- ...e,
244
- reactions: r(e.reactions, s, c)
245
- } : e)
246
- } : e) });
247
- };
248
- c.push(l.on("reaction:added", (e) => f(e, u))), c.push(l.on("reaction:removed", (e) => f(e, d)));
249
- let p = /* @__PURE__ */ new Map(), m = 0, b = 0;
250
- c.push(l.on("cursor:move", (e) => {
251
- if (!V(n, l) || !o.cursors) return;
252
- let r = L(e);
253
- if (!r) return;
254
- let i = Date.now(), a = r.user.id, s = p.get(a);
255
- if (s === void 0 && p.size >= o.maxRenderedCursors) {
256
- let e, t = Infinity;
257
- for (let [n, r] of p) r < t && (t = r, e = n);
258
- if (e !== void 0 && i - t >= g) p.delete(e);
259
- else return;
260
- }
261
- s !== void 0 && i - s < g || (i - m >= _ && (m = i, b = 0), !(b >= v) && (b++, p.set(a, i), t.emit("cursor:move", r)));
262
- })), c.push(l.on("cursor:leave", (e) => {
263
- V(n, l) && i(e) && T(e.userId) && (p.delete(e.userId.trim()), t.emit("cursor:leave", { userId: e.userId.trim() }));
264
- })), c.push(l.on("user:joined", (e) => {
265
- V(n, l) && D(e) && t.emit("user:joined", O(e));
266
- })), c.push(l.on("user:left", (e) => {
267
- V(n, l) && i(e) && T(e.userId) && t.emit("user:left", { userId: e.userId.trim() });
268
- })), c.push(l.on("presence:update", (e) => {
269
- if (!V(n, l) || !o.presence || !i(e)) return;
270
- let r = k(e.users);
271
- if (!r) return;
272
- let a = { users: r };
273
- t.setState({ onlineUsers: r }), t.emit("presence:update", a);
274
- })), c.push(l.on("drawing:stroke", (e) => {
275
- V(n, l) && i(e) && T(e.userId) && R(e.path) && t.emit("drawing:stroke", {
276
- userId: e.userId.trim(),
277
- path: structuredClone(e.path)
278
- });
279
- }));
280
- try {
281
- t.setState({ connectionStatus: "connecting" });
282
- let e = l.connect();
283
- e && typeof e.catch == "function" && e.catch((e) => {
284
- t.setState({ connectionStatus: "error" }), t.handleError(e);
285
- });
286
- } catch (e) {
287
- t.setState({ connectionStatus: "error" }), t.handleError(e);
288
- return;
289
- }
290
- /* v8 ignore next -- SSR guard unreachable in jsdom */
291
- typeof document < "u" && typeof window < "u" && o.cursors && (n.mouseMoveHandler = (e) => {
292
- if (t.getState().isOverlayVisible && n.wsManager?.isConnected()) {
293
- if (window.innerWidth <= 0 || window.innerHeight <= 0) return;
294
- let t = Math.max(0, Math.min(100, e.clientX / window.innerWidth * 100)), r = Math.max(0, Math.min(100, e.clientY / window.innerHeight * 100));
295
- n.wsManager.sendCursorMove(t, r, s().url);
296
- }
297
- }, document.addEventListener("mousemove", n.mouseMoveHandler));
298
- }
299
- function W(e) {
300
- typeof window < "u" && typeof document < "u" && e.mouseMoveHandler && (document.removeEventListener("mousemove", e.mouseMoveHandler), e.mouseMoveHandler = null);
301
- }
302
- export { U as initializeWebSocket, W as removeMouseMoveListener };