@ubio/webvision 1.0.1 → 1.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 CHANGED
@@ -1,3 +1,146 @@
1
+ // src/page/highlight.ts
2
+ function highlightSnapshot(snapshot, nodeMap) {
3
+ const container = getHighlightContainer();
4
+ container.innerHTML = "";
5
+ highlightRecursive(snapshot, nodeMap, container);
6
+ }
7
+ function highlightRecursive(snapshot, nodeMap, container) {
8
+ highlightEl(snapshot, nodeMap, container);
9
+ for (const child of snapshot.children ?? []) {
10
+ highlightRecursive(child, nodeMap, container);
11
+ }
12
+ }
13
+ function highlightEl(snapshot, nodeMap, container) {
14
+ const isContainerEl = !snapshot.leaf && snapshot.children?.every((child) => child.nodeType === "element");
15
+ if (isContainerEl) {
16
+ return;
17
+ }
18
+ const node = nodeMap.get(snapshot.nodeId);
19
+ if (!(node instanceof Element)) {
20
+ return;
21
+ }
22
+ const color = getColor(snapshot.nodeId);
23
+ const rect = node.getBoundingClientRect();
24
+ const overlay = document.createElement("div");
25
+ container.appendChild(overlay);
26
+ overlay.style.position = "absolute";
27
+ overlay.style.top = `${rect.top}px`;
28
+ overlay.style.left = `${rect.left}px`;
29
+ overlay.style.width = `${rect.width}px`;
30
+ overlay.style.height = `${rect.height}px`;
31
+ overlay.style.border = `2px solid ${color}`;
32
+ const label = document.createElement("div");
33
+ overlay.appendChild(label);
34
+ label.style.position = "absolute";
35
+ label.style.bottom = `100%`;
36
+ label.style.left = `0`;
37
+ label.style.backgroundColor = color;
38
+ label.style.color = "white";
39
+ label.style.fontSize = "10px";
40
+ label.style.fontFamily = "monospace";
41
+ label.style.fontWeight = "normal";
42
+ label.style.fontStyle = "normal";
43
+ label.style.opacity = "0.8";
44
+ label.style.padding = "0 2px";
45
+ label.style.transform = "translateY(50%)";
46
+ label.textContent = String(snapshot.nodeId);
47
+ }
48
+ function removeHighlight() {
49
+ const container = getHighlightContainer();
50
+ document.documentElement.removeChild(container);
51
+ }
52
+ function getHighlightContainer() {
53
+ let container = document.querySelector("#webvision-highlight");
54
+ if (!container) {
55
+ container = document.createElement("div");
56
+ container.id = "webvision-highlight";
57
+ container.style.position = "absolute";
58
+ container.style.pointerEvents = "none";
59
+ container.style.top = "0";
60
+ container.style.left = "0";
61
+ container.style.width = "100%";
62
+ container.style.height = "100%";
63
+ container.style.zIndex = "2147483646";
64
+ document.documentElement.appendChild(container);
65
+ }
66
+ return container;
67
+ }
68
+ function getColor(index) {
69
+ const hue = index * 120 * 0.382 % 360;
70
+ return `hsl(${hue}, 85%, 50%)`;
71
+ }
72
+
73
+ // src/page/html.ts
74
+ function captureAncestorHtml(el) {
75
+ const html = [];
76
+ let current = el;
77
+ while (current) {
78
+ html.push(captureHtmlLine(current));
79
+ current = current.parentElement;
80
+ }
81
+ return html.reverse().join("\n");
82
+ }
83
+ function captureHtmlLine(el) {
84
+ const html = [];
85
+ html.push(`${el.tagName.toLowerCase()}`);
86
+ for (const attr of el.attributes) {
87
+ html.push(`${attr.name}="${attr.value}"`);
88
+ }
89
+ return `<${html.join(" ")}>`;
90
+ }
91
+
92
+ // src/page/render.ts
93
+ function renderSnapshot(snapshot, options = {}) {
94
+ const opts = {
95
+ depth: 0,
96
+ includeNodeId: true,
97
+ includeClassList: true,
98
+ ...options
99
+ };
100
+ if (opts.maxHeight && snapshot.rect.y > opts.maxHeight) {
101
+ return "";
102
+ }
103
+ const buffer = [
104
+ renderLine(snapshot, opts)
105
+ ];
106
+ for (const child of snapshot.children ?? []) {
107
+ const childSnapshot = renderSnapshot(child, {
108
+ ...opts,
109
+ depth: opts.depth + 1
110
+ });
111
+ if (childSnapshot) {
112
+ buffer.push(childSnapshot);
113
+ }
114
+ }
115
+ return buffer.join("\n");
116
+ }
117
+ function renderLine(snapshot, options) {
118
+ const indent = " ".repeat(options.depth);
119
+ const components = [indent];
120
+ if (snapshot.nodeType === "text") {
121
+ return [indent, snapshot.textContent].filter(Boolean).join(" ");
122
+ }
123
+ components.push(snapshot.tagName ?? "");
124
+ if (options.includeNodeId) {
125
+ components.push(`[nodeId=${snapshot.nodeId}]`);
126
+ }
127
+ if (options.includeClassList) {
128
+ for (const className of snapshot.classList ?? []) {
129
+ components.push(`.${className}`);
130
+ }
131
+ }
132
+ if (snapshot.src) {
133
+ components.push(`(${snapshot.src})`);
134
+ }
135
+ if (snapshot.href) {
136
+ components.push(`(${snapshot.href})`);
137
+ }
138
+ if (snapshot.textContent) {
139
+ components.push(" " + snapshot.textContent);
140
+ }
141
+ return components.filter(Boolean).join("");
142
+ }
143
+
1
144
  // src/page/utils.ts
