@commentkit/comment-kit 0.6.2 → 0.6.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 (107) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +63 -60
  3. package/dist/angular/comment-kit-ui-DlWdgxZJ.js +17929 -0
  4. package/dist/{qwik/dom-BjJ-QroQ.js → angular/dom-Cx1nMbdI.js} +9 -2
  5. package/dist/angular/{mount-ui-CxChSb8B.js → mount-ui-Q_U4OkMo.js} +1 -1
  6. package/dist/angular/{realtime-CfJZMEAi.js → realtime-VrKV0lPI.js} +11 -2
  7. package/dist/angular/styles-CmEq782M.js +2 -0
  8. package/dist/angular.es.js +23 -7
  9. package/dist/comment-kit.es.js +23 -7
  10. package/dist/core/comment-kit-ui-CwoXDJXR.js +17929 -0
  11. package/dist/core/{mount-ui-DrFjMJJu.js → mount-ui-D-pILMLR.js} +1 -1
  12. package/dist/core/{realtime-DYf6E_sN.js → realtime-C3_O7gi2.js} +2 -2
  13. package/dist/core/styles-Dzn_nEz7.js +2 -0
  14. package/dist/core/{websocket-manager-DorGPjR4.js → websocket-manager-D1_TEuy_.js} +9 -0
  15. package/dist/preact/comment-kit-ui-CIeAiL3D.js +17929 -0
  16. package/dist/{angular/dom-ON-u4y6t.js → preact/dom-_ULpq7rg.js} +9 -2
  17. package/dist/preact/{mount-ui-b9JcJQYE.js → mount-ui-8BL4DWNw.js} +1 -1
  18. package/dist/preact/{realtime-BFgP4BlB.js → realtime-COin_nJF.js} +11 -2
  19. package/dist/preact/styles-ECCK6Z_C.js +2 -0
  20. package/dist/preact.es.js +23 -7
  21. package/dist/qwik/comment-kit-ui-CT3GZ8ry.js +17929 -0
  22. package/dist/{solid/dom-Bpw1A0oz.js → qwik/dom-Dm3gzBBJ.js} +9 -2
  23. package/dist/qwik/{mount-ui-CaRrLb9u.js → mount-ui-DQ22eQbu.js} +1 -1
  24. package/dist/qwik/{realtime-DUhkZAVc.js → realtime-DhfcBrwF.js} +11 -2
  25. package/dist/qwik/styles-CMcDFAyE.js +2 -0
  26. package/dist/qwik.es.js +23 -7
  27. package/dist/react/{limits-Dflmuf1P.js → limits-CpprSem3.js} +10 -3
  28. package/dist/react/{realtime-C7h-Agwo.js → realtime-DGqScuox.js} +125 -116
  29. package/dist/react.es.js +12023 -3561
  30. package/dist/solid/comment-kit-ui-BXcJmq6H.js +17929 -0
  31. package/dist/{preact/dom-BAV8grk_.js → solid/dom-DqDH-Gml.js} +9 -2
  32. package/dist/solid/{mount-ui-bPWYgjmm.js → mount-ui-DmrWIA8O.js} +1 -1
  33. package/dist/solid/{realtime-DK86zDCJ.js → realtime-DbUJK4gU.js} +11 -2
  34. package/dist/solid/styles-Be_8-1ZV.js +2 -0
  35. package/dist/solid.es.js +23 -7
  36. package/dist/svelte/comment-kit-ui-C-8rQmBN.js +17929 -0
  37. package/dist/svelte/dom-MyTrWzy_.js +104 -0
  38. package/dist/svelte/{mount-ui-DtXWMEYn.js → mount-ui-CDgJuoAF.js} +1 -1
  39. package/dist/svelte/{realtime-zYOctwRk.js → realtime-M1CJbCBA.js} +11 -2
  40. package/dist/svelte/styles-B863Tn5m.js +2 -0
  41. package/dist/svelte.es.js +23 -7
  42. package/dist/types/core/comment-kit-core.d.ts +12 -0
  43. package/dist/types/core/websocket-manager.d.ts +5 -0
  44. package/dist/types/react/comments/comment-flow.d.ts +8 -0
  45. package/dist/types/react/comments/outcomes.d.ts +22 -0
  46. package/dist/types/react/comments/pin-geometry.d.ts +12 -0
  47. package/dist/types/react/comments/view-model.d.ts +59 -0
  48. package/dist/types/react/components/comment-actions.d.ts +20 -0
  49. package/dist/types/react/components/comment-body.d.ts +8 -0
  50. package/dist/types/react/components/comment-composer-actions.d.ts +26 -0
  51. package/dist/types/react/components/comment-composer-extras-fields.d.ts +35 -0
  52. package/dist/types/react/components/comment-composer-extras-toolbar.d.ts +28 -0
  53. package/dist/types/react/components/comment-composer-extras.d.ts +10 -0
  54. package/dist/types/react/components/comment-composer-hook.d.ts +53 -0
  55. package/dist/types/react/components/comment-composer-media.d.ts +30 -0
  56. package/dist/types/react/components/comment-composer.d.ts +4 -0
  57. package/dist/types/react/components/comment-connection-alert.d.ts +7 -0
  58. package/dist/types/react/components/comment-custom-cursor.d.ts +14 -0
  59. package/dist/types/react/components/comment-emoji-picker.d.ts +12 -0
  60. package/dist/types/react/components/comment-error-banner.d.ts +8 -0
  61. package/dist/types/react/components/comment-format-toolbar.d.ts +6 -0
  62. package/dist/types/react/components/comment-header.d.ts +41 -0
  63. package/dist/types/react/components/comment-image-lightbox.d.ts +18 -0
  64. package/dist/types/react/components/comment-images.d.ts +15 -0
  65. package/dist/types/react/components/comment-item.d.ts +25 -0
  66. package/dist/types/react/components/comment-login-modal.d.ts +20 -0
  67. package/dist/types/react/components/comment-marker-layer-composer.d.ts +21 -0
  68. package/dist/types/react/components/comment-marker-layer.d.ts +26 -0
  69. package/dist/types/react/components/comment-marker-popover.d.ts +12 -0
  70. package/dist/types/react/components/comment-marker.d.ts +14 -0
  71. package/dist/types/react/components/comment-page-ref.d.ts +9 -0
  72. package/dist/types/react/components/comment-panel.d.ts +17 -0
  73. package/dist/types/react/components/comment-quoted-text.d.ts +9 -0
  74. package/dist/types/react/components/comment-reactions.d.ts +11 -0
  75. package/dist/types/react/components/comment-thread-detail-badges.d.ts +16 -0
  76. package/dist/types/react/components/comment-thread-detail-meta.d.ts +8 -0
  77. package/dist/types/react/components/comment-thread-detail-replies.d.ts +13 -0
  78. package/dist/types/react/components/comment-thread-detail.d.ts +10 -0
  79. package/dist/types/react/components/comment-thread-footer.d.ts +12 -0
  80. package/dist/types/react/components/comment-thread-list-item.d.ts +14 -0
  81. package/dist/types/react/components/comment-thread-list.d.ts +8 -0
  82. package/dist/types/react/components/comment-user-avatar-tooltip.d.ts +12 -0
  83. package/dist/types/react/ui/primitives/alert/alert.d.ts +8 -0
  84. package/dist/types/react/ui/primitives/alert/index.d.ts +1 -0
  85. package/dist/vue/comment-kit-ui-Cq30Cmvs.js +17929 -0
  86. package/dist/vue/dom-C7krZAR8.js +104 -0
  87. package/dist/vue/{mount-ui-DdTYzv6J.js → mount-ui-Dqz0_jd_.js} +1 -1
  88. package/dist/vue/{realtime-YJKvS2eB.js → realtime-B0B5cE-E.js} +11 -2
  89. package/dist/vue/styles-C4t8gcea.js +2 -0
  90. package/dist/vue.es.js +23 -7
  91. package/package.json +3 -6
  92. package/dist/angular/comment-kit-ui-wEJfMh4T.js +0 -9483
  93. package/dist/angular/styles-CvndAWRF.js +0 -2
  94. package/dist/core/comment-kit-ui-DjWARy4X.js +0 -9483
  95. package/dist/core/styles-D19zARBi.js +0 -2
  96. package/dist/preact/comment-kit-ui-BKi15Z4Q.js +0 -9483
  97. package/dist/preact/styles-Dwd4AJR8.js +0 -2
  98. package/dist/qwik/comment-kit-ui-CRmJhZlX.js +0 -9483
  99. package/dist/qwik/styles-BB1B91hh.js +0 -2
  100. package/dist/solid/comment-kit-ui-Dw_67h_e.js +0 -9483
  101. package/dist/solid/styles-CtYBghRP.js +0 -2
  102. package/dist/svelte/comment-kit-ui-DhCWlEd8.js +0 -9483
  103. package/dist/svelte/dom-mfioQqLy.js +0 -97
  104. package/dist/svelte/styles-DKCGeARl.js +0 -2
  105. package/dist/vue/comment-kit-ui-BX1wDZ2c.js +0 -9483
  106. package/dist/vue/dom-eo0P9Z6Z.js +0 -97
  107. package/dist/vue/styles-BrHt1-ia.js +0 -2
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import { n as e } from "./chunk--MHYZ-zp.js";
3
- import { a as t, d as n, f as r, g as i, h as a, m as o, p as s, t as c, u as l } from "./limits-Dflmuf1P.js";
3
+ import { _ as t, a as n, d as r, f as i, g as a, h as o, m as s, p as c, t as l } from "./limits-CpprSem3.js";
4
4
  var u = null;
