@commentkit/comment-kit 1.0.0-beta.0 → 1.0.0-beta.2

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 (49) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +102 -8
  3. package/SECURITY.md +7 -2
  4. package/dist/npm/chunks/Guest-CKoV6pEK.js +157 -0
  5. package/dist/npm/chunks/MarkupEditor-DAo4qppg.js +199 -0
  6. package/dist/npm/chunks/Panel-BRBDHlGg.js +399 -0
  7. package/dist/npm/chunks/Shortcuts-CHMcrjAM.js +56 -0
  8. package/dist/npm/chunks/ThreadCard-D8FzIxbs.js +570 -0
  9. package/dist/npm/chunks/ar-D3SPpN1T.js +195 -0
  10. package/dist/npm/chunks/{client-D1vrh_5G.js → client-D1NizpDK.js} +86 -49
  11. package/dist/npm/chunks/de-C8eC6c6f.js +187 -0
  12. package/dist/npm/chunks/es-Bczf42tm.js +187 -0
  13. package/dist/npm/chunks/extension--it1LAj-.js +54 -0
  14. package/dist/npm/chunks/extension-XfuRGu2o.js +26 -0
  15. package/dist/npm/chunks/format-Bw_tNOh9.js +524 -0
  16. package/dist/npm/chunks/fr-BaQw-v2e.js +187 -0
  17. package/dist/npm/chunks/hi-BamV-yXv.js +187 -0
  18. package/dist/npm/chunks/{html2canvas-_mjSRP3G.js → html2canvas-DfGb8yka.js} +1145 -1132
  19. package/dist/npm/chunks/it-DC14_EjN.js +187 -0
  20. package/dist/npm/chunks/ja-B1mmTN7Y.js +187 -0
  21. package/dist/npm/chunks/mount-5fFig0k6.js +1447 -0
  22. package/dist/npm/chunks/nl-BfhqUsmX.js +187 -0
  23. package/dist/npm/chunks/privacy-DLhezjyi.js +30 -0
  24. package/dist/npm/chunks/pt-BR-CEPu4W5U.js +187 -0
  25. package/dist/npm/chunks/{pusher-DRKlokR8.js → pusher-BSsQoE1K.js} +1 -1
  26. package/dist/npm/chunks/realtime-CBRW9BB3.js +34 -0
  27. package/dist/npm/chunks/report-Dh4fxd4J.js +27 -0
  28. package/dist/npm/chunks/{rolldown-runtime-VHNaYcLd.js → rolldown-runtime-Y_bBpyJl.js} +10 -3
  29. package/dist/npm/chunks/src-DujplxfI.js +517 -0
  30. package/dist/npm/chunks/zh-CN-kgqjYwHQ.js +187 -0
  31. package/dist/npm/element.js +28 -11
  32. package/dist/npm/headless.js +2 -2
  33. package/dist/npm/index.js +3 -3
  34. package/dist/npm/react.js +12 -3
  35. package/dist/npm/svelte.js +12 -3
  36. package/dist/npm/types/adapters/react.d.ts +2 -0
  37. package/dist/npm/types/adapters/svelte.d.ts +1 -1
  38. package/dist/npm/types/adapters/vue.d.ts +72 -0
  39. package/dist/npm/types/core/api.d.ts +2 -0
  40. package/dist/npm/types/core/auth.d.ts +42 -3
  41. package/dist/npm/types/core/client.d.ts +15 -1
  42. package/dist/npm/types/core/types.d.ts +31 -6
  43. package/dist/npm/types/element.d.ts +4 -1
  44. package/dist/npm/types/index.d.ts +3 -1
  45. package/dist/npm/vue.js +46 -7
  46. package/package.json +8 -2
  47. package/dist/npm/chunks/mount-Ce1MZrcm.js +0 -2485
  48. package/dist/npm/chunks/realtime-5SvAvTUU.js +0 -23
  49. package/dist/npm/chunks/src-DJjfvVsa.js +0 -330
