@commentkit/comment-kit 0.7.7 → 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 (129) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +172 -732
  3. package/SECURITY.md +24 -14
  4. package/dist/npm/THIRD_PARTY_NOTICES.txt +73 -0
  5. package/dist/npm/chunks/Guest-CKoV6pEK.js +157 -0
  6. package/dist/npm/chunks/MarkupEditor-DAo4qppg.js +199 -0
  7. package/dist/npm/chunks/Panel-BRBDHlGg.js +399 -0
  8. package/dist/npm/chunks/Shortcuts-CHMcrjAM.js +56 -0
  9. package/dist/npm/chunks/ThreadCard-D8FzIxbs.js +570 -0
  10. package/dist/npm/chunks/anchor-DT-Ynhh1.js +270 -0
  11. package/dist/npm/chunks/ar-D3SPpN1T.js +195 -0
  12. package/dist/npm/chunks/client-D1NizpDK.js +627 -0
  13. package/dist/{shared/capture-colors-D0uLr-vZ.js → npm/chunks/colors-CX-IPjvb.js} +2 -0
  14. package/dist/npm/chunks/de-C8eC6c6f.js +187 -0
  15. package/dist/npm/chunks/es-Bczf42tm.js +187 -0
  16. package/dist/npm/chunks/extension--it1LAj-.js +54 -0
  17. package/dist/npm/chunks/extension-XfuRGu2o.js +26 -0
  18. package/dist/npm/chunks/format-Bw_tNOh9.js +524 -0
  19. package/dist/npm/chunks/fr-BaQw-v2e.js +187 -0
  20. package/dist/npm/chunks/hi-BamV-yXv.js +187 -0
  21. package/dist/npm/chunks/html2canvas-DfGb8yka.js +4024 -0
  22. package/dist/npm/chunks/it-DC14_EjN.js +187 -0
  23. package/dist/npm/chunks/ja-B1mmTN7Y.js +187 -0
  24. package/dist/npm/chunks/mount-5fFig0k6.js +1447 -0
  25. package/dist/npm/chunks/nl-BfhqUsmX.js +187 -0
  26. package/dist/npm/chunks/privacy-DLhezjyi.js +30 -0
  27. package/dist/npm/chunks/pt-BR-CEPu4W5U.js +187 -0
  28. package/dist/{shared/pusher-CnhQgAvF.js → npm/chunks/pusher-BSsQoE1K.js} +224 -222
  29. package/dist/npm/chunks/realtime-CBRW9BB3.js +34 -0
  30. package/dist/npm/chunks/report-Dh4fxd4J.js +27 -0
  31. package/dist/npm/chunks/rolldown-runtime-Y_bBpyJl.js +20 -0
  32. package/dist/npm/chunks/src-DujplxfI.js +517 -0
  33. package/dist/npm/chunks/zh-CN-kgqjYwHQ.js +187 -0
  34. package/dist/npm/element.js +41 -0
  35. package/dist/npm/headless.js +3 -0
  36. package/dist/npm/index.js +3 -0
  37. package/dist/npm/react.js +26 -0
  38. package/dist/npm/svelte.js +17 -0
  39. package/dist/npm/types/adapters/react.d.ts +11 -0
  40. package/dist/npm/types/adapters/svelte.d.ts +9 -0
  41. package/dist/npm/types/adapters/vue.d.ts +118 -0
  42. package/dist/npm/types/anchor/index.d.ts +49 -0
  43. package/dist/npm/types/core/api.d.ts +31 -0
  44. package/dist/npm/types/core/auth.d.ts +87 -0
  45. package/dist/npm/types/core/client.d.ts +114 -0
  46. package/dist/npm/types/core/store.d.ts +7 -0
  47. package/dist/npm/types/core/types.d.ts +303 -0
  48. package/dist/npm/types/element.d.ts +13 -0
  49. package/dist/npm/types/headless.d.ts +7 -0
  50. package/dist/npm/types/index.d.ts +32 -0
  51. package/dist/npm/vue.js +71 -0
  52. package/package.json +71 -173
  53. package/dist/THIRD_PARTY_NOTICES.txt +0 -284
  54. package/dist/angular.es.js +0 -321
  55. package/dist/comment-kit.es.js +0 -218
  56. package/dist/demo.es.js +0 -483
  57. package/dist/headless.es.js +0 -4
  58. package/dist/preact.es.js +0 -117
  59. package/dist/qwik.es.js +0 -1
  60. package/dist/qwik.qwik.mjs +0 -114
  61. package/dist/react.es.js +0 -98
  62. package/dist/shared/ShadowRootContext-DD6a0QaI.js +0 -11
  63. package/dist/shared/annotation-icons-Dh-bmNYK.js +0 -172
  64. package/dist/shared/annotation-toolbar-zeiCmKIr.js +0 -1086
  65. package/dist/shared/attachment-refresh-DAacLaRu.js +0 -94
  66. package/dist/shared/bridge-CJoGYngu.js +0 -177
  67. package/dist/shared/button-D4GHW6oZ.js +0 -474
  68. package/dist/shared/button-group-BVR7iT-S.js +0 -91
  69. package/dist/shared/capture-privacy-CiOrcAlt.js +0 -101
  70. package/dist/shared/comment-drawing-canvas-Btc12IsS.js +0 -124
  71. package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
  72. package/dist/shared/comment-image-lightbox--QpbcAtH.js +0 -190
  73. package/dist/shared/comment-images-content-C_r4SHM-.js +0 -214
  74. package/dist/shared/comment-kit-core-CmLUFujd.js +0 -3682
  75. package/dist/shared/comment-kit-ui-BHwYuSIi.js +0 -19391
  76. package/dist/shared/comment-screenshot-annotator-zJZyO-XM.js +0 -151
  77. package/dist/shared/comment-screenshot-overlay-CoKTYB0J.js +0 -205
  78. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +0 -153
  79. package/dist/shared/createReactComponent-BZHeRbD0.js +0 -45
  80. package/dist/shared/dev-export-panel-Cnt6oCZU.js +0 -207
  81. package/dist/shared/dev-grab-B85jo9AS.js +0 -197
  82. package/dist/shared/dist-D9A5k-N4.js +0 -617
  83. package/dist/shared/dom-Bhf4WFtY.js +0 -223
  84. package/dist/shared/element-selector-Cng84xC7.js +0 -902
  85. package/dist/shared/error-boundary-D3PD74vI.js +0 -21
  86. package/dist/shared/errors-Bu5ajEmB.js +0 -22
  87. package/dist/shared/icons-nzMOLzrm.js +0 -266
  88. package/dist/shared/input-UPtAj0M6.js +0 -111
  89. package/dist/shared/mount-ui-Dz7FB_Ak.js +0 -208
  90. package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
  91. package/dist/shared/realtime-yGLX4wMK.js +0 -334
  92. package/dist/shared/request-activity-DQrAUwfA.js +0 -11
  93. package/dist/shared/screenshot-B5-hwpmt.js +0 -199
  94. package/dist/shared/separator-UhJb0Row.js +0 -3955
  95. package/dist/shared/shadow-root-B58ZI2yz.js +0 -133
  96. package/dist/shared/styles-CnYsLS2f.js +0 -2
  97. package/dist/shared/text-B4HHZNaa.js +0 -23
  98. package/dist/shared/token-session-D92MYbNu.js +0 -25
  99. package/dist/shared/useLabelableId-8n0QmH8N.js +0 -154
  100. package/dist/shared/useRender-Uxk1OPK-.js +0 -5
  101. package/dist/shared/useValueChanged-DKq5cMot.js +0 -92
  102. package/dist/shared/validation-3wbbbuX0.js +0 -70
  103. package/dist/shared/websocket-manager-KhH4hL0Q.js +0 -381
  104. package/dist/solid.es.js +0 -98
  105. package/dist/svelte.es.js +0 -130
  106. package/dist/types/adapters/bridge.d.ts +0 -122
  107. package/dist/types/angular/index.d.ts +0 -145
  108. package/dist/types/core/agent-context.d.ts +0 -17
  109. package/dist/types/core/api-client.d.ts +0 -155
  110. package/dist/types/core/comment-kit-core.d.ts +0 -254
  111. package/dist/types/core/local-demo.d.ts +0 -60
  112. package/dist/types/core/types.d.ts +0 -770
  113. package/dist/types/core/websocket-manager.d.ts +0 -125
  114. package/dist/types/core/write-access.d.ts +0 -11
  115. package/dist/types/demo.d.ts +0 -17
  116. package/dist/types/headless.d.ts +0 -8
  117. package/dist/types/index.d.ts +0 -87
  118. package/dist/types/preact/index.d.ts +0 -25
  119. package/dist/types/qwik/index.d.ts +0 -73
  120. package/dist/types/react/client.d.ts +0 -31
  121. package/dist/types/react/index.d.ts +0 -4
  122. package/dist/types/solid/index.d.ts +0 -37
  123. package/dist/types/svelte/index.d.ts +0 -55
  124. package/dist/types/utils/dom.d.ts +0 -59
  125. package/dist/types/utils/event-emitter.d.ts +0 -11
  126. package/dist/types/vue/index.d.ts +0 -87
  127. package/dist/vue.es.js +0 -148
  128. package/docs/api-reference.md +0 -405
  129. package/docs/local-demo.md +0 -60