5
5
  function d() {
6
6
  return u ||= import("./pusher-3dki8s2l.js").then((t) => /* @__PURE__ */ e(t.default, 1)).then((e) => e.default ?? e), u;
7
7
  }
8
- var f = c.ID, p = c.NAME, m = c.EMAIL, h = c.PAGE, g = c.COLOR, ee = c.DRAWING_PATH_DATA, te = c.DRAWING_TEXT, _ = c.ONLINE_USERS, v = {
8
+ var f = l.ID, p = l.NAME, m = l.EMAIL, h = l.PAGE, g = l.COLOR, ee = l.DRAWING_PATH_DATA, te = l.DRAWING_TEXT, _ = l.ONLINE_USERS, v = {
9
9
  id: "unknown",
10
10
  name: "Unknown",
11
11
  email: "unknown@example.invalid"
@@ -24,19 +24,19 @@ function b(e) {
24
24
  return a(e, f);
25
25
  }
26
26
  function x(e) {
27
- return r(e) ? b(e.id) && a(e.name, p) && i(e.email) && o(e.avatar, h) : !1;
27
+ return c(e) ? b(e.id) && a(e.name, p) && t(e.email) && o(e.avatar, h) : !1;
28
28
  }
29
29
  function S(e) {
30
- return r(e) ? b(e.id) && s(e.content, c.CONTENT) && b(e.userId) && r(e.position) && l(e.position.x) && l(e.position.y) && x(e.author) : !1;
30
+ return c(e) ? b(e.id) && s(e.content, l.CONTENT) && b(e.userId) && c(e.position) && r(e.position.x) && r(e.position.y) && x(e.author) : !1;
31
31
  }
32
32
  function C(e) {
33
- return r(e) ? b(e.id) && s(e.content, c.CONTENT) && x(e.author) : !1;
33
+ return c(e) ? b(e.id) && s(e.content, l.CONTENT) && x(e.author) : !1;
34
34
  }
35
35
  function re(e) {
36
- return r(e) ? l(e.x) && e.x >= 0 && e.x <= 100 && l(e.y) && e.y >= 0 && e.y <= 100 && a(e.page, h) : !1;
36
+ return c(e) ? r(e.x) && e.x >= 0 && e.x <= 100 && r(e.y) && e.y >= 0 && e.y <= 100 && a(e.page, h) : !1;
37
37
  }
38
38
  function w(e) {
39
- return !r(e) || !a(e.type, 20) || !ne.has(e.type) || !a(e.stroke, g) || !l(e.strokeWidth) || e.strokeWidth <= 0 || e.strokeWidth > 100 || !a(e.fill, g) ? !1 : o(e.d, ee) && o(e.text, te) && (e.x === void 0 || l(e.x)) && (e.y === void 0 || l(e.y)) && (e.width === void 0 || l(e.width)) && (e.height === void 0 || l(e.height));
39
+ return !c(e) || !a(e.type, 20) || !ne.has(e.type) || !a(e.stroke, g) || !r(e.strokeWidth) || e.strokeWidth <= 0 || e.strokeWidth > 100 || !a(e.fill, g) ? !1 : o(e.d, ee) && o(e.text, te) && (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));
40
40
  }
41
41
  function T(e) {
42
42
  return {
@@ -61,24 +61,24 @@ function O() {
61
61
  return { ...v };
62
62
  }
63
63
  function k(e) {
64
- let t = String(e.projectId).trim();
65
- if (!b(t) || !/^[\w.-]+$/.test(t)) throw Error("Invalid WebSocket projectId");
66
- let n;
64
+ let n = String(e.projectId).trim();
65
+ if (!b(n) || !/^[\w.-]+$/.test(n)) throw Error("Invalid WebSocket projectId");
66
+ let r;
67
67
  try {
68
- n = new URL(e.authEndpoint);
68
+ r = new URL(e.authEndpoint);
69
69
  } catch {
70
70
  throw Error("Invalid WebSocket auth endpoint");
71
71
  }
72
- if (n.protocol !== "https:" && !(n.protocol === "http:" && E(n.hostname))) throw Error("Invalid WebSocket auth endpoint");
72
+ if (r.protocol !== "https:" && !(r.protocol === "http:" && E(r.hostname))) throw Error("Invalid WebSocket auth endpoint");
73
73
  if (!a(e.key, 256)) throw Error("Invalid WebSocket key");
74
74
  if (!D(e.wsHost)) throw Error("Invalid WebSocket host");
75
75
  if (!a(e.apiKey, 512)) throw Error("Invalid WebSocket API key");
76
- if (e.userEmail && !i(e.userEmail)) throw Error("Invalid WebSocket user email");
76
+ if (e.userEmail && !t(e.userEmail)) throw Error("Invalid WebSocket user email");
77
77
  if (e.userInfo && !x(e.userInfo)) throw Error("Invalid WebSocket user info");
78
78
  return {
79
79
  ...e,
80
- projectId: t,
81
- authEndpoint: n.toString(),
80
+ projectId: n,
81
+ authEndpoint: r.toString(),
82
82
  userInfo: e.userInfo ? T(e.userInfo) : void 0
83
83
  };
84
84
  }
@@ -150,6 +150,15 @@ var A = class e {
150
150
  this.emit("error", /* @__PURE__ */ Error("WebSocket connection failed"));
151
151
  }), this.subscribeToChannel();
152
152
  }
153
+ reconnect() {
154
+ if (!this.destroyed) {
155
+ if (!this.pusher) {
156
+ this.connect();
157
+ return;
158
+ }
159
+ this.pusher.connect();
160
+ }
161
+ }
153
162
  disconnect() {
154
163
  this.presenceChannel &&= (this.pusher?.unsubscribe(`presence-project.${this.config.projectId}`), null), this.pusher &&= (this.pusher.disconnect(), null), this.onlineUsers.clear();
155
164
  }
@@ -192,20 +201,20 @@ var A = class e {
192
201
  S(e) && this.emit("comment:updated", e);
193
202
  }), t("comment_deleted", (e) => {
194
203
  let t = e;
195
- r(t) && b(t.id) && this.emit("comment:deleted", { id: t.id });
204
+ c(t) && b(t.id) && this.emit("comment:deleted", { id: t.id });
196
205
  }), t("comment_resolved", (e) => {
197
206
  S(e) && this.emit("comment:resolved", e);
198
207
  }), t("comment_completed", (e) => {
199
208
  S(e) && this.emit("comment:completed", e);
200
209
  }), t("reply_added", (e) => {
201
210
  let t = e;
202
- r(t) && b(t.commentId) && C(t.reply) && this.emit("reply:added", {
211
+ c(t) && b(t.commentId) && C(t.reply) && this.emit("reply:added", {
203
212
  commentId: t.commentId,
204
213
  reply: t.reply
205
214
  });
206
215
  }), t("reaction_added", (e) => {
207
216
  let t = e;
208
- r(t) && b(t.commentId) && a(t.emoji, 32) && b(t.userId) && this.emit("reaction:added", {
217
+ c(t) && b(t.commentId) && a(t.emoji, 32) && b(t.userId) && this.emit("reaction:added", {
209
218
  commentId: t.commentId,
210
219
  ...b(t.replyId) ? { replyId: t.replyId } : {},
211
220
  emoji: t.emoji,
@@ -213,7 +222,7 @@ var A = class e {
213
222
  });
214
223
  }), t("reaction_removed", (e) => {
215
224
  let t = e;
216
- r(t) && b(t.commentId) && a(t.emoji, 32) && b(t.userId) && this.emit("reaction:removed", {
225
+ c(t) && b(t.commentId) && a(t.emoji, 32) && b(t.userId) && this.emit("reaction:removed", {
217
226
  commentId: t.commentId,
218
227
  ...b(t.replyId) ? { replyId: t.replyId } : {},
219
228
  emoji: t.emoji,
@@ -229,10 +238,10 @@ var A = class e {
229
238
  }
230
239
  }), this.presenceChannel.bind("client-cursor_leave", (e) => {
231
240
  let t = e;
232
- r(t) && b(t.userId) && this.emit("cursor:leave", { userId: t.userId });
241
+ c(t) && b(t.userId) && this.emit("cursor:leave", { userId: t.userId });
233
242
  }), this.presenceChannel.bind("client-drawing_stroke", (e) => {
234
243
  let t = e;
235
- r(t) && b(t.userId) && w(t.path) && this.emit("drawing:stroke", {
244
+ c(t) && b(t.userId) && w(t.path) && this.emit("drawing:stroke", {
236
245
  userId: t.userId,
237
246
  path: t.path
238
247
  });
@@ -280,13 +289,13 @@ var A = class e {
280
289
  destroy() {
281
290
  this.destroyed = !0, this.disconnect(), this.listeners.clear();
282
291
  }
283
- }, j = c.ID, M = c.CONTENT, ae = c.NAME, oe = c.EMAIL, N = c.PAGE, se = c.EMOJI, P = c.ONLINE_USERS, F = c.REACTION_COUNT, I = 33, L = 1e3, R = c.CURSOR_EMITS_PER_SEC;
292
+ }, j = l.ID, M = l.CONTENT, ae = l.NAME, oe = l.EMAIL, N = l.PAGE, se = l.EMOJI, P = l.ONLINE_USERS, F = l.REACTION_COUNT, I = 33, L = 1e3, R = l.CURSOR_EMITS_PER_SEC;
284
293
  function z(e) {
285
294
  let t = e.config.realtime, n = t?.maxRenderedCursors;
286
295
  return {
287
296
  cursors: t?.cursors !== !1,
288
297
  presence: t?.presence !== !1,
289
- maxRenderedCursors: typeof n == "number" && Number.isFinite(n) && n >= 0 ? Math.min(Math.floor(n), P) : c.RENDERED_CURSORS
298
+ maxRenderedCursors: typeof n == "number" && Number.isFinite(n) && n >= 0 ? Math.min(Math.floor(n), P) : l.RENDERED_CURSORS
290
299
  };
291
300
  }
292
301
  var B = new Set([
@@ -321,7 +330,7 @@ function ce(e) {
321
330
  return n > 0 && n === t.lastIndexOf("@") && n < t.length - 1 && !/\s/.test(t);
322
331
  }
323
332
  function K(e) {
324
- return r(e) && G(e.id) && W(e.name, ae) && ce(e.email) && o(e.avatar, N) && o(e.organizationId, j);
333
+ return c(e) && G(e.id) && W(e.name, ae) && ce(e.email) && o(e.avatar, N) && o(e.organizationId, j);
325
334
  }
326
335
  function q(e) {
327
336
  return {
@@ -344,13 +353,13 @@ function le(e) {
344
353
  return t;
345
354
  }
346
355
  function ue(e) {
347
- return r(e) ? n(e.x) && n(e.y) : !1;
356
+ return c(e) ? i(e.x) && i(e.y) : !1;
348
357
  }
349
358
  function de(e) {
350
- return r(e) && W(e.url, N) && W(e.path, N) && W(e.title, N);
359
+ return c(e) && W(e.url, N) && W(e.path, N) && W(e.title, N);
351
360
  }
352
361
  function fe(e) {
353
- return r(e) && X(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= F && typeof e.reacted == "boolean";
362
+ return c(e) && X(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= F && typeof e.reacted == "boolean";
354
363
  }
355
364
  function pe(e) {
356
365
  return {
@@ -360,13 +369,13 @@ function pe(e) {
360
369
  };
361
370
  }
362
371
  function J(e) {
363
- return !r(e) || !G(e.id) || !B.has(e.type) || !W(e.content, M) || !ue(e.position) || !V.has(e.status) || !H.has(e.priority) || !K(e.author) || !G(e.userId) || !W(e.createdAt, N) || !W(e.updatedAt, N) || !de(e.page) || !Array.isArray(e.replies) || !Array.isArray(e.attachments) ? null : pe(structuredClone(e));
372
+ return !c(e) || !G(e.id) || !B.has(e.type) || !W(e.content, M) || !ue(e.position) || !V.has(e.status) || !H.has(e.priority) || !K(e.author) || !G(e.userId) || !W(e.createdAt, N) || !W(e.updatedAt, N) || !de(e.page) || !Array.isArray(e.replies) || !Array.isArray(e.attachments) ? null : pe(structuredClone(e));
364
373
  }
365
374
  function Y(e) {
366
- return !r(e) || !G(e.id) || !W(e.content, M) || !K(e.author) || !W(e.createdAt, N) ? null : structuredClone(e);
375
+ return !c(e) || !G(e.id) || !W(e.content, M) || !K(e.author) || !W(e.createdAt, N) ? null : structuredClone(e);
367
376
  }
368
377
  function me(e) {
369
- return !r(e) || !K(e.user) || !l(e.x) || e.x < 0 || e.x > 100 || !l(e.y) || e.y < 0 || e.y > 100 || !W(e.page, N) ? null : {
378
+ return !c(e) || !K(e.user) || !r(e.x) || e.x < 0 || e.x > 100 || !r(e.y) || e.y < 0 || e.y > 100 || !W(e.page, N) ? null : {
370
379
  x: e.x,
371
380
  y: e.y,
372
381
  page: e.page.trim(),
@@ -374,7 +383,7 @@ function me(e) {
374
383
  };
375
384
  }
376
385
  function he(e) {
377
- return r(e) ? W(e.type, c.DRAWING_TYPE) && U.has(e.type) && W(e.stroke, c.COLOR) && l(e.strokeWidth) && e.strokeWidth >= 0 && W(e.fill, c.COLOR) && o(e.d, c.DRAWING_PATH_DATA) && o(e.text, c.DRAWING_TEXT) && (e.x === void 0 || l(e.x)) && (e.y === void 0 || l(e.y)) && (e.width === void 0 || l(e.width)) && (e.height === void 0 || l(e.height)) : !1;
386
+ return c(e) ? W(e.type, l.DRAWING_TYPE) && U.has(e.type) && W(e.stroke, l.COLOR) && r(e.strokeWidth) && e.strokeWidth >= 0 && W(e.fill, l.COLOR) && o(e.d, l.DRAWING_PATH_DATA) && o(e.text, l.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;
378
387
  }
379
388
  function X(e) {
380
389
  return W(e, se);
@@ -390,19 +399,19 @@ function Z(e, t) {
390
399
  function Q(e, t) {
391
400
  e.setState({ comments: e.getState().comments.map((e) => e.id === t.id ? t : e) });
392
401
  }
393
- function _e(e, n) {
402
+ function _e(e, t) {
394
403
  if (e.config.features?.realtime === !1 || !e.config.reverb?.host || !e.config.reverb?.key) return;
395
- if (n.wsManager) {
396
- for (let e of n.wsUnsubscribers) ge(e);
397
- n.wsUnsubscribers = [], $(n);
404
+ if (t.wsManager) {
405
+ for (let e of t.wsUnsubscribers) ge(e);
406
+ t.wsUnsubscribers = [], $(t);
398
407
  try {
399
- n.wsManager.destroy();
408
+ t.wsManager.destroy();
400
409
  } catch {}
401
- n.wsManager = null;
410
+ t.wsManager = null;
402
411
  }
403
- let i = e.config.baseUrl || "https://api.commentkit.com/api", a = e.getState().currentUser, o = z(e);
412
+ let r = e.config.baseUrl || "https://api.commentkit.dev/api", i = e.getState().currentUser, a = z(e);
404
413
  try {
405
- n.wsManager = new A({
414
+ t.wsManager = new A({
406
415
  key: e.config.reverb.key,
407
416
  wsHost: e.config.reverb.host,
408
417
  wsPort: e.config.reverb.port ?? 443,
@@ -410,61 +419,61 @@ function _e(e, n) {
410
419
  /* v8 ignore next -- projectId always provided in config */
411
420
  projectId: e.config.projectId || "",
412
421
  apiKey: e.config.apiKey,
413
- authEndpoint: `${i}/broadcasting/auth`,
414
- userEmail: a?.email,
415
- userInfo: a ? {
416
- id: a.id,
417
- name: a.name,
418
- email: a.email
422
+ authEndpoint: `${r}/broadcasting/auth`,
423
+ userEmail: i?.email,
424
+ userInfo: i ? {
425
+ id: i.id,
426
+ name: i.name,
427
+ email: i.email
419
428
  } : void 0
420
429
  });
421
430
  } catch (t) {
422
431
  e.setState({ connectionStatus: "error" }), e.handleError(t);
423
432
  return;
424
433
  }
425
- let s = n.wsUnsubscribers, c = n.wsManager;
426
- s.push(c.on("connected", () => {
427
- Z(n, c) && (e.setState({ connectionStatus: "connected" }), n.wsManager?.requestPresence());
428
- })), s.push(c.on("disconnected", () => {
429
- Z(n, c) && e.setState({ connectionStatus: "disconnected" });
430
- })), s.push(c.on("reconnecting", () => {
431
- Z(n, c) && e.setState({ connectionStatus: "connecting" });
432
- })), s.push(c.on("error", () => {
433
- Z(n, c) && e.setState({ connectionStatus: "error" });
434
- })), s.push(c.on("comment:resolved", (t) => {
435
- if (!Z(n, c)) return;
436
- let r = J(t);
434
+ let o = t.wsUnsubscribers, s = t.wsManager;
435
+ o.push(s.on("connected", () => {
436
+ Z(t, s) && (e.setState({ connectionStatus: "connected" }), t.wsManager?.requestPresence());
437
+ })), o.push(s.on("disconnected", () => {
438
+ Z(t, s) && e.setState({ connectionStatus: "disconnected" });
439
+ })), o.push(s.on("reconnecting", () => {
440
+ Z(t, s) && e.setState({ connectionStatus: "connecting" });
441
+ })), o.push(s.on("error", () => {
442
+ Z(t, s) && e.setState({ connectionStatus: "error" });
443
+ })), o.push(s.on("comment:resolved", (n) => {
444
+ if (!Z(t, s)) return;
445
+ let r = J(n);
437
446
  r && (Q(e, r), e.emit("comment:resolved", r));
438
- })), s.push(c.on("comment:completed", (t) => {
439
- if (!Z(n, c)) return;
440
- let r = J(t);
447
+ })), o.push(s.on("comment:completed", (n) => {
448
+ if (!Z(t, s)) return;
449
+ let r = J(n);
441
450
  r && (Q(e, r), e.emit("comment:completed", r));
442
- })), s.push(c.on("comment:created", (r) => {
443
- if (!Z(n, c)) return;
451
+ })), o.push(s.on("comment:created", (r) => {
452
+ if (!Z(t, s)) return;
444
453
  let i = J(r);
445
- i && i.page.path === t().path && (e.getState().comments.find((e) => e.id === i.id) || (e.setState({ comments: [...e.getState().comments, i] }), e.emit("comment:created", i)));
446
- })), s.push(c.on("comment:updated", (t) => {
447
- if (!Z(n, c)) return;
448
- let r = J(t);
454
+ i && i.page.path === n().path && (e.getState().comments.find((e) => e.id === i.id) || (e.setState({ comments: [...e.getState().comments, i] }), e.emit("comment:created", i)));
455
+ })), o.push(s.on("comment:updated", (n) => {
456
+ if (!Z(t, s)) return;
457
+ let r = J(n);
449
458
  r && (Q(e, r), e.emit("comment:updated", r));
450
- })), s.push(c.on("comment:deleted", (t) => {
451
- if (!Z(n, c) || !r(t) || !G(t.id)) return;
452
- let i = t.id.trim();
459
+ })), o.push(s.on("comment:deleted", (n) => {
460
+ if (!Z(t, s) || !c(n) || !G(n.id)) return;
461
+ let r = n.id.trim();
453
462
  e.setState({
454
- comments: e.getState().comments.filter((e) => e.id !== i),
455
- selectedComment: e.getState().selectedComment?.id === i ? null : e.getState().selectedComment
456
- }), e.emit("comment:deleted", { id: i });
457
- })), s.push(c.on("reply:added", (t) => {
458
- if (!Z(n, c) || !r(t) || !G(t.commentId)) return;
459
- let i = Y(t.reply);
460
- if (!i) return;
461
- let a = t.commentId.trim(), o = e.getState().comments.map((e) => e.id !== a || e.replies.some((e) => e.id === i.id) ? e : {
463
+ comments: e.getState().comments.filter((e) => e.id !== r),
464
+ selectedComment: e.getState().selectedComment?.id === r ? null : e.getState().selectedComment
465
+ }), e.emit("comment:deleted", { id: r });
466
+ })), o.push(s.on("reply:added", (n) => {
467
+ if (!Z(t, s) || !c(n) || !G(n.commentId)) return;
468
+ let r = Y(n.reply);
469
+ if (!r) return;
470
+ let i = n.commentId.trim(), a = e.getState().comments.map((e) => e.id !== i || e.replies.some((e) => e.id === r.id) ? e : {
462
471
  ...e,
463
- replies: [...e.replies, i]
472
+ replies: [...e.replies, r]
464
473
  });
465
- e.setState({ comments: o });
466
- let s = o.find((e) => e.id === a);
467
- s && e.emit("comment:updated", s);
474
+ e.setState({ comments: a });
475
+ let o = a.find((e) => e.id === i);
476
+ o && e.emit("comment:updated", o);
468
477
  }));
469
478
  let l = (e, t, n) => {
470
479
  let r = (e ?? []).filter((e) => X(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= F), i = r.findIndex((e) => e.emoji === t);
@@ -488,55 +497,55 @@ function _e(e, n) {
488
497
  ...e,
489
498
  count: n ? e.count : e.count - 1,
490
499
  reacted: n ? !1 : e.reacted
491
- } : e).filter((e) => e.count > 0), d = (t, i) => {
492
- if (!Z(n, c) || !r(t) || !G(t.commentId) || !X(t.emoji) || !G(t.userId)) return;
493
- let a = t.commentId.trim(), o = G(t.replyId) ? t.replyId.trim() : null, s = t.emoji.trim(), l = t.userId.trim() === e.getState().currentUser?.id;
494
- e.setState({ comments: e.getState().comments.map((e) => e.id === a ? o === null ? {
500
+ } : e).filter((e) => e.count > 0), d = (n, r) => {
501
+ if (!Z(t, s) || !c(n) || !G(n.commentId) || !X(n.emoji) || !G(n.userId)) return;
502
+ let i = n.commentId.trim(), a = G(n.replyId) ? n.replyId.trim() : null, o = n.emoji.trim(), l = n.userId.trim() === e.getState().currentUser?.id;
503
+ e.setState({ comments: e.getState().comments.map((e) => e.id === i ? a === null ? {
495
504
  ...e,
496
- reactions: i(e.reactions, s, l)
505
+ reactions: r(e.reactions, o, l)
497
506
  } : {
498
507
  ...e,
499
- replies: e.replies.map((e) => e.id === o ? {
508
+ replies: e.replies.map((e) => e.id === a ? {
500
509
  ...e,
501
- reactions: i(e.reactions, s, l)
510
+ reactions: r(e.reactions, o, l)
502
511
  } : e)
503
512
  } : e) });
504
513
  };
505
- s.push(c.on("reaction:added", (e) => d(e, l))), s.push(c.on("reaction:removed", (e) => d(e, u)));
514
+ o.push(s.on("reaction:added", (e) => d(e, l))), o.push(s.on("reaction:removed", (e) => d(e, u)));
506
515
  let f = /* @__PURE__ */ new Map(), p = 0, m = 0;
507
- s.push(c.on("cursor:move", (t) => {
508
- if (!Z(n, c) || !o.cursors) return;
509
- let r = me(t);
516
+ o.push(s.on("cursor:move", (n) => {
517
+ if (!Z(t, s) || !a.cursors) return;
518
+ let r = me(n);
510
519
  if (!r) return;
511
- let i = Date.now(), a = r.user.id, s = f.get(a);
512
- if (s === void 0 && f.size >= o.maxRenderedCursors) {
520
+ let i = Date.now(), o = r.user.id, c = f.get(o);
521
+ if (c === void 0 && f.size >= a.maxRenderedCursors) {
513
522
  let e, t = Infinity;
514
523
  for (let [n, r] of f) r < t && (t = r, e = n);
515
524
  if (e !== void 0 && i - t >= I) f.delete(e);
516
525
  else return;
517
526
  }
518
- s !== void 0 && i - s < I || (i - p >= L && (p = i, m = 0), !(m >= R) && (m++, f.set(a, i), e.emit("cursor:move", r)));
519
- })), s.push(c.on("cursor:leave", (t) => {
520
- !Z(n, c) || !r(t) || !G(t.userId) || (f.delete(t.userId.trim()), e.emit("cursor:leave", { userId: t.userId.trim() }));
521
- })), s.push(c.on("user:joined", (t) => {
522
- !Z(n, c) || !K(t) || e.emit("user:joined", q(t));
523
- })), s.push(c.on("user:left", (t) => {
524
- !Z(n, c) || !r(t) || !G(t.userId) || e.emit("user:left", { userId: t.userId.trim() });
525
- })), s.push(c.on("presence:update", (t) => {
526
- if (!Z(n, c) || !o.presence || !r(t)) return;
527
- let i = le(t.users);
528
- if (!i) return;
529
- let a = { users: i };
530
- e.setState({ onlineUsers: i }), e.emit("presence:update", a);
531
- })), s.push(c.on("drawing:stroke", (t) => {
532
- !Z(n, c) || !r(t) || !G(t.userId) || !he(t.path) || e.emit("drawing:stroke", {
533
- userId: t.userId.trim(),
534
- path: structuredClone(t.path)
527
+ c !== void 0 && i - c < I || (i - p >= L && (p = i, m = 0), !(m >= R) && (m++, f.set(o, i), e.emit("cursor:move", r)));
528
+ })), o.push(s.on("cursor:leave", (n) => {
529
+ !Z(t, s) || !c(n) || !G(n.userId) || (f.delete(n.userId.trim()), e.emit("cursor:leave", { userId: n.userId.trim() }));
530
+ })), o.push(s.on("user:joined", (n) => {
531
+ !Z(t, s) || !K(n) || e.emit("user:joined", q(n));
532
+ })), o.push(s.on("user:left", (n) => {
533
+ !Z(t, s) || !c(n) || !G(n.userId) || e.emit("user:left", { userId: n.userId.trim() });
534
+ })), o.push(s.on("presence:update", (n) => {
535
+ if (!Z(t, s) || !a.presence || !c(n)) return;
536
+ let r = le(n.users);
537
+ if (!r) return;
538
+ let i = { users: r };
539
+ e.setState({ onlineUsers: r }), e.emit("presence:update", i);
540
+ })), o.push(s.on("drawing:stroke", (n) => {
541
+ !Z(t, s) || !c(n) || !G(n.userId) || !he(n.path) || e.emit("drawing:stroke", {
542
+ userId: n.userId.trim(),
543
+ path: structuredClone(n.path)
535
544
  });
536
545
  }));
537
546
  try {
538
547
  e.setState({ connectionStatus: "connecting" });
539
- let t = c.connect();
548
+ let t = s.connect();
540
549
  t && typeof t.catch == "function" && t.catch((t) => {
541
550
  e.setState({ connectionStatus: "error" }), e.handleError(t);
542
551
  });
@@ -544,13 +553,13 @@ function _e(e, n) {
544
553
  e.setState({ connectionStatus: "error" }), e.handleError(t);
545
554
  return;
546
555
  }
547
- typeof document > "u" || typeof window > "u" || o.cursors && (n.mouseMoveHandler = (r) => {
548
- if (e.getState().isOverlayVisible && n.wsManager?.isConnected()) {
556
+ typeof document > "u" || typeof window > "u" || a.cursors && (t.mouseMoveHandler = (r) => {
557
+ if (e.getState().isOverlayVisible && t.wsManager?.isConnected()) {
549
558
  if (window.innerWidth <= 0 || window.innerHeight <= 0) return;
550
559
  let e = Math.max(0, Math.min(100, r.clientX / window.innerWidth * 100)), i = Math.max(0, Math.min(100, r.clientY / window.innerHeight * 100));
551
- n.wsManager.sendCursorMove(e, i, t().url);
560
+ t.wsManager.sendCursorMove(e, i, n().url);
552
561
  }
553
- }, document.addEventListener("mousemove", n.mouseMoveHandler));
562
+ }, document.addEventListener("mousemove", t.mouseMoveHandler));
554
563
  }
555
564
  function $(e) {
556
565
  typeof window < "u" && typeof document < "u" && e.mouseMoveHandler && (document.removeEventListener("mousemove", e.mouseMoveHandler), e.mouseMoveHandler = null);