2
145
  function isHidden(element, options = {}) {
3
146
  const {
@@ -10,7 +153,7 @@ function isHidden(element, options = {}) {
10
153
  const display = style.display;
11
154
  const visibility = style.visibility;
12
155
  const transform = style.transform;
13
- if (display === "none" || checkOpacity && opacity < 0.1 || checkVisibility && visibility === "hidden" || checkTransform && transform.includes("scale(0)")) {
156
+ if (display === "none" || checkOpacity && opacity === 0 || checkVisibility && visibility === "hidden" || checkTransform && transform.includes("scale(0)")) {
14
157
  return true;
15
158
  }
16
159
  if (!element.checkVisibility()) {
@@ -35,8 +178,8 @@ function deepIsHidden(element, options = {}) {
35
178
  function normalizeText(str) {
36
179
  return str.replace(/\p{Cf}/gu, " ").replace(/\s+/g, " ").trim();
37
180
  }
38
- function containsImage(el) {
39
- return el.matches("img") || !!el.querySelector("img");
181
+ function containsSelector(el, selector) {
182
+ return el.matches(selector) || !!el.querySelector(selector);
40
183
  }
41
184
  function isRecursiveInline(el, ignoreTags = []) {
42
185
  for (const child of el.childNodes) {
@@ -106,23 +249,39 @@ var DEFAULT_SEMANTIC_TAGS = [
106
249
  "sub",
107
250
  "sup"
108
251
  ];
109
- var DomSnapshot = class _DomSnapshot {
110
- constructor(node, parent, options) {
252
+ function createSnapshot(root, options = {}) {
253
+ const opts = {
254
+ startId: 0,
255
+ skipHidden: true,
256
+ skipEmptyText: true,
257
+ skipImages: false,
258
+ skipIframes: false,
259
+ skipTags: DEFAULT_SKIP_TAGS,
260
+ tagPreference: DEFAULT_SEMANTIC_TAGS,
261
+ collapseInline: true,
262
+ ...options
263
+ };
264
+ const counter = new Counter(opts.startId);
265
+ const nodeMap = /* @__PURE__ */ new Map();
266
+ const tree = new SnapshotTree(root, null, counter, opts);
267
+ tree.fillMap(nodeMap);
268
+ return {
269
+ nodeMap,
270
+ snapshot: tree.toJson(),
271
+ maxId: counter.value
272
+ };
273
+ }
274
+ var SnapshotTree = class _SnapshotTree {
275
+ constructor(node, parent, counter, options) {
111
276
  this.node = node;
112
277
  this.parent = parent;
278
+ this.counter = counter;
279
+ this.options = options;
113
280
  this.children = [];
114
- this.options = {
115
- skipHidden: true,
116
- skipEmptyText: true,
117
- skipImages: false,
118
- skipTags: DEFAULT_SKIP_TAGS,
119
- tagPreference: DEFAULT_SEMANTIC_TAGS,
120
- collapseInline: true,
121
- ...options
122
- };
281
+ this.nodeId = this.counter.next();
123
282
  this.classList = [...this.element?.classList ?? []];
124
283
  if (this.element) {
125
- this.parseTree(this.element);
284
+ this.parseTree(this.element, this.getAcceptedChildren(this.element));
126
285
  }
127
286
  }
128
287
  get element() {
@@ -135,40 +294,28 @@ var DomSnapshot = class _DomSnapshot {
135
294
  const text = this.node instanceof HTMLElement ? this.node.innerText : this.node.textContent;
136
295
  return normalizeText(text ?? "");
137
296
  }
138
- get indent() {
139
- return " ".repeat(this.depth);
140
- }
141
- get isLeaf() {
297
+ get leaf() {
142
298
  return this.children.length === 0;
143
299
  }
144
300
  get tagName() {
145
- return this.node instanceof Element ? this.node.tagName.toLowerCase() : "";
301
+ return this.node instanceof Element ? this.node.tagName.toLowerCase() : void 0;
146
302
  }
147
303
  get href() {
148
- return this.node instanceof HTMLAnchorElement ? this.node.href : "";
304
+ return this.node instanceof HTMLAnchorElement ? this.node.href : void 0;
149
305
  }
150
306
  get src() {
151
- return this.node instanceof HTMLImageElement ? this.node.src : "";
152
- }
153
- getFontSize() {
154
- if (this.node instanceof Text) {
155
- return this.parent?.getFontSize() ?? 0;
156
- }
157
- return Number(getComputedStyle(this.node).fontSize?.replace("px", ""));
307
+ return this.node.src ?? void 0;
158
308
  }
159
- getTextSize(rootFontSize) {
160
- const ownFontSize = this.getFontSize();
161
- if (ownFontSize > 1.2 * rootFontSize) {
162
- return "large";
309
+ get clientRect() {
310
+ if (this.node instanceof Element) {
311
+ return this.node.getBoundingClientRect();
163
312
  }
164
- if (ownFontSize < 0.85 * rootFontSize) {
165
- return "small";
166
- }
167
- return "normal";
313
+ const range = document.createRange();
314
+ range.selectNodeContents(this.node);
315
+ return range.getBoundingClientRect();
168
316
  }
169
- parseTree(el) {
317
+ parseTree(el, childNodes) {
170
318
  this.children = [];
171
- const childNodes = this.getAcceptedChildren(el);
172
319
  if (childNodes.length === 1) {
173
320
  return this.collapseWrapper(el, childNodes[0]);
174
321
  }
@@ -176,7 +323,7 @@ var DomSnapshot = class _DomSnapshot {
176
323
  return;
177
324
  }
178
325
  for (const childNode of childNodes) {
179
- const snapshot = new _DomSnapshot(childNode, this, this.options);
326
+ const snapshot = new _SnapshotTree(childNode, this, this.counter, this.options);
180
327
  this.children.push(snapshot);
181
328
  }
182
329
  }
@@ -193,11 +340,13 @@ var DomSnapshot = class _DomSnapshot {
193
340
  this.classList.push(...child.classList);
194
341
  const parentRank = this.options.tagPreference.indexOf(el.tagName.toLowerCase());
195
342
  const childRank = this.options.tagPreference.indexOf(child.tagName.toLowerCase());
196
- const preferParent = parentRank !== -1 && parentRank < childRank;
343
+ const preferParent = parentRank !== -1 && (parentRank < childRank || childRank === -1);
197
344
  if (!preferParent) {
198
345
  this.node = child;
199
346
  }
200
- this.parseTree(child);
347
+ if (this.element) {
348
+ this.parseTree(this.element, this.getAcceptedChildren(child));
349
+ }
201
350
  }
202
351
  getAcceptedChildren(el) {
203
352
  const childNodes = [...el.childNodes];
@@ -206,10 +355,16 @@ var DomSnapshot = class _DomSnapshot {
206
355
  return false;
207
356
  }
208
357
  if (node instanceof Element) {
209
- if (this.options.skipHidden && deepIsHidden(node, { checkOpacity: false })) {
358
+ if (this.options.skipHidden && deepIsHidden(node)) {
210
359
  return false;
211
360
  }
212
- if (!this.options.skipImages && containsImage(node)) {
361
+ if (containsSelector(node, "input")) {
362
+ return true;
363
+ }
364
+ if (!this.options.skipIframes && containsSelector(node, "iframe")) {
365
+ return true;
366
+ }
367
+ if (!this.options.skipImages && containsSelector(node, "img")) {
213
368
  return true;
214
369
  }
215
370
  if (this.options.skipTags.includes(node.tagName.toLowerCase())) {
@@ -225,43 +380,60 @@ var DomSnapshot = class _DomSnapshot {
225
380
  return true;
226
381
  });
227
382
  }
228
- toIndentedText() {
229
- const buffer = [
230
- this.renderLine()
231
- ];
383
+ fillMap(map) {
384
+ map.set(this.nodeId, this.node);
232
385
  for (const child of this.children) {
233
- buffer.push(child.toIndentedText());
386
+ child.fillMap(map);
234
387
  }
235
- return buffer.join("\n");
236
388
  }
237
- renderLine() {
238
- const indent = " ".repeat(this.depth);
239
- const components = [indent];
240
- if (this.node instanceof Text) {
241
- return [indent, this.inlineText].filter(Boolean).join(" ");
242
- }
243
- const { tagName, src, href } = this;
244
- components.push(tagName);
245
- if (src) {
246
- components.push(`(${src})`);
247
- }
248
- if (href) {
249
- components.push(`(${href})`);
250
- }
251
- if (this.isLeaf) {
252
- components.push(" " + this.inlineText);
253
- }
254
- return components.filter(Boolean).join("");
389
+ toJson() {
390
+ const { top, left, width, height } = this.clientRect;
391
+ return {
392
+ nodeId: this.nodeId,
393
+ nodeType: this.node instanceof Element ? "element" : "text",
394
+ leaf: this.leaf,
395
+ tagName: this.tagName,
396
+ rect: {
397
+ x: left,
398
+ y: top,
399
+ width,
400
+ height
401
+ },
402
+ classList: this.node instanceof Element ? this.classList : void 0,
403
+ textContent: this.leaf ? this.inlineText : void 0,
404
+ href: this.href,
405
+ src: this.src,
406
+ children: this.leaf ? void 0 : this.children.map((child) => child.toJson())
407
+ };
408
+ }
409
+ };
410
+ var Counter = class {
411
+ constructor(value = 0) {
412
+ this.value = value;
413
+ }
414
+ next() {
415
+ this.value += 1;
416
+ return this.value;
255
417
  }
256
418
  };
257
419
  export {
420
+ Counter,
258
421
  DEFAULT_SEMANTIC_TAGS,
259
422
  DEFAULT_SKIP_TAGS,
260
- DomSnapshot,
261
- containsImage,
423
+ SnapshotTree,
424
+ captureAncestorHtml,
425
+ captureHtmlLine,
426
+ containsSelector,
427
+ createSnapshot,
262
428
  deepIsHidden,
429
+ getHighlightContainer,
263
430
  hasVisibleArea,
431
+ highlightEl,
432
+ highlightSnapshot,
264
433
  isHidden,
265
434
  isRecursiveInline,
266
- normalizeText
435
+ normalizeText,
436
+ removeHighlight,
437
+ renderLine,
438
+ renderSnapshot
267
439
  };
@@ -0,0 +1,5 @@
1
+ import { SnapshotItem, SnapshotNode } from './snapshot.js';
2
+ export declare function highlightSnapshot(snapshot: SnapshotItem, nodeMap: Map<number, SnapshotNode>): void;
3
+ export declare function highlightEl(snapshot: SnapshotItem, nodeMap: Map<number, SnapshotNode>, container: HTMLElement): void;
4
+ export declare function removeHighlight(): void;
5
+ export declare function getHighlightContainer(): HTMLElement;
@@ -0,0 +1,71 @@
1
+ export function highlightSnapshot(snapshot, nodeMap) {
2
+ const container = getHighlightContainer();
3
+ container.innerHTML = '';
4
+ highlightRecursive(snapshot, nodeMap, container);
5
+ }
6
+ function highlightRecursive(snapshot, nodeMap, container) {
7
+ highlightEl(snapshot, nodeMap, container);
8
+ for (const child of snapshot.children ?? []) {
9
+ highlightRecursive(child, nodeMap, container);
10
+ }
11
+ }
12
+ export function highlightEl(snapshot, nodeMap, container) {
13
+ const isContainerEl = !snapshot.leaf && snapshot.children?.every(child => child.nodeType === 'element');
14
+ if (isContainerEl) {
15
+ return;
16
+ }
17
+ const node = nodeMap.get(snapshot.nodeId);
18
+ if (!(node instanceof Element)) {
19
+ return;
20
+ }
21
+ const color = getColor(snapshot.nodeId);
22
+ const rect = node.getBoundingClientRect();
23
+ const overlay = document.createElement('div');
24
+ container.appendChild(overlay);
25
+ overlay.style.position = 'absolute';
26
+ overlay.style.top = `${rect.top}px`;
27
+ overlay.style.left = `${rect.left}px`;
28
+ overlay.style.width = `${rect.width}px`;
29
+ overlay.style.height = `${rect.height}px`;
30
+ overlay.style.border = `2px solid ${color}`;
31
+ const label = document.createElement('div');
32
+ overlay.appendChild(label);
33
+ label.style.position = 'absolute';
34
+ label.style.bottom = `100%`;
35
+ label.style.left = `0`;
36
+ label.style.backgroundColor = color;
37
+ label.style.color = 'white';
38
+ label.style.fontSize = '10px';
39
+ label.style.fontFamily = 'monospace';
40
+ label.style.fontWeight = 'normal';
41
+ label.style.fontStyle = 'normal';
42
+ label.style.opacity = '0.8';
43
+ label.style.padding = '0 2px';
44
+ label.style.transform = 'translateY(50%)';
45
+ label.textContent = String(snapshot.nodeId);
46
+ }
47
+ export function removeHighlight() {
48
+ const container = getHighlightContainer();
49
+ document.documentElement.removeChild(container);
50
+ }
51
+ export function getHighlightContainer() {
52
+ let container = document.querySelector('#webvision-highlight');
53
+ if (!container) {
54
+ container = document.createElement('div');
55
+ container.id = 'webvision-highlight';
56
+ container.style.position = 'absolute';
57
+ container.style.pointerEvents = 'none';
58
+ container.style.top = '0';
59
+ container.style.left = '0';
60
+ container.style.width = '100%';
61
+ container.style.height = '100%';
62
+ container.style.zIndex = '2147483646'; // Maximum z-index value
63
+ document.documentElement.appendChild(container);
64
+ }
65
+ return container;
66
+ }
67
+ function getColor(index) {
68
+ const hue = (index * 120 * .382) % 360;
69
+ return `hsl(${hue}, 85%, 50%)`;
70
+ }
71
+ //# sourceMappingURL=highlight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.js","sourceRoot":"","sources":["../../src/page/highlight.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAC7B,QAAsB,EACtB,OAAkC;IAElC,MAAM,SAAS,GAAG,qBAAqB,EAAE,CAAC;IAC1C,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC;IACzB,kBAAk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AC;AACpD,CAAC;AAED,MAAM,UAAU,qBAAqB;IACjC,IAAI,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,sBAAsB,CAAgB,CAAC;IAC9E,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1C,SAAS,CAAC,EAAE,GAAG,qBAAqB,CAAC;QACrC,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;QACtC,SAAS,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;QACvC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC;QAC1B,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;QAC3B,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;QAC/B,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;QAChC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC,wBAAwB;QAC/D,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACpD,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,2 @@
1
+ export declare function captureAncestorHtml(el: HTMLElement): string;
2
+ export declare function captureHtmlLine(el: HTMLElement): string;
@@ -0,0 +1,18 @@
1
+ export function captureAncestorHtml(el) {
2
+ const html = [];
3
+ let current = el;
4
+ while (current) {
5
+ html.push(captureHtmlLine(current));
6
+ current = current.parentElement;
7
+ }
8
+ return html.reverse().join('\n');
9
+ }
10
+ export function captureHtmlLine(el) {
11
+ const html = [];
12
+ html.push(`${el.tagName.toLowerCase()}`);
13
+ for (const attr of el.attributes) {
14
+ html.push(`${attr.name}="${attr.value}"`);
15
+ }
16
+ return `<${html.join(' ')}>`;
17
+ }
18
+ //# sourceMappingURL=html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/page/html.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,EAAe;IAC/C,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,IAAI,OAAO,GAAuB,EAAE,CAAC;IACrC,OAAO,OAAO,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;QACpC,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAe;IAC3C,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AACjC,CAAC"}
@@ -1,2 +1,5 @@
1
+ export * from './highlight.js';
2
+ export * from './html.js';
3
+ export * from './render.js';
1
4
  export * from './snapshot.js';
2
5
  export * from './utils.js';
package/out/page/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ export * from './highlight.js';
2
+ export * from './html.js';
3
+ export * from './render.js';
1
4
  export * from './snapshot.js';
2
5
  export * from './utils.js';
3
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/page/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/page/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { SnapshotItem } from './snapshot.js';
2
+ export interface SnapshotRenderOptions {
3
+ depth: number;
4
+ includeNodeId: boolean;
5
+ includeClassList: boolean;
6
+ maxHeight?: number;
7
+ }
8
+ export declare function renderSnapshot(snapshot: SnapshotItem, options?: Partial<SnapshotRenderOptions>): string;
9
+ export declare function renderLine(snapshot: SnapshotItem, options: SnapshotRenderOptions): string;
@@ -0,0 +1,51 @@
1
+ export function renderSnapshot(snapshot, options = {}) {
2
+ const opts = {
3
+ depth: 0,
4
+ includeNodeId: true,
5
+ includeClassList: true,
6
+ ...options,
7
+ };
8
+ if (opts.maxHeight && snapshot.rect.y > opts.maxHeight) {
9
+ return '';
10
+ }
11
+ const buffer = [
12
+ renderLine(snapshot, opts),
13
+ ];
14
+ for (const child of snapshot.children ?? []) {
15
+ const childSnapshot = renderSnapshot(child, {
16
+ ...opts,
17
+ depth: opts.depth + 1,
18
+ });
19
+ if (childSnapshot) {
20
+ buffer.push(childSnapshot);
21
+ }
22
+ }
23
+ return buffer.join('\n');
24
+ }
25
+ export function renderLine(snapshot, options) {
26
+ const indent = ' '.repeat(options.depth);
27
+ const components = [indent];
28
+ if (snapshot.nodeType === 'text') {
29
+ return [indent, snapshot.textContent].filter(Boolean).join(' ');
30
+ }
31
+ components.push(snapshot.tagName ?? '');
32
+ if (options.includeNodeId) {
33
+ components.push(`[nodeId=${snapshot.nodeId}]`);
34
+ }
35
+ if (options.includeClassList) {
36
+ for (const className of snapshot.classList ?? []) {
37
+ components.push(`.${className}`);
38
+ }
39
+ }
40
+ if (snapshot.src) {
41
+ components.push(`(${snapshot.src})`);
42
+ }
43
+ if (snapshot.href) {
44
+ components.push(`(${snapshot.href})`);
45
+ }
46
+ if (snapshot.textContent) {
47
+ components.push(' ' + snapshot.textContent);
48
+ }
49
+ return components.filter(Boolean).join('');
50
+ }
51
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/page/render.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,cAAc,CAAC,QAAsB,EAAE,UAA0C,EAAE;IAC/F,MAAM,IAAI,GAA0B;QAChC,KAAK,EAAE,CAAC;QACR,aAAa,EAAE,IAAI;QACnB,gBAAgB,EAAE,IAAI;QACtB,GAAG,OAAO;KACb,CAAC;IACF,IAAI,IAAI,CAAC,SAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACrD,OAAO,EAAE,CAAC;IACd,CAAC;IACD,MAAM,MAAM,GAAG;QACX,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC;KAC7B,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC;QAC1C,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,EAAE;YACxC,GAAG,IAAI;YACP,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC;SACxB,CAAC,CAAC;QACH,IAAI,aAAa,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,QAAsB,EAAE,OAA8B;IAC7E,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC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S: string[];
3
- export interface DomSnapshotOptions {
3
+ export type SnapshotNode = Element | Text;
4
+ export interface SnapshotOptions {
5
+ startId: number;
4
6
  skipHidden: boolean;
5
7
  skipImages: boolean;
8
+ skipIframes: boolean;
6
9
  skipEmptyText: boolean;
7
10
  skipTags: string[];
8
11
  tagPreference: string[];
9
12
  collapseInline: boolean;
10
13
  }
11
- export declare class DomSnapshot {
14
+ export interface SnapshotItem {
15
+ nodeId: number;
16
+ nodeType: 'element' | 'text';
17
+ leaf: boolean;
18
+ rect: {
19
+ x: number;
20
+ y: number;
21
+ width: number;
22
+ height: number;
23
+ };
24
+ tagName?: string;
25
+ classList?: string[];
26
+ textContent?: string;
27
+ href?: string;
28
+ src?: string;
29
+ children?: SnapshotItem[];
30
+ }
31
+ export declare function createSnapshot(root: SnapshotNode, options?: Partial<SnapshotOptions>): {
32
+ nodeMap: Map<number, SnapshotNode>;
33
+ snapshot: SnapshotItem;
34
+ maxId: number;
35
+ };
36
+ export declare class SnapshotTree {
12
37
  node: Element | Text;
13
- parent: DomSnapshot | null;
14
- options: DomSnapshotOptions;
38
+ parent: SnapshotTree | null;
39
+ counter: Counter;
40
+ options: SnapshotOptions;
41
+ nodeId: number;
15
42
  classList: string[];
16
- children: DomSnapshot[];
17
- constructor(node: Element | Text, parent: DomSnapshot | null, options: Partial<DomSnapshotOptions>);
43
+ children: SnapshotTree[];
44
+ constructor(node: Element | Text, parent: SnapshotTree | null, counter: Counter, options: SnapshotOptions);
18
45
  get element(): Element | null;
19
46
  get depth(): number;
20
47
  get inlineText(): string;
21
- get indent(): string;
22
- get isLeaf(): boolean;
23
- get tagName(): string;
24
- get href(): string;
25
- get src(): string;
26
- getFontSize(): number;
27
- getTextSize(rootFontSize: number): "large" | "small" | "normal";
48
+ get leaf(): boolean;
49
+ get tagName(): string | undefined;
50
+ get href(): string | undefined;
51
+ get src(): any;
52
+ get clientRect(): DOMRect;
28
53
  private parseTree;
29
54
  /**
30
55
  * Collapses an element with only one visible child into one.
@@ -34,6 +59,11 @@ export declare class DomSnapshot {
34
59
  */
35
60
  private collapseWrapper;
36
61
  private getAcceptedChildren;
37
- toIndentedText(): string;
38
- renderLine(): string;
62
+ fillMap(map: Map<number, SnapshotNode>): void;
63
+ toJson(): SnapshotItem;
64
+ }
65
+ export declare class Counter {
66
+ value: number;
67
+ constructor(value?: number);
68
+ next(): number;
39
69
  }
@@ -1,4 +1,4 @@
1
- import { containsImage, deepIsHidden, isRecursiveInline, normalizeText } from './utils.js';
1
+ import { containsSelector, deepIsHidden, isRecursiveInline, normalizeText } from './utils.js';
2
2
  export const DEFAULT_SKIP_TAGS = ['svg', 'script', 'noscript', 'style', 'link', 'meta'];
3
3
  export const DEFAULT_SEMANTIC_TAGS = [
4
4
  'a', 'button', 'label', 'section',
@@ -10,23 +10,39 @@ export const DEFAULT_SEMANTIC_TAGS = [
10
10
  'form', 'input', 'textarea', 'select', 'option', 'fieldset', 'legend',
11
11
  'strong', 'em', 'sub', 'sup',
12
12
  ];
13
- export class DomSnapshot {
14
- constructor(node, parent, options) {
13
+ export function createSnapshot(root, options = {}) {
14
+ const opts = {
15
+ startId: 0,
16
+ skipHidden: true,
17
+ skipEmptyText: true,
18
+ skipImages: false,
19
+ skipIframes: false,
20
+ skipTags: DEFAULT_SKIP_TAGS,
21
+ tagPreference: DEFAULT_SEMANTIC_TAGS,
22
+ collapseInline: true,
23
+ ...options,
24
+ };
25
+ const counter = new Counter(opts.startId);
26
+ const nodeMap = new Map();
27
+ const tree = new SnapshotTree(root, null, counter, opts);
28
+ tree.fillMap(nodeMap);
29
+ return {
30
+ nodeMap,
31
+ snapshot: tree.toJson(),
32
+ maxId: counter.value,
33
+ };
34
+ }
35
+ export class SnapshotTree {
36
+ constructor(node, parent, counter, options) {
15
37
  this.node = node;
16
38
  this.parent = parent;
39
+ this.counter = counter;
40
+ this.options = options;
17
41
  this.children = [];
18
- this.options = {
19
- skipHidden: true,
20
- skipEmptyText: true,
21
- skipImages: false,
22
- skipTags: DEFAULT_SKIP_TAGS,
23
- tagPreference: DEFAULT_SEMANTIC_TAGS,
24
- collapseInline: true,
25
- ...options,
26
- };
42
+ this.nodeId = this.counter.next();
27
43
  this.classList = [...(this.element?.classList ?? [])];
28
44
  if (this.element) {
29
- this.parseTree(this.element);
45
+ this.parseTree(this.element, this.getAcceptedChildren(this.element));
30
46
  }
31
47
  }
32
48
  get element() {
@@ -41,40 +57,28 @@ export class DomSnapshot {
41
57
  this.node.textContent;
42
58
  return normalizeText(text ?? '');
43
59
  }
44
- get indent() {
45
- return ' '.repeat(this.depth);
46
- }
47
- get isLeaf() {
60
+ get leaf() {
48
61
  return this.children.length === 0;
49
62
  }
50
63
  get tagName() {
51
- return this.node instanceof Element ? this.node.tagName.toLowerCase() : '';
64
+ return this.node instanceof Element ? this.node.tagName.toLowerCase() : undefined;
52
65
  }
53
66
  get href() {
54
- return this.node instanceof HTMLAnchorElement ? this.node.href : '';
67
+ return this.node instanceof HTMLAnchorElement ? this.node.href : undefined;
55
68
  }
56
69
  get src() {
57
- return this.node instanceof HTMLImageElement ? this.node.src : '';
58
- }
59
- getFontSize() {
60
- if (this.node instanceof Text) {
61
- return this.parent?.getFontSize() ?? 0;
62
- }
63
- return Number(getComputedStyle(this.node).fontSize?.replace('px', ''));
70
+ return this.node.src ?? undefined;
64
71
  }
65
- getTextSize(rootFontSize) {
66
- const ownFontSize = this.getFontSize();
67
- if (ownFontSize > 1.2 * rootFontSize) {
68
- return 'large';
72
+ get clientRect() {
73
+ if (this.node instanceof Element) {
74
+ return this.node.getBoundingClientRect();
69
75
  }
70
- if (ownFontSize < 0.85 * rootFontSize) {
71
- return 'small';
72
- }
73
- return 'normal';
76
+ const range = document.createRange();
77
+ range.selectNodeContents(this.node);
78
+ return range.getBoundingClientRect();
74
79
  }
75
- parseTree(el) {
80
+ parseTree(el, childNodes) {
76
81
  this.children = [];
77
- const childNodes = this.getAcceptedChildren(el);
78
82
  if (childNodes.length === 1) {
79
83
  return this.collapseWrapper(el, childNodes[0]);
80
84
  }
@@ -83,7 +87,7 @@ export class DomSnapshot {
83
87
  return;
84
88
  }
85
89
  for (const childNode of childNodes) {
86
- const snapshot = new DomSnapshot(childNode, this, this.options);
90
+ const snapshot = new SnapshotTree(childNode, this, this.counter, this.options);
87
91
  this.children.push(snapshot);
88
92
  }
89
93
  }
@@ -100,12 +104,14 @@ export class DomSnapshot {
100
104
  this.classList.push(...child.classList);
101
105
  const parentRank = this.options.tagPreference.indexOf(el.tagName.toLowerCase());
102
106
  const childRank = this.options.tagPreference.indexOf(child.tagName.toLowerCase());
103
- const preferParent = parentRank !== -1 && (parentRank < childRank);
107
+ const preferParent = parentRank !== -1 && (parentRank < childRank || childRank === -1);
104
108
  if (!preferParent) {
105
109
  this.node = child;
106
110
  }
107
111
  // Continue parsing child element
108
- this.parseTree(child);
112
+ if (this.element) {
113
+ this.parseTree(this.element, this.getAcceptedChildren(child));
114
+ }
109
115
  }
110
116
  getAcceptedChildren(el) {
111
117
  const childNodes = [...el.childNodes];
@@ -117,11 +123,19 @@ export class DomSnapshot {
117
123
  if (node instanceof Element) {
118
124
  // Skip hidden elements (opacity, display, visibility, etc)
119
125
  // TODO checkOpacity breaks PDF viewer
120
- if (this.options.skipHidden && deepIsHidden(node, { checkOpacity: false })) {
126
+ if (this.options.skipHidden && deepIsHidden(node)) {
121
127
  return false;
122
128
  }
123
- // Do not skip images even if other criteria are met
124
- if (!this.options.skipImages && containsImage(node)) {
129
+ // Always include inputs
130
+ if (containsSelector(node, 'input')) {
131
+ return true;
132
+ }
133
+ // Always include iframes, unless explicitly skipped
134
+ if (!this.options.skipIframes && containsSelector(node, 'iframe')) {
135
+ return true;
136
+ }
137
+ // Always include images, unless explicitly skipped
138
+ if (!this.options.skipImages && containsSelector(node, 'img')) {
125
139
  return true;
126
140
  }
127
141
  // Skip listed tags
@@ -139,33 +153,40 @@ export class DomSnapshot {
139
153
  return true;
140
154
  });
141
155
  }
142
- toIndentedText() {
143
- const buffer = [
144
- this.renderLine(),
145
- ];
156
+ fillMap(map) {
157
+ map.set(this.nodeId, this.node);
146
158
  for (const child of this.children) {
147
- buffer.push(child.toIndentedText());
159
+ child.fillMap(map);
148
160
  }
149
- return buffer.join('\n');
150
161
  }
151
- renderLine() {
152
- const indent = ' '.repeat(this.depth);
153
- const components = [indent];
154
- if (this.node instanceof Text) {
155
- return [indent, this.inlineText].filter(Boolean).join(' ');
156
- }
157
- const { tagName, src, href } = this;
158
- components.push(tagName);
159
- if (src) {
160
- components.push(`(${src})`);
161
- }
162
- if (href) {
163
- components.push(`(${href})`);
164
- }
165
- if (this.isLeaf) {
166
- components.push(' ' + this.inlineText);
167
- }
168
- return components.filter(Boolean).join('');
162
+ toJson() {
163
+ const { top, left, width, height } = this.clientRect;
164
+ return {
165
+ nodeId: this.nodeId,
166
+ nodeType: this.node instanceof Element ? 'element' : 'text',
167
+ leaf: this.leaf,
168
+ tagName: this.tagName,
169
+ rect: {
170
+ x: left,
171
+ y: top,
172
+ width,
173
+ height,
174
+ },
175
+ classList: this.node instanceof Element ? this.classList : undefined,
176
+ textContent: this.leaf ? this.inlineText : undefined,
177
+ href: this.href,
178
+ src: this.src,
179
+ children: this.leaf ? undefined : this.children.map(child => child.toJson()),
180
+ };
181
+ }
182
+ }
183
+ export class Counter {
184
+ constructor(value = 0) {
185
+ this.value = value;
186
+ }
187
+ next() {
188
+ this.value += 1;
189
+ return this.value;
169
190
  }
170
191
  }
171
192
  //# sourceMappingURL=snapshot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/page/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACxF,MAAM,CAAC,MA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C,MAAM;YAC3D,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE;gBACF,CAAC,EAAE,IAAI;gBACP,CAAC,EAAE,GAAG;gBACN,KAAK;gBACL,MAAM;aACT;YACD,SAAS,EAAE,IAAI,CAAC,IAAI,YAAY,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;YACpE,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;YACpD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;SAC/E,CAAC;IACN,CAAC;CAEJ;AAED,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;CAEJ"}
@@ -15,5 +15,5 @@ export declare function isHidden(element: Element, options?: Partial<VisibilityO
15
15
  export declare function hasVisibleArea(element: Element): boolean;
16
16
  export declare function deepIsHidden(element: Element, options?: Partial<VisibilityOptions>): boolean;
17
17
  export declare function normalizeText(str: string): string;
18
- export declare function containsImage(el: Element): boolean;
18
+ export declare function containsSelector(el: Element, selector: string): boolean;
19
19
  export declare function isRecursiveInline(el: Element, ignoreTags?: string[]): boolean;
package/out/page/utils.js CHANGED
@@ -14,7 +14,7 @@ export function isHidden(element, options = {}) {
14
14
  const visibility = style.visibility;
15
15
  const transform = style.transform;
16
16
  if (display === 'none' ||
17
- (checkOpacity && opacity < 0.1) ||
17
+ (checkOpacity && opacity === 0) ||
18
18
  (checkVisibility && (visibility === 'hidden')) ||
19
19
  (checkTransform && transform.includes('scale(0)'))) {
20
20
  return true;
@@ -44,8 +44,8 @@ export function normalizeText(str) {
44
44
  .replace(/\s+/g, ' ')
45
45
  .trim();
46
46
  }
47
- export function containsImage(el) {
48
- return el.matches('img') || !!el.querySelector('img');
47
+ export function containsSelector(el, selector) {
48
+ return el.matches(selector) || !!el.querySelector(selector);
49
49
  }
50
50
  export function isRecursiveInline(el, ignoreTags = []) {
51
51
  for (const child of el.childNodes) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/page/utils.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAgB,EAAE,UAAsC,EAAE;IAC/E,MAAM,EACF,YAAY,GAAG,IAAI,EACnB,eAAe,GAAG,IAAI,EACtB,cAAc,GAAG,IAAI,GACxB,GAAG,OAAO,CAAC;IACZ,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;IACpC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IAClC,IACI,OAAO,KAAK,MAAM;QAClB,CAAC,YAAY,IAAI,OAAO,GAAG,GAAG,CAAC;QAC/B,CAAC,eAAe,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC;QAC9C,CAAC,cAAc,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,EACpD,CAAC;QACC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAA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C3B,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;gBACnD,OAAO,KAAK,CAAC;YACjB,CAAC;YACD,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;YAChD,MAAM,MAAM,GAAG,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,cAAc,CAAC;YAClE,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,OAAO,KAAK,CAAC;YACjB,CAAC;YACD,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC;gBACxC,OAAO,KAAK,CAAC;YACjB,CAAC;QACL,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@ubio/webvision",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "main": "out/main/index.js",
5
5
  "type": "module",
6
6
  "exports": {
7
- "./page": "./out/page/index.js"
7
+ ".": "./out/page/index.js",
8
+ "./page": "./build/page.mjs"
8
9
  },
9
10
  "files": [
10
11
  "out/main",