@commentkit/comment-kit 0.7.0 → 0.7.2

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 (56) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +10 -6
  3. package/SECURITY.md +14 -6
  4. package/dist/angular.es.js +2 -2
  5. package/dist/comment-kit.es.js +5 -5
  6. package/dist/demo.es.js +36 -34
  7. package/dist/headless.es.js +3 -3
  8. package/dist/preact.es.js +2 -2
  9. package/dist/qwik.qwik.mjs +2 -2
  10. package/dist/react.es.js +2 -2
  11. package/dist/shared/{ShadowRootContext-Bv-4aElu.js → ShadowRootContext-CjciYxVN.js} +4 -4
  12. package/dist/shared/annotation-toolbar-CZI1KVdW.js +1094 -0
  13. package/dist/shared/attachment-refresh-mQw-L7hB.js +94 -0
  14. package/dist/shared/{button-group-Cl9CrvvU.js → button-group-C285iSkZ.js} +14 -16
  15. package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
  16. package/dist/shared/capture-privacy-DUROnio5.js +77 -0
  17. package/dist/shared/{comment-drawing-canvas-Dzb5YoFw.js → comment-drawing-canvas-CYFFKgCm.js} +2 -2
  18. package/dist/shared/{comment-utils-BycYTSxA.js → comment-icon-4SQd3nlz.js} +30 -24
  19. package/dist/shared/comment-image-lightbox-DmTNxuqX.js +190 -0
  20. package/dist/shared/comment-images-content-BX4DQ9Ol.js +214 -0
  21. package/dist/shared/{comment-kit-core-BaSuMzp9.js → comment-kit-core-VuIidMeu.js} +1096 -793
  22. package/dist/shared/{comment-kit-ui-CzfdAZs2.js → comment-kit-ui-BjJ1ZLiv.js} +6091 -6486
  23. package/dist/shared/{comment-screenshot-annotator-C7X-_bm6.js → comment-screenshot-annotator-CMOG1md7.js} +5 -5
  24. package/dist/shared/{comment-screenshot-overlay-wIrZrcRy.js → comment-screenshot-overlay-iWW-V-Iw.js} +114 -118
  25. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +153 -0
  26. package/dist/shared/{dev-export-panel-FwFVdady.js → dev-export-panel-CrRENbMn.js} +9 -10
  27. package/dist/shared/dev-grab-Ca4MlS2Y.js +196 -0
  28. package/dist/shared/{element-selector-BhJm-NSs.js → element-selector-g1bTvdEA.js} +450 -408
  29. package/dist/shared/{mount-ui--ijs8pWT.js → mount-ui-Dz5QLq4W.js} +121 -106
  30. package/dist/shared/{pusher-ipHMJnO_.js → pusher-ue0D83de.js} +1 -1
  31. package/dist/shared/realtime-CieWAnsW.js +321 -0
  32. package/dist/shared/realtime-recovery-BSVMwsXJ.js +135 -0
  33. package/dist/shared/request-activity-DQrAUwfA.js +11 -0
  34. package/dist/shared/{separator-XDBsaWyw.js → separator-aphZiRoJ.js} +1 -1
  35. package/dist/shared/{shadow-root-C5v-T8lQ.js → shadow-root-Cv1aLuFf.js} +31 -31
  36. package/dist/shared/{styles-D3yMtaec.js → styles-CnYsLS2f.js} +1 -1
  37. package/dist/shared/text-B4HHZNaa.js +23 -0
  38. package/dist/shared/token-session-CPQpt3-u.js +25 -0
  39. package/dist/shared/useRender-D1z_X_BY.js +5 -0
  40. package/dist/shared/{validation-C7QG8j7Z.js → validation-3wbbbuX0.js} +26 -1
  41. package/dist/shared/websocket-manager-BnK55c3U.js +381 -0
  42. package/dist/solid.es.js +2 -2
  43. package/dist/svelte.es.js +2 -2
  44. package/dist/types/core/api-client.d.ts +11 -2
  45. package/dist/types/core/comment-kit-core.d.ts +11 -5
  46. package/dist/types/core/types.d.ts +54 -2
  47. package/dist/types/core/websocket-manager.d.ts +13 -0
  48. package/dist/types/core/write-access.d.ts +9 -0
  49. package/dist/vue.es.js +2 -2
  50. package/docs/api-reference.md +25 -4
  51. package/package.json +3 -2
  52. package/dist/shared/annotation-toolbar-B9SxYqoF.js +0 -1093
  53. package/dist/shared/comment-image-lightbox-BPYJT1sB.js +0 -183
  54. package/dist/shared/dev-grab-DDqg0LQf.js +0 -203
  55. package/dist/shared/realtime-Dk41VwKg.js +0 -302
  56. package/dist/shared/websocket-manager-DhLWh3Jr.js +0 -302
