@commentkit/comment-kit 1.0.0-beta.0 → 1.0.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 (52) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +99 -7
  3. package/SECURITY.md +7 -2
  4. package/dist/npm/chunks/Guest-VNoofLxw.js +157 -0
  5. package/dist/npm/chunks/MarkupEditor-DTXrS3DD.js +199 -0
  6. package/dist/npm/chunks/Panel-B88JYH52.js +438 -0
  7. package/dist/npm/chunks/Shortcuts-BSOKdMHt.js +56 -0
  8. package/dist/npm/chunks/ThreadCard-izybwXIC.js +817 -0
  9. package/dist/npm/chunks/ar-O7EPv0mI.js +222 -0
  10. package/dist/npm/chunks/art-DK1JwPIo.js +155 -0
  11. package/dist/npm/chunks/{client-D1vrh_5G.js → client-Iegfv6ZC.js} +95 -65
  12. package/dist/npm/chunks/de-PGyZVNHX.js +211 -0
  13. package/dist/npm/chunks/es-Bq1idl8M.js +211 -0
  14. package/dist/npm/chunks/extension-B7SelsS0.js +54 -0
  15. package/dist/npm/chunks/extension-DSA8S8Qz.js +26 -0
  16. package/dist/npm/chunks/format-B5tJGtPC.js +524 -0
  17. package/dist/npm/chunks/fr-BVB9GGco.js +211 -0
  18. package/dist/npm/chunks/hi-DyBvrjzQ.js +211 -0
  19. package/dist/npm/chunks/{html2canvas-_mjSRP3G.js → html2canvas-DfGb8yka.js} +1145 -1132
  20. package/dist/npm/chunks/it-BlMMMwZh.js +211 -0
  21. package/dist/npm/chunks/ja-lAioBCJv.js +211 -0
  22. package/dist/npm/chunks/live-YFyP1GnP.js +34 -0
  23. package/dist/npm/chunks/mount-Dx_8NhX3.js +1484 -0
  24. package/dist/npm/chunks/nl-DR8mLHnn.js +211 -0
  25. package/dist/npm/chunks/privacy-DLhezjyi.js +30 -0
  26. package/dist/npm/chunks/pt-BR-D7j6aDPx.js +211 -0
  27. package/dist/npm/chunks/{pusher-DRKlokR8.js → pusher-BSsQoE1K.js} +1 -1
  28. package/dist/npm/chunks/realtime-CBRW9BB3.js +34 -0
  29. package/dist/npm/chunks/report-DoDVi1qT.js +28 -0
  30. package/dist/npm/chunks/{rolldown-runtime-VHNaYcLd.js → rolldown-runtime-Y_bBpyJl.js} +10 -3
  31. package/dist/npm/chunks/src-C1Qp94nr.js +549 -0
  32. package/dist/npm/chunks/zh-CN-tzYg9NPH.js +211 -0
  33. package/dist/npm/element.js +28 -11
  34. package/dist/npm/headless.js +2 -2
  35. package/dist/npm/index.js +3 -3
  36. package/dist/npm/react.js +12 -3
  37. package/dist/npm/svelte.js +12 -3
  38. package/dist/npm/types/adapters/react.d.ts +2 -0
  39. package/dist/npm/types/adapters/svelte.d.ts +1 -1
  40. package/dist/npm/types/adapters/vue.d.ts +72 -0
  41. package/dist/npm/types/anchor/index.d.ts +0 -1
  42. package/dist/npm/types/core/api.d.ts +2 -0
  43. package/dist/npm/types/core/auth.d.ts +42 -5
  44. package/dist/npm/types/core/client.d.ts +22 -7
  45. package/dist/npm/types/core/types.d.ts +50 -6
  46. package/dist/npm/types/element.d.ts +4 -1
  47. package/dist/npm/types/index.d.ts +3 -1
  48. package/dist/npm/vue.js +46 -7
  49. package/package.json +8 -2
  50. package/dist/npm/chunks/mount-Ce1MZrcm.js +0 -2485
  51. package/dist/npm/chunks/realtime-5SvAvTUU.js +0 -23
  52. package/dist/npm/chunks/src-DJjfvVsa.js +0 -330
