@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.
Files changed (73) hide show
  1. package/CHANGELOG.md +63 -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 +25 -13
  8. package/dist/demo.es.js +148 -70
  9. package/dist/headless.es.js +3 -3
  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-cGC1p-SP.js +1093 -0
  16. package/dist/shared/attachment-refresh-CzQFXHkL.js +94 -0
  17. package/dist/shared/{bridge-DRE03N9X.js → bridge-CJoGYngu.js} +6 -3
  18. package/dist/shared/{button-group-CHfMRXyA.js → button-group-CWdKaOlC.js} +14 -16
  19. package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
  20. package/dist/shared/comment-drawing-canvas-DdXlMgbF.js +124 -0
  21. package/dist/shared/comment-icon-Dg9ZWpz-.js +608 -0
  22. package/dist/shared/comment-image-lightbox-B7iHjnAz.js +190 -0
  23. package/dist/shared/comment-images-content-D7YNUgo5.js +214 -0
  24. package/dist/shared/{comment-kit-core-D0kY00St.js → comment-kit-core-C862uNAm.js} +1371 -853
  25. package/dist/shared/comment-kit-ui-0vd-DY4S.js +19977 -0
  26. package/dist/shared/comment-screenshot-annotator-DcaSSuWB.js +151 -0
  27. package/dist/shared/comment-screenshot-overlay-D_nFoJmM.js +207 -0
  28. package/dist/shared/{dev-export-panel-BLngcr5q.js → dev-export-panel-pWBlhlse.js} +8 -8
  29. package/dist/shared/dev-grab-eQ9EgEGY.js +210 -0
  30. package/dist/shared/dist-De294MVF.js +623 -0
  31. package/dist/shared/{element-selector-CtFzgHvq.js → element-selector-DC-_XJ0k.js} +350 -305
  32. package/dist/shared/{icons-BSHCWYO1.js → icons-nzMOLzrm.js} +2 -3
  33. package/dist/shared/{mount-ui-CVivB_eQ.js → mount-ui-B68j8r6I.js} +4 -4
  34. package/dist/shared/{pusher-BEl7Qn-8.js → pusher-C1FHQGXV.js} +1 -1
  35. package/dist/shared/realtime-Diqz7G_y.js +317 -0
  36. package/dist/shared/realtime-recovery-DJ_adc-H.js +135 -0
  37. package/dist/shared/{separator-DusFNTs-.js → separator-XDBsaWyw.js} +891 -785
  38. package/dist/shared/{shadow-root-CmYXiSRR.js → shadow-root-CrO75sED.js} +1 -1
  39. package/dist/shared/styles-C9Jwvm0Q.js +2 -0
  40. package/dist/shared/useRender-D1z_X_BY.js +5 -0
  41. package/dist/shared/{useValueChanged-DQXLia-2.js → useValueChanged-CrzfD8l-.js} +15 -15
  42. package/dist/shared/{validation-C7QG8j7Z.js → validation-D-8u4M7I.js} +14 -1
  43. package/dist/shared/{websocket-manager-BTRqNTB7.js → websocket-manager-CFak_YHy.js} +148 -89
  44. package/dist/solid.es.js +3 -3
  45. package/dist/svelte.es.js +3 -3
  46. package/dist/types/adapters/bridge.d.ts +9 -12
  47. package/dist/types/angular/index.d.ts +15 -5
  48. package/dist/types/core/api-client.d.ts +24 -18
  49. package/dist/types/core/comment-kit-core.d.ts +28 -11
  50. package/dist/types/core/local-demo.d.ts +1 -0
  51. package/dist/types/core/types.d.ts +103 -0
  52. package/dist/types/core/websocket-manager.d.ts +12 -0
  53. package/dist/types/core/write-access.d.ts +9 -0
  54. package/dist/types/headless.d.ts +1 -1
  55. package/dist/types/index.d.ts +8 -4
  56. package/dist/types/qwik/index.d.ts +4 -1
  57. package/dist/vue.es.js +3 -3
  58. package/docs/api-reference.md +378 -0
  59. package/docs/local-demo.md +60 -0
  60. package/package.json +17 -6
  61. package/dist/shared/annotation-toolbar-pX17NLmJ.js +0 -1104
  62. package/dist/shared/clamp-CcFVX0vC.js +0 -55
  63. package/dist/shared/comment-drawing-canvas-CYu5SwRf.js +0 -126
  64. package/dist/shared/comment-image-lightbox-0VdAs2iT.js +0 -178
  65. package/dist/shared/comment-kit-ui-D2j2gvnm.js +0 -16685
  66. package/dist/shared/comment-screenshot-annotator-BuojwviY.js +0 -137
  67. package/dist/shared/comment-screenshot-overlay-BZX0Vcb8.js +0 -144
  68. package/dist/shared/dev-grab-pDAfH2lr.js +0 -203
  69. package/dist/shared/local-demo-context-BohlYbHt.js +0 -6
  70. package/dist/shared/realtime-BG_t_ze7.js +0 -281
  71. package/dist/shared/resolveAriaLabelledBy-CIKpnjNJ.js +0 -669
  72. package/dist/shared/styles-D_FEJZ9G.js +0 -2
  73. package/dist/shared/useLabelableId-DGbfdMi_.js +0 -155
