@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.
- package/CHANGELOG.md +87 -0
- package/README.md +172 -732
- package/SECURITY.md +24 -14
- package/dist/npm/THIRD_PARTY_NOTICES.txt +73 -0
- package/dist/npm/chunks/Guest-CKoV6pEK.js +157 -0
- package/dist/npm/chunks/MarkupEditor-DAo4qppg.js +199 -0
- package/dist/npm/chunks/Panel-BRBDHlGg.js +399 -0
- package/dist/npm/chunks/Shortcuts-CHMcrjAM.js +56 -0
- package/dist/npm/chunks/ThreadCard-D8FzIxbs.js +570 -0
- package/dist/npm/chunks/anchor-DT-Ynhh1.js +270 -0
- package/dist/npm/chunks/ar-D3SPpN1T.js +195 -0
- package/dist/npm/chunks/client-D1NizpDK.js +627 -0
- package/dist/{shared/capture-colors-D0uLr-vZ.js → npm/chunks/colors-CX-IPjvb.js} +2 -0
- package/dist/npm/chunks/de-C8eC6c6f.js +187 -0
- package/dist/npm/chunks/es-Bczf42tm.js +187 -0
- package/dist/npm/chunks/extension--it1LAj-.js +54 -0
- package/dist/npm/chunks/extension-XfuRGu2o.js +26 -0
- package/dist/npm/chunks/format-Bw_tNOh9.js +524 -0
- package/dist/npm/chunks/fr-BaQw-v2e.js +187 -0
- package/dist/npm/chunks/hi-BamV-yXv.js +187 -0
- package/dist/npm/chunks/html2canvas-DfGb8yka.js +4024 -0
- package/dist/npm/chunks/it-DC14_EjN.js +187 -0
- package/dist/npm/chunks/ja-B1mmTN7Y.js +187 -0
- package/dist/npm/chunks/mount-5fFig0k6.js +1447 -0
- package/dist/npm/chunks/nl-BfhqUsmX.js +187 -0
- package/dist/npm/chunks/privacy-DLhezjyi.js +30 -0
- package/dist/npm/chunks/pt-BR-CEPu4W5U.js +187 -0
- package/dist/{shared/pusher-CnhQgAvF.js → npm/chunks/pusher-BSsQoE1K.js} +224 -222
- package/dist/npm/chunks/realtime-CBRW9BB3.js +34 -0
- package/dist/npm/chunks/report-Dh4fxd4J.js +27 -0
- package/dist/npm/chunks/rolldown-runtime-Y_bBpyJl.js +20 -0
- package/dist/npm/chunks/src-DujplxfI.js +517 -0
- package/dist/npm/chunks/zh-CN-kgqjYwHQ.js +187 -0
- package/dist/npm/element.js +41 -0
- package/dist/npm/headless.js +3 -0
- package/dist/npm/index.js +3 -0
- package/dist/npm/react.js +26 -0
- package/dist/npm/svelte.js +17 -0
- package/dist/npm/types/adapters/react.d.ts +11 -0
- package/dist/npm/types/adapters/svelte.d.ts +9 -0
- package/dist/npm/types/adapters/vue.d.ts +118 -0
- package/dist/npm/types/anchor/index.d.ts +49 -0
- package/dist/npm/types/core/api.d.ts +31 -0
- package/dist/npm/types/core/auth.d.ts +87 -0
- package/dist/npm/types/core/client.d.ts +114 -0
- package/dist/npm/types/core/store.d.ts +7 -0
- package/dist/npm/types/core/types.d.ts +303 -0
- package/dist/npm/types/element.d.ts +13 -0
- package/dist/npm/types/headless.d.ts +7 -0
- package/dist/npm/types/index.d.ts +32 -0
- package/dist/npm/vue.js +71 -0
- package/package.json +71 -173
- package/dist/THIRD_PARTY_NOTICES.txt +0 -284
- package/dist/angular.es.js +0 -321
- package/dist/comment-kit.es.js +0 -218
- package/dist/demo.es.js +0 -483
- package/dist/headless.es.js +0 -4
- package/dist/preact.es.js +0 -117
- package/dist/qwik.es.js +0 -1
- package/dist/qwik.qwik.mjs +0 -114
- package/dist/react.es.js +0 -98
- package/dist/shared/ShadowRootContext-DD6a0QaI.js +0 -11
- package/dist/shared/annotation-icons-Dh-bmNYK.js +0 -172
- package/dist/shared/annotation-toolbar-zeiCmKIr.js +0 -1086
- package/dist/shared/attachment-refresh-DAacLaRu.js +0 -94
- package/dist/shared/bridge-CJoGYngu.js +0 -177
- package/dist/shared/button-D4GHW6oZ.js +0 -474
- package/dist/shared/button-group-BVR7iT-S.js +0 -91
- package/dist/shared/capture-privacy-CiOrcAlt.js +0 -101
- package/dist/shared/comment-drawing-canvas-Btc12IsS.js +0 -124
- package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
- package/dist/shared/comment-image-lightbox--QpbcAtH.js +0 -190
- package/dist/shared/comment-images-content-C_r4SHM-.js +0 -214
- package/dist/shared/comment-kit-core-CmLUFujd.js +0 -3682
- package/dist/shared/comment-kit-ui-BHwYuSIi.js +0 -19391
- package/dist/shared/comment-screenshot-annotator-zJZyO-XM.js +0 -151
- package/dist/shared/comment-screenshot-overlay-CoKTYB0J.js +0 -205
- package/dist/shared/comment-shortcut-groups-CfEmkitU.js +0 -153
- package/dist/shared/createReactComponent-BZHeRbD0.js +0 -45
- package/dist/shared/dev-export-panel-Cnt6oCZU.js +0 -207
- package/dist/shared/dev-grab-B85jo9AS.js +0 -197
- package/dist/shared/dist-D9A5k-N4.js +0 -617
- package/dist/shared/dom-Bhf4WFtY.js +0 -223
- package/dist/shared/element-selector-Cng84xC7.js +0 -902
- package/dist/shared/error-boundary-D3PD74vI.js +0 -21
- package/dist/shared/errors-Bu5ajEmB.js +0 -22
- package/dist/shared/icons-nzMOLzrm.js +0 -266
- package/dist/shared/input-UPtAj0M6.js +0 -111
- package/dist/shared/mount-ui-Dz7FB_Ak.js +0 -208
- package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
- package/dist/shared/realtime-yGLX4wMK.js +0 -334
- package/dist/shared/request-activity-DQrAUwfA.js +0 -11
- package/dist/shared/screenshot-B5-hwpmt.js +0 -199
- package/dist/shared/separator-UhJb0Row.js +0 -3955
- package/dist/shared/shadow-root-B58ZI2yz.js +0 -133
- package/dist/shared/styles-CnYsLS2f.js +0 -2
- package/dist/shared/text-B4HHZNaa.js +0 -23
- package/dist/shared/token-session-D92MYbNu.js +0 -25
- package/dist/shared/useLabelableId-8n0QmH8N.js +0 -154
- package/dist/shared/useRender-Uxk1OPK-.js +0 -5
- package/dist/shared/useValueChanged-DKq5cMot.js +0 -92
- package/dist/shared/validation-3wbbbuX0.js +0 -70
- package/dist/shared/websocket-manager-KhH4hL0Q.js +0 -381
- package/dist/solid.es.js +0 -98
- package/dist/svelte.es.js +0 -130
- package/dist/types/adapters/bridge.d.ts +0 -122
- package/dist/types/angular/index.d.ts +0 -145
- package/dist/types/core/agent-context.d.ts +0 -17
- package/dist/types/core/api-client.d.ts +0 -155
- package/dist/types/core/comment-kit-core.d.ts +0 -254
- package/dist/types/core/local-demo.d.ts +0 -60
- package/dist/types/core/types.d.ts +0 -770
- package/dist/types/core/websocket-manager.d.ts +0 -125
- package/dist/types/core/write-access.d.ts +0 -11
- package/dist/types/demo.d.ts +0 -17
- package/dist/types/headless.d.ts +0 -8
- package/dist/types/index.d.ts +0 -87
- package/dist/types/preact/index.d.ts +0 -25
- package/dist/types/qwik/index.d.ts +0 -73
- package/dist/types/react/client.d.ts +0 -31
- package/dist/types/react/index.d.ts +0 -4
- package/dist/types/solid/index.d.ts +0 -37
- package/dist/types/svelte/index.d.ts +0 -55
- package/dist/types/utils/dom.d.ts +0 -59
- package/dist/types/utils/event-emitter.d.ts +0 -11
- package/dist/types/vue/index.d.ts +0 -87
- package/dist/vue.es.js +0 -148
- package/docs/api-reference.md +0 -405
- package/docs/local-demo.md +0 -60
package/dist/vue.es.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./shared/comment-kit-core-CmLUFujd.js";
|
|
2
|
-
import { n as t, r as n, t as r } from "./shared/bridge-CJoGYngu.js";
|
|
3
|
-
import { n as i, t as a } from "./shared/errors-Bu5ajEmB.js";
|
|
4
|
-
import { computed as o, h as s, onMounted as c, onUnmounted as l, shallowRef as u, watch as d } from "vue";
|
|
5
|
-
function f(s) {
|
|
6
|
-
let f = typeof s == "function" ? s : () => s, p = u(null), m = u(!1), h = u(!0), g = u(null), _ = u(null), v = o(() => r.isAuthenticated(p.value)), y = o(() => r.isOverlayVisible(p.value)), b = o(() => r.isSidebarVisible(p.value)), x = o(() => r.currentUser(p.value)), S = o(() => r.comments(p.value)), C = o(() => r.activeTool(p.value)), w = o(() => r.otpStep(p.value)), T = o(() => r.otpEmail(p.value)), E = o(() => r.pendingMutationCount(p.value)), D = o(() => r.isOnline(p.value)), O = o(() => r.selectedComment(p.value)), k = o(() => r.connectionStatus(p.value)), A = o(() => r.panelView(p.value)), j = o(() => r.isShortcutsOverlayVisible(p.value)), M = o(() => r.activeDrawing(p.value)), N = o(() => r.activeScreenshot(p.value)), P = t(() => _.value, (e) => {
|
|
7
|
-
g.value = a(e);
|
|
8
|
-
}), F = [], I = null, L = !1, R = !1, z = () => {
|
|
9
|
-
if (!R) {
|
|
10
|
-
R = !0;
|
|
11
|
-
try {
|
|
12
|
-
f().onReady?.();
|
|
13
|
-
} catch {}
|
|
14
|
-
}
|
|
15
|
-
}, B = (e) => {
|
|
16
|
-
g.value = e;
|
|
17
|
-
try {
|
|
18
|
-
f().onError?.(e);
|
|
19
|
-
} catch {}
|
|
20
|
-
}, V = async (e) => {
|
|
21
|
-
try {
|
|
22
|
-
let { mountCommentKitUI: t } = await import("./shared/mount-ui-Dz7FB_Ak.js").then((e) => e.n);
|
|
23
|
-
if (L || _.value !== e) return;
|
|
24
|
-
let n = await t(e);
|
|
25
|
-
if (L || _.value !== e) {
|
|
26
|
-
n.unmount();
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
I = n;
|
|
30
|
-
} catch (t) {
|
|
31
|
-
!L && _.value === e && B(i(t));
|
|
32
|
-
}
|
|
33
|
-
}, H = () => {
|
|
34
|
-
for (; F.length > 0;) {
|
|
35
|
-
let e = F.pop();
|
|
36
|
-
try {
|
|
37
|
-
e?.();
|
|
38
|
-
} catch {}
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
I?.unmount();
|
|
42
|
-
} catch {}
|
|
43
|
-
I = null;
|
|
44
|
-
let e = _.value;
|
|
45
|
-
if (_.value = null, e) try {
|
|
46
|
-
e.destroy();
|
|
47
|
-
} catch {}
|
|
48
|
-
m.value = !1, R = !1;
|
|
49
|
-
}, U = () => {
|
|
50
|
-
if (L) return;
|
|
51
|
-
let t = f(), r = null;
|
|
52
|
-
try {
|
|
53
|
-
h.value = !0, g.value = null, r = new e(t), _.value = r, n(P), t.enabled !== !1 && V(r), F.push(r.on("state:changed", (e) => {
|
|
54
|
-
L || _.value !== r || (p.value = e, e.isAuthenticated && z());
|
|
55
|
-
}), r.on("error", (e) => {
|
|
56
|
-
L || _.value !== r || B(e);
|
|
57
|
-
}));
|
|
58
|
-
let i = r.getState();
|
|
59
|
-
if (L || _.value !== r) return;
|
|
60
|
-
p.value = i, m.value = !0, h.value = !1, i.isAuthenticated && z();
|
|
61
|
-
} catch (e) {
|
|
62
|
-
if (r && _.value === r) {
|
|
63
|
-
_.value = null;
|
|
64
|
-
try {
|
|
65
|
-
r.destroy();
|
|
66
|
-
} catch {}
|
|
67
|
-
}
|
|
68
|
-
L || (h.value = !1, B(a(e))), _.value = null;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
return l(() => {
|
|
72
|
-
L = !0, H();
|
|
73
|
-
}), c(() => {
|
|
74
|
-
U();
|
|
75
|
-
}), d(() => {
|
|
76
|
-
let e = f();
|
|
77
|
-
return [
|
|
78
|
-
e.apiKey,
|
|
79
|
-
e.baseUrl,
|
|
80
|
-
e.enabled,
|
|
81
|
-
e.screenshotProvider !== void 0,
|
|
82
|
-
JSON.stringify(e.ui ?? null)
|
|
83
|
-
];
|
|
84
|
-
}, (e, t) => {
|
|
85
|
-
!L && _.value && (t && e.every((e, n) => e === t[n]) || (H(), U()));
|
|
86
|
-
}), {
|
|
87
|
-
state: p,
|
|
88
|
-
isReady: m,
|
|
89
|
-
isLoading: h,
|
|
90
|
-
error: g,
|
|
91
|
-
core: _,
|
|
92
|
-
isAuthenticated: v,
|
|
93
|
-
isOverlayVisible: y,
|
|
94
|
-
isSidebarVisible: b,
|
|
95
|
-
currentUser: x,
|
|
96
|
-
comments: S,
|
|
97
|
-
activeTool: C,
|
|
98
|
-
otpStep: w,
|
|
99
|
-
otpEmail: T,
|
|
100
|
-
pendingMutationCount: E,
|
|
101
|
-
isOnline: D,
|
|
102
|
-
selectedComment: O,
|
|
103
|
-
connectionStatus: k,
|
|
104
|
-
panelView: A,
|
|
105
|
-
isShortcutsOverlayVisible: j,
|
|
106
|
-
activeDrawing: M,
|
|
107
|
-
activeScreenshot: N,
|
|
108
|
-
...P
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
var p = {
|
|
112
|
-
name: "CommentKit",
|
|
113
|
-
props: {
|
|
114
|
-
apiKey: {
|
|
115
|
-
type: String,
|
|
116
|
-
required: !0
|
|
117
|
-
},
|
|
118
|
-
baseUrl: {
|
|
119
|
-
type: String,
|
|
120
|
-
default: void 0
|
|
121
|
-
},
|
|
122
|
-
enabled: { default: void 0 },
|
|
123
|
-
screenshotProvider: {
|
|
124
|
-
type: Function,
|
|
125
|
-
default: void 0
|
|
126
|
-
},
|
|
127
|
-
ui: {
|
|
128
|
-
type: Object,
|
|
129
|
-
default: void 0
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
emits: ["ready", "error"],
|
|
133
|
-
setup(e, { emit: t, slots: n }) {
|
|
134
|
-
let { isLoading: r } = f(() => ({
|
|
135
|
-
apiKey: e.apiKey,
|
|
136
|
-
baseUrl: e.baseUrl,
|
|
137
|
-
enabled: e.enabled,
|
|
138
|
-
screenshotProvider: e.screenshotProvider,
|
|
139
|
-
ui: e.ui,
|
|
140
|
-
onReady: () => t("ready"),
|
|
141
|
-
onError: (e) => t("error", e)
|
|
142
|
-
}));
|
|
143
|
-
return () => s("div", { class: "comment-kit-vue" }, [...n.default?.() ?? [], ...r.value && n.loading ? n.loading() ?? [] : []]);
|
|
144
|
-
}
|
|
145
|
-
}, m = { install(e) {
|
|
146
|
-
e.component("CommentKit", p), e.provide("commentKitUtils", { useCommentKit: f });
|
|
147
|
-
} };
|
|
148
|
-
export { p as CommentKit, p as default, m as CommentKitPlugin, f as useCommentKit };
|
package/docs/api-reference.md
DELETED
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
# API Reference
|
|
2
|
-
|
|
3
|
-
Reference for the CommentKit engine and integration APIs. This file is included in the npm package alongside its public TypeScript declarations.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Core Methods
|
|
8
|
-
|
|
9
|
-
The tables describe `CommentKitCore`. The vanilla `CommentKit` instance delegates the integration methods and exposes the engine through `getCore()`. React exposes `core` from `useCommentKit()`; other adapters expose their core through a ref, store, signal or observable and delegate their documented action methods. For a low-level engine method such as `blockEscape()`, use that core handle. Headless consumers import `CommentKitCore` from `@commentkit/comment-kit/headless`.
|
|
10
|
-
|
|
11
|
-
Many action methods return `Promise<void>` and report validation or backend failures through the `error` event and `getState().error`. A resolved promise can also mean an offline mutation was queued. Custom interfaces should observe the relevant comment/offline events and state before declaring a save successful; upload and capture helpers can also reject or return `null`.
|
|
12
|
-
|
|
13
|
-
Qwik uses `useCommentKit` from `@commentkit/comment-kit/qwik` inside `component$`; the hook handles client mounting with `useVisibleTask$`. Destructure its `core` signal and use `core.value?.method()` inside Qwik event handlers rather than capturing plain bridge callbacks across an `onClick$` boundary. The deprecated `useCommentKit$` alias remains available for compatibility. The built-in Qwik widget requires React and ReactDOM, like the other UI adapters.
|
|
14
|
-
|
|
15
|
-
### Authentication
|
|
16
|
-
|
|
17
|
-
| Method | Returns | Description |
|
|
18
|
-
| ----------------------- | --------------- | ----------------------------------------------------------------------- |
|
|
19
|
-
| `validateInvite(email)` | `Promise<void>` | Validate a member invite token + email, then auto-trigger OTP flow |
|
|
20
|
-
| `login(email)` | `Promise<void>` | Request OTP code sent to the given email |
|
|
21
|
-
| `verifyOtp(code)` | `Promise<void>` | Verify the email code, then the authenticator/recovery code if required |
|
|
22
|
-
| `cancelOtp()` | `void` | Cancel the OTP flow and return to email entry |
|
|
23
|
-
| `resendOtp()` | `Promise<void>` | Resend OTP to the same email |
|
|
24
|
-
| `logout()` | `void` | Clear authentication and disconnect real-time |
|
|
25
|
-
|
|
26
|
-
For accounts with two-factor authentication enabled, the email code advances `otpStep` to `"mfa"`; it does **not** authenticate the user or issue a bearer token. The built-in widget asks for an authenticator or unused recovery code. Headless/custom UIs should render that second step and call `verifyOtp(code)` again. Treat only `isAuthenticated`/`auth:login` as completed sign-in. The short-lived `otpMfaChallenge` stays in memory and is cleared on cancellation, logout, or successful sign-in. Closing the login modal also cancels pending authentication responses.
|
|
27
|
-
|
|
28
|
-
The backend binds this challenge to the account, project, current email and enrolled factor, expires it after five minutes, limits guesses, and consumes successful challenges and recovery codes once. Older SDKs fail closed when the API requires MFA; upgrade the widget to complete that flow.
|
|
29
|
-
|
|
30
|
-
### UI Controls
|
|
31
|
-
|
|
32
|
-
| Method | Returns | Description |
|
|
33
|
-
| -------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
34
|
-
| `toggleOverlay()` | `void` | Show or hide the comment overlay |
|
|
35
|
-
| `toggleSidebar()` | `void` | Show or hide the comment sidebar |
|
|
36
|
-
| `toggleLoginModal()` | `void` | Show or hide the login modal |
|
|
37
|
-
| `setTool(tool)` | `void` | Set the active tool. Pass `"comment"`, `"select"`, `"draw"`, `"highlight"`, `"screenshot"`, or `null` to deactivate |
|
|
38
|
-
| `toggleShortcutsOverlay()` | `void` | Show or hide the keyboard shortcuts overlay |
|
|
39
|
-
| `setPanelView(view)` | `void` | Set the sidebar panel view: `"list"`, `"detail"`, `"settings"`, `"activity"`, or `"dev-export"` (localhost only) |
|
|
40
|
-
| `blockEscape()` | `() => void` | Block the core's Escape chain while an overlay UI is open. Returns a release function. Used by built-in overlays (context menu); also available to custom UI |
|
|
41
|
-
|
|
42
|
-
### Comments
|
|
43
|
-
|
|
44
|
-
| Method | Returns | Description |
|
|
45
|
-
| ------------------------------------------------------------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
46
|
-
| `createComment(type, content, position, priority?, textSelection?, drawingData?, options?)` | `Promise<void>` | Create a new comment with optimistic UI update. `type` is `"pin"`, `"highlight"`, or `"drawing"` |
|
|
47
|
-
| `createHighlight(textSelection, content)` | `Promise<void>` | Convenience wrapper around `createComment("highlight", …)` |
|
|
48
|
-
| `createDrawing(drawingData, position, content)` | `Promise<void>` | Convenience wrapper around `createComment("drawing", …)` |
|
|
49
|
-
| `updateComment(commentId, updates)` | `Promise<void>` | Update fields on an existing comment (content, status, priority, description, assignees, checklist, drawingData, textSelection) |
|
|
50
|
-
| `deleteComment(id)` | `Promise<void>` | Delete a comment (optimistic, rolls back on failure) |
|
|
51
|
-
| `resolveComment(id)` | `Promise<void>` | Mark a comment as resolved |
|
|
52
|
-
| `unresolveComment(id)` | `Promise<void>` | Reopen a resolved comment |
|
|
53
|
-
| `completeComment(id)` | `Promise<void>` | Mark a comment as complete |
|
|
54
|
-
| `selectComment(comment)` | `void` | Select a comment (pass `null` to deselect) |
|
|
55
|
-
| `addReply(commentId, content, options?)` | `Promise<void>` | Add a reply, optional draft attachment IDs, mentions and a quote target; a reply reopens a closed thread |
|
|
56
|
-
| `updateReply(commentId, replyId, content, options?)` | `Promise<void>` | Update reply content and optional attachment/mention metadata |
|
|
57
|
-
| `deleteReply(commentId, replyId)` | `Promise<void>` | Delete a reply |
|
|
58
|
-
| `reactToComment(commentId, emoji, replyId?)` | `Promise<void>` | Toggle a parent reaction, or a specific reply reaction when `replyId` is supplied |
|
|
59
|
-
| `updateCommentPosition(commentId, x, y)` | `Promise<void>` | Move a comment pin to new coordinates |
|
|
60
|
-
| `loadEarlierReplies()` | `Promise<void>` | Prepend the next page of replies for the selected thread |
|
|
61
|
-
| `setCommentQuery(query)` | `Promise<void>` | Change server search/filters and reset the list cursor |
|
|
62
|
-
| `loadMoreComments()` | `Promise<void>` | Load the next page of comments (pagination) |
|
|
63
|
-
|
|
64
|
-
### Project context, branches and retrieval
|
|
65
|
-
|
|
66
|
-
| Method | Returns | Description |
|
|
67
|
-
| ------------------------ | --------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
68
|
-
| `reloadComments()` | `Promise<void>` | Replace loaded comments with the first page for the active project/branch. |
|
|
69
|
-
| `setBranch(branch)` | `Promise<void>` | Select a nonempty branch name or `null` for all branches; clear the current selection/list and load that branch’s first page. |
|
|
70
|
-
| `reloadProjectContext()` | `Promise<void>` | Refresh authenticated project, organization, member, usage, branch and permission context. |
|
|
71
|
-
|
|
72
|
-
Use `updateComment(id, { checklistPatch: { id: taskId, done: true } })` to toggle one checklist task without replacing another reviewer’s task state. The whole `checklist` array remains available for editing labels and ordering. Never send both in one request.
|
|
73
|
-
|
|
74
|
-
Read `getState().projectContext`, `getState().activeBranch`, `getState().comments` and `getState().pagination` for the results. Context is null until an authenticated response is available. A missing context route on an older API is tolerated; it does not enable new server features. `loadMoreComments()` appends another page and becomes a no-op when there are no more pages.
|
|
75
|
-
|
|
76
|
-
Set `config.branch` to the branch actually deployed on the host, such as `main`. This controls the branch recorded on new pins, highlights, drawings and screenshots, including offline replay. `setBranch()` changes the viewing filter; selecting another branch or **All branches** does not relabel feedback created on a configured deployment. A caller can explicitly override the branch of `createComment` through `CommentCreateOptions.branch`. For older integrations without `config.branch`, creation retains the selected branch as its fallback.
|
|
77
|
-
|
|
78
|
-
The API fetches across project pages. The built-in **Page** tab requests the current path from the server; **All** includes other pages. A `#comment-ID` link retrieves its authorized target even beyond the first loaded page. The engine resolves this internally after authentication; do not call a private loader. Cross-page links retain the comment’s original page URL, and markers only target the current page’s DOM.
|
|
79
|
-
|
|
80
|
-
The built-in panel sends text search (up to 200 characters), status, priority, assignee, author, page and sort filters to the backend. Search covers authorized thread and reply content and author names across the project, not only loaded threads. Changing filters resets the cursor and invalidates older requests. `core.setCommentQuery({ search, status, priority, assignee, user: "me", pagePath, sort, excludeComplete })` exposes this behavior to custom UIs.
|
|
81
|
-
|
|
82
|
-
Lists use stable cursor pagination and compact thread summaries (`detailLoaded: false`, `repliesCount`, empty `replies`). Selecting a summary fetches the newest 50 replies. `core.loadEarlierReplies()` prepends the next bounded history page; the built-in panel exposes **Load earlier replies**. Replies remain chronologically ordered. Async agent copy hydrates at most 12 recent replies per selected summary, discloses omitted replies, and keeps private signed URLs out of the payload. The synchronous export describes only its loaded snapshot.
|
|
83
|
-
|
|
84
|
-
Deploy the matching backend API before this SDK. The backend retains the full, offset-based response for older SDKs that do not request the new read contract. The separate local-browser demo continues to filter its local data.
|
|
85
|
-
|
|
86
|
-
`projectContext.permissions.canWriteComments` and `writeRestriction` describe the current backend write capability. An expired paid plan keeps authenticated viewing and export, while creation, replies, edits, deletion, reactions, status changes, pin moves and uploads are disabled. A project-level disabled-comments setting is shown separately from a missing paid plan. The backend enforces these rules; hiding UI controls is not authorization. Storage or individual tool limits do not disable ordinary text feedback. The public browser-local demo is a separate sandbox and does not grant access to production projects.
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
// With an authenticated core from your integration:
|
|
90
|
-
await core.setBranch("preview");
|
|
91
|
-
await core.loadMoreComments();
|
|
92
|
-
await core.reloadProjectContext();
|
|
93
|
-
const { projectContext, activeBranch, pagination } = core.getState();
|
|
94
|
-
|
|
95
|
-
await core.setBranch(null); // All branches, including older untagged comments.
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### Composer payloads and message identity
|
|
99
|
-
|
|
100
|
-
`CommentCreateOptions` carries `description`, `assignees`, `checklist`, `mentions`, `files`, preuploaded `attachmentIds`, `branch` and `deviceInfo`. It is the final argument of `createComment`. `ReplyOptions` carries `attachmentIds`, `mentions` and `replyTo`. These APIs require the matching backend deployment and migrations described in the [installation guide](../README.md#backend-upgrade-order).
|
|
101
|
-
|
|
102
|
-
```ts
|
|
103
|
-
const attachmentIds = await core.uploadFiles([file]);
|
|
104
|
-
await core.addReply(threadId, "Here is the revised layout", {
|
|
105
|
-
attachmentIds,
|
|
106
|
-
replyTo: { type: "comment", id: threadId },
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// Parent and reply IDs belong to separate namespaces.
|
|
110
|
-
await core.reactToComment(threadId, "👍", replyId);
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
A quote target is `{ type: "comment" | "reply", id: string }`. The backend validates that it belongs to the thread and returns the saved author/body snapshot; callers do not supply trusted author text. Temporary optimistic IDs are not valid persisted quote or reaction targets. Preserve successful upload IDs if your custom interface retries a failed save; the built-in composer does this automatically.
|
|
114
|
-
|
|
115
|
-
Comments expose canonical `createdAt`/`updatedAt` and optional `resolvedAt`/`completedAt` timestamps. Real workflow transitions set lifecycle dates, repeated transitions preserve them, and reopening or replying clears them. Legacy records can omit historical lifecycle dates. Format dates only for display; keep their canonical values for equality and ordering.
|
|
116
|
-
|
|
117
|
-
### Drawing / Screenshot / Files
|
|
118
|
-
|
|
119
|
-
| Method | Returns | Description |
|
|
120
|
-
| ------------------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
121
|
-
| `captureScreenshot(element?)` | `Promise<ScreenshotResult \| null>` | Capture a screenshot of the page or a specific element |
|
|
122
|
-
| `uploadScreenshot(screenshot, content, position)` | `Promise<Comment \| null>` | Upload a screenshot and create a comment |
|
|
123
|
-
| `setActiveScreenshot(screenshot)` | `void` | Set the currently-active screenshot (drives the screenshot composer UI) |
|
|
124
|
-
| `setActiveDrawing(drawing)` | `void` | Set the currently-active drawing (drives the drawing composer UI) |
|
|
125
|
-
| `sendDrawingStroke(path)` | `void` | Broadcast a drawing stroke to other connected users via the realtime channel |
|
|
126
|
-
| `uploadFiles(files, options?)` | `Promise<string[]>` | Upload supported attachment files and return IDs. Omit options for drafts, or use `{ commentId?, replyId? }` to attach directly to an authorized record |
|
|
127
|
-
|
|
128
|
-
### Agent Handoff
|
|
129
|
-
|
|
130
|
-
Pass stakeholder feedback or grabbed elements to your coding agent — Claude Desktop, Cursor, Codex, Continue, Zed AI, or any clipboard-aware tool.
|
|
131
|
-
|
|
132
|
-
| Method | Returns | Description |
|
|
133
|
-
| ----------------------------------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
134
|
-
| `getAgentContext(options?)` | `AgentContextExport` | Build a comments-only export (sync). Uses selector + XPath only |
|
|
135
|
-
| `getAgentContextAsync(options?)` | `Promise<AgentContextExport>` | Same as above but also resolves each comment's element to a source-file location when the optional source-resolver peer dep is installed |
|
|
136
|
-
| `formatAgentContext(options?)` | `string` | Build the sync export, then render it as Markdown |
|
|
137
|
-
| `formatAgentContextAsync(options?)` | `Promise<string>` | Build the async (source-enriched) export, then render it as Markdown |
|
|
138
|
-
| `copyAgentContext(options?)` | `Promise<string>` | Build the async export, format it as Markdown, and copy it to the clipboard. Emits `agent:context-copied` |
|
|
139
|
-
| `grabElement(element, options?)` | `Promise<DevGrabResult \| null>` | Capture an element: screenshot + source-resolved location + HTML + selector/XPath. Writes Markdown + `image/png` to the clipboard. Emits `agent:element-grabbed` |
|
|
140
|
-
| `grabElements(elements, options?)` | `Promise<DevGrabBundle \| null>` | Same as `grabElement` for an array. Inlines each screenshot as a Markdown data URL. Emits `agent:elements-grabbed` |
|
|
141
|
-
|
|
142
|
-
`AgentContextOptions`:
|
|
143
|
-
|
|
144
|
-
| Field | Type | Default | Description |
|
|
145
|
-
| ----------------- | ---------- | ----------- | ------------------------------------------------------------------------- |
|
|
146
|
-
| `includeResolved` | `boolean` | `false` | Include resolved + completed comments in the export |
|
|
147
|
-
| `currentPageOnly` | `boolean` | `false` | Include only comments anchored to the current page |
|
|
148
|
-
| `includeHtml` | `boolean` | `false` | Include a clipped `outerHTML` preview for each comment's resolved element |
|
|
149
|
-
| `commentIds` | `string[]` | `undefined` | Restrict the export to specific comment ids |
|
|
150
|
-
| `maxComments` | `number` | `200` | Hard cap on number of comments exported (max `500`) |
|
|
151
|
-
| `instructions` | `string` | (built-in) | Replace the leading instructions block sent to the agent |
|
|
152
|
-
|
|
153
|
-
### Utility
|
|
154
|
-
|
|
155
|
-
| Method | Returns | Description |
|
|
156
|
-
| --------------------------- | ---------------------------- | --------------------------------------------------------------------------------------- |
|
|
157
|
-
| `getState()` | `CommentKitState` | Get the current state snapshot (deep-cloned — safe to mutate) |
|
|
158
|
-
| `getFeatures()` | `object` | Get resolved feature flags |
|
|
159
|
-
| `getConfig()` | `Readonly<CommentKitConfig>` | Get a public configuration copy; internal project and realtime credentials are excluded |
|
|
160
|
-
| `getProjectMembers()` | `Promise<User[]>` | Fetch team members for @mention autocomplete |
|
|
161
|
-
| `getOnlineUsers()` | `User[]` | Get currently connected users |
|
|
162
|
-
| `getUnreadActivityCount()` | `number` | Get unread activity feed count |
|
|
163
|
-
| `getPendingMutationCount()` | `number` | Get queued offline mutations count |
|
|
164
|
-
| `markThreadSeen(threadId)` | `void` | Mark a thread as seen |
|
|
165
|
-
| `isThreadNew(threadId)` | `boolean` | Check if a thread is unseen |
|
|
166
|
-
| `markAllActivitiesRead()` | `void` | Mark all activities as read |
|
|
167
|
-
| `destroy()` | `void` | Clean up all listeners, timers, and WebSocket connections |
|
|
168
|
-
|
|
169
|
-
---
|
|
170
|
-
|
|
171
|
-
## Events
|
|
172
|
-
|
|
173
|
-
Listen to SDK events for custom integrations.
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
// Subscribe
|
|
177
|
-
const unsub = ck.on("comment:created", (comment) => {
|
|
178
|
-
console.log("New comment:", comment);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
// Unsubscribe
|
|
182
|
-
unsub();
|
|
183
|
-
// or: ck.off("comment:created", handler);
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### Comment Events
|
|
187
|
-
|
|
188
|
-
| Event | Payload | When |
|
|
189
|
-
| ------------------- | ------------------------------- | -------------------------------- |
|
|
190
|
-
| `comment:created` | `Comment` | A new comment was created |
|
|
191
|
-
| `comment:updated` | `Comment` | A comment was modified |
|
|
192
|
-
| `comment:deleted` | `{ id: string }` | A comment was deleted |
|
|
193
|
-
| `comment:resolved` | `Comment` | A comment was marked as resolved |
|
|
194
|
-
| `comment:completed` | `Comment` | A comment was marked as complete |
|
|
195
|
-
| `comment:reaction` | `{ commentId, emoji, comment }` | A reaction was toggled |
|
|
196
|
-
| `comment:position` | `{ commentId, position }` | A comment was repositioned |
|
|
197
|
-
|
|
198
|
-
### Auth Events
|
|
199
|
-
|
|
200
|
-
| Event | Payload | When |
|
|
201
|
-
| -------------------- | ----------------------- | -------------------------------------------------- |
|
|
202
|
-
| `auth:login` | `User` | User authenticated successfully |
|
|
203
|
-
| `auth:logout` | `void` | User logged out |
|
|
204
|
-
| `auth:otp-requested` | `{ email, expiresIn? }` | OTP was sent to email |
|
|
205
|
-
| `auth:otp-verified` | `User` | Email and any required second factor were verified |
|
|
206
|
-
|
|
207
|
-
### UI Events
|
|
208
|
-
|
|
209
|
-
| Event | Payload | When |
|
|
210
|
-
| ------------------- | ----------------- | ----------------------------- |
|
|
211
|
-
| `tool:changed` | `ToolType` | Active tool changed |
|
|
212
|
-
| `overlay:toggled` | `boolean` | Overlay visibility changed |
|
|
213
|
-
| `sidebar:toggled` | `boolean` | Sidebar visibility changed |
|
|
214
|
-
| `shortcuts:toggled` | `boolean` | Shortcuts overlay toggled |
|
|
215
|
-
| `state:changed` | `CommentKitState` | Any state changed (catch-all) |
|
|
216
|
-
|
|
217
|
-
### Agent Events
|
|
218
|
-
|
|
219
|
-
| Event | Payload | When |
|
|
220
|
-
| ------------------------ | ----------------------------------------------------------- | ------------------------------------------------------- |
|
|
221
|
-
| `agent:context-copied` | `{ commentCount: number; sourceResolved?: boolean }` | Stakeholder-comment context was copied to the clipboard |
|
|
222
|
-
| `agent:element-grabbed` | `{ source: string \| null; componentName: string \| null }` | A single element was grabbed for the agent |
|
|
223
|
-
| `agent:elements-grabbed` | `{ count: number }` | A multi-element bundle was grabbed for the agent |
|
|
224
|
-
|
|
225
|
-
### SDK Events
|
|
226
|
-
|
|
227
|
-
| Event | Payload | When |
|
|
228
|
-
| -------------- | ------------------------------------- | ---------------------------------------------------- |
|
|
229
|
-
| `sdk:outdated` | `{ current: string; latest: string }` | The backend reports a newer SDK version is available |
|
|
230
|
-
| `error` | `ApiError` | An error was produced anywhere in the SDK |
|
|
231
|
-
|
|
232
|
-
### Real-Time Events
|
|
233
|
-
|
|
234
|
-
| Event | Payload | When |
|
|
235
|
-
| -------------------- | ------------------- | ---------------------------------- |
|
|
236
|
-
| `cursor:move` | `CursorPosition` | Another user moved their cursor |
|
|
237
|
-
| `cursor:leave` | `{ userId }` | A user's cursor left the page |
|
|
238
|
-
| `user:joined` | `User` | A user came online |
|
|
239
|
-
| `user:left` | `{ userId }` | A user went offline |
|
|
240
|
-
| `presence:update` | `{ users: User[] }` | Online users list changed |
|
|
241
|
-
| `connection:changed` | `ConnectionStatus` | WebSocket connection state changed |
|
|
242
|
-
| `drawing:stroke` | `{ userId, path }` | Another user drew a stroke |
|
|
243
|
-
|
|
244
|
-
### Offline Events
|
|
245
|
-
|
|
246
|
-
| Event | Payload | When |
|
|
247
|
-
| ------------------- | ----------------- | ------------------------------------------------------------------------------------------ |
|
|
248
|
-
| `offline:queued` | `QueuedMutation` | A mutation was queued for retry |
|
|
249
|
-
| `offline:retrying` | `{ id, attempt }` | A queued mutation is being retried |
|
|
250
|
-
| `offline:completed` | `{ id }` | A queued mutation succeeded |
|
|
251
|
-
| `offline:failed` | `{ id, error }` | A queued mutation was rejected, lost its authorized owner/dependency, or exhausted retries |
|
|
252
|
-
|
|
253
|
-
---
|
|
254
|
-
|
|
255
|
-
## Selective Subscriptions
|
|
256
|
-
|
|
257
|
-
For performance-sensitive integrations, subscribe to specific state slices instead of the catch-all `state:changed` event.
|
|
258
|
-
|
|
259
|
-
### Slice Subscriptions
|
|
260
|
-
|
|
261
|
-
```typescript
|
|
262
|
-
// Only fires when auth-related state changes
|
|
263
|
-
const unsub = ck.onSlice("auth", (state) => {
|
|
264
|
-
console.log("Auth changed:", state.isAuthenticated);
|
|
265
|
-
});
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
Available slices:
|
|
269
|
-
|
|
270
|
-
| Slice | Keys |
|
|
271
|
-
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
272
|
-
| `auth` | `isAuthenticated`, `currentUser`, `project`, `projectContext`, `isLoginModalVisible`, `otpStep`, `otpEmail`, `otpMfaChallenge` |
|
|
273
|
-
| `ui` | `isOverlayVisible`, `isSidebarVisible`, `isShortcutsOverlayVisible`, `activeTool`, `isCommentModeActive`, `isDrawingModeActive`, `isHighlightModeActive`, `isScreenshotModeActive`, `selectedComment`, `activeComment`, `activeDrawing`, `activeScreenshot`, `panelView`, `activities`, `isLoading`, `error` |
|
|
274
|
-
| `comments` | `comments`, `pagination`, `seenThreadIds`, `activeBranch` |
|
|
275
|
-
| `realtime` | `onlineUsers`, `connectionStatus`, `pendingMutations`, `isOnline` |
|
|
276
|
-
|
|
277
|
-
### Selector Subscriptions
|
|
278
|
-
|
|
279
|
-
```typescript
|
|
280
|
-
// Only fires when the selected value changes
|
|
281
|
-
const unsub = ck.select(
|
|
282
|
-
(state) => state.comments.length,
|
|
283
|
-
(count) => console.log(`Now have ${count} comments`),
|
|
284
|
-
);
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
---
|
|
288
|
-
|
|
289
|
-
## TypeScript Types
|
|
290
|
-
|
|
291
|
-
Import shared protocol types from the headless entry. Framework entries also export selected integration types; their generated declarations are the source of truth:
|
|
292
|
-
|
|
293
|
-
```typescript
|
|
294
|
-
import type {
|
|
295
|
-
// Core models
|
|
296
|
-
Comment,
|
|
297
|
-
CommentReaction,
|
|
298
|
-
Reply,
|
|
299
|
-
ReplyOptions,
|
|
300
|
-
ReplyTarget,
|
|
301
|
-
CommentCreateOptions,
|
|
302
|
-
CommentDeviceInfo,
|
|
303
|
-
ProjectContext,
|
|
304
|
-
User,
|
|
305
|
-
Position,
|
|
306
|
-
Attachment,
|
|
307
|
-
TextSelection,
|
|
308
|
-
DrawingData,
|
|
309
|
-
DrawingPath,
|
|
310
|
-
ScreenshotResult,
|
|
311
|
-
ScreenshotProvider,
|
|
312
|
-
ActivityItem,
|
|
313
|
-
Mention,
|
|
314
|
-
Organization,
|
|
315
|
-
OrganizationMember,
|
|
316
|
-
Project,
|
|
317
|
-
|
|
318
|
-
// Config + state
|
|
319
|
-
CommentKitConfig,
|
|
320
|
-
CommentKitState,
|
|
321
|
-
CommentKitEvents,
|
|
322
|
-
StateSlice,
|
|
323
|
-
PanelView,
|
|
324
|
-
ToolType,
|
|
325
|
-
CommentMode,
|
|
326
|
-
ConnectionStatus,
|
|
327
|
-
PaginationInfo,
|
|
328
|
-
CursorPosition,
|
|
329
|
-
DeviceInfo,
|
|
330
|
-
TaskStatus,
|
|
331
|
-
TaskChecklistItem,
|
|
332
|
-
|
|
333
|
-
// Auth
|
|
334
|
-
AuthResponse,
|
|
335
|
-
OtpStep,
|
|
336
|
-
OtpResponse,
|
|
337
|
-
OtpVerifyResponse,
|
|
338
|
-
InviteValidationResponse,
|
|
339
|
-
|
|
340
|
-
// Agent handoff
|
|
341
|
-
AgentContextOptions,
|
|
342
|
-
AgentContextExport,
|
|
343
|
-
AgentCommentContext,
|
|
344
|
-
AgentElementContext,
|
|
345
|
-
|
|
346
|
-
// Dev grab
|
|
347
|
-
DevGrabOptions,
|
|
348
|
-
DevGrabAttachment,
|
|
349
|
-
|
|
350
|
-
// Errors + events
|
|
351
|
-
ApiError,
|
|
352
|
-
EventListener,
|
|
353
|
-
Unsubscribe,
|
|
354
|
-
|
|
355
|
-
// Filters
|
|
356
|
-
CommentFilter,
|
|
357
|
-
StatusFilter,
|
|
358
|
-
PriorityFilter,
|
|
359
|
-
AssigneeFilter,
|
|
360
|
-
PageFilter,
|
|
361
|
-
UserFilter,
|
|
362
|
-
SortOrder,
|
|
363
|
-
} from "@commentkit/comment-kit/headless";
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
### Key Types
|
|
367
|
-
|
|
368
|
-
**`Comment`** — A comment thread with author, position, replies, reactions, attachments, and task metadata.
|
|
369
|
-
|
|
370
|
-
**`ProjectContext`** — Authenticated project/organization identity, members and roles, storage usage (`limit: null` for unlimited), branch names and permissions. `canManageComments` identifies owner/admin moderation; `canTriage`, `canComplete`, `canExportAgentContext`, `canUseMcp` and `accessScope` distinguish internal members from project reviewers. External reviewers receive `organization.plan: null`, `usage: null` and no participant email directory. These optional capabilities preserve compatibility with earlier servers. `project.isPlayground` is a server-owned presentation flag; it never grants permissions.
|
|
371
|
-
|
|
372
|
-
**`ReplyOptions`** — Optional attachment IDs, mentions and a typed quote target for reply creation/editing.
|
|
373
|
-
|
|
374
|
-
**`User`** — A user with id, name, email, optional avatar, and optional organizationId.
|
|
375
|
-
|
|
376
|
-
**`CommentKitConfig`** — Configuration object passed to the SDK constructor. Includes `apiKey`, optional `baseUrl`, `branch`, `enabled`, `screenshotProvider`, `ui` (theme, position, activation) and realtime options. A trusted host can provide `authToken` from its backend; the SDK verifies it with `GET /auth/me` under the project API key before emitting `auth:login` or loading private comments. Do not put the token in a URL. Use `persistence: "memory"` for temporary sessions: the SDK neither restores/saves bearer credentials in sessionStorage nor reads/writes its offline queue in localStorage. The default `"session"` preserves standard OTP in-tab restoration and offline replay. `getConfig()` never returns `authToken`.
|
|
377
|
-
|
|
378
|
-
```ts
|
|
379
|
-
const kit = new CommentKit({
|
|
380
|
-
apiKey: session.projectKey,
|
|
381
|
-
baseUrl: `${location.origin}/api`,
|
|
382
|
-
authToken: session.sdkToken,
|
|
383
|
-
persistence: "memory",
|
|
384
|
-
});
|
|
385
|
-
kit.on("auth:login", (user) => {
|
|
386
|
-
// The server verified this member; private comments load afterward.
|
|
387
|
-
});
|
|
388
|
-
kit.on("error", (error) => {
|
|
389
|
-
// Handle an expired or rejected member token.
|
|
390
|
-
});
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
**`CommentKitState`** — The full state tree. Includes auth, `projectContext`, `activeBranch`, UI, comments, realtime, offline queue, pagination and activities.
|
|
394
|
-
|
|
395
|
-
**`CommentKitEvents`** — Maps event names to their payload types for type-safe `on()`/`off()` calls.
|
|
396
|
-
|
|
397
|
-
**`ApiError`** — Structured error with `error` code, `message`, and HTTP `code`, plus an optional `details` object.
|
|
398
|
-
|
|
399
|
-
**`AgentContextExport`** — The bundle returned by `getAgentContext` / `getAgentContextAsync`. Versioned, with element and source context, replies, and a `sourceResolved` flag. Page credentials and signed attachment URLs are redacted; attachment IDs and metadata remain available.
|
|
400
|
-
|
|
401
|
-
**`DevGrabResult`** — Result of `grabElement`. Element context, HTML, optional screenshot data URL, and the Markdown payload that hit the clipboard. Page credentials are redacted in results, events, and Markdown.
|
|
402
|
-
|
|
403
|
-
**`DevGrabBundle`** — Result of `grabElements`. An array of `DevGrabResult` plus one bundled Markdown payload.
|
|
404
|
-
|
|
405
|
-
See the installed [public protocol declarations](../dist/types/core/types.d.ts) for complete details. Result types that are not named exports can be inferred with `Awaited<ReturnType<CommentKitCore["grabElement"]>>` and the corresponding method name.
|
package/docs/local-demo.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# Private browser demo
|
|
2
|
-
|
|
3
|
-
`createCommentKitDemo` mounts the real CommentKit core and Shadow DOM UI with a
|
|
4
|
-
browser-local store. It is an explicit sandbox, separate from project API keys,
|
|
5
|
-
OTP sessions, backend data and the offline mutation queue.
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
const { createCommentKitDemo } = await import("@commentkit/comment-kit/demo");
|
|
9
|
-
const demo = await createCommentKitDemo({
|
|
10
|
-
storageKey: "website:v1", // Stored as commentkit:demo:website:v1
|
|
11
|
-
ui: { theme: "auto" },
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const unsubscribe = demo.onSessionChange((session) => {
|
|
15
|
-
console.log(session.expiresAt, session.persistence, session.commentCount);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
// Call from a visitor's explicit action.
|
|
19
|
-
await demo.getCore().copyAgentContext({ currentPageOnly: true });
|
|
20
|
-
|
|
21
|
-
// Clear only this demo and create a fresh 24-hour window.
|
|
22
|
-
demo.reset();
|
|
23
|
-
|
|
24
|
-
// Reopen pin mode after dismissing it.
|
|
25
|
-
demo.start();
|
|
26
|
-
|
|
27
|
-
// On navigation/unmount: retained demo data can be resumed before expiry.
|
|
28
|
-
unsubscribe();
|
|
29
|
-
demo.destroy();
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
The factory is asynchronous and rejects when a widget is already mounted. Call
|
|
33
|
-
it on demand, and destroy any instance that finishes loading after its host
|
|
34
|
-
component unmounts. The ordinary SDK constructor and framework adapters keep
|
|
35
|
-
their normal production behavior.
|
|
36
|
-
|
|
37
|
-
## Behavior
|
|
38
|
-
|
|
39
|
-
- Pins and element comments, replies, edits, deletions, resolution, reactions and
|
|
40
|
-
clipboard context use the normal core/UI paths with a local data client.
|
|
41
|
-
- The identity is explicitly local “You”; no account is created and no email is
|
|
42
|
-
sent. The internal `you@demo.invalid` identifier is never an address to contact.
|
|
43
|
-
- The expiration deadline is fixed at creation or Reset. Reads and edits do not
|
|
44
|
-
extend it. Expired data is rejected and cleared on access, visibility/focus,
|
|
45
|
-
writes and a timer while the page is open. Closed browsers cannot execute a
|
|
46
|
-
scheduled deletion; reopening checks expiration before hydration into the UI.
|
|
47
|
-
- Storage is scoped under `commentkit:demo:` and capped at 50 comments, 20 replies
|
|
48
|
-
per comment and 512,000 serialized characters. Stored records are validated
|
|
49
|
-
and reconstructed before use; external avatars, files and drawing data cannot
|
|
50
|
-
hydrate into the demo.
|
|
51
|
-
- If browser storage is unavailable, the sandbox uses memory for the current
|
|
52
|
-
page lifetime. Surface `persistence` so the visitor can see this limitation.
|
|
53
|
-
- File uploads, screenshot capture, drawing, highlighting, OTP, realtime and
|
|
54
|
-
network requests are unavailable. The demo does not prove cross-device
|
|
55
|
-
collaboration or live-to-localhost synchronization; explain those separately.
|
|
56
|
-
- `reset()` starts fresh; `destroy()` releases listeners, timers and UI without
|
|
57
|
-
deleting a still-valid demo. Production sessions and queues are untouched.
|
|
58
|
-
|
|
59
|
-
Suggested disclosure: “Private to this browser. Available for up to 24 hours.
|
|
60
|
-
Reset anytime.” If `persistence === "memory"`, explain that refresh clears it.
|