@commentkit/comment-kit 0.7.7 → 1.0.0-beta.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 (109) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +108 -762
  3. package/SECURITY.md +19 -14
  4. package/dist/npm/THIRD_PARTY_NOTICES.txt +73 -0
  5. package/dist/npm/chunks/anchor-DT-Ynhh1.js +270 -0
  6. package/dist/npm/chunks/client-D1vrh_5G.js +590 -0
  7. package/dist/{shared/capture-colors-D0uLr-vZ.js → npm/chunks/colors-CX-IPjvb.js} +2 -0
  8. package/dist/npm/chunks/html2canvas-_mjSRP3G.js +4011 -0
  9. package/dist/npm/chunks/mount-Ce1MZrcm.js +2485 -0
  10. package/dist/{shared/pusher-CnhQgAvF.js → npm/chunks/pusher-DRKlokR8.js} +224 -222
  11. package/dist/npm/chunks/realtime-5SvAvTUU.js +23 -0
  12. package/dist/npm/chunks/rolldown-runtime-VHNaYcLd.js +13 -0
  13. package/dist/npm/chunks/src-DJjfvVsa.js +330 -0
  14. package/dist/npm/element.js +24 -0
  15. package/dist/npm/headless.js +3 -0
  16. package/dist/npm/index.js +3 -0
  17. package/dist/npm/react.js +17 -0
  18. package/dist/npm/svelte.js +8 -0
  19. package/dist/npm/types/adapters/react.d.ts +9 -0
  20. package/dist/npm/types/adapters/svelte.d.ts +9 -0
  21. package/dist/npm/types/adapters/vue.d.ts +46 -0
  22. package/dist/npm/types/anchor/index.d.ts +49 -0
  23. package/dist/npm/types/core/api.d.ts +29 -0
  24. package/dist/npm/types/core/auth.d.ts +48 -0
  25. package/dist/npm/types/core/client.d.ts +100 -0
  26. package/dist/npm/types/core/store.d.ts +7 -0
  27. package/dist/npm/types/core/types.d.ts +278 -0
  28. package/dist/npm/types/element.d.ts +10 -0
  29. package/dist/npm/types/headless.d.ts +7 -0
  30. package/dist/npm/types/index.d.ts +30 -0
  31. package/dist/npm/vue.js +32 -0
  32. package/package.json +65 -173
  33. package/dist/THIRD_PARTY_NOTICES.txt +0 -284
  34. package/dist/angular.es.js +0 -321
  35. package/dist/comment-kit.es.js +0 -218
  36. package/dist/demo.es.js +0 -483
  37. package/dist/headless.es.js +0 -4
  38. package/dist/preact.es.js +0 -117
  39. package/dist/qwik.es.js +0 -1
  40. package/dist/qwik.qwik.mjs +0 -114
  41. package/dist/react.es.js +0 -98
  42. package/dist/shared/ShadowRootContext-DD6a0QaI.js +0 -11
  43. package/dist/shared/annotation-icons-Dh-bmNYK.js +0 -172
  44. package/dist/shared/annotation-toolbar-zeiCmKIr.js +0 -1086
  45. package/dist/shared/attachment-refresh-DAacLaRu.js +0 -94
  46. package/dist/shared/bridge-CJoGYngu.js +0 -177
  47. package/dist/shared/button-D4GHW6oZ.js +0 -474
  48. package/dist/shared/button-group-BVR7iT-S.js +0 -91
  49. package/dist/shared/capture-privacy-CiOrcAlt.js +0 -101
  50. package/dist/shared/comment-drawing-canvas-Btc12IsS.js +0 -124
  51. package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
  52. package/dist/shared/comment-image-lightbox--QpbcAtH.js +0 -190
  53. package/dist/shared/comment-images-content-C_r4SHM-.js +0 -214
  54. package/dist/shared/comment-kit-core-CmLUFujd.js +0 -3682
  55. package/dist/shared/comment-kit-ui-BHwYuSIi.js +0 -19391
  56. package/dist/shared/comment-screenshot-annotator-zJZyO-XM.js +0 -151
  57. package/dist/shared/comment-screenshot-overlay-CoKTYB0J.js +0 -205
  58. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +0 -153
  59. package/dist/shared/createReactComponent-BZHeRbD0.js +0 -45
  60. package/dist/shared/dev-export-panel-Cnt6oCZU.js +0 -207
  61. package/dist/shared/dev-grab-B85jo9AS.js +0 -197
  62. package/dist/shared/dist-D9A5k-N4.js +0 -617
  63. package/dist/shared/dom-Bhf4WFtY.js +0 -223
  64. package/dist/shared/element-selector-Cng84xC7.js +0 -902
  65. package/dist/shared/error-boundary-D3PD74vI.js +0 -21
  66. package/dist/shared/errors-Bu5ajEmB.js +0 -22
  67. package/dist/shared/icons-nzMOLzrm.js +0 -266
  68. package/dist/shared/input-UPtAj0M6.js +0 -111
  69. package/dist/shared/mount-ui-Dz7FB_Ak.js +0 -208
  70. package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
  71. package/dist/shared/realtime-yGLX4wMK.js +0 -334
  72. package/dist/shared/request-activity-DQrAUwfA.js +0 -11
  73. package/dist/shared/screenshot-B5-hwpmt.js +0 -199
  74. package/dist/shared/separator-UhJb0Row.js +0 -3955
  75. package/dist/shared/shadow-root-B58ZI2yz.js +0 -133
  76. package/dist/shared/styles-CnYsLS2f.js +0 -2
  77. package/dist/shared/text-B4HHZNaa.js +0 -23
  78. package/dist/shared/token-session-D92MYbNu.js +0 -25
  79. package/dist/shared/useLabelableId-8n0QmH8N.js +0 -154
  80. package/dist/shared/useRender-Uxk1OPK-.js +0 -5
  81. package/dist/shared/useValueChanged-DKq5cMot.js +0 -92
  82. package/dist/shared/validation-3wbbbuX0.js +0 -70
  83. package/dist/shared/websocket-manager-KhH4hL0Q.js +0 -381
  84. package/dist/solid.es.js +0 -98
  85. package/dist/svelte.es.js +0 -130
  86. package/dist/types/adapters/bridge.d.ts +0 -122
  87. package/dist/types/angular/index.d.ts +0 -145
  88. package/dist/types/core/agent-context.d.ts +0 -17
  89. package/dist/types/core/api-client.d.ts +0 -155
  90. package/dist/types/core/comment-kit-core.d.ts +0 -254
  91. package/dist/types/core/local-demo.d.ts +0 -60
  92. package/dist/types/core/types.d.ts +0 -770
  93. package/dist/types/core/websocket-manager.d.ts +0 -125
  94. package/dist/types/core/write-access.d.ts +0 -11
  95. package/dist/types/demo.d.ts +0 -17
  96. package/dist/types/headless.d.ts +0 -8
  97. package/dist/types/index.d.ts +0 -87
  98. package/dist/types/preact/index.d.ts +0 -25
  99. package/dist/types/qwik/index.d.ts +0 -73
  100. package/dist/types/react/client.d.ts +0 -31
  101. package/dist/types/react/index.d.ts +0 -4
  102. package/dist/types/solid/index.d.ts +0 -37
  103. package/dist/types/svelte/index.d.ts +0 -55
  104. package/dist/types/utils/dom.d.ts +0 -59
  105. package/dist/types/utils/event-emitter.d.ts +0 -11
  106. package/dist/types/vue/index.d.ts +0 -87
  107. package/dist/vue.es.js +0 -148
  108. package/docs/api-reference.md +0 -405
  109. package/docs/local-demo.md +0 -60