@@ -1,302 +0,0 @@
1
- import { c as e, i as t, l as n, o as r, s as i, u as a } from "./validation-C7QG8j7Z.js";
2
- import { i as o } from "./comment-kit-core-BaSuMzp9.js";
3
- var s = Object.create, c = Object.defineProperty, l = Object.getOwnPropertyDescriptor, u = Object.getOwnPropertyNames, d = Object.getPrototypeOf, f = Object.prototype.hasOwnProperty, p = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), m = (e, t) => {
4
- let n = {};
5
- for (var r in e) c(n, r, {
6
- get: e[r],
7
- enumerable: !0
8
- });
9
- return t || c(n, Symbol.toStringTag, { value: "Module" }), n;
10
- }, h = (e, t, n, r) => {
11
- if (t && typeof t == "object" || typeof t == "function") for (var i = u(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !f.call(e, s) && s !== n && c(e, s, {
12
- get: ((e) => t[e]).bind(null, s),
13
- enumerable: !(r = l(t, s)) || r.enumerable
14
- });
15
- return e;
16
- }, g = (e, t, n) => (n = e == null ? {} : s(d(e)), h(t || !e || !e.__esModule || !f.call(e, "default") ? c(n, "default", {
17
- value: e,
18
- enumerable: !0
19
- }) : n, e)), _ = null;
20
- function v() {
21
- return _ ||= import("./pusher-ipHMJnO_.js").then((e) => /* @__PURE__ */ g(e.default, 1)).then((e) => e.default ?? e), _;
22
- }
23
- var y = o.ID, b = o.NAME, x = o.EMAIL, S = o.PAGE, C = o.COLOR, w = o.DRAWING_PATH_DATA, T = o.DRAWING_TEXT, E = o.ONLINE_USERS, D = {
24
- id: "unknown",
25
- name: "Unknown",
26
- email: "unknown@example.invalid"
27
- }, O = /* @__PURE__ */ new Set([
28
- "client-cursor_move",
29
- "client-cursor_leave",
30
- "client-drawing_stroke"
31
- ]), k = /* @__PURE__ */ new Set([
32
- "path",
33
- "line",
34
- "rectangle",
35
- "circle",
36
- "text"
37
- ]);
38
- function A(e) {
39
- return n(e, y);
40
- }
41
- function j(t) {
42
- return r(t) ? A(t.id) && n(t.name, b) && a(t.email) && e(t.avatar, S) : !1;
43
- }
44
- function M(e) {
45
- return r(e) ? A(e.id) && i(e.content, o.CONTENT) && A(e.userId) && r(e.position) && t(e.position.x) && t(e.position.y) && j(e.author) : !1;
46
- }
47
- function N(e) {
48
- return r(e) ? A(e.id) && i(e.content, o.CONTENT) && j(e.author) : !1;
49
- }
50
- function P(e) {
51
- return r(e) ? t(e.x) && e.x >= 0 && e.x <= 100 && t(e.y) && e.y >= 0 && e.y <= 100 && n(e.page, S) : !1;
52
- }
53
- function F(i) {
54
- return !r(i) || !n(i.type, 20) || !k.has(i.type) || !n(i.stroke, C) || !t(i.strokeWidth) || i.strokeWidth <= 0 || i.strokeWidth > 100 || !n(i.fill, C) ? !1 : e(i.d, w) && e(i.text, T) && (i.x === void 0 || t(i.x)) && (i.y === void 0 || t(i.y)) && (i.width === void 0 || t(i.width)) && (i.height === void 0 || t(i.height));
55
- }
56
- function I(e) {
57
- return {
58
- id: e.id.slice(0, y),
59
- name: e.name.slice(0, b),
60
- email: e.email.slice(0, x),
61
- ...e.avatar ? { avatar: e.avatar.slice(0, S) } : {},
62
- ...e.organizationId ? { organizationId: e.organizationId.slice(0, y) } : {}
63
- };
64
- }
65
- function L(e) {
66
- return n(e, S) ? e : "";
67
- }
68
- function R(e) {
69
- let t = e.toLowerCase().replace(/^\[|\]$/g, "");
70
- return t === "localhost" || t === "127.0.0.1" || t === "::1";
71
- }
72
- function z(e) {
73
- return n(e, 253) && (e === "localhost" || /^[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?$/.test(e));
74
- }
75
- function B() {
76
- return { ...D };
77
- }
78
- function V(e) {
79
- let t = String(e.projectId).trim();
80
- if (!A(t) || !/^[\w.-]+$/.test(t)) throw Error("Invalid WebSocket projectId");
81
- let r;
82
- try {
83
- r = new URL(e.authEndpoint);
84
- } catch {
85
- throw Error("Invalid WebSocket auth endpoint");
86
- }
87
- if (r.protocol !== "https:" && !(r.protocol === "http:" && R(r.hostname))) throw Error("Invalid WebSocket auth endpoint");
88
- if (!n(e.key, 256)) throw Error("Invalid WebSocket key");
89
- if (!z(e.wsHost)) throw Error("Invalid WebSocket host");
90
- if (!n(e.apiKey, 512)) throw Error("Invalid WebSocket API key");
91
- if (e.userEmail && !a(e.userEmail)) throw Error("Invalid WebSocket user email");
92
- if (e.userInfo && !j(e.userInfo)) throw Error("Invalid WebSocket user info");
93
- return {
94
- ...e,
95
- projectId: t,
96
- authEndpoint: r.toString(),
97
- userInfo: e.userInfo ? I(e.userInfo) : void 0
98
- };
99
- }
100
- var H = class e {
101
- static {
102
- this.MAX_LISTENERS_PER_EVENT = 100;
103
- }
104
- constructor(e) {
105
- this.listeners = /* @__PURE__ */ new Map(), this.pusher = null, this.presenceChannel = null, this.onlineUsers = /* @__PURE__ */ new Map(), this.lastCursorUpdate = 0, this.cursorThrottle = 50, this.reconnectAttempts = 0, this.connecting = null, this.destroyed = !1, this.config = V(e);
106
- }
107
- on(t, n) {
108
- let r = this.listeners.get(t);
109
- return r || (r = /* @__PURE__ */ new Set(), this.listeners.set(t, r)), r.size >= e.MAX_LISTENERS_PER_EVENT && console.warn(`[CommentKit WS] Max listeners (${e.MAX_LISTENERS_PER_EVENT}) reached for '${t}' — possible memory leak`), r.add(n), () => {
110
- let e = this.listeners.get(t);
111
- e?.delete(n), e?.size === 0 && this.listeners.delete(t);
112
- };
113
- }
114
- emit(e, t) {
115
- let n = this.listeners.get(e);
116
- if (n) for (let r of Array.from(n)) try {
117
- r(t);
118
- } catch (t) {
119
- console.error(`[CommentKit WS] Error in '${e}' listener:`, t);
120
- }
121
- }
122
- async connect() {
123
- if (!(this.pusher || this.destroyed)) return this.connecting ||= this.openConnection().finally(() => {
124
- this.connecting = null;
125
- }), this.connecting;
126
- }
127
- async openConnection() {
128
- if (this.pusher || this.destroyed) return;
129
- let e = await v();
130
- if (this.destroyed) return;
131
- let t = { "X-API-Key": this.config.apiKey };
132
- this.config.userEmail && (t["X-User-Email"] = this.config.userEmail), this.pusher = new e(this.config.key, {
133
- cluster: "",
134
- wsHost: this.config.wsHost,
135
- wsPort: this.config.wsPort ?? 443,
136
- wssPort: this.config.wsPort ?? 443,
137
- forceTLS: this.config.forceTLS ?? !0,
138
- enabledTransports: this.config.forceTLS === !1 ? ["ws", "wss"] : ["wss"],
139
- disableStats: !0,
140
- channelAuthorization: {
141
- transport: "ajax",
142
- endpoint: this.config.authEndpoint,
143
- headers: t,
144
- params: this.config.userInfo ? {
145
- user_id: this.config.userInfo.id,
146
- user_name: this.config.userInfo.name,
147
- user_email: this.config.userInfo.email
148
- } : {}
149
- }
150
- }), this.pusher.connection.bind("connected", () => {
151
- this.reconnectAttempts = 0, this.emit("connected", void 0);
152
- }), this.pusher.connection.bind("disconnected", () => {
153
- this.emit("disconnected", {
154
- code: 1e3,
155
- reason: "Disconnected"
156
- });
157
- }), this.pusher.connection.bind("connecting", () => {
158
- this.reconnectAttempts > 0 && this.emit("reconnecting", {
159
- attempt: this.reconnectAttempts,
160
- maxAttempts: 5
161
- });
162
- }), this.pusher.connection.bind("unavailable", () => {
163
- this.reconnectAttempts++, this.emit("error", /* @__PURE__ */ Error("WebSocket connection unavailable"));
164
- }), this.pusher.connection.bind("failed", () => {
165
- this.emit("error", /* @__PURE__ */ Error("WebSocket connection failed"));
166
- }), this.subscribeToChannel();
167
- }
168
- reconnect() {
169
- this.destroyed || (this.pusher ? this.pusher.connect() : this.connect());
170
- }
171
- disconnect() {
172
- this.presenceChannel &&= (this.pusher?.unsubscribe(`presence-project.${this.config.projectId}`), null), this.pusher &&= (this.pusher.disconnect(), null), this.onlineUsers.clear();
173
- }
174
- isConnected() {
175
- return this.pusher?.connection.state === "connected";
176
- }
177
- getOnlineUsers() {
178
- return Array.from(this.onlineUsers.values());
179
- }
180
- subscribeToChannel() {
181
- if (!this.pusher) return;
182
- let e = `presence-project.${this.config.projectId}`;
183
- this.presenceChannel = this.pusher.subscribe(e), this.presenceChannel.bind("pusher:subscription_succeeded", (e) => {
184
- this.onlineUsers.clear(), e.each((e) => {
185
- if (this.onlineUsers.size >= E) return;
186
- let t = this.memberToUser(e);
187
- t && this.onlineUsers.set(t.id, t);
188
- }), this.emit("presence:update", { users: this.getOnlineUsers() });
189
- }), this.presenceChannel.bind("pusher:member_added", (e) => {
190
- let t = this.memberToUser(e);
191
- if (t) {
192
- if (!this.onlineUsers.has(t.id) && this.onlineUsers.size >= E) return;
193
- this.onlineUsers.set(t.id, t), this.emit("user:joined", t), this.emit("presence:update", { users: this.getOnlineUsers() });
194
- }
195
- }), this.presenceChannel.bind("pusher:member_removed", (e) => {
196
- if (!A(e.id)) return;
197
- let t = e.id;
198
- this.onlineUsers.delete(t), this.emit("user:left", { userId: t }), this.emit("presence:update", { users: this.getOnlineUsers() });
199
- }), this.presenceChannel.bind("pusher:subscription_error", (e) => {
200
- console.error("[CommentKit WS] Channel subscription error:", e);
201
- let t = n(e.type, 80) ? e.type : "unknown";
202
- this.emit("error", /* @__PURE__ */ Error(`Channel subscription failed: ${t}`));
203
- });
204
- let t = (e, t) => {
205
- this.presenceChannel?.bind(e, t), this.presenceChannel?.bind(`.${e}`, t);
206
- };
207
- t("comment_created", (e) => {
208
- M(e) && this.emit("comment:created", e);
209
- }), t("comment_updated", (e) => {
210
- M(e) && this.emit("comment:updated", e);
211
- }), t("comment_deleted", (e) => {
212
- let t = e;
213
- r(t) && A(t.id) && this.emit("comment:deleted", { id: t.id });
214
- }), t("comment_resolved", (e) => {
215
- M(e) && this.emit("comment:resolved", e);
216
- }), t("comment_completed", (e) => {
217
- M(e) && this.emit("comment:completed", e);
218
- }), t("reply_added", (e) => {
219
- let t = e;
220
- r(t) && A(t.commentId) && N(t.reply) && this.emit("reply:added", {
221
- commentId: t.commentId,
222
- reply: t.reply
223
- });
224
- }), t("reaction_added", (e) => {
225
- let t = e;
226
- r(t) && A(t.commentId) && n(t.emoji, 32) && A(t.userId) && this.emit("reaction:added", {
227
- commentId: t.commentId,
228
- ...A(t.replyId) ? { replyId: t.replyId } : {},
229
- emoji: t.emoji,
230
- userId: t.userId
231
- });
232
- }), t("reaction_removed", (e) => {
233
- let t = e;
234
- r(t) && A(t.commentId) && n(t.emoji, 32) && A(t.userId) && this.emit("reaction:removed", {
235
- commentId: t.commentId,
236
- ...A(t.replyId) ? { replyId: t.replyId } : {},
237
- emoji: t.emoji,
238
- userId: t.userId
239
- });
240
- }), this.presenceChannel.bind("client-cursor_move", (e) => {
241
- if (P(e)) {
242
- let t = e, n = j(t.user) ? t.user : B();
243
- this.emit("cursor:move", {
244
- ...e,
245
- user: n
246
- });
247
- }
248
- }), this.presenceChannel.bind("client-cursor_leave", (e) => {
249
- let t = e;
250
- r(t) && A(t.userId) && this.emit("cursor:leave", { userId: t.userId });
251
- }), this.presenceChannel.bind("client-drawing_stroke", (e) => {
252
- let t = e;
253
- r(t) && A(t.userId) && F(t.path) && this.emit("drawing:stroke", {
254
- userId: t.userId,
255
- path: t.path
256
- });
257
- });
258
- }
259
- memberToUser(e) {
260
- if (!A(e.id)) return null;
261
- let t = e.info;
262
- if (!t) return null;
263
- let n = t.email == null || t.email === "" ? `${String(e.id)}@presence.invalid` : t.email, r = {
264
- id: String(e.id),
265
- name: t.name || "Anonymous",
266
- email: n,
267
- avatar: t.avatar
268
- };
269
- return j(r) ? I(r) : null;
270
- }
271
- sendCursorMove(e, t, n) {
272
- if (!Number.isFinite(e) || !Number.isFinite(t)) return;
273
- let r = L(n);
274
- if (!r) return;
275
- let i = Math.max(0, Math.min(100, e)), a = Math.max(0, Math.min(100, t)), o = Date.now();
276
- o - this.lastCursorUpdate < this.cursorThrottle || (this.lastCursorUpdate = o, this.triggerClientEvent("client-cursor_move", {
277
- x: i,
278
- y: a,
279
- page: r,
280
- user: this.config.userInfo || B()
281
- }));
282
- }
283
- sendCursorLeave() {
284
- this.triggerClientEvent("client-cursor_leave", { userId: this.config.userInfo?.id || "unknown" });
285
- }
286
- sendDrawingStroke(e) {
287
- F(e) && this.triggerClientEvent("client-drawing_stroke", {
288
- userId: this.config.userInfo?.id || "unknown",
289
- path: e
290
- });
291
- }
292
- requestPresence() {}
293
- triggerClientEvent(e, t) {
294
- if (O.has(e) && this.presenceChannel) try {
295
- this.presenceChannel.trigger(e, t);
296
- } catch {}
297
- }
298
- destroy() {
299
- this.destroyed = !0, this.disconnect(), this.listeners.clear();
300
- }
301
- };
302
- export { p as n, m as r, H as t };