appium-remote-debugger 15.9.1 → 15.10.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 (81) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/mixins/connect.js +4 -4
  3. package/build/lib/mixins/connect.js.map +1 -1
  4. package/build/lib/mixins/execute.d.ts.map +1 -1
  5. package/build/lib/mixins/execute.js +2 -2
  6. package/build/lib/mixins/execute.js.map +1 -1
  7. package/build/lib/mixins/message-handlers.d.ts.map +1 -1
  8. package/build/lib/mixins/message-handlers.js +3 -2
  9. package/build/lib/mixins/message-handlers.js.map +1 -1
  10. package/build/lib/mixins/misc.d.ts +2 -1
  11. package/build/lib/mixins/misc.d.ts.map +1 -1
  12. package/build/lib/mixins/misc.js +5 -4
  13. package/build/lib/mixins/misc.js.map +1 -1
  14. package/build/lib/mixins/navigate.d.ts.map +1 -1
  15. package/build/lib/mixins/navigate.js +5 -4
  16. package/build/lib/mixins/navigate.js.map +1 -1
  17. package/build/lib/remote-debugger-real-device.js.map +1 -1
  18. package/build/lib/remote-debugger.d.ts +2 -2
  19. package/build/lib/remote-debugger.d.ts.map +1 -1
  20. package/build/lib/remote-debugger.js +5 -7
  21. package/build/lib/remote-debugger.js.map +1 -1
  22. package/build/lib/rpc/rpc-client-real-device-shim.js +3 -3
  23. package/build/lib/rpc/rpc-client-real-device-shim.js.map +1 -1
  24. package/build/lib/rpc/rpc-client.d.ts.map +1 -1
  25. package/build/lib/rpc/rpc-client.js +16 -16
  26. package/build/lib/rpc/rpc-client.js.map +1 -1
  27. package/build/lib/rpc/rpc-message-handler.d.ts.map +1 -1
  28. package/build/lib/rpc/rpc-message-handler.js +3 -4
  29. package/build/lib/rpc/rpc-message-handler.js.map +1 -1
  30. package/build/lib/utils/errors.d.ts +13 -0
  31. package/build/lib/utils/errors.d.ts.map +1 -0
  32. package/build/lib/utils/errors.js +24 -0
  33. package/build/lib/utils/errors.js.map +1 -0
  34. package/build/lib/utils/index.d.ts +7 -0
  35. package/build/lib/utils/index.d.ts.map +1 -0
  36. package/build/lib/utils/index.js +25 -0
  37. package/build/lib/utils/index.js.map +1 -0
  38. package/build/lib/utils/inspector.d.ts +30 -0
  39. package/build/lib/utils/inspector.d.ts.map +1 -0
  40. package/build/lib/utils/inspector.js +91 -0
  41. package/build/lib/utils/inspector.js.map +1 -0
  42. package/build/lib/utils/javascript.d.ts +25 -0
  43. package/build/lib/utils/javascript.d.ts.map +1 -0
  44. package/build/lib/utils/javascript.js +90 -0
  45. package/build/lib/utils/javascript.js.map +1 -0
  46. package/build/lib/utils/module.d.ts +20 -0
  47. package/build/lib/utils/module.d.ts.map +1 -0
  48. package/build/lib/utils/module.js +36 -0
  49. package/build/lib/utils/module.js.map +1 -0
  50. package/build/lib/utils/object.d.ts +29 -0
  51. package/build/lib/utils/object.d.ts.map +1 -0
  52. package/build/lib/utils/object.js +54 -0
  53. package/build/lib/utils/object.js.map +1 -0
  54. package/build/lib/utils/platform.d.ts +7 -0
  55. package/build/lib/utils/platform.d.ts.map +1 -0
  56. package/build/lib/utils/platform.js +13 -0
  57. package/build/lib/utils/platform.js.map +1 -0
  58. package/lib/appium-ios-device.d.ts +12 -0
  59. package/lib/mixins/connect.ts +6 -6
  60. package/lib/mixins/execute.ts +2 -3
  61. package/lib/mixins/message-handlers.ts +4 -3
  62. package/lib/mixins/misc.ts +6 -5
  63. package/lib/mixins/navigate.ts +10 -5
  64. package/lib/remote-debugger-real-device.ts +1 -1
  65. package/lib/remote-debugger.ts +8 -10
  66. package/lib/rpc/rpc-client-real-device-shim.ts +3 -3
  67. package/lib/rpc/rpc-client.ts +16 -23
  68. package/lib/rpc/rpc-message-handler.ts +3 -4
  69. package/lib/utils/errors.ts +19 -0
  70. package/lib/utils/index.ts +16 -0
  71. package/lib/utils/inspector.ts +99 -0
  72. package/lib/utils/javascript.ts +89 -0
  73. package/lib/utils/module.ts +33 -0
  74. package/lib/utils/object.ts +55 -0
  75. package/lib/utils/platform.ts +10 -0
  76. package/package.json +9 -3
  77. package/build/lib/utils.d.ts +0 -167
  78. package/build/lib/utils.d.ts.map +0 -1
  79. package/build/lib/utils.js +0 -422
  80. package/build/lib/utils.js.map +0 -1
  81. package/lib/utils.ts +0 -443
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RESPONSE_LOG_LENGTH = void 0;
4
+ exports.simpleStringify = simpleStringify;
5
+ exports.convertJavascriptEvaluationResult = convertJavascriptEvaluationResult;
6
+ const base_driver_1 = require("@appium/base-driver");
7
+ const support_1 = require("@appium/support");
8
+ exports.RESPONSE_LOG_LENGTH = 100;
9
+ /**
10
+ * Converts a value to a best-effort JSON string for logging, removing noisy
11
+ * function properties from cloneable objects when possible.
12
+ *
13
+ * Falls back to `String(value)` when JSON serialization returns `undefined`
14
+ * or throws (for example, for functions, symbols, or circular structures).
15
+ *
16
+ * @param value - The value to stringify.
17
+ * @param multiline - If true, formats JSON output with indentation. Defaults to false.
18
+ * @returns A string representation suitable for logging.
19
+ */
20
+ function simpleStringify(value, multiline = false) {
21
+ const stringify = (val) => {
22
+ try {
23
+ return multiline
24
+ ? (JSON.stringify(val, null, 2) ?? String(val))
25
+ : (JSON.stringify(val) ?? String(val));
26
+ }
27
+ catch {
28
+ return String(val);
29
+ }
30
+ };
31
+ if (!value) {
32
+ return stringify(value);
33
+ }
34
+ let cleanValue = value;
35
+ if (typeof value === 'object' && value !== null) {
36
+ try {
37
+ cleanValue = removeNoisyProperties(structuredClone(value));
38
+ }
39
+ catch {
40
+ // Fall back to the original value when cloning fails (e.g., non-cloneable graph entries).
41
+ cleanValue = value;
42
+ }
43
+ }
44
+ return stringify(cleanValue);
45
+ }
46
+ /**
47
+ * Converts the result from a JavaScript evaluation in the remote debugger
48
+ * into a usable format. Handles errors, serialization, and cleans up noisy
49
+ * function properties.
50
+ *
51
+ * @param res - The raw result from the remote debugger's JavaScript evaluation.
52
+ * @returns The cleaned and converted result value.
53
+ * @throws Error if the result is undefined, has an unexpected type, or contains
54
+ * an error status code.
55
+ */
56
+ function convertJavascriptEvaluationResult(res) {
57
+ if (res === undefined) {
58
+ throw new Error(`Did not get OK result from remote debugger. Result was: ${support_1.util.truncateString(simpleStringify(res), exports.RESPONSE_LOG_LENGTH)}`);
59
+ }
60
+ else if (typeof res === 'string') {
61
+ try {
62
+ res = JSON.parse(res);
63
+ }
64
+ catch {
65
+ // we might get a serialized object, but we might not
66
+ // if we get here, it is just a value
67
+ }
68
+ }
69
+ else if ((typeof res !== 'object' && typeof res !== 'function') || res === null) {
70
+ throw new Error(`Result has unexpected type: (${typeof res}).`);
71
+ }
72
+ if (Object.hasOwn(res, 'status') && res.status !== 0) {
73
+ // we got some form of error.
74
+ throw (0, base_driver_1.errorFromMJSONWPStatusCode)(res.status, res.value.message || res.value);
75
+ }
76
+ // with either have an object with a `value` property (even if `null`),
77
+ // or a plain object
78
+ const value = Object.hasOwn(res, 'value') ? res.value : res;
79
+ return removeNoisyProperties(value);
80
+ }
81
+ function removeNoisyProperties(obj) {
82
+ if (obj && typeof obj === 'object') {
83
+ const record = obj;
84
+ for (const property of ['ceil', 'clone', 'floor', 'round', 'scale', 'toString']) {
85
+ delete record[property];
86
+ }
87
+ }
88
+ return obj;
89
+ }
90
+ //# sourceMappingURL=javascript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../lib/utils/javascript.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,20 @@
1
+ import type { StringRecord } from '@appium/types';
2
+ declare function resolveModuleRoot(): string;
3
+ /**
4
+ * Calculates the path to the current module's root folder.
5
+ * The result is memoized for performance.
6
+ *
7
+ * @returns The full path to the module root directory.
8
+ * @throws Error if the module root folder cannot be determined.
9
+ */
10
+ export declare const getModuleRoot: typeof resolveModuleRoot & {
11
+ cache: Map<unknown, string>;
12
+ };
13
+ /**
14
+ * Reads and parses the package.json file from the module root.
15
+ *
16
+ * @returns The parsed package.json contents as a StringRecord.
17
+ */
18
+ export declare function getModuleProperties(): StringRecord;
19
+ export {};
20
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../lib/utils/module.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAIhD,iBAAS,iBAAiB,IAAI,MAAM,CAMnC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;CAAkC,CAAC;AAE7D;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,CAGlD"}
@@ -0,0 +1,36 @@
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.getModuleRoot = void 0;
7
+ exports.getModuleProperties = getModuleProperties;
8
+ const support_1 = require("@appium/support");
9
+ const node_fs_1 = __importDefault(require("node:fs"));
10
+ const node_path_1 = __importDefault(require("node:path"));
11
+ const MODULE_NAME = 'appium-remote-debugger';
12
+ function resolveModuleRoot() {
13
+ const root = support_1.node.getModuleRootSync(MODULE_NAME, __filename);
14
+ if (!root) {
15
+ throw new Error(`Cannot find the root folder of the ${MODULE_NAME} Node.js module`);
16
+ }
17
+ return root;
18
+ }
19
+ /**
20
+ * Calculates the path to the current module's root folder.
21
+ * The result is memoized for performance.
22
+ *
23
+ * @returns The full path to the module root directory.
24
+ * @throws Error if the module root folder cannot be determined.
25
+ */
26
+ exports.getModuleRoot = support_1.util.memoize(resolveModuleRoot);
27
+ /**
28
+ * Reads and parses the package.json file from the module root.
29
+ *
30
+ * @returns The parsed package.json contents as a StringRecord.
31
+ */
32
+ function getModuleProperties() {
33
+ const fullPath = node_path_1.default.resolve((0, exports.getModuleRoot)(), 'package.json');
34
+ return JSON.parse(node_fs_1.default.readFileSync(fullPath, 'utf8'));
35
+ }
36
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../../lib/utils/module.ts"],"names":[],"mappings":";;;;;;AA6BA,kDAGC;AAhCD,6CAA2C;AAC3C,sDAA6B;AAC7B,0DAA6B;AAG7B,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAE7C,SAAS,iBAAiB;IACxB,MAAM,IAAI,GAAG,cAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAC7D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,sCAAsC,WAAW,iBAAiB,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACU,QAAA,aAAa,GAAG,cAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE7D;;;;GAIG;AACH,SAAgB,mBAAmB;IACjC,MAAM,QAAQ,GAAG,mBAAI,CAAC,OAAO,CAAC,IAAA,qBAAa,GAAE,EAAE,cAAc,CAAC,CAAC;IAC/D,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { StringRecord } from '@appium/types';
2
+ /**
3
+ * Creates a shallow object where undefined keys from `target` are filled
4
+ * from `defaultsObj`.
5
+ *
6
+ * @param target - The object with priority values.
7
+ * @param defaultsObj - The object providing fallback values.
8
+ * @returns A new object containing merged defaulted values.
9
+ */
10
+ export declare function defaults<T extends Record<string, any>, U extends Record<string, any>>(target: T, defaultsObj: U): T & U;
11
+ /**
12
+ * Performs deep strict equality comparison.
13
+ *
14
+ * @param a - First value.
15
+ * @param b - Second value.
16
+ * @returns True when both values are deeply equal.
17
+ */
18
+ export declare function deepEqual(a: unknown, b: unknown): boolean;
19
+ /**
20
+ * Validates that all parameters in the provided object have non-nil values.
21
+ * Throws an error if any parameters are missing (null or undefined).
22
+ *
23
+ * @template T - The type of the parameters object.
24
+ * @param params - An object containing parameters to validate.
25
+ * @returns The same parameters object if all values are valid.
26
+ * @throws Error if any parameters are missing, listing all missing parameter names.
27
+ */
28
+ export declare function checkParams<T extends StringRecord>(params: T): T;
29
+ //# sourceMappingURL=object.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../lib/utils/object.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAEhD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnF,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,CAAC,GACb,CAAC,GAAG,CAAC,CAQP;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,YAAY,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAShE"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaults = defaults;
4
+ exports.deepEqual = deepEqual;
5
+ exports.checkParams = checkParams;
6
+ const support_1 = require("@appium/support");
7
+ const node_util_1 = require("node:util");
8
+ /**
9
+ * Creates a shallow object where undefined keys from `target` are filled
10
+ * from `defaultsObj`.
11
+ *
12
+ * @param target - The object with priority values.
13
+ * @param defaultsObj - The object providing fallback values.
14
+ * @returns A new object containing merged defaulted values.
15
+ */
16
+ function defaults(target, defaultsObj) {
17
+ const result = { ...target };
18
+ for (const [key, value] of Object.entries(defaultsObj)) {
19
+ if (result[key] === undefined) {
20
+ result[key] = value;
21
+ }
22
+ }
23
+ return result;
24
+ }
25
+ /**
26
+ * Performs deep strict equality comparison.
27
+ *
28
+ * @param a - First value.
29
+ * @param b - Second value.
30
+ * @returns True when both values are deeply equal.
31
+ */
32
+ function deepEqual(a, b) {
33
+ return (0, node_util_1.isDeepStrictEqual)(a, b);
34
+ }
35
+ /**
36
+ * Validates that all parameters in the provided object have non-nil values.
37
+ * Throws an error if any parameters are missing (null or undefined).
38
+ *
39
+ * @template T - The type of the parameters object.
40
+ * @param params - An object containing parameters to validate.
41
+ * @returns The same parameters object if all values are valid.
42
+ * @throws Error if any parameters are missing, listing all missing parameter names.
43
+ */
44
+ function checkParams(params) {
45
+ // check if all parameters have a value
46
+ const errors = Object.entries(params)
47
+ .filter(([, value]) => value == null)
48
+ .map(([param]) => param);
49
+ if (errors.length) {
50
+ throw new Error(`Missing ${support_1.util.pluralize('parameter', errors.length)}: ${errors.join(', ')}`);
51
+ }
52
+ return params;
53
+ }
54
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../lib/utils/object.ts"],"names":[],"mappings":";;AAYA,4BAWC;AASD,8BAEC;AAWD,kCASC;AAtDD,6CAAqC;AACrC,yCAA4C;AAG5C;;;;;;;GAOG;AACH,SAAgB,QAAQ,CACtB,MAAS,EACT,WAAc;IAEd,MAAM,MAAM,GAAG,EAAC,GAAG,MAAM,EAAU,CAAC;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACvD,IAAI,MAAM,CAAC,GAAoB,CAAC,KAAK,SAAS,EAAE,CAAC;YAC9C,MAAc,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,CAAU,EAAE,CAAU;IAC9C,OAAO,IAAA,6BAAiB,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAyB,MAAS;IAC3D,uCAAuC;IACvC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAClC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC;SACpC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,WAAW,cAAI,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Determines if the WebInspector shim can be used based on the provided iOS platform version.
3
+ * @param platformVersion - The iOS platform version string (e.g., "18.0", "17.5.1"), or undefined/null when unknown.
4
+ * @returns true if the WebInspector shim can be used, false otherwise
5
+ */
6
+ export declare function canUseWebInspectorShim(platformVersion: string | undefined | null): boolean;
7
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../lib/utils/platform.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAE1F"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.canUseWebInspectorShim = canUseWebInspectorShim;
4
+ const support_1 = require("@appium/support");
5
+ /**
6
+ * Determines if the WebInspector shim can be used based on the provided iOS platform version.
7
+ * @param platformVersion - The iOS platform version string (e.g., "18.0", "17.5.1"), or undefined/null when unknown.
8
+ * @returns true if the WebInspector shim can be used, false otherwise
9
+ */
10
+ function canUseWebInspectorShim(platformVersion) {
11
+ return !!platformVersion && support_1.util.compareVersions(platformVersion, '>=', '18.0');
12
+ }
13
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../../../lib/utils/platform.ts"],"names":[],"mappings":";;AAOA,wDAEC;AATD,6CAAqC;AAErC;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,eAA0C;IAC/E,OAAO,CAAC,CAAC,eAAe,IAAI,cAAI,CAAC,eAAe,CAAC,eAAe,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAClF,CAAC"}
@@ -0,0 +1,12 @@
1
+ declare module 'appium-ios-device' {
2
+ export const services: {
3
+ startWebInspectorService(
4
+ udid: string,
5
+ opts: Record<string, unknown>,
6
+ ): Promise<{
7
+ listenMessage: (handler: (data: Buffer) => void) => void;
8
+ sendMessage: (cmd: Buffer) => void;
9
+ close?: () => void | Promise<void>;
10
+ }>;
11
+ };
12
+ }
@@ -1,4 +1,4 @@
1
- import {isEmpty, pageArrayFromDict, uniq, WEB_CONTENT_BUNDLE_ID, appIdsForBundle} from '../utils';
1
+ import {pageArrayFromDict, WEB_CONTENT_BUNDLE_ID, appIdsForBundle} from '../utils';
2
2
  import {events} from './events';
