appium-remote-debugger 11.4.2 → 11.5.1

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 (68) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/mixins/connect.d.ts +30 -56
  3. package/build/lib/mixins/connect.d.ts.map +1 -1
  4. package/build/lib/mixins/connect.js +57 -90
  5. package/build/lib/mixins/connect.js.map +1 -1
  6. package/build/lib/mixins/cookies.d.ts +22 -0
  7. package/build/lib/mixins/cookies.d.ts.map +1 -0
  8. package/build/lib/mixins/cookies.js +48 -0
  9. package/build/lib/mixins/cookies.js.map +1 -0
  10. package/build/lib/mixins/events.d.ts +17 -2
  11. package/build/lib/mixins/events.d.ts.map +1 -1
  12. package/build/lib/mixins/events.js +29 -2
  13. package/build/lib/mixins/events.js.map +1 -1
  14. package/build/lib/mixins/execute.d.ts +5 -12
  15. package/build/lib/mixins/execute.d.ts.map +1 -1
  16. package/build/lib/mixins/execute.js +18 -30
  17. package/build/lib/mixins/execute.js.map +1 -1
  18. package/build/lib/mixins/message-handlers.d.ts +13 -23
  19. package/build/lib/mixins/message-handlers.d.ts.map +1 -1
  20. package/build/lib/mixins/message-handlers.js +56 -27
  21. package/build/lib/mixins/message-handlers.js.map +1 -1
  22. package/build/lib/mixins/misc.d.ts +51 -0
  23. package/build/lib/mixins/misc.d.ts.map +1 -0
  24. package/build/lib/mixins/misc.js +132 -0
  25. package/build/lib/mixins/misc.js.map +1 -0
  26. package/build/lib/mixins/navigate.d.ts +20 -29
  27. package/build/lib/mixins/navigate.d.ts.map +1 -1
  28. package/build/lib/mixins/navigate.js +25 -23
  29. package/build/lib/mixins/navigate.js.map +1 -1
  30. package/build/lib/mixins/screenshot.d.ts +13 -0
  31. package/build/lib/mixins/screenshot.d.ts.map +1 -0
  32. package/build/lib/mixins/screenshot.js +31 -0
  33. package/build/lib/mixins/screenshot.js.map +1 -0
  34. package/build/lib/remote-debugger-real-device.d.ts +16 -2
  35. package/build/lib/remote-debugger-real-device.d.ts.map +1 -1
  36. package/build/lib/remote-debugger-real-device.js +11 -1
  37. package/build/lib/remote-debugger-real-device.js.map +1 -1
  38. package/build/lib/remote-debugger.d.ts +153 -174
  39. package/build/lib/remote-debugger.d.ts.map +1 -1
  40. package/build/lib/remote-debugger.js +147 -213
  41. package/build/lib/remote-debugger.js.map +1 -1
  42. package/build/lib/rpc/rpc-client.d.ts +2 -1
  43. package/build/lib/rpc/rpc-client.d.ts.map +1 -1
  44. package/build/lib/rpc/rpc-client.js +2 -0
  45. package/build/lib/rpc/rpc-client.js.map +1 -1
  46. package/build/lib/utils.d.ts +20 -16
  47. package/build/lib/utils.d.ts.map +1 -1
  48. package/build/lib/utils.js +33 -25
  49. package/build/lib/utils.js.map +1 -1
  50. package/build/tsconfig.tsbuildinfo +1 -1
  51. package/lib/mixins/connect.js +61 -105
  52. package/lib/mixins/cookies.js +45 -0
  53. package/lib/mixins/events.js +25 -1
  54. package/lib/mixins/execute.js +18 -39
  55. package/lib/mixins/message-handlers.js +67 -36
  56. package/lib/mixins/misc.js +128 -0
  57. package/lib/mixins/navigate.js +26 -30
  58. package/lib/mixins/screenshot.js +34 -0
  59. package/lib/remote-debugger-real-device.js +14 -1
  60. package/lib/remote-debugger.js +133 -305
  61. package/lib/rpc/rpc-client.js +3 -1
  62. package/lib/utils.js +42 -38
  63. package/package.json +1 -1
  64. package/build/lib/mixins/index.d.ts +0 -5
  65. package/build/lib/mixins/index.d.ts.map +0 -1
  66. package/build/lib/mixins/index.js +0 -16
  67. package/build/lib/mixins/index.js.map +0 -1
  68. package/lib/mixins/index.js +0 -14
package/lib/utils.js CHANGED
@@ -3,6 +3,8 @@ import _ from 'lodash';
3
3
  import B from 'bluebird';
4
4
  import { errorFromMJSONWPStatusCode } from '@appium/base-driver';
5
5
  import { util, node } from '@appium/support';
6
+ import nodeFs from 'node:fs';
7
+ import path from 'node:path';
6
8
 
