@expo/cli 0.18.2 → 0.18.4

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 (36) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/install/installAsync.js +2 -2
  3. package/build/src/install/installAsync.js.map +1 -1
  4. package/build/src/run/ios/XcodeBuild.types.js.map +1 -1
  5. package/build/src/run/ios/appleDevice/AppleDevice.js +103 -31
  6. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  7. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +14 -0
  8. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -1
  9. package/build/src/run/ios/launchApp.js +12 -7
  10. package/build/src/run/ios/launchApp.js.map +1 -1
  11. package/build/src/run/ios/options/appleDestinations.js +124 -0
  12. package/build/src/run/ios/options/appleDestinations.js.map +1 -0
  13. package/build/src/run/ios/options/promptDevice.js +1 -1
  14. package/build/src/run/ios/options/promptDevice.js.map +1 -1
  15. package/build/src/run/ios/options/resolveDevice.js +49 -16
  16. package/build/src/run/ios/options/resolveDevice.js.map +1 -1
  17. package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -1
  18. package/build/src/run/ios/options/resolveOptions.js +6 -3
  19. package/build/src/run/ios/options/resolveOptions.js.map +1 -1
  20. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  21. package/build/src/start/platforms/ios/devicectl.js +371 -0
  22. package/build/src/start/platforms/ios/devicectl.js.map +1 -0
  23. package/build/src/start/platforms/ios/promptAppleDevice.js.map +1 -1
  24. package/build/src/start/platforms/ios/simctl.js.map +1 -1
  25. package/build/src/start/server/metro/debugging/AtlasPrerequisite.js +47 -0
  26. package/build/src/start/server/metro/debugging/AtlasPrerequisite.js.map +1 -0
  27. package/build/src/start/server/metro/debugging/attachAtlas.js +69 -0
  28. package/build/src/start/server/metro/debugging/attachAtlas.js.map +1 -0
  29. package/build/src/start/server/metro/instantiateMetro.js +11 -0
  30. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  31. package/build/src/start/server/metro/router.js +4 -2
  32. package/build/src/start/server/metro/router.js.map +1 -1
  33. package/build/src/utils/env.js +3 -0
  34. package/build/src/utils/env.js.map +1 -1
  35. package/build/src/utils/telemetry/getContext.js +1 -1
  36. package/package.json +4 -3
