@commentkit/comment-kit 0.7.1 → 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 +14 -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 +35 -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-CzQFXHkL.js → attachment-refresh-mQw-L7hB.js} +2 -2
- package/dist/shared/{button-group-CWdKaOlC.js → button-group-C285iSkZ.js} +1 -1
- package/dist/shared/capture-privacy-DUROnio5.js +77 -0
- package/dist/shared/{comment-drawing-canvas-DdXlMgbF.js → comment-drawing-canvas-CYFFKgCm.js} +2 -2
- package/dist/shared/{comment-icon-Dg9ZWpz-.js → comment-icon-4SQd3nlz.js} +1 -1
- package/dist/shared/{comment-image-lightbox-B7iHjnAz.js → comment-image-lightbox-DmTNxuqX.js} +5 -5
- package/dist/shared/{comment-images-content-D7YNUgo5.js → comment-images-content-BX4DQ9Ol.js} +3 -3
- package/dist/shared/{comment-kit-core-C862uNAm.js → comment-kit-core-VuIidMeu.js} +786 -703
- package/dist/shared/{comment-kit-ui-0vd-DY4S.js → comment-kit-ui-BjJ1ZLiv.js} +4429 -4620
- package/dist/shared/{comment-screenshot-annotator-DcaSSuWB.js → comment-screenshot-annotator-CMOG1md7.js} +2 -2
- package/dist/shared/{comment-screenshot-overlay-D_nFoJmM.js → comment-screenshot-overlay-iWW-V-Iw.js} +113 -118
- package/dist/shared/comment-shortcut-groups-CfEmkitU.js +153 -0
- package/dist/shared/{dev-export-panel-pWBlhlse.js → dev-export-panel-CrRENbMn.js} +3 -4
- package/dist/shared/dev-grab-Ca4MlS2Y.js +196 -0
- package/dist/shared/{element-selector-DC-_XJ0k.js → element-selector-g1bTvdEA.js} +408 -405
- package/dist/shared/{mount-ui-B68j8r6I.js → mount-ui-Dz5QLq4W.js} +121 -106
- package/dist/shared/{pusher-C1FHQGXV.js → pusher-ue0D83de.js} +1 -1
- package/dist/shared/realtime-CieWAnsW.js +321 -0
- package/dist/shared/{realtime-recovery-DJ_adc-H.js → realtime-recovery-BSVMwsXJ.js} +1 -1
- 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-CrO75sED.js → shadow-root-Cv1aLuFf.js} +31 -31
- package/dist/shared/{styles-C9Jwvm0Q.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/{validation-D-8u4M7I.js → validation-3wbbbuX0.js} +14 -2
- package/dist/shared/{websocket-manager-CFak_YHy.js → websocket-manager-BnK55c3U.js} +136 -116
- package/dist/solid.es.js +2 -2
- package/dist/svelte.es.js +2 -2
- package/dist/types/core/api-client.d.ts +3 -1
- package/dist/types/core/comment-kit-core.d.ts +2 -5
- package/dist/types/core/types.d.ts +22 -5
- package/dist/types/core/websocket-manager.d.ts +1 -0
- package/dist/vue.es.js +2 -2
- package/docs/api-reference.md +19 -4
- package/package.json +1 -1
- package/dist/shared/annotation-toolbar-cGC1p-SP.js +0 -1093
- package/dist/shared/dev-grab-eQ9EgEGY.js +0 -210
- package/dist/shared/realtime-Diqz7G_y.js +0 -317
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
import { o as e } from "./websocket-manager-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function a(e) {
|
|
8
|
-
n = e;
|
|
9
|
-
for (let e of r) e();
|
|
1
|
+
import { o as e } from "./websocket-manager-BnK55c3U.js";
|
|
2
|
+
import { u as t } from "./comment-kit-core-VuIidMeu.js";
|
|
3
|
+
import { n } from "./errors-Bu5ajEmB.js";
|
|
4
|
+
var r = null, i = /* @__PURE__ */ new Set();
|
|
5
|
+
function a() {
|
|
6
|
+
return r;
|
|
10
7
|
}
|
|
11
8
|
function o(e) {
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
r = e;
|
|
10
|
+
for (let e of i) e();
|
|
11
|
+
}
|
|
12
|
+
function s(e) {
|
|
13
|
+
return i.add(e), () => {
|
|
14
|
+
i.delete(e);
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
for (let e of
|
|
17
|
+
function c() {
|
|
18
|
+
r = null;
|
|
19
|
+
for (let e of i) e();
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function l(e) {
|
|
21
22
|
return typeof e.requiresShortcut != "function" || !e.requiresShortcut();
|
|
22
23
|
}
|
|
23
|
-
function l(e, t) {
|
|
24
|
-
return !!(t.isLoginModalVisible || t.isShortcutsOverlayVisible || t.isSidebarVisible || t.activeTool || t.selectedComment || t.activeComment || t.activeDrawing || t.activeScreenshot || t.error || t.isAuthenticated && (c(e) || t.isOverlayVisible));
|
|
25
|
-
}
|
|
26
24
|
function u(e, t) {
|
|
25
|
+
return !!(t.isLoginModalVisible || t.isShortcutsOverlayVisible || t.isSidebarVisible || t.activeTool || t.selectedComment || t.activeComment || t.activeDrawing || t.activeScreenshot || t.error || t.isAuthenticated && (l(e) || t.isOverlayVisible));
|
|
26
|
+
}
|
|
27
|
+
function d(e, t) {
|
|
27
28
|
return !!(!e.isOverlayVisible && t.isOverlayVisible || !e.isSidebarVisible && t.isSidebarVisible || !e.isLoginModalVisible && t.isLoginModalVisible || !e.isShortcutsOverlayVisible && t.isShortcutsOverlayVisible || !e.isAuthenticated && t.isAuthenticated || t.activeTool && t.activeTool !== e.activeTool || t.selectedComment && t.selectedComment.id !== e.selectedComment?.id || !e.activeComment && t.activeComment || !e.activeDrawing && t.activeDrawing || !e.activeScreenshot && t.activeScreenshot);
|
|
28
29
|
}
|
|
29
|
-
var
|
|
30
|
-
function
|
|
30
|
+
var f = "\n:host{all:initial;position:fixed;z-index:2147483647;font-family:var(--font-brand-sans,system-ui,sans-serif);color-scheme:light dark;--ck-bg:#f7f6f2;--ck-fg:#121316;--ck-border:#d9d6cf;--ck-primary:#ff5733;--ck-on-primary:#121316}\n:host([hidden]){display:none}\n:host([data-theme=dark]){--ck-bg:#121316;--ck-fg:#f7f6f2;--ck-border:#424348}\n@media(prefers-color-scheme:dark){:host(:not([data-theme=light])){--ck-bg:#121316;--ck-fg:#f7f6f2;--ck-border:#424348}}\n*{box-sizing:border-box} .launcher{display:flex;align-items:center;gap:8px;max-width:min(360px,calc(100vw - 32px));padding:8px;border:1px solid var(--ck-border);border-radius:16px;background:var(--ck-bg);color:var(--ck-fg);box-shadow:0 4px 18px #0002;font:14px/1.4 var(--font-brand-sans,system-ui,sans-serif)}\nbutton{appearance:none;display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:40px;padding:8px 12px;border:0;border-radius:10px;background:transparent;color:inherit;font:inherit;cursor:pointer}button:focus-visible{outline:2px solid var(--ck-primary);outline-offset:2px}button:disabled{cursor:wait;opacity:.7}button[data-primary]{background:var(--ck-primary);color:var(--ck-on-primary)}svg{width:24px;height:24px;flex:none}.message{margin:0;max-width:200px} [role=alert]{font-size:13px}\n";
|
|
31
|
+
function p(e, t) {
|
|
31
32
|
let n = document.createElement("div");
|
|
32
33
|
n.setAttribute("data-commentkit-launcher", ""), n.setAttribute("data-commentkit-ui", "");
|
|
33
34
|
let r = t.config?.ui?.position ?? "bottom-right";
|
|
34
35
|
n.style.setProperty(r.startsWith("top") ? "top" : "bottom", "16px"), n.style.setProperty(r.endsWith("left") ? "left" : "right", "16px");
|
|
35
|
-
let
|
|
36
|
-
|
|
36
|
+
let i = n.attachShadow({ mode: "open" }), o = document.createElement("style");
|
|
37
|
+
o.textContent = f;
|
|
37
38
|
let c = document.createElement("div");
|
|
38
|
-
c.className = "launcher",
|
|
39
|
-
let l = document.documentElement, u = window.matchMedia("(prefers-color-scheme: dark)"),
|
|
40
|
-
let e = t.config?.ui?.theme, r = e === "dark" || e === "light" ? e : null,
|
|
41
|
-
n.dataset.theme =
|
|
39
|
+
c.className = "launcher", i.append(o, c), e.append(n);
|
|
40
|
+
let l = document.documentElement, u = window.matchMedia("(prefers-color-scheme: dark)"), d = () => {
|
|
41
|
+
let e = t.config?.ui?.theme, r = e === "dark" || e === "light" ? e : null, i = l.style.colorScheme;
|
|
42
|
+
n.dataset.theme = a() ?? r ?? (l.classList.contains("dark") ? "dark" : l.classList.contains("light") ? "light" : i === "light" || i === "dark" ? i : u.matches ? "dark" : "light");
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
-
let p = new MutationObserver(
|
|
44
|
+
d();
|
|
45
|
+
let p = new MutationObserver(d);
|
|
45
46
|
p.observe(l, {
|
|
46
47
|
attributes: !0,
|
|
47
48
|
attributeFilter: ["class", "style"]
|
|
48
|
-
}), u.addEventListener("change",
|
|
49
|
-
let m =
|
|
49
|
+
}), u.addEventListener("change", d);
|
|
50
|
+
let m = s(d), h = (e, t) => {
|
|
50
51
|
let n = document.createElement("button");
|
|
51
52
|
return n.type = "button", n.textContent = e, n.addEventListener("click", t), n;
|
|
52
53
|
};
|
|
@@ -55,7 +56,7 @@ function f(e, t) {
|
|
|
55
56
|
if (n.hidden = !r, c.replaceChildren(), r) {
|
|
56
57
|
if (e === "idle") {
|
|
57
58
|
let e = h("Comments", t.onActivate);
|
|
58
|
-
e.setAttribute("aria-label", "Open
|
|
59
|
+
e.setAttribute("aria-label", "Open Comments"), e.setAttribute("data-primary", "");
|
|
59
60
|
let n = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
60
61
|
n.setAttribute("viewBox", "0 0 64 64"), n.setAttribute("aria-hidden", "true");
|
|
61
62
|
let r = document.createElementNS(n.namespaceURI, "path");
|
|
@@ -67,127 +68,141 @@ function f(e, t) {
|
|
|
67
68
|
}
|
|
68
69
|
},
|
|
69
70
|
remove() {
|
|
70
|
-
p.disconnect(), u.removeEventListener("change",
|
|
71
|
+
p.disconnect(), u.removeEventListener("change", d), m(), n.remove();
|
|
71
72
|
}
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
|
-
var
|
|
75
|
-
function
|
|
75
|
+
var m = /* @__PURE__ */ e({ mountCommentKitUI: () => b });
|
|
76
|
+
function h(e, t) {
|
|
76
77
|
try {
|
|
77
|
-
return e[t];
|
|
78
|
+
return e?.[t];
|
|
78
79
|
} catch {
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
-
let n =
|
|
83
|
+
function g(e, t) {
|
|
84
|
+
let n = h(e, t) ?? h(h(e, "default"), t);
|
|
84
85
|
if (typeof n == "function") return n;
|
|
85
|
-
let r = m(e, "default");
|
|
86
|
-
if (r && typeof r == "object") {
|
|
87
|
-
let e = r[t];
|
|
88
|
-
if (typeof e == "function") return e;
|
|
89
|
-
}
|
|
90
86
|
throw TypeError(`React module did not provide ${t}`);
|
|
91
87
|
}
|
|
92
|
-
function
|
|
88
|
+
function _(e) {
|
|
93
89
|
let t = e;
|
|
94
90
|
if (!t || typeof t.getState != "function" || typeof t.on != "function") throw TypeError("CommentKit UI requires a valid CommentKitCore instance");
|
|
95
91
|
}
|
|
96
|
-
function
|
|
92
|
+
function v() {
|
|
97
93
|
if (typeof document > "u" || !document.body) throw Error("CommentKit UI requires a browser document body");
|
|
98
94
|
return document.body;
|
|
99
95
|
}
|
|
100
|
-
function
|
|
96
|
+
function y(e) {
|
|
101
97
|
return typeof e == "function";
|
|
102
98
|
}
|
|
103
|
-
async function
|
|
104
|
-
|
|
105
|
-
let
|
|
106
|
-
if (
|
|
107
|
-
if (
|
|
108
|
-
let
|
|
109
|
-
|
|
110
|
-
let
|
|
111
|
-
|
|
112
|
-
|
|
99
|
+
async function b(e, r = {}) {
|
|
100
|
+
_(e);
|
|
101
|
+
let i = v(), a = typeof e.getConfig == "function" ? e.getConfig() : void 0;
|
|
102
|
+
if (r.signal?.aborted || a?.enabled === !1) return { unmount() {} };
|
|
103
|
+
if (i.querySelector("[data-commentkit], [data-commentkit-host]")) return console.warn("[CommentKit] UI is already mounted on this page — skipping duplicate mount. Destroy the existing instance first if you need to remount."), { unmount() {} };
|
|
104
|
+
let o = e.getState(), s = document.createElement("div");
|
|
105
|
+
s.setAttribute("data-commentkit", ""), i.appendChild(s);
|
|
106
|
+
let c = !1, f = () => {
|
|
107
|
+
let e = t();
|
|
108
|
+
e !== c && (c = e, s.style.display = e ? "none" : "", b && S && S(o));
|
|
109
|
+
}, m = new MutationObserver(f);
|
|
110
|
+
m.observe(i, {
|
|
111
|
+
subtree: !0,
|
|
112
|
+
childList: !0,
|
|
113
|
+
attributes: !0,
|
|
114
|
+
attributeFilter: [
|
|
115
|
+
"open",
|
|
116
|
+
"role",
|
|
117
|
+
"aria-modal",
|
|
118
|
+
"hidden",
|
|
119
|
+
"class",
|
|
120
|
+
"style"
|
|
121
|
+
]
|
|
122
|
+
});
|
|
123
|
+
let h = !0, b = null, x = null, S = null, C = null, w = 0, T = !1, E = !1, D = !1, O = o, k = u(e, o), A = null;
|
|
124
|
+
f();
|
|
125
|
+
let j = () => {
|
|
126
|
+
if (!h) return;
|
|
127
|
+
h = !1, m.disconnect(), w++, r.signal?.removeEventListener("abort", j);
|
|
113
128
|
try {
|
|
114
|
-
|
|
129
|
+
x?.();
|
|
115
130
|
} catch {}
|
|
116
|
-
|
|
117
|
-
let e =
|
|
118
|
-
|
|
131
|
+
x = null;
|
|
132
|
+
let e = b;
|
|
133
|
+
b = null;
|
|
119
134
|
let t = () => {
|
|
120
135
|
try {
|
|
121
136
|
e?.unmount();
|
|
122
137
|
} catch {}
|
|
123
138
|
};
|
|
124
|
-
e &&
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
if (!
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
let
|
|
132
|
-
return
|
|
139
|
+
e && r.deferUnmount ? queueMicrotask(t) : t(), A?.remove(), A = null, s.remove();
|
|
140
|
+
}, M = () => {
|
|
141
|
+
D = !0, E = !0, T = !1, w++, C = null, o.activeTool && e.setTool(null), o.isLoginModalVisible && e.toggleLoginModal(), o.isShortcutsOverlayVisible && e.toggleShortcutsOverlay(), o.isSidebarVisible && e.toggleSidebar(), !l(e) && e.getState().isOverlayVisible && e.toggleOverlay(), O = e.getState(), k = u(e, O), D = !1, A?.render("idle", l(e));
|
|
142
|
+
}, N = () => {
|
|
143
|
+
if (!h || b) return Promise.resolve();
|
|
144
|
+
if (C) return C;
|
|
145
|
+
T = !1, E = !1;
|
|
146
|
+
let t = ++w;
|
|
147
|
+
return A?.render("loading"), C = (async () => {
|
|
133
148
|
try {
|
|
134
|
-
let [
|
|
149
|
+
let [n, r, i, l, u, d] = await Promise.all([
|
|
135
150
|
import("react"),
|
|
136
151
|
import("react-dom/client"),
|
|
137
|
-
import("./styles-
|
|
138
|
-
import("./shadow-root-
|
|
152
|
+
import("./styles-CnYsLS2f.js"),
|
|
153
|
+
import("./shadow-root-Cv1aLuFf.js"),
|
|
139
154
|
import("./error-boundary-D3PD74vI.js"),
|
|
140
|
-
import("./comment-kit-ui-
|
|
155
|
+
import("./comment-kit-ui-BjJ1ZLiv.js").then((e) => e.t)
|
|
141
156
|
]);
|
|
142
|
-
if (!
|
|
143
|
-
let
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
styles:
|
|
147
|
-
config:
|
|
148
|
-
},
|
|
157
|
+
if (!h || t !== w) return;
|
|
158
|
+
let f = g(n, "createElement"), p = g(r, "createRoot"), m = l.ShadowContainer, _ = u.ErrorBoundary;
|
|
159
|
+
A?.remove(), A = null, b = p(s), S = (t) => {
|
|
160
|
+
h && b && b.render(f(_, null, f(l.HostModalContext.Provider, { value: c }, f(m, {
|
|
161
|
+
styles: i.default,
|
|
162
|
+
config: a
|
|
163
|
+
}, f(d.CommentKitUI, {
|
|
149
164
|
core: e,
|
|
150
165
|
state: t
|
|
151
|
-
}))));
|
|
152
|
-
},
|
|
166
|
+
})))));
|
|
167
|
+
}, S(o);
|
|
153
168
|
} catch (r) {
|
|
154
|
-
if (!
|
|
169
|
+
if (!h || t !== w) return;
|
|
155
170
|
try {
|
|
156
|
-
|
|
171
|
+
b?.unmount();
|
|
157
172
|
} catch {}
|
|
158
|
-
|
|
173
|
+
b = null, S = null, T = !0, A ||= P(), A.render("error");
|
|
159
174
|
try {
|
|
160
|
-
e.emit("error",
|
|
175
|
+
e.emit("error", n(r));
|
|
161
176
|
} catch {}
|
|
162
177
|
} finally {
|
|
163
|
-
|
|
178
|
+
t === w && (C = null);
|
|
164
179
|
}
|
|
165
|
-
})(),
|
|
166
|
-
},
|
|
167
|
-
config:
|
|
180
|
+
})(), C;
|
|
181
|
+
}, P = () => p(s, {
|
|
182
|
+
config: a,
|
|
168
183
|
onActivate: () => {
|
|
169
|
-
!
|
|
184
|
+
!T && l(e) && !e.getState().isSidebarVisible && e.toggleSidebar(), N();
|
|
170
185
|
},
|
|
171
|
-
onCancel:
|
|
172
|
-
}),
|
|
173
|
-
if (!
|
|
174
|
-
if (
|
|
175
|
-
|
|
186
|
+
onCancel: M
|
|
187
|
+
}), F = (t) => {
|
|
188
|
+
if (!h || (o = t, D)) return;
|
|
189
|
+
if (b && S) {
|
|
190
|
+
S(t);
|
|
176
191
|
return;
|
|
177
192
|
}
|
|
178
|
-
let n =
|
|
179
|
-
(!n ||
|
|
180
|
-
let r = n && !
|
|
181
|
-
|
|
193
|
+
let n = u(e, t);
|
|
194
|
+
(!n || E && d(O, t)) && (E = !1), k && !n && C && (w++, C = null, A?.render("idle", l(e)));
|
|
195
|
+
let r = n && !k;
|
|
196
|
+
k = n, n && (!T || r) && !E ? N() : !C && !T && A?.render("idle", l(e));
|
|
182
197
|
};
|
|
183
198
|
try {
|
|
184
|
-
|
|
185
|
-
let t = e.on("state:changed",
|
|
186
|
-
if (!
|
|
187
|
-
|
|
199
|
+
A = P(), A.render("idle", l(e));
|
|
200
|
+
let t = e.on("state:changed", F);
|
|
201
|
+
if (!y(t)) throw TypeError("CommentKit core subscription did not return an unsubscribe function");
|
|
202
|
+
x = t, r.signal?.addEventListener("abort", j, { once: !0 }), r.signal?.aborted ? j() : k && N();
|
|
188
203
|
} catch (e) {
|
|
189
|
-
throw
|
|
204
|
+
throw j(), e;
|
|
190
205
|
}
|
|
191
|
-
return { unmount:
|
|
206
|
+
return { unmount: j };
|
|
192
207
|
}
|
|
193
|
-
export { a,
|
|
208
|
+
export { o as a, c as i, m as n, s as o, a as r, b as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e } from "./websocket-manager-
|
|
1
|
+
import { a as e } from "./websocket-manager-BnK55c3U.js";
|
|
2
2
|
var t = /* @__PURE__ */ e(((e, t) => {
|
|
3
3
|
(function(n, r) {
|
|
4
4
|
typeof e == "object" && typeof t == "object" ? t.exports = r() : typeof define == "function" && define.amd ? define([], r) : typeof e == "object" ? e.Pusher = r() : n.Pusher = r();
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./websocket-manager-BnK55c3U.js";
|
|
2
|
+
import { a as i, d as a, i as o, l as s, o as c } from "./validation-3wbbbuX0.js";
|
|
3
|
+
import { s as l } from "./comment-kit-core-VuIidMeu.js";
|
|
4
|
+
import { o as u } from "./dom-Bhf4WFtY.js";
|
|
5
|
+
import { i as d } from "./text-B4HHZNaa.js";
|
|
6
|
+
var f = l.ID, p = l.CONTENT, m = l.NAME, h = l.EMAIL, g = l.PAGE, _ = l.EMOJI, v = l.ONLINE_USERS, y = l.REACTION_COUNT, b = 33, x = 1e3, S = l.CURSOR_EMITS_PER_SEC;
|
|
7
|
+
function C(e) {
|
|
8
|
+
let t = e.config.realtime, n = t?.maxRenderedCursors;
|
|
9
|
+
return {
|
|
10
|
+
cursors: t?.cursors !== !1,
|
|
11
|
+
presence: t?.presence !== !1,
|
|
12
|
+
maxRenderedCursors: typeof n == "number" && Number.isFinite(n) && n >= 0 ? Math.min(Math.floor(n), v) : l.RENDERED_CURSORS
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
var w = /* @__PURE__ */ new Set([
|
|
16
|
+
"pin",
|
|
17
|
+
"highlight",
|
|
18
|
+
"drawing"
|
|
19
|
+
]), T = /* @__PURE__ */ new Set([
|
|
20
|
+
"open",
|
|
21
|
+
"resolved",
|
|
22
|
+
"complete"
|
|
23
|
+
]), E = /* @__PURE__ */ new Set([
|
|
24
|
+
"low",
|
|
25
|
+
"medium",
|
|
26
|
+
"high",
|
|
27
|
+
"urgent"
|
|
28
|
+
]), D = /* @__PURE__ */ new Set([
|
|
29
|
+
"path",
|
|
30
|
+
"line",
|
|
31
|
+
"rectangle",
|
|
32
|
+
"circle",
|
|
33
|
+
"text"
|
|
34
|
+
]);
|
|
35
|
+
function O(e, t) {
|
|
36
|
+
return s(e, t);
|
|
37
|
+
}
|
|
38
|
+
function k(e) {
|
|
39
|
+
return O(e, f);
|
|
40
|
+
}
|
|
41
|
+
function A(e) {
|
|
42
|
+
if (!O(e, h)) return !1;
|
|
43
|
+
let t = e.trim(), n = t.indexOf("@");
|
|
44
|
+
return n > 0 && n === t.lastIndexOf("@") && n < t.length - 1 && !/\s/.test(t);
|
|
45
|
+
}
|
|
46
|
+
function j(e) {
|
|
47
|
+
return c(e) && k(e.id) && O(e.name, m) && A(e.email) && a(e.avatar, g) && a(e.organizationId, f);
|
|
48
|
+
}
|
|
49
|
+
function M(e) {
|
|
50
|
+
return {
|
|
51
|
+
id: e.id.trim(),
|
|
52
|
+
name: e.name.trim(),
|
|
53
|
+
email: e.email.trim(),
|
|
54
|
+
...e.avatar ? { avatar: e.avatar.trim() } : {},
|
|
55
|
+
...e.organizationId ? { organizationId: e.organizationId.trim() } : {}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function N(t) {
|
|
59
|
+
if (!Array.isArray(t)) return null;
|
|
60
|
+
let n = [], r = /* @__PURE__ */ new Set();
|
|
61
|
+
for (let i of t) {
|
|
62
|
+
if (n.length >= v) break;
|
|
63
|
+
let t = e(i);
|
|
64
|
+
if (!j(t)) continue;
|
|
65
|
+
let a = M(t);
|
|
66
|
+
r.has(a.id) || (r.add(a.id), n.push(a));
|
|
67
|
+
}
|
|
68
|
+
return n;
|
|
69
|
+
}
|
|
70
|
+
function P(e) {
|
|
71
|
+
return c(e) ? i(e.x) && i(e.y) : !1;
|
|
72
|
+
}
|
|
73
|
+
function F(e) {
|
|
74
|
+
return c(e) && O(e.url, g) && O(e.path, g) && typeof e.title == "string" && a(e.title, g);
|
|
75
|
+
}
|
|
76
|
+
function I(e) {
|
|
77
|
+
return c(e) && U(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= y && typeof e.reacted == "boolean";
|
|
78
|
+
}
|
|
79
|
+
function L(e, t) {
|
|
80
|
+
if (Array.isArray(e)) return e.filter(I).map((e) => {
|
|
81
|
+
if (!Array.isArray(e.userIds)) return e;
|
|
82
|
+
let n = e.userIds.filter(k);
|
|
83
|
+
return {
|
|
84
|
+
...e,
|
|
85
|
+
userIds: n,
|
|
86
|
+
reacted: !!t && n.includes(t)
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function R(e, t) {
|
|
91
|
+
return {
|
|
92
|
+
...e,
|
|
93
|
+
replies: Array.isArray(e.replies) ? e.replies.flatMap((e) => {
|
|
94
|
+
let n = B(e, t);
|
|
95
|
+
return n ? [n] : [];
|
|
96
|
+
}) : [],
|
|
97
|
+
...e.reactions === void 0 ? {} : { reactions: L(e.reactions, t) }
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function z(e, n) {
|
|
101
|
+
return e = t(e), !c(e) || !k(e.id) || !w.has(e.type) || !O(e.content, p) || !P(e.position) || !T.has(e.status) || !E.has(e.priority) || !j(e.author) || !k(e.userId) || !O(e.createdAt, g) || !O(e.updatedAt, g) || !F(e.page) || !Array.isArray(e.replies) || !Array.isArray(e.attachments) ? null : R(structuredClone(e), n);
|
|
102
|
+
}
|
|
103
|
+
function B(e, t) {
|
|
104
|
+
if (e = n(e), !c(e) || !k(e.id) || !O(e.content, p) || !j(e.author) || !O(e.createdAt, g)) return null;
|
|
105
|
+
let r = structuredClone(e);
|
|
106
|
+
return r.reactions &&= L(r.reactions, t), r;
|
|
107
|
+
}
|
|
108
|
+
function V(t) {
|
|
109
|
+
if (!c(t)) return null;
|
|
110
|
+
let n = e(t.user);
|
|
111
|
+
return !j(n) || !o(t.x) || t.x < 0 || t.x > 100 || !o(t.y) || t.y < 0 || t.y > 100 || !O(t.page, g) ? null : {
|
|
112
|
+
x: t.x,
|
|
113
|
+
y: t.y,
|
|
114
|
+
page: t.page.trim(),
|
|
115
|
+
user: M(n)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function H(e) {
|
|
119
|
+
return c(e) ? O(e.type, l.DRAWING_TYPE) && D.has(e.type) && O(e.stroke, l.COLOR) && o(e.strokeWidth) && e.strokeWidth >= 0 && O(e.fill, l.COLOR) && a(e.d, l.DRAWING_PATH_DATA) && a(e.text, l.DRAWING_TEXT) && (e.x === void 0 || o(e.x)) && (e.y === void 0 || o(e.y)) && (e.width === void 0 || o(e.width)) && (e.height === void 0 || o(e.height)) : !1;
|
|
120
|
+
}
|
|
121
|
+
function U(e) {
|
|
122
|
+
return O(e, _);
|
|
123
|
+
}
|
|
124
|
+
function W(e) {
|
|
125
|
+
try {
|
|
126
|
+
e();
|
|
127
|
+
} catch {}
|
|
128
|
+
}
|
|
129
|
+
function G(e, t) {
|
|
130
|
+
return e.wsManager === t;
|
|
131
|
+
}
|
|
132
|
+
function K(e, t) {
|
|
133
|
+
e.setState({ comments: e.getState().comments.map((e) => e.id === t.id ? t : e) });
|
|
134
|
+
}
|
|
135
|
+
function q(t, n, i) {
|
|
136
|
+
if (t.config.features?.realtime === !1 || !t.config.reverb?.host || !t.config.reverb?.key) return;
|
|
137
|
+
if (n.wsManager) {
|
|
138
|
+
for (let e of n.wsUnsubscribers) W(e);
|
|
139
|
+
n.wsUnsubscribers = [], J(n);
|
|
140
|
+
try {
|
|
141
|
+
n.wsManager.destroy();
|
|
142
|
+
} catch {}
|
|
143
|
+
n.wsManager = null;
|
|
144
|
+
}
|
|
145
|
+
let a = t.config.baseUrl || "https://api.commentkit.dev/api", o = t.getState().currentUser, s = C(t);
|
|
146
|
+
try {
|
|
147
|
+
n.wsManager = new r({
|
|
148
|
+
key: t.config.reverb.key,
|
|
149
|
+
wsHost: t.config.reverb.host,
|
|
150
|
+
wsPort: t.config.reverb.port ?? 443,
|
|
151
|
+
forceTLS: (t.config.reverb.scheme ?? "wss") === "wss",
|
|
152
|
+
/* v8 ignore next -- projectId always provided in config */
|
|
153
|
+
projectId: t.config.projectId || "",
|
|
154
|
+
apiKey: t.config.apiKey,
|
|
155
|
+
authEndpoint: `${a}/broadcasting/auth`,
|
|
156
|
+
authorizeChannel: (e, n) => t.apiClient.authorizeChannel(e, n),
|
|
157
|
+
userEmail: o?.email,
|
|
158
|
+
userInfo: o ? {
|
|
159
|
+
id: o.id,
|
|
160
|
+
name: o.name,
|
|
161
|
+
email: o.email
|
|
162
|
+
} : void 0
|
|
163
|
+
});
|
|
164
|
+
} catch (e) {
|
|
165
|
+
t.setState({ connectionStatus: "error" }), t.handleError(e);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
let l = n.wsUnsubscribers, f = n.wsManager, p, m, h = !1, g = () => m ??= import("./realtime-recovery-BSVMwsXJ.js").then((e) => {
|
|
169
|
+
if (!h && i && G(n, f)) return p = e.createRealtimeRecovery(t, i, () => G(n, f), z), p;
|
|
170
|
+
}).catch((e) => {
|
|
171
|
+
m = void 0, h || t.handleError(e);
|
|
172
|
+
});
|
|
173
|
+
l.push(() => {
|
|
174
|
+
h = !0, p?.dispose();
|
|
175
|
+
}), l.push(f.on("subscribed", () => {
|
|
176
|
+
G(n, f) && i && g().then((e) => e?.refreshWindow());
|
|
177
|
+
})), l.push(f.on("comment:refresh", (e) => {
|
|
178
|
+
G(n, f) && i && g().then((t) => t?.refreshThread(e));
|
|
179
|
+
})), l.push(f.on("connected", () => {
|
|
180
|
+
G(n, f) && (t.setState({ connectionStatus: "connected" }), n.wsManager?.requestPresence());
|
|
181
|
+
})), l.push(f.on("disconnected", () => {
|
|
182
|
+
G(n, f) && t.setState({ connectionStatus: "disconnected" });
|
|
183
|
+
})), l.push(f.on("reconnecting", () => {
|
|
184
|
+
G(n, f) && t.setState({ connectionStatus: "connecting" });
|
|
185
|
+
})), l.push(f.on("error", () => {
|
|
186
|
+
G(n, f) && t.setState({ connectionStatus: "error" });
|
|
187
|
+
})), l.push(f.on("comment:resolved", (e) => {
|
|
188
|
+
if (!G(n, f)) return;
|
|
189
|
+
let r = z(e, t.getState().currentUser?.id);
|
|
190
|
+
r && (K(t, r), t.emit("comment:resolved", r));
|
|
191
|
+
})), l.push(f.on("comment:completed", (e) => {
|
|
192
|
+
if (!G(n, f)) return;
|
|
193
|
+
let r = z(e, t.getState().currentUser?.id);
|
|
194
|
+
r && (K(t, r), t.emit("comment:completed", r));
|
|
195
|
+
})), l.push(f.on("comment:created", (e) => {
|
|
196
|
+
if (!G(n, f)) return;
|
|
197
|
+
let r = z(e, t.getState().currentUser?.id);
|
|
198
|
+
if (!r) return;
|
|
199
|
+
let i = t.getState().activeBranch;
|
|
200
|
+
i && r.branch !== i || t.getState().comments.find((e) => e.id === r.id) || (t.setState({ comments: [...t.getState().comments, r] }), t.emit("comment:created", r));
|
|
201
|
+
})), l.push(f.on("comment:updated", (e) => {
|
|
202
|
+
if (!G(n, f)) return;
|
|
203
|
+
let r = z(e, t.getState().currentUser?.id);
|
|
204
|
+
r && (K(t, r), t.emit("comment:updated", r));
|
|
205
|
+
})), l.push(f.on("comment:deleted", (e) => {
|
|
206
|
+
if (!G(n, f) || !c(e) || !k(e.id)) return;
|
|
207
|
+
let r = e.id.trim();
|
|
208
|
+
t.setState({
|
|
209
|
+
comments: t.getState().comments.filter((e) => e.id !== r),
|
|
210
|
+
selectedComment: t.getState().selectedComment?.id === r ? null : t.getState().selectedComment
|
|
211
|
+
}), t.emit("comment:deleted", { id: r });
|
|
212
|
+
})), l.push(f.on("reply:added", (e) => {
|
|
213
|
+
if (!G(n, f) || !c(e) || !k(e.commentId)) return;
|
|
214
|
+
let r = B(e.reply, t.getState().currentUser?.id);
|
|
215
|
+
if (!r) return;
|
|
216
|
+
let i = e.commentId.trim(), a = t.getState().comments.map((e) => e.id !== i || e.replies.some((e) => e.id === r.id) ? e : {
|
|
217
|
+
...e,
|
|
218
|
+
status: "open",
|
|
219
|
+
resolvedAt: void 0,
|
|
220
|
+
completedAt: void 0,
|
|
221
|
+
replies: [...e.replies, r]
|
|
222
|
+
});
|
|
223
|
+
t.setState({ comments: a });
|
|
224
|
+
let o = a.find((e) => e.id === i);
|
|
225
|
+
o && t.emit("comment:updated", o);
|
|
226
|
+
}));
|
|
227
|
+
let _ = (e, t, n) => {
|
|
228
|
+
let r = (e ?? []).filter((e) => U(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= y), i = r.findIndex((e) => e.emoji === t);
|
|
229
|
+
if (i !== -1) {
|
|
230
|
+
let e = r[i];
|
|
231
|
+
r[i] = n ? {
|
|
232
|
+
...e,
|
|
233
|
+
reacted: !0
|
|
234
|
+
} : {
|
|
235
|
+
...e,
|
|
236
|
+
count: Math.min(e.count + 1, y),
|
|
237
|
+
reacted: e.reacted
|
|
238
|
+
};
|
|
239
|
+
} else r.push({
|
|
240
|
+
emoji: t,
|
|
241
|
+
count: 1,
|
|
242
|
+
reacted: n
|
|
243
|
+
});
|
|
244
|
+
return r;
|
|
245
|
+
}, v = (e, t, n) => (e ?? []).filter((e) => U(e.emoji) && Number.isInteger(e.count) && e.count > 0 && e.count <= y).map((e) => e.emoji === t ? {
|
|
246
|
+
...e,
|
|
247
|
+
count: n ? e.count : e.count - 1,
|
|
248
|
+
reacted: !n && e.reacted
|
|
249
|
+
} : e).filter((e) => e.count > 0), w = (e, r) => {
|
|
250
|
+
if (!G(n, f) || !c(e) || !k(e.commentId) || !U(e.emoji) || !k(e.userId)) return;
|
|
251
|
+
let a = e.commentId.trim(), o = k(e.replyId) ? e.replyId.trim() : null, s = e.emoji.trim(), l = e.userId.trim() === t.getState().currentUser?.id;
|
|
252
|
+
l && i ? g().then((e) => e?.refreshThread({
|
|
253
|
+
commentId: a,
|
|
254
|
+
event: "comment:updated"
|
|
255
|
+
})) : t.setState({ comments: t.getState().comments.map((e) => e.id === a ? o === null ? {
|
|
256
|
+
...e,
|
|
257
|
+
reactions: r(e.reactions, s, l)
|
|
258
|
+
} : {
|
|
259
|
+
...e,
|
|
260
|
+
replies: e.replies.map((e) => e.id === o ? {
|
|
261
|
+
...e,
|
|
262
|
+
reactions: r(e.reactions, s, l)
|
|
263
|
+
} : e)
|
|
264
|
+
} : e) });
|
|
265
|
+
};
|
|
266
|
+
l.push(f.on("reaction:added", (e) => w(e, _))), l.push(f.on("reaction:removed", (e) => w(e, v)));
|
|
267
|
+
let T = /* @__PURE__ */ new Map(), E = 0, D = 0;
|
|
268
|
+
l.push(f.on("cursor:move", (e) => {
|
|
269
|
+
if (!G(n, f) || !s.cursors) return;
|
|
270
|
+
let r = V(e);
|
|
271
|
+
if (!r) return;
|
|
272
|
+
let i = Date.now(), a = r.user.id, o = T.get(a);
|
|
273
|
+
if (o === void 0 && T.size >= s.maxRenderedCursors) {
|
|
274
|
+
let e, t = Infinity;
|
|
275
|
+
for (let [n, r] of T) r < t && (t = r, e = n);
|
|
276
|
+
if (e !== void 0 && i - t >= b) T.delete(e);
|
|
277
|
+
else return;
|
|
278
|
+
}
|
|
279
|
+
o !== void 0 && i - o < b || (i - E >= x && (E = i, D = 0), !(D >= S) && (D++, T.set(a, i), t.emit("cursor:move", r)));
|
|
280
|
+
})), l.push(f.on("cursor:leave", (e) => {
|
|
281
|
+
G(n, f) && c(e) && k(e.userId) && (T.delete(e.userId.trim()), t.emit("cursor:leave", { userId: e.userId.trim() }));
|
|
282
|
+
})), l.push(f.on("user:joined", (r) => {
|
|
283
|
+
let i = e(r);
|
|
284
|
+
G(n, f) && j(i) && t.emit("user:joined", M(i));
|
|
285
|
+
})), l.push(f.on("user:left", (e) => {
|
|
286
|
+
G(n, f) && c(e) && k(e.userId) && t.emit("user:left", { userId: e.userId.trim() });
|
|
287
|
+
})), l.push(f.on("presence:update", (e) => {
|
|
288
|
+
if (!G(n, f) || !s.presence || !c(e)) return;
|
|
289
|
+
let r = N(e.users);
|
|
290
|
+
if (!r) return;
|
|
291
|
+
let i = { users: r };
|
|
292
|
+
t.setState({ onlineUsers: r }), t.emit("presence:update", i);
|
|
293
|
+
})), l.push(f.on("drawing:stroke", (e) => {
|
|
294
|
+
G(n, f) && c(e) && k(e.userId) && H(e.path) && t.emit("drawing:stroke", {
|
|
295
|
+
userId: e.userId.trim(),
|
|
296
|
+
path: structuredClone(e.path)
|
|
297
|
+
});
|
|
298
|
+
}));
|
|
299
|
+
try {
|
|
300
|
+
t.setState({ connectionStatus: "connecting" });
|
|
301
|
+
let e = f.connect();
|
|
302
|
+
e && typeof e.catch == "function" && e.catch((e) => {
|
|
303
|
+
t.setState({ connectionStatus: "error" }), t.handleError(e);
|
|
304
|
+
});
|
|
305
|
+
} catch (e) {
|
|
306
|
+
t.setState({ connectionStatus: "error" }), t.handleError(e);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
/* v8 ignore next -- SSR guard unreachable in jsdom */
|
|
310
|
+
typeof document < "u" && typeof window < "u" && s.cursors && (n.mouseMoveHandler = (e) => {
|
|
311
|
+
if (t.getState().isOverlayVisible && n.wsManager?.isConnected()) {
|
|
312
|
+
if (window.innerWidth <= 0 || window.innerHeight <= 0) return;
|
|
313
|
+
let t = Math.max(0, Math.min(100, e.clientX / window.innerWidth * 100)), r = Math.max(0, Math.min(100, e.clientY / window.innerHeight * 100));
|
|
314
|
+
n.wsManager.sendCursorMove(t, r, d(u().url));
|
|
315
|
+
}
|
|
316
|
+
}, document.addEventListener("mousemove", n.mouseMoveHandler));
|
|
317
|
+
}
|
|
318
|
+
function J(e) {
|
|
319
|
+
typeof window < "u" && typeof document < "u" && e.mouseMoveHandler && (document.removeEventListener("mousemove", e.mouseMoveHandler), e.mouseMoveHandler = null);
|
|
320
|
+
}
|
|
321
|
+
export { q as initializeWebSocket, J as removeMouseMoveListener };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as e } from "./request-activity-DQrAUwfA.js";
|
|
2
2
|
function t(t, n, r, i) {
|
|
3
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
4
|
let n = t.getState();
|
|
@@ -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 };
|