package/dist/demo.es.js CHANGED
@@ -1,5 +1,5 @@
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";
1
+ import { o as e, r as t } from "./shared/validation-D-8u4M7I.js";
2
+ import { g as n, t as r } from "./shared/comment-kit-core-C862uNAm.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());
@@ -121,19 +174,20 @@ var _ = class {
121
174
  setEnvironment() {},
122
175
  setOnAuthExpired() {},
123
176
  validateApiKey: async () => this.unavailable(),
177
+ authorizeChannel: async () => this.unavailable(),
124
178
  requestOtp: async () => this.unavailable(),
125
179
  verifyOtp: async () => this.unavailable(),
126
180
  validateInvite: async () => this.unavailable(),
127
- getComments: async (e, t = "all") => {
181
+ getComments: async (e, t = "all", n = 1, r = o, i, a) => {
128
182
  this.sync();
129
- let n = this.getComments().filter((n) => (!e || n.page.path === e) && (t === "all" || n.status === t));
183
+ 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
184
  return {
131
- comments: n,
185
+ comments: s.slice(u, u + l),
132
186
  pagination: {
133
- total: n.length,
134
- hasMore: !1,
135
- page: 1,
136
- limit: o
187
+ total: s.length,
188
+ hasMore: u + l < s.length,
189
+ page: c,
190
+ limit: l
137
191
  }
138
192
  };
139
193
  },
@@ -156,56 +210,68 @@ var _ = class {
156
210
  attachments: [],
157
211
  description: s?.description,
158
212
  checklist: s?.checklist,
159
- assignees: s?.assignees
213
+ assignees: s?.assignees,
214
+ mentions: s?.mentions,
215
+ branch: s?.branch,
216
+ deviceInfo: s?.deviceInfo
160
217
  })), this.getComments().find((e) => e.id === u);
161
218
  },
162
- updateComment: async (e, t) => t.attachmentIds?.length || t.drawingData || t.textSelection ? this.unavailable() : this.modify(e, (e) => Object.assign(e, t, { isEdited: !0 })),
219
+ updateComment: async (e, t) => t.attachmentIds?.length || t.drawingData || t.textSelection ? this.unavailable() : this.modify(e, (e) => {
220
+ Object.assign(e, t, {
221
+ isEdited: !0,
222
+ status: e.status,
223
+ resolvedAt: e.resolvedAt,
224
+ completedAt: e.completedAt
225
+ }), t.status !== void 0 && p(e, t.status);
226
+ }),
163
227
  deleteComment: async (e) => {
164
228
  this.write((t) => {
165
229
  let n = t.indexOf(this.find(t, e));
166
230
  t.splice(n, 1);
167
231
  });
168
232
  },