@@ -0,0 +1,187 @@
1
+ //#region src/ui/locales/zh-CN.ts
2
+ var e = {
3
+ comment: "评论",
4
+ commentHint: "点击页面上的任意位置即可评论",
5
+ inbox: "收件箱",
6
+ close: "关闭",
7
+ cancel: "取消",
8
+ send: "发送",
9
+ sending: "正在发送…",
10
+ reply: "回复",
11
+ replyPlaceholder: "写下回复…",
12
+ composerPlaceholder: "这里需要怎么改?写得越具体越好。",
13
+ modeBar: "点击任意位置评论 · 拖动可框选区域 · 先选中文字可引用 · 按 Esc 退出",
14
+ modeBarTouch: "轻点任意位置评论 · 照常滚动 · 先选中文字可引用",
15
+ commentOnPage: "评论整个页面",
16
+ commentFocused: "评论选中的部分",
17
+ attach: "添加附件",
18
+ screenshot: "截图",
19
+ screenshotIncluded: "会自动附上你当前看到的画面截图。",
20
+ screenshotRemove: "不附截图",
21
+ screenshotAdd: "附上截图",
22
+ markup: "在截图上标注",
23
+ markupDone: "标注完成",
24
+ tool_arrow: "箭头",
25
+ tool_rect: "方框",
26
+ tool_pen: "画笔",
27
+ tool_blur: "遮挡",
28
+ tool_text: "文字",
29
+ markupTextPrompt: "备注写什么?",
30
+ undo: "撤销",
31
+ color_red: "红色",
32
+ color_orange: "橙色",
33
+ color_green: "绿色",
34
+ color_blue: "蓝色",
35
+ color_black: "黑色",
36
+ capturing: "正在截图…",
37
+ uploadFailed: "文件没能添加。你仍然可以发送评论。",
38
+ signInToSend: "最后一步:告诉我们你是谁",
39
+ signInExplain: "我们会打开一个小窗口,请你确认邮箱。在这台设备上只需要做一次。",
40
+ signIn: "继续",
41
+ signInMember: "登录",
42
+ signOut: "退出登录",
43
+ popupBlocked: "浏览器拦截了登录窗口。请再点一次按钮,或允许本网站弹出窗口。",
44
+ signInCancelled: "登录窗口在完成前被关闭了。你的评论还在。",
45
+ sent: "已发送!团队已收到通知。",
46
+ sentGuest: "已发送!有人回复时我们会发邮件告诉你。",
47
+ thisPage: "当前页面",
48
+ allPages: "所有页面",
49
+ notifications: "通知",
50
+ nothingHere: "这个页面还没有反馈。",
51
+ nothingHereHint: "点击“评论”,然后点击页面上的任意位置。",
52
+ allCaughtUp: "没有新消息了。",
53
+ search: "搜索反馈",
54
+ detached: "页面上已经找不到这个位置了。评论之后页面可能有改动。",
55
+ moved: "评论之后,页面的这部分有改动。",
56
+ status_open: "待处理",
57
+ status_in_progress: "处理中",
58
+ status_in_review: "待确认",
59
+ status_resolved: "已解决",
60
+ status_closed: "已关闭",
61
+ resolve: "解决",
62
+ resolveHint: "标记为已修复",
63
+ reopen: "重新打开",
64
+ markInProgress: "开始处理",
65
+ markInReview: "请求确认",
66
+ closeThread: "不做修改直接关闭",
67
+ reviewAsk: "团队认为已经修好了。你看可以吗?",
68
+ looksGood: "可以了 — 解决",
69
+ notYet: "还不行 — 回复",
70
+ copyLink: "复制链接",
71
+ copied: "已复制",
72
+ copyForAgent: "复制给 AI 助手",
73
+ copiedForAgent: "已复制。粘贴到你的 AI 编程助手里即可。",
74
+ delete: "删除",
75
+ deleteConfirm: "要为所有人删除这条反馈吗?回复和截图也会一起删除。",
76
+ edit: "编辑",
77
+ edited: "已编辑",
78
+ save: "保存",
79
+ mute: "不再通知",
80
+ unmute: "通知我",
81
+ unassigned: "未指派",
82
+ readOnly: "工作区的套餐已到期,反馈目前只能查看。你仍然可以阅读所有内容。",
83
+ offline: "你已离线。草稿会一直保留,直到你恢复联网。",
84
+ offlineSend: "你已离线。评论已保存在这里,恢复联网后再发送即可。",
85
+ errorGeneric: "出了点问题,请重试。",
86
+ loadFailed: "反馈加载失败。请检查网络后重试。",
87
+ sendFailed: "评论还没发出去。内容还在,可以再试一次。",
88
+ retry: "重试",
89
+ loadingThread: "正在加载对话…",
90
+ readOnlyReply: "你可以查看这段对话,但目前无法回复。",
91
+ noReplyAccess: "你可以查看这条反馈,但没有回复权限。",
92
+ notOnPage: "当前页面上找不到",
93
+ more: "更多",
94
+ allStatuses: "全部",
95
+ markAllRead: "全部标为已读",
96
+ messageCount: "{n} 条消息",
97
+ messageCount_one: "{n} 条消息",
98
+ kind_mention: "提到了你",
99
+ kind_reply: "回复了",
100
+ kind_assigned: "指派给了你",
101
+ kind_ready_for_review: "请你确认一个修复",
102
+ kind_reopened: "重新打开了",
103
+ kind_resolved: "解决了",
104
+ kind_closed: "关闭了",
105
+ kind_new_feedback: "提交了反馈",
106
+ kind_due_soon: "提醒你:快到期了",
107
+ kind_overdue: "提醒你:已经逾期",
108
+ kind_agent_request: "等待你的批准",
109
+ branchFilter: "显示哪个分支",
110
+ thisBranch: "当前分支({branch})",
111
+ allBranches: "所有分支",
112
+ onBranch: "在 {branch}",
113
+ leftOnBranch: "留在 {branch}{commit}",
114
+ welcomeTitle: "为 {project} 提反馈",
115
+ welcomeBody: "点击“评论”,再点击需要修改的位置。无需注册账号。",
116
+ gotIt: "知道了",
117
+ justNow: "刚刚",
118
+ loadingEarlier: "加载中…",
119
+ reactWith: "用 {emoji} 回应",
120
+ shortcutsTitle: "键盘快捷键",
121
+ shortcutComment: "评论页面上的内容",
122
+ shortcutNext: "前往下一条或上一条评论",
123
+ shortcutResolve: "将打开的评论标记为已解决",
124
+ shortcutClose: "关闭或返回",
125
+ shortcutSend: "发送你写的内容",
126
+ shortcutToggle: "显示或隐藏 CommentKit",
127
+ shortcutHelp: "显示此列表",
128
+ deleteReplyConfirm: "要为所有人删除这条回复吗?",
129
+ replyDeleted: "回复已删除",
130
+ peopleHere: "{n} 人在线",
131
+ peopleHere_one: "{n} 人在线",
132
+ markupTextAdd: "添加备注",
133
+ includeDiagnostics: "附上浏览器错误,帮助开发者排查",
134
+ filters: "筛选",
135
+ assignedToMe: "指派给我",
136
+ assigneeFilter: "指派给",
137
+ anyone: "任何人",
138
+ labelFilter: "标签",
139
+ anyLabel: "任意标签",
140
+ fileNotAllowed: "无法附加 {name}。可以附加图片、PDF、文本、视频和 Office 文件。",
141
+ fileTooBig: "{name} 太大,无法附加。上限为 {size}。",
142
+ tooManyFiles: "最多可以附加 {n} 个文件。",
143
+ removeFile: "移除 {name}",
144
+ threadNotFound: "这条反馈已被删除,或者你已无权查看。",
145
+ readOnlyShort: "只读:你可以查看反馈,但目前无法添加。",
146
+ guestExplain: "我们会通过邮件发送一个 6 位验证码。输入后你的评论会立即发布。",
147
+ guestName: "你的姓名",
148
+ guestEmail: "你的邮箱",
149
+ shareExpired: "此客户链接已过期。请向团队索取新链接。",
150
+ verifyTitle: "请查看邮箱",
151
+ verifyBody: "输入 6 位验证码即可发布你的评论。验证码已发送至 {email}。",
152
+ verifyCode: "6 位验证码",
153
+ verifyPublish: "发布评论",
154
+ verifyResend: "重新发送验证码",
155
+ verifyResent: "新的验证码已发送,可能需要一分钟才能收到。",
156
+ verifyWait: "请等待一分钟后再索取新的验证码。",
157
+ verifyWrong: "验证码不正确。请检查邮件,或重新发送验证码。",
158
+ verifyDifferent: "使用其他邮箱",
159
+ verifyExpired: "此验证码已无法使用。你的评论仍保存在这台设备上。",
160
+ welcomeBodyTouch: "轻点“评论”,再轻点需要修改的位置。无需注册账号。",
161
+ screen_phone: "在手机大小的屏幕上留下",
162
+ screen_tablet: "在平板大小的屏幕上留下",
163
+ screen_wide: "在更宽的屏幕上留下",
164
+ size_phone: "手机",
165
+ size_tablet: "平板",
166
+ size_wide: "宽屏",
167
+ notYetPlaceholder: "还有什么需要修改?",
168
+ muted: "你将不再收到关于 {ref} 的邮件。",
169
+ followed: "你将重新收到关于 {ref} 的邮件。",
170
+ readOnlyGuest: "此网站目前暂停接收新反馈。你仍然可以阅读所有内容。",
171
+ paused: "此网站目前暂停接收反馈。请稍后再来。",
172
+ savedHere: "你的评论已保存在这台设备上。",
173
+ saving: "正在保存…",
174
+ statusFilter: "状态",
175
+ resolvedToast: "已解决 {ref}。",
176
+ guestIntro: "留下你的姓名和邮箱,方便团队回复你。无需注册账号。",
177
+ guestNameMissing: "请填写姓名,让团队知道是谁写的。",
178
+ guestEmailInvalid: "请检查邮箱地址,例如 name@company.com。",
179
+ verifyLinkExpired: "此客户链接已过期。请向发送链接的人索取新链接。你的评论已保存在这台设备上。",
180
+ verifyRemoved: "团队已移除你对此网站的访问权限。请让他们重新添加你。",
181
+ writeAgain: "重新填写",
182
+ pendingNote: "你的评论正在等待我们发送到 {email} 的验证码。",
183
+ enterCode: "输入验证码",
184
+ feedbackRef: "反馈 {ref}"
185
+ };
186
+ //#endregion
187
+ export { e as default };
@@ -1,22 +1,39 @@
1
- import { t as e } from "./chunks/src-DJjfvVsa.js";
2
- import { s as t } from "./chunks/client-D1vrh_5G.js";
1
+ import { t as e } from "./chunks/src-DujplxfI.js";
2
+ import { l as t } from "./chunks/client-D1NizpDK.js";
3
3
  //#region src/element.ts