@@ -0,0 +1,211 @@
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
+ nothingAnywhere: "这个网站还没有反馈。",
53
+ noMatch: "没有符合搜索或筛选条件的反馈。",
54
+ clearFilters: "清除筛选",
55
+ allCaughtUp: "没有新消息了。",
56
+ search: "搜索反馈",
57
+ detached: "页面上已经找不到这个位置了。评论之后页面可能有改动。",
58
+ moved: "评论之后,页面的这部分有改动。",
59
+ status_open: "待处理",
60
+ status_in_progress: "处理中",
61
+ status_in_review: "待确认",
62
+ status_resolved: "已解决",
63
+ status_closed: "已关闭",
64
+ resolve: "解决",
65
+ resolveHint: "标记为已修复",
66
+ reopen: "重新打开",
67
+ markInProgress: "开始处理",
68
+ markInReview: "请求确认",
69
+ closeThread: "不做修改直接关闭",
70
+ reviewAsk: "团队认为已经修好了。你看可以吗?",
71
+ looksGood: "可以了 — 解决",
72
+ notYet: "还不行 — 回复",
73
+ copyLink: "复制链接",
74
+ copied: "已复制",
75
+ copyForAgent: "复制给 AI 助手",
76
+ copiedForAgent: "已复制。粘贴到你的 AI 编程助手里即可。",
77
+ delete: "删除",
78
+ deleteConfirm: "要为所有人删除这条反馈吗?回复和截图也会一起删除。",
79
+ edit: "编辑",
80
+ edited: "已编辑",
81
+ save: "保存",
82
+ mute: "关闭通知",
83
+ unmute: "开启通知",
84
+ unassigned: "未指派",
85
+ readOnly: "你的团队订阅已到期,反馈目前只能查看。你仍然可以阅读所有内容。",
86
+ offline: "你已离线。草稿会一直保留,直到你恢复联网。",
87
+ offlineSend: "你已离线。评论已保存在这里,恢复联网后再发送即可。",
88
+ errorGeneric: "出了点问题,请重试。",
89
+ loadFailed: "反馈加载失败。请检查网络后重试。",
90
+ sendFailed: "评论还没发出去。内容还在,可以再试一次。",
91
+ retry: "重试",
92
+ loadingThread: "正在加载对话…",
93
+ readOnlyReply: "你可以查看这段对话,但目前无法回复。",
94
+ noReplyAccess: "你可以查看这条反馈,但没有回复权限。",
95
+ notOnPage: "当前页面上找不到",
96
+ more: "更多",
97
+ allStatuses: "全部",
98
+ markAllRead: "全部标为已读",
99
+ messageCount: "{n} 条消息",
100
+ messageCount_one: "{n} 条消息",
101
+ kind_mention: "{actor} 提到了你",
102
+ kind_reply: "{actor} 回复了",
103
+ kind_assigned: "{actor} 指派给了你",
104
+ kind_ready_for_review: "{actor} 请你确认一个修复",
105
+ kind_reopened: "{actor} 重新打开了",
106
+ kind_resolved: "{actor} 解决了",
107
+ kind_closed: "{actor} 关闭了",
108
+ kind_new_feedback: "{actor} 提交了反馈",
109
+ kind_due_soon: "{actor} 提醒你:快到期了",
110
+ kind_overdue: "{actor} 提醒你:已经逾期",
111
+ kind_agent_request: "{actor} 等待你的批准",
112
+ personName: "{name}",
113
+ branchFilter: "显示网站的哪个版本",
114
+ thisBranch: "当前版本({branch})",
115
+ allBranches: "所有版本",
116
+ onBranch: "版本 {branch}",
117
+ leftOnBranch: "在版本 {branch}{commit} 上留下",
118
+ welcomeTitle: "为 {project} 提反馈",
119
+ welcomeBody: "点击“评论”,再点击需要修改的位置。无需注册账号。",
120
+ gotIt: "知道了",
121
+ justNow: "刚刚",
122
+ loadingEarlier: "加载中…",
123
+ reactWith: "用 {emoji} 回应",
124
+ shortcutsTitle: "键盘快捷键",
125
+ shortcutComment: "评论页面上的内容",
126
+ shortcutNext: "前往下一条或上一条评论",
127
+ shortcutResolve: "将打开的评论标记为已解决",
128
+ shortcutClose: "关闭或返回",
129
+ shortcutSend: "发送你写的内容",
130
+ shortcutToggle: "显示或隐藏 CommentKit",
131
+ shortcutHelp: "显示此列表",
132
+ deleteReplyConfirm: "要为所有人删除这条回复吗?",
133
+ replyDeleted: "回复已删除",
134
+ peopleHere: "{n} 人正在查看",
135
+ peopleHere_one: "{n} 人正在查看",
136
+ markupTextAdd: "添加备注",
137
+ includeDiagnostics: "附上技术细节,帮助开发者排查",
138
+ filters: "筛选",
139
+ assignedToMe: "指派给我",
140
+ assigneeFilter: "指派给",
141
+ anyone: "任何人",
142
+ labelFilter: "标签",
143
+ anyLabel: "任意标签",
144
+ fileNotAllowed: "无法附加 {name}。可以附加图片、PDF、文本、视频和 Office 文件。",
145
+ fileTooBig: "{name} 太大,无法附加。上限为 {size}。",
146
+ tooManyFiles: "最多可以附加 {n} 个文件。",
147
+ tooManyFiles_one: "最多可以附加 {n} 个文件。",
148
+ removeFile: "移除 {name}",
149
+ threadNotFound: "这条反馈已被删除,或者你已无权查看。",
150
+ readOnlyShort: "只读:你可以查看反馈,但目前无法添加。",
151
+ guestExplain: "我们会通过邮件发送一个 6 位验证码。输入验证码后,你的评论会立即发布。",
152
+ guestName: "你的姓名",
153
+ guestEmail: "你的邮箱",
154
+ shareExpired: "此客户链接已过期。请向团队索取新链接。",
155
+ verifyTitle: "请查看邮箱",
156
+ verifyBody: "输入 6 位验证码即可发布你的评论。验证码已发送至 {email}。",
157
+ verifyCode: "6 位验证码",
158
+ verifyPublish: "发布评论",
159
+ verifyResend: "重新发送验证码",
160
+ verifyResent: "新的验证码已发送,可能需要一分钟才能收到。",
161
+ verifyWait: "请等待一分钟后再索取新的验证码。",
162
+ verifyWrong: "验证码不正确。请检查邮件,或重新发送验证码。",
163
+ verifyDifferent: "使用其他邮箱",
164
+ verifyExpired: "此验证码已无法使用。你的评论仍保存在这台设备上。",
165
+ welcomeBodyTouch: "轻点“评论”,再轻点需要修改的位置。无需注册账号。",
166
+ screen_phone: "在手机大小的屏幕上留下",
167
+ screen_tablet: "在平板大小的屏幕上留下",
168
+ screen_wide: "在更宽的屏幕上留下",
169
+ size_phone: "手机",
170
+ size_tablet: "平板",
171
+ size_wide: "宽屏",
172
+ notYetPlaceholder: "还有什么需要修改?",
173
+ muted: "你将不再收到关于 {ref} 的邮件。",
174
+ followed: "你将重新收到关于 {ref} 的邮件。",
175
+ readOnlyGuest: "此网站目前暂停接收新反馈。你仍然可以阅读所有内容。",
176
+ paused: "此网站目前暂停接收反馈。请稍后再来。",
177
+ savedHere: "你的评论已保存在这台设备上。",
178
+ saving: "正在保存…",
179
+ statusFilter: "状态",
180
+ resolvedToast: "{ref} 已解决。",
181
+ guestIntro: "留下你的姓名和邮箱,方便团队回复你。无需注册账号。",
182
+ guestNameMissing: "请填写姓名,让团队知道是谁写的。",
183
+ guestEmailInvalid: "请检查邮箱地址,例如 name@company.com。",
184
+ verifyLinkExpired: "此客户链接已过期。请向发送链接的人索取新链接。你的评论已保存在这台设备上。",
185
+ verifyRemoved: "团队已移除你对此网站的访问权限。请让他们重新添加你。",
186
+ writeAgain: "重新填写",
187
+ pendingNote: "你的评论正在等待我们发送到 {email} 的验证码。",
188
+ enterCode: "输入验证码",
189
+ feedbackRef: "反馈 {ref}",
190
+ networkError: "无法连接到 CommentKit。请检查网络连接:你的文字已保存在这里,可以再试一次。",
191
+ noAccess: "你无权查看此网站上的反馈。请让团队重新邀请你。",
192
+ originNotAllowed: "暂时无法从这个网址发送反馈。请让团队把它添加到项目中。",
193
+ forbidden: "你没有权限执行此操作。",
194
+ tooFast: "操作太频繁了。请稍等片刻再试。",
195
+ sentWithoutScreenshot: "已发送,但没有附上截图:截图未能上传。",
196
+ sentWithoutFiles: "已发送,但有些文件没能附加。你可以在回复中再附加。",
197
+ replyFailed: "你的回复还没有发送。内容仍在这里,可以再试一次。",
198
+ taskDetails: "任务详情",
199
+ priority: "优先级",
200
+ priority_none: "无优先级",
201
+ priority_low: "低",
202
+ priority_medium: "中",
203
+ priority_high: "高",
204
+ priority_urgent: "紧急",
205
+ dueDate: "截止日期",
206
+ dueOn: "截止 {date}",
207
+ labels: "标签",
208
+ noLabels: "无标签"
209
+ };
210
+ //#endregion
211
+ 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-C1Qp94nr.js";
2
+ import { l as t } from "./chunks/client-Iegfv6ZC.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-Iegfv6ZC.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-C1Qp94nr.js";
2
+ import { c as t, n } from "./chunks/client-Iegfv6ZC.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-C1Qp94nr.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-C1Qp94nr.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;
@@ -42,7 +42,6 @@ export interface AnchorInput {
42
42
  }
