@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
package/dist/demo.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { o as e, r as t } from "./shared/validation-C7QG8j7Z.js";
2
- import { p as n, t as r } from "./shared/comment-kit-core-D0kY00St.js";
2
+ import { p as n, t as r } from "./shared/comment-kit-core-BaSuMzp9.js";
3
3
  var i = 864e5, a = 512e3, o = 50, s = 20, c = "commentkit:demo:", l = {
4
4
  id: "local-demo-you",
5
5
  name: "You",
@@ -12,22 +12,81 @@ function d(e) {
12
12
  return typeof e == "string" && e.length <= 40 && Number.isFinite(Date.parse(e));
13
13
  }
14
14
  function f(e) {
15
+ return d(e) && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:Z|[+-]\d{2}:\d{2})$/.test(e);
16
+ }
17
+ function p(e, t) {
18
+ e.status !== t && (e.status = t, t === "open" ? (delete e.resolvedAt, delete e.completedAt) : t === "resolved" ? (e.resolvedAt = (/* @__PURE__ */ new Date()).toISOString(), delete e.completedAt) : t === "complete" && (e.completedAt = (/* @__PURE__ */ new Date()).toISOString()));
19
+ }
20
+ function m(e) {
15
21
  return typeof e == "string" && /^[a-zA-Z0-9_-]{1,128}$/.test(e);
16
22
  }
