@commentkit/comment-kit 0.7.6 → 1.0.0-beta.0
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 +30 -0
- package/README.md +108 -762
- package/SECURITY.md +19 -14
- package/dist/npm/THIRD_PARTY_NOTICES.txt +73 -0
- package/dist/npm/chunks/anchor-DT-Ynhh1.js +270 -0
- package/dist/npm/chunks/client-D1vrh_5G.js +590 -0
- package/dist/{shared/capture-colors-D0uLr-vZ.js → npm/chunks/colors-CX-IPjvb.js} +2 -0
- package/dist/npm/chunks/html2canvas-_mjSRP3G.js +4011 -0
- package/dist/npm/chunks/mount-Ce1MZrcm.js +2485 -0
- package/dist/{shared/pusher-BUaiCkDJ.js → npm/chunks/pusher-DRKlokR8.js} +224 -222
- package/dist/npm/chunks/realtime-5SvAvTUU.js +23 -0
- package/dist/npm/chunks/rolldown-runtime-VHNaYcLd.js +13 -0
- package/dist/npm/chunks/src-DJjfvVsa.js +330 -0
- package/dist/npm/element.js +24 -0
- package/dist/npm/headless.js +3 -0
- package/dist/npm/index.js +3 -0
- package/dist/npm/react.js +17 -0
- package/dist/npm/svelte.js +8 -0
- package/dist/npm/types/adapters/react.d.ts +9 -0
- package/dist/npm/types/adapters/svelte.d.ts +9 -0
- package/dist/npm/types/adapters/vue.d.ts +46 -0
- package/dist/npm/types/anchor/index.d.ts +49 -0
- package/dist/npm/types/core/api.d.ts +29 -0
- package/dist/npm/types/core/auth.d.ts +48 -0
- package/dist/npm/types/core/client.d.ts +100 -0
- package/dist/npm/types/core/store.d.ts +7 -0
- package/dist/npm/types/core/types.d.ts +278 -0
- package/dist/npm/types/element.d.ts +10 -0
- package/dist/npm/types/headless.d.ts +7 -0
- package/dist/npm/types/index.d.ts +30 -0
- package/dist/npm/vue.js +32 -0
- package/package.json +65 -173
- package/dist/THIRD_PARTY_NOTICES.txt +0 -284
- package/dist/angular.es.js +0 -321
- package/dist/comment-kit.es.js +0 -218
- package/dist/demo.es.js +0 -483
- package/dist/headless.es.js +0 -4
- package/dist/preact.es.js +0 -117
- package/dist/qwik.es.js +0 -1
- package/dist/qwik.qwik.mjs +0 -114
- package/dist/react.es.js +0 -98
- package/dist/shared/ShadowRootContext-DD6a0QaI.js +0 -11
- package/dist/shared/annotation-icons-Dh-bmNYK.js +0 -172
- package/dist/shared/annotation-toolbar-RSrb0Nku.js +0 -1086
- package/dist/shared/attachment-refresh-CSTYwRW-.js +0 -94
- package/dist/shared/bridge-CJoGYngu.js +0 -177
- package/dist/shared/button-D4GHW6oZ.js +0 -474
- package/dist/shared/button-group-BVR7iT-S.js +0 -91
- package/dist/shared/capture-privacy-DUROnio5.js +0 -77
- package/dist/shared/comment-drawing-canvas-DbuXP54N.js +0 -124
- package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
- package/dist/shared/comment-image-lightbox-zlIGEVA-.js +0 -190
- package/dist/shared/comment-images-content-aYbJb79_.js +0 -214
- package/dist/shared/comment-kit-core-B0k7XsMz.js +0 -3680
- package/dist/shared/comment-kit-ui-BXLJcZYQ.js +0 -19391
- package/dist/shared/comment-screenshot-annotator-ChWwYJzO.js +0 -151
- package/dist/shared/comment-screenshot-overlay-Bufg3rHz.js +0 -205
- package/dist/shared/comment-shortcut-groups-CfEmkitU.js +0 -153
- package/dist/shared/createReactComponent-BZHeRbD0.js +0 -45
- package/dist/shared/dev-export-panel-DAZenvgD.js +0 -207
- package/dist/shared/dev-grab-O8q25zar.js +0 -197
- package/dist/shared/dist-D9A5k-N4.js +0 -617
- package/dist/shared/dom-Bhf4WFtY.js +0 -223
- package/dist/shared/element-selector-CYkwzfEr.js +0 -902
- package/dist/shared/error-boundary-D3PD74vI.js +0 -21
- package/dist/shared/errors-Bu5ajEmB.js +0 -22
- package/dist/shared/icons-nzMOLzrm.js +0 -266
- package/dist/shared/input-UPtAj0M6.js +0 -111
- package/dist/shared/mount-ui-BKaWBhKq.js +0 -208
- package/dist/shared/realtime-C0Z8dXXH.js +0 -334
- package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
- package/dist/shared/request-activity-DQrAUwfA.js +0 -11
- package/dist/shared/screenshot-B-ZfFItT.js +0 -199
- package/dist/shared/separator-UhJb0Row.js +0 -3955
- package/dist/shared/shadow-root-Cd3SLHyj.js +0 -133
- package/dist/shared/styles-CnYsLS2f.js +0 -2
- package/dist/shared/text-B4HHZNaa.js +0 -23
- package/dist/shared/token-session-DplW5QDx.js +0 -25
- package/dist/shared/useLabelableId-8n0QmH8N.js +0 -154
- package/dist/shared/useRender-Uxk1OPK-.js +0 -5
- package/dist/shared/useValueChanged-DKq5cMot.js +0 -92
- package/dist/shared/validation-3wbbbuX0.js +0 -70
- package/dist/shared/websocket-manager-798cRDyL.js +0 -381
- package/dist/solid.es.js +0 -98
- package/dist/svelte.es.js +0 -130
- package/dist/types/adapters/bridge.d.ts +0 -122
- package/dist/types/angular/index.d.ts +0 -145
- package/dist/types/core/agent-context.d.ts +0 -17
- package/dist/types/core/api-client.d.ts +0 -155
- package/dist/types/core/comment-kit-core.d.ts +0 -254
- package/dist/types/core/local-demo.d.ts +0 -60
- package/dist/types/core/types.d.ts +0 -770
- package/dist/types/core/websocket-manager.d.ts +0 -125
- package/dist/types/core/write-access.d.ts +0 -11
- package/dist/types/demo.d.ts +0 -17
- package/dist/types/headless.d.ts +0 -8
- package/dist/types/index.d.ts +0 -87
- package/dist/types/preact/index.d.ts +0 -25
- package/dist/types/qwik/index.d.ts +0 -73
- package/dist/types/react/client.d.ts +0 -31
- package/dist/types/react/index.d.ts +0 -4
- package/dist/types/solid/index.d.ts +0 -37
- package/dist/types/svelte/index.d.ts +0 -55
- package/dist/types/utils/dom.d.ts +0 -59
- package/dist/types/utils/event-emitter.d.ts +0 -11
- package/dist/types/vue/index.d.ts +0 -87
- package/dist/vue.es.js +0 -148
- package/docs/api-reference.md +0 -405
- package/docs/local-demo.md +0 -60
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./button-D4GHW6oZ.js";
|
|
2
|
-
import { i as t, o as n, r, t as i } from "./separator-UhJb0Row.js";
|
|
3
|
-
import { t as a } from "./createReactComponent-BZHeRbD0.js";
|
|
4
|
-
import { F as o, N as s, P as c, S as l, u } from "./comment-kit-ui-BXLJcZYQ.js";
|
|
5
|
-
import * as d from "react";
|
|
6
|
-
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
7
|
-
var h = a("outline", "refresh", "Refresh", [["path", {
|
|
8
|
-
d: "M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",
|
|
9
|
-
key: "svg-0"
|
|
10
|
-
}], ["path", {
|
|
11
|
-
d: "M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",
|
|
12
|
-
key: "svg-1"
|
|
13
|
-
}]]), g = ".ck-dev-export-host{background:var(--popover);border:1px solid var(--border);width:min(420px,100vw - 32px);max-height:calc(100vh - 32px);z-index:var(--z-ck-overlay);border-radius:10px;flex-direction:column;display:flex;position:fixed;top:16px;right:16px;overflow:hidden;box-shadow:0 8px 32px #0000001f}.ck-dev-export{height:100%;font-family:var(--font-sans);color:var(--popover-foreground);flex-direction:column;gap:8px;padding:12px;font-size:14px;line-height:1.4;display:flex}.ck-dev-export-header{flex-direction:column;gap:4px;display:flex}.ck-dev-export-title{align-items:center;gap:6px;font-size:13px;font-weight:600;display:inline-flex}.ck-dev-export-help{color:var(--muted-foreground);margin:0;font-size:12px}.ck-dev-export-help code{font-family:var(--font-mono);background:color-mix(in oklch, var(--muted) 60%, transparent);border-radius:4px;padding:1px 4px;font-size:.92em}.ck-dev-export-toolbar{align-items:center;gap:8px;padding:6px 0;display:flex}.ck-dev-export-count{color:var(--muted-foreground);font-size:12px}.ck-dev-export-truncation{color:var(--muted-foreground);margin:0;font-size:11px}.ck-dev-export-actions{align-items:center;gap:4px;margin-left:auto;display:inline-flex}.ck-dev-export-scroll{flex:1;min-height:0}.ck-dev-export-list{flex-direction:column;gap:4px;margin:0;padding:0;list-style:none;display:flex}.ck-dev-export-row{cursor:default;background:0 0;border:1px solid #0000;border-radius:6px;align-items:flex-start;gap:8px;padding:8px;display:flex}.ck-dev-export-row[data-checked=true]{background:color-mix(in oklch, var(--accent) 70%, transparent);border-color:var(--border)}.ck-dev-export-row-body{cursor:pointer;flex-direction:column;gap:2px;min-width:0;display:flex}.ck-dev-export-row-title{text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:500;overflow:hidden}.ck-dev-export-row-meta{color:var(--muted-foreground);align-items:center;gap:4px;font-size:11px;display:inline-flex}.ck-dev-export-row-meta [data-priority=urgent]{color:var(--ck-priority-urgent);font-weight:600}.ck-dev-export-row-meta [data-priority=high]{color:var(--priority-high-foreground);font-weight:600}.ck-dev-export-empty{color:var(--muted-foreground);text-align:center;padding:16px;font-size:12px}.ck-dev-export-error,.ck-dev-export-success{margin:0;font-size:12px}.ck-dev-export-error{color:var(--destructive)}.ck-dev-export-success{color:var(--ck-status-success)}", _ = 200;
|
|
14
|
-
function v(e, t = 140) {
|
|
15
|
-
let n = e.replace(/\s+/g, " ").trim();
|
|
16
|
-
return n.length > t ? `${n.slice(0, t - 1)}…` : n;
|
|
17
|
-
}
|
|
18
|
-
var y = 2500, b = ({ core: a, state: f }) => {
|
|
19
|
-
let [g, b] = d.useState(() => /* @__PURE__ */ new Set()), [x, S] = d.useState(!1), [C, w] = d.useState(null), [T, E] = d.useState(null), D = d.useMemo(() => f.comments.reduce((e, t) => e + +(t.status === "open"), 0), [f.comments]), O = d.useMemo(() => f.comments.filter((e) => e.status === "open").slice(0, _).map((e) => ({
|
|
20
|
-
id: e.id,
|
|
21
|
-
title: v(e.content || "(no content)"),
|
|
22
|
-
page: e.page.path || e.page.url || "unknown",
|
|
23
|
-
author: e.author.name || e.author.email,
|
|
24
|
-
priority: e.priority
|
|
25
|
-
})), [f.comments]), k = D > O.length;
|
|
26
|
-
d.useEffect(() => {
|
|
27
|
-
b((e) => {
|
|
28
|
-
let t = /* @__PURE__ */ new Set();
|
|
29
|
-
for (let n of e) O.some((e) => e.id === n) && t.add(n);
|
|
30
|
-
return t.size === e.size ? e : t;
|
|
31
|
-
});
|
|
32
|
-
}, [O]), d.useEffect(() => {
|
|
33
|
-
if (C == null) return;
|
|
34
|
-
let e = setTimeout(() => w(null), y);
|
|
35
|
-
return () => clearTimeout(e);
|
|
36
|
-
}, [C]);
|
|
37
|
-
let A = O.length > 0 && g.size === O.length, j = g.size > 0 && g.size < O.length, M = g.size === 0, N = (e) => {
|
|
38
|
-
w(null), b((t) => {
|
|
39
|
-
let n = new Set(t);
|
|
40
|
-
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
return /* @__PURE__ */ m("div", {
|
|
44
|
-
className: "ck-dev-export",
|
|
45
|
-
"data-testid": "ck-dev-export-panel",
|
|
46
|
-
children: [
|
|
47
|
-
/* @__PURE__ */ m("header", {
|
|
48
|
-
className: "ck-dev-export-header",
|
|
49
|
-
children: [/* @__PURE__ */ m("div", {
|
|
50
|
-
className: "ck-dev-export-title",
|
|
51
|
-
children: [/* @__PURE__ */ p(s, {
|
|
52
|
-
size: 16,
|
|
53
|
-
"aria-hidden": !0
|
|
54
|
-
}), /* @__PURE__ */ p("strong", { children: "Dev export" })]
|
|
55
|
-
}), /* @__PURE__ */ p("p", {
|
|
56
|
-
className: "ck-dev-export-help",
|
|
57
|
-
children: "Select stakeholder comments to bundle into a single Markdown payload for your agent. Each comment is enriched with the source file location when source resolution is available."
|
|
58
|
-
})]
|
|
59
|
-
}),
|
|
60
|
-
/* @__PURE__ */ p(i, {}),
|
|
61
|
-
/* @__PURE__ */ m("div", {
|
|
62
|
-
className: "ck-dev-export-toolbar",
|
|
63
|
-
children: [
|
|
64
|
-
/* @__PURE__ */ p(l, {
|
|
65
|
-
checked: A,
|
|
66
|
-
indeterminate: j,
|
|
67
|
-
onCheckedChange: () => {
|
|
68
|
-
w(null), b((e) => e.size === O.length ? /* @__PURE__ */ new Set() : new Set(O.map((e) => e.id)));
|
|
69
|
-
},
|
|
70
|
-
"aria-label": A ? "Deselect all" : "Select all",
|
|
71
|
-
disabled: O.length === 0
|
|
72
|
-
}),
|
|
73
|
-
/* @__PURE__ */ m("span", {
|
|
74
|
-
className: "ck-dev-export-count",
|
|
75
|
-
children: [
|
|
76
|
-
g.size,
|
|
77
|
-
" of ",
|
|
78
|
-
O.length,
|
|
79
|
-
" selected"
|
|
80
|
-
]
|
|
81
|
-
}),
|
|
82
|
-
/* @__PURE__ */ m("div", {
|
|
83
|
-
className: "ck-dev-export-actions",
|
|
84
|
-
children: [/* @__PURE__ */ m(r, { children: [/* @__PURE__ */ p(n, {
|
|
85
|
-
render: /* @__PURE__ */ p(e, {
|
|
86
|
-
type: "button",
|
|
87
|
-
variant: "ghost",
|
|
88
|
-
size: "icon",
|
|
89
|
-
onClick: async () => {
|
|
90
|
-
if (!x) {
|
|
91
|
-
S(!0), E(null);
|
|
92
|
-
try {
|
|
93
|
-
await a.reloadComments();
|
|
94
|
-
} catch {
|
|
95
|
-
E("Could not refresh comments");
|
|
96
|
-
} finally {
|
|
97
|
-
S(!1);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
disabled: x,
|
|
102
|
-
"aria-label": "Refresh comments"
|
|
103
|
-
}),
|
|
104
|
-
children: /* @__PURE__ */ p(h, {
|
|
105
|
-
size: 14,
|
|
106
|
-
"aria-hidden": !0
|
|
107
|
-
})
|
|
108
|
-
}), /* @__PURE__ */ p(t, { children: "Refresh comments" })] }), /* @__PURE__ */ m(e, {
|
|
109
|
-
type: "button",
|
|
110
|
-
onClick: async () => {
|
|
111
|
-
if (!(M || x)) {
|
|
112
|
-
S(!0), E(null);
|
|
113
|
-
try {
|
|
114
|
-
await a.copyAgentContext({
|
|
115
|
-
commentIds: Array.from(g),
|
|
116
|
-
includeResolved: !1
|
|
117
|
-
}), w(Date.now());
|
|
118
|
-
} catch {
|
|
119
|
-
E("Could not copy. Allow clipboard access and try again.");
|
|
120
|
-
} finally {
|
|
121
|
-
S(!1);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
disabled: M || x,
|
|
126
|
-
children: [/* @__PURE__ */ p(c, {
|
|
127
|
-
size: 14,
|
|
128
|
-
"aria-hidden": !0
|
|
129
|
-
}), x ? "Copying…" : `Copy ${g.size || ""} for agent`.trim()]
|
|
130
|
-
})]
|
|
131
|
-
})
|
|
132
|
-
]
|
|
133
|
-
}),
|
|
134
|
-
k && /* @__PURE__ */ m("p", {
|
|
135
|
-
className: "ck-dev-export-truncation",
|
|
136
|
-
role: "note",
|
|
137
|
-
children: [
|
|
138
|
-
"Showing first ",
|
|
139
|
-
O.length,
|
|
140
|
-
" of ",
|
|
141
|
-
D,
|
|
142
|
-
" open comments."
|
|
143
|
-
]
|
|
144
|
-
}),
|
|
145
|
-
/* @__PURE__ */ p(u, {
|
|
146
|
-
className: "ck-dev-export-scroll",
|
|
147
|
-
children: O.length === 0 ? /* @__PURE__ */ p(o, {
|
|
148
|
-
className: "ck-dev-export-empty",
|
|
149
|
-
children: "No open stakeholder comments on this project. Comments left in production or staging will show up here for bulk export."
|
|
150
|
-
}) : /* @__PURE__ */ p("ul", {
|
|
151
|
-
className: "ck-dev-export-list",
|
|
152
|
-
children: O.map((e) => {
|
|
153
|
-
let t = g.has(e.id);
|
|
154
|
-
return /* @__PURE__ */ m("li", {
|
|
155
|
-
className: "ck-dev-export-row",
|
|
156
|
-
"data-checked": t,
|
|
157
|
-
children: [/* @__PURE__ */ p(l, {
|
|
158
|
-
checked: t,
|
|
159
|
-
onCheckedChange: () => N(e.id),
|
|
160
|
-
"aria-label": `Select ${e.title}`
|
|
161
|
-
}), /* @__PURE__ */ m("div", {
|
|
162
|
-
className: "ck-dev-export-row-body",
|
|
163
|
-
onClick: () => N(e.id),
|
|
164
|
-
children: [/* @__PURE__ */ p("div", {
|
|
165
|
-
className: "ck-dev-export-row-title",
|
|
166
|
-
children: e.title
|
|
167
|
-
}), /* @__PURE__ */ m("div", {
|
|
168
|
-
className: "ck-dev-export-row-meta",
|
|
169
|
-
children: [
|
|
170
|
-
/* @__PURE__ */ p("span", {
|
|
171
|
-
"data-priority": e.priority,
|
|
172
|
-
children: e.priority
|
|
173
|
-
}),
|
|
174
|
-
/* @__PURE__ */ p("span", { children: "·" }),
|
|
175
|
-
/* @__PURE__ */ p("span", { children: e.author }),
|
|
176
|
-
/* @__PURE__ */ p("span", { children: "·" }),
|
|
177
|
-
/* @__PURE__ */ p("span", {
|
|
178
|
-
title: e.page,
|
|
179
|
-
children: e.page
|
|
180
|
-
})
|
|
181
|
-
]
|
|
182
|
-
})]
|
|
183
|
-
})]
|
|
184
|
-
}, e.id);
|
|
185
|
-
})
|
|
186
|
-
})
|
|
187
|
-
}),
|
|
188
|
-
T && /* @__PURE__ */ p("p", {
|
|
189
|
-
className: "ck-dev-export-error",
|
|
190
|
-
role: "alert",
|
|
191
|
-
children: T
|
|
192
|
-
}),
|
|
193
|
-
C && !T && /* @__PURE__ */ p("p", {
|
|
194
|
-
className: "ck-dev-export-success",
|
|
195
|
-
role: "status",
|
|
196
|
-
children: "Copied. Paste into your agent now."
|
|
197
|
-
})
|
|
198
|
-
]
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
function x(e) {
|
|
202
|
-
return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("style", {
|
|
203
|
-
"data-ck-tool-styles": "dev-export",
|
|
204
|
-
children: g
|
|
205
|
-
}), /* @__PURE__ */ p(b, { ...e })] });
|
|
206
|
-
}
|
|
207
|
-
export { x as DevExportPanel };
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { f as e, g as t, p as n } from "./comment-kit-core-B0k7XsMz.js";
|
|
2
|
-
import { a as r, i, o as a } from "./dom-Bhf4WFtY.js";
|
|
3
|
-
import { n as o, t as s } from "./capture-privacy-DUROnio5.js";
|
|
4
|
-
import { a as c, n as l, t as u } from "./text-B4HHZNaa.js";
|
|
5
|
-
import { captureScreenshot as d } from "./screenshot-B-ZfFItT.js";
|
|
6
|
-
var f = 4e3, p = 500, m = 2e3, h = 1e3, g = 5, _ = 25, v = 3145728;
|
|
7
|
-
function y() {
|
|
8
|
-
let { url: e, path: t, title: n } = a();
|
|
9
|
-
return {
|
|
10
|
-
url: c(e),
|
|
11
|
-
path: c(t),
|
|
12
|
-
title: n
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function b(e) {
|
|
16
|
-
let t = l(e?.comment, m);
|
|
17
|
-
return t.length > 0 ? t : null;
|
|
18
|
-
}
|
|
19
|
-
function x(e) {
|
|
20
|
-
return (e?.attachments ?? []).slice(0, g).flatMap((e) => {
|
|
21
|
-
let t = l(e.name, h), n = l(e.path, h);
|
|
22
|
-
return !t || !n ? [] : [{
|
|
23
|
-
name: t,
|
|
24
|
-
path: n,
|
|
25
|
-
...e.pathSource ? { pathSource: e.pathSource } : {},
|
|
26
|
-
...e.type ? { type: l(e.type, h) } : {},
|
|
27
|
-
...typeof e.size == "number" ? { size: e.size } : {},
|
|
28
|
-
...typeof e.lastModified == "number" ? { lastModified: e.lastModified } : {}
|
|
29
|
-
}];
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
function S(e) {
|
|
33
|
-
return typeof HTMLElement < "u" && e instanceof HTMLElement;
|
|
34
|
-
}
|
|
35
|
-
function C(e, t, n, a) {
|
|
36
|
-
let s = e.getBoundingClientRect(), c = i(e), u = r(e), d = e.getAttribute("class"), m = e.getAttribute("role"), h = e.getAttribute("aria-label"), g = o(e), _ = l(g.text, p), v = l(g.html, f);
|
|
37
|
-
return {
|
|
38
|
-
found: !0,
|
|
39
|
-
tagName: e.tagName.toLowerCase(),
|
|
40
|
-
...e.id ? { id: e.id } : {},
|
|
41
|
-
...d ? { className: d } : {},
|
|
42
|
-
...m ? { role: m } : {},
|
|
43
|
-
...h ? { ariaLabel: h } : {},
|
|
44
|
-
..._ ? { text: _ } : {},
|
|
45
|
-
rect: {
|
|
46
|
-
top: s.top,
|
|
47
|
-
left: s.left,
|
|
48
|
-
width: s.width,
|
|
49
|
-
height: s.height
|
|
50
|
-
},
|
|
51
|
-
...v ? { htmlPreview: v } : {},
|
|
52
|
-
...c ? { selector: c } : {},
|
|
53
|
-
...u ? { xpath: u } : {},
|
|
54
|
-
...t ? {
|
|
55
|
-
source: w(t),
|
|
56
|
-
stack: n.map(w)
|
|
57
|
-
} : {},
|
|
58
|
-
...a ? { componentName: a } : {}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function w(e) {
|
|
62
|
-
return {
|
|
63
|
-
filePath: e.filePath,
|
|
64
|
-
lineNumber: e.lineNumber,
|
|
65
|
-
columnNumber: e.columnNumber,
|
|
66
|
-
componentName: e.componentName
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function T(e) {
|
|
70
|
-
let t = `${l(e.filePath, 2e3)}${e.lineNumber === null ? "" : `:${e.lineNumber}`}${e.columnNumber === null ? "" : `:${e.columnNumber}`}`;
|
|
71
|
-
return e.componentName ? `${l(e.componentName, 300)} (${t})` : t;
|
|
72
|
-
}
|
|
73
|
-
function E(e, t, n, r, i, a) {
|
|
74
|
-
let o = [
|
|
75
|
-
"# CommentKit Element Grab",
|
|
76
|
-
"",
|
|
77
|
-
u,
|
|
78
|
-
""
|
|
79
|
-
], s = l(t.tagName ?? "element", 100), c = t.id ? `#${l(t.id, 300)}` : "";
|
|
80
|
-
if (o.push(`**Tag:** \`${s}${c}\``), i && o.push(`**Comment:** ${i}`), a.length > 0) {
|
|
81
|
-
o.push("", "**Attachments:**");
|
|
82
|
-
for (let e of a) {
|
|
83
|
-
let t = [
|
|
84
|
-
e.type ? `type: \`${e.type}\`` : null,
|
|
85
|
-
typeof e.size == "number" ? `size: ${e.size} bytes` : null,
|
|
86
|
-
e.pathSource ? `path source: ${e.pathSource}` : null
|
|
87
|
-
].filter(Boolean).join(", ");
|
|
88
|
-
o.push(`- \`${e.name}\` - path: \`${e.path}\`${t ? ` (${t})` : ""}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (t.componentName && o.push(`**Component:** \`${l(t.componentName, 300)}\``), t.source && o.push(`**Source:** ${T(t.source)}`), t.stack && t.stack.length > 1) {
|
|
92
|
-
o.push("", "**Stack:**");
|
|
93
|
-
for (let e of t.stack) o.push(`- ${T(e)}`);
|
|
94
|
-
}
|
|
95
|
-
return t.source || (t.selector && o.push(`**Selector:** \`${l(t.selector, 2e3)}\``), t.xpath && o.push(`**XPath:** \`${l(t.xpath, 2e3)}\``)), o.push(`**Page:** ${l(e.title || "Untitled", 300)} — ${l(e.url || e.path, 4e3)}`), o.push(""), o.push("**HTML:**", "```html", n, "```", ""), r && o.push("**Screenshot:** captured. If no image accompanies this paste, attach it from the export preview.", ""), o.join("\n");
|
|
96
|
-
}
|
|
97
|
-
function D(e) {
|
|
98
|
-
let t = e.element;
|
|
99
|
-
return {
|
|
100
|
-
tagName: t.tagName,
|
|
101
|
-
id: t.id,
|
|
102
|
-
className: t.className,
|
|
103
|
-
textContent: t.text,
|
|
104
|
-
componentName: t.componentName,
|
|
105
|
-
filePath: t.source?.filePath,
|
|
106
|
-
lineNumber: t.source?.lineNumber ?? void 0,
|
|
107
|
-
columnNumber: t.source?.columnNumber ?? void 0,
|
|
108
|
-
comment: e.comment ?? void 0,
|
|
109
|
-
attachments: e.attachments,
|
|
110
|
-
selector: t.selector,
|
|
111
|
-
xpath: t.xpath
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function O(e) {
|
|
115
|
-
if (typeof window > "u" || typeof window.dispatchEvent != "function") return;
|
|
116
|
-
let t = e[0];
|
|
117
|
-
t && window.dispatchEvent(new CustomEvent("commentkit:element-selected", { detail: {
|
|
118
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
119
|
-
page: t.page,
|
|
120
|
-
elements: e.map(D)
|
|
121
|
-
} }));
|
|
122
|
-
}
|
|
123
|
-
async function k(r, i, a, o) {
|
|
124
|
-
if (!r || typeof Element > "u" || !(r instanceof Element) || typeof r.getBoundingClientRect != "function" || s(r)) return null;
|
|
125
|
-
let c = (S(r), r), l = await t(r), u = l?.source ?? null, f = l?.stack ?? [], p = l?.componentName ?? null, m = await d(i, a, c, { reportErrors: !1 }), h = m?.dataUrl ?? null, g = m?.blob ?? null, _ = C(r, u, f, p), v = _.htmlPreview ?? "", w = y(), T = b(o), D = x(o), k = E(w, _, v, h, T, D);
|
|
126
|
-
try {
|
|
127
|
-
g ? await e(k, g) : await n(k);
|
|
128
|
-
} catch {}
|
|
129
|
-
let A = {
|
|
130
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
131
|
-
page: w,
|
|
132
|
-
element: _,
|
|
133
|
-
comment: T,
|
|
134
|
-
attachments: D,
|
|
135
|
-
html: v,
|
|
136
|
-
screenshotDataUrl: h,
|
|
137
|
-
markdown: k
|
|
138
|
-
};
|
|
139
|
-
return O([A]), A;
|
|
140
|
-
}
|
|
141
|
-
function A(e, t, n, r) {
|
|
142
|
-
let i = [
|
|
143
|
-
"# CommentKit Element Grab",
|
|
144
|
-
"",
|
|
145
|
-
u,
|
|
146
|
-
"",
|
|
147
|
-
`**Elements:** ${t.length}`,
|
|
148
|
-
`**Page:** ${l(e.title || "Untitled", 300)} — ${l(e.url || e.path, 4e3)}`
|
|
149
|
-
];
|
|
150
|
-
if (n && i.push(`**Comment:** ${n}`), r.length > 0) {
|
|
151
|
-
i.push("", "**Attachments:**");
|
|
152
|
-
for (let e of r) i.push(`- \`${e.name}\` - path: \`${e.path}\`${e.pathSource ? ` (path source: ${e.pathSource})` : ""}`);
|
|
153
|
-
}
|
|
154
|
-
return i.push(""), t.forEach((e, t) => {
|
|
155
|
-
let { element: n } = e, r = l(n.tagName ?? "element", 100), a = n.id ? `#${l(n.id, 300)}` : "";
|
|
156
|
-
i.push(`## [${t + 1}] \`${r}${a}\``), n.componentName && i.push(`- Component: \`${l(n.componentName, 300)}\``), n.source && i.push(`- Source: ${T(n.source)}`), n.stack && n.stack.length > 1 && i.push(`- Stack: ${n.stack.map((e) => l(e.componentName ?? e.filePath, 2e3)).join(" → ")}`), n.source || (n.selector && i.push(`- Selector: \`${l(n.selector, 2e3)}\``), n.xpath && i.push(`- XPath: \`${l(n.xpath, 2e3)}\``)), i.push("", "```html", e.html, "```", ""), e.screenshotDataUrl && i.push(``, "");
|
|
157
|
-
}), i.join("\n");
|
|
158
|
-
}
|
|
159
|
-
async function j(e, r, i, a) {
|
|
160
|
-
let o = e.filter((e) => !!e && typeof Element < "u" && e instanceof Element && typeof e.getBoundingClientRect == "function" && !s(e));
|
|
161
|
-
if (o.length === 0) return null;
|
|
162
|
-
let c = o.slice(0, _);
|
|
163
|
-
o.length > _ && typeof console < "u" && console.warn(`[CommentKit] grabElements was called with ${o.length} elements — capped to ${_} for clipboard size. Pass fewer elements to avoid truncation.`);
|
|
164
|
-
let l = [], u = 0, f = 0, p = b(a), m = x(a);
|
|
165
|
-
for (let e of c) {
|
|
166
|
-
let n = (S(e), e), a = await t(e), o = a?.source ?? null, s = a?.stack ?? [], c = a?.componentName ?? null, h = null;
|
|
167
|
-
if (u < v) {
|
|
168
|
-
let e = (await d(r, i, n, { reportErrors: !1 }))?.dataUrl ?? null;
|
|
169
|
-
e && u + e.length <= v ? (h = e, u += e.length) : e && f++;
|
|
170
|
-
} else f++;
|
|
171
|
-
let g = C(e, o, s, c), _ = g.htmlPreview ?? "", b = y(), x = E(b, g, _, h, p, m);
|
|
172
|
-
l.push({
|
|
173
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
174
|
-
page: b,
|
|
175
|
-
element: g,
|
|
176
|
-
comment: p,
|
|
177
|
-
attachments: m,
|
|
178
|
-
html: _,
|
|
179
|
-
screenshotDataUrl: h,
|
|
180
|
-
markdown: x
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
f > 0 && typeof console < "u" && console.warn(`[CommentKit] grabElements dropped ${f} screenshot${f === 1 ? "" : "s"} to stay under the ${Math.round(v / 1024 / 1024)}MB clipboard budget.`);
|
|
184
|
-
let h = y(), g = A(h, l, p, m);
|
|
185
|
-
try {
|
|
186
|
-
await n(g);
|
|
187
|
-
} catch {}
|
|
188
|
-
let w = {
|
|
189
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
190
|
-
page: h,
|
|
191
|
-
results: l,
|
|
192
|
-
attachments: m,
|
|
193
|
-
markdown: g
|
|
194
|
-
};
|
|
195
|
-
return O(l), w;
|
|
196
|
-
}
|
|
197
|
-
export { k as grabElement, j as grabElements };
|