4
4
  var n = class extends HTMLElement {
5
5
  constructor(...e) {
6
6
  super(...e), t(this, "kit", null);
7
7
  }
8
+ attributeChangedCallback(e, t, n) {
9
+ t !== n && this.isConnected && (this.disconnectedCallback(), this.connectedCallback());
10
+ }
8
11
  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
- }));
12
+ try {
13
+ let t = this.getAttribute("project");
14
+ if (!t) return;
15
+ this.kit = e({
16
+ project: t,
17
+ branch: this.getAttribute("branch"),
18
+ commit: this.getAttribute("commit"),
19
+ endpoint: this.getAttribute("endpoint") ?? void 0,
20
+ locale: this.getAttribute("locale") ?? void 0,
21
+ theme: this.getAttribute("theme") ?? void 0,
22
+ position: this.getAttribute("position") ?? void 0,
23
+ auth: this.getAttribute("auth") ?? void 0,
24
+ deploymentUrl: this.getAttribute("deployment-url"),
25
+ hideOnProduction: this.getAttribute("hide-on-production") !== "false",
26
+ shortcuts: this.getAttribute("shortcuts") !== "false"
27
+ });
28
+ } catch (e) {
29
+ console.warn("[CommentKit] The widget could not start.", e);
30
+ }
17
31
  }
