@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
package/dist/es/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/es/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
|
}
|
|
@@ -57,7 +57,10 @@ __export(browser_exports, {
|
|
|
57
57
|
module.exports = __toCommonJS(browser_exports);
|
|
58
58
|
|
|
59
59
|
// src/bridge-mode/page-browser-side.ts
|
|
60
|
-
var
|
|
60
|
+
var import_node_assert4 = __toESM(require("assert"));
|
|
61
|
+
|
|
62
|
+
// src/chrome-extension/page.ts
|
|
63
|
+
var import_node_assert2 = __toESM(require("assert"));
|
|
61
64
|
|
|
62
65
|
// src/chrome-extension/cdpInput.ts
|
|
63
66
|
var import_node_assert = __toESM(require("assert"));
|
|
@@ -644,9 +647,12 @@ var ChromeExtensionProxyPage = class {
|
|
|
644
647
|
constructor(trackingActiveTab) {
|
|
645
648
|
this.pageType = "chrome-extension-proxy";
|
|
646
649
|
this.activeTabId = null;
|
|
650
|
+
this.tabIdOfDebuggerAttached = null;
|
|
647
651
|
this.attachingDebugger = null;
|
|
652
|
+
this.destroyed = false;
|
|
648
653
|
this.mouse = {
|
|
649
654
|
click: async (x, y) => {
|
|
655
|
+
await this.showMousePointer(x, y);
|
|
650
656
|
await this.sendCommandToDebugger("Input.dispatchMouseEvent", {
|
|
651
657
|
type: "mousePressed",
|
|
652
658
|
x,
|
|
@@ -663,15 +669,19 @@ var ChromeExtensionProxyPage = class {
|
|
|
663
669
|
});
|
|
664
670
|
},
|
|
665
671
|
wheel: async (deltaX, deltaY, startX, startY) => {
|
|
672
|
+
const finalX = startX || 50;
|
|
673
|
+
const finalY = startY || 50;
|
|
674
|
+
await this.showMousePointer(finalX, finalY);
|
|
666
675
|
await this.sendCommandToDebugger("Input.dispatchMouseEvent", {
|
|
667
676
|
type: "mouseWheel",
|
|
668
|
-
x:
|
|
669
|
-
y:
|
|
677
|
+
x: finalX,
|
|
678
|
+
y: finalY,
|
|
670
679
|
deltaX,
|
|
671
680
|
deltaY
|
|
672
681
|
});
|
|
673
682
|
},
|
|
674
683
|
move: async (x, y) => {
|
|
684
|
+
await this.showMousePointer(x, y);
|
|
675
685
|
await this.sendCommandToDebugger("Input.dispatchMouseEvent", {
|
|
676
686
|
type: "mouseMoved",
|
|
677
687
|
x,
|
|
@@ -696,8 +706,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
696
706
|
this.trackingActiveTab = trackingActiveTab;
|
|
697
707
|
}
|
|
698
708
|
async getTabId() {
|
|
699
|
-
|
|
700
|
-
if (this.activeTabId && !trackingActiveTab) {
|
|
709
|
+
if (this.activeTabId && !this.trackingActiveTab) {
|
|
701
710
|
return this.activeTabId;
|
|
702
711
|
}
|
|
703
712
|
const tabId = await chrome.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
|
@@ -708,6 +717,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
708
717
|
return this.activeTabId;
|
|
709
718
|
}
|
|
710
719
|
async attachDebugger() {
|
|
720
|
+
(0, import_node_assert2.default)(!this.destroyed, "Page is destroyed");
|
|
711
721
|
if (this.attachingDebugger) {
|
|
712
722
|
await this.attachingDebugger;
|
|
713
723
|
return;
|
|
@@ -721,52 +731,89 @@ var ChromeExtensionProxyPage = class {
|
|
|
721
731
|
}
|
|
722
732
|
try {
|
|
723
733
|
const currentTabId = await this.getTabId();
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
(target2) => target2.tabId === currentTabId && target2.attached === true
|
|
727
|
-
);
|
|
728
|
-
if (!target) {
|
|
729
|
-
await chrome.debugger.attach({ tabId: currentTabId }, "1.3");
|
|
730
|
-
await sleep(340);
|
|
734
|
+
if (this.tabIdOfDebuggerAttached === currentTabId) {
|
|
735
|
+
return;
|
|
731
736
|
}
|
|
737
|
+
if (this.tabIdOfDebuggerAttached && this.tabIdOfDebuggerAttached !== currentTabId) {
|
|
738
|
+
console.log(
|
|
739
|
+
"detach the previous tab",
|
|
740
|
+
this.tabIdOfDebuggerAttached,
|
|
741
|
+
"->",
|
|
742
|
+
currentTabId
|
|
743
|
+
);
|
|
744
|
+
try {
|
|
745
|
+
await this.detachDebugger(this.tabIdOfDebuggerAttached);
|
|
746
|
+
} catch (error) {
|
|
747
|
+
console.error("Failed to detach debugger", error);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
await chrome.debugger.attach({ tabId: currentTabId }, "1.3");
|
|
751
|
+
await sleep(500);
|
|
752
|
+
this.tabIdOfDebuggerAttached = currentTabId;
|
|
753
|
+
await this.enableWaterFlowAnimation();
|
|
754
|
+
} catch (error) {
|
|
755
|
+
console.error("Failed to attach debugger", error);
|
|
732
756
|
} finally {
|
|
733
757
|
this.attachingDebugger = null;
|
|
734
758
|
}
|
|
735
759
|
})();
|
|
736
760
|
await this.attachingDebugger;
|
|
737
761
|
}
|
|
738
|
-
async
|
|
739
|
-
const
|
|
740
|
-
|
|
741
|
-
|
|
762
|
+
async showMousePointer(x, y) {
|
|
763
|
+
const pointerScript = `(() => {
|
|
764
|
+
if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {
|
|
765
|
+
window.midsceneWaterFlowAnimation.enable();
|
|
766
|
+
window.midsceneWaterFlowAnimation.showMousePointer(${x}, ${y});
|
|
767
|
+
} else {
|
|
768
|
+
console.log('midsceneWaterFlowAnimation is not defined');
|
|
769
|
+
}
|
|
770
|
+
})()`;
|
|
771
|
+
await this.sendCommandToDebugger("Runtime.evaluate", {
|
|
772
|
+
expression: `${pointerScript}`
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
async hideMousePointer() {
|
|
776
|
+
await this.sendCommandToDebugger("Runtime.evaluate", {
|
|
777
|
+
expression: `(() => {
|
|
778
|
+
if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {
|
|
779
|
+
window.midsceneWaterFlowAnimation.hideMousePointer();
|
|
780
|
+
}
|
|
781
|
+
})()`
|
|
742
782
|
});
|
|
743
783
|
}
|
|
784
|
+
async detachDebugger(tabId) {
|
|
785
|
+
const tabIdToDetach = tabId || this.tabIdOfDebuggerAttached;
|
|
786
|
+
if (!tabIdToDetach) {
|
|
787
|
+
console.warn("No tab id to detach");
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
await this.disableWaterFlowAnimation(tabIdToDetach);
|
|
791
|
+
await sleep(200);
|
|
792
|
+
await chrome.debugger.detach({ tabId: tabIdToDetach });
|
|
793
|
+
this.tabIdOfDebuggerAttached = null;
|
|
794
|
+
}
|
|
795
|
+
async enableWaterFlowAnimation() {
|
|
796
|
+
const script = await injectWaterFlowAnimation();
|
|
797
|
+
await chrome.debugger.sendCommand(
|
|
798
|
+
{ tabId: this.tabIdOfDebuggerAttached },
|
|
799
|
+
"Runtime.evaluate",
|
|
800
|
+
{
|
|
801
|
+
expression: script
|
|
802
|
+
}
|
|
803
|
+
);
|
|
804
|
+
}
|
|
744
805
|
async disableWaterFlowAnimation(tabId) {
|
|
745
806
|
const script = await injectStopWaterFlowAnimation();
|
|
746
807
|
await chrome.debugger.sendCommand({ tabId }, "Runtime.evaluate", {
|
|
747
808
|
expression: script
|
|
748
809
|
});
|
|
749
810
|
}
|
|
750
|
-
async detachDebugger() {
|
|
751
|
-
const targets = await chrome.debugger.getTargets();
|
|
752
|
-
const attendTabs = targets.filter(
|
|
753
|
-
(target) => target.attached === true && !target.url.startsWith("chrome-extension://")
|
|
754
|
-
);
|
|
755
|
-
if (attendTabs.length > 0) {
|
|
756
|
-
for (const tab of attendTabs) {
|
|
757
|
-
if (tab.tabId) {
|
|
758
|
-
await this.disableWaterFlowAnimation(tab.tabId);
|
|
759
|
-
chrome.debugger.detach({ tabId: tab.tabId });
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
811
|
async sendCommandToDebugger(command, params) {
|
|
765
812
|
await this.attachDebugger();
|
|
766
|
-
|
|
767
|
-
this.enableWaterFlowAnimation(
|
|
813
|
+
(0, import_node_assert2.default)(this.tabIdOfDebuggerAttached, "Debugger is not attached");
|
|
814
|
+
this.enableWaterFlowAnimation();
|
|
768
815
|
return await chrome.debugger.sendCommand(
|
|
769
|
-
{ tabId },
|
|
816
|
+
{ tabId: this.tabIdOfDebuggerAttached },
|
|
770
817
|
command,
|
|
771
818
|
params
|
|
772
819
|
);
|
|
@@ -823,6 +870,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
823
870
|
);
|
|
824
871
|
}
|
|
825
872
|
async getElementInfos() {
|
|
873
|
+
await this.hideMousePointer();
|
|
826
874
|
const content = await this.getPageContentByCDP();
|
|
827
875
|
if (content == null ? void 0 : content.size) {
|
|
828
876
|
this.viewportSize = content.size;
|
|
@@ -836,6 +884,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
836
884
|
return content.size;
|
|
837
885
|
}
|
|
838
886
|
async screenshotBase64() {
|
|
887
|
+
await this.hideMousePointer();
|
|
839
888
|
const base64 = await this.sendCommandToDebugger("Page.captureScreenshot", {
|
|
840
889
|
format: "jpeg",
|
|
841
890
|
quality: 70
|
|
@@ -935,6 +984,7 @@ var ChromeExtensionProxyPage = class {
|
|
|
935
984
|
async destroy() {
|
|
936
985
|
this.activeTabId = null;
|
|
937
986
|
await this.detachDebugger();
|
|
987
|
+
this.destroyed = true;
|
|
938
988
|
}
|
|
939
989
|
};
|
|
940
990
|
|
|
@@ -943,7 +993,7 @@ var DefaultBridgeServerPort = 3766;
|
|
|
943
993
|
var DefaultLocalEndpoint = `http://127.0.0.1:${DefaultBridgeServerPort}`;
|
|
944
994
|
|
|
945
995
|
// src/bridge-mode/io-client.ts
|
|
946
|
-
var
|
|
996
|
+
var import_node_assert3 = __toESM(require("assert"));
|
|
947
997
|
var import_socket = require("socket.io-client");
|
|
948
998
|
var BridgeClient = class {
|
|
949
999
|
constructor(endpoint, onBridgeCall, onDisconnect) {
|
|
@@ -958,7 +1008,7 @@ var BridgeClient = class {
|
|
|
958
1008
|
this.socket = (0, import_socket.io)(this.endpoint, {
|
|
959
1009
|
reconnection: false,
|
|
960
1010
|
query: {
|
|
961
|
-
version: "0.
|
|
1011
|
+
version: "0.10.0"
|
|
962
1012
|
}
|
|
963
1013
|
});
|
|
964
1014
|
const timeout = setTimeout(() => {
|
|
@@ -983,7 +1033,7 @@ var BridgeClient = class {
|
|
|
983
1033
|
});
|
|
984
1034
|
this.socket.on("bridge-call" /* Call */, (call) => {
|
|
985
1035
|
const id = call.id;
|
|
986
|
-
(0,
|
|
1036
|
+
(0, import_node_assert3.default)(typeof id !== "undefined", "call id is required");
|
|
987
1037
|
Promise.resolve().then(async () => {
|
|
988
1038
|
var _a, _b;
|
|
989
1039
|
let response;
|
|
@@ -1017,8 +1067,8 @@ ${(e == null ? void 0 : e.stack) || ""}`;
|
|
|
1017
1067
|
var ChromeExtensionPageBrowserSide = class extends ChromeExtensionProxyPage {
|
|
1018
1068
|
constructor(onDisconnect = () => {
|
|
1019
1069
|
}, onLogMessage = () => {
|
|
1020
|
-
}) {
|
|
1021
|
-
super(
|
|
1070
|
+
}, trackingActiveTab = false) {
|
|
1071
|
+
super(trackingActiveTab);
|
|
1022
1072
|
this.onDisconnect = onDisconnect;
|
|
1023
1073
|
this.onLogMessage = onLogMessage;
|
|
1024
1074
|
this.bridgeClient = null;
|
|
@@ -1074,26 +1124,32 @@ var ChromeExtensionPageBrowserSide = class extends ChromeExtensionProxyPage {
|
|
|
1074
1124
|
);
|
|
1075
1125
|
await this.bridgeClient.connect();
|
|
1076
1126
|
this.onLogMessage(
|
|
1077
|
-
`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${"0.
|
|
1127
|
+
`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${"0.10.0"}`,
|
|
1078
1128
|
"log"
|
|
1079
1129
|
);
|
|
1080
1130
|
}
|
|
1081
1131
|
async connect() {
|
|
1082
1132
|
return await this.setupBridgeClient();
|
|
1083
1133
|
}
|
|
1084
|
-
async connectNewTabWithUrl(url) {
|
|
1134
|
+
async connectNewTabWithUrl(url, options) {
|
|
1085
1135
|
const tab = await chrome.tabs.create({ url });
|
|
1086
1136
|
const tabId = tab.id;
|
|
1087
|
-
(0,
|
|
1137
|
+
(0, import_node_assert4.default)(tabId, "failed to get tabId after creating a new tab");
|
|
1088
1138
|
this.onLogMessage(`Creating new tab: ${url}`, "log");
|
|
1139
|
+
if (options == null ? void 0 : options.trackingActiveTab) {
|
|
1140
|
+
this.trackingActiveTab = true;
|
|
1141
|
+
}
|
|
1089
1142
|
}
|
|
1090
|
-
async connectCurrentTab() {
|
|
1143
|
+
async connectCurrentTab(options) {
|
|
1091
1144
|
var _a, _b;
|
|
1092
1145
|
const tabs = await chrome.tabs.query({ active: true, currentWindow: true });
|
|
1093
1146
|
console.log("current tab", tabs);
|
|
1094
1147
|
const tabId = (_a = tabs[0]) == null ? void 0 : _a.id;
|
|
1095
|
-
(0,
|
|
1148
|
+
(0, import_node_assert4.default)(tabId, "failed to get tabId");
|
|
1096
1149
|
this.onLogMessage(`Connected to current tab: ${(_b = tabs[0]) == null ? void 0 : _b.url}`, "log");
|
|
1150
|
+
if (options == null ? void 0 : options.trackingActiveTab) {
|
|
1151
|
+
this.trackingActiveTab = true;
|
|
1152
|
+
}
|
|
1097
1153
|
}
|
|
1098
1154
|
async destroy() {
|
|
1099
1155
|
if (this.bridgeClient) {
|
package/dist/lib/bridge-mode.js
CHANGED
|
@@ -1649,7 +1649,7 @@ var BridgeServer = class {
|
|
|
1649
1649
|
this.socket = socket;
|
|
1650
1650
|
const clientVersion = socket.handshake.query.version;
|
|
1651
1651
|
console.log(
|
|
1652
|
-
`Bridge connected, cli-side version v${"0.
|
|
1652
|
+
`Bridge connected, cli-side version v${"0.10.0"}, browser-side version v${clientVersion}`
|
|
1653
1653
|
);
|
|
1654
1654
|
socket.on("bridge-call-response" /* CallResponse */, (params) => {
|
|
1655
1655
|
const id = params.id;
|
|
@@ -1682,7 +1682,7 @@ var BridgeServer = class {
|
|
|
1682
1682
|
var _a;
|
|
1683
1683
|
(_a = this.onConnect) == null ? void 0 : _a.call(this);
|
|
1684
1684
|
const payload = {
|
|
1685
|
-
version: "0.
|
|
1685
|
+
version: "0.10.0"
|
|
1686
1686
|
};
|
|
1687
1687
|
socket.emit("bridge-connected" /* Connected */, payload);
|
|
1688
1688
|
Promise.resolve().then(() => {
|
|
@@ -1771,6 +1771,7 @@ var BridgeServer = class {
|
|
|
1771
1771
|
};
|
|
1772
1772
|
|
|
1773
1773
|
// src/bridge-mode/agent-cli-side.ts
|
|
1774
|
+
var sleep2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1774
1775
|
var getBridgePageInCliSide = () => {
|
|
1775
1776
|
const server = new BridgeServer(DefaultBridgeServerPort);
|
|
1776
1777
|
server.listen();
|
|
@@ -1842,11 +1843,13 @@ var AgentOverChromeBridge = class extends PageAgent {
|
|
|
1842
1843
|
}
|
|
1843
1844
|
});
|
|
1844
1845
|
}
|
|
1845
|
-
async connectNewTabWithUrl(url) {
|
|
1846
|
-
await this.page.connectNewTabWithUrl(url);
|
|
1846
|
+
async connectNewTabWithUrl(url, options) {
|
|
1847
|
+
await this.page.connectNewTabWithUrl(url, options);
|
|
1848
|
+
await sleep2(500);
|
|
1847
1849
|
}
|
|
1848
|
-
async connectCurrentTab() {
|
|
1849
|
-
await this.page.connectCurrentTab();
|
|
1850
|
+
async connectCurrentTab(options) {
|
|
1851
|
+
await this.page.connectCurrentTab(options);
|
|
1852
|
+
await sleep2(500);
|
|
1850
1853
|
}
|
|
1851
1854
|
async aiAction(prompt, options) {
|
|
1852
1855
|
if (options) {
|