@expo/cli 0.18.16 → 0.18.18
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/build/bin/cli +1 -1
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +110 -41
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +0 -1
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +130 -92
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportHermes.js +15 -0
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +3 -48
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/run/startBundler.js +1 -8
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/platforms/DeviceManager.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +7 -2
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/AndroidDeviceManager.js +3 -0
- package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +6 -2
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/platforms/ios/simctl.js +80 -0
- package/build/src/start/platforms/ios/simctl.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +9 -2
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +13 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +9 -123
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +391 -102
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +0 -9
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +19 -12
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +49 -2
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/metroPrivateServer.js +26 -0
- package/build/src/start/server/metro/metroPrivateServer.js.map +1 -0
- package/build/src/start/server/metro/runServer-fork.js +28 -20
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +5 -13
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +6 -3
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +11 -3
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
- package/build/src/utils/port.js +1 -1
- package/build/src/utils/port.js.map +1 -1
- package/build/src/utils/telemetry/getContext.js +1 -1
- package/package.json +5 -4
- package/build/src/export/fork-bundleAsync.js +0 -284
- package/build/src/export/fork-bundleAsync.js.map +0 -1
|
@@ -30,9 +30,40 @@ function _spawnAsync() {
|
|
|
30
30
|
};
|
|
31
31
|
return data;
|
|
32
32
|
}
|
|
33
|
+
function _bplistCreator() {
|
|
34
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("bplist-creator"));
|
|
35
|
+
_bplistCreator = function() {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
function _fs() {
|
|
41
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
42
|
+
_fs = function() {
|
|
43
|
+
return data;
|
|
44
|
+
};
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
function _os() {
|
|
48
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("os"));
|
|
49
|
+
_os = function() {
|
|
50
|
+
return data;
|
|
51
|
+
};
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
function _path() {
|
|
55
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
56
|
+
_path = function() {
|
|
57
|
+
return data;
|
|
58
|
+
};
|
|
59
|
+
return data;
|
|
60
|
+
}
|
|
33
61
|
const _xcrun = require("./xcrun");
|
|
34
62
|
const _log = /*#__PURE__*/ _interopRequireWildcard(require("../../../log"));
|
|
35
63
|
const _errors = require("../../../utils/errors");
|
|
64
|
+
const _fn = require("../../../utils/fn");
|
|
65
|
+
const _plist = require("../../../utils/plist");
|
|
66
|
+
const _profile = require("../../../utils/profile");
|
|
36
67
|
function _interopRequireDefault(obj) {
|
|
37
68
|
return obj && obj.__esModule ? obj : {
|
|
38
69
|
default: obj
|
|
@@ -77,6 +108,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
77
108
|
}
|
|
78
109
|
return newObj;
|
|
79
110
|
}
|
|
111
|
+
const debug = require("debug")("expo:simctl");
|
|
80
112
|
function isOSType(value) {
|
|
81
113
|
if (!value || typeof value !== "string") return false;
|
|
82
114
|
const knownTypes = [
|
|
@@ -126,7 +158,55 @@ async function getInfoPlistValueAsync(device, { appId , key , containerPath })
|
|
|
126
158
|
}
|
|
127
159
|
return null;
|
|
128
160
|
}
|
|
161
|
+
/** Rewrite the simulator permissions to allow opening deep links without needing to prompt the user first. */ async function updateSimulatorLinkingPermissionsAsync(device, { url , appId }) {
|
|
162
|
+
if (!device.udid || !appId) {
|
|
163
|
+
debug("Skipping deep link permissions as missing properties could not be found:", {
|
|
164
|
+
url,
|
|
165
|
+
appId,
|
|
166
|
+
udid: device.udid
|
|
167
|
+
});
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
debug("Rewriting simulator permissions to support deep linking:", {
|
|
171
|
+
url,
|
|
172
|
+
appId,
|
|
173
|
+
udid: device.udid
|
|
174
|
+
});
|
|
175
|
+
let scheme;
|
|
176
|
+
try {
|
|
177
|
+
// Attempt to extract the scheme from the URL.
|
|
178
|
+
scheme = new URL(url).protocol.slice(0, -1);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
debug(`Could not parse the URL scheme: ${error.message}`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
// Get the hard-coded path to the simulator's scheme approval plist file.
|
|
184
|
+
const plistPath = _path().default.join(_os().default.homedir(), `Library/Developer/CoreSimulator/Devices`, device.udid, `data/Library/Preferences/com.apple.launchservices.schemeapproval.plist`);
|
|
185
|
+
const plistData = _fs().default.existsSync(plistPath) ? await (0, _plist.parsePlistAsync)(plistPath) : // Can be tested by launching a new simulator or by deleting the file and relaunching the simulator.
|
|
186
|
+
{};
|
|
187
|
+
debug("Allowed links:", plistData);
|
|
188
|
+
const key = `com.apple.CoreSimulator.CoreSimulatorBridge-->${scheme}`;
|
|
189
|
+
// Replace any existing value for the scheme with the new appId.
|
|
190
|
+
plistData[key] = appId;
|
|
191
|
+
debug("Allowing deep link:", {
|
|
192
|
+
key,
|
|
193
|
+
appId
|
|
194
|
+
});
|
|
195
|
+
try {
|
|
196
|
+
const data = (0, _bplistCreator().default)(plistData);
|
|
197
|
+
// Write the updated plist back to disk
|
|
198
|
+
await _fs().default.promises.writeFile(plistPath, data);
|
|
199
|
+
} catch (error1) {
|
|
200
|
+
_log.warn(`Could not update simulator linking permissions: ${error1.message}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const updateSimulatorLinkingPermissionsAsyncMemo = (0, _fn.memoize)(updateSimulatorLinkingPermissionsAsync);
|
|
129
204
|
async function openUrlAsync(device, options) {
|
|
205
|
+
if (options.appId) {
|
|
206
|
+
await (0, _profile.profile)(updateSimulatorLinkingPermissionsAsyncMemo, "updateSimulatorLinkingPermissionsAsync")({
|
|
207
|
+
udid: device.udid
|
|
208
|
+
}, options);
|
|
209
|
+
}
|
|
130
210
|
try {
|
|
131
211
|
// Skip logging since this is likely to fail.
|
|
132
212
|
await simctlAsync([
|
|
@@ -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' | '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;IAWZC,cAAc,MAAdA,cAAc;IAkDdC,eAAe,MAAfA,eAAe;IAMfC,WAAW,MAAXA,WAAW;;;8DAlRqB,mBAAmB;;;;;;uBAE9C,SAAS;2DACf,cAAc;wBACN,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4C7C,SAASZ,QAAQ,CAACa,KAAU,EAAmB;IACpD,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE,OAAO,KAAK,CAAC;IAEtD,MAAMC,UAAU,GAAG;QAAC,KAAK;QAAE,MAAM;QAAE,SAAS;QAAE,OAAO;KAAC,AAAC;IACvD,IAAI,CAACA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,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';\nimport bplistCreator from 'bplist-creator';\nimport fs from 'fs';\nimport os from 'os';\nimport path from 'path';\n\nimport { xcrunAsync } from './xcrun';\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport { memoize } from '../../../utils/fn';\nimport { parsePlistAsync } from '../../../utils/plist';\nimport { profile } from '../../../utils/profile';\n\nconst debug = require('debug')('expo:simctl') as typeof console.log;\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/** Rewrite the simulator permissions to allow opening deep links without needing to prompt the user first. */\nasync function updateSimulatorLinkingPermissionsAsync(\n device: Partial<DeviceContext>,\n { url, appId }: { url: string; appId?: string }\n) {\n if (!device.udid || !appId) {\n debug('Skipping deep link permissions as missing properties could not be found:', {\n url,\n appId,\n udid: device.udid,\n });\n return;\n }\n debug('Rewriting simulator permissions to support deep linking:', {\n url,\n appId,\n udid: device.udid,\n });\n let scheme: string;\n try {\n // Attempt to extract the scheme from the URL.\n scheme = new URL(url).protocol.slice(0, -1);\n } catch (error: any) {\n debug(`Could not parse the URL scheme: ${error.message}`);\n return;\n }\n\n // Get the hard-coded path to the simulator's scheme approval plist file.\n const plistPath = path.join(\n os.homedir(),\n `Library/Developer/CoreSimulator/Devices`,\n device.udid,\n `data/Library/Preferences/com.apple.launchservices.schemeapproval.plist`\n );\n\n const plistData = fs.existsSync(plistPath)\n ? // If the file exists, then read it in the bplist format.\n await parsePlistAsync(plistPath)\n : // The file doesn't exist when we first launch the simulator, but an empty object can be used to create it (June 2024 x Xcode 15.3).\n // Can be tested by launching a new simulator or by deleting the file and relaunching the simulator.\n {};\n\n debug('Allowed links:', plistData);\n const key = `com.apple.CoreSimulator.CoreSimulatorBridge-->${scheme}`;\n // Replace any existing value for the scheme with the new appId.\n plistData[key] = appId;\n debug('Allowing deep link:', { key, appId });\n\n try {\n const data = bplistCreator(plistData);\n // Write the updated plist back to disk\n await fs.promises.writeFile(plistPath, data);\n } catch (error: any) {\n Log.warn(`Could not update simulator linking permissions: ${error.message}`);\n }\n}\n\nconst updateSimulatorLinkingPermissionsAsyncMemo = memoize(updateSimulatorLinkingPermissionsAsync);\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; appId?: string }\n): Promise<void> {\n if (options.appId) {\n await profile(\n updateSimulatorLinkingPermissionsAsyncMemo,\n 'updateSimulatorLinkingPermissionsAsync'\n )({ udid: device.udid }, options);\n }\n\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","debug","require","value","knownTypes","includes","Log","warn","join","device","appId","stdout","resolveId","trim","error","stderr","match","key","containerPath","ensuredContainerPath","output","spawnAsync","stdio","updateSimulatorLinkingPermissionsAsync","url","udid","scheme","URL","protocol","slice","message","plistPath","path","os","homedir","plistData","fs","existsSync","parsePlistAsync","data","bplistCreator","promises","writeFile","updateSimulatorLinkingPermissionsAsyncMemo","memoize","options","profile","results","openAppIdInternalAsync","status","CommandError","simulatorDeviceInfo","getRuntimesAsync","Object","values","devices","flatMap","runtime","filter","state","find","bootedDevice","filePath","parseSimControlJSONResults","input","JSON","parse","type","query","result","info","keys","runtimeSuffix","split","pop","osType","osVersionComponents","osVersion","sims","windowName","name","flat","args","xcrunAsync"],"mappings":"AAAA;;;;;;;;;;;IAyDgBA,QAAQ,MAARA,QAAQ;IAiBFC,qBAAqB,MAArBA,qBAAqB;IAoBrBC,sBAAsB,MAAtBA,sBAAsB;IA0FtBC,YAAY,MAAZA,YAAY;IA+BZC,cAAc,MAAdA,cAAc;IA8BdC,SAAS,MAATA,SAAS;IAMTC,wBAAwB,MAAxBA,wBAAwB;IAQxBC,mBAAmB,MAAnBA,mBAAmB;IAWnBC,eAAe,MAAfA,eAAe;IAYfC,YAAY,MAAZA,Y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GAAG,MAAMC,gBAAgB,CAAC,SAAS,CAAC,AAAC;IAC9D,OAAOC,MAAM,CAACC,MAAM,CAACH,mBAAmB,CAACI,OAAO,CAAC,CAAC0B,IAAI,EAAE,CAAC;AAC3D,CAAC;AAGM,eAAejF,WAAW,CAC/BkF,IAA4B,EAC5BrC,OAAsB,EACA;IACtB,OAAOsC,IAAAA,MAAU,WAAA,EAAC;QAAC,QAAQ;WAAKD,IAAI;KAAC,EAAErC,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,SAASjC,SAAS,CAACH,MAA8B,EAAU;QAClDA,KAAW;IAAlB,OAAOA,CAAAA,KAAW,GAAXA,MAAM,CAACgB,IAAI,YAAXhB,KAAW,GAAI,QAAQ,CAAC;AACjC,CAAC"}
|
|
@@ -167,7 +167,9 @@ class BundlerDevServer {
|
|
|
167
167
|
await this._startTunnelAsync();
|
|
168
168
|
}
|
|
169
169
|
await this.startDevSessionAsync();
|
|
170
|
-
|
|
170
|
+
if (!options.isExporting) {
|
|
171
|
+
this.watchConfig();
|
|
172
|
+
}
|
|
171
173
|
}
|
|
172
174
|
watchConfig() {
|
|
173
175
|
var ref;
|
|
@@ -247,11 +249,16 @@ class BundlerDevServer {
|
|
|
247
249
|
// Close the server.
|
|
248
250
|
debug(`Stopping dev server (bundler: ${this.name})`);
|
|
249
251
|
if ((ref = this.instance) == null ? void 0 : ref.server) {
|
|
252
|
+
// Check if server is even running.
|
|
250
253
|
this.instance.server.close((error)=>{
|
|
251
254
|
debug(`Stopped dev server (bundler: ${this.name})`);
|
|
252
255
|
this.instance = null;
|
|
253
256
|
if (error) {
|
|
254
|
-
|
|
257
|
+
if ("code" in error && error.code === "ERR_SERVER_NOT_RUNNING") {
|
|
258
|
+
resolve();
|
|
259
|
+
} else {
|
|
260
|
+
reject(error);
|
|
261
|
+
}
|
|
255
262
|
} else {
|
|
256
263
|
resolve();
|
|
257
264
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import assert from 'assert';\nimport resolveFrom from 'resolve-from';\n\nimport { AsyncNgrok } from './AsyncNgrok';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { openBrowserAsync } from '../../utils/open';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\n\nexport type MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\n addListener?(event: string, listener: (...args: any[]) => void): unknown;\n};\n\nexport type DevServerInstance = {\n /** Bundler dev server instance. */\n server: ServerLike;\n /** Dev server URL location properties. */\n location: {\n url: string;\n port: number;\n protocol: 'http' | 'https';\n host?: string;\n };\n /** Additional middleware that's attached to the `server`. */\n middleware: any;\n /** Message socket for communicating with the runtime. */\n messageSocket: MessageSocket;\n};\n\nexport interface BundlerStartOptions {\n /** Should the dev server use `https` protocol. */\n https?: boolean;\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Is dev client enabled. */\n devClient?: boolean;\n /** Should run dev servers with clean caches. */\n resetDevServer?: boolean;\n /** Code signing private key path (defaults to same directory as certificate) */\n privateKeyPath?: string;\n\n /** Max amount of workers (threads) to use with Metro bundler, defaults to undefined for max workers. */\n maxWorkers?: number;\n /** Port to start the dev server on. */\n port?: number;\n\n /** Should start a headless dev server e.g. mock representation to approximate info from a server running in a different process. */\n headless?: boolean;\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n\n /** Will the bundler be used for exporting. NOTE: This is an odd option to pass to the dev server. */\n isExporting?: boolean;\n\n // Webpack options\n /** Should modify and create PWA icons. */\n isImageEditingEnabled?: boolean;\n\n location: CreateURLOptions;\n}\n\nconst PLATFORM_MANAGERS = {\n simulator: () =>\n require('../platforms/ios/ApplePlatformManager')\n .ApplePlatformManager as typeof import('../platforms/ios/ApplePlatformManager').ApplePlatformManager,\n emulator: () =>\n require('../platforms/android/AndroidPlatformManager')\n .AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Ngrok instance for managing tunnel connections. */\n protected ngrok: AsyncNgrok | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n private notifier: FileNotifier | null = null;\n protected readonly devToolsPluginManager: DevToolsPluginManager;\n public isDevClient: boolean;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n /** Advanced options */\n options?: {\n /**\n * The instance of DevToolsPluginManager\n * @default new DevToolsPluginManager(projectRoot)\n */\n devToolsPluginManager?: DevToolsPluginManager;\n // TODO: Replace with custom scheme maybe...\n isDevClient?: boolean;\n }\n ) {\n this.devToolsPluginManager =\n options?.devToolsPluginManager ?? new DevToolsPluginManager(projectRoot);\n this.isDevClient = options?.isDevClient ?? false;\n }\n\n protected setInstance(instance: DevServerInstance) {\n this.instance = instance;\n }\n\n /** Get the manifest middleware function. */\n protected async getManifestMiddlewareAsync(\n options: Pick<BundlerStartOptions, 'minify' | 'mode' | 'privateKeyPath'> = {}\n ) {\n const Middleware = require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware;\n\n const urlCreator = this.getUrlCreator();\n const middleware = new Middleware(this.projectRoot, {\n constructUrl: urlCreator.constructUrl.bind(urlCreator),\n mode: options.mode,\n minify: options.minify,\n isNativeWebpack: this.name === 'webpack' && this.isTargetingNative(),\n privateKeyPath: options.privateKeyPath,\n });\n return middleware;\n }\n\n /** Start the dev server using settings defined in the start command. */\n public async startAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n await this.stopAsync();\n\n let instance: DevServerInstance;\n if (options.headless) {\n instance = await this.startHeadlessAsync(options);\n } else {\n instance = await this.startImplementationAsync(options);\n }\n\n this.setInstance(instance);\n await this.postStartAsync(options);\n return instance;\n }\n\n protected abstract startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance>;\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n return false;\n }\n\n public abstract startTypeScriptServices(): Promise<void>;\n\n public async watchEnvironmentVariables(): Promise<void> {\n // noop -- We've only implemented this functionality in Metro.\n }\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: () => {\n this.instance = null;\n },\n addListener() {},\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n /**\n * Runs after the `startAsync` function, performing any additional common operations.\n * You can assume the dev server is started by the time this function is called.\n */\n protected async postStartAsync(options: BundlerStartOptions) {\n if (\n options.location.hostType === 'tunnel' &&\n !env.EXPO_OFFLINE &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n }\n await this.startDevSessionAsync();\n\n this.watchConfig();\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n this.notifier?.stopObserving();\n this.notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n this.notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[ngrok] connect to port: ' + port);\n this.ngrok = new AsyncNgrok(this.projectRoot, port);\n await this.ngrok.startAsync();\n return this.ngrok;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n this.devSession?.stopNotifying?.();\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' }),\n () => {\n // TODO: This appears to be happening consistently after an hour.\n // We should investigate why this is happening and fix it on our servers.\n // Log.error(\n // chalk.red(\n // '\\nAn unexpected error occurred while updating the Dev Session API. This project will not appear in the \"Development servers\" section of the Expo Go app until this process has been restarted.'\n // )\n // );\n // Log.exception(error);\n this.devSession?.closeAsync().catch((error) => {\n debug('[dev-session] error closing: ' + error.message);\n });\n }\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop file watching.\n this.notifier?.stopObserving();\n\n // Stop the dev session timer and tell Expo API to remove dev session.\n await this.devSession?.closeAsync();\n\n // Stop ngrok if running.\n await this.ngrok?.stopAsync().catch((e) => {\n Log.error(`Error stopping ngrok:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n public getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl()\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n return location.url ?? null;\n }\n\n /** Get the base URL for JS inspector */\n public getJsInspectorBaseUrl(): string {\n if (this.name !== 'metro') {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the JS inspector base url - bundler[${this.name}]`\n );\n }\n return this.getUrlCreator().constructUrl({ scheme: 'http' });\n }\n\n /** Get the tunnel URL from ngrok. */\n public getTunnelUrl(): string | null {\n return this.ngrok?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const serverUrl = this.getDevServerUrl({ hostType: 'localhost' });\n // Allow opening the tunnel URL when using Metro web.\n const url = this.name === 'metro' ? this.getTunnelUrl() ?? serverUrl : serverUrl;\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<BaseOpenInCustomProps> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(): string {\n return this.getUrlCreator().constructUrl({ scheme: 'exp' });\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected isRedirectPageEnabled(): boolean {\n return (\n !env.EXPO_NO_REDIRECT_PAGE &&\n // if user passed --dev-client flag, skip interstitial page\n !this.isDevClient &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-client')\n );\n }\n\n /** Get the redirect URL when redirecting is enabled. */\n public getRedirectUrl(platform: keyof typeof PLATFORM_MANAGERS | null = null): string | null {\n if (!this.isRedirectPageEnabled()) {\n debug('Redirect page is disabled');\n return null;\n }\n\n return (\n this.getUrlCreator().constructLoadingUrl(\n {},\n platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null\n ) ?? null\n );\n }\n\n public getReactDevToolsUrl(): string {\n return new URL(\n '_expo/react-devtools',\n this.getUrlCreator().constructUrl({ scheme: 'http' })\n ).toString();\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this),\n getRedirectUrl: this.getRedirectUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["BundlerDevServer","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","constructor","projectRoot","platformBundlers","options","ngrok","devSession","instance","platformManagers","urlCreator","notifier","devToolsPluginManager","DevToolsPluginManager","isDevClient","setInstance","getManifestMiddlewareAsync","Middleware","ExpoGoManifestHandlerMiddleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","waitForTypeScriptAsync","watchEnvironmentVariables","port","CommandError","server","close","addListener","location","host","url","protocol","messageSocket","broadcast","hostType","env","EXPO_OFFLINE","_startTunnelAsync","startDevSessionAsync","watchConfig","stopObserving","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncNgrok","stopNotifying","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","closeAsync","catch","error","message","runtime","isTargetingWeb","web","broadcastMessage","method","params","e","Log","exception","resolveWithTimeout","Promise","resolve","reject","timeout","errorMessage","assert","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getJsInspectorBaseUrl","getActiveUrl","openPlatformAsync","launchTarget","resolver","serverUrl","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","getExpoGoUrl","isRedirectPageEnabled","EXPO_NO_REDIRECT_PAGE","resolveFrom","silent","getRedirectUrl","platform","constructLoadingUrl","getReactDevToolsUrl","URL","toString","Manager","getCustomRuntimeUrl"],"mappings":"AAAA;;;;+BAwFsBA,kBAAgB;;aAAhBA,gBAAgB;;;8DAxFnB,QAAQ;;;;;;;8DACH,cAAc;;;;;;4BAEX,cAAc;4EACP,yBAAyB;oCACxB,sBAAsB;4BACZ,cAAc;2DAEtC,WAAW;8BACH,0BAA0B;uBACpB,mBAAmB;qBAClC,iBAAiB;wBACR,oBAAoB;sBAChB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOnD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,6BAA6B,CAAC,AAAsB,AAAC;AA2DpF,MAAMC,iBAAiB,GAAG;IACxBC,SAAS,EAAE,IACTF,OAAO,CAAC,uCAAuC,CAAC,CAC7CG,oBAAoB,AAA+E;IACxGC,QAAQ,EAAE,IACRJ,OAAO,CAAC,6CAA6C,CAAC,CACnDK,sBAAs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,UAAU,CAAC6E,qBAAqB,CAACjE,IAAI,CAAC,IAAI,CAACZ,UAAU,CAAC;gBAChF4F,YAAY,EAAE,IAAI,CAACA,YAAY,CAAChF,IAAI,CAAC,IAAI,CAAC;gBAC1CqF,cAAc,EAAE,IAAI,CAACA,cAAc,CAACrF,IAAI,CAAC,IAAI,EAAEsF,QAAQ,CAAC;gBACxD7C,eAAe,EAAE,IAAI,CAACA,eAAe,CAACzC,IAAI,CAAC,IAAI,EAAE;oBAAE0B,QAAQ,EAAE,WAAW;iBAAE,CAAC;aAC5E,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAACvC,gBAAgB,CAACmG,QAAQ,CAAC,CAAC;IACzC;CACD"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import assert from 'assert';\nimport resolveFrom from 'resolve-from';\n\nimport { AsyncNgrok } from './AsyncNgrok';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { openBrowserAsync } from '../../utils/open';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\n\nexport type MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\n addListener?(event: string, listener: (...args: any[]) => void): unknown;\n};\n\nexport type DevServerInstance = {\n /** Bundler dev server instance. */\n server: ServerLike;\n /** Dev server URL location properties. */\n location: {\n url: string;\n port: number;\n protocol: 'http' | 'https';\n host?: string;\n };\n /** Additional middleware that's attached to the `server`. */\n middleware: any;\n /** Message socket for communicating with the runtime. */\n messageSocket: MessageSocket;\n};\n\nexport interface BundlerStartOptions {\n /** Should the dev server use `https` protocol. */\n https?: boolean;\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Is dev client enabled. */\n devClient?: boolean;\n /** Should run dev servers with clean caches. */\n resetDevServer?: boolean;\n /** Code signing private key path (defaults to same directory as certificate) */\n privateKeyPath?: string;\n\n /** Max amount of workers (threads) to use with Metro bundler, defaults to undefined for max workers. */\n maxWorkers?: number;\n /** Port to start the dev server on. */\n port?: number;\n\n /** Should start a headless dev server e.g. mock representation to approximate info from a server running in a different process. */\n headless?: boolean;\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n\n /** Will the bundler be used for exporting. NOTE: This is an odd option to pass to the dev server. */\n isExporting?: boolean;\n\n // Webpack options\n /** Should modify and create PWA icons. */\n isImageEditingEnabled?: boolean;\n\n location: CreateURLOptions;\n}\n\nconst PLATFORM_MANAGERS = {\n simulator: () =>\n require('../platforms/ios/ApplePlatformManager')\n .ApplePlatformManager as typeof import('../platforms/ios/ApplePlatformManager').ApplePlatformManager,\n emulator: () =>\n require('../platforms/android/AndroidPlatformManager')\n .AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Ngrok instance for managing tunnel connections. */\n protected ngrok: AsyncNgrok | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n private notifier: FileNotifier | null = null;\n protected readonly devToolsPluginManager: DevToolsPluginManager;\n public isDevClient: boolean;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n /** Advanced options */\n options?: {\n /**\n * The instance of DevToolsPluginManager\n * @default new DevToolsPluginManager(projectRoot)\n */\n devToolsPluginManager?: DevToolsPluginManager;\n // TODO: Replace with custom scheme maybe...\n isDevClient?: boolean;\n }\n ) {\n this.devToolsPluginManager =\n options?.devToolsPluginManager ?? new DevToolsPluginManager(projectRoot);\n this.isDevClient = options?.isDevClient ?? false;\n }\n\n protected setInstance(instance: DevServerInstance) {\n this.instance = instance;\n }\n\n /** Get the manifest middleware function. */\n protected async getManifestMiddlewareAsync(\n options: Pick<BundlerStartOptions, 'minify' | 'mode' | 'privateKeyPath'> = {}\n ) {\n const Middleware = require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware;\n\n const urlCreator = this.getUrlCreator();\n const middleware = new Middleware(this.projectRoot, {\n constructUrl: urlCreator.constructUrl.bind(urlCreator),\n mode: options.mode,\n minify: options.minify,\n isNativeWebpack: this.name === 'webpack' && this.isTargetingNative(),\n privateKeyPath: options.privateKeyPath,\n });\n return middleware;\n }\n\n /** Start the dev server using settings defined in the start command. */\n public async startAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n await this.stopAsync();\n\n let instance: DevServerInstance;\n if (options.headless) {\n instance = await this.startHeadlessAsync(options);\n } else {\n instance = await this.startImplementationAsync(options);\n }\n\n this.setInstance(instance);\n await this.postStartAsync(options);\n return instance;\n }\n\n protected abstract startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance>;\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n return false;\n }\n\n public abstract startTypeScriptServices(): Promise<void>;\n\n public async watchEnvironmentVariables(): Promise<void> {\n // noop -- We've only implemented this functionality in Metro.\n }\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: () => {\n this.instance = null;\n },\n addListener() {},\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n /**\n * Runs after the `startAsync` function, performing any additional common operations.\n * You can assume the dev server is started by the time this function is called.\n */\n protected async postStartAsync(options: BundlerStartOptions) {\n if (\n options.location.hostType === 'tunnel' &&\n !env.EXPO_OFFLINE &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n }\n await this.startDevSessionAsync();\n\n if (!options.isExporting) {\n this.watchConfig();\n }\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n this.notifier?.stopObserving();\n this.notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n this.notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[ngrok] connect to port: ' + port);\n this.ngrok = new AsyncNgrok(this.projectRoot, port);\n await this.ngrok.startAsync();\n return this.ngrok;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n this.devSession?.stopNotifying?.();\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' }),\n () => {\n // TODO: This appears to be happening consistently after an hour.\n // We should investigate why this is happening and fix it on our servers.\n // Log.error(\n // chalk.red(\n // '\\nAn unexpected error occurred while updating the Dev Session API. This project will not appear in the \"Development servers\" section of the Expo Go app until this process has been restarted.'\n // )\n // );\n // Log.exception(error);\n this.devSession?.closeAsync().catch((error) => {\n debug('[dev-session] error closing: ' + error.message);\n });\n }\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop file watching.\n this.notifier?.stopObserving();\n\n // Stop the dev session timer and tell Expo API to remove dev session.\n await this.devSession?.closeAsync();\n\n // Stop ngrok if running.\n await this.ngrok?.stopAsync().catch((e) => {\n Log.error(`Error stopping ngrok:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n // Check if server is even running.\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n if ('code' in error && error.code === 'ERR_SERVER_NOT_RUNNING') {\n resolve();\n } else {\n reject(error);\n }\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n public getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl()\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n return location.url ?? null;\n }\n\n /** Get the base URL for JS inspector */\n public getJsInspectorBaseUrl(): string {\n if (this.name !== 'metro') {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the JS inspector base url - bundler[${this.name}]`\n );\n }\n return this.getUrlCreator().constructUrl({ scheme: 'http' });\n }\n\n /** Get the tunnel URL from ngrok. */\n public getTunnelUrl(): string | null {\n return this.ngrok?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const serverUrl = this.getDevServerUrl({ hostType: 'localhost' });\n // Allow opening the tunnel URL when using Metro web.\n const url = this.name === 'metro' ? this.getTunnelUrl() ?? serverUrl : serverUrl;\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<BaseOpenInCustomProps> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(): string {\n return this.getUrlCreator().constructUrl({ scheme: 'exp' });\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected isRedirectPageEnabled(): boolean {\n return (\n !env.EXPO_NO_REDIRECT_PAGE &&\n // if user passed --dev-client flag, skip interstitial page\n !this.isDevClient &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-client')\n );\n }\n\n /** Get the redirect URL when redirecting is enabled. */\n public getRedirectUrl(platform: keyof typeof PLATFORM_MANAGERS | null = null): string | null {\n if (!this.isRedirectPageEnabled()) {\n debug('Redirect page is disabled');\n return null;\n }\n\n return (\n this.getUrlCreator().constructLoadingUrl(\n {},\n platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null\n ) ?? null\n );\n }\n\n public getReactDevToolsUrl(): string {\n return new URL(\n '_expo/react-devtools',\n this.getUrlCreator().constructUrl({ scheme: 'http' })\n ).toString();\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this),\n getRedirectUrl: this.getRedirectUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["BundlerDevServer","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","constructor","projectRoot","platformBundlers","options","ngrok","devSession","instance","platformManagers","urlCreator","notifier","devToolsPluginManager","DevToolsPluginManager","isDevClient","setInstance","getManifestMiddlewareAsync","Middleware","ExpoGoManifestHandlerMiddleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","waitForTypeScriptAsync","watchEnvironmentVariables","port","CommandError","server","close","addListener","location","host","url","protocol","messageSocket","broadcast","hostType","env","EXPO_OFFLINE","_startTunnelAsync","startDevSessionAsync","isExporting","watchConfig","stopObserving","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncNgrok","stopNotifying","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","closeAsync","catch","error","message","runtime","isTargetingWeb","web","broadcastMessage","method","params","e","Log","exception","resolveWithTimeout","Promise","resolve","reject","code","timeout","errorMessage","assert","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getJsInspectorBaseUrl","getActiveUrl","openPlatformAsync","launchTarget","resolver","serverUrl","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","getExpoGoUrl","isRedirectPageEnabled","EXPO_NO_REDIRECT_PAGE","resolveFrom","silent","getRedirectUrl","platform","constructLoadingUrl","getReactDevToolsUrl","URL","toString","Man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89,12 +89,24 @@ const BUNDLERS = {
|
|
|
89
89
|
metro: ()=>require("./metro/MetroBundlerDevServer").MetroBundlerDevServer
|
|
90
90
|
};
|
|
91
91
|
class DevServerManager {
|
|
92
|
+
static async startMetroAsync(projectRoot, startOptions) {
|
|
93
|
+
const devServerManager = new DevServerManager(projectRoot, startOptions);
|
|
94
|
+
await devServerManager.startAsync([
|
|
95
|
+
{
|
|
96
|
+
type: "metro",
|
|
97
|
+
options: startOptions
|
|
98
|
+
},
|
|
99
|
+
]);
|
|
100
|
+
return devServerManager;
|
|
101
|
+
}
|
|
92
102
|
constructor(projectRoot, options){
|
|
93
103
|
this.projectRoot = projectRoot;
|
|
94
104
|
this.options = options;
|
|
95
105
|
this.projectPrerequisites = [];
|
|
96
106
|
this.notifier = null;
|
|
97
|
-
|
|
107
|
+
if (!options.isExporting) {
|
|
108
|
+
this.notifier = this.watchBabelConfig();
|
|
109
|
+
}
|
|
98
110
|
this.devtoolsPluginManager = new _devToolsPluginManager.default(projectRoot);
|
|
99
111
|
}
|
|
100
112
|
watchBabelConfig() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { getPlatformBundlers } from './platformBundlers';\nimport { Log } from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { env } from '../../utils/env';\nimport { logEventAsync } from '../../utils/telemetry';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport { TypeScriptProjectPrerequisite } from '../doctor/typescript/TypeScriptProjectPrerequisite';\nimport { printItem } from '../interface/commandsTable';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { resolveSchemeAsync } from '../resolveOptions';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst devServers: BundlerDevServer[] = [];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n private projectPrerequisites: ProjectPrerequisite<any, void>[] = [];\n public readonly devtoolsPluginManager: DevToolsPluginManager;\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n this.notifier = this.watchBabelConfig();\n this.devtoolsPluginManager = new DevToolsPluginManager(projectRoot);\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite<any, any>) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n return await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(this.projectRoot, exp).web;\n debug(`Starting ${bundler} dev server for web`);\n return this.startAsync([\n {\n type: bundler,\n options: this.options,\n },\n ]);\n }\n\n /** Switch between Expo Go and Expo Dev Clients. */\n async toggleRuntimeMode(isUsingDevClient: boolean = !this.options.devClient): Promise<boolean> {\n const nextMode = isUsingDevClient ? '--dev-client' : '--go';\n Log.log(printItem(chalk`Switching to {bold ${nextMode}}`));\n\n const nextScheme = await resolveSchemeAsync(this.projectRoot, {\n devClient: isUsingDevClient,\n // NOTE: The custom `--scheme` argument is lost from this point on.\n });\n\n this.options.location.scheme = nextScheme;\n this.options.devClient = isUsingDevClient;\n for (const devServer of devServers) {\n devServer.isDevClient = isUsingDevClient;\n const urlCreator = devServer.getUrlCreator();\n urlCreator.defaults ??= {};\n urlCreator.defaults.scheme = nextScheme;\n }\n\n debug(`New runtime options (runtime: ${nextMode}):`, this.options);\n return true;\n }\n\n /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n\n await logEventAsync('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\n\n const platformBundlers = getPlatformBundlers(this.projectRoot, exp);\n\n // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(this.projectRoot, platformBundlers, {\n devToolsPluginManager: this.devtoolsPluginManager,\n isDevClient: !!options?.devClient,\n });\n await server.startAsync(options ?? this.options);\n devServers.push(server);\n }\n\n return exp;\n }\n\n async bootstrapTypeScriptAsync() {\n const typescriptPrerequisite = await this.ensureProjectPrerequisiteAsync(\n TypeScriptProjectPrerequisite\n );\n\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n return;\n }\n\n // Optionally, wait for the user to add TypeScript during the\n // development cycle.\n const server = devServers.find((server) => server.name === 'metro');\n if (!server) {\n return;\n }\n\n // The dev server shouldn't wait for the typescript services\n if (!typescriptPrerequisite) {\n server.waitForTypeScriptAsync().then(async (success) => {\n if (success) {\n server.startTypeScriptServices();\n }\n });\n } else {\n server.startTypeScriptServices();\n }\n }\n\n async watchEnvironmentVariables() {\n await devServers.find((server) => server.name === 'metro')?.watchEnvironmentVariables();\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n this.notifier?.stopObserving(),\n // Stop all dev servers\n ...devServers.map((server) => server.stopAsync()),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n ]);\n }\n}\n"],"names":["DevServerManager","urlCreator","debug","require","devServers","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","constructor","projectRoot","options","projectPrerequisites","notifier","watchBabelConfig","devtoolsPluginManager","DevToolsPluginManager","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","startAsync","type","toggleRuntimeMode","isUsingDevClient","devClient","nextMode","Log","log","printItem","nextScheme","resolveSchemeAsync","scheme","devServer","isDevClient","getUrlCreator","defaults","startOptions","logEventAsync","sdkVersion","platformBundlers","BundlerDevServerClass","devToolsPluginManager","bootstrapTypeScriptAsync","typescriptPrerequisite","TypeScriptProjectPrerequisite","env","EXPO_NO_TYPESCRIPT_SETUP","name","waitForTypeScriptAsync","then","success","startTypeScriptServices","watchEnvironmentVariables","stopAsync","Promise","allSettled","stopObserving","map","AndroidDebugBridge","getServer"],"mappings":"AAAA;;;;+BAoCaA,kBAAgB;;aAAhBA,gBAAgB;;;yBApCS,cAAc;;;;;;;8DACjC,QAAQ;;;;;;;8DACT,OAAO;;;;;;4EAGS,yBAAyB;kCACvB,oBAAoB;qBACpC,WAAW;8BACF,0BAA0B;qBACnC,iBAAiB;2BACP,uBAAuB;+CAEP,oDAAoD;+BACxE,4BAA4B;2DAClB,0BAA0B;gCAC3B,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAuIhDC,WAAU;AArIhB,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oCAAoC,CAAC,AAAsB,AAAC;AAO3F,MAAMC,UAAU,GAAuB,EAAE,AAAC;AAE1C,MAAMC,QAAQ,GAAG;IACfC,OAAO,EAAE,IACPH,OAAO,CAAC,mCAAmC,CAAC,CACzCI,uBAAuB,AAA8E;IAC1GC,KAAK,EAAE,IACLL,OAAO,CAAC,+BAA+B,CAAC,CACrCM,qBAAqB,AAAwE;CACnG,AAAC;AAGK,MAAMT,gBAAgB;IAM3BU,YACSC,WAAmB,EAEnBC,OAA4B,CACnC;QAHOD,mBAAAA,WAAmB,CAAA;QAEnBC,eAAAA,OAA4B,CAAA;aAR7BC,oBAAoB,GAAqC,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AAW;YACXK,IAAkB,CAACC,SAAS,EAAE,CAACN,SAAS,EAAE;SAC3C,CAAC,CAAC;IACL;CACD"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { getPlatformBundlers } from './platformBundlers';\nimport { Log } from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { env } from '../../utils/env';\nimport { logEventAsync } from '../../utils/telemetry';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport { TypeScriptProjectPrerequisite } from '../doctor/typescript/TypeScriptProjectPrerequisite';\nimport { printItem } from '../interface/commandsTable';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { resolveSchemeAsync } from '../resolveOptions';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst devServers: BundlerDevServer[] = [];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n static async startMetroAsync(projectRoot: string, startOptions: BundlerStartOptions) {\n const devServerManager = new DevServerManager(projectRoot, startOptions);\n\n await devServerManager.startAsync([\n {\n type: 'metro',\n options: startOptions,\n },\n ]);\n return devServerManager;\n }\n\n private projectPrerequisites: ProjectPrerequisite<any, void>[] = [];\n public readonly devtoolsPluginManager: DevToolsPluginManager;\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n if (!options.isExporting) {\n this.notifier = this.watchBabelConfig();\n }\n this.devtoolsPluginManager = new DevToolsPluginManager(projectRoot);\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite<any, any>) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n return await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(this.projectRoot, exp).web;\n debug(`Starting ${bundler} dev server for web`);\n return this.startAsync([\n {\n type: bundler,\n options: this.options,\n },\n ]);\n }\n\n /** Switch between Expo Go and Expo Dev Clients. */\n async toggleRuntimeMode(isUsingDevClient: boolean = !this.options.devClient): Promise<boolean> {\n const nextMode = isUsingDevClient ? '--dev-client' : '--go';\n Log.log(printItem(chalk`Switching to {bold ${nextMode}}`));\n\n const nextScheme = await resolveSchemeAsync(this.projectRoot, {\n devClient: isUsingDevClient,\n // NOTE: The custom `--scheme` argument is lost from this point on.\n });\n\n this.options.location.scheme = nextScheme;\n this.options.devClient = isUsingDevClient;\n for (const devServer of devServers) {\n devServer.isDevClient = isUsingDevClient;\n const urlCreator = devServer.getUrlCreator();\n urlCreator.defaults ??= {};\n urlCreator.defaults.scheme = nextScheme;\n }\n\n debug(`New runtime options (runtime: ${nextMode}):`, this.options);\n return true;\n }\n\n /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n\n await logEventAsync('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\n\n const platformBundlers = getPlatformBundlers(this.projectRoot, exp);\n\n // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(this.projectRoot, platformBundlers, {\n devToolsPluginManager: this.devtoolsPluginManager,\n isDevClient: !!options?.devClient,\n });\n await server.startAsync(options ?? this.options);\n devServers.push(server);\n }\n\n return exp;\n }\n\n async bootstrapTypeScriptAsync() {\n const typescriptPrerequisite = await this.ensureProjectPrerequisiteAsync(\n TypeScriptProjectPrerequisite\n );\n\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n return;\n }\n\n // Optionally, wait for the user to add TypeScript during the\n // development cycle.\n const server = devServers.find((server) => server.name === 'metro');\n if (!server) {\n return;\n }\n\n // The dev server shouldn't wait for the typescript services\n if (!typescriptPrerequisite) {\n server.waitForTypeScriptAsync().then(async (success) => {\n if (success) {\n server.startTypeScriptServices();\n }\n });\n } else {\n server.startTypeScriptServices();\n }\n }\n\n async watchEnvironmentVariables() {\n await devServers.find((server) => server.name === 'metro')?.watchEnvironmentVariables();\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n this.notifier?.stopObserving(),\n // Stop all dev servers\n ...devServers.map((server) => server.stopAsync()),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n ]);\n }\n}\n"],"names":["DevServerManager","urlCreator","debug","require","devServers","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","startMetroAsync","projectRoot","startOptions","devServerManager","startAsync","type","options","constructor","projectPrerequisites","notifier","isExporting","watchBabelConfig","devtoolsPluginManager","DevToolsPluginManager","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","toggleRuntimeMode","isUsingDevClient","devClient","nextMode","Log","log","printItem","nextScheme","resolveSchemeAsync","scheme","devServer","isDevClient","getUrlCreator","defaults","logEventAsync","sdkVersion","platformBundlers","BundlerDevServerClass","devToolsPluginManager","bootstrapTypeScriptAsync","typescriptPrerequisite","TypeScriptProjectPrerequisite","env","EXPO_NO_TYPESCRIPT_SETUP","name","waitForTypeScriptAsync","then","success","startTypeScriptServices","watchEnvironmentVariables","stopAsync","Promise","allSettled","stopObserving","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