@commentkit/comment-kit 0.7.0 → 0.7.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 (56) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +10 -6
  3. package/SECURITY.md +14 -6
  4. package/dist/angular.es.js +2 -2
  5. package/dist/comment-kit.es.js +5 -5
  6. package/dist/demo.es.js +36 -34
  7. package/dist/headless.es.js +3 -3
  8. package/dist/preact.es.js +2 -2
  9. package/dist/qwik.qwik.mjs +2 -2
  10. package/dist/react.es.js +2 -2
  11. package/dist/shared/{ShadowRootContext-Bv-4aElu.js → ShadowRootContext-CjciYxVN.js} +4 -4
  12. package/dist/shared/annotation-toolbar-CZI1KVdW.js +1094 -0
  13. package/dist/shared/attachment-refresh-mQw-L7hB.js +94 -0
  14. package/dist/shared/{button-group-Cl9CrvvU.js → button-group-C285iSkZ.js} +14 -16
  15. package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
  16. package/dist/shared/capture-privacy-DUROnio5.js +77 -0
  17. package/dist/shared/{comment-drawing-canvas-Dzb5YoFw.js → comment-drawing-canvas-CYFFKgCm.js} +2 -2
  18. package/dist/shared/{comment-utils-BycYTSxA.js → comment-icon-4SQd3nlz.js} +30 -24
  19. package/dist/shared/comment-image-lightbox-DmTNxuqX.js +190 -0
  20. package/dist/shared/comment-images-content-BX4DQ9Ol.js +214 -0
  21. package/dist/shared/{comment-kit-core-BaSuMzp9.js → comment-kit-core-VuIidMeu.js} +1096 -793
  22. package/dist/shared/{comment-kit-ui-CzfdAZs2.js → comment-kit-ui-BjJ1ZLiv.js} +6091 -6486
  23. package/dist/shared/{comment-screenshot-annotator-C7X-_bm6.js → comment-screenshot-annotator-CMOG1md7.js} +5 -5
  24. package/dist/shared/{comment-screenshot-overlay-wIrZrcRy.js → comment-screenshot-overlay-iWW-V-Iw.js} +114 -118
  25. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +153 -0
  26. package/dist/shared/{dev-export-panel-FwFVdady.js → dev-export-panel-CrRENbMn.js} +9 -10
  27. package/dist/shared/dev-grab-Ca4MlS2Y.js +196 -0
  28. package/dist/shared/{element-selector-BhJm-NSs.js → element-selector-g1bTvdEA.js} +450 -408
  29. package/dist/shared/{mount-ui--ijs8pWT.js → mount-ui-Dz5QLq4W.js} +121 -106
  30. package/dist/shared/{pusher-ipHMJnO_.js → pusher-ue0D83de.js} +1 -1
  31. package/dist/shared/realtime-CieWAnsW.js +321 -0
  32. package/dist/shared/realtime-recovery-BSVMwsXJ.js +135 -0
  33. package/dist/shared/request-activity-DQrAUwfA.js +11 -0
  34. package/dist/shared/{separator-XDBsaWyw.js → separator-aphZiRoJ.js} +1 -1
  35. package/dist/shared/{shadow-root-C5v-T8lQ.js → shadow-root-Cv1aLuFf.js} +31 -31
  36. package/dist/shared/{styles-D3yMtaec.js → styles-CnYsLS2f.js} +1 -1
  37. package/dist/shared/text-B4HHZNaa.js +23 -0
  38. package/dist/shared/token-session-CPQpt3-u.js +25 -0
  39. package/dist/shared/useRender-D1z_X_BY.js +5 -0
  40. package/dist/shared/{validation-C7QG8j7Z.js → validation-3wbbbuX0.js} +26 -1
  41. package/dist/shared/websocket-manager-BnK55c3U.js +381 -0
  42. package/dist/solid.es.js +2 -2
  43. package/dist/svelte.es.js +2 -2
  44. package/dist/types/core/api-client.d.ts +11 -2
  45. package/dist/types/core/comment-kit-core.d.ts +11 -5
  46. package/dist/types/core/types.d.ts +54 -2
  47. package/dist/types/core/websocket-manager.d.ts +13 -0
  48. package/dist/types/core/write-access.d.ts +9 -0
  49. package/dist/vue.es.js +2 -2
  50. package/docs/api-reference.md +25 -4
  51. package/package.json +3 -2
  52. package/dist/shared/annotation-toolbar-B9SxYqoF.js +0 -1093
  53. package/dist/shared/comment-image-lightbox-BPYJT1sB.js +0 -183
  54. package/dist/shared/dev-grab-DDqg0LQf.js +0 -203
  55. package/dist/shared/realtime-Dk41VwKg.js +0 -302
  56. package/dist/shared/websocket-manager-DhLWh3Jr.js +0 -302