43
43
  export declare function createAnchor(input: AnchorInput): Anchor;
44
44
  export declare function stableSelector(el: Element): string | null;
45
- export declare function xpathOf(el: Element): string | null;
46
45
  export declare function fingerprint(el: Element): string | null;
47
46
  export declare function resolveAnchor(anchor: Anchor, root?: ParentNode): ResolvedAnchor;
48
47
  /** Dice coefficient on character bigrams: 1 = identical, 0 = nothing in common. */
@@ -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,14 +1,23 @@
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
- /** 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
13
  /**
6
14
  * Widget sign-in: a popup on the CommentKit domain (credentials never touch
7
15
  * this page), PKCE, short-lived access tokens and a rotating refresh token.
8
16
  *
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.
17
+ * The refresh token is kept in localStorage (sessionStorage when the project
18
+ * turns "remember me" off) under a key scoped to the project. It only works
19
+ * from this exact origin, rotates on every use, and replaying an old one
20
+ * revokes the whole session server-side.
12
21
  */
13
22
  export declare class AuthManager {
14
23
  private readonly endpoint;
@@ -17,6 +26,8 @@ export declare class AuthManager {
17
26
  private access;
18
27
  private refreshing;
19
28
  private listeners;
29
+ private remember;
30
+ private authorize;
20
31
  constructor(endpoint: string, projectKey: string, origin?: string);
21
32
  get storageKey(): string;
22
33
  hasSession(): boolean;
@@ -29,6 +40,8 @@ export declare class AuthManager {
29
40
  share?: string | null;
30
41
  mode?: AuthMode;
31
42
  }): Promise<SignInResult>;
43
+ /** Trade a one-time code (from the popup, a redirect or the browser extension) for a session. */
44
+ exchange(code: string, verifier: string): Promise<boolean>;
32
45
  /**
33
46
  * Finish a redirect sign-in when the page loads with ?ck_code=&ck_state=.
34
47
  * Returns true when a session was created. Removes the params from the URL.
@@ -40,7 +53,31 @@ export declare class AuthManager {
40
53
  signOut(): Promise<void>;
41
54
  private awaitCode;
42
55
  private refresh;
56
+ /**
57
+ * Applies the widget config's `auth`. `remember` is the project's "remember me" policy:
58
+ * true (or absent) keeps the refresh token in localStorage across visits, false in
59
+ * sessionStorage for this tab only; switching moves an existing token to the right place.
60
+ * `authorize_url` is the sign-in page to open (http(s) only; else <endpoint>/widget/connect).
61
+ */
62
+ configure(config?: {
63
+ authorize_url?: string;
64
+ remember?: boolean;
65
+ }): void;
66
+ /**
67
+ * A share-link guest's pending token (POST /guest/start): it may only post their first comment,
68
+ * its uploads, and confirm or resend the emailed code. Kept for this tab only (sessionStorage);
69
+ * it never counts as a session.
70
+ */
71
+ pending(): PendingGuest | null;
72
+ setPending(pending: PendingGuest | null): void;
73
+ private get pendingKey();
74
+ /** Start a normal session from tokens the API issued (POST /guest/verify). Ends the pending token. */
75
+ adopt(tokens: Tokens): void;
43
76
  private store;
77
+ /** Only the policy's storage holds the token; the other one is always emptied. */
78
+ private write;
79
+ /** [where the policy keeps the token, the other one]. */
80
+ private stores;
44
81
  private clear;
45
82
  private readRefresh;
46
83
  private emit;
@@ -1,10 +1,10 @@
1
1
  import { ApiClient } from "./api.js";
2
2
  import { AuthManager, type SignInResult } from "./auth.js";
3
+ import type { FeedbackPing } from "./types.js";
3
4
  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";
5
+ import type { Anchor, Attachment, CaptureInput, CommentKitEvents, CommentKitOptions, InboxItem, Label, Message, Page, Person, Session, Thread, ThreadPriority, ThreadStatus, WidgetConfig } from "./types.js";
5
6
  import { CommentKitError } from "./types.js";
6
7
  export declare const SDK_VERSION: string;
7
- export declare const DEFAULT_ENDPOINT = "https://commentkit.dev";
8
8
  export interface ClientState {
9
9
  config: WidgetConfig | null;
10
10
  session: Session | null;
@@ -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,12 @@ 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;
38
+ private reportNonce;
32
39
  constructor(options: CommentKitOptions);
40
+ /** The widget's own crash, sent to CommentKit with the SDK version (see core/report.ts). */
41
+ reportCrash(error: unknown, kind?: "crash" | "start"): void;
33
42
  on<K extends keyof CommentKitEvents>(event: K, listener: Listener<K>): () => void;
34
43
  emit<K extends keyof CommentKitEvents>(event: K, payload: CommentKitEvents[K]): void;
35
44
  loadConfig(): Promise<WidgetConfig>;
@@ -41,11 +50,14 @@ export declare class CommentKitClient {
41
50
  branchFilter(): string | undefined;
42
51
  /** Switch between this branch and all branches, and reload the page's feedback. */
43
52
  setAllBranches(on: boolean): Promise<Thread[]>;
53
+ /** `label` is a label id; servers that do not filter by label yet ignore it. */
44
54
  listThreads(query?: {
45
55
  status?: string;
46
56
  q?: string;
47
57
  assignee?: string;
58
+ label?: number;
48
59
  branch?: string;
60
+ page_url?: string;
49
61
  cursor?: string;
50
62
  limit?: number;
51
63
  sort?: string;
@@ -57,11 +69,16 @@ export declare class CommentKitClient {
57
69
  capture?: CaptureInput | null;
58
70
  attachmentIds?: string[];
59
71
  mentionIds?: number[];
72
+ /** The same key for every attempt at this one comment, so a lost response never creates it twice. */
73
+ idempotencyKey?: string;
60
74
  }): Promise<Thread>;
75
+ /** Reviewers may only resolve or reopen; priority, assignee, due date and labels are for members who can triage. */
61
76
  updateThread(id: string, changes: {
62
77
  status?: ThreadStatus;
63
78
  priority?: ThreadPriority;
64
79
  assignee_id?: number | null;
80
+ due_at?: string | null;
81
+ label_ids?: number[];
65
82
  }): Promise<Thread>;
66
83
  deleteThread(id: string): Promise<void>;
67
84
  messages(threadId: string, cursor?: string): Promise<Page<Message>>;
@@ -69,6 +86,7 @@ export declare class CommentKitClient {
69
86
  replyTo?: string | null;
70
87
  attachmentIds?: string[];
71
88
  mentionIds?: number[];
89
+ idempotencyKey?: string;
72
90
  }): Promise<Message>;
73
91
  editMessage(id: string, body: string): Promise<Message>;
74
92
  deleteMessage(id: string): Promise<void>;
@@ -76,6 +94,7 @@ export declare class CommentKitClient {
76
94
  watch(threadId: string, on: boolean): Promise<{
77
95
  watching: boolean;
78
96
  }>;
97
+ labels(): Promise<Label[]>;
79
98
  people(): Promise<(Person & {
80
99
  assignable: boolean;
81
100
  })[]>;
@@ -86,11 +105,7 @@ export declare class CommentKitClient {
86
105
  all?: boolean;
87
106
  }): Promise<void>;
88
107
  upload(file: Blob, name: string, kind?: "screenshot" | "file"): Promise<Attachment>;
89
- connectRealtime(onChange: (event: {
90
- type: string;
91
- thread_id: string;
92
- actor: string | null;
93
- }) => void): Promise<void>;
108
+ connectRealtime(onChange: (event: FeedbackPing) => void): Promise<void>;
94
109
  refreshThread(id: string): Promise<void>;
95
110
  private upsert;
96
111
  destroy(): void;