misoai-web 1.0.6 → 1.5.7
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/README.md +5 -349
- package/dist/es/agent.js +165 -428
- package/dist/es/agent.js.map +1 -1
- package/dist/es/bridge-mode-browser.js +10 -9
- package/dist/es/bridge-mode-browser.js.map +1 -1
- package/dist/es/bridge-mode.js +167 -430
- package/dist/es/bridge-mode.js.map +1 -1
- package/dist/es/chrome-extension.js +173 -435
- package/dist/es/chrome-extension.js.map +1 -1
- package/dist/es/index.js +185 -432
- package/dist/es/index.js.map +1 -1
- package/dist/es/midscene-playground.js +165 -428
- package/dist/es/midscene-playground.js.map +1 -1
- package/dist/es/midscene-server.js.map +1 -1
- package/dist/es/playground.js +165 -428
- package/dist/es/playground.js.map +1 -1
- package/dist/es/playwright-report.js +1 -1
- package/dist/es/playwright-report.js.map +1 -1
- package/dist/es/playwright.js +182 -429
- package/dist/es/playwright.js.map +1 -1
- package/dist/es/puppeteer-agent-launcher.js +169 -432
- package/dist/es/puppeteer-agent-launcher.js.map +1 -1
- package/dist/es/puppeteer.js +169 -432
- package/dist/es/puppeteer.js.map +1 -1
- package/dist/es/ui-utils.js.map +1 -1
- package/dist/es/utils.js +7 -4
- package/dist/es/utils.js.map +1 -1
- package/dist/es/yaml.js +29 -3
- package/dist/es/yaml.js.map +1 -1
- package/dist/lib/agent.js +163 -426
- package/dist/lib/agent.js.map +1 -1
- package/dist/lib/bridge-mode-browser.js +10 -9
- package/dist/lib/bridge-mode-browser.js.map +1 -1
- package/dist/lib/bridge-mode.js +165 -428
- package/dist/lib/bridge-mode.js.map +1 -1
- package/dist/lib/chrome-extension.js +171 -433
- package/dist/lib/chrome-extension.js.map +1 -1
- package/dist/lib/index.js +183 -430
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/midscene-playground.js +163 -426
- package/dist/lib/midscene-playground.js.map +1 -1
- package/dist/lib/midscene-server.js.map +1 -1
- package/dist/lib/playground.js +163 -426
- package/dist/lib/playground.js.map +1 -1
- package/dist/lib/playwright-report.js +1 -1
- package/dist/lib/playwright-report.js.map +1 -1
- package/dist/lib/playwright.js +180 -427
- package/dist/lib/playwright.js.map +1 -1
- package/dist/lib/puppeteer-agent-launcher.js +167 -430
- package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
- package/dist/lib/puppeteer.js +167 -430
- package/dist/lib/puppeteer.js.map +1 -1
- package/dist/lib/ui-utils.js.map +1 -1
- package/dist/lib/utils.js +7 -4
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/yaml.js +29 -3
- package/dist/lib/yaml.js.map +1 -1
- package/dist/types/agent.d.ts +13 -51
- package/dist/types/bridge-mode-browser.d.ts +2 -3
- package/dist/types/bridge-mode.d.ts +2 -3
- package/dist/types/{browser-aec1055d.d.ts → browser-9b472ffb.d.ts} +1 -1
- package/dist/types/chrome-extension.d.ts +2 -3
- package/dist/types/index.d.ts +1 -2
- package/dist/types/midscene-server.d.ts +1 -2
- package/dist/types/{page-86ab0fe1.d.ts → page-ed0ecb44.d.ts} +19 -9
- package/dist/types/playground.d.ts +2 -3
- package/dist/types/playwright.d.ts +9 -2
- package/dist/types/puppeteer-agent-launcher.d.ts +1 -2
- package/dist/types/puppeteer.d.ts +6 -5
- package/dist/types/ui-utils.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -2
- package/dist/types/yaml.d.ts +1 -2
- package/iife-script/htmlElement.js +53 -75
- package/iife-script/htmlElementDebug.js +35 -56
- package/package.json +24 -24
- package/LICENSE +0 -21
@@ -1,10 +1,10 @@
|
|
1
1
|
import { Page as Page$2 } from 'playwright';
|
2
|
+
import * as misoai_core from 'misoai-core';
|
2
3
|
import { BaseElement, Rect, UIContext, PlaywrightParserOpt, PlanningLocateParam, ElementTreeNode, Size, Point, PageType } from 'misoai-core';
|
3
4
|
import { ElementInfo, ElementNode } from 'misoai-shared/extractor';
|
4
5
|
import { Page as Page$1, KeyInput } from 'puppeteer';
|
5
6
|
import { DebugFunction } from 'misoai-shared/logger';
|
6
7
|
import { NodeType } from 'misoai-shared/constants';
|
7
|
-
import * as misoai_core__ from 'misoai-core/.';
|
8
8
|
|
9
9
|
declare class WebElementInfo implements BaseElement {
|
10
10
|
content: string;
|
@@ -18,7 +18,8 @@ declare class WebElementInfo implements BaseElement {
|
|
18
18
|
[key: string]: string;
|
19
19
|
};
|
20
20
|
xpaths?: string[];
|
21
|
-
|
21
|
+
isVisible: boolean;
|
22
|
+
constructor({ content, rect, locator, id, attributes, indexId, xpaths, isVisible, }: {
|
22
23
|
content: string;
|
23
24
|
rect: Rect;
|
24
25
|
locator?: string;
|
@@ -29,6 +30,7 @@ declare class WebElementInfo implements BaseElement {
|
|
29
30
|
};
|
30
31
|
indexId: number;
|
31
32
|
xpaths?: string[];
|
33
|
+
isVisible: boolean;
|
32
34
|
});
|
33
35
|
}
|
34
36
|
|
@@ -157,7 +159,10 @@ declare class ChromeExtensionProxyPage implements AbstractPage {
|
|
157
159
|
private latestMouseX;
|
158
160
|
private latestMouseY;
|
159
161
|
mouse: {
|
160
|
-
click: (x: number, y: number
|
162
|
+
click: (x: number, y: number, options?: {
|
163
|
+
button?: MouseButton;
|
164
|
+
count?: number;
|
165
|
+
}) => Promise<void>;
|
161
166
|
wheel: (deltaX: number, deltaY: number, startX?: number, startY?: number) => Promise<void>;
|
162
167
|
move: (x: number, y: number) => Promise<void>;
|
163
168
|
drag: (from: {
|
@@ -190,7 +195,7 @@ declare class StaticPage implements AbstractPage {
|
|
190
195
|
getElementsNodeTree(): Promise<any>;
|
191
196
|
getXpathsById(id: string): Promise<any>;
|
192
197
|
getElementInfoByXpath(xpath: string): Promise<any>;
|
193
|
-
size(): Promise<
|
198
|
+
size(): Promise<misoai_core.Size>;
|
194
199
|
screenshotBase64(): Promise<string>;
|
195
200
|
url(): Promise<string>;
|
196
201
|
scrollUntilTop(startingPoint?: Point): Promise<any>;
|
@@ -276,13 +281,14 @@ declare class Page<AgentType extends 'puppeteer' | 'playwright', PageType extend
|
|
276
281
|
destroy(): Promise<void>;
|
277
282
|
}
|
278
283
|
|
284
|
+
type PuppeteerPageOpt = {
|
285
|
+
waitForNavigationTimeout?: number;
|
286
|
+
waitForNetworkIdleTimeout?: number;
|
287
|
+
};
|
279
288
|
declare class WebPage$2 extends Page<'puppeteer', Page$1> {
|
280
289
|
waitForNavigationTimeout: number;
|
281
290
|
waitForNetworkIdleTimeout: number;
|
282
|
-
constructor(page: Page$1, opts?:
|
283
|
-
waitForNavigationTimeout?: number;
|
284
|
-
waitForNetworkIdleTimeout?: number;
|
285
|
-
});
|
291
|
+
constructor(page: Page$1, opts?: PuppeteerPageOpt);
|
286
292
|
waitUntilNetworkIdle(options?: {
|
287
293
|
idleTime?: number;
|
288
294
|
concurrency?: number;
|
@@ -317,6 +323,10 @@ interface AndroidDevicePage extends AbstractPage {
|
|
317
323
|
recentApps(): Promise<void>;
|
318
324
|
}
|
319
325
|
|
326
|
+
type AndroidDeviceInputOpt = {
|
327
|
+
autoDismissKeyboard?: boolean;
|
328
|
+
};
|
329
|
+
|
320
330
|
type WebPage$1 =
|
321
331
|
| WebPage
|
322
332
|
| WebPage$2
|
@@ -330,4 +340,4 @@ declare class WebPage extends Page<'playwright', Page$2> {
|
|
330
340
|
constructor(page: Page$2);
|
331
341
|
}
|
332
342
|
|
333
|
-
export { type AndroidDevicePage as A, ChromeExtensionProxyPage as C, ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED as E, StaticPage as S, type WebPage$1 as W,
|
343
|
+
export { type AndroidDevicePage as A, ChromeExtensionProxyPage as C, ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED as E, type PuppeteerPageOpt as P, StaticPage as S, type WebPage$1 as W, type AndroidDeviceInputOpt as a, AbstractPage as b, WebPage$2 as c, WebPage as d, WebElementInfo as e, type WebUIContext as f, type ChromePageDestroyOptions as g, printReportMsg as h, getCurrentExecutionFile as i, generateCacheId as j, replaceIllegalPathCharsAndSpace as k, forceClosePopup as l, matchElementFromPlan as m, parseContextFromWebPage as p, reportFileName as r };
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { S as StaticPage } from './page-
|
2
|
-
export { E as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-
|
1
|
+
import { S as StaticPage } from './page-ed0ecb44.js';
|
2
|
+
export { E as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-ed0ecb44.js';
|
3
3
|
import { PageAgent } from './agent.js';
|
4
4
|
import 'playwright';
|
5
5
|
import 'misoai-core';
|
@@ -7,7 +7,6 @@ import 'misoai-shared/extractor';
|
|
7
7
|
import 'puppeteer';
|
8
8
|
import 'misoai-shared/logger';
|
9
9
|
import 'misoai-shared/constants';
|
10
|
-
import 'misoai-core/.';
|
11
10
|
import 'misoai-core/ai-model';
|
12
11
|
|
13
12
|
declare class StaticPageAgent extends PageAgent {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { PageAgent, PageAgentOpt } from './agent.js';
|
2
2
|
import { Page } from 'playwright';
|
3
|
-
import {
|
3
|
+
import { d as WebPage } from './page-ed0ecb44.js';
|
4
4
|
import { AgentWaitForOpt } from 'misoai-core';
|
5
5
|
import { TestInfo } from '@playwright/test';
|
6
6
|
export { overrideAIConfig } from 'misoai-shared/env';
|
@@ -9,7 +9,6 @@ import 'misoai-shared/extractor';
|
|
9
9
|
import 'puppeteer';
|
10
10
|
import 'misoai-shared/logger';
|
11
11
|
import 'misoai-shared/constants';
|
12
|
-
import 'misoai-core/.';
|
13
12
|
|
14
13
|
declare const PlaywrightAiFixture: (options?: {
|
15
14
|
forceSameTabNavigation?: boolean;
|
@@ -27,6 +26,9 @@ declare const PlaywrightAiFixture: (options?: {
|
|
27
26
|
aiTap: ({ page }: {
|
28
27
|
page: Page;
|
29
28
|
}, use: any, testInfo: TestInfo) => Promise<void>;
|
29
|
+
aiRightClick: ({ page }: {
|
30
|
+
page: Page;
|
31
|
+
}, use: any, testInfo: TestInfo) => Promise<void>;
|
30
32
|
aiHover: ({ page }: {
|
31
33
|
page: Page;
|
32
34
|
}, use: any, testInfo: TestInfo) => Promise<void>;
|
@@ -60,12 +62,16 @@ declare const PlaywrightAiFixture: (options?: {
|
|
60
62
|
aiBoolean: ({ page }: {
|
61
63
|
page: Page;
|
62
64
|
}, use: any, testInfo: TestInfo) => Promise<void>;
|
65
|
+
logScreenshot: ({ page }: {
|
66
|
+
page: Page;
|
67
|
+
}, use: any, testInfo: TestInfo) => Promise<void>;
|
63
68
|
};
|
64
69
|
type PlayWrightAiFixtureType = {
|
65
70
|
agentForPage: (page?: any, opts?: any) => Promise<PageAgent>;
|
66
71
|
ai: <T = any>(prompt: string) => Promise<T>;
|
67
72
|
aiAction: (taskPrompt: string) => ReturnType<PageAgent['aiAction']>;
|
68
73
|
aiTap: (...args: Parameters<PageAgent['aiTap']>) => ReturnType<PageAgent['aiTap']>;
|
74
|
+
aiRightClick: (...args: Parameters<PageAgent['aiRightClick']>) => ReturnType<PageAgent['aiRightClick']>;
|
69
75
|
aiHover: (...args: Parameters<PageAgent['aiHover']>) => ReturnType<PageAgent['aiHover']>;
|
70
76
|
aiInput: (...args: Parameters<PageAgent['aiInput']>) => ReturnType<PageAgent['aiInput']>;
|
71
77
|
aiKeyboardPress: (...args: Parameters<PageAgent['aiKeyboardPress']>) => ReturnType<PageAgent['aiKeyboardPress']>;
|
@@ -77,6 +83,7 @@ type PlayWrightAiFixtureType = {
|
|
77
83
|
aiNumber: (...args: Parameters<PageAgent['aiNumber']>) => ReturnType<PageAgent['aiNumber']>;
|
78
84
|
aiString: (...args: Parameters<PageAgent['aiString']>) => ReturnType<PageAgent['aiString']>;
|
79
85
|
aiBoolean: (...args: Parameters<PageAgent['aiBoolean']>) => ReturnType<PageAgent['aiBoolean']>;
|
86
|
+
logScreenshot: (...args: Parameters<PageAgent['logScreenshot']>) => ReturnType<PageAgent['logScreenshot']>;
|
80
87
|
};
|
81
88
|
|
82
89
|
declare class PlaywrightAgent extends PageAgent<WebPage> {
|
@@ -2,12 +2,11 @@ import * as puppeteer from 'puppeteer';
|
|
2
2
|
import { PuppeteerAgent } from './puppeteer.js';
|
3
3
|
import { MidsceneYamlScriptWebEnv } from 'misoai-core';
|
4
4
|
import './agent.js';
|
5
|
-
import './page-
|
5
|
+
import './page-ed0ecb44.js';
|
6
6
|
import 'playwright';
|
7
7
|
import 'misoai-shared/extractor';
|
8
8
|
import 'misoai-shared/logger';
|
9
9
|
import 'misoai-shared/constants';
|
10
|
-
import 'misoai-core/.';
|
11
10
|
import 'misoai-core/ai-model';
|
12
11
|
import 'misoai-shared/env';
|
13
12
|
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { PageAgentOpt, PageAgent } from './agent.js';
|
2
2
|
import { Page } from 'puppeteer';
|
3
|
-
import {
|
3
|
+
import { P as PuppeteerPageOpt, c as WebPage } from './page-ed0ecb44.js';
|
4
|
+
export { a as AndroidDeviceInputOpt } from './page-ed0ecb44.js';
|
4
5
|
export { overrideAIConfig } from 'misoai-shared/env';
|
5
6
|
import 'misoai-core';
|
6
7
|
import 'misoai-core/ai-model';
|
@@ -8,10 +9,10 @@ import 'playwright';
|
|
8
9
|
import 'misoai-shared/extractor';
|
9
10
|
import 'misoai-shared/logger';
|
10
11
|
import 'misoai-shared/constants';
|
11
|
-
import 'misoai-core/.';
|
12
12
|
|
13
|
+
type PuppeteerAgentOpt = PageAgentOpt & PuppeteerPageOpt;
|
13
14
|
declare class PuppeteerAgent extends PageAgent<WebPage> {
|
14
|
-
constructor(page: Page, opts?:
|
15
|
+
constructor(page: Page, opts?: PuppeteerAgentOpt);
|
15
16
|
}
|
16
17
|
|
17
|
-
export { PuppeteerAgent, WebPage as PuppeteerWebPage };
|
18
|
+
export { PuppeteerAgent, type PuppeteerAgentOpt, WebPage as PuppeteerWebPage };
|
package/dist/types/ui-utils.d.ts
CHANGED
@@ -7,7 +7,7 @@ declare function getKeyCommands(value: string | string[]): Array<{
|
|
7
7
|
}>;
|
8
8
|
declare function locateParamStr(locate?: DetailedLocateParam): string;
|
9
9
|
declare function scrollParamStr(scrollParam?: PlanningActionParamScroll): string;
|
10
|
-
declare function taskTitleStr(type: 'Tap' | 'Hover' | 'Input' | 'KeyboardPress' | 'Scroll' | 'Action' | 'Query' | 'Assert' | 'WaitFor' | 'Locate' | 'Boolean' | 'Number' | 'String', prompt: string): string;
|
10
|
+
declare function taskTitleStr(type: 'Tap' | 'Hover' | 'Input' | 'RightClick' | 'KeyboardPress' | 'Scroll' | 'Action' | 'Query' | 'Assert' | 'WaitFor' | 'Locate' | 'Boolean' | 'Number' | 'String', prompt: string): string;
|
11
11
|
declare function paramStr(task: ExecutionTask): string;
|
12
12
|
declare const limitOpenNewTabScript = "\nif (!window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__) {\n window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__ = true;\n\n // Intercept the window.open method (only once)\n window.open = function(url) {\n console.log('Blocked window.open:', url);\n window.location.href = url;\n return null;\n };\n\n // Block all a tag clicks with target=\"_blank\" (only once)\n document.addEventListener('click', function(e) {\n const target = e.target.closest('a');\n if (target && target.target === '_blank') {\n e.preventDefault();\n console.log('Blocked new tab:', target.href);\n window.location.href = target.href;\n target.removeAttribute('target');\n }\n }, true);\n}\n";
|
13
13
|
|
package/dist/types/utils.d.ts
CHANGED
@@ -2,7 +2,6 @@ import 'misoai-core';
|
|
2
2
|
import 'misoai-shared/logger';
|
3
3
|
import 'playwright';
|
4
4
|
import 'puppeteer';
|
5
|
-
export { E as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED,
|
5
|
+
export { E as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED, f as WebUIContext, l as forceClosePopup, j as generateCacheId, i as getCurrentExecutionFile, m as matchElementFromPlan, p as parseContextFromWebPage, h as printReportMsg, k as replaceIllegalPathCharsAndSpace, r as reportFileName } from './page-ed0ecb44.js';
|
6
6
|
import 'misoai-shared/extractor';
|
7
7
|
import 'misoai-shared/constants';
|
8
|
-
import 'misoai-core/.';
|
package/dist/types/yaml.d.ts
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
export { S as ScriptPlayer, p as parseYamlScript } from './utils-badc824e.js';
|
2
2
|
import { MidsceneYamlScriptWebEnv, MidsceneYamlTask } from 'misoai-core';
|
3
3
|
import './agent.js';
|
4
|
-
import './page-
|
4
|
+
import './page-ed0ecb44.js';
|
5
5
|
import 'playwright';
|
6
6
|
import 'misoai-shared/extractor';
|
7
7
|
import 'puppeteer';
|
8
8
|
import 'misoai-shared/logger';
|
9
9
|
import 'misoai-shared/constants';
|
10
|
-
import 'misoai-core/.';
|
11
10
|
import 'misoai-core/ai-model';
|
12
11
|
|
13
12
|
declare function buildYaml(env: MidsceneYamlScriptWebEnv, tasks: MidsceneYamlTask[]): string;
|
@@ -48,9 +48,9 @@ var midscene_element_inspector = (() => {
|
|
48
48
|
));
|
49
49
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
50
50
|
|
51
|
-
// resolve-false
|
51
|
+
// resolve-false:/empty-stub
|
52
52
|
var require_empty_stub = __commonJS({
|
53
|
-
"resolve-false
|
53
|
+
"resolve-false:/empty-stub"(exports, module) {
|
54
54
|
"use strict";
|
55
55
|
module.exports = {};
|
56
56
|
}
|
@@ -587,6 +587,8 @@ var midscene_element_inspector = (() => {
|
|
587
587
|
setNodeHashCacheListOnWindow: () => setNodeHashCacheListOnWindow,
|
588
588
|
traverseTree: () => traverseTree,
|
589
589
|
treeToList: () => treeToList,
|
590
|
+
trimAttributes: () => trimAttributes,
|
591
|
+
truncateText: () => truncateText,
|
590
592
|
webExtractNodeTree: () => extractTreeNode,
|
591
593
|
webExtractNodeTreeAsString: () => extractTreeNodeAsString,
|
592
594
|
webExtractTextWithPosition: () => extractTextWithPosition
|
@@ -615,7 +617,7 @@ var midscene_element_inspector = (() => {
|
|
615
617
|
const tailorAttributes = Object.keys(attributes).reduce(
|
616
618
|
(res, currentKey) => {
|
617
619
|
const attributeVal = attributes[currentKey];
|
618
|
-
if (currentKey === "style" || currentKey === "
|
620
|
+
if (currentKey === "style" || currentKey === "htmlTagName" || currentKey === "nodeType") {
|
619
621
|
return res;
|
620
622
|
}
|
621
623
|
res[currentKey] = truncateText(attributeVal, truncateTextLength);
|
@@ -626,13 +628,13 @@ var midscene_element_inspector = (() => {
|
|
626
628
|
return tailorAttributes;
|
627
629
|
}
|
628
630
|
var nodeSizeThreshold = 4;
|
629
|
-
function descriptionOfTree(tree, truncateTextLength, filterNonTextContent = false) {
|
631
|
+
function descriptionOfTree(tree, truncateTextLength, filterNonTextContent = false, visibleOnly = true) {
|
630
632
|
const attributesString = (kv) => {
|
631
633
|
return Object.entries(kv).map(
|
632
634
|
([key, value]) => `${key}="${truncateText(value, truncateTextLength)}"`
|
633
635
|
).join(" ");
|
634
636
|
};
|
635
|
-
function buildContentTree(node, indent = 0) {
|
637
|
+
function buildContentTree(node, indent = 0, visibleOnly2 = true) {
|
636
638
|
var _a;
|
637
639
|
let before = "";
|
638
640
|
let contentWithIndent = "";
|
@@ -641,13 +643,17 @@ var midscene_element_inspector = (() => {
|
|
641
643
|
const indentStr = " ".repeat(indent);
|
642
644
|
let children = "";
|
643
645
|
for (let i = 0; i < (node.children || []).length; i++) {
|
644
|
-
const childContent = buildContentTree(
|
646
|
+
const childContent = buildContentTree(
|
647
|
+
node.children[i],
|
648
|
+
indent + 1,
|
649
|
+
visibleOnly2
|
650
|
+
);
|
645
651
|
if (childContent) {
|
646
652
|
children += `
|
647
653
|
${childContent}`;
|
648
654
|
}
|
649
655
|
}
|
650
|
-
if (node.node && node.node.rect.width > nodeSizeThreshold && node.node.rect.height > nodeSizeThreshold && (!filterNonTextContent || filterNonTextContent && node.node.content)) {
|
656
|
+
if (node.node && node.node.rect.width > nodeSizeThreshold && node.node.rect.height > nodeSizeThreshold && (!filterNonTextContent || filterNonTextContent && node.node.content) && (!visibleOnly2 || visibleOnly2 && node.node.isVisible)) {
|
651
657
|
emptyNode = false;
|
652
658
|
let nodeTypeString;
|
653
659
|
if ((_a = node.node.attributes) == null ? void 0 : _a.htmlTagName) {
|
@@ -685,7 +691,7 @@ ${indentStr}${after}`;
|
|
685
691
|
}
|
686
692
|
return "";
|
687
693
|
}
|
688
|
-
const result = buildContentTree(tree);
|
694
|
+
const result = buildContentTree(tree, 0, visibleOnly);
|
689
695
|
return result.replace(/^\s*\n/gm, "");
|
690
696
|
}
|
691
697
|
function treeToList(tree) {
|
@@ -986,7 +992,7 @@ ${indentStr}${after}`;
|
|
986
992
|
});
|
987
993
|
return true;
|
988
994
|
};
|
989
|
-
function elementRect(el, currentWindow, currentDocument, baseZoom = 1
|
995
|
+
function elementRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
990
996
|
if (!el) {
|
991
997
|
logger(el, "Element is not in the DOM hierarchy");
|
992
998
|
return false;
|
@@ -1010,21 +1016,11 @@ ${indentStr}${after}`;
|
|
1010
1016
|
if (baseZoom === 1 && isElementCovered(el, rect, currentWindow)) {
|
1011
1017
|
return false;
|
1012
1018
|
}
|
1013
|
-
const
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
if (!isPartiallyInViewport) {
|
1019
|
-
logger(el, "Element is completely outside the viewport", {
|
1020
|
-
rect,
|
1021
|
-
viewportHeight,
|
1022
|
-
viewportWidth,
|
1023
|
-
scrollTop,
|
1024
|
-
scrollLeft
|
1025
|
-
});
|
1026
|
-
return false;
|
1027
|
-
}
|
1019
|
+
const isVisible = isElementPartiallyInViewport(
|
1020
|
+
rect,
|
1021
|
+
currentWindow,
|
1022
|
+
currentDocument
|
1023
|
+
);
|
1028
1024
|
let parent = el;
|
1029
1025
|
const parentUntilNonStatic = (currentNode) => {
|
1030
1026
|
let parent2 = currentNode == null ? void 0 : currentNode.parentElement;
|
@@ -1068,7 +1064,8 @@ ${indentStr}${after}`;
|
|
1068
1064
|
top: Math.round(rect.top),
|
1069
1065
|
width: Math.round(rect.width),
|
1070
1066
|
height: Math.round(rect.height),
|
1071
|
-
zoom: rect.zoom
|
1067
|
+
zoom: rect.zoom,
|
1068
|
+
isVisible
|
1072
1069
|
};
|
1073
1070
|
}
|
1074
1071
|
function getNodeAttributes(node, currentWindow) {
|
@@ -1137,26 +1134,21 @@ ${indentStr}${after}`;
|
|
1137
1134
|
let tagName = "";
|
1138
1135
|
if (node instanceof HTMLElement) {
|
1139
1136
|
tagName = node.tagName.toLowerCase();
|
1140
|
-
}
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1137
|
+
} else {
|
1138
|
+
const parentElement = node.parentElement;
|
1139
|
+
if (parentElement && parentElement instanceof HTMLElement) {
|
1140
|
+
tagName = parentElement.tagName.toLowerCase();
|
1141
|
+
}
|
1144
1142
|
}
|
1145
1143
|
return tagName ? `<${tagName}>` : "";
|
1146
1144
|
}
|
1147
|
-
function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1, basePoint = { left: 0, top: 0 }
|
1145
|
+
function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1, basePoint = { left: 0, top: 0 }) {
|
1148
1146
|
var _a;
|
1149
|
-
const rect = elementRect(
|
1150
|
-
node,
|
1151
|
-
currentWindow,
|
1152
|
-
currentDocument,
|
1153
|
-
baseZoom,
|
1154
|
-
visibleOnly
|
1155
|
-
);
|
1147
|
+
const rect = elementRect(node, currentWindow, currentDocument, baseZoom);
|
1156
1148
|
if (!rect) {
|
1157
1149
|
return null;
|
1158
1150
|
}
|
1159
|
-
if (
|
1151
|
+
if (rect.width < CONTAINER_MINI_WIDTH || rect.height < CONTAINER_MINI_HEIGHT) {
|
1160
1152
|
return null;
|
1161
1153
|
}
|
1162
1154
|
if (basePoint.left !== 0 || basePoint.top !== 0) {
|
@@ -1195,7 +1187,8 @@ ${indentStr}${after}`;
|
|
1195
1187
|
Math.round(rect.left + rect.width / 2),
|
1196
1188
|
Math.round(rect.top + rect.height / 2)
|
1197
1189
|
],
|
1198
|
-
zoom: rect.zoom
|
1190
|
+
zoom: rect.zoom,
|
1191
|
+
isVisible: rect.isVisible
|
1199
1192
|
};
|
1200
1193
|
return elementInfo;
|
1201
1194
|
}
|
@@ -1204,8 +1197,7 @@ ${indentStr}${after}`;
|
|
1204
1197
|
node,
|
1205
1198
|
currentWindow,
|
1206
1199
|
currentDocument,
|
1207
|
-
baseZoom
|
1208
|
-
visibleOnly
|
1200
|
+
baseZoom
|
1209
1201
|
);
|
1210
1202
|
if (!rect2) {
|
1211
1203
|
return null;
|
@@ -1231,7 +1223,8 @@ ${indentStr}${after}`;
|
|
1231
1223
|
Math.round(rect2.left + rect2.width / 2),
|
1232
1224
|
Math.round(rect2.top + rect2.height / 2)
|
1233
1225
|
],
|
1234
|
-
zoom: rect2.zoom
|
1226
|
+
zoom: rect2.zoom,
|
1227
|
+
isVisible: rect2.isVisible
|
1235
1228
|
};
|
1236
1229
|
return elementInfo;
|
1237
1230
|
}
|
@@ -1257,7 +1250,8 @@ ${indentStr}${after}`;
|
|
1257
1250
|
Math.round(rect.left + rect.width / 2),
|
1258
1251
|
Math.round(rect.top + rect.height / 2)
|
1259
1252
|
],
|
1260
|
-
zoom: rect.zoom
|
1253
|
+
zoom: rect.zoom,
|
1254
|
+
isVisible: rect.isVisible
|
1261
1255
|
};
|
1262
1256
|
return elementInfo;
|
1263
1257
|
}
|
@@ -1289,7 +1283,8 @@ ${indentStr}${after}`;
|
|
1289
1283
|
],
|
1290
1284
|
content: text,
|
1291
1285
|
rect,
|
1292
|
-
zoom: rect.zoom
|
1286
|
+
zoom: rect.zoom,
|
1287
|
+
isVisible: rect.isVisible
|
1293
1288
|
};
|
1294
1289
|
return elementInfo;
|
1295
1290
|
}
|
@@ -1315,7 +1310,8 @@ ${indentStr}${after}`;
|
|
1315
1310
|
Math.round(rect.left + rect.width / 2),
|
1316
1311
|
Math.round(rect.top + rect.height / 2)
|
1317
1312
|
],
|
1318
|
-
zoom: rect.zoom
|
1313
|
+
zoom: rect.zoom,
|
1314
|
+
isVisible: rect.isVisible
|
1319
1315
|
};
|
1320
1316
|
return elementInfo;
|
1321
1317
|
}
|
@@ -1339,7 +1335,8 @@ ${indentStr}${after}`;
|
|
1339
1335
|
Math.round(rect.left + rect.width / 2),
|
1340
1336
|
Math.round(rect.top + rect.height / 2)
|
1341
1337
|
],
|
1342
|
-
zoom: rect.zoom
|
1338
|
+
zoom: rect.zoom,
|
1339
|
+
isVisible: rect.isVisible
|
1343
1340
|
};
|
1344
1341
|
return elementInfo;
|
1345
1342
|
}
|
@@ -1359,9 +1356,9 @@ ${indentStr}${after}`;
|
|
1359
1356
|
dfsTopChildren({ children: elementNode.children, node: elementNode.node });
|
1360
1357
|
return elementInfoArray;
|
1361
1358
|
}
|
1362
|
-
function extractTreeNodeAsString(initNode, debugMode2 = false) {
|
1359
|
+
function extractTreeNodeAsString(initNode, visibleOnly = false, debugMode2 = false) {
|
1363
1360
|
const elementNode = extractTreeNode(initNode, debugMode2);
|
1364
|
-
return descriptionOfTree(elementNode);
|
1361
|
+
return descriptionOfTree(elementNode, void 0, false, visibleOnly);
|
1365
1362
|
}
|
1366
1363
|
function extractTreeNode(initNode, debugMode2 = false) {
|
1367
1364
|
setDebugMode(debugMode2);
|
@@ -1392,7 +1389,7 @@ ${indentStr}${after}`;
|
|
1392
1389
|
node: elementInfo,
|
1393
1390
|
children: []
|
1394
1391
|
};
|
1395
|
-
if ((elementInfo == null ? void 0 : elementInfo.nodeType) === "BUTTON Node" /* BUTTON */ || (elementInfo == null ? void 0 : elementInfo.nodeType) === "IMG Node" /* IMG */ || (elementInfo == null ? void 0 : elementInfo.nodeType) === "TEXT Node" /* TEXT */ || (elementInfo == null ? void 0 : elementInfo.nodeType) === "
|
1392
|
+
if ((elementInfo == null ? void 0 : elementInfo.nodeType) === "BUTTON Node" /* BUTTON */ || (elementInfo == null ? void 0 : elementInfo.nodeType) === "IMG Node" /* IMG */ || (elementInfo == null ? void 0 : elementInfo.nodeType) === "TEXT Node" /* TEXT */ || (elementInfo == null ? void 0 : elementInfo.nodeType) === "FORM_ITEM Node" /* FORM_ITEM */ || (elementInfo == null ? void 0 : elementInfo.nodeType) === "CONTAINER Node" /* CONTAINER */) {
|
1396
1393
|
return nodeInfo;
|
1397
1394
|
}
|
1398
1395
|
const rect = getRect(node, baseZoom, currentWindow);
|
@@ -1447,14 +1444,8 @@ ${indentStr}${after}`;
|
|
1447
1444
|
children: topChildren
|
1448
1445
|
};
|
1449
1446
|
}
|
1450
|
-
function mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom = 1
|
1451
|
-
const selfRect = elementRect(
|
1452
|
-
node,
|
1453
|
-
currentWindow,
|
1454
|
-
currentDocument,
|
1455
|
-
baseZoom,
|
1456
|
-
visibleOnly
|
1457
|
-
);
|
1447
|
+
function mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom = 1) {
|
1448
|
+
const selfRect = elementRect(node, currentWindow, currentDocument, baseZoom);
|
1458
1449
|
if (!selfRect)
|
1459
1450
|
return null;
|
1460
1451
|
let minLeft = selfRect.left;
|
@@ -1465,13 +1456,7 @@ ${indentStr}${after}`;
|
|
1465
1456
|
for (let i = 0; i < child.childNodes.length; i++) {
|
1466
1457
|
const sub = child.childNodes[i];
|
1467
1458
|
if (sub.nodeType === 1) {
|
1468
|
-
const rect = elementRect(
|
1469
|
-
sub,
|
1470
|
-
currentWindow,
|
1471
|
-
currentDocument,
|
1472
|
-
baseZoom,
|
1473
|
-
visibleOnly
|
1474
|
-
);
|
1459
|
+
const rect = elementRect(sub, currentWindow, currentDocument, baseZoom);
|
1475
1460
|
if (rect) {
|
1476
1461
|
minLeft = Math.min(minLeft, rect.left);
|
1477
1462
|
minTop = Math.min(minTop, rect.top);
|
@@ -1588,17 +1573,10 @@ ${indentStr}${after}`;
|
|
1588
1573
|
node.scrollIntoView({ behavior: "instant", block: "center" });
|
1589
1574
|
}
|
1590
1575
|
}
|
1591
|
-
return collectElementInfo(
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
1,
|
1596
|
-
{
|
1597
|
-
left: 0,
|
1598
|
-
top: 0
|
1599
|
-
},
|
1600
|
-
false
|
1601
|
-
);
|
1576
|
+
return collectElementInfo(node, window, document, 1, {
|
1577
|
+
left: 0,
|
1578
|
+
top: 0
|
1579
|
+
});
|
1602
1580
|
}
|
1603
1581
|
return __toCommonJS(extractor_exports);
|
1604
1582
|
})();
|