@commentkit/comment-kit 0.7.1 → 0.7.3
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 +22 -0
- package/README.md +10 -6
- package/SECURITY.md +14 -6
- package/dist/angular.es.js +2 -2
- package/dist/comment-kit.es.js +5 -5
- package/dist/demo.es.js +35 -34
- package/dist/headless.es.js +3 -3
- package/dist/preact.es.js +2 -2
- package/dist/qwik.qwik.mjs +2 -2
- package/dist/react.es.js +2 -2
- package/dist/shared/{ShadowRootContext-Bv-4aElu.js → ShadowRootContext-CjciYxVN.js} +4 -4
- package/dist/shared/annotation-toolbar-XpqojzM2.js +1094 -0
- package/dist/shared/{attachment-refresh-CzQFXHkL.js → attachment-refresh-agUheZPF.js} +2 -2
- package/dist/shared/{button-group-CWdKaOlC.js → button-group-C285iSkZ.js} +1 -1
- package/dist/shared/capture-privacy-DUROnio5.js +77 -0
- package/dist/shared/{comment-drawing-canvas-DdXlMgbF.js → comment-drawing-canvas-B3zqdIZH.js} +2 -2
- package/dist/shared/{comment-icon-Dg9ZWpz-.js → comment-icon-4SQd3nlz.js} +1 -1
- package/dist/shared/{comment-image-lightbox-B7iHjnAz.js → comment-image-lightbox-j9y3Klh6.js} +5 -5
- package/dist/shared/{comment-images-content-D7YNUgo5.js → comment-images-content-aJrMaOi9.js} +3 -3
- package/dist/shared/{comment-kit-core-C862uNAm.js → comment-kit-core-Bsyydwpk.js} +786 -703
- package/dist/shared/{comment-kit-ui-0vd-DY4S.js → comment-kit-ui-qKjCHHOy.js} +4642 -4820
- package/dist/shared/{comment-screenshot-annotator-DcaSSuWB.js → comment-screenshot-annotator-aDtgMbBF.js} +2 -2
- package/dist/shared/{comment-screenshot-overlay-D_nFoJmM.js → comment-screenshot-overlay-B-rAubia.js} +113 -118
- package/dist/shared/comment-shortcut-groups-CfEmkitU.js +153 -0
- package/dist/shared/{dev-export-panel-pWBlhlse.js → dev-export-panel-mrxmtzei.js} +3 -4
- package/dist/shared/dev-grab-Cc-lJYBv.js +196 -0
- package/dist/shared/{element-selector-DC-_XJ0k.js → element-selector-4TxTAXHK.js} +408 -405
- package/dist/shared/{mount-ui-B68j8r6I.js → mount-ui-Dbqe5VsO.js} +121 -106
- package/dist/shared/{pusher-C1FHQGXV.js → pusher-zAMukOay.js} +1 -1
- package/dist/shared/{realtime-recovery-DJ_adc-H.js → realtime-recovery-BSVMwsXJ.js} +1 -1
- package/dist/shared/realtime-t5o6fk6w.js +321 -0
- package/dist/shared/request-activity-DQrAUwfA.js +11 -0
- package/dist/shared/{separator-XDBsaWyw.js → separator-aphZiRoJ.js} +1 -1
- package/dist/shared/{shadow-root-CrO75sED.js → shadow-root-DlfbvZF9.js} +31 -31
- package/dist/shared/{styles-C9Jwvm0Q.js → styles-CnYsLS2f.js} +1 -1
- package/dist/shared/text-B4HHZNaa.js +23 -0
- package/dist/shared/token-session-ZzSO1tEl.js +25 -0
- package/dist/shared/{validation-D-8u4M7I.js → validation-3wbbbuX0.js} +14 -2
- package/dist/shared/{websocket-manager-CFak_YHy.js → websocket-manager-DGN8T9mq.js} +136 -116
- package/dist/solid.es.js +2 -2
- package/dist/svelte.es.js +2 -2
- package/dist/types/core/api-client.d.ts +3 -1
- package/dist/types/core/comment-kit-core.d.ts +2 -5
- package/dist/types/core/types.d.ts +22 -5
- package/dist/types/core/websocket-manager.d.ts +1 -0
- package/dist/vue.es.js +2 -2
- package/docs/api-reference.md +19 -4
- package/package.json +1 -1
- package/dist/shared/annotation-toolbar-cGC1p-SP.js +0 -1093
- package/dist/shared/dev-grab-eQ9EgEGY.js +0 -210
- package/dist/shared/realtime-Diqz7G_y.js +0 -317
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { c as e, f as t, l as n, m as r, p as i, r as a } from "./comment-kit-core-C862uNAm.js";
|
|
2
|
-
import { a as o, i as s, o as c } from "./dom-Bhf4WFtY.js";
|
|
3
|
-
var l = 4e3, u = 500, d = 2e3, f = 1e3, p = 5, m = 25, h = 3145728;
|
|
4
|
-
function g(e) {
|
|
5
|
-
let t = r(e?.comment, d);
|
|
6
|
-
return t.length > 0 ? t : null;
|
|
7
|
-
}
|
|
8
|
-
function _(e) {
|
|
9
|
-
return (e?.attachments ?? []).slice(0, p).flatMap((e) => {
|
|
10
|
-
let t = r(e.name, f), n = r(e.path, f);
|
|
11
|
-
return !t || !n ? [] : [{
|
|
12
|
-
name: t,
|
|
13
|
-
path: n,
|
|
14
|
-
...e.pathSource ? { pathSource: e.pathSource } : {},
|
|
15
|
-
...e.type ? { type: r(e.type, f) } : {},
|
|
16
|
-
...typeof e.size == "number" ? { size: e.size } : {},
|
|
17
|
-
...typeof e.lastModified == "number" ? { lastModified: e.lastModified } : {}
|
|
18
|
-
}];
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function v(e) {
|
|
22
|
-
return typeof HTMLElement < "u" && e instanceof HTMLElement;
|
|
23
|
-
}
|
|
24
|
-
function y(e, t, n, i) {
|
|
25
|
-
let a = e.getBoundingClientRect(), c = s(e), d = o(e), f = e.getAttribute("class"), p = e.getAttribute("role"), m = e.getAttribute("aria-label"), h = r(e.textContent, u), g = r(e.outerHTML, l);
|
|
26
|
-
return {
|
|
27
|
-
found: !0,
|
|
28
|
-
tagName: e.tagName.toLowerCase(),
|
|
29
|
-
...e.id ? { id: e.id } : {},
|
|
30
|
-
...f ? { className: f } : {},
|
|
31
|
-
...p ? { role: p } : {},
|
|
32
|
-
...m ? { ariaLabel: m } : {},
|
|
33
|
-
...h ? { text: h } : {},
|
|
34
|
-
rect: {
|
|
35
|
-
top: a.top,
|
|
36
|
-
left: a.left,
|
|
37
|
-
width: a.width,
|
|
38
|
-
height: a.height
|
|
39
|
-
},
|
|
40
|
-
...g ? { htmlPreview: g } : {},
|
|
41
|
-
...c ? { selector: c } : {},
|
|
42
|
-
...d ? { xpath: d } : {},
|
|
43
|
-
...t ? {
|
|
44
|
-
source: b(t),
|
|
45
|
-
stack: n.map(b)
|
|
46
|
-
} : {},
|
|
47
|
-
...i ? { componentName: i } : {}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function b(e) {
|
|
51
|
-
return {
|
|
52
|
-
filePath: e.filePath,
|
|
53
|
-
lineNumber: e.lineNumber,
|
|
54
|
-
columnNumber: e.columnNumber,
|
|
55
|
-
componentName: e.componentName
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function x(e) {
|
|
59
|
-
let t = `${r(e.filePath, 2e3)}${e.lineNumber === null ? "" : `:${e.lineNumber}`}${e.columnNumber === null ? "" : `:${e.columnNumber}`}`;
|
|
60
|
-
return e.componentName ? `${r(e.componentName, 300)} (${t})` : t;
|
|
61
|
-
}
|
|
62
|
-
function S(e, t, n, a, o, s) {
|
|
63
|
-
let c = [
|
|
64
|
-
"# CommentKit Element Grab",
|
|
65
|
-
"",
|
|
66
|
-
i,
|
|
67
|
-
""
|
|
68
|
-
], l = r(t.tagName ?? "element", 100), u = t.id ? `#${r(t.id, 300)}` : "";
|
|
69
|
-
if (c.push(`**Tag:** \`${l}${u}\``), o && c.push(`**Comment:** ${o}`), s.length > 0) {
|
|
70
|
-
c.push("", "**Attachments:**");
|
|
71
|
-
for (let e of s) {
|
|
72
|
-
let t = [
|
|
73
|
-
e.type ? `type: \`${e.type}\`` : null,
|
|
74
|
-
typeof e.size == "number" ? `size: ${e.size} bytes` : null,
|
|
75
|
-
e.pathSource ? `path source: ${e.pathSource}` : null
|
|
76
|
-
].filter(Boolean).join(", ");
|
|
77
|
-
c.push(`- \`${e.name}\` - path: \`${e.path}\`${t ? ` (${t})` : ""}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (t.componentName && c.push(`**Component:** \`${r(t.componentName, 300)}\``), t.source && c.push(`**Source:** ${x(t.source)}`), t.stack && t.stack.length > 1) {
|
|
81
|
-
c.push("", "**Stack:**");
|
|
82
|
-
for (let e of t.stack) c.push(`- ${x(e)}`);
|
|
83
|
-
}
|
|
84
|
-
return t.source || (t.selector && c.push(`**Selector:** \`${r(t.selector, 2e3)}\``), t.xpath && c.push(`**XPath:** \`${r(t.xpath, 2e3)}\``)), c.push(`**Page:** ${r(e.title || "Untitled", 300)} — ${r(e.url || e.path, 4e3)}`), c.push(""), c.push("**HTML:**", "```html", n, "```", ""), a && c.push("**Screenshot:** captured. If no image accompanies this paste, attach it from the export preview.", ""), c.join("\n");
|
|
85
|
-
}
|
|
86
|
-
function C(e) {
|
|
87
|
-
let t = e.element;
|
|
88
|
-
return {
|
|
89
|
-
tagName: t.tagName,
|
|
90
|
-
id: t.id,
|
|
91
|
-
className: t.className,
|
|
92
|
-
textContent: t.text,
|
|
93
|
-
componentName: t.componentName,
|
|
94
|
-
filePath: t.source?.filePath,
|
|
95
|
-
lineNumber: t.source?.lineNumber ?? void 0,
|
|
96
|
-
columnNumber: t.source?.columnNumber ?? void 0,
|
|
97
|
-
comment: e.comment ?? void 0,
|
|
98
|
-
attachments: e.attachments,
|
|
99
|
-
selector: t.selector,
|
|
100
|
-
xpath: t.xpath
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function w(e) {
|
|
104
|
-
if (typeof window > "u" || typeof window.dispatchEvent != "function") return;
|
|
105
|
-
let t = e[0];
|
|
106
|
-
t && window.dispatchEvent(new CustomEvent("commentkit:element-selected", { detail: {
|
|
107
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
108
|
-
page: t.page,
|
|
109
|
-
elements: e.map(C)
|
|
110
|
-
} }));
|
|
111
|
-
}
|
|
112
|
-
async function T(i, o, s, u) {
|
|
113
|
-
if (!i || typeof Element > "u" || !(i instanceof Element) || typeof i.getBoundingClientRect != "function") return null;
|
|
114
|
-
let d = (v(i), i), f = await t(i), p = f?.source ?? null, m = f?.stack ?? [], h = f?.componentName ?? null, b = await a(o, s, d, { reportErrors: !1 }), x = b?.dataUrl ?? null, C = b?.blob ?? null, T = y(i, p, m, h), E = T.htmlPreview ?? r(i.outerHTML, l), D = c(), O = g(u), k = _(u), A = S({
|
|
115
|
-
url: D.url,
|
|
116
|
-
path: D.path,
|
|
117
|
-
title: D.title
|
|
118
|
-
}, T, E, x, O, k);
|
|
119
|
-
try {
|
|
120
|
-
C ? await e(A, C) : await n(A);
|
|
121
|
-
} catch {}
|
|
122
|
-
let j = {
|
|
123
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
124
|
-
page: {
|
|
125
|
-
url: D.url,
|
|
126
|
-
path: D.path,
|
|
127
|
-
title: D.title
|
|
128
|
-
},
|
|
129
|
-
element: T,
|
|
130
|
-
comment: O,
|
|
131
|
-
attachments: k,
|
|
132
|
-
html: E,
|
|
133
|
-
screenshotDataUrl: x,
|
|
134
|
-
markdown: A
|
|
135
|
-
};
|
|
136
|
-
return w([j]), j;
|
|
137
|
-
}
|
|
138
|
-
function E(e, t, n, a) {
|
|
139
|
-
let o = [
|
|
140
|
-
"# CommentKit Element Grab",
|
|
141
|
-
"",
|
|
142
|
-
i,
|
|
143
|
-
"",
|
|
144
|
-
`**Elements:** ${t.length}`,
|
|
145
|
-
`**Page:** ${r(e.title || "Untitled", 300)} — ${r(e.url || e.path, 4e3)}`
|
|
146
|
-
];
|
|
147
|
-
if (n && o.push(`**Comment:** ${n}`), a.length > 0) {
|
|
148
|
-
o.push("", "**Attachments:**");
|
|
149
|
-
for (let e of a) o.push(`- \`${e.name}\` - path: \`${e.path}\`${e.pathSource ? ` (path source: ${e.pathSource})` : ""}`);
|
|
150
|
-
}
|
|
151
|
-
return o.push(""), t.forEach((e, t) => {
|
|
152
|
-
let { element: n } = e, i = r(n.tagName ?? "element", 100), a = n.id ? `#${r(n.id, 300)}` : "";
|
|
153
|
-
o.push(`## [${t + 1}] \`${i}${a}\``), n.componentName && o.push(`- Component: \`${r(n.componentName, 300)}\``), n.source && o.push(`- Source: ${x(n.source)}`), n.stack && n.stack.length > 1 && o.push(`- Stack: ${n.stack.map((e) => r(e.componentName ?? e.filePath, 2e3)).join(" → ")}`), n.source || (n.selector && o.push(`- Selector: \`${r(n.selector, 2e3)}\``), n.xpath && o.push(`- XPath: \`${r(n.xpath, 2e3)}\``)), o.push("", "```html", e.html, "```", ""), e.screenshotDataUrl && o.push(``, "");
|
|
154
|
-
}), o.join("\n");
|
|
155
|
-
}
|
|
156
|
-
async function D(e, i, o, s) {
|
|
157
|
-
let u = e.filter((e) => !!e && typeof Element < "u" && e instanceof Element && typeof e.getBoundingClientRect == "function");
|
|
158
|
-
if (u.length === 0) return null;
|
|
159
|
-
let d = u.slice(0, m);
|
|
160
|
-
u.length > m && typeof console < "u" && console.warn(`[CommentKit] grabElements was called with ${u.length} elements — capped to ${m} for clipboard size. Pass fewer elements to avoid truncation.`);
|
|
161
|
-
let f = [], p = 0, b = 0, x = g(s), C = _(s);
|
|
162
|
-
for (let e of d) {
|
|
163
|
-
let n = (v(e), e), s = await t(e), u = s?.source ?? null, d = s?.stack ?? [], m = s?.componentName ?? null, g = null;
|
|
164
|
-
if (p < h) {
|
|
165
|
-
let e = (await a(i, o, n, { reportErrors: !1 }))?.dataUrl ?? null;
|
|
166
|
-
e && p + e.length <= h ? (g = e, p += e.length) : e && b++;
|
|
167
|
-
} else b++;
|
|
168
|
-
let _ = y(e, u, d, m), w = _.htmlPreview ?? r(e.outerHTML, l), T = c(), E = S({
|
|
169
|
-
url: T.url,
|
|
170
|
-
path: T.path,
|
|
171
|
-
title: T.title
|
|
172
|
-
}, _, w, g, x, C);
|
|
173
|
-
f.push({
|
|
174
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
175
|
-
page: {
|
|
176
|
-
url: T.url,
|
|
177
|
-
path: T.path,
|
|
178
|
-
title: T.title
|
|
179
|
-
},
|
|
180
|
-
element: _,
|
|
181
|
-
comment: x,
|
|
182
|
-
attachments: C,
|
|
183
|
-
html: w,
|
|
184
|
-
screenshotDataUrl: g,
|
|
185
|
-
markdown: E
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
b > 0 && typeof console < "u" && console.warn(`[CommentKit] grabElements dropped ${b} screenshot${b === 1 ? "" : "s"} to stay under the ${Math.round(h / 1024 / 1024)}MB clipboard budget.`);
|
|
189
|
-
let T = c(), D = E({
|
|
190
|
-
url: T.url,
|
|
191
|
-
path: T.path,
|
|
192
|
-
title: T.title
|
|
193
|
-
}, f, x, C);
|
|
194
|
-
try {
|
|
195
|
-
await n(D);
|
|
196
|
-
} catch {}
|
|
197
|
-
let O = {
|
|
198
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
199
|
-
page: {
|
|
200
|
-
url: T.url,
|
|
201
|
-
path: T.path,
|
|
202
|
-
title: T.title
|
|
203
|
-
},
|
|
204
|
-
results: f,
|
|
205
|
-
attachments: C,
|
|
206
|
-
markdown: D
|
|
207
|
-
};
|
|
208
|
-
return w(f), O;
|
|
209
|
-
}
|
|
210
|
-
export { T as grabElement, D as grabElements };
|
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import { i as e, n as t, r as n, t as r } from "./websocket-manager-CFak_YHy.js";
|
|
2
|
-
import { a as i, c as a, i as o, l as s, o as c } from "./validation-D-8u4M7I.js";
|
|
3
|
-
import { i as l } from "./comment-kit-core-C862uNAm.js";
|
|
4
|
-
import { o as u } from "./dom-Bhf4WFtY.js";
|
|
5
|
-
var d = l.ID, f = l.CONTENT, p = l.NAME, m = l.EMAIL, h = l.PAGE, g = l.EMOJI, _ = l.ONLINE_USERS, v = l.REACTION_COUNT, y = 33, b = 1e3, x = l.CURSOR_EMITS_PER_SEC;
|
|
6
|
-
function S(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), _) : l.RENDERED_CURSORS
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
var C = /* @__PURE__ */ new Set([
|
|
15
|
-
"pin",
|
|
16
|
-
"highlight",
|
|
17
|
-
"drawing"
|
|
18
|
-
]), w = /* @__PURE__ */ new Set([
|
|
19
|
-
"open",
|
|
20
|
-
"resolved",
|
|
21
|
-
"complete"
|
|
22
|
-
]), T = /* @__PURE__ */ new Set([
|
|
23
|
-
"low",
|
|
24
|
-
"medium",
|
|
25
|
-
"high",
|
|
26
|
-
"urgent"
|
|
27
|
-
]), E = /* @__PURE__ */ new Set([
|
|
28
|
-
"path",
|
|
29
|
-
"line",
|
|
30
|
-
"rectangle",
|
|
31
|
-
"circle",
|
|
32
|
-
"text"
|
|
33
|
-
]);
|
|
34
|
-
function D(e, t) {
|
|
35
|
-
return a(e, t);
|
|
36
|
-
}
|
|
37
|
-
function O(e) {
|
|
38
|
-
return D(e, d);
|
|
39
|
-
}
|
|
40
|
-
function k(e) {
|
|
41
|
-
if (!D(e, m)) 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 A(e) {
|
|
46
|
-
return c(e) && O(e.id) && D(e.name, p) && k(e.email) && s(e.avatar, h) && s(e.organizationId, d);
|
|
47
|
-
}
|
|
48
|
-
function j(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 M(t) {
|
|
58
|
-
if (!Array.isArray(t)) return null;
|
|
59
|
-
let n = [], r = /* @__PURE__ */ new Set();
|
|
60
|
-
for (let i of t) {
|
|
61
|
-
if (n.length >= _) break;
|
|
62
|
-
let t = e(i);
|
|
63
|
-
if (!A(t)) continue;
|
|
64
|
-
let a = j(t);
|
|
65
|
-
r.has(a.id) || (r.add(a.id), n.push(a));
|
|
66
|
-
}
|
|
67
|
-
return n;
|
|
68
|
-
}
|
|
69
|
-
function N(e) {
|
|
70
|
-
return c(e) ? i(e.x) && i(e.y) : !1;
|
|
71
|
-
}
|
|
72
|
-
function P(e) {
|
|
73
|
-
return c(e) && D(e.url, h) && D(e.path, h) && typeof e.title == "string" && s(e.title, h);
|
|
74
|
-
}
|
|
75
|
-
function F(e) {
|
|
76
|
-
return c(e) && H(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= v && typeof e.reacted == "boolean";
|
|
77
|
-
}
|
|
78
|
-
function I(e, t) {
|
|
79
|
-
if (Array.isArray(e)) return e.filter(F).map((e) => {
|
|
80
|
-
if (!Array.isArray(e.userIds)) return e;
|
|
81
|
-
let n = e.userIds.filter(O);
|
|
82
|
-
return {
|
|
83
|
-
...e,
|
|
84
|
-
userIds: n,
|
|
85
|
-
reacted: !!t && n.includes(t)
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function L(e, t) {
|
|
90
|
-
return {
|
|
91
|
-
...e,
|
|
92
|
-
replies: Array.isArray(e.replies) ? e.replies.flatMap((e) => {
|
|
93
|
-
let n = z(e, t);
|
|
94
|
-
return n ? [n] : [];
|
|
95
|
-
}) : [],
|
|
96
|
-
...e.reactions === void 0 ? {} : { reactions: I(e.reactions, t) }
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function R(e, n) {
|
|
100
|
-
return e = t(e), !c(e) || !O(e.id) || !C.has(e.type) || !D(e.content, f) || !N(e.position) || !w.has(e.status) || !T.has(e.priority) || !A(e.author) || !O(e.userId) || !D(e.createdAt, h) || !D(e.updatedAt, h) || !P(e.page) || !Array.isArray(e.replies) || !Array.isArray(e.attachments) ? null : L(structuredClone(e), n);
|
|
101
|
-
}
|
|
102
|
-
function z(e, t) {
|
|
103
|
-
if (e = n(e), !c(e) || !O(e.id) || !D(e.content, f) || !A(e.author) || !D(e.createdAt, h)) return null;
|
|
104
|
-
let r = structuredClone(e);
|
|
105
|
-
return r.reactions &&= I(r.reactions, t), r;
|
|
106
|
-
}
|
|
107
|
-
function B(t) {
|
|
108
|
-
if (!c(t)) return null;
|
|
109
|
-
let n = e(t.user);
|
|
110
|
-
return !A(n) || !o(t.x) || t.x < 0 || t.x > 100 || !o(t.y) || t.y < 0 || t.y > 100 || !D(t.page, h) ? null : {
|
|
111
|
-
x: t.x,
|
|
112
|
-
y: t.y,
|
|
113
|
-
page: t.page.trim(),
|
|
114
|
-
user: j(n)
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function V(e) {
|
|
118
|
-
return c(e) ? D(e.type, l.DRAWING_TYPE) && E.has(e.type) && D(e.stroke, l.COLOR) && o(e.strokeWidth) && e.strokeWidth >= 0 && D(e.fill, l.COLOR) && s(e.d, l.DRAWING_PATH_DATA) && s(e.text, l.DRAWING_TEXT) && (e.x === void 0 || o(e.x)) && (e.y === void 0 || o(e.y)) && (e.width === void 0 || o(e.width)) && (e.height === void 0 || o(e.height)) : !1;
|
|
119
|
-
}
|
|
120
|
-
function H(e) {
|
|
121
|
-
return D(e, g);
|
|
122
|
-
}
|
|
123
|
-
function U(e) {
|
|
124
|
-
try {
|
|
125
|
-
e();
|
|
126
|
-
} catch {}
|
|
127
|
-
}
|
|
128
|
-
function W(e, t) {
|
|
129
|
-
return e.wsManager === t;
|
|
130
|
-
}
|
|
131
|
-
function G(e, t) {
|
|
132
|
-
e.setState({ comments: e.getState().comments.map((e) => e.id === t.id ? t : e) });
|
|
133
|
-
}
|
|
134
|
-
function K(t, n, i) {
|
|
135
|
-
if (t.config.features?.realtime === !1 || !t.config.reverb?.host || !t.config.reverb?.key) return;
|
|
136
|
-
if (n.wsManager) {
|
|
137
|
-
for (let e of n.wsUnsubscribers) U(e);
|
|
138
|
-
n.wsUnsubscribers = [], q(n);
|
|
139
|
-
try {
|
|
140
|
-
n.wsManager.destroy();
|
|
141
|
-
} catch {}
|
|
142
|
-
n.wsManager = null;
|
|
143
|
-
}
|
|
144
|
-
let a = t.config.baseUrl || "https://api.commentkit.dev/api", o = t.getState().currentUser, s = S(t);
|
|
145
|
-
try {
|
|
146
|
-
n.wsManager = new r({
|
|
147
|
-
key: t.config.reverb.key,
|
|
148
|
-
wsHost: t.config.reverb.host,
|
|
149
|
-
wsPort: t.config.reverb.port ?? 443,
|
|
150
|
-
forceTLS: (t.config.reverb.scheme ?? "wss") === "wss",
|
|
151
|
-
/* v8 ignore next -- projectId always provided in config */
|
|
152
|
-
projectId: t.config.projectId || "",
|
|
153
|
-
apiKey: t.config.apiKey,
|
|
154
|
-
authEndpoint: `${a}/broadcasting/auth`,
|
|
155
|
-
authorizeChannel: (e, n) => t.apiClient.authorizeChannel(e, n),
|
|
156
|
-
userEmail: o?.email,
|
|
157
|
-
userInfo: o ? {
|
|
158
|
-
id: o.id,
|
|
159
|
-
name: o.name,
|
|
160
|
-
email: o.email
|
|
161
|
-
} : void 0
|
|
162
|
-
});
|
|
163
|
-
} catch (e) {
|
|
164
|
-
t.setState({ connectionStatus: "error" }), t.handleError(e);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
let l = n.wsUnsubscribers, d = n.wsManager, f, p, m = !1, h = () => p ??= import("./realtime-recovery-DJ_adc-H.js").then((e) => {
|
|
168
|
-
if (!m && i && W(n, d)) return f = e.createRealtimeRecovery(t, i, () => W(n, d), R), f;
|
|
169
|
-
}).catch((e) => {
|
|
170
|
-
p = void 0, m || t.handleError(e);
|
|
171
|
-
});
|
|
172
|
-
l.push(() => {
|
|
173
|
-
m = !0, f?.dispose();
|
|
174
|
-
}), l.push(d.on("subscribed", () => {
|
|
175
|
-
W(n, d) && i && h().then((e) => e?.refreshWindow());
|
|
176
|
-
})), l.push(d.on("comment:refresh", (e) => {
|
|
177
|
-
W(n, d) && i && h().then((t) => t?.refreshThread(e));
|
|
178
|
-
})), l.push(d.on("connected", () => {
|
|
179
|
-
W(n, d) && (t.setState({ connectionStatus: "connected" }), n.wsManager?.requestPresence());
|
|
180
|
-
})), l.push(d.on("disconnected", () => {
|
|
181
|
-
W(n, d) && t.setState({ connectionStatus: "disconnected" });
|
|
182
|
-
})), l.push(d.on("reconnecting", () => {
|
|
183
|
-
W(n, d) && t.setState({ connectionStatus: "connecting" });
|
|
184
|
-
})), l.push(d.on("error", () => {
|
|
185
|
-
W(n, d) && t.setState({ connectionStatus: "error" });
|
|
186
|
-
})), l.push(d.on("comment:resolved", (e) => {
|
|
187
|
-
if (!W(n, d)) return;
|
|
188
|
-
let r = R(e, t.getState().currentUser?.id);
|
|
189
|
-
r && (G(t, r), t.emit("comment:resolved", r));
|
|
190
|
-
})), l.push(d.on("comment:completed", (e) => {
|
|
191
|
-
if (!W(n, d)) return;
|
|
192
|
-
let r = R(e, t.getState().currentUser?.id);
|
|
193
|
-
r && (G(t, r), t.emit("comment:completed", r));
|
|
194
|
-
})), l.push(d.on("comment:created", (e) => {
|
|
195
|
-
if (!W(n, d)) return;
|
|
196
|
-
let r = R(e, t.getState().currentUser?.id);
|
|
197
|
-
if (!r) return;
|
|
198
|
-
let i = t.getState().activeBranch;
|
|
199
|
-
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));
|
|
200
|
-
})), l.push(d.on("comment:updated", (e) => {
|
|
201
|
-
if (!W(n, d)) return;
|
|
202
|
-
let r = R(e, t.getState().currentUser?.id);
|
|
203
|
-
r && (G(t, r), t.emit("comment:updated", r));
|
|
204
|
-
})), l.push(d.on("comment:deleted", (e) => {
|
|
205
|
-
if (!W(n, d) || !c(e) || !O(e.id)) return;
|
|
206
|
-
let r = e.id.trim();
|
|
207
|
-
t.setState({
|
|
208
|
-
comments: t.getState().comments.filter((e) => e.id !== r),
|
|
209
|
-
selectedComment: t.getState().selectedComment?.id === r ? null : t.getState().selectedComment
|
|
210
|
-
}), t.emit("comment:deleted", { id: r });
|
|
211
|
-
})), l.push(d.on("reply:added", (e) => {
|
|
212
|
-
if (!W(n, d) || !c(e) || !O(e.commentId)) return;
|
|
213
|
-
let r = z(e.reply, t.getState().currentUser?.id);
|
|
214
|
-
if (!r) return;
|
|
215
|
-
let i = e.commentId.trim(), a = t.getState().comments.map((e) => e.id !== i || e.replies.some((e) => e.id === r.id) ? e : {
|
|
216
|
-
...e,
|
|
217
|
-
status: "open",
|
|
218
|
-
resolvedAt: void 0,
|
|
219
|
-
completedAt: void 0,
|
|
220
|
-
replies: [...e.replies, r]
|
|
221
|
-
});
|
|
222
|
-
t.setState({ comments: a });
|
|
223
|
-
let o = a.find((e) => e.id === i);
|
|
224
|
-
o && t.emit("comment:updated", o);
|
|
225
|
-
}));
|
|
226
|
-
let g = (e, t, n) => {
|
|
227
|
-
let r = (e ?? []).filter((e) => H(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= v), i = r.findIndex((e) => e.emoji === t);
|
|
228
|
-
if (i !== -1) {
|
|
229
|
-
let e = r[i];
|
|
230
|
-
r[i] = n ? {
|
|
231
|
-
...e,
|
|
232
|
-
reacted: !0
|
|
233
|
-
} : {
|
|
234
|
-
...e,
|
|
235
|
-
count: Math.min(e.count + 1, v),
|
|
236
|
-
reacted: e.reacted
|
|
237
|
-
};
|
|
238
|
-
} else r.push({
|
|
239
|
-
emoji: t,
|
|
240
|
-
count: 1,
|
|
241
|
-
reacted: n
|
|
242
|
-
});
|
|
243
|
-
return r;
|
|
244
|
-
}, _ = (e, t, n) => (e ?? []).filter((e) => H(e.emoji) && Number.isInteger(e.count) && e.count > 0 && e.count <= v).map((e) => e.emoji === t ? {
|
|
245
|
-
...e,
|
|
246
|
-
count: n ? e.count : e.count - 1,
|
|
247
|
-
reacted: !n && e.reacted
|
|
248
|
-
} : e).filter((e) => e.count > 0), C = (e, r) => {
|
|
249
|
-
if (!W(n, d) || !c(e) || !O(e.commentId) || !H(e.emoji) || !O(e.userId)) return;
|
|
250
|
-
let i = e.commentId.trim(), a = O(e.replyId) ? e.replyId.trim() : null, o = e.emoji.trim(), s = e.userId.trim() === t.getState().currentUser?.id;
|
|
251
|
-
t.setState({ comments: t.getState().comments.map((e) => e.id === i ? a === null ? {
|
|
252
|
-
...e,
|
|
253
|
-
reactions: r(e.reactions, o, s)
|
|
254
|
-
} : {
|
|
255
|
-
...e,
|
|
256
|
-
replies: e.replies.map((e) => e.id === a ? {
|
|
257
|
-
...e,
|
|
258
|
-
reactions: r(e.reactions, o, s)
|
|
259
|
-
} : e)
|
|
260
|
-
} : e) });
|
|
261
|
-
};
|
|
262
|
-
l.push(d.on("reaction:added", (e) => C(e, g))), l.push(d.on("reaction:removed", (e) => C(e, _)));
|
|
263
|
-
let w = /* @__PURE__ */ new Map(), T = 0, E = 0;
|
|
264
|
-
l.push(d.on("cursor:move", (e) => {
|
|
265
|
-
if (!W(n, d) || !s.cursors) return;
|
|
266
|
-
let r = B(e);
|
|
267
|
-
if (!r) return;
|
|
268
|
-
let i = Date.now(), a = r.user.id, o = w.get(a);
|
|
269
|
-
if (o === void 0 && w.size >= s.maxRenderedCursors) {
|
|
270
|
-
let e, t = Infinity;
|
|
271
|
-
for (let [n, r] of w) r < t && (t = r, e = n);
|
|
272
|
-
if (e !== void 0 && i - t >= y) w.delete(e);
|
|
273
|
-
else return;
|
|
274
|
-
}
|
|
275
|
-
o !== void 0 && i - o < y || (i - T >= b && (T = i, E = 0), !(E >= x) && (E++, w.set(a, i), t.emit("cursor:move", r)));
|
|
276
|
-
})), l.push(d.on("cursor:leave", (e) => {
|
|
277
|
-
W(n, d) && c(e) && O(e.userId) && (w.delete(e.userId.trim()), t.emit("cursor:leave", { userId: e.userId.trim() }));
|
|
278
|
-
})), l.push(d.on("user:joined", (r) => {
|
|
279
|
-
let i = e(r);
|
|
280
|
-
W(n, d) && A(i) && t.emit("user:joined", j(i));
|
|
281
|
-
})), l.push(d.on("user:left", (e) => {
|
|
282
|
-
W(n, d) && c(e) && O(e.userId) && t.emit("user:left", { userId: e.userId.trim() });
|
|
283
|
-
})), l.push(d.on("presence:update", (e) => {
|
|
284
|
-
if (!W(n, d) || !s.presence || !c(e)) return;
|
|
285
|
-
let r = M(e.users);
|
|
286
|
-
if (!r) return;
|
|
287
|
-
let i = { users: r };
|
|
288
|
-
t.setState({ onlineUsers: r }), t.emit("presence:update", i);
|
|
289
|
-
})), l.push(d.on("drawing:stroke", (e) => {
|
|
290
|
-
W(n, d) && c(e) && O(e.userId) && V(e.path) && t.emit("drawing:stroke", {
|
|
291
|
-
userId: e.userId.trim(),
|
|
292
|
-
path: structuredClone(e.path)
|
|
293
|
-
});
|
|
294
|
-
}));
|
|
295
|
-
try {
|
|
296
|
-
t.setState({ connectionStatus: "connecting" });
|
|
297
|
-
let e = d.connect();
|
|
298
|
-
e && typeof e.catch == "function" && e.catch((e) => {
|
|
299
|
-
t.setState({ connectionStatus: "error" }), t.handleError(e);
|
|
300
|
-
});
|
|
301
|
-
} catch (e) {
|
|
302
|
-
t.setState({ connectionStatus: "error" }), t.handleError(e);
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
/* v8 ignore next -- SSR guard unreachable in jsdom */
|
|
306
|
-
typeof document < "u" && typeof window < "u" && s.cursors && (n.mouseMoveHandler = (e) => {
|
|
307
|
-
if (t.getState().isOverlayVisible && n.wsManager?.isConnected()) {
|
|
308
|
-
if (window.innerWidth <= 0 || window.innerHeight <= 0) return;
|
|
309
|
-
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));
|
|
310
|
-
n.wsManager.sendCursorMove(t, r, u().url);
|
|
311
|
-
}
|
|
312
|
-
}, document.addEventListener("mousemove", n.mouseMoveHandler));
|
|
313
|
-
}
|
|
314
|
-
function q(e) {
|
|
315
|
-
typeof window < "u" && typeof document < "u" && e.mouseMoveHandler && (document.removeEventListener("mousemove", e.mouseMoveHandler), e.mouseMoveHandler = null);
|
|
316
|
-
}
|
|
317
|
-
export { K as initializeWebSocket, q as removeMouseMoveListener };
|