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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +108 -762
  3. package/SECURITY.md +19 -14
  4. package/dist/npm/THIRD_PARTY_NOTICES.txt +73 -0
  5. package/dist/npm/chunks/anchor-DT-Ynhh1.js +270 -0
  6. package/dist/npm/chunks/client-D1vrh_5G.js +590 -0
  7. package/dist/{shared/capture-colors-D0uLr-vZ.js → npm/chunks/colors-CX-IPjvb.js} +2 -0
  8. package/dist/npm/chunks/html2canvas-_mjSRP3G.js +4011 -0
  9. package/dist/npm/chunks/mount-Ce1MZrcm.js +2485 -0
  10. package/dist/{shared/pusher-CnhQgAvF.js → npm/chunks/pusher-DRKlokR8.js} +224 -222
  11. package/dist/npm/chunks/realtime-5SvAvTUU.js +23 -0
  12. package/dist/npm/chunks/rolldown-runtime-VHNaYcLd.js +13 -0
  13. package/dist/npm/chunks/src-DJjfvVsa.js +330 -0
  14. package/dist/npm/element.js +24 -0
  15. package/dist/npm/headless.js +3 -0
  16. package/dist/npm/index.js +3 -0
  17. package/dist/npm/react.js +17 -0
  18. package/dist/npm/svelte.js +8 -0
  19. package/dist/npm/types/adapters/react.d.ts +9 -0
  20. package/dist/npm/types/adapters/svelte.d.ts +9 -0
  21. package/dist/npm/types/adapters/vue.d.ts +46 -0
  22. package/dist/npm/types/anchor/index.d.ts +49 -0
  23. package/dist/npm/types/core/api.d.ts +29 -0
  24. package/dist/npm/types/core/auth.d.ts +48 -0
  25. package/dist/npm/types/core/client.d.ts +100 -0
  26. package/dist/npm/types/core/store.d.ts +7 -0
  27. package/dist/npm/types/core/types.d.ts +278 -0
  28. package/dist/npm/types/element.d.ts +10 -0
  29. package/dist/npm/types/headless.d.ts +7 -0
  30. package/dist/npm/types/index.d.ts +30 -0
  31. package/dist/npm/vue.js +32 -0
  32. package/package.json +65 -173
  33. package/dist/THIRD_PARTY_NOTICES.txt +0 -284
  34. package/dist/angular.es.js +0 -321
  35. package/dist/comment-kit.es.js +0 -218
  36. package/dist/demo.es.js +0 -483
  37. package/dist/headless.es.js +0 -4
  38. package/dist/preact.es.js +0 -117
  39. package/dist/qwik.es.js +0 -1
  40. package/dist/qwik.qwik.mjs +0 -114
  41. package/dist/react.es.js +0 -98
  42. package/dist/shared/ShadowRootContext-DD6a0QaI.js +0 -11
  43. package/dist/shared/annotation-icons-Dh-bmNYK.js +0 -172
  44. package/dist/shared/annotation-toolbar-zeiCmKIr.js +0 -1086
  45. package/dist/shared/attachment-refresh-DAacLaRu.js +0 -94
  46. package/dist/shared/bridge-CJoGYngu.js +0 -177
  47. package/dist/shared/button-D4GHW6oZ.js +0 -474
  48. package/dist/shared/button-group-BVR7iT-S.js +0 -91
  49. package/dist/shared/capture-privacy-CiOrcAlt.js +0 -101
  50. package/dist/shared/comment-drawing-canvas-Btc12IsS.js +0 -124
  51. package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
  52. package/dist/shared/comment-image-lightbox--QpbcAtH.js +0 -190
  53. package/dist/shared/comment-images-content-C_r4SHM-.js +0 -214
  54. package/dist/shared/comment-kit-core-CmLUFujd.js +0 -3682
  55. package/dist/shared/comment-kit-ui-BHwYuSIi.js +0 -19391
  56. package/dist/shared/comment-screenshot-annotator-zJZyO-XM.js +0 -151
  57. package/dist/shared/comment-screenshot-overlay-CoKTYB0J.js +0 -205
  58. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +0 -153
  59. package/dist/shared/createReactComponent-BZHeRbD0.js +0 -45
  60. package/dist/shared/dev-export-panel-Cnt6oCZU.js +0 -207
  61. package/dist/shared/dev-grab-B85jo9AS.js +0 -197
  62. package/dist/shared/dist-D9A5k-N4.js +0 -617
  63. package/dist/shared/dom-Bhf4WFtY.js +0 -223
  64. package/dist/shared/element-selector-Cng84xC7.js +0 -902
  65. package/dist/shared/error-boundary-D3PD74vI.js +0 -21
  66. package/dist/shared/errors-Bu5ajEmB.js +0 -22
  67. package/dist/shared/icons-nzMOLzrm.js +0 -266
  68. package/dist/shared/input-UPtAj0M6.js +0 -111
  69. package/dist/shared/mount-ui-Dz7FB_Ak.js +0 -208
  70. package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
  71. package/dist/shared/realtime-yGLX4wMK.js +0 -334
  72. package/dist/shared/request-activity-DQrAUwfA.js +0 -11
  73. package/dist/shared/screenshot-B5-hwpmt.js +0 -199
  74. package/dist/shared/separator-UhJb0Row.js +0 -3955
  75. package/dist/shared/shadow-root-B58ZI2yz.js +0 -133
  76. package/dist/shared/styles-CnYsLS2f.js +0 -2
  77. package/dist/shared/text-B4HHZNaa.js +0 -23
  78. package/dist/shared/token-session-D92MYbNu.js +0 -25
  79. package/dist/shared/useLabelableId-8n0QmH8N.js +0 -154
  80. package/dist/shared/useRender-Uxk1OPK-.js +0 -5
  81. package/dist/shared/useValueChanged-DKq5cMot.js +0 -92
  82. package/dist/shared/validation-3wbbbuX0.js +0 -70
  83. package/dist/shared/websocket-manager-KhH4hL0Q.js +0 -381
  84. package/dist/solid.es.js +0 -98
  85. package/dist/svelte.es.js +0 -130
  86. package/dist/types/adapters/bridge.d.ts +0 -122
  87. package/dist/types/angular/index.d.ts +0 -145
  88. package/dist/types/core/agent-context.d.ts +0 -17
  89. package/dist/types/core/api-client.d.ts +0 -155
  90. package/dist/types/core/comment-kit-core.d.ts +0 -254
  91. package/dist/types/core/local-demo.d.ts +0 -60
  92. package/dist/types/core/types.d.ts +0 -770
  93. package/dist/types/core/websocket-manager.d.ts +0 -125
  94. package/dist/types/core/write-access.d.ts +0 -11
  95. package/dist/types/demo.d.ts +0 -17
  96. package/dist/types/headless.d.ts +0 -8
  97. package/dist/types/index.d.ts +0 -87
  98. package/dist/types/preact/index.d.ts +0 -25
  99. package/dist/types/qwik/index.d.ts +0 -73
  100. package/dist/types/react/client.d.ts +0 -31
  101. package/dist/types/react/index.d.ts +0 -4
  102. package/dist/types/solid/index.d.ts +0 -37
  103. package/dist/types/svelte/index.d.ts +0 -55
  104. package/dist/types/utils/dom.d.ts +0 -59
  105. package/dist/types/utils/event-emitter.d.ts +0 -11
  106. package/dist/types/vue/index.d.ts +0 -87
  107. package/dist/vue.es.js +0 -148
  108. package/docs/api-reference.md +0 -405
  109. package/docs/local-demo.md +0 -60
