@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.
Files changed (56) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +10 -6
  3. package/SECURITY.md +14 -6
  4. package/dist/angular.es.js +2 -2
  5. package/dist/comment-kit.es.js +5 -5
  6. package/dist/demo.es.js +36 -34
  7. package/dist/headless.es.js +3 -3
  8. package/dist/preact.es.js +2 -2
  9. package/dist/qwik.qwik.mjs +2 -2
  10. package/dist/react.es.js +2 -2
  11. package/dist/shared/{ShadowRootContext-Bv-4aElu.js → ShadowRootContext-CjciYxVN.js} +4 -4
  12. package/dist/shared/annotation-toolbar-CZI1KVdW.js +1094 -0
  13. package/dist/shared/attachment-refresh-mQw-L7hB.js +94 -0
  14. package/dist/shared/{button-group-Cl9CrvvU.js → button-group-C285iSkZ.js} +14 -16
  15. package/dist/shared/capture-colors-CxSLsU5-.js +74 -0
  16. package/dist/shared/capture-privacy-DUROnio5.js +77 -0
  17. package/dist/shared/{comment-drawing-canvas-Dzb5YoFw.js → comment-drawing-canvas-CYFFKgCm.js} +2 -2
  18. package/dist/shared/{comment-utils-BycYTSxA.js → comment-icon-4SQd3nlz.js} +30 -24
  19. package/dist/shared/comment-image-lightbox-DmTNxuqX.js +190 -0
  20. package/dist/shared/comment-images-content-BX4DQ9Ol.js +214 -0
  21. package/dist/shared/{comment-kit-core-BaSuMzp9.js → comment-kit-core-VuIidMeu.js} +1096 -793
  22. package/dist/shared/{comment-kit-ui-CzfdAZs2.js → comment-kit-ui-BjJ1ZLiv.js} +6091 -6486
  23. package/dist/shared/{comment-screenshot-annotator-C7X-_bm6.js → comment-screenshot-annotator-CMOG1md7.js} +5 -5
  24. package/dist/shared/{comment-screenshot-overlay-wIrZrcRy.js → comment-screenshot-overlay-iWW-V-Iw.js} +114 -118
  25. package/dist/shared/comment-shortcut-groups-CfEmkitU.js +153 -0
  26. package/dist/shared/{dev-export-panel-FwFVdady.js → dev-export-panel-CrRENbMn.js} +9 -10
  27. package/dist/shared/dev-grab-Ca4MlS2Y.js +196 -0
  28. package/dist/shared/{element-selector-BhJm-NSs.js → element-selector-g1bTvdEA.js} +450 -408
  29. package/dist/shared/{mount-ui--ijs8pWT.js → mount-ui-Dz5QLq4W.js} +121 -106
  30. package/dist/shared/{pusher-ipHMJnO_.js → pusher-ue0D83de.js} +1 -1
  31. package/dist/shared/realtime-CieWAnsW.js +321 -0
  32. package/dist/shared/realtime-recovery-BSVMwsXJ.js +135 -0
  33. package/dist/shared/request-activity-DQrAUwfA.js +11 -0
  34. package/dist/shared/{separator-XDBsaWyw.js → separator-aphZiRoJ.js} +1 -1
  35. package/dist/shared/{shadow-root-C5v-T8lQ.js → shadow-root-Cv1aLuFf.js} +31 -31
  36. package/dist/shared/{styles-D3yMtaec.js → styles-CnYsLS2f.js} +1 -1
  37. package/dist/shared/text-B4HHZNaa.js +23 -0
  38. package/dist/shared/token-session-CPQpt3-u.js +25 -0
  39. package/dist/shared/useRender-D1z_X_BY.js +5 -0
  40. package/dist/shared/{validation-C7QG8j7Z.js → validation-3wbbbuX0.js} +26 -1
  41. package/dist/shared/websocket-manager-BnK55c3U.js +381 -0
  42. package/dist/solid.es.js +2 -2
  43. package/dist/svelte.es.js +2 -2
  44. package/dist/types/core/api-client.d.ts +11 -2
  45. package/dist/types/core/comment-kit-core.d.ts +11 -5
  46. package/dist/types/core/types.d.ts +54 -2
  47. package/dist/types/core/websocket-manager.d.ts +13 -0
  48. package/dist/types/core/write-access.d.ts +9 -0
  49. package/dist/vue.es.js +2 -2
  50. package/docs/api-reference.md +25 -4
  51. package/package.json +3 -2
  52. package/dist/shared/annotation-toolbar-B9SxYqoF.js +0 -1093
  53. package/dist/shared/comment-image-lightbox-BPYJT1sB.js +0 -183
  54. package/dist/shared/dev-grab-DDqg0LQf.js +0 -203
  55. package/dist/shared/realtime-Dk41VwKg.js +0 -302
  56. package/dist/shared/websocket-manager-DhLWh3Jr.js +0 -302
