appium-ios-simulator 8.0.11 → 8.0.13
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.
- package/CHANGELOG.md +12 -0
- package/build/lib/defaults-utils.d.ts +1 -0
- package/build/lib/defaults-utils.d.ts.map +1 -1
- package/build/lib/defaults-utils.js +15 -7
- package/build/lib/defaults-utils.js.map +1 -1
- package/build/lib/extensions/applications.d.ts.map +1 -1
- package/build/lib/extensions/applications.js +2 -2
- package/build/lib/extensions/applications.js.map +1 -1
- package/build/lib/extensions/biometric.d.ts.map +1 -1
- package/build/lib/extensions/biometric.js +9 -13
- package/build/lib/extensions/biometric.js.map +1 -1
- package/build/lib/extensions/geolocation.d.ts.map +1 -1
- package/build/lib/extensions/geolocation.js.map +1 -1
- package/build/lib/extensions/keychain.d.ts.map +1 -1
- package/build/lib/extensions/keychain.js +14 -11
- package/build/lib/extensions/keychain.js.map +1 -1
- package/build/lib/extensions/misc.d.ts.map +1 -1
- package/build/lib/extensions/misc.js +2 -5
- package/build/lib/extensions/misc.js.map +1 -1
- package/build/lib/extensions/permissions.d.ts.map +1 -1
- package/build/lib/extensions/permissions.js +19 -11
- package/build/lib/extensions/permissions.js.map +1 -1
- package/build/lib/extensions/safari.d.ts.map +1 -1
- package/build/lib/extensions/safari.js +1 -1
- package/build/lib/extensions/safari.js.map +1 -1
- package/build/lib/extensions/settings.d.ts +2 -2
- package/build/lib/extensions/settings.d.ts.map +1 -1
- package/build/lib/extensions/settings.js +31 -30
- package/build/lib/extensions/settings.js.map +1 -1
- package/build/lib/index.d.ts +5 -0
- package/build/lib/index.d.ts.map +1 -0
- package/build/{index.js → lib/index.js} +2 -3
- package/build/lib/index.js.map +1 -0
- package/build/lib/logger.js.map +1 -1
- package/build/lib/simulator-xcode-14.d.ts.map +1 -1
- package/build/lib/simulator-xcode-14.js +7 -8
- package/build/lib/simulator-xcode-14.js.map +1 -1
- package/build/lib/simulator-xcode-15.d.ts.map +1 -1
- package/build/lib/simulator-xcode-15.js +4 -2
- package/build/lib/simulator-xcode-15.js.map +1 -1
- package/build/lib/simulator.d.ts.map +1 -1
- package/build/lib/simulator.js +3 -3
- package/build/lib/simulator.js.map +1 -1
- package/build/lib/types.d.ts.map +1 -1
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +3 -3
- package/build/lib/utils.js.map +1 -1
- package/lib/defaults-utils.ts +32 -15
- package/lib/extensions/applications.ts +30 -24
- package/lib/extensions/biometric.ts +27 -21
- package/lib/extensions/geolocation.ts +6 -3
- package/lib/extensions/keychain.ts +22 -18
- package/lib/extensions/misc.ts +9 -12
- package/lib/extensions/permissions.ts +93 -52
- package/lib/extensions/safari.ts +61 -32
- package/lib/extensions/settings.ts +153 -81
- package/lib/index.ts +6 -0
- package/lib/logger.ts +1 -1
- package/lib/simulator-xcode-14.ts +65 -45
- package/lib/simulator-xcode-15.ts +7 -6
- package/lib/simulator.ts +13 -17
- package/lib/types.ts +14 -14
- package/lib/utils.ts +25 -18
- package/package.json +6 -6
- package/build/index.d.ts +0 -5
- package/build/index.d.ts.map +0 -1
- package/build/index.js.map +0 -1
- package/index.ts +0 -8
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import {
|
|
2
|
+
import {NSUserDefaults, generateDefaultsCommandArgs} from '../defaults-utils';
|
|
3
3
|
import B from 'bluebird';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import {exec} from 'teen_process';
|
|
6
6
|
import AsyncLock from 'async-lock';
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
9
|
-
|
|
7
|
+
import {fs} from '@appium/support';
|
|
8
|
+
import type {
|
|
9
|
+
CoreSimulator,
|
|
10
|
+
HasSettings,
|
|
11
|
+
DevicePreferences,
|
|
12
|
+
CommonPreferences,
|
|
13
|
+
RunOptions,
|
|
14
|
+
LocalizationOptions,
|
|
15
|
+
} from '../types';
|
|
16
|
+
import type {StringRecord} from '@appium/types';
|
|
10
17
|
|
|
11
18
|
type CoreSimulatorWithSettings = CoreSimulator & HasSettings;
|
|
12
19
|
|
|
@@ -14,7 +21,12 @@ type CoreSimulatorWithSettings = CoreSimulator & HasSettings;
|
|
|
14
21
|
// com.apple.locationd: translates system prompts for location
|
|
15
22
|
// com.apple.tccd: translates system prompts for camera, microphone, contact, photos and app tracking transparency
|
|
16
23
|
// com.apple.akd: translates `Sign in with your Apple ID` system prompt
|
|
17
|
-
const SERVICES_FOR_TRANSLATION = [
|
|
24
|
+
const SERVICES_FOR_TRANSLATION = [
|
|
25
|
+
'com.apple.SpringBoard',
|
|
26
|
+
'com.apple.locationd',
|
|
27
|
+
'com.apple.tccd',
|
|
28
|
+
'com.apple.akd',
|
|
29
|
+
] as const;
|
|
18
30
|
const GLOBAL_PREFS_PLIST = '.GlobalPreferences.plist';
|
|
19
31
|
const PREFERENCES_PLIST_GUARD = new AsyncLock();
|
|
20
32
|
const DOMAIN = Object.freeze({
|
|
@@ -27,9 +39,12 @@ const DOMAIN = Object.freeze({
|
|
|
27
39
|
*
|
|
28
40
|
* @param reduceMotion Whether to enable or disable the setting.
|
|
29
41
|
*/
|
|
30
|
-
export async function setReduceMotion(
|
|
42
|
+
export async function setReduceMotion(
|
|
43
|
+
this: CoreSimulatorWithSettings,
|
|
44
|
+
reduceMotion: boolean,
|
|
45
|
+
): Promise<boolean> {
|
|
31
46
|
return await this.updateSettings(DOMAIN.ACCESSIBILITY, {
|
|
32
|
-
ReduceMotionEnabled: Number(reduceMotion)
|
|
47
|
+
ReduceMotionEnabled: Number(reduceMotion),
|
|
33
48
|
});
|
|
34
49
|
}
|
|
35
50
|
|
|
@@ -40,10 +55,10 @@ export async function setReduceMotion(this: CoreSimulatorWithSettings, reduceMot
|
|
|
40
55
|
*/
|
|
41
56
|
export async function setReduceTransparency(
|
|
42
57
|
this: CoreSimulatorWithSettings,
|
|
43
|
-
reduceTransparency: boolean
|
|
58
|
+
reduceTransparency: boolean,
|
|
44
59
|
): Promise<boolean> {
|
|
45
60
|
return await this.updateSettings(DOMAIN.ACCESSIBILITY, {
|
|
46
|
-
EnhancedBackgroundContrastEnabled: Number(reduceTransparency)
|
|
61
|
+
EnhancedBackgroundContrastEnabled: Number(reduceTransparency),
|
|
47
62
|
});
|
|
48
63
|
}
|
|
49
64
|
|
|
@@ -51,11 +66,13 @@ export async function setReduceTransparency(
|
|
|
51
66
|
* Disable keyboard tutorial as 'com.apple.keyboard.preferences' domain via 'defaults' command.
|
|
52
67
|
* @returns Promise that resolves to true if settings were updated
|
|
53
68
|
*/
|
|
54
|
-
export async function disableKeyboardIntroduction(
|
|
69
|
+
export async function disableKeyboardIntroduction(
|
|
70
|
+
this: CoreSimulatorWithSettings,
|
|
71
|
+
): Promise<boolean> {
|
|
55
72
|
return await this.updateSettings(DOMAIN.KEYBOARD, {
|
|
56
73
|
// To disable 'DidShowContinuousPathIntroduction' for iOS 15+ simulators since changing the preference via WDA
|
|
57
74
|
// does not work on them. Lower than the versions also can have this preference, but nothing happen.
|
|
58
|
-
DidShowContinuousPathIntroduction: 1
|
|
75
|
+
DidShowContinuousPathIntroduction: 1,
|
|
59
76
|
});
|
|
60
77
|
}
|
|
61
78
|
|
|
@@ -71,16 +88,16 @@ export async function disableKeyboardIntroduction(this: CoreSimulatorWithSetting
|
|
|
71
88
|
export async function updateSettings(
|
|
72
89
|
this: CoreSimulatorWithSettings,
|
|
73
90
|
domain: string,
|
|
74
|
-
updates: StringRecord
|
|
91
|
+
updates: StringRecord,
|
|
75
92
|
): Promise<boolean> {
|
|
76
93
|
if (_.isEmpty(updates)) {
|
|
77
94
|
return false;
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
const argChunks = generateDefaultsCommandArgs(updates);
|
|
81
|
-
await B.all(
|
|
82
|
-
'defaults', 'write', domain, ...args
|
|
83
|
-
|
|
98
|
+
await B.all(
|
|
99
|
+
argChunks.map((args) => this.simctl.spawnProcess(['defaults', 'write', domain, ...args])),
|
|
100
|
+
);
|
|
84
101
|
return true;
|
|
85
102
|
}
|
|
86
103
|
|
|
@@ -119,8 +136,11 @@ export async function getAppearance(this: CoreSimulatorWithSettings): Promise<st
|
|
|
119
136
|
* Acceptable value is 'enabled' or 'disabled' with Xcode 16.2.
|
|
120
137
|
* @since Xcode SDK 15 (but lower xcode could have this command)
|
|
121
138
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
139
|
+
export async function setIncreaseContrast(
|
|
140
|
+
this: CoreSimulatorWithSettings,
|
|
141
|
+
value: string,
|
|
142
|
+
): Promise<void> {
|
|
143
|
+
void value;
|
|
124
144
|
throw new Error(`Xcode SDK '${this.xcodeVersion}' is too old to set content size`);
|
|
125
145
|
}
|
|
126
146
|
|
|
@@ -148,8 +168,11 @@ export async function getIncreaseContrast(this: CoreSimulatorWithSettings): Prom
|
|
|
148
168
|
* accessibility-extra-extra-extra-large with Xcode 16.2.
|
|
149
169
|
* @since Xcode SDK 15 (but lower xcode could have this command)
|
|
150
170
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
171
|
+
export async function setContentSize(
|
|
172
|
+
this: CoreSimulatorWithSettings,
|
|
173
|
+
value: string,
|
|
174
|
+
): Promise<void> {
|
|
175
|
+
void value;
|
|
153
176
|
throw new Error(`Xcode SDK '${this.xcodeVersion}' is too old to set content size`);
|
|
154
177
|
}
|
|
155
178
|
|
|
@@ -178,17 +201,17 @@ export async function getContentSize(this: CoreSimulatorWithSettings): Promise<s
|
|
|
178
201
|
*/
|
|
179
202
|
export async function configureLocalization(
|
|
180
203
|
this: CoreSimulatorWithSettings,
|
|
181
|
-
opts: LocalizationOptions = {}
|
|
204
|
+
opts: LocalizationOptions = {},
|
|
182
205
|
): Promise<boolean> {
|
|
183
206
|
if (_.isEmpty(opts)) {
|
|
184
207
|
return false;
|
|
185
208
|
}
|
|
186
209
|
|
|
187
|
-
const {
|
|
210
|
+
const {language, locale, keyboard} = opts;
|
|
188
211
|
const globalPrefs: Record<string, any> = {};
|
|
189
212
|
let keyboardId: string | null = null;
|
|
190
213
|
if (_.isPlainObject(keyboard) && keyboard) {
|
|
191
|
-
const {
|
|
214
|
+
const {name, layout, hardware} = keyboard;
|
|
192
215
|
if (!name) {
|
|
193
216
|
throw new Error(`The 'keyboard' field must have a valid name set`);
|
|
194
217
|
}
|
|
@@ -202,14 +225,14 @@ export async function configureLocalization(
|
|
|
202
225
|
globalPrefs.AppleKeyboards = [keyboardId];
|
|
203
226
|
}
|
|
204
227
|
if (_.isPlainObject(language) && language) {
|
|
205
|
-
const {
|
|
228
|
+
const {name} = language;
|
|
206
229
|
if (!name) {
|
|
207
230
|
throw new Error(`The 'language' field must have a valid name set`);
|
|
208
231
|
}
|
|
209
232
|
globalPrefs.AppleLanguages = [name];
|
|
210
233
|
}
|
|
211
234
|
if (_.isPlainObject(locale) && locale) {
|
|
212
|
-
const {
|
|
235
|
+
const {name, calendar} = locale;
|
|
213
236
|
if (!name) {
|
|
214
237
|
throw new Error(`The 'locale' field must have a valid name set`);
|
|
215
238
|
}
|
|
@@ -225,48 +248,64 @@ export async function configureLocalization(
|
|
|
225
248
|
|
|
226
249
|
let previousAppleLanguages: any = null;
|
|
227
250
|
if (globalPrefs.AppleLanguages) {
|
|
228
|
-
const absolutePrefsPath = path.join(
|
|
251
|
+
const absolutePrefsPath = path.join(
|
|
252
|
+
this.getDir(),
|
|
253
|
+
'Library',
|
|
254
|
+
'Preferences',
|
|
255
|
+
GLOBAL_PREFS_PLIST,
|
|
256
|
+
);
|
|
229
257
|
try {
|
|
230
258
|
const {stdout} = await exec('plutil', ['-convert', 'json', absolutePrefsPath, '-o', '-']);
|
|
231
259
|
previousAppleLanguages = JSON.parse(stdout).AppleLanguages;
|
|
232
260
|
} catch (e: any) {
|
|
233
|
-
this.log.debug(
|
|
261
|
+
this.log.debug(
|
|
262
|
+
`Cannot retrieve the current value of the 'AppleLanguages' preference: ${e.message}`,
|
|
263
|
+
);
|
|
234
264
|
}
|
|
235
265
|
}
|
|
236
266
|
|
|
237
267
|
const argChunks = generateDefaultsCommandArgs(globalPrefs, true);
|
|
238
|
-
await B.all(
|
|
239
|
-
|
|
240
|
-
|
|
268
|
+
await B.all(
|
|
269
|
+
argChunks.map((args) =>
|
|
270
|
+
this.simctl.spawnProcess(['defaults', 'write', GLOBAL_PREFS_PLIST, ...args]),
|
|
271
|
+
),
|
|
272
|
+
);
|
|
241
273
|
|
|
242
274
|
if (keyboard && keyboardId) {
|
|
243
|
-
const argChunks = generateDefaultsCommandArgs(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
275
|
+
const argChunks = generateDefaultsCommandArgs(
|
|
276
|
+
{
|
|
277
|
+
KeyboardsCurrentAndNext: [keyboardId],
|
|
278
|
+
KeyboardLastUsed: keyboardId,
|
|
279
|
+
KeyboardLastUsedForLanguage: {[keyboard.name]: keyboardId},
|
|
280
|
+
},
|
|
281
|
+
true,
|
|
282
|
+
);
|
|
283
|
+
await B.all(
|
|
284
|
+
argChunks.map((args) =>
|
|
285
|
+
this.simctl.spawnProcess(['defaults', 'write', 'com.apple.Preferences', ...args]),
|
|
286
|
+
),
|
|
287
|
+
);
|
|
251
288
|
}
|
|
252
289
|
|
|
253
290
|
if (globalPrefs.AppleLanguages) {
|
|
254
291
|
if (_.isEqual(previousAppleLanguages, globalPrefs.AppleLanguages)) {
|
|
255
292
|
this.log.info(
|
|
256
293
|
`The 'AppleLanguages' preference is already set to '${globalPrefs.AppleLanguages}'. ` +
|
|
257
|
-
|
|
294
|
+
`Skipping services reset`,
|
|
258
295
|
);
|
|
259
296
|
} else if (language?.skipSyncUiDialogTranslation) {
|
|
260
|
-
this.log.info(
|
|
297
|
+
this.log.info(
|
|
298
|
+
'Skipping services reset as requested. This might leave some system UI alerts untranslated',
|
|
299
|
+
);
|
|
261
300
|
} else {
|
|
262
301
|
this.log.info(
|
|
263
302
|
`Will restart the following services in order to sync UI dialogs translation: ` +
|
|
264
|
-
|
|
265
|
-
|
|
303
|
+
`${SERVICES_FOR_TRANSLATION}. This might have unexpected side effects, ` +
|
|
304
|
+
`see https://github.com/appium/appium/issues/19440 for more details`,
|
|
305
|
+
);
|
|
306
|
+
await B.all(
|
|
307
|
+
SERVICES_FOR_TRANSLATION.map((arg) => this.simctl.spawnProcess(['launchctl', 'stop', arg])),
|
|
266
308
|
);
|
|
267
|
-
await B.all(SERVICES_FOR_TRANSLATION.map((arg) => this.simctl.spawnProcess([
|
|
268
|
-
'launchctl', 'stop', arg
|
|
269
|
-
])));
|
|
270
309
|
}
|
|
271
310
|
}
|
|
272
311
|
|
|
@@ -279,9 +318,12 @@ export async function configureLocalization(
|
|
|
279
318
|
* @param isEnabled Whether to enable or disable the setting.
|
|
280
319
|
* @returns Promise that resolves to true if settings were updated
|
|
281
320
|
*/
|
|
282
|
-
export async function setAutoFillPasswords(
|
|
321
|
+
export async function setAutoFillPasswords(
|
|
322
|
+
this: CoreSimulatorWithSettings,
|
|
323
|
+
isEnabled: boolean,
|
|
324
|
+
): Promise<boolean> {
|
|
283
325
|
return await this.updateSettings('com.apple.WebUI', {
|
|
284
|
-
AutoFillPasswords: Number(isEnabled)
|
|
326
|
+
AutoFillPasswords: Number(isEnabled),
|
|
285
327
|
});
|
|
286
328
|
}
|
|
287
329
|
|
|
@@ -299,22 +341,31 @@ export async function setAutoFillPasswords(this: CoreSimulatorWithSettings, isEn
|
|
|
299
341
|
export async function updatePreferences(
|
|
300
342
|
this: CoreSimulatorWithSettings,
|
|
301
343
|
devicePrefs: DevicePreferences = {},
|
|
302
|
-
commonPrefs: CommonPreferences = {}
|
|
344
|
+
commonPrefs: CommonPreferences = {},
|
|
303
345
|
): Promise<boolean> {
|
|
304
346
|
if (!_.isEmpty(devicePrefs)) {
|
|
305
|
-
this.log.debug(
|
|
347
|
+
this.log.debug(
|
|
348
|
+
`Setting preferences of ${this.udid} Simulator to ${JSON.stringify(devicePrefs)}`,
|
|
349
|
+
);
|
|
306
350
|
}
|
|
307
351
|
if (!_.isEmpty(commonPrefs)) {
|
|
308
352
|
this.log.debug(`Setting common Simulator preferences to ${JSON.stringify(commonPrefs)}`);
|
|
309
353
|
}
|
|
310
354
|
const homeFolderPath = process.env.HOME;
|
|
311
355
|
if (!homeFolderPath) {
|
|
312
|
-
this.log.warn(
|
|
313
|
-
`
|
|
356
|
+
this.log.warn(
|
|
357
|
+
`Cannot get the path to HOME folder from the process environment. ` +
|
|
358
|
+
`Ignoring Simulator preferences update.`,
|
|
359
|
+
);
|
|
314
360
|
return false;
|
|
315
361
|
}
|
|
316
362
|
verifyDevicePreferences.bind(this)(devicePrefs);
|
|
317
|
-
const plistPath = path.resolve(
|
|
363
|
+
const plistPath = path.resolve(
|
|
364
|
+
homeFolderPath,
|
|
365
|
+
'Library',
|
|
366
|
+
'Preferences',
|
|
367
|
+
'com.apple.iphonesimulator.plist',
|
|
368
|
+
);
|
|
318
369
|
return await PREFERENCES_PLIST_GUARD.acquire(this.constructor.name, async () => {
|
|
319
370
|
const defaults = new NSUserDefaults(plistPath);
|
|
320
371
|
const prefsToUpdate = _.clone(commonPrefs);
|
|
@@ -324,24 +375,30 @@ export async function updatePreferences(
|
|
|
324
375
|
const udidKey = this.udid.toUpperCase();
|
|
325
376
|
if (await fs.exists(plistPath)) {
|
|
326
377
|
const currentPlistContent = await defaults.asJson();
|
|
327
|
-
if (
|
|
328
|
-
|
|
378
|
+
if (
|
|
379
|
+
_.isPlainObject(currentPlistContent.DevicePreferences) &&
|
|
380
|
+
_.isPlainObject(currentPlistContent.DevicePreferences[udidKey])
|
|
381
|
+
) {
|
|
329
382
|
existingDevicePrefs = currentPlistContent.DevicePreferences[udidKey];
|
|
330
383
|
}
|
|
331
384
|
}
|
|
332
385
|
Object.assign(prefsToUpdate, {
|
|
333
386
|
DevicePreferences: {
|
|
334
|
-
[udidKey]: Object.assign({}, existingDevicePrefs || {}, devicePrefs)
|
|
335
|
-
}
|
|
387
|
+
[udidKey]: Object.assign({}, existingDevicePrefs || {}, devicePrefs),
|
|
388
|
+
},
|
|
336
389
|
});
|
|
337
390
|
}
|
|
338
391
|
await defaults.update(prefsToUpdate);
|
|
339
|
-
this.log.debug(
|
|
340
|
-
|
|
392
|
+
this.log.debug(
|
|
393
|
+
`Updated ${this.udid} Simulator preferences at '${plistPath}' with ` +
|
|
394
|
+
JSON.stringify(prefsToUpdate),
|
|
395
|
+
);
|
|
341
396
|
return true;
|
|
342
397
|
} catch (e: any) {
|
|
343
|
-
this.log.warn(
|
|
344
|
-
`
|
|
398
|
+
this.log.warn(
|
|
399
|
+
`Cannot update ${this.udid} Simulator preferences at '${plistPath}'. ` +
|
|
400
|
+
`Try to delete the file manually in order to reset it. Original error: ${e.message}`,
|
|
401
|
+
);
|
|
345
402
|
return false;
|
|
346
403
|
}
|
|
347
404
|
});
|
|
@@ -357,14 +414,9 @@ export async function updatePreferences(
|
|
|
357
414
|
*/
|
|
358
415
|
export function compileSimulatorPreferences(
|
|
359
416
|
this: CoreSimulatorWithSettings,
|
|
360
|
-
opts: RunOptions = {}
|
|
417
|
+
opts: RunOptions = {},
|
|
361
418
|
): [DevicePreferences, CommonPreferences & Record<string, any>] {
|
|
362
|
-
const {
|
|
363
|
-
connectHardwareKeyboard,
|
|
364
|
-
tracePointer,
|
|
365
|
-
pasteboardAutomaticSync,
|
|
366
|
-
scaleFactor,
|
|
367
|
-
} = opts;
|
|
419
|
+
const {connectHardwareKeyboard, tracePointer, pasteboardAutomaticSync, scaleFactor} = opts;
|
|
368
420
|
const commonPreferences: CommonPreferences & Record<string, any> = {
|
|
369
421
|
// This option is necessary to make the Simulator window follow
|
|
370
422
|
// the actual XCUIDevice orientation
|
|
@@ -374,7 +426,9 @@ export function compileSimulatorPreferences(
|
|
|
374
426
|
DetachOnWindowClose: false,
|
|
375
427
|
AttachBootedOnStart: true,
|
|
376
428
|
};
|
|
377
|
-
const devicePreferences: DevicePreferences = opts.devicePreferences
|
|
429
|
+
const devicePreferences: DevicePreferences = opts.devicePreferences
|
|
430
|
+
? _.cloneDeep(opts.devicePreferences)
|
|
431
|
+
: {};
|
|
378
432
|
if (scaleFactor) {
|
|
379
433
|
devicePreferences.SimulatorWindowLastScale = parseFloat(scaleFactor);
|
|
380
434
|
}
|
|
@@ -401,7 +455,9 @@ export function compileSimulatorPreferences(
|
|
|
401
455
|
// Do not add -PasteboardAutomaticSync
|
|
402
456
|
break;
|
|
403
457
|
default:
|
|
404
|
-
this.log.info(
|
|
458
|
+
this.log.info(
|
|
459
|
+
`['on', 'off' or 'system'] are available as the pasteboard automatic sync option. Defaulting to 'off'`,
|
|
460
|
+
);
|
|
405
461
|
commonPreferences.PasteboardAutomaticSync = false;
|
|
406
462
|
}
|
|
407
463
|
return [devicePreferences, commonPreferences];
|
|
@@ -415,40 +471,56 @@ export function compileSimulatorPreferences(
|
|
|
415
471
|
* @throws {Error} If any of the given preference values does not match the expected
|
|
416
472
|
* format.
|
|
417
473
|
*/
|
|
418
|
-
export function verifyDevicePreferences(
|
|
474
|
+
export function verifyDevicePreferences(
|
|
475
|
+
this: CoreSimulatorWithSettings,
|
|
476
|
+
prefs: DevicePreferences = {},
|
|
477
|
+
): void {
|
|
419
478
|
if (_.isEmpty(prefs)) {
|
|
420
479
|
return;
|
|
421
480
|
}
|
|
422
481
|
|
|
423
482
|
if (!_.isUndefined(prefs.SimulatorWindowLastScale)) {
|
|
424
483
|
if (!_.isNumber(prefs.SimulatorWindowLastScale) || prefs.SimulatorWindowLastScale <= 0) {
|
|
425
|
-
throw this.log.errorWithException(
|
|
426
|
-
`
|
|
484
|
+
throw this.log.errorWithException(
|
|
485
|
+
`SimulatorWindowLastScale is expected to be a positive float value. ` +
|
|
486
|
+
`'${prefs.SimulatorWindowLastScale}' is assigned instead.`,
|
|
487
|
+
);
|
|
427
488
|
}
|
|
428
489
|
}
|
|
429
490
|
|
|
430
491
|
if (!_.isUndefined(prefs.SimulatorWindowCenter)) {
|
|
431
492
|
// https://regex101.com/r/2ZXOij/2
|
|
432
493
|
const verificationPattern = /{-?\d+(\.\d+)?,-?\d+(\.\d+)?}/;
|
|
433
|
-
if (
|
|
434
|
-
|
|
435
|
-
|
|
494
|
+
if (
|
|
495
|
+
!_.isString(prefs.SimulatorWindowCenter) ||
|
|
496
|
+
!verificationPattern.test(prefs.SimulatorWindowCenter)
|
|
497
|
+
) {
|
|
498
|
+
throw this.log.errorWithException(
|
|
499
|
+
`SimulatorWindowCenter is expected to match "{floatXPosition,floatYPosition}" format (without spaces). ` +
|
|
500
|
+
`'${prefs.SimulatorWindowCenter}' is assigned instead.`,
|
|
501
|
+
);
|
|
436
502
|
}
|
|
437
503
|
}
|
|
438
504
|
|
|
439
505
|
if (!_.isUndefined(prefs.SimulatorWindowOrientation)) {
|
|
440
506
|
const acceptableValues = ['Portrait', 'LandscapeLeft', 'PortraitUpsideDown', 'LandscapeRight'];
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
507
|
+
if (
|
|
508
|
+
!prefs.SimulatorWindowOrientation ||
|
|
509
|
+
!acceptableValues.includes(prefs.SimulatorWindowOrientation)
|
|
510
|
+
) {
|
|
511
|
+
throw this.log.errorWithException(
|
|
512
|
+
`SimulatorWindowOrientation is expected to be one of ${acceptableValues}. ` +
|
|
513
|
+
`'${prefs.SimulatorWindowOrientation}' is assigned instead.`,
|
|
514
|
+
);
|
|
444
515
|
}
|
|
445
516
|
}
|
|
446
517
|
|
|
447
518
|
if (!_.isUndefined(prefs.SimulatorWindowRotationAngle)) {
|
|
448
519
|
if (!_.isNumber(prefs.SimulatorWindowRotationAngle)) {
|
|
449
|
-
throw this.log.errorWithException(
|
|
450
|
-
`
|
|
520
|
+
throw this.log.errorWithException(
|
|
521
|
+
`SimulatorWindowRotationAngle is expected to be a valid number. ` +
|
|
522
|
+
`'${prefs.SimulatorWindowRotationAngle}' is assigned instead.`,
|
|
523
|
+
);
|
|
451
524
|
}
|
|
452
525
|
}
|
|
453
526
|
}
|
|
454
|
-
|
package/lib/index.ts
ADDED
package/lib/logger.ts
CHANGED