appium-remote-debugger 15.2.9 → 15.2.11

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 (48) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/mixins/connect.d.ts +47 -31
  3. package/build/lib/mixins/connect.d.ts.map +1 -1
  4. package/build/lib/mixins/connect.js +105 -86
  5. package/build/lib/mixins/connect.js.map +1 -1
  6. package/build/lib/mixins/cookies.d.ts +17 -13
  7. package/build/lib/mixins/cookies.d.ts.map +1 -1
  8. package/build/lib/mixins/cookies.js +12 -12
  9. package/build/lib/mixins/cookies.js.map +1 -1
  10. package/build/lib/mixins/events.d.ts +32 -31
  11. package/build/lib/mixins/events.d.ts.map +1 -1
  12. package/build/lib/mixins/events.js +21 -24
  13. package/build/lib/mixins/events.js.map +1 -1
  14. package/build/lib/mixins/execute.d.ts +35 -24
  15. package/build/lib/mixins/execute.d.ts.map +1 -1
  16. package/build/lib/mixins/execute.js +34 -26
  17. package/build/lib/mixins/execute.js.map +1 -1
  18. package/build/lib/mixins/message-handlers.d.ts +63 -43
  19. package/build/lib/mixins/message-handlers.d.ts.map +1 -1
  20. package/build/lib/mixins/message-handlers.js +74 -57
  21. package/build/lib/mixins/message-handlers.js.map +1 -1
  22. package/build/lib/mixins/misc.d.ts +34 -24
  23. package/build/lib/mixins/misc.d.ts.map +1 -1
  24. package/build/lib/mixins/misc.js +27 -21
  25. package/build/lib/mixins/misc.js.map +1 -1
  26. package/build/lib/mixins/navigate.d.ts +39 -27
  27. package/build/lib/mixins/navigate.d.ts.map +1 -1
  28. package/build/lib/mixins/navigate.js +31 -31
  29. package/build/lib/mixins/navigate.js.map +1 -1
  30. package/build/lib/mixins/screenshot.d.ts +21 -11
  31. package/build/lib/mixins/screenshot.d.ts.map +1 -1
  32. package/build/lib/mixins/screenshot.js +10 -14
  33. package/build/lib/mixins/screenshot.js.map +1 -1
  34. package/build/tsconfig.tsbuildinfo +1 -1
  35. package/lib/mixins/{connect.js → connect.ts} +153 -113
  36. package/lib/mixins/cookies.ts +61 -0
  37. package/lib/mixins/events.ts +91 -0
  38. package/lib/mixins/{execute.js → execute.ts} +59 -33
  39. package/lib/mixins/message-handlers.ts +272 -0
  40. package/lib/mixins/misc.ts +136 -0
  41. package/lib/mixins/{navigate.js → navigate.ts} +44 -41
  42. package/lib/mixins/screenshot.ts +52 -0
  43. package/package.json +1 -1
  44. package/lib/mixins/cookies.js +0 -53
  45. package/lib/mixins/events.js +0 -81
  46. package/lib/mixins/message-handlers.js +0 -224
  47. package/lib/mixins/misc.js +0 -121
  48. package/lib/mixins/screenshot.js +0 -43