17
- function p(t) {
23
+ function h(t) {
18
24
  return e(t) && typeof t.x == "number" && Number.isFinite(t.x) && t.x >= 0 && t.x <= 100 && typeof t.y == "number" && Number.isFinite(t.y) && t.y >= 0 && t.y <= 100 && (t.element === void 0 || u(t.element, 2048)) && (t.xpath === void 0 || u(t.xpath, 2048));
19
25
  }
20
- function m(t) {
21
- return !e(t) || !f(t.id) || !u(t.content, 5e3) || !d(t.createdAt) ? null : {
26
+ function g(t) {
27
+ if (t === void 0) return [];
28
+ if (!Array.isArray(t) || t.length > 20) return null;
29
+ let n = [], r = /* @__PURE__ */ new Set();
30
+ for (let i of t) {
31
+ if (!e(i) || !u(i.emoji, 32) || typeof i.reacted != "boolean" || r.has(i.emoji)) return null;
32
+ r.add(i.emoji), i.reacted && n.push({
33
+ emoji: i.emoji,
34
+ count: 1,
35
+ reacted: !0
36
+ });
37
+ }
38
+ return n;
39
+ }
40
+ function _(t) {
41
+ if (t === void 0) return [];
42
+ if (!Array.isArray(t) || t.length > 100) return null;
43
+ let n = [];
44
+ for (let r of t) {
45
+ if (!e(r) || !m(r.userId)) return null;
46
+ r.userId === l.id && n.length === 0 && n.push({
47
+ userId: l.id,
48
+ name: l.name
49
+ });
50
+ }
51
+ return n;
52
+ }
53
+ function v(t) {
54
+ if (t !== void 0) return !e(t) || !u(t.browser, 255) || !u(t.os, 255) || !u(t.windowSize, 64) || typeof t.devicePixelRatio != "number" || !Number.isFinite(t.devicePixelRatio) || t.devicePixelRatio <= 0 || t.devicePixelRatio > 16 || !["desktop", "mobile"].includes(t.type) || t.deployment !== void 0 && !u(t.deployment, 255, !0) ? null : {
55
+ browser: t.browser,
56
+ os: t.os,
57
+ windowSize: t.windowSize,
58
+ devicePixelRatio: t.devicePixelRatio,
59
+ type: t.type,
60
+ ...t.deployment === void 0 ? {} : { deployment: t.deployment }
61
+ };
62
+ }
63
+ function y(t) {
64
+ if (!e(t) || !m(t.id) || !u(t.content, 5e3) || !d(t.createdAt)) return null;
65
+ let n = g(t.reactions), r = _(t.mentions);
66
+ if (!n || !r) return null;
67
+ let i = t.replyTo, a;
68
+ if (i !== void 0) {
69
+ if (!e(i) || !m(i.id) || !["comment", "reply"].includes(i.type) || !u(i.body, 1e4)) return null;
70
+ a = {
71
+ id: i.id,
72
+ type: i.type,
73
+ authorName: l.name,
74
+ body: i.body
75
+ };
76
+ }
77
+ return {
22
78
  id: t.id,
23
79
  content: t.content,
24
80
  createdAt: t.createdAt,
25
81
  author: { ...l },
82
+ reactions: n,
83
+ mentions: r,
84
+ ...a ? { replyTo: a } : {},
26
85
  ...t.isEdited === !0 ? { isEdited: !0 } : {}
27
86
  };
28
87
  }
29
- function h(t) {
30
- if (!e(t) || !f(t.id) || t.type !== "pin" || !u(t.content, 1e4) || !p(t.position) || ![
88
+ function b(t) {
89
+ if (!e(t) || !m(t.id) || t.type !== "pin" || !u(t.content, 1e4) || !h(t.position) || ![
31
90
  "open",
32
91
  "resolved",
33
92
  "complete"
@@ -36,15 +95,15 @@ function h(t) {
36
95
  "medium",
37
96
  "high",
38
97
  "urgent"
39
- ].includes(t.priority) || !d(t.createdAt) || !d(t.updatedAt) || !e(t.page) || !u(t.page.url, 2e3) || !u(t.page.path, 2e3) || !u(t.page.title, 2e3, !0) || !Array.isArray(t.replies) || t.replies.length > s || t.description !== void 0 && !u(t.description, 1e4, !0)) return null;
98
+ ].includes(t.priority) || !d(t.createdAt) || !d(t.updatedAt) || t.resolvedAt != null && !f(t.resolvedAt) || t.completedAt != null && !f(t.completedAt) || !e(t.page) || !u(t.page.url, 2e3) || !u(t.page.path, 2e3) || !u(t.page.title, 2e3, !0) || !Array.isArray(t.replies) || t.replies.length > s || t.description !== void 0 && !u(t.description, 1e4, !0) || t.branch !== void 0 && !u(t.branch, 255)) return null;
40
99
  let n;
41
100
  try {
42
101
  if (n = new URL(t.page.url), n.origin !== window.location.origin || n.username || n.password || n.pathname + n.search !== t.page.path) return null;
43
102
  } catch {
44
103
  return null;
45
104
  }
46
- let r = t.replies.map(m);
47
- if (r.some((e) => !e) || new Set(r.map((e) => e.id)).size !== r.length) return null;
105
+ let r = t.replies.map(y);
106
+ if (r.some((e) => !e) || r.some((e) => e?.replyTo?.type === "comment" && e.replyTo.id !== t.id) || new Set(r.map((e) => e.id)).size !== r.length) return null;
48
107
  let i = [];
49
108
  if (t.checklist !== void 0) {
50
109
  if (!Array.isArray(t.checklist) || t.checklist.length > 25) return null;
@@ -57,19 +116,8 @@ function h(t) {
57
116
  });
58
117
  }
59
118
  }
60
- let a = [];
61
- if (t.reactions !== void 0) {
62
- if (!Array.isArray(t.reactions) || t.reactions.length > 20) return null;
63
- for (let n of t.reactions) {
64
- if (!e(n) || !u(n.emoji, 32) || typeof n.reacted != "boolean") return null;
65
- n.reacted && a.push({
66
- emoji: n.emoji,
67
- count: 1,
68
- reacted: !0
69
- });
70
- }
71
- }
72
- return {
119
+ let a = g(t.reactions), o = _(t.mentions), c = v(t.deviceInfo);
120
+ return !a || !o || c === null ? null : {
73
121
  id: t.id,
74
122
  type: "pin",
75
123
  content: t.content,
@@ -85,6 +133,8 @@ function h(t) {
85
133
  userId: l.id,
86
134
  createdAt: t.createdAt,
87
135
  updatedAt: t.updatedAt,
136
+ ...f(t.resolvedAt) ? { resolvedAt: t.resolvedAt } : {},
137
+ ...f(t.completedAt) ? { completedAt: t.completedAt } : {},
88
138
  page: {
89
139
  url: n.href,
90
140
  path: t.page.path,
@@ -94,12 +144,15 @@ function h(t) {
94
144
  attachments: [],
95
145
  checklist: i,
96
146
  reactions: a,
147
+ mentions: o,
148
+ ...c ? { deviceInfo: c } : {},
149
+ ...t.branch === void 0 ? {} : { branch: t.branch },
97
150
  assignees: Array.isArray(t.assignees) && t.assignees.some((t) => e(t) && t.id === l.id) ? [{ ...l }] : [],
98
151
  ...t.description === void 0 ? {} : { description: t.description },
99
152
  ...t.isEdited === !0 ? { isEdited: !0 } : {}
100
153
  };
101
154
  }
102
- function g() {
155
+ function x() {
103
156
  let e = Date.now();
104
157
  return {
105
158
  version: 1,
@@ -108,9 +161,9 @@ function g() {
108
161
  comments: []
109
162
  };
110
163
  }
111
- var _ = class {
164
+ var S = class {
112
165
  constructor(e = {}) {
113
- this.user = { ...l }, this.storage = null, this.data = g(), this.timer = null, this.destroyed = !1, this.expiryNotified = !1, this.revision = 0, this.listeners = /* @__PURE__ */ new Set(), this.lastSerialized = null, this.onFocus = () => {
166
+ this.user = { ...l }, this.storage = null, this.data = x(), this.timer = null, this.destroyed = !1, this.expiryNotified = !1, this.revision = 0, this.listeners = /* @__PURE__ */ new Set(), this.lastSerialized = null, this.onFocus = () => {
114
167
  this.sync();
115
168
  }, this.onStorage = (e) => {
116
169
  (e.key === this.storageKey || e.key === null) && (e.newValue === null ? (this.expiryNotified = !1, this.data.comments = [], this.data.expiresAt = Math.min(this.data.expiresAt, Date.now()), this.lastSerialized = null, this.notify("expired")) : this.sync());
@@ -124,16 +177,16 @@ var _ = class {
124
177
  requestOtp: async () => this.unavailable(),
125
178
  verifyOtp: async () => this.unavailable(),
126
179
  validateInvite: async () => this.unavailable(),
127
- getComments: async (e, t = "all") => {
180
+ getComments: async (e, t = "all", n = 1, r = o, i, a) => {
128
181
  this.sync();
129
- let n = this.getComments().filter((n) => (!e || n.page.path === e) && (t === "all" || n.status === t));
182
+ let s = this.getComments().filter((n) => (!e || n.page.path === e) && (t === "all" || n.status === t) && (!i || n.environment === i) && (!a || n.branch === a)), c = Number.isFinite(n) ? Math.max(1, Math.floor(n)) : 1, l = Number.isFinite(r) ? Math.min(100, Math.max(1, Math.floor(r))) : o, u = (c - 1) * l;
130
183
  return {
131
- comments: n,
184
+ comments: s.slice(u, u + l),
132
185
  pagination: {
133
- total: n.length,
134
- hasMore: !1,
135
- page: 1,
136
- limit: o
186
+ total: s.length,
187
+ hasMore: u + l < s.length,
188
+ page: c,
189
+ limit: l
137
190
  }
138
191
  };
139
192
  },
@@ -156,56 +209,68 @@ var _ = class {
156
209
  attachments: [],
157
210
  description: s?.description,
158
211
  checklist: s?.checklist,
159
- assignees: s?.assignees
212
+ assignees: s?.assignees,
213
+ mentions: s?.mentions,
214
+ branch: s?.branch,
215
+ deviceInfo: s?.deviceInfo
160
216
  })), this.getComments().find((e) => e.id === u);
161
217
  },
162
- updateComment: async (e, t) => t.attachmentIds?.length || t.drawingData || t.textSelection ? this.unavailable() : this.modify(e, (e) => Object.assign(e, t, { isEdited: !0 })),
218
+ updateComment: async (e, t) => t.attachmentIds?.length || t.drawingData || t.textSelection ? this.unavailable() : this.modify(e, (e) => {
219
+ Object.assign(e, t, {
220
+ isEdited: !0,
221
+ status: e.status,
222
+ resolvedAt: e.resolvedAt,
223
+ completedAt: e.completedAt
224
+ }), t.status !== void 0 && p(e, t.status);
225
+ }),
163
226
  deleteComment: async (e) => {
164
227
  this.write((t) => {
165
228
  let n = t.indexOf(this.find(t, e));
166
229
  t.splice(n, 1);
167
230
  });
168
231
  },
169
- addReply: async (e, t) => {
170
- let n = {
232
+ addReply: async (e, t, n, r) => {
233
+ if (r?.attachmentIds?.length) return this.unavailable();
234
+ let i = {
171
235
  id: `reply-${crypto.randomUUID()}`,
172
236
  content: t,
173
237
  author: { ...l },
174
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
238
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
239
+ mentions: r?.mentions
175
240
  };
176
- return this.modify(e, (e) => e.replies.push(n)), structuredClone(n);
241
+ return this.modify(e, (e) => {
242
+ r?.replyTo && (i.replyTo = this.quote(e, r.replyTo)), e.replies.push(i), p(e, "open");
243
+ }).replies.find((e) => e.id === i.id);
177
244
  },
178
- updateReply: async (e, t, r) => this.modify(e, (e) => {
179
- let i = e.replies.find((e) => e.id === t);
180
- if (!i) throw new n("not_found", "This demo reply no longer exists.", 404);
181
- i.content = r, i.isEdited = !0;
245
+ updateReply: async (e, t, r, i) => i?.attachmentIds?.length ? this.unavailable() : this.modify(e, (e) => {
246
+ let a = e.replies.find((e) => e.id === t);
247
+ if (!a) throw new n("not_found", "This demo reply no longer exists.", 404);
248
+ a.content = r, a.isEdited = !0, i?.mentions !== void 0 && (a.mentions = i.mentions), i?.replyTo && (a.replyTo = this.quote(e, i.replyTo));
182
249
  }).replies.find((e) => e.id === t),
183
250
  deleteReply: async (e, t) => {
184
251
  this.modify(e, (e) => {
185
252
  e.replies = e.replies.filter((e) => e.id !== t);
186
253
  });
187
254
  },
188
- resolveComment: async (e) => this.modify(e, (e) => {
189
- e.status = "resolved";
190
- }),
191
- unresolveComment: async (e) => this.modify(e, (e) => {
192
- e.status = "open";
193
- }),
194
- markComplete: async (e) => this.modify(e, (e) => {
195
- e.status = "complete";
196
- }),
197
- addReaction: async (e, t) => {
255
+ resolveComment: async (e) => this.modify(e, (e) => p(e, "resolved")),
256
+ unresolveComment: async (e) => this.modify(e, (e) => p(e, "open")),
257
+ markComplete: async (e) => this.modify(e, (e) => p(e, "complete")),
258
+ addReaction: async (e, t, r) => {
198
259
  this.modify(e, (e) => {
199
- e.reactions = [...(e.reactions ?? []).filter((e) => e.emoji !== t), {
260
+ let i = r ? e.replies.find((e) => e.id === r) : e;
261
+ if (!i) throw new n("not_found", "This demo reply no longer exists.", 404);
262
+ i.reactions = [...(i.reactions ?? []).filter((e) => e.emoji !== t), {
200
263
  emoji: t,
201
264
  count: 1,
202
265
  reacted: !0
203
266
  }];
204
267
  });
205
268
  },
206
- removeReaction: async (e, t) => {
269
+ removeReaction: async (e, t, r) => {
207
270
  this.modify(e, (e) => {
208
- e.reactions = (e.reactions ?? []).filter((e) => e.emoji !== t);
271
+ let i = r ? e.replies.find((e) => e.id === r) : e;
272
+ if (!i) throw new n("not_found", "This demo reply no longer exists.", 404);
273
+ i.reactions = (i.reactions ?? []).filter((e) => e.emoji !== t);
209
274
  });
210
275
  },
211
276
  updatePosition: async (e, t) => this.modify(e, (e) => {
@@ -216,6 +281,8 @@ var _ = class {
216
281
  uploadFile: async () => this.unavailable(),
217
282
  uploadScreenshot: async () => this.unavailable(),
218
283
  uploadFiles: async () => this.unavailable(),
284
+ getComment: async (e) => (this.sync(), this.find(this.getComments(), e)),
285
+ getProjectContext: async () => this.unavailable(),
219
286
  getProjectMembers: async () => [{ ...l }]
220
287
  };
221
288
  let t = e.storageKey ?? "website-v1";
@@ -224,7 +291,7 @@ var _ = class {
224
291
  try {
225
292
  this.storage = window.localStorage;
226
293
  } catch {}
227
- this.hydrate(), this.data.expiresAt <= Date.now() && (this.data = g()), this.persist(), this.armExpiry(), window.addEventListener("focus", this.onFocus), document.addEventListener("visibilitychange", this.onFocus), window.addEventListener("storage", this.onStorage);
294
+ this.hydrate(), this.data.expiresAt <= Date.now() && (this.data = x()), this.persist(), this.armExpiry(), window.addEventListener("focus", this.onFocus), document.addEventListener("visibilitychange", this.onFocus), window.addEventListener("storage", this.onStorage);
228
295
  }
229
296
  hydrate() {
230
297
  if (this.storage) try {
@@ -238,7 +305,7 @@ var _ = class {
238
305
  if (t.length > a) throw Error("Oversized demo");
239
306
  let r = JSON.parse(t);
240
307
  if (!e(r) || r.version !== 1 || typeof r.createdAt != "number" || !Number.isSafeInteger(r.createdAt) || r.createdAt > Date.now() || r.expiresAt !== r.createdAt + 864e5 || !Array.isArray(r.comments) || r.comments.length > o) throw Error("Invalid demo");
241
- let i = r.comments.map(h);
308
+ let i = r.comments.map(b);
242
309
  if (i.some((e) => !e) || new Set(i.map((e) => e.id)).size !== i.length) throw Error("Invalid comments");
243
310
  this.data = {
244
311
  version: 1,
@@ -252,7 +319,7 @@ var _ = class {
252
319
  } catch {
253
320
  this.storage = null;
254
321
  }
255
- this.lastSerialized = null, this.data = g();
322
+ this.lastSerialized = null, this.data = x();
256
323
  }
257
324
  }
258
325
  persist() {
@@ -316,7 +383,7 @@ var _ = class {
316
383
  } catch {}
317
384
  }
318
385
  reset() {
319
- this.destroyed || (this.expiryNotified = !1, this.data = g(), this.persist(), this.armExpiry(), this.notify("reset"));
386
+ this.destroyed || (this.expiryNotified = !1, this.data = x(), this.persist(), this.armExpiry(), this.notify("reset"));
320
387
  }
321
388
  activate() {
322
389
  this.checkExpiry() && this.reset();
@@ -325,7 +392,7 @@ var _ = class {
325
392
  if (this.sync(), this.checkExpiry()) throw new n("demo_expired", "Your demo has expired. Start a new demo to continue.", 410);
326
393
  let t = structuredClone(this.data.comments);
327
394
  if (e(t), t.length > o) throw new n("demo_full", "This demo holds up to 50 comments. Reset it to start again.", 413);
328
- let r = t.map(h);
395
+ let r = t.map(b);
329
396
  if (r.some((e) => !e)) throw new n("invalid_demo_data", "The demo comment is invalid or exceeds its limit.", 400);
330
397
  let i = {
331
398
  ...this.data,
@@ -345,18 +412,28 @@ var _ = class {
345
412
  t(r), r.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
346
413
  }), this.getComments().find((t) => t.id === e);
347
414
  }
415
+ quote(e, t) {
416
+ let r = t.type === "comment" && t.id === e.id ? e : t.type === "reply" ? e.replies.find((e) => e.id === t.id) : void 0;
417
+ if (!r) throw new n("not_found", "The quoted demo comment no longer exists.", 404);
418
+ return {
419
+ id: r.id,
420
+ type: t.type,
421
+ authorName: l.name,
422
+ body: r.content
423
+ };
424
+ }
348
425
  unavailable() {
349
426
  throw new n("demo_unavailable", "This action is unavailable in the private browser demo.", 400);
350
427
  }
351
428
  destroy() {
352
429
  this.destroyed = !0, this.timer && clearTimeout(this.timer), this.listeners.clear(), window.removeEventListener("focus", this.onFocus), document.removeEventListener("visibilitychange", this.onFocus), window.removeEventListener("storage", this.onStorage);
353
430
  }
354
- }, v = !1;
355
- async function y(e = {}) {
431
+ }, C = !1;
432
+ async function w(e = {}) {
356
433
  if (typeof window > "u" || typeof document > "u") throw Error("The CommentKit demo requires a browser");
357
- if (v || document.querySelector("[data-commentkit], [data-commentkit-host]")) throw Error("Destroy the existing CommentKit widget before starting a demo");
358
- let t = new _(e);
359
- v = !0;
434
+ if (C || document.querySelector("[data-commentkit], [data-commentkit-host]")) throw Error("Destroy the existing CommentKit widget before starting a demo");
435
+ let t = new S(e);
436
+ C = !0;
360
437
  let n = new r({
361
438
  apiKey: "",
362
439
  ui: {
@@ -365,10 +442,10 @@ async function y(e = {}) {
365
442
  }
366
443
  }, t), i;
367
444
  try {
368
- let { mountCommentKitUI: e } = await import("./shared/mount-ui-CVivB_eQ.js").then((e) => e.n);
445
+ let { mountCommentKitUI: e } = await import("./shared/mount-ui--ijs8pWT.js").then((e) => e.n);
369
446
  i = await e(n);
370
447
  } catch (e) {
371
- throw n.destroy(), v = !1, e;
448
+ throw n.destroy(), C = !1, e;
372
449
  }
373
450
  let a = !1, o = {
374
451
  start() {
@@ -378,7 +455,7 @@ async function y(e = {}) {
378
455
  a || (t.reset(), n.startLocalDemo());
379
456
  },
380
457
  destroy() {
381
- a || (a = !0, i.unmount(), n.destroy(), v = !1);
458
+ a || (a = !0, i.unmount(), n.destroy(), C = !1);
382
459
  },
383
460
  getSession() {
384
461
  return t.getSession();
@@ -392,4 +469,4 @@ async function y(e = {}) {
392
469
  };
393
470
  return o.start(), o;
394
471
  }
395
- export { y as createCommentKitDemo };
472
+ export { w as createCommentKitDemo };
@@ -1,4 +1,4 @@
1
- import { t as e } from "./shared/websocket-manager-BTRqNTB7.js";
2
- import { a as t, c as n, f as r, g as i, h as a, l as o, m as s, n as c, t as l } from "./shared/comment-kit-core-D0kY00St.js";
1
+ import { t as e } from "./shared/websocket-manager-DhLWh3Jr.js";
2
+ import { a as t, c as n, f as r, g as i, h as a, l as o, m as s, n as c, t as l } from "./shared/comment-kit-core-BaSuMzp9.js";
3
3
  import { a as u, c as d, d as f, f as p, i as m, l as h, m as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "./shared/dom-Bhf4WFtY.js";
4
4
  export { r as ApiClient, l as CommentKitCore, t as EventEmitter, c as SDK_VERSION, e as WebSocketManager, n as createAgentContext, S as debounce, _ as findElement, o as formatAgentContext, s as formatMention, b as generateId, m as generateSelector, u as generateXPath, v as getCurrentPage, x as getElementBounds, d as getSelectionRange, h as getSelectionText, C as isElementVisible, f as isInteractiveElement, a as parseMentions, p as percentageToViewport, i as stripMentionMarkup, y as throttle, g as viewportToPercentage };
package/dist/preact.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { t as e } from "./shared/comment-kit-core-D0kY00St.js";
2
- import { n as t, r as n, t as r } from "./shared/bridge-DRE03N9X.js";
1
+ import { t as e } from "./shared/comment-kit-core-BaSuMzp9.js";
2
+ import { n as t, r as n, t as r } from "./shared/bridge-CJoGYngu.js";
3
3
  import { n as i, t as a } from "./shared/errors-Bu5ajEmB.js";
4
4
  import { useEffect as o, useMemo as s, useRef as c, useState as l } from "preact/hooks";
5
5
  function u(u) {
@@ -34,7 +34,7 @@ function u(u) {
34
34
  }
35
35
  }, l = async (e) => {
36
36
  try {
37
- let { mountCommentKitUI: t } = await import("./shared/mount-ui-CVivB_eQ.js").then((e) => e.n);
37
+ let { mountCommentKitUI: t } = await import("./shared/mount-ui--ijs8pWT.js").then((e) => e.n);
38
38
  if (r || d.current !== e) return;
39
39
  let n = await t(e);
40
40
  if (r || d.current !== e) {
package/dist/qwik.es.js CHANGED
@@ -1,110 +1 @@
1
- import { t as e } from "./shared/comment-kit-core-D0kY00St.js";
2
- import { n as t, r as n, t as r } from "./shared/bridge-DRE03N9X.js";
3
- import { n as i, t as a } from "./shared/errors-Bu5ajEmB.js";
4
- import { noSerialize as o, useComputed$ as s, useSignal as c, useStore as l, useVisibleTask$ as u } from "@builder.io/qwik";
5
- function d(d) {
6
- let f = c(null), p = c(!1), m = c(!0), h = c(null), g = c(null), _ = s(() => r.isAuthenticated(f.value)), v = s(() => r.isOverlayVisible(f.value)), y = s(() => r.isSidebarVisible(f.value)), b = s(() => r.currentUser(f.value)), x = s(() => r.comments(f.value)), S = s(() => r.activeTool(f.value)), C = s(() => r.otpStep(f.value)), w = s(() => r.otpEmail(f.value)), T = s(() => r.pendingMutationCount(f.value)), E = s(() => r.isOnline(f.value)), D = s(() => r.selectedComment(f.value)), O = s(() => r.connectionStatus(f.value)), k = s(() => r.panelView(f.value)), A = s(() => r.isShortcutsOverlayVisible(f.value)), j = s(() => r.activeDrawing(f.value)), M = s(() => r.activeScreenshot(f.value)), N = t(() => g.value ?? null, (e) => {
7
- h.value = a(e);
8
- }), P = {
9
- apiKey: d.apiKey,
10
- ...d.baseUrl === void 0 ? {} : { baseUrl: d.baseUrl },
11
- ...d.enabled === void 0 ? {} : { enabled: d.enabled },
12
- ...d.ui === void 0 ? {} : { ui: d.ui }
13
- }, F = d.onReady$, I = d.onError$, L = l({});
14
- return L.extras = o({
15
- options: d,
16
- notifyBridge: () => n(N)
17
- }), u(({ cleanup: t }) => {
18
- let n = L.extras, r = n?.options, s = r ?? P, c = [], l = null, u = !1, d = !1, _ = () => {
19
- if (!d) {
20
- d = !0;
21
- try {
22
- r?.onReady?.();
23
- } catch {}
24
- F && F();
25
- }
26
- }, v = (e) => {
27
- h.value = e;
28
- try {
29
- r?.onError?.(e);
30
- } catch {}
31
- I && I(e);
32
- }, y = () => {
33
- for (; c.length > 0;) {
34
- let e = c.pop();
35
- try {
36
- e?.();
37
- } catch {}
38
- }
39
- }, b = async (e) => {
40
- try {
41
- let { mountCommentKitUI: t } = await import("./shared/mount-ui-CVivB_eQ.js").then((e) => e.n);
42
- if (u || g.value !== e) return;
43
- let n = await t(e);
44
- if (u || g.value !== e) {
45
- try {
46
- n.unmount();
47
- } catch {}
48
- return;
49
- }
50
- l = n;
51
- } catch (t) {
52
- !u && g.value === e && v(i(t));
53
- }
54
- }, x = null;
55
- try {
56
- m.value = !0, h.value = null, x = new e(s), g.value = o(x) ?? null, n?.notifyBridge(), s.enabled !== !1 && b(x), c.push(x.on("state:changed", (e) => {
57
- u || g.value !== x || (f.value = e, e.isAuthenticated && _());
58
- }), x.on("error", (e) => {
59
- u || g.value !== x || v(e);
60
- }));
61
- let t = x.getState();
62
- f.value = t, p.value = !0, m.value = !1, t.isAuthenticated && _();
63
- } catch (e) {
64
- let t = a(e);
65
- if (x && g.value === x) {
66
- g.value = null, y();
67
- try {
68
- x.destroy();
69
- } catch {}
70
- }
71
- m.value = !1, v(t);
72
- }
73
- t(() => {
74
- u = !0, y();
75
- try {
76
- l?.unmount();
77
- } catch {}
78
- l = null;
79
- let e = g.value;
80
- if (g.value = null, e) try {
81
- e.destroy();
82
- } catch {}
83
- f.value = null, p.value = !1, m.value = !0, h.value = null;
84
- });
85
- }), {
86
- state: f,
87
- isReady: p,
88
- isLoading: m,
89
- error: h,
90
- core: g,
91
- isAuthenticated: _,
92
- isOverlayVisible: v,
93
- isSidebarVisible: y,
94
- currentUser: b,
95
- comments: x,
96
- activeTool: S,
97
- otpStep: C,
98
- otpEmail: w,
99
- pendingMutationCount: T,
100
- isOnline: E,
101
- selectedComment: D,
102
- connectionStatus: O,
103
- panelView: k,
104
- isShortcutsOverlayVisible: A,
105
- activeDrawing: j,
106
- activeScreenshot: M,
107
- ...N
108
- };
109
- }
110
- export { d as useCommentKit$ };
1
+ export * from "./qwik.qwik.mjs";
@@ -0,0 +1,114 @@
1
+ import { t as e } from "./shared/comment-kit-core-BaSuMzp9.js";
2
+ import { n as t, r as n, t as r } from "./shared/bridge-CJoGYngu.js";
3
+ import { n as i, t as a } from "./shared/errors-Bu5ajEmB.js";
4
+ import { noSerialize as o, useComputed$ as s, useSignal as c, useStore as l, useVisibleTask$ as u } from "@builder.io/qwik";
5
+ function d(d) {
6
+ let f = c(null), p = c(!1), m = c(!0), h = c(null), g = c(null), _ = s(() => r.isAuthenticated(f.value)), v = s(() => r.isOverlayVisible(f.value)), y = s(() => r.isSidebarVisible(f.value)), b = s(() => r.currentUser(f.value)), x = s(() => r.comments(f.value)), S = s(() => r.activeTool(f.value)), C = s(() => r.otpStep(f.value)), w = s(() => r.otpEmail(f.value)), T = s(() => r.pendingMutationCount(f.value)), E = s(() => r.isOnline(f.value)), D = s(() => r.selectedComment(f.value)), O = s(() => r.connectionStatus(f.value)), k = s(() => r.panelView(f.value)), A = s(() => r.isShortcutsOverlayVisible(f.value)), j = s(() => r.activeDrawing(f.value)), M = s(() => r.activeScreenshot(f.value)), N = t(() => g.value ?? null, (e) => {
7
+ h.value = a(e);
8
+ });
9
+ for (let e of Object.values(N)) o(e);
10
+ let P = {
11
+ apiKey: d.apiKey,
12
+ ...d.baseUrl === void 0 ? {} : { baseUrl: d.baseUrl },
13
+ ...d.enabled === void 0 ? {} : { enabled: d.enabled },
14
+ ...d.branch === void 0 ? {} : { branch: d.branch },
15
+ ...d.realtime === void 0 ? {} : { realtime: d.realtime },
16
+ ...d.ui === void 0 ? {} : { ui: d.ui }
17
+ }, F = d.onReady$, I = d.onError$, L = l({});
18
+ return L.extras = o({
19
+ options: d,
20
+ notifyBridge: () => n(N)
21
+ }), u(({ cleanup: t }) => {
22
+ let n = L.extras, r = n?.options, s = r ?? P, c = [], l = null, u = !1, d = !1, _ = () => {
23
+ if (!d) {
24
+ d = !0;
25
+ try {
26
+ r?.onReady?.();
27
+ } catch {}
28
+ F && F();
29
+ }
30
+ }, v = (e) => {
31
+ h.value = e;
32
+ try {
33
+ r?.onError?.(e);
34
+ } catch {}
35
+ I && I(e);
36
+ }, y = () => {
37
+ for (; c.length > 0;) {
38
+ let e = c.pop();
39
+ try {
40
+ e?.();
41
+ } catch {}
42
+ }
43
+ }, b = async (e) => {
44
+ try {
45
+ let { mountCommentKitUI: t } = await import("./shared/mount-ui--ijs8pWT.js").then((e) => e.n);
46
+ if (u || g.value !== e) return;
47
+ let n = await t(e);
48
+ if (u || g.value !== e) {
49
+ try {
50
+ n.unmount();
51
+ } catch {}
52
+ return;
53
+ }
54
+ l = n;
55
+ } catch (t) {
56
+ !u && g.value === e && v(i(t));
57
+ }
58
+ }, x = null;
59
+ try {
60
+ m.value = !0, h.value = null, x = new e(s), g.value = o(x) ?? null, n?.notifyBridge(), s.enabled !== !1 && b(x), c.push(x.on("state:changed", (e) => {
61
+ u || g.value !== x || (f.value = e, e.isAuthenticated && _());
62
+ }), x.on("error", (e) => {
63
+ u || g.value !== x || v(e);
64
+ }));
65
+ let t = x.getState();
66
+ f.value = t, p.value = !0, m.value = !1, t.isAuthenticated && _();
67
+ } catch (e) {
68
+ let t = a(e);
69
+ if (x && g.value === x) {
70
+ g.value = null, y();
71
+ try {
72
+ x.destroy();
73
+ } catch {}
74
+ }
75
+ m.value = !1, v(t);
76
+ }
77
+ t(() => {
78
+ u = !0, y();
79
+ try {
80
+ l?.unmount();
81
+ } catch {}
82
+ l = null;
83
+ let e = g.value;
84
+ if (g.value = null, e) try {
85
+ e.destroy();
86
+ } catch {}
87
+ f.value = null, p.value = !1, m.value = !0, h.value = null;
88
+ });
89
+ }), {
90
+ state: f,
91
+ isReady: p,
92
+ isLoading: m,
93
+ error: h,
94
+ core: g,
95
+ isAuthenticated: _,
96
+ isOverlayVisible: v,
97
+ isSidebarVisible: y,
98
+ currentUser: b,
99
+ comments: x,
100
+ activeTool: S,
101
+ otpStep: C,
102
+ otpEmail: w,
103
+ pendingMutationCount: T,
104
+ isOnline: E,
105
+ selectedComment: D,
106
+ connectionStatus: O,
107
+ panelView: k,
108
+ isShortcutsOverlayVisible: A,
109
+ activeDrawing: j,
110
+ activeScreenshot: M,
111
+ ...N
112
+ };
113
+ }
114
+ export { d as useCommentKit, d as useCommentKit$, d as useCommentKitQrl };
package/dist/react.es.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  "use client";
3
- import { t as e } from "./shared/comment-kit-core-D0kY00St.js";
4
- import { n as t, r as n, t as r } from "./shared/bridge-DRE03N9X.js";
3
+ import { t as e } from "./shared/comment-kit-core-BaSuMzp9.js";
4
+ import { n as t, r as n, t as r } from "./shared/bridge-CJoGYngu.js";
5
5
  import { n as i, t as a } from "./shared/errors-Bu5ajEmB.js";
6
- import { t as o } from "./shared/mount-ui-CVivB_eQ.js";
6
+ import { t as o } from "./shared/mount-ui--ijs8pWT.js";
7
7
  import { useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d, useSyncExternalStore as f } from "react";
8
8
  import { Fragment as p, jsx as m } from "react/jsx-runtime";
9
9
  function h(i, o = {}) {