@@ -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 };
@@ -0,0 +1,41 @@
1
+ import { t as e } from "./chunks/src-DujplxfI.js";
2
+ import { l as t } from "./chunks/client-D1NizpDK.js";
3
+ //#region src/element.ts
4
+ var n = class extends HTMLElement {
5
+ constructor(...e) {
6
+ super(...e), t(this, "kit", null);
7
+ }
8
+ attributeChangedCallback(e, t, n) {
9
+ t !== n && this.isConnected && (this.disconnectedCallback(), this.connectedCallback());
10
+ }
11
+ connectedCallback() {
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
+ }
31
+ }
32
+ disconnectedCallback() {
33
+ try {
34
+ this.kit?.destroy();
35
+ } catch {}
36
+ this.kit = null;
37
+ }
38
+ };
39
+ t(n, "observedAttributes", ["project"]), typeof customElements < "u" && !customElements.get("comment-kit") && customElements.define("comment-kit", n);
40
+ //#endregion
41
+ export { n as CommentKitElement };
@@ -0,0 +1,3 @@
1
+ import { c as e, i as t, n, r, s as i, t as a } from "./chunks/client-D1NizpDK.js";
2
+ import { i as o, r as s, t as c } from "./chunks/anchor-DT-Ynhh1.js";
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 };
@@ -0,0 +1,3 @@
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 };
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { t as e } from "./chunks/src-DujplxfI.js";
3
+ import { useEffect as t } from "react";
4
+ //#region src/adapters/react.tsx
5
+ function n(n) {
6
+ return t(() => {
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
+ }
18
+ }, [
19
+ n.project,
20
+ n.branch,
21
+ n.commit,
22
+ n.endpoint
23
+ ]), null;
24
+ }
25
+ //#endregion
26
+ export { n as CommentKit, n as default, e as init };
@@ -0,0 +1,17 @@
1
+ import { t as e } from "./chunks/src-DujplxfI.js";
2
+ //#region src/adapters/svelte.ts
3
+ function t(t, n) {
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
+ } };
15
+ }
16
+ //#endregion
17
+ export { t as commentkit, e as init };
@@ -0,0 +1,11 @@
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
+ * 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.
8
+ */
9
+ export declare function CommentKit(props: CommentKitOptions): null;
10
+ export default CommentKit;
11
+ 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. Never throws into your app.
5
+ */
6
+ export declare function commentkit(_node: HTMLElement, options: CommentKitOptions): {
7
+ destroy: () => void;
8
+ };
9
+ export { init };
@@ -0,0 +1,118 @@
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
+ 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
+ };
53
+ }>, () => null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
54
+ project: {
55
+ type: StringConstructor;
56
+ required: true;
57
+ };
58
+ branch: {
59
+ type: PropType<string | null>;
60
+ default: null;
61
+ };
62
+ commit: {
63
+ type: PropType<string | null>;
64
+ default: null;
65
+ };
66
+ endpoint: {
67
+ type: StringConstructor;
68
+ default: undefined;
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
+ };
102
+ }>> & Readonly<{}>, {
103
+ branch: string | null;
104
+ commit: string | null;
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;
114
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
115
+ export declare const CommentKitPlugin: {
116
+ install(_app: App, options: CommentKitOptions): void;
117
+ };
118
+ 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,31 @@
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
+ /** Reuse this Idempotency-Key (a "Try again" after a failed attempt must send the same one). */
8
+ idempotencyKey?: string;
9
+ headers?: Record<string, string>;
10
+ /** Skip the Authorization header (public endpoints). */
11
+ anonymous?: boolean;
12
+ signal?: AbortSignal;
13
+ }
14
+ export type TokenProvider = {
15
+ accessToken(): Promise<string | null>;
16
+ /** Called once on a 401; returns true if a fresh token is now available. */
17
+ recover(): Promise<boolean>;
18
+ };
19
+ /**
20
+ * Thin fetch wrapper for /api/v1: JSON in/out, problem+json errors as
21
+ * CommentKitError, one silent re-auth on 401, and bounded retries with
22
+ * backoff for transient failures (network, 429, 5xx).
23
+ */
24
+ export declare class ApiClient {
25
+ private readonly baseUrl;
26
+ private readonly tokens;
27
+ private readonly sdkVersion;
28
+ constructor(baseUrl: string, tokens: TokenProvider, sdkVersion: string);
29
+ request<T>(path: string, options?: ApiRequest): Promise<T>;
30
+ url(path: string, query?: ApiRequest["query"]): string;
31
+ }
@@ -0,0 +1,87 @@
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
+ }
11
+ export type SignInResult = "signed_in" | "popup_blocked" | "cancelled" | "failed" | "redirecting";
12
+ export type AuthMode = "auto" | "popup" | "redirect";
13
+ /** In-app browsers (WhatsApp, Instagram, Slack…) open "popups" in the same view, so use a full-page redirect there. */
14
+ export declare function prefersRedirect(ua?: string): boolean;
15
+ /**
16
+ * Widget sign-in: a popup on the CommentKit domain (credentials never touch
17
+ * this page), PKCE, short-lived access tokens and a rotating refresh token.
18
+ *
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.
23
+ */
24
+ export declare class AuthManager {
25
+ private readonly endpoint;
26
+ private readonly projectKey;
27
+ private readonly origin;
28
+ private access;
29
+ private refreshing;
30
+ private listeners;
31
+ private remember;
32
+ private authorize;
33
+ constructor(endpoint: string, projectKey: string, origin?: string);
34
+ get storageKey(): string;
35
+ hasSession(): boolean;
36
+ onChange(listener: (signedIn: boolean) => void): () => void;
37
+ /** A valid access token, refreshing if needed. null when signed out. */
38
+ accessToken(): Promise<string | null>;
39
+ recover(): Promise<boolean>;
40
+ /** Must be called from a user gesture (click) so the popup is allowed. */
41
+ signIn(options?: {
42
+ share?: string | null;
43
+ mode?: AuthMode;
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>;
47
+ /**
48
+ * Finish a redirect sign-in when the page loads with ?ck_code=&ck_state=.
49
+ * Returns true when a session was created. Removes the params from the URL.
50
+ */
51
+ completeRedirect(): Promise<boolean>;
52
+ private get pkceKey();
53
+ private authorizeUrl;
54
+ private redirect;
55
+ signOut(): Promise<void>;
56
+ private awaitCode;
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;
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;
83
+ private clear;
84
+ private readRefresh;
85
+ private emit;
86
+ private post;
87
+ }