3
3
  import {timing, util} from '@appium/support';
4
4
  import {retryInterval, waitForCondition} from 'asyncbox';
@@ -84,7 +84,7 @@ export async function connect(
84
84
  const timer = new timing.Timer().start();
85
85
  this.log.debug(`Waiting up to ${timeout}ms for applications to be reported`);
86
86
  try {
87
- await waitForCondition(() => !isEmpty(getAppDict(this)), {
87
+ await waitForCondition(() => !util.isEmpty(getAppDict(this)), {
88
88
  waitMs: timeout,
89
89
  intervalMs: APP_CONNECT_INTERVAL_MS,
90
90
  });
@@ -138,7 +138,7 @@ export async function selectApp(
138
138
  this.log.debug('Selecting application');
139
139
 
140
140
  const timer = new timing.Timer().start();
141
- if (isEmpty(getAppDict(this))) {
141
+ if (util.isEmpty(getAppDict(this))) {
142
142
  this.log.debug('No applications currently connected.');
143
143
  return [];
144
144
  }
@@ -236,7 +236,7 @@ export function getPossibleDebuggerAppKeys(this: RemoteDebugger, bundleIds: stri
236
236
  }
237
237
 
238
238
  // go through the possible bundle identifiers
239
- const possibleBundleIds = uniq([
239
+ const possibleBundleIds = util.uniq([
240
240
  WEB_CONTENT_BUNDLE_ID,
241
241
  WEB_CONTENT_PROCESS_BUNDLE_ID,
242
242
  SAFARI_VIEW_PROCESS_BUNDLE_ID,
@@ -273,7 +273,7 @@ export function getPossibleDebuggerAppKeys(this: RemoteDebugger, bundleIds: stri
273
273
  `capability to match other applications. Add a wildcard ('*') to match all apps.`,
274
274
  );
275
275
 
276
- return uniq(proxiedAppIds);
276
+ return util.uniq(proxiedAppIds);
277
277
  }
278
278
 
279
279
  /**
@@ -361,7 +361,7 @@ async function searchForApp(
361
361
  throw new Error(
362
362
  `Could not connect to a valid webapp. Make sure it is debuggable and has at least one active page.`,
363
363
  );
364
- })) as Promise<AppPage>;
364
+ })) as AppPage;
365
365
  }
366
366
 
367
367
  /**
@@ -4,7 +4,6 @@ import {
4
4
  simpleStringify,
5
5
  convertJavascriptEvaluationResult,
6
6
  RESPONSE_LOG_LENGTH,
7
- truncateString,
8
7
  } from '../utils';
9
8
  import {getScriptForAtom} from '../atoms';
10
9
  import {util, timing} from '@appium/support';
@@ -35,7 +34,7 @@ export async function executeAtom(
35
34
  const script = await getScriptForAtom(atom, args, frames);
36
35
  const value = await this.execute(script);
37
36
  this.log.debug(
38
- `Received result for atom '${atom}' execution: ${truncateString(simpleStringify(value), RESPONSE_LOG_LENGTH)}`,
37
+ `Received result for atom '${atom}' execution: ${util.truncateString(simpleStringify(value), RESPONSE_LOG_LENGTH)}`,
39
38
  );
40
39
  return value;
41
40
  }
@@ -175,7 +174,7 @@ export async function execute(
175
174
 
176
175
  const rpcClient = this.requireRpcClient(true);
177
176
  await rpcClient.waitForPage(appIdKey as AppIdKey, pageIdKey as PageIdKey);
178
- this.log.debug(`Sending javascript command: '${truncateString(command, 50)}'`);
177
+ this.log.debug(`Sending javascript command: '${util.truncateString(command, 50)}'`);
179
178
  const res = await rpcClient.send('Runtime.evaluate', {
180
179
  expression: command,
181
180
  returnByValue: true,
@@ -1,5 +1,6 @@
1
+ import {util} from '@appium/support';
1
2
  import {events} from './events';
2
- import {deepEqual, defaults, isEmpty, pageArrayFromDict, appInfoFromDict} from '../utils';
3
+ import {deepEqual, defaults, pageArrayFromDict, appInfoFromDict} from '../utils';
3
4
  import {
4
5
  setAppIdKey,
5
6
  getAppDict,
@@ -34,7 +35,7 @@ export async function onPageChange(
34
35
  appIdKey: string,
35
36
  pageDict: StringRecord,
36
37
  ): Promise<void> {
37
- if (isEmpty(pageDict)) {
38
+ if (util.isEmpty(pageDict)) {
38
39
  return;
39
40
  }
40
41
 
@@ -115,7 +116,7 @@ export function onAppDisconnect(
115
116
  setAppIdKey(this, getDebuggerAppKey.bind(this)(getBundleId(this) as string));
116
117
  }
117
118
 
118
- if (isEmpty(getAppDict(this))) {
119
+ if (util.isEmpty(getAppDict(this))) {
119
120
  // this means we no longer have any apps. what the what?
120
121
  this.log.debug('Main app disconnected. Disconnecting altogether.');
121
122
  this.emit(events.EVENT_DISCONNECT, true);
@@ -1,6 +1,8 @@
1
- import {checkParams, TimeoutError, withTimeout} from '../utils';
1
+ import {withTimeout} from 'asyncbox';
2
+ import {checkParams, TimeoutError} from '../utils';
2
3
  import {getAppIdKey, getPageIdKey} from './property-accessors';
3
4
  import type {RemoteDebugger} from '../remote-debugger';
5
+ import type {EventListener} from '../types';
4
6
 
5
7
  const SAFARI_BUNDLE_ID = 'com.apple.mobilesafari';
6
8
  const GARBAGE_COLLECT_TIMEOUT_MS = 5000;
@@ -22,10 +24,7 @@ export async function launchSafari(this: RemoteDebugger): Promise<void> {
22
24
  * @param fn - Event listener function that will be called when timeline events are recorded.
23
25
  * @returns A promise that resolves when the timeline recording has started.
24
26
  */
25
- export async function startTimeline(
26
- this: RemoteDebugger,
27
- fn: import('../types').EventListener,
28
- ): Promise<any> {
27
+ export async function startTimeline(this: RemoteDebugger, fn: EventListener): Promise<any> {
29
28
  this.log.debug('Starting to record the timeline');
30
29
  this.requireRpcClient().on('Timeline.eventRecorded', fn);
31
30
  return await this.requireRpcClient().send('Timeline.start', {
@@ -84,6 +83,7 @@ export async function isJavascriptExecutionBlocked(
84
83
  pageIdKey: getPageIdKey(this),
85
84
  }),
86
85
  timeoutMs,
86
+ new TimeoutError(`Operation timed out after ${timeoutMs}ms`),
87
87
  );
88
88
  return false;
89
89
  } catch {
@@ -122,6 +122,7 @@ export async function garbageCollect(
122
122
  pageIdKey: getPageIdKey(this),
123
123
  }),
124
124
  timeoutMs,
125
+ new TimeoutError(`Operation timed out after ${timeoutMs}ms`),
125
126
  );
126
127
  this.log.debug(`Garbage collection successful`);
127
128
  } catch (e: any) {
@@ -1,4 +1,5 @@
1
- import {cancellableDelay, checkParams, delay, TimeoutError, withTimeout} from '../utils';
1
+ import {sleep, withTimeout} from 'asyncbox';
2
+ import {DelayCancellation, checkParams, TimeoutError} from '../utils';
2
3
  import {events} from './events';
3
4
  import {timing} from '@appium/support';
4
5
  import {
@@ -86,7 +87,7 @@ export async function waitForDom(
86
87
 
87
88
  let isPageLoading = true;
88
89
  setPageLoading(this, true);
89
- setPageLoadDelay(this, cancellableDelay(readinessTimeoutMs));
90
+ setPageLoadDelay(this, sleep({ms: readinessTimeoutMs, cancelError: new DelayCancellation()}));
90
91
  const pageReadinessPromise = (async () => {
91
92
  let retry = 0;
92
93
  while (isPageLoading) {
@@ -97,7 +98,7 @@ export async function waitForDom(
97
98
  PAGE_READINESS_CHECK_INTERVAL_MS * Math.pow(2, retry),
98
99
  readinessTimeoutMs - elapsedMs,
99
100
  );
100
- await delay(intervalMs);
101
+ await sleep(intervalMs);
101
102
  // we can get this called in the middle of trying to find a new app
102
103
  if (!getAppIdKey(this)) {
103
104
  this.log.debug('Not connected to an application. Ignoring page readiess check');
@@ -153,7 +154,11 @@ export async function checkPageIsReady(this: RemoteDebugger, timeoutMs?: number)
153
154
  const readyCmd = 'document.readyState;';
154
155
  const actualTimeoutMs = timeoutMs ?? getPageReadyTimeout(this);
155
156
  try {
156
- const readyState = await withTimeout(this.execute(readyCmd), actualTimeoutMs);
157
+ const readyState = await withTimeout(
158
+ this.execute(readyCmd),
159
+ actualTimeoutMs,
160
+ new TimeoutError(`Operation timed out after ${actualTimeoutMs}ms`),
161
+ );
157
162
  this.log.debug(
158
163
  JSON.stringify({
159
164
  readyState,
@@ -199,7 +204,7 @@ export async function navToUrl(this: RemoteDebugger, url: string): Promise<void>
199
204
  const readinessTimeoutMs = this.pageLoadMs;
200
205
  let onPageLoaded: (() => void) | undefined;
201
206
  let onPageLoadedTimeout: NodeJS.Timeout | undefined | null;
202
- setPageLoadDelay(this, cancellableDelay(readinessTimeoutMs));
207
+ setPageLoadDelay(this, sleep({ms: readinessTimeoutMs, cancelError: new DelayCancellation()}));
203
208
  setPageLoading(this, true);
204
209
  let isPageLoading = true;
205
210
  const start = new timing.Timer().start();
@@ -34,7 +34,7 @@ export class RemoteDebuggerRealDevice extends RemoteDebugger {
34
34
  pageLoadTimeoutMs: this._pageLoadMs,
35
35
  };
36
36
 
37
- this._useWebInspectorShim = canUseWebInspectorShim(this._platformVersion as string);
37
+ this._useWebInspectorShim = canUseWebInspectorShim(this._platformVersion);
38
38
  if (this._useWebInspectorShim) {
39
39
  const shimClient = new RpcClientRealDeviceShim(commonOpts);
40
40
  try {
@@ -10,7 +10,7 @@ import * as cookieMixins from './mixins/cookies';
10
10
  import * as screenshotMixins from './mixins/screenshot';
11
11
  import * as eventMixins from './mixins/events';
12
12
  import * as miscellaneousMixins from './mixins/misc';
13
- import type {CancellableDelay} from './utils';
13
+ import type {CancellablePromise} from 'asyncbox';
14
14
  import type {RemoteDebuggerOptions, AppDict, EventListener, PageIdKey, AppIdKey} from './types';
15
15
  import type {AppiumLogger, StringRecord} from '@appium/types';
16
16
  import type {RpcClient} from './rpc/rpc-client';
@@ -67,16 +67,16 @@ export class RemoteDebugger extends EventEmitter {
67
67
  frameDetached = navigationMixins.frameDetached;
68
68
 
69
69
  protected _skippedApps: string[];
70
- protected _clientEventListeners: StringRecord<EventListener[]>;
71
- protected _appDict: AppDict;
70
+ protected _clientEventListeners!: StringRecord<EventListener[]>;
71
+ protected _appDict: AppDict = {};
72
72
  protected _appIdKey?: AppIdKey;
73
73
  protected _pageIdKey?: PageIdKey;
74
74
  protected _connectedDrivers?: StringRecord[];
75
75
  protected _currentState?: string;
76
- protected _pageLoadDelay?: CancellableDelay;
77
- protected _rpcClient: RpcClient | null;
78
- protected _pageLoading: boolean;
79
- protected _navigatingToPage: boolean;
76
+ protected _pageLoadDelay?: CancellablePromise<void>;
77
+ protected _rpcClient: RpcClient | null = null;
78
+ protected _pageLoading: boolean = false;
79
+ protected _navigatingToPage: boolean = false;
80
80
  protected _allowNavigationWithoutReload: boolean;
81
81
  protected _pageLoadMs?: number;
82
82
  protected readonly _pageLoadStrategy?: string;
@@ -263,8 +263,6 @@ export class RemoteDebugger extends EventEmitter {
263
263
  }
264
264
  }
265
265
 
266
- for (const [name, event] of Object.entries(eventMixins.events)) {
267
- RemoteDebugger[name] = event;
268
- }
266
+ Object.assign(RemoteDebugger, eventMixins.events);
269
267
 
270
268
  export default RemoteDebugger;
@@ -1,5 +1,5 @@
1
+ import {util} from '@appium/support';
1
2
  import {log} from '../logger';
2
- import {isPlainObject} from '../utils';
3
3
  import {RpcClient} from './rpc-client';
4
4
  import type {RemoteCommand, RpcClientOptions} from '../types';
5
5
  import type {StringRecord} from '@appium/types';
@@ -190,7 +190,7 @@ export class RpcClientRealDeviceShim extends RpcClient {
190
190
  };
191
191
 
192
192
  // Convert buffer data to strings where necessary
193
- if (isPlainObject(message.__argument)) {
193
+ if (util.isPlainObject(message.__argument)) {
194
194
  const args = {...message.__argument};
195
195
 
196
196
  // Handle WIRMessageDataKey and WIRSocketDataKey which may be buffers
@@ -213,7 +213,7 @@ export class RpcClientRealDeviceShim extends RpcClient {
213
213
  * @returns The translated arguments for the shim service.
214
214
  */
215
215
  private translateArguments(args: any): StringRecord {
216
- if (!isPlainObject(args)) {
216
+ if (!util.isPlainObject(args)) {
217
217
  return {};
218
218
  }
219
219