@midscene/web 0.10.1 → 0.10.2

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 (34) hide show
  1. package/dist/es/appium.js +41 -5
  2. package/dist/es/bridge-mode-browser.js +43 -396
  3. package/dist/es/bridge-mode.js +44 -15
  4. package/dist/es/chrome-extension.js +59 -398
  5. package/dist/es/index.js +96 -9
  6. package/dist/es/midscene-playground.js +26 -5
  7. package/dist/es/playground.js +26 -5
  8. package/dist/es/playwright.js +62 -8
  9. package/dist/es/puppeteer.js +90 -13
  10. package/dist/lib/appium.js +41 -5
  11. package/dist/lib/bridge-mode-browser.js +43 -396
  12. package/dist/lib/bridge-mode.js +44 -15
  13. package/dist/lib/chrome-extension.js +59 -398
  14. package/dist/lib/index.js +96 -9
  15. package/dist/lib/midscene-playground.js +26 -5
  16. package/dist/lib/playground.js +26 -5
  17. package/dist/lib/playwright.js +62 -8
  18. package/dist/lib/puppeteer.js +90 -13
  19. package/dist/types/appium.d.ts +3 -3
  20. package/dist/types/bridge-mode-browser.d.ts +3 -3
  21. package/dist/types/bridge-mode.d.ts +6 -5
  22. package/dist/types/{browser-fd2e9b68.d.ts → browser-bc6c204c.d.ts} +1 -1
  23. package/dist/types/chrome-extension.d.ts +4 -4
  24. package/dist/types/debug.d.ts +2 -2
  25. package/dist/types/index.d.ts +4 -4
  26. package/dist/types/{page-fc3be0ec.d.ts → page-cfd75cdf.d.ts} +34 -4
  27. package/dist/types/playground.d.ts +4 -4
  28. package/dist/types/playwright.d.ts +4 -4
  29. package/dist/types/puppeteer.d.ts +8 -7
  30. package/dist/types/{tasks-f2973dd7.d.ts → tasks-681afd8a.d.ts} +4 -3
  31. package/dist/types/{utils-ccbb6ff6.d.ts → utils-1c43a008.d.ts} +1 -1
  32. package/dist/types/utils.d.ts +2 -2
  33. package/dist/types/yaml.d.ts +4 -4
  34. package/package.json +5 -3
