appium-xcuitest-driver 10.10.1 → 10.12.0

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 (75) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/lib/app-infos-cache.d.ts +29 -31
  3. package/build/lib/app-infos-cache.d.ts.map +1 -1
  4. package/build/lib/app-infos-cache.js +29 -33
  5. package/build/lib/app-infos-cache.js.map +1 -1
  6. package/build/lib/app-utils.d.ts +30 -59
  7. package/build/lib/app-utils.d.ts.map +1 -1
  8. package/build/lib/app-utils.js +158 -211
  9. package/build/lib/app-utils.js.map +1 -1
  10. package/build/lib/commands/battery.d.ts.map +1 -1
  11. package/build/lib/commands/battery.js +4 -8
  12. package/build/lib/commands/battery.js.map +1 -1
  13. package/build/lib/commands/biometric.d.ts.map +1 -1
  14. package/build/lib/commands/biometric.js +1 -5
  15. package/build/lib/commands/biometric.js.map +1 -1
  16. package/build/lib/commands/condition.js +4 -4
  17. package/build/lib/commands/condition.js.map +1 -1
  18. package/build/lib/commands/content-size.js +1 -1
  19. package/build/lib/commands/content-size.js.map +1 -1
  20. package/build/lib/commands/find.js +2 -2
  21. package/build/lib/commands/find.js.map +1 -1
  22. package/build/lib/commands/increase-contrast.js +1 -1
  23. package/build/lib/commands/increase-contrast.js.map +1 -1
  24. package/build/lib/commands/keychains.d.ts.map +1 -1
  25. package/build/lib/commands/keychains.js +1 -5
  26. package/build/lib/commands/keychains.js.map +1 -1
  27. package/build/lib/commands/localization.d.ts.map +1 -1
  28. package/build/lib/commands/localization.js +1 -5
  29. package/build/lib/commands/localization.js.map +1 -1
  30. package/build/lib/commands/pasteboard.d.ts.map +1 -1
  31. package/build/lib/commands/pasteboard.js +10 -8
  32. package/build/lib/commands/pasteboard.js.map +1 -1
  33. package/build/lib/commands/permissions.js +1 -1
  34. package/build/lib/commands/permissions.js.map +1 -1
  35. package/build/lib/css-converter.d.ts +3 -9
  36. package/build/lib/css-converter.d.ts.map +1 -1
  37. package/build/lib/css-converter.js +41 -52
  38. package/build/lib/css-converter.js.map +1 -1
  39. package/build/lib/device/real-device-management.js +14 -14
  40. package/build/lib/device/real-device-management.js.map +1 -1
  41. package/build/lib/device/simulator-management.d.ts.map +1 -1
  42. package/build/lib/device/simulator-management.js +8 -4
  43. package/build/lib/device/simulator-management.js.map +1 -1
  44. package/build/lib/driver.d.ts.map +1 -1
  45. package/build/lib/driver.js +3 -3
  46. package/build/lib/driver.js.map +1 -1
  47. package/build/lib/logger.d.ts +1 -2
  48. package/build/lib/logger.d.ts.map +1 -1
  49. package/build/lib/logger.js +2 -2
  50. package/build/lib/logger.js.map +1 -1
  51. package/build/lib/utils.d.ts +76 -134
  52. package/build/lib/utils.d.ts.map +1 -1
  53. package/build/lib/utils.js +80 -141
  54. package/build/lib/utils.js.map +1 -1
  55. package/lib/{app-infos-cache.js → app-infos-cache.ts} +44 -46
  56. package/lib/{app-utils.js → app-utils.ts} +215 -245
  57. package/lib/commands/battery.js +3 -4
  58. package/lib/commands/biometric.js +1 -2
  59. package/lib/commands/condition.js +1 -1
  60. package/lib/commands/content-size.js +1 -1
  61. package/lib/commands/find.js +1 -1
  62. package/lib/commands/increase-contrast.js +1 -1
  63. package/lib/commands/keychains.js +1 -2
  64. package/lib/commands/localization.js +1 -2
  65. package/lib/commands/pasteboard.js +9 -8
  66. package/lib/commands/permissions.js +1 -1
  67. package/lib/{css-converter.js → css-converter.ts} +75 -88
  68. package/lib/device/real-device-management.ts +1 -1
  69. package/lib/device/simulator-management.ts +9 -4
  70. package/lib/driver.ts +6 -4
  71. package/lib/logger.ts +3 -0
  72. package/lib/{utils.js → utils.ts} +102 -139
  73. package/npm-shrinkwrap.json +121 -74
  74. package/package.json +4 -4
  75. package/lib/logger.js +0 -5
