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