package/dist/es/appium.js CHANGED
@@ -553,7 +553,10 @@ var PageTaskExecutor = class {
553
553
  locate: plan2.locate,
554
554
  executor: async (param, taskContext) => {
555
555
  const { task } = taskContext;
556
- (0, import_node_assert.default)((param == null ? void 0 : param.prompt) || (param == null ? void 0 : param.id), "No prompt or id to locate");
556
+ (0, import_node_assert.default)(
557
+ (param == null ? void 0 : param.prompt) || (param == null ? void 0 : param.id) || (param == null ? void 0 : param.position),
558
+ "No prompt or id or position to locate"
559
+ );
557
560
  let insightDump;
558
561
  const dumpCollector = (dump) => {
559
562
  insightDump = dump;
@@ -708,6 +711,22 @@ var PageTaskExecutor = class {
708
711
  }
709
712
  };
710
713
  tasks.push(taskActionTap);
714
+ } else if (plan2.type === "Drag") {
715
+ const taskActionDrag = {
716
+ type: "Action",
717
+ subType: "Drag",
718
+ param: plan2.param,
719
+ thought: plan2.thought,
720
+ locate: plan2.locate,
721
+ executor: async (taskParam) => {
722
+ (0, import_node_assert.default)(
723
+ (taskParam == null ? void 0 : taskParam.start_box) && (taskParam == null ? void 0 : taskParam.end_box),
724
+ "No start_box or end_box to drag"
725
+ );
726
+ await this.page.mouse.drag(taskParam.start_box, taskParam.end_box);
727
+ }
728
+ };
729
+ tasks.push(taskActionDrag);
711
730
  } else if (plan2.type === "Hover") {
712
731
  const taskActionHover = {
713
732
  type: "Action",
@@ -742,9 +761,9 @@ var PageTaskExecutor = class {
742
761
  } else if (scrollToEventName === "untilLeft") {
743
762
  await this.page.scrollUntilLeft(startingPoint);
744
763
  } else if (scrollToEventName === "once" || !scrollToEventName) {
745
- if (taskParam.direction === "down" || !taskParam.direction) {
764
+ if ((taskParam == null ? void 0 : taskParam.direction) === "down" || !taskParam || !taskParam.direction) {
746
765
  await this.page.scrollDown(
747
- taskParam.distance || void 0,
766
+ (taskParam == null ? void 0 : taskParam.distance) || void 0,
748
767
  startingPoint
749
768
  );
750
769
  } else if (taskParam.direction === "up") {
@@ -939,6 +958,7 @@ var PageTaskExecutor = class {
939
958
  userPrompt
940
959
  },
941
960
  executor: async (param, executorContext) => {
961
+ var _a;
942
962
  const shotTime = Date.now();
943
963
  const pageContext = await this.insight.contextRetrieverFn("locate");
944
964
  const recordItem = {
@@ -975,7 +995,7 @@ var PageTaskExecutor = class {
975
995
  return {
976
996
  output: {
977
997
  actions,
978
- thought: actions[0].thought,
998
+ thought: (_a = actions[0]) == null ? void 0 : _a.thought,
979
999
  actionType: actions[0].type,
980
1000
  taskWillBeAccomplished: false,
981
1001
  furtherPlan: {
@@ -1815,7 +1835,8 @@ var Page = class {
1815
1835
  return {
1816
1836
  click: (x, y, options) => this.mouseClick(x, y, (options == null ? void 0 : options.button) || "left"),
1817
1837
  wheel: (deltaX, deltaY) => this.mouseWheel(deltaX, deltaY),
1818
- move: (x, y) => this.mouseMove(x, y)
1838
+ move: (x, y) => this.mouseMove(x, y),
1839
+ drag: (from, to) => this.mouseDrag(from, to)
1819
1840
  };
1820
1841
  }
1821
1842
  // Object that includes keyboard and mouse operations
@@ -1962,6 +1983,21 @@ var Page = class {
1962
1983
  }
1963
1984
  ]);
1964
1985
  }
1986
+ async mouseDrag(from, to) {
1987
+ await this.browser.performActions([
1988
+ {
1989
+ type: "pointer",
1990
+ id: "mouse",
1991
+ parameters: { pointerType: "mouse" },
1992
+ actions: [
1993
+ { type: "pointerMove", duration: 0, x: from.x, y: from.y },
1994
+ { type: "pointerDown", button: 0 },
1995
+ { type: "pointerMove", duration: 500, x: to.x, y: to.y },
1996
+ { type: "pointerUp", button: 0 }
1997
+ ]
1998
+ }
1999
+ ]);
2000
+ }
1965
2001
  async mouseWheel(deltaX, deltaY, duration = 1e3) {
1966
2002
  const n = 4;
1967
2003
  const windowSize = await this.browser.getWindowSize();
@@ -64,395 +64,7 @@ var import_node_assert2 = __toESM(require("assert"));
64
64
 
65
65
  // src/chrome-extension/cdpInput.ts
66
66
  var import_node_assert = __toESM(require("assert"));
67
-
68
- // src/chrome-extension/USKeyboardLayout.ts
69
- var _keyDefinitions = {
70
- "0": { keyCode: 48, key: "0", code: "Digit0" },
71
- "1": { keyCode: 49, key: "1", code: "Digit1" },
72
- "2": { keyCode: 50, key: "2", code: "Digit2" },
73
- "3": { keyCode: 51, key: "3", code: "Digit3" },
74
- "4": { keyCode: 52, key: "4", code: "Digit4" },
75
- "5": { keyCode: 53, key: "5", code: "Digit5" },
76
- "6": { keyCode: 54, key: "6", code: "Digit6" },
77
- "7": { keyCode: 55, key: "7", code: "Digit7" },
78
- "8": { keyCode: 56, key: "8", code: "Digit8" },
79
- "9": { keyCode: 57, key: "9", code: "Digit9" },
80
- Power: { key: "Power", code: "Power" },
81
- Eject: { key: "Eject", code: "Eject" },
82
- Abort: { keyCode: 3, code: "Abort", key: "Cancel" },
83
- Help: { keyCode: 6, code: "Help", key: "Help" },
84
- Backspace: { keyCode: 8, code: "Backspace", key: "Backspace" },
85
- Tab: { keyCode: 9, code: "Tab", key: "Tab" },
86
- Numpad5: {
87
- keyCode: 12,
88
- shiftKeyCode: 101,
89
- key: "Clear",
90
- code: "Numpad5",
91
- shiftKey: "5",
92
- location: 3
93
- },
94
- NumpadEnter: {
95
- keyCode: 13,
96
- code: "NumpadEnter",
97
- key: "Enter",
98
- text: "\r",
99
- location: 3
100
- },
101
- Enter: { keyCode: 13, code: "Enter", key: "Enter", text: "\r" },
102
- "\r": { keyCode: 13, code: "Enter", key: "Enter", text: "\r" },
103
- "\n": { keyCode: 13, code: "Enter", key: "Enter", text: "\r" },
104
- ShiftLeft: { keyCode: 16, code: "ShiftLeft", key: "Shift", location: 1 },
105
- ShiftRight: { keyCode: 16, code: "ShiftRight", key: "Shift", location: 2 },
106
- ControlLeft: {
107
- keyCode: 17,
108
- code: "ControlLeft",
109
- key: "Control",
110
- location: 1
111
- },
112
- ControlRight: {
113
- keyCode: 17,
114
- code: "ControlRight",
115
- key: "Control",
116
- location: 2
117
- },
118
- AltLeft: { keyCode: 18, code: "AltLeft", key: "Alt", location: 1 },
119
- AltRight: { keyCode: 18, code: "AltRight", key: "Alt", location: 2 },
120
- Pause: { keyCode: 19, code: "Pause", key: "Pause" },
121
- CapsLock: { keyCode: 20, code: "CapsLock", key: "CapsLock" },
122
- Escape: { keyCode: 27, code: "Escape", key: "Escape" },
123
- Convert: { keyCode: 28, code: "Convert", key: "Convert" },
124
- NonConvert: { keyCode: 29, code: "NonConvert", key: "NonConvert" },
125
- Space: { keyCode: 32, code: "Space", key: " " },
126
- Numpad9: {
127
- keyCode: 33,
128
- shiftKeyCode: 105,
129
- key: "PageUp",
130
- code: "Numpad9",
131
- shiftKey: "9",
132
- location: 3
133
- },
134
- PageUp: { keyCode: 33, code: "PageUp", key: "PageUp" },
135
- Numpad3: {
136
- keyCode: 34,
137
- shiftKeyCode: 99,
138
- key: "PageDown",
139
- code: "Numpad3",
140
- shiftKey: "3",
141
- location: 3
142
- },
143
- PageDown: { keyCode: 34, code: "PageDown", key: "PageDown" },
144
- End: { keyCode: 35, code: "End", key: "End" },
145
- Numpad1: {
146
- keyCode: 35,
147
- shiftKeyCode: 97,
148
- key: "End",
149
- code: "Numpad1",
150
- shiftKey: "1",
151
- location: 3
152
- },
153
- Home: { keyCode: 36, code: "Home", key: "Home" },
154
- Numpad7: {
155
- keyCode: 36,
156
- shiftKeyCode: 103,
157
- key: "Home",
158
- code: "Numpad7",
159
- shiftKey: "7",
160
- location: 3
161
- },
162
- ArrowLeft: { keyCode: 37, code: "ArrowLeft", key: "ArrowLeft" },
163
- Numpad4: {
164
- keyCode: 37,
165
- shiftKeyCode: 100,
166
- key: "ArrowLeft",
167
- code: "Numpad4",
168
- shiftKey: "4",
169
- location: 3
170
- },
171
- Numpad8: {
172
- keyCode: 38,
173
- shiftKeyCode: 104,
174
- key: "ArrowUp",
175
- code: "Numpad8",
176
- shiftKey: "8",
177
- location: 3
178
- },
179
- ArrowUp: { keyCode: 38, code: "ArrowUp", key: "ArrowUp" },
180
- ArrowRight: { keyCode: 39, code: "ArrowRight", key: "ArrowRight" },
181
- Numpad6: {
182
- keyCode: 39,
183
- shiftKeyCode: 102,
184
- key: "ArrowRight",
185
- code: "Numpad6",
186
- shiftKey: "6",
187
- location: 3
188
- },
189
- Numpad2: {
190
- keyCode: 40,
191
- shiftKeyCode: 98,
192
- key: "ArrowDown",
193
- code: "Numpad2",
194
- shiftKey: "2",
195
- location: 3
196
- },
197
- ArrowDown: { keyCode: 40, code: "ArrowDown", key: "ArrowDown" },
198
- Select: { keyCode: 41, code: "Select", key: "Select" },
199
- Open: { keyCode: 43, code: "Open", key: "Execute" },
200
- PrintScreen: { keyCode: 44, code: "PrintScreen", key: "PrintScreen" },
201
- Insert: { keyCode: 45, code: "Insert", key: "Insert" },
202
- Numpad0: {
203
- keyCode: 45,
204
- shiftKeyCode: 96,
205
- key: "Insert",
206
- code: "Numpad0",
207
- shiftKey: "0",
208
- location: 3
209
- },
210
- Delete: { keyCode: 46, code: "Delete", key: "Delete" },
211
- NumpadDecimal: {
212
- keyCode: 46,
213
- shiftKeyCode: 110,
214
- code: "NumpadDecimal",
215
- key: "\0",
216
- shiftKey: ".",
217
- location: 3
218
- },
219
- Digit0: { keyCode: 48, code: "Digit0", shiftKey: ")", key: "0" },
220
- Digit1: { keyCode: 49, code: "Digit1", shiftKey: "!", key: "1" },
221
- Digit2: { keyCode: 50, code: "Digit2", shiftKey: "@", key: "2" },
222
- Digit3: { keyCode: 51, code: "Digit3", shiftKey: "#", key: "3" },
223
- Digit4: { keyCode: 52, code: "Digit4", shiftKey: "$", key: "4" },
224
- Digit5: { keyCode: 53, code: "Digit5", shiftKey: "%", key: "5" },
225
- Digit6: { keyCode: 54, code: "Digit6", shiftKey: "^", key: "6" },
226
- Digit7: { keyCode: 55, code: "Digit7", shiftKey: "&", key: "7" },
227
- Digit8: { keyCode: 56, code: "Digit8", shiftKey: "*", key: "8" },
228
- Digit9: { keyCode: 57, code: "Digit9", shiftKey: "(", key: "9" },
229
- KeyA: { keyCode: 65, code: "KeyA", shiftKey: "A", key: "a" },
230
- KeyB: { keyCode: 66, code: "KeyB", shiftKey: "B", key: "b" },
231
- KeyC: { keyCode: 67, code: "KeyC", shiftKey: "C", key: "c" },
232
- KeyD: { keyCode: 68, code: "KeyD", shiftKey: "D", key: "d" },
233
- KeyE: { keyCode: 69, code: "KeyE", shiftKey: "E", key: "e" },
234
- KeyF: { keyCode: 70, code: "KeyF", shiftKey: "F", key: "f" },
235
- KeyG: { keyCode: 71, code: "KeyG", shiftKey: "G", key: "g" },
236
- KeyH: { keyCode: 72, code: "KeyH", shiftKey: "H", key: "h" },
237
- KeyI: { keyCode: 73, code: "KeyI", shiftKey: "I", key: "i" },
238
- KeyJ: { keyCode: 74, code: "KeyJ", shiftKey: "J", key: "j" },
239
- KeyK: { keyCode: 75, code: "KeyK", shiftKey: "K", key: "k" },
240
- KeyL: { keyCode: 76, code: "KeyL", shiftKey: "L", key: "l" },
241
- KeyM: { keyCode: 77, code: "KeyM", shiftKey: "M", key: "m" },
242
- KeyN: { keyCode: 78, code: "KeyN", shiftKey: "N", key: "n" },
243
- KeyO: { keyCode: 79, code: "KeyO", shiftKey: "O", key: "o" },
244
- KeyP: { keyCode: 80, code: "KeyP", shiftKey: "P", key: "p" },
245
- KeyQ: { keyCode: 81, code: "KeyQ", shiftKey: "Q", key: "q" },
246
- KeyR: { keyCode: 82, code: "KeyR", shiftKey: "R", key: "r" },
247
- KeyS: { keyCode: 83, code: "KeyS", shiftKey: "S", key: "s" },
248
- KeyT: { keyCode: 84, code: "KeyT", shiftKey: "T", key: "t" },
249
- KeyU: { keyCode: 85, code: "KeyU", shiftKey: "U", key: "u" },
250
- KeyV: { keyCode: 86, code: "KeyV", shiftKey: "V", key: "v" },
251
- KeyW: { keyCode: 87, code: "KeyW", shiftKey: "W", key: "w" },
252
- KeyX: { keyCode: 88, code: "KeyX", shiftKey: "X", key: "x" },
253
- KeyY: { keyCode: 89, code: "KeyY", shiftKey: "Y", key: "y" },
254
- KeyZ: { keyCode: 90, code: "KeyZ", shiftKey: "Z", key: "z" },
255
- MetaLeft: { keyCode: 91, code: "MetaLeft", key: "Meta", location: 1 },
256
- MetaRight: { keyCode: 92, code: "MetaRight", key: "Meta", location: 2 },
257
- ContextMenu: { keyCode: 93, code: "ContextMenu", key: "ContextMenu" },
258
- NumpadMultiply: {
259
- keyCode: 106,
260
- code: "NumpadMultiply",
261
- key: "*",
262
- location: 3
263
- },
264
- NumpadAdd: { keyCode: 107, code: "NumpadAdd", key: "+", location: 3 },
265
- NumpadSubtract: {
266
- keyCode: 109,
267
- code: "NumpadSubtract",
268
- key: "-",
269
- location: 3
270
- },
271
- NumpadDivide: { keyCode: 111, code: "NumpadDivide", key: "/", location: 3 },
272
- F1: { keyCode: 112, code: "F1", key: "F1" },
273
- F2: { keyCode: 113, code: "F2", key: "F2" },
274
- F3: { keyCode: 114, code: "F3", key: "F3" },
275
- F4: { keyCode: 115, code: "F4", key: "F4" },
276
- F5: { keyCode: 116, code: "F5", key: "F5" },
277
- F6: { keyCode: 117, code: "F6", key: "F6" },
278
- F7: { keyCode: 118, code: "F7", key: "F7" },
279
- F8: { keyCode: 119, code: "F8", key: "F8" },
280
- F9: { keyCode: 120, code: "F9", key: "F9" },
281
- F10: { keyCode: 121, code: "F10", key: "F10" },
282
- F11: { keyCode: 122, code: "F11", key: "F11" },
283
- F12: { keyCode: 123, code: "F12", key: "F12" },
284
- F13: { keyCode: 124, code: "F13", key: "F13" },
285
- F14: { keyCode: 125, code: "F14", key: "F14" },
286
- F15: { keyCode: 126, code: "F15", key: "F15" },
287
- F16: { keyCode: 127, code: "F16", key: "F16" },
288
- F17: { keyCode: 128, code: "F17", key: "F17" },
289
- F18: { keyCode: 129, code: "F18", key: "F18" },
290
- F19: { keyCode: 130, code: "F19", key: "F19" },
291
- F20: { keyCode: 131, code: "F20", key: "F20" },
292
- F21: { keyCode: 132, code: "F21", key: "F21" },
293
- F22: { keyCode: 133, code: "F22", key: "F22" },
294
- F23: { keyCode: 134, code: "F23", key: "F23" },
295
- F24: { keyCode: 135, code: "F24", key: "F24" },
296
- NumLock: { keyCode: 144, code: "NumLock", key: "NumLock" },
297
- ScrollLock: { keyCode: 145, code: "ScrollLock", key: "ScrollLock" },
298
- AudioVolumeMute: {
299
- keyCode: 173,
300
- code: "AudioVolumeMute",
301
- key: "AudioVolumeMute"
302
- },
303
- AudioVolumeDown: {
304
- keyCode: 174,
305
- code: "AudioVolumeDown",
306
- key: "AudioVolumeDown"
307
- },
308
- AudioVolumeUp: { keyCode: 175, code: "AudioVolumeUp", key: "AudioVolumeUp" },
309
- MediaTrackNext: {
310
- keyCode: 176,
311
- code: "MediaTrackNext",
312
- key: "MediaTrackNext"
313
- },
314
- MediaTrackPrevious: {
315
- keyCode: 177,
316
- code: "MediaTrackPrevious",
317
- key: "MediaTrackPrevious"
318
- },
319
- MediaStop: { keyCode: 178, code: "MediaStop", key: "MediaStop" },
320
- MediaPlayPause: {
321
- keyCode: 179,
322
- code: "MediaPlayPause",
323
- key: "MediaPlayPause"
324
- },
325
- Semicolon: { keyCode: 186, code: "Semicolon", shiftKey: ":", key: ";" },
326
- Equal: { keyCode: 187, code: "Equal", shiftKey: "+", key: "=" },
327
- NumpadEqual: { keyCode: 187, code: "NumpadEqual", key: "=", location: 3 },
328
- Comma: { keyCode: 188, code: "Comma", shiftKey: "<", key: "," },
329
- Minus: { keyCode: 189, code: "Minus", shiftKey: "_", key: "-" },
330
- Period: { keyCode: 190, code: "Period", shiftKey: ">", key: "." },
331
- Slash: { keyCode: 191, code: "Slash", shiftKey: "?", key: "/" },
332
- Backquote: { keyCode: 192, code: "Backquote", shiftKey: "~", key: "`" },
333
- BracketLeft: { keyCode: 219, code: "BracketLeft", shiftKey: "{", key: "[" },
334
- Backslash: { keyCode: 220, code: "Backslash", shiftKey: "|", key: "\\" },
335
- BracketRight: { keyCode: 221, code: "BracketRight", shiftKey: "}", key: "]" },
336
- Quote: { keyCode: 222, code: "Quote", shiftKey: '"', key: "'" },
337
- AltGraph: { keyCode: 225, code: "AltGraph", key: "AltGraph" },
338
- Props: { keyCode: 247, code: "Props", key: "CrSel" },
339
- Cancel: { keyCode: 3, key: "Cancel", code: "Abort" },
340
- Clear: { keyCode: 12, key: "Clear", code: "Numpad5", location: 3 },
341
- Shift: { keyCode: 16, key: "Shift", code: "ShiftLeft", location: 1 },
342
- Control: { keyCode: 17, key: "Control", code: "ControlLeft", location: 1 },
343
- Alt: { keyCode: 18, key: "Alt", code: "AltLeft", location: 1 },
344
- Accept: { keyCode: 30, key: "Accept" },
345
- ModeChange: { keyCode: 31, key: "ModeChange" },
346
- " ": { keyCode: 32, key: " ", code: "Space" },
347
- Print: { keyCode: 42, key: "Print" },
348
- Execute: { keyCode: 43, key: "Execute", code: "Open" },
349
- "\0": { keyCode: 46, key: "\0", code: "NumpadDecimal", location: 3 },
350
- a: { keyCode: 65, key: "a", code: "KeyA" },
351
- b: { keyCode: 66, key: "b", code: "KeyB" },
352
- c: { keyCode: 67, key: "c", code: "KeyC" },
353
- d: { keyCode: 68, key: "d", code: "KeyD" },
354
- e: { keyCode: 69, key: "e", code: "KeyE" },
355
- f: { keyCode: 70, key: "f", code: "KeyF" },
356
- g: { keyCode: 71, key: "g", code: "KeyG" },
357
- h: { keyCode: 72, key: "h", code: "KeyH" },
358
- i: { keyCode: 73, key: "i", code: "KeyI" },
359
- j: { keyCode: 74, key: "j", code: "KeyJ" },
360
- k: { keyCode: 75, key: "k", code: "KeyK" },
361
- l: { keyCode: 76, key: "l", code: "KeyL" },
362
- m: { keyCode: 77, key: "m", code: "KeyM" },
363
- n: { keyCode: 78, key: "n", code: "KeyN" },
364
- o: { keyCode: 79, key: "o", code: "KeyO" },
365
- p: { keyCode: 80, key: "p", code: "KeyP" },
366
- q: { keyCode: 81, key: "q", code: "KeyQ" },
367
- r: { keyCode: 82, key: "r", code: "KeyR" },
368
- s: { keyCode: 83, key: "s", code: "KeyS" },
369
- t: { keyCode: 84, key: "t", code: "KeyT" },
370
- u: { keyCode: 85, key: "u", code: "KeyU" },
371
- v: { keyCode: 86, key: "v", code: "KeyV" },
372
- w: { keyCode: 87, key: "w", code: "KeyW" },
373
- x: { keyCode: 88, key: "x", code: "KeyX" },
374
- y: { keyCode: 89, key: "y", code: "KeyY" },
375
- z: { keyCode: 90, key: "z", code: "KeyZ" },
376
- Meta: { keyCode: 91, key: "Meta", code: "MetaLeft", location: 1 },
377
- "*": { keyCode: 106, key: "*", code: "NumpadMultiply", location: 3 },
378
- "+": { keyCode: 107, key: "+", code: "NumpadAdd", location: 3 },
379
- "-": { keyCode: 109, key: "-", code: "NumpadSubtract", location: 3 },
380
- "/": { keyCode: 111, key: "/", code: "NumpadDivide", location: 3 },
381
- ";": { keyCode: 186, key: ";", code: "Semicolon" },
382
- "=": { keyCode: 187, key: "=", code: "Equal" },
383
- ",": { keyCode: 188, key: ",", code: "Comma" },
384
- ".": { keyCode: 190, key: ".", code: "Period" },
385
- "`": { keyCode: 192, key: "`", code: "Backquote" },
386
- "[": { keyCode: 219, key: "[", code: "BracketLeft" },
387
- "\\": { keyCode: 220, key: "\\", code: "Backslash" },
388
- "]": { keyCode: 221, key: "]", code: "BracketRight" },
389
- "'": { keyCode: 222, key: "'", code: "Quote" },
390
- Attn: { keyCode: 246, key: "Attn" },
391
- CrSel: { keyCode: 247, key: "CrSel", code: "Props" },
392
- ExSel: { keyCode: 248, key: "ExSel" },
393
- EraseEof: { keyCode: 249, key: "EraseEof" },
394
- Play: { keyCode: 250, key: "Play" },
395
- ZoomOut: { keyCode: 251, key: "ZoomOut" },
396
- ")": { keyCode: 48, key: ")", code: "Digit0" },
397
- "!": { keyCode: 49, key: "!", code: "Digit1" },
398
- "@": { keyCode: 50, key: "@", code: "Digit2" },
399
- "#": { keyCode: 51, key: "#", code: "Digit3" },
400
- $: { keyCode: 52, key: "$", code: "Digit4" },
401
- "%": { keyCode: 53, key: "%", code: "Digit5" },
402
- "^": { keyCode: 54, key: "^", code: "Digit6" },
403
- "&": { keyCode: 55, key: "&", code: "Digit7" },
404
- "(": { keyCode: 57, key: "(", code: "Digit9" },
405
- A: { keyCode: 65, key: "A", code: "KeyA" },
406
- B: { keyCode: 66, key: "B", code: "KeyB" },
407
- C: { keyCode: 67, key: "C", code: "KeyC" },
408
- D: { keyCode: 68, key: "D", code: "KeyD" },
409
- E: { keyCode: 69, key: "E", code: "KeyE" },
410
- F: { keyCode: 70, key: "F", code: "KeyF" },
411
- G: { keyCode: 71, key: "G", code: "KeyG" },
412
- H: { keyCode: 72, key: "H", code: "KeyH" },
413
- I: { keyCode: 73, key: "I", code: "KeyI" },
414
- J: { keyCode: 74, key: "J", code: "KeyJ" },
415
- K: { keyCode: 75, key: "K", code: "KeyK" },
416
- L: { keyCode: 76, key: "L", code: "KeyL" },
417
- M: { keyCode: 77, key: "M", code: "KeyM" },
418
- N: { keyCode: 78, key: "N", code: "KeyN" },
419
- O: { keyCode: 79, key: "O", code: "KeyO" },
420
- P: { keyCode: 80, key: "P", code: "KeyP" },
421
- Q: { keyCode: 81, key: "Q", code: "KeyQ" },
422
- R: { keyCode: 82, key: "R", code: "KeyR" },
423
- S: { keyCode: 83, key: "S", code: "KeyS" },
424
- T: { keyCode: 84, key: "T", code: "KeyT" },
425
- U: { keyCode: 85, key: "U", code: "KeyU" },
426
- V: { keyCode: 86, key: "V", code: "KeyV" },
427
- W: { keyCode: 87, key: "W", code: "KeyW" },
428
- X: { keyCode: 88, key: "X", code: "KeyX" },
429
- Y: { keyCode: 89, key: "Y", code: "KeyY" },
430
- Z: { keyCode: 90, key: "Z", code: "KeyZ" },
431
- ":": { keyCode: 186, key: ":", code: "Semicolon" },
432
- "<": { keyCode: 188, key: "<", code: "Comma" },
433
- _: { keyCode: 189, key: "_", code: "Minus" },
434
- ">": { keyCode: 190, key: ">", code: "Period" },
435
- "?": { keyCode: 191, key: "?", code: "Slash" },
436
- "~": { keyCode: 192, key: "~", code: "Backquote" },
437
- "{": { keyCode: 219, key: "{", code: "BracketLeft" },
438
- "|": { keyCode: 220, key: "|", code: "Backslash" },
439
- "}": { keyCode: 221, key: "}", code: "BracketRight" },
440
- '"': { keyCode: 222, key: '"', code: "Quote" },
441
- SoftLeft: { key: "SoftLeft", code: "SoftLeft", location: 4 },
442
- SoftRight: { key: "SoftRight", code: "SoftRight", location: 4 },
443
- Camera: { keyCode: 44, key: "Camera", code: "Camera", location: 4 },
444
- Call: { key: "Call", code: "Call", location: 4 },
445
- EndCall: { keyCode: 95, key: "EndCall", code: "EndCall", location: 4 },
446
- VolumeDown: {
447
- keyCode: 182,
448
- key: "VolumeDown",
449
- code: "VolumeDown",
450
- location: 4
451
- },
452
- VolumeUp: { keyCode: 183, key: "VolumeUp", code: "VolumeUp", location: 4 }
453
- };
454
-
455
- // src/chrome-extension/cdpInput.ts
67
+ var import_keyboard_layout = require("@midscene/shared/keyboard-layout");
456
68
  var _pressedKeys, _client, _modifierBit, modifierBit_fn, _keyDescriptionForString, keyDescriptionForString_fn;
457
69
  var CdpKeyboard = class {
458
70
  constructor(client) {
@@ -506,7 +118,7 @@ var CdpKeyboard = class {
506
118
  await __privateGet(this, _client).send("Input.insertText", { text: char });
507
119
  }
508
120
  charIsKey(char) {
509
- return !!_keyDefinitions[char];
121
+ return !!import_keyboard_layout._keyDefinitions[char];
510
122
  }
511
123
  async type(text, options = {}) {
512
124
  const delay = options.delay || void 0;
@@ -525,13 +137,18 @@ var CdpKeyboard = class {
525
137
  }
526
138
  async press(key, options = {}) {
527
139
  const { delay = null } = options;
528
- await this.down(key, options);
140
+ const keys = Array.isArray(key) ? key : [key];
141
+ for (const k of keys) {
142
+ await this.down(k, options);
143
+ }
529
144
  if (delay) {
530
145
  await new Promise((f) => {
531
146
  return setTimeout(f, options.delay);
532
147
  });
533
148
  }
534
- await this.up(key);
149
+ for (const k of [...keys].reverse()) {
150
+ await this.up(k);
151
+ }
535
152
  }
536
153
  };
537
154
  _pressedKeys = new WeakMap();
@@ -562,7 +179,7 @@ keyDescriptionForString_fn = function(keyString) {
562
179
  text: "",
563
180
  location: 0
564
181
  };
565
- const definition = _keyDefinitions[keyString];
182
+ const definition = import_keyboard_layout._keyDefinitions[keyString];
566
183
  (0, import_node_assert.default)(definition, `Unknown key: "${keyString}"`);
567
184
  if (definition.key) {
568
185
  description.key = definition.key;
@@ -687,6 +304,24 @@ var ChromeExtensionProxyPage = class {
687
304
  x,
688
305
  y
689
306
  });
307
+ },
308
+ drag: async (from, to) => {
309
+ await this.mouse.move(from.x, from.y);
310
+ await this.sendCommandToDebugger("Input.dispatchMouseEvent", {
311
+ type: "mousePressed",
312
+ x: from.x,
313
+ y: from.y,
314
+ button: "left",
315
+ clickCount: 1
316
+ });
317
+ await this.mouse.move(to.x, to.y);
318
+ await this.sendCommandToDebugger("Input.dispatchMouseEvent", {
319
+ type: "mouseReleased",
320
+ x: to.x,
321
+ y: to.y,
322
+ button: "left",
323
+ clickCount: 1
324
+ });
690
325
  }
691
326
  };
692
327
  this.keyboard = {
@@ -700,7 +335,13 @@ var ChromeExtensionProxyPage = class {
700
335
  const cdpKeyboard = new CdpKeyboard({
701
336
  send: this.sendCommandToDebugger.bind(this)
702
337
  });
703
- await cdpKeyboard.press(key, { delay: 0 });
338
+ const keys = Array.isArray(key) ? key : [key];
339
+ for (const k of keys) {
340
+ await cdpKeyboard.down(k);
341
+ }
342
+ for (const k of [...keys].reverse()) {
343
+ await cdpKeyboard.up(k);
344
+ }
704
345
  }
705
346
  };
706
347
  this.trackingActiveTab = trackingActiveTab;
@@ -1004,7 +645,7 @@ var BridgeClient = class {
1004
645
  this.socket = (0, import_socket.io)(this.endpoint, {
1005
646
  reconnection: false,
1006
647
  query: {
1007
- version: "0.10.1"
648
+ version: "0.10.2"
1008
649
  }
1009
650
  });
1010
651
  const timeout = setTimeout(() => {
@@ -1092,10 +733,16 @@ var ChromeExtensionPageBrowserSide = class extends ChromeExtensionProxyPage {
1092
733
  }
1093
734
  if (method.startsWith("mouse." /* PREFIX */)) {
1094
735
  const actionName = method.split(".")[1];
736
+ if (actionName === "drag") {
737
+ return this.mouse[actionName].apply(this.mouse, args);
738
+ }
1095
739
  return this.mouse[actionName].apply(this.mouse, args);
1096
740
  }
1097
741
  if (method.startsWith("keyboard." /* PREFIX */)) {
1098
742
  const actionName = method.split(".")[1];
743
+ if (actionName === "press") {
744
+ return this.keyboard[actionName].apply(this.keyboard, args);
745
+ }
1099
746
  return this.keyboard[actionName].apply(this.keyboard, args);
1100
747
  }
1101
748
  try {
@@ -1120,7 +767,7 @@ var ChromeExtensionPageBrowserSide = class extends ChromeExtensionProxyPage {
1120
767
  );
1121
768
  await this.bridgeClient.connect();
1122
769
  this.onLogMessage(
1123
- `Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${"0.10.1"}`,
770
+ `Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${"0.10.2"}`,
1124
771
  "log"
1125
772
  );
1126
773
  }