@commentkit/comment-kit 0.0.0-stage → 0.6.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 +276 -0
- package/LICENSE +18 -0
- package/README.md +766 -2
- package/dist/angular/ShadowRootContext-2BrAO1qU.js +7 -0
- package/dist/angular/chunk-Cyg4N8Ue.js +11 -0
- package/dist/angular/comment-kit-ui-wEJfMh4T.js +9483 -0
- package/dist/angular/dom-ON-u4y6t.js +97 -0
- package/dist/angular/error-boundary-CxhCm8iF.js +21 -0
- package/dist/angular/limits-AEqOBweE.js +71 -0
- package/dist/angular/mount-ui-CxChSb8B.js +55 -0
- package/dist/angular/pusher-Vs-W-c8I.js +2504 -0
- package/dist/angular/realtime-CfJZMEAi.js +558 -0
- package/dist/angular/shadow-root-C7wgghDv.js +86 -0
- package/dist/angular/styles-CvndAWRF.js +2 -0
- package/dist/angular.es.js +3656 -0
- package/dist/comment-kit.es.js +3361 -0
- package/dist/core/ShadowRootContext--ArKkwbH.js +7 -0
- package/dist/core/chunk-t7YoJN_i.js +11 -0
- package/dist/core/comment-kit-ui-DjWARy4X.js +9483 -0
- package/dist/core/dom-x9svfpMk.js +223 -0
- package/dist/core/error-boundary-CN_BGsYl.js +21 -0
- package/dist/core/mount-ui-DrFjMJJu.js +55 -0
- package/dist/core/pusher-CizoY5NA.js +2504 -0
- package/dist/core/realtime-DYf6E_sN.js +278 -0
- package/dist/core/shadow-root-09zwHxly.js +86 -0
- package/dist/core/styles-D19zARBi.js +2 -0
- package/dist/core/websocket-manager-DorGPjR4.js +351 -0
- package/dist/preact/ShadowRootContext-CJWLIRy4.js +7 -0
- package/dist/preact/chunk-CZ0PdaaN.js +11 -0
- package/dist/preact/comment-kit-ui-BKi15Z4Q.js +9483 -0
- package/dist/preact/dom-BAV8grk_.js +97 -0
- package/dist/preact/error-boundary-B4-Bfy3g.js +21 -0
- package/dist/preact/limits-C3ZEKcL_.js +71 -0
- package/dist/preact/mount-ui-b9JcJQYE.js +55 -0
- package/dist/preact/pusher-BP4kCufH.js +2504 -0
- package/dist/preact/realtime-BFgP4BlB.js +558 -0
- package/dist/preact/shadow-root-DAhpHo_W.js +86 -0
- package/dist/preact/styles-Dwd4AJR8.js +2 -0
- package/dist/preact.es.js +3465 -0
- package/dist/qwik/ShadowRootContext-CTbULRKq.js +7 -0
- package/dist/qwik/chunk-CKKKzG2Q.js +11 -0
- package/dist/qwik/comment-kit-ui-CRmJhZlX.js +9483 -0
- package/dist/qwik/dom-BjJ-QroQ.js +97 -0
- package/dist/qwik/error-boundary-C4hlYQwS.js +21 -0
- package/dist/qwik/limits-DK35yjGY.js +71 -0
- package/dist/qwik/mount-ui-CaRrLb9u.js +55 -0
- package/dist/qwik/pusher-B1KgC4iB.js +2504 -0
- package/dist/qwik/realtime-DUhkZAVc.js +558 -0
- package/dist/qwik/shadow-root-tLjXys-_.js +86 -0
- package/dist/qwik/styles-BB1B91hh.js +2 -0
- package/dist/qwik.es.js +3458 -0
- package/dist/react/chunk--MHYZ-zp.js +12 -0
- package/dist/react/limits-Dflmuf1P.js +168 -0
- package/dist/react/pusher-3dki8s2l.js +2505 -0
- package/dist/react/realtime-C7h-Agwo.js +558 -0
- package/dist/react.es.js +13010 -0
- package/dist/solid/ShadowRootContext-BS6MCclL.js +7 -0
- package/dist/solid/chunk-B2NCWFvW.js +11 -0
- package/dist/solid/comment-kit-ui-Dw_67h_e.js +9483 -0
- package/dist/solid/dom-Bpw1A0oz.js +97 -0
- package/dist/solid/error-boundary-9mimpbZA.js +21 -0
- package/dist/solid/limits-B_69IbLl.js +71 -0
- package/dist/solid/mount-ui-bPWYgjmm.js +55 -0
- package/dist/solid/pusher-_RVNpj1f.js +2504 -0
- package/dist/solid/realtime-DK86zDCJ.js +558 -0
- package/dist/solid/shadow-root-D5nErAFI.js +86 -0
- package/dist/solid/styles-CtYBghRP.js +2 -0
- package/dist/solid.es.js +3446 -0
- package/dist/svelte/ShadowRootContext-DhByMr-q.js +7 -0
- package/dist/svelte/chunk-Pi70BKld.js +11 -0
- package/dist/svelte/comment-kit-ui-DhCWlEd8.js +9483 -0
- package/dist/svelte/dom-mfioQqLy.js +97 -0
- package/dist/svelte/error-boundary-C3GWI_IX.js +21 -0
- package/dist/svelte/limits-CURF22v3.js +71 -0
- package/dist/svelte/mount-ui-DtXWMEYn.js +55 -0
- package/dist/svelte/pusher-DN1BiUDw.js +2504 -0
- package/dist/svelte/realtime-zYOctwRk.js +558 -0
- package/dist/svelte/shadow-root-Cz-v-rYe.js +86 -0
- package/dist/svelte/styles-DKCGeARl.js +2 -0
- package/dist/svelte.es.js +3478 -0
- package/dist/types/adapters/bridge.d.ts +125 -0
- package/dist/types/adapters/errors.d.ts +3 -0
- package/dist/types/angular/index.d.ts +135 -0
- package/dist/types/core/agent-context.d.ts +17 -0
- package/dist/types/core/api-client.d.ts +137 -0
- package/dist/types/core/auth.d.ts +18 -0
- package/dist/types/core/comment-kit-core.d.ts +215 -0
- package/dist/types/core/comments.d.ts +43 -0
- package/dist/types/core/dev-grab.d.ts +14 -0
- package/dist/types/core/keyboard.d.ts +12 -0
- package/dist/types/core/limits.d.ts +52 -0
- package/dist/types/core/offline-queue.d.ts +23 -0
- package/dist/types/core/realtime.d.ts +9 -0
- package/dist/types/core/screenshot.d.ts +12 -0
- package/dist/types/core/session.d.ts +9 -0
- package/dist/types/core/source-resolver.d.ts +19 -0
- package/dist/types/core/state.d.ts +24 -0
- package/dist/types/core/types.d.ts +610 -0
- package/dist/types/core/websocket-manager.d.ts +107 -0
- package/dist/types/index.d.ts +85 -0
- package/dist/types/preact/index.d.ts +25 -0
- package/dist/types/qwik/index.d.ts +70 -0
- package/dist/types/react/client.d.ts +31 -0
- package/dist/types/react/comment-kit-ui.d.ts +9 -0
- package/dist/types/react/components/comment-fab.d.ts +34 -0
- package/dist/types/react/components/dev-export-panel.d.ts +10 -0
- package/dist/types/react/components/element-selector.d.ts +11 -0
- package/dist/types/react/components/live-region.d.ts +16 -0
- package/dist/types/react/components/screenshot-capture.d.ts +17 -0
- package/dist/types/react/components/status-indicator.d.ts +43 -0
- package/dist/types/react/error-boundary.d.ts +25 -0
- package/dist/types/react/index.d.ts +4 -0
- package/dist/types/react/is-local-host.d.ts +2 -0
- package/dist/types/react/mount-ui.d.ts +19 -0
- package/dist/types/react/shadow-root.d.ts +23 -0
- package/dist/types/react/shims/use-sync-external-store-with-selector.d.ts +4 -0
- package/dist/types/react/shims/use-sync-external-store.d.ts +1 -0
- package/dist/types/react/ui/lib/ShadowRootContext.d.ts +10 -0
- package/dist/types/react/ui/lib/cn.d.ts +12 -0
- package/dist/types/react/ui/primitives/alert-dialog/alert-dialog.d.ts +23 -0
- package/dist/types/react/ui/primitives/alert-dialog/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/avatar/avatar.d.ts +10 -0
- package/dist/types/react/ui/primitives/avatar/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/badge/badge.d.ts +5 -0
- package/dist/types/react/ui/primitives/badge/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/button/button.d.ts +6 -0
- package/dist/types/react/ui/primitives/button/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/card/card.d.ts +11 -0
- package/dist/types/react/ui/primitives/card/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/checkbox/checkbox.d.ts +3 -0
- package/dist/types/react/ui/primitives/checkbox/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/dialog/dialog.d.ts +17 -0
- package/dist/types/react/ui/primitives/dialog/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/dropdown-menu/dropdown-menu.d.ts +29 -0
- package/dist/types/react/ui/primitives/dropdown-menu/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/empty/empty.d.ts +10 -0
- package/dist/types/react/ui/primitives/empty/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/field/field.d.ts +22 -0
- package/dist/types/react/ui/primitives/field/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/hover-card/hover-card.d.ts +6 -0
- package/dist/types/react/ui/primitives/hover-card/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/input/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/input/input.d.ts +3 -0
- package/dist/types/react/ui/primitives/input-group/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/input-group/input-group.d.ts +16 -0
- package/dist/types/react/ui/primitives/kbd/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/kbd/kbd.d.ts +4 -0
- package/dist/types/react/ui/primitives/label/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/label/label.d.ts +3 -0
- package/dist/types/react/ui/primitives/native-select/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/native-select/native-select.d.ts +7 -0
- package/dist/types/react/ui/primitives/popover/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/popover/popover.d.ts +9 -0
- package/dist/types/react/ui/primitives/preview/component-preview.d.ts +8 -0
- package/dist/types/react/ui/primitives/progress/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/progress/progress.d.ts +7 -0
- package/dist/types/react/ui/primitives/radio-group/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/radio-group/radio-group.d.ts +6 -0
- package/dist/types/react/ui/primitives/scroll-area/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/scroll-area/scroll-area.d.ts +6 -0
- package/dist/types/react/ui/primitives/select/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/select/select.d.ts +15 -0
- package/dist/types/react/ui/primitives/separator/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/separator/separator.d.ts +3 -0
- package/dist/types/react/ui/primitives/sheet/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/sheet/sheet.d.ts +14 -0
- package/dist/types/react/ui/primitives/skeleton/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/skeleton/skeleton.d.ts +3 -0
- package/dist/types/react/ui/primitives/slider/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/slider/slider.d.ts +7 -0
- package/dist/types/react/ui/primitives/sonner/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/sonner/sonner.d.ts +4 -0
- package/dist/types/react/ui/primitives/spinner/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/spinner/spinner.d.ts +3 -0
- package/dist/types/react/ui/primitives/switch/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/switch/switch.d.ts +5 -0
- package/dist/types/react/ui/primitives/tabs/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/tabs/tabs.d.ts +8 -0
- package/dist/types/react/ui/primitives/textarea/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/textarea/textarea.d.ts +3 -0
- package/dist/types/react/ui/primitives/toggle/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/toggle/toggle.d.ts +7 -0
- package/dist/types/react/ui/primitives/toggle-group/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/toggle-group/toggle-group.d.ts +14 -0
- package/dist/types/react/ui/primitives/tooltip/index.d.ts +1 -0
- package/dist/types/react/ui/primitives/tooltip/tooltip.d.ts +7 -0
- package/dist/types/solid/index.d.ts +37 -0
- package/dist/types/svelte/index.d.ts +55 -0
- package/dist/types/utils/dom.d.ts +59 -0
- package/dist/types/utils/event-emitter.d.ts +11 -0
- package/dist/types/utils/freeze-animations.d.ts +8 -0
- package/dist/types/utils/text.d.ts +9 -0
- package/dist/types/utils/validation.d.ts +10 -0
- package/dist/types/vue/index.d.ts +87 -0
- package/dist/vue/ShadowRootContext-BQTcHNil.js +7 -0
- package/dist/vue/chunk-DHrubWSL.js +11 -0
- package/dist/vue/comment-kit-ui-BX1wDZ2c.js +9483 -0
- package/dist/vue/dom-eo0P9Z6Z.js +97 -0
- package/dist/vue/error-boundary-DW6uGR8U.js +21 -0
- package/dist/vue/limits-B6csdQeI.js +71 -0
- package/dist/vue/mount-ui-DdTYzv6J.js +55 -0
- package/dist/vue/pusher-cmjNbW6a.js +2504 -0
- package/dist/vue/realtime-YJKvS2eB.js +558 -0
- package/dist/vue/shadow-root-SLTVf5yk.js +86 -0
- package/dist/vue/styles-BrHt1-ia.js +2 -0
- package/dist/vue.es.js +3495 -0
- package/package.json +205 -4
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { n as e } from "./chunk-t7YoJN_i.js";
|
|
2
|
+
function t(e) {
|
|
3
|
+
for (let t = 0; t < e.length; t++) {
|
|
4
|
+
let n = e.charCodeAt(t);
|
|
5
|
+
if (n < 32 || n === 127) return !0;
|
|
6
|
+
}
|
|
7
|
+
return !1;
|
|
8
|
+
}
|
|
9
|
+
function n(e) {
|
|
10
|
+
for (let t = 0; t < e.length; t++) {
|
|
11
|
+
let n = e.charCodeAt(t);
|
|
12
|
+
if (n < 32 && n !== 9 && n !== 10 && n !== 13 || n === 127) return !0;
|
|
13
|
+
}
|
|
14
|
+
return !1;
|
|
15
|
+
}
|
|
16
|
+
function r(e) {
|
|
17
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
18
|
+
}
|
|
19
|
+
function i(e) {
|
|
20
|
+
return typeof e == "number" && Number.isFinite(e);
|
|
21
|
+
}
|
|
22
|
+
function a(e) {
|
|
23
|
+
return i(e) && e >= 0 && e <= 100;
|
|
24
|
+
}
|
|
25
|
+
function o(e, n) {
|
|
26
|
+
return typeof e == "string" && e.trim().length > 0 && e.length <= n && !t(e);
|
|
27
|
+
}
|
|
28
|
+
function s(e, n) {
|
|
29
|
+
return e === void 0 || typeof e == "string" && e.length <= n && !t(e);
|
|
30
|
+
}
|
|
31
|
+
function c(e, t) {
|
|
32
|
+
return typeof e == "string" && e.trim().length > 0 && e.length <= t && !n(e);
|
|
33
|
+
}
|
|
34
|
+
function l(e, t = 254) {
|
|
35
|
+
if (!o(e, t)) return !1;
|
|
36
|
+
let n = e.trim();
|
|
37
|
+
if (n !== e) return !1;
|
|
38
|
+
let r = n.indexOf("@");
|
|
39
|
+
return r > 0 && r === n.lastIndexOf("@") && r < n.length - 1 && !/\s/.test(n);
|
|
40
|
+
}
|
|
41
|
+
var u = new Set(/* @__PURE__ */ "exe.dll.bat.cmd.com.msi.scr.pif.cpl.sh.bash.zsh.ps1.py.rb.pl.php.jar.js.mjs.cjs.html.htm.xhtml.svg.swf.wasm".split("."));
|
|
42
|
+
function d(e) {
|
|
43
|
+
let t = e.lastIndexOf("."), n = t >= 0 ? e.slice(t + 1).toLowerCase() : "";
|
|
44
|
+
return u.has(n);
|
|
45
|
+
}
|
|
46
|
+
var f = Object.freeze({
|
|
47
|
+
ID: 256,
|
|
48
|
+
CONTENT: 1e4,
|
|
49
|
+
REPLY_CONTENT: 5e3,
|
|
50
|
+
NAME: 500,
|
|
51
|
+
EMAIL: 254,
|
|
52
|
+
PAGE: 2e3,
|
|
53
|
+
SELECTOR: 2048,
|
|
54
|
+
EMOJI: 32,
|
|
55
|
+
COLOR: 128,
|
|
56
|
+
DRAWING_PATH_DATA: 5e4,
|
|
57
|
+
DRAWING_TEXT: 5e3,
|
|
58
|
+
DRAWING_TYPE: 20,
|
|
59
|
+
DRAWING_PATHS: 1e3,
|
|
60
|
+
TEXT_SELECTION: 2e4,
|
|
61
|
+
DESCRIPTION: 1e4,
|
|
62
|
+
ASSIGNEES: 100,
|
|
63
|
+
CHECKLIST_ITEMS: 100,
|
|
64
|
+
CHECKLIST_LABEL: 500,
|
|
65
|
+
ONLINE_USERS: 500,
|
|
66
|
+
RENDERED_CURSORS: 24,
|
|
67
|
+
CURSOR_EMITS_PER_SEC: 240,
|
|
68
|
+
REACTION_COUNT: 1e6,
|
|
69
|
+
PENDING_MUTATIONS: 1e3,
|
|
70
|
+
RETRY_DELAY: 3e4
|
|
71
|
+
}), p = null;
|
|
72
|
+
function m() {
|
|
73
|
+
return p ||= import("./pusher-CizoY5NA.js").then((t) => /* @__PURE__ */ e(t.default, 1)).then((e) => e.default ?? e), p;
|
|
74
|
+
}
|
|
75
|
+
var h = f.ID, g = f.NAME, _ = f.EMAIL, v = f.PAGE, y = f.COLOR, b = f.DRAWING_PATH_DATA, x = f.DRAWING_TEXT, S = f.ONLINE_USERS, C = {
|
|
76
|
+
id: "unknown",
|
|
77
|
+
name: "Unknown",
|
|
78
|
+
email: "unknown@example.invalid"
|
|
79
|
+
}, w = new Set([
|
|
80
|
+
"client-cursor_move",
|
|
81
|
+
"client-cursor_leave",
|
|
82
|
+
"client-drawing_stroke"
|
|
83
|
+
]), T = new Set([
|
|
84
|
+
"path",
|
|
85
|
+
"line",
|
|
86
|
+
"rectangle",
|
|
87
|
+
"circle",
|
|
88
|
+
"text"
|
|
89
|
+
]);
|
|
90
|
+
function E(e) {
|
|
91
|
+
return o(e, h);
|
|
92
|
+
}
|
|
93
|
+
function D(e) {
|
|
94
|
+
return r(e) ? E(e.id) && o(e.name, g) && l(e.email) && s(e.avatar, v) : !1;
|
|
95
|
+
}
|
|
96
|
+
function O(e) {
|
|
97
|
+
return r(e) ? E(e.id) && c(e.content, f.CONTENT) && E(e.userId) && r(e.position) && i(e.position.x) && i(e.position.y) && D(e.author) : !1;
|
|
98
|
+
}
|
|
99
|
+
function k(e) {
|
|
100
|
+
return r(e) ? E(e.id) && c(e.content, f.CONTENT) && D(e.author) : !1;
|
|
101
|
+
}
|
|
102
|
+
function A(e) {
|
|
103
|
+
return r(e) ? i(e.x) && e.x >= 0 && e.x <= 100 && i(e.y) && e.y >= 0 && e.y <= 100 && o(e.page, v) : !1;
|
|
104
|
+
}
|
|
105
|
+
function j(e) {
|
|
106
|
+
return !r(e) || !o(e.type, 20) || !T.has(e.type) || !o(e.stroke, y) || !i(e.strokeWidth) || e.strokeWidth <= 0 || e.strokeWidth > 100 || !o(e.fill, y) ? !1 : s(e.d, b) && s(e.text, x) && (e.x === void 0 || i(e.x)) && (e.y === void 0 || i(e.y)) && (e.width === void 0 || i(e.width)) && (e.height === void 0 || i(e.height));
|
|
107
|
+
}
|
|
108
|
+
function M(e) {
|
|
109
|
+
return {
|
|
110
|
+
id: e.id.slice(0, h),
|
|
111
|
+
name: e.name.slice(0, g),
|
|
112
|
+
email: e.email.slice(0, _),
|
|
113
|
+
...e.avatar ? { avatar: e.avatar.slice(0, v) } : {},
|
|
114
|
+
...e.organizationId ? { organizationId: e.organizationId.slice(0, h) } : {}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function N(e) {
|
|
118
|
+
return o(e, v) ? e : "";
|
|
119
|
+
}
|
|
120
|
+
function P(e) {
|
|
121
|
+
let t = e.toLowerCase().replace(/^\[|\]$/g, "");
|
|
122
|
+
return t === "localhost" || t === "127.0.0.1" || t === "::1";
|
|
123
|
+
}
|
|
124
|
+
function F(e) {
|
|
125
|
+
return o(e, 253) && (e === "localhost" || /^[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?$/.test(e));
|
|
126
|
+
}
|
|
127
|
+
function I() {
|
|
128
|
+
return { ...C };
|
|
129
|
+
}
|
|
130
|
+
function L(e) {
|
|
131
|
+
let t = String(e.projectId).trim();
|
|
132
|
+
if (!E(t) || !/^[\w.-]+$/.test(t)) throw Error("Invalid WebSocket projectId");
|
|
133
|
+
let n;
|
|
134
|
+
try {
|
|
135
|
+
n = new URL(e.authEndpoint);
|
|
136
|
+
} catch {
|
|
137
|
+
throw Error("Invalid WebSocket auth endpoint");
|
|
138
|
+
}
|
|
139
|
+
if (n.protocol !== "https:" && !(n.protocol === "http:" && P(n.hostname))) throw Error("Invalid WebSocket auth endpoint");
|
|
140
|
+
if (!o(e.key, 256)) throw Error("Invalid WebSocket key");
|
|
141
|
+
if (!F(e.wsHost)) throw Error("Invalid WebSocket host");
|
|
142
|
+
if (!o(e.apiKey, 512)) throw Error("Invalid WebSocket API key");
|
|
143
|
+
if (e.userEmail && !l(e.userEmail)) throw Error("Invalid WebSocket user email");
|
|
144
|
+
if (e.userInfo && !D(e.userInfo)) throw Error("Invalid WebSocket user info");
|
|
145
|
+
return {
|
|
146
|
+
...e,
|
|
147
|
+
projectId: t,
|
|
148
|
+
authEndpoint: n.toString(),
|
|
149
|
+
userInfo: e.userInfo ? M(e.userInfo) : void 0
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
var R = class e {
|
|
153
|
+
static {
|
|
154
|
+
this.MAX_LISTENERS_PER_EVENT = 100;
|
|
155
|
+
}
|
|
156
|
+
constructor(e) {
|
|
157
|
+
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 = L(e);
|
|
158
|
+
}
|
|
159
|
+
on(t, n) {
|
|
160
|
+
let r = this.listeners.get(t);
|
|
161
|
+
return r || (r = /* @__PURE__ */ new Set(), this.listeners.set(t, r)), r.size >= e.MAX_LISTENERS_PER_EVENT && console.warn(`[CommentKit WS] Max listeners (${e.MAX_LISTENERS_PER_EVENT}) reached for '${t}' — possible memory leak`), r.add(n), () => {
|
|
162
|
+
let e = this.listeners.get(t);
|
|
163
|
+
e?.delete(n), e?.size === 0 && this.listeners.delete(t);
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
emit(e, t) {
|
|
167
|
+
let n = this.listeners.get(e);
|
|
168
|
+
if (n) for (let r of Array.from(n)) try {
|
|
169
|
+
r(t);
|
|
170
|
+
} catch (t) {
|
|
171
|
+
console.error(`[CommentKit WS] Error in '${e}' listener:`, t);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async connect() {
|
|
175
|
+
if (!(this.pusher || this.destroyed)) return this.connecting ||= this.openConnection().finally(() => {
|
|
176
|
+
this.connecting = null;
|
|
177
|
+
}), this.connecting;
|
|
178
|
+
}
|
|
179
|
+
async openConnection() {
|
|
180
|
+
if (this.pusher || this.destroyed) return;
|
|
181
|
+
let e = await m();
|
|
182
|
+
if (this.destroyed) return;
|
|
183
|
+
let t = { "X-API-Key": this.config.apiKey };
|
|
184
|
+
this.config.userEmail && (t["X-User-Email"] = this.config.userEmail), this.pusher = new e(this.config.key, {
|
|
185
|
+
cluster: "",
|
|
186
|
+
wsHost: this.config.wsHost,
|
|
187
|
+
wsPort: this.config.wsPort ?? 443,
|
|
188
|
+
wssPort: this.config.wsPort ?? 443,
|
|
189
|
+
forceTLS: this.config.forceTLS ?? !0,
|
|
190
|
+
enabledTransports: this.config.forceTLS === !1 ? ["ws", "wss"] : ["wss"],
|
|
191
|
+
disableStats: !0,
|
|
192
|
+
channelAuthorization: {
|
|
193
|
+
transport: "ajax",
|
|
194
|
+
endpoint: this.config.authEndpoint,
|
|
195
|
+
headers: t,
|
|
196
|
+
params: this.config.userInfo ? {
|
|
197
|
+
user_id: this.config.userInfo.id,
|
|
198
|
+
user_name: this.config.userInfo.name,
|
|
199
|
+
user_email: this.config.userInfo.email
|
|
200
|
+
} : {}
|
|
201
|
+
}
|
|
202
|
+
}), this.pusher.connection.bind("connected", () => {
|
|
203
|
+
this.reconnectAttempts = 0, this.emit("connected", void 0);
|
|
204
|
+
}), this.pusher.connection.bind("disconnected", () => {
|
|
205
|
+
this.emit("disconnected", {
|
|
206
|
+
code: 1e3,
|
|
207
|
+
reason: "Disconnected"
|
|
208
|
+
});
|
|
209
|
+
}), this.pusher.connection.bind("connecting", () => {
|
|
210
|
+
this.reconnectAttempts > 0 && this.emit("reconnecting", {
|
|
211
|
+
attempt: this.reconnectAttempts,
|
|
212
|
+
maxAttempts: 5
|
|
213
|
+
});
|
|
214
|
+
}), this.pusher.connection.bind("unavailable", () => {
|
|
215
|
+
this.reconnectAttempts++, this.emit("error", /* @__PURE__ */ Error("WebSocket connection unavailable"));
|
|
216
|
+
}), this.pusher.connection.bind("failed", () => {
|
|
217
|
+
this.emit("error", /* @__PURE__ */ Error("WebSocket connection failed"));
|
|
218
|
+
}), this.subscribeToChannel();
|
|
219
|
+
}
|
|
220
|
+
disconnect() {
|
|
221
|
+
this.presenceChannel &&= (this.pusher?.unsubscribe(`presence-project.${this.config.projectId}`), null), this.pusher &&= (this.pusher.disconnect(), null), this.onlineUsers.clear();
|
|
222
|
+
}
|
|
223
|
+
isConnected() {
|
|
224
|
+
return this.pusher?.connection.state === "connected";
|
|
225
|
+
}
|
|
226
|
+
getOnlineUsers() {
|
|
227
|
+
return Array.from(this.onlineUsers.values());
|
|
228
|
+
}
|
|
229
|
+
subscribeToChannel() {
|
|
230
|
+
if (!this.pusher) return;
|
|
231
|
+
let e = `presence-project.${this.config.projectId}`;
|
|
232
|
+
this.presenceChannel = this.pusher.subscribe(e), this.presenceChannel.bind("pusher:subscription_succeeded", (e) => {
|
|
233
|
+
this.onlineUsers.clear(), e.each((e) => {
|
|
234
|
+
if (this.onlineUsers.size >= S) return;
|
|
235
|
+
let t = this.memberToUser(e);
|
|
236
|
+
t && this.onlineUsers.set(t.id, t);
|
|
237
|
+
}), this.emit("presence:update", { users: this.getOnlineUsers() });
|
|
238
|
+
}), this.presenceChannel.bind("pusher:member_added", (e) => {
|
|
239
|
+
let t = this.memberToUser(e);
|
|
240
|
+
if (t) {
|
|
241
|
+
if (!this.onlineUsers.has(t.id) && this.onlineUsers.size >= S) return;
|
|
242
|
+
this.onlineUsers.set(t.id, t), this.emit("user:joined", t), this.emit("presence:update", { users: this.getOnlineUsers() });
|
|
243
|
+
}
|
|
244
|
+
}), this.presenceChannel.bind("pusher:member_removed", (e) => {
|
|
245
|
+
if (!E(e.id)) return;
|
|
246
|
+
let t = e.id;
|
|
247
|
+
this.onlineUsers.delete(t), this.emit("user:left", { userId: t }), this.emit("presence:update", { users: this.getOnlineUsers() });
|
|
248
|
+
}), this.presenceChannel.bind("pusher:subscription_error", (e) => {
|
|
249
|
+
console.error("[CommentKit WS] Channel subscription error:", e);
|
|
250
|
+
let t = o(e.type, 80) ? e.type : "unknown";
|
|
251
|
+
this.emit("error", /* @__PURE__ */ Error(`Channel subscription failed: ${t}`));
|
|
252
|
+
});
|
|
253
|
+
let t = (e, t) => {
|
|
254
|
+
this.presenceChannel?.bind(e, t), this.presenceChannel?.bind(`.${e}`, t);
|
|
255
|
+
};
|
|
256
|
+
t("comment_created", (e) => {
|
|
257
|
+
O(e) && this.emit("comment:created", e);
|
|
258
|
+
}), t("comment_updated", (e) => {
|
|
259
|
+
O(e) && this.emit("comment:updated", e);
|
|
260
|
+
}), t("comment_deleted", (e) => {
|
|
261
|
+
let t = e;
|
|
262
|
+
r(t) && E(t.id) && this.emit("comment:deleted", { id: t.id });
|
|
263
|
+
}), t("comment_resolved", (e) => {
|
|
264
|
+
O(e) && this.emit("comment:resolved", e);
|
|
265
|
+
}), t("comment_completed", (e) => {
|
|
266
|
+
O(e) && this.emit("comment:completed", e);
|
|
267
|
+
}), t("reply_added", (e) => {
|
|
268
|
+
let t = e;
|
|
269
|
+
r(t) && E(t.commentId) && k(t.reply) && this.emit("reply:added", {
|
|
270
|
+
commentId: t.commentId,
|
|
271
|
+
reply: t.reply
|
|
272
|
+
});
|
|
273
|
+
}), t("reaction_added", (e) => {
|
|
274
|
+
let t = e;
|
|
275
|
+
r(t) && E(t.commentId) && o(t.emoji, 32) && E(t.userId) && this.emit("reaction:added", {
|
|
276
|
+
commentId: t.commentId,
|
|
277
|
+
...E(t.replyId) ? { replyId: t.replyId } : {},
|
|
278
|
+
emoji: t.emoji,
|
|
279
|
+
userId: t.userId
|
|
280
|
+
});
|
|
281
|
+
}), t("reaction_removed", (e) => {
|
|
282
|
+
let t = e;
|
|
283
|
+
r(t) && E(t.commentId) && o(t.emoji, 32) && E(t.userId) && this.emit("reaction:removed", {
|
|
284
|
+
commentId: t.commentId,
|
|
285
|
+
...E(t.replyId) ? { replyId: t.replyId } : {},
|
|
286
|
+
emoji: t.emoji,
|
|
287
|
+
userId: t.userId
|
|
288
|
+
});
|
|
289
|
+
}), this.presenceChannel.bind("client-cursor_move", (e) => {
|
|
290
|
+
if (A(e)) {
|
|
291
|
+
let t = e, n = D(t.user) ? t.user : I();
|
|
292
|
+
this.emit("cursor:move", {
|
|
293
|
+
...e,
|
|
294
|
+
user: n
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}), this.presenceChannel.bind("client-cursor_leave", (e) => {
|
|
298
|
+
let t = e;
|
|
299
|
+
r(t) && E(t.userId) && this.emit("cursor:leave", { userId: t.userId });
|
|
300
|
+
}), this.presenceChannel.bind("client-drawing_stroke", (e) => {
|
|
301
|
+
let t = e;
|
|
302
|
+
r(t) && E(t.userId) && j(t.path) && this.emit("drawing:stroke", {
|
|
303
|
+
userId: t.userId,
|
|
304
|
+
path: t.path
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
memberToUser(e) {
|
|
309
|
+
if (!E(e.id)) return null;
|
|
310
|
+
let t = e.info;
|
|
311
|
+
if (!t) return null;
|
|
312
|
+
let n = t.email == null || t.email === "" ? `${String(e.id)}@presence.invalid` : t.email, r = {
|
|
313
|
+
id: String(e.id),
|
|
314
|
+
name: t.name || "Anonymous",
|
|
315
|
+
email: n,
|
|
316
|
+
avatar: t.avatar
|
|
317
|
+
};
|
|
318
|
+
return D(r) ? M(r) : null;
|
|
319
|
+
}
|
|
320
|
+
sendCursorMove(e, t, n) {
|
|
321
|
+
if (!Number.isFinite(e) || !Number.isFinite(t)) return;
|
|
322
|
+
let r = N(n);
|
|
323
|
+
if (!r) return;
|
|
324
|
+
let i = Math.max(0, Math.min(100, e)), a = Math.max(0, Math.min(100, t)), o = Date.now();
|
|
325
|
+
o - this.lastCursorUpdate < this.cursorThrottle || (this.lastCursorUpdate = o, this.triggerClientEvent("client-cursor_move", {
|
|
326
|
+
x: i,
|
|
327
|
+
y: a,
|
|
328
|
+
page: r,
|
|
329
|
+
user: this.config.userInfo || I()
|
|
330
|
+
}));
|
|
331
|
+
}
|
|
332
|
+
sendCursorLeave() {
|
|
333
|
+
this.triggerClientEvent("client-cursor_leave", { userId: this.config.userInfo?.id || "unknown" });
|
|
334
|
+
}
|
|
335
|
+
sendDrawingStroke(e) {
|
|
336
|
+
j(e) && this.triggerClientEvent("client-drawing_stroke", {
|
|
337
|
+
userId: this.config.userInfo?.id || "unknown",
|
|
338
|
+
path: e
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
requestPresence() {}
|
|
342
|
+
triggerClientEvent(e, t) {
|
|
343
|
+
if (w.has(e) && this.presenceChannel) try {
|
|
344
|
+
this.presenceChannel.trigger(e, t);
|
|
345
|
+
} catch {}
|
|
346
|
+
}
|
|
347
|
+
destroy() {
|
|
348
|
+
this.destroyed = !0, this.disconnect(), this.listeners.clear();
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
export { n as a, r as c, o as d, l as f, t as i, c as l, f as n, i as o, d as r, a as s, R as t, s as u };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext as e, useContext as t } from "react";
|
|
2
|
+
var n = e(null), r = !1;
|
|
3
|
+
function i() {
|
|
4
|
+
let e = t(n);
|
|
5
|
+
return e === null && !r && typeof process < "u" && process.env.NODE_ENV !== "production" && (r = !0, console.warn("[CommentKit] useShadowRoot() returned null — a portal primitive (Popover/Dialog/Select/etc.) is rendering outside <ShadowRootContext.Provider>. Portalled content will fall back to document.body, where ck-* styles are not present.")), e;
|
|
6
|
+
}
|
|
7
|
+
export { i as n, n as t };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
|
|
2
|
+
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
3
|
+
get: ((e) => i[e]).bind(null, d),
|
|
4
|
+
enumerable: !(s = n(i, d)) || s.enumerable
|
|
5
|
+
});
|
|
6
|
+
return e;
|
|
7
|
+
}, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
|
|
8
|
+
value: n,
|
|
9
|
+
enumerable: !0
|
|
10
|
+
}) : a, n));
|
|
11
|
+
export { c as n, o as t };
|