@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.
- package/CHANGELOG.md +41 -0
- package/README.md +10 -6
- package/SECURITY.md +14 -6
- package/dist/angular.es.js +2 -2
- package/dist/comment-kit.es.js +5 -5
- package/dist/demo.es.js +36 -34
- 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/{ShadowRootContext-Bv-4aElu.js → ShadowRootContext-CjciYxVN.js} +4 -4
- package/dist/shared/annotation-toolbar-CZI1KVdW.js +1094 -0
- package/dist/shared/attachment-refresh-mQw-L7hB.js +94 -0
- package/dist/shared/{button-group-Cl9CrvvU.js → button-group-C285iSkZ.js} +14 -16
- package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
- package/dist/shared/capture-privacy-DUROnio5.js +77 -0
- package/dist/shared/{comment-drawing-canvas-Dzb5YoFw.js → comment-drawing-canvas-CYFFKgCm.js} +2 -2
- package/dist/shared/{comment-utils-BycYTSxA.js → comment-icon-4SQd3nlz.js} +30 -24
- package/dist/shared/comment-image-lightbox-DmTNxuqX.js +190 -0
- package/dist/shared/comment-images-content-BX4DQ9Ol.js +214 -0
- package/dist/shared/{comment-kit-core-BaSuMzp9.js → comment-kit-core-VuIidMeu.js} +1096 -793
- package/dist/shared/{comment-kit-ui-CzfdAZs2.js → comment-kit-ui-BjJ1ZLiv.js} +6091 -6486
- package/dist/shared/{comment-screenshot-annotator-C7X-_bm6.js → comment-screenshot-annotator-CMOG1md7.js} +5 -5
- package/dist/shared/{comment-screenshot-overlay-wIrZrcRy.js → comment-screenshot-overlay-iWW-V-Iw.js} +114 -118
- package/dist/shared/comment-shortcut-groups-CfEmkitU.js +153 -0
- package/dist/shared/{dev-export-panel-FwFVdady.js → dev-export-panel-CrRENbMn.js} +9 -10
- package/dist/shared/dev-grab-Ca4MlS2Y.js +196 -0
- package/dist/shared/{element-selector-BhJm-NSs.js → element-selector-g1bTvdEA.js} +450 -408
- package/dist/shared/{mount-ui--ijs8pWT.js → mount-ui-Dz5QLq4W.js} +121 -106
- package/dist/shared/{pusher-ipHMJnO_.js → pusher-ue0D83de.js} +1 -1
- package/dist/shared/realtime-CieWAnsW.js +321 -0
- package/dist/shared/realtime-recovery-BSVMwsXJ.js +135 -0
- package/dist/shared/request-activity-DQrAUwfA.js +11 -0
- package/dist/shared/{separator-XDBsaWyw.js → separator-aphZiRoJ.js} +1 -1
- package/dist/shared/{shadow-root-C5v-T8lQ.js → shadow-root-Cv1aLuFf.js} +31 -31
- package/dist/shared/{styles-D3yMtaec.js → styles-CnYsLS2f.js} +1 -1
- package/dist/shared/text-B4HHZNaa.js +23 -0
- package/dist/shared/token-session-CPQpt3-u.js +25 -0
- package/dist/shared/useRender-D1z_X_BY.js +5 -0
- package/dist/shared/{validation-C7QG8j7Z.js → validation-3wbbbuX0.js} +26 -1
- package/dist/shared/websocket-manager-BnK55c3U.js +381 -0
- package/dist/solid.es.js +2 -2
- package/dist/svelte.es.js +2 -2
- package/dist/types/core/api-client.d.ts +11 -2
- package/dist/types/core/comment-kit-core.d.ts +11 -5
- package/dist/types/core/types.d.ts +54 -2
- package/dist/types/core/websocket-manager.d.ts +13 -0
- package/dist/types/core/write-access.d.ts +9 -0
- package/dist/vue.es.js +2 -2
- package/docs/api-reference.md +25 -4
- package/package.json +3 -2
- package/dist/shared/annotation-toolbar-B9SxYqoF.js +0 -1093
- 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
- package/dist/shared/websocket-manager-DhLWh3Jr.js +0 -302
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { n as e } from "./request-activity-DQrAUwfA.js";
|
|
2
|
+
function t(t, n, r, i) {
|
|
3
|
+
let a = !1, o = !1, s = !1, c = !1, l, u, d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), p = () => !a && r() && t.getState().isAuthenticated, m = () => {
|
|
4
|
+
let n = t.getState();
|
|
5
|
+
return n.isLoading || n.pendingMutations.length > 0 || e(t.apiClient);
|
|
6
|
+
}, h = (e, n) => p() && e.isCurrent?.() !== !1 && n.activeBranch === t.getState().activeBranch, g = (e) => {
|
|
7
|
+
let n = t.getState();
|
|
8
|
+
return !m() && e.comments === n.comments && e.pagination === n.pagination && e.selectedComment?.id === n.selectedComment?.id;
|
|
9
|
+
}, _ = (e, t) => {
|
|
10
|
+
let n = i(e, t.currentUser?.id);
|
|
11
|
+
if (!n) throw Error("Invalid comment refresh response");
|
|
12
|
+
return n;
|
|
13
|
+
}, v = (e, t) => !t.activeBranch || e.branch === t.activeBranch, y = (e) => typeof e == "object" && !!e && "code" in e && e.code === 404, b = (e) => {
|
|
14
|
+
let t = typeof e == "object" && e && "code" in e ? e.code : null;
|
|
15
|
+
return typeof t == "number" && (t === 0 || t === 408 || t === 429 || t >= 500 && t <= 599);
|
|
16
|
+
};
|
|
17
|
+
async function x(e, n) {
|
|
18
|
+
let r = Math.max(1, n.pagination?.page ?? 1), i = n.pagination?.limit ?? 50, a = /* @__PURE__ */ new Map(), o = n.pagination;
|
|
19
|
+
for (let t = 1; t <= r; t++) {
|
|
20
|
+
let r = await e.apiClient.getComments(void 0, "all", t, i, void 0, n.activeBranch);
|
|
21
|
+
if (!h(e, n)) return;
|
|
22
|
+
if (!g(n)) {
|
|
23
|
+
c = !0;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
for (let e of r.comments) {
|
|
27
|
+
let t = _(e, n);
|
|
28
|
+
v(t, n) && a.set(t.id, t);
|
|
29
|
+
}
|
|
30
|
+
if (o = r.pagination, !o.hasMore) break;
|
|
31
|
+
}
|
|
32
|
+
let s = n.selectedComment?.id, l = s ? a.get(s) ?? null : null;
|
|
33
|
+
if (s && !l) try {
|
|
34
|
+
let t = _(await e.apiClient.getComment(s), n);
|
|
35
|
+
if (t.id !== s) throw Error("Invalid comment refresh response");
|
|
36
|
+
v(t, n) && (l = t, a.set(t.id, t));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
if (!y(e)) throw e;
|
|
39
|
+
}
|
|
40
|
+
if (!h(e, n)) return;
|
|
41
|
+
if (!g(n)) {
|
|
42
|
+
c = !0;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
let u = t.getState();
|
|
46
|
+
e.setState({
|
|
47
|
+
comments: [...a.values()],
|
|
48
|
+
pagination: o,
|
|
49
|
+
...u.selectedComment?.id === s ? { selectedComment: l } : {}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function S(e, n, r, i) {
|
|
53
|
+
let a;
|
|
54
|
+
try {
|
|
55
|
+
if (a = _(await e.apiClient.getComment(r), n), a.id !== r) throw Error("Invalid comment refresh response");
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (!y(e)) throw e;
|
|
58
|
+
a = null;
|
|
59
|
+
}
|
|
60
|
+
if (!h(e, n)) return;
|
|
61
|
+
if (!g(n)) {
|
|
62
|
+
for (let e of i) T({
|
|
63
|
+
commentId: r,
|
|
64
|
+
event: e
|
|
65
|
+
});
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
let o = t.getState(), s = o.comments.some((e) => e.id === r);
|
|
69
|
+
if (a && !v(a, n)) return;
|
|
70
|
+
let c = o.comments.filter((e) => e.id !== r);
|
|
71
|
+
if (a && (s || i.has("comment:created"))) {
|
|
72
|
+
let e = o.comments.findIndex((e) => e.id === r);
|
|
73
|
+
c.splice(e < 0 ? c.length : e, 0, a);
|
|
74
|
+
}
|
|
75
|
+
if (e.setState({
|
|
76
|
+
comments: c,
|
|
77
|
+
...o.selectedComment?.id === r ? { selectedComment: a } : {}
|
|
78
|
+
}), !a) s && e.emit("comment:deleted", { id: r });
|
|
79
|
+
else for (let t of i) (t !== "comment:created" || !s) && e.emit(t, a);
|
|
80
|
+
}
|
|
81
|
+
async function C() {
|
|
82
|
+
if (s = !1, !p() || o || !c && !f.size) return;
|
|
83
|
+
if (m()) {
|
|
84
|
+
e(t.apiClient) && !l && (l = setTimeout(() => {
|
|
85
|
+
l = void 0, w();
|
|
86
|
+
}, 100));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
o = !0;
|
|
90
|
+
let r = n.capture(), i = t.getState(), a = c, g = a ? void 0 : f.entries().next().value, _ = a ? "window" : `thread:${g?.[0]}`;
|
|
91
|
+
try {
|
|
92
|
+
if (a) c = !1, await x(r, i);
|
|
93
|
+
else if (g) {
|
|
94
|
+
let [e, t] = g;
|
|
95
|
+
f.delete(e), await S(r, i, e, t);
|
|
96
|
+
}
|
|
97
|
+
d.delete(_);
|
|
98
|
+
} catch (e) {
|
|
99
|
+
if (h(r, i)) {
|
|
100
|
+
let t = d.get(_) ?? 0;
|
|
101
|
+
b(e) && t < 2 ? (d.set(_, t + 1), u = setTimeout(() => {
|
|
102
|
+
if (u = void 0, h(r, i)) {
|
|
103
|
+
if (a) c = !0;
|
|
104
|
+
else if (g) for (let e of g[1]) T({
|
|
105
|
+
commentId: g[0],
|
|
106
|
+
event: e
|
|
107
|
+
});
|
|
108
|
+
} else d.delete(_);
|
|
109
|
+
w();
|
|
110
|
+
}, 1e3 * 2 ** t)) : (d.delete(_), r.handleError(e));
|
|
111
|
+
}
|
|
112
|
+
} finally {
|
|
113
|
+
o = !1, w();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function w() {
|
|
117
|
+
!p() || s || o || u || !c && !f.size || (s = !0, Promise.resolve().then(C));
|
|
118
|
+
}
|
|
119
|
+
function T({ commentId: e, event: t }) {
|
|
120
|
+
if (!p()) return;
|
|
121
|
+
let n = f.get(e) ?? /* @__PURE__ */ new Set();
|
|
122
|
+
n.add(t), f.size < 256 || f.has(e) ? f.set(e, n) : c = !0, w();
|
|
123
|
+
}
|
|
124
|
+
let E = n.subscribe(w);
|
|
125
|
+
return {
|
|
126
|
+
refreshThread: T,
|
|
127
|
+
refreshWindow() {
|
|
128
|
+
p() && (c = !0, w());
|
|
129
|
+
},
|
|
130
|
+
dispose() {
|
|
131
|
+
a = !0, l && clearTimeout(l), u && clearTimeout(u), d.clear(), f.clear(), E();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export { t as createRealtimeRecovery };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var e = /* @__PURE__ */ new WeakMap();
|
|
2
|
+
function t(t) {
|
|
3
|
+
return (e.get(t) ?? 0) > 0;
|
|
4
|
+
}
|
|
5
|
+
function n(t) {
|
|
6
|
+
return e.set(t, (e.get(t) ?? 0) + 1), () => {
|
|
7
|
+
let n = (e.get(t) ?? 1) - 1;
|
|
8
|
+
n ? e.set(t, n) : e.delete(t);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export { t as n, n as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as e, B as t, C as n, D as r, E as i, F as a, I as o, L as s, M as c, N as l, O as u, P as d, S as f, T as p, V as m, _ as h, b as g, c as _, d as v, j as y, k as b, m as x, p as S, u as C, v as w, w as T, x as E, y as D, z as O } from "./button-By0hGrJK.js";
|
|
2
2
|
import { C as k, D as A, F as j, N as M, O as N, P, S as ee, d as te, i as F, j as I, k as L, l as ne, n as re, p as R, r as z } from "./useValueChanged-CrzfD8l-.js";
|
|
3
|
-
import {
|
|
3
|
+
import { a as ie, r as ae } from "./ShadowRootContext-CjciYxVN.js";
|
|
4
4
|
import * as B from "react";
|
|
5
5
|
import { useDebugValue as V, useEffect as oe, useLayoutEffect as H, useMemo as se, useRef as ce, useSyncExternalStore as le, useSyncExternalStore as U } from "react";
|
|
6
6
|
import { jsx as W, jsxs as ue } from "react/jsx-runtime";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { o as e, r as t } from "./mount-ui
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { createPortal as
|
|
7
|
-
var
|
|
8
|
-
let { direction: t = "ltr" } = e, r =
|
|
9
|
-
return /*#__PURE__*/
|
|
1
|
+
import { o as e, r as t } from "./mount-ui-Dz5QLq4W.js";
|
|
2
|
+
import { i as n, n as r, t as i } from "./ShadowRootContext-CjciYxVN.js";
|
|
3
|
+
import * as a from "react";
|
|
4
|
+
import { useCallback as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
5
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
|
+
import { createPortal as m } from "react-dom";
|
|
7
|
+
var h = function(e) {
|
|
8
|
+
let { direction: t = "ltr" } = e, r = a.useMemo(() => ({ direction: t }), [t]);
|
|
9
|
+
return /*#__PURE__*/ f(n.Provider, {
|
|
10
10
|
value: r,
|
|
11
11
|
children: e.children
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
|
-
process.env.NODE_ENV !== "production" && (
|
|
15
|
-
var
|
|
16
|
-
function
|
|
14
|
+
process.env.NODE_ENV !== "production" && (h.displayName = "DirectionProvider");
|
|
15
|
+
var g = "https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=Geist+Mono:wght@100..900&display=swap";
|
|
16
|
+
function _() {
|
|
17
17
|
/* v8 ignore stop */
|
|
18
18
|
if (typeof document > "u" || document.querySelector("link[data-commentkit-font]")) return;
|
|
19
19
|
let e = getComputedStyle(document.documentElement);
|
|
@@ -25,12 +25,12 @@ function g() {
|
|
|
25
25
|
t.rel = "preconnect", t.href = "https://fonts.gstatic.com", t.crossOrigin = "anonymous", document.head.appendChild(t);
|
|
26
26
|
}
|
|
27
27
|
let t = document.createElement("link");
|
|
28
|
-
t.rel = "stylesheet", t.href =
|
|
28
|
+
t.rel = "stylesheet", t.href = g, t.setAttribute("data-commentkit-font", "geist"), document.head.appendChild(t);
|
|
29
29
|
}
|
|
30
|
-
var
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
let e =
|
|
30
|
+
var v = ({ children: n, styles: i, config: a }) => {
|
|
31
|
+
let g = l(null), [v, y] = u(null), [b, x] = u(null), [S, C] = u(!1), [w, T] = u("ltr"), E = a?.ui?.loadRemoteFonts === !0, D = a?.ui?.theme;
|
|
32
|
+
s(() => {
|
|
33
|
+
let e = g.current;
|
|
34
34
|
/* v8 ignore start -- ref always set when useEffect fires */
|
|
35
35
|
if (e) {
|
|
36
36
|
/* v8 ignore stop */
|
|
@@ -42,11 +42,11 @@ var _ = ({ children: n, styles: i, config: h }) => {
|
|
|
42
42
|
y(t);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
}, []),
|
|
46
|
-
E &&
|
|
47
|
-
}, [E]),
|
|
45
|
+
}, []), s(() => {
|
|
46
|
+
E && _();
|
|
47
|
+
}, [E]), s(() => {
|
|
48
48
|
let n = document.documentElement, r = window.matchMedia("(prefers-color-scheme: dark)"), i = () => {
|
|
49
|
-
T(getComputedStyle(
|
|
49
|
+
T(getComputedStyle(g.current || n).direction === "rtl" ? "rtl" : "ltr");
|
|
50
50
|
let e = t();
|
|
51
51
|
if (e) {
|
|
52
52
|
C(e === "dark");
|
|
@@ -81,7 +81,7 @@ var _ = ({ children: n, styles: i, config: h }) => {
|
|
|
81
81
|
o(), a.disconnect(), r.removeEventListener("change", i);
|
|
82
82
|
};
|
|
83
83
|
}, [D]);
|
|
84
|
-
let O =
|
|
84
|
+
let O = o(() => {
|
|
85
85
|
/* v8 ignore start -- SSR guard unreachable in jsdom */
|
|
86
86
|
if (typeof window > "u") return "";
|
|
87
87
|
/* v8 ignore stop */
|
|
@@ -89,8 +89,8 @@ var _ = ({ children: n, styles: i, config: h }) => {
|
|
|
89
89
|
if (!a && !o && !i) return "";
|
|
90
90
|
let s = [];
|
|
91
91
|
return a && s.push(t ? `--font-sans: ${a}, ui-sans-serif, sans-serif` : `--font-sans: ${a}, "DM Sans", "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`), o && s.push(n ? `--font-heading: ${o}, ui-sans-serif, sans-serif` : `--font-heading: ${o}, var(--font-sans)`), i && s.push(`--font-mono: ${i}, "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace`), `:host { ${s.join("; ")}; }`;
|
|
92
|
-
}, []), [k, A] =
|
|
93
|
-
|
|
92
|
+
}, []), [k, A] = u(() => O());
|
|
93
|
+
s(() => {
|
|
94
94
|
let e = !1, t = () => {
|
|
95
95
|
if (e) return;
|
|
96
96
|
let t = O();
|
|
@@ -102,9 +102,9 @@ var _ = ({ children: n, styles: i, config: h }) => {
|
|
|
102
102
|
e = !0, clearTimeout(n);
|
|
103
103
|
};
|
|
104
104
|
}, [O]);
|
|
105
|
-
let j =
|
|
106
|
-
return /* @__PURE__ */
|
|
107
|
-
ref:
|
|
105
|
+
let j = c(() => i + "\n" + k, [i, k]);
|
|
106
|
+
return /* @__PURE__ */ f("div", {
|
|
107
|
+
ref: g,
|
|
108
108
|
"data-commentkit-host": !0,
|
|
109
109
|
"data-ck-dark": S || void 0,
|
|
110
110
|
style: {
|
|
@@ -117,14 +117,14 @@ var _ = ({ children: n, styles: i, config: h }) => {
|
|
|
117
117
|
zIndex: 2147483647,
|
|
118
118
|
pointerEvents: "none"
|
|
119
119
|
},
|
|
120
|
-
children: v &&
|
|
120
|
+
children: v && m(/* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("style", { children: j }), /* @__PURE__ */ f(r.Provider, {
|
|
121
121
|
value: b,
|
|
122
|
-
children: /* @__PURE__ */
|
|
122
|
+
children: /* @__PURE__ */ f("div", {
|
|
123
123
|
ref: x,
|
|
124
124
|
className: "ck-root",
|
|
125
125
|
"data-commentkit-ui": !0,
|
|
126
126
|
"data-theme": S ? "dark" : "light",
|
|
127
|
-
children: b ? /* @__PURE__ */
|
|
127
|
+
children: b ? /* @__PURE__ */ f(h, {
|
|
128
128
|
direction: w,
|
|
129
129
|
children: n
|
|
130
130
|
}) : null
|
|
@@ -132,4 +132,4 @@ var _ = ({ children: n, styles: i, config: h }) => {
|
|
|
132
132
|
})] }), v)
|
|
133
133
|
});
|
|
134
134
|
};
|
|
135
|
-
export {
|
|
135
|
+
export { i as HostModalContext, v as ShadowContainer };
|