@commentkit/comment-kit 0.6.9 → 0.7.0

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 (62) hide show
  1. package/CHANGELOG.md +36 -4
  2. package/LICENSE +18 -2
  3. package/README.md +133 -88
  4. package/SECURITY.md +48 -0
  5. package/dist/THIRD_PARTY_NOTICES.txt +284 -0
  6. package/dist/angular.es.js +25 -12
  7. package/dist/comment-kit.es.js +23 -11
  8. package/dist/demo.es.js +146 -69
  9. package/dist/headless.es.js +2 -2
  10. package/dist/preact.es.js +3 -3
  11. package/dist/qwik.es.js +1 -110
  12. package/dist/qwik.qwik.mjs +114 -0
  13. package/dist/react.es.js +3 -3
  14. package/dist/shared/annotation-icons-Dh-bmNYK.js +172 -0
  15. package/dist/shared/annotation-toolbar-B9SxYqoF.js +1093 -0
  16. package/dist/shared/{bridge-DRE03N9X.js → bridge-CJoGYngu.js} +6 -3
  17. package/dist/shared/{button-group-CHfMRXyA.js → button-group-Cl9CrvvU.js} +1 -1
  18. package/dist/shared/comment-drawing-canvas-Dzb5YoFw.js +124 -0
  19. package/dist/shared/{comment-image-lightbox-0VdAs2iT.js → comment-image-lightbox-BPYJT1sB.js} +62 -57
  20. package/dist/shared/{comment-kit-core-D0kY00St.js → comment-kit-core-BaSuMzp9.js} +1027 -729
  21. package/dist/shared/comment-kit-ui-CzfdAZs2.js +20181 -0
  22. package/dist/shared/comment-screenshot-annotator-C7X-_bm6.js +151 -0
  23. package/dist/shared/comment-screenshot-overlay-wIrZrcRy.js +206 -0
  24. package/dist/shared/comment-utils-BycYTSxA.js +602 -0
  25. package/dist/shared/{dev-export-panel-BLngcr5q.js → dev-export-panel-FwFVdady.js} +8 -8
  26. package/dist/shared/{dev-grab-pDAfH2lr.js → dev-grab-DDqg0LQf.js} +1 -1
  27. package/dist/shared/dist-De294MVF.js +623 -0
  28. package/dist/shared/{element-selector-CtFzgHvq.js → element-selector-BhJm-NSs.js} +294 -288
  29. package/dist/shared/{icons-BSHCWYO1.js → icons-nzMOLzrm.js} +2 -3
  30. package/dist/shared/{mount-ui-CVivB_eQ.js → mount-ui--ijs8pWT.js} +4 -4
  31. package/dist/shared/{pusher-BEl7Qn-8.js → pusher-ipHMJnO_.js} +1 -1
  32. package/dist/shared/{realtime-BG_t_ze7.js → realtime-Dk41VwKg.js} +71 -50
  33. package/dist/shared/{separator-DusFNTs-.js → separator-XDBsaWyw.js} +891 -785
  34. package/dist/shared/{shadow-root-CmYXiSRR.js → shadow-root-C5v-T8lQ.js} +1 -1
  35. package/dist/shared/styles-D3yMtaec.js +2 -0
  36. package/dist/shared/{useValueChanged-DQXLia-2.js → useValueChanged-CrzfD8l-.js} +15 -15
  37. package/dist/shared/{websocket-manager-BTRqNTB7.js → websocket-manager-DhLWh3Jr.js} +2 -2
  38. package/dist/solid.es.js +3 -3
  39. package/dist/svelte.es.js +3 -3
  40. package/dist/types/adapters/bridge.d.ts +9 -12
  41. package/dist/types/angular/index.d.ts +15 -5
  42. package/dist/types/core/api-client.d.ts +16 -17
  43. package/dist/types/core/comment-kit-core.d.ts +19 -11
  44. package/dist/types/core/local-demo.d.ts +1 -0
  45. package/dist/types/core/types.d.ts +68 -0
  46. package/dist/types/headless.d.ts +1 -1
  47. package/dist/types/index.d.ts +8 -4
  48. package/dist/types/qwik/index.d.ts +4 -1
  49. package/dist/vue.es.js +3 -3
  50. package/docs/api-reference.md +372 -0
  51. package/docs/local-demo.md +60 -0
  52. package/package.json +16 -6
  53. package/dist/shared/annotation-toolbar-pX17NLmJ.js +0 -1104
  54. package/dist/shared/clamp-CcFVX0vC.js +0 -55
  55. package/dist/shared/comment-drawing-canvas-CYu5SwRf.js +0 -126
  56. package/dist/shared/comment-kit-ui-D2j2gvnm.js +0 -16685
  57. package/dist/shared/comment-screenshot-annotator-BuojwviY.js +0 -137
  58. package/dist/shared/comment-screenshot-overlay-BZX0Vcb8.js +0 -144
  59. package/dist/shared/local-demo-context-BohlYbHt.js +0 -6
  60. package/dist/shared/resolveAriaLabelledBy-CIKpnjNJ.js +0 -669
  61. package/dist/shared/styles-D_FEJZ9G.js +0 -2
  62. package/dist/shared/useLabelableId-DGbfdMi_.js +0 -155
