@ubio/webvision 1.2.6 → 2.1.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/build/page.mjs +760 -355
- package/out/page/counter.d.ts +6 -0
- package/out/page/counter.js +13 -0
- package/out/page/counter.js.map +1 -0
- package/out/page/dom.d.ts +21 -0
- package/out/page/dom.js +172 -0
- package/out/page/dom.js.map +1 -0
- package/out/page/frame.d.ts +22 -0
- package/out/page/frame.js +69 -0
- package/out/page/frame.js.map +1 -0
- package/out/page/index.d.ts +9 -3
- package/out/page/index.js +9 -3
- package/out/page/index.js.map +1 -1
- package/out/page/overlay.d.ts +3 -0
- package/out/page/overlay.js +75 -0
- package/out/page/overlay.js.map +1 -0
- package/out/page/parser.d.ts +59 -0
- package/out/page/parser.js +249 -0
- package/out/page/parser.js.map +1 -0
- package/out/page/probe.d.ts +5 -0
- package/out/page/probe.js +36 -0
- package/out/page/probe.js.map +1 -0
- package/out/page/render.d.ts +12 -8
- package/out/page/render.js +73 -38
- package/out/page/render.js.map +1 -1
- package/out/page/snapshot.d.ts +9 -68
- package/out/page/snapshot.js +23 -183
- package/out/page/snapshot.js.map +1 -1
- package/out/page/traverse.d.ts +5 -0
- package/out/page/traverse.js +7 -0
- package/out/page/traverse.js.map +1 -0
- package/out/page/tree.d.ts +22 -0
- package/out/page/tree.js +59 -0
- package/out/page/tree.js.map +1 -0
- package/out/page/util.d.ts +3 -0
- package/out/page/util.js +9 -0
- package/out/page/util.js.map +1 -0
- package/package.json +6 -3
- package/out/page/highlight.d.ts +0 -5
- package/out/page/highlight.js +0 -72
- package/out/page/highlight.js.map +0 -1
- package/out/page/html.d.ts +0 -4
- package/out/page/html.js +0 -42
- package/out/page/html.js.map +0 -1
- package/out/page/utils.d.ts +0 -19
- package/out/page/utils.js +0 -68
- package/out/page/utils.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"counter.js","sourceRoot":"","sources":["../../src/page/counter.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,OAAO;IAEhB,YAAmB,QAAQ,CAAC;QAAT,UAAK,GAAL,KAAK,CAAI;IAAG,CAAC;IAEhC,IAAI;QACA,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;CAEJ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const INTERACTIVE_TAGS: string[];
|
|
2
|
+
export declare const INTERACTIVE_ROLES: string[];
|
|
3
|
+
export interface Viewport {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function isHidden(el: Element): boolean;
|
|
8
|
+
export declare function getNormalizedText(el: Element): string;
|
|
9
|
+
export declare function normalizeText(str: string): string;
|
|
10
|
+
export declare function truncateAttrValue(value: string, limit?: number): string;
|
|
11
|
+
export declare function escapeAttribute(value: string): string;
|
|
12
|
+
export declare function containsSelector(el: Element, selector: string): boolean;
|
|
13
|
+
export declare function getOffsetTop(node: Node): number;
|
|
14
|
+
export declare function hasVisibleArea(element: Element): boolean;
|
|
15
|
+
export declare function isDeepHidden(element: Element): boolean;
|
|
16
|
+
export declare function isInteractive(el: Element): boolean;
|
|
17
|
+
export declare function getViewportSize(): Viewport;
|
|
18
|
+
export declare function isRectInViewport(rect: DOMRect, viewport: Viewport): boolean;
|
|
19
|
+
export declare function makeOverlaysOpaque(el: HTMLElement): void;
|
|
20
|
+
export declare function isRandomIdentifier(str: string): boolean;
|
|
21
|
+
export declare function fixZIndex(el: HTMLElement): void;
|
package/out/page/dom.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
const ORIGINAL_STYLE_SYMBOL = Symbol('vx:originalStyle');
|
|
2
|
+
export const INTERACTIVE_TAGS = ['a', 'button', 'input', 'textarea', 'select', 'label'];
|
|
3
|
+
export const INTERACTIVE_ROLES = [
|
|
4
|
+
'button', 'link', 'checkbox', 'radio', 'textbox', 'combobox', 'listbox', 'menu', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'option', 'optgroup', 'progressbar', 'scrollbar', 'slider', 'spinbutton', 'switch', 'tab', 'tablist', 'timer', 'toolbar'
|
|
5
|
+
];
|
|
6
|
+
export function isHidden(el) {
|
|
7
|
+
const style = getComputedStyle(el);
|
|
8
|
+
if (style.display === 'none') {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (style.visibility === 'hidden') {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (style.opacity === '0') {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
export function getNormalizedText(el) {
|
|
20
|
+
return normalizeText(el.textContent ?? '');
|
|
21
|
+
}
|
|
22
|
+
export function normalizeText(str) {
|
|
23
|
+
return str
|
|
24
|
+
.replace(/\p{Cf}/gu, ' ')
|
|
25
|
+
.replace(/\s+/g, ' ')
|
|
26
|
+
.trim();
|
|
27
|
+
}
|
|
28
|
+
export function truncateAttrValue(value, limit = 100) {
|
|
29
|
+
if (value.match(/^(javascript:)?void/)) {
|
|
30
|
+
return '';
|
|
31
|
+
}
|
|
32
|
+
if (value.startsWith('data:')) {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
if (value.length > limit) {
|
|
36
|
+
return value.slice(0, limit) + '…';
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
export function escapeAttribute(value) {
|
|
41
|
+
return value
|
|
42
|
+
.replace(/&/g, '&') // Escape ampersand first!
|
|
43
|
+
.replace(/"/g, '"') // Escape double quotes
|
|
44
|
+
.replace(/'/g, ''') // Escape single quotes
|
|
45
|
+
.replace(/</g, '<') // Escape less than
|
|
46
|
+
.replace(/>/g, '>') // Escape greater than
|
|
47
|
+
.replace(/\r?\n/g, ' '); // Replace newlines with space
|
|
48
|
+
}
|
|
49
|
+
export function containsSelector(el, selector) {
|
|
50
|
+
return el.matches(selector) || !!el.querySelector(selector);
|
|
51
|
+
}
|
|
52
|
+
export function getOffsetTop(node) {
|
|
53
|
+
let y = 0;
|
|
54
|
+
let current = node;
|
|
55
|
+
while (current) {
|
|
56
|
+
y += current.offsetTop ?? 0;
|
|
57
|
+
current = current.offsetParent;
|
|
58
|
+
}
|
|
59
|
+
return y;
|
|
60
|
+
}
|
|
61
|
+
export function hasVisibleArea(element) {
|
|
62
|
+
const rect = element.getBoundingClientRect();
|
|
63
|
+
const area = rect.width * rect.height;
|
|
64
|
+
return area > 64;
|
|
65
|
+
}
|
|
66
|
+
export function isDeepHidden(element) {
|
|
67
|
+
if (isHidden(element)) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
if (!hasVisibleArea(element)) {
|
|
71
|
+
return [...element.children].every(el => isDeepHidden(el));
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
export function isInteractive(el) {
|
|
76
|
+
const htmlEl = el;
|
|
77
|
+
if (INTERACTIVE_TAGS.includes(el.tagName.toLowerCase())) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
const tabindex = htmlEl.getAttribute('tabindex');
|
|
81
|
+
if (tabindex && parseInt(tabindex) >= 0) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
const role = htmlEl.getAttribute('role') ?? htmlEl.getAttribute('aria-role') ?? '';
|
|
85
|
+
if (INTERACTIVE_ROLES.includes(role)) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
if (htmlEl.onclick != null) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
export function getViewportSize() {
|
|
94
|
+
return {
|
|
95
|
+
width: window.innerWidth,
|
|
96
|
+
height: window.innerHeight,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export function isRectInViewport(rect, viewport) {
|
|
100
|
+
return rect.left < viewport.width &&
|
|
101
|
+
rect.right > 0 &&
|
|
102
|
+
rect.top < viewport.height &&
|
|
103
|
+
rect.bottom > 0;
|
|
104
|
+
}
|
|
105
|
+
export function makeOverlaysOpaque(el) {
|
|
106
|
+
if (!el[ORIGINAL_STYLE_SYMBOL]) {
|
|
107
|
+
el[ORIGINAL_STYLE_SYMBOL] = el.getAttribute('style');
|
|
108
|
+
}
|
|
109
|
+
// Only apply to big elements
|
|
110
|
+
const rect = el.getBoundingClientRect();
|
|
111
|
+
if (rect.width < 500 || rect.height < 500) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const style = getComputedStyle(el);
|
|
115
|
+
if (style.pointerEvents === 'none') {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
el.style.setProperty('animation', 'none', 'important');
|
|
119
|
+
el.style.setProperty('transition', 'none', 'important');
|
|
120
|
+
el.style.setProperty('backdrop-filter', 'none', 'important');
|
|
121
|
+
el.style.setProperty('mix-blend-mode', 'normal', 'important');
|
|
122
|
+
el.style.setProperty('opacity', '1', 'important');
|
|
123
|
+
el.style.setProperty('filter', 'none', 'important');
|
|
124
|
+
const bg = style.backgroundColor;
|
|
125
|
+
el.style.setProperty('background-color', removeAlpha(bg));
|
|
126
|
+
}
|
|
127
|
+
function removeAlpha(color) {
|
|
128
|
+
const rgba = color.match(/^rgba\((.*)\)$/);
|
|
129
|
+
if (!rgba) {
|
|
130
|
+
return color;
|
|
131
|
+
}
|
|
132
|
+
const [r, g, b, a] = rgba[1].split(',').map(parseFloat);
|
|
133
|
+
if (a > 0 && a < 1) {
|
|
134
|
+
return `rgba(${r},${g},${b},1)`;
|
|
135
|
+
}
|
|
136
|
+
return color;
|
|
137
|
+
}
|
|
138
|
+
export function isRandomIdentifier(str) {
|
|
139
|
+
const words = str.split(/[_-]/g);
|
|
140
|
+
return !words.some(w => isWordLike(w)) || words.some(w => isRandomString(w));
|
|
141
|
+
}
|
|
142
|
+
function isWordLike(str) {
|
|
143
|
+
if (str.length <= 2) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
// Words don't usually have a lot of vowels or consonants in a row
|
|
147
|
+
if (/[^eyuioa]{4,}/.test(str)) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (/[eyuioa]{4,}/.test(str)) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
function isRandomString(str) {
|
|
156
|
+
// Hex strings will often consist of at least one digit and A-F letters
|
|
157
|
+
if (/^[0-9a-f]+$/i.test(str) && /[0-9]/.test(str)) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
// Digits separated by non-digits are a sign of random ids
|
|
161
|
+
if (/[0-9][^0-9]+[0-9]/.test(str)) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
export function fixZIndex(el) {
|
|
167
|
+
const style = getComputedStyle(el);
|
|
168
|
+
if (Number(style.zIndex) > 2147483600) {
|
|
169
|
+
el.style.setProperty('z-index', '2147483600', 'important');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=dom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../../src/page/dom.ts"],"names":[],"mappings":"AAAA,MAAM,qBAAqB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACxF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,U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IAAI,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,GAAW;IAC/B,uEAAuE;IACvE,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,0DAA0D;IAC1D,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAe;IACrC,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACnC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;QACpC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAC/D,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { VxNode } from './parser.js';
|
|
2
|
+
import { VxRenderOptions } from './render.js';
|
|
3
|
+
export interface VxFrame {
|
|
4
|
+
frameId: number;
|
|
5
|
+
iframeRef?: number;
|
|
6
|
+
refRange: [number, number];
|
|
7
|
+
nodes: VxNode[];
|
|
8
|
+
isOmitted?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class VxPageView<T extends VxFrame> {
|
|
11
|
+
readonly vxFrames: T[];
|
|
12
|
+
private vxFrameMap;
|
|
13
|
+
private vxTreeMap;
|
|
14
|
+
constructor(vxFrames: T[]);
|
|
15
|
+
findFrameByFrameId(frameId: number): T | null;
|
|
16
|
+
getFrameByFrameId(frameId: number): T;
|
|
17
|
+
findFrameByRef(ref: number): T | null;
|
|
18
|
+
getFrameByRef(ref: number): T;
|
|
19
|
+
findParentFrame(frameId: number): T | null;
|
|
20
|
+
isFrameShown(frameId: number): boolean;
|
|
21
|
+
renderAll(options: VxRenderOptions): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { VxTreeView } from './tree.js';
|
|
2
|
+
export class VxPageView {
|
|
3
|
+
constructor(vxFrames) {
|
|
4
|
+
this.vxFrames = vxFrames;
|
|
5
|
+
this.vxFrameMap = new Map();
|
|
6
|
+
this.vxTreeMap = new Map();
|
|
7
|
+
for (const frame of vxFrames) {
|
|
8
|
+
this.vxFrameMap.set(frame.frameId, frame);
|
|
9
|
+
this.vxTreeMap.set(frame.frameId, new VxTreeView(frame.nodes));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
findFrameByFrameId(frameId) {
|
|
13
|
+
return this.vxFrameMap.get(frameId) ?? null;
|
|
14
|
+
}
|
|
15
|
+
getFrameByFrameId(frameId) {
|
|
16
|
+
const vxFrame = this.vxFrameMap.get(frameId);
|
|
17
|
+
if (vxFrame == null) {
|
|
18
|
+
throw new Error(`[VX] Frame not found for [frameId=${frameId}]`);
|
|
19
|
+
}
|
|
20
|
+
return vxFrame;
|
|
21
|
+
}
|
|
22
|
+
findFrameByRef(ref) {
|
|
23
|
+
const vxFrame = this.vxFrames.find(frame => ref >= frame.refRange[0] && ref <= frame.refRange[1]);
|
|
24
|
+
if (!vxFrame) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return this.vxFrameMap.get(vxFrame.frameId) ?? null;
|
|
28
|
+
}
|
|
29
|
+
getFrameByRef(ref) {
|
|
30
|
+
const vxFrame = this.findFrameByRef(ref);
|
|
31
|
+
if (vxFrame == null) {
|
|
32
|
+
throw new Error(`[VX] Frame not found for [ref=${ref}]`);
|
|
33
|
+
}
|
|
34
|
+
return vxFrame;
|
|
35
|
+
}
|
|
36
|
+
findParentFrame(frameId) {
|
|
37
|
+
const frame = this.getFrameByFrameId(frameId);
|
|
38
|
+
const iframeRef = frame?.iframeRef;
|
|
39
|
+
if (iframeRef == null) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return this.findFrameByRef(iframeRef);
|
|
43
|
+
}
|
|
44
|
+
isFrameShown(frameId) {
|
|
45
|
+
const frame = this.getFrameByFrameId(frameId);
|
|
46
|
+
if (!frame) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const parentFrame = this.findParentFrame(frameId);
|
|
50
|
+
const { iframeRef } = frame;
|
|
51
|
+
if (parentFrame == null || iframeRef == null) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
const vxTree = this.vxTreeMap.get(frameId);
|
|
55
|
+
const existsInParent = !!vxTree?.findNode(iframeRef);
|
|
56
|
+
return existsInParent ? this.isFrameShown(parentFrame.frameId) : false;
|
|
57
|
+
}
|
|
58
|
+
renderAll(options) {
|
|
59
|
+
return this.vxFrames.map(frame => {
|
|
60
|
+
const vxTree = this.vxTreeMap.get(frame.frameId);
|
|
61
|
+
const rendered = vxTree?.render(options);
|
|
62
|
+
return [
|
|
63
|
+
`FRAME ${frame.frameId}`,
|
|
64
|
+
rendered,
|
|
65
|
+
].join('\n\n');
|
|
66
|
+
}).join('\n\n');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame.js","sourceRoot":"","sources":["../../src/page/frame.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAUvC,MAAM,OAAO,UAAU;IAKnB,YAAqB,QAAa;QAAb,aAAQ,GAAR,QAAQ,CAAK;QAH1B,eAAU,GAAG,IAAI,GAAG,EAAa,CAAC;QAClC,cAAS,GAAG,IAAI,GAAG,EAAsB,CAAC;QAG9C,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC1C,IAAI,CAAC,SAAS,CA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AAI,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;CAEJ"}
|
package/out/page/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './counter.js';
|
|
2
|
+
export * from './dom.js';
|
|
3
|
+
export * from './frame.js';
|
|
4
|
+
export * from './overlay.js';
|
|
5
|
+
export * from './parser.js';
|
|
6
|
+
export * from './probe.js';
|
|
3
7
|
export * from './render.js';
|
|
4
8
|
export * from './snapshot.js';
|
|
5
|
-
export * from './
|
|
9
|
+
export * from './traverse.js';
|
|
10
|
+
export * from './tree.js';
|
|
11
|
+
export * from './util.js';
|
package/out/page/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './counter.js';
|
|
2
|
+
export * from './dom.js';
|
|
3
|
+
export * from './frame.js';
|
|
4
|
+
export * from './overlay.js';
|
|
5
|
+
export * from './parser.js';
|
|
6
|
+
export * from './probe.js';
|
|
3
7
|
export * from './render.js';
|
|
4
8
|
export * from './snapshot.js';
|
|
5
|
-
export * from './
|
|
9
|
+
export * from './traverse.js';
|
|
10
|
+
export * from './tree.js';
|
|
11
|
+
export * from './util.js';
|
|
6
12
|
//# sourceMappingURL=index.js.map
|
package/out/page/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/page/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/page/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { VX_IGNORE_SYMBOL } from './parser.js';
|
|
2
|
+
export function showPoint(x, y, clear = true) {
|
|
3
|
+
if (clear) {
|
|
4
|
+
clearOverlay();
|
|
5
|
+
}
|
|
6
|
+
const point = document.createElement('div');
|
|
7
|
+
point.style.position = 'absolute';
|
|
8
|
+
point.style.left = `${x}px`;
|
|
9
|
+
point.style.top = `${y}px`;
|
|
10
|
+
point.style.width = '32px';
|
|
11
|
+
point.style.height = '32px';
|
|
12
|
+
point.style.transform = 'translate(-50%, -50%)';
|
|
13
|
+
point.style.backgroundColor = 'red';
|
|
14
|
+
point.style.borderRadius = '100%';
|
|
15
|
+
point.style.opacity = '0.5';
|
|
16
|
+
const container = getOverlayContainer();
|
|
17
|
+
container.appendChild(point);
|
|
18
|
+
}
|
|
19
|
+
export function clearOverlay() {
|
|
20
|
+
const container = getOverlayContainer();
|
|
21
|
+
container.remove();
|
|
22
|
+
}
|
|
23
|
+
export function highlightEl(el, ref = 0) {
|
|
24
|
+
if (!(el instanceof Element)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const container = getOverlayContainer();
|
|
28
|
+
const color = getColor(ref);
|
|
29
|
+
const rect = el.getBoundingClientRect();
|
|
30
|
+
const overlay = document.createElement('div');
|
|
31
|
+
container.appendChild(overlay);
|
|
32
|
+
overlay.style.position = 'absolute';
|
|
33
|
+
overlay.style.top = `${rect.top}px`;
|
|
34
|
+
overlay.style.left = `${rect.left}px`;
|
|
35
|
+
overlay.style.width = `${rect.width}px`;
|
|
36
|
+
overlay.style.height = `${rect.height}px`;
|
|
37
|
+
overlay.style.border = `2px solid ${color}`;
|
|
38
|
+
const label = document.createElement('div');
|
|
39
|
+
overlay.appendChild(label);
|
|
40
|
+
label.style.position = 'absolute';
|
|
41
|
+
label.style.bottom = `100%`;
|
|
42
|
+
label.style.left = `0`;
|
|
43
|
+
label.style.backgroundColor = color;
|
|
44
|
+
label.style.color = 'white';
|
|
45
|
+
label.style.fontSize = '10px';
|
|
46
|
+
label.style.fontFamily = 'monospace';
|
|
47
|
+
label.style.fontWeight = 'normal';
|
|
48
|
+
label.style.fontStyle = 'normal';
|
|
49
|
+
label.style.opacity = '0.8';
|
|
50
|
+
label.style.padding = '0 2px';
|
|
51
|
+
label.style.transform = 'translateY(50%)';
|
|
52
|
+
label.textContent = String(ref);
|
|
53
|
+
}
|
|
54
|
+
function getOverlayContainer() {
|
|
55
|
+
let container = document.querySelector('#webvision-overlay');
|
|
56
|
+
if (!container) {
|
|
57
|
+
container = document.createElement('div');
|
|
58
|
+
container[VX_IGNORE_SYMBOL] = true;
|
|
59
|
+
container.id = 'webvision-overlay';
|
|
60
|
+
container.style.position = 'fixed';
|
|
61
|
+
container.style.top = '0';
|
|
62
|
+
container.style.left = '0';
|
|
63
|
+
container.style.bottom = '0';
|
|
64
|
+
container.style.right = '0';
|
|
65
|
+
container.style.zIndex = '2147483647'; // Maximum z-index value
|
|
66
|
+
container.style.pointerEvents = 'none';
|
|
67
|
+
document.body.appendChild(container);
|
|
68
|
+
}
|
|
69
|
+
return container;
|
|
70
|
+
}
|
|
71
|
+
function getColor(index) {
|
|
72
|
+
const hue = (index * 120 * .382) % 360;
|
|
73
|
+
return `hsl(${hue}, 85%, 50%)`;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.js","sourceRoot":"","sources":["../../src/page/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,UAAU,SAAS,CAAC,CAAS,EAAE,CAAS,EAAE,KAAK,GAAG,IAAI;IACxD,IAAI,KAAK,EAAE,CAAC;QACR,YAAY,EAAE,CAAC;IACnB,CAAC;IACD,MAAM,KAAK,GAAG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C,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,mBAAmB;IACxB,IAAI,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,oBAAoB,CAAgB,CAAC;IAC5E,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACzC,SAAiB,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;QAC5C,SAAS,CAAC,EAAE,GAAG,mBAAmB,CAAC;QACnC,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC;QACnC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;QAC1B,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;QAC3B,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;QAC7B,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC;QAC5B,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC,wBAAwB;QAC/D,SAAS,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;QACvC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;IACvC,OAAO,OAAO,GAAG,aAAa,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export declare const VX_NODE_SYMBOL: unique symbol;
|
|
2
|
+
export declare const VX_IGNORE_SYMBOL: unique symbol;
|
|
3
|
+
export declare const VX_IGNORE_TAGS: string[];
|
|
4
|
+
export declare const VX_LABEL_ATTRS: string[];
|
|
5
|
+
export declare const VX_VALUE_ATTRS: string[];
|
|
6
|
+
export declare const VX_SRC_ATTRS: string[];
|
|
7
|
+
export declare const VX_TAG_PREFERENCE: string[];
|
|
8
|
+
export type VxDomNode = Element | Text;
|
|
9
|
+
export interface VxNode {
|
|
10
|
+
ref: number;
|
|
11
|
+
tagName?: string;
|
|
12
|
+
children?: VxNode[];
|
|
13
|
+
id?: string;
|
|
14
|
+
classList?: string[];
|
|
15
|
+
textContent?: string;
|
|
16
|
+
hasVisibleArea?: boolean;
|
|
17
|
+
isInteractive?: boolean;
|
|
18
|
+
isOutsideViewport?: boolean;
|
|
19
|
+
isProbeHit?: boolean;
|
|
20
|
+
isKept?: boolean;
|
|
21
|
+
srcAttrs?: Record<string, string>;
|
|
22
|
+
labelAttrs?: Record<string, string>;
|
|
23
|
+
valueAttrs?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
export interface VxTreeOptions {
|
|
26
|
+
startRef?: number;
|
|
27
|
+
skipImages?: boolean;
|
|
28
|
+
viewportOnly?: boolean;
|
|
29
|
+
probeViewport?: boolean;
|
|
30
|
+
opaqueOverlays?: boolean;
|
|
31
|
+
unnestDivs?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export type VxTransform = (vxNode: VxNode) => VxNode;
|
|
34
|
+
export declare class VxTreeParser {
|
|
35
|
+
options: VxTreeOptions;
|
|
36
|
+
private counter;
|
|
37
|
+
private viewport;
|
|
38
|
+
private refRange;
|
|
39
|
+
private vxNodes;
|
|
40
|
+
private probeElements;
|
|
41
|
+
private domRefMap;
|
|
42
|
+
constructor(options?: VxTreeOptions);
|
|
43
|
+
private parseDocument;
|
|
44
|
+
getNodes(): VxNode[];
|
|
45
|
+
getRefRange(): [number, number];
|
|
46
|
+
getDomMap(): Map<number, Node>;
|
|
47
|
+
private parseNode;
|
|
48
|
+
private parseElement;
|
|
49
|
+
private makeNode;
|
|
50
|
+
private pruneRecursive;
|
|
51
|
+
private collapseSingleChild;
|
|
52
|
+
private collapsePreferParent;
|
|
53
|
+
private collapseMerge;
|
|
54
|
+
private shouldOmit;
|
|
55
|
+
private isProbeHit;
|
|
56
|
+
private collectLabelAttrs;
|
|
57
|
+
private collectValueAttrs;
|
|
58
|
+
private collectSrcAttrs;
|
|
59
|
+
}
|