@midscene/web 0.9.2 → 0.10.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/dist/es/bridge-mode-browser.js +99 -43
- package/dist/es/bridge-mode.js +9 -6
- package/dist/es/chrome-extension.js +82 -32
- package/dist/es/index.js +20 -28
- package/dist/es/playwright.js +20 -28
- package/dist/es/puppeteer.js +20 -28
- package/dist/lib/bridge-mode-browser.js +99 -43
- package/dist/lib/bridge-mode.js +9 -6
- package/dist/lib/chrome-extension.js +82 -32
- package/dist/lib/index.js +20 -28
- package/dist/lib/playwright.js +20 -28
- package/dist/lib/puppeteer.js +20 -28
- package/dist/types/appium.d.ts +3 -3
- package/dist/types/bridge-mode-browser.d.ts +3 -27
- package/dist/types/bridge-mode.d.ts +6 -6
- package/dist/types/browser-d3c008c0.d.ts +34 -0
- package/dist/types/chrome-extension.d.ts +4 -4
- package/dist/types/debug.d.ts +2 -2
- package/dist/types/index.d.ts +4 -4
- package/dist/types/{page-29b209ea.d.ts → page-a1d76532.d.ts} +10 -5
- package/dist/types/playground.d.ts +4 -4
- package/dist/types/playwright.d.ts +4 -4
- package/dist/types/puppeteer.d.ts +3 -3
- package/dist/types/{tasks-07be2324.d.ts → tasks-54dbbfb4.d.ts} +3 -3
- package/dist/types/{utils-d3597829.d.ts → utils-7a58a29c.d.ts} +1 -1
- package/dist/types/utils.d.ts +2 -2
- package/dist/types/yaml.d.ts +4 -4
- package/package.json +3 -3
|
@@ -1618,6 +1618,9 @@ var ChromeExtensionProxyPageAgent = class extends PageAgent {
|
|
|
1618
1618
|
}
|
|
1619
1619
|
};
|
|
1620
1620
|
|
|
1621
|
+
// src/chrome-extension/page.ts
|
|
1622
|
+
var import_node_assert4 = __toESM(require("assert"));
|
|
1623
|
+
|
|
1621
1624
|
// src/chrome-extension/cdpInput.ts
|
|
1622
1625
|
var import_node_assert3 = __toESM(require("assert"));
|
|
1623
1626
|
|
|
@@ -2203,9 +2206,12 @@ var ChromeExtensionProxyPage = class {
|
|
|
2203
2206
|
constructor(trackingActiveTab) {
|
|
2204
2207
|
this.pageType = "chrome-extension-proxy";
|
|
2205
2208
|
this.activeTabId = null;
|
|
2209
|
+
this.tabIdOfDebuggerAttached = null;
|
|
2206
2210
|
this.attachingDebugger = null;
|
|
2211
|
+
this.destroyed = false;
|
|
2207
2212
|
this.mouse = {
|
|
2208
2213
|
click: async (x, y) => {
|
|
2214
|
+
await this.showMousePointer(x, y);
|
|
2209
2215
|
await this.sendCommandToDebugger("Input.dispatchMouseEvent", {
|
|
2210
2216
|
type: "mousePressed",
|
|
2211
2217
|
x,
|
|
@@ -2222,15 +2228,19 @@ var ChromeExtensionProxyPage = class {
|
|
|
2222
2228
|
});
|
|
2223
2229
|
},
|
|
2224
2230
|
wheel: async (deltaX, deltaY, startX, startY) => {
|
|
2231
|
+
const finalX = startX || 50;
|
|
2232
|
+
const finalY = startY || 50;
|
|
2233
|
+
await this.showMousePointer(finalX, finalY);
|
|
2225
2234
|
await this.sendCommandToDebugger("Input.dispatchMouseEvent", {
|
|
2226
2235
|
type: "mouseWheel",
|
|
2227
|
-
x:
|
|
2228
|
-
y:
|
|
2236
|
+
x: finalX,
|
|
2237
|
+
y: finalY,
|
|
2229
2238
|
deltaX,
|
|
2230
2239
|
deltaY
|
|
2231
2240
|
});
|
|
2232
2241
|
},
|
|
2233
2242
|
move: async (x, y) => {
|
|
2243
|
+
await this.showMousePointer(x, y);
|
|
2234
2244
|
await this.sendCommandToDebugger("Input.dispatchMouseEvent", {
|
|
2235
2245
|
type: "mouseMoved",
|
|
2236
2246
|
x,
|
|
@@ -2255,8 +2265,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
2255
2265
|
this.trackingActiveTab = trackingActiveTab;
|
|
2256
2266
|
}
|
|
2257
2267
|
async getTabId() {
|
|
2258
|
-
|
|
2259
|
-
if (this.activeTabId && !trackingActiveTab) {
|
|
2268
|
+
if (this.activeTabId && !this.trackingActiveTab) {
|
|
2260
2269
|
return this.activeTabId;
|
|
2261
2270
|
}
|
|
2262
2271
|
const tabId = await chrome.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
|
@@ -2267,6 +2276,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
2267
2276
|
return this.activeTabId;
|
|
2268
2277
|
}
|
|
2269
2278
|
async attachDebugger() {
|
|
2279
|
+
(0, import_node_assert4.default)(!this.destroyed, "Page is destroyed");
|
|
2270
2280
|
if (this.attachingDebugger) {
|
|
2271
2281
|
await this.attachingDebugger;
|
|
2272
2282
|
return;
|
|
@@ -2280,52 +2290,89 @@ var ChromeExtensionProxyPage = class {
|
|
|
2280
2290
|
}
|
|
2281
2291
|
try {
|
|
2282
2292
|
const currentTabId = await this.getTabId();
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
(target2) => target2.tabId === currentTabId && target2.attached === true
|
|
2286
|
-
);
|
|
2287
|
-
if (!target) {
|
|
2288
|
-
await chrome.debugger.attach({ tabId: currentTabId }, "1.3");
|
|
2289
|
-
await sleep2(340);
|
|
2293
|
+
if (this.tabIdOfDebuggerAttached === currentTabId) {
|
|
2294
|
+
return;
|
|
2290
2295
|
}
|
|
2296
|
+
if (this.tabIdOfDebuggerAttached && this.tabIdOfDebuggerAttached !== currentTabId) {
|
|
2297
|
+
console.log(
|
|
2298
|
+
"detach the previous tab",
|
|
2299
|
+
this.tabIdOfDebuggerAttached,
|
|
2300
|
+
"->",
|
|
2301
|
+
currentTabId
|
|
2302
|
+
);
|
|
2303
|
+
try {
|
|
2304
|
+
await this.detachDebugger(this.tabIdOfDebuggerAttached);
|
|
2305
|
+
} catch (error) {
|
|
2306
|
+
console.error("Failed to detach debugger", error);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
await chrome.debugger.attach({ tabId: currentTabId }, "1.3");
|
|
2310
|
+
await sleep2(500);
|
|
2311
|
+
this.tabIdOfDebuggerAttached = currentTabId;
|
|
2312
|
+
await this.enableWaterFlowAnimation();
|
|
2313
|
+
} catch (error) {
|
|
2314
|
+
console.error("Failed to attach debugger", error);
|
|
2291
2315
|
} finally {
|
|
2292
2316
|
this.attachingDebugger = null;
|
|
2293
2317
|
}
|
|
2294
2318
|
})();
|
|
2295
2319
|
await this.attachingDebugger;
|
|
2296
2320
|
}
|
|
2297
|
-
async
|
|
2298
|
-
const
|
|
2299
|
-
|
|
2300
|
-
|
|
2321
|
+
async showMousePointer(x, y) {
|
|
2322
|
+
const pointerScript = `(() => {
|
|
2323
|
+
if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {
|
|
2324
|
+
window.midsceneWaterFlowAnimation.enable();
|
|
2325
|
+
window.midsceneWaterFlowAnimation.showMousePointer(${x}, ${y});
|
|
2326
|
+
} else {
|
|
2327
|
+
console.log('midsceneWaterFlowAnimation is not defined');
|
|
2328
|
+
}
|
|
2329
|
+
})()`;
|
|
2330
|
+
await this.sendCommandToDebugger("Runtime.evaluate", {
|
|
2331
|
+
expression: `${pointerScript}`
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
async hideMousePointer() {
|
|
2335
|
+
await this.sendCommandToDebugger("Runtime.evaluate", {
|
|
2336
|
+
expression: `(() => {
|
|
2337
|
+
if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {
|
|
2338
|
+
window.midsceneWaterFlowAnimation.hideMousePointer();
|
|
2339
|
+
}
|
|
2340
|
+
})()`
|
|
2301
2341
|
});
|
|
2302
2342
|
}
|
|
2343
|
+
async detachDebugger(tabId) {
|
|
2344
|
+
const tabIdToDetach = tabId || this.tabIdOfDebuggerAttached;
|
|
2345
|
+
if (!tabIdToDetach) {
|
|
2346
|
+
console.warn("No tab id to detach");
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2349
|
+
await this.disableWaterFlowAnimation(tabIdToDetach);
|
|
2350
|
+
await sleep2(200);
|
|
2351
|
+
await chrome.debugger.detach({ tabId: tabIdToDetach });
|
|
2352
|
+
this.tabIdOfDebuggerAttached = null;
|
|
2353
|
+
}
|
|
2354
|
+
async enableWaterFlowAnimation() {
|
|
2355
|
+
const script = await injectWaterFlowAnimation();
|
|
2356
|
+
await chrome.debugger.sendCommand(
|
|
2357
|
+
{ tabId: this.tabIdOfDebuggerAttached },
|
|
2358
|
+
"Runtime.evaluate",
|
|
2359
|
+
{
|
|
2360
|
+
expression: script
|
|
2361
|
+
}
|
|
2362
|
+
);
|
|
2363
|
+
}
|
|
2303
2364
|
async disableWaterFlowAnimation(tabId) {
|
|
2304
2365
|
const script = await injectStopWaterFlowAnimation();
|
|
2305
2366
|
await chrome.debugger.sendCommand({ tabId }, "Runtime.evaluate", {
|
|
2306
2367
|
expression: script
|
|
2307
2368
|
});
|
|
2308
2369
|
}
|
|
2309
|
-
async detachDebugger() {
|
|
2310
|
-
const targets = await chrome.debugger.getTargets();
|
|
2311
|
-
const attendTabs = targets.filter(
|
|
2312
|
-
(target) => target.attached === true && !target.url.startsWith("chrome-extension://")
|
|
2313
|
-
);
|
|
2314
|
-
if (attendTabs.length > 0) {
|
|
2315
|
-
for (const tab of attendTabs) {
|
|
2316
|
-
if (tab.tabId) {
|
|
2317
|
-
await this.disableWaterFlowAnimation(tab.tabId);
|
|
2318
|
-
chrome.debugger.detach({ tabId: tab.tabId });
|
|
2319
|
-
}
|
|
2320
|
-
}
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
2370
|
async sendCommandToDebugger(command, params) {
|
|
2324
2371
|
await this.attachDebugger();
|
|
2325
|
-
|
|
2326
|
-
this.enableWaterFlowAnimation(
|
|
2372
|
+
(0, import_node_assert4.default)(this.tabIdOfDebuggerAttached, "Debugger is not attached");
|
|
2373
|
+
this.enableWaterFlowAnimation();
|
|
2327
2374
|
return await chrome.debugger.sendCommand(
|
|
2328
|
-
{ tabId },
|
|
2375
|
+
{ tabId: this.tabIdOfDebuggerAttached },
|
|
2329
2376
|
command,
|
|
2330
2377
|
params
|
|
2331
2378
|
);
|
|
@@ -2382,6 +2429,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
2382
2429
|
);
|
|
2383
2430
|
}
|
|
2384
2431
|
async getElementInfos() {
|
|
2432
|
+
await this.hideMousePointer();
|
|
2385
2433
|
const content = await this.getPageContentByCDP();
|
|
2386
2434
|
if (content == null ? void 0 : content.size) {
|
|
2387
2435
|
this.viewportSize = content.size;
|
|
@@ -2395,6 +2443,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
2395
2443
|
return content.size;
|
|
2396
2444
|
}
|
|
2397
2445
|
async screenshotBase64() {
|
|
2446
|
+
await this.hideMousePointer();
|
|
2398
2447
|
const base64 = await this.sendCommandToDebugger("Page.captureScreenshot", {
|
|
2399
2448
|
format: "jpeg",
|
|
2400
2449
|
quality: 70
|
|
@@ -2494,6 +2543,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
2494
2543
|
async destroy() {
|
|
2495
2544
|
this.activeTabId = null;
|
|
2496
2545
|
await this.detachDebugger();
|
|
2546
|
+
this.destroyed = true;
|
|
2497
2547
|
}
|
|
2498
2548
|
};
|
|
2499
2549
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/lib/index.js
CHANGED
|
@@ -1845,61 +1845,53 @@ var Page = class {
|
|
|
1845
1845
|
}
|
|
1846
1846
|
await this.keyboard.press("Backspace");
|
|
1847
1847
|
}
|
|
1848
|
-
async
|
|
1849
|
-
if (
|
|
1850
|
-
await this.mouse.move(
|
|
1848
|
+
async moveToPoint(point) {
|
|
1849
|
+
if (point) {
|
|
1850
|
+
await this.mouse.move(point.left, point.top);
|
|
1851
|
+
} else {
|
|
1852
|
+
const size = await this.size();
|
|
1853
|
+
await this.mouse.move(size.width / 2, size.height / 2);
|
|
1851
1854
|
}
|
|
1855
|
+
}
|
|
1856
|
+
async scrollUntilTop(startingPoint) {
|
|
1857
|
+
await this.moveToPoint(startingPoint);
|
|
1852
1858
|
return this.mouse.wheel(0, -9999999);
|
|
1853
1859
|
}
|
|
1854
1860
|
async scrollUntilBottom(startingPoint) {
|
|
1855
|
-
|
|
1856
|
-
await this.mouse.move(startingPoint.left, startingPoint.top);
|
|
1857
|
-
}
|
|
1861
|
+
await this.moveToPoint(startingPoint);
|
|
1858
1862
|
return this.mouse.wheel(0, 9999999);
|
|
1859
1863
|
}
|
|
1860
1864
|
async scrollUntilLeft(startingPoint) {
|
|
1861
|
-
|
|
1862
|
-
await this.mouse.move(startingPoint.left, startingPoint.top);
|
|
1863
|
-
}
|
|
1865
|
+
await this.moveToPoint(startingPoint);
|
|
1864
1866
|
return this.mouse.wheel(-9999999, 0);
|
|
1865
1867
|
}
|
|
1866
1868
|
async scrollUntilRight(startingPoint) {
|
|
1867
|
-
|
|
1868
|
-
await this.mouse.move(startingPoint.left, startingPoint.top);
|
|
1869
|
-
}
|
|
1869
|
+
await this.moveToPoint(startingPoint);
|
|
1870
1870
|
return this.mouse.wheel(9999999, 0);
|
|
1871
1871
|
}
|
|
1872
1872
|
async scrollUp(distance, startingPoint) {
|
|
1873
1873
|
const innerHeight = await this.evaluate(() => window.innerHeight);
|
|
1874
1874
|
const scrollDistance = distance || innerHeight * 0.7;
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
}
|
|
1878
|
-
await this.mouse.wheel(0, -scrollDistance);
|
|
1875
|
+
await this.moveToPoint(startingPoint);
|
|
1876
|
+
return this.mouse.wheel(0, -scrollDistance);
|
|
1879
1877
|
}
|
|
1880
1878
|
async scrollDown(distance, startingPoint) {
|
|
1881
1879
|
const innerHeight = await this.evaluate(() => window.innerHeight);
|
|
1882
1880
|
const scrollDistance = distance || innerHeight * 0.7;
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
}
|
|
1886
|
-
await this.mouse.wheel(0, scrollDistance);
|
|
1881
|
+
await this.moveToPoint(startingPoint);
|
|
1882
|
+
return this.mouse.wheel(0, scrollDistance);
|
|
1887
1883
|
}
|
|
1888
1884
|
async scrollLeft(distance, startingPoint) {
|
|
1889
1885
|
const innerWidth = await this.evaluate(() => window.innerWidth);
|
|
1890
1886
|
const scrollDistance = distance || innerWidth * 0.7;
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
}
|
|
1894
|
-
await this.mouse.wheel(-scrollDistance, 0);
|
|
1887
|
+
await this.moveToPoint(startingPoint);
|
|
1888
|
+
return this.mouse.wheel(-scrollDistance, 0);
|
|
1895
1889
|
}
|
|
1896
1890
|
async scrollRight(distance, startingPoint) {
|
|
1897
1891
|
const innerWidth = await this.evaluate(() => window.innerWidth);
|
|
1898
1892
|
const scrollDistance = distance || innerWidth * 0.7;
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
}
|
|
1902
|
-
await this.mouse.wheel(scrollDistance, 0);
|
|
1893
|
+
await this.moveToPoint(startingPoint);
|
|
1894
|
+
return this.mouse.wheel(scrollDistance, 0);
|
|
1903
1895
|
}
|
|
1904
1896
|
async destroy() {
|
|
1905
1897
|
}
|
package/dist/lib/playwright.js
CHANGED
|
@@ -1839,61 +1839,53 @@ var Page = class {
|
|
|
1839
1839
|
}
|
|
1840
1840
|
await this.keyboard.press("Backspace");
|
|
1841
1841
|
}
|
|
1842
|
-
async
|
|
1843
|
-
if (
|
|
1844
|
-
await this.mouse.move(
|
|
1842
|
+
async moveToPoint(point) {
|
|
1843
|
+
if (point) {
|
|
1844
|
+
await this.mouse.move(point.left, point.top);
|
|
1845
|
+
} else {
|
|
1846
|
+
const size = await this.size();
|
|
1847
|
+
await this.mouse.move(size.width / 2, size.height / 2);
|
|
1845
1848
|
}
|
|
1849
|
+
}
|
|
1850
|
+
async scrollUntilTop(startingPoint) {
|
|
1851
|
+
await this.moveToPoint(startingPoint);
|
|
1846
1852
|
return this.mouse.wheel(0, -9999999);
|
|
1847
1853
|
}
|
|
1848
1854
|
async scrollUntilBottom(startingPoint) {
|
|
1849
|
-
|
|
1850
|
-
await this.mouse.move(startingPoint.left, startingPoint.top);
|
|
1851
|
-
}
|
|
1855
|
+
await this.moveToPoint(startingPoint);
|
|
1852
1856
|
return this.mouse.wheel(0, 9999999);
|
|
1853
1857
|
}
|
|
1854
1858
|
async scrollUntilLeft(startingPoint) {
|
|
1855
|
-
|
|
1856
|
-
await this.mouse.move(startingPoint.left, startingPoint.top);
|
|
1857
|
-
}
|
|
1859
|
+
await this.moveToPoint(startingPoint);
|
|
1858
1860
|
return this.mouse.wheel(-9999999, 0);
|
|
1859
1861
|
}
|
|
1860
1862
|
async scrollUntilRight(startingPoint) {
|
|
1861
|
-
|
|
1862
|
-
await this.mouse.move(startingPoint.left, startingPoint.top);
|
|
1863
|
-
}
|
|
1863
|
+
await this.moveToPoint(startingPoint);
|
|
1864
1864
|
return this.mouse.wheel(9999999, 0);
|
|
1865
1865
|
}
|
|
1866
1866
|
async scrollUp(distance, startingPoint) {
|
|
1867
1867
|
const innerHeight = await this.evaluate(() => window.innerHeight);
|
|
1868
1868
|
const scrollDistance = distance || innerHeight * 0.7;
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
}
|
|
1872
|
-
await this.mouse.wheel(0, -scrollDistance);
|
|
1869
|
+
await this.moveToPoint(startingPoint);
|
|
1870
|
+
return this.mouse.wheel(0, -scrollDistance);
|
|
1873
1871
|
}
|
|
1874
1872
|
async scrollDown(distance, startingPoint) {
|
|
1875
1873
|
const innerHeight = await this.evaluate(() => window.innerHeight);
|
|
1876
1874
|
const scrollDistance = distance || innerHeight * 0.7;
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
}
|
|
1880
|
-
await this.mouse.wheel(0, scrollDistance);
|
|
1875
|
+
await this.moveToPoint(startingPoint);
|
|
1876
|
+
return this.mouse.wheel(0, scrollDistance);
|
|
1881
1877
|
}
|
|
1882
1878
|
async scrollLeft(distance, startingPoint) {
|
|
1883
1879
|
const innerWidth = await this.evaluate(() => window.innerWidth);
|
|
1884
1880
|
const scrollDistance = distance || innerWidth * 0.7;
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
}
|
|
1888
|
-
await this.mouse.wheel(-scrollDistance, 0);
|
|
1881
|
+
await this.moveToPoint(startingPoint);
|
|
1882
|
+
return this.mouse.wheel(-scrollDistance, 0);
|
|
1889
1883
|
}
|
|
1890
1884
|
async scrollRight(distance, startingPoint) {
|
|
1891
1885
|
const innerWidth = await this.evaluate(() => window.innerWidth);
|
|
1892
1886
|
const scrollDistance = distance || innerWidth * 0.7;
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
}
|
|
1896
|
-
await this.mouse.wheel(scrollDistance, 0);
|
|
1887
|
+
await this.moveToPoint(startingPoint);
|
|
1888
|
+
return this.mouse.wheel(scrollDistance, 0);
|
|
1897
1889
|
}
|
|
1898
1890
|
async destroy() {
|
|
1899
1891
|
}
|
package/dist/lib/puppeteer.js
CHANGED
|
@@ -1684,61 +1684,53 @@ var Page = class {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
await this.keyboard.press("Backspace");
|
|
1686
1686
|
}
|
|
1687
|
-
async
|
|
1688
|
-
if (
|
|
1689
|
-
await this.mouse.move(
|
|
1687
|
+
async moveToPoint(point) {
|
|
1688
|
+
if (point) {
|
|
1689
|
+
await this.mouse.move(point.left, point.top);
|
|
1690
|
+
} else {
|
|
1691
|
+
const size = await this.size();
|
|
1692
|
+
await this.mouse.move(size.width / 2, size.height / 2);
|
|
1690
1693
|
}
|
|
1694
|
+
}
|
|
1695
|
+
async scrollUntilTop(startingPoint) {
|
|
1696
|
+
await this.moveToPoint(startingPoint);
|
|
1691
1697
|
return this.mouse.wheel(0, -9999999);
|
|
1692
1698
|
}
|
|
1693
1699
|
async scrollUntilBottom(startingPoint) {
|
|
1694
|
-
|
|
1695
|
-
await this.mouse.move(startingPoint.left, startingPoint.top);
|
|
1696
|
-
}
|
|
1700
|
+
await this.moveToPoint(startingPoint);
|
|
1697
1701
|
return this.mouse.wheel(0, 9999999);
|
|
1698
1702
|
}
|
|
1699
1703
|
async scrollUntilLeft(startingPoint) {
|
|
1700
|
-
|
|
1701
|
-
await this.mouse.move(startingPoint.left, startingPoint.top);
|
|
1702
|
-
}
|
|
1704
|
+
await this.moveToPoint(startingPoint);
|
|
1703
1705
|
return this.mouse.wheel(-9999999, 0);
|
|
1704
1706
|
}
|
|
1705
1707
|
async scrollUntilRight(startingPoint) {
|
|
1706
|
-
|
|
1707
|
-
await this.mouse.move(startingPoint.left, startingPoint.top);
|
|
1708
|
-
}
|
|
1708
|
+
await this.moveToPoint(startingPoint);
|
|
1709
1709
|
return this.mouse.wheel(9999999, 0);
|
|
1710
1710
|
}
|
|
1711
1711
|
async scrollUp(distance, startingPoint) {
|
|
1712
1712
|
const innerHeight = await this.evaluate(() => window.innerHeight);
|
|
1713
1713
|
const scrollDistance = distance || innerHeight * 0.7;
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
}
|
|
1717
|
-
await this.mouse.wheel(0, -scrollDistance);
|
|
1714
|
+
await this.moveToPoint(startingPoint);
|
|
1715
|
+
return this.mouse.wheel(0, -scrollDistance);
|
|
1718
1716
|
}
|
|
1719
1717
|
async scrollDown(distance, startingPoint) {
|
|
1720
1718
|
const innerHeight = await this.evaluate(() => window.innerHeight);
|
|
1721
1719
|
const scrollDistance = distance || innerHeight * 0.7;
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
}
|
|
1725
|
-
await this.mouse.wheel(0, scrollDistance);
|
|
1720
|
+
await this.moveToPoint(startingPoint);
|
|
1721
|
+
return this.mouse.wheel(0, scrollDistance);
|
|
1726
1722
|
}
|
|
1727
1723
|
async scrollLeft(distance, startingPoint) {
|
|
1728
1724
|
const innerWidth = await this.evaluate(() => window.innerWidth);
|
|
1729
1725
|
const scrollDistance = distance || innerWidth * 0.7;
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
}
|
|
1733
|
-
await this.mouse.wheel(-scrollDistance, 0);
|
|
1726
|
+
await this.moveToPoint(startingPoint);
|
|
1727
|
+
return this.mouse.wheel(-scrollDistance, 0);
|
|
1734
1728
|
}
|
|
1735
1729
|
async scrollRight(distance, startingPoint) {
|
|
1736
1730
|
const innerWidth = await this.evaluate(() => window.innerWidth);
|
|
1737
1731
|
const scrollDistance = distance || innerWidth * 0.7;
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
}
|
|
1741
|
-
await this.mouse.wheel(scrollDistance, 0);
|
|
1732
|
+
await this.moveToPoint(startingPoint);
|
|
1733
|
+
return this.mouse.wheel(scrollDistance, 0);
|
|
1742
1734
|
}
|
|
1743
1735
|
async destroy() {
|
|
1744
1736
|
}
|
package/dist/types/appium.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { P as AppiumAgent } from './tasks-
|
|
2
|
-
export { P as AppiumPage } from './page-
|
|
3
|
-
import '@midscene/core/dist/lib/types/types-
|
|
1
|
+
export { P as AppiumAgent } from './tasks-54dbbfb4.js';
|
|
2
|
+
export { P as AppiumPage } from './page-a1d76532.js';
|
|
3
|
+
import '@midscene/core/dist/lib/types/types-64c4d87b';
|
|
4
4
|
import '@midscene/core';
|
|
5
5
|
import '@midscene/core/ai-model';
|
|
6
6
|
import '@midscene/shared/fs';
|
|
@@ -1,32 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
export { C as ChromeExtensionPageBrowserSide } from './browser-d3c008c0.js';
|
|
2
|
+
import './page-a1d76532.js';
|
|
2
3
|
import 'playwright';
|
|
3
4
|
import '@midscene/core';
|
|
4
5
|
import 'puppeteer';
|
|
5
6
|
import '@midscene/shared/constants';
|
|
6
|
-
import '@midscene/core/dist/lib/types/types-
|
|
7
|
+
import '@midscene/core/dist/lib/types/types-64c4d87b';
|
|
7
8
|
import 'webdriverio';
|
|
8
|
-
|
|
9
|
-
declare class BridgeClient {
|
|
10
|
-
endpoint: string;
|
|
11
|
-
onBridgeCall: (method: string, args: any[]) => Promise<any>;
|
|
12
|
-
onDisconnect?: (() => void) | undefined;
|
|
13
|
-
private socket;
|
|
14
|
-
serverVersion: string | null;
|
|
15
|
-
constructor(endpoint: string, onBridgeCall: (method: string, args: any[]) => Promise<any>, onDisconnect?: (() => void) | undefined);
|
|
16
|
-
connect(): Promise<unknown>;
|
|
17
|
-
disconnect(): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
declare class ChromeExtensionPageBrowserSide extends ChromeExtensionProxyPage {
|
|
21
|
-
onDisconnect: () => void;
|
|
22
|
-
onLogMessage: (message: string, type: 'log' | 'status') => void;
|
|
23
|
-
bridgeClient: BridgeClient | null;
|
|
24
|
-
constructor(onDisconnect?: () => void, onLogMessage?: (message: string, type: 'log' | 'status') => void);
|
|
25
|
-
private setupBridgeClient;
|
|
26
|
-
connect(): Promise<void>;
|
|
27
|
-
connectNewTabWithUrl(url: string): Promise<void>;
|
|
28
|
-
connectCurrentTab(): Promise<void>;
|
|
29
|
-
destroy(): Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { ChromeExtensionPageBrowserSide };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as PageAgent } from './tasks-
|
|
2
|
-
import { ChromeExtensionPageBrowserSide } from './
|
|
3
|
-
import '@midscene/core/dist/lib/types/types-
|
|
4
|
-
import './page-
|
|
1
|
+
import { P as PageAgent } from './tasks-54dbbfb4.js';
|
|
2
|
+
import { B as BridgeConnectTabOptions, C as ChromeExtensionPageBrowserSide } from './browser-d3c008c0.js';
|
|
3
|
+
import '@midscene/core/dist/lib/types/types-64c4d87b';
|
|
4
|
+
import './page-a1d76532.js';
|
|
5
5
|
import 'playwright';
|
|
6
6
|
import '@midscene/core';
|
|
7
7
|
import 'puppeteer';
|
|
@@ -15,8 +15,8 @@ interface ChromeExtensionPageCliSide extends ChromeExtensionPageBrowserSide {
|
|
|
15
15
|
}
|
|
16
16
|
declare class AgentOverChromeBridge extends PageAgent<ChromeExtensionPageCliSide> {
|
|
17
17
|
constructor();
|
|
18
|
-
connectNewTabWithUrl(url: string): Promise<void>;
|
|
19
|
-
connectCurrentTab(): Promise<void>;
|
|
18
|
+
connectNewTabWithUrl(url: string, options?: BridgeConnectTabOptions): Promise<void>;
|
|
19
|
+
connectCurrentTab(options?: BridgeConnectTabOptions): Promise<void>;
|
|
20
20
|
aiAction(prompt: string, options?: any): Promise<void>;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { C as ChromeExtensionProxyPage } from './page-a1d76532.js';
|
|
2
|
+
|
|
3
|
+
interface BridgeConnectTabOptions {
|
|
4
|
+
/**
|
|
5
|
+
* If true, the page will always track the active tab.
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
trackingActiveTab?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare class BridgeClient {
|
|
12
|
+
endpoint: string;
|
|
13
|
+
onBridgeCall: (method: string, args: any[]) => Promise<any>;
|
|
14
|
+
onDisconnect?: (() => void) | undefined;
|
|
15
|
+
private socket;
|
|
16
|
+
serverVersion: string | null;
|
|
17
|
+
constructor(endpoint: string, onBridgeCall: (method: string, args: any[]) => Promise<any>, onDisconnect?: (() => void) | undefined);
|
|
18
|
+
connect(): Promise<unknown>;
|
|
19
|
+
disconnect(): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare class ChromeExtensionPageBrowserSide extends ChromeExtensionProxyPage {
|
|
23
|
+
onDisconnect: () => void;
|
|
24
|
+
onLogMessage: (message: string, type: 'log' | 'status') => void;
|
|
25
|
+
bridgeClient: BridgeClient | null;
|
|
26
|
+
constructor(onDisconnect?: () => void, onLogMessage?: (message: string, type: 'log' | 'status') => void, trackingActiveTab?: boolean);
|
|
27
|
+
private setupBridgeClient;
|
|
28
|
+
connect(): Promise<void>;
|
|
29
|
+
connectNewTabWithUrl(url: string, options?: BridgeConnectTabOptions): Promise<void>;
|
|
30
|
+
connectCurrentTab(options?: BridgeConnectTabOptions): Promise<void>;
|
|
31
|
+
destroy(): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { type BridgeConnectTabOptions as B, ChromeExtensionPageBrowserSide as C };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as ChromeExtensionProxyPage } from './page-
|
|
2
|
-
export { a as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-
|
|
3
|
-
import { P as PageAgent } from './tasks-
|
|
1
|
+
import { C as ChromeExtensionProxyPage } from './page-a1d76532.js';
|
|
2
|
+
export { a as ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED } from './page-a1d76532.js';
|
|
3
|
+
import { P as PageAgent } from './tasks-54dbbfb4.js';
|
|
4
4
|
import 'playwright';
|
|
5
5
|
import '@midscene/core';
|
|
6
6
|
import 'puppeteer';
|
|
7
7
|
import '@midscene/shared/constants';
|
|
8
|
-
import '@midscene/core/dist/lib/types/types-
|
|
8
|
+
import '@midscene/core/dist/lib/types/types-64c4d87b';
|
|
9
9
|
import 'webdriverio';
|
|
10
10
|
import '@midscene/core/ai-model';
|
|
11
11
|
import '@midscene/shared/fs';
|
package/dist/types/debug.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { writeFileSync } from 'node:fs';
|
|
2
|
-
import { W as WebPage, E as ElementInfo } from './page-
|
|
2
|
+
import { W as WebPage, E as ElementInfo } from './page-a1d76532.js';
|
|
3
3
|
import 'playwright';
|
|
4
4
|
import '@midscene/core';
|
|
5
5
|
import 'puppeteer';
|
|
6
6
|
import '@midscene/shared/constants';
|
|
7
|
-
import '@midscene/core/dist/lib/types/types-
|
|
7
|
+
import '@midscene/core/dist/lib/types/types-64c4d87b';
|
|
8
8
|
import 'webdriverio';
|
|
9
9
|
|
|
10
10
|
declare function generateExtractData(page: WebPage, targetDir: string, saveImgType?: {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export { PlayWrightAiFixtureType, PlaywrightAiFixture } from './playwright.js';
|
|
2
|
-
export { P as AppiumAgent, P as PlaywrightAgent } from './tasks-
|
|
3
|
-
export { P as AppiumPage } from './page-
|
|
2
|
+
export { P as AppiumAgent, P as PlaywrightAgent } from './tasks-54dbbfb4.js';
|
|
3
|
+
export { P as AppiumPage } from './page-a1d76532.js';
|
|
4
4
|
export { StaticPageAgent } from './playground.js';
|
|
5
5
|
export { PuppeteerAgent } from './puppeteer.js';
|
|
6
6
|
export { generateExtractData } from './debug.js';
|
|
7
|
-
export { S as ScriptPlayer, f as flowItemBrief, p as parseYamlScript } from './utils-
|
|
7
|
+
export { S as ScriptPlayer, f as flowItemBrief, p as parseYamlScript } from './utils-7a58a29c.js';
|
|
8
8
|
import '@midscene/core';
|
|
9
9
|
import '@playwright/test';
|
|
10
10
|
import 'playwright';
|
|
11
11
|
import '@midscene/core/env';
|
|
12
|
-
import '@midscene/core/dist/lib/types/types-
|
|
12
|
+
import '@midscene/core/dist/lib/types/types-64c4d87b';
|
|
13
13
|
import '@midscene/core/ai-model';
|
|
14
14
|
import '@midscene/shared/fs';
|
|
15
15
|
import 'puppeteer';
|
|
@@ -2,7 +2,7 @@ import { Page as Page$3 } from 'playwright';
|
|
|
2
2
|
import { BaseElement, Rect, UIContext, PlaywrightParserOpt, Size, Point } from '@midscene/core';
|
|
3
3
|
import { KeyInput, Page as Page$2 } from 'puppeteer';
|
|
4
4
|
import { NodeType } from '@midscene/shared/constants';
|
|
5
|
-
import * as
|
|
5
|
+
import * as _midscene_core_dist_lib_types_types_64c4d87b from '@midscene/core/dist/lib/types/types-64c4d87b';
|
|
6
6
|
import { Browser } from 'webdriverio';
|
|
7
7
|
|
|
8
8
|
declare class WebElementInfo implements BaseElement {
|
|
@@ -143,16 +143,20 @@ declare class Page$1 implements AbstractPage {
|
|
|
143
143
|
|
|
144
144
|
declare class ChromeExtensionProxyPage implements AbstractPage {
|
|
145
145
|
pageType: string;
|
|
146
|
-
trackingActiveTab:
|
|
146
|
+
trackingActiveTab: boolean;
|
|
147
147
|
private viewportSize?;
|
|
148
148
|
private activeTabId;
|
|
149
|
+
private tabIdOfDebuggerAttached;
|
|
149
150
|
private attachingDebugger;
|
|
150
|
-
|
|
151
|
+
private destroyed;
|
|
152
|
+
constructor(trackingActiveTab: boolean);
|
|
151
153
|
getTabId(): Promise<number>;
|
|
152
154
|
private attachDebugger;
|
|
155
|
+
private showMousePointer;
|
|
156
|
+
private hideMousePointer;
|
|
157
|
+
private detachDebugger;
|
|
153
158
|
private enableWaterFlowAnimation;
|
|
154
159
|
private disableWaterFlowAnimation;
|
|
155
|
-
private detachDebugger;
|
|
156
160
|
private sendCommandToDebugger;
|
|
157
161
|
private getPageContentByCDP;
|
|
158
162
|
waitUntilNetworkIdle(): Promise<void>;
|
|
@@ -186,7 +190,7 @@ declare class StaticPage implements AbstractPage {
|
|
|
186
190
|
private uiContext;
|
|
187
191
|
constructor(uiContext: WebUIContext);
|
|
188
192
|
getElementInfos(): Promise<any>;
|
|
189
|
-
size(): Promise<
|
|
193
|
+
size(): Promise<_midscene_core_dist_lib_types_types_64c4d87b.S>;
|
|
190
194
|
screenshotBase64(): Promise<string>;
|
|
191
195
|
url(): Promise<string>;
|
|
192
196
|
scrollUntilTop(startingPoint?: Point): Promise<any>;
|
|
@@ -235,6 +239,7 @@ declare class Page<AgentType extends 'puppeteer' | 'playwright', PageType extend
|
|
|
235
239
|
up: (key: WebKeyInput) => Promise<void>;
|
|
236
240
|
};
|
|
237
241
|
clearInput(element: ElementInfo): Promise<void>;
|
|
242
|
+
private moveToPoint;
|
|
238
243
|
scrollUntilTop(startingPoint?: Point): Promise<void>;
|
|
239
244
|
scrollUntilBottom(startingPoint?: Point): Promise<void>;
|
|
240
245
|
scrollUntilLeft(startingPoint?: Point): Promise<void>;
|