package/dist/demo.es.js DELETED
@@ -1,483 +0,0 @@
1
- import { o as e, r as t } from "./shared/validation-3wbbbuX0.js";
2
- import { t as n, v as r } from "./shared/comment-kit-core-CmLUFujd.js";
3
- var i = 864e5, a = 512e3, o = 50, s = 20, c = "commentkit:demo:", l = {
4
- id: "local-demo-you",
5
- name: "You",
6
- email: "you@demo.invalid"
7
- };
8
- function u(e, n, r = !1) {
9
- return typeof e == "string" && (r || e.trim().length > 0) && e.length <= n && !t(e);
10
- }
11
- function d(e) {
12
- return typeof e == "string" && e.length <= 40 && Number.isFinite(Date.parse(e));
13
- }
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) {
21
- return typeof e == "string" && /^[a-zA-Z0-9_-]{1,128}$/.test(e);
22
- }
23
- function h(t) {
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));
25
- }
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 {
78
- id: t.id,
79
- content: t.content,
80
- createdAt: t.createdAt,
81
- author: { ...l },
82
- reactions: n,
83
- mentions: r,
84
- ...a ? { replyTo: a } : {},
85
- ...t.isEdited === !0 ? { isEdited: !0 } : {}
86
- };
87
- }
88
- function b(t) {
89
- if (!e(t) || !m(t.id) || t.type !== "pin" || !u(t.content, 1e4) || !h(t.position) || ![
90
- "open",
91
- "resolved",
92
- "complete"
93
- ].includes(t.status) || ![
94
- "low",
95
- "medium",
96
- "high",
97
- "urgent"
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;
99
- let n;
100
- try {
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;
102
- } catch {
103
- return null;
104
- }
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;
107
- let i = [];
108
- if (t.checklist !== void 0) {
109
- if (!Array.isArray(t.checklist) || t.checklist.length > 25) return null;
110
- for (let n of t.checklist) {
111
- if (!e(n) || !u(n.id, 256) || !u(n.label, 500) || typeof n.done != "boolean") return null;
112
- i.push({
113
- id: n.id,
114
- label: n.label,
115
- done: n.done
116
- });
117
- }
118
- }
119
- let a = g(t.reactions), o = _(t.mentions), c = v(t.deviceInfo);
120
- return !a || !o || c === null ? null : {
121
- id: t.id,
122
- type: "pin",
123
- content: t.content,
124
- position: {
125
- x: t.position.x,
126
- y: t.position.y,
127
- ...t.position.element ? { element: t.position.element } : {},
128
- ...t.position.xpath ? { xpath: t.position.xpath } : {}
129
- },
130
- status: t.status,
131
- priority: t.priority,
132
- author: { ...l },
133
- userId: l.id,
134
- createdAt: t.createdAt,
135
- updatedAt: t.updatedAt,
136
- ...f(t.resolvedAt) ? { resolvedAt: t.resolvedAt } : {},
137
- ...f(t.completedAt) ? { completedAt: t.completedAt } : {},
138
- page: {
139
- url: n.href,
140
- path: t.page.path,
141
- title: t.page.title
142
- },
143
- replies: r,
144
- attachments: [],
145
- checklist: i,
146
- reactions: a,
147
- mentions: o,
148
- ...c ? { deviceInfo: c } : {},
149
- ...t.branch === void 0 ? {} : { branch: t.branch },
150
- assignees: Array.isArray(t.assignees) && t.assignees.some((t) => e(t) && t.id === l.id) ? [{ ...l }] : [],
151
- ...t.description === void 0 ? {} : { description: t.description },
152
- ...t.isEdited === !0 ? { isEdited: !0 } : {}
153
- };
154
- }
155
- function x() {
156
- let e = Date.now();
157
- return {
158
- version: 1,
159
- createdAt: e,
160
- expiresAt: e + i,
161
- comments: []
162
- };
163
- }
164
- var S = class {
165
- constructor(e = {}) {
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 = () => {
167
- this.sync();
168
- }, this.onStorage = (e) => {
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());
170
- }, this.client = {
171
- setProject() {},
172
- setUserEmail() {},
173
- setAuthToken() {},
174
- setEnvironment() {},
175
- setOnAuthExpired() {},
176
- validateApiKey: async () => this.unavailable(),
177
- verifySession: async () => this.unavailable(),
178
- authorizeChannel: async () => this.unavailable(),
179
- requestOtp: async () => this.unavailable(),
180
- verifyOtp: async () => this.unavailable(),
181
- verifyMfa: async () => this.unavailable(),
182
- validateInvite: async () => this.unavailable(),
183
- getComments: async (e, t = "all", n = 1, r = o, i, a) => {
184
- this.sync();
185
- 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;
186
- return {
187
- comments: s.slice(u, u + l),
188
- pagination: {
189
- total: s.length,
190
- hasMore: u + l < s.length,
191
- page: c,
192
- limit: l
193
- }
194
- };
195
- },
196
- createComment: async (e, t, n, r, i = "medium", a, o, s) => {
197
- if (e !== "pin" || s?.attachmentIds?.length) return this.unavailable();
198
- let c = (/* @__PURE__ */ new Date()).toISOString(), u = `demo-${crypto.randomUUID()}`;
199
- return this.write((a) => a.push({
200
- id: u,
201
- type: e,
202
- content: t,
203
- position: n,
204
- page: r,
205
- priority: i,
206
- status: "open",
207
- author: { ...l },
208
- userId: l.id,
209
- createdAt: c,
210
- updatedAt: c,
211
- replies: [],
212
- attachments: [],
213
- description: s?.description,
214
- checklist: s?.checklist,
215
- assignees: s?.assignees,
216
- mentions: s?.mentions,
217
- branch: s?.branch,
218
- deviceInfo: s?.deviceInfo
219
- })), this.find(this.getComments(), u);
220
- },
221
- updateComment: async (e, t) => t.attachmentIds?.length || t.drawingData || t.textSelection ? this.unavailable() : this.modify(e, (e) => {
222
- let { checklistPatch: n, ...r } = t;
223
- n && (e.checklist = e.checklist?.map((e) => e.id === n.id ? {
224
- ...e,
225
- done: n.done
226
- } : e)), Object.assign(e, r, {
227
- isEdited: !0,
228
- status: e.status,
229
- resolvedAt: e.resolvedAt,
230
- completedAt: e.completedAt
231
- }), t.status !== void 0 && p(e, t.status);
232
- }),
233
- deleteComment: async (e) => {
234
- this.write((t) => {
235
- let n = t.indexOf(this.find(t, e));
236
- t.splice(n, 1);
237
- });
238
- },
239
- addReply: async (e, t, n, r) => {
240
- if (r?.attachmentIds?.length) return this.unavailable();
241
- let i = {
242
- id: `reply-${crypto.randomUUID()}`,
243
- content: t,
244
- author: { ...l },
245
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
246
- mentions: r?.mentions
247
- }, a = this.modify(e, (e) => {
248
- r?.replyTo && (i.replyTo = this.quote(e, r.replyTo)), e.replies.push(i), p(e, "open");
249
- });
250
- return this.find(a.replies, i.id);
251
- },
252
- updateReply: async (e, t, n, i) => {
253
- if (i?.attachmentIds?.length) return this.unavailable();
254
- let a = this.modify(e, (e) => {
255
- let a = e.replies.find((e) => e.id === t);
256
- if (!a) throw new r("not_found", "This demo reply no longer exists.", 404);
257
- a.content = n, a.isEdited = !0, i?.mentions !== void 0 && (a.mentions = i.mentions), i?.replyTo && (a.replyTo = this.quote(e, i.replyTo));
258
- });
259
- return this.find(a.replies, t);
260
- },
261
- deleteReply: async (e, t) => {
262
- this.modify(e, (e) => {
263
- e.replies = e.replies.filter((e) => e.id !== t);
264
- });
265
- },
266
- resolveComment: async (e) => this.modify(e, (e) => p(e, "resolved")),
267
- unresolveComment: async (e) => this.modify(e, (e) => p(e, "open")),
268
- markComplete: async (e) => this.modify(e, (e) => p(e, "complete")),
269
- addReaction: async (e, t, n) => {
270
- this.modify(e, (e) => {
271
- let i = n ? e.replies.find((e) => e.id === n) : e;
272
- if (!i) throw new r("not_found", "This demo reply no longer exists.", 404);
273
- i.reactions = [...(i.reactions ?? []).filter((e) => e.emoji !== t), {
274
- emoji: t,
275
- count: 1,
276
- reacted: !0
277
- }];
278
- });
279
- },
280
- removeReaction: async (e, t, n) => {
281
- this.modify(e, (e) => {
282
- let i = n ? e.replies.find((e) => e.id === n) : e;
283
- if (!i) throw new r("not_found", "This demo reply no longer exists.", 404);
284
- i.reactions = (i.reactions ?? []).filter((e) => e.emoji !== t);
285
- });
286
- },
287
- updatePosition: async (e, t) => this.modify(e, (e) => {
288
- e.position = t;
289
- }),
290
- createHighlight: async () => this.unavailable(),
291
- createDrawing: async () => this.unavailable(),
292
- uploadFile: async () => this.unavailable(),
293
- uploadScreenshot: async () => this.unavailable(),
294
- uploadFiles: async () => this.unavailable(),
295
- getComment: async (e) => (this.sync(), this.find(this.getComments(), e)),
296
- getProjectContext: async () => this.unavailable(),
297
- getProjectMembers: async () => [{ ...l }]
298
- };
299
- let t = e.storageKey ?? "website-v1";
300
- if (!/^[a-zA-Z0-9:_-]{1,160}$/.test(t)) throw Error("Invalid demo storage key");
301
- this.storageKey = c + t;
302
- try {
303
- this.storage = window.localStorage;
304
- } catch {}
305
- 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);
306
- }
307
- hydrate() {
308
- if (this.storage) try {
309
- let t = this.storage.getItem(this.storageKey);
310
- if (t === this.lastSerialized) return;
311
- let n = this.lastSerialized !== null;
312
- if (this.lastSerialized = t, !t) {
313
- n && (this.data.comments = [], this.data.expiresAt = Math.min(this.data.expiresAt, Date.now()));
314
- return;
315
- }
316
- if (t.length > a) throw Error("Oversized demo");
317
- let r = JSON.parse(t);
318
- 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");
319
- let i = r.comments.map(b);
320
- if (i.some((e) => !e) || new Set(i.map((e) => e?.id)).size !== i.length) throw Error("Invalid comments");
321
- this.data = {
322
- version: 1,
323
- createdAt: r.createdAt,
324
- expiresAt: r.expiresAt,
325
- comments: i
326
- };
327
- } catch {
328
- try {
329
- this.storage.removeItem(this.storageKey);
330
- } catch {
331
- this.storage = null;
332
- }
333
- this.lastSerialized = null, this.data = x();
334
- }
335
- }
336
- persist() {
337
- let e = JSON.stringify(this.data);
338
- if (e.length > a) throw new r("demo_full", "This demo is full. Reset it to start again.", 413);
339
- if (this.storage) try {
340
- this.storage.setItem(this.storageKey, e), this.lastSerialized = e;
341
- } catch {
342
- try {
343
- this.storage.removeItem(this.storageKey);
344
- } catch {}
345
- this.storage = null;
346
- }
347
- }
348
- armExpiry() {
349
- this.timer && clearTimeout(this.timer), !this.destroyed && (this.timer = setTimeout(() => {
350
- this.timer = null, this.checkExpiry();
351
- }, Math.max(0, this.data.expiresAt - Date.now())));
352
- }
353
- sync() {
354
- if (this.destroyed) return;
355
- let e = this.lastSerialized;
356
- this.hydrate(), !this.checkExpiry() && e !== this.lastSerialized && (this.armExpiry(), this.notify("storage"));
357
- }
358
- checkExpiry() {
359
- if (this.destroyed || this.data.expiresAt > Date.now()) return this.destroyed;
360
- if (!this.expiryNotified) {
361
- if (this.expiryNotified = !0, this.data.comments = [], this.storage) try {
362
- this.storage.removeItem(this.storageKey);
363
- } catch {
364
- this.storage = null;
365
- }
366
- this.lastSerialized = null, this.notify("expired");
367
- }
368
- return !0;
369
- }
370
- getSession() {
371
- return this.checkExpiry(), {
372
- expiresAt: this.data.expiresAt,
373
- persistence: this.storage ? "localStorage" : "memory",
374
- commentCount: this.data.comments.length,
375
- expired: this.data.expiresAt <= Date.now()
376
- };
377
- }
378
- getComments() {
379
- return this.checkExpiry(), structuredClone(this.data.comments);
380
- }
381
- subscribe(e) {
382
- return this.listeners.add(e), () => this.listeners.delete(e);
383
- }
384
- refresh() {
385
- this.sync();
386
- }
387
- getRevision() {
388
- return this.revision;
389
- }
390
- notify(e) {
391
- e !== "persist" && (this.revision += 1);
392
- for (let t of this.listeners) try {
393
- t(e);
394
- } catch {}
395
- }
396
- reset() {
397
- this.destroyed || (this.expiryNotified = !1, this.data = x(), this.persist(), this.armExpiry(), this.notify("reset"));
398
- }
399
- activate() {
400
- this.checkExpiry() && this.reset();
401
- }
402
- write(e) {
403
- if (this.sync(), this.checkExpiry()) throw new r("demo_expired", "Your demo has expired. Start a new demo to continue.", 410);
404
- let t = structuredClone(this.data.comments);
405
- if (e(t), t.length > o) throw new r("demo_full", "This demo holds up to 50 comments. Reset it to start again.", 413);
406
- let n = t.map(b);
407
- if (n.some((e) => !e)) throw new r("invalid_demo_data", "The demo comment is invalid or exceeds its limit.", 400);
408
- let i = {
409
- ...this.data,
410
- comments: n
411
- };
412
- if (JSON.stringify(i).length > a) throw new r("demo_full", "This demo is full. Reset it to start again.", 413);
413
- this.data = i, this.persist(), this.notify("persist");
414
- }
415
- find(e, t) {
416
- let n = e.find((e) => e.id === t);
417
- if (!n) throw new r("not_found", "This demo comment no longer exists.", 404);
418
- return n;
419
- }
420
- modify(e, t) {
421
- return this.write((n) => {
422
- let r = this.find(n, e);
423
- t(r), r.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
424
- }), this.find(this.getComments(), e);
425
- }
426
- quote(e, t) {
427
- let n = t.type === "comment" && t.id === e.id ? e : t.type === "reply" ? e.replies.find((e) => e.id === t.id) : void 0;
428
- if (!n) throw new r("not_found", "The quoted demo comment no longer exists.", 404);
429
- return {
430
- id: n.id,
431
- type: t.type,
432
- authorName: l.name,
433
- body: n.content
434
- };
435
- }
436
- unavailable() {
437
- throw new r("demo_unavailable", "This action is unavailable in the private browser demo.", 400);
438
- }
439
- destroy() {
440
- 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);
441
- }
442
- }, C = !1;
443
- async function w(e = {}) {
444
- if (typeof window > "u" || typeof document > "u") throw Error("The CommentKit demo requires a browser");
445
- if (C || document.querySelector("[data-commentkit], [data-commentkit-host]")) throw Error("Destroy the existing CommentKit widget before starting a demo");
446
- let t = new S(e);
447
- C = !0;
448
- let r = new n({
449
- apiKey: "",
450
- ui: {
451
- ...e.ui,
452
- loadRemoteFonts: !1
453
- }
454
- }, t), i;
455
- try {
456
- let { mountCommentKitUI: e } = await import("./shared/mount-ui-Dz7FB_Ak.js").then((e) => e.n);
457
- i = await e(r);
458
- } catch (e) {
459
- throw r.destroy(), C = !1, e;
460
- }
461
- let a = !1, o = {
462
- start() {
463
- a || r.startLocalDemo();
464
- },
465
- reset() {
466
- a || (t.reset(), r.startLocalDemo());
467
- },
468
- destroy() {
469
- a || (a = !0, i.unmount(), r.destroy(), C = !1);
470
- },
471
- getSession() {
472
- return t.getSession();
473
- },
474
- getCore() {
475
- return r;
476
- },
477
- onSessionChange(e) {
478
- return t.subscribe(() => e(t.getSession()));
479
- }
480
- };
481
- return o.start(), o;
482
- }
483
- export { w as createCommentKitDemo };
@@ -1,4 +0,0 @@
1
- import { t as e } from "./shared/websocket-manager-KhH4hL0Q.js";
2
- import { _ as t, b as n, h as r, l as i, m as a, n as o, t as s, x as c, y as l } from "./shared/comment-kit-core-CmLUFujd.js";
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 { t as ApiClient, s as CommentKitCore, i as EventEmitter, o as SDK_VERSION, e as WebSocketManager, a as createAgentContext, S as debounce, _ as findElement, r as formatAgentContext, l 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, n as parseMentions, p as percentageToViewport, c as stripMentionMarkup, y as throttle, g as viewportToPercentage };
package/dist/preact.es.js DELETED
@@ -1,117 +0,0 @@
1
- import { t as e } from "./shared/comment-kit-core-CmLUFujd.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 { useEffect as o, useMemo as s, useRef as c, useState as l } from "preact/hooks";
5
- function u(u) {
6
- let d = c(null), f = c(null), p = c(u), [m, h] = l(null), [g, _] = l(null), [v, y] = l(null);
7
- p.current = u;
8
- let b = u, x = b.features, S = b.reverb, C = !!u.screenshotProvider, w = (e) => {
9
- y(e);
10
- try {
11
- p.current.onError?.(e);
12
- } catch {}
13
- }, T = s(() => t(() => d.current, (e) => {
14
- let t = a(e);
15
- y(t);
16
- try {
17
- p.current.onError?.(t);
18
- } catch {}
19
- }), []);
20
- o(() => {
21
- let t = [], r = !1, o = !1, s = () => {
22
- if (!o) {
23
- o = !0;
24
- try {
25
- p.current.onReady?.();
26
- } catch {}
27
- }
28
- }, c = () => {
29
- for (; t.length > 0;) {
30
- let e = t.pop();
31
- try {
32
- e?.();
33
- } catch {}
34
- }
35
- }, l = async (e) => {
36
- try {
37
- let { mountCommentKitUI: t } = await import("./shared/mount-ui-Dz7FB_Ak.js").then((e) => e.n);
38
- if (r || d.current !== e) return;
39
- let n = await t(e);
40
- if (r || d.current !== e) {
41
- try {
42
- n.unmount();
43
- } catch {}
44
- return;
45
- }
46
- f.current = n;
47
- } catch (t) {
48
- !r && d.current === e && w(i(t));
49
- }
50
- }, u = null;
51
- try {
52
- y(null), u = new e(p.current), d.current = u, _(u), n(T), p.current.enabled !== !1 && l(u), t.push(u.on("state:changed", (e) => {
53
- r || d.current !== u || (h(e), e.isAuthenticated && s());
54
- }), u.on("error", (e) => {
55
- r || d.current !== u || w(e);
56
- }));
57
- let i = u.getState();
58
- h(i), i.isAuthenticated && s();
59
- } catch (e) {
60
- let t = a(e);
61
- if (u && d.current === u) {
62
- d.current = null, _(null), c();
63
- try {
64
- u.destroy();
65
- } catch {}
66
- }
67
- w(t);
68
- }
69
- return () => {
70
- r = !0, c();
71
- try {
72
- f.current?.unmount();
73
- } catch {}
74
- f.current = null;
75
- let e = d.current;
76
- if (d.current = null, _(null), e) try {
77
- e.destroy();
78
- } catch {}
79
- h(null);
80
- };
81
- }, [
82
- T,
83
- u.apiKey,
84
- u.enabled,
85
- C,
86
- u.ui?.theme,
87
- u.ui?.position,
88
- b.baseUrl,
89
- b.projectId,
90
- b.environment,
91
- b.inviteToken,
92
- x?.comments,
93
- x?.drawing,
94
- x?.highlighting,
95
- x?.screenshots,
96
- x?.realtime,
97
- S?.key,
98
- S?.host,
99
- S?.port,
100
- S?.scheme
101
- ]);
102
- let E = s(() => {
103
- let e = {};
104
- for (let t of Object.keys(r)) e[t] = r[t](m);
105
- return e;
106
- }, [m]), D = g !== null && m !== null;
107
- return {
108
- ...T,
109
- ...E,
110
- state: m,
111
- core: g,
112
- isReady: D,
113
- isLoading: !D || (m?.isLoading ?? !1),
114
- error: v
115
- };
116
- }
117
- export { u as useCommentKit };
package/dist/qwik.es.js DELETED
@@ -1 +0,0 @@
1
- export * from "./qwik.qwik.mjs";