169
- addReply: async (e, t) => {
170
- let n = {
233
+ addReply: async (e, t, n, r) => {
234
+ if (r?.attachmentIds?.length) return this.unavailable();
235
+ let i = {
171
236
  id: `reply-${crypto.randomUUID()}`,
172
237
  content: t,
173
238
  author: { ...l },
174
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
239
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
240
+ mentions: r?.mentions
175
241
  };
176
- return this.modify(e, (e) => e.replies.push(n)), structuredClone(n);
242
+ return this.modify(e, (e) => {
243
+ r?.replyTo && (i.replyTo = this.quote(e, r.replyTo)), e.replies.push(i), p(e, "open");
244
+ }).replies.find((e) => e.id === i.id);
177
245
  },
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;
246
+ updateReply: async (e, t, r, i) => i?.attachmentIds?.length ? this.unavailable() : this.modify(e, (e) => {
247
+ let a = e.replies.find((e) => e.id === t);
248
+ if (!a) throw new n("not_found", "This demo reply no longer exists.", 404);
249
+ a.content = r, a.isEdited = !0, i?.mentions !== void 0 && (a.mentions = i.mentions), i?.replyTo && (a.replyTo = this.quote(e, i.replyTo));
182
250
  }).replies.find((e) => e.id === t),
183
251
  deleteReply: async (e, t) => {
184
252
  this.modify(e, (e) => {
185
253
  e.replies = e.replies.filter((e) => e.id !== t);
186
254
  });
187
255
  },
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) => {
256
+ resolveComment: async (e) => this.modify(e, (e) => p(e, "resolved")),
257
+ unresolveComment: async (e) => this.modify(e, (e) => p(e, "open")),
258
+ markComplete: async (e) => this.modify(e, (e) => p(e, "complete")),
259
+ addReaction: async (e, t, r) => {
198
260
  this.modify(e, (e) => {
199
- e.reactions = [...(e.reactions ?? []).filter((e) => e.emoji !== t), {
261
+ let i = r ? e.replies.find((e) => e.id === r) : e;
262
+ if (!i) throw new n("not_found", "This demo reply no longer exists.", 404);
263
+ i.reactions = [...(i.reactions ?? []).filter((e) => e.emoji !== t), {
200
264
  emoji: t,
201
265
  count: 1,
202
266
  reacted: !0
203
267
  }];
204
268
  });
205
269
  },
206
- removeReaction: async (e, t) => {
270
+ removeReaction: async (e, t, r) => {
207
271
  this.modify(e, (e) => {
208
- e.reactions = (e.reactions ?? []).filter((e) => e.emoji !== t);
272
+ let i = r ? e.replies.find((e) => e.id === r) : e;
273
+ if (!i) throw new n("not_found", "This demo reply no longer exists.", 404);
274
+ i.reactions = (i.reactions ?? []).filter((e) => e.emoji !== t);
209
275
  });
210
276
  },
211
277
  updatePosition: async (e, t) => this.modify(e, (e) => {
@@ -216,6 +282,8 @@ var _ = class {
216
282
  uploadFile: async () => this.unavailable(),
217
283
  uploadScreenshot: async () => this.unavailable(),
218
284
  uploadFiles: async () => this.unavailable(),
285
+ getComment: async (e) => (this.sync(), this.find(this.getComments(), e)),
286
+ getProjectContext: async () => this.unavailable(),
219
287
  getProjectMembers: async () => [{ ...l }]
220
288
  };
221
289
  let t = e.storageKey ?? "website-v1";
@@ -224,7 +292,7 @@ var _ = class {
224
292
  try {
225
293
  this.storage = window.localStorage;
226
294
  } 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);
295
+ 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
296
  }
229
297
  hydrate() {
230
298
  if (this.storage) try {
@@ -238,7 +306,7 @@ var _ = class {
238
306
  if (t.length > a) throw Error("Oversized demo");
239
307
  let r = JSON.parse(t);
240
308
  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);
309
+ let i = r.comments.map(b);
242
310
  if (i.some((e) => !e) || new Set(i.map((e) => e.id)).size !== i.length) throw Error("Invalid comments");
243
311
  this.data = {
244
312
  version: 1,
@@ -252,7 +320,7 @@ var _ = class {
252
320
  } catch {
253
321
  this.storage = null;
254
322
  }
255
- this.lastSerialized = null, this.data = g();
323
+ this.lastSerialized = null, this.data = x();
256
324
  }
257
325
  }
258
326
  persist() {
@@ -316,7 +384,7 @@ var _ = class {
316
384
  } catch {}
317
385
  }
318
386
  reset() {
319
- this.destroyed || (this.expiryNotified = !1, this.data = g(), this.persist(), this.armExpiry(), this.notify("reset"));
387
+ this.destroyed || (this.expiryNotified = !1, this.data = x(), this.persist(), this.armExpiry(), this.notify("reset"));
320
388
  }
321
389
  activate() {
322
390
  this.checkExpiry() && this.reset();
@@ -325,7 +393,7 @@ var _ = class {
325
393
  if (this.sync(), this.checkExpiry()) throw new n("demo_expired", "Your demo has expired. Start a new demo to continue.", 410);
326
394
  let t = structuredClone(this.data.comments);
327
395
  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);
396
+ let r = t.map(b);
329
397
  if (r.some((e) => !e)) throw new n("invalid_demo_data", "The demo comment is invalid or exceeds its limit.", 400);
330
398
  let i = {
331
399
  ...this.data,
@@ -345,18 +413,28 @@ var _ = class {
345
413
  t(r), r.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
346
414
  }), this.getComments().find((t) => t.id === e);
347
415
  }
416
+ quote(e, t) {
417
+ let r = t.type === "comment" && t.id === e.id ? e : t.type === "reply" ? e.replies.find((e) => e.id === t.id) : void 0;
418
+ if (!r) throw new n("not_found", "The quoted demo comment no longer exists.", 404);
419
+ return {
420
+ id: r.id,
421
+ type: t.type,
422
+ authorName: l.name,
423
+ body: r.content
424
+ };
425
+ }
348
426
  unavailable() {
349
427
  throw new n("demo_unavailable", "This action is unavailable in the private browser demo.", 400);
350
428
  }
351
429
  destroy() {
352
430
  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
431
  }
354
- }, v = !1;
355
- async function y(e = {}) {
432
+ }, C = !1;
433
+ async function w(e = {}) {
356
434
  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;
435
+ if (C || document.querySelector("[data-commentkit], [data-commentkit-host]")) throw Error("Destroy the existing CommentKit widget before starting a demo");
436
+ let t = new S(e);
437
+ C = !0;
360
438
  let n = new r({
361
439
  apiKey: "",
362
440
  ui: {
@@ -365,10 +443,10 @@ async function y(e = {}) {
365
443
  }
366
444
  }, t), i;
367
445
  try {
368
- let { mountCommentKitUI: e } = await import("./shared/mount-ui-CVivB_eQ.js").then((e) => e.n);
446
+ let { mountCommentKitUI: e } = await import("./shared/mount-ui-B68j8r6I.js").then((e) => e.n);
369
447
  i = await e(n);
370
448
  } catch (e) {
371
- throw n.destroy(), v = !1, e;
449
+ throw n.destroy(), C = !1, e;
372
450
  }
373
451
  let a = !1, o = {
374
452
  start() {
@@ -378,7 +456,7 @@ async function y(e = {}) {
378
456
  a || (t.reset(), n.startLocalDemo());
379
457
  },
380
458
  destroy() {
381
- a || (a = !0, i.unmount(), n.destroy(), v = !1);
459
+ a || (a = !0, i.unmount(), n.destroy(), C = !1);
382
460
  },
383
461
  getSession() {
384
462
  return t.getSession();
@@ -392,4 +470,4 @@ async function y(e = {}) {
392
470
  };
393
471
  return o.start(), o;
394
472
  }
395
- export { y as createCommentKitDemo };
473
+ 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-CFak_YHy.js";
2
+ import { _ as t, d as n, h as r, n as i, o as a, t as o, u as s, v as c, y as l } from "./shared/comment-kit-core-C862uNAm.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
- 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 };
4
+ export { r as ApiClient, o as CommentKitCore, a as EventEmitter, i as SDK_VERSION, e as WebSocketManager, s as createAgentContext, S as debounce, _ as findElement, n as formatAgentContext, t 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, c as parseMentions, p as percentageToViewport, l 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-C862uNAm.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-B68j8r6I.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-C862uNAm.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-B68j8r6I.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-C862uNAm.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-B68j8r6I.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 = {}) {