@donggui/web 1.5.5-donggui.3

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 (166) hide show
  1. package/README.md +9 -0
  2. package/bin/midscene-playground +3 -0
  3. package/bin/midscene-web +2 -0
  4. package/dist/es/bin.mjs +23 -0
  5. package/dist/es/bin.mjs.map +1 -0
  6. package/dist/es/bridge-mode/agent-cli-side.mjs +137 -0
  7. package/dist/es/bridge-mode/agent-cli-side.mjs.map +1 -0
  8. package/dist/es/bridge-mode/browser.mjs +2 -0
  9. package/dist/es/bridge-mode/common.mjs +43 -0
  10. package/dist/es/bridge-mode/common.mjs.map +1 -0
  11. package/dist/es/bridge-mode/index.mjs +4 -0
  12. package/dist/es/bridge-mode/io-client.mjs +101 -0
  13. package/dist/es/bridge-mode/io-client.mjs.map +1 -0
  14. package/dist/es/bridge-mode/io-server.mjs +210 -0
  15. package/dist/es/bridge-mode/io-server.mjs.map +1 -0
  16. package/dist/es/bridge-mode/page-browser-side.mjs +118 -0
  17. package/dist/es/bridge-mode/page-browser-side.mjs.map +1 -0
  18. package/dist/es/chrome-extension/agent.mjs +9 -0
  19. package/dist/es/chrome-extension/agent.mjs.map +1 -0
  20. package/dist/es/chrome-extension/cdpInput.mjs +174 -0
  21. package/dist/es/chrome-extension/cdpInput.mjs.LICENSE.txt +5 -0
  22. package/dist/es/chrome-extension/cdpInput.mjs.map +1 -0
  23. package/dist/es/chrome-extension/dynamic-scripts.mjs +38 -0
  24. package/dist/es/chrome-extension/dynamic-scripts.mjs.map +1 -0
  25. package/dist/es/chrome-extension/index.mjs +5 -0
  26. package/dist/es/chrome-extension/page.mjs +651 -0
  27. package/dist/es/chrome-extension/page.mjs.map +1 -0
  28. package/dist/es/cli.mjs +16 -0
  29. package/dist/es/cli.mjs.map +1 -0
  30. package/dist/es/common/cache-helper.mjs +28 -0
  31. package/dist/es/common/cache-helper.mjs.map +1 -0
  32. package/dist/es/index.mjs +6 -0
  33. package/dist/es/mcp-server.mjs +35 -0
  34. package/dist/es/mcp-server.mjs.map +1 -0
  35. package/dist/es/mcp-tools-puppeteer.mjs +215 -0
  36. package/dist/es/mcp-tools-puppeteer.mjs.map +1 -0
  37. package/dist/es/mcp-tools.mjs +78 -0
  38. package/dist/es/mcp-tools.mjs.map +1 -0
  39. package/dist/es/playwright/ai-fixture.mjs +367 -0
  40. package/dist/es/playwright/ai-fixture.mjs.map +1 -0
  41. package/dist/es/playwright/index.mjs +40 -0
  42. package/dist/es/playwright/index.mjs.map +1 -0
  43. package/dist/es/playwright/page.mjs +44 -0
  44. package/dist/es/playwright/page.mjs.map +1 -0
  45. package/dist/es/playwright/reporter/index.mjs +216 -0
  46. package/dist/es/playwright/reporter/index.mjs.map +1 -0
  47. package/dist/es/puppeteer/agent-launcher.mjs +185 -0
  48. package/dist/es/puppeteer/agent-launcher.mjs.map +1 -0
  49. package/dist/es/puppeteer/base-page.mjs +564 -0
  50. package/dist/es/puppeteer/base-page.mjs.map +1 -0
  51. package/dist/es/puppeteer/index.mjs +34 -0
  52. package/dist/es/puppeteer/index.mjs.map +1 -0
  53. package/dist/es/puppeteer/page.mjs +9 -0
  54. package/dist/es/puppeteer/page.mjs.map +1 -0
  55. package/dist/es/static/index.mjs +3 -0
  56. package/dist/es/static/static-agent.mjs +12 -0
  57. package/dist/es/static/static-agent.mjs.map +1 -0
  58. package/dist/es/static/static-page.mjs +122 -0
  59. package/dist/es/static/static-page.mjs.map +1 -0
  60. package/dist/es/utils.mjs +8 -0
  61. package/dist/es/utils.mjs.map +1 -0
  62. package/dist/es/web-element.mjs +59 -0
  63. package/dist/es/web-element.mjs.map +1 -0
  64. package/dist/es/web-page.mjs +260 -0
  65. package/dist/es/web-page.mjs.map +1 -0
  66. package/dist/lib/bin.js +29 -0
  67. package/dist/lib/bin.js.map +1 -0
  68. package/dist/lib/bridge-mode/agent-cli-side.js +174 -0
  69. package/dist/lib/bridge-mode/agent-cli-side.js.map +1 -0
  70. package/dist/lib/bridge-mode/browser.js +38 -0
  71. package/dist/lib/bridge-mode/browser.js.map +1 -0
  72. package/dist/lib/bridge-mode/common.js +107 -0
  73. package/dist/lib/bridge-mode/common.js.map +1 -0
  74. package/dist/lib/bridge-mode/index.js +46 -0
  75. package/dist/lib/bridge-mode/index.js.map +1 -0
  76. package/dist/lib/bridge-mode/io-client.js +135 -0
  77. package/dist/lib/bridge-mode/io-client.js.map +1 -0
  78. package/dist/lib/bridge-mode/io-server.js +247 -0
  79. package/dist/lib/bridge-mode/io-server.js.map +1 -0
  80. package/dist/lib/bridge-mode/page-browser-side.js +162 -0
  81. package/dist/lib/bridge-mode/page-browser-side.js.map +1 -0
  82. package/dist/lib/chrome-extension/agent.js +43 -0
  83. package/dist/lib/chrome-extension/agent.js.map +1 -0
  84. package/dist/lib/chrome-extension/cdpInput.js +208 -0
  85. package/dist/lib/chrome-extension/cdpInput.js.LICENSE.txt +5 -0
  86. package/dist/lib/chrome-extension/cdpInput.js.map +1 -0
  87. package/dist/lib/chrome-extension/dynamic-scripts.js +88 -0
  88. package/dist/lib/chrome-extension/dynamic-scripts.js.map +1 -0
  89. package/dist/lib/chrome-extension/index.js +60 -0
  90. package/dist/lib/chrome-extension/index.js.map +1 -0
  91. package/dist/lib/chrome-extension/page.js +685 -0
  92. package/dist/lib/chrome-extension/page.js.map +1 -0
  93. package/dist/lib/cli.js +22 -0
  94. package/dist/lib/cli.js.map +1 -0
  95. package/dist/lib/common/cache-helper.js +68 -0
  96. package/dist/lib/common/cache-helper.js.map +1 -0
  97. package/dist/lib/index.js +60 -0
  98. package/dist/lib/index.js.map +1 -0
  99. package/dist/lib/mcp-server.js +75 -0
  100. package/dist/lib/mcp-server.js.map +1 -0
  101. package/dist/lib/mcp-tools-puppeteer.js +259 -0
  102. package/dist/lib/mcp-tools-puppeteer.js.map +1 -0
  103. package/dist/lib/mcp-tools.js +112 -0
  104. package/dist/lib/mcp-tools.js.map +1 -0
  105. package/dist/lib/playwright/ai-fixture.js +404 -0
  106. package/dist/lib/playwright/ai-fixture.js.map +1 -0
  107. package/dist/lib/playwright/index.js +93 -0
  108. package/dist/lib/playwright/index.js.map +1 -0
  109. package/dist/lib/playwright/page.js +78 -0
  110. package/dist/lib/playwright/page.js.map +1 -0
  111. package/dist/lib/playwright/reporter/index.js +250 -0
  112. package/dist/lib/playwright/reporter/index.js.map +1 -0
  113. package/dist/lib/puppeteer/agent-launcher.js +253 -0
  114. package/dist/lib/puppeteer/agent-launcher.js.map +1 -0
  115. package/dist/lib/puppeteer/base-page.js +607 -0
  116. package/dist/lib/puppeteer/base-page.js.map +1 -0
  117. package/dist/lib/puppeteer/index.js +84 -0
  118. package/dist/lib/puppeteer/index.js.map +1 -0
  119. package/dist/lib/puppeteer/page.js +43 -0
  120. package/dist/lib/puppeteer/page.js.map +1 -0
  121. package/dist/lib/static/index.js +52 -0
  122. package/dist/lib/static/index.js.map +1 -0
  123. package/dist/lib/static/static-agent.js +46 -0
  124. package/dist/lib/static/static-agent.js.map +1 -0
  125. package/dist/lib/static/static-page.js +156 -0
  126. package/dist/lib/static/static-page.js.map +1 -0
  127. package/dist/lib/utils.js +40 -0
  128. package/dist/lib/utils.js.map +1 -0
  129. package/dist/lib/web-element.js +96 -0
  130. package/dist/lib/web-element.js.map +1 -0
  131. package/dist/lib/web-page.js +310 -0
  132. package/dist/lib/web-page.js.map +1 -0
  133. package/dist/types/bin.d.ts +1 -0
  134. package/dist/types/bridge-mode/agent-cli-side.d.ts +49 -0
  135. package/dist/types/bridge-mode/browser.d.ts +2 -0
  136. package/dist/types/bridge-mode/common.d.ts +74 -0
  137. package/dist/types/bridge-mode/index.d.ts +4 -0
  138. package/dist/types/bridge-mode/io-client.d.ts +10 -0
  139. package/dist/types/bridge-mode/io-server.d.ts +27 -0
  140. package/dist/types/bridge-mode/page-browser-side.d.ts +21 -0
  141. package/dist/types/chrome-extension/agent.d.ts +5 -0
  142. package/dist/types/chrome-extension/cdpInput.d.ts +52 -0
  143. package/dist/types/chrome-extension/dynamic-scripts.d.ts +3 -0
  144. package/dist/types/chrome-extension/index.d.ts +5 -0
  145. package/dist/types/chrome-extension/page.d.ts +110 -0
  146. package/dist/types/cli.d.ts +1 -0
  147. package/dist/types/common/cache-helper.d.ts +20 -0
  148. package/dist/types/index.d.ts +7 -0
  149. package/dist/types/mcp-server.d.ts +26 -0
  150. package/dist/types/mcp-tools-puppeteer.d.ts +13 -0
  151. package/dist/types/mcp-tools.d.ts +12 -0
  152. package/dist/types/playwright/ai-fixture.d.ts +131 -0
  153. package/dist/types/playwright/index.d.ts +13 -0
  154. package/dist/types/playwright/page.d.ts +11 -0
  155. package/dist/types/playwright/reporter/index.d.ts +42 -0
  156. package/dist/types/puppeteer/agent-launcher.d.ts +61 -0
  157. package/dist/types/puppeteer/base-page.d.ts +106 -0
  158. package/dist/types/puppeteer/index.d.ts +10 -0
  159. package/dist/types/puppeteer/page.d.ts +6 -0
  160. package/dist/types/static/index.d.ts +2 -0
  161. package/dist/types/static/static-agent.d.ts +5 -0
  162. package/dist/types/static/static-page.d.ts +42 -0
  163. package/dist/types/utils.d.ts +6 -0
  164. package/dist/types/web-element.d.ts +48 -0
  165. package/dist/types/web-page.d.ts +62 -0
  166. package/package.json +166 -0
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ ExtensionBridgePageBrowserSide: ()=>ExtensionBridgePageBrowserSide
37
+ });
38
+ const utils_namespaceObject = require("@midscene/shared/utils");
39
+ const page_js_namespaceObject = require("../chrome-extension/page.js");
40
+ var page_js_default = /*#__PURE__*/ __webpack_require__.n(page_js_namespaceObject);
41
+ const external_common_js_namespaceObject = require("./common.js");
42
+ const external_io_client_js_namespaceObject = require("./io-client.js");
43
+ function _define_property(obj, key, value) {
44
+ if (key in obj) Object.defineProperty(obj, key, {
45
+ value: value,
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true
49
+ });
50
+ else obj[key] = value;
51
+ return obj;
52
+ }
53
+ class ExtensionBridgePageBrowserSide extends page_js_default() {
54
+ async setupBridgeClient() {
55
+ const endpoint = this.serverEndpoint || `ws://localhost:${external_common_js_namespaceObject.DefaultBridgeServerPort}`;
56
+ this.bridgeClient = new external_io_client_js_namespaceObject.BridgeClient(endpoint, async (method, args)=>{
57
+ if (this.confirmationPromise) {
58
+ const allowed = await this.confirmationPromise;
59
+ if (!allowed) throw new Error('Connection denied by user');
60
+ }
61
+ console.log('bridge call from cli side', method, args);
62
+ if (method === external_common_js_namespaceObject.BridgeEvent.ConnectNewTabWithUrl) return this.connectNewTabWithUrl.apply(this, args);
63
+ if (method === external_common_js_namespaceObject.BridgeEvent.GetBrowserTabList) return this.getBrowserTabList.apply(this, args);
64
+ if (method === external_common_js_namespaceObject.BridgeEvent.SetActiveTabId) return this.setActiveTabId.apply(this, args);
65
+ if (method === external_common_js_namespaceObject.BridgeEvent.ConnectCurrentTab) return this.connectCurrentTab.apply(this, args);
66
+ if (method === external_common_js_namespaceObject.BridgeEvent.UpdateAgentStatus) return this.onLogMessage(args[0], 'status');
67
+ const tabId = await this.getActiveTabId();
68
+ if (!tabId || 0 === tabId) throw new Error('no tab is connected');
69
+ if (method.startsWith(external_common_js_namespaceObject.MouseEvent.PREFIX)) {
70
+ const actionName = method.split('.')[1];
71
+ return this.mouse[actionName].apply(this.mouse, args);
72
+ }
73
+ if (method.startsWith(external_common_js_namespaceObject.KeyboardEvent.PREFIX)) {
74
+ const actionName = method.split('.')[1];
75
+ return this.keyboard[actionName].apply(this.keyboard, args);
76
+ }
77
+ if (!this[method]) return void console.warn('method not found', method);
78
+ try {
79
+ const result = await this[method](...args);
80
+ return result;
81
+ } catch (e) {
82
+ const errorMessage = e instanceof Error ? e.message : 'Unknown error';
83
+ console.error('error calling method', method, args, e);
84
+ this.onLogMessage(`Error calling method: ${method}, ${errorMessage}`, 'log');
85
+ throw new Error(errorMessage, {
86
+ cause: e
87
+ });
88
+ }
89
+ }, ()=>this.destroy());
90
+ await this.bridgeClient.connect();
91
+ if (this.onConnectionRequest) {
92
+ this.onLogMessage('Waiting for user confirmation...', 'log');
93
+ this.confirmationPromise = this.onConnectionRequest();
94
+ const allowed = await this.confirmationPromise;
95
+ this.confirmationPromise = null;
96
+ if (!allowed) {
97
+ this.onLogMessage('Connection denied by user', 'log');
98
+ this.bridgeClient.disconnect();
99
+ this.bridgeClient = null;
100
+ throw new Error('Connection denied by user');
101
+ }
102
+ }
103
+ this.onLogMessage(`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v1.5.5-donggui.3`, 'log');
104
+ }
105
+ async connect() {
106
+ return await this.setupBridgeClient();
107
+ }
108
+ async connectNewTabWithUrl(url, options = {
109
+ forceSameTabNavigation: true
110
+ }) {
111
+ const tab = await chrome.tabs.create({
112
+ url
113
+ });
114
+ const tabId = tab.id;
115
+ (0, utils_namespaceObject.assert)(tabId, 'failed to get tabId after creating a new tab');
116
+ this.onLogMessage(`Creating new tab: ${url}`, 'log');
117
+ this.newlyCreatedTabIds.push(tabId);
118
+ if (options?.forceSameTabNavigation) this.forceSameTabNavigation = true;
119
+ await this.setActiveTabId(tabId);
120
+ }
121
+ async connectCurrentTab(options = {
122
+ forceSameTabNavigation: true
123
+ }) {
124
+ const tabs = await chrome.tabs.query({
125
+ active: true,
126
+ currentWindow: true
127
+ });
128
+ const tabId = tabs[0]?.id;
129
+ (0, utils_namespaceObject.assert)(tabId, 'failed to get tabId');
130
+ this.onLogMessage(`Connected to current tab: ${tabs[0]?.url}`, 'log');
131
+ if (options?.forceSameTabNavigation) this.forceSameTabNavigation = true;
132
+ await this.setActiveTabId(tabId);
133
+ }
134
+ async setDestroyOptions(options) {
135
+ this.destroyOptions = options;
136
+ }
137
+ async destroy() {
138
+ if (this.destroyOptions?.closeTab && this.newlyCreatedTabIds.length > 0) {
139
+ this.onLogMessage('Closing all newly created tabs by bridge...', 'log');
140
+ for (const tabId of this.newlyCreatedTabIds)await chrome.tabs.remove(tabId);
141
+ this.newlyCreatedTabIds = [];
142
+ }
143
+ await super.destroy();
144
+ if (this.bridgeClient) {
145
+ this.bridgeClient.disconnect();
146
+ this.bridgeClient = null;
147
+ this.onDisconnect();
148
+ }
149
+ }
150
+ constructor(serverEndpoint, onDisconnect = ()=>{}, onLogMessage = ()=>{}, forceSameTabNavigation = true, onConnectionRequest){
151
+ super(forceSameTabNavigation), _define_property(this, "serverEndpoint", void 0), _define_property(this, "onDisconnect", void 0), _define_property(this, "onLogMessage", void 0), _define_property(this, "onConnectionRequest", void 0), _define_property(this, "bridgeClient", void 0), _define_property(this, "destroyOptions", void 0), _define_property(this, "newlyCreatedTabIds", void 0), _define_property(this, "confirmationPromise", void 0), this.serverEndpoint = serverEndpoint, this.onDisconnect = onDisconnect, this.onLogMessage = onLogMessage, this.onConnectionRequest = onConnectionRequest, this.bridgeClient = null, this.newlyCreatedTabIds = [], this.confirmationPromise = null;
152
+ }
153
+ }
154
+ exports.ExtensionBridgePageBrowserSide = __webpack_exports__.ExtensionBridgePageBrowserSide;
155
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
156
+ "ExtensionBridgePageBrowserSide"
157
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
158
+ Object.defineProperty(exports, '__esModule', {
159
+ value: true
160
+ });
161
+
162
+ //# sourceMappingURL=page-browser-side.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge-mode/page-browser-side.js","sources":["webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/bridge-mode/page-browser-side.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { assert } from '@midscene/shared/utils';\nimport ChromeExtensionProxyPage from '../chrome-extension/page';\nimport type {\n ChromePageDestroyOptions,\n KeyboardAction,\n MouseAction,\n} from '../web-page';\nimport {\n type BridgeConnectTabOptions,\n BridgeEvent,\n DefaultBridgeServerPort,\n KeyboardEvent,\n MouseEvent,\n} from './common';\nimport { BridgeClient } from './io-client';\n\ndeclare const __VERSION__: string;\n\nexport class ExtensionBridgePageBrowserSide extends ChromeExtensionProxyPage {\n public bridgeClient: BridgeClient | null = null;\n\n private destroyOptions?: ChromePageDestroyOptions;\n\n private newlyCreatedTabIds: number[] = [];\n\n // Connection confirmation state\n private confirmationPromise: Promise<boolean> | null = null;\n\n constructor(\n public serverEndpoint?: string,\n public onDisconnect: () => void = () => {},\n public onLogMessage: (\n message: string,\n type: 'log' | 'status',\n ) => void = () => {},\n forceSameTabNavigation = true,\n public onConnectionRequest?: () => Promise<boolean>,\n ) {\n super(forceSameTabNavigation);\n }\n\n private async setupBridgeClient() {\n const endpoint =\n this.serverEndpoint || `ws://localhost:${DefaultBridgeServerPort}`;\n this.bridgeClient = new BridgeClient(\n endpoint,\n async (method, args: any[]) => {\n // Wait for user confirmation before processing any commands\n if (this.confirmationPromise) {\n const allowed = await this.confirmationPromise;\n if (!allowed) {\n throw new Error('Connection denied by user');\n }\n }\n\n console.log('bridge call from cli side', method, args);\n if (method === BridgeEvent.ConnectNewTabWithUrl) {\n return this.connectNewTabWithUrl.apply(\n this,\n args as unknown as [string],\n );\n }\n\n if (method === BridgeEvent.GetBrowserTabList) {\n return this.getBrowserTabList.apply(this, args as any);\n }\n\n if (method === BridgeEvent.SetActiveTabId) {\n return this.setActiveTabId.apply(this, args as any);\n }\n\n if (method === BridgeEvent.ConnectCurrentTab) {\n return this.connectCurrentTab.apply(this, args as any);\n }\n\n if (method === BridgeEvent.UpdateAgentStatus) {\n return this.onLogMessage(args[0] as string, 'status');\n }\n\n const tabId = await this.getActiveTabId();\n if (!tabId || tabId === 0) {\n throw new Error('no tab is connected');\n }\n\n // this.onLogMessage(`calling method: ${method}`);\n\n if (method.startsWith(MouseEvent.PREFIX)) {\n const actionName = method.split('.')[1] as keyof MouseAction;\n if (actionName === 'drag') {\n return this.mouse[actionName].apply(this.mouse, args as any);\n }\n return this.mouse[actionName].apply(this.mouse, args as any);\n }\n\n if (method.startsWith(KeyboardEvent.PREFIX)) {\n const actionName = method.split('.')[1] as keyof KeyboardAction;\n if (actionName === 'press') {\n return this.keyboard[actionName].apply(this.keyboard, args as any);\n }\n return this.keyboard[actionName].apply(this.keyboard, args as any);\n }\n\n if (!this[method as keyof ChromeExtensionProxyPage]) {\n console.warn('method not found', method);\n return undefined;\n }\n\n try {\n // @ts-expect-error\n const result = await this[method as keyof ChromeExtensionProxyPage](\n ...args,\n );\n return result;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : 'Unknown error';\n console.error('error calling method', method, args, e);\n this.onLogMessage(\n `Error calling method: ${method}, ${errorMessage}`,\n 'log',\n );\n throw new Error(errorMessage, { cause: e });\n }\n },\n // on disconnect\n () => {\n return this.destroy();\n },\n );\n await this.bridgeClient.connect();\n\n // Request user confirmation after connection is established\n if (this.onConnectionRequest) {\n this.onLogMessage('Waiting for user confirmation...', 'log');\n this.confirmationPromise = this.onConnectionRequest();\n const allowed = await this.confirmationPromise;\n this.confirmationPromise = null;\n\n if (!allowed) {\n this.onLogMessage('Connection denied by user', 'log');\n this.bridgeClient.disconnect();\n this.bridgeClient = null;\n throw new Error('Connection denied by user');\n }\n }\n\n this.onLogMessage(\n `Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${__VERSION__}`,\n 'log',\n );\n }\n\n public async connect() {\n return await this.setupBridgeClient();\n }\n\n public async connectNewTabWithUrl(\n url: string,\n options: BridgeConnectTabOptions = {\n forceSameTabNavigation: true,\n },\n ) {\n const tab = await chrome.tabs.create({ url });\n const tabId = tab.id;\n assert(tabId, 'failed to get tabId after creating a new tab');\n\n // new tab\n this.onLogMessage(`Creating new tab: ${url}`, 'log');\n this.newlyCreatedTabIds.push(tabId);\n\n if (options?.forceSameTabNavigation) {\n this.forceSameTabNavigation = true;\n }\n\n await this.setActiveTabId(tabId);\n }\n\n public async connectCurrentTab(\n options: BridgeConnectTabOptions = {\n forceSameTabNavigation: true,\n },\n ) {\n const tabs = await chrome.tabs.query({ active: true, currentWindow: true });\n const tabId = tabs[0]?.id;\n assert(tabId, 'failed to get tabId');\n\n this.onLogMessage(`Connected to current tab: ${tabs[0]?.url}`, 'log');\n\n if (options?.forceSameTabNavigation) {\n this.forceSameTabNavigation = true;\n }\n\n await this.setActiveTabId(tabId);\n }\n\n public async setDestroyOptions(options: ChromePageDestroyOptions) {\n this.destroyOptions = options;\n }\n\n async destroy() {\n if (this.destroyOptions?.closeTab && this.newlyCreatedTabIds.length > 0) {\n this.onLogMessage('Closing all newly created tabs by bridge...', 'log');\n for (const tabId of this.newlyCreatedTabIds) {\n await chrome.tabs.remove(tabId);\n }\n this.newlyCreatedTabIds = [];\n }\n\n await super.destroy();\n\n if (this.bridgeClient) {\n this.bridgeClient.disconnect();\n this.bridgeClient = null;\n this.onDisconnect();\n }\n }\n}\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","ExtensionBridgePageBrowserSide","ChromeExtensionProxyPage","endpoint","DefaultBridgeServerPort","BridgeClient","method","args","allowed","Error","console","BridgeEvent","tabId","MouseEvent","actionName","KeyboardEvent","result","e","errorMessage","url","options","tab","chrome","assert","tabs","serverEndpoint","onDisconnect","onLogMessage","forceSameTabNavigation","onConnectionRequest"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CA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IAAI,CAAC,cAAc,GAAGA;IACxB;IAEA,MAAM,UAAU;QACd,IAAI,IAAI,CAAC,cAAc,EAAE,YAAY,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,GAAG;YACvE,IAAI,CAAC,YAAY,CAAC,+CAA+C;YACjE,KAAK,MAAMR,SAAS,IAAI,CAAC,kBAAkB,CACzC,MAAMU,OAAO,IAAI,CAAC,MAAM,CAACV;YAE3B,IAAI,CAAC,kBAAkB,GAAG,EAAE;QAC9B;QAEA,MAAM,KAAK,CAAC;QAEZ,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,IAAI,CAAC,YAAY,CAAC,UAAU;YAC5B,IAAI,CAAC,YAAY,GAAG;YACpB,IAAI,CAAC,YAAY;QACnB;IACF;IA1LA,YACSa,cAAuB,EACvBC,eAA2B,KAAO,CAAC,EACnCC,eAGK,KAAO,CAAC,EACpBC,yBAAyB,IAAI,EACtBC,mBAA4C,CACnD;QACA,KAAK,CAACD,yBAAAA,iBAAAA,IAAAA,EAAAA,kBAAAA,KAAAA,IAAAA,iBAAAA,IAAAA,EAAAA,gBAAAA,KAAAA,IAAAA,iBAAAA,IAAAA,EAAAA,gBAAAA,KAAAA,IAAAA,iBAAAA,IAAAA,EAAAA,uBAAAA,KAAAA,IAnBR,uBAAO,gBAAP,SAEA,uBAAQ,kBAAR,SAEA,uBAAQ,sBAAR,SAGA,uBAAQ,uBAAR,cAGSH,cAAc,GAAdA,gBAAAA,IAAAA,CACAC,YAAY,GAAZA,cAAAA,IAAAA,CACAC,YAAY,GAAZA,cAAAA,IAAAA,CAKAE,mBAAmB,GAAnBA,qBAAAA,IAAAA,CAjBF,YAAY,GAAwB,WAInC,kBAAkB,GAAa,EAAE,OAGjC,mBAAmB,GAA4B;IAavD;AAgLF"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ ChromeExtensionProxyPageAgent: ()=>ChromeExtensionProxyPageAgent
28
+ });
29
+ const agent_namespaceObject = require("@midscene/core/agent");
30
+ class ChromeExtensionProxyPageAgent extends agent_namespaceObject.Agent {
31
+ constructor(page, opts){
32
+ super(page, opts);
33
+ }
34
+ }
35
+ exports.ChromeExtensionProxyPageAgent = __webpack_exports__.ChromeExtensionProxyPageAgent;
36
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
37
+ "ChromeExtensionProxyPageAgent"
38
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
39
+ Object.defineProperty(exports, '__esModule', {
40
+ value: true
41
+ });
42
+
43
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome-extension/agent.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/chrome-extension/agent.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type AgentOpt, Agent as PageAgent } from '@midscene/core/agent';\nimport type ChromeExtensionProxyPage from './page';\n\nexport class ChromeExtensionProxyPageAgent extends PageAgent {\n // biome-ignore lint/complexity/noUselessConstructor: <explanation>\n constructor(page: ChromeExtensionProxyPage, opts?: AgentOpt) {\n super(page, opts);\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","ChromeExtensionProxyPageAgent","PageAgent","page","opts"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;ACHO,MAAMI,sCAAsCC,sBAAAA,KAASA;IAE1D,YAAYC,IAA8B,EAAEC,IAAe,CAAE;QAC3D,KAAK,CAACD,MAAMC;IACd;AACF"}
@@ -0,0 +1,208 @@
1
+ /*! For license information please see cdpInput.js.LICENSE.txt */
2
+ "use strict";
3
+ var __webpack_require__ = {};
4
+ (()=>{
5
+ __webpack_require__.d = (exports1, definition)=>{
6
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ get: definition[key]
9
+ });
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.r = (exports1)=>{
17
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
18
+ value: 'Module'
19
+ });
20
+ Object.defineProperty(exports1, '__esModule', {
21
+ value: true
22
+ });
23
+ };
24
+ })();
25
+ var __webpack_exports__ = {};
26
+ __webpack_require__.r(__webpack_exports__);
27
+ __webpack_require__.d(__webpack_exports__, {
28
+ CdpKeyboard: ()=>CdpKeyboard
29
+ });
30
+ const us_keyboard_layout_namespaceObject = require("@midscene/shared/us-keyboard-layout");
31
+ const utils_namespaceObject = require("@midscene/shared/utils");
32
+ /**
33
+ * @license
34
+ * Copyright 2017 Google Inc.
35
+ * SPDX-License-Identifier: Apache-2.0
36
+ */ function _check_private_redeclaration(obj, privateCollection) {
37
+ if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
38
+ }
39
+ function _class_apply_descriptor_get(receiver, descriptor) {
40
+ if (descriptor.get) return descriptor.get.call(receiver);
41
+ return descriptor.value;
42
+ }
43
+ function _class_apply_descriptor_set(receiver, descriptor, value) {
44
+ if (descriptor.set) descriptor.set.call(receiver, value);
45
+ else {
46
+ if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
47
+ descriptor.value = value;
48
+ }
49
+ }
50
+ function _class_extract_field_descriptor(receiver, privateMap, action) {
51
+ if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
52
+ return privateMap.get(receiver);
53
+ }
54
+ function _class_private_field_get(receiver, privateMap) {
55
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
56
+ return _class_apply_descriptor_get(receiver, descriptor);
57
+ }
58
+ function _class_private_field_init(obj, privateMap, value) {
59
+ _check_private_redeclaration(obj, privateMap);
60
+ privateMap.set(obj, value);
61
+ }
62
+ function _class_private_field_set(receiver, privateMap, value) {
63
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
64
+ _class_apply_descriptor_set(receiver, descriptor, value);
65
+ return value;
66
+ }
67
+ function _class_private_method_get(receiver, privateSet, fn) {
68
+ if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
69
+ return fn;
70
+ }
71
+ function _class_private_method_init(obj, privateSet) {
72
+ _check_private_redeclaration(obj, privateSet);
73
+ privateSet.add(obj);
74
+ }
75
+ function _define_property(obj, key, value) {
76
+ if (key in obj) Object.defineProperty(obj, key, {
77
+ value: value,
78
+ enumerable: true,
79
+ configurable: true,
80
+ writable: true
81
+ });
82
+ else obj[key] = value;
83
+ return obj;
84
+ }
85
+ var _pressedKeys = /*#__PURE__*/ new WeakMap(), _client = /*#__PURE__*/ new WeakMap(), _modifierBit = /*#__PURE__*/ new WeakSet(), _keyDescriptionForString = /*#__PURE__*/ new WeakSet();
86
+ class CdpKeyboard {
87
+ updateClient(client) {
88
+ _class_private_field_set(this, _client, client);
89
+ }
90
+ async down(key, options = {
91
+ text: void 0,
92
+ commands: []
93
+ }) {
94
+ const description = _class_private_method_get(this, _keyDescriptionForString, keyDescriptionForString).call(this, key);
95
+ const autoRepeat = _class_private_field_get(this, _pressedKeys).has(description.code);
96
+ _class_private_field_get(this, _pressedKeys).add(description.code);
97
+ this._modifiers |= _class_private_method_get(this, _modifierBit, modifierBit).call(this, description.key);
98
+ const text = void 0 === options.text ? description.text : options.text;
99
+ await _class_private_field_get(this, _client).send('Input.dispatchKeyEvent', {
100
+ type: text ? 'keyDown' : 'rawKeyDown',
101
+ modifiers: this._modifiers,
102
+ windowsVirtualKeyCode: description.keyCode,
103
+ code: description.code,
104
+ key: description.key,
105
+ text: text,
106
+ unmodifiedText: text,
107
+ autoRepeat,
108
+ location: description.location,
109
+ isKeypad: 3 === description.location,
110
+ commands: options.commands
111
+ });
112
+ }
113
+ async up(key) {
114
+ const description = _class_private_method_get(this, _keyDescriptionForString, keyDescriptionForString).call(this, key);
115
+ this._modifiers &= ~_class_private_method_get(this, _modifierBit, modifierBit).call(this, description.key);
116
+ _class_private_field_get(this, _pressedKeys).delete(description.code);
117
+ await _class_private_field_get(this, _client).send('Input.dispatchKeyEvent', {
118
+ type: 'keyUp',
119
+ modifiers: this._modifiers,
120
+ key: description.key,
121
+ windowsVirtualKeyCode: description.keyCode,
122
+ code: description.code,
123
+ location: description.location
124
+ });
125
+ }
126
+ async sendCharacter(char) {
127
+ await _class_private_field_get(this, _client).send('Input.insertText', {
128
+ text: char
129
+ });
130
+ }
131
+ charIsKey(char) {
132
+ return !!us_keyboard_layout_namespaceObject._keyDefinitions[char];
133
+ }
134
+ async type(text, options = {}) {
135
+ const delay = options.delay || void 0;
136
+ for (const char of text)if (this.charIsKey(char)) await this.press(char, {
137
+ delay
138
+ });
139
+ else {
140
+ if (delay) await new Promise((f)=>setTimeout(f, delay));
141
+ await this.sendCharacter(char);
142
+ }
143
+ }
144
+ async press(key, options = {}) {
145
+ const { delay = null } = options;
146
+ const keys = Array.isArray(key) ? key : [
147
+ key
148
+ ];
149
+ for (const k of keys)await this.down(k, options);
150
+ if (delay) await new Promise((f)=>setTimeout(f, options.delay));
151
+ for (const k of [
152
+ ...keys
153
+ ].reverse())await this.up(k);
154
+ }
155
+ constructor(client){
156
+ _class_private_method_init(this, _modifierBit);
157
+ _class_private_method_init(this, _keyDescriptionForString);
158
+ _class_private_field_init(this, _pressedKeys, {
159
+ writable: true,
160
+ value: new Set()
161
+ });
162
+ _class_private_field_init(this, _client, {
163
+ writable: true,
164
+ value: void 0
165
+ });
166
+ _define_property(this, "_modifiers", 0);
167
+ _class_private_field_set(this, _client, client);
168
+ }
169
+ }
170
+ function modifierBit(key) {
171
+ if ('Alt' === key) return 1;
172
+ if ('Control' === key) return 2;
173
+ if ('Meta' === key) return 4;
174
+ if ('Shift' === key) return 8;
175
+ return 0;
176
+ }
177
+ function keyDescriptionForString(keyString) {
178
+ const shift = 8 & this._modifiers;
179
+ const description = {
180
+ key: '',
181
+ keyCode: 0,
182
+ code: '',
183
+ text: '',
184
+ location: 0
185
+ };
186
+ const definition = us_keyboard_layout_namespaceObject._keyDefinitions[keyString];
187
+ (0, utils_namespaceObject.assert)(definition, `Unknown key: "${keyString}"`);
188
+ if (definition.key) description.key = definition.key;
189
+ if (shift && definition.shiftKey) description.key = definition.shiftKey;
190
+ if (definition.keyCode) description.keyCode = definition.keyCode;
191
+ if (shift && definition.shiftKeyCode) description.keyCode = definition.shiftKeyCode;
192
+ if (definition.code) description.code = definition.code;
193
+ if (definition.location) description.location = definition.location;
194
+ if (1 === description.key.length) description.text = description.key;
195
+ if (definition.text) description.text = definition.text;
196
+ if (shift && definition.shiftText) description.text = definition.shiftText;
197
+ if (-9 & this._modifiers) description.text = '';
198
+ return description;
199
+ }
200
+ exports.CdpKeyboard = __webpack_exports__.CdpKeyboard;
201
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
202
+ "CdpKeyboard"
203
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
204
+ Object.defineProperty(exports, '__esModule', {
205
+ value: true
206
+ });
207
+
208
+ //# sourceMappingURL=cdpInput.js.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google Inc.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome-extension/cdpInput.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/chrome-extension/cdpInput.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// From https://github.com/puppeteer/puppeteer/blob/15abcc390862fd08cc3475532f2d9a11284aee6b/packages/puppeteer-core/src/cdp/Input.ts#L55\n// with some modifications to fit the session type\n/**\n * @license\n * Copyright 2017 Google Inc.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type KeyDefinition,\n type KeyInput,\n _keyDefinitions,\n} from '@midscene/shared/us-keyboard-layout';\nimport { assert } from '@midscene/shared/utils';\n\ntype KeyDescription = Required<\n Pick<KeyDefinition, 'keyCode' | 'key' | 'text' | 'code' | 'location'>\n>;\n\n/**\n * @public\n */\nexport interface KeyDownOptions {\n /**\n * @deprecated Do not use. This is automatically handled.\n */\n text?: string;\n /**\n * @deprecated Do not use. This is automatically handled.\n */\n commands?: string[];\n}\n\n/**\n * @public\n */\nexport interface KeyboardTypeOptions {\n /**\n * Time to wait between key presses in milliseconds\n * @default undefined\n */\n delay?: number;\n}\n\n/**\n * @public\n */\nexport type KeyPressOptions = KeyDownOptions & KeyboardTypeOptions;\n\ntype InternalCDPSession = {\n send: (command: string, params: any) => Promise<void>;\n};\n\n/**\n * @internal\n */\nexport class CdpKeyboard {\n #pressedKeys = new Set<string>();\n\n #client: InternalCDPSession;\n\n _modifiers = 0;\n\n constructor(client: InternalCDPSession) {\n this.#client = client;\n }\n\n updateClient(client: InternalCDPSession): void {\n this.#client = client;\n }\n\n async down(\n key: KeyInput,\n options: Readonly<KeyDownOptions> = {\n text: undefined,\n commands: [],\n },\n ): Promise<void> {\n const description = this.#keyDescriptionForString(key);\n\n const autoRepeat = this.#pressedKeys.has(description.code);\n this.#pressedKeys.add(description.code);\n this._modifiers |= this.#modifierBit(description.key);\n\n const text = options.text === undefined ? description.text : options.text;\n await this.#client.send('Input.dispatchKeyEvent', {\n type: text ? 'keyDown' : 'rawKeyDown',\n modifiers: this._modifiers,\n windowsVirtualKeyCode: description.keyCode,\n code: description.code,\n key: description.key,\n text: text,\n unmodifiedText: text,\n autoRepeat,\n location: description.location,\n isKeypad: description.location === 3,\n commands: options.commands,\n });\n }\n\n #modifierBit(key: string): number {\n if (key === 'Alt') {\n return 1;\n }\n if (key === 'Control') {\n return 2;\n }\n if (key === 'Meta') {\n return 4;\n }\n if (key === 'Shift') {\n return 8;\n }\n return 0;\n }\n\n #keyDescriptionForString(keyString: KeyInput): KeyDescription {\n const shift = this._modifiers & 8;\n const description = {\n key: '',\n keyCode: 0,\n code: '',\n text: '',\n location: 0,\n };\n\n const definition = _keyDefinitions[keyString];\n\n assert(definition, `Unknown key: \"${keyString}\"`);\n\n if (definition.key) {\n description.key = definition.key;\n }\n if (shift && definition.shiftKey) {\n description.key = definition.shiftKey;\n }\n\n if (definition.keyCode) {\n description.keyCode = definition.keyCode;\n }\n if (shift && definition.shiftKeyCode) {\n description.keyCode = definition.shiftKeyCode;\n }\n\n if (definition.code) {\n description.code = definition.code;\n }\n\n if (definition.location) {\n description.location = definition.location;\n }\n\n if (description.key.length === 1) {\n description.text = description.key;\n }\n\n if (definition.text) {\n description.text = definition.text;\n }\n if (shift && definition.shiftText) {\n description.text = definition.shiftText;\n }\n\n // if any modifiers besides shift are pressed, no text should be sent\n if (this._modifiers & ~8) {\n description.text = '';\n }\n\n return description;\n }\n\n async up(key: KeyInput): Promise<void> {\n const description = this.#keyDescriptionForString(key);\n\n this._modifiers &= ~this.#modifierBit(description.key);\n this.#pressedKeys.delete(description.code);\n await this.#client.send('Input.dispatchKeyEvent', {\n type: 'keyUp',\n modifiers: this._modifiers,\n key: description.key,\n windowsVirtualKeyCode: description.keyCode,\n code: description.code,\n location: description.location,\n });\n }\n\n async sendCharacter(char: string): Promise<void> {\n await this.#client.send('Input.insertText', { text: char });\n }\n\n private charIsKey(char: string): char is KeyInput {\n return !!_keyDefinitions[char as KeyInput];\n }\n\n async type(\n text: string,\n options: Readonly<KeyboardTypeOptions> = {},\n ): Promise<void> {\n const delay = options.delay || undefined;\n for (const char of text) {\n if (this.charIsKey(char)) {\n await this.press(char, { delay });\n } else {\n if (delay) {\n await new Promise((f) => {\n return setTimeout(f, delay);\n });\n }\n await this.sendCharacter(char);\n }\n }\n }\n\n async press(\n key: KeyInput | KeyInput[],\n options: Readonly<KeyPressOptions> = {},\n ): Promise<void> {\n const { delay = null } = options;\n const keys = Array.isArray(key) ? key : [key];\n\n for (const k of keys) {\n await this.down(k, options);\n }\n\n if (delay) {\n await new Promise((f) => {\n return setTimeout(f, options.delay);\n });\n }\n\n for (const k of [...keys].reverse()) {\n await this.up(k);\n }\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","_pressedKeys","_client","modifierBit","keyDescriptionForString","CdpKeyboard","client","options","undefined","description","autoRepeat","text","char","_keyDefinitions","delay","Promise","f","setTimeout","keys","Array","k","Set","keyString","shift","assert"],"mappings":";;;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cA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YAAY,QAAQ,GAAGd,WAAW,QAAQ;IAG5C,IAAIc,AAA2B,MAA3BA,YAAY,GAAG,CAAC,MAAM,EACxBA,YAAY,IAAI,GAAGA,YAAY,GAAG;IAGpC,IAAId,WAAW,IAAI,EACjBc,YAAY,IAAI,GAAGd,WAAW,IAAI;IAEpC,IAAI4B,SAAS5B,WAAW,SAAS,EAC/Bc,YAAY,IAAI,GAAGd,WAAW,SAAS;IAIzC,IAAI,AAAkB,KAAlB,IAAI,CAAC,UAAU,EACjBc,YAAY,IAAI,GAAG;IAGrB,OAAOA;AACT"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ injectWaterFlowAnimation: ()=>injectWaterFlowAnimation,
37
+ getHtmlElementScript: ()=>getHtmlElementScript,
38
+ injectStopWaterFlowAnimation: ()=>injectStopWaterFlowAnimation
39
+ });
40
+ const external_node_fs_namespaceObject = require("node:fs");
41
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
42
+ const utils_namespaceObject = require("@midscene/shared/utils");
43
+ let scriptFileContentCache = null;
44
+ const getHtmlElementScript = async ()=>{
45
+ const scriptFileToRetrieve = chrome.runtime.getURL("scripts/htmlElement.js");
46
+ if (scriptFileContentCache) return scriptFileContentCache;
47
+ if (utils_namespaceObject.ifInBrowser || utils_namespaceObject.ifInWorker) {
48
+ const script = await fetch(scriptFileToRetrieve);
49
+ scriptFileContentCache = await script.text();
50
+ return scriptFileContentCache;
51
+ }
52
+ return external_node_fs_default().readFileSync(scriptFileToRetrieve, 'utf8');
53
+ };
54
+ let waterFlowScriptFileContentCache = null;
55
+ const injectWaterFlowAnimation = async ()=>{
56
+ const waterFlowScriptFileToRetrieve = chrome.runtime.getURL("scripts/water-flow.js");
57
+ if (waterFlowScriptFileContentCache) return waterFlowScriptFileContentCache;
58
+ if (utils_namespaceObject.ifInBrowser || utils_namespaceObject.ifInWorker) {
59
+ const script = await fetch(waterFlowScriptFileToRetrieve);
60
+ waterFlowScriptFileContentCache = await script.text();
61
+ return waterFlowScriptFileContentCache;
62
+ }
63
+ return external_node_fs_default().readFileSync(waterFlowScriptFileToRetrieve, 'utf8');
64
+ };
65
+ let stopWaterFlowScriptFileContentCache = null;
66
+ const injectStopWaterFlowAnimation = async ()=>{
67
+ const stopWaterFlowScriptFileToRetrieve = chrome.runtime.getURL("scripts/stop-water-flow.js");
68
+ if (stopWaterFlowScriptFileContentCache) return stopWaterFlowScriptFileContentCache;
69
+ if (utils_namespaceObject.ifInBrowser || utils_namespaceObject.ifInWorker) {
70
+ const script = await fetch(stopWaterFlowScriptFileToRetrieve);
71
+ stopWaterFlowScriptFileContentCache = await script.text();
72
+ return stopWaterFlowScriptFileContentCache;
73
+ }
74
+ return external_node_fs_default().readFileSync(stopWaterFlowScriptFileToRetrieve, 'utf8');
75
+ };
76
+ exports.getHtmlElementScript = __webpack_exports__.getHtmlElementScript;
77
+ exports.injectStopWaterFlowAnimation = __webpack_exports__.injectStopWaterFlowAnimation;
78
+ exports.injectWaterFlowAnimation = __webpack_exports__.injectWaterFlowAnimation;
79
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
80
+ "getHtmlElementScript",
81
+ "injectStopWaterFlowAnimation",
82
+ "injectWaterFlowAnimation"
83
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
84
+ Object.defineProperty(exports, '__esModule', {
85
+ value: true
86
+ });
87
+
88
+ //# sourceMappingURL=dynamic-scripts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome-extension/dynamic-scripts.js","sources":["webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/chrome-extension/dynamic-scripts.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import fs from 'node:fs';\nimport { ifInBrowser, ifInWorker } from '@midscene/shared/utils';\n\n// remember to include this file into extension's package\n// extract html element from page\nlet scriptFileContentCache: string | null = null;\nexport const getHtmlElementScript = async () => {\n const scriptFileToRetrieve = chrome.runtime.getURL('scripts/htmlElement.js');\n if (scriptFileContentCache) return scriptFileContentCache;\n if (ifInBrowser || ifInWorker) {\n const script = await fetch(scriptFileToRetrieve);\n scriptFileContentCache = await script.text();\n return scriptFileContentCache;\n }\n return fs.readFileSync(scriptFileToRetrieve, 'utf8');\n};\n\n// inject water flow animation\nlet waterFlowScriptFileContentCache: string | null = null;\nexport const injectWaterFlowAnimation = async () => {\n const waterFlowScriptFileToRetrieve = chrome.runtime.getURL(\n 'scripts/water-flow.js',\n );\n if (waterFlowScriptFileContentCache) return waterFlowScriptFileContentCache;\n if (ifInBrowser || ifInWorker) {\n const script = await fetch(waterFlowScriptFileToRetrieve);\n waterFlowScriptFileContentCache = await script.text();\n return waterFlowScriptFileContentCache;\n }\n return fs.readFileSync(waterFlowScriptFileToRetrieve, 'utf8');\n};\n\n// inject stop water flow animation\nlet stopWaterFlowScriptFileContentCache: string | null = null;\nexport const injectStopWaterFlowAnimation = async () => {\n const stopWaterFlowScriptFileToRetrieve = chrome.runtime.getURL(\n 'scripts/stop-water-flow.js',\n );\n if (stopWaterFlowScriptFileContentCache)\n return stopWaterFlowScriptFileContentCache;\n if (ifInBrowser || ifInWorker) {\n const script = await fetch(stopWaterFlowScriptFileToRetrieve);\n stopWaterFlowScriptFileContentCache = await script.text();\n return stopWaterFlowScriptFileContentCache;\n }\n return fs.readFileSync(stopWaterFlowScriptFileToRetrieve, 'utf8');\n};\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","scriptFileContentCache","getHtmlElementScript","scriptFileToRetrieve","chrome","ifInBrowser","ifInWorker","script","fetch","fs","waterFlowScriptFileContentCache","injectWaterFlowAnimation","waterFlowScriptFileToRetrieve","stopWaterFlowScriptFileContentCache","injectStopWaterFlowAnimation","stopWaterFlowScriptFileToRetrieve"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,Q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AAA,YAAe,CAACG,+BAA+B;AACxD;AAGA,IAAIC,sCAAqD;AAClD,MAAMC,+BAA+B;IAC1C,MAAMC,oCAAoCX,OAAO,OAAO,CAAC,MAAM,CAC7D;IAEF,IAAIS,qCACF,OAAOA;IACT,IAAIR,sBAAAA,WAAWA,IAAIC,sBAAAA,UAAUA,EAAE;QAC7B,MAAMC,SAAS,MAAMC,MAAMO;QAC3BF,sCAAsC,MAAMN,OAAO,IAAI;QACvD,OAAOM;IACT;IACA,OAAOJ,2BAAAA,YAAe,CAACM,mCAAmC;AAC5D"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ ChromeExtensionProxyPage: ()=>external_page_js_default(),
37
+ overrideAIConfig: ()=>env_namespaceObject.overrideAIConfig,
38
+ ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED: ()=>common_namespaceObject.ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED,
39
+ ChromeExtensionProxyPageAgent: ()=>external_agent_js_namespaceObject.ChromeExtensionProxyPageAgent
40
+ });
41
+ const common_namespaceObject = require("@midscene/shared/common");
42
+ const external_agent_js_namespaceObject = require("./agent.js");
43
+ const external_page_js_namespaceObject = require("./page.js");
44
+ var external_page_js_default = /*#__PURE__*/ __webpack_require__.n(external_page_js_namespaceObject);
45
+ const env_namespaceObject = require("@midscene/shared/env");
46
+ exports.ChromeExtensionProxyPage = __webpack_exports__.ChromeExtensionProxyPage;
47
+ exports.ChromeExtensionProxyPageAgent = __webpack_exports__.ChromeExtensionProxyPageAgent;
48
+ exports.ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = __webpack_exports__.ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED;
49
+ exports.overrideAIConfig = __webpack_exports__.overrideAIConfig;
50
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
51
+ "ChromeExtensionProxyPage",
52
+ "ChromeExtensionProxyPageAgent",
53
+ "ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED",
54
+ "overrideAIConfig"
55
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
56
+ Object.defineProperty(exports, '__esModule', {
57
+ value: true
58
+ });
59
+
60
+ //# sourceMappingURL=index.js.map