@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.
- package/CHANGELOG.md +17 -0
- package/README.md +63 -60
- package/dist/angular/comment-kit-ui-DlWdgxZJ.js +17929 -0
- package/dist/{qwik/dom-BjJ-QroQ.js → angular/dom-Cx1nMbdI.js} +9 -2
- package/dist/angular/{mount-ui-CxChSb8B.js → mount-ui-Q_U4OkMo.js} +1 -1
- package/dist/angular/{realtime-CfJZMEAi.js → realtime-VrKV0lPI.js} +11 -2
- package/dist/angular/styles-CmEq782M.js +2 -0
- package/dist/angular.es.js +23 -7
- package/dist/comment-kit.es.js +23 -7
- package/dist/core/comment-kit-ui-CwoXDJXR.js +17929 -0
- package/dist/core/{mount-ui-DrFjMJJu.js → mount-ui-D-pILMLR.js} +1 -1
- package/dist/core/{realtime-DYf6E_sN.js → realtime-C3_O7gi2.js} +2 -2
- package/dist/core/styles-Dzn_nEz7.js +2 -0
- package/dist/core/{websocket-manager-DorGPjR4.js → websocket-manager-D1_TEuy_.js} +9 -0
- package/dist/preact/comment-kit-ui-CIeAiL3D.js +17929 -0
- package/dist/{angular/dom-ON-u4y6t.js → preact/dom-_ULpq7rg.js} +9 -2
- package/dist/preact/{mount-ui-b9JcJQYE.js → mount-ui-8BL4DWNw.js} +1 -1
- package/dist/preact/{realtime-BFgP4BlB.js → realtime-COin_nJF.js} +11 -2
- package/dist/preact/styles-ECCK6Z_C.js +2 -0
- package/dist/preact.es.js +23 -7
- package/dist/qwik/comment-kit-ui-CT3GZ8ry.js +17929 -0
- package/dist/{solid/dom-Bpw1A0oz.js → qwik/dom-Dm3gzBBJ.js} +9 -2
- package/dist/qwik/{mount-ui-CaRrLb9u.js → mount-ui-DQ22eQbu.js} +1 -1
- package/dist/qwik/{realtime-DUhkZAVc.js → realtime-DhfcBrwF.js} +11 -2
- package/dist/qwik/styles-CMcDFAyE.js +2 -0
- package/dist/qwik.es.js +23 -7
- package/dist/react/{limits-Dflmuf1P.js → limits-CpprSem3.js} +10 -3
- package/dist/react/{realtime-C7h-Agwo.js → realtime-DGqScuox.js} +125 -116
- package/dist/react.es.js +12023 -3561
- package/dist/solid/comment-kit-ui-BXcJmq6H.js +17929 -0
- package/dist/{preact/dom-BAV8grk_.js → solid/dom-DqDH-Gml.js} +9 -2
- package/dist/solid/{mount-ui-bPWYgjmm.js → mount-ui-DmrWIA8O.js} +1 -1
- package/dist/solid/{realtime-DK86zDCJ.js → realtime-DbUJK4gU.js} +11 -2
- package/dist/solid/styles-Be_8-1ZV.js +2 -0
- package/dist/solid.es.js +23 -7
- package/dist/svelte/comment-kit-ui-C-8rQmBN.js +17929 -0
- package/dist/svelte/dom-MyTrWzy_.js +104 -0
- package/dist/svelte/{mount-ui-DtXWMEYn.js → mount-ui-CDgJuoAF.js} +1 -1
- package/dist/svelte/{realtime-zYOctwRk.js → realtime-M1CJbCBA.js} +11 -2
- package/dist/svelte/styles-B863Tn5m.js +2 -0
- package/dist/svelte.es.js +23 -7
- package/dist/types/core/comment-kit-core.d.ts +12 -0
- package/dist/types/core/websocket-manager.d.ts +5 -0
- package/dist/types/react/comments/comment-flow.d.ts +8 -0
- package/dist/types/react/comments/outcomes.d.ts +22 -0
- package/dist/types/react/comments/pin-geometry.d.ts +12 -0
- package/dist/types/react/comments/view-model.d.ts +59 -0
- package/dist/types/react/components/comment-actions.d.ts +20 -0
- package/dist/types/react/components/comment-body.d.ts +8 -0
- package/dist/types/react/components/comment-composer-actions.d.ts +26 -0
- package/dist/types/react/components/comment-composer-extras-fields.d.ts +35 -0
- package/dist/types/react/components/comment-composer-extras-toolbar.d.ts +28 -0
- package/dist/types/react/components/comment-composer-extras.d.ts +10 -0
- package/dist/types/react/components/comment-composer-hook.d.ts +53 -0
- package/dist/types/react/components/comment-composer-media.d.ts +30 -0
- package/dist/types/react/components/comment-composer.d.ts +4 -0
- package/dist/types/react/components/comment-connection-alert.d.ts +7 -0
- package/dist/types/react/components/comment-custom-cursor.d.ts +14 -0
- package/dist/types/react/components/comment-emoji-picker.d.ts +12 -0
- package/dist/types/react/components/comment-error-banner.d.ts +8 -0
- package/dist/types/react/components/comment-format-toolbar.d.ts +6 -0
- package/dist/types/react/components/comment-header.d.ts +41 -0
- package/dist/types/react/components/comment-image-lightbox.d.ts +18 -0
- package/dist/types/react/components/comment-images.d.ts +15 -0
- package/dist/types/react/components/comment-item.d.ts +25 -0
- package/dist/types/react/components/comment-login-modal.d.ts +20 -0
- package/dist/types/react/components/comment-marker-layer-composer.d.ts +21 -0
- package/dist/types/react/components/comment-marker-layer.d.ts +26 -0
- package/dist/types/react/components/comment-marker-popover.d.ts +12 -0
- package/dist/types/react/components/comment-marker.d.ts +14 -0
- package/dist/types/react/components/comment-page-ref.d.ts +9 -0
- package/dist/types/react/components/comment-panel.d.ts +17 -0
- package/dist/types/react/components/comment-quoted-text.d.ts +9 -0
- package/dist/types/react/components/comment-reactions.d.ts +11 -0
- package/dist/types/react/components/comment-thread-detail-badges.d.ts +16 -0
- package/dist/types/react/components/comment-thread-detail-meta.d.ts +8 -0
- package/dist/types/react/components/comment-thread-detail-replies.d.ts +13 -0
- package/dist/types/react/components/comment-thread-detail.d.ts +10 -0
- package/dist/types/react/components/comment-thread-footer.d.ts +12 -0
- package/dist/types/react/components/comment-thread-list-item.d.ts +14 -0
- package/dist/types/react/components/comment-thread-list.d.ts +8 -0
- package/dist/types/react/components/comment-user-avatar-tooltip.d.ts +12 -0
- package/dist/types/react/ui/primitives/alert/alert.d.ts +8 -0
- package/dist/types/react/ui/primitives/alert/index.d.ts +1 -0
- package/dist/vue/comment-kit-ui-Cq30Cmvs.js +17929 -0
- package/dist/vue/dom-C7krZAR8.js +104 -0
- package/dist/vue/{mount-ui-DdTYzv6J.js → mount-ui-Dqz0_jd_.js} +1 -1
- package/dist/vue/{realtime-YJKvS2eB.js → realtime-B0B5cE-E.js} +11 -2
- package/dist/vue/styles-C4t8gcea.js +2 -0
- package/dist/vue.es.js +23 -7
- package/package.json +3 -6
- package/dist/angular/comment-kit-ui-wEJfMh4T.js +0 -9483
- package/dist/angular/styles-CvndAWRF.js +0 -2
- package/dist/core/comment-kit-ui-DjWARy4X.js +0 -9483
- package/dist/core/styles-D19zARBi.js +0 -2
- package/dist/preact/comment-kit-ui-BKi15Z4Q.js +0 -9483
- package/dist/preact/styles-Dwd4AJR8.js +0 -2
- package/dist/qwik/comment-kit-ui-CRmJhZlX.js +0 -9483
- package/dist/qwik/styles-BB1B91hh.js +0 -2
- package/dist/solid/comment-kit-ui-Dw_67h_e.js +0 -9483
- package/dist/solid/styles-CtYBghRP.js +0 -2
- package/dist/svelte/comment-kit-ui-DhCWlEd8.js +0 -9483
- package/dist/svelte/dom-mfioQqLy.js +0 -97
- package/dist/svelte/styles-DKCGeARl.js +0 -2
- package/dist/vue/comment-kit-ui-BX1wDZ2c.js +0 -9483
- package/dist/vue/dom-eo0P9Z6Z.js +0 -97
- 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 {
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 !
|
|
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
|
|
65
|
-
if (!b(
|
|
66
|
-
let
|
|
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
|
-
|
|
68
|
+
r = new URL(e.authEndpoint);
|
|
69
69
|
} catch {
|
|
70
70
|
throw Error("Invalid WebSocket auth endpoint");
|
|
71
71
|
}
|
|
72
|
-
if (
|
|
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 && !
|
|
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:
|
|
81
|
-
authEndpoint:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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) :
|
|
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
|
|
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
|
|
356
|
+
return c(e) ? i(e.x) && i(e.y) : !1;
|
|
348
357
|
}
|
|
349
358
|
function de(e) {
|
|
350
|
-
return
|
|
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
|
|
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 !
|
|
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 !
|
|
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 !
|
|
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
|
|
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,
|
|
402
|
+
function _e(e, t) {
|
|
394
403
|
if (e.config.features?.realtime === !1 || !e.config.reverb?.host || !e.config.reverb?.key) return;
|
|
395
|
-
if (
|
|
396
|
-
for (let e of
|
|
397
|
-
|
|
404
|
+
if (t.wsManager) {
|
|
405
|
+
for (let e of t.wsUnsubscribers) ge(e);
|
|
406
|
+
t.wsUnsubscribers = [], $(t);
|
|
398
407
|
try {
|
|
399
|
-
|
|
408
|
+
t.wsManager.destroy();
|
|
400
409
|
} catch {}
|
|
401
|
-
|
|
410
|
+
t.wsManager = null;
|
|
402
411
|
}
|
|
403
|
-
let
|
|
412
|
+
let r = e.config.baseUrl || "https://api.commentkit.dev/api", i = e.getState().currentUser, a = z(e);
|
|
404
413
|
try {
|
|
405
|
-
|
|
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: `${
|
|
414
|
-
userEmail:
|
|
415
|
-
userInfo:
|
|
416
|
-
id:
|
|
417
|
-
name:
|
|
418
|
-
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
|
|
426
|
-
|
|
427
|
-
Z(
|
|
428
|
-
})),
|
|
429
|
-
Z(
|
|
430
|
-
})),
|
|
431
|
-
Z(
|
|
432
|
-
})),
|
|
433
|
-
Z(
|
|
434
|
-
})),
|
|
435
|
-
if (!Z(
|
|
436
|
-
let r = J(
|
|
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
|
-
})),
|
|
439
|
-
if (!Z(
|
|
440
|
-
let r = J(
|
|
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
|
-
})),
|
|
443
|
-
if (!Z(
|
|
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 ===
|
|
446
|
-
})),
|
|
447
|
-
if (!Z(
|
|
448
|
-
let r = J(
|
|
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
|
-
})),
|
|
451
|
-
if (!Z(
|
|
452
|
-
let
|
|
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 !==
|
|
455
|
-
selectedComment: e.getState().selectedComment?.id ===
|
|
456
|
-
}), e.emit("comment:deleted", { id:
|
|
457
|
-
})),
|
|
458
|
-
if (!Z(
|
|
459
|
-
let
|
|
460
|
-
if (!
|
|
461
|
-
let
|
|
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,
|
|
472
|
+
replies: [...e.replies, r]
|
|
464
473
|
});
|
|
465
|
-
e.setState({ comments:
|
|
466
|
-
let
|
|
467
|
-
|
|
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 = (
|
|
492
|
-
if (!Z(
|
|
493
|
-
let
|
|
494
|
-
e.setState({ comments: e.getState().comments.map((e) => e.id ===
|
|
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:
|
|
505
|
+
reactions: r(e.reactions, o, l)
|
|
497
506
|
} : {
|
|
498
507
|
...e,
|
|
499
|
-
replies: e.replies.map((e) => e.id ===
|
|
508
|
+
replies: e.replies.map((e) => e.id === a ? {
|
|
500
509
|
...e,
|
|
501
|
-
reactions:
|
|
510
|
+
reactions: r(e.reactions, o, l)
|
|
502
511
|
} : e)
|
|
503
512
|
} : e) });
|
|
504
513
|
};
|
|
505
|
-
|
|
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
|
-
|
|
508
|
-
if (!Z(
|
|
509
|
-
let r = me(
|
|
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(),
|
|
512
|
-
if (
|
|
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
|
-
|
|
519
|
-
})),
|
|
520
|
-
!Z(
|
|
521
|
-
})),
|
|
522
|
-
!Z(
|
|
523
|
-
})),
|
|
524
|
-
!Z(
|
|
525
|
-
})),
|
|
526
|
-
if (!Z(
|
|
527
|
-
let
|
|
528
|
-
if (!
|
|
529
|
-
let
|
|
530
|
-
e.setState({ onlineUsers:
|
|
531
|
-
})),
|
|
532
|
-
!Z(
|
|
533
|
-
userId:
|
|
534
|
-
path: structuredClone(
|
|
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 =
|
|
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" ||
|
|
548
|
-
if (e.getState().isOverlayVisible &&
|
|
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
|
-
|
|
560
|
+
t.wsManager.sendCursorMove(e, i, n().url);
|
|
552
561
|
}
|
|
553
|
-
}, document.addEventListener("mousemove",
|
|
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);
|