@expo/cli 0.2.6 → 0.2.9

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 (43) hide show
  1. package/build/bin/cli +2 -2
  2. package/build/src/install/checkPackages.js +2 -2
  3. package/build/src/install/checkPackages.js.map +1 -1
  4. package/build/src/prebuild/clearNativeFolder.js +5 -2
  5. package/build/src/prebuild/clearNativeFolder.js.map +1 -1
  6. package/build/src/register/registerAsync.js +2 -2
  7. package/build/src/register/registerAsync.js.map +1 -1
  8. package/build/src/run/hints.js +2 -2
  9. package/build/src/run/hints.js.map +1 -1
  10. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +2 -2
  11. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -1
  12. package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +2 -2
  13. package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -1
  14. package/build/src/run/startBundler.js +2 -2
  15. package/build/src/run/startBundler.js.map +1 -1
  16. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +2 -2
  17. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  18. package/build/src/start/platforms/ExpoGoInstaller.js +2 -1
  19. package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
  20. package/build/src/start/platforms/PlatformManager.js +1 -1
  21. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  22. package/build/src/start/platforms/ios/AppleDeviceManager.js +12 -1
  23. package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
  24. package/build/src/start/server/DevelopmentSession.js +11 -6
  25. package/build/src/start/server/DevelopmentSession.js.map +1 -1
  26. package/build/src/start/server/UrlCreator.js +7 -2
  27. package/build/src/start/server/UrlCreator.js.map +1 -1
  28. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
  29. package/build/src/start/startAsync.js +8 -8
  30. package/build/src/start/startAsync.js.map +1 -1
  31. package/build/src/utils/analytics/rudderstackClient.js +24 -38
  32. package/build/src/utils/analytics/rudderstackClient.js.map +1 -1
  33. package/build/src/utils/env.js +16 -0
  34. package/build/src/utils/env.js.map +1 -1
  35. package/build/src/utils/git.js +2 -1
  36. package/build/src/utils/git.js.map +1 -1
  37. package/build/src/utils/interactive.js +11 -0
  38. package/build/src/utils/interactive.js.map +1 -0
  39. package/build/src/utils/ora.js +2 -1
  40. package/build/src/utils/ora.js.map +1 -1
  41. package/build/src/utils/prompts.js +2 -2
  42. package/build/src/utils/prompts.js.map +1 -1
  43. package/package.json +5 -5
@@ -6,8 +6,11 @@ exports.ensureSimulatorOpenAsync = ensureSimulatorOpenAsync;
6
6
  var osascript = _interopRequireWildcard(require("@expo/osascript"));
7
7
  var _assert = _interopRequireDefault(require("assert"));
8
8
  var _chalk = _interopRequireDefault(require("chalk"));
9
+ var _fs = _interopRequireDefault(require("fs"));
10
+ var _path = _interopRequireDefault(require("path"));
9
11
  var _delay = require("../../../utils/delay");
10
12
  var _errors = require("../../../utils/errors");
13
+ var _plist = require("../../../utils/plist");
11
14
  var _url = require("../../../utils/url");
12
15
  var _deviceManager = require("../DeviceManager");
13
16
  var _expoGoInstaller = require("../ExpoGoInstaller");
@@ -42,6 +45,7 @@ function _interopRequireWildcard(obj) {
42
45
  return newObj;
43
46
  }
44
47
  }
48
+ const debug = require("debug")("expo:start:platforms:ios:AppleDeviceManager");
45
49
  const EXPO_GO_BUNDLE_IDENTIFIER = "host.exp.Exponent";