@@ -1,121 +0,0 @@
1
- import { checkParams } from '../utils';
2
- import B, { TimeoutError as BTimeoutError } from 'bluebird';
3
- import {
4
- getAppIdKey,
5
- getPageIdKey,
6
- } from './property-accessors';
7
-
8
- const SAFARI_BUNDLE_ID = 'com.apple.mobilesafari';
9
- const GARBAGE_COLLECT_TIMEOUT_MS = 5000;
10
-
11
- /**
12
- * @this {RemoteDebugger}
13
- * @returns {Promise<void>}
14
- */
15
- export async function launchSafari () {
16
- await this.requireRpcClient().send('launchApplication', {
17
- bundleId: SAFARI_BUNDLE_ID
18
- });
19
- }
20
-
21
- /**
22
- * @this {RemoteDebugger}
23
- * @param {import('../types').EventListener} fn
24
- * @returns {Promise<any>}
25
- */
26
- export async function startTimeline (fn) {
27
- this.log.debug('Starting to record the timeline');
28
- this.requireRpcClient().on('Timeline.eventRecorded', fn);
29
- return await this.requireRpcClient().send('Timeline.start', {
30
- appIdKey: getAppIdKey(this),
31
- pageIdKey: getPageIdKey(this),
32
- });
33
- }
34
-
35
- /**
36
- * @this {RemoteDebugger}
37
- * @returns {Promise<any>}
38
- */
39
- export async function stopTimeline () {
40
- this.log.debug('Stopping to record the timeline');
41
- await this.requireRpcClient().send('Timeline.stop', {
42
- appIdKey: getAppIdKey(this),
43
- pageIdKey: getPageIdKey(this),
44
- });
45
- }
46
-
47
- // Potentially this does not work for mobile safari
48
- /**
49
- * @this {RemoteDebugger}
50
- * @param {string} value
51
- * @returns {Promise<any>}
52
- */
53
- export async function overrideUserAgent (value) {
54
- this.log.debug('Setting overrideUserAgent');
55
- return await this.requireRpcClient().send('Page.overrideUserAgent', {
56
- appIdKey: getAppIdKey(this),
57
- pageIdKey: getPageIdKey(this),
58
- value,
59
- });
60
- }
61
-
62
- /**
63
- * @this {RemoteDebugger}
64
- * @param {number} [timeoutMs=1000] The maximum amount of milliseconds to wait for
65
- * a javascript command response
66
- * @returns {Promise<boolean>} Whether the current page responds to javascript commands
67
- */
68
- export async function isJavascriptExecutionBlocked (timeoutMs = 1000) {
69
- try {
70
- await B.resolve(
71
- this.requireRpcClient().send('Runtime.evaluate', {
72
- expression: '1+1;',
73
- returnByValue: true,
74
- appIdKey: getAppIdKey(this),
75
- pageIdKey: getPageIdKey(this),
76
- })
77
- ).timeout(timeoutMs);
78
- return false;
79
- } catch {
80
- return true;
81
- }
82
- }
83
-
84
- /**
85
- * @this {RemoteDebugger}
86
- * @param {number} [timeoutMs=GARBAGE_COLLECT_TIMEOUT_MS]
87
- * @returns {Promise<void>}
88
- */
89
- export async function garbageCollect (timeoutMs = GARBAGE_COLLECT_TIMEOUT_MS) {
90
- this.log.debug(`Garbage collecting with ${timeoutMs}ms timeout`);
91
-
92
- try {
93
- checkParams({
94
- appIdKey: getAppIdKey(this),
95
- pageIdKey: getPageIdKey(this),
96
- });
97
- } catch {
98
- this.log.debug(`Unable to collect garbage at this time`);
99
- return;
100
- }
101
-
102
- try {
103
- await B.resolve(this.requireRpcClient().send(
104
- 'Heap.gc', {
105
- appIdKey: getAppIdKey(this),
106
- pageIdKey: getPageIdKey(this),
107
- })
108
- ).timeout(timeoutMs);
109
- this.log.debug(`Garbage collection successful`);
110
- } catch (e) {
111
- if (e instanceof BTimeoutError) {
112
- this.log.debug(`Garbage collection timed out after ${timeoutMs}ms`);
113
- } else {
114
- this.log.debug(`Unable to collect garbage: ${e.message}`);
115
- }
116
- }
117
- }
118
-
119
- /**
120
- * @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
121
- */
@@ -1,43 +0,0 @@
1
- import {
2
- getAppIdKey,
3
- getPageIdKey,
4
- } from './property-accessors';
5
-
6
- /**
7
- * Capture a rect of the page or by default the viewport
8
- * @this {RemoteDebugger}
9
- * @param {ScreenshotCaptureOptions} [opts={}] if rect is null capture the whole
10
- * coordinate system else capture the rect in the given coordinateSystem
11
- * @returns {Promise<string>} a base64 encoded string of the screenshot
12
- */
13
- export async function captureScreenshot(opts = {}) {
14
- const {rect = null, coordinateSystem = 'Viewport'} = opts;
15
- this.log.debug('Capturing screenshot');
16
-
17
- const arect = rect ?? /** @type {import('@appium/types').Rect} */ (await this.executeAtom(
18
- 'execute_script',
19
- ['return {x: 0, y: 0, width: window.innerWidth, height: window.innerHeight}', []]
20
- ));
21
- const response = await this.requireRpcClient().send('Page.snapshotRect', {
22
- ...arect,
23
- appIdKey: getAppIdKey(this),
24
- pageIdKey: getPageIdKey(this),
25
- coordinateSystem,
26
- });
27
-
28
- if (response.error) {
29
- throw new Error(response.error);
30
- }
31
-
32
- return response.dataURL.replace(/^data:image\/png;base64,/, '');
33
- }
34
-
35
- /**
36
- * @typedef {Object} ScreenshotCaptureOptions
37
- * @property {import('@appium/types').Rect | null} [rect=null]
38
- * @property {"Viewport" | "Page"} [coordinateSystem="Viewport"]
39
- */
40
-
41
- /**
42
- * @typedef {import('../remote-debugger').RemoteDebugger} RemoteDebugger
43
- */