@@ -1,11 +1,11 @@
1
1
  import _ from 'lodash';
2
- import path from 'path';
2
+ import path from 'node:path';
3
3
  import {plist, fs, tempDir, zip} from 'appium/support';
4
4
  import {LRUCache} from 'lru-cache';
5
5
  import B from 'bluebird';
6
+ import type {AppiumLogger, StringRecord} from '@appium/types';
6
7
 
7
- /** @type {LRUCache<string, import('@appium/types').StringRecord>} */
8
- const MANIFEST_CACHE = new LRUCache({
8
+ const MANIFEST_CACHE = new LRUCache<string, StringRecord>({
9
9
  max: 40,
10
10
  updateAgeOnHas: true,
11
11
  });
@@ -16,20 +16,19 @@ const IPA_ROOT_PLIST_PATH_PATTERN = new RegExp(
16
16
  const MAX_MANIFEST_SIZE = 1024 * 1024; // 1 MiB
17
17
 
18
18
  export class AppInfosCache {
19
- /**
20
- * @param {import('@appium/types').AppiumLogger} log
21
- */
22
- constructor (log) {
19
+ private readonly log: AppiumLogger;
20
+
21
+ constructor(log: AppiumLogger) {
23
22
  this.log = log;
24
23
  }
25
24
 
26
25
  /**
27
26
  *
28
- * @param {string} bundlePath Full path to the .ipa or .app bundle
29
- * @param {string} propertyName
30
- * @returns {Promise<any>}
27
+ * @param bundlePath Full path to the .ipa or .app bundle
28
+ * @param propertyName
29
+ * @returns
31
30
  */
32
- async extractManifestProperty (bundlePath, propertyName) {
31
+ async extractManifestProperty(bundlePath: string, propertyName: string): Promise<any> {
33
32
  const result = (await this.put(bundlePath))[propertyName];
34
33
  this.log.debug(`${propertyName}: ${JSON.stringify(result)}`);
35
34
  return result;
@@ -37,28 +36,28 @@ export class AppInfosCache {
37
36
 
38
37
  /**
39
38
  *
40
- * @param {string} bundlePath Full path to the .ipa or .app bundle
41
- * @returns {Promise<string>}
39
+ * @param bundlePath Full path to the .ipa or .app bundle
40
+ * @returns
42
41
  */
43
- async extractBundleId (bundlePath) {
42
+ async extractBundleId(bundlePath: string): Promise<string> {
44
43
  return await this.extractManifestProperty(bundlePath, 'CFBundleIdentifier');
45
44
  }
46
45
 
47
46
  /**
48
47
  *
49
- * @param {string} bundlePath Full path to the .ipa or .app bundle
50
- * @returns {Promise<string>}
48
+ * @param bundlePath Full path to the .ipa or .app bundle
49
+ * @returns
51
50
  */
52
- async extractBundleVersion (bundlePath) {
51
+ async extractBundleVersion(bundlePath: string): Promise<string> {
53
52
  return await this.extractManifestProperty(bundlePath, 'CFBundleVersion');
54
53
  }
55
54
 
56
55
  /**
57
56
  *
58
- * @param {string} bundlePath Full path to the .ipa or .app bundle
59
- * @returns {Promise<string[]>}
57
+ * @param bundlePath Full path to the .ipa or .app bundle
58
+ * @returns
60
59
  */
61
- async extractAppPlatforms (bundlePath) {
60
+ async extractAppPlatforms(bundlePath: string): Promise<string[]> {
62
61
  const result = await this.extractManifestProperty(bundlePath, 'CFBundleSupportedPlatforms');
63
62
  if (!Array.isArray(result)) {
64
63
  throw new Error(`${path.basename(bundlePath)}': CFBundleSupportedPlatforms is not a valid list`);
@@ -68,34 +67,32 @@ export class AppInfosCache {
68
67
 
69
68
  /**
70
69
  *
71
- * @param {string} bundlePath Full path to the .ipa or .app bundle
72
- * @returns {Promise<string>}
70
+ * @param bundlePath Full path to the .ipa or .app bundle
71
+ * @returns
73
72
  */
74
- async extractExecutableName (bundlePath) {
73
+ async extractExecutableName(bundlePath: string): Promise<string> {
75
74
  return await this.extractManifestProperty(bundlePath, 'CFBundleExecutable');
76
75
  }
77
76
 
78
77
  /**
79
78
  *
80
- * @param {string} bundlePath Full path to the .ipa or .app bundle
81
- * @returns {Promise<import('@appium/types').StringRecord>} The payload of the manifest plist
82
- * @throws {Error} If the given app is not a valid bundle
79
+ * @param bundlePath Full path to the .ipa or .app bundle
80
+ * @returns The payload of the manifest plist
81
+ * @throws If the given app is not a valid bundle
83
82
  */
84
- async put (bundlePath) {
83
+ async put(bundlePath: string): Promise<StringRecord> {
85
84
  return (await fs.stat(bundlePath)).isFile()
86
85
  ? await this._putIpa(bundlePath)
87
86
  : await this._putApp(bundlePath);
88
87
  }
89
88
 
90
89
  /**
91
- * @param {string} ipaPath Fill path to the .ipa bundle
92
- * @returns {Promise<import('@appium/types').StringRecord>} The payload of the manifest plist
90
+ * @param ipaPath Fill path to the .ipa bundle
91
+ * @returns The payload of the manifest plist
93
92
  */
94
- async _putIpa(ipaPath) {
95
- /** @type {import('@appium/types').StringRecord|undefined} */
96
- let manifestPayload;
97
- /** @type {Error|undefined} */
98
- let lastError;
93
+ private async _putIpa(ipaPath: string): Promise<StringRecord> {
94
+ let manifestPayload: StringRecord | undefined;
95
+ let lastError: Error | undefined;
99
96
  try {
100
97
  await zip.readEntries(ipaPath, async ({entry, extractEntryTo}) => {
101
98
  // For a future reference:
@@ -126,7 +123,7 @@ export class AppInfosCache {
126
123
  );
127
124
  MANIFEST_CACHE.set(hash, manifestPayload);
128
125
  }
129
- } catch (e) {
126
+ } catch (e: any) {
130
127
  this.log.debug(e.stack);
131
128
  lastError = e;
132
129
  } finally {
@@ -134,7 +131,7 @@ export class AppInfosCache {
134
131
  }
135
132
  return false;
136
133
  });
137
- } catch (e) {
134
+ } catch (e: any) {
138
135
  this.log.debug(e.stack);
139
136
  throw new Error(`Cannot find ${MANIFEST_FILE_NAME} in '${ipaPath}'. Is it a valid application bundle?`);
140
137
  }
@@ -149,14 +146,15 @@ export class AppInfosCache {
149
146
  }
150
147
 
151
148
  /**
152
- * @param {string} appPath Fill path to the .app bundle
153
- * @returns {Promise<import('@appium/types').StringRecord>} The payload of the manifest plist
149
+ * @param appPath Fill path to the .app bundle
150
+ * @returns The payload of the manifest plist
154
151
  */
155
- async _putApp(appPath) {
152
+ private async _putApp(appPath: string): Promise<StringRecord> {
156
153
  const manifestPath = path.join(appPath, MANIFEST_FILE_NAME);
157
154
  const hash = await fs.hash(manifestPath);
158
- if (MANIFEST_CACHE.has(hash)) {
159
- return /** @type {import('@appium/types').StringRecord} */ (MANIFEST_CACHE.get(hash));
155
+ const cached = MANIFEST_CACHE.get(hash);
156
+ if (cached) {
157
+ return cached;
160
158
  }
161
159
  const [payload, stat] = await B.all([
162
160
  this._readPlist(manifestPath, appPath),
@@ -172,14 +170,14 @@ export class AppInfosCache {
172
170
  }
173
171
 
174
172
  /**
175
- * @param {string} plistPath Full path to the plist
176
- * @param {string} bundlePath Full path to .ipa or .app bundle
177
- * @returns {Promise<any>} The payload of the plist file
173
+ * @param plistPath Full path to the plist
174
+ * @param bundlePath Full path to .ipa or .app bundle
175
+ * @returns The payload of the plist file
178
176
  */
179
- async _readPlist(plistPath, bundlePath) {
177
+ private async _readPlist(plistPath: string, bundlePath: string): Promise<any> {
180
178
  try {
181
179
  return await plist.parsePlistFile(plistPath);
182
- } catch (e) {
180
+ } catch (e: any) {
183
181
  this.log.debug(e.stack);
184
182
  throw new Error(`Cannot parse ${MANIFEST_FILE_NAME} of '${bundlePath}'. Is it a valid application bundle?`);
185
183
  }