46
50
  async function ensureSimulatorOpenAsync({ udid , osType } = {}, tryAgain = true) {
47
51
  // Use a default simulator if none was specified
@@ -146,7 +150,14 @@ class AppleDeviceManager extends _deviceManager.DeviceManager {
146
150
  await this.waitForAppInstalledAsync(await this.getApplicationIdFromBundle(filePath));
147
151
  }
148
152
  async getApplicationIdFromBundle(filePath) {
149
- // TODO: Implement...
153
+ debug("getApplicationIdFromBundle:", filePath);
154
+ const builtInfoPlistPath = _path.default.join(filePath, "Info.plist");
155
+ if (_fs.default.existsSync(builtInfoPlistPath)) {
156
+ const { CFBundleIdentifier } = await (0, _plist).parsePlistAsync(builtInfoPlistPath);
157
+ debug("getApplicationIdFromBundle: using built Info.plist", CFBundleIdentifier);
158
+ return CFBundleIdentifier;
159
+ }
160
+ debug("getApplicationIdFromBundle: no Info.plist found");
150
161
  return EXPO_GO_BUNDLE_IDENTIFIER;
151
162
  }
152
163
  async waitForAppInstalledAsync(applicationId) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/ios/AppleDeviceManager.ts"],"sourcesContent":["import * as osascript from '@expo/osascript';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { delayAsync, waitForActionAsync } from '../../../utils/delay';\nimport { CommandError } from '../../../utils/errors';\nimport { validateUrl } from '../../../utils/url';\nimport { DeviceManager } from '../DeviceManager';\nimport { ExpoGoInstaller } from '../ExpoGoInstaller';\nimport { BaseResolveDeviceProps } from '../PlatformManager';\nimport { assertSystemRequirementsAsync } from './assertSystemRequirements';\nimport { ensureSimulatorAppRunningAsync } from './ensureSimulatorAppRunning';\nimport {\n getBestBootedSimulatorAsync,\n getBestUnbootedSimulatorAsync,\n getSelectableSimulatorsAsync,\n} from './getBestSimulator';\nimport { promptAppleDeviceAsync } from './promptAppleDevice';\nimport * as SimControl from './simctl';\n\nconst EXPO_GO_BUNDLE_IDENTIFIER = 'host.exp.Exponent';\n\n/**\n * Ensure a simulator is booted and the Simulator app is opened.\n * This is where any timeout related error handling should live.\n */\nexport async function ensureSimulatorOpenAsync(\n { udid, osType }: Partial<Pick<SimControl.Device, 'udid' | 'osType'>> = {},\n tryAgain: boolean = true\n): Promise<SimControl.Device> {\n // Use a default simulator if none was specified\n if (!udid) {\n // If a simulator is open, side step the entire booting sequence.\n const simulatorOpenedByApp = await getBestBootedSimulatorAsync({ osType });\n if (simulatorOpenedByApp) {\n return simulatorOpenedByApp;\n }\n\n // Otherwise, find the best possible simulator from user defaults and continue\n const bestUdid = await getBestUnbootedSimulatorAsync({ osType });\n if (!bestUdid) {\n throw new CommandError('No simulators found.');\n }\n udid = bestUdid;\n }\n\n const bootedDevice = await waitForActionAsync({\n action: () => {\n // Just for the type check.\n assert(udid);\n return SimControl.bootAsync({ udid });\n },\n });\n\n if (!bootedDevice) {\n // Give it a second chance, this might not be needed but it could potentially lead to a better UX on slower devices.\n if (tryAgain) {\n return await ensureSimulatorOpenAsync({ udid, osType }, false);\n }\n // TODO: We should eliminate all needs for a timeout error, it's bad UX to get an error about the simulator not starting while the user can clearly see it starting on their slow computer.\n throw new CommandError(\n 'SIMULATOR_TIMEOUT',\n `Simulator didn't boot fast enough. Try opening Simulator first, then running your app.`\n );\n }\n return bootedDevice;\n}\nexport class AppleDeviceManager extends DeviceManager<SimControl.Device> {\n static assertSystemRequirementsAsync = assertSystemRequirementsAsync;\n\n static async resolveAsync({\n device,\n shouldPrompt,\n }: BaseResolveDeviceProps<\n Partial<Pick<SimControl.Device, 'udid' | 'osType'>>\n > = {}): Promise<AppleDeviceManager> {\n if (shouldPrompt) {\n const devices = await getSelectableSimulatorsAsync(device);\n device = await promptAppleDeviceAsync(devices, device?.osType);\n }\n\n const booted = await ensureSimulatorOpenAsync(device);\n return new AppleDeviceManager(booted);\n }\n\n get name() {\n return this.device.name;\n }\n\n get identifier(): string {\n return this.device.udid;\n }\n\n async getAppVersionAsync(appId: string): Promise<string | null> {\n return await SimControl.getInfoPlistValueAsync(this.device, {\n appId,\n key: 'CFBundleShortVersionString',\n });\n }\n\n async startAsync(): Promise<SimControl.Device> {\n return ensureSimulatorOpenAsync({ osType: this.device.osType, udid: this.device.udid });\n }\n\n async launchApplicationIdAsync(appId: string) {\n try {\n const result = await SimControl.openAppIdAsync(this.device, {\n appId,\n });\n if (result.status === 0) {\n await this.activateWindowAsync();\n } else {\n throw new CommandError(result.stderr);\n }\n } catch (error: any) {\n let errorMessage = `Couldn't open iOS app with ID \"${appId}\" on device \"${this.name}\".`;\n if (error instanceof CommandError && error.code === 'APP_NOT_INSTALLED') {\n if (appId === EXPO_GO_BUNDLE_IDENTIFIER) {\n errorMessage = `Couldn't open Expo Go app on device \"${this.name}\". Please install.`;\n } else {\n errorMessage += `\\nThe app might not be installed, try installing it with: ${chalk.bold(\n `expo run:ios -d ${this.device.udid}`\n )}`;\n }\n }\n if (error.stderr) {\n errorMessage += chalk.gray(`\\n${error.stderr}`);\n } else if (error.message) {\n errorMessage += chalk.gray(`\\n${error.message}`);\n }\n throw new CommandError(errorMessage);\n }\n }\n\n async installAppAsync(filePath: string) {\n await SimControl.installAsync(this.device, {\n filePath,\n });\n\n await this.waitForAppInstalledAsync(await this.getApplicationIdFromBundle(filePath));\n }\n\n private async getApplicationIdFromBundle(filePath: string): Promise<string> {\n // TODO: Implement...\n return EXPO_GO_BUNDLE_IDENTIFIER;\n }\n\n private async waitForAppInstalledAsync(applicationId: string): Promise<boolean> {\n while (true) {\n if (await this.isAppInstalledAsync(applicationId)) {\n return true;\n }\n await delayAsync(100);\n }\n }\n\n async uninstallAppAsync(appId: string) {\n await SimControl.uninstallAsync(this.device, {\n appId,\n });\n }\n\n async isAppInstalledAsync(appId: string) {\n return !!(await SimControl.getContainerPathAsync(this.device, {\n appId,\n }));\n }\n\n async openUrlAsync(url: string) {\n // Non-compliant URLs will be treated as application identifiers.\n if (!validateUrl(url, { requireProtocol: true })) {\n return await this.launchApplicationIdAsync(url);\n }\n\n try {\n await SimControl.openUrlAsync(this.device, { url });\n } catch (error: any) {\n // 194 means the device does not conform to a given URL, in this case we'll assume that the desired app is not installed.\n if (error.status === 194) {\n // An error was encountered processing the command (domain=NSOSStatusErrorDomain, code=-10814):\n // The operation couldn’t be completed. (OSStatus error -10814.)\n //\n // This can be thrown when no app conforms to the URI scheme that we attempted to open.\n throw new CommandError(\n 'APP_NOT_INSTALLED',\n `Device ${this.device.name} (${this.device.udid}) has no app to handle the URI: ${url}`\n );\n }\n throw error;\n }\n }\n\n async activateWindowAsync() {\n await ensureSimulatorAppRunningAsync(this.device);\n // TODO: Focus the individual window\n await osascript.execAsync(`tell application \"Simulator\" to activate`);\n }\n\n async ensureExpoGoAsync(sdkVersion?: string): Promise<boolean> {\n const installer = new ExpoGoInstaller('ios', EXPO_GO_BUNDLE_IDENTIFIER, sdkVersion);\n return installer.ensureAsync(this);\n }\n}\n"],"names":["ensureSimulatorOpenAsync","osascript","SimControl","EXPO_GO_BUNDLE_IDENTIFIER","udid","osType","tryAgain","simulatorOpenedByApp","getBestBootedSimulatorAsync","bestUdid","getBestUnbootedSimulatorAsync","CommandError","bootedDevice","waitForActionAsync","action","assert","bootAsync","AppleDeviceManager","DeviceManager","assertSystemRequirementsAsync","resolveAsync","device","shouldPrompt","devices","getSelectableSimulatorsAsync","promptAppleDeviceAsync","booted","name","identifier","getAppVersionAsync","appId","getInfoPlistValueAsync","key","startAsync","launchApplicationIdAsync","result","openAppIdAsync","status","activateWindowAsync","stderr","error","errorMessage","code","chalk","bold","gray","message","installAppAsync","filePath","installAsync","waitForAppInstalledAsync","getApplicationIdFromBundle","applicationId","isAppInstalledAsync","delayAsync","uninstallAppAsync","uninstallAsync","getContainerPathAsync","openUrlAsync","url","validateUrl","requireProtocol","ensureSimulatorAppRunningAsync","execAsync","ensureExpoGoAsync","sdkVersion","installer","ExpoGoInstaller","ensureAsync"],"mappings":"AAAA;;;;QA0BsBA,wBAAwB,GAAxBA,wBAAwB;AA1BlCC,IAAAA,SAAS,mCAAM,iBAAiB,EAAvB;AACF,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEsB,IAAA,MAAsB,WAAtB,sBAAsB,CAAA;AACxC,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACxB,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AAClB,IAAA,cAAkB,WAAlB,kBAAkB,CAAA;AAChB,IAAA,gBAAoB,WAApB,oBAAoB,CAAA;AAEN,IAAA,yBAA4B,WAA5B,4BAA4B,CAAA;AAC3B,IAAA,0BAA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,GAAG,CAAC,CAAC;SACjD;QAED,IAAI;YACF,MAAMzD,UAAU,CAACwD,YAAY,CAAC,IAAI,CAACrC,MAAM,EAAE;gBAAEsC,GAAG;aAAE,CAAC,CAAC;SACrD,CAAC,OAAOnB,KAAK,EAAO;YACnB,yHAAyH;YACzH,IAAIA,KAAK,CAACH,MAAM,KAAK,GAAG,EAAE;gBACxB,+FAA+F;gBAC/F,kEAAgE;gBAChE,EAAE;gBACF,uFAAuF;gBACvF,MAAM,IAAI1B,OAAY,aAAA,CACpB,mBAAmB,EACnB,CAAC,OAAO,EAAE,IAAI,CAACU,MAAM,CAACM,IAAI,CAAC,EAAE,EAAE,IAAI,CAACN,MAAM,CAACjB,IAAI,CAAC,gCAAgC,EAAEuD,GAAG,CAAC,CAAC,CACxF,CAAC;aACH;YACD,MAAMnB,KAAK,CAAC;SACb;KACF;IAED,MAAMF,mBAAmB,GAAG;QAC1B,MAAMwB,CAAAA,GAAAA,0BAA8B,AAAa,CAAA,+BAAb,CAAC,IAAI,CAACzC,MAAM,CAAC,CAAC;QAClD,oCAAoC;QACpC,MAAMpB,SAAS,CAAC8D,SAAS,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC;KACvE;IAED,MAAMC,iBAAiB,CAACC,UAAmB,EAAoB;QAC7D,MAAMC,SAAS,GAAG,IAAIC,gBAAe,gBAAA,CAAC,KAAK,EAAEhE,yBAAyB,EAAE8D,UAAU,CAAC,AAAC;QACpF,OAAOC,SAAS,CAACE,WAAW,CAAC,IAAI,CAAC,CAAC;KACpC;CACF;QAvIYnD,kBAAkB,GAAlBA,kBAAkB"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/ios/AppleDeviceManager.ts"],"sourcesContent":["import * as osascript from '@expo/osascript';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { delayAsync, waitForActionAsync } from '../../../utils/delay';\nimport { CommandError } from '../../../utils/errors';\nimport { parsePlistAsync } from '../../../utils/plist';\nimport { validateUrl } from '../../../utils/url';\nimport { DeviceManager } from '../DeviceManager';\nimport { ExpoGoInstaller } from '../ExpoGoInstaller';\nimport { BaseResolveDeviceProps } from '../PlatformManager';\nimport { assertSystemRequirementsAsync } from './assertSystemRequirements';\nimport { ensureSimulatorAppRunningAsync } from './ensureSimulatorAppRunning';\nimport {\n getBestBootedSimulatorAsync,\n getBestUnbootedSimulatorAsync,\n getSelectableSimulatorsAsync,\n} from './getBestSimulator';\nimport { promptAppleDeviceAsync } from './promptAppleDevice';\nimport * as SimControl from './simctl';\n\nconst debug = require('debug')('expo:start:platforms:ios:AppleDeviceManager') as typeof console.log;\n\nconst EXPO_GO_BUNDLE_IDENTIFIER = 'host.exp.Exponent';\n\n/**\n * Ensure a simulator is booted and the Simulator app is opened.\n * This is where any timeout related error handling should live.\n */\nexport async function ensureSimulatorOpenAsync(\n { udid, osType }: Partial<Pick<SimControl.Device, 'udid' | 'osType'>> = {},\n tryAgain: boolean = true\n): Promise<SimControl.Device> {\n // Use a default simulator if none was specified\n if (!udid) {\n // If a simulator is open, side step the entire booting sequence.\n const simulatorOpenedByApp = await getBestBootedSimulatorAsync({ osType });\n if (simulatorOpenedByApp) {\n return simulatorOpenedByApp;\n }\n\n // Otherwise, find the best possible simulator from user defaults and continue\n const bestUdid = await getBestUnbootedSimulatorAsync({ osType });\n if (!bestUdid) {\n throw new CommandError('No simulators found.');\n }\n udid = bestUdid;\n }\n\n const bootedDevice = await waitForActionAsync({\n action: () => {\n // Just for the type check.\n assert(udid);\n return SimControl.bootAsync({ udid });\n },\n });\n\n if (!bootedDevice) {\n // Give it a second chance, this might not be needed but it could potentially lead to a better UX on slower devices.\n if (tryAgain) {\n return await ensureSimulatorOpenAsync({ udid, osType }, false);\n }\n // TODO: We should eliminate all needs for a timeout error, it's bad UX to get an error about the simulator not starting while the user can clearly see it starting on their slow computer.\n throw new CommandError(\n 'SIMULATOR_TIMEOUT',\n `Simulator didn't boot fast enough. Try opening Simulator first, then running your app.`\n );\n }\n return bootedDevice;\n}\nexport class AppleDeviceManager extends DeviceManager<SimControl.Device> {\n static assertSystemRequirementsAsync = assertSystemRequirementsAsync;\n\n static async resolveAsync({\n device,\n shouldPrompt,\n }: BaseResolveDeviceProps<\n Partial<Pick<SimControl.Device, 'udid' | 'osType'>>\n > = {}): Promise<AppleDeviceManager> {\n if (shouldPrompt) {\n const devices = await getSelectableSimulatorsAsync(device);\n device = await promptAppleDeviceAsync(devices, device?.osType);\n }\n\n const booted = await ensureSimulatorOpenAsync(device);\n return new AppleDeviceManager(booted);\n }\n\n get name() {\n return this.device.name;\n }\n\n get identifier(): string {\n return this.device.udid;\n }\n\n async getAppVersionAsync(appId: string): Promise<string | null> {\n return await SimControl.getInfoPlistValueAsync(this.device, {\n appId,\n key: 'CFBundleShortVersionString',\n });\n }\n\n async startAsync(): Promise<SimControl.Device> {\n return ensureSimulatorOpenAsync({ osType: this.device.osType, udid: this.device.udid });\n }\n\n async launchApplicationIdAsync(appId: string) {\n try {\n const result = await SimControl.openAppIdAsync(this.device, {\n appId,\n });\n if (result.status === 0) {\n await this.activateWindowAsync();\n } else {\n throw new CommandError(result.stderr);\n }\n } catch (error: any) {\n let errorMessage = `Couldn't open iOS app with ID \"${appId}\" on device \"${this.name}\".`;\n if (error instanceof CommandError && error.code === 'APP_NOT_INSTALLED') {\n if (appId === EXPO_GO_BUNDLE_IDENTIFIER) {\n errorMessage = `Couldn't open Expo Go app on device \"${this.name}\". Please install.`;\n } else {\n errorMessage += `\\nThe app might not be installed, try installing it with: ${chalk.bold(\n `expo run:ios -d ${this.device.udid}`\n )}`;\n }\n }\n if (error.stderr) {\n errorMessage += chalk.gray(`\\n${error.stderr}`);\n } else if (error.message) {\n errorMessage += chalk.gray(`\\n${error.message}`);\n }\n throw new CommandError(errorMessage);\n }\n }\n\n async installAppAsync(filePath: string) {\n await SimControl.installAsync(this.device, {\n filePath,\n });\n\n await this.waitForAppInstalledAsync(await this.getApplicationIdFromBundle(filePath));\n }\n\n private async getApplicationIdFromBundle(filePath: string): Promise<string> {\n debug('getApplicationIdFromBundle:', filePath);\n const builtInfoPlistPath = path.join(filePath, 'Info.plist');\n if (fs.existsSync(builtInfoPlistPath)) {\n const { CFBundleIdentifier } = await parsePlistAsync(builtInfoPlistPath);\n debug('getApplicationIdFromBundle: using built Info.plist', CFBundleIdentifier);\n return CFBundleIdentifier;\n }\n debug('getApplicationIdFromBundle: no Info.plist found');\n return EXPO_GO_BUNDLE_IDENTIFIER;\n }\n\n private async waitForAppInstalledAsync(applicationId: string): Promise<boolean> {\n while (true) {\n if (await this.isAppInstalledAsync(applicationId)) {\n return true;\n }\n await delayAsync(100);\n }\n }\n\n async uninstallAppAsync(appId: string) {\n await SimControl.uninstallAsync(this.device, {\n appId,\n });\n }\n\n async isAppInstalledAsync(appId: string) {\n return !!(await SimControl.getContainerPathAsync(this.device, {\n appId,\n }));\n }\n\n async openUrlAsync(url: string) {\n // Non-compliant URLs will be treated as application identifiers.\n if (!validateUrl(url, { requireProtocol: true })) {\n return await this.launchApplicationIdAsync(url);\n }\n\n try {\n await SimControl.openUrlAsync(this.device, { url });\n } catch (error: any) {\n // 194 means the device does not conform to a given URL, in this case we'll assume that the desired app is not installed.\n if (error.status === 194) {\n // An error was encountered processing the command (domain=NSOSStatusErrorDomain, code=-10814):\n // The operation couldn’t be completed. (OSStatus error -10814.)\n //\n // This can be thrown when no app conforms to the URI scheme that we attempted to open.\n throw new CommandError(\n 'APP_NOT_INSTALLED',\n `Device ${this.device.name} (${this.device.udid}) has no app to handle the URI: ${url}`\n );\n }\n throw error;\n }\n }\n\n async activateWindowAsync() {\n await ensureSimulatorAppRunningAsync(this.device);\n // TODO: Focus the individual window\n await osascript.execAsync(`tell application \"Simulator\" to activate`);\n }\n\n async ensureExpoGoAsync(sdkVersion?: string): Promise<boolean> {\n const installer = new ExpoGoInstaller('ios', EXPO_GO_BUNDLE_IDENTIFIER, sdkVersion);\n return installer.ensureAsync(this);\n }\n}\n"],"names":["ensureSimulatorOpenAsync","osascript","SimControl","debug","require","EXPO_GO_BUNDLE_IDENTIFIER","udid","osType","tryAgain","simulatorOpenedByApp","getBestBootedSimulatorAsync","bestUdid","getBestUnbootedSimulatorAsync","CommandError","bootedDevice","waitForActionAsync","action","assert","bootAsync","AppleDeviceManager","DeviceManager","assertSystemRequirementsAsync","resolveAsync","device","shouldPrompt","devices","getSelectableSimulatorsAsync","promptAppleDeviceAsync","booted","name","identifier","getAppVersionAsync","appId","getInfoPlistValueAsync","key","startAsync","launchApplicationIdAsync","result","openAppIdAsync","status","activateWindowAsync","stderr","error","errorMessage","code","chalk","bold","gray","message","installAppAsync","filePath","installAsync","waitForAppInstalledAsync","getApplicationIdFromBundle","builtInfoPlistPath","path","join","fs","existsSync","CFBundleIdentifier","parsePlistAsync","applicationId","isAppInstalledAsync","delayAsync","uninstallAppAsync","uninstallAsync","getContainerPathAsync","openUrlAsync","url","validateUrl","requireProtocol","ensureSimulatorAppRunningAsync","execAsync","ensureExpoGoAsync","sdkVersion","installer","ExpoGoInstaller","ensureAsync"],"mappings":"AAAA;;;;QA+BsBA,wBAAwB,GAAxBA,wBAAwB;AA/BlCC,IAAAA,SAAS,mCAAM,iBAAiB,EAAvB;AACF,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEwB,IAAA,MAAsB,WAAtB,sBAAsB,CAAA;AACxC,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACpB,IAAA,MAAsB,WAAtB,sBAAsB,CAAA;AAC1B,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AAClB,IAAA,cAAkB,WAAlB,kBAAkB,CAAA;AAChB,IAAA,gBAAoB,WAApB,oBAAoB,CAAA;AAEN,IAAA,yBAA4B,WAA5B,4BAA4B,CAAA;AAC3B,IAAA,0BAA6B,WAA7B,6BAA6B,C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CAAC,wCAAwC,CAAC,CAAC,CAAC;KACvE;IAED,MAAMC,iBAAiB,CAACC,UAAmB,EAAoB;QAC7D,MAAMC,SAAS,GAAG,IAAIC,gBAAe,gBAAA,CAAC,KAAK,EAAEvE,yBAAyB,EAAEqE,UAAU,CAAC,AAAC;QACpF,OAAOC,SAAS,CAACE,WAAW,CAAC,IAAI,CAAC,CAAC;KACpC;CACF;QA9IY1D,kBAAkB,GAAlBA,kBAAkB"}
@@ -6,6 +6,7 @@ var _config = require("@expo/config");
6
6
  var _settings = require("../../api/settings");
7
7
  var _updateDevelopmentSession = require("../../api/updateDevelopmentSession");
8
8
  var _user = require("../../api/user/user");
9
+ var _log = require("../../log");
9
10
  var ProjectDevices = _interopRequireWildcard(require("../project/devices"));
10
11
  function _interopRequireWildcard(obj) {
11
12
  if (obj && obj.__esModule) {
@@ -64,12 +65,16 @@ class DevelopmentSession {
64
65
  }
65
66
  if (this.url) {
66
67
  debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);
67
- await (0, _updateDevelopmentSession).updateDevelopmentSessionAsync({
68
- url: this.url,
69
- runtime,
70
- exp,
71
- deviceIds
72
- });
68
+ try {
69
+ await (0, _updateDevelopmentSession).updateDevelopmentSessionAsync({
70
+ url: this.url,
71
+ runtime,
72
+ exp,
73
+ deviceIds
74
+ });
75
+ } catch (error) {
76
+ _log.Log.warn(`Non-fatal error updating development session API: ${error}`);
77
+ }
73
78
  }
74
79
  this.stopNotifying();
75
80
  this.timeout = setTimeout(()=>this.startAsync({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport { APISettings } from '../../api/settings';\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nconst UPDATE_FREQUENCY = 20 * 1000; // 20 seconds\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n private timeout: NodeJS.Timeout | null = null;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * This method starts an interval that will continue to ping the servers until we stop it.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n * @returns\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n if (APISettings.isOffline) {\n debug('Development session will not ping because the server is offline.');\n this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n }\n\n this.stopNotifying();\n\n this.timeout = setTimeout(() => this.startAsync({ exp, runtime }), UPDATE_FREQUENCY);\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Stop notifying the Expo servers that the development session is running. */\n public stopNotifying() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = null;\n }\n\n public async closeAsync(): Promise<void> {\n this.stopNotifying();\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n return;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n }\n}\n"],"names":["ProjectDevices","debug","require","UPDATE_FREQUENCY","isAuthenticatedAsync","getUserAsync","catch","DevelopmentSession","constructor","projectRoot","url","timeout","startAsync","exp","getConfig","runtime","APISettings","isOffline","stopNotifying","deviceIds","getDeviceInstallationIdsAsync","length","updateDevelopmentSessionAsync","setTimeout","devices","getDevicesInfoAsync","map","installationId","clearTimeout","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc,CAAA;AAExB,IAAA,SAAoB,WAApB,oBAAoB,CAAA;AAIzC,IAAA,yBAAoC,WAApC,oCAAoC,CAAA;AACd,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACtCA,IAAAA,cAAc,mCAAM,oBAAoB,EAA1B;;;;;;;;;;;;;;;;;;;;;;AAE1B,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAE7F,MAAMC,gBAAgB,GAAG,EAAE,GAAG,IAAI,AAAC,EAAC,aAAa;AAEjD,eAAeC,oBAAoB,GAAqB;IACtD,OAAO,CAAC,CAAE,MAAMC,CAAAA,GAAAA,KAAY,AAAE,CAAA,aAAF,EAAE,CAACC,KAAK,CAAC,IAAM,IAAI;IAAA,CAAC,AAAC,CAAC;CACnD;AAEM,MAAMC,kBAAkB;IAG7BC,YAEUC,WAAmB,EAEpBC,GAAkB,CACzB;aAHQD,WAAmB,GAAnBA,WAAmB;aAEpBC,GAAkB,GAAlBA,GAAkB;aANnBC,OAAO,GAA0B,IAAI;KAOzC;IAEJ;;;;;;;;;;KAUG,CACH,MAAaC,UAAU,CAAC,EACtBC,GAAG,EAAGC,CAAAA,GAAAA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AAG,CAAC,CAAC,EAAEC,cAAc,CAAA,EAAE,GAAKA,cAAc;QAAA,CAAC,CAAC;KAC5D;IAED,+EAA+E,CAC/E,AAAOT,aAAa,GAAG;QACrB,IAAI,IAAI,CAACP,OAAO,EAAE;YAChBiB,YAAY,CAAC,IAAI,CAACjB,OAAO,CAAC,CAAC;SAC5B;QACD,IAAI,CAACA,OAAO,GAAG,IAAI,CAAC;KACrB;IAED,MAAakB,UAAU,GAAkB;QACvC,IAAI,CAACX,aAAa,EAAE,CAAC;QAErB,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACC,6BAA6B,EAAE,AAAC;QAE7D,IAAI,CAAE,MAAMhB,oBAAoB,EAAE,AAAC,IAAI,CAACe,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEE,MAAM,CAAA,EAAE;YACzD,OAAO;SACR;QAED,IAAI,IAAI,CAACX,GAAG,EAAE;YACZ,MAAMoB,CAAAA,GAAAA,yBAA4B,AAGhC,CAAA,6BAHgC,CAAC;gBACjCpB,GAAG,EAAE,IAAI,CAACA,GAAG;gBACbS,SAAS;aACV,CAAC,CAAC;SACJ;KACF;CACF;QAzFYZ,kBAAkB,GAAlBA,kBAAkB"}
1
+ {"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport { APISettings } from '../../api/settings';\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport { Log } from '../../log';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nconst UPDATE_FREQUENCY = 20 * 1000; // 20 seconds\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n private timeout: NodeJS.Timeout | null = null;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * This method starts an interval that will continue to ping the servers until we stop it.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n * @returns\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n if (APISettings.isOffline) {\n debug('Development session will not ping because the server is offline.');\n this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n try {\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n } catch (error) {\n Log.warn(`Non-fatal error updating development session API: ${error}`);\n }\n }\n\n this.stopNotifying();\n\n this.timeout = setTimeout(() => this.startAsync({ exp, runtime }), UPDATE_FREQUENCY);\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Stop notifying the Expo servers that the development session is running. */\n public stopNotifying() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = null;\n }\n\n public async closeAsync(): Promise<void> {\n this.stopNotifying();\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n return;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n }\n}\n"],"names":["ProjectDevices","debug","require","UPDATE_FREQUENCY","isAuthenticatedAsync","getUserAsync","catch","DevelopmentSession","constructor","projectRoot","url","timeout","startAsync","exp","getConfig","runtime","APISettings","isOffline","stopNotifying","deviceIds","getDeviceInstallationIdsAsync","length","updateDevelopmentSessionAsync","error","Log","warn","setTimeout","devices","getDevicesInfoAsync","map","installationId","clearTimeout","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc,CAAA;AAExB,IAAA,SAAoB,WAApB,oBAAoB,CAAA;AAIzC,IAAA,yBAAoC,WAApC,oCAAoC,CAAA;AACd,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AAC9B,IAAA,IAAW,WAAX,WAAW,CAAA;AACnBA,IAAAA,cAAc,mCAAM,oBAAoB,EAA1B;;;;;;;;;;;;;;;;;;;;;;AAE1B,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAE7F,MAAMC,gBAAgB,GAAG,EAAE,GAAG,IAAI,AAAC,EAAC,aAAa;AAEjD,eAAeC,oBAAoB,GAAqB;IACtD,OAAO,CAAC,CAAE,MAAMC,CAAAA,GAAAA,KAAY,AAAE,CAAA,aAAF,EAAE,CAACC,KAAK,CAAC,IAAM,IAAI;IAAA,CAAC,AAAC,CAAC;CACnD;AAEM,MAAMC,kBAAkB;IAG7BC,YAEUC,WAAmB,EAEpBC,GAAkB,CACzB;aAHQD,WAAmB,GAAnBA,WAAmB;aAEpBC,GAAkB,GAAlBA,GAAkB;aANnBC,OAAO,GAA0B,IAAI;KAOzC;IAEJ;;;;;;;;;;KAUG,CACH,MAAaC,UAAU,CAAC,EACtBC,GAAG,EAAGC,CAAAA,GAAAA,OAAS,AAAkB,CAAA,UAAlB,CAAC,IAAI,CAACL,WAAW,CAAC,CAACI,GAA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BAAmB,CAAC,IAAI,CAACnB,WAAW,CAAC,AAAC;QAC/E,OAAOkB,OAAO,CAACE,GAAG,CAAC,CAAC,EAAEC,cAAc,CAAA,EAAE,GAAKA,cAAc;QAAA,CAAC,CAAC;KAC5D;IAED,+EAA+E,CAC/E,AAAOZ,aAAa,GAAG;QACrB,IAAI,IAAI,CAACP,OAAO,EAAE;YAChBoB,YAAY,CAAC,IAAI,CAACpB,OAAO,CAAC,CAAC;SAC5B;QACD,IAAI,CAACA,OAAO,GAAG,IAAI,CAAC;KACrB;IAED,MAAaqB,UAAU,GAAkB;QACvC,IAAI,CAACd,aAAa,EAAE,CAAC;QAErB,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACC,6BAA6B,EAAE,AAAC;QAE7D,IAAI,CAAE,MAAMhB,oBAAoB,EAAE,AAAC,IAAI,CAACe,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEE,MAAM,CAAA,EAAE;YACzD,OAAO;SACR;QAED,IAAI,IAAI,CAACX,GAAG,EAAE;YACZ,MAAMuB,CAAAA,GAAAA,yBAA4B,AAGhC,CAAA,6BAHgC,CAAC;gBACjCvB,GAAG,EAAE,IAAI,CAACA,GAAG;gBACbS,SAAS;aACV,CAAC,CAAC;SACJ;KACF;CACF;QA7FYZ,kBAAkB,GAAlBA,kBAAkB"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  var _assert = _interopRequireDefault(require("assert"));
6
6
  var _url = require("url");
7
7
  var Log = _interopRequireWildcard(require("../../log"));
8
+ var _env = require("../../utils/env");
8
9
  var _ip = require("../../utils/ip");
9
10
  function _interopRequireDefault(obj) {
10
11
  return obj && obj.__esModule ? obj : {
@@ -153,9 +154,13 @@ function joinUrlComponents({ protocol , hostname , port }) {
153
154
  // This is because Android React Native WebSocket implementation is not spec compliant and fails without a port:
154
155
  // `E unknown:ReactNative: java.lang.IllegalArgumentException: Invalid URL port: "-1"`
155
156
  // Invoked first in `metro-runtime/src/modules/HMRClient.js`
156
- const validPort = port || "80";
157
+ const validPort = _env.env.EXPO_NO_DEFAULT_PORT ? port : port || "80";
157
158
  const validProtocol = protocol ? `${protocol}://` : "";
158
- return `${validProtocol}${hostname}:${validPort}`;
159
+ let url = `${validProtocol}${hostname}`;
160
+ if (validPort) {
161
+ url += `:${validPort}`;
162
+ }
163
+ return url;
159
164
  }
160
165
  /** @deprecated */ function getProxyUrl() {
161
166
  return process.env.EXPO_PACKAGER_PROXY_URL;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport { getIpAddress } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\nexport class UrlCreator {\n constructor(\n private defaults: CreateURLOptions | undefined,\n private bundlerInfo: { port: number; getTunnelUrl?: () => string | null }\n ) {}\n\n /**\n * @returns URL like `http://localhost:19000/_expo/loading?platform=ios`\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n url.search = new URLSearchParams({ platform }).toString();\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase())\n ) {\n return null;\n }\n\n const manifestUrl = this.constructUrl({ ...options, scheme: 'http' });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nfunction getDefaultHostname(options: Pick<CreateURLOptions, 'hostname'>) {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // Restrict the use of `localhost`\n // TODO: Note why we do this.\n return '127.0.0.1';\n }\n\n return options.hostname || getIpAddress();\n}\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n // Android HMR breaks without this port 80.\n // This is because Android React Native WebSocket implementation is not spec compliant and fails without a port:\n // `E unknown:ReactNative: java.lang.IllegalArgumentException: Invalid URL port: \"-1\"`\n // Invoked first in `metro-runtime/src/modules/HMRClient.js`\n const validPort = port || '80';\n const validProtocol = protocol ? `${protocol}://` : '';\n\n return `${validProtocol}${hostname}:${validPort}`;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["Log","debug","require","UrlCreator","constructor","defaults","bundlerInfo","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","hostType","components","warn","getDefaultHostname","parsedProxyUrl","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","getIpAddress","assert","validPort","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACP,IAAA,IAAK,WAAL,KAAK,CAAA;AAEbA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,CAAC,CAAC;CACnD;AAED,kBAAkB,CAClB,SAASb,WAAW,GAAuB;IACzC,OAAOO,OAAO,CAACC,GAAG,CAACO,uBAAuB,CAAC;CAC5C,CAED,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
1
+ {"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport { env } from '../../utils/env';\nimport { getIpAddress } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\nexport class UrlCreator {\n constructor(\n private defaults: CreateURLOptions | undefined,\n private bundlerInfo: { port: number; getTunnelUrl?: () => string | null }\n ) {}\n\n /**\n * @returns URL like `http://localhost:19000/_expo/loading?platform=ios`\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n url.search = new URLSearchParams({ platform }).toString();\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase())\n ) {\n return null;\n }\n\n const manifestUrl = this.constructUrl({ ...options, scheme: 'http' });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nfunction getDefaultHostname(options: Pick<CreateURLOptions, 'hostname'>) {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // Restrict the use of `localhost`\n // TODO: Note why we do this.\n return '127.0.0.1';\n }\n\n return options.hostname || getIpAddress();\n}\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n // Android HMR breaks without this port 80.\n // This is because Android React Native WebSocket implementation is not spec compliant and fails without a port:\n // `E unknown:ReactNative: java.lang.IllegalArgumentException: Invalid URL port: \"-1\"`\n // Invoked first in `metro-runtime/src/modules/HMRClient.js`\n const validPort = env.EXPO_NO_DEFAULT_PORT ? port : port || '80';\n const validProtocol = protocol ? `${protocol}://` : '';\n\n let url = `${validProtocol}${hostname}`;\n\n if (validPort) {\n url += `:${validPort}`;\n }\n\n return url;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["Log","debug","require","UrlCreator","constructor","defaults","bundlerInfo","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","hostType","components","warn","getDefaultHostname","parsedProxyUrl","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","getIpAddress","assert","validPort","EXPO_NO_DEFAULT_PORT","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACP,IAAA,IAAK,WAAL,KAAK,CAAA;AAEbA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACK,IAAA,IAAiB,WAAjB,i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QAAQ,CAAC,CAAC,AAAC;IAExC,IAAIe,SAAS,EAAE;QACbtC,GAAG,IAAI,CAAC,CAAC,EAAEsC,SAAS,CAAC,CAAC,CAAC;KACxB;IAED,OAAOtC,GAAG,CAAC;CACZ;AAED,kBAAkB,CAClB,SAASyB,WAAW,GAAuB;IACzC,OAAOO,OAAO,CAACC,GAAG,CAACQ,uBAAuB,CAAC;CAC5C,CAED,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
@@ -128,7 +128,7 @@ async function createHostInfoAsync() {
128
128
  host: await _userSettings.default.getAnonymousIdentifierAsync(),
129
129
  server: "expo",
130
130
  // Defined in the build step
131
- serverVersion: "0.2.6",
131
+ serverVersion: "0.2.9",
132
132
  serverDriver: _manifestMiddleware.DEVELOPER_TOOL,
133
133
  serverOS: _os.default.platform(),
134
134
  serverOSVersion: _os.default.release()
@@ -8,8 +8,8 @@ var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var Log = _interopRequireWildcard(require("../log"));
9
9
  var _getDevClientProperties = _interopRequireDefault(require("../utils/analytics/getDevClientProperties"));
10
10
  var _rudderstackClient = require("../utils/analytics/rudderstackClient");
11
- var _env = require("../utils/env");
12
11
  var _exit = require("../utils/exit");
12
+ var _interactive = require("../utils/interactive");
13
13
  var _profile = require("../utils/profile");
14
14
  var _validateDependenciesVersions = require("./doctor/dependencies/validateDependenciesVersions");
15
15
  var _typeScriptProjectPrerequisite = require("./doctor/typescript/TypeScriptProjectPrerequisite");
@@ -110,13 +110,13 @@ async function startAsync(projectRoot, options, settings) {
110
110
  }
111
111
  // Some tracking thing
112
112
  if (options.devClient) {
113
- track(projectRoot, exp);
113
+ await trackAsync(projectRoot, exp);
114
114
  }
115
115
  await (0, _profile).profile(devServerManager.startAsync.bind(devServerManager))(startOptions);
116
116
  // Open project on devices.
117
117
  await (0, _profile).profile(_openPlatforms.openPlatformsAsync)(devServerManager, options);
118
118
  // Present the Terminal UI.
119
- if (!_env.env.CI) {
119
+ if ((0, _interactive).isInteractive()) {
120
120
  var _platforms;
121
121
  await (0, _profile).profile(_startInterface.startInterfaceAsync)(devServerManager, {
122
122
  platforms: (_platforms = exp.platforms) != null ? _platforms : [
@@ -135,15 +135,15 @@ async function startAsync(projectRoot, options, settings) {
135
135
  }
136
136
  // Final note about closing the server.
137
137
  const logLocation = settings.webOnly ? "in the browser console" : "below";
138
- Log.log(_chalk.default`Logs for your project will appear ${logLocation}.${_env.env.CI ? "" : _chalk.default.dim(` Press Ctrl+C to exit.`)}`);
138
+ Log.log(_chalk.default`Logs for your project will appear ${logLocation}.${(0, _interactive).isInteractive() ? _chalk.default.dim(` Press Ctrl+C to exit.`) : ""}`);
139
139
  }
140
- function track(projectRoot, exp) {
141
- (0, _rudderstackClient).logEvent("dev client start command", {
140
+ async function trackAsync(projectRoot, exp) {
141
+ await (0, _rudderstackClient).logEventAsync("dev client start command", {
142
142
  status: "started",
143
143
  ...(0, _getDevClientProperties).default(projectRoot, exp)
144
144
  });
145
- (0, _exit).installExitHooks(()=>{
146
- (0, _rudderstackClient).logEvent("dev client start command", {
145
+ (0, _exit).installExitHooks(async ()=>{
146
+ await (0, _rudderstackClient).logEventAsync("dev client start command", {
147
147
  status: "finished",
148
148
  ...(0, _getDevClientProperties).default(projectRoot, exp)
149
149
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/start/startAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport getDevClientProperties from '../utils/analytics/getDevClientProperties';\nimport { logEvent } from '../utils/analytics/rudderstackClient';\nimport { env } from '../utils/env';\nimport { installExitHooks } from '../utils/exit';\nimport { profile } from '../utils/profile';\nimport { validateDependenciesVersionsAsync } from './doctor/dependencies/validateDependenciesVersions';\nimport { TypeScriptProjectPrerequisite } from './doctor/typescript/TypeScriptProjectPrerequisite';\nimport { WebSupportProjectPrerequisite } from './doctor/web/WebSupportProjectPrerequisite';\nimport { startInterfaceAsync } from './interface/startInterface';\nimport { Options, resolvePortsAsync } from './resolveOptions';\nimport { BundlerStartOptions } from './server/BundlerDevServer';\nimport { DevServerManager, MultiBundlerStartOptions } from './server/DevServerManager';\nimport { openPlatformsAsync } from './server/openPlatforms';\nimport { getPlatformBundlers, PlatformBundlers } from './server/platformBundlers';\n\nasync function getMultiBundlerStartOptions(\n projectRoot: string,\n { forceManifestType, ...options }: Options,\n settings: { webOnly?: boolean },\n platformBundlers: PlatformBundlers\n): Promise<[BundlerStartOptions, MultiBundlerStartOptions]> {\n const commonOptions: BundlerStartOptions = {\n mode: options.dev ? 'development' : 'production',\n devClient: options.devClient,\n forceManifestType,\n privateKeyPath: options.privateKeyPath ?? undefined,\n https: options.https,\n maxWorkers: options.maxWorkers,\n resetDevServer: options.clear,\n minify: options.minify,\n location: {\n hostType: options.host,\n scheme: options.scheme,\n },\n };\n const multiBundlerSettings = await resolvePortsAsync(projectRoot, options, settings);\n\n const optionalBundlers: Partial<PlatformBundlers> = { ...platformBundlers };\n // In the default case, we don't want to start multiple bundlers since this is\n // a bit slower. Our priority (for legacy) is native platforms.\n if (!options.web) {\n delete optionalBundlers['web'];\n }\n\n const bundlers = [...new Set(Object.values(optionalBundlers))];\n const multiBundlerStartOptions = bundlers.map((bundler) => {\n const port =\n bundler === 'webpack' ? multiBundlerSettings.webpackPort : multiBundlerSettings.metroPort;\n return {\n type: bundler,\n options: {\n ...commonOptions,\n port,\n },\n };\n });\n\n return [commonOptions, multiBundlerStartOptions];\n}\n\nexport async function startAsync(\n projectRoot: string,\n options: Options,\n settings: { webOnly?: boolean }\n) {\n Log.log(chalk.gray(`Starting project at ${projectRoot}`));\n\n const { exp, pkg } = profile(getConfig)(projectRoot);\n\n const platformBundlers = getPlatformBundlers(exp);\n\n if (!options.forceManifestType) {\n const easUpdatesUrlRegex = /^https:\\/\\/(staging-)?u\\.expo\\.dev/;\n const isEasUpdatesUrl = exp.updates?.url ? easUpdatesUrlRegex.test(exp.updates.url) : false;\n options.forceManifestType = isEasUpdatesUrl ? 'expo-updates' : 'classic';\n }\n\n const [defaultOptions, startOptions] = await getMultiBundlerStartOptions(\n projectRoot,\n options,\n settings,\n platformBundlers\n );\n\n const devServerManager = new DevServerManager(projectRoot, defaultOptions);\n\n // Validations\n\n if (options.web || settings.webOnly) {\n await devServerManager.ensureProjectPrerequisiteAsync(WebSupportProjectPrerequisite);\n }\n\n await devServerManager.ensureProjectPrerequisiteAsync(TypeScriptProjectPrerequisite);\n\n if (!settings.webOnly && !options.devClient) {\n await profile(validateDependenciesVersionsAsync)(projectRoot, exp, pkg);\n }\n\n // Some tracking thing\n\n if (options.devClient) {\n track(projectRoot, exp);\n }\n\n await profile(devServerManager.startAsync.bind(devServerManager))(startOptions);\n\n // Open project on devices.\n await profile(openPlatformsAsync)(devServerManager, options);\n\n // Present the Terminal UI.\n if (!env.CI) {\n await profile(startInterfaceAsync)(devServerManager, {\n platforms: exp.platforms ?? ['ios', 'android', 'web'],\n });\n } else {\n // Display the server location in CI...\n const url = devServerManager.getDefaultDevServer()?.getDevServerUrl();\n if (url) {\n Log.log(chalk`Waiting on {underline ${url}}`);\n }\n }\n\n // Final note about closing the server.\n const logLocation = settings.webOnly ? 'in the browser console' : 'below';\n Log.log(\n chalk`Logs for your project will appear ${logLocation}.${\n env.CI ? '' : chalk.dim(` Press Ctrl+C to exit.`)\n }`\n );\n}\n\nfunction track(projectRoot: string, exp: ExpoConfig) {\n logEvent('dev client start command', {\n status: 'started',\n ...getDevClientProperties(projectRoot, exp),\n });\n installExitHooks(() => {\n logEvent('dev client start command', {\n status: 'finished',\n ...getDevClientProperties(projectRoot, exp),\n });\n // UnifiedAnalytics.flush();\n });\n}\n"],"names":["startAsync","Log","getMultiBundlerStartOptions","projectRoot","forceManifestType","options","settings","platformBundlers","commonOptions","mode","dev","devClient","privateKeyPath","undefined","https","maxWorkers","resetDevServer","clear","minify","location","hostType","host","scheme","multiBundlerSettings","resolvePortsAsync","optionalBundlers","web","bundlers","Set","Object","values","multiBundlerStartOptions","map","bundler","port","webpackPort","metroPort","type","log","chalk","gray","exp","pkg","profile","getConfig","getPlatformBundlers","easUpdatesUrlRegex","isEasUpdatesUrl","updates","url","test","defaultOptions","startOptions","devServerManager","DevServerManager","webOnly","ensureProjectPrerequisiteAsync","WebSupportProjectPrerequisite","TypeScriptProjectPrerequisite","validateDependenciesVersionsAsync","track","bind","openPlatformsAsync","env","CI","startInterfaceAsync","platforms","getDefaultDevServer","getDevServerUrl","logLocation","dim","logEvent","status","getDevClientProperties","installExitHooks"],"mappings":"AAAA;;;;QAgEsBA,UAAU,GAAVA,UAAU;AAhEM,IAAA,OAAc,WAAd,cAAc,CAAA;AAClC,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACoB,IAAA,uBAA2C,kCAA3C,2CAA2C,EAAA;AACrD,IAAA,kBAAsC,WAAtC,sCAAsC,CAAA;AAC3C,IAAA,IAAc,WAAd,cAAc,CAAA;AACD,IAAA,KAAe,WAAf,eAAe,CAAA;AACxB,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AACQ,IAAA,6BAAoD,WAApD,oDAAoD,CAAA;AACxD,IAAA,8BAAmD,WAAnD,mDAAmD,CAAA;AACnD,IAAA,8BAA4C,WAA5C,4CAA4C,CAAA;AACtD,IAAA,eAA4B,WAA5B,4BAA4B,CAAA;AACrB,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAEF,IAAA,iBAA2B,WAA3B,2BAA2B,CAAA;AACnD,IAAA,cAAwB,WAAxB,wBAAwB,CAAA;AACL,IAAA,iBAA2B,WAA3B,2BAA2B,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjF,eAAeC,2BAA2B,CACxCC,WAAmB,EACnB,EAAEC,iBAAiB,CAAA,EAAE,GAAGC,OAAO,EAAW,EAC1CC,QAA+B,EAC/BC,gBAAkC,EACwB;QAKxCF,eAAsB;IAJxC,MAAMG,aAAa,GAAwB;QACz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AAE,AAAC;QACtE,IAAInB,GAAG,EAAE;YACPhD,GAAG,CAACqC,GAAG,CAACC,MAAK,QAAA,CAAC,sBAAsB,EAAEU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/C;KACF;IAED,uCAAuC;IACvC,MAAMoB,WAAW,GAAG/D,QAAQ,CAACiD,OAAO,GAAG,wBAAwB,GAAG,OAAO,AAAC;IAC1EtD,GAAG,CAACqC,GAAG,CACLC,MAAK,QAAA,CAAC,kCAAkC,EAAE8B,WAAW,CAAC,CAAC,EACrDN,IAAG,IAAA,CAACC,EAAE,GAAG,EAAE,GAAGzB,MAAK,QAAA,CAAC+B,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAClD,CAAC,CACH,CAAC;CACH;AAED,SAASV,KAAK,CAACzD,WAAmB,EAAEsC,GAAe,EAAE;IACnD8B,CAAAA,GAAAA,kBAAQ,AAGN,CAAA,SAHM,CAAC,0BAA0B,EAAE;QACnCC,MAAM,EAAE,SAAS;QACjB,GAAGC,CAAAA,GAAAA,uBAAsB,AAAkB,CAAA,QAAlB,CAACtE,WAAW,EAAEsC,GAAG,CAAC;KAC5C,CAAC,CAAC;IACHiC,CAAAA,GAAAA,KAAgB,AAMd,CAAA,iBANc,CAAC,IAAM;QACrBH,CAAAA,GAAAA,kBAAQ,AAGN,CAAA,SAHM,CAAC,0BAA0B,EAAE;YACnCC,MAAM,EAAE,UAAU;YAClB,GAAGC,CAAAA,GAAAA,uBAAsB,AAAkB,CAAA,QAAlB,CAACtE,WAAW,EAAEsC,GAAG,CAAC;SAC5C,CAAC,CAAC;IACH,4BAA4B;KAC7B,CAAC,CAAC;CACJ"}
1
+ {"version":3,"sources":["../../../src/start/startAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport getDevClientProperties from '../utils/analytics/getDevClientProperties';\nimport { logEventAsync } from '../utils/analytics/rudderstackClient';\nimport { installExitHooks } from '../utils/exit';\nimport { isInteractive } from '../utils/interactive';\nimport { profile } from '../utils/profile';\nimport { validateDependenciesVersionsAsync } from './doctor/dependencies/validateDependenciesVersions';\nimport { TypeScriptProjectPrerequisite } from './doctor/typescript/TypeScriptProjectPrerequisite';\nimport { WebSupportProjectPrerequisite } from './doctor/web/WebSupportProjectPrerequisite';\nimport { startInterfaceAsync } from './interface/startInterface';\nimport { Options, resolvePortsAsync } from './resolveOptions';\nimport { BundlerStartOptions } from './server/BundlerDevServer';\nimport { DevServerManager, MultiBundlerStartOptions } from './server/DevServerManager';\nimport { openPlatformsAsync } from './server/openPlatforms';\nimport { getPlatformBundlers, PlatformBundlers } from './server/platformBundlers';\n\nasync function getMultiBundlerStartOptions(\n projectRoot: string,\n { forceManifestType, ...options }: Options,\n settings: { webOnly?: boolean },\n platformBundlers: PlatformBundlers\n): Promise<[BundlerStartOptions, MultiBundlerStartOptions]> {\n const commonOptions: BundlerStartOptions = {\n mode: options.dev ? 'development' : 'production',\n devClient: options.devClient,\n forceManifestType,\n privateKeyPath: options.privateKeyPath ?? undefined,\n https: options.https,\n maxWorkers: options.maxWorkers,\n resetDevServer: options.clear,\n minify: options.minify,\n location: {\n hostType: options.host,\n scheme: options.scheme,\n },\n };\n const multiBundlerSettings = await resolvePortsAsync(projectRoot, options, settings);\n\n const optionalBundlers: Partial<PlatformBundlers> = { ...platformBundlers };\n // In the default case, we don't want to start multiple bundlers since this is\n // a bit slower. Our priority (for legacy) is native platforms.\n if (!options.web) {\n delete optionalBundlers['web'];\n }\n\n const bundlers = [...new Set(Object.values(optionalBundlers))];\n const multiBundlerStartOptions = bundlers.map((bundler) => {\n const port =\n bundler === 'webpack' ? multiBundlerSettings.webpackPort : multiBundlerSettings.metroPort;\n return {\n type: bundler,\n options: {\n ...commonOptions,\n port,\n },\n };\n });\n\n return [commonOptions, multiBundlerStartOptions];\n}\n\nexport async function startAsync(\n projectRoot: string,\n options: Options,\n settings: { webOnly?: boolean }\n) {\n Log.log(chalk.gray(`Starting project at ${projectRoot}`));\n\n const { exp, pkg } = profile(getConfig)(projectRoot);\n\n const platformBundlers = getPlatformBundlers(exp);\n\n if (!options.forceManifestType) {\n const easUpdatesUrlRegex = /^https:\\/\\/(staging-)?u\\.expo\\.dev/;\n const isEasUpdatesUrl = exp.updates?.url ? easUpdatesUrlRegex.test(exp.updates.url) : false;\n options.forceManifestType = isEasUpdatesUrl ? 'expo-updates' : 'classic';\n }\n\n const [defaultOptions, startOptions] = await getMultiBundlerStartOptions(\n projectRoot,\n options,\n settings,\n platformBundlers\n );\n\n const devServerManager = new DevServerManager(projectRoot, defaultOptions);\n\n // Validations\n\n if (options.web || settings.webOnly) {\n await devServerManager.ensureProjectPrerequisiteAsync(WebSupportProjectPrerequisite);\n }\n\n await devServerManager.ensureProjectPrerequisiteAsync(TypeScriptProjectPrerequisite);\n\n if (!settings.webOnly && !options.devClient) {\n await profile(validateDependenciesVersionsAsync)(projectRoot, exp, pkg);\n }\n\n // Some tracking thing\n\n if (options.devClient) {\n await trackAsync(projectRoot, exp);\n }\n\n await profile(devServerManager.startAsync.bind(devServerManager))(startOptions);\n\n // Open project on devices.\n await profile(openPlatformsAsync)(devServerManager, options);\n\n // Present the Terminal UI.\n if (isInteractive()) {\n await profile(startInterfaceAsync)(devServerManager, {\n platforms: exp.platforms ?? ['ios', 'android', 'web'],\n });\n } else {\n // Display the server location in CI...\n const url = devServerManager.getDefaultDevServer()?.getDevServerUrl();\n if (url) {\n Log.log(chalk`Waiting on {underline ${url}}`);\n }\n }\n\n // Final note about closing the server.\n const logLocation = settings.webOnly ? 'in the browser console' : 'below';\n Log.log(\n chalk`Logs for your project will appear ${logLocation}.${\n isInteractive() ? chalk.dim(` Press Ctrl+C to exit.`) : ''\n }`\n );\n}\n\nasync function trackAsync(projectRoot: string, exp: ExpoConfig): Promise<void> {\n await logEventAsync('dev client start command', {\n status: 'started',\n ...getDevClientProperties(projectRoot, exp),\n });\n installExitHooks(async () => {\n await logEventAsync('dev client start command', {\n status: 'finished',\n ...getDevClientProperties(projectRoot, exp),\n });\n // UnifiedAnalytics.flush();\n });\n}\n"],"names":["startAsync","Log","getMultiBundlerStartOptions","projectRoot","forceManifestType","options","settings","platformBundlers","commonOptions","mode","dev","devClient","privateKeyPath","undefined","https","maxWorkers","resetDevServer","clear","minify","location","hostType","host","scheme","multiBundlerSettings","resolvePortsAsync","optionalBundlers","web","bundlers","Set","Object","values","multiBundlerStartOptions","map","bundler","port","webpackPort","metroPort","type","log","chalk","gray","exp","pkg","profile","getConfig","getPlatformBundlers","easUpdatesUrlRegex","isEasUpdatesUrl","updates","url","test","defaultOptions","startOptions","devServerManager","DevServerManager","webOnly","ensureProjectPrerequisiteAsync","WebSupportProjectPrerequisite","TypeScriptProjectPrerequisite","validateDependenciesVersionsAsync","trackAsync","bind","openPlatformsAsync","isInteractive","startInterfaceAsync","platforms","getDefaultDevServer","getDevServerUrl","logLocation","dim","logEventAsync","status","getDevClientProperties","installExitHooks"],"mappings":"AAAA;;;;QAgEsBA,UAAU,GAAVA,UAAU;AAhEM,IAAA,OAAc,WAAd,cAAc,CAAA;AAClC,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACoB,IAAA,uBAA2C,kCAA3C,2CAA2C,EAAA;AAChD,IAAA,kBAAsC,WAAtC,sCAAsC,CAAA;AACnC,IAAA,KAAe,WAAf,eAAe,CAAA;AAClB,IAAA,YAAsB,WAAtB,sBAAsB,CAAA;AAC5B,IAAA,QAAkB,WAAlB,kBAAkB,CAAA;AACQ,IAAA,6BAAoD,WAApD,oDAAoD,CAAA;AACxD,IAAA,8BAAmD,WAAnD,mDAAmD,CAAA;AACnD,IAAA,8BAA4C,WAA5C,4CAA4C,CAAA;AACtD,IAAA,eAA4B,WAA5B,4BAA4B,CAAA;AACrB,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAEF,IAAA,iBAA2B,WAA3B,2BAA2B,CAAA;AACnD,IAAA,c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AAAA,GAAAA,uBAAsB,AAAkB,CAAA,QAAlB,CAACrE,WAAW,EAAEsC,GAAG,CAAC;SAC5C,CAAC,CAAC;IACH,4BAA4B;KAC7B,CAAC,CAAC;CACJ"}
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
+ exports.resetInternalStateForTesting = resetInternalStateForTesting;
6
+ exports.getRudderAnalyticsClient = getRudderAnalyticsClient;
5
7
  exports.setUserDataAsync = setUserDataAsync;
6
- exports.logEvent = logEvent;
7
8
  exports.logEventAsync = logEventAsync;
8
9
  exports.getContext = getContext;
9
10
  var _rudderSdkNode = _interopRequireDefault(require("@expo/rudder-sdk-node"));
10
11
  var ciInfo = _interopRequireWildcard(require("ci-info"));
11
12
  var _os = _interopRequireDefault(require("os"));
12
- var _uuid = require("uuid");
13
13
  var _userSettings = _interopRequireDefault(require("../../api/user/UserSettings"));
14
14
  var _user = require("../../api/user/user");
15
15
  var _env = require("../env");
@@ -47,7 +47,12 @@ const PLATFORM_TO_ANALYTICS_PLATFORM = {
47
47
  let client = null;
48
48
  let identified = false;
49
49
  let identifyData = null;
50
- function getClient() {
50
+ function resetInternalStateForTesting() {
51
+ identified = false;
52
+ identifyData = null;
53
+ client = null;
54
+ }
55
+ function getRudderAnalyticsClient() {
51
56
  if (client) {
52
57
  return client;
53
58
  }
@@ -73,49 +78,30 @@ async function setUserDataAsync(userId, traits) {
73
78
  deviceId,
74
79
  traits
75
80
  };
76
- ensureIdentified();
81
+ identifyIfNotYetIdentified();
77
82
  }
78
- function logEvent(event, properties = {}) {
83
+ async function logEventAsync(event, properties = {}) {
79
84
  if (_env.env.EXPO_NO_TELEMETRY) {
80
85
  return;
81
86
  }
82
- ensureIdentified();
83
- const { userId , deviceId } = identifyData != null ? identifyData : {};
84
- const commonEventProperties = {
85
- source_version: "0.2.6",
86
- source: "expo"
87
- };
88
- const identity = {
89
- userId: userId != null ? userId : undefined,
90
- anonymousId: deviceId != null ? deviceId : (0, _uuid).v4()
91
- };
92
- getClient().track({
93
- event,
94
- properties: {
95
- ...properties,
96
- ...commonEventProperties
97
- },
98
- ...identity,
99
- context: getContext()
100
- });
101
- }
102
- async function logEventAsync(event, properties = {}) {
103
- if (_env.env.EXPO_NO_TELEMETRY) {
87
+ // this has the side effect of calling `setUserData` which fetches the user and populates identifyData
88
+ try {
89
+ await (0, _user).getUserAsync();
90
+ } catch {}
91
+ identifyIfNotYetIdentified();
92
+ if (!identifyData) {
104
93
  return;
105
94
  }
106
- await (0, _user).getUserAsync().catch(()=>null
107
- );
108
- ensureIdentified();
109
- const { userId , deviceId } = identifyData != null ? identifyData : {};
95
+ const { userId , deviceId } = identifyData;
110
96
  const commonEventProperties = {
111
- source_version: "0.2.6",
97
+ source_version: "0.2.9",
112
98
  source: "expo"
113
99
  };
114
100
  const identity = {
115
- userId: userId != null ? userId : undefined,
116
- anonymousId: deviceId != null ? deviceId : (0, _uuid).v4()
101
+ userId,
102
+ anonymousId: deviceId
117
103
  };
118
- getClient().track({
104
+ getRudderAnalyticsClient().track({
119
105
  event,
120
106
  properties: {
121
107
  ...properties,
@@ -125,11 +111,11 @@ async function logEventAsync(event, properties = {}) {
125
111
  context: getContext()
126
112
  });
127
113
  }
128
- function ensureIdentified() {
114
+ function identifyIfNotYetIdentified() {
129
115
  if (_env.env.EXPO_NO_TELEMETRY || identified || !identifyData) {
130
116
  return;
131
117
  }
132
- getClient().identify({
118
+ getRudderAnalyticsClient().identify({
133
119
  userId: identifyData.userId,
134
120
  anonymousId: identifyData.deviceId,
135
121
  traits: identifyData.traits
@@ -149,7 +135,7 @@ function getContext() {
149
135
  },
150
136
  app: {
151
137
  name: "expo",
152
- version: "0.2.6"
138
+ version: "0.2.9"
153
139
  },
154
140
  ci: ciInfo.isCI ? {
155
141
  name: ciInfo.name,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utils/analytics/rudderstackClient.ts"],"sourcesContent":["import RudderAnalytics from '@expo/rudder-sdk-node';\nimport * as ciInfo from 'ci-info';\nimport os from 'os';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport UserSettings from '../../api/user/UserSettings';\nimport { getUserAsync } from '../../api/user/user';\nimport { env } from '../env';\n\nconst PLATFORM_TO_ANALYTICS_PLATFORM: { [platform: string]: string } = {\n darwin: 'Mac',\n win32: 'Windows',\n linux: 'Linux',\n};\n\nlet client: RudderAnalytics | null = null;\nlet identified = false;\nlet identifyData: {\n userId: string;\n deviceId: string;\n traits: Record<string, any>;\n} | null = null;\n\nfunction getClient(): RudderAnalytics {\n if (client) {\n return client;\n }\n\n client = new RudderAnalytics(\n env.EXPO_STAGING || env.EXPO_LOCAL\n ? '24TKICqYKilXM480mA7ktgVDdea'\n : '24TKR7CQAaGgIrLTgu3Fp4OdOkI', // expo unified\n 'https://cdp.expo.dev/v1/batch',\n {\n flushInterval: 300,\n }\n );\n\n // Install flush on exit...\n process.on('SIGINT', () => client?.flush?.());\n process.on('SIGTERM', () => client?.flush?.());\n\n return client;\n}\n\nexport async function setUserDataAsync(userId: string, traits: Record<string, any>): Promise<void> {\n if (env.EXPO_NO_TELEMETRY) {\n return;\n }\n\n const deviceId = await UserSettings.getAnonymousIdentifierAsync();\n\n identifyData = {\n userId,\n deviceId,\n traits,\n };\n\n ensureIdentified();\n}\n\ntype Event =\n | 'action'\n | 'Open Url on Device'\n | 'Start Project'\n | 'Serve Manifest'\n | 'Serve Expo Updates Manifest'\n | 'dev client start command'\n | 'dev client run command';\n\nexport function logEvent(event: Event, properties: Record<string, any> = {}): void {\n if (env.EXPO_NO_TELEMETRY) {\n return;\n }\n\n ensureIdentified();\n\n const { userId, deviceId } = identifyData ?? {};\n const commonEventProperties = { source_version: process.env.__EXPO_VERSION, source: 'expo' };\n\n const identity = { userId: userId ?? undefined, anonymousId: deviceId ?? uuidv4() };\n getClient().track({\n event,\n properties: { ...properties, ...commonEventProperties },\n ...identity,\n context: getContext(),\n });\n}\n\n/** Log event while ensuring the user is identified. */\nexport async function logEventAsync(\n event: Event,\n properties: Record<string, any> = {}\n): Promise<void> {\n if (env.EXPO_NO_TELEMETRY) {\n return;\n }\n\n await getUserAsync().catch(() => null);\n ensureIdentified();\n\n const { userId, deviceId } = identifyData ?? {};\n const commonEventProperties = { source_version: process.env.__EXPO_VERSION, source: 'expo' };\n\n const identity = { userId: userId ?? undefined, anonymousId: deviceId ?? uuidv4() };\n getClient().track({\n event,\n properties: { ...properties, ...commonEventProperties },\n ...identity,\n context: getContext(),\n });\n}\n\nfunction ensureIdentified(): void {\n if (env.EXPO_NO_TELEMETRY || identified || !identifyData) {\n return;\n }\n\n getClient().identify({\n userId: identifyData.userId,\n anonymousId: identifyData.deviceId,\n traits: identifyData.traits,\n });\n identified = true;\n}\n\n/** Exposed for testing only */\nexport function getContext(): Record<string, any> {\n const platform = PLATFORM_TO_ANALYTICS_PLATFORM[os.platform()] || os.platform();\n return {\n os: { name: platform, version: os.release() },\n device: { type: platform, model: platform },\n app: { name: 'expo', version: process.env.__EXPO_VERSION },\n ci: ciInfo.isCI ? { name: ciInfo.name, isPr: ciInfo.isPR } : undefined,\n };\n}\n"],"names":["setUserDataAsync","logEvent","logEventAsync","getContext","ciInfo","PLATFORM_TO_ANALYTICS_PLATFORM","darwin","win32","linux","client","identified","identifyData","getClient","RudderAnalytics","env","EXPO_STAGING","EXPO_LOCAL","flushInterval","process","on","flush","userId","traits","EXPO_NO_TELEMETRY","deviceId","UserSettings","getAnonymousIdentifierAsync","ensureIdentified","event","properties","commonEventProperties","source_version","__EXPO_VERSION","source","identity","undefined","anonymousId","uuidv4","track","context","getUserAsync","catch","identify","platform","os","name","version","release","device","type","model","app","ci","isCI","isPr","isPR"],"mappings":"AAAA;;;;QA6CsBA,gBAAgB,GAAhBA,gBAAgB;QAyBtBC,QAAQ,GAARA,QAAQ;QAoBFC,aAAa,GAAbA,aAAa;QAqCnBC,UAAU,GAAVA,UAAU;AA/HE,IAAA,cAAuB,kCAAvB,uBAAuB,EAAA;AACvCC,IAAA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AEF,GAAE,QAAA,CAACG,OAAO,EAAE;SAAE;QAC7CC,MAAM,EAAE;YAAEC,IAAI,EAAEN,QAAQ;YAAEO,KAAK,EAAEP,QAAQ;SAAE;QAC3CQ,GAAG,EAAE;YAAEN,IAAI,EAAE,MAAM;YAAEC,OAAO,EAAE5B,OAAO,CAACJ,GAAG,CAACkB,cAAc;SAAE;QAC1DoB,EAAE,EAAEhD,MAAM,CAACiD,IAAI,GAAG;YAAER,IAAI,EAAEzC,MAAM,CAACyC,IAAI;YAAES,IAAI,EAAElD,MAAM,CAACmD,IAAI;SAAE,GAAGpB,SAAS;KACvE,CAAC;CACH"}
1
+ {"version":3,"sources":["../../../../src/utils/analytics/rudderstackClient.ts"],"sourcesContent":["import RudderAnalytics from '@expo/rudder-sdk-node';\nimport * as ciInfo from 'ci-info';\nimport os from 'os';\n\nimport UserSettings from '../../api/user/UserSettings';\nimport { getUserAsync } from '../../api/user/user';\nimport { env } from '../env';\n\nconst PLATFORM_TO_ANALYTICS_PLATFORM: { [platform: string]: string } = {\n darwin: 'Mac',\n win32: 'Windows',\n linux: 'Linux',\n};\n\nlet client: RudderAnalytics | null = null;\nlet identified = false;\nlet identifyData: {\n userId: string;\n deviceId: string;\n traits: Record<string, any>;\n} | null = null;\n\nexport function resetInternalStateForTesting() {\n identified = false;\n identifyData = null;\n client = null;\n}\n\nexport function getRudderAnalyticsClient(): RudderAnalytics {\n if (client) {\n return client;\n }\n\n client = new RudderAnalytics(\n env.EXPO_STAGING || env.EXPO_LOCAL\n ? '24TKICqYKilXM480mA7ktgVDdea'\n : '24TKR7CQAaGgIrLTgu3Fp4OdOkI', // expo unified\n 'https://cdp.expo.dev/v1/batch',\n {\n flushInterval: 300,\n }\n );\n\n // Install flush on exit...\n process.on('SIGINT', () => client?.flush?.());\n process.on('SIGTERM', () => client?.flush?.());\n\n return client;\n}\n\nexport async function setUserDataAsync(userId: string, traits: Record<string, any>): Promise<void> {\n if (env.EXPO_NO_TELEMETRY) {\n return;\n }\n\n const deviceId = await UserSettings.getAnonymousIdentifierAsync();\n\n identifyData = {\n userId,\n deviceId,\n traits,\n };\n\n identifyIfNotYetIdentified();\n}\n\ntype Event =\n | 'action'\n | 'Open Url on Device'\n | 'Start Project'\n | 'Serve Manifest'\n | 'Serve Expo Updates Manifest'\n | 'dev client start command'\n | 'dev client run command';\n\n/**\n * Log an event, ensuring the user is identified before logging the event.\n **/\nexport async function logEventAsync(\n event: Event,\n properties: Record<string, any> = {}\n): Promise<void> {\n if (env.EXPO_NO_TELEMETRY) {\n return;\n }\n\n // this has the side effect of calling `setUserData` which fetches the user and populates identifyData\n try {\n await getUserAsync();\n } catch {}\n\n identifyIfNotYetIdentified();\n\n if (!identifyData) {\n return;\n }\n const { userId, deviceId } = identifyData;\n const commonEventProperties = { source_version: process.env.__EXPO_VERSION, source: 'expo' };\n\n const identity = { userId, anonymousId: deviceId };\n getRudderAnalyticsClient().track({\n event,\n properties: { ...properties, ...commonEventProperties },\n ...identity,\n context: getContext(),\n });\n}\n\nfunction identifyIfNotYetIdentified(): void {\n if (env.EXPO_NO_TELEMETRY || identified || !identifyData) {\n return;\n }\n\n getRudderAnalyticsClient().identify({\n userId: identifyData.userId,\n anonymousId: identifyData.deviceId,\n traits: identifyData.traits,\n });\n identified = true;\n}\n\n/** Exposed for testing only */\nexport function getContext(): Record<string, any> {\n const platform = PLATFORM_TO_ANALYTICS_PLATFORM[os.platform()] || os.platform();\n return {\n os: { name: platform, version: os.release() },\n device: { type: platform, model: platform },\n app: { name: 'expo', version: process.env.__EXPO_VERSION },\n ci: ciInfo.isCI ? { name: ciInfo.name, isPr: ciInfo.isPR } : undefined,\n };\n}\n"],"names":["resetInternalStateForTesting","getRudderAnalyticsClient","setUserDataAsync","logEventAsync","getContext","ciInfo","PLATFORM_TO_ANALYTICS_PLATFORM","darwin","win32","linux","client","identified","identifyData","RudderAnalytics","env","EXPO_STAGING","EXPO_LOCAL","flushInterval","process","on","flush","userId","traits","EXPO_NO_TELEMETRY","deviceId","UserSettings","getAnonymousIdentifierAsync","identifyIfNotYetIdentified","event","properties","getUserAsync","commonEventProperties","source_version","__EXPO_VERSION","source","identity","anonymousId","track","context","identify","platform","os","name","version","release","device","type","model","app","ci","isCI","isPr","isPR","undefined"],"mappings":"AAAA;;;;QAsBgBA,4BAA4B,GAA5BA,4BAA4B;QAM5BC,wBAAwB,GAAxBA,wBAAwB;QAsBlBC,gBAAgB,GAAhBA,gBAAgB;QA4BhBC,aAAa,GAAbA,aAAa;QA4CnBC,UAAU,GAAVA,UAAU;AA1HE,IAAA,cAAuB,kCAAvB,uBAAuB,EAAA;AACvCC,IAAAA,MAAM,mCAAM,SAAS,EAAf;AACH,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEM,IAAA,aAA6B,kCAA7B,6BAA6B,EAAA;AACzB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AAC9B,IAAA,IAAQ,WAAR,QAAQ,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5B,MAAMC,8BAA8B,GAAmC;IACrEC,MAAM,EAAE,KAAK;IACbC,KAAK,EAAE,SAAS;IAChBC,KAAK,EAAE,OAAO;CACf,AAAC;AAEF,IAAIC,MAAM,GAA2B,IAAI,AAAC;AAC1C,IAAIC,UAAU,GAAG,KAAK,AAAC;AACvB,IAAIC,YAAY,GAIL,IAAI,AAAC;AAET,SAASZ,4BAA4B,GAAG;IAC7CW,UAAU,GAAG,KAAK,CAAC;IACnBC,YAAY,GAAG,IAAI,CAAC;IACpBF,MAAM,GAAG,IAAI,CAAC;CACf;AAEM,SAAST,wBAAwB,GAAoB;IAC1D,IAAIS,MAAM,EAAE;QACV,OAAOA,MAAM,CAAC;KACf;IAEDA,MAAM,GAAG,IAAIG,cAAe,QAAA,CAC1BC,IAAG,IAAA,CAACC,YAAY,IAAID,IAAG,IAAA,CAACE,UAAU,GAC9B,6BAA6B,GAC7B,6BAA6B,EACjC,+BAA+B,EAC/B;QACEC,aAAa,EAAE,GAAG;KACn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+C,IAAI;SAAE,GAAGC,SAAS;KACvE,CAAC;CACH"}
@@ -61,6 +61,22 @@ class Env {
61
61
  /** Higher priority `$EDIOTR` variable for indicating which editor to use when pressing `o` in the Terminal UI. */ get EXPO_EDITOR() {
62
62
  return (0, _getenv).string("EXPO_EDITOR", "");
63
63
  }
64
+ /**
65
+ * Overwrite the dev server URL, disregarding the `--port`, `--host`, `--tunnel`, `--lan`, `--localhost` arguments.
66
+ * This is useful for browser editors that require custom proxy URLs.
67
+ *
68
+ * The URL will not be used verbatim unless `EXPO_NO_DEFAULT_PORT=true` is also set,
69
+ * otherwise a `:80` port will be added for Android support.
70
+ */ get EXPO_PACKAGER_PROXY_URL() {
71
+ return (0, _getenv).string("EXPO_PACKAGER_PROXY_URL", "");
72
+ }
73
+ /**
74
+ * Disable the enforced `:80` port when using custom dev server URLs.
75
+ * This can break the incomplete Android WebSocket implementation but allows
76
+ * `EXPO_PACKAGER_PROXY_URL` to work as expected.
77
+ * */ get EXPO_NO_DEFAULT_PORT() {
78
+ return (0, _getenv).boolish("EXPO_NO_DEFAULT_PORT", false);
79
+ }
64
80
  }
65
81
  const env = new Env();
66
82
  exports.env = env;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/env.ts"],"sourcesContent":["import { boolish, int, string } from 'getenv';\n\n// @expo/webpack-config -> expo-pwa -> @expo/image-utils: EXPO_IMAGE_UTILS_NO_SHARP\n\n// TODO: EXPO_CLI_USERNAME, EXPO_CLI_PASSWORD\n\nclass Env {\n /** Enable profiling metrics */\n get EXPO_PROFILE() {\n return boolish('EXPO_PROFILE', false);\n }\n\n /** Enable debug logging */\n get EXPO_DEBUG() {\n return boolish('EXPO_DEBUG', false);\n }\n\n /** Enable the beta version of Expo (TODO: Should this just be in the beta version of expo releases?) */\n get EXPO_BETA() {\n return boolish('EXPO_BETA', false);\n }\n\n /** Enable staging API environment */\n get EXPO_STAGING() {\n return boolish('EXPO_STAGING', false);\n }\n\n /** Enable local API environment */\n get EXPO_LOCAL() {\n return boolish('EXPO_LOCAL', false);\n }\n\n /** Is running in non-interactive CI mode */\n get CI() {\n return boolish('CI', false);\n }\n\n /** Disable telemetry (analytics) */\n get EXPO_NO_TELEMETRY() {\n return boolish('EXPO_NO_TELEMETRY', false);\n }\n\n /** local directory to the universe repo for testing locally */\n get EXPO_UNIVERSE_DIR() {\n return string('EXPO_UNIVERSE_DIR', '');\n }\n\n /** @deprecated Default Webpack host string */\n get WEB_HOST() {\n return string('WEB_HOST', '0.0.0.0');\n }\n\n /** Skip warning users about a dirty git status */\n get EXPO_NO_GIT_STATUS() {\n return boolish('EXPO_NO_GIT_STATUS', false);\n }\n /** Disable auto web setup */\n get EXPO_NO_WEB_SETUP() {\n return boolish('EXPO_NO_WEB_SETUP', false);\n }\n /** Disable auto TypeScript setup */\n get EXPO_NO_TYPESCRIPT_SETUP() {\n return boolish('EXPO_NO_TYPESCRIPT_SETUP', false);\n }\n /** Disable all API caches. Does not disable bundler caches. */\n get EXPO_NO_CACHE() {\n return boolish('EXPO_NO_CACHE', false);\n }\n /** Enable the experimental interstitial app select page. */\n get EXPO_ENABLE_INTERSTITIAL_PAGE() {\n return boolish('EXPO_ENABLE_INTERSTITIAL_PAGE', false);\n }\n /** The React Metro port that's baked into react-native scripts and tools. */\n get RCT_METRO_PORT() {\n return int('RCT_METRO_PORT', 0);\n }\n /** Skip validating the manifest during `export`. */\n get EXPO_SKIP_MANIFEST_VALIDATION_TOKEN(): boolean {\n return !!string('EXPO_SKIP_MANIFEST_VALIDATION_TOKEN');\n }\n\n /** Public folder path relative to the project root. Default to `public` */\n get EXPO_PUBLIC_FOLDER(): string {\n return string('EXPO_PUBLIC_FOLDER', 'public');\n }\n\n /** Higher priority `$EDIOTR` variable for indicating which editor to use when pressing `o` in the Terminal UI. */\n get EXPO_EDITOR(): string {\n return string('EXPO_EDITOR', '');\n }\n}\n\nexport const env = new Env();\n"],"names":["Env","EXPO_PROFILE","boolish","EXPO_DEBUG","EXPO_BETA","EXPO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ACpD,IAAIC,mCAAmC,GAAY;QACjD,OAAO,CAAC,CAACT,CAAAA,GAAAA,OAAM,AAAuC,CAAA,OAAvC,CAAC,qCAAqC,CAAC,CAAC;KACxD;IAED,2EAA2E,CAC3E,IAAIU,kBAAkB,GAAW;QAC/B,OAAOV,CAAAA,GAAAA,OAAM,AAAgC,CAAA,OAAhC,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;KAC/C;IAED,kHAAkH,CAClH,IAAIW,WAAW,GAAW;QACxB,OAAOX,CAAAA,GAAAA,OAAM,AAAmB,CAAA,OAAnB,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;KAClC;CACF;AAEM,MAAMY,GAAG,GAAG,IAAItB,GAAG,EAAE,AAAC;QAAhBsB,GAAG,GAAHA,GAAG"}
1
+ {"version":3,"sources":["../../../src/utils/env.ts"],"sourcesContent":["import { boolish, int, string } from 'getenv';\n\n// @expo/webpack-config -> expo-pwa -> @expo/image-utils: EXPO_IMAGE_UTILS_NO_SHARP\n\n// TODO: EXPO_CLI_USERNAME, EXPO_CLI_PASSWORD\n\nclass Env {\n /** Enable profiling metrics */\n get EXPO_PROFILE() {\n return boolish('EXPO_PROFILE', false);\n }\n\n /** Enable debug logging */\n get EXPO_DEBUG() {\n return boolish('EXPO_DEBUG', false);\n }\n\n /** Enable the beta version of Expo (TODO: Should this just be in the beta version of expo releases?) */\n get EXPO_BETA() {\n return boolish('EXPO_BETA', false);\n }\n\n /** Enable staging API environment */\n get EXPO_STAGING() {\n return boolish('EXPO_STAGING', false);\n }\n\n /** Enable local API environment */\n get EXPO_LOCAL() {\n return boolish('EXPO_LOCAL', false);\n }\n\n /** Is running in non-interactive CI mode */\n get CI() {\n return boolish('CI', false);\n }\n\n /** Disable telemetry (analytics) */\n get EXPO_NO_TELEMETRY() {\n return boolish('EXPO_NO_TELEMETRY', false);\n }\n\n /** local directory to the universe repo for testing locally */\n get EXPO_UNIVERSE_DIR() {\n return string('EXPO_UNIVERSE_DIR', '');\n }\n\n /** @deprecated Default Webpack host string */\n get WEB_HOST() {\n return string('WEB_HOST', '0.0.0.0');\n }\n\n /** Skip warning users about a dirty git status */\n get EXPO_NO_GIT_STATUS() {\n return boolish('EXPO_NO_GIT_STATUS', false);\n }\n /** Disable auto web setup */\n get EXPO_NO_WEB_SETUP() {\n return boolish('EXPO_NO_WEB_SETUP', false);\n }\n /** Disable auto TypeScript setup */\n get EXPO_NO_TYPESCRIPT_SETUP() {\n return boolish('EXPO_NO_TYPESCRIPT_SETUP', false);\n }\n /** Disable all API caches. Does not disable bundler caches. */\n get EXPO_NO_CACHE() {\n return boolish('EXPO_NO_CACHE', false);\n }\n /** Enable the experimental interstitial app select page. */\n get EXPO_ENABLE_INTERSTITIAL_PAGE() {\n return boolish('EXPO_ENABLE_INTERSTITIAL_PAGE', false);\n }\n /** The React Metro port that's baked into react-native scripts and tools. */\n get RCT_METRO_PORT() {\n return int('RCT_METRO_PORT', 0);\n }\n /** Skip validating the manifest during `export`. */\n get EXPO_SKIP_MANIFEST_VALIDATION_TOKEN(): boolean {\n return !!string('EXPO_SKIP_MANIFEST_VALIDATION_TOKEN');\n }\n\n /** Public folder path relative to the project root. Default to `public` */\n get EXPO_PUBLIC_FOLDER(): string {\n return string('EXPO_PUBLIC_FOLDER', 'public');\n }\n\n /** Higher priority `$EDIOTR` variable for indicating which editor to use when pressing `o` in the Terminal UI. */\n get EXPO_EDITOR(): string {\n return string('EXPO_EDITOR', '');\n }\n\n /**\n * Overwrite the dev server URL, disregarding the `--port`, `--host`, `--tunnel`, `--lan`, `--localhost` arguments.\n * This is useful for browser editors that require custom proxy URLs.\n *\n * The URL will not be used verbatim unless `EXPO_NO_DEFAULT_PORT=true` is also set,\n * otherwise a `:80` port will be added for Android support.\n */\n get EXPO_PACKAGER_PROXY_URL(): string {\n return string('EXPO_PACKAGER_PROXY_URL', '');\n }\n\n /**\n * Disable the enforced `:80` port when using custom dev server URLs.\n * This can break the incomplete Android WebSocket implementation but allows\n * `EXPO_PACKAGER_PROXY_URL` to work as expected.\n * */\n get EXPO_NO_DEFAULT_PORT(): boolean {\n return boolish('EXPO_NO_DEFAULT_PORT', false);\n }\n}\n\nexport const env = new Env();\n"],"names":["Env","EXPO_PROFILE","boolish","EXPO_DEBUG","EXPO_BETA","EXPO_STAGING","EXPO_LOCAL","CI","EXPO_NO_TELEMETRY","EXPO_UNIVERSE_DIR","string","WEB_HOST","EXPO_NO_GIT_STATUS","EXPO_NO_WEB_SETUP","EXPO_NO_TYPESCRIPT_SETUP","EXPO_NO_CACHE","EXPO_ENABLE_INTERSTITIAL_PAGE","RCT_METRO_PORT","int","EXPO_SKIP_MANIFEST_VALIDATION_TOKEN","EXPO_PUBLIC_FOLDER","EXPO_EDITOR","EXPO_PACKAGER_PROXY_URL","EXPO_NO_DEFAULT_PORT","env"],"mappings":"AAAA;;;;;AAAqC,IAAA,OAAQ,WAAR,QAAQ,CAAA;AAE7C,mFAAmF;AAEnF,6CAA6C;AAE7C,MAAMA,GAAG;IACP,+BAA+B,CAC/B,IAAIC,YAAY,GAAG;QACjB,OAAOC,CAAAA,GAAAA,OAAO,AAAuB,CAAA,QAAvB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;KACvC;IAED,2BAA2B,CAC3B,IAAIC,UAAU,GAAG;QACf,OAAOD,CAAAA,GAAAA,OAAO,AAAqB,CAAA,QAArB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;KACrC;IAED,wGAAwG,CACxG,IAAIE,SAAS,GAAG;QACd,OAAOF,CAAAA,GAAAA,OAAO,AAAoB,CAAA,QAApB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;KACpC;IAED,qCAAqC,CACrC,IAAIG,YAAY,GAAG;QACjB,OAAOH,CAAAA,GAAAA,OAAO,AAAuB,CAAA,QAAvB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;KACvC;IAED,mCAAmC,CACnC,IAAII,UAAU,GAAG;QACf,OAAOJ,CAAAA,GAAAA,OAAO,AAAqB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