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.
Files changed (76) hide show
  1. package/README.md +5 -349
  2. package/dist/es/agent.js +165 -428
  3. package/dist/es/agent.js.map +1 -1
  4. package/dist/es/bridge-mode-browser.js +10 -9
  5. package/dist/es/bridge-mode-browser.js.map +1 -1
  6. package/dist/es/bridge-mode.js +167 -430
  7. package/dist/es/bridge-mode.js.map +1 -1
  8. package/dist/es/chrome-extension.js +173 -435
  9. package/dist/es/chrome-extension.js.map +1 -1
  10. package/dist/es/index.js +185 -432
  11. package/dist/es/index.js.map +1 -1
  12. package/dist/es/midscene-playground.js +165 -428
  13. package/dist/es/midscene-playground.js.map +1 -1
  14. package/dist/es/midscene-server.js.map +1 -1
  15. package/dist/es/playground.js +165 -428
  16. package/dist/es/playground.js.map +1 -1
  17. package/dist/es/playwright-report.js +1 -1
  18. package/dist/es/playwright-report.js.map +1 -1
  19. package/dist/es/playwright.js +182 -429
  20. package/dist/es/playwright.js.map +1 -1
  21. package/dist/es/puppeteer-agent-launcher.js +169 -432
  22. package/dist/es/puppeteer-agent-launcher.js.map +1 -1
  23. package/dist/es/puppeteer.js +169 -432
  24. package/dist/es/puppeteer.js.map +1 -1
  25. package/dist/es/ui-utils.js.map +1 -1
  26. package/dist/es/utils.js +7 -4
  27. package/dist/es/utils.js.map +1 -1
  28. package/dist/es/yaml.js +29 -3
  29. package/dist/es/yaml.js.map +1 -1
  30. package/dist/lib/agent.js +163 -426
  31. package/dist/lib/agent.js.map +1 -1
  32. package/dist/lib/bridge-mode-browser.js +10 -9
  33. package/dist/lib/bridge-mode-browser.js.map +1 -1
  34. package/dist/lib/bridge-mode.js +165 -428
  35. package/dist/lib/bridge-mode.js.map +1 -1
  36. package/dist/lib/chrome-extension.js +171 -433
  37. package/dist/lib/chrome-extension.js.map +1 -1
  38. package/dist/lib/index.js +183 -430
  39. package/dist/lib/index.js.map +1 -1
  40. package/dist/lib/midscene-playground.js +163 -426
  41. package/dist/lib/midscene-playground.js.map +1 -1
  42. package/dist/lib/midscene-server.js.map +1 -1
  43. package/dist/lib/playground.js +163 -426
  44. package/dist/lib/playground.js.map +1 -1
  45. package/dist/lib/playwright-report.js +1 -1
  46. package/dist/lib/playwright-report.js.map +1 -1
  47. package/dist/lib/playwright.js +180 -427
  48. package/dist/lib/playwright.js.map +1 -1
  49. package/dist/lib/puppeteer-agent-launcher.js +167 -430
  50. package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
  51. package/dist/lib/puppeteer.js +167 -430
  52. package/dist/lib/puppeteer.js.map +1 -1
  53. package/dist/lib/ui-utils.js.map +1 -1
  54. package/dist/lib/utils.js +7 -4
  55. package/dist/lib/utils.js.map +1 -1
  56. package/dist/lib/yaml.js +29 -3
  57. package/dist/lib/yaml.js.map +1 -1
  58. package/dist/types/agent.d.ts +13 -51
  59. package/dist/types/bridge-mode-browser.d.ts +2 -3
  60. package/dist/types/bridge-mode.d.ts +2 -3
  61. package/dist/types/{browser-aec1055d.d.ts → browser-9b472ffb.d.ts} +1 -1
  62. package/dist/types/chrome-extension.d.ts +2 -3
  63. package/dist/types/index.d.ts +1 -2
  64. package/dist/types/midscene-server.d.ts +1 -2
  65. package/dist/types/{page-86ab0fe1.d.ts → page-ed0ecb44.d.ts} +19 -9
  66. package/dist/types/playground.d.ts +2 -3
  67. package/dist/types/playwright.d.ts +9 -2
  68. package/dist/types/puppeteer-agent-launcher.d.ts +1 -2
  69. package/dist/types/puppeteer.d.ts +6 -5
  70. package/dist/types/ui-utils.d.ts +1 -1
  71. package/dist/types/utils.d.ts +1 -2
  72. package/dist/types/yaml.d.ts +1 -2
  73. package/iife-script/htmlElement.js +53 -75
  74. package/iife-script/htmlElementDebug.js +35 -56
  75. package/package.json +24 -24
  76. package/LICENSE +0 -21
@@ -43,9 +43,9 @@ var midscene_element_inspector = (() => {
43
43
  mod
44
44
  ));
45
45
 
46
- // resolve-false:\empty-stub
46
+ // resolve-false:/empty-stub
47
47
  var require_empty_stub = __commonJS({
48
- "resolve-false:\\empty-stub"(exports, module) {
48
+ "resolve-false:/empty-stub"(exports, module) {
49
49
  "use strict";
50
50
  module.exports = {};
51
51
  }
@@ -825,7 +825,7 @@ var midscene_element_inspector = (() => {
825
825
  });
826
826
  return true;
827
827
  };
828
- function elementRect(el, currentWindow, currentDocument, baseZoom = 1, visibleOnly = true) {
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 scrollLeft = currentWindow.pageXOffset || currentDocument.documentElement.scrollLeft;
853
- const scrollTop = currentWindow.pageYOffset || currentDocument.documentElement.scrollTop;
854
- const viewportWidth = currentWindow.innerWidth || currentDocument.documentElement.clientWidth;
855
- const viewportHeight = currentWindow.innerHeight || currentDocument.documentElement.clientHeight;
856
- const isPartiallyInViewport = visibleOnly ? isElementPartiallyInViewport(rect, currentWindow, currentDocument) : true;
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
- const parentElement = node.parentElement;
991
- if (parentElement && parentElement instanceof HTMLElement) {
992
- tagName = parentElement.tagName.toLowerCase();
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 }, visibleOnly = true) {
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 (visibleOnly && (rect.width < CONTAINER_MINI_WIDTH || rect.height < CONTAINER_MINI_HEIGHT)) {
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) === "Anchor Node" /* A */ || (elementInfo == null ? void 0 : elementInfo.nodeType) === "FORM_ITEM Node" /* FORM_ITEM */ || (elementInfo == null ? void 0 : elementInfo.nodeType) === "CONTAINER Node" /* CONTAINER */) {
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, visibleOnly = true) {
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,9 +8,9 @@
8
8
  "Browser use",
9
9
  "Android use"
10
10
  ],
11
- "version": "1.0.6",
11
+ "version": "1.5.7",
12
12
  "repository": "https://github.com/web-infra-dev/midscene",
13
- "homepage": "https://misoai.com/",
13
+ "homepage": "https://midscenejs.com/",
14
14
  "jsnext:source": "./src/index.ts",
15
15
  "main": "./dist/lib/index.js",
16
16
  "types": "./dist/types/index.d.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.5",
149
- "misoai-shared": "1.0.1",
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
- "scripts": {
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.