18
32
  disconnectedCallback() {
19
- this.kit?.destroy(), this.kit = null;
33
+ try {
34
+ this.kit?.destroy();
35
+ } catch {}
36
+ this.kit = null;
20
37
  }
21
38
  };
22
39
  t(n, "observedAttributes", ["project"]), typeof customElements < "u" && !customElements.get("comment-kit") && customElements.define("comment-kit", n);
@@ -1,3 +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";
1
+ import { c as e, i as t, n, r, s as i, t as a } from "./chunks/client-D1NizpDK.js";
2
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 };
3
+ export { i as ApiClient, t as AuthManager, a as CommentKitClient, e as CommentKitError, n as SDK_VERSION, c as createAnchor, r as currentPageUrl, s as resolveAnchor, o as stableSelector };
package/dist/npm/index.js CHANGED
@@ -1,3 +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 };
1
+ import { t as e } from "./chunks/src-DujplxfI.js";
2
+ import { c as t, n } from "./chunks/client-D1NizpDK.js";
3
+ export { t as CommentKitError, n as SDK_VERSION, e as init };
package/dist/npm/react.js CHANGED
@@ -1,11 +1,20 @@
1
1
  "use client";
2
- import { t as e } from "./chunks/src-DJjfvVsa.js";
2
+ import { t as e } from "./chunks/src-DujplxfI.js";
3
3
  import { useEffect as t } from "react";