@@ -1,183 +0,0 @@
1
- import { n as e } from "./dist-De294MVF.js";
2
- import { s as t, t as n } from "./button-By0hGrJK.js";
3
- import { i as r, o as i, r as a } from "./separator-XDBsaWyw.js";
4
- import { r as o } from "./comment-utils-BycYTSxA.js";
5
- import { t as s } from "./button-group-Cl9CrvvU.js";
6
- import { d as c, f as l, u } from "./comment-kit-ui-CzfdAZs2.js";
7
- import * as d from "react";
8
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
9
- var h = ".ck-dialog-content.ck-image-lightbox{width:100vw;max-width:none;height:100dvh;max-height:none;box-shadow:none;background-color:#0000;border:0;border-radius:0;justify-content:center;align-items:center;gap:0;padding:0;display:flex;inset:0;translate:none}@media (width>=640px){.ck-dialog-content.ck-image-lightbox{max-width:none}}.ck-root[data-theme=dark] .ck-dialog-content.ck-image-lightbox{box-shadow:none}.ck-image-lightbox-prev,.ck-image-lightbox-next{position:absolute}.ck-image-lightbox-prev{inset-inline-start:1rem}.ck-image-lightbox-next{inset-inline-end:1rem}.ck-image-lightbox-photo{object-fit:contain;width:auto;max-width:90vw;height:auto;max-height:90vh}.ck-image-lightbox-meta{border-radius:var(--radius-xl);background-color:var(--muted);text-align:center;max-width:90vw;color:var(--muted-foreground);padding:.25rem .625rem;font-size:.75rem;line-height:1rem;position:absolute;bottom:3.5rem;left:50%;transform:translate(-50%)}.ck-image-lightbox-actions{top:1rem;position:absolute;inset-inline-end:1rem}.ck-image-lightbox-dots{gap:.5rem;display:flex;position:absolute;bottom:1.5rem}.ck-image-lightbox-dot{cursor:pointer;background-color:color-mix(in oklch, var(--foreground) 40%, transparent);border:0;border-radius:999px;width:.625rem;height:.625rem;padding:0;transition:background-color .15s cubic-bezier(.4,0,.2,1)}.ck-image-lightbox-dot:hover{background-color:color-mix(in oklch, var(--foreground) 60%, transparent)}.ck-image-lightbox-dot--active,.ck-image-lightbox-dot--active:hover{background-color:var(--foreground)}";
10
- function g({ className: e, children: t, ...n }) {
11
- return /* @__PURE__ */ p("svg", {
12
- viewBox: "0 0 24 24",
13
- fill: "none",
14
- stroke: "currentColor",
15
- strokeWidth: 1.5,
16
- strokeLinecap: "round",
17
- strokeLinejoin: "round",
18
- "aria-hidden": "true",
19
- ...n,
20
- className: e,
21
- children: t
22
- });
23
- }
24
- function _() {
25
- return /* @__PURE__ */ p(g, { children: /* @__PURE__ */ p("path", { d: "M15 6C15 6 9.00001 10.4189 9 12C8.99999 13.5812 15 18 15 18" }) });
26
- }
27
- function v() {
28
- return /* @__PURE__ */ p(g, { children: /* @__PURE__ */ p("path", { d: "M9.00005 6C9.00005 6 15 10.4189 15 12C15 13.5812 9 18 9 18" }) });
29
- }
30
- function y() {
31
- return /* @__PURE__ */ m(g, { children: [/* @__PURE__ */ p("path", { d: "M7.5 14.5C7.5 11.2002 7.5 9.55025 8.52513 8.52513C9.55025 7.5 11.2002 7.5 14.5 7.5C17.7998 7.5 19.4497 7.5 20.4749 8.52513C21.5 9.55025 21.5 11.2002 21.5 14.5C21.5 17.7998 21.5 19.4497 20.4749 20.4749C19.4497 21.5 17.7998 21.5 14.5 21.5C11.2002 21.5 9.55025 21.5 8.52513 20.4749C7.5 19.4497 7.5 17.7998 7.5 14.5Z" }), /* @__PURE__ */ p("path", { d: "M7.5 16.5C6.10355 16.5 5.40533 16.5 4.84402 16.3036C3.83866 15.9518 3.0482 15.1613 2.69641 14.156C2.5 13.5947 2.5 12.8964 2.5 11.5V9.5C2.5 6.20017 2.5 4.55025 3.52513 3.52513C4.55025 2.5 6.20017 2.5 9.5 2.5H11.5C12.8964 2.5 13.5947 2.5 14.156 2.69641C15.1613 3.0482 15.9518 3.83866 16.3036 4.84402C16.5 5.40533 16.5 6.10355 16.5 7.5" })] });
32
- }
33
- function b() {
34
- return /* @__PURE__ */ m(g, { children: [/* @__PURE__ */ p("path", { d: "M2.99969 17.0002C2.99969 17.9302 2.99969 18.3952 3.10192 18.7767C3.37932 19.8119 4.18796 20.6206 5.22324 20.898C5.60474 21.0002 6.06972 21.0002 6.99969 21.0002L16.9997 21.0002C17.9297 21.0002 18.3947 21.0002 18.7762 20.898C19.8114 20.6206 20.6201 19.8119 20.8975 18.7767C20.9997 18.3952 20.9997 17.9302 20.9997 17.0002" }), /* @__PURE__ */ p("path", { d: "M16.4998 11.5002C16.4998 11.5002 13.1856 16.0002 11.9997 16.0002C10.8139 16.0002 7.49976 11.5002 7.49976 11.5002M11.9997 15.0002V3.00016" })] });
35
- }
36
- function x() {
37
- return /* @__PURE__ */ p(g, { children: /* @__PURE__ */ p("path", { d: "M18 6L6.00081 17.9992M17.9992 18L6 6.00085" }) });
38
- }
39
- var S = d.memo(function({ images: h, initialIndex: g, open: S, onClose: C, returnFocusRef: w }) {
40
- let [T, E] = d.useState(g);
41
- d.useEffect(() => {
42
- S && E(Math.max(0, Math.min(g, h.length - 1)));
43
- }, [
44
- g,
45
- S,
46
- h.length
47
- ]);
48
- let D = h[T], O = !!(D && (D.type ?? D.filename ?? D.size != null)), k = async (t) => {
49
- if (t.stopPropagation(), D) try {
50
- let t = new URL(D.url, window.location.href);
51
- if (t.protocol !== "http:" && t.protocol !== "https:" && t.protocol !== "data:" && t.protocol !== "blob:") throw Error("Invalid image URL protocol");
52
- let n = await fetch(t.href);
53
- if (!n.ok) throw Error(`Failed to fetch image (${String(n.status)})`);
54
- let r = await n.blob();
55
- await navigator.clipboard.write([new ClipboardItem({ [r.type]: r })]), e.success("Image copied");
56
- } catch {
57
- e.error("Failed to copy image");
58
- }
59
- };
60
- return /* @__PURE__ */ p(u, {
61
- open: S && h.length > 0,
62
- onOpenChange: (e) => {
63
- e || C();
64
- },
65
- children: /* @__PURE__ */ m(c, {
66
- showCloseButton: !1,
67
- finalFocus: w,
68
- "aria-describedby": void 0,
69
- className: "ck-image-lightbox",
70
- onClick: C,
71
- onKeyDownCapture: (e) => {
72
- if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
73
- e.preventDefault(), e.stopPropagation();
74
- let t = e.key === "ArrowLeft" ? -1 : 1;
75
- E((e) => Math.max(0, Math.min(h.length - 1, e + t)));
76
- },
77
- children: [/* @__PURE__ */ p(l, {
78
- className: "ck-sr-only",
79
- children: "Image lightbox"
80
- }), D ? /* @__PURE__ */ m(f, { children: [
81
- h.length > 1 && T > 0 ? /* @__PURE__ */ p(n, {
82
- variant: "outline",
83
- size: "icon",
84
- "aria-label": "Previous image",
85
- className: "ck-image-lightbox-prev",
86
- onClick: (e) => {
87
- e.stopPropagation(), E((e) => e - 1);
88
- },
89
- children: /* @__PURE__ */ p(_, {})
90
- }) : null,
91
- h.length > 1 && T < h.length - 1 ? /* @__PURE__ */ p(n, {
92
- variant: "outline",
93
- size: "icon",
94
- "aria-label": "Next image",
95
- className: "ck-image-lightbox-next",
96
- onClick: (e) => {
97
- e.stopPropagation(), E((e) => e + 1);
98
- },
99
- children: /* @__PURE__ */ p(v, {})
100
- }) : null,
101
- /* @__PURE__ */ p("img", {
102
- src: D.url,
103
- alt: D.alt ?? D.filename ?? `Image ${String(T + 1)}`,
104
- className: "ck-image-lightbox-photo",
105
- onClick: (e) => {
106
- e.stopPropagation();
107
- }
108
- }),
109
- O ? /* @__PURE__ */ p("div", {
110
- className: "ck-image-lightbox-meta",
111
- onClick: (e) => {
112
- e.stopPropagation();
113
- },
114
- children: [
115
- D.type,
116
- D.filename,
117
- o(D.size)
118
- ].filter(Boolean).join(" • ")
119
- }) : null,
120
- /* @__PURE__ */ m(s, {
121
- className: "ck-image-lightbox-actions",
122
- onClick: (e) => {
123
- e.stopPropagation();
124
- },
125
- children: [
126
- /* @__PURE__ */ m(a, { children: [/* @__PURE__ */ p(i, {
127
- render: /* @__PURE__ */ p(n, {
128
- variant: "outline",
129
- size: "icon",
130
- "aria-label": "Copy image",
131
- onClick: (e) => {
132
- k(e);
133
- }
134
- }),
135
- children: /* @__PURE__ */ p(y, {})
136
- }), /* @__PURE__ */ p(r, { children: "Copy image" })] }),
137
- /* @__PURE__ */ m(a, { children: [/* @__PURE__ */ p(i, {
138
- render: /* @__PURE__ */ p(n, {
139
- variant: "outline",
140
- size: "icon",
141
- "aria-label": "Download",
142
- onClick: (e) => {
143
- if (e.stopPropagation(), !D) return;
144
- let t = document.createElement("a");
145
- t.href = D.url, t.download = D.alt ?? `image-${String(T + 1)}`, t.target = "_blank", t.click();
146
- }
147
- }),
148
- children: /* @__PURE__ */ p(b, {})
149
- }), /* @__PURE__ */ p(r, { children: "Download" })] }),
150
- /* @__PURE__ */ m(a, { children: [/* @__PURE__ */ p(i, {
151
- render: /* @__PURE__ */ p(n, {
152
- variant: "outline",
153
- size: "icon",
154
- "aria-label": "Close",
155
- onClick: C
156
- }),
157
- children: /* @__PURE__ */ p(x, {})
158
- }), /* @__PURE__ */ p(r, { children: "Close" })] })
159
- ]
160
- }),
161
- h.length > 1 ? /* @__PURE__ */ p("div", {
162
- className: "ck-image-lightbox-dots",
163
- children: h.map((e, n) => /* @__PURE__ */ p("button", {
164
- type: "button",
165
- "aria-label": `Go to image ${String(n + 1)}`,
166
- "aria-current": n === T ? "true" : void 0,
167
- className: t("ck-image-lightbox-dot", n === T && "ck-image-lightbox-dot--active"),
168
- onClick: (e) => {
169
- e.stopPropagation(), E(n);
170
- }
171
- }, e.id))
172
- }) : null
173
- ] }) : null]
174
- })
175
- });
176
- });
177
- function C(e) {
178
- return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("style", {
179
- "data-ck-tool-styles": "lightbox",
180
- children: h
181
- }), /* @__PURE__ */ p(S, { ...e })] });
182
- }
183
- export { C as CommentImageLightbox };
@@ -1,203 +0,0 @@
1
- import { d as e, o as t, r as n, s as r, u as i } from "./comment-kit-core-BaSuMzp9.js";
2
- import { a, i as o, o as s } from "./dom-Bhf4WFtY.js";
3
- var c = 4e3, l = 500, u = 2e3, d = 1e3, f = 5, p = 25, m = 3145728;
4
- function h(t) {
5
- let n = e(t?.comment, u);
6
- return n.length > 0 ? n : null;
7
- }
8
- function g(t) {
9
- return (t?.attachments ?? []).slice(0, f).flatMap((t) => {
10
- let n = e(t.name, d), r = e(t.path, d);
11
- return !n || !r ? [] : [{
12
- name: n,
13
- path: r,
14
- ...t.pathSource ? { pathSource: t.pathSource } : {},
15
- ...t.type ? { type: e(t.type, d) } : {},
16
- ...typeof t.size == "number" ? { size: t.size } : {},
17
- ...typeof t.lastModified == "number" ? { lastModified: t.lastModified } : {}
18
- }];
19
- });
20
- }
21
- function _(e) {
22
- return typeof HTMLElement < "u" && e instanceof HTMLElement;
23
- }
24
- function v(t, n, r, i) {
25
- let s = t.getBoundingClientRect(), u = o(t), d = a(t), f = t.getAttribute("class"), p = t.getAttribute("role"), m = t.getAttribute("aria-label"), h = e(t.textContent, l), g = e(t.outerHTML, c);
26
- return {
27
- found: !0,
28
- tagName: t.tagName.toLowerCase(),
29
- ...t.id ? { id: t.id } : {},
30
- ...f ? { className: f } : {},
31
- ...p ? { role: p } : {},
32
- ...m ? { ariaLabel: m } : {},
33
- ...h ? { text: h } : {},
34
- rect: {
35
- top: s.top,
36
- left: s.left,
37
- width: s.width,
38
- height: s.height
39
- },
40
- ...g ? { htmlPreview: g } : {},
41
- ...u ? { selector: u } : {},
42
- ...d ? { xpath: d } : {},
43
- ...n ? {
44
- source: y(n),
45
- stack: r.map(y)
46
- } : {},
47
- ...i ? { componentName: i } : {}
48
- };
49
- }
50
- function y(e) {
51
- return {
52
- filePath: e.filePath,
53
- lineNumber: e.lineNumber,
54
- columnNumber: e.columnNumber,
55
- componentName: e.componentName
56
- };
57
- }
58
- function b(e) {
59
- let t = `${e.filePath}${e.lineNumber === null ? "" : `:${e.lineNumber}`}${e.columnNumber === null ? "" : `:${e.columnNumber}`}`;
60
- return e.componentName ? `${e.componentName} (${t})` : t;
61
- }
62
- function x(e, t, n, r, i, a) {
63
- let o = ["# CommentKit Element Grab", ""], s = t.tagName ?? "element", c = t.id ? `#${t.id}` : "";
64
- if (o.push(`**Tag:** \`${s}${c}\``), i && o.push(`**Comment:** ${i}`), a.length > 0) {
65
- o.push("", "**Attachments:**");
66
- for (let e of a) {
67
- let t = [
68
- e.type ? `type: \`${e.type}\`` : null,
69
- typeof e.size == "number" ? `size: ${e.size} bytes` : null,
70
- e.pathSource ? `path source: ${e.pathSource}` : null
71
- ].filter(Boolean).join(", ");
72
- o.push(`- \`${e.name}\` - path: \`${e.path}\`${t ? ` (${t})` : ""}`);
73
- }
74
- }
75
- if (t.componentName && o.push(`**Component:** \`${t.componentName}\``), t.source && o.push(`**Source:** ${b(t.source)}`), t.stack && t.stack.length > 1) {
76
- o.push("", "**Stack:**");
77
- for (let e of t.stack) o.push(`- ${b(e)}`);
78
- }
79
- return t.source || (t.selector && o.push(`**Selector:** \`${t.selector}\``), t.xpath && o.push(`**XPath:** \`${t.xpath}\``)), o.push(`**Page:** ${e.title || "Untitled"} — ${e.url || e.path}`), o.push(""), o.push("**HTML:**", "```html", n, "```", ""), r && o.push("**Screenshot:** attached to clipboard as an image (paste below this text).", ""), o.join("\n");
80
- }
81
- function S(e) {
82
- let t = e.element;
83
- return {
84
- tagName: t.tagName,
85
- id: t.id,
86
- className: t.className,
87
- textContent: t.text,
88
- componentName: t.componentName,
89
- filePath: t.source?.filePath,
90
- lineNumber: t.source?.lineNumber ?? void 0,
91
- columnNumber: t.source?.columnNumber ?? void 0,
92
- comment: e.comment ?? void 0,
93
- attachments: e.attachments,
94
- selector: t.selector,
95
- xpath: t.xpath
96
- };
97
- }
98
- function C(e) {
99
- if (typeof window > "u" || typeof window.dispatchEvent != "function") return;
100
- let t = e[0];
101
- t && window.dispatchEvent(new CustomEvent("commentkit:element-selected", { detail: {
102
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
103
- page: t.page,
104
- elements: e.map(S)
105
- } }));
106
- }
107
- async function w(a, o, l, u) {
108
- if (!a || typeof Element > "u" || !(a instanceof Element) || typeof a.getBoundingClientRect != "function") return null;
109
- let d = (_(a), a), f = await i(a), p = f?.source ?? null, m = f?.stack ?? [], y = f?.componentName ?? null, b = await n(o, l, d, { reportErrors: !1 }), S = b?.dataUrl ?? null, w = b?.blob ?? null, T = v(a, p, m, y), E = T.htmlPreview ?? e(a.outerHTML, c), D = s(), O = h(u), k = g(u), A = x({
110
- url: D.url,
111
- path: D.path,
112
- title: D.title
113
- }, T, E, S, O, k);
114
- try {
115
- w ? await t(A, w) : await r(A);
116
- } catch {}
117
- let j = {
118
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
119
- page: {
120
- url: D.url,
121
- path: D.path,
122
- title: D.title
123
- },
124
- element: T,
125
- comment: O,
126
- attachments: k,
127
- html: E,
128
- screenshotDataUrl: S,
129
- markdown: A
130
- };
131
- return C([j]), j;
132
- }
133
- function T(e, t, n, r) {
134
- let i = [
135
- "# CommentKit Element Grab",
136
- "",
137
- `**Elements:** ${t.length}`,
138
- `**Page:** ${e.title || "Untitled"} — ${e.url || e.path}`
139
- ];
140
- if (n && i.push(`**Comment:** ${n}`), r.length > 0) {
141
- i.push("", "**Attachments:**");
142
- for (let e of r) i.push(`- \`${e.name}\` - path: \`${e.path}\`${e.pathSource ? ` (path source: ${e.pathSource})` : ""}`);
143
- }
144
- return i.push(""), t.forEach((e, t) => {
145
- let { element: n } = e, r = n.tagName ?? "element", a = n.id ? `#${n.id}` : "";
146
- i.push(`## [${t + 1}] \`${r}${a}\``), n.componentName && i.push(`- Component: \`${n.componentName}\``), n.source && i.push(`- Source: ${b(n.source)}`), n.stack && n.stack.length > 1 && i.push(`- Stack: ${n.stack.map((e) => e.componentName ?? e.filePath).join(" → ")}`), n.source || (n.selector && i.push(`- Selector: \`${n.selector}\``), n.xpath && i.push(`- XPath: \`${n.xpath}\``)), i.push("", "```html", e.html, "```", ""), e.screenshotDataUrl && i.push(`![screenshot](${e.screenshotDataUrl})`, "");
147
- }), i.join("\n");
148
- }
149
- async function E(t, a, o, l) {
150
- let u = t.filter((e) => !!e && typeof Element < "u" && e instanceof Element && typeof e.getBoundingClientRect == "function");
151
- if (u.length === 0) return null;
152
- let d = u.slice(0, p);
153
- u.length > p && typeof console < "u" && console.warn(`[CommentKit] grabElements was called with ${u.length} elements — capped to ${p} for clipboard size. Pass fewer elements to avoid truncation.`);
154
- let f = [], y = 0, b = 0, S = h(l), w = g(l);
155
- for (let t of d) {
156
- let r = (_(t), t), l = await i(t), u = l?.source ?? null, d = l?.stack ?? [], p = l?.componentName ?? null, h = null;
157
- if (y < m) {
158
- let e = (await n(a, o, r, { reportErrors: !1 }))?.dataUrl ?? null;
159
- e && y + e.length <= m ? (h = e, y += e.length) : e && b++;
160
- } else b++;
161
- let g = v(t, u, d, p), C = g.htmlPreview ?? e(t.outerHTML, c), T = s(), E = x({
162
- url: T.url,
163
- path: T.path,
164
- title: T.title
165
- }, g, C, h, S, w);
166
- f.push({
167
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
168
- page: {
169
- url: T.url,
170
- path: T.path,
171
- title: T.title
172
- },
173
- element: g,
174
- comment: S,
175
- attachments: w,
176
- html: C,
177
- screenshotDataUrl: h,
178
- markdown: E
179
- });
180
- }
181
- b > 0 && typeof console < "u" && console.warn(`[CommentKit] grabElements dropped ${b} screenshot${b === 1 ? "" : "s"} to stay under the ${Math.round(m / 1024 / 1024)}MB clipboard budget.`);
182
- let E = s(), D = T({
183
- url: E.url,
184
- path: E.path,
185
- title: E.title
186
- }, f, S, w);
187
- try {
188
- await r(D);
189
- } catch {}
190
- let O = {
191
- generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
192
- page: {
193
- url: E.url,
194
- path: E.path,
195
- title: E.title
196
- },
197
- results: f,
198
- attachments: w,
199
- markdown: D
200
- };
201
- return C(f), O;
202
- }
203
- export { w as grabElement, E as grabElements };
@@ -1,302 +0,0 @@
1
- import { t as e } from "./websocket-manager-DhLWh3Jr.js";
2
- import { a as t, c as n, i as r, o as i, s as a } from "./validation-C7QG8j7Z.js";
3
- import { i as o } from "./comment-kit-core-BaSuMzp9.js";
4
- import { o as s } from "./dom-Bhf4WFtY.js";
5
- var c = o.ID, l = o.CONTENT, u = o.NAME, d = o.EMAIL, f = o.PAGE, p = o.EMOJI, m = o.ONLINE_USERS, h = o.REACTION_COUNT, g = 33, _ = 1e3, v = o.CURSOR_EMITS_PER_SEC;
6
- function y(e) {
7
- let t = e.config.realtime, n = t?.maxRenderedCursors;
8
- return {
9
- cursors: t?.cursors !== !1,
10
- presence: t?.presence !== !1,
11
- maxRenderedCursors: typeof n == "number" && Number.isFinite(n) && n >= 0 ? Math.min(Math.floor(n), m) : o.RENDERED_CURSORS
12
- };
13
- }
14
- var b = /* @__PURE__ */ new Set([
15
- "pin",
16
- "highlight",
17
- "drawing"
18
- ]), x = /* @__PURE__ */ new Set([
19
- "open",
20
- "resolved",
21
- "complete"
22
- ]), S = /* @__PURE__ */ new Set([
23
- "low",
24
- "medium",
25
- "high",
26
- "urgent"
27
- ]), C = /* @__PURE__ */ new Set([
28
- "path",
29
- "line",
30
- "rectangle",
31
- "circle",
32
- "text"
33
- ]);
34
- function w(e, t) {
35
- return a(e, t);
36
- }
37
- function T(e) {
38
- return w(e, c);
39
- }
40
- function E(e) {
41
- if (!w(e, d)) return !1;
42
- let t = e.trim(), n = t.indexOf("@");
43
- return n > 0 && n === t.lastIndexOf("@") && n < t.length - 1 && !/\s/.test(t);
44
- }
45
- function D(e) {
46
- return i(e) && T(e.id) && w(e.name, u) && E(e.email) && n(e.avatar, f) && n(e.organizationId, c);
47
- }
48
- function O(e) {
49
- return {
50
- id: e.id.trim(),
51
- name: e.name.trim(),
52
- email: e.email.trim(),
53
- ...e.avatar ? { avatar: e.avatar.trim() } : {},
54
- ...e.organizationId ? { organizationId: e.organizationId.trim() } : {}
55
- };
56
- }
57
- function k(e) {
58
- if (!Array.isArray(e)) return null;
59
- let t = [], n = /* @__PURE__ */ new Set();
60
- for (let r of e) {
61
- if (t.length >= m) break;
62
- if (!D(r)) continue;
63
- let e = O(r);
64
- n.has(e.id) || (n.add(e.id), t.push(e));
65
- }
66
- return t;
67
- }
68
- function A(e) {
69
- return i(e) ? t(e.x) && t(e.y) : !1;
70
- }
71
- function j(e) {
72
- return i(e) && w(e.url, f) && w(e.path, f) && w(e.title, f);
73
- }
74
- function M(e) {
75
- return i(e) && z(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= h && typeof e.reacted == "boolean";
76
- }
77
- function N(e, t) {
78
- if (Array.isArray(e)) return e.filter(M).map((e) => {
79
- if (!Array.isArray(e.userIds)) return e;
80
- let n = e.userIds.filter(T);
81
- return {
82
- ...e,
83
- userIds: n,
84
- reacted: !!t && n.includes(t)
85
- };
86
- });
87
- }
88
- function P(e, t) {
89
- return {
90
- ...e,
91
- replies: Array.isArray(e.replies) ? e.replies.flatMap((e) => {
92
- let n = I(e, t);
93
- return n ? [n] : [];
94
- }) : [],
95
- ...e.reactions === void 0 ? {} : { reactions: N(e.reactions, t) }
96
- };
97
- }
98
- function F(e, t) {
99
- return !i(e) || !T(e.id) || !b.has(e.type) || !w(e.content, l) || !A(e.position) || !x.has(e.status) || !S.has(e.priority) || !D(e.author) || !T(e.userId) || !w(e.createdAt, f) || !w(e.updatedAt, f) || !j(e.page) || !Array.isArray(e.replies) || !Array.isArray(e.attachments) ? null : P(structuredClone(e), t);
100
- }
101
- function I(e, t) {
102
- if (!i(e) || !T(e.id) || !w(e.content, l) || !D(e.author) || !w(e.createdAt, f)) return null;
103
- let n = structuredClone(e);
104
- return n.reactions &&= N(n.reactions, t), n;
105
- }
106
- function L(e) {
107
- return !i(e) || !D(e.user) || !r(e.x) || e.x < 0 || e.x > 100 || !r(e.y) || e.y < 0 || e.y > 100 || !w(e.page, f) ? null : {
108
- x: e.x,
109
- y: e.y,
110
- page: e.page.trim(),
111
- user: O(e.user)
112
- };
113
- }
114
- function R(e) {
115
- return i(e) ? w(e.type, o.DRAWING_TYPE) && C.has(e.type) && w(e.stroke, o.COLOR) && r(e.strokeWidth) && e.strokeWidth >= 0 && w(e.fill, o.COLOR) && n(e.d, o.DRAWING_PATH_DATA) && n(e.text, o.DRAWING_TEXT) && (e.x === void 0 || r(e.x)) && (e.y === void 0 || r(e.y)) && (e.width === void 0 || r(e.width)) && (e.height === void 0 || r(e.height)) : !1;
116
- }
117
- function z(e) {
118
- return w(e, p);
119
- }
120
- function B(e) {
121
- try {
122
- e();
123
- } catch {}
124
- }
125
- function V(e, t) {
126
- return e.wsManager === t;
127
- }
128
- function H(e, t) {
129
- e.setState({ comments: e.getState().comments.map((e) => e.id === t.id ? t : e) });
130
- }
131
- function U(t, n) {
132
- if (t.config.features?.realtime === !1 || !t.config.reverb?.host || !t.config.reverb?.key) return;
133
- if (n.wsManager) {
134
- for (let e of n.wsUnsubscribers) B(e);
135
- n.wsUnsubscribers = [], W(n);
136
- try {
137
- n.wsManager.destroy();
138
- } catch {}
139
- n.wsManager = null;
140
- }
141
- let r = t.config.baseUrl || "https://api.commentkit.dev/api", a = t.getState().currentUser, o = y(t);
142
- try {
143
- n.wsManager = new e({
144
- key: t.config.reverb.key,
145
- wsHost: t.config.reverb.host,
146
- wsPort: t.config.reverb.port ?? 443,
147
- forceTLS: (t.config.reverb.scheme ?? "wss") === "wss",
148
- /* v8 ignore next -- projectId always provided in config */
149
- projectId: t.config.projectId || "",
150
- apiKey: t.config.apiKey,
151
- authEndpoint: `${r}/broadcasting/auth`,
152
- userEmail: a?.email,
153
- userInfo: a ? {
154
- id: a.id,
155
- name: a.name,
156
- email: a.email
157
- } : void 0
158
- });
159
- } catch (e) {
160
- t.setState({ connectionStatus: "error" }), t.handleError(e);
161
- return;
162
- }
163
- let c = n.wsUnsubscribers, l = n.wsManager;
164
- c.push(l.on("connected", () => {
165
- V(n, l) && (t.setState({ connectionStatus: "connected" }), n.wsManager?.requestPresence());
166
- })), c.push(l.on("disconnected", () => {
167
- V(n, l) && t.setState({ connectionStatus: "disconnected" });
168
- })), c.push(l.on("reconnecting", () => {
169
- V(n, l) && t.setState({ connectionStatus: "connecting" });
170
- })), c.push(l.on("error", () => {
171
- V(n, l) && t.setState({ connectionStatus: "error" });
172
- })), c.push(l.on("comment:resolved", (e) => {
173
- if (!V(n, l)) return;
174
- let r = F(e, t.getState().currentUser?.id);
175
- r && (H(t, r), t.emit("comment:resolved", r));
176
- })), c.push(l.on("comment:completed", (e) => {
177
- if (!V(n, l)) return;
178
- let r = F(e, t.getState().currentUser?.id);
179
- r && (H(t, r), t.emit("comment:completed", r));
180
- })), c.push(l.on("comment:created", (e) => {
181
- if (!V(n, l)) return;
182
- let r = F(e, t.getState().currentUser?.id);
183
- if (!r) return;
184
- let i = t.getState().activeBranch;
185
- 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));
186
- })), c.push(l.on("comment:updated", (e) => {
187
- if (!V(n, l)) return;
188
- let r = F(e, t.getState().currentUser?.id);
189
- r && (H(t, r), t.emit("comment:updated", r));
190
- })), c.push(l.on("comment:deleted", (e) => {
191
- if (!V(n, l) || !i(e) || !T(e.id)) return;
192
- let r = e.id.trim();
193
- t.setState({
194
- comments: t.getState().comments.filter((e) => e.id !== r),
195
- selectedComment: t.getState().selectedComment?.id === r ? null : t.getState().selectedComment
196
- }), t.emit("comment:deleted", { id: r });
197
- })), c.push(l.on("reply:added", (e) => {
198
- if (!V(n, l) || !i(e) || !T(e.commentId)) return;
199
- let r = I(e.reply, t.getState().currentUser?.id);
200
- if (!r) return;
201
- let a = e.commentId.trim(), o = t.getState().comments.map((e) => e.id !== a || e.replies.some((e) => e.id === r.id) ? e : {
202
- ...e,
203
- status: "open",
204
- resolvedAt: void 0,
205
- completedAt: void 0,
206
- replies: [...e.replies, r]
207
- });
208
- t.setState({ comments: o });
209
- let s = o.find((e) => e.id === a);
210
- s && t.emit("comment:updated", s);
211
- }));
212
- let u = (e, t, n) => {
213
- let r = (e ?? []).filter((e) => z(e.emoji) && Number.isInteger(e.count) && e.count >= 0 && e.count <= h), i = r.findIndex((e) => e.emoji === t);
214
- if (i !== -1) {
215
- let e = r[i];
216
- r[i] = n ? {
217
- ...e,
218
- reacted: !0
219
- } : {
220
- ...e,
221
- count: Math.min(e.count + 1, h),
222
- reacted: e.reacted
223
- };
224
- } else r.push({
225
- emoji: t,
226
- count: 1,
227
- reacted: n
228
- });
229
- return r;
230
- }, d = (e, t, n) => (e ?? []).filter((e) => z(e.emoji) && Number.isInteger(e.count) && e.count > 0 && e.count <= h).map((e) => e.emoji === t ? {
231
- ...e,
232
- count: n ? e.count : e.count - 1,
233
- reacted: !n && e.reacted
234
- } : e).filter((e) => e.count > 0), f = (e, r) => {
235
- if (!V(n, l) || !i(e) || !T(e.commentId) || !z(e.emoji) || !T(e.userId)) return;
236
- let a = e.commentId.trim(), o = T(e.replyId) ? e.replyId.trim() : null, s = e.emoji.trim(), c = e.userId.trim() === t.getState().currentUser?.id;
237
- t.setState({ comments: t.getState().comments.map((e) => e.id === a ? o === null ? {
238
- ...e,
239
- reactions: r(e.reactions, s, c)
240
- } : {
241
- ...e,
242
- replies: e.replies.map((e) => e.id === o ? {
243
- ...e,
244
- reactions: r(e.reactions, s, c)
245
- } : e)
246
- } : e) });
247
- };
248
- c.push(l.on("reaction:added", (e) => f(e, u))), c.push(l.on("reaction:removed", (e) => f(e, d)));
249
- let p = /* @__PURE__ */ new Map(), m = 0, b = 0;
250
- c.push(l.on("cursor:move", (e) => {
251
- if (!V(n, l) || !o.cursors) return;
252
- let r = L(e);
253
- if (!r) return;
254
- let i = Date.now(), a = r.user.id, s = p.get(a);
255
- if (s === void 0 && p.size >= o.maxRenderedCursors) {
256
- let e, t = Infinity;
257
- for (let [n, r] of p) r < t && (t = r, e = n);
258
- if (e !== void 0 && i - t >= g) p.delete(e);
259
- else return;
260
- }
261
- s !== void 0 && i - s < g || (i - m >= _ && (m = i, b = 0), !(b >= v) && (b++, p.set(a, i), t.emit("cursor:move", r)));
262
- })), c.push(l.on("cursor:leave", (e) => {
263
- V(n, l) && i(e) && T(e.userId) && (p.delete(e.userId.trim()), t.emit("cursor:leave", { userId: e.userId.trim() }));
264
- })), c.push(l.on("user:joined", (e) => {
265
- V(n, l) && D(e) && t.emit("user:joined", O(e));
266
- })), c.push(l.on("user:left", (e) => {
267
- V(n, l) && i(e) && T(e.userId) && t.emit("user:left", { userId: e.userId.trim() });
268
- })), c.push(l.on("presence:update", (e) => {
269
- if (!V(n, l) || !o.presence || !i(e)) return;
270
- let r = k(e.users);
271
- if (!r) return;
272
- let a = { users: r };
273
- t.setState({ onlineUsers: r }), t.emit("presence:update", a);
274
- })), c.push(l.on("drawing:stroke", (e) => {
275
- V(n, l) && i(e) && T(e.userId) && R(e.path) && t.emit("drawing:stroke", {
276
- userId: e.userId.trim(),
277
- path: structuredClone(e.path)
278
- });
279
- }));
280
- try {
281
- t.setState({ connectionStatus: "connecting" });
282
- let e = l.connect();
283
- e && typeof e.catch == "function" && e.catch((e) => {
284
- t.setState({ connectionStatus: "error" }), t.handleError(e);
285
- });
286
- } catch (e) {
287
- t.setState({ connectionStatus: "error" }), t.handleError(e);
288
- return;
289
- }
290
- /* v8 ignore next -- SSR guard unreachable in jsdom */
291
- typeof document < "u" && typeof window < "u" && o.cursors && (n.mouseMoveHandler = (e) => {
292
- if (t.getState().isOverlayVisible && n.wsManager?.isConnected()) {
293
- if (window.innerWidth <= 0 || window.innerHeight <= 0) return;
294
- 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));
295
- n.wsManager.sendCursorMove(t, r, s().url);
296
- }
297
- }, document.addEventListener("mousemove", n.mouseMoveHandler));
298
- }
299
- function W(e) {
300
- typeof window < "u" && typeof document < "u" && e.mouseMoveHandler && (document.removeEventListener("mousemove", e.mouseMoveHandler), e.mouseMoveHandler = null);
301
- }
302
- export { U as initializeWebSocket, W as removeMouseMoveListener };