@commentkit/comment-kit 0.7.7 → 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 +24 -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-CnhQgAvF.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-zeiCmKIr.js +0 -1086
- package/dist/shared/attachment-refresh-DAacLaRu.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-CiOrcAlt.js +0 -101
- package/dist/shared/comment-drawing-canvas-Btc12IsS.js +0 -124
- package/dist/shared/comment-icon-D8JTCEJ7.js +0 -607
- package/dist/shared/comment-image-lightbox--QpbcAtH.js +0 -190
- package/dist/shared/comment-images-content-C_r4SHM-.js +0 -214
- package/dist/shared/comment-kit-core-CmLUFujd.js +0 -3682
- package/dist/shared/comment-kit-ui-BHwYuSIi.js +0 -19391
- package/dist/shared/comment-screenshot-annotator-zJZyO-XM.js +0 -151
- package/dist/shared/comment-screenshot-overlay-CoKTYB0J.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-Cnt6oCZU.js +0 -207
- package/dist/shared/dev-grab-B85jo9AS.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-Cng84xC7.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-Dz7FB_Ak.js +0 -208
- package/dist/shared/realtime-recovery-BjlV-ewc.js +0 -162
- package/dist/shared/realtime-yGLX4wMK.js +0 -334
- package/dist/shared/request-activity-DQrAUwfA.js +0 -11
- package/dist/shared/screenshot-B5-hwpmt.js +0 -199
- package/dist/shared/separator-UhJb0Row.js +0 -3955
- package/dist/shared/shadow-root-B58ZI2yz.js +0 -133
- package/dist/shared/styles-CnYsLS2f.js +0 -2
- package/dist/shared/text-B4HHZNaa.js +0 -23
- package/dist/shared/token-session-D92MYbNu.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-KhH4hL0Q.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
package/SECURITY.md
CHANGED
|
@@ -32,25 +32,30 @@ We will credit reporters in release notes unless you prefer to remain anonymous.
|
|
|
32
32
|
|
|
33
33
|
This policy covers:
|
|
34
34
|
|
|
35
|
-
- **The CommentKit SDK** (`@commentkit/comment-kit`
|
|
36
|
-
- **The MCP server** (`comment-kit-mcp
|
|
35
|
+
- **The CommentKit SDK** (`@commentkit/comment-kit`): the script-tag loader, `init()`, the `<comment-kit>` element, and the React, Vue and Svelte helpers.
|
|
36
|
+
- **The MCP server** (`comment-kit-mcp`, in `mcp/`).
|
|
37
37
|
|
|
38
|
-
Vulnerabilities in the hosted
|
|
38
|
+
Vulnerabilities in the hosted service (`commentkit.dev`, the dashboard and API) are welcome at the same address.
|
|
39
39
|
|
|
40
|
-
##
|
|
40
|
+
## How CommentKit protects you
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
- **The project key identifies, it does not authorise.** `pk_…` keys are public. The API only accepts browser calls from the website addresses you list in Project → Installation (exact scheme, host and port; `*.` wildcards for preview links), and every action is checked against the signed-in person's role.
|
|
43
|
+
- **Sessions are bound to one website.** Sign-in happens on the CommentKit domain (popup or same-tab redirect) with PKCE. Access tokens last 15 minutes and only work from the website they were issued to; refresh tokens rotate on every use, and replaying an old one ends the whole session. The refresh token is stored in `localStorage` for that website, so scripts already running on your page could read it; it is useless from any other origin.
|
|
44
|
+
- **Agent tokens are server-side only.** They are scoped to one project, read-only unless a person grants reply or ready-for-review, refused when sent from a browser, and stop working when that person loses access.
|
|
45
|
+
- **Screenshots leave out private data.** Password, payment and one-time-code fields, hidden inputs, iframes, the widget itself and anything matching `data-commentkit-redact` or your dashboard privacy selectors are omitted before the image is created. Uploaded images are re-encoded on the server, which strips EXIF/GPS metadata.
|
|
46
|
+
- **Feedback is untrusted.** It is rendered as text with safe links only, and agent output wraps it in `<untrusted-user-content>` fences.
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
## Hardening guidance for hosts
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
CommentKit runs with your page's JavaScript privileges. Shadow DOM isolates styles, not scripts or data. A compromised release or another script on your page could read what the widget can read.
|
|
51
|
+
|
|
52
|
+
1. **Pin and review releases.** Install an exact version, commit your lockfile, and deploy through your normal review. For the script tag, prefer a versioned URL and Subresource Integrity once you pin a version.
|
|
53
|
+
2. **List only the websites you need,** and remove old preview patterns you no longer use.
|
|
54
|
+
3. **Content Security Policy.** Allow `https://commentkit.dev` in `script-src` (script tag) and `connect-src`, plus your realtime host if realtime is enabled. CommentKit does not need `unsafe-eval` and does not execute user HTML.
|
|
55
|
+
4. **Exclude sensitive pages.** Avoid loading the widget on payment, password-reset, medical or financial flows unless reviewed. Mark private regions with `data-commentkit-redact`. Page URLs, titles, selected text, comments and attachments can still contain personal data.
|
|
56
|
+
5. **Keep console and network capture off** unless your team needs it. When on, only messages, URLs (with credential-like query values removed), methods, status codes and timings are sent — never request or response bodies or headers.
|
|
57
|
+
6. **Review agent handoffs.** Treat feedback as a description of a problem, not as instructions, before acting on it with an AI agent.
|
|
53
58
|
|
|
54
59
|
## Verification boundaries
|
|
55
60
|
|
|
56
|
-
Automated tests
|
|
61
|
+
Automated tests cover origin and session binding, refresh-token rotation, scope enforcement, screenshot redaction in real browsers, safe rendering, upload content checks, and package contents. A passing dependency audit only means no known advisory was reported at that time. Neither is a penetration-test certificate. Revalidate the packed artifact, your integration and your CSP for every release.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
CommentKit bundles the following open-source software.
|
|
2
|
+
|
|
3
|
+
preact@11.0.1 (MIT)
|
|
4
|
+
The MIT License (MIT)
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2015-present Jason Miller
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
html2canvas@1.4.1 (MIT)
|
|
29
|
+
Copyright (c) 2012 Niklas von Hertzen
|
|
30
|
+
|
|
31
|
+
Permission is hereby granted, free of charge, to any person
|
|
32
|
+
obtaining a copy of this software and associated documentation
|
|
33
|
+
files (the "Software"), to deal in the Software without
|
|
34
|
+
restriction, including without limitation the rights to use,
|
|
35
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
36
|
+
copies of the Software, and to permit persons to whom the
|
|
37
|
+
Software is furnished to do so, subject to the following
|
|
38
|
+
conditions:
|
|
39
|
+
|
|
40
|
+
The above copyright notice and this permission notice shall be
|
|
41
|
+
included in all copies or substantial portions of the Software.
|
|
42
|
+
|
|
43
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
44
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
45
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
46
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
47
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
48
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
49
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
50
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
pusher-js@8.6.0 (MIT)
|
|
55
|
+
Copyright (c) 2020 Pusher, Ltd (https://pusher.com)
|
|
56
|
+
|
|
57
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
58
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
59
|
+
in the Software without restriction, including without limitation the rights
|
|
60
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
61
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
62
|
+
furnished to do so, subject to the following conditions:
|
|
63
|
+
|
|
64
|
+
The above copyright notice and this permission notice shall be included in
|
|
65
|
+
all copies or substantial portions of the Software.
|
|
66
|
+
|
|
67
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
68
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
69
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
70
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
71
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
72
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
73
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
function e(e) {
|
|
2
|
+
return !!e?.closest("[data-commentkit-host],[data-commentkit-ui]");
|
|
3
|
+
}
|
|
4
|
+
function t(e) {
|
|
5
|
+
let t = n(e.element), i = t.getBoundingClientRect(), s = Math.max(1, i.width), l = Math.max(1, i.height), u = (e) => Math.min(1, Math.max(0, e)), d = e.endX !== void 0 && e.endY !== void 0 && Math.abs(e.endX - e.clientX) > 8 && Math.abs(e.endY - e.clientY) > 8, f = e.quote?.trim() ? e.quote.trim().slice(0, 2e3) : null, p = Math.min(e.clientX, e.endX ?? e.clientX), m = Math.min(e.clientY, e.endY ?? e.clientY);
|
|
6
|
+
return {
|
|
7
|
+
type: f ? "text" : d ? "region" : "element",
|
|
8
|
+
ck_id: t.closest("[data-ck-id]")?.getAttribute("data-ck-id") ?? null,
|
|
9
|
+
source: t.closest("[data-ck-src]")?.getAttribute("data-ck-src") ?? null,
|
|
10
|
+
selector: r(t),
|
|
11
|
+
xpath: a(t),
|
|
12
|
+
fingerprint: o(t),
|
|
13
|
+
quote: f,
|
|
14
|
+
offset: {
|
|
15
|
+
x: c(u((e.clientX - i.left) / s)),
|
|
16
|
+
y: c(u((e.clientY - i.top) / l))
|
|
17
|
+
},
|
|
18
|
+
rect: d ? {
|
|
19
|
+
x: c(u((p - i.left) / s)),
|
|
20
|
+
y: c(u((m - i.top) / l)),
|
|
21
|
+
w: c(u(Math.abs((e.endX ?? 0) - e.clientX) / s)),
|
|
22
|
+
h: c(u(Math.abs((e.endY ?? 0) - e.clientY) / l))
|
|
23
|
+
} : null,
|
|
24
|
+
page: {
|
|
25
|
+
x: c((e.clientX + scrollX) / Math.max(1, document.documentElement.scrollWidth) * 100, 2),
|
|
26
|
+
y: Math.round(e.clientY + scrollY)
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function n(t) {
|
|
31
|
+
let n = t.closest("a,button,[role=button],input,select,textarea,label,summary");
|
|
32
|
+
return n && !e(n) ? n : t;
|
|
33
|
+
}
|
|
34
|
+
function r(e) {
|
|
35
|
+
if (!e.isConnected) return null;
|
|
36
|
+
let t = [], n = e;
|
|
37
|
+
for (let e = 0; n && n !== document.documentElement && e < 8; e++) {
|
|
38
|
+
let e = n.getAttribute("id");
|
|
39
|
+
if (e && i(e)) {
|
|
40
|
+
t.unshift(`#${CSS.escape(e)}`);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
let r = [
|
|
44
|
+
"data-ck-id",
|
|
45
|
+
"data-testid",
|
|
46
|
+
"data-test",
|
|
47
|
+
"data-cy",
|
|
48
|
+
"name"
|
|
49
|
+
].find((e) => n.getAttribute(e));
|
|
50
|
+
if (r) {
|
|
51
|
+
if (t.unshift(`${n.tagName.toLowerCase()}[${r}="${CSS.escape(n.getAttribute(r))}"]`), r !== "name") break;
|
|
52
|
+
n = n.parentElement;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
let a = n.tagName.toLowerCase(), o = [...n.classList].filter(i).slice(0, 2);
|
|
56
|
+
o.length && (a += o.map((e) => `.${CSS.escape(e)}`).join(""));
|
|
57
|
+
let s = n.parentElement;
|
|
58
|
+
if (s) {
|
|
59
|
+
let e = [...s.children].filter((e) => e.tagName === n.tagName);
|
|
60
|
+
e.length > 1 && (a += `:nth-of-type(${e.indexOf(n) + 1})`);
|
|
61
|
+
}
|
|
62
|
+
t.unshift(a), n = s;
|
|
63
|
+
}
|
|
64
|
+
return t.length ? t.join(" > ").slice(0, 1e3) : null;
|
|
65
|
+
}
|
|
66
|
+
function i(e) {
|
|
67
|
+
return e.length > 40 || e.length < 2 || /^(css|sc|jsx|emotion|svelte|astro)-[a-z0-9]+$/i.test(e) || /[0-9a-f]{5,}/i.test(e) && /\d/.test(e) || /^[a-z]+_[a-z0-9]{5,}$/i.test(e) || /^(radix|headlessui|react-aria|mui)-/i.test(e) || /:r[0-9a-z]+:/i.test(e) ? !1 : /^[a-zA-Z_][\w-]*$/.test(e);
|
|
68
|
+
}
|
|
69
|
+
function a(e) {
|
|
70
|
+
let t = [], n = e;
|
|
71
|
+
for (; n && n.nodeType === 1 && t.length < 30;) {
|
|
72
|
+
let e = 1;
|
|
73
|
+
for (let t = n.previousElementSibling; t; t = t.previousElementSibling) t.tagName === n.tagName && e++;
|
|
74
|
+
t.unshift(`${n.tagName.toLowerCase()}[${e}]`), n = n.parentElement;
|
|
75
|
+
}
|
|
76
|
+
return t.length ? `/${t.join("/")}`.slice(0, 2e3) : null;
|
|
77
|
+
}
|
|
78
|
+
function o(e) {
|
|
79
|
+
let t = s(e.textContent ?? "").slice(0, 160), n = s(e.getAttribute("aria-label") ?? e.getAttribute("alt") ?? e.getAttribute("placeholder") ?? "") || t;
|
|
80
|
+
return n ? `${e.tagName.toLowerCase()}|${n}`.slice(0, 500) : null;
|
|
81
|
+
}
|
|
82
|
+
function s(e) {
|
|
83
|
+
return e.replace(/\s+/g, " ").trim().toLowerCase();
|
|
84
|
+
}
|
|
85
|
+
function c(e, t = 4) {
|
|
86
|
+
let n = 10 ** t;
|
|
87
|
+
return Math.round(e * n) / n;
|
|
88
|
+
}
|
|
89
|
+
function l(e, t = document) {
|
|
90
|
+
let n = u(e, t);
|
|
91
|
+
if (e.type === "text" && e.quote) {
|
|
92
|
+
let t = v(e.quote, n?.element ?? document.body);
|
|
93
|
+
if (t) {
|
|
94
|
+
let e = t.getBoundingClientRect();
|
|
95
|
+
return {
|
|
96
|
+
state: n?.state ?? "moved",
|
|
97
|
+
element: n?.element ?? t.startContainer.parentElement,
|
|
98
|
+
point: {
|
|
99
|
+
x: e.left + scrollX,
|
|
100
|
+
y: e.top + scrollY
|
|
101
|
+
},
|
|
102
|
+
rect: {
|
|
103
|
+
x: e.left + scrollX,
|
|
104
|
+
y: e.top + scrollY,
|
|
105
|
+
w: e.width,
|
|
106
|
+
h: e.height
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (n) {
|
|
112
|
+
let t = n.element.getBoundingClientRect(), r = e.offset ?? {
|
|
113
|
+
x: .5,
|
|
114
|
+
y: .5
|
|
115
|
+
}, i = e.rect ? {
|
|
116
|
+
x: t.left + scrollX + e.rect.x * t.width,
|
|
117
|
+
y: t.top + scrollY + e.rect.y * t.height,
|
|
118
|
+
w: e.rect.w * t.width,
|
|
119
|
+
h: e.rect.h * t.height
|
|
120
|
+
} : null;
|
|
121
|
+
return {
|
|
122
|
+
state: n.state,
|
|
123
|
+
element: n.element,
|
|
124
|
+
point: i ? {
|
|
125
|
+
x: i.x,
|
|
126
|
+
y: i.y
|
|
127
|
+
} : {
|
|
128
|
+
x: t.left + scrollX + r.x * t.width,
|
|
129
|
+
y: t.top + scrollY + r.y * t.height
|
|
130
|
+
},
|
|
131
|
+
rect: i
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
state: "detached",
|
|
136
|
+
element: null,
|
|
137
|
+
point: {
|
|
138
|
+
x: e.page.x / 100 * document.documentElement.scrollWidth,
|
|
139
|
+
y: e.page.y
|
|
140
|
+
},
|
|
141
|
+
rect: null
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function u(t, n) {
|
|
145
|
+
let r = (t) => !!t && t.isConnected && !e(t) && _(t);
|
|
146
|
+
if (t.ck_id) {
|
|
147
|
+
let e = n.querySelector(`[data-ck-id="${CSS.escape(t.ck_id)}"]`);
|
|
148
|
+
if (r(e)) return {
|
|
149
|
+
element: e,
|
|
150
|
+
state: "anchored"
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (t.source) {
|
|
154
|
+
let e = [...n.querySelectorAll(`[data-ck-src="${CSS.escape(t.source)}"]`)].filter(r), i = m(e, t.fingerprint);
|
|
155
|
+
if (i) return {
|
|
156
|
+
element: i.el,
|
|
157
|
+
state: e.length === 1 || i.score > .9 ? "anchored" : "moved"
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (t.selector) {
|
|
161
|
+
let e = [];
|
|
162
|
+
try {
|
|
163
|
+
e = [...n.querySelectorAll(t.selector)].filter(r);
|
|
164
|
+
} catch {}
|
|
165
|
+
let i = m(e, t.fingerprint);
|
|
166
|
+
if (i && (i.score >= .6 || !t.fingerprint)) return {
|
|
167
|
+
element: i.el,
|
|
168
|
+
state: i.score >= .9 || !t.fingerprint ? "anchored" : "moved"
|
|
169
|
+
};
|
|
170
|
+
if (i && e.length === 1 && !t.selector.includes(" > ") && d.test(t.selector)) return {
|
|
171
|
+
element: i.el,
|
|
172
|
+
state: "moved"
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
if (t.xpath) {
|
|
176
|
+
let e = g(t.xpath);
|
|
177
|
+
if (r(e) && (!t.fingerprint || h(o(e), t.fingerprint) >= .8)) return {
|
|
178
|
+
element: e,
|
|
179
|
+
state: "moved"
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (t.fingerprint) {
|
|
183
|
+
let [e, i] = p(t.fingerprint);
|
|
184
|
+
if (e && /^[a-z0-9]+$/.test(e)) {
|
|
185
|
+
let i = m([...n.querySelectorAll(e)].filter(r).slice(0, 2e3), t.fingerprint);
|
|
186
|
+
if (i && i.score >= .85) return {
|
|
187
|
+
element: i.el,
|
|
188
|
+
state: "moved"
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if (i && i.length >= 12) {
|
|
192
|
+
let e = [...n.querySelectorAll(f)].filter(r).slice(0, 2e3), t = null;
|
|
193
|
+
for (let n of e) {
|
|
194
|
+
let e = h(p(o(n) ?? "")[1], i);
|
|
195
|
+
e >= .95 && (!t || e > t.score) && (t = {
|
|
196
|
+
el: n,
|
|
197
|
+
score: e
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (t) return {
|
|
201
|
+
element: t.el,
|
|
202
|
+
state: "moved"
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
var d = /^(#|[a-z0-9]+\[data-(ck-id|testid|test|cy)=)/, f = "h1,h2,h3,h4,h5,h6,p,li,td,th,a,button,label,span,div,section,article,dt,dd,figcaption,blockquote";
|
|
209
|
+
function p(e) {
|
|
210
|
+
let t = e.indexOf("|");
|
|
211
|
+
return t < 0 ? ["", e] : [e.slice(0, t), e.slice(t + 1)];
|
|
212
|
+
}
|
|
213
|
+
function m(e, t) {
|
|
214
|
+
if (!e.length) return null;
|
|
215
|
+
if (!t) return {
|
|
216
|
+
el: e[0],
|
|
217
|
+
score: 1
|
|
218
|
+
};
|
|
219
|
+
let n = null;
|
|
220
|
+
for (let r of e) {
|
|
221
|
+
let e = h(o(r), t);
|
|
222
|
+
if ((!n || e > n.score) && (n = {
|
|
223
|
+
el: r,
|
|
224
|
+
score: e
|
|
225
|
+
}), e === 1) break;
|
|
226
|
+
}
|
|
227
|
+
return n;
|
|
228
|
+
}
|
|
229
|
+
function h(e, t) {
|
|
230
|
+
if (!e || !t) return 0;
|
|
231
|
+
if (e === t) return 1;
|
|
232
|
+
let n = (e) => {
|
|
233
|
+
let t = /* @__PURE__ */ new Map();
|
|
234
|
+
for (let n = 0; n < e.length - 1; n++) {
|
|
235
|
+
let r = e.slice(n, n + 2);
|
|
236
|
+
t.set(r, (t.get(r) ?? 0) + 1);
|
|
237
|
+
}
|
|
238
|
+
return t;
|
|
239
|
+
}, r = n(e), i = n(t), a = 0;
|
|
240
|
+
for (let [e, t] of r) a += Math.min(t, i.get(e) ?? 0);
|
|
241
|
+
let o = Math.max(1, e.length - 1 + (t.length - 1));
|
|
242
|
+
return 2 * a / o;
|
|
243
|
+
}
|
|
244
|
+
function g(e) {
|
|
245
|
+
try {
|
|
246
|
+
let t = document.evaluate(e, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
|
|
247
|
+
return t.singleNodeValue instanceof Element ? t.singleNodeValue : null;
|
|
248
|
+
} catch {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function _(e) {
|
|
253
|
+
let t = e.getBoundingClientRect();
|
|
254
|
+
return t.width > 0 || t.height > 0 || typeof navigator < "u" && navigator.userAgent.includes("jsdom");
|
|
255
|
+
}
|
|
256
|
+
function v(t, n) {
|
|
257
|
+
let r = t.replace(/\s+/g, " ").trim();
|
|
258
|
+
if (!r) return null;
|
|
259
|
+
let i = document.createTreeWalker(n, NodeFilter.SHOW_TEXT, { acceptNode: (t) => e(t.parentElement) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT });
|
|
260
|
+
for (let e = i.nextNode(); e; e = i.nextNode()) {
|
|
261
|
+
let t = e.textContent ?? "", n = t.indexOf(r.slice(0, Math.min(r.length, 60)));
|
|
262
|
+
if (n >= 0) {
|
|
263
|
+
let i = document.createRange();
|
|
264
|
+
return i.setStart(e, n), i.setEnd(e, Math.min(t.length, n + r.length)), i;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
270
|
+
export { r as i, e as n, l as r, t };
|