@commentkit/comment-kit 0.7.0 → 0.7.1
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 +27 -0
- package/dist/angular.es.js +2 -2
- package/dist/comment-kit.es.js +5 -5
- package/dist/demo.es.js +4 -3
- package/dist/headless.es.js +3 -3
- package/dist/preact.es.js +2 -2
- package/dist/qwik.qwik.mjs +2 -2
- package/dist/react.es.js +2 -2
- package/dist/shared/{annotation-toolbar-B9SxYqoF.js → annotation-toolbar-cGC1p-SP.js} +379 -379
- package/dist/shared/attachment-refresh-CzQFXHkL.js +94 -0
- package/dist/shared/{button-group-Cl9CrvvU.js → button-group-CWdKaOlC.js} +14 -16
- package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
- package/dist/shared/{comment-drawing-canvas-Dzb5YoFw.js → comment-drawing-canvas-DdXlMgbF.js} +2 -2
- package/dist/shared/{comment-utils-BycYTSxA.js → comment-icon-Dg9ZWpz-.js} +29 -23
- package/dist/shared/comment-image-lightbox-B7iHjnAz.js +190 -0
- package/dist/shared/comment-images-content-D7YNUgo5.js +214 -0
- package/dist/shared/{comment-kit-core-BaSuMzp9.js → comment-kit-core-C862uNAm.js} +998 -778
- package/dist/shared/{comment-kit-ui-CzfdAZs2.js → comment-kit-ui-0vd-DY4S.js} +5206 -5410
- package/dist/shared/{comment-screenshot-annotator-C7X-_bm6.js → comment-screenshot-annotator-DcaSSuWB.js} +5 -5
- package/dist/shared/{comment-screenshot-overlay-wIrZrcRy.js → comment-screenshot-overlay-D_nFoJmM.js} +6 -5
- package/dist/shared/{dev-export-panel-FwFVdady.js → dev-export-panel-pWBlhlse.js} +7 -7
- package/dist/shared/dev-grab-eQ9EgEGY.js +210 -0
- package/dist/shared/{element-selector-BhJm-NSs.js → element-selector-DC-_XJ0k.js} +311 -272
- package/dist/shared/{mount-ui--ijs8pWT.js → mount-ui-B68j8r6I.js} +4 -4
- package/dist/shared/{pusher-ipHMJnO_.js → pusher-C1FHQGXV.js} +1 -1
- package/dist/shared/realtime-Diqz7G_y.js +317 -0
- package/dist/shared/realtime-recovery-DJ_adc-H.js +135 -0
- package/dist/shared/{shadow-root-C5v-T8lQ.js → shadow-root-CrO75sED.js} +1 -1
- package/dist/shared/{styles-D3yMtaec.js → styles-C9Jwvm0Q.js} +1 -1
- package/dist/shared/useRender-D1z_X_BY.js +5 -0
- package/dist/shared/{validation-C7QG8j7Z.js → validation-D-8u4M7I.js} +14 -1
- package/dist/shared/{websocket-manager-DhLWh3Jr.js → websocket-manager-CFak_YHy.js} +148 -89
- package/dist/solid.es.js +2 -2
- package/dist/svelte.es.js +2 -2
- package/dist/types/core/api-client.d.ts +8 -1
- package/dist/types/core/comment-kit-core.d.ts +9 -0
- package/dist/types/core/types.d.ts +35 -0
- package/dist/types/core/websocket-manager.d.ts +12 -0
- package/dist/types/core/write-access.d.ts +9 -0
- package/dist/vue.es.js +2 -2
- package/docs/api-reference.md +6 -0
- package/package.json +3 -2
- package/dist/shared/comment-image-lightbox-BPYJT1sB.js +0 -183
- package/dist/shared/dev-grab-DDqg0LQf.js +0 -203
- package/dist/shared/realtime-Dk41VwKg.js +0 -302
|
@@ -42,4 +42,17 @@ function u(e) {
|
|
|
42
42
|
let t = e.lastIndexOf("."), n = t >= 0 ? e.slice(t + 1).toLowerCase() : "";
|
|
43
43
|
return l.has(n);
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
function d(t, n = !1) {
|
|
46
|
+
if (typeof t != "string" || !t || t.trim() !== t || e(t)) return !1;
|
|
47
|
+
if (n && /^data:image\/(?:png|jpeg|gif|webp|avif);base64,[A-Za-z0-9+/]+={0,2}$/i.test(t)) return !0;
|
|
48
|
+
try {
|
|
49
|
+
return [
|
|
50
|
+
"http:",
|
|
51
|
+
"https:",
|
|
52
|
+
"blob:"
|
|
53
|
+
].includes(new URL(t, "https://commentkit.dev").protocol);
|
|
54
|
+
} catch {
|
|
55
|
+
return !1;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export { i as a, s as c, c as d, r as i, o as l, e as n, n as o, t as r, d as s, u as t, a as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as e,
|
|
2
|
-
import { i as o } from "./comment-kit-core-
|
|
1
|
+
import { c as e, d as t, i as n, l as r, o as i, u as a } from "./validation-D-8u4M7I.js";
|
|
2
|
+
import { i as o } from "./comment-kit-core-C862uNAm.js";
|
|
3
3
|
var s = Object.create, c = Object.defineProperty, l = Object.getOwnPropertyDescriptor, u = Object.getOwnPropertyNames, d = Object.getPrototypeOf, f = Object.prototype.hasOwnProperty, p = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), m = (e, t) => {
|
|
4
4
|
let n = {};
|
|
5
5
|
for (var r in e) c(n, r, {
|
|
@@ -16,93 +16,131 @@ var s = Object.create, c = Object.defineProperty, l = Object.getOwnPropertyDescr
|
|
|
16
16
|
}, g = (e, t, n) => (n = e == null ? {} : s(d(e)), h(t || !e || !e.__esModule || !f.call(e, "default") ? c(n, "default", {
|
|
17
17
|
value: e,
|
|
18
18
|
enumerable: !0
|
|
19
|
-
}) : n, e))
|
|
20
|
-
function
|
|
21
|
-
|
|
19
|
+
}) : n, e));
|
|
20
|
+
function _(e, t) {
|
|
21
|
+
let n = { ...e };
|
|
22
|
+
for (let e of t) n[e] === null && delete n[e];
|
|
23
|
+
return n;
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
function v(e) {
|
|
26
|
+
return i(e) ? _(e, ["avatar", "organizationId"]) : e;
|
|
27
|
+
}
|
|
28
|
+
function y(e) {
|
|
29
|
+
return i(e) ? _(e, [
|
|
30
|
+
"thumbnail",
|
|
31
|
+
"filename",
|
|
32
|
+
"mimeType"
|
|
33
|
+
]) : e;
|
|
34
|
+
}
|
|
35
|
+
function b(e) {
|
|
36
|
+
if (!i(e)) return e;
|
|
37
|
+
let t = _(e, ["replyTo"]);
|
|
38
|
+
return t.author = v(t.author), Array.isArray(t.attachments) && (t.attachments = t.attachments.map(y)), t;
|
|
39
|
+
}
|
|
40
|
+
function x(e) {
|
|
41
|
+
if (!i(e)) return e;
|
|
42
|
+
let t = _(e, [
|
|
43
|
+
"description",
|
|
44
|
+
"textSelection",
|
|
45
|
+
"drawingData",
|
|
46
|
+
"environment",
|
|
47
|
+
"branch",
|
|
48
|
+
"deviceInfo",
|
|
49
|
+
"resolvedAt",
|
|
50
|
+
"completedAt"
|
|
51
|
+
]);
|
|
52
|
+
return t.author = v(t.author), "user" in t && (t.user = v(t.user)), i(t.position) && (t.position = _(t.position, ["element", "xpath"])), i(t.page) && t.page.title === null && (t.page = {
|
|
53
|
+
...t.page,
|
|
54
|
+
title: ""
|
|
55
|
+
}), Array.isArray(t.assignees) && (t.assignees = t.assignees.map(v)), Array.isArray(t.replies) && (t.replies = t.replies.map(b)), Array.isArray(t.attachments) && (t.attachments = t.attachments.map(y)), t;
|
|
56
|
+
}
|
|
57
|
+
var S = null;
|
|
58
|
+
function C() {
|
|
59
|
+
return S ||= import("./pusher-C1FHQGXV.js").then((e) => /* @__PURE__ */ g(e.default, 1)).then((e) => e.default ?? e), S;
|
|
60
|
+
}
|
|
61
|
+
var w = o.ID, T = o.NAME, E = o.EMAIL, D = o.PAGE, O = o.COLOR, k = o.DRAWING_PATH_DATA, A = o.DRAWING_TEXT, j = o.ONLINE_USERS, M = {
|
|
24
62
|
id: "unknown",
|
|
25
63
|
name: "Unknown",
|
|
26
64
|
email: "unknown@example.invalid"
|
|
27
|
-
},
|
|
65
|
+
}, N = /* @__PURE__ */ new Set([
|
|
28
66
|
"client-cursor_move",
|
|
29
67
|
"client-cursor_leave",
|
|
30
68
|
"client-drawing_stroke"
|
|
31
|
-
]),
|
|
69
|
+
]), P = /* @__PURE__ */ new Set([
|
|
32
70
|
"path",
|
|
33
71
|
"line",
|
|
34
72
|
"rectangle",
|
|
35
73
|
"circle",
|
|
36
74
|
"text"
|
|
37
75
|
]);
|
|
38
|
-
function
|
|
39
|
-
return
|
|
76
|
+
function F(e) {
|
|
77
|
+
return a(e, w);
|
|
40
78
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
79
|
+
function I(e) {
|
|
80
|
+
return i(e) ? F(e.id) && a(e.name, T) && t(e.email) && r(e.avatar, D) : !1;
|
|
43
81
|
}
|
|
44
|
-
function
|
|
45
|
-
return
|
|
82
|
+
function L(t) {
|
|
83
|
+
return i(t) ? F(t.id) && e(t.content, o.CONTENT) && F(t.userId) && i(t.position) && n(t.position.x) && n(t.position.y) && I(t.author) : !1;
|
|
46
84
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
85
|
+
function R(t) {
|
|
86
|
+
return i(t) ? F(t.id) && e(t.content, o.CONTENT) && I(t.author) : !1;
|
|
49
87
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
88
|
+
function z(e) {
|
|
89
|
+
return i(e) ? n(e.x) && e.x >= 0 && e.x <= 100 && n(e.y) && e.y >= 0 && e.y <= 100 && a(e.page, D) : !1;
|
|
52
90
|
}
|
|
53
|
-
function
|
|
54
|
-
return !
|
|
91
|
+
function B(e) {
|
|
92
|
+
return !i(e) || !a(e.type, 20) || !P.has(e.type) || !a(e.stroke, O) || !n(e.strokeWidth) || e.strokeWidth <= 0 || e.strokeWidth > 100 || !a(e.fill, O) ? !1 : r(e.d, k) && r(e.text, A) && (e.x === void 0 || n(e.x)) && (e.y === void 0 || n(e.y)) && (e.width === void 0 || n(e.width)) && (e.height === void 0 || n(e.height));
|
|
55
93
|
}
|
|
56
|
-
function
|
|
94
|
+
function V(e) {
|
|
57
95
|
return {
|
|
58
|
-
id: e.id.slice(0,
|
|
59
|
-
name: e.name.slice(0,
|
|
60
|
-
email: e.email.slice(0,
|
|
61
|
-
...e.avatar ? { avatar: e.avatar.slice(0,
|
|
62
|
-
...e.organizationId ? { organizationId: e.organizationId.slice(0,
|
|
96
|
+
id: e.id.slice(0, w),
|
|
97
|
+
name: e.name.slice(0, T),
|
|
98
|
+
email: e.email.slice(0, E),
|
|
99
|
+
...e.avatar ? { avatar: e.avatar.slice(0, D) } : {},
|
|
100
|
+
...e.organizationId ? { organizationId: e.organizationId.slice(0, w) } : {}
|
|
63
101
|
};
|
|
64
102
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
103
|
+
function H(e) {
|
|
104
|
+
return a(e, D) ? e : "";
|
|
67
105
|
}
|
|
68
|
-
function
|
|
106
|
+
function U(e) {
|
|
69
107
|
let t = e.toLowerCase().replace(/^\[|\]$/g, "");
|
|
70
108
|
return t === "localhost" || t === "127.0.0.1" || t === "::1";
|
|
71
109
|
}
|
|
72
|
-
function
|
|
73
|
-
return
|
|
110
|
+
function W(e) {
|
|
111
|
+
return a(e, 253) && (e === "localhost" || /^[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?$/.test(e));
|
|
74
112
|
}
|
|
75
|
-
function
|
|
76
|
-
return { ...
|
|
113
|
+
function G() {
|
|
114
|
+
return { ...M };
|
|
77
115
|
}
|
|
78
|
-
function
|
|
79
|
-
let
|
|
80
|
-
if (!
|
|
116
|
+
function K(e) {
|
|
117
|
+
let n = String(e.projectId).trim();
|
|
118
|
+
if (!F(n) || !/^[\w.-]+$/.test(n)) throw Error("Invalid WebSocket projectId");
|
|
81
119
|
let r;
|
|
82
120
|
try {
|
|
83
121
|
r = new URL(e.authEndpoint);
|
|
84
122
|
} catch {
|
|
85
123
|
throw Error("Invalid WebSocket auth endpoint");
|
|
86
124
|
}
|
|
87
|
-
if (r.protocol !== "https:" && !(r.protocol === "http:" &&
|
|
88
|
-
if (!
|
|
89
|
-
if (!
|
|
90
|
-
if (!
|
|
91
|
-
if (e.userEmail && !
|
|
92
|
-
if (e.userInfo && !
|
|
125
|
+
if (r.protocol !== "https:" && !(r.protocol === "http:" && U(r.hostname))) throw Error("Invalid WebSocket auth endpoint");
|
|
126
|
+
if (!a(e.key, 256)) throw Error("Invalid WebSocket key");
|
|
127
|
+
if (!W(e.wsHost)) throw Error("Invalid WebSocket host");
|
|
128
|
+
if (!a(e.apiKey, 512)) throw Error("Invalid WebSocket API key");
|
|
129
|
+
if (e.userEmail && !t(e.userEmail)) throw Error("Invalid WebSocket user email");
|
|
130
|
+
if (e.userInfo && !I(e.userInfo)) throw Error("Invalid WebSocket user info");
|
|
93
131
|
return {
|
|
94
132
|
...e,
|
|
95
|
-
projectId:
|
|
133
|
+
projectId: n,
|
|
96
134
|
authEndpoint: r.toString(),
|
|
97
|
-
userInfo: e.userInfo ?
|
|
135
|
+
userInfo: e.userInfo ? V(e.userInfo) : void 0
|
|
98
136
|
};
|
|
99
137
|
}
|
|
100
|
-
var
|
|
138
|
+
var q = class e {
|
|
101
139
|
static {
|
|
102
140
|
this.MAX_LISTENERS_PER_EVENT = 100;
|
|
103
141
|
}
|
|
104
142
|
constructor(e) {
|
|
105
|
-
this.listeners = /* @__PURE__ */ new Map(), this.pusher = null, this.presenceChannel = null, this.onlineUsers = /* @__PURE__ */ new Map(), this.lastCursorUpdate = 0, this.cursorThrottle = 50, this.reconnectAttempts = 0, this.connecting = null, this.destroyed = !1, this.config =
|
|
143
|
+
this.listeners = /* @__PURE__ */ new Map(), this.pusher = null, this.presenceChannel = null, this.onlineUsers = /* @__PURE__ */ new Map(), this.lastCursorUpdate = 0, this.cursorThrottle = 50, this.reconnectAttempts = 0, this.connecting = null, this.destroyed = !1, this.authorizationGeneration = 0, this.config = K(e);
|
|
106
144
|
}
|
|
107
145
|
on(t, n) {
|
|
108
146
|
let r = this.listeners.get(t);
|
|
@@ -126,7 +164,7 @@ var H = class e {
|
|
|
126
164
|
}
|
|
127
165
|
async openConnection() {
|
|
128
166
|
if (this.pusher || this.destroyed) return;
|
|
129
|
-
let e = await
|
|
167
|
+
let e = await C();
|
|
130
168
|
if (this.destroyed) return;
|
|
131
169
|
let t = { "X-API-Key": this.config.apiKey };
|
|
132
170
|
this.config.userEmail && (t["X-User-Email"] = this.config.userEmail), this.pusher = new e(this.config.key, {
|
|
@@ -135,9 +173,9 @@ var H = class e {
|
|
|
135
173
|
wsPort: this.config.wsPort ?? 443,
|
|
136
174
|
wssPort: this.config.wsPort ?? 443,
|
|
137
175
|
forceTLS: this.config.forceTLS ?? !0,
|
|
138
|
-
enabledTransports:
|
|
176
|
+
enabledTransports: ["ws"],
|
|
139
177
|
disableStats: !0,
|
|
140
|
-
channelAuthorization: {
|
|
178
|
+
channelAuthorization: this.config.authorizeChannel ? { customHandler: this.createChannelAuthorizer(this.config.authorizeChannel) } : {
|
|
141
179
|
transport: "ajax",
|
|
142
180
|
endpoint: this.config.authEndpoint,
|
|
143
181
|
headers: t,
|
|
@@ -165,11 +203,27 @@ var H = class e {
|
|
|
165
203
|
this.emit("error", /* @__PURE__ */ Error("WebSocket connection failed"));
|
|
166
204
|
}), this.subscribeToChannel();
|
|
167
205
|
}
|
|
206
|
+
createChannelAuthorizer(e) {
|
|
207
|
+
return (t, n) => {
|
|
208
|
+
let r = this.authorizationGeneration, i = () => !this.destroyed && r === this.authorizationGeneration && this.pusher?.connection.socket_id === t.socketId;
|
|
209
|
+
Promise.resolve().then(() => e(t.socketId, t.channelName)).then((e) => {
|
|
210
|
+
i() && n(null, e);
|
|
211
|
+
}, (e) => {
|
|
212
|
+
i() && n(e instanceof Error ? e : /* @__PURE__ */ Error("Channel authorization failed"), null);
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
}
|
|
168
216
|
reconnect() {
|
|
169
|
-
|
|
217
|
+
if (this.destroyed) return;
|
|
218
|
+
if (!this.pusher) {
|
|
219
|
+
this.connect();
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
let e = this.pusher;
|
|
223
|
+
this.authorizationGeneration++, this.reconnectAttempts++, this.onlineUsers.clear(), this.emit("presence:update", { users: [] }), e.disconnect(), !this.destroyed && this.pusher === e && e.connect();
|
|
170
224
|
}
|
|
171
225
|
disconnect() {
|
|
172
|
-
this.presenceChannel &&= (this.pusher?.unsubscribe(`presence-project.${this.config.projectId}`), null), this.pusher &&= (this.pusher.disconnect(), null), this.onlineUsers.clear();
|
|
226
|
+
this.authorizationGeneration++, this.presenceChannel &&= (this.pusher?.unsubscribe(`presence-project.${this.config.projectId}`), null), this.pusher &&= (this.pusher.disconnect(), null), this.onlineUsers.clear();
|
|
173
227
|
}
|
|
174
228
|
isConnected() {
|
|
175
229
|
return this.pusher?.connection.state === "connected";
|
|
@@ -182,64 +236,69 @@ var H = class e {
|
|
|
182
236
|
let e = `presence-project.${this.config.projectId}`;
|
|
183
237
|
this.presenceChannel = this.pusher.subscribe(e), this.presenceChannel.bind("pusher:subscription_succeeded", (e) => {
|
|
184
238
|
this.onlineUsers.clear(), e.each((e) => {
|
|
185
|
-
if (this.onlineUsers.size >=
|
|
239
|
+
if (this.onlineUsers.size >= j) return;
|
|
186
240
|
let t = this.memberToUser(e);
|
|
187
241
|
t && this.onlineUsers.set(t.id, t);
|
|
188
|
-
}), this.emit("presence:update", { users: this.getOnlineUsers() });
|
|
242
|
+
}), this.emit("presence:update", { users: this.getOnlineUsers() }), this.emit("subscribed", void 0);
|
|
189
243
|
}), this.presenceChannel.bind("pusher:member_added", (e) => {
|
|
190
244
|
let t = this.memberToUser(e);
|
|
191
245
|
if (t) {
|
|
192
|
-
if (!this.onlineUsers.has(t.id) && this.onlineUsers.size >=
|
|
246
|
+
if (!this.onlineUsers.has(t.id) && this.onlineUsers.size >= j) return;
|
|
193
247
|
this.onlineUsers.set(t.id, t), this.emit("user:joined", t), this.emit("presence:update", { users: this.getOnlineUsers() });
|
|
194
248
|
}
|
|
195
249
|
}), this.presenceChannel.bind("pusher:member_removed", (e) => {
|
|
196
|
-
if (!
|
|
250
|
+
if (!F(e.id)) return;
|
|
197
251
|
let t = e.id;
|
|
198
252
|
this.onlineUsers.delete(t), this.emit("user:left", { userId: t }), this.emit("presence:update", { users: this.getOnlineUsers() });
|
|
199
253
|
}), this.presenceChannel.bind("pusher:subscription_error", (e) => {
|
|
200
254
|
console.error("[CommentKit WS] Channel subscription error:", e);
|
|
201
|
-
let t =
|
|
255
|
+
let t = a(e.type, 80) ? e.type : "unknown";
|
|
202
256
|
this.emit("error", /* @__PURE__ */ Error(`Channel subscription failed: ${t}`));
|
|
203
257
|
});
|
|
204
258
|
let t = (e, t) => {
|
|
205
259
|
this.presenceChannel?.bind(e, t), this.presenceChannel?.bind(`.${e}`, t);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
260
|
+
}, n = (e, n) => {
|
|
261
|
+
t(e, (e) => {
|
|
262
|
+
if (r(e, n)) return;
|
|
263
|
+
let t = x(e);
|
|
264
|
+
L(t) && this.emit(n, t);
|
|
265
|
+
});
|
|
266
|
+
}, r = (e, t) => !i(e) || e.refresh !== !0 || !F(e.commentId) ? !1 : (this.emit("comment:refresh", {
|
|
267
|
+
commentId: e.commentId.trim(),
|
|
268
|
+
event: t
|
|
269
|
+
}), !0);
|
|
270
|
+
n("comment_created", "comment:created"), n("comment_updated", "comment:updated"), t("comment_deleted", (e) => {
|
|
212
271
|
let t = e;
|
|
213
|
-
|
|
214
|
-
}),
|
|
215
|
-
|
|
216
|
-
}), t("comment_completed", (e) => {
|
|
217
|
-
M(e) && this.emit("comment:completed", e);
|
|
218
|
-
}), t("reply_added", (e) => {
|
|
272
|
+
i(t) && F(t.id) && this.emit("comment:deleted", { id: t.id });
|
|
273
|
+
}), n("comment_resolved", "comment:resolved"), n("comment_completed", "comment:completed"), t("reply_added", (e) => {
|
|
274
|
+
if (r(e, "comment:updated")) return;
|
|
219
275
|
let t = e;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
reply:
|
|
223
|
-
|
|
276
|
+
if (i(t) && F(t.commentId)) {
|
|
277
|
+
let e = b(t.reply);
|
|
278
|
+
R(e) && this.emit("reply:added", {
|
|
279
|
+
commentId: t.commentId,
|
|
280
|
+
reply: e
|
|
281
|
+
});
|
|
282
|
+
}
|
|
224
283
|
}), t("reaction_added", (e) => {
|
|
225
284
|
let t = e;
|
|
226
|
-
|
|
285
|
+
i(t) && F(t.commentId) && a(t.emoji, 32) && F(t.userId) && this.emit("reaction:added", {
|
|
227
286
|
commentId: t.commentId,
|
|
228
|
-
...
|
|
287
|
+
...F(t.replyId) ? { replyId: t.replyId } : {},
|
|
229
288
|
emoji: t.emoji,
|
|
230
289
|
userId: t.userId
|
|
231
290
|
});
|
|
232
291
|
}), t("reaction_removed", (e) => {
|
|
233
292
|
let t = e;
|
|
234
|
-
|
|
293
|
+
i(t) && F(t.commentId) && a(t.emoji, 32) && F(t.userId) && this.emit("reaction:removed", {
|
|
235
294
|
commentId: t.commentId,
|
|
236
|
-
...
|
|
295
|
+
...F(t.replyId) ? { replyId: t.replyId } : {},
|
|
237
296
|
emoji: t.emoji,
|
|
238
297
|
userId: t.userId
|
|
239
298
|
});
|
|
240
299
|
}), this.presenceChannel.bind("client-cursor_move", (e) => {
|
|
241
|
-
if (
|
|
242
|
-
let t = e, n =
|
|
300
|
+
if (z(e)) {
|
|
301
|
+
let t = v(e.user), n = I(t) ? V(t) : G();
|
|
243
302
|
this.emit("cursor:move", {
|
|
244
303
|
...e,
|
|
245
304
|
user: n
|
|
@@ -247,51 +306,51 @@ var H = class e {
|
|
|
247
306
|
}
|
|
248
307
|
}), this.presenceChannel.bind("client-cursor_leave", (e) => {
|
|
249
308
|
let t = e;
|
|
250
|
-
|
|
309
|
+
i(t) && F(t.userId) && this.emit("cursor:leave", { userId: t.userId });
|
|
251
310
|
}), this.presenceChannel.bind("client-drawing_stroke", (e) => {
|
|
252
311
|
let t = e;
|
|
253
|
-
|
|
312
|
+
i(t) && F(t.userId) && B(t.path) && this.emit("drawing:stroke", {
|
|
254
313
|
userId: t.userId,
|
|
255
314
|
path: t.path
|
|
256
315
|
});
|
|
257
316
|
});
|
|
258
317
|
}
|
|
259
318
|
memberToUser(e) {
|
|
260
|
-
if (!
|
|
319
|
+
if (!F(e.id)) return null;
|
|
261
320
|
let t = e.info;
|
|
262
321
|
if (!t) return null;
|
|
263
|
-
let n = t.email == null || t.email === "" ? `${String(e.id)}@presence.invalid` : t.email, r = {
|
|
322
|
+
let n = t.email == null || t.email === "" ? `${String(e.id)}@presence.invalid` : t.email, r = v({
|
|
264
323
|
id: String(e.id),
|
|
265
324
|
name: t.name || "Anonymous",
|
|
266
325
|
email: n,
|
|
267
326
|
avatar: t.avatar
|
|
268
|
-
};
|
|
269
|
-
return
|
|
327
|
+
});
|
|
328
|
+
return I(r) ? V(r) : null;
|
|
270
329
|
}
|
|
271
330
|
sendCursorMove(e, t, n) {
|
|
272
331
|
if (!Number.isFinite(e) || !Number.isFinite(t)) return;
|
|
273
|
-
let r =
|
|
332
|
+
let r = H(n);
|
|
274
333
|
if (!r) return;
|
|
275
334
|
let i = Math.max(0, Math.min(100, e)), a = Math.max(0, Math.min(100, t)), o = Date.now();
|
|
276
335
|
o - this.lastCursorUpdate < this.cursorThrottle || (this.lastCursorUpdate = o, this.triggerClientEvent("client-cursor_move", {
|
|
277
336
|
x: i,
|
|
278
337
|
y: a,
|
|
279
338
|
page: r,
|
|
280
|
-
user: this.config.userInfo ||
|
|
339
|
+
user: this.config.userInfo || G()
|
|
281
340
|
}));
|
|
282
341
|
}
|
|
283
342
|
sendCursorLeave() {
|
|
284
343
|
this.triggerClientEvent("client-cursor_leave", { userId: this.config.userInfo?.id || "unknown" });
|
|
285
344
|
}
|
|
286
345
|
sendDrawingStroke(e) {
|
|
287
|
-
|
|
346
|
+
B(e) && this.triggerClientEvent("client-drawing_stroke", {
|
|
288
347
|
userId: this.config.userInfo?.id || "unknown",
|
|
289
348
|
path: e
|
|
290
349
|
});
|
|
291
350
|
}
|
|
292
351
|
requestPresence() {}
|
|
293
352
|
triggerClientEvent(e, t) {
|
|
294
|
-
if (
|
|
353
|
+
if (N.has(e) && this.presenceChannel) try {
|
|
295
354
|
this.presenceChannel.trigger(e, t);
|
|
296
355
|
} catch {}
|
|
297
356
|
}
|
|
@@ -299,4 +358,4 @@ var H = class e {
|
|
|
299
358
|
this.destroyed = !0, this.disconnect(), this.listeners.clear();
|
|
300
359
|
}
|
|
301
360
|
};
|
|
302
|
-
export { p as n, m as r,
|
|
361
|
+
export { p as a, v as i, x as n, m as o, b as r, q as t };
|
package/dist/solid.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./shared/comment-kit-core-
|
|
1
|
+
import { t as e } from "./shared/comment-kit-core-C862uNAm.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 { createMemo as o, createSignal as s, onCleanup as c, onMount as l } from "solid-js";
|
|
@@ -24,7 +24,7 @@ function u(u) {
|
|
|
24
24
|
}
|
|
25
25
|
}, K = async (e) => {
|
|
26
26
|
try {
|
|
27
|
-
let { mountCommentKitUI: t } = await import("./shared/mount-ui
|
|
27
|
+
let { mountCommentKitUI: t } = await import("./shared/mount-ui-B68j8r6I.js").then((e) => e.n);
|
|
28
28
|
if (w || x !== e) return;
|
|
29
29
|
let n = await t(e);
|
|
30
30
|
if (w || x !== e) {
|
package/dist/svelte.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./shared/comment-kit-core-
|
|
1
|
+
import { t as e } from "./shared/comment-kit-core-C862uNAm.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 { onDestroy as o } from "svelte";
|
|
@@ -23,7 +23,7 @@ function d(o) {
|
|
|
23
23
|
} catch {}
|
|
24
24
|
}, B = async (e) => {
|
|
25
25
|
try {
|
|
26
|
-
let { mountCommentKitUI: t } = await import("./shared/mount-ui
|
|
26
|
+
let { mountCommentKitUI: t } = await import("./shared/mount-ui-B68j8r6I.js").then((e) => e.n);
|
|
27
27
|
if (I || c(d) !== e) return;
|
|
28
28
|
let n = await t(e);
|
|
29
29
|
if (I || c(d) !== e) {
|
|
@@ -3,13 +3,15 @@ export declare class ApiClient {
|
|
|
3
3
|
private baseUrl;
|
|
4
4
|
private apiKey;
|
|
5
5
|
private projectId;
|
|
6
|
+
private channelProjectId;
|
|
6
7
|
private userEmail;
|
|
7
8
|
private authToken;
|
|
8
9
|
private authRevision;
|
|
9
10
|
private environment;
|
|
10
11
|
private onAuthExpired;
|
|
11
12
|
constructor(config: ResolvedConfig);
|
|
12
|
-
|
|
13
|
+
/** HTTP routes may use a slug while presence channels always use the project ID. */
|
|
14
|
+
setProject(projectId: string, channelProjectId?: string): void;
|
|
13
15
|
setUserEmail(email: string | null): void;
|
|
14
16
|
setAuthToken(token: string | null): void;
|
|
15
17
|
setEnvironment(environment: CommentEnvironment | null): void;
|
|
@@ -21,6 +23,11 @@ export declare class ApiClient {
|
|
|
21
23
|
private requestFormData;
|
|
22
24
|
private requireProjectId;
|
|
23
25
|
validateApiKey(): Promise<AuthResponse>;
|
|
26
|
+
/** Authorize presence using the current SDK session, never a copied bearer token. */
|
|
27
|
+
authorizeChannel(socketId: string, channelName: string): Promise<{
|
|
28
|
+
auth: string;
|
|
29
|
+
channel_data: string;
|
|
30
|
+
}>;
|
|
24
31
|
requestOtp(email: string): Promise<OtpResponse>;
|
|
25
32
|
verifyOtp(email: string, otp: string): Promise<OtpVerifyResponse>;
|
|
26
33
|
validateInvite(token: string, email: string): Promise<InviteValidationResponse>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CommentWriteAccess } from "./write-access";
|
|
1
2
|
import { EventEmitter } from "../utils/event-emitter";
|
|
2
3
|
import type { LocalDemoStore } from "./local-demo";
|
|
3
4
|
import type { AgentContextExport, AgentContextOptions, Comment, CommentCreateOptions, ReplyOptions, CommentKitConfig, CommentKitState, DevGrabBundle, DevGrabOptions, DevGrabResult, DrawingData, DrawingPath, Position, ResolvedConfig, ScreenshotResult, StateSlice, TextSelection, ToolType, Unsubscribe, User } from "./types";
|
|
@@ -26,12 +27,14 @@ export declare class CommentKitCore extends EventEmitter {
|
|
|
26
27
|
private initialized;
|
|
27
28
|
private destroyed;
|
|
28
29
|
private sessionRevision;
|
|
30
|
+
private writeRestriction;
|
|
29
31
|
private authRequestRevision;
|
|
30
32
|
private commentsFetchRevision;
|
|
31
33
|
private contextFetchRevision;
|
|
32
34
|
private deepLinkRequest;
|
|
33
35
|
private reactionRequests;
|
|
34
36
|
private draftUploads;
|
|
37
|
+
private attachmentRefreshes;
|
|
35
38
|
private screenshotProvider;
|
|
36
39
|
private bootRetryTimer;
|
|
37
40
|
private bootAttempts;
|
|
@@ -86,6 +89,10 @@ export declare class CommentKitCore extends EventEmitter {
|
|
|
86
89
|
* Use this instead of accessing config directly.
|
|
87
90
|
*/
|
|
88
91
|
getFeatures(): NonNullable<ResolvedConfig["features"]>;
|
|
92
|
+
/** Whether this project currently permits comment mutations (independent of login). */
|
|
93
|
+
canWriteComments(): boolean;
|
|
94
|
+
getWriteAccess(): CommentWriteAccess;
|
|
95
|
+
private requireCommentWrite;
|
|
89
96
|
/**
|
|
90
97
|
* Get the public configuration (excludes internal auto-detected fields
|
|
91
98
|
* such as projectId and reverb connection details).
|
|
@@ -147,6 +154,8 @@ export declare class CommentKitCore extends EventEmitter {
|
|
|
147
154
|
* loaded, this refreshes existing data — e.g. to pick up remote edits.
|
|
148
155
|
*/
|
|
149
156
|
reloadComments(): Promise<void>;
|
|
157
|
+
/** @internal Refresh signed attachment links without discarding pagination or local edits. */
|
|
158
|
+
refreshAttachmentUrl(attachmentId: string): Promise<string | null>;
|
|
150
159
|
/** Refresh authenticated member, plan and usage data without fabricating demo values. */
|
|
151
160
|
reloadProjectContext(): Promise<void>;
|
|
152
161
|
setBranch(branch: string | null): Promise<void>;
|
|
@@ -74,9 +74,24 @@ export interface AgentCommentContext {
|
|
|
74
74
|
author: Pick<User, "id" | "name" | "email">;
|
|
75
75
|
createdAt: string;
|
|
76
76
|
updatedAt: string;
|
|
77
|
+
environment?: CommentEnvironment;
|
|
78
|
+
branch?: string;
|
|
79
|
+
deviceInfo?: CommentDeviceInfo;
|
|
80
|
+
description?: string;
|
|
81
|
+
assignees?: Array<Pick<User, "id" | "name" | "email">>;
|
|
82
|
+
mentions?: Mention[];
|
|
83
|
+
checklist?: TaskChecklistItem[];
|
|
84
|
+
reactions?: CommentReaction[];
|
|
85
|
+
isEdited?: boolean;
|
|
86
|
+
resolvedAt?: string;
|
|
87
|
+
completedAt?: string;
|
|
77
88
|
page: Comment["page"];
|
|
78
89
|
position: Position;
|
|
90
|
+
textSelection?: TextSelection;
|
|
91
|
+
drawingData?: DrawingData;
|
|
79
92
|
element: AgentElementContext;
|
|
93
|
+
/** All files and annotations attached to the feedback, not only the first screenshot. */
|
|
94
|
+
attachments?: Attachment[];
|
|
80
95
|
/** Stakeholder-attached screenshot (data URL or remote URL), when present. */
|
|
81
96
|
screenshotUrl?: string;
|
|
82
97
|
replies: Array<{
|
|
@@ -84,6 +99,11 @@ export interface AgentCommentContext {
|
|
|
84
99
|
content: string;
|
|
85
100
|
author: Pick<User, "id" | "name" | "email">;
|
|
86
101
|
createdAt: string;
|
|
102
|
+
isEdited?: boolean;
|
|
103
|
+
replyTo?: Reply["replyTo"];
|
|
104
|
+
mentions?: Mention[];
|
|
105
|
+
reactions?: CommentReaction[];
|
|
106
|
+
attachments?: Attachment[];
|
|
87
107
|
}>;
|
|
88
108
|
}
|
|
89
109
|
export interface AgentContextExport {
|
|
@@ -96,6 +116,19 @@ export interface AgentContextExport {
|
|
|
96
116
|
title: string;
|
|
97
117
|
};
|
|
98
118
|
comments: AgentCommentContext[];
|
|
119
|
+
/** Identifiers only: API keys, auth tokens and project settings are never exported. */
|
|
120
|
+
project?: Pick<Project, "id" | "name" | "slug">;
|
|
121
|
+
/** Export scope describes the loaded snapshot; it does not fetch additional pages. */
|
|
122
|
+
scope?: {
|
|
123
|
+
activeBranch: string | null;
|
|
124
|
+
currentPageOnly: boolean;
|
|
125
|
+
includeResolved: boolean;
|
|
126
|
+
loadedCommentCount: number;
|
|
127
|
+
matchingCommentCount: number;
|
|
128
|
+
exportedCommentCount: number;
|
|
129
|
+
hasMoreOnServer: boolean;
|
|
130
|
+
truncated: boolean;
|
|
131
|
+
};
|
|
99
132
|
/** True when source resolution succeeded for at least one comment. */
|
|
100
133
|
sourceResolved: boolean;
|
|
101
134
|
}
|
|
@@ -219,6 +252,8 @@ export interface ProjectContext {
|
|
|
219
252
|
permissions: {
|
|
220
253
|
canManageComments: boolean;
|
|
221
254
|
canInvite: boolean;
|
|
255
|
+
canWriteComments?: boolean;
|
|
256
|
+
writeRestriction?: "plan_required" | "feature_disabled" | null;
|
|
222
257
|
};
|
|
223
258
|
}
|
|
224
259
|
export interface CommentDeviceInfo {
|
|
@@ -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.
|
|
@@ -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;
|