@@ -0,0 +1,371 @@
1
+ /**
2
+ * Copyright © 2024 650 Industries.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ function _export(target, all) {
11
+ for(var name in all)Object.defineProperty(target, name, {
12
+ enumerable: true,
13
+ get: all[name]
14
+ });
15
+ }
16
+ _export(exports, {
17
+ devicectlAsync: ()=>devicectlAsync,
18
+ getConnectedAppleDevicesAsync: ()=>getConnectedAppleDevicesAsync,
19
+ launchBinaryOnMacAsync: ()=>launchBinaryOnMacAsync,
20
+ launchAppWithDeviceCtl: ()=>launchAppWithDeviceCtl,
21
+ hasDevicectlEverBeenInstalled: ()=>hasDevicectlEverBeenInstalled,
22
+ installAndLaunchAppAsync: ()=>installAndLaunchAppAsync
23
+ });
24
+ function _getUserState() {
25
+ const data = require("@expo/config/build/getUserState");
26
+ _getUserState = function() {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ function _jsonFile() {
32
+ const data = /*#__PURE__*/ _interopRequireDefault(require("@expo/json-file"));
33
+ _jsonFile = function() {
34
+ return data;
35
+ };
36
+ return data;
37
+ }
38
+ function _spawnAsync() {
39
+ const data = /*#__PURE__*/ _interopRequireDefault(require("@expo/spawn-async"));
40
+ _spawnAsync = function() {
41
+ return data;
42
+ };
43
+ return data;
44
+ }
45
+ function _chalk() {
46
+ const data = /*#__PURE__*/ _interopRequireDefault(require("chalk"));
47
+ _chalk = function() {
48
+ return data;
49
+ };
50
+ return data;
51
+ }
52
+ function _childProcess() {
53
+ const data = require("child_process");
54
+ _childProcess = function() {
55
+ return data;
56
+ };
57
+ return data;
58
+ }
59
+ function _fs() {
60
+ const data = /*#__PURE__*/ _interopRequireDefault(require("fs"));
61
+ _fs = function() {
62
+ return data;
63
+ };
64
+ return data;
65
+ }
66
+ function _nodeAssert() {
67
+ const data = /*#__PURE__*/ _interopRequireDefault(require("node:assert"));
68
+ _nodeAssert = function() {
69
+ return data;
70
+ };
71
+ return data;
72
+ }
73
+ function _os() {
74
+ const data = require("os");
75
+ _os = function() {
76
+ return data;
77
+ };
78
+ return data;
79
+ }
80
+ function _path() {
81
+ const data = /*#__PURE__*/ _interopRequireDefault(require("path"));
82
+ _path = function() {
83
+ return data;
84
+ };
85
+ return data;
86
+ }
87
+ function _tempy() {
88
+ const data = /*#__PURE__*/ _interopRequireDefault(require("tempy"));
89
+ _tempy = function() {
90
+ return data;
91
+ };
92
+ return data;
93
+ }
94
+ const _xcrun = require("./xcrun");
95
+ const _log = /*#__PURE__*/ _interopRequireWildcard(require("../../../log"));
96
+ const _errors = require("../../../utils/errors");
97
+ const _exit = require("../../../utils/exit");
98
+ const _interactive = require("../../../utils/interactive");
99
+ const _ora = require("../../../utils/ora");
100
+ const _prompts = require("../../../utils/prompts");
101
+ function _interopRequireDefault(obj) {
102
+ return obj && obj.__esModule ? obj : {
103
+ default: obj
104
+ };
105
+ }
106
+ function _getRequireWildcardCache(nodeInterop) {
107
+ if (typeof WeakMap !== "function") return null;
108
+ var cacheBabelInterop = new WeakMap();
109
+ var cacheNodeInterop = new WeakMap();
110
+ return (_getRequireWildcardCache = function(nodeInterop) {
111
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
112
+ })(nodeInterop);
113
+ }
114
+ function _interopRequireWildcard(obj, nodeInterop) {
115
+ if (!nodeInterop && obj && obj.__esModule) {
116
+ return obj;
117
+ }
118
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
119
+ return {
120
+ default: obj
121
+ };
122
+ }
123
+ var cache = _getRequireWildcardCache(nodeInterop);
124
+ if (cache && cache.has(obj)) {
125
+ return cache.get(obj);
126
+ }
127
+ var newObj = {};
128
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
129
+ for(var key in obj){
130
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
131
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
132
+ if (desc && (desc.get || desc.set)) {
133
+ Object.defineProperty(newObj, key, desc);
134
+ } else {
135
+ newObj[key] = obj[key];
136
+ }
137
+ }
138
+ }
139
+ newObj.default = obj;
140
+ if (cache) {
141
+ cache.set(obj, newObj);
142
+ }
143
+ return newObj;
144
+ }
145
+ const DEVICE_CTL_EXISTS_PATH = _path().default.join((0, _getUserState().getExpoHomeDirectory)(), "devicectl-exists");
146
+ const debug = require("debug")("expo:devicectl");
147
+ async function devicectlAsync(args, options) {
148
+ try {
149
+ return await (0, _xcrun.xcrunAsync)([
150
+ "devicectl",
151
+ ...args
152
+ ], options);
153
+ } catch (error) {
154
+ if (error instanceof _errors.CommandError) {
155
+ throw error;
156
+ }
157
+ if ("stderr" in error) {
158
+ const errorCodes = getDeviceCtlErrorCodes(error.stderr);
159
+ if (errorCodes.includes("Locked")) {
160
+ throw new _errors.CommandError("APPLE_DEVICE_LOCKED", "Device is locked, unlock and try again.");
161
+ }
162
+ }
163
+ throw error;
164
+ }
165
+ }
166
+ async function getConnectedAppleDevicesAsync() {
167
+ var ref, ref1;
168
+ if (!hasDevicectlEverBeenInstalled()) {
169
+ debug("devicectl not found, skipping remote Apple devices.");
170
+ return [];
171
+ }
172
+ const tmpPath = _tempy().default.file();
173
+ const devices = await devicectlAsync([
174
+ "list",
175
+ "devices",
176
+ "--json-output",
177
+ tmpPath,
178
+ // Give two seconds before timing out: between 5 and 9223372036854775807
179
+ "--timeout",
180
+ "5",
181
+ ]);
182
+ debug(devices.stdout);
183
+ const devicesJson = await _jsonFile().default.readAsync(tmpPath);
184
+ if (((ref = devicesJson) == null ? void 0 : (ref1 = ref.info) == null ? void 0 : ref1.jsonVersion) !== 2) {
185
+ _log.warn("Unexpected devicectl JSON version output from devicectl. Connecting to physical Apple devices may not work as expected.");
186
+ }
187
+ assertDevicesJson(devicesJson);
188
+ return devicesJson.result.devices;
189
+ }
190
+ function assertDevicesJson(results) {
191
+ var ref;
192
+ (0, _nodeAssert().default)(results != null && "result" in results && Array.isArray(results == null ? void 0 : (ref = results.result) == null ? void 0 : ref.devices), "Malformed JSON output from devicectl: " + JSON.stringify(results, null, 2));
193
+ }
194
+ async function launchBinaryOnMacAsync(bundleId, appBinaryPath) {
195
+ const args = [
196
+ "-b",
197
+ bundleId,
198
+ appBinaryPath
199
+ ];
200
+ try {
201
+ await (0, _spawnAsync().default)("open", args);
202
+ } catch (error) {
203
+ if ("code" in error) {
204
+ if (error.code === 1) {
205
+ throw new _errors.CommandError("MACOS_LAUNCH", "Failed to launch the compatible binary on macOS: open " + args.join(" ") + "\n\n" + error.message);
206
+ }
207
+ }
208
+ throw error;
209
+ }
210
+ }
211
+ async function installAppWithDeviceCtlAsync(uuid, bundleIdOrAppPath, onProgress) {
212
+ // 𝝠 xcrun devicectl device install app --device 00001110-001111110110101A /Users/evanbacon/Library/Developer/Xcode/DerivedData/Router-hgbqaxzhrhkiftfweydvhgttadvn/Build/Products/Debug-iphoneos/Router.app --verbose
213
+ return new Promise((resolve, reject)=>{
214
+ const args = [
215
+ "devicectl",
216
+ "device",
217
+ "install",
218
+ "app",
219
+ "--device",
220
+ uuid,
221
+ bundleIdOrAppPath,
222
+ ];
223
+ const childProcess = (0, _childProcess().spawn)("xcrun", args);
224
+ debug("xcrun " + args.join(" "));
225
+ let currentProgress = 0;
226
+ let hasStarted = false;
227
+ function updateProgress(progress) {
228
+ hasStarted = true;
229
+ if (progress <= currentProgress) {
230
+ return;
231
+ }
232
+ currentProgress = progress;
233
+ onProgress({
234
+ progress,
235
+ isComplete: progress === 100,
236
+ status: "Installing"
237
+ });
238
+ }
239
+ childProcess.stdout.on("data", (data)=>{
240
+ // Sometimes more than one chunk comes at a time, here we split by system newline,
241
+ // then trim and filter.
242
+ const strings = data.toString().split(_os().EOL).map((value)=>value.trim());
243
+ strings.forEach((str)=>{
244
+ // Match the progress percentage:
245
+ // - '34%... 35%...' -> 34
246
+ // - '31%...' -> 31
247
+ // - 'Complete!' -> 100
248
+ const match = str.match(/(\d+)%\.\.\./);
249
+ if (match) {
250
+ updateProgress(parseInt(match[1], 10));
251
+ } else if (hasStarted) {
252
+ updateProgress(100);
253
+ }
254
+ });
255
+ debug("[stdout]:", strings);
256
+ });
257
+ childProcess.on("close", (code)=>{
258
+ debug("[close]: " + code);
259
+ if (code === 0) {
260
+ resolve();
261
+ } else {
262
+ const stderr = childProcess.stderr.read();
263
+ const err = new Error(stderr);
264
+ err.code = code;
265
+ detach(err);
266
+ }
267
+ });
268
+ const detach = async (err)=>{
269
+ off == null ? void 0 : off();
270
+ if (childProcess) {
271
+ return new Promise((resolve)=>{
272
+ childProcess == null ? void 0 : childProcess.on("close", resolve);
273
+ childProcess == null ? void 0 : childProcess.kill();
274
+ // childProcess = null;
275
+ reject(err != null ? err : new _errors.CommandError("detached"));
276
+ });
277
+ }
278
+ };
279
+ const off = (0, _exit.installExitHooks)(()=>detach());
280
+ });
281
+ }
282
+ async function launchAppWithDeviceCtl(deviceId, bundleId) {
283
+ await devicectlAsync([
284
+ "device",
285
+ "process",
286
+ "launch",
287
+ "--device",
288
+ deviceId,
289
+ bundleId
290
+ ]);
291
+ }
292
+ /** Find all error codes from the output log */ function getDeviceCtlErrorCodes(log) {
293
+ return [
294
+ ...log.matchAll(/BSErrorCodeDescription\s+=\s+(.*)$/gim)
295
+ ].map(([_line, code])=>code);
296
+ }
297
+ let hasEverBeenInstalled;
298
+ function hasDevicectlEverBeenInstalled() {
299
+ if (hasEverBeenInstalled) return hasEverBeenInstalled;
300
+ // It doesn't appear possible for devicectl to ever be uninstalled. We can just check once and store this result forever
301
+ // to prevent cold boots of devicectl from slowing down all invocations of `expo run ios`
302
+ if (_fs().default.existsSync(DEVICE_CTL_EXISTS_PATH)) {
303
+ hasEverBeenInstalled = true;
304
+ return true;
305
+ }
306
+ const isInstalled = isDevicectlInstalled();
307
+ if (isInstalled) {
308
+ _fs().default.writeFileSync(DEVICE_CTL_EXISTS_PATH, "1");
309
+ }
310
+ hasEverBeenInstalled = isInstalled;
311
+ return isInstalled;
312
+ }
313
+ function isDevicectlInstalled() {
314
+ try {
315
+ (0, _childProcess().execSync)("xcrun devicectl --version", {
316
+ stdio: "ignore"
317
+ });
318
+ return true;
319
+ } catch {
320
+ return false;
321
+ }
322
+ }
323
+ async function installAndLaunchAppAsync(props) {
324
+ debug("Running on device:", props);
325
+ const { bundle , bundleIdentifier , udid , deviceName } = props;
326
+ let indicator;
327
+ try {
328
+ if (!indicator) {
329
+ indicator = (0, _ora.ora)(`Connecting to: ${props.deviceName}`).start();
330
+ }
331
+ await installAppWithDeviceCtlAsync(udid, bundle, ({ status , isComplete , progress })=>{
332
+ if (!indicator) {
333
+ indicator = (0, _ora.ora)(status).start();
334
+ }
335
+ indicator.text = `${_chalk().default.bold(status)} ${progress}%`;
336
+ if (isComplete) {
337
+ indicator.succeed();
338
+ }
339
+ });
340
+ } catch (error) {
341
+ if (indicator) {
342
+ indicator.fail();
343
+ }
344
+ throw error;
345
+ }
346
+ async function launchAppOptionally() {
347
+ try {
348
+ await launchAppWithDeviceCtl(udid, bundleIdentifier);
349
+ } catch (error) {
350
+ if (indicator) {
351
+ indicator.fail();
352
+ }
353
+ if (error.code === "APPLE_DEVICE_LOCKED") {
354
+ var ref;
355
+ // Get the app name from the binary path.
356
+ const appName = (ref = _path().default.basename(bundle).split(".")[0]) != null ? ref : "app";
357
+ if ((0, _interactive.isInteractive)() && await (0, _prompts.confirmAsync)({
358
+ message: `Cannot launch ${appName} because the device is locked. Unlock ${deviceName} to continue...`,
359
+ initial: true
360
+ })) {
361
+ return launchAppOptionally();
362
+ }
363
+ throw new _errors.CommandError(`Cannot launch ${appName} on ${deviceName} because the device is locked.`);
364
+ }
365
+ throw error;
366
+ }
367
+ }
368
+ await launchAppOptionally();
369
+ }
370
+
371
+ //# sourceMappingURL=devicectl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/platforms/ios/devicectl.ts"],"sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { getExpoHomeDirectory } from '@expo/config/build/getUserState';\nimport JsonFile from '@expo/json-file';\nimport spawnAsync, { SpawnOptions, SpawnResult } from '@expo/spawn-async';\nimport chalk from 'chalk';\nimport { spawn, execSync } from 'child_process';\nimport fs from 'fs';\nimport assert from 'node:assert';\nimport { Ora } from 'ora';\nimport { EOL } from 'os';\nimport path from 'path';\nimport tempy from 'tempy';\n\nimport { xcrunAsync } from './xcrun';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { installExitHooks } from '../../../utils/exit';\nimport { isInteractive } from '../../../utils/interactive';\nimport { ora } from '../../../utils/ora';\nimport { confirmAsync } from '../../../utils/prompts';\n\nconst DEVICE_CTL_EXISTS_PATH = path.join(getExpoHomeDirectory(), 'devicectl-exists');\n\nconst debug = require('debug')('expo:devicectl') as typeof console.log;\n\n// eslint-disable-next-line @typescript-eslint/ban-types\ntype AnyEnum<T extends string = string> = T | (string & {});\n\ntype DeviceCtlDevice = {\n capabilities: DeviceCtlDeviceCapability[];\n connectionProperties: DeviceCtlConnectionProperties;\n deviceProperties: DeviceCtlDeviceProperties;\n hardwareProperties: DeviceCtlHardwareProperties;\n /** \"A1A1AAA1-0011-1AA1-11A1-10A1111AA11A\" */\n identifier: string;\n visibilityClass: AnyEnum<'default'>;\n};\n\ntype DeviceCtlHardwareProperties = {\n cpuType: DeviceCtlCpuType;\n deviceType: AnyEnum<'iPhone'>;\n /** 1114404411111111 */\n ecid: number;\n /** \"D74AP\" */\n hardwareModel: string;\n /** 512000000000 */\n internalStorageCapacity: number;\n /** true */\n isProductionFused: boolean;\n /** \"iPhone 14 Pro Max\" */\n marketingName: string;\n /** \"iOS\" */\n platform: AnyEnum<'iOS' | 'xrOS'>;\n /** \"iPhone15,3\" */\n productType: AnyEnum<'iPhone13,4' | 'iPhone15,3'>;\n reality: AnyEnum<'physical'>;\n /** \"X2X1CC1XXX\" */\n serialNumber: string;\n supportedCPUTypes: DeviceCtlCpuType[];\n /** [1] */\n supportedDeviceFamilies: number[];\n thinningProductType: AnyEnum<'iPhone15,3'>;\n /** \"00001110-001111110110101A\" */\n udid: string;\n};\n\ntype DeviceCtlDeviceProperties = {\n /** true */\n bootedFromSnapshot: boolean;\n /** \"com.apple.os.update-AD0CF111ACFF11A11111A76A3D1262AE42A3F56F305AF5AE1135393A7A14A7D1\" */\n bootedSnapshotName: string;\n /** false */\n ddiServicesAvailable: boolean;\n\n developerModeStatus: AnyEnum<'enabled'>;\n /** false */\n hasInternalOSBuild: boolean;\n /** \"Evan's phone\" */\n name: string;\n /** \"21E236\" */\n osBuildUpdate: string;\n /** \"17.4.1\" */\n osVersionNumber: string;\n /** false */\n rootFileSystemIsWritable: boolean;\n};\n\ntype DeviceCtlDeviceCapability =\n | {\n name: AnyEnum;\n featureIdentifier: AnyEnum;\n }\n | {\n featureIdentifier: 'com.apple.coredevice.feature.connectdevice';\n name: 'Connect to Device';\n }\n | {\n featureIdentifier: 'com.apple.coredevice.feature.unpairdevice';\n name: 'Unpair Device';\n }\n | {\n featureIdentifier: 'com.apple.coredevice.feature.acquireusageassertion';\n name: 'Acquire Usage Assertion';\n };\n\ntype DeviceCtlConnectionProperties = {\n authenticationType: AnyEnum<'manualPairing'>;\n isMobileDeviceOnly: boolean;\n /** \"2024-04-20T22:50:04.244Z\" */\n lastConnectionDate: string;\n pairingState: AnyEnum<'paired'>;\n /** [\"00001111-001111110110101A.coredevice.local\", \"A1A1AAA1-0011-1AA1-11A1-10A1111AA11A.coredevice.local\"] */\n potentialHostnames: string[];\n transportType: AnyEnum<'localNetwork' | 'wired'>;\n tunnelState: AnyEnum<'disconnected'>;\n tunnelTransportProtocol: AnyEnum<'tcp'>;\n};\n\ntype DeviceCtlCpuType = {\n name: AnyEnum<'arm64e' | 'arm64' | 'arm64_32'>;\n subType: number;\n /** 16777228 */\n type: number;\n};\n\n/** Run a `devicectl` command. */\nexport async function devicectlAsync(\n args: (string | undefined)[],\n options?: SpawnOptions\n): Promise<SpawnResult> {\n try {\n return await xcrunAsync(['devicectl', ...args], options);\n } catch (error: any) {\n if (error instanceof CommandError) {\n throw error;\n }\n if ('stderr' in error) {\n const errorCodes = getDeviceCtlErrorCodes(error.stderr);\n if (errorCodes.includes('Locked')) {\n throw new CommandError('APPLE_DEVICE_LOCKED', 'Device is locked, unlock and try again.');\n }\n }\n throw error;\n }\n}\n\nexport async function getConnectedAppleDevicesAsync() {\n if (!hasDevicectlEverBeenInstalled()) {\n debug('devicectl not found, skipping remote Apple devices.');\n return [];\n }\n\n const tmpPath = tempy.file();\n const devices = await devicectlAsync([\n 'list',\n 'devices',\n '--json-output',\n tmpPath,\n // Give two seconds before timing out: between 5 and 9223372036854775807\n '--timeout',\n '5',\n ]);\n debug(devices.stdout);\n const devicesJson = await JsonFile.readAsync(tmpPath);\n\n if ((devicesJson as any)?.info?.jsonVersion !== 2) {\n Log.warn(\n 'Unexpected devicectl JSON version output from devicectl. Connecting to physical Apple devices may not work as expected.'\n );\n }\n\n assertDevicesJson(devicesJson);\n\n return devicesJson.result.devices as DeviceCtlDevice[];\n}\n\nfunction assertDevicesJson(\n results: any\n): asserts results is { result: { devices: DeviceCtlDevice[] } } {\n assert(\n results != null && 'result' in results && Array.isArray(results?.result?.devices),\n 'Malformed JSON output from devicectl: ' + JSON.stringify(results, null, 2)\n );\n}\n\nexport async function launchBinaryOnMacAsync(\n bundleId: string,\n appBinaryPath: string\n): Promise<void> {\n const args = ['-b', bundleId, appBinaryPath];\n try {\n await spawnAsync('open', args);\n } catch (error: any) {\n if ('code' in error) {\n if (error.code === 1) {\n throw new CommandError(\n 'MACOS_LAUNCH',\n 'Failed to launch the compatible binary on macOS: open ' +\n args.join(' ') +\n '\\n\\n' +\n error.message\n );\n }\n }\n throw error;\n }\n}\n\nasync function installAppWithDeviceCtlAsync(\n uuid: string,\n bundleIdOrAppPath: string,\n onProgress: (event: { status: string; isComplete: boolean; progress: number }) => void\n): Promise<void> {\n // 𝝠 xcrun devicectl device install app --device 00001110-001111110110101A /Users/evanbacon/Library/Developer/Xcode/DerivedData/Router-hgbqaxzhrhkiftfweydvhgttadvn/Build/Products/Debug-iphoneos/Router.app --verbose\n return new Promise((resolve, reject) => {\n const args: string[] = [\n 'devicectl',\n 'device',\n 'install',\n 'app',\n '--device',\n uuid,\n bundleIdOrAppPath,\n ];\n const childProcess = spawn('xcrun', args);\n debug('xcrun ' + args.join(' '));\n\n let currentProgress = 0;\n let hasStarted = false;\n\n function updateProgress(progress: number) {\n hasStarted = true;\n if (progress <= currentProgress) {\n return;\n }\n currentProgress = progress;\n onProgress({\n progress,\n isComplete: progress === 100,\n status: 'Installing',\n });\n }\n\n childProcess.stdout.on('data', (data: Buffer) => {\n // Sometimes more than one chunk comes at a time, here we split by system newline,\n // then trim and filter.\n const strings = data\n .toString()\n .split(EOL)\n .map((value) => value.trim());\n\n strings.forEach((str) => {\n // Match the progress percentage:\n // - '34%... 35%...' -> 34\n // - '31%...' -> 31\n // - 'Complete!' -> 100\n\n const match = str.match(/(\\d+)%\\.\\.\\./);\n if (match) {\n updateProgress(parseInt(match[1], 10));\n } else if (hasStarted) {\n updateProgress(100);\n }\n });\n\n debug('[stdout]:', strings);\n });\n\n childProcess.on('close', (code) => {\n debug('[close]: ' + code);\n if (code === 0) {\n resolve();\n } else {\n const stderr = childProcess.stderr.read();\n const err = new Error(stderr);\n (err as any).code = code;\n detach(err);\n }\n });\n\n const detach = async (err?: Error) => {\n off?.();\n if (childProcess) {\n return new Promise<void>((resolve) => {\n childProcess?.on('close', resolve);\n childProcess?.kill();\n // childProcess = null;\n reject(err ?? new CommandError('detached'));\n });\n }\n };\n\n const off = installExitHooks(() => detach());\n });\n}\n\nexport async function launchAppWithDeviceCtl(deviceId: string, bundleId: string) {\n await devicectlAsync(['device', 'process', 'launch', '--device', deviceId, bundleId]);\n}\n\n/** Find all error codes from the output log */\nfunction getDeviceCtlErrorCodes(log: string): string[] {\n return [...log.matchAll(/BSErrorCodeDescription\\s+=\\s+(.*)$/gim)].map(([_line, code]) => code);\n}\n\nlet hasEverBeenInstalled: boolean | undefined;\n\nexport function hasDevicectlEverBeenInstalled() {\n if (hasEverBeenInstalled) return hasEverBeenInstalled;\n // It doesn't appear possible for devicectl to ever be uninstalled. We can just check once and store this result forever\n // to prevent cold boots of devicectl from slowing down all invocations of `expo run ios`\n if (fs.existsSync(DEVICE_CTL_EXISTS_PATH)) {\n hasEverBeenInstalled = true;\n return true;\n }\n\n const isInstalled = isDevicectlInstalled();\n\n if (isInstalled) {\n fs.writeFileSync(DEVICE_CTL_EXISTS_PATH, '1');\n }\n hasEverBeenInstalled = isInstalled;\n return isInstalled;\n}\n\nfunction isDevicectlInstalled() {\n try {\n execSync('xcrun devicectl --version', { stdio: 'ignore' });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Wraps the apple device method for installing and running an app,\n * adds indicator and retry loop for when the device is locked.\n */\nexport async function installAndLaunchAppAsync(props: {\n bundle: string;\n bundleIdentifier: string;\n udid: string;\n deviceName: string;\n}): Promise<void> {\n debug('Running on device:', props);\n const { bundle, bundleIdentifier, udid, deviceName } = props;\n let indicator: Ora | undefined;\n\n try {\n if (!indicator) {\n indicator = ora(`Connecting to: ${props.deviceName}`).start();\n }\n\n await installAppWithDeviceCtlAsync(\n udid,\n bundle,\n ({\n status,\n isComplete,\n progress,\n }: {\n status: string;\n isComplete: boolean;\n progress: number;\n }) => {\n if (!indicator) {\n indicator = ora(status).start();\n }\n indicator.text = `${chalk.bold(status)} ${progress}%`;\n if (isComplete) {\n indicator.succeed();\n }\n }\n );\n } catch (error: any) {\n if (indicator) {\n indicator.fail();\n }\n throw error;\n }\n\n async function launchAppOptionally() {\n try {\n await launchAppWithDeviceCtl(udid, bundleIdentifier);\n } catch (error: any) {\n if (indicator) {\n indicator.fail();\n }\n if (error.code === 'APPLE_DEVICE_LOCKED') {\n // Get the app name from the binary path.\n const appName = path.basename(bundle).split('.')[0] ?? 'app';\n if (\n isInteractive() &&\n (await confirmAsync({\n message: `Cannot launch ${appName} because the device is locked. Unlock ${deviceName} to continue...`,\n initial: true,\n }))\n ) {\n return launchAppOptionally();\n }\n throw new CommandError(\n `Cannot launch ${appName} on ${deviceName} because the device is locked.`\n );\n }\n throw error;\n }\n }\n\n await launchAppOptionally();\n}\n"],"names":["devicectlAsync","getConnectedAppleDevicesAsync","launchBinaryOnMacAsync","launchAppWithDeviceCtl","hasDevicectlEverBeenInstalled","installAndLaunchAppAsync","DEVICE_CTL_EXISTS_PATH","path","join","getExpoHomeDirectory","debug","require","args","options","xcrunAsync","error","CommandError","errorCodes","getDeviceCtlErrorCodes","stderr","includes","tmpPath","tempy","file","devices","stdout","devicesJson","JsonFile","readAsync","info","jsonVersion","Log","warn","assertDevicesJson","result","results","assert","Array","isArray","JSON","stringify","bundleId","appBinaryPath","spawnAsync","code","message","installAppWithDeviceCtlAsync","uuid","bundleIdOrAppPath","onProgress","Promise","resolve","reject","childProcess","spawn","currentProgress","hasStarted","updateProgress","progress","isComplete","status","on","data","strings","toString","split","EOL","map","value","trim","forEach","str","match","parseInt","read","err","Error","detach","off","kill","installExitHooks","deviceId","log","matchAll","_line","hasEverBeenInstalled","fs","existsSync","isInstalled","isDevicectlInstalled","writeFileSync","execSync","stdio","props","bundle","bundleIdentifier","udid","deviceName","indicator","ora","start","text","chalk","bold","succeed","fail","launchAppOptionally","appName","basename","isInteractive","confirmAsync","initial"],"mappings":"AAAA;;;;;CAKC,GAED;;;;;;;;;;;IA6HsBA,cAAc,MAAdA,cAAc;IAoBdC,6BAA6B,MAA7BA,6B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,OAAO,EAAE,CAAC,cAAc,EAAE8D,OAAO,CAAC,sCAAsC,EAAEV,UAAU,CAAC,eAAe,CAAC;oBACrGc,OAAO,EAAE,IAAI;iBACd,CAAC,AAAC,EACH;oBACA,OAAOL,mBAAmB,EAAE,CAAC;gBAC/B,CAAC;gBACD,MAAM,IAAI1F,OAAY,aAAA,CACpB,CAAC,cAAc,EAAE2F,OAAO,CAAC,IAAI,EAAEV,UAAU,CAAC,8BAA8B,CAAC,CAC1E,CAAC;YACJ,CAAC;YACD,MAAMlF,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,MAAM2F,mBAAmB,EAAE,CAAC;AAC9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/ios/promptAppleDevice.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { getBestSimulatorAsync } from './getBestSimulator';\nimport { Device } from './simctl';\nimport { createSelectionFilter, promptAsync } from '../../../utils/prompts';\n\n/**\n * Sort the devices so the last simulator that was opened (user's default) is the first suggested.\n *\n * @param devices list of devices to sort.\n * @param osType optional sort by operating system.\n */\nexport async function sortDefaultDeviceToBeginningAsync(\n devices: Device[],\n osType?: Device['osType']\n): Promise<Device[]> {\n const defaultId = await getBestSimulatorAsync({ osType });\n if (defaultId) {\n let iterations = 0;\n while (devices[0].udid !== defaultId && iterations < devices.length) {\n devices.push(devices.shift()!);\n iterations++;\n }\n }\n return devices;\n}\n\n/** Prompt the user to select an Apple device, sorting the most likely option to the beginning. */\nexport async function promptAppleDeviceAsync(\n devices: Device[],\n osType?: Device['osType']\n): Promise<Device> {\n devices = await sortDefaultDeviceToBeginningAsync(devices, osType);\n const results = await promptAppleDeviceInternalAsync(devices);\n return devices.find(({ udid }) => results === udid)!;\n}\n\nasync function promptAppleDeviceInternalAsync(devices: Device[]): Promise<string> {\n // TODO: provide an option to add or download more simulators\n // TODO: Add support for physical devices too.\n\n const { value } = await promptAsync({\n type: 'autocomplete',\n name: 'value',\n limit: 11,\n message: 'Select a simulator',\n choices: devices.map((item) => {\n const isActive = item.state === 'Booted';\n const format = isActive ? chalk.bold : (text: string) => text;\n return {\n title: `${format(item.name)} ${chalk.dim(`(${item.osVersion})`)}`,\n value: item.udid,\n };\n }),\n suggest: createSelectionFilter(),\n });\n\n return value;\n}\n"],"names":["sortDefaultDeviceToBeginningAsync","promptAppleDeviceAsync","devices","osType","defaultId","getBestSimulatorAsync","iterations","udid","length","push","shift","results","promptAppleDeviceInternalAsync","find","value","promptAsync","type","name","limit","message","choices","map","item","isActive","state","format","chalk","bold","text","title","dim","osVersion","suggest","createSelectionFilter"],"mappings":"AAAA;;;;;;;;;;;IAYsBA,iCAAiC,MAAjCA,iCAAiC;IAgBjCC,sBAAsB,MAAtBA,sBAAsB;;;8DA5B1B,OAAO;;;;;;kCAEa,oBAAoB;yBAEP,wBAAwB;;;;;;AAQpE,eAAeD,iCAAiC,CACrDE,OAAiB,EACjBC,MAAyB,EACN;IACnB,MAAMC,SAAS,GAAG,MAAMC,IAAAA,iBAAqB,sBAAA,EAAC;QAAEF,MAAM;KAAE,CAAC,AAAC;IAC1D,IAAIC,SAAS,EAAE;QACb,IAAIE,UAAU,GAAG,CAAC,AAAC;QACnB,MAAOJ,OAAO,CAAC,CAAC,CAAC,CAACK,IAAI,KAAKH,SAAS,IAAIE,UAAU,GAAGJ,OAAO,CAACM,MAAM,CAAE;YACnEN,OAAO,CAACO,IAAI,CAACP,OAAO,CAACQ,KAAK,EAAE,CAAE,CAAC;YAC/BJ,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAOJ,OAAO,CAAC;AACjB,CAAC;AAGM,eAAeD,sBAAsB,CAC1CC,OAAiB,EACjBC,MAAyB,EACR;IACjBD,OAAO,GAAG,MAAMF,iCAAiC,CAACE,OAAO,EAAEC,MAAM,CAAC,CAAC;IACnE,MAAMQ,OAAO,GAAG,MAAMC,8BAA8B,CAACV,OAAO,CAAC,AAAC;IAC9D,OAAOA,OAAO,CAACW,IAAI,CAAC,CAAC,EAAEN,IAAI,CAAA,EAAE,GAAKI,OAAO,KAAKJ,IAAI,CAAC,CAAE;AACvD,CAAC;AAED,eAAeK,8BAA8B,CAACV,OAAiB,EAAmB;IAChF,6DAA6D;IAC7D,8CAA8C;IAE9C,MAAM,EAAEY,KAAK,CAAA,EAAE,GAAG,MAAMC,IAAAA,QAAW,YAAA,EAAC;QAClCC,IAAI,EAAE,cAAc;QACpBC,IAAI,EAAE,OAAO;QACbC,KAAK,EAAE,EAAE;QACTC,OAAO,EAAE,oBAAoB;QAC7BC,OAAO,EAAElB,OAAO,CAACmB,GAAG,CAAC,CAACC,IAAI,GAAK;YAC7B,MAAMC,QAAQ,GAAGD,IAAI,CAACE,KAAK,KAAK,QAAQ,AAAC;YACzC,MAAMC,MAAM,GAAGF,QAAQ,GAAGG,MAAK,EAAA,QAAA,CAACC,IAAI,GAAG,CAACC,IAAY,GAAKA,IAAI,AAAC;YAC9D,OAAO;gBACLC,KAAK,EAAE,CAAC,EAAEJ,MAAM,CAACH,IAAI,CAACL,IAAI,CAAC,CAAC,CAAC,EAAES,MAAK,EAAA,QAAA,CAACI,GAAG,CAAC,CAAC,CAAC,EAAER,IAAI,CAACS,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjEjB,KAAK,EAAEQ,IAAI,CAACf,IAAI;aACjB,CAAC;QACJ,CAAC,CAAC;QACFyB,OAAO,EAAEC,IAAAA,QAAqB,sBAAA,GAAE;KACjC,CAAC,AAAC;IAEH,OAAOnB,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/ios/promptAppleDevice.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { getBestSimulatorAsync } from './getBestSimulator';\nimport { Device } from './simctl';\nimport { createSelectionFilter, promptAsync } from '../../../utils/prompts';\n\n/**\n * Sort the devices so the last simulator that was opened (user's default) is the first suggested.\n *\n * @param devices list of devices to sort.\n * @param osType optional sort by operating system.\n */\nexport async function sortDefaultDeviceToBeginningAsync<T extends { udid: string }>(\n devices: T[],\n osType?: Device['osType']\n): Promise<T[]> {\n const defaultId = await getBestSimulatorAsync({ osType });\n if (defaultId) {\n let iterations = 0;\n while (devices[0].udid !== defaultId && iterations < devices.length) {\n devices.push(devices.shift()!);\n iterations++;\n }\n }\n return devices;\n}\n\n/** Prompt the user to select an Apple device, sorting the most likely option to the beginning. */\nexport async function promptAppleDeviceAsync(\n devices: Device[],\n osType?: Device['osType']\n): Promise<Device> {\n devices = await sortDefaultDeviceToBeginningAsync(devices, osType);\n const results = await promptAppleDeviceInternalAsync(devices);\n return devices.find(({ udid }) => results === udid)!;\n}\n\nasync function promptAppleDeviceInternalAsync(devices: Device[]): Promise<string> {\n // TODO: provide an option to add or download more simulators\n // TODO: Add support for physical devices too.\n\n const { value } = await promptAsync({\n type: 'autocomplete',\n name: 'value',\n limit: 11,\n message: 'Select a simulator',\n choices: devices.map((item) => {\n const isActive = item.state === 'Booted';\n const format = isActive ? chalk.bold : (text: string) => text;\n return {\n title: `${format(item.name)} ${chalk.dim(`(${item.osVersion})`)}`,\n value: item.udid,\n };\n }),\n suggest: createSelectionFilter(),\n });\n\n return value;\n}\n"],"names":["sortDefaultDeviceToBeginningAsync","promptAppleDeviceAsync","devices","osType","defaultId","getBestSimulatorAsync","iterations","udid","length","push","shift","results","promptAppleDeviceInternalAsync","find","value","promptAsync","type","name","limit","message","choices","map","item","isActive","state","format","chalk","bold","text","title","dim","osVersion","suggest","createSelectionFilter"],"mappings":"AAAA;;;;;;;;;;;IAYsBA,iCAAiC,MAAjCA,iCAAiC;IAgBjCC,sBAAsB,MAAtBA,sBAAsB;;;8DA5B1B,OAAO;;;;;;kCAEa,oBAAoB;yBAEP,wBAAwB;;;;;;AAQpE,eAAeD,iCAAiC,CACrDE,OAAY,EACZC,MAAyB,EACX;IACd,MAAMC,SAAS,GAAG,MAAMC,IAAAA,iBAAqB,sBAAA,EAAC;QAAEF,MAAM;KAAE,CAAC,AA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AAES,MAAK,EAAA,QAAA,CAACI,GAAG,CAAC,CAAC,CAAC,EAAER,IAAI,CAACS,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjEjB,KAAK,EAAEQ,IAAI,CAACf,IAAI;aACjB,CAAC;QACJ,CAAC,CAAC;QACFyB,OAAO,EAAEC,IAAAA,QAAqB,sBAAA,GAAE;KACjC,CAAC,AAAC;IAEH,OAAOnB,KAAK,CAAC;AACf,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/ios/simctl.ts"],"sourcesContent":["import spawnAsync, { SpawnOptions, SpawnResult } from '@expo/spawn-async';\n\nimport { xcrunAsync } from './xcrun';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\n\ntype DeviceState = 'Shutdown' | 'Booted';\n\nexport type OSType = 'iOS' | 'tvOS' | 'watchOS' | 'macOS';\n\nexport type Device = {\n availabilityError?: 'runtime profile not found';\n /** '/Users/name/Library/Developer/CoreSimulator/Devices/00E55DC0-0364-49DF-9EC6-77BE587137D4/data' */\n dataPath: string;\n /** @example `2811236352` */\n dataPathSize?: number;\n /** '/Users/name/Library/Logs/CoreSimulator/00E55DC0-0364-49DF-9EC6-77BE587137D4' */\n logPath: string;\n /** @example `479232` */\n logPathSize?: number;\n /** '00E55DC0-0364-49DF-9EC6-77BE587137D4' */\n udid: string;\n /** 'com.apple.CoreSimulator.SimRuntime.iOS-15-1' */\n runtime: string;\n /** If the device is \"available\" which generally means that the OS files haven't been deleted (this can happen when Xcode updates). */\n isAvailable: boolean;\n /** 'com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro' */\n deviceTypeIdentifier: string;\n state: DeviceState;\n /** 'iPhone 13 Pro' */\n name: string;\n /** Type of OS the device uses. */\n osType: OSType;\n /** '15.1' */\n osVersion: string;\n /** 'iPhone 13 Pro (15.1)' */\n windowName: string;\n};\n\ntype SimulatorDeviceList = {\n devices: {\n [runtime: string]: Device[];\n };\n};\n\ntype DeviceContext = Pick<Device, 'udid'>;\n\n/** Returns true if the given value is an `OSType`, if we don't recognize the value we continue anyways but warn. */\nexport function isOSType(value: any): value is OSType {\n if (!value || typeof value !== 'string') return false;\n\n const knownTypes = ['iOS', 'tvOS', 'watchOS', 'macOS'];\n if (!knownTypes.includes(value)) {\n Log.warn(`Unknown OS type: ${value}. Expected one of: ${knownTypes.join(', ')}`);\n }\n return true;\n}\n\n/**\n * Returns the local path for the installed tar.app. Returns null when the app isn't installed.\n *\n * @param device context for selecting a device.\n * @param props.appId bundle identifier for app.\n * @returns local file path to installed app binary, e.g. '/Users/evanbacon/Library/Developer/CoreSimulator/Devices/EFEEA6EF-E3F5-4EDE-9B72-29EAFA7514AE/data/Containers/Bundle/Application/FA43A0C6-C2AD-442D-B8B1-EAF3E88CF3BF/Exponent-2.21.3.tar.app'\n */\nexport async function getContainerPathAsync(\n device: Partial<DeviceContext>,\n {\n appId,\n }: {\n appId: string;\n }\n): Promise<string | null> {\n try {\n const { stdout } = await simctlAsync(['get_app_container', resolveId(device), appId]);\n return stdout.trim();\n } catch (error: any) {\n if (error.stderr?.match(/No such file or directory/)) {\n return null;\n }\n throw error;\n }\n}\n\n/** Return a value from an installed app's Info.plist. */\nexport async function getInfoPlistValueAsync(\n device: Partial<DeviceContext>,\n {\n appId,\n key,\n containerPath,\n }: {\n appId: string;\n key: string;\n containerPath?: string;\n }\n): Promise<string | null> {\n const ensuredContainerPath = containerPath ?? (await getContainerPathAsync(device, { appId }));\n if (ensuredContainerPath) {\n try {\n const { output } = await spawnAsync(\n 'defaults',\n ['read', `${ensuredContainerPath}/Info`, key],\n {\n stdio: 'pipe',\n }\n );\n return output.join('\\n').trim();\n } catch {\n return null;\n }\n }\n return null;\n}\n\n/** Open a URL on a device. The url can have any protocol. */\nexport async function openUrlAsync(\n device: Partial<DeviceContext>,\n options: { url: string }\n): Promise<void> {\n try {\n // Skip logging since this is likely to fail.\n await simctlAsync(['openurl', resolveId(device), options.url]);\n } catch (error: any) {\n if (!error.stderr?.match(/Unable to lookup in current state: Shut/)) {\n throw error;\n }\n\n // If the device was in a weird in-between state (\"Shutting Down\" or \"Shutdown\"), then attempt to reboot it and try again.\n // This can happen when quitting the Simulator app, and immediately pressing `i` to reopen the project.\n\n // First boot the simulator\n await bootDeviceAsync({ udid: resolveId(device) });\n\n // Finally, try again...\n return await openUrlAsync(device, options);\n }\n}\n\n/** Open a simulator using a bundle identifier. If no app with a matching bundle identifier is installed then an error will be thrown. */\nexport async function openAppIdAsync(\n device: Partial<DeviceContext>,\n options: {\n appId: string;\n }\n): Promise<SpawnResult> {\n const results = await openAppIdInternalAsync(device, options);\n // Similar to 194, this is a conformance issue which indicates that the given device has no app that can handle our launch request.\n if (results.status === 4) {\n throw new CommandError('APP_NOT_INSTALLED', results.stderr);\n }\n return results;\n}\nasync function openAppIdInternalAsync(\n device: Partial<DeviceContext>,\n options: {\n appId: string;\n }\n): Promise<SpawnResult> {\n try {\n return await simctlAsync(['launch', resolveId(device), options.appId]);\n } catch (error: any) {\n if ('status' in error) {\n return error;\n }\n throw error;\n }\n}\n\n// This will only boot in headless mode if the Simulator app is not running.\nexport async function bootAsync(device: DeviceContext): Promise<Device | null> {\n await bootDeviceAsync(device);\n return isDeviceBootedAsync(device);\n}\n\n/** Returns a list of devices whose current state is 'Booted' as an array. */\nexport async function getBootedSimulatorsAsync(): Promise<Device[]> {\n const simulatorDeviceInfo = await getRuntimesAsync('devices');\n return Object.values(simulatorDeviceInfo.devices).flatMap((runtime) =>\n runtime.filter((device) => device.state === 'Booted')\n );\n}\n\n/** Returns the current device if its state is 'Booted'. */\nexport async function isDeviceBootedAsync(device: Partial<DeviceContext>): Promise<Device | null> {\n // Simulators can be booted even if the app isn't running :(\n const devices = await getBootedSimulatorsAsync();\n if (device.udid) {\n return devices.find((bootedDevice) => bootedDevice.udid === device.udid) ?? null;\n }\n\n return devices[0] ?? null;\n}\n\n/** Boot a device. */\nexport async function bootDeviceAsync(device: DeviceContext): Promise<void> {\n try {\n // Skip logging since this is likely to fail.\n await simctlAsync(['boot', device.udid]);\n } catch (error: any) {\n if (!error.stderr?.match(/Unable to boot device in current state: Booted/)) {\n throw error;\n }\n }\n}\n\n/** Install a binary file on the device. */\nexport async function installAsync(\n device: Partial<DeviceContext>,\n options: {\n /** Local absolute file path to an app binary that is built and provisioned for iOS simulators. */\n filePath: string;\n }\n): Promise<any> {\n return simctlAsync(['install', resolveId(device), options.filePath]);\n}\n\n/** Uninstall an app from the provided device. */\nexport async function uninstallAsync(\n device: Partial<DeviceContext>,\n options: {\n /** Bundle identifier */\n appId: string;\n }\n): Promise<any> {\n return simctlAsync(['uninstall', resolveId(device), options.appId]);\n}\n\nfunction parseSimControlJSONResults(input: string): any {\n try {\n return JSON.parse(input);\n } catch (error: any) {\n // Nov 15, 2020: Observed this can happen when opening the simulator and the simulator prompts the user to update the xcode command line tools.\n // Unexpected token I in JSON at position 0\n if (error.message.includes('Unexpected token')) {\n Log.error(`Apple's simctl returned malformed JSON:\\n${input}`);\n }\n throw error;\n }\n}\n\n/** Get all runtime devices given a certain type. */\nasync function getRuntimesAsync(\n type: 'devices' | 'devicetypes' | 'runtimes' | 'pairs',\n query?: string | 'available'\n): Promise<SimulatorDeviceList> {\n const result = await simctlAsync(['list', type, '--json', query]);\n const info = parseSimControlJSONResults(result.stdout) as SimulatorDeviceList;\n\n for (const runtime of Object.keys(info.devices)) {\n // Given a string like 'com.apple.CoreSimulator.SimRuntime.tvOS-13-4'\n const runtimeSuffix = runtime.split('com.apple.CoreSimulator.SimRuntime.').pop()!;\n // Create an array [tvOS, 13, 4]\n const [osType, ...osVersionComponents] = runtimeSuffix.split('-');\n // Join the end components [13, 4] -> '13.4'\n const osVersion = osVersionComponents.join('.');\n const sims = info.devices[runtime];\n for (const device of sims) {\n device.runtime = runtime;\n device.osVersion = osVersion;\n device.windowName = `${device.name} (${osVersion})`;\n device.osType = osType as OSType;\n }\n }\n return info;\n}\n\n/** Return a list of iOS simulators. */\nexport async function getDevicesAsync(): Promise<Device[]> {\n const simulatorDeviceInfo = await getRuntimesAsync('devices');\n return Object.values(simulatorDeviceInfo.devices).flat();\n}\n\n/** Run a `simctl` command. */\nexport async function simctlAsync(\n args: (string | undefined)[],\n options?: SpawnOptions\n): Promise<SpawnResult> {\n return xcrunAsync(['simctl', ...args], options);\n}\n\nfunction resolveId(device: Partial<DeviceContext>): string {\n return device.udid ?? 'booted';\n}\n"],"names":["isOSType","getContainerPathAsync","getInfoPlistValueAsync","openUrlAsync","openAppIdAsync","bootAsync","getBootedSimulatorsAsync","isDeviceBootedAsync","bootDeviceAsync","installAsync","uninstallAsync","getDevicesAsync","simctlAsync","value","knownTypes","includes","Log","warn","join","device","appId","stdout","resolveId","trim","error","stderr","match","key","containerPath","ensuredContainerPath","output","spawnAsync","stdio","options","url","udid","results","openAppIdInternalAsync","status","CommandError","simulatorDeviceInfo","getRuntimesAsync","Object","values","devices","flatMap","runtime","filter","state","find","bootedDevice","filePath","parseSimControlJSONResults","input","JSON","parse","message","type","query","result","info","keys","runtimeSuffix","split","pop","osType","osVersionComponents","osVersion","sims","windowName","name","flat","args","xcrunAsync"],"mappings":"AAAA;;;;;;;;;;;IAgDgBA,QAAQ,MAARA,QAAQ;IAiBFC,qBAAqB,MAArBA,qBAAqB;IAoBrBC,sBAAsB,MAAtBA,sBAAsB;IA+BtBC,YAAY,MAAZA,YAAY;IAwBZC,cAAc,MAAdA,cAAc;IA8BdC,SAAS,MAATA,SAAS;IAMTC,wBAAwB,MAAxBA,wBAAwB;IAQxBC,mBAAmB,MAAnBA,mBAAmB;IAWnBC,eAAe,MAAfA,eAAe;IAYfC,YAAY,MAAZA,YAAY;IAWZC,cAAc,MAAdA,cAAc;IAkDdC,eAAe,MAAfA,eAAe;IAMfC,WAAW,MAAXA,WAAW;;;8DAlRqB,mBAAmB;;;;;;uBAE9C,SAAS;2DACf,cAAc;wBACN,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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IACzD,MAAM6B,mBAAmB,GAAG,MAAMC,gBAAgB,CAAC,SAAS,CAAC,AAAC;IAC9D,OAAOC,MAAM,CAACC,MAAM,CAACH,mBAAmB,CAACI,OAAO,CAAC,CAAC2B,IAAI,EAAE,CAAC;AAC3D,CAAC;AAGM,eAAe3D,WAAW,CAC/B4D,IAA4B,EAC5BvC,OAAsB,EACA;IACtB,OAAOwC,IAAAA,MAAU,WAAA,EAAC;QAAC,QAAQ;WAAKD,IAAI;KAAC,EAAEvC,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,SAASX,SAAS,CAACH,MAA8B,EAAU;QAClDA,KAAW;IAAlB,OAAOA,CAAAA,KAAW,GAAXA,MAAM,CAACgB,IAAI,YAAXhB,KAAW,GAAI,QAAQ,CAAC;AACjC,CAAC"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/ios/simctl.ts"],"sourcesContent":["import spawnAsync, { SpawnOptions, SpawnResult } from '@expo/spawn-async';\n\nimport { xcrunAsync } from './xcrun';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\n\ntype DeviceState = 'Shutdown' | 'Booted';\n\nexport type OSType = 'iOS' | 'tvOS' | 'watchOS' | 'macOS' | 'xrOS';\n\nexport type Device = {\n availabilityError?: 'runtime profile not found';\n /** '/Users/name/Library/Developer/CoreSimulator/Devices/00E55DC0-0364-49DF-9EC6-77BE587137D4/data' */\n dataPath: string;\n /** @example `2811236352` */\n dataPathSize?: number;\n /** '/Users/name/Library/Logs/CoreSimulator/00E55DC0-0364-49DF-9EC6-77BE587137D4' */\n logPath: string;\n /** @example `479232` */\n logPathSize?: number;\n /** '00E55DC0-0364-49DF-9EC6-77BE587137D4' */\n udid: string;\n /** 'com.apple.CoreSimulator.SimRuntime.iOS-15-1' */\n runtime: string;\n /** If the device is \"available\" which generally means that the OS files haven't been deleted (this can happen when Xcode updates). */\n isAvailable: boolean;\n /** 'com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro' */\n deviceTypeIdentifier: string;\n state: DeviceState;\n /** 'iPhone 13 Pro' */\n name: string;\n /** Type of OS the device uses. */\n osType: OSType;\n /** '15.1' */\n osVersion: string;\n /** 'iPhone 13 Pro (15.1)' */\n windowName: string;\n};\n\ntype SimulatorDeviceList = {\n devices: {\n [runtime: string]: Device[];\n };\n};\n\ntype DeviceContext = Pick<Device, 'udid'>;\n\n/** Returns true if the given value is an `OSType`, if we don't recognize the value we continue anyways but warn. */\nexport function isOSType(value: any): value is OSType {\n if (!value || typeof value !== 'string') return false;\n\n const knownTypes = ['iOS', 'tvOS', 'watchOS', 'macOS'];\n if (!knownTypes.includes(value)) {\n Log.warn(`Unknown OS type: ${value}. Expected one of: ${knownTypes.join(', ')}`);\n }\n return true;\n}\n\n/**\n * Returns the local path for the installed tar.app. Returns null when the app isn't installed.\n *\n * @param device context for selecting a device.\n * @param props.appId bundle identifier for app.\n * @returns local file path to installed app binary, e.g. '/Users/evanbacon/Library/Developer/CoreSimulator/Devices/EFEEA6EF-E3F5-4EDE-9B72-29EAFA7514AE/data/Containers/Bundle/Application/FA43A0C6-C2AD-442D-B8B1-EAF3E88CF3BF/Exponent-2.21.3.tar.app'\n */\nexport async function getContainerPathAsync(\n device: Partial<DeviceContext>,\n {\n appId,\n }: {\n appId: string;\n }\n): Promise<string | null> {\n try {\n const { stdout } = await simctlAsync(['get_app_container', resolveId(device), appId]);\n return stdout.trim();\n } catch (error: any) {\n if (error.stderr?.match(/No such file or directory/)) {\n return null;\n }\n throw error;\n }\n}\n\n/** Return a value from an installed app's Info.plist. */\nexport async function getInfoPlistValueAsync(\n device: Partial<DeviceContext>,\n {\n appId,\n key,\n containerPath,\n }: {\n appId: string;\n key: string;\n containerPath?: string;\n }\n): Promise<string | null> {\n const ensuredContainerPath = containerPath ?? (await getContainerPathAsync(device, { appId }));\n if (ensuredContainerPath) {\n try {\n const { output } = await spawnAsync(\n 'defaults',\n ['read', `${ensuredContainerPath}/Info`, key],\n {\n stdio: 'pipe',\n }\n );\n return output.join('\\n').trim();\n } catch {\n return null;\n }\n }\n return null;\n}\n\n/** Open a URL on a device. The url can have any protocol. */\nexport async function openUrlAsync(\n device: Partial<DeviceContext>,\n options: { url: string }\n): Promise<void> {\n try {\n // Skip logging since this is likely to fail.\n await simctlAsync(['openurl', resolveId(device), options.url]);\n } catch (error: any) {\n if (!error.stderr?.match(/Unable to lookup in current state: Shut/)) {\n throw error;\n }\n\n // If the device was in a weird in-between state (\"Shutting Down\" or \"Shutdown\"), then attempt to reboot it and try again.\n // This can happen when quitting the Simulator app, and immediately pressing `i` to reopen the project.\n\n // First boot the simulator\n await bootDeviceAsync({ udid: resolveId(device) });\n\n // Finally, try again...\n return await openUrlAsync(device, options);\n }\n}\n\n/** Open a simulator using a bundle identifier. If no app with a matching bundle identifier is installed then an error will be thrown. */\nexport async function openAppIdAsync(\n device: Partial<DeviceContext>,\n options: {\n appId: string;\n }\n): Promise<SpawnResult> {\n const results = await openAppIdInternalAsync(device, options);\n // Similar to 194, this is a conformance issue which indicates that the given device has no app that can handle our launch request.\n if (results.status === 4) {\n throw new CommandError('APP_NOT_INSTALLED', results.stderr);\n }\n return results;\n}\nasync function openAppIdInternalAsync(\n device: Partial<DeviceContext>,\n options: {\n appId: string;\n }\n): Promise<SpawnResult> {\n try {\n return await simctlAsync(['launch', resolveId(device), options.appId]);\n } catch (error: any) {\n if ('status' in error) {\n return error;\n }\n throw error;\n }\n}\n\n// This will only boot in headless mode if the Simulator app is not running.\nexport async function bootAsync(device: DeviceContext): Promise<Device | null> {\n await bootDeviceAsync(device);\n return isDeviceBootedAsync(device);\n}\n\n/** Returns a list of devices whose current state is 'Booted' as an array. */\nexport async function getBootedSimulatorsAsync(): Promise<Device[]> {\n const simulatorDeviceInfo = await getRuntimesAsync('devices');\n return Object.values(simulatorDeviceInfo.devices).flatMap((runtime) =>\n runtime.filter((device) => device.state === 'Booted')\n );\n}\n\n/** Returns the current device if its state is 'Booted'. */\nexport async function isDeviceBootedAsync(device: Partial<DeviceContext>): Promise<Device | null> {\n // Simulators can be booted even if the app isn't running :(\n const devices = await getBootedSimulatorsAsync();\n if (device.udid) {\n return devices.find((bootedDevice) => bootedDevice.udid === device.udid) ?? null;\n }\n\n return devices[0] ?? null;\n}\n\n/** Boot a device. */\nexport async function bootDeviceAsync(device: DeviceContext): Promise<void> {\n try {\n // Skip logging since this is likely to fail.\n await simctlAsync(['boot', device.udid]);\n } catch (error: any) {\n if (!error.stderr?.match(/Unable to boot device in current state: Booted/)) {\n throw error;\n }\n }\n}\n\n/** Install a binary file on the device. */\nexport async function installAsync(\n device: Partial<DeviceContext>,\n options: {\n /** Local absolute file path to an app binary that is built and provisioned for iOS simulators. */\n filePath: string;\n }\n): Promise<any> {\n return simctlAsync(['install', resolveId(device), options.filePath]);\n}\n\n/** Uninstall an app from the provided device. */\nexport async function uninstallAsync(\n device: Partial<DeviceContext>,\n options: {\n /** Bundle identifier */\n appId: string;\n }\n): Promise<any> {\n return simctlAsync(['uninstall', resolveId(device), options.appId]);\n}\n\nfunction parseSimControlJSONResults(input: string): any {\n try {\n return JSON.parse(input);\n } catch (error: any) {\n // Nov 15, 2020: Observed this can happen when opening the simulator and the simulator prompts the user to update the xcode command line tools.\n // Unexpected token I in JSON at position 0\n if (error.message.includes('Unexpected token')) {\n Log.error(`Apple's simctl returned malformed JSON:\\n${input}`);\n }\n throw error;\n }\n}\n\n/** Get all runtime devices given a certain type. */\nasync function getRuntimesAsync(\n type: 'devices' | 'devicetypes' | 'runtimes' | 'pairs',\n query?: string | 'available'\n): Promise<SimulatorDeviceList> {\n const result = await simctlAsync(['list', type, '--json', query]);\n const info = parseSimControlJSONResults(result.stdout) as SimulatorDeviceList;\n\n for (const runtime of Object.keys(info.devices)) {\n // Given a string like 'com.apple.CoreSimulator.SimRuntime.tvOS-13-4'\n const runtimeSuffix = runtime.split('com.apple.CoreSimulator.SimRuntime.').pop()!;\n // Create an array [tvOS, 13, 4]\n const [osType, ...osVersionComponents] = runtimeSuffix.split('-');\n // Join the end components [13, 4] -> '13.4'\n const osVersion = osVersionComponents.join('.');\n const sims = info.devices[runtime];\n for (const device of sims) {\n device.runtime = runtime;\n device.osVersion = osVersion;\n device.windowName = `${device.name} (${osVersion})`;\n device.osType = osType as OSType;\n }\n }\n return info;\n}\n\n/** Return a list of iOS simulators. */\nexport async function getDevicesAsync(): Promise<Device[]> {\n const simulatorDeviceInfo = await getRuntimesAsync('devices');\n return Object.values(simulatorDeviceInfo.devices).flat();\n}\n\n/** Run a `simctl` command. */\nexport async function simctlAsync(\n args: (string | undefined)[],\n options?: SpawnOptions\n): Promise<SpawnResult> {\n return xcrunAsync(['simctl', ...args], options);\n}\n\nfunction resolveId(device: Partial<DeviceContext>): string {\n return device.udid ?? 'booted';\n}\n"],"names":["isOSType","getContainerPathAsync","getInfoPlistValueAsync","openUrlAsync","openAppIdAsync","bootAsync","getBootedSimulatorsAsync","isDeviceBootedAsync","bootDeviceAsync","installAsync","uninstallAsync","getDevicesAsync","simctlAsync","value","knownTypes","includes","Log","warn","join","device","appId","stdout","resolveId","trim","error","stderr","match","key","containerPath","ensuredContainerPath","output","spawnAsync","stdio","options","url","udid","results","openAppIdInternalAsync","status","CommandError","simulatorDeviceInfo","getRuntimesAsync","Object","values","devices","flatMap","runtime","filter","state","find","bootedDevice","filePath","parseSimControlJSONResults","input","JSON","parse","message","type","query","result","info","keys","runtimeSuffix","split","pop","osType","osVersionComponents","osVersion","sims","windowName","name","flat","args","xcrunAsync"],"mappings":"AAAA;;;;;;;;;;;IAgDgBA,QAAQ,MAARA,QAAQ;IAiBFC,qBAAqB,MAArBA,qBAAqB;IAoBrBC,sBAAsB,MAAtBA,sBAAsB;IA+BtBC,YAAY,MAAZA,YAAY;IAwBZC,cAAc,MAAdA,cAAc;IA8BdC,SAAS,MAATA,SAAS;IAMTC,wBAAwB,MAAxBA,wBAAwB;IAQxBC,mBAAmB,MAAnBA,mBAAmB;IAWnBC,eAAe,MAAfA,eAAe;IAYfC,YAAY,MAAZA,YAAY;I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AACmD,IAAI,CAAC,EAAE,EAAEH,SAAS,CAAC,CAAC,CAAC,CAAC;YACpDhD,MAAM,CAAC8C,MAAM,GAAGA,MAAM,AAAU,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAOL,IAAI,CAAC;AACd,CAAC;AAGM,eAAejD,eAAe,GAAsB;IACzD,MAAM6B,mBAAmB,GAAG,MAAMC,gBAAgB,CAAC,SAAS,CAAC,AAAC;IAC9D,OAAOC,MAAM,CAACC,MAAM,CAACH,mBAAmB,CAACI,OAAO,CAAC,CAAC2B,IAAI,EAAE,CAAC;AAC3D,CAAC;AAGM,eAAe3D,WAAW,CAC/B4D,IAA4B,EAC5BvC,OAAsB,EACA;IACtB,OAAOwC,IAAAA,MAAU,WAAA,EAAC;QAAC,QAAQ;WAAKD,IAAI;KAAC,EAAEvC,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,SAASX,SAAS,CAACH,MAA8B,EAAU;QAClDA,KAAW;IAAlB,OAAOA,CAAAA,KAAW,GAAXA,MAAM,CAACgB,IAAI,YAAXhB,KAAW,GAAI,QAAQ,CAAC;AACjC,CAAC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "AtlasPrerequisite", {
6
+ enumerable: true,
7
+ get: ()=>AtlasPrerequisite
8
+ });
9
+ const _prerequisite = require("../../../doctor/Prerequisite");
10
+ const _ensureDependenciesAsync = require("../../../doctor/dependencies/ensureDependenciesAsync");
11
+ class AtlasPrerequisite extends _prerequisite.ProjectPrerequisite {
12
+ async assertImplementation({ exp } = {}) {
13
+ await this.ensureAtlasInstalled({
14
+ exp
15
+ });
16
+ return true;
17
+ }
18
+ async bootstrapAsync({ exp } = {}) {
19
+ await this.ensureAtlasInstalled({
20
+ exp,
21
+ skipPrompt: true,
22
+ isProjectMutable: true
23
+ });
24
+ }
25
+ async ensureAtlasInstalled(options = {}) {
26
+ try {
27
+ return await (0, _ensureDependenciesAsync.ensureDependenciesAsync)(this.projectRoot, {
28
+ ...options,
29
+ installMessage: "Expo Atlas is required to gather bundle information, but it is not installed in this project.",
30
+ warningMessage: "Expo Atlas is not installed in this project, unable to gather bundle information.",
31
+ requiredPackages: [
32
+ {
33
+ version: "^0.1.1",
34
+ pkg: "expo-atlas",
35
+ file: "expo-atlas/package.json",
36
+ dev: true
37
+ },
38
+ ]
39
+ });
40
+ } catch (error) {
41
+ this.resetAssertion({});
42
+ throw error;
43
+ }
44
+ }
45
+ }
46
+
47
+ //# sourceMappingURL=AtlasPrerequisite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/start/server/metro/debugging/AtlasPrerequisite.ts"],"sourcesContent":["import { ProjectPrerequisite } from '../../../doctor/Prerequisite';\nimport {\n type EnsureDependenciesOptions,\n ensureDependenciesAsync,\n} from '../../../doctor/dependencies/ensureDependenciesAsync';\n\nexport class AtlasPrerequisite extends ProjectPrerequisite<\n boolean,\n Pick<EnsureDependenciesOptions, 'exp'>\n> {\n async assertImplementation({ exp }: Pick<EnsureDependenciesOptions, 'exp'> = {}) {\n await this.ensureAtlasInstalled({ exp });\n return true;\n }\n\n async bootstrapAsync({ exp }: Pick<EnsureDependenciesOptions, 'exp'> = {}) {\n await this.ensureAtlasInstalled({ exp, skipPrompt: true, isProjectMutable: true });\n }\n\n private async ensureAtlasInstalled(options: Partial<EnsureDependenciesOptions> = {}) {\n try {\n return await ensureDependenciesAsync(this.projectRoot, {\n ...options,\n installMessage:\n 'Expo Atlas is required to gather bundle information, but it is not installed in this project.',\n warningMessage:\n 'Expo Atlas is not installed in this project, unable to gather bundle information.',\n requiredPackages: [\n { version: '^0.1.1', pkg: 'expo-atlas', file: 'expo-atlas/package.json', dev: true },\n ],\n });\n } catch (error) {\n this.resetAssertion({});\n throw error;\n }\n }\n}\n"],"names":["AtlasPrerequisite","ProjectPrerequisite","assertImplementation","exp","ensureAtlasInstalled","bootstrapAsync","skipPrompt","isProjectMutable","options","ensureDependenciesAsync","projectRoot","installMessage","warningMessage","requiredPackages","version","pkg","file","dev","error","resetAssertion"],"mappings":"AAAA;;;;+BAMaA,mBAAiB;;aAAjBA,iBAAiB;;8BANM,8BAA8B;yCAI3D,sDAAsD;AAEtD,MAAMA,iBAAiB,SAASC,aAAmB,oBAAA;UAIlDC,oBAAoB,CAAC,EAAEC,GAAG,CAAA,EAA0C,GAAG,EAAE,EAAE;QAC/E,MAAM,IAAI,CAACC,oBAAoB,CAAC;YAAED,GAAG;SAAE,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd;UAEME,cAAc,CAAC,EAAEF,GAAG,CAAA,EAA0C,GAAG,EAAE,EAAE;QACzE,MAAM,IAAI,CAACC,oBAAoB,CAAC;YAAED,GAAG;YAAEG,UAAU,EAAE,IAAI;YAAEC,gBAAgB,EAAE,IAAI;SAAE,CAAC,CAAC;IACrF;UAEcH,oBAAoB,CAACI,OAA2C,GAAG,EAAE,EAAE;QACnF,IAAI;YACF,OAAO,MAAMC,IAAAA,wBAAuB,wBAAA,EAAC,IAAI,CAACC,WAAW,EAAE;gBACrD,GAAGF,OAAO;gBACVG,cAAc,EACZ,+FAA+F;gBACjGC,cAAc,EACZ,mFAAmF;gBACrFC,gBAAgB,EAAE;oBAChB;wBAAEC,OAAO,EAAE,QAAQ;wBAAEC,GAAG,EAAE,YAAY;wBAAEC,IAAI,EAAE,yBAAyB;wBAAEC,GAAG,EAAE,IAAI;qBAAE;iBACrF;aACF,CAAC,CAAC;QACL,EAAE,OAAOC,KAAK,EAAE;YACd,IAAI,CAACC,cAAc,CAAC,EAAE,CAAC,CAAC;YACxB,MAAMD,KAAK,CAAC;QACd,CAAC;IACH;CACD"}