@@ -248,8 +248,7 @@ var m = n("MultiplicationSignCircleIcon", [["path", {
248
248
  strokeWidth: "1.5",
249
249
  key: "7"
250
250
  }]
251
- ]);
252
- n("ArrowDown02Icon", [["path", {
251
+ ]), g = n("ArrowDown02Icon", [["path", {
253
252
  d: "M12 18.502V5.00195",
254
253
  stroke: "currentColor",
255
254
  strokeLinecap: "round",
@@ -264,4 +263,4 @@ n("ArrowDown02Icon", [["path", {
264
263
  strokeWidth: "1.5",
265
264
  key: "1"
266
265
  }]]);
267
- export { a, o as c, i as d, s as f, l as i, f as l, p as n, c as o, u as p, r, d as s, m as t, h as u };
266
+ export { l as a, d as c, h as d, i as f, r as i, o as l, u as m, p as n, a as o, s as p, g as r, c as s, m as t, f as u };
@@ -1,4 +1,4 @@
1
- import { r as e } from "./websocket-manager-BTRqNTB7.js";
1
+ import { r as e } from "./websocket-manager-DhLWh3Jr.js";
2
2
  import { n as t } from "./errors-Bu5ajEmB.js";
3
3
  var n = null, r = /* @__PURE__ */ new Set();
4
4
  function i() {
@@ -134,10 +134,10 @@ async function y(e, n = {}) {
134
134
  let [t, r, c, l, u, f] = await Promise.all([
135
135
  import("react"),
136
136
  import("react-dom/client"),
137
- import("./styles-D_FEJZ9G.js"),
138
- import("./shadow-root-CmYXiSRR.js"),
137
+ import("./styles-D3yMtaec.js"),
138
+ import("./shadow-root-C5v-T8lQ.js"),
139
139
  import("./error-boundary-D3PD74vI.js"),
140
- import("./comment-kit-ui-D2j2gvnm.js").then((e) => e.t)
140
+ import("./comment-kit-ui-CzfdAZs2.js").then((e) => e.t)
141
141
  ]);
142
142
  if (!s || n !== b) return;
143
143
  let p = h(t, "createElement"), g = h(r, "createRoot"), _ = l.ShadowContainer, v = u.ErrorBoundary;
@@ -1,4 +1,4 @@
1
- import { n as e } from "./websocket-manager-BTRqNTB7.js";
1
+ import { n as e } from "./websocket-manager-DhLWh3Jr.js";
2
2
  var t = /* @__PURE__ */ e(((e, t) => {
3
3
  (function(n, r) {
4
4
  typeof e == "object" && typeof t == "object" ? t.exports = r() : typeof define == "function" && define.amd ? define([], r) : typeof e == "object" ? e.Pusher = r() : n.Pusher = r();
@@ -1,6 +1,6 @@
1
- import { t as e } from "./websocket-manager-BTRqNTB7.js";
1
+ import { t as e } from "./websocket-manager-DhLWh3Jr.js";
2
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";
3
+ import { i as o } from "./comment-kit-core-BaSuMzp9.js";
4
4
  import { o as s } from "./dom-Bhf4WFtY.js";
5
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
6
  function y(e) {
@@ -72,22 +72,38 @@ function j(e) {
72
72
  return i(e) && w(e.url, f) && w(e.path, f) && w(e.title, f);
73
73
  }
74
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";
75
+ return i(e) && z(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= h && typeof e.reacted == "boolean";
76
76
  }
77
- function N(e) {
77
+ function N(e, t) {
78
+ if (Array.isArray(e)) return e.filter(M).map((e) => {
79
+ if (!Array.isArray(e.userIds)) return e;
80
+ let n = e.userIds.filter(T);
81
+ return {
82
+ ...e,
83
+ userIds: n,
84
+ reacted: !!t && n.includes(t)
85
+ };
86
+ });
87
+ }
88
+ function P(e, t) {
78
89
  return {
79
90
  ...e,
80
- replies: Array.isArray(e.replies) ? e.replies.filter((e) => F(e) !== null) : [],
81
- ...e.reactions === void 0 ? {} : { reactions: (e.reactions ?? []).filter(M) }
91
+ replies: Array.isArray(e.replies) ? e.replies.flatMap((e) => {
92
+ let n = I(e, t);
93
+ return n ? [n] : [];
94
+ }) : [],
95
+ ...e.reactions === void 0 ? {} : { reactions: N(e.reactions, t) }
82
96
  };
83
97
  }
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));
98
+ function F(e, t) {
99
+ 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 : P(structuredClone(e), t);
86
100
  }
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);
101
+ function I(e, t) {
102
+ if (!i(e) || !T(e.id) || !w(e.content, l) || !D(e.author) || !w(e.createdAt, f)) return null;
103
+ let n = structuredClone(e);
104
+ return n.reactions &&= N(n.reactions, t), n;
89
105
  }
90
- function I(e) {
106
+ function L(e) {
91
107
  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
108
  x: e.x,
93
109
  y: e.y,
@@ -95,28 +111,28 @@ function I(e) {
95
111
  user: O(e.user)
96
112
  };
97
113
  }
98
- function L(e) {
114
+ function R(e) {
99
115
  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
116
  }
101
- function R(e) {
117
+ function z(e) {
102
118
  return w(e, p);
103
119
  }
104
- function z(e) {
120
+ function B(e) {
105
121
  try {
106
122
  e();
107
123
  } catch {}
108
124
  }
109
- function B(e, t) {
125
+ function V(e, t) {
110
126
  return e.wsManager === t;
111
127
  }
112
- function V(e, t) {
128
+ function H(e, t) {
113
129
  e.setState({ comments: e.getState().comments.map((e) => e.id === t.id ? t : e) });
114
130
  }
115
- function H(t, n) {
131
+ function U(t, n) {
116
132
  if (t.config.features?.realtime === !1 || !t.config.reverb?.host || !t.config.reverb?.key) return;
117
133
  if (n.wsManager) {
118
- for (let e of n.wsUnsubscribers) z(e);
119
- n.wsUnsubscribers = [], U(n);
134
+ for (let e of n.wsUnsubscribers) B(e);
135
+ n.wsUnsubscribers = [], W(n);
120
136
  try {
121
137
  n.wsManager.destroy();
122
138
  } catch {}
@@ -146,42 +162,47 @@ function H(t, n) {
146
162
  }
147
163
  let c = n.wsUnsubscribers, l = n.wsManager;
148
164
  c.push(l.on("connected", () => {
149
- B(n, l) && (t.setState({ connectionStatus: "connected" }), n.wsManager?.requestPresence());
165
+ V(n, l) && (t.setState({ connectionStatus: "connected" }), n.wsManager?.requestPresence());
150
166
  })), c.push(l.on("disconnected", () => {
151
- B(n, l) && t.setState({ connectionStatus: "disconnected" });
167
+ V(n, l) && t.setState({ connectionStatus: "disconnected" });
152
168
  })), c.push(l.on("reconnecting", () => {
153
- B(n, l) && t.setState({ connectionStatus: "connecting" });
169
+ V(n, l) && t.setState({ connectionStatus: "connecting" });
154
170
  })), c.push(l.on("error", () => {
155
- B(n, l) && t.setState({ connectionStatus: "error" });
171
+ V(n, l) && t.setState({ connectionStatus: "error" });
156
172
  })), 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));
173
+ if (!V(n, l)) return;
174
+ let r = F(e, t.getState().currentUser?.id);
175
+ r && (H(t, r), t.emit("comment:resolved", r));
160
176
  })), 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));
177
+ if (!V(n, l)) return;
178
+ let r = F(e, t.getState().currentUser?.id);
179
+ r && (H(t, r), t.emit("comment:completed", r));
164
180
  })), 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)));
181
+ if (!V(n, l)) return;
182
+ let r = F(e, t.getState().currentUser?.id);
183
+ if (!r) return;
184
+ let i = t.getState().activeBranch;
185
+ 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));
168
186
  })), 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));
187
+ if (!V(n, l)) return;
188
+ let r = F(e, t.getState().currentUser?.id);
189
+ r && (H(t, r), t.emit("comment:updated", r));
172
190
  })), c.push(l.on("comment:deleted", (e) => {
173
- if (!B(n, l) || !i(e) || !T(e.id)) return;
191
+ if (!V(n, l) || !i(e) || !T(e.id)) return;
174
192
  let r = e.id.trim();
175
193
  t.setState({
176
194
  comments: t.getState().comments.filter((e) => e.id !== r),
177
195
  selectedComment: t.getState().selectedComment?.id === r ? null : t.getState().selectedComment
178
196
  }), t.emit("comment:deleted", { id: r });
179
197
  })), c.push(l.on("reply:added", (e) => {
180
- if (!B(n, l) || !i(e) || !T(e.commentId)) return;
181
- let r = F(e.reply);
198
+ if (!V(n, l) || !i(e) || !T(e.commentId)) return;
199
+ let r = I(e.reply, t.getState().currentUser?.id);
182
200
  if (!r) return;
183
201
  let a = e.commentId.trim(), o = t.getState().comments.map((e) => e.id !== a || e.replies.some((e) => e.id === r.id) ? e : {
184
202
  ...e,
203
+ status: "open",
204
+ resolvedAt: void 0,
205
+ completedAt: void 0,
185
206
  replies: [...e.replies, r]
186
207
  });
187
208
  t.setState({ comments: o });
@@ -189,7 +210,7 @@ function H(t, n) {
189
210
  s && t.emit("comment:updated", s);
190
211
  }));
191
212
  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);
