@commentkit/comment-kit 0.7.6 → 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 +30 -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-BUaiCkDJ.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-RSrb0Nku.js +0 -1086
  45. package/dist/shared/attachment-refresh-CSTYwRW-.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-DUROnio5.js +0 -77
  50. package/dist/shared/comment-drawing-canvas-DbuXP54N.js +0 -124
  51. package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
  52. package/dist/shared/comment-image-lightbox-zlIGEVA-.js +0 -190
  53. package/dist/shared/comment-images-content-aYbJb79_.js +0 -214
  54. package/dist/shared/comment-kit-core-B0k7XsMz.js +0 -3680
  55. package/dist/shared/comment-kit-ui-BXLJcZYQ.js +0 -19391
  56. package/dist/shared/comment-screenshot-annotator-ChWwYJzO.js +0 -151
  57. package/dist/shared/comment-screenshot-overlay-Bufg3rHz.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-DAZenvgD.js +0 -207
  61. package/dist/shared/dev-grab-O8q25zar.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-CYkwzfEr.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-BKaWBhKq.js +0 -208
  70. package/dist/shared/realtime-C0Z8dXXH.js +0 -334
  71. package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
  72. package/dist/shared/request-activity-DQrAUwfA.js +0 -11
  73. package/dist/shared/screenshot-B-ZfFItT.js +0 -199
  74. package/dist/shared/separator-UhJb0Row.js +0 -3955
  75. package/dist/shared/shadow-root-Cd3SLHyj.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-DplW5QDx.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-798cRDyL.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
