misoai-web 1.5.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/dist/es/agent.js +124 -21
- 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 +126 -23
- package/dist/es/bridge-mode.js.map +1 -1
- package/dist/es/chrome-extension.js +132 -28
- package/dist/es/chrome-extension.js.map +1 -1
- package/dist/es/index.js +140 -21
- package/dist/es/index.js.map +1 -1
- package/dist/es/midscene-playground.js +124 -21
- package/dist/es/midscene-playground.js.map +1 -1
- package/dist/es/midscene-server.js.map +1 -1
- package/dist/es/playground.js +124 -21
- 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 +140 -21
- package/dist/es/playwright.js.map +1 -1
- package/dist/es/puppeteer-agent-launcher.js +124 -21
- package/dist/es/puppeteer-agent-launcher.js.map +1 -1
- package/dist/es/puppeteer.js +124 -21
- 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 +24 -0
- package/dist/es/yaml.js.map +1 -1
- package/dist/lib/agent.js +122 -19
- 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 +124 -21
- package/dist/lib/bridge-mode.js.map +1 -1
- package/dist/lib/chrome-extension.js +130 -26
- package/dist/lib/chrome-extension.js.map +1 -1
- package/dist/lib/index.js +138 -19
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/midscene-playground.js +122 -19
- package/dist/lib/midscene-playground.js.map +1 -1
- package/dist/lib/midscene-server.js.map +1 -1
- package/dist/lib/playground.js +122 -19
- 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 +138 -19
- package/dist/lib/playwright.js.map +1 -1
- package/dist/lib/puppeteer-agent-launcher.js +122 -19
- package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
- package/dist/lib/puppeteer.js +122 -19
- 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 +24 -0
- package/dist/lib/yaml.js.map +1 -1
- package/dist/types/agent.d.ts +10 -7
- 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 +51 -73
- package/iife-script/htmlElementDebug.js +33 -54
- package/package.json +23 -23
- package/LICENSE +0 -21
@@ -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;
|
@@ -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
|
})();
|
@@ -825,7 +825,7 @@ var midscene_element_inspector = (() => {
|
|
825
825
|
});
|
826
826
|
return true;
|
827
827
|
};
|
828
|
-
function elementRect(el, currentWindow, currentDocument, baseZoom = 1
|
828
|
+
function elementRect(el, currentWindow, currentDocument, baseZoom = 1) {
|
829
829
|
if (!el) {
|
830
830
|
logger(el, "Element is not in the DOM hierarchy");
|
831
831
|
return false;
|
@@ -849,21 +849,11 @@ var midscene_element_inspector = (() => {
|
|
849
849
|
if (baseZoom === 1 && isElementCovered(el, rect, currentWindow)) {
|
850
850
|
return false;
|
851
851
|
}
|
852
|
-
const
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
if (!isPartiallyInViewport) {
|
858
|
-
logger(el, "Element is completely outside the viewport", {
|
859
|
-
rect,
|
860
|
-
viewportHeight,
|
861
|
-
viewportWidth,
|
862
|
-
scrollTop,
|
863
|
-
scrollLeft
|
864
|
-
});
|
865
|
-
return false;
|
866
|
-
}
|
852
|
+
const isVisible = isElementPartiallyInViewport(
|
853
|
+
rect,
|
854
|
+
currentWindow,
|
855
|
+
currentDocument
|
856
|
+
);
|
867
857
|
let parent = el;
|
868
858
|
const parentUntilNonStatic = (currentNode) => {
|
869
859
|
let parent2 = currentNode == null ? void 0 : currentNode.parentElement;
|
@@ -907,7 +897,8 @@ var midscene_element_inspector = (() => {
|
|
907
897
|
top: Math.round(rect.top),
|
908
898
|
width: Math.round(rect.width),
|
909
899
|
height: Math.round(rect.height),
|
910
|
-
zoom: rect.zoom
|
900
|
+
zoom: rect.zoom,
|
901
|
+
isVisible
|
911
902
|
};
|
912
903
|
}
|
913
904
|
function getNodeAttributes(node, currentWindow) {
|
@@ -986,26 +977,21 @@ var midscene_element_inspector = (() => {
|
|
986
977
|
let tagName = "";
|
987
978
|
if (node instanceof HTMLElement) {
|
988
979
|
tagName = node.tagName.toLowerCase();
|
989
|
-
}
|
990
|
-
|
991
|
-
|
992
|
-
|
980
|
+
} else {
|
981
|
+
const parentElement = node.parentElement;
|
982
|
+
if (parentElement && parentElement instanceof HTMLElement) {
|
983
|
+
tagName = parentElement.tagName.toLowerCase();
|
984
|
+
}
|
993
985
|
}
|
994
986
|
return tagName ? `<${tagName}>` : "";
|
995
987
|
}
|
996
|
-
function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1, basePoint = { left: 0, top: 0 }
|
988
|
+
function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1, basePoint = { left: 0, top: 0 }) {
|
997
989
|
var _a;
|
998
|
-
const rect = elementRect(
|
999
|
-
node,
|
1000
|
-
currentWindow,
|
1001
|
-
currentDocument,
|
1002
|
-
baseZoom,
|
1003
|
-
visibleOnly
|
1004
|
-
);
|
990
|
+
const rect = elementRect(node, currentWindow, currentDocument, baseZoom);
|
1005
991
|
if (!rect) {
|
1006
992
|
return null;
|
1007
993
|
}
|
1008
|
-
if (
|
994
|
+
if (rect.width < CONTAINER_MINI_WIDTH || rect.height < CONTAINER_MINI_HEIGHT) {
|
1009
995
|
return null;
|
1010
996
|
}
|
1011
997
|
if (basePoint.left !== 0 || basePoint.top !== 0) {
|
@@ -1044,7 +1030,8 @@ var midscene_element_inspector = (() => {
|
|
1044
1030
|
Math.round(rect.left + rect.width / 2),
|
1045
1031
|
Math.round(rect.top + rect.height / 2)
|
1046
1032
|
],
|
1047
|
-
zoom: rect.zoom
|
1033
|
+
zoom: rect.zoom,
|
1034
|
+
isVisible: rect.isVisible
|
1048
1035
|
};
|
1049
1036
|
return elementInfo;
|
1050
1037
|
}
|
@@ -1053,8 +1040,7 @@ var midscene_element_inspector = (() => {
|
|
1053
1040
|
node,
|
1054
1041
|
currentWindow,
|
1055
1042
|
currentDocument,
|
1056
|
-
baseZoom
|
1057
|
-
visibleOnly
|
1043
|
+
baseZoom
|
1058
1044
|
);
|
1059
1045
|
if (!rect2) {
|
1060
1046
|
return null;
|
@@ -1080,7 +1066,8 @@ var midscene_element_inspector = (() => {
|
|
1080
1066
|
Math.round(rect2.left + rect2.width / 2),
|
1081
1067
|
Math.round(rect2.top + rect2.height / 2)
|
1082
1068
|
],
|
1083
|
-
zoom: rect2.zoom
|
1069
|
+
zoom: rect2.zoom,
|
1070
|
+
isVisible: rect2.isVisible
|
1084
1071
|
};
|
1085
1072
|
return elementInfo;
|
1086
1073
|
}
|
@@ -1106,7 +1093,8 @@ var midscene_element_inspector = (() => {
|
|
1106
1093
|
Math.round(rect.left + rect.width / 2),
|
1107
1094
|
Math.round(rect.top + rect.height / 2)
|
1108
1095
|
],
|
1109
|
-
zoom: rect.zoom
|
1096
|
+
zoom: rect.zoom,
|
1097
|
+
isVisible: rect.isVisible
|
1110
1098
|
};
|
1111
1099
|
return elementInfo;
|
1112
1100
|
}
|
@@ -1138,7 +1126,8 @@ var midscene_element_inspector = (() => {
|
|
1138
1126
|
],
|
1139
1127
|
content: text,
|
1140
1128
|
rect,
|
1141
|
-
zoom: rect.zoom
|
1129
|
+
zoom: rect.zoom,
|
1130
|
+
isVisible: rect.isVisible
|
1142
1131
|
};
|
1143
1132
|
return elementInfo;
|
1144
1133
|
}
|
@@ -1164,7 +1153,8 @@ var midscene_element_inspector = (() => {
|
|
1164
1153
|
Math.round(rect.left + rect.width / 2),
|
1165
1154
|
Math.round(rect.top + rect.height / 2)
|
1166
1155
|
],
|
1167
|
-
zoom: rect.zoom
|
1156
|
+
zoom: rect.zoom,
|
1157
|
+
isVisible: rect.isVisible
|
1168
1158
|
};
|
1169
1159
|
return elementInfo;
|
1170
1160
|
}
|
@@ -1188,7 +1178,8 @@ var midscene_element_inspector = (() => {
|
|
1188
1178
|
Math.round(rect.left + rect.width / 2),
|
1189
1179
|
Math.round(rect.top + rect.height / 2)
|
1190
1180
|
],
|
1191
|
-
zoom: rect.zoom
|
1181
|
+
zoom: rect.zoom,
|
1182
|
+
isVisible: rect.isVisible
|
1192
1183
|
};
|
1193
1184
|
return elementInfo;
|
1194
1185
|
}
|
@@ -1237,7 +1228,7 @@ var midscene_element_inspector = (() => {
|
|
1237
1228
|
node: elementInfo,
|
1238
1229
|
children: []
|
1239
1230
|
};
|
1240
|
-
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) === "
|
1231
|
+
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 */) {
|
1241
1232
|
return nodeInfo;
|
1242
1233
|
}
|
1243
1234
|
const rect = getRect(node, baseZoom, currentWindow);
|
@@ -1292,14 +1283,8 @@ var midscene_element_inspector = (() => {
|
|
1292
1283
|
children: topChildren
|
1293
1284
|
};
|
1294
1285
|
}
|
1295
|
-
function mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom = 1
|
1296
|
-
const selfRect = elementRect(
|
1297
|
-
node,
|
1298
|
-
currentWindow,
|
1299
|
-
currentDocument,
|
1300
|
-
baseZoom,
|
1301
|
-
visibleOnly
|
1302
|
-
);
|
1286
|
+
function mergeElementAndChildrenRects(node, currentWindow, currentDocument, baseZoom = 1) {
|
1287
|
+
const selfRect = elementRect(node, currentWindow, currentDocument, baseZoom);
|
1303
1288
|
if (!selfRect)
|
1304
1289
|
return null;
|
1305
1290
|
let minLeft = selfRect.left;
|
@@ -1310,13 +1295,7 @@ var midscene_element_inspector = (() => {
|
|
1310
1295
|
for (let i = 0; i < child.childNodes.length; i++) {
|
1311
1296
|
const sub = child.childNodes[i];
|
1312
1297
|
if (sub.nodeType === 1) {
|
1313
|
-
const rect = elementRect(
|
1314
|
-
sub,
|
1315
|
-
currentWindow,
|
1316
|
-
currentDocument,
|
1317
|
-
baseZoom,
|
1318
|
-
visibleOnly
|
1319
|
-
);
|
1298
|
+
const rect = elementRect(sub, currentWindow, currentDocument, baseZoom);
|
1320
1299
|
if (rect) {
|
1321
1300
|
minLeft = Math.min(minLeft, rect.left);
|
1322
1301
|
minTop = Math.min(minTop, rect.top);
|
package/package.json
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
"Browser use",
|
9
9
|
"Android use"
|
10
10
|
],
|
11
|
-
"version": "1.5.
|
11
|
+
"version": "1.5.7",
|
12
12
|
"repository": "https://github.com/web-infra-dev/midscene",
|
13
13
|
"homepage": "https://midscenejs.com/",
|
14
14
|
"jsnext:source": "./src/index.ts",
|
@@ -137,6 +137,24 @@
|
|
137
137
|
"quiet": false
|
138
138
|
}
|
139
139
|
},
|
140
|
+
"scripts": {
|
141
|
+
"dev": "npm run build && npx npm-watch",
|
142
|
+
"dev:server": "npm run build && ./bin/midscene-playground",
|
143
|
+
"build": "modern build -c ./modern.config.ts",
|
144
|
+
"postbuild": "node scripts/check-exports.js",
|
145
|
+
"build:watch": "modern build -w -c ./modern.config.ts",
|
146
|
+
"test": "vitest --run",
|
147
|
+
"test:u": "vitest --run -u",
|
148
|
+
"test:ai": "AI_TEST_TYPE=web npm run test",
|
149
|
+
"test:ai:bridge": "MIDSCENE_CACHE=true BRIDGE_MODE=true vitest --run tests/ai/bridge/open-new-tab.test.ts",
|
150
|
+
"test:ai:cache": "MIDSCENE_CACHE=true npm run test",
|
151
|
+
"upgrade": "modern upgrade",
|
152
|
+
"e2e": "playwright test --config=tests/playwright.config.ts",
|
153
|
+
"e2e:report": "MIDSCENE_REPORT=true playwright test --config=tests/playwright.config.ts",
|
154
|
+
"e2e:cache": "MIDSCENE_CACHE=true playwright test --config=tests/playwright.config.ts",
|
155
|
+
"e2e:ui": "playwright test --config=tests/playwright.config.ts --ui",
|
156
|
+
"e2e:ui:cache": "MIDSCENE_CACHE=true playwright test --config=tests/playwright.config.ts --ui"
|
157
|
+
},
|
140
158
|
"files": [
|
141
159
|
"static",
|
142
160
|
"dist",
|
@@ -145,8 +163,8 @@
|
|
145
163
|
"bin"
|
146
164
|
],
|
147
165
|
"dependencies": {
|
148
|
-
"misoai-core": "1.0.
|
149
|
-
"misoai-shared": "1.0.
|
166
|
+
"misoai-core": "1.0.7",
|
167
|
+
"misoai-shared": "1.0.3",
|
150
168
|
"@xmldom/xmldom": "0.8.10",
|
151
169
|
"cors": "2.8.5",
|
152
170
|
"dayjs": "1.11.11",
|
@@ -198,23 +216,5 @@
|
|
198
216
|
"access": "public",
|
199
217
|
"registry": "https://registry.npmjs.org"
|
200
218
|
},
|
201
|
-
"license": "MIT"
|
202
|
-
|
203
|
-
"dev": "npm run build && npx npm-watch",
|
204
|
-
"dev:server": "npm run build && ./bin/midscene-playground",
|
205
|
-
"build": "modern build -c ./modern.config.ts",
|
206
|
-
"postbuild": "node scripts/check-exports.js",
|
207
|
-
"build:watch": "modern build -w -c ./modern.config.ts",
|
208
|
-
"test": "vitest --run",
|
209
|
-
"test:u": "vitest --run -u",
|
210
|
-
"test:ai": "AI_TEST_TYPE=web npm run test",
|
211
|
-
"test:ai:bridge": "MIDSCENE_CACHE=true BRIDGE_MODE=true vitest --run tests/ai/bridge/open-new-tab.test.ts",
|
212
|
-
"test:ai:cache": "MIDSCENE_CACHE=true npm run test",
|
213
|
-
"upgrade": "modern upgrade",
|
214
|
-
"e2e": "playwright test --config=tests/playwright.config.ts",
|
215
|
-
"e2e:report": "MIDSCENE_REPORT=true playwright test --config=tests/playwright.config.ts",
|
216
|
-
"e2e:cache": "MIDSCENE_CACHE=true playwright test --config=tests/playwright.config.ts",
|
217
|
-
"e2e:ui": "playwright test --config=tests/playwright.config.ts --ui",
|
218
|
-
"e2e:ui:cache": "MIDSCENE_CACHE=true playwright test --config=tests/playwright.config.ts --ui"
|
219
|
-
}
|
220
|
-
}
|
219
|
+
"license": "MIT"
|
220
|
+
}
|
package/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2024-present Bytedance, Inc. and its affiliates.
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|