213
+ let r = (e ?? []).filter((e) => z(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= h), i = r.findIndex((e) => e.emoji === t);
193
214
  if (i !== -1) {
194
215
  let e = r[i];
195
216
  r[i] = n ? {
@@ -206,12 +227,12 @@ function H(t, n) {
206
227
  reacted: n
207
228
  });
208
229
  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 ? {
230
+ }, d = (e, t, n) => (e ?? []).filter((e) => z(e.emoji) && Number.isInteger(e.count) && e.count > 0 && e.count <= h).map((e) => e.emoji === t ? {
210
231
  ...e,
211
232
  count: n ? e.count : e.count - 1,
212
233
  reacted: !n && e.reacted
213
234
  } : 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;
235
+ if (!V(n, l) || !i(e) || !T(e.commentId) || !z(e.emoji) || !T(e.userId)) return;
215
236
  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
237
  t.setState({ comments: t.getState().comments.map((e) => e.id === a ? o === null ? {
217
238
  ...e,
@@ -227,8 +248,8 @@ function H(t, n) {
227
248
  c.push(l.on("reaction:added", (e) => f(e, u))), c.push(l.on("reaction:removed", (e) => f(e, d)));
228
249
  let p = /* @__PURE__ */ new Map(), m = 0, b = 0;
229
250
  c.push(l.on("cursor:move", (e) => {
230
- if (!B(n, l) || !o.cursors) return;
231
- let r = I(e);
251
+ if (!V(n, l) || !o.cursors) return;
252
+ let r = L(e);
232
253
  if (!r) return;
233
254
  let i = Date.now(), a = r.user.id, s = p.get(a);
234
255
  if (s === void 0 && p.size >= o.maxRenderedCursors) {
@@ -239,19 +260,19 @@ function H(t, n) {
239
260
  }
240
261
  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
262
  })), 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() }));
263
+ V(n, l) && i(e) && T(e.userId) && (p.delete(e.userId.trim()), t.emit("cursor:leave", { userId: e.userId.trim() }));
243
264
  })), c.push(l.on("user:joined", (e) => {
244
- B(n, l) && D(e) && t.emit("user:joined", O(e));
265
+ V(n, l) && D(e) && t.emit("user:joined", O(e));
245
266
  })), c.push(l.on("user:left", (e) => {
246
- B(n, l) && i(e) && T(e.userId) && t.emit("user:left", { userId: e.userId.trim() });
267
+ V(n, l) && i(e) && T(e.userId) && t.emit("user:left", { userId: e.userId.trim() });
247
268
  })), c.push(l.on("presence:update", (e) => {
248
- if (!B(n, l) || !o.presence || !i(e)) return;
269
+ if (!V(n, l) || !o.presence || !i(e)) return;
249
270
  let r = k(e.users);
250
271
  if (!r) return;
251
272
  let a = { users: r };
252
273
  t.setState({ onlineUsers: r }), t.emit("presence:update", a);
253
274
  })), c.push(l.on("drawing:stroke", (e) => {
254
- B(n, l) && i(e) && T(e.userId) && L(e.path) && t.emit("drawing:stroke", {
275
+ V(n, l) && i(e) && T(e.userId) && R(e.path) && t.emit("drawing:stroke", {
255
276
  userId: e.userId.trim(),
256
277
  path: structuredClone(e.path)
257
278
  });
@@ -275,7 +296,7 @@ function H(t, n) {
275
296
  }
276
297
  }, document.addEventListener("mousemove", n.mouseMoveHandler));
277
298
  }
278
- function U(e) {
299
+ function W(e) {
279
300
  typeof window < "u" && typeof document < "u" && e.mouseMoveHandler && (document.removeEventListener("mousemove", e.mouseMoveHandler), e.mouseMoveHandler = null);
280
301
  }
281
- export { H as initializeWebSocket, U as removeMouseMoveListener };
302
+ export { U as initializeWebSocket, W as removeMouseMoveListener };