@@ -1,254 +0,0 @@
1
- import { type CommentWriteAccess } from "./write-access";
2
- import { EventEmitter } from "../utils/event-emitter";
3
- import type { LocalDemoStore } from "./local-demo";
4
- import type { AgentContextExport, AgentContextOptions, Comment, CommentUpdate, CommentQuery, CommentCreateOptions, ReplyOptions, CommentKitConfig, CommentKitState, DevGrabBundle, DevGrabOptions, DevGrabResult, DrawingData, DrawingPath, Position, ResolvedConfig, ScreenshotResult, StateSlice, TextSelection, ToolType, Unsubscribe, User } from "./types";
5
- /**
6
- * Current SDK version — compared against the backend's sdkLatestVersion on
7
- * init. Injected from package.json at build time (vite `define`) so it can't
8
- * drift; the literal fallback keeps tsc/test runs (which don't apply the
9
- * define) working.
10
- */
11
- export declare const SDK_VERSION: string;
12
- export declare class CommentKitCore extends EventEmitter {
13
- private state;
14
- private apiClient;
15
- private readonly localDemo;
16
- private wsManager;
17
- private wsUnsubscribers;
18
- private config;
19
- private initialAuthToken;
20
- private keyboardHandler;
21
- private holdActivationHandler;
22
- private holdBlurHandler;
23
- private toggleHandler;
24
- private mouseMoveHandler;
25
- private hashChangeHandler;
26
- private onlineHandler;
27
- private offlineHandler;
28
- private initialized;
29
- private destroyed;
30
- private sessionRevision;
31
- private writeRestriction;
32
- private authRequestRevision;
33
- private commentsFetchRevision;
34
- private contextFetchRevision;
35
- private deepLinkRequest;
36
- private reactionRequests;
37
- private draftUploads;
38
- private attachmentRefreshes;
39
- private screenshotProvider;
40
- private bootRetryTimer;
41
- private bootAttempts;
42
- private pendingStateUpdates;
43
- private flushScheduled;
44
- private isFlushing;
45
- private readonly queueGuard;
46
- private get isProcessingQueue();
47
- private set isProcessingQueue(value);
48
- private activeMutations;
49
- private get isLoadingMore();
50
- private set isLoadingMore(value);
51
- private sliceSubscribers;
52
- private readonly retryTimerRef;
53
- private get retryTimer();
54
- private set retryTimer(value);
55
- private ctx;
56
- private kbdCallbacks;
57
- private commentCb;
58
- private realtimeRefs;
59
- constructor(config: CommentKitConfig | ResolvedConfig, localDemo?: LocalDemoStore);
60
- /** True only for a separately constructed, browser-local sandbox. */
61
- isLocalDemo(): boolean;
62
- private restoreDemoState;
63
- /** Reveal the local sandbox with the pin tool. Normal instances are unaffected. */
64
- startLocalDemo(): void;
65
- private detectEnvironment;
66
- private boot;
67
- /**
68
- * Auto-detect member invite token from URL query params.
69
- * Param: ?ck_invite=<token>
70
- *
71
- * The token is validated at capture time (64 chars of [A-Za-z0-9_-]) and
72
- * stripped from the address bar immediately so the credential doesn't
73
- * persist in browser history, Referer headers, or analytics URL logs.
74
- */
75
- private autoDetectInviteToken;
76
- private initialize;
77
- private setState;
78
- private getInternalState;
79
- private cloneStateSnapshot;
80
- private flushState;
81
- private notifySubscribers;
82
- /**
83
- * Force-flush any batched state updates synchronously.
84
- * Useful in tests or when you need immediate state propagation.
85
- */
86
- flushStateSync(): void;
87
- getState(): CommentKitState;
88
- /**
89
- * Get the resolved feature flags for this instance.
90
- * Use this instead of accessing config directly.
91
- */
92
- getFeatures(): NonNullable<ResolvedConfig["features"]>;
93
- /** Whether this project currently permits comment mutations (independent of login). */
94
- canWriteComments(): boolean;
95
- getWriteAccess(): CommentWriteAccess;
96
- private requireCommentWrite;
97
- /**
98
- * Get the public configuration (excludes internal auto-detected fields
99
- * such as projectId and reverb connection details).
100
- */
101
- getConfig(): Readonly<CommentKitConfig>;
102
- /**
103
- * Validate a member invite token + email against the backend.
104
- * Validation prepares the invitation challenge; OTP and enrolled MFA must
105
- * still complete before the backend grants access.
106
- */
107
- validateInvite(email: string): Promise<void>;
108
- /**
109
- * Subscribe to changes in a specific state slice.
110
- * The callback only fires when keys in that slice actually change.
111
- */
112
- onSlice(slice: StateSlice, callback: (state: CommentKitState) => void): Unsubscribe;
113
- /**
114
- * Subscribe with a selector. Callback only fires when the selected value changes.
115
- * The selector receives the live state object — by convention, do not mutate it.
116
- */
117
- select<T>(selector: (state: CommentKitState) => T, callback: (value: T) => void): Unsubscribe;
118
- private handleError;
119
- /** Verify a supplied bearer or a saved in-tab session after key validation. */
120
- private restorePersistedSession;
121
- /** Shared post-auth path used by OTP verify and session restore. */
122
- private afterAuthenticated;
123
- private beginAuthRequest;
124
- login(email: string): Promise<void>;
125
- private otpFailedAttempts;
126
- private otpCooldownUntil;
127
- verifyOtp(otp: string): Promise<void>;
128
- cancelOtp(): void;
129
- resendOtp(): Promise<void>;
130
- logout(): void;
131
- private handleAuthExpired;
132
- toggleLoginModal(): void;
133
- /**
134
- * Production, staging, and preview hosts keep the toolbar and comments
135
- * hidden until the keyboard shortcut and a successful login.
136
- */
137
- requiresShortcut(): boolean;
138
- toggleOverlay(): void;
139
- toggleSidebar(): void;
140
- private overlayBeforeTool;
141
- setTool(tool: ToolType): void;
142
- private operationContext;
143
- private operationCallbacks;
144
- private loadMoreGuard;
145
- private commentsRequestContext;
146
- private loadComments;
147
- loadMoreComments(): Promise<void>;
148
- /**
149
- * Re-fetch the current page's comments from the server (page 1). Unlike
150
- * `loadMoreComments`, which paginates forward and no-ops once everything is
151
- * loaded, this refreshes existing data — e.g. to pick up remote edits.
152
- */
153
- setCommentQuery(query: CommentQuery): Promise<void>;
154
- loadEarlierReplies(): Promise<void>;
155
- reloadComments(): Promise<void>;
156
- /** @internal Refresh signed attachment links without discarding pagination or local edits. */
157
- refreshAttachmentUrl(attachmentId: string): Promise<string | null>;
158
- /** Refresh authenticated member, plan and usage data without fabricating demo values. */
159
- reloadProjectContext(): Promise<void>;
160
- setBranch(branch: string | null): Promise<void>;
161
- /** Upload drafts before creating their record. Reuse successful uploads if saving is retried. */
162
- uploadDraftFiles(files: File[]): Promise<string[]>;
163
- createComment(type: "pin" | "highlight" | "drawing", content: string, position: Position, priority?: "low" | "medium" | "high" | "urgent", textSelection?: TextSelection, drawingData?: DrawingData, options?: CommentCreateOptions): Promise<void>;
164
- updateComment(commentId: string, updates: CommentUpdate): Promise<void>;
165
- deleteComment(commentId: string): Promise<void>;
166
- addReply(commentId: string, content: string, options?: ReplyOptions): Promise<void>;
167
- updateReply(commentId: string, replyId: string, content: string, options?: ReplyOptions): Promise<void>;
168
- deleteReply(commentId: string, replyId: string): Promise<void>;
169
- private requireThreadStatus;
170
- resolveComment(commentId: string): Promise<void>;
171
- unresolveComment(commentId: string): Promise<void>;
172
- selectComment(comment: Comment | null): void;
173
- completeComment(commentId: string): Promise<void>;
174
- reactToComment(commentId: string, emoji: string, replyId?: string): Promise<void>;
175
- updateCommentPosition(commentId: string, x: number, y: number): Promise<void>;
176
- private offlinePersistUnsub;
177
- /**
178
- * Restore any offline mutations persisted from a previous session (keyed by
179
- * project) and wire up auto-persistence so the queue survives reloads. Called
180
- * once, after the projectId is known.
181
- */
182
- private hydrateOfflineQueue;
183
- private shouldQueueMutation;
184
- private queueMutation;
185
- private scheduleRetry;
186
- private processOfflineQueue;
187
- private executeMutation;
188
- getPendingMutationCount(): number;
189
- /** Clear the last published error so a dismissed banner does not stick. */
190
- clearError(): void;
191
- /**
192
- * Retry the realtime socket. Safe to call when realtime was never started:
193
- * authenticated sessions initialize it, everyone else is ignored.
194
- */
195
- retryConnection(): void;
196
- markThreadSeen(threadId: string): void;
197
- isThreadNew(threadId: string): boolean;
198
- setPanelView(view: CommentKitState["panelView"]): void;
199
- toggleShortcutsOverlay(): void;
200
- private addActivity;
201
- markAllActivitiesRead(): void;
202
- getUnreadActivityCount(): number;
203
- private handleDeepLink;
204
- createHighlight(textSelection: TextSelection, content: string): Promise<void>;
205
- createDrawing(drawingData: DrawingData, position: Position, content: string): Promise<void>;
206
- setActiveDrawing(drawing: DrawingData | null): void;
207
- sendDrawingStroke(path: DrawingPath): void;
208
- captureScreenshot(element?: HTMLElement): Promise<ScreenshotResult | null>;
209
- uploadScreenshot(screenshot: ScreenshotResult, content: string, position: Position): Promise<Comment | null>;
210
- setActiveScreenshot(screenshot: ScreenshotResult | null): void;
211
- uploadFiles(files: File[], options?: {
212
- commentId?: string;
213
- replyId?: string;
214
- }): Promise<string[]>;
215
- /**
216
- * Build a comments-only export. Synchronous — uses selector + XPath only.
217
- * For source-resolved output (file:line:col + component stack), use
218
- * `getAgentContextAsync` instead, which awaits source resolution when available.
219
- */
220
- private requireAgentExport;
221
- getAgentContext(options?: AgentContextOptions): AgentContextExport;
222
- /**
223
- * Same as `getAgentContext` but also resolves each comment's element to a
224
- * source-file location when the optional source-resolver peer is installed. Resolves to the
225
- * sync export when the peer dep is absent or no element can be resolved.
226
- */
227
- getAgentContextAsync(options?: AgentContextOptions): Promise<AgentContextExport>;
228
- formatAgentContext(options?: AgentContextOptions): string;
229
- formatAgentContextAsync(options?: AgentContextOptions): Promise<string>;
230
- copyAgentContext(options?: AgentContextOptions): Promise<string>;
231
- /** Single-element grab — see core/dev-grab.ts. Dev-mode element-tool entry. */
232
- grabElement(element: Element, options?: DevGrabOptions): Promise<DevGrabResult | null>;
233
- /** Multi-element grab — bundles N elements into one clipboard payload. */
234
- grabElements(elements: Element[], options?: DevGrabOptions): Promise<DevGrabBundle | null>;
235
- getProjectMembers(): Promise<User[]>;
236
- private handleToggleRequest;
237
- private handleKeyboardShortcuts;
238
- private readonly escapeBlockers;
239
- private matchesHoldKey;
240
- /**
241
- * Block the core's Escape chain. Used by overlay UIs (context menus,
242
- * dropdowns) that want Escape to dismiss their own surface first instead of
243
- * walking the core's chain (which would otherwise also clear the tool).
244
- * Returns a release function — call it to unregister the blocker.
245
- */
246
- blockEscape(): () => void;
247
- private initializeWebSocket;
248
- getOnlineUsers(): User[];
249
- private syncRealtimeRefs;
250
- private syncFromRealtimeRefs;
251
- private removeMouseMoveListener;
252
- private disconnectRealtime;
253
- destroy(): void;
254
- }
@@ -1,60 +0,0 @@
1
- import type { ApiClient } from "./api-client";
2
- import type { Comment, CommentKitConfig } from "./types";
3
- /** A demo window is fixed at creation; reading or editing never extends it. */
4
- export declare const LOCAL_DEMO_TTL: number;
5
- export interface CommentKitDemoOptions {
6
- /** A name scoped below commentkit:demo:. Never used for production sessions. */
7
- storageKey?: string;
8
- ui?: Pick<NonNullable<CommentKitConfig["ui"]>, "theme" | "position">;
9
- }
10
- export interface CommentKitDemoSession {
11
- expiresAt: number;
12
- persistence: "localStorage" | "memory";
13
- commentCount: number;
14
- expired: boolean;
15
- }
16
- type ChangeReason = "persist" | "reset" | "expired" | "storage";
17
- type PublicApiClient = Pick<ApiClient, keyof ApiClient>;
18
- /** A closed local store: it has no fetch, token, websocket, upload, or queue dependency. */
19
- export declare class LocalDemoStore {
20
- readonly user: {
21
- id: string;
22
- name: string;
23
- email: string;
24
- avatar?: string;
25
- organizationId?: string;
26
- };
27
- readonly storageKey: string;
28
- private storage;
29
- private data;
30
- private timer;
31
- private destroyed;
32
- private expiryNotified;
33
- private revision;
34
- private listeners;
35
- private lastSerialized;
36
- constructor(options?: CommentKitDemoOptions);
37
- private hydrate;
38
- private persist;
39
- private armExpiry;
40
- private onFocus;
41
- private onStorage;
42
- private sync;
43
- checkExpiry(): boolean;
44
- getSession(): CommentKitDemoSession;
45
- getComments(): Comment[];
46
- subscribe(listener: (reason: ChangeReason) => void): () => void;
47
- refresh(): void;
48
- getRevision(): number;
49
- private notify;
50
- reset(): void;
51
- activate(): void;
52
- private write;
53
- private find;
54
- private modify;
55
- private quote;
56
- readonly client: PublicApiClient;
57
- private unavailable;
58
- destroy(): void;
59
- }
60
- export {};