@@ -0,0 +1,23 @@
1
+ import { n as e } from "./rolldown-runtime-VHNaYcLd.js";
2
+ //#region src/core/realtime.ts
3
+ async function t(t) {
4
+ let { default: n } = await import("./pusher-DRKlokR8.js").then((t) => /* @__PURE__ */ e(t.default, 1)), r = new n(t.key, {
5
+ wsHost: t.host,
6
+ wsPort: t.port,
7
+ wssPort: t.port,
8
+ forceTLS: t.scheme === "https",
9
+ enabledTransports: ["ws", "wss"],
10
+ disableStats: !0,
11
+ cluster: "",
12
+ channelAuthorization: {
13
+ transport: "ajax",
14
+ endpoint: "/unused",
15
+ customHandler: (e, n) => {
16
+ t.authorize(e.socketId, e.channelName).then((e) => n(null, e), (e) => n(e, null));
17
+ }
18
+ }
19
+ });
20
+ return r.subscribe(`presence-ck.project.${t.projectId}`).bind("feedback.changed", (e) => t.onFeedback(e)), r.subscribe(`private-ck.inbox.${t.inbox}`).bind("inbox.changed", (e) => t.onInbox(e.unread)), { disconnect: () => r.disconnect() };
21
+ }
22
+ //#endregion
23
+ export { t as connect };
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), s = (e, i, o, s) => {
3
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
+ get: ((e) => i[e]).bind(null, d),
5
+ enumerable: !(s = n(i, d)) || s.enumerable
6
+ });
7
+ return e;
8
+ }, c = (n, r, o) => (o = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule || !a.call(n, "default") ? t(o, "default", {
9
+ value: n,
10
+ enumerable: !0
11
+ }) : o, n));
12
+ //#endregion
13
+ export { c as n, o as t };
@@ -0,0 +1,330 @@
1
+ import { t as e } from "./client-D1vrh_5G.js";
2
+ //#region src/activation.ts
3
+ var t = "commentkit:active";
4
+ function n(e = location.origin) {
5
+ let t = new URL(e).hostname;
6
+ return t === "localhost" || t === "127.0.0.1" || t === "[::1]" || t.endsWith(".localhost") || t.endsWith(".test");
7
+ }
8
+ function r(e, t = !0) {
9
+ if (!t || n()) return !0;
10
+ let r = new URLSearchParams(location.search);
11
+ if (r.has("ck") || r.has("ck_thread") || r.has("ck_code")) return !0;
12
+ try {
13
+ return !!localStorage.getItem(`commentkit:v1:${e}`) || localStorage.getItem("commentkit:active") === "1";
14
+ } catch {
15
+ return !1;
16
+ }
17
+ }
18
+ function i(e) {
19
+ try {
20
+ e ? localStorage.setItem(t, "1") : localStorage.removeItem(t);
21
+ } catch {}
22
+ }
23
+ function a(e) {
24
+ let t = (t) => {
25
+ (t.metaKey || t.ctrlKey) && t.shiftKey && t.key.toLowerCase() === "k" && (t.preventDefault(), e());
26
+ };
27
+ return addEventListener("keydown", t), () => removeEventListener("keydown", t);
28
+ }
29
+ //#endregion
30
+ //#region src/capture/diagnostics.ts
31
+ var o = 20, s = /^(token|access_token|id_token|refresh_token|code|key|api_key|apikey|secret|password|pass|auth|session|sig|signature|x-amz-[a-z-]+|ck_invite)$/i, c = [], l = [], u = !1;
32
+ function d(e) {
33
+ if (u) return () => void 0;
34
+ u = !0;
35
+ let t = [];
36
+ if (e.console) {
37
+ for (let e of ["error", "warn"]) {
38
+ let n = console[e];
39
+ console[e] = (...t) => {
40
+ m(c, {
41
+ level: e,
42
+ message: g(t.map(_).join(" ")).slice(0, 1e3),
43
+ at: (/* @__PURE__ */ new Date()).toISOString()
44
+ }), n.apply(console, t);
45
+ }, t.push(() => console[e] = n);
46
+ }
47
+ let e = (e) => m(c, {
48
+ level: "error",
49
+ message: g(e.message || String(e.error)).slice(0, 1e3),
50
+ at: (/* @__PURE__ */ new Date()).toISOString()
51
+ }), n = (e) => m(c, {
52
+ level: "error",
53
+ message: g(`Unhandled promise rejection: ${_(e.reason)}`).slice(0, 1e3),
54
+ at: (/* @__PURE__ */ new Date()).toISOString()
55
+ });
56
+ addEventListener("error", e), addEventListener("unhandledrejection", n), t.push(() => removeEventListener("error", e), () => removeEventListener("unhandledrejection", n));
57
+ }
58
+ if (e.network && typeof fetch == "function") {
59
+ let e = window.fetch;
60
+ window.fetch = async (...t) => {
61
+ let n = performance.now(), r = (t[1]?.method ?? (t[0] instanceof Request ? t[0].method : "GET")).toUpperCase(), i = t[0] instanceof Request ? t[0].url : String(t[0]);
62
+ try {
63
+ let a = await e(...t);
64
+ return a.status >= 400 && p(r, i, a.status, n), a;
65
+ } catch (e) {
66
+ throw p(r, i, 0, n), e;
67
+ }
68
+ }, t.push(() => window.fetch = e);
69
+ }
70
+ return () => {
71
+ t.forEach((e) => e()), u = !1;
72
+ };
73
+ }
74
+ function f() {
75
+ return {
76
+ console: c.length ? [...c] : void 0,
77
+ network: l.length ? [...l] : void 0
78
+ };
79
+ }
80
+ function p(e, t, n, r) {
81
+ t.includes("/api/v1/") || m(l, {
82
+ method: e.slice(0, 10),
83
+ url: h(t).slice(0, 2e3),
84
+ status: n,
85
+ duration_ms: Math.round(performance.now() - r)
86
+ });
87
+ }
88
+ function m(e, t) {
89
+ e.push(t), e.length > o && e.shift();
90
+ }
91
+ function h(e) {
92
+ try {
93
+ let t = new URL(e, location.href);
94
+ t.username = "", t.password = "";
95
+ for (let e of [...t.searchParams.keys()]) s.test(e) && t.searchParams.set(e, "[redacted]");
96
+ return t.toString();
97
+ } catch {
98
+ return "[unparseable url]";
99
+ }
100
+ }
101
+ function g(e) {
102
+ return e.replace(/Bearer\s+[A-Za-z0-9._~+/-]+=*/gi, "Bearer [redacted]").replace(/eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]+/g, "[redacted-jwt]").replace(/https?:\/\/[^\s"'<>]+/g, (e) => h(e));
103
+ }
104
+ function _(e) {
105
+ if (e instanceof Error) return `${e.name}: ${e.message}`;
106
+ if (typeof e == "string") return e;
107
+ try {
108
+ return JSON.stringify(e)?.slice(0, 500) ?? String(e);
109
+ } catch {
110
+ return String(e);
111
+ }
112
+ }
113
+ //#endregion
114
+ //#region src/ui/i18n.ts
115
+ var v = {
116
+ launcher: "Feedback",
117
+ launcherHint: "Leave feedback on this page",
118
+ comment: "Comment",
119
+ commentHint: "Click anything on the page to comment on it",
120
+ inbox: "Inbox",
121
+ close: "Close",
122
+ cancel: "Cancel",
123
+ send: "Send",
124
+ sending: "Sending…",
125
+ reply: "Reply",
126
+ replyPlaceholder: "Write a reply…",
127
+ composerPlaceholder: "What should change here? Be as specific as you like.",
128
+ modeBar: "Click anything to comment · Drag to mark an area · Esc to stop",
129
+ modeBarTouch: "Tap anything to comment · Scroll as usual · Select text first to quote it",
130
+ commentOnPage: "Comment on the whole page",
131
+ commentFocused: "Comment on the selected part",
132
+ attach: "Attach a file",
133
+ screenshot: "Screenshot",
134
+ screenshotIncluded: "A screenshot of what you see is included automatically.",
135
+ screenshotRemove: "Don't include screenshot",
136
+ screenshotAdd: "Include screenshot",
137
+ markup: "Draw on screenshot",
138
+ markupDone: "Done drawing",
139
+ capturing: "Taking screenshot…",
140
+ uploadFailed: "The file could not be attached. You can still send your comment.",
141
+ signInToSend: "One last step: tell us who you are",
142
+ signInExplain: "We open a small window so you can confirm your email. You only do this once on this device.",
143
+ signIn: "Continue",
144
+ signInMember: "Sign in",
145
+ signOut: "Sign out",
146
+ popupBlocked: "Your browser blocked the sign-in window. Click the button again, or allow pop-ups for this site.",
147
+ signInCancelled: "Sign-in was closed before it finished. Your comment is still here.",
148
+ sent: "Sent! The team has been notified.",
149
+ sentGuest: "Sent! We'll email you when someone replies.",
150
+ thisPage: "This page",
151
+ allPages: "All pages",
152
+ notifications: "Notifications",
153
+ nothingHere: "No feedback on this page yet.",
154
+ nothingHereHint: "Click Comment, then click anything on the page.",
155
+ allCaughtUp: "You're all caught up.",
156
+ search: "Search feedback",
157
+ detached: "We can't find this spot on the page anymore. It may have changed since the comment was left.",
158
+ moved: "This part of the page changed since the comment was left.",
159
+ otherScreen: "Left on a {width}px wide screen",
160
+ status_open: "Open",
161
+ status_in_progress: "In progress",
162
+ status_in_review: "Ready for review",
163
+ status_resolved: "Resolved",
164
+ status_closed: "Closed",
165
+ resolve: "Resolve",
166
+ resolveHint: "Mark this as fixed",
167
+ reopen: "Reopen",
168
+ markInProgress: "Start working",
169
+ markInReview: "Ready for review",
170
+ closeThread: "Close without changes",
171
+ reviewAsk: "The team thinks this is fixed. Does it look right to you?",
172
+ looksGood: "Looks good — resolve",
173
+ notYet: "Not yet — reply",
174
+ copyLink: "Copy link",
175
+ copied: "Copied",
176
+ copyForAgent: "Copy for AI agent",
177
+ copiedForAgent: "Copied. Paste it into your AI coding agent.",
178
+ delete: "Delete",
179
+ deleteConfirm: "Delete this feedback for everyone? This can't be undone.",
180
+ edit: "Edit",
181
+ edited: "edited",
182
+ save: "Save",
183
+ mute: "Stop notifications",
184
+ unmute: "Notify me",
185
+ assign: "Assign",
186
+ unassigned: "Unassigned",
187
+ priority: "Priority",
188
+ readOnly: "Feedback is read-only right now because the workspace plan has ended. You can still read everything.",
189
+ offline: "You're offline. We'll keep your draft until you're back.",
190
+ offlineSend: "You're offline. Your comment is saved here; send it when you're back online.",
191
+ errorGeneric: "Something went wrong. Please try again.",
192
+ loadFailed: "We couldn't load the feedback. Check your connection and try again.",
193
+ sendFailed: "Your comment wasn't sent yet. It's still here, so you can try again.",
194
+ retry: "Try again",
195
+ loadingThread: "Loading the conversation…",
196
+ readOnlyReply: "You can read this conversation, but replies are turned off right now.",
197
+ noReplyAccess: "You can read this feedback, but you don't have permission to reply.",
198
+ notOnPage: "Not found on this page",
199
+ more: "More",
200
+ allStatuses: "All",
201
+ markAllRead: "Mark all as read",
202
+ messageCount: "{n} messages",
203
+ messageCountOne: "1 message",
204
+ kind_mention: "mentioned you",
205
+ kind_reply: "replied",
206
+ kind_assigned: "assigned you",
207
+ kind_ready_for_review: "asked you to check a fix",
208
+ kind_reopened: "reopened",
209
+ kind_resolved: "resolved",
210
+ kind_closed: "closed",
211
+ kind_new_feedback: "left feedback",
212
+ kind_due_soon: "reminds you this is due soon",
213
+ kind_overdue: "reminds you this is overdue",
214
+ kind_agent_request: "wants your approval",
215
+ branchFilter: "Which branch to show",
216
+ thisBranch: "This branch ({branch})",
217
+ allBranches: "All branches",
218
+ onBranch: "on {branch}",
219
+ leftOnBranch: "Left on {branch}{commit}",
220
+ welcomeTitle: "You're invited to give feedback",
221
+ welcomeBody: "Click Comment, then click anything on this page that should change. Your comment stays pinned to that exact spot.",
222
+ welcomeStart: "Show me how",
223
+ tourStep1: "Click Comment",
224
+ tourStep2: "Click the part of the page you want to talk about",
225
+ tourStep3: "Write what should change and press Send",
226
+ gotIt: "Got it",
227
+ shortcuts: "Shortcuts: C to comment, J / K for next or previous, E to resolve, Esc to close, Cmd/Ctrl + Shift + K to show or hide",
228
+ justNow: "just now",
229
+ minutesAgo: "{n} min ago",
230
+ hoursAgo: "{n} h ago",
231
+ daysAgo: "{n} d ago",
232
+ loadingEarlier: "Loading…",
233
+ you: "You",
234
+ team: "Team"
235
+ }, y = { en: v }, b = v;
236
+ function x(e) {
237
+ b = y[(e ?? navigator.language ?? "en").toLowerCase().split("-")[0] ?? "en"] ?? v;
238
+ }
239
+ function S(e, t = {}) {
240
+ return (b[e] ?? v[e]).replace(/\{(\w+)\}/g, (e, n) => String(t[n] ?? ""));
241
+ }
242
+ function C() {
243
+ let e = document.documentElement.dir || document.body?.dir;
244
+ return e === "rtl" || e === "ltr" ? e : /^(ar|he|fa|ur|ps|yi)(-|$)/i.test(document.documentElement.lang || navigator.language || "") ? "rtl" : "ltr";
245
+ }
246
+ function w(e) {
247
+ let t = Math.max(0, (Date.now() - new Date(e).getTime()) / 1e3);
248
+ return t < 60 ? S("justNow") : t < 3600 ? S("minutesAgo", { n: Math.floor(t / 60) }) : t < 86400 ? S("hoursAgo", { n: Math.floor(t / 3600) }) : t < 2592e3 ? S("daysAgo", { n: Math.floor(t / 86400) }) : new Date(e).toLocaleDateString();
249
+ }
250
+ //#endregion
251
+ //#region src/index.ts
252
+ var T = null;
253
+ function E() {
254
+ let e = (e) => typeof e == "string" && e.trim() ? e.trim().slice(0, 255) : null;
255
+ try {
256
+ let t = typeof __COMMENTKIT_BUILD__ < "u" ? __COMMENTKIT_BUILD__ : globalThis.__COMMENTKIT_BUILD__;
257
+ if (typeof t == "string" && (t = JSON.parse(t)), !t || typeof t != "object") return {
258
+ branch: null,
259
+ commit: null
260
+ };
261
+ let n = t;
262
+ return {
263
+ branch: e(n.branch),
264
+ commit: e(n.commit)
265
+ };
266
+ } catch {
267
+ return {
268
+ branch: null,
269
+ commit: null
270
+ };
271
+ }
272
+ }
273
+ function D(t) {
274
+ if (T) return T;
275
+ if (typeof window > "u") return O(t);
276
+ if (!t?.project || !/^pk_(live|test)_[a-z0-9]{20,40}$/.test(t.project)) return console.warn("[CommentKit] init() needs your publishable project key (pk_live_… or pk_test_…). Find it in Project settings → Install."), O(t);
277
+ let n = E(), o = {
278
+ ...t,
279
+ branch: t.branch || n.branch,
280
+ commit: t.commit || n.commit
281
+ };
282
+ x(o.locale);
283
+ let s = new e(o), c = null, l = null, u = null, f = () => c ? Promise.resolve() : (u ?? (u = (async () => {
284
+ try {
285
+ let e = await s.loadConfig();
286
+ if (!e.enabled) return;
287
+ await s.auth.completeRedirect().catch(() => !1), await s.loadSession().catch(() => null), l = d({
288
+ console: e.features.console_capture,
289
+ network: e.features.network_capture
290
+ });
291
+ let { mountWidget: t } = await import("./mount-Ce1MZrcm.js");
292
+ c = t(s), s.emit("ready", { session: s.state.get().session });
293
+ } catch (e) {
294
+ console.warn("[CommentKit] The widget could not start.", e);
295
+ } finally {
296
+ u = null;
297
+ }
298
+ })()), u), p = () => {
299
+ c?.(), c = null, l?.(), l = null;
300
+ }, m = a(() => {
301
+ c ? (p(), i(!1)) : (i(!0), f());
302
+ });
303
+ return r(o.project, o.hideOnProduction ?? !0) && f(), T = {
304
+ client: s,
305
+ show: f,
306
+ hide: p,
307
+ signIn: async () => await s.signIn() === "signed_in",
308
+ signOut: () => s.signOut(),
309
+ session: () => s.state.get().session,
310
+ on: (e, t) => s.on(e, t),
311
+ destroy() {
312
+ p(), m(), s.destroy(), T = null;
313
+ }
314
+ }, T;
315
+ }
316
+ function O(e) {
317
+ let t = async () => void 0;
318
+ return {
319
+ client: void 0,
320
+ show: t,
321
+ hide: () => void 0,
322
+ signIn: async () => !1,
323
+ signOut: t,
324
+ session: () => null,
325
+ on: () => () => void 0,
326
+ destroy: () => void 0
327
+ };
328
+ }
329
+ //#endregion
330
+ export { f as a, C as i, w as n, S as r, D as t };
@@ -0,0 +1,24 @@
1
+ import { t as e } from "./chunks/src-DJjfvVsa.js";
2
+ import { s as t } from "./chunks/client-D1vrh_5G.js";
3
+ //#region src/element.ts
4
+ var n = class extends HTMLElement {
5
+ constructor(...e) {
6
+ super(...e), t(this, "kit", null);
7
+ }
8
+ connectedCallback() {
9
+ let t = this.getAttribute("project");
10
+ t && (this.kit = e({
11
+ project: t,
12
+ branch: this.getAttribute("branch"),
13
+ commit: this.getAttribute("commit"),
14
+ endpoint: this.getAttribute("endpoint") ?? void 0,
15
+ theme: this.getAttribute("theme") ?? void 0
16
+ }));
17
+ }
18
+ disconnectedCallback() {
19
+ this.kit?.destroy(), this.kit = null;
20
+ }
21
+ };
22
+ t(n, "observedAttributes", ["project"]), typeof customElements < "u" && !customElements.get("comment-kit") && customElements.define("comment-kit", n);
23
+ //#endregion
24
+ export { n as CommentKitElement };
@@ -0,0 +1,3 @@
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./chunks/client-D1vrh_5G.js";
2
+ import { i as o, r as s, t as c } from "./chunks/anchor-DT-Ynhh1.js";
3
+ export { e as ApiClient, t as AuthManager, a as CommentKitClient, r as CommentKitError, n as SDK_VERSION, c as createAnchor, i as currentPageUrl, s as resolveAnchor, o as stableSelector };
@@ -0,0 +1,3 @@
1
+ import { t as e } from "./chunks/src-DJjfvVsa.js";
2
+ import { n as t, o as n } from "./chunks/client-D1vrh_5G.js";
3
+ export { n as CommentKitError, t as SDK_VERSION, e as init };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { t as e } from "./chunks/src-DJjfvVsa.js";
3
+ import { useEffect as t } from "react";
4
+ //#region src/adapters/react.tsx
5
+ function n(n) {
6
+ return t(() => {
7
+ let t = e(n);
8
+ return () => t.destroy();
9
+ }, [
10
+ n.project,
11
+ n.branch,
12
+ n.commit,
13
+ n.endpoint
14
+ ]), null;
15
+ }
16
+ //#endregion
17
+ export { n as CommentKit, n as default, e as init };
@@ -0,0 +1,8 @@
1
+ import { t as e } from "./chunks/src-DJjfvVsa.js";
2
+ //#region src/adapters/svelte.ts
3
+ function t(t, n) {
4
+ let r = e(n);
5
+ return { destroy: () => r.destroy() };
6
+ }
7
+ //#endregion
8
+ export { t as commentkit, e as init };
@@ -0,0 +1,9 @@
1
+ import { init, type CommentKitOptions } from "../index.js";
2
+ /**
3
+ * React / Next.js. Put it once in your root layout:
4
+ * <CommentKit project="pk_live_…" branch={process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF} />
5
+ * Renders nothing itself; the widget lives in its own Shadow DOM.
6
+ */
7
+ export declare function CommentKit(props: CommentKitOptions): null;
8
+ export default CommentKit;
9
+ export { init };
@@ -0,0 +1,9 @@
1
+ import { init, type CommentKitOptions } from "../index.js";
2
+ /**
3
+ * Svelte / SvelteKit: <svelte:body use:commentkit={{ project: "pk_live_…" }} />
4
+ * or call init() inside onMount.
5
+ */
6
+ export declare function commentkit(_node: HTMLElement, options: CommentKitOptions): {
7
+ destroy: () => void;
8
+ };
9
+ export { init };
@@ -0,0 +1,46 @@
1
+ import { type App, type PropType } from "vue";
2
+ import { init, type CommentKitOptions } from "../index.js";
3
+ /** <CommentKit project="pk_live_…" /> — or app.use(CommentKitPlugin, { project }) */
4
+ export declare const CommentKit: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
5
+ project: {
6
+ type: StringConstructor;
7
+ required: true;
8
+ };
9
+ branch: {
10
+ type: PropType<string | null>;
11
+ default: null;
12
+ };
13
+ commit: {
14
+ type: PropType<string | null>;
15
+ default: null;
16
+ };
17
+ endpoint: {
18
+ type: StringConstructor;
19
+ default: undefined;
20
+ };
21
+ }>, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
22
+ project: {
23
+ type: StringConstructor;
24
+ required: true;
25
+ };
26
+ branch: {
27
+ type: PropType<string | null>;
28
+ default: null;
29
+ };
30
+ commit: {
31
+ type: PropType<string | null>;
32
+ default: null;
33
+ };
34
+ endpoint: {
35
+ type: StringConstructor;
36
+ default: undefined;
37
+ };
38
+ }>> & Readonly<{}>, {
39
+ branch: string | null;
40
+ commit: string | null;
41
+ endpoint: string;
42
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
43
+ export declare const CommentKitPlugin: {
44
+ install(_app: App, options: CommentKitOptions): void;
45
+ };
46
+ export { init };
@@ -0,0 +1,49 @@
1
+ import type { Anchor } from "../core/types.js";
2
+ /**
3
+ * Anchoring: remember where feedback points so it can be found again after the
4
+ * page changes (new deploys, reordered lists, different breakpoints).
5
+ *
6
+ * Strategies, strongest first:
7
+ * 1. data-ck-id developer-provided stable id
8
+ * 2. data-ck-src build-time source location (dev/preview builds)
9
+ * 3. selector stable CSS path (ids, test ids, aria) avoiding hashed classes
10
+ * 4. xpath structural path
11
+ * 5. fingerprint normalized text of the element, fuzzy matched
12
+ * 6. page raw coordinates (last resort)
13
+ */
14
+ export type AnchorState = "anchored" | "moved" | "detached";
15
+ export interface ResolvedAnchor {
16
+ state: AnchorState;
17
+ element: Element | null;
18
+ /** Pin point in document coordinates (px). */
19
+ point: {
20
+ x: number;
21
+ y: number;
22
+ };
23
+ /** Region in document coordinates, for region and text anchors. */
24
+ rect: {
25
+ x: number;
26
+ y: number;
27
+ w: number;
28
+ h: number;
29
+ } | null;
30
+ }
31
+ export declare function isWidgetElement(el: Element | null): boolean;
32
+ export interface AnchorInput {
33
+ element: Element;
34
+ /** Click or drag-start point in viewport coordinates. */
35
+ clientX: number;
36
+ clientY: number;
37
+ /** Drag end for region comments, viewport coordinates. */
38
+ endX?: number;
39
+ endY?: number;
40
+ /** Selected text for text comments. */
41
+ quote?: string | null;
42
+ }
43
+ export declare function createAnchor(input: AnchorInput): Anchor;
44
+ export declare function stableSelector(el: Element): string | null;
45
+ export declare function xpathOf(el: Element): string | null;
46
+ export declare function fingerprint(el: Element): string | null;
47
+ export declare function resolveAnchor(anchor: Anchor, root?: ParentNode): ResolvedAnchor;
48
+ /** Dice coefficient on character bigrams: 1 = identical, 0 = nothing in common. */
49
+ export declare function similarity(a: string | null | undefined, b: string | null | undefined): number;
@@ -0,0 +1,29 @@
1
+ export interface ApiRequest {
2
+ method?: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
3
+ query?: Record<string, string | number | boolean | null | undefined>;
4
+ body?: unknown;
5
+ /** Adds an Idempotency-Key so retried creates never duplicate. */
6
+ idempotent?: boolean;
7
+ headers?: Record<string, string>;
8
+ /** Skip the Authorization header (public endpoints). */
9
+ anonymous?: boolean;
10
+ signal?: AbortSignal;
11
+ }
12
+ export type TokenProvider = {
13
+ accessToken(): Promise<string | null>;
14
+ /** Called once on a 401; returns true if a fresh token is now available. */
15
+ recover(): Promise<boolean>;
16
+ };
17
+ /**
18
+ * Thin fetch wrapper for /api/v1: JSON in/out, problem+json errors as
19
+ * CommentKitError, one silent re-auth on 401, and bounded retries with
20
+ * backoff for transient failures (network, 429, 5xx).
21
+ */
22
+ export declare class ApiClient {
23
+ private readonly baseUrl;
24
+ private readonly tokens;
25
+ private readonly sdkVersion;
26
+ constructor(baseUrl: string, tokens: TokenProvider, sdkVersion: string);
27
+ request<T>(path: string, options?: ApiRequest): Promise<T>;
28
+ url(path: string, query?: ApiRequest["query"]): string;
29
+ }
@@ -0,0 +1,48 @@
1
+ export type SignInResult = "signed_in" | "popup_blocked" | "cancelled" | "failed" | "redirecting";
2
+ export type AuthMode = "auto" | "popup" | "redirect";
3
+ /** In-app browsers (WhatsApp, Instagram, Slack…) open "popups" in the same view, so use a full-page redirect there. */
4
+ export declare function prefersRedirect(ua?: string): boolean;
5
+ /**
6
+ * Widget sign-in: a popup on the CommentKit domain (credentials never touch
7
+ * this page), PKCE, short-lived access tokens and a rotating refresh token.
8
+ *
9
+ * The refresh token is kept in localStorage under a key scoped to the project.
10
+ * It only works from this exact origin, rotates on every use, and replaying an
11
+ * old one revokes the whole session server-side.
12
+ */
13
+ export declare class AuthManager {
14
+ private readonly endpoint;
15
+ private readonly projectKey;
16
+ private readonly origin;
17
+ private access;
18
+ private refreshing;
19
+ private listeners;
20
+ constructor(endpoint: string, projectKey: string, origin?: string);
21
+ get storageKey(): string;
22
+ hasSession(): boolean;
23
+ onChange(listener: (signedIn: boolean) => void): () => void;
24
+ /** A valid access token, refreshing if needed. null when signed out. */
25
+ accessToken(): Promise<string | null>;
26
+ recover(): Promise<boolean>;
27
+ /** Must be called from a user gesture (click) so the popup is allowed. */
28
+ signIn(options?: {
29
+ share?: string | null;
30
+ mode?: AuthMode;
31
+ }): Promise<SignInResult>;
32
+ /**
33
+ * Finish a redirect sign-in when the page loads with ?ck_code=&ck_state=.
34
+ * Returns true when a session was created. Removes the params from the URL.
35
+ */
36
+ completeRedirect(): Promise<boolean>;
37
+ private get pkceKey();
38
+ private authorizeUrl;
39
+ private redirect;
40
+ signOut(): Promise<void>;
41
+ private awaitCode;
42
+ private refresh;
43
+ private store;
44
+ private clear;
45
+ private readRefresh;
46
+ private emit;
47
+ private post;
48
+ }