7
9
  const MODULE_NAME = 'appium-remote-debugger';
8
10
 
@@ -21,7 +23,7 @@ const ACCEPTED_PAGE_TYPES = [
21
23
  'WIRTypePage', // iOS 11.4 webview
22
24
  ];
23
25
 
24
- const RESPONSE_LOG_LENGTH = 100;
26
+ export const RESPONSE_LOG_LENGTH = 100;
25
27
 
26
28
  /**
27
29
  * @typedef {Object} DeferredPromise
@@ -49,7 +51,7 @@ const RESPONSE_LOG_LENGTH = 100;
49
51
  * @param {Record<string, any>} dict
50
52
  * @returns {[string, AppInfo]}
51
53
  */
52
- function appInfoFromDict (dict) {
54
+ export function appInfoFromDict (dict) {
53
55
  const id = dict.WIRApplicationIdentifierKey;
54
56
  const isProxy = _.isString(dict.WIRIsApplicationProxyKey)
55
57
  ? dict.WIRIsApplicationProxyKey.toLowerCase() === 'true'
@@ -85,7 +87,7 @@ function appInfoFromDict (dict) {
85
87
  * Take a dictionary from the remote debugger and makes a more manageable
86
88
  * dictionary of pages available.
87
89
  */
88
- function pageArrayFromDict (pageDict) {
90
+ export function pageArrayFromDict (pageDict) {
89
91
  if (pageDict.id) {
90
92
  // the page is already translated, so wrap in an array and pass back
91
93
  return [pageDict];
@@ -112,7 +114,7 @@ function pageArrayFromDict (pageDict) {
112
114
  * @param {Record<string, any>} appDict
113
115
  * @returns {string|undefined}
114
116
  */
115
- function getDebuggerAppKey (bundleId, appDict) {
117
+ export function getDebuggerAppKey (bundleId, appDict) {
116
118
  let appId;
117
119
  for (const [key, data] of _.toPairs(appDict)) {
118
120
  if (data.bundleId === bundleId) {
@@ -141,29 +143,6 @@ function getDebuggerAppKey (bundleId, appDict) {
141
143
  return appId;
142
144
  }
143
145
 
144
- /**
145
- *
146
- * @param {string} bundleId
147
- * @param {Record<string, any>} appDict
148
- * @returns {string[]}
149
- */
150
- function appIdsForBundle (bundleId, appDict) {
151
- /** @type {Set<string>} */
152
- const appIds = new Set();
153
- for (const [key, data] of _.toPairs(appDict)) {
154
- if (data.bundleId.endsWith(bundleId)) {
155
- appIds.add(key);
156
- }
157
- }
158
-
159
- // if nothing is found, try to get the generic app
160
- if (appIds.size === 0 && bundleId !== WEB_CONTENT_BUNDLE_ID) {
161
- return appIdsForBundle(WEB_CONTENT_BUNDLE_ID, appDict);
162
- }
163
-
164
- return Array.from(appIds);
165
- }
166
-
167
146
  /**
168
147
  * Find app keys based on assigned bundleIds from appDict
169
148
  * When bundleIds includes a wildcard ('*'), returns all appKeys in appDict.
@@ -171,7 +150,7 @@ function appIdsForBundle (bundleId, appDict) {
171
150
  * @param {Record<string, any>} appDict
172
151
  * @returns {string[]}
173
152
  */
174
- function getPossibleDebuggerAppKeys(bundleIds, appDict) {
153
+ export function getPossibleDebuggerAppKeys(bundleIds, appDict) {
175
154
  if (bundleIds.includes(WILDCARD_BUNDLE_ID)) {
176
155
  log.debug('Skip checking bundle identifiers because the bundleIds includes a wildcard');
177
156
  return _.uniq(Object.keys(appDict));
@@ -207,7 +186,7 @@ function getPossibleDebuggerAppKeys(bundleIds, appDict) {
207
186
  return Array.from(proxiedAppIds);
208
187
  }
209
188
 
210
- function checkParams (params) {
189
+ export function checkParams (params) {
211
190
  // check if all parameters have a value
212
191
  const errors = _.toPairs(params)
213
192
  .filter(([, value]) => _.isNil(value))
@@ -217,7 +196,7 @@ function checkParams (params) {
217
196
  }
218
197
  }
219
198
 
220
- function simpleStringify (value, multiline = false) {
199
+ export function simpleStringify (value, multiline = false) {
221
200
  if (!value) {
222
201
  return JSON.stringify(value);
223
202
  }
@@ -234,7 +213,7 @@ function simpleStringify (value, multiline = false) {
234
213
  /**
235
214
  * @returns {DeferredPromise}
236
215
  */
237
- function deferredPromise () {
216
+ export function deferredPromise () {
238
217
  // http://bluebirdjs.com/docs/api/deferred-migration.html
239
218
  /** @type {(...args: any[]) => void} */
240
219
  let resolve;
@@ -253,7 +232,7 @@ function deferredPromise () {
253
232
  };
254
233
  }
255
234
 
256
- function convertResult (res) {
235
+ export function convertResult (res) {
257
236
  if (_.isUndefined(res)) {
258
237
  throw new Error(`Did not get OK result from remote debugger. Result was: ${_.truncate(simpleStringify(res), {length: RESPONSE_LOG_LENGTH})}`);
259
238
  } else if (_.isString(res)) {
@@ -291,7 +270,7 @@ function convertResult (res) {
291
270
  * @returns {string} The full path to module root
292
271
  * @throws {Error} If the current module root folder cannot be determined
293
272
  */
294
- const getModuleRoot = _.memoize(function getModuleRoot () {
273
+ export const getModuleRoot = _.memoize(function getModuleRoot () {
295
274
  const root = node.getModuleRootSync(MODULE_NAME, __filename);
296
275
  if (!root) {
297
276
  throw new Error(`Cannot find the root folder of the ${MODULE_NAME} Node.js module`);
@@ -299,8 +278,33 @@ const getModuleRoot = _.memoize(function getModuleRoot () {
299
278
  return root;
300
279
  });
301
280
 
302
- export {
303
- appInfoFromDict, pageArrayFromDict, getDebuggerAppKey,
304
- getPossibleDebuggerAppKeys, checkParams, simpleStringify, deferredPromise,
305
- convertResult, RESPONSE_LOG_LENGTH, getModuleRoot,
306
- };
281
+ /**
282
+ * @returns {import('@appium/types').StringRecord}
283
+ */
284
+ export function getModuleProperties() {
285
+ const fullPath = path.resolve(getModuleRoot(), 'package.json');
286
+ return JSON.parse(nodeFs.readFileSync(fullPath, 'utf8'));
287
+ }
288
+
289
+ /**
290
+ *
291
+ * @param {string} bundleId
292
+ * @param {Record<string, any>} appDict
293
+ * @returns {string[]}
294
+ */
295
+ function appIdsForBundle (bundleId, appDict) {
296
+ /** @type {Set<string>} */
297
+ const appIds = new Set();
298
+ for (const [key, data] of _.toPairs(appDict)) {
299
+ if (data.bundleId.endsWith(bundleId)) {
300
+ appIds.add(key);
301
+ }
302
+ }
303
+
304
+ // if nothing is found, try to get the generic app
305
+ if (appIds.size === 0 && bundleId !== WEB_CONTENT_BUNDLE_ID) {
306
+ return appIdsForBundle(WEB_CONTENT_BUNDLE_ID, appDict);
307
+ }
308
+
309
+ return Array.from(appIds);
310
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "appium"
6
6
  ],
7
- "version": "11.4.2",
7
+ "version": "11.5.1",
8
8
  "author": "Appium Contributors",
9
9
  "license": "Apache-2.0",
10
10
  "repository": {
@@ -1,5 +0,0 @@
1
- export default mixins;
2
- export const mixins: any;
3
- import events from './events';
4
- export { events };
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/mixins/index.js"],"names":[],"mappings":";AAOA,yBAEE;mBARiB,UAAU"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.events = exports.mixins = void 0;
7
- const connect_1 = __importDefault(require("./connect"));
8
- const events_1 = __importDefault(require("./events"));
9
- exports.events = events_1.default;
10
- const execute_1 = __importDefault(require("./execute"));
11
- const navigate_1 = __importDefault(require("./navigate"));
12
- const message_handlers_1 = __importDefault(require("./message-handlers"));
13
- const mixins = Object.assign({}, connect_1.default, events_1.default, execute_1.default, navigate_1.default, message_handlers_1.default);
14
- exports.mixins = mixins;
15
- exports.default = mixins;
16
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/mixins/index.js"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,sDAA8B;AAWb,iBAXV,gBAAM,CAWU;AAVvB,wDAAgC;AAChC,0DAAkC;AAClC,0EAAiD;AAGjD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAC7B,iBAAO,EAAE,gBAAM,EAAE,iBAAO,EAAE,kBAAQ,EAAE,0BAAe,CACpD,CAAC;AAGO,wBAAM;AACf,kBAAe,MAAM,CAAC"}
@@ -1,14 +0,0 @@
1
- import connect from './connect';
2
- import events from './events';
3
- import execute from './execute';
4
- import navigate from './navigate';
5
- import messageHandlers from './message-handlers';
6
-
7
-
8
- const mixins = Object.assign({},
9
- connect, events, execute, navigate, messageHandlers
10
- );
11
-
12
-
13
- export { mixins, events };
14
- export default mixins;