@@ -65,6 +65,11 @@ export interface DevGrabOptions {
65
65
  /** Optional local file references to include in the agent payload. */
66
66
  attachments?: DevGrabAttachment[];
67
67
  }
68
+ /** Attachment metadata safe to export to agents; signed URLs are omitted. */
69
+ export type AgentAttachmentReference = Pick<Attachment, "id" | "type" | "filename" | "mimeType" | "size"> & {
70
+ url?: string;
71
+ inlineContentOmitted?: true;
72
+ };
68
73
  export interface AgentCommentContext {
69
74
  id: string;
70
75
  type: Comment["type"];
@@ -74,16 +79,36 @@ export interface AgentCommentContext {
74
79
  author: Pick<User, "id" | "name" | "email">;
75
80
  createdAt: string;
76
81
  updatedAt: string;
82
+ environment?: CommentEnvironment;
83
+ branch?: string;
84
+ deviceInfo?: CommentDeviceInfo;
85
+ description?: string;
86
+ assignees?: Array<Pick<User, "id" | "name" | "email">>;
87
+ mentions?: Mention[];
88
+ checklist?: TaskChecklistItem[];
89
+ reactions?: CommentReaction[];
90
+ isEdited?: boolean;
91
+ resolvedAt?: string;
92
+ completedAt?: string;
77
93
  page: Comment["page"];
78
94
  position: Position;
95
+ textSelection?: TextSelection;
96
+ drawingData?: DrawingData;
79
97
  element: AgentElementContext;
80
- /** Stakeholder-attached screenshot (data URL or remote URL), when present. */
98
+ /** All attachment IDs and metadata, with only credential-free public URLs. */
99
+ attachments?: AgentAttachmentReference[];
100
+ /** Credential-free screenshot URL, when one is available. */
81
101
  screenshotUrl?: string;
82
102
  replies: Array<{
83
103
  id: string;
84
104
  content: string;
85
105
  author: Pick<User, "id" | "name" | "email">;
86
106
  createdAt: string;
107
+ isEdited?: boolean;
108
+ replyTo?: Reply["replyTo"];
109
+ mentions?: Mention[];
110
+ reactions?: CommentReaction[];
111
+ attachments?: AgentAttachmentReference[];
87
112
  }>;
88
113
  }
89
114
  export interface AgentContextExport {
@@ -96,6 +121,19 @@ export interface AgentContextExport {
96
121
  title: string;
97
122
  };
98
123
  comments: AgentCommentContext[];
124
+ /** Identifiers only: API keys, auth tokens and project settings are never exported. */
125
+ project?: Pick<Project, "id" | "name" | "slug">;
126
+ /** Export scope describes the loaded snapshot; it does not fetch additional pages. */
127
+ scope?: {
128
+ activeBranch: string | null;
129
+ currentPageOnly: boolean;
130
+ includeResolved: boolean;
131
+ loadedCommentCount: number;
132
+ matchingCommentCount: number;
133
+ exportedCommentCount: number;
134
+ hasMoreOnServer: boolean;
135
+ truncated: boolean;
136
+ };
99
137
  /** True when source resolution succeeded for at least one comment. */
100
138
  sourceResolved: boolean;
101
139
  }
@@ -199,7 +237,9 @@ export interface Project {
199
237
  }
200
238
  /** Authenticated project data used by the embedded member and settings views. */
201
239
  export interface ProjectContext {
202
- project: Pick<Project, "id" | "name" | "slug">;
240
+ project: Pick<Project, "id" | "name" | "slug"> & {
241
+ isPlayground?: boolean;
242
+ };
203
243
  organization: {
204
244
  id: string;
205
245
  name: string;
@@ -219,6 +259,8 @@ export interface ProjectContext {
219
259
  permissions: {
220
260
  canManageComments: boolean;
221
261
  canInvite: boolean;
262
+ canWriteComments?: boolean;
263
+ writeRestriction?: "plan_required" | "feature_disabled" | null;
222
264
  };
223
265
  }
224
266
  export interface CommentDeviceInfo {
@@ -415,6 +457,10 @@ export interface CommentKitConfig {
415
457
  branch?: string;
416
458
  /** API key from the CommentKit dashboard. */
417
459
  apiKey: string;
460
+ /** Short-lived member token from your backend. Verified against /auth/me before sign-in. */
461
+ authToken?: string;
462
+ /** "memory" keeps bearer sessions and offline edits out of browser storage. Default: "session". */
463
+ persistence?: "memory" | "session";
418
464
  /** API base URL override. Useful for self-hosted, staging, and local API deployments. */
419
465
  baseUrl?: string;
420
466
  /** Enable or disable the widget. Default: true */
@@ -551,6 +597,12 @@ export interface OtpVerifyResponse {
551
597
  user: User;
552
598
  project: Project;
553
599
  }
600
+ export interface SessionVerificationResponse {
601
+ success: boolean;
602
+ verified: boolean;
603
+ user: User;
604
+ project: Project;
605
+ }
554
606
  export interface InviteValidationResponse {
555
607
  success: boolean;
556
608
  message: string;
@@ -22,9 +22,15 @@ export interface WebSocketConfig {
22
22
  name: string;
23
23
  email: string;
24
24
  };
25
+ /** Session-aware authorization; keeps bearer credentials inside the API client. */
26
+ authorizeChannel?: (socketId: string, channelName: string) => Promise<{
27
+ auth: string;
28
+ channel_data: string;
29
+ }>;
25
30
  }
26
31
  export interface WebSocketEvents {
27
32
  connected: void;
33
+ subscribed: void;
28
34
  disconnected: {
29
35
  code: number;
30
36
  reason: string;
@@ -45,6 +51,10 @@ export interface WebSocketEvents {
45
51
  };
46
52
  "comment:resolved": Comment;
47
53
  "comment:completed": Comment;
54
+ "comment:refresh": {
55
+ commentId: string;
56
+ event: "comment:created" | "comment:updated" | "comment:resolved" | "comment:completed";
57
+ };
48
58
  "reply:added": {
49
59
  commentId: string;
50
60
  reply: Reply;
@@ -86,12 +96,14 @@ export declare class WebSocketManager {
86
96
  private reconnectAttempts;
87
97
  private connecting;
88
98
  private destroyed;
99
+ private authorizationGeneration;
89
100
  private static readonly MAX_LISTENERS_PER_EVENT;
90
101
  constructor(config: WebSocketConfig);
91
102
  on<K extends WsEventKey>(event: K, listener: WsListener<WebSocketEvents[K]>): () => void;
92
103
  private emit;
93
104
  connect(): Promise<void>;
94
105
  private openConnection;
106
+ private createChannelAuthorizer;
95
107
  /**
96
108
  * Ask an existing socket to connect again. When no socket exists yet,
97
109
  * this starts the normal connect path.
@@ -101,6 +113,7 @@ export declare class WebSocketManager {
101
113
  isConnected(): boolean;
102
114
  getOnlineUsers(): User[];
103
115
  private subscribeToChannel;
116
+ private authenticatedClientEventUser;
104
117
  private memberToUser;
105
118
  sendCursorMove(x: number, y: number, page: string): void;
106
119
  sendCursorLeave(): void;
@@ -0,0 +1,9 @@
1
+ import type { CommentKitState, ResolvedConfig } from "./types";
2
+ export interface CommentWriteAccess {
3
+ canWrite: boolean;
4
+ canManageComments: boolean;
5
+ planRequired: boolean;
6
+ message: string;
7
+ }
8
+ /** Mirrors the server capability. Authentication and authorization remain server enforced. */
9
+ export declare function getCommentWriteAccess(config: Pick<ResolvedConfig, "features">, state: Pick<CommentKitState, "projectContext">, restriction?: "plan_required" | "feature_disabled" | null): CommentWriteAccess;
package/dist/vue.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as e } from "./shared/comment-kit-core-BaSuMzp9.js";
1
+ import { t as e } from "./shared/comment-kit-core-VuIidMeu.js";
2
2
  import { n as t, r as n, t as r } from "./shared/bridge-CJoGYngu.js";
3
3
  import { n as i, t as a } from "./shared/errors-Bu5ajEmB.js";
4
4
  import { computed as o, h as s, onMounted as c, onUnmounted as l, shallowRef as u, watch as d } from "vue";
@@ -19,7 +19,7 @@ function f(s) {
19
19
  } catch {}
20
20
  }, V = async (e) => {
21
21
  try {
22
- let { mountCommentKitUI: t } = await import("./shared/mount-ui--ijs8pWT.js").then((e) => e.n);
22
+ let { mountCommentKitUI: t } = await import("./shared/mount-ui-Dz5QLq4W.js").then((e) => e.n);
23
23
  if (L || _.value !== e) return;
24
24
  let n = await t(e);
25
25
  if (L || _.value !== e) {
@@ -65,8 +65,14 @@ Qwik uses `useCommentKit` from `@commentkit/comment-kit/qwik` inside `component$
65
65
 
66
66
  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.
67
67
 
68
+ 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.
69
+
68
70
  The API fetches across project pages. The built-in **Page** tab filters loaded records to the current path; **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.
69
71
 
72
+ Panel text search and its local filters apply to the comments already loaded. When more pages exist, the panel explains this scope and keeps **Load more comments** available even if the current search has no matches. They are not server-wide search endpoints.
73
+
74
+ `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.
75
+
70
76
  ```ts
71
77
  // With an authenticated core from your integration:
72
78
  await core.setBranch("preview");
@@ -349,13 +355,28 @@ import type {
349
355
 
350
356
  **`Comment`** — A comment thread with author, position, replies, reactions, attachments, and task metadata.
351
357
 
352
- **`ProjectContext`** — Authenticated project/organization identity, members and roles, storage usage (`limit: null` for unlimited), branch names and `canManageComments`/`canInvite` capabilities.
358
+ **`ProjectContext`** — Authenticated project/organization identity, members and roles, storage usage (`limit: null` for unlimited), branch names and `canManageComments`/`canInvite` capabilities. `project.isPlayground` is an optional server-owned presentation flag; it never changes the returned plan or permissions.
353
359
 
354
360
  **`ReplyOptions`** — Optional attachment IDs, mentions and a typed quote target for reply creation/editing.
355
361
 
356
362
  **`User`** — A user with id, name, email, optional avatar, and optional organizationId.
357
363
 
358
- **`CommentKitConfig`** — Configuration object passed to the SDK constructor. Includes `apiKey`, optional `baseUrl`, `branch`, `enabled`, `screenshotProvider`, `ui` (theme, position, activation) and realtime options.
364
+ **`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`.
365
+
366
+ ```ts
367
+ const kit = new CommentKit({
368
+ apiKey: session.projectKey,
369
+ baseUrl: `${location.origin}/api`,
370
+ authToken: session.sdkToken,
371
+ persistence: "memory",
372
+ });
373
+ kit.on("auth:login", (user) => {
374
+ // The server verified this member; private comments load afterward.
375
+ });
376
+ kit.on("error", (error) => {
377
+ // Handle an expired or rejected member token.
378
+ });
379
+ ```
359
380
 
360
381
  **`CommentKitState`** — The full state tree. Includes auth, `projectContext`, `activeBranch`, UI, comments, realtime, offline queue, pagination and activities.
361
382
 
@@ -363,9 +384,9 @@ import type {
363
384
 
364
385
  **`ApiError`** — Structured error with `error` code, `message`, and HTTP `code`, plus an optional `details` object.
365
386
 
366
- **`AgentContextExport`** — The bundle returned by `getAgentContext` / `getAgentContextAsync`. Versioned, includes per-comment element + source frames + replies plus a `sourceResolved` flag.
387
+ **`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.
367
388
 
368
- **`DevGrabResult`** — Result of `grabElement`. Element context, HTML, optional screenshot data URL, and the Markdown payload that hit the clipboard.
389
+ **`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.
369
390
 
370
391
  **`DevGrabBundle`** — Result of `grabElements`. An array of `DevGrabResult` plus one bundled Markdown payload.
371
392
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commentkit/comment-kit",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Figma-style collaborative commenting, drawing, and feedback tools for any website. Works with React, Vue, Svelte, Angular, and Vanilla JS.",
5
5
  "keywords": [
6
6
  "angular",
@@ -107,6 +107,7 @@
107
107
  "analyze": "ANALYZE=true BUILD_TARGET=all vp build",
108
108
  "preview": "vp preview",
109
109
  "test": "vp test run",
110
+ "test:coverage": "vp test run --coverage",
110
111
  "test:watch": "vp test watch",
111
112
  "test:ui": "vp test --ui",
112
113
  "test:e2e": "playwright test",
@@ -133,7 +134,7 @@
133
134
  "build:size": "node tools/check-size.mjs",
134
135
  "test:consumers": "node tools/smoke-consumers.mjs --next",
135
136
  "release:check": "npm run release:package && npm run test:e2e",
136
- "release:package": "npm run check && npm run typecheck:test && npm run lint:md && npm run build && npm test && npm run test:consumers && npm audit --audit-level=high"
137
+ "release:package": "npm run check && npm run typecheck:test && npm run lint:md && npm run build && npm run test:coverage && npm run test:consumers && npm audit --audit-level=high"
137
138
  },
138
139
  "devDependencies": {
139
140
  "@angular/common": "^22.2.3",