4
4
  //#region src/adapters/react.tsx
5
5
  function n(n) {
6
6
  return t(() => {
7
- let t = e(n);
8
- return () => t.destroy();
7
+ try {
8
+ let t = e(n);
9
+ return () => {
10
+ try {
11
+ t.destroy();
12
+ } catch {}
13
+ };
14
+ } catch (e) {
15
+ console.warn("[CommentKit] The widget could not start.", e);
16
+ return;
17
+ }
9
18
  }, [
10
19
  n.project,
11
20
  n.branch,
@@ -1,8 +1,17 @@
1
- import { t as e } from "./chunks/src-DJjfvVsa.js";
1
+ import { t as e } from "./chunks/src-DujplxfI.js";
2
2
  //#region src/adapters/svelte.ts
3
3
  function t(t, n) {
4
- let r = e(n);
5
- return { destroy: () => r.destroy() };
4
+ let r = null;
5
+ try {
6
+ r = e(n);
7
+ } catch (e) {
8
+ console.warn("[CommentKit] The widget could not start.", e);
9
+ }
10
+ return { destroy: () => {
11
+ try {
12
+ r?.destroy();
13
+ } catch {}
14
+ } };
6
15
  }
7
16
  //#endregion
8
17
  export { t as commentkit, e as init };
@@ -3,6 +3,8 @@ import { init, type CommentKitOptions } from "../index.js";
3
3
  * React / Next.js. Put it once in your root layout:
4
4
  * <CommentKit project="pk_live_…" branch={process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF} />
5
5
  * Renders nothing itself; the widget lives in its own Shadow DOM.
6
+ * Never throws into your app: a failure is one console warning.
7
+ * Options are read when it mounts; changing project, branch, commit or endpoint restarts it.
6
8
  */
7
9
  export declare function CommentKit(props: CommentKitOptions): null;
8
10
  export default CommentKit;
@@ -1,7 +1,7 @@
1
1
  import { init, type CommentKitOptions } from "../index.js";
2
2
  /**
3
3
  * Svelte / SvelteKit: <svelte:body use:commentkit={{ project: "pk_live_…" }} />
4
- * or call init() inside onMount.
4
+ * or call init() inside onMount. Never throws into your app.
5
5
  */
6
6
  export declare function commentkit(_node: HTMLElement, options: CommentKitOptions): {
7
7
  destroy: () => void;
@@ -18,6 +18,38 @@ export declare const CommentKit: import("vue").DefineComponent<import("vue").Ext
18
18
  type: StringConstructor;
19
19
  default: undefined;
20
20
  };
21
+ deploymentUrl: {
22
+ type: PropType<string | null>;
23
+ default: undefined;
24
+ };
25
+ hideOnProduction: {
26
+ type: BooleanConstructor;
27
+ default: undefined;
28
+ };
29
+ theme: {
30
+ type: PropType<CommentKitOptions["theme"]>;
31
+ default: undefined;
32
+ };
33
+ position: {
34
+ type: PropType<CommentKitOptions["position"]>;
35
+ default: undefined;
36
+ };
37
+ redact: {
38
+ type: PropType<string[]>;
39
+ default: undefined;
40
+ };
41
+ locale: {
42
+ type: StringConstructor;
43
+ default: undefined;
44
+ };
45
+ auth: {
46
+ type: PropType<CommentKitOptions["auth"]>;
47
+ default: undefined;
48
+ };
49
+ shortcuts: {
50
+ type: BooleanConstructor;
51
+ default: undefined;
52
+ };
21
53
  }>, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
22
54
  project: {
23
55
  type: StringConstructor;
@@ -35,10 +67,50 @@ export declare const CommentKit: import("vue").DefineComponent<import("vue").Ext
35
67
  type: StringConstructor;
36
68
  default: undefined;
37
69
  };
70
+ deploymentUrl: {
71
+ type: PropType<string | null>;
72
+ default: undefined;
73
+ };
74
+ hideOnProduction: {
75
+ type: BooleanConstructor;
76
+ default: undefined;
77
+ };
78
+ theme: {
79
+ type: PropType<CommentKitOptions["theme"]>;
80
+ default: undefined;
81
+ };
82
+ position: {
83
+ type: PropType<CommentKitOptions["position"]>;
84
+ default: undefined;
85
+ };
86
+ redact: {
87
+ type: PropType<string[]>;
88
+ default: undefined;
89
+ };
90
+ locale: {
91
+ type: StringConstructor;
92
+ default: undefined;
93
+ };
94
+ auth: {
95
+ type: PropType<CommentKitOptions["auth"]>;
96
+ default: undefined;
97
+ };
98
+ shortcuts: {
99
+ type: BooleanConstructor;
100
+ default: undefined;
101
+ };
38
102
  }>> & Readonly<{}>, {
39
103
  branch: string | null;
40
104
  commit: string | null;
41
105
  endpoint: string;
106
+ deploymentUrl: string | null;
107
+ hideOnProduction: boolean;
108
+ theme: "auto" | "dark" | "light" | undefined;
109
+ position: import("../index.js").Position | undefined;
110
+ redact: string[];
111
+ locale: string;
112
+ auth: "auto" | "popup" | "redirect" | undefined;
113
+ shortcuts: boolean;
42
114
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
43
115
  export declare const CommentKitPlugin: {
44
116
  install(_app: App, options: CommentKitOptions): void;
@@ -4,6 +4,8 @@ export interface ApiRequest {
4
4
  body?: unknown;
5
5
  /** Adds an Idempotency-Key so retried creates never duplicate. */
6
6
  idempotent?: boolean;
7
+ /** Reuse this Idempotency-Key (a "Try again" after a failed attempt must send the same one). */
8
+ idempotencyKey?: string;
7
9
  headers?: Record<string, string>;
8
10
  /** Skip the Authorization header (public endpoints). */
9
11
  anonymous?: boolean;
@@ -1,3 +1,13 @@
1
+ export interface PendingGuest {
2
+ token: string;
3
+ email: string;
4
+ expiresAt: number;
5
+ }
6
+ export interface Tokens {
7
+ access_token: string;
8
+ refresh_token: string;
9
+ expires_in: number;
10
+ }
1
11
  export type SignInResult = "signed_in" | "popup_blocked" | "cancelled" | "failed" | "redirecting";
2
12
  export type AuthMode = "auto" | "popup" | "redirect";
3
13
  /** In-app browsers (WhatsApp, Instagram, Slack…) open "popups" in the same view, so use a full-page redirect there. */
@@ -6,9 +16,10 @@ export declare function prefersRedirect(ua?: string): boolean;
6
16
  * Widget sign-in: a popup on the CommentKit domain (credentials never touch
7
17
  * this page), PKCE, short-lived access tokens and a rotating refresh token.
8
18
  *
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.
19
+ * The refresh token is kept in localStorage (sessionStorage when the project
20
+ * turns "remember me" off) under a key scoped to the project. It only works
21
+ * from this exact origin, rotates on every use, and replaying an old one
22
+ * revokes the whole session server-side.
12
23
  */
13
24
  export declare class AuthManager {
14
25
  private readonly endpoint;
@@ -17,6 +28,8 @@ export declare class AuthManager {
17
28
  private access;
18
29
  private refreshing;
19
30
  private listeners;
31
+ private remember;
32
+ private authorize;
20
33
  constructor(endpoint: string, projectKey: string, origin?: string);
21
34
  get storageKey(): string;
22
35
  hasSession(): boolean;
@@ -29,6 +42,8 @@ export declare class AuthManager {
29
42
  share?: string | null;
30
43
  mode?: AuthMode;
31
44
  }): Promise<SignInResult>;
45
+ /** Trade a one-time code (from the popup, a redirect or the browser extension) for a session. */
46
+ exchange(code: string, verifier: string): Promise<boolean>;
32
47
  /**
33
48
  * Finish a redirect sign-in when the page loads with ?ck_code=&ck_state=.
34
49
  * Returns true when a session was created. Removes the params from the URL.
@@ -40,7 +55,31 @@ export declare class AuthManager {
40
55
  signOut(): Promise<void>;
41
56
  private awaitCode;
42
57
  private refresh;
58
+ /**
59
+ * Applies the widget config's `auth`. `remember` is the project's "remember me" policy:
60
+ * true (or absent) keeps the refresh token in localStorage across visits, false in
61
+ * sessionStorage for this tab only; switching moves an existing token to the right place.
62
+ * `authorize_url` is the sign-in page to open (http(s) only; else <endpoint>/widget/connect).
63
+ */
64
+ configure(config?: {
65
+ authorize_url?: string;
66
+ remember?: boolean;
67
+ }): void;
68
+ /**
69
+ * A share-link guest's pending token (POST /guest/start): it may only post their first comment,
70
+ * its uploads, and confirm or resend the emailed code. Kept for this tab only (sessionStorage);
71
+ * it never counts as a session.
72
+ */
73
+ pending(): PendingGuest | null;
74
+ setPending(pending: PendingGuest | null): void;
75
+ private get pendingKey();
76
+ /** Start a normal session from tokens the API issued (POST /guest/verify). Ends the pending token. */
77
+ adopt(tokens: Tokens): void;
43
78
  private store;
79
+ /** Only the policy's storage holds the token; the other one is always emptied. */
80
+ private write;
81
+ /** [where the policy keeps the token, the other one]. */
82
+ private stores;
44
83
  private clear;
45
84
  private readRefresh;
46
85
  private emit;
@@ -1,7 +1,7 @@
1
1
  import { ApiClient } from "./api.js";
2
2
  import { AuthManager, type SignInResult } from "./auth.js";
3
3
  import { type Store } from "./store.js";
4
- import type { Anchor, Attachment, CaptureInput, CommentKitEvents, CommentKitOptions, InboxItem, Message, Page, Person, Session, Thread, ThreadPriority, ThreadStatus, WidgetConfig } from "./types.js";
4
+ import type { Anchor, Attachment, CaptureInput, CommentKitEvents, CommentKitOptions, InboxItem, Label, Message, Page, Person, Session, Thread, ThreadPriority, ThreadStatus, WidgetConfig } from "./types.js";
5
5
  import { CommentKitError } from "./types.js";
6
6
  export declare const SDK_VERSION: string;
7
7
  export declare const DEFAULT_ENDPOINT = "https://commentkit.dev";
@@ -16,6 +16,10 @@ export interface ClientState {
16
16
  unread: number;
17
17
  online: boolean;
18
18
  error: CommentKitError | null;
19
+ /** People on this project right now (realtime presence), you included. 0 when unknown or realtime is off. */
20
+ here: number;
21
+ /** A thread someone asked to open (window.CommentKit.open, init().open): an id or a reference like CK-12. */
22
+ opening: string | null;
19
23
  }
20
24
  type Listener<K extends keyof CommentKitEvents> = (payload: CommentKitEvents[K]) => void;
21
25
  /**
@@ -29,7 +33,11 @@ export declare class CommentKitClient {
29
33
  readonly state: Store<ClientState>;
30
34
  private listeners;
31
35
  private realtime;
36
+ private readonly endpoint;
37
+ private configRead;
32
38
  constructor(options: CommentKitOptions);
39
+ /** The widget's own crash, sent to CommentKit with the SDK version (see core/report.ts). */
40
+ reportCrash(error: unknown, kind?: "crash" | "start"): void;
33
41
  on<K extends keyof CommentKitEvents>(event: K, listener: Listener<K>): () => void;
34
42
  emit<K extends keyof CommentKitEvents>(event: K, payload: CommentKitEvents[K]): void;
35
43
  loadConfig(): Promise<WidgetConfig>;
@@ -41,11 +49,14 @@ export declare class CommentKitClient {
41
49
  branchFilter(): string | undefined;
42
50
  /** Switch between this branch and all branches, and reload the page's feedback. */
43
51
  setAllBranches(on: boolean): Promise<Thread[]>;
52
+ /** `label` is a label id; servers that do not filter by label yet ignore it. */
44
53
  listThreads(query?: {
45
54
  status?: string;
46
55
  q?: string;
47
56
  assignee?: string;
57
+ label?: number;
48
58
  branch?: string;
59
+ page_url?: string;
49
60
  cursor?: string;
50
61
  limit?: number;
51
62
  sort?: string;
@@ -57,6 +68,8 @@ export declare class CommentKitClient {
57
68
  capture?: CaptureInput | null;
58
69
  attachmentIds?: string[];
59
70
  mentionIds?: number[];
71
+ /** The same key for every attempt at this one comment, so a lost response never creates it twice. */
72
+ idempotencyKey?: string;
60
73
  }): Promise<Thread>;
61
74
  updateThread(id: string, changes: {
62
75
  status?: ThreadStatus;
@@ -76,6 +89,7 @@ export declare class CommentKitClient {
76
89
  watch(threadId: string, on: boolean): Promise<{
77
90
  watching: boolean;
78
91
  }>;
92
+ labels(): Promise<Label[]>;
79
93
  people(): Promise<(Person & {
80
94
  assignable: boolean;
81
95
  })[]>;
@@ -120,11 +120,7 @@ export interface Thread {
120
120
  priority: ThreadPriority;
121
121
  assignee: Person | null;
122
122
  due_at: string | null;
123
- labels?: {
124
- id: number;
125
- name: string;
126
- color: string;
127
- }[];
123
+ labels?: Label[];
128
124
  page: {
129
125
  url: string;
130
126
  path: string;
@@ -147,6 +143,10 @@ export interface Thread {
147
143
  console: CaptureInput["console"] | null;
148
144
  network: CaptureInput["network"] | null;
149
145
  } | null;
146
+ /** Only in the answer to a share-link guest's own first comment, until they enter the emailed code. */
147
+ pending_verification?: boolean;
148
+ /** Whether you get notifications about this thread, when the server says (PUT / DELETE /threads/{id}/watch change it). */
149
+ watching?: boolean;
150
150
  last_activity_at: string;
151
151
  resolved_at: string | null;
152
152
  closed_at: string | null;
@@ -183,6 +183,11 @@ export interface WidgetConfig {
183
183
  realtime: boolean;
184
184
  console_capture: boolean;
185
185
  network_capture: boolean;
186
+ /**
187
+ * When console or network capture is on, reviewers choose per comment whether to include it.
188
+ * true: the "Include browser errors" box starts checked. Absent or false: unchecked.
189
+ */
190
+ capture_consent_default?: boolean;
186
191
  };
187
192
  appearance: {
188
193
  theme: "auto" | "light" | "dark";
@@ -195,8 +200,13 @@ export interface WidgetConfig {
195
200
  limits: {
196
201
  max_upload_bytes: number;
197
202
  };
203
+ /**
204
+ * remember: keep people signed in on this device after the tab closes (true, the default when absent),
205
+ * or only for this tab (false: the refresh token lives in sessionStorage).
206
+ */
198
207
  auth: {
199
208
  authorize_url: string;
209
+ remember?: boolean;
200
210
  };
201
211
  realtime?: {
202
212
  key: string;
@@ -206,6 +216,11 @@ export interface WidgetConfig {
206
216
  auth_endpoint: string;
207
217
  } | null;
208
218
  }
219
+ export interface Label {
220
+ id: number;
221
+ name: string;
222
+ color: string;
223
+ }
209
224
  export type Position = "bottom-right" | "bottom-left" | "top-right" | "top-left";
210
225
  export interface InboxItem {
211
226
  id: string;
@@ -242,13 +257,23 @@ export interface CommentKitOptions {
242
257
  position?: Position;
243
258
  /** CSS selectors whose content is never captured in screenshots. */
244
259
  redact?: string[];
245
- /** Interface language. Defaults to the browser language. */
260
+ /**
261
+ * Interface language, e.g. "fr" or "pt-BR". Defaults to the page's <html lang>,
262
+ * then the browser language. Built in: en, es, fr, de, pt-BR, it, nl, ja, zh-CN,
263
+ * hi, ar (right to left). Anything else falls back to English.
264
+ */
246
265
  locale?: string;
247
266
  /**
248
267
  * How sign-in opens: "auto" (default) uses a popup on desktop and a full-page
249
268
  * redirect inside in-app browsers or when popups are blocked.
250
269
  */
251
270
  auth?: "auto" | "popup" | "redirect";
271
+ /**
272
+ * Single-key shortcuts while the widget is shown: C to comment, J / K for next or previous,
273
+ * E to resolve, ? for the list. Default true. Set false when your app has its own shortcuts
274
+ * (WCAG 2.1.4). Esc and Cmd/Ctrl+Shift+K keep working.
275
+ */
276
+ shortcuts?: boolean;
252
277
  }
253
278
  export interface CommentKitEvents {
254
279
  ready: {
@@ -1,10 +1,13 @@
1
1
  /**
2
2
  * <comment-kit project="pk_live_…" branch="main"></comment-kit>
3
- * Works in any framework or plain HTML.
3
+ * Works in any framework or plain HTML. Attributes: project (required), branch, commit, locale,
4
+ * theme, position, auth, endpoint, deployment-url, hide-on-production="false", shortcuts="false". Changing project
5
+ * restarts the widget.
4
6
  */
5
7
  export declare class CommentKitElement extends HTMLElement {
6
8
  static observedAttributes: string[];
7
9
  private kit;
10
+ attributeChangedCallback(_name: string, before: string | null, after: string | null): void;
8
11
  connectedCallback(): void;
9
12
  disconnectedCallback(): void;
10
13
  }