@expo/cli 0.24.13 → 0.24.14

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 (45) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/metro-require/require.js +6 -4
  3. package/build/src/export/exportHermes.js +2 -2
  4. package/build/src/export/exportHermes.js.map +1 -1
  5. package/build/src/prebuild/resolveTemplate.js +4 -4
  6. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  7. package/build/src/run/ios/XcodeBuild.js +3 -3
  8. package/build/src/run/ios/XcodeBuild.js.map +1 -1
  9. package/build/src/start/doctor/SecurityBinPrerequisite.js +1 -1
  10. package/build/src/start/doctor/SecurityBinPrerequisite.js.map +1 -1
  11. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +1 -1
  12. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  13. package/build/src/start/doctor/dependencies/resolvePackages.js +1 -1
  14. package/build/src/start/doctor/dependencies/resolvePackages.js.map +1 -1
  15. package/build/src/start/doctor/ngrok/ExternalModule.js +1 -1
  16. package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
  17. package/build/src/start/platforms/PlatformManager.js +1 -1
  18. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  19. package/build/src/start/platforms/android/AndroidPlatformManager.js +1 -1
  20. package/build/src/start/platforms/android/AndroidPlatformManager.js.map +1 -1
  21. package/build/src/start/platforms/android/getDevices.js +1 -1
  22. package/build/src/start/platforms/android/getDevices.js.map +1 -1
  23. package/build/src/start/platforms/ios/AppleDeviceManager.js +1 -1
  24. package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
  25. package/build/src/start/platforms/ios/xcrun.js +1 -1
  26. package/build/src/start/platforms/ios/xcrun.js.map +1 -1
  27. package/build/src/start/server/metro/MetroTerminalReporter.js +1 -1
  28. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  29. package/build/src/start/server/metro/createJResolver.js +2 -2
  30. package/build/src/start/server/metro/createJResolver.js.map +1 -1
  31. package/build/src/start/server/metro/createServerComponentsMiddleware.js +0 -1
  32. package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
  33. package/build/src/start/server/metro/runServer-fork.js +1 -1
  34. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  35. package/build/src/start/server/metro/withMetroMultiPlatform.js +1 -1
  36. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  37. package/build/src/start/server/middleware/CorsMiddleware.js +1 -1
  38. package/build/src/start/server/middleware/CorsMiddleware.js.map +1 -1
  39. package/build/src/utils/modifyConfigAsync.js +1 -1
  40. package/build/src/utils/modifyConfigAsync.js.map +1 -1
  41. package/build/src/utils/scheme.js +1 -1
  42. package/build/src/utils/scheme.js.map +1 -1
  43. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  44. package/build/src/utils/telemetry/utils/context.js +1 -1
  45. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/platforms/PlatformManager.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { AppIdResolver } from './AppIdResolver';\nimport { DeviceManager } from './DeviceManager';\nimport { Log } from '../../log';\nimport { CommandError, UnimplementedError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\n\nconst debug = require('debug')('expo:start:platforms:platformManager') as typeof console.log;\n\nexport interface BaseOpenInCustomProps {\n scheme?: string;\n applicationId?: string | null;\n}\n\nexport interface BaseResolveDeviceProps<IDevice> {\n /** Should prompt the user to select a device. */\n shouldPrompt?: boolean;\n /** The target device to use. */\n device?: IDevice;\n}\n\n/** An abstract class for launching a URL on a device. */\nexport class PlatformManager<\n IDevice,\n IOpenInCustomProps extends BaseOpenInCustomProps = BaseOpenInCustomProps,\n IResolveDeviceProps extends BaseResolveDeviceProps<IDevice> = BaseResolveDeviceProps<IDevice>,\n> {\n constructor(\n protected projectRoot: string,\n protected props: {\n platform: 'ios' | 'android';\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL. */\n getExpoGoUrl: () => string;\n /**\n * Get redirect URL for native disambiguation.\n * @returns a URL like `http://localhost:8081/_expo/loading`\n */\n getRedirectUrl: () => string | null;\n /** Dev Client */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n /** Resolve a device, this function should automatically handle opening the device and asserting any system validations. */\n resolveDeviceAsync: (\n resolver?: Partial<IResolveDeviceProps>\n ) => Promise<DeviceManager<IDevice>>;\n }\n ) {}\n\n /** Returns the project application identifier or asserts that one is not defined. Exposed for testing. */\n _getAppIdResolver(): AppIdResolver {\n throw new UnimplementedError();\n }\n\n /**\n * Get the URL for users intending to launch the project in Expo Go.\n * The CLI will check if the project has a custom dev client and if the redirect page feature is enabled.\n * If both are true, the CLI will return the redirect page URL.\n */\n protected async getExpoGoOrCustomRuntimeUrlAsync(\n deviceManager: DeviceManager<IDevice>\n ): Promise<string> {\n // Determine if the redirect page feature is enabled first since it's the cheapest to check.\n const redirectUrl = this.props.getRedirectUrl();\n if (redirectUrl) {\n // If the redirect page feature is enabled, check if the project has a resolvable native identifier.\n let applicationId;\n try {\n applicationId = await this._getAppIdResolver().getAppIdAsync();\n } catch {\n Log.warn(\n chalk`\\u203A Launching in Expo Go. If you want to use a ` +\n `development build, you need to create and install one first, or, if you already ` +\n chalk`have a build, add {bold ios.bundleIdentifier} and {bold android.package} to ` +\n `this project's app config.\\n${learnMore('https://docs.expo.dev/development/build/')}`\n );\n }\n if (applicationId) {\n debug(`Resolving launch URL: (appId: ${applicationId}, redirect URL: ${redirectUrl})`);\n // NOTE(EvanBacon): This adds considerable amount of time to the command, we should consider removing or memoizing it.\n // Finally determine if the target device has a custom dev client installed.\n if (\n await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId)\n ) {\n return redirectUrl;\n } else {\n // Log a warning if no development build is available on the device, but the\n // interstitial page would otherwise be opened.\n Log.warn(\n chalk`\\u203A The {bold expo-dev-client} package is installed, but a development build is not ` +\n chalk`installed on {bold ${deviceManager.name}}.\\nLaunching in Expo Go. If you want to use a ` +\n `development build, you need to create and install one first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n }\n }\n\n return this.props.getExpoGoUrl();\n }\n\n protected async openProjectInExpoGoAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n const url = await this.getExpoGoOrCustomRuntimeUrlAsync(deviceManager);\n\n deviceManager.logOpeningUrl(url);\n\n // TODO: Expensive, we should only do this once.\n const { exp } = getConfig(this.projectRoot);\n const sdkVersion = exp.sdkVersion;\n assert(sdkVersion, 'sdkVersion should be resolved by getConfig');\n await deviceManager.ensureExpoGoAsync(sdkVersion);\n\n deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url, { appId: deviceManager.getExpoGoAppId() });\n\n return { url };\n }\n\n protected async openProjectInCustomRuntimeAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {},\n props: Partial<IOpenInCustomProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open custom (${Object.entries(props)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ')})`\n );\n\n let url = this.props.getCustomRuntimeUrl({ scheme: props.scheme });\n debug(`Opening project in custom runtime: ${url} -- %O`, props);\n // TODO: It's unclear why we do application id validation when opening with a URL\n // NOTE: But having it enables us to allow the deep link to directly open on iOS simulators without the modal.\n const applicationId = props.applicationId ?? (await this._getAppIdResolver().getAppIdAsync());\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n\n if (!(await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId))) {\n throw new CommandError(\n `No development build (${applicationId}) for this project is installed. ` +\n `Please make and install a development build on the device first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n if (!url) {\n url = this._resolveAlternativeLaunchUrl(applicationId, props);\n }\n\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n\n await deviceManager.openUrlAsync(url, {\n appId: applicationId,\n });\n\n return {\n url,\n };\n }\n\n /** Launch the project on a device given the input runtime. */\n async openAsync(\n options:\n | {\n runtime: 'expo' | 'web';\n }\n | {\n runtime: 'custom';\n props?: Partial<IOpenInCustomProps>;\n },\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open (runtime: ${options.runtime}, platform: ${this.props.platform}, device: %O, shouldPrompt: ${resolveSettings.shouldPrompt})`,\n resolveSettings.device\n );\n if (options.runtime === 'expo') {\n return this.openProjectInExpoGoAsync(resolveSettings);\n } else if (options.runtime === 'web') {\n return this.openWebProjectAsync(resolveSettings);\n } else if (options.runtime === 'custom') {\n return this.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n } else {\n throw new CommandError(`Invalid runtime target: ${options.runtime}`);\n }\n }\n\n /** Open the current web project (Webpack) in a device . */\n private async openWebProjectAsync(resolveSettings: Partial<IResolveDeviceProps> = {}): Promise<{\n url: string;\n }> {\n const url = this.props.getDevServerUrl();\n assert(url, 'Dev server is not running.');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return { url };\n }\n\n /** If the launch URL cannot be determined (`custom` runtimes) then an alternative string can be provided to open the device. Often a device ID or activity to launch. Exposed for testing. */\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props: Partial<IOpenInCustomProps> = {}\n ): string {\n throw new UnimplementedError();\n }\n}\n"],"names":["PlatformManager","debug","require","constructor","projectRoot","props","_getAppIdResolver","UnimplementedError","getExpoGoOrCustomRuntimeUrlAsync","deviceManager","redirectUrl","getRedirectUrl","applicationId","getAppIdAsync","Log","warn","chalk","learnMore","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","name","getExpoGoUrl","openProjectInExpoGoAsync","resolveSettings","resolveDeviceAsync","url","logOpeningUrl","exp","getConfig","sdkVersion","assert","ensureExpoGoAsync","activateWindowAsync","openUrlAsync","appId","getExpoGoAppId","openProjectInCustomRuntimeAsync","Object","entries","map","k","v","join","getCustomRuntimeUrl","scheme","CommandError","_resolveAlternativeLaunchUrl","openAsync","options","runtime","platform","shouldPrompt","device","openWebProjectAsync","getDevServerUrl"],"mappings":";;;;+BAyBaA;;;eAAAA;;;;yBAzBa;;;;;;;gEACP;;;;;;;gEACD;;;;;;qBAIE;wBAC6B;sBACvB;;;;;;AAE1B,MAAMC,QAAQC,QAAQ,SAAS;AAexB,MAAMF;IAKXG,YACE,AAAUC,WAAmB,EAC7B,AAAUC,KAiBT,CACD;aAnBUD,cAAAA;aACAC,QAAAA;IAkBT;IAEH,wGAAwG,GACxGC,oBAAmC;QACjC,MAAM,IAAIC,0BAAkB;IAC9B;IAEA;;;;GAIC,GACD,MAAgBC,iCACdC,aAAqC,EACpB;QACjB,4FAA4F;QAC5F,MAAMC,cAAc,IAAI,CAACL,KAAK,CAACM,cAAc;QAC7C,IAAID,aAAa;YACf,oGAAoG;YACpG,IAAIE;YACJ,IAAI;gBACFA,gBAAgB,MAAM,IAAI,CAACN,iBAAiB,GAAGO,aAAa;YAC9D,EAAE,OAAM;gBACNC,QAAG,CAACC,IAAI,CACNC,IAAAA,gBAAK,CAAA,CAAC,kDAAkD,CAAC,GACvD,CAAC,gFAAgF,CAAC,GAClFA,IAAAA,gBAAK,CAAA,CAAC,4EAA4E,CAAC,GACnF,CAAC,4BAA4B,EAAEC,IAAAA,eAAS,EAAC,6CAA6C;YAE5F;YACA,IAAIL,eAAe;gBACjBX,MAAM,CAAC,8BAA8B,EAAEW,cAAc,gBAAgB,EAAEF,YAAY,CAAC,CAAC;gBACrF,sHAAsH;gBACtH,4EAA4E;gBAC5E,IACE,MAAMD,cAAcS,mDAAmD,CAACN,gBACxE;oBACA,OAAOF;gBACT,OAAO;o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AEG,QAAQC,OAAO,EAAE;QACrE;IACF;IAEA,yDAAyD,GACzD,MAAcI,oBAAoB9B,kBAAgD,CAAC,CAAC,EAEjF;QACD,MAAME,MAAM,IAAI,CAACnB,KAAK,CAACgD,eAAe;QACtCxB,IAAAA,iBAAM,EAACL,KAAK;QAEZ,MAAMf,gBAAgB,MAAM,IAAI,CAACJ,KAAK,CAACkB,kBAAkB,CAACD;QAC1Db,cAAcgB,aAAa,CAACD;QAC5B,MAAMf,cAAcsB,mBAAmB;QACvC,MAAMtB,cAAcuB,YAAY,CAACR;QAEjC,OAAO;YAAEA;QAAI;IACf;IAEA,4LAA4L,GAC5LqB,6BACEjC,aAAqB,EACrBP,QAAqC,CAAC,CAAC,EAC/B;QACR,MAAM,IAAIE,0BAAkB;IAC9B;AACF"}
1
+ {"version":3,"sources":["../../../../src/start/platforms/PlatformManager.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { AppIdResolver } from './AppIdResolver';\nimport { DeviceManager } from './DeviceManager';\nimport { Log } from '../../log';\nimport { CommandError, UnimplementedError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\n\nconst debug = require('debug')('expo:start:platforms:platformManager') as typeof console.log;\n\nexport interface BaseOpenInCustomProps {\n scheme?: string;\n applicationId?: string | null;\n}\n\nexport interface BaseResolveDeviceProps<IDevice> {\n /** Should prompt the user to select a device. */\n shouldPrompt?: boolean;\n /** The target device to use. */\n device?: IDevice;\n}\n\n/** An abstract class for launching a URL on a device. */\nexport class PlatformManager<\n IDevice,\n IOpenInCustomProps extends BaseOpenInCustomProps = BaseOpenInCustomProps,\n IResolveDeviceProps extends BaseResolveDeviceProps<IDevice> = BaseResolveDeviceProps<IDevice>,\n> {\n constructor(\n protected projectRoot: string,\n protected props: {\n platform: 'ios' | 'android';\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL. */\n getExpoGoUrl: () => string;\n /**\n * Get redirect URL for native disambiguation.\n * @returns a URL like `http://localhost:8081/_expo/loading`\n */\n getRedirectUrl: () => string | null;\n /** Dev Client */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n /** Resolve a device, this function should automatically handle opening the device and asserting any system validations. */\n resolveDeviceAsync: (\n resolver?: Partial<IResolveDeviceProps>\n ) => Promise<DeviceManager<IDevice>>;\n }\n ) {}\n\n /** Returns the project application identifier or asserts that one is not defined. Exposed for testing. */\n _getAppIdResolver(): AppIdResolver {\n throw new UnimplementedError();\n }\n\n /**\n * Get the URL for users intending to launch the project in Expo Go.\n * The CLI will check if the project has a custom dev client and if the redirect page feature is enabled.\n * If both are true, the CLI will return the redirect page URL.\n */\n protected async getExpoGoOrCustomRuntimeUrlAsync(\n deviceManager: DeviceManager<IDevice>\n ): Promise<string> {\n // Determine if the redirect page feature is enabled first since it's the cheapest to check.\n const redirectUrl = this.props.getRedirectUrl();\n if (redirectUrl) {\n // If the redirect page feature is enabled, check if the project has a resolvable native identifier.\n let applicationId;\n try {\n applicationId = await this._getAppIdResolver().getAppIdAsync();\n } catch {\n Log.warn(\n chalk`\\u203A Launching in Expo Go. If you want to use a ` +\n `development build, you need to create and install one first, or, if you already ` +\n chalk`have a build, add {bold ios.bundleIdentifier} and {bold android.package} to ` +\n `this project's app config.\\n${learnMore('https://docs.expo.dev/development/build/')}`\n );\n }\n if (applicationId) {\n debug(`Resolving launch URL: (appId: ${applicationId}, redirect URL: ${redirectUrl})`);\n // NOTE(EvanBacon): This adds considerable amount of time to the command, we should consider removing or memoizing it.\n // Finally determine if the target device has a custom dev client installed.\n if (\n await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId)\n ) {\n return redirectUrl;\n } else {\n // Log a warning if no development build is available on the device, but the\n // interstitial page would otherwise be opened.\n Log.warn(\n chalk`\\u203A The {bold expo-dev-client} package is installed, but a development build is not ` +\n chalk`installed on {bold ${deviceManager.name}}.\\nLaunching in Expo Go. If you want to use a ` +\n `development build, you need to create and install one first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n }\n }\n\n return this.props.getExpoGoUrl();\n }\n\n protected async openProjectInExpoGoAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n const url = await this.getExpoGoOrCustomRuntimeUrlAsync(deviceManager);\n\n deviceManager.logOpeningUrl(url);\n\n // TODO: Expensive, we should only do this once.\n const { exp } = getConfig(this.projectRoot);\n const sdkVersion = exp.sdkVersion;\n assert(sdkVersion, 'sdkVersion should be resolved by getConfig');\n await deviceManager.ensureExpoGoAsync(sdkVersion);\n\n deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url, { appId: deviceManager.getExpoGoAppId() });\n\n return { url };\n }\n\n protected async openProjectInCustomRuntimeAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {},\n props: Partial<IOpenInCustomProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open custom (${Object.entries(props)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ')})`\n );\n\n let url = this.props.getCustomRuntimeUrl({ scheme: props.scheme });\n debug(`Opening project in custom runtime: ${url} -- %O`, props);\n // TODO: It's unclear why we do application id validation when opening with a URL\n // NOTE: But having it enables us to allow the deep link to directly open on iOS simulators without the modal.\n const applicationId = props.applicationId ?? (await this._getAppIdResolver().getAppIdAsync());\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n\n if (!(await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId))) {\n throw new CommandError(\n `No development build (${applicationId}) for this project is installed. ` +\n `Install a development build on the target device and try again.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n if (!url) {\n url = this._resolveAlternativeLaunchUrl(applicationId, props);\n }\n\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n\n await deviceManager.openUrlAsync(url, {\n appId: applicationId,\n });\n\n return {\n url,\n };\n }\n\n /** Launch the project on a device given the input runtime. */\n async openAsync(\n options:\n | {\n runtime: 'expo' | 'web';\n }\n | {\n runtime: 'custom';\n props?: Partial<IOpenInCustomProps>;\n },\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open (runtime: ${options.runtime}, platform: ${this.props.platform}, device: %O, shouldPrompt: ${resolveSettings.shouldPrompt})`,\n resolveSettings.device\n );\n if (options.runtime === 'expo') {\n return this.openProjectInExpoGoAsync(resolveSettings);\n } else if (options.runtime === 'web') {\n return this.openWebProjectAsync(resolveSettings);\n } else if (options.runtime === 'custom') {\n return this.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n } else {\n throw new CommandError(`Invalid runtime target: ${options.runtime}`);\n }\n }\n\n /** Open the current web project (Webpack) in a device . */\n private async openWebProjectAsync(resolveSettings: Partial<IResolveDeviceProps> = {}): Promise<{\n url: string;\n }> {\n const url = this.props.getDevServerUrl();\n assert(url, 'Dev server is not running.');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return { url };\n }\n\n /** If the launch URL cannot be determined (`custom` runtimes) then an alternative string can be provided to open the device. Often a device ID or activity to launch. Exposed for testing. */\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props: Partial<IOpenInCustomProps> = {}\n ): string {\n throw new UnimplementedError();\n }\n}\n"],"names":["PlatformManager","debug","require","constructor","projectRoot","props","_getAppIdResolver","UnimplementedError","getExpoGoOrCustomRuntimeUrlAsync","deviceManager","redirectUrl","getRedirectUrl","applicationId","getAppIdAsync","Log","warn","chalk","learnMore","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","name","getExpoGoUrl","openProjectInExpoGoAsync","resolveSettings","resolveDeviceAsync","url","logOpeningUrl","exp","getConfig","sdkVersion","assert","ensureExpoGoAsync","activateWindowAsync","openUrlAsync","appId","getExpoGoAppId","openProjectInCustomRuntimeAsync","Object","entries","map","k","v","join","getCustomRuntimeUrl","scheme","CommandError","_resolveAlternativeLaunchUrl","openAsync","options","runtime","platform","shouldPrompt","device","openWebProjectAsync","getDevServerUrl"],"mappings":";;;;+BAyBaA;;;eAAAA;;;;yBAzBa;;;;;;;gEACP;;;;;;;gEACD;;;;;;qBAIE;wBAC6B;sBACvB;;;;;;AAE1B,MAAMC,QAAQC,QAAQ,SAAS;AAexB,MAAMF;IAKXG,YACE,AAAUC,WAAmB,EAC7B,AAAUC,KAiBT,CACD;aAnBUD,cAAAA;aACAC,QAAAA;IAkBT;IAEH,wGAAwG,GACxGC,oBAAmC;QACjC,MAAM,IAAIC,0BAAkB;IAC9B;IAEA;;;;GAIC,GACD,MAAgBC,iCACdC,aAAqC,EACpB;QACjB,4FAA4F;QAC5F,MAAMC,cAAc,IAAI,CAACL,KAAK,CAACM,cAAc;QAC7C,IAAID,aAAa;YACf,oGAAoG;YACpG,IAAIE;YACJ,IAAI;gBACFA,gBAAgB,MAAM,IAAI,CAACN,iBAAiB,GAAGO,aAAa;YAC9D,EAAE,OAAM;gBACNC,QAAG,CAACC,IAAI,CACNC,IAAAA,gBAAK,CAAA,CAAC,kDAAkD,CAAC,GACvD,CAAC,gFAAgF,CAAC,GAClFA,IAAAA,gBAAK,CAAA,CAAC,4EAA4E,CAAC,GACnF,CAAC,4BAA4B,EAAEC,IAAAA,eAAS,EAAC,6CAA6C;YAE5F;YACA,IAAIL,eAAe;gBACjBX,MAAM,CAAC,8BAA8B,EAAEW,cAAc,gBAAgB,EAAEF,YAAY,CAAC,CAAC;gBACrF,sHAAsH;gBACtH,4EAA4E;gBAC5E,IACE,MAAMD,cAAcS,mDAAmD,CAACN,gBACxE;oBACA,OAAOF;gBACT,OAAO;oBACL,4EAA4E;oBAC5E,+CAA+C;oBAC/CI,QAAG,CAACC,IAAI,CACNC,IAAAA,gBAAK,CAAA,CAAC,uFAAuF,CAAC,GAC5FA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MAAM,IAAI,CAACnB,KAAK,CAACgD,eAAe;QACtCxB,IAAAA,iBAAM,EAACL,KAAK;QAEZ,MAAMf,gBAAgB,MAAM,IAAI,CAACJ,KAAK,CAACkB,kBAAkB,CAACD;QAC1Db,cAAcgB,aAAa,CAACD;QAC5B,MAAMf,cAAcsB,mBAAmB;QACvC,MAAMtB,cAAcuB,YAAY,CAACR;QAEjC,OAAO;YAAEA;QAAI;IACf;IAEA,4LAA4L,GAC5LqB,6BACEjC,aAAqB,EACrBP,QAAqC,CAAC,CAAC,EAC/B;QACR,MAAM,IAAIE,0BAAkB;IAC9B;AACF"}
@@ -60,7 +60,7 @@ class AndroidPlatformManager extends _PlatformManager.PlatformManager {
60
60
  debug(`Opening custom runtime using launch activity: ${launchActivity} --`, options.props);
61
61
  const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);
62
62
  if (!await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(customAppId)) {
63
- throw new _errors.CommandError(`No development build (${customAppId}) for this project is installed. ` + `Please make and install a development build on the device first.\n${(0, _link.learnMore)('https://docs.expo.dev/development/build/')}`);
63
+ throw new _errors.CommandError(`No development build (${customAppId}) for this project is installed. ` + `Install a development build on the target device and try again.\n${(0, _link.learnMore)('https://docs.expo.dev/development/build/')}`);
64
64
  }
65
65
  deviceManager.logOpeningUrl(url ?? launchActivity);
66
66
  await deviceManager.activateWindowAsync();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/android/AndroidPlatformManager.ts"],"sourcesContent":["import { AndroidAppIdResolver } from './AndroidAppIdResolver';\nimport { AndroidDeviceManager } from './AndroidDeviceManager';\nimport { Device } from './adb';\nimport { startAdbReverseAsync } from './adbReverse';\nimport { CommandError } from '../../../utils/errors';\nimport { memoize } from '../../../utils/fn';\nimport { learnMore } from '../../../utils/link';\nimport { hasDirectDevClientDependency } from '../../detectDevClient';\nimport { AppIdResolver } from '../AppIdResolver';\nimport { BaseOpenInCustomProps, BaseResolveDeviceProps, PlatformManager } from '../PlatformManager';\n\nconst debug = require('debug')(\n 'expo:start:platforms:platformManager:android'\n) as typeof console.log;\n\nexport interface AndroidOpenInCustomProps extends BaseOpenInCustomProps {\n /**\n * The Android app intent to launch through `adb shell am start -n <launchActivity>`.\n */\n launchActivity?: string;\n /**\n * The custom app id to launch, provided through `--app-id`.\n * By default, the app id is identical to the package name.\n * When using product flavors, the app id might be customized.\n */\n customAppId?: string;\n}\n\nexport class AndroidPlatformManager extends PlatformManager<Device, AndroidOpenInCustomProps> {\n /** The last used custom launch props, should be reused whenever launching custom runtime without launch props */\n private lastCustomRuntimeLaunchProps?: AndroidOpenInCustomProps;\n /** Memoized method to detect if dev client is installed */\n private hasDevClientInstalled: () => boolean;\n\n constructor(\n protected projectRoot: string,\n protected port: number,\n options: {\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL */\n getExpoGoUrl: () => string;\n /** Get redirect URL for native disambiguation. */\n getRedirectUrl: () => string | null;\n /** Dev Client URL. */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n }\n ) {\n super(projectRoot, {\n platform: 'android',\n ...options,\n resolveDeviceAsync: AndroidDeviceManager.resolveAsync,\n });\n\n this.hasDevClientInstalled = memoize(hasDirectDevClientDependency.bind(this, projectRoot));\n }\n\n async openAsync(\n options:\n | { runtime: 'expo' | 'web' }\n | { runtime: 'custom'; props?: Partial<AndroidOpenInCustomProps> },\n resolveSettings?: Partial<BaseResolveDeviceProps<Device>>\n ): Promise<{ url: string }> {\n await startAdbReverseAsync([this.port]);\n\n if (options.runtime === 'custom') {\n // Store the resolved launch properties for future \"openAsync\" request.\n // This reuses the same launch properties when opening through the CLI interface (pressing `a`).\n if (options.props) {\n this.lastCustomRuntimeLaunchProps = options.props;\n } else if (!options.props && this.lastCustomRuntimeLaunchProps) {\n options.props = this.lastCustomRuntimeLaunchProps;\n }\n\n // Handle projects that need to launch with a custom app id and launch activity\n return this.openProjectInCustomRuntimeWithCustomAppIdAsync(options, resolveSettings);\n }\n\n return super.openAsync(options, resolveSettings);\n }\n\n /**\n * Launch the custom runtime project, using the provided custom app id and launch activity.\n * Instead of \"open url\", this will launch the activity directly.\n * If dev client is installed, it will also pass the dev client URL to the activity.\n */\n async openProjectInCustomRuntimeWithCustomAppIdAsync(\n options: { runtime: 'custom'; props?: Partial<AndroidOpenInCustomProps> },\n resolveSettings?: Partial<BaseResolveDeviceProps<Device>>\n ) {\n // Fall back to default dev client URL open behavior if no custom app id or launch activity is provided\n if (!options.props?.customAppId || !options.props?.launchActivity) {\n return super.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n }\n\n const { customAppId, launchActivity } = options.props;\n const url = this.hasDevClientInstalled()\n ? (this.props.getCustomRuntimeUrl({ scheme: options.props.scheme }) ?? undefined)\n : undefined;\n\n debug(`Opening custom runtime using launch activity: ${launchActivity} --`, options.props);\n\n const deviceManager = (await this.props.resolveDeviceAsync(\n resolveSettings\n )) as AndroidDeviceManager;\n\n if (!(await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(customAppId))) {\n throw new CommandError(\n `No development build (${customAppId}) for this project is installed. ` +\n `Please make and install a development build on the device first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n deviceManager.logOpeningUrl(url ?? launchActivity);\n await deviceManager.activateWindowAsync();\n await deviceManager.launchActivityAsync(launchActivity, url);\n\n return { url: url ?? launchActivity };\n }\n\n _getAppIdResolver(): AppIdResolver {\n return new AndroidAppIdResolver(this.projectRoot);\n }\n\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props?: Partial<AndroidOpenInCustomProps>\n ): string {\n return props?.launchActivity ?? `${applicationId}/.MainActivity`;\n }\n}\n"],"names":["AndroidPlatformManager","debug","require","PlatformManager","constructor","projectRoot","port","options","platform","resolveDeviceAsync","AndroidDeviceManager","resolveAsync","hasDevClientInstalled","memoize","hasDirectDevClientDependency","bind","openAsync","resolveSettings","startAdbReverseAsync","runtime","props","lastCustomRuntimeLaunchProps","openProjectInCustomRuntimeWithCustomAppIdAsync","customAppId","launchActivity","openProjectInCustomRuntimeAsync","url","getCustomRuntimeUrl","scheme","undefined","deviceManager","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","CommandError","learnMore","logOpeningUrl","activateWindowAsync","launchActivityAsync","_getAppIdResolver","AndroidAppIdResolver","_resolveAlternativeLaunchUrl","applicationId"],"mappings":";;;;+BA4BaA;;;eAAAA;;;sCA5BwB;sCACA;4BAEA;wBACR;oBACL;sBACE;iCACmB;iCAEkC;AAE/E,MAAMC,QAAQC,QAAQ,SACpB;AAgBK,MAAMF,+BAA+BG,gCAAe;IAMzDC,YACE,AAAUC,WAAmB,EAC7B,AAAUC,IAAY,EACtBC,OASC,CACD;QACA,KAAK,CAACF,aAAa;YACjBG,UAAU;YACV,GAAGD,OAAO;YACVE,oBAAoBC,0CAAoB,CAACC,YAAY;QACvD,SAjBUN,cAAAA,kBACAC,OAAAA;QAkBV,IAAI,CAACM,qBAAqB,GAAGC,IAAAA,WAAO,EAACC,6CAA4B,CAACC,IAAI,CAAC,IAAI,EAAEV;IAC/E;IAEA,MAAMW,UACJT,OAEoE,EACpEU,eAAyD,EAC/B;QAC1B,MAAMC,IAAAA,gCAAoB,EAAC;YAAC,IAAI,CAACZ,IAAI;SAAC;QAEtC,IAAIC,QAAQY,OAAO,KAAK,UAAU;YAChC,uEAAuE;YACvE,gGAAgG;YAChG,IAAIZ,QAAQa,KAAK,EAAE;gBACjB,IAAI,CAACC,4BAA4B,GAAGd,QAAQa,KAAK;YACnD,OAAO,IAAI,CAACb,QAAQa,KAAK,IAAI,IAAI,CAACC,4BAA4B,EAAE;gBAC9Dd,QAAQa,KAAK,GAAG,IAAI,CAACC,4BAA4B;YACnD;YAEA,+EAA+E;YAC/E,OAAO,IAAI,CAACC,8CAA8C,CAACf,SAASU;QACtE;QAEA,OAAO,KAAK,CAACD,UAAUT,SAASU;IAClC;IAEA;;;;GAIC,G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cesContent":["import { AndroidAppIdResolver } from './AndroidAppIdResolver';\nimport { AndroidDeviceManager } from './AndroidDeviceManager';\nimport { Device } from './adb';\nimport { startAdbReverseAsync } from './adbReverse';\nimport { CommandError } from '../../../utils/errors';\nimport { memoize } from '../../../utils/fn';\nimport { learnMore } from '../../../utils/link';\nimport { hasDirectDevClientDependency } from '../../detectDevClient';\nimport { AppIdResolver } from '../AppIdResolver';\nimport { BaseOpenInCustomProps, BaseResolveDeviceProps, PlatformManager } from '../PlatformManager';\n\nconst debug = require('debug')(\n 'expo:start:platforms:platformManager:android'\n) as typeof console.log;\n\nexport interface AndroidOpenInCustomProps extends BaseOpenInCustomProps {\n /**\n * The Android app intent to launch through `adb shell am start -n <launchActivity>`.\n */\n launchActivity?: string;\n /**\n * The custom app id to launch, provided through `--app-id`.\n * By default, the app id is identical to the package name.\n * When using product flavors, the app id might be customized.\n */\n customAppId?: string;\n}\n\nexport class AndroidPlatformManager extends PlatformManager<Device, AndroidOpenInCustomProps> {\n /** The last used custom launch props, should be reused whenever launching custom runtime without launch props */\n private lastCustomRuntimeLaunchProps?: AndroidOpenInCustomProps;\n /** Memoized method to detect if dev client is installed */\n private hasDevClientInstalled: () => boolean;\n\n constructor(\n protected projectRoot: string,\n protected port: number,\n options: {\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL */\n getExpoGoUrl: () => string;\n /** Get redirect URL for native disambiguation. */\n getRedirectUrl: () => string | null;\n /** Dev Client URL. */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n }\n ) {\n super(projectRoot, {\n platform: 'android',\n ...options,\n resolveDeviceAsync: AndroidDeviceManager.resolveAsync,\n });\n\n this.hasDevClientInstalled = memoize(hasDirectDevClientDependency.bind(this, projectRoot));\n }\n\n async openAsync(\n options:\n | { runtime: 'expo' | 'web' }\n | { runtime: 'custom'; props?: Partial<AndroidOpenInCustomProps> },\n resolveSettings?: Partial<BaseResolveDeviceProps<Device>>\n ): Promise<{ url: string }> {\n await startAdbReverseAsync([this.port]);\n\n if (options.runtime === 'custom') {\n // Store the resolved launch properties for future \"openAsync\" request.\n // This reuses the same launch properties when opening through the CLI interface (pressing `a`).\n if (options.props) {\n this.lastCustomRuntimeLaunchProps = options.props;\n } else if (!options.props && this.lastCustomRuntimeLaunchProps) {\n options.props = this.lastCustomRuntimeLaunchProps;\n }\n\n // Handle projects that need to launch with a custom app id and launch activity\n return this.openProjectInCustomRuntimeWithCustomAppIdAsync(options, resolveSettings);\n }\n\n return super.openAsync(options, resolveSettings);\n }\n\n /**\n * Launch the custom runtime project, using the provided custom app id and launch activity.\n * Instead of \"open url\", this will launch the activity directly.\n * If dev client is installed, it will also pass the dev client URL to the activity.\n */\n async openProjectInCustomRuntimeWithCustomAppIdAsync(\n options: { runtime: 'custom'; props?: Partial<AndroidOpenInCustomProps> },\n resolveSettings?: Partial<BaseResolveDeviceProps<Device>>\n ) {\n // Fall back to default dev client URL open behavior if no custom app id or launch activity is provided\n if (!options.props?.customAppId || !options.props?.launchActivity) {\n return super.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n }\n\n const { customAppId, launchActivity } = options.props;\n const url = this.hasDevClientInstalled()\n ? (this.props.getCustomRuntimeUrl({ scheme: options.props.scheme }) ?? undefined)\n : undefined;\n\n debug(`Opening custom runtime using launch activity: ${launchActivity} --`, options.props);\n\n const deviceManager = (await this.props.resolveDeviceAsync(\n resolveSettings\n )) as AndroidDeviceManager;\n\n if (!(await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(customAppId))) {\n throw new CommandError(\n `No development build (${customAppId}) for this project is installed. ` +\n `Install a development build on the target device and try again.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n deviceManager.logOpeningUrl(url ?? launchActivity);\n await deviceManager.activateWindowAsync();\n await deviceManager.launchActivityAsync(launchActivity, url);\n\n return { url: url ?? launchActivity };\n }\n\n _getAppIdResolver(): AppIdResolver {\n return new AndroidAppIdResolver(this.projectRoot);\n }\n\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props?: Partial<AndroidOpenInCustomProps>\n ): string {\n return props?.launchActivity ?? `${applicationId}/.MainActivity`;\n }\n}\n"],"names":["AndroidPlatformManager","debug","require","PlatformManager","constructor","projectRoot","port","options","platform","resolveDeviceAsync","AndroidDeviceManager","resolveAsync","hasDevClientInstalled","memoize","hasDirectDevClientDependency","bind","openAsync","resolveSettings","startAdbReverseAsync","runtime","props","lastCustomRuntimeLaunchProps","openProjectInCustomRuntimeWithCustomAppIdAsync","customAppId","launchActivity","openProjectInCustomRuntimeAsync","url","getCustomRuntimeUrl","scheme","undefined","deviceManager","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","CommandError","learnMore","logOpeningUrl","activateWindowAsync","launchActivityAsync","_getAppIdResolver","AndroidAppIdResolver","_resolveAlternativeLaunchUrl","applicationId"],"mappings":";;;;+BA4BaA;;;eAAAA;;;sCA5BwB;sCACA;4BAEA;wBACR;oBACL;sBACE;iCACmB;iCAEkC;AAE/E,MAAMC,QAAQC,QAAQ,SACpB;AAgBK,MAAMF,+BAA+BG,gCAAe;IAMzDC,YACE,AAAUC,WAAmB,EAC7B,AAAUC,IAAY,EACtBC,OASC,CACD;QACA,KAAK,CAACF,aAAa;YACjBG,UAAU;YACV,GAAGD,OAAO;YACVE,oBAAoBC,0CAAoB,CAACC,YAAY;QACvD,SAjBUN,cAAAA,kBACAC,OAAAA;QAkBV,IAAI,CAACM,qBAAqB,GAAGC,IAAAA,WAAO,EAACC,6CAA4B,CAACC,IAAI,CAAC,IAAI,EAAEV;IAC/E;IAEA,MAAMW,UACJT,OAEoE,EACpEU,eAAyD,EAC/B;QAC1B,MAAMC,IAAAA,gCAAoB,EAAC;YAAC,IAAI,CAACZ,IAAI;SAAC;QAEtC,IAAIC,QAAQY,OAAO,KAAK,UAAU;YAChC,uEAAuE;YACvE,gGAAgG;YAChG,IAAIZ,QAAQa,KAAK,EAAE;gBACjB,IAA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KAAKA,OAAOF;QAAe;IACtC;IAEAa,oBAAmC;QACjC,OAAO,IAAIC,0CAAoB,CAAC,IAAI,CAACjC,WAAW;IAClD;IAEAkC,6BACEC,aAAqB,EACrBpB,KAAyC,EACjC;QACR,OAAOA,CAAAA,yBAAAA,MAAOI,cAAc,KAAI,GAAGgB,cAAc,cAAc,CAAC;IAClE;AACF"}
@@ -28,7 +28,7 @@ async function getDevicesAsync() {
28
28
  if (!allDevices.length) {
29
29
  throw new _errors.CommandError([
30
30
  `No Android connected device found, and no emulators could be started automatically.`,
31
- `Please connect a device or create an emulator (https://docs.expo.dev/workflow/android-studio-emulator).`,
31
+ `Connect a device or create an emulator (https://docs.expo.dev/workflow/android-studio-emulator).`,
32
32
  `Then follow the instructions here to enable USB debugging:`,
33
33
  `https://developer.android.com/studio/run/device.html#developer-device-options. If you are using Genymotion go to Settings -> ADB, select "Use custom Android SDK tools", and point it at your Android SDK directory.`
34
34
  ].join('\n'));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/android/getDevices.ts"],"sourcesContent":["import { Device, getAttachedDevicesAsync } from './adb';\nimport { listAvdsAsync } from './emulator';\nimport { CommandError } from '../../../utils/errors';\n\n/** Get a list of all devices including offline emulators. Asserts if no devices are available. */\nexport async function getDevicesAsync(): Promise<Device[]> {\n const bootedDevices = await getAttachedDevicesAsync();\n\n const data = await listAvdsAsync();\n const connectedNames = bootedDevices.map(({ name }) => name);\n\n const offlineEmulators = data\n .filter(({ name }) => !connectedNames.includes(name))\n .map(({ name, type }) => {\n return {\n name,\n type,\n isBooted: false,\n // TODO: Are emulators always authorized?\n isAuthorized: true,\n };\n });\n\n const allDevices = bootedDevices.concat(offlineEmulators);\n\n if (!allDevices.length) {\n throw new CommandError(\n [\n `No Android connected device found, and no emulators could be started automatically.`,\n `Please connect a device or create an emulator (https://docs.expo.dev/workflow/android-studio-emulator).`,\n `Then follow the instructions here to enable USB debugging:`,\n `https://developer.android.com/studio/run/device.html#developer-device-options. If you are using Genymotion go to Settings -> ADB, select \"Use custom Android SDK tools\", and point it at your Android SDK directory.`,\n ].join('\\n')\n );\n }\n\n return allDevices;\n}\n"],"names":["getDevicesAsync","bootedDevices","getAttachedDevicesAsync","data","listAvdsAsync","connectedNames","map","name","offlineEmulators","filter","includes","type","isBooted","isAuthorized","allDevices","concat","length","CommandError","join"],"mappings":";;;;+BAKsBA;;;eAAAA;;;qBAL0B;0BAClB;wBACD;AAGtB,eAAeA;IACpB,MAAMC,gBAAgB,MAAMC,IAAAA,4BAAuB;IAEnD,MAAMC,OAAO,MAAMC,IAAAA,uBAAa;IAChC,MAAMC,iBAAiBJ,cAAcK,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAEvD,MAAMC,mBAAmBL,KACtBM,MAAM,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAK,CAACF,eAAeK,QAAQ,CAACH,OAC9CD,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEI,IAAI,EAAE;QAClB,OAAO;YACLJ;YACAI;YACAC,UAAU;YACV,yCAAyC;YACzCC,cAAc;QAChB;IACF;IAEF,MAAMC,aAAab,cAAcc,MAAM,CAACP;IAExC,IAAI,CAACM,WAAWE,MAAM,EAAE;QACtB,MAAM,IAAIC,oBAAY,CACpB;YACE,CAAC,mFAAmF,CAAC;YACrF,CAAC,uGAAuG,CAAC;YACzG,CAAC,0DAA0D,CAAC;YAC5D,CAAC,oNAAoN,CAAC;SACvN,CAACC,IAAI,CAAC;IAEX;IAEA,OAAOJ;AACT"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/android/getDevices.ts"],"sourcesContent":["import { Device, getAttachedDevicesAsync } from './adb';\nimport { listAvdsAsync } from './emulator';\nimport { CommandError } from '../../../utils/errors';\n\n/** Get a list of all devices including offline emulators. Asserts if no devices are available. */\nexport async function getDevicesAsync(): Promise<Device[]> {\n const bootedDevices = await getAttachedDevicesAsync();\n\n const data = await listAvdsAsync();\n const connectedNames = bootedDevices.map(({ name }) => name);\n\n const offlineEmulators = data\n .filter(({ name }) => !connectedNames.includes(name))\n .map(({ name, type }) => {\n return {\n name,\n type,\n isBooted: false,\n // TODO: Are emulators always authorized?\n isAuthorized: true,\n };\n });\n\n const allDevices = bootedDevices.concat(offlineEmulators);\n\n if (!allDevices.length) {\n throw new CommandError(\n [\n `No Android connected device found, and no emulators could be started automatically.`,\n `Connect a device or create an emulator (https://docs.expo.dev/workflow/android-studio-emulator).`,\n `Then follow the instructions here to enable USB debugging:`,\n `https://developer.android.com/studio/run/device.html#developer-device-options. If you are using Genymotion go to Settings -> ADB, select \"Use custom Android SDK tools\", and point it at your Android SDK directory.`,\n ].join('\\n')\n );\n }\n\n return allDevices;\n}\n"],"names":["getDevicesAsync","bootedDevices","getAttachedDevicesAsync","data","listAvdsAsync","connectedNames","map","name","offlineEmulators","filter","includes","type","isBooted","isAuthorized","allDevices","concat","length","CommandError","join"],"mappings":";;;;+BAKsBA;;;eAAAA;;;qBAL0B;0BAClB;wBACD;AAGtB,eAAeA;IACpB,MAAMC,gBAAgB,MAAMC,IAAAA,4BAAuB;IAEnD,MAAMC,OAAO,MAAMC,IAAAA,uBAAa;IAChC,MAAMC,iBAAiBJ,cAAcK,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAEvD,MAAMC,mBAAmBL,KACtBM,MAAM,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAK,CAACF,eAAeK,QAAQ,CAACH,OAC9CD,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEI,IAAI,EAAE;QAClB,OAAO;YACLJ;YACAI;YACAC,UAAU;YACV,yCAAyC;YACzCC,cAAc;QAChB;IACF;IAEF,MAAMC,aAAab,cAAcc,MAAM,CAACP;IAExC,IAAI,CAACM,WAAWE,MAAM,EAAE;QACtB,MAAM,IAAIC,oBAAY,CACpB;YACE,CAAC,mFAAmF,CAAC;YACrF,CAAC,gGAAgG,CAAC;YAClG,CAAC,0DAA0D,CAAC;YAC5D,CAAC,oNAAoN,CAAC;SACvN,CAACC,IAAI,CAAC;IAEX;IAEA,OAAOJ;AACT"}
@@ -194,7 +194,7 @@ class AppleDeviceManager extends _DeviceManager.DeviceManager {
194
194
  let errorMessage = `Couldn't open iOS app with ID "${appId}" on device "${this.name}".`;
195
195
  if (error instanceof _errors.CommandError && error.code === 'APP_NOT_INSTALLED') {
196
196
  if (appId === EXPO_GO_BUNDLE_IDENTIFIER) {
197
- errorMessage = `Couldn't open Expo Go app on device "${this.name}". Please install.`;
197
+ errorMessage = `Couldn't open Expo Go app on device "${this.name}". Install it: https://expo.dev/go.`;
198
198
  } else {
199
199
  errorMessage += `\nThe app might not be installed, try installing it with: ${_chalk().default.bold(`npx expo run:ios -d ${this.device.udid}`)}`;
200
200
  }
@@ -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';\nimport fs from 'fs';\nimport path from 'path';\n\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';\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';\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(\n appId: string,\n { containerPath }: { containerPath?: string } = {}\n ): Promise<string | null> {\n return await SimControl.getInfoPlistValueAsync(this.device, {\n appId,\n key: 'CFBundleShortVersionString',\n containerPath,\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 `npx 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.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(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 isAppInstalledAndIfSoReturnContainerPathForIOSAsync(appId: string) {\n return (\n (await SimControl.getContainerPathAsync(this.device, {\n appId,\n })) ?? false\n );\n }\n\n async openUrlAsync(url: string, options: { appId?: 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, appId: options.appId });\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 getExpoGoAppId(): string {\n return EXPO_GO_BUNDLE_IDENTIFIER;\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":["AppleDeviceManager","ensureSimulatorOpenAsync","debug","require","EXPO_GO_BUNDLE_IDENTIFIER","udid","osType","tryAgain","simulatorOpenedByApp","getBestBootedSimulatorAsync","bestUdid","getBestUnbootedSimulatorAsync","CommandError","bootedDevice","waitForActionAsync","action","assert","SimControl","bootAsync","DeviceManager","assertSystemRequirementsAsync","resolveAsync","device","shouldPrompt","devices","getSelectableSimulatorsAsync","promptAppleDeviceAsync","booted","name","identifier","getAppVersionAsync","appId","containerPath","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","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","delayAsync","uninstallAppAsync","uninstallAsync","getContainerPathAsync","openUrlAsync","url","options","validateUrl","requireProtocol","ensureSimulatorAppRunningAsync","osascript","execAsync","getExpoGoAppId","ensureExpoGoAsync","sdkVersion","installer","ExpoGoInstaller","ensureAsync"],"mappings":";;;;;;;;;;;IAwEaA,kBAAkB;eAAlBA;;IAzCSC,wBAAwB;eAAxBA;;;;iEA/BK;;;;;;;gEACR;;;;;;;gEACD;;;;;;;gEACH;;;;;;;gEACE;;;;;;0CAE6B;2CACC;kCAKxC;mCACgC;gEACX;uBACmB;wBAClB;uBACG;qBACJ;+BACE;iCACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGhC,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,4BAA4B;AAM3B,eAAeH,yBACpB,EAAEI,IAAI,EAAEC,MAAM,EAAuD,GAAG,CAAC,CAAC,EAC1EC,WAAoB,IAAI;IAExB,gDAAgD;IAChD,IAAI,CAACF,MAAM;QACT,iEAAiE;QACjE,MAAMG,uBAAuB,MAAMC,IAAAA,6CAA2B,EAAC;YAAEH;QAAO;QACxE,IAAIE,sBAAsB;YACxB,OAAOA;QACT;QAEA,8EAA8E;QAC9E,MAAME,WAAW,MAAMC,IAAAA,+CAA6B,EAAC;YAAEL;QAAO;QAC9D,IAAI,CAACI,UAAU;YACb,MAAM,IAAIE,oBAAY,CAAC;QACzB;QACAP,OAAOK;IACT;IAEA,MAAMG,eAAe,MAAMC,IAAAA,yBAAkB,EAAC;QAC5CC,QAAQ;YACN,2BAA2B;YAC3BC,IAAAA,iBAAM,EAACX;YACP,OAAOY,QAAWC,SAA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DAA8B,EAAC,IAAI,CAAClD,MAAM;QAChD,oCAAoC;QACpC,MAAMmD,aAAUC,SAAS,CAAC,CAAC,wCAAwC,CAAC;IACtE;IAEAC,iBAAyB;QACvB,OAAOvE;IACT;IAEA,MAAMwE,kBAAkBC,UAAkB,EAAoB;QAC5D,MAAMC,YAAY,IAAIC,gCAAe,CAAC,OAAO3E,2BAA2ByE;QACxE,OAAOC,UAAUE,WAAW,CAAC,IAAI;IACnC;AACF"}
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 { 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';\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';\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(\n appId: string,\n { containerPath }: { containerPath?: string } = {}\n ): Promise<string | null> {\n return await SimControl.getInfoPlistValueAsync(this.device, {\n appId,\n key: 'CFBundleShortVersionString',\n containerPath,\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}\". Install it: https://expo.dev/go.`;\n } else {\n errorMessage += `\\nThe app might not be installed, try installing it with: ${chalk.bold(\n `npx 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.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(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 isAppInstalledAndIfSoReturnContainerPathForIOSAsync(appId: string) {\n return (\n (await SimControl.getContainerPathAsync(this.device, {\n appId,\n })) ?? false\n );\n }\n\n async openUrlAsync(url: string, options: { appId?: 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, appId: options.appId });\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 getExpoGoAppId(): string {\n return EXPO_GO_BUNDLE_IDENTIFIER;\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":["AppleDeviceManager","ensureSimulatorOpenAsync","debug","require","EXPO_GO_BUNDLE_IDENTIFIER","udid","osType","tryAgain","simulatorOpenedByApp","getBestBootedSimulatorAsync","bestUdid","getBestUnbootedSimulatorAsync","CommandError","bootedDevice","waitForActionAsync","action","assert","SimControl","bootAsync","DeviceManager","assertSystemRequirementsAsync","resolveAsync","device","shouldPrompt","devices","getSelectableSimulatorsAsync","promptAppleDeviceAsync","booted","name","identifier","getAppVersionAsync","appId","containerPath","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","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","delayAsync","uninstallAppAsync","uninstallAsync","getContainerPathAsync","openUrlAsync","url","options","validateUrl","requireProtocol","ensureSimulatorAppRunningAsync","osascript","execAsync","getExpoGoAppId","ensureExpoGoAsync","sdkVersion","installer","ExpoGoInstaller","ensureAsync"],"mappings":";;;;;;;;;;;IAwEaA,kBAAkB;eAAlBA;;IAzCSC,wBAAwB;eAAxBA;;;;iEA/BK;;;;;;;gEACR;;;;;;;gEACD;;;;;;;gEACH;;;;;;;gEACE;;;;;;0CAE6B;2CACC;kCAKxC;mCACgC;gEACX;uBACmB;wBAClB;uBACG;qBACJ;+BACE;iCACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGhC,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,4BAA4B;AAM3B,eAAeH,yBACpB,EAAEI,IAAI,EAAEC,MAAM,EAAuD,GAAG,CAAC,CAAC,EAC1EC,WAAoB,IAAI;IAExB,gDAAgD;IAChD,IAAI,CAACF,MAAM;QACT,iEAAiE;QACjE,MAAMG,uBAAuB,MAAMC,IAAAA,6CAA2B,EAAC;YAAEH;QAAO;QACxE,IAAIE,sBAAsB;YACxB,OAAOA;QACT;QAEA,8EAA8E;QAC9E,MAAME,WAAW,MAAMC,IAAAA,+CAA6B,EAAC;YAAEL;QAAO;QAC9D,IAAI,CAACI,UAAU;YACb,MAAM,IAAIE,oBAAY,CAAC;QACzB;QACAP,OAAOK;IACT;IAEA,MAAMG,eAAe,MAAMC,IAAAA,yBAAkB,EAAC;QAC5CC,QAAQ;YACN,2BAA2B;YAC3BC,IAAAA,iBAAM,EAACX;YACP,OAAOY,QAAWC,SAAS,CAAC;gBAAEb;YAAK;QACrC;IACF;IAEA,IAAI,CAACQ,cAAc;QACjB,oHAAoH;QACpH,IAAIN,UAAU;YACZ,OAAO,MAAMN,yBAAyB;gBAAEI;gBAAMC;YAAO,GAAG;QAC1D;QACA,2LAA2L;QAC3L,MAA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QAC5D,MAAMC,YAAY,IAAIC,gCAAe,CAAC,OAAO3E,2BAA2ByE;QACxE,OAAOC,UAAUE,WAAW,CAAC,IAAI;IACnC;AACF"}
@@ -51,7 +51,7 @@ async function xcrunAsync(args, options) {
51
51
  function throwXcrunError(e) {
52
52
  var _e_stderr;
53
53
  if (isLicenseOutOfDate(e.stdout) || isLicenseOutOfDate(e.stderr)) {
54
- throw new _errors.CommandError('XCODE_LICENSE_NOT_ACCEPTED', 'Xcode license is not accepted. Please run `sudo xcodebuild -license`.');
54
+ throw new _errors.CommandError('XCODE_LICENSE_NOT_ACCEPTED', 'Xcode license is not accepted. Run `sudo xcodebuild -license`.');
55
55
  } else if ((_e_stderr = e.stderr) == null ? void 0 : _e_stderr.includes('not a developer tool or in PATH')) {
56
56
  throw new _errors.CommandError('SIMCTL_NOT_AVAILABLE', `You may need to run ${_chalk().default.bold('sudo xcode-select -s /Applications/Xcode.app')} and try again.`);
57
57
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/ios/xcrun.ts"],"sourcesContent":["import spawnAsync, { SpawnOptions, SpawnResult } from '@expo/spawn-async';\nimport chalk from 'chalk';\n\nimport { CommandError } from '../../../utils/errors';\n\nconst debug = require('debug')('expo:start:platforms:ios:xcrun') as typeof console.log;\n\nexport function isSpawnResultError(obj: any): obj is Error & SpawnResult {\n return (\n obj &&\n 'message' in obj &&\n obj.status !== undefined &&\n obj.stdout !== undefined &&\n obj.stderr !== undefined\n );\n}\n\nexport async function xcrunAsync(args: (string | undefined)[], options?: SpawnOptions) {\n debug('Running: xcrun ' + args.join(' '));\n try {\n return await spawnAsync('xcrun', args.filter(Boolean) as string[], options);\n } catch (e) {\n throwXcrunError(e);\n }\n}\n\nfunction throwXcrunError(e: any): never {\n if (isLicenseOutOfDate(e.stdout) || isLicenseOutOfDate(e.stderr)) {\n throw new CommandError(\n 'XCODE_LICENSE_NOT_ACCEPTED',\n 'Xcode license is not accepted. Please run `sudo xcodebuild -license`.'\n );\n } else if (e.stderr?.includes('not a developer tool or in PATH')) {\n throw new CommandError(\n 'SIMCTL_NOT_AVAILABLE',\n `You may need to run ${chalk.bold(\n 'sudo xcode-select -s /Applications/Xcode.app'\n )} and try again.`\n );\n }\n // Attempt to craft a better error message...\n if (Array.isArray(e.output)) {\n e.message += '\\n' + e.output.join('\\n').trim();\n } else if (e.stderr) {\n e.message += '\\n' + e.stderr;\n }\n throw e;\n}\n\nfunction isLicenseOutOfDate(text: string) {\n if (!text) {\n return false;\n }\n\n const lower = text.toLowerCase();\n return lower.includes('xcode') && lower.includes('license');\n}\n"],"names":["isSpawnResultError","xcrunAsync","debug","require","obj","status","undefined","stdout","stderr","args","options","join","spawnAsync","filter","Boolean","e","throwXcrunError","isLicenseOutOfDate","CommandError","includes","chalk","bold","Array","isArray","output","message","trim","text","lower","toLowerCase"],"mappings":";;;;;;;;;;;IAOgBA,kBAAkB;eAAlBA;;IAUMC,UAAU;eAAVA;;;;gEAjBgC;;;;;;;gEACpC;;;;;;wBAEW;;;;;;AAE7B,MAAMC,QAAQC,QAAQ,SAAS;AAExB,SAASH,mBAAmBI,GAAQ;IACzC,OACEA,OACA,aAAaA,OACbA,IAAIC,MAAM,KAAKC,aACfF,IAAIG,MAAM,KAAKD,aACfF,IAAII,MAAM,KAAKF;AAEnB;AAEO,eAAeL,WAAWQ,IAA4B,EAAEC,OAAsB;IACnFR,MAAM,oBAAoBO,KAAKE,IAAI,CAAC;IACpC,IAAI;QACF,OAAO,MAAMC,IAAAA,qBAAU,EAAC,SAASH,KAAKI,MAAM,CAACC,UAAsBJ;IACrE,EAAE,OAAOK,GAAG;QACVC,gBAAgBD;IAClB;AACF;AAEA,SAASC,gBAAgBD,CAAM;QAMlBA;IALX,IAAIE,mBAAmBF,EAAER,MAAM,KAAKU,mBAAmBF,EAAEP,MAAM,GAAG;QAChE,MAAM,IAAIU,oBAAY,CACpB,8BACA;IAEJ,OAAO,KAAIH,YAAAA,EAAEP,MAAM,qBAARO,UAAUI,QAAQ,CAAC,oCAAoC;QAChE,MAAM,IAAID,oBAAY,CACpB,wBACA,CAAC,oBAAoB,EAAEE,gBAAK,CAACC,IAAI,CAC/B,gDACA,eAAe,CAAC;IAEtB;IACA,6CAA6C;IAC7C,IAAIC,MAAMC,OAAO,CAACR,EAAES,MAAM,GAAG;QAC3BT,EAAEU,OAAO,IAAI,OAAOV,EAAES,MAAM,CAACb,IAAI,CAAC,MAAMe,IAAI;IAC9C,OAAO,IAAIX,EAAEP,MAAM,EAAE;QACnBO,EAAEU,OAAO,IAAI,OAAOV,EAAEP,MAAM;IAC9B;IACA,MAAMO;AACR;AAEA,SAASE,mBAAmBU,IAAY;IACtC,IAAI,CAACA,MAAM;QACT,OAAO;IACT;IAEA,MAAMC,QAAQD,KAAKE,WAAW;IAC9B,OAAOD,MAAMT,QAAQ,CAAC,YAAYS,MAAMT,QAAQ,CAAC;AACnD"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/ios/xcrun.ts"],"sourcesContent":["import spawnAsync, { SpawnOptions, SpawnResult } from '@expo/spawn-async';\nimport chalk from 'chalk';\n\nimport { CommandError } from '../../../utils/errors';\n\nconst debug = require('debug')('expo:start:platforms:ios:xcrun') as typeof console.log;\n\nexport function isSpawnResultError(obj: any): obj is Error & SpawnResult {\n return (\n obj &&\n 'message' in obj &&\n obj.status !== undefined &&\n obj.stdout !== undefined &&\n obj.stderr !== undefined\n );\n}\n\nexport async function xcrunAsync(args: (string | undefined)[], options?: SpawnOptions) {\n debug('Running: xcrun ' + args.join(' '));\n try {\n return await spawnAsync('xcrun', args.filter(Boolean) as string[], options);\n } catch (e) {\n throwXcrunError(e);\n }\n}\n\nfunction throwXcrunError(e: any): never {\n if (isLicenseOutOfDate(e.stdout) || isLicenseOutOfDate(e.stderr)) {\n throw new CommandError(\n 'XCODE_LICENSE_NOT_ACCEPTED',\n 'Xcode license is not accepted. Run `sudo xcodebuild -license`.'\n );\n } else if (e.stderr?.includes('not a developer tool or in PATH')) {\n throw new CommandError(\n 'SIMCTL_NOT_AVAILABLE',\n `You may need to run ${chalk.bold(\n 'sudo xcode-select -s /Applications/Xcode.app'\n )} and try again.`\n );\n }\n // Attempt to craft a better error message...\n if (Array.isArray(e.output)) {\n e.message += '\\n' + e.output.join('\\n').trim();\n } else if (e.stderr) {\n e.message += '\\n' + e.stderr;\n }\n throw e;\n}\n\nfunction isLicenseOutOfDate(text: string) {\n if (!text) {\n return false;\n }\n\n const lower = text.toLowerCase();\n return lower.includes('xcode') && lower.includes('license');\n}\n"],"names":["isSpawnResultError","xcrunAsync","debug","require","obj","status","undefined","stdout","stderr","args","options","join","spawnAsync","filter","Boolean","e","throwXcrunError","isLicenseOutOfDate","CommandError","includes","chalk","bold","Array","isArray","output","message","trim","text","lower","toLowerCase"],"mappings":";;;;;;;;;;;IAOgBA,kBAAkB;eAAlBA;;IAUMC,UAAU;eAAVA;;;;gEAjBgC;;;;;;;gEACpC;;;;;;wBAEW;;;;;;AAE7B,MAAMC,QAAQC,QAAQ,SAAS;AAExB,SAASH,mBAAmBI,GAAQ;IACzC,OACEA,OACA,aAAaA,OACbA,IAAIC,MAAM,KAAKC,aACfF,IAAIG,MAAM,KAAKD,aACfF,IAAII,MAAM,KAAKF;AAEnB;AAEO,eAAeL,WAAWQ,IAA4B,EAAEC,OAAsB;IACnFR,MAAM,oBAAoBO,KAAKE,IAAI,CAAC;IACpC,IAAI;QACF,OAAO,MAAMC,IAAAA,qBAAU,EAAC,SAASH,KAAKI,MAAM,CAACC,UAAsBJ;IACrE,EAAE,OAAOK,GAAG;QACVC,gBAAgBD;IAClB;AACF;AAEA,SAASC,gBAAgBD,CAAM;QAMlBA;IALX,IAAIE,mBAAmBF,EAAER,MAAM,KAAKU,mBAAmBF,EAAEP,MAAM,GAAG;QAChE,MAAM,IAAIU,oBAAY,CACpB,8BACA;IAEJ,OAAO,KAAIH,YAAAA,EAAEP,MAAM,qBAARO,UAAUI,QAAQ,CAAC,oCAAoC;QAChE,MAAM,IAAID,oBAAY,CACpB,wBACA,CAAC,oBAAoB,EAAEE,gBAAK,CAACC,IAAI,CAC/B,gDACA,eAAe,CAAC;IAEtB;IACA,6CAA6C;IAC7C,IAAIC,MAAMC,OAAO,CAACR,EAAES,MAAM,GAAG;QAC3BT,EAAEU,OAAO,IAAI,OAAOV,EAAES,MAAM,CAACb,IAAI,CAAC,MAAMe,IAAI;IAC9C,OAAO,IAAIX,EAAEP,MAAM,EAAE;QACnBO,EAAEU,OAAO,IAAI,OAAOV,EAAEP,MAAM;IAC9B;IACA,MAAMO;AACR;AAEA,SAASE,mBAAmBU,IAAY;IACtC,IAAI,CAACA,MAAM;QACT,OAAO;IACT;IAEA,MAAMC,QAAQD,KAAKE,WAAW;IAC9B,OAAOD,MAAMT,QAAQ,CAAC,YAAYS,MAAMT,QAAQ,CAAC;AACnD"}
@@ -188,7 +188,7 @@ class MetroTerminalReporter extends _TerminalReporter.TerminalReporter {
188
188
  // Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290
189
189
  this.terminal.log(_chalk().default.red([
190
190
  'Metro is operating with reduced performance.',
191
- 'Please fix the problem above and restart Metro.'
191
+ 'Fix the problem above and restart Metro.'
192
192
  ].join('\n')));
193
193
  }
194
194
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/MetroTerminalReporter.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Terminal } from 'metro-core';\nimport path from 'path';\n\nimport { logWarning, TerminalReporter } from './TerminalReporter';\nimport {\n BuildPhase,\n BundleDetails,\n BundleProgress,\n SnippetError,\n TerminalReportableEvent,\n} from './TerminalReporter.types';\nimport { NODE_STDLIB_MODULES } from './externals';\nimport { env } from '../../../utils/env';\nimport { learnMore } from '../../../utils/link';\nimport {\n logLikeMetro,\n maybeSymbolicateAndFormatReactErrorLogAsync,\n parseErrorStringToObject,\n} from '../serverLogLikeMetro';\n\nconst debug = require('debug')('expo:metro:logger') as typeof console.log;\n\nconst MAX_PROGRESS_BAR_CHAR_WIDTH = 16;\nconst DARK_BLOCK_CHAR = '\\u2593';\nconst LIGHT_BLOCK_CHAR = '\\u2591';\n/**\n * Extends the default Metro logger and adds some additional features.\n * Also removes the giant Metro logo from the output.\n */\nexport class MetroTerminalReporter extends TerminalReporter {\n constructor(\n public projectRoot: string,\n terminal: Terminal\n ) {\n super(terminal);\n }\n\n _log(event: TerminalReportableEvent): void {\n switch (event.type) {\n case 'unstable_server_log':\n if (typeof event.data?.[0] === 'string') {\n const message = event.data[0];\n if (message.match(/JavaScript logs have moved/)) {\n // Hide this very loud message from upstream React Native in favor of the note in the terminal UI:\n // The \"› Press j │ open debugger\"\n\n // logger?.info(\n // '\\u001B[1m\\u001B[7m💡 JavaScript logs have moved!\\u001B[22m They can now be ' +\n // 'viewed in React Native DevTools. Tip: Type \\u001B[1mj\\u001B[22m in ' +\n // 'the terminal to open (requires Google Chrome or Microsoft Edge).' +\n // '\\u001B[27m',\n // );\n return;\n }\n\n if (!env.EXPO_DEBUG) {\n // In the context of developing an iOS app or website, the MetroInspectorProxy \"connection\" logs are very confusing.\n // Here we'll hide them behind EXPO_DEBUG or DEBUG=expo:*. In the future we can reformat them to clearly indicate that the \"Connection\" is regarding the debugger.\n // These logs are also confusing because they can say \"connection established\" even when the debugger is not in a usable state. Really they belong in a UI or behind some sort of debug logging.\n if (message.match(/Connection (closed|established|failed|terminated)/i)) {\n // Skip logging.\n return;\n }\n }\n }\n break;\n case 'client_log': {\n if (this.shouldFilterClientLog(event)) {\n return;\n }\n const { level } = event;\n\n if (!level) {\n break;\n }\n\n const mode = event.mode === 'NOBRIDGE' || event.mode === 'BRIDGE' ? '' : (event.mode ?? '');\n // @ts-expect-error\n if (level === 'warn' || level === 'error') {\n // Quick check to see if an unsymbolicated stack is being logged.\n const msg = event.data.join('\\n');\n if (msg.includes('.bundle//&platform=')) {\n const parsed = parseErrorStringToObject(msg);\n\n if (parsed) {\n maybeSymbolicateAndFormatReactErrorLogAsync(this.projectRoot, level, parsed)\n .then((res) => {\n // Overwrite the Metro terminal logging so we can improve the warnings, symbolicate stacks, and inject extra info.\n logLikeMetro(this.terminal.log.bind(this.terminal), level, mode, res);\n })\n .catch((e) => {\n // Fallback on the original error message if we can't symbolicate the stack.\n debug('Error formatting stack', e);\n\n // Overwrite the Metro terminal logging so we can improve the warnings, symbolicate stacks, and inject extra info.\n logLikeMetro(this.terminal.log.bind(this.terminal), level, mode, ...event.data);\n });\n\n return;\n }\n }\n }\n\n // Overwrite the Metro terminal logging so we can improve the warnings, symbolicate stacks, and inject extra info.\n logLikeMetro(this.terminal.log.bind(this.terminal), level, mode, ...event.data);\n return;\n }\n }\n return super._log(event);\n }\n\n // Used for testing\n _getElapsedTime(startTime: bigint): bigint {\n return process.hrtime.bigint() - startTime;\n }\n /**\n * Extends the bundle progress to include the current platform that we're bundling.\n *\n * @returns `iOS path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)`\n */\n _getBundleStatusMessage(progress: BundleProgress, phase: BuildPhase): string {\n const env = getEnvironmentForBuildDetails(progress.bundleDetails);\n const platform = env || getPlatformTagForBuildDetails(progress.bundleDetails);\n const inProgress = phase === 'in_progress';\n\n let localPath: string;\n\n if (\n typeof progress.bundleDetails?.customTransformOptions?.dom === 'string' &&\n progress.bundleDetails.customTransformOptions.dom.includes(path.sep)\n ) {\n // Because we use a generated entry file for DOM components, we need to adjust the logging path so it\n // shows a unique path for each component.\n // Here, we take the relative import path and remove all the starting slashes.\n localPath = progress.bundleDetails.customTransformOptions.dom.replace(/^(\\.?\\.[\\\\/])+/, '');\n } else {\n const inputFile = progress.bundleDetails.entryFile;\n\n localPath = path.isAbsolute(inputFile)\n ? path.relative(this.projectRoot, inputFile)\n : inputFile;\n }\n\n if (!inProgress) {\n const status = phase === 'done' ? `Bundled ` : `Bundling failed `;\n const color = phase === 'done' ? chalk.green : chalk.red;\n\n const startTime = this._bundleTimers.get(progress.bundleDetails.buildID!);\n\n let time: string = '';\n\n if (startTime != null) {\n const elapsed: bigint = this._getElapsedTime(startTime);\n const micro = Number(elapsed) / 1000;\n const converted = Number(elapsed) / 1e6;\n // If the milliseconds are < 0.5 then it will display as 0, so we display in microseconds.\n if (converted <= 0.5) {\n const tenthFractionOfMicro = ((micro * 10) / 1000).toFixed(0);\n // Format as microseconds to nearest tenth\n time = chalk.cyan.bold(`0.${tenthFractionOfMicro}ms`);\n } else {\n time = chalk.dim(converted.toFixed(0) + 'ms');\n }\n }\n\n // iOS Bundled 150ms\n const plural = progress.totalFileCount === 1 ? '' : 's';\n return (\n color(platform + status) +\n time +\n chalk.reset.dim(` ${localPath} (${progress.totalFileCount} module${plural})`)\n );\n }\n\n const filledBar = Math.floor(progress.ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);\n\n const _progress = inProgress\n ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +\n chalk.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) +\n chalk.bold(` ${(100 * progress.ratio).toFixed(1).padStart(4)}% `) +\n chalk.dim(\n `(${progress.transformedFileCount\n .toString()\n .padStart(progress.totalFileCount.toString().length)}/${progress.totalFileCount})`\n )\n : '';\n\n return (\n platform +\n chalk.reset.dim(`${path.dirname(localPath)}${path.sep}`) +\n chalk.bold(path.basename(localPath)) +\n ' ' +\n _progress\n );\n }\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void {\n // Don't print a giant logo...\n this.terminal.log(chalk.dim('Starting Metro Bundler'));\n }\n\n shouldFilterClientLog(event: { type: 'client_log'; data: unknown[] }): boolean {\n return isAppRegistryStartupMessage(event.data);\n }\n\n shouldFilterBundleEvent(event: TerminalReportableEvent): boolean {\n return 'bundleDetails' in event && event.bundleDetails?.bundleType === 'map';\n }\n\n /** Print the cache clear message. */\n transformCacheReset(): void {\n logWarning(\n this.terminal,\n chalk`Bundler cache is empty, rebuilding {dim (this may take a minute)}`\n );\n }\n\n /** One of the first logs that will be printed */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {\n // this.terminal.log('Dependency graph is loading...');\n if (hasReducedPerformance) {\n // Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290\n this.terminal.log(\n chalk.red(\n [\n 'Metro is operating with reduced performance.',\n 'Please fix the problem above and restart Metro.',\n ].join('\\n')\n )\n );\n }\n }\n\n _logBundlingError(error: SnippetError): void {\n const moduleResolutionError = formatUsingNodeStandardLibraryError(this.projectRoot, error);\n const cause = error.cause as undefined | { _expoImportStack?: string };\n if (moduleResolutionError) {\n let message = maybeAppendCodeFrame(moduleResolutionError, error.message);\n if (cause?._expoImportStack) {\n message += `\\n\\n${cause?._expoImportStack}`;\n }\n return this.terminal.log(message);\n }\n if (cause?._expoImportStack) {\n error.message += `\\n\\n${cause._expoImportStack}`;\n }\n return super._logBundlingError(error);\n }\n}\n\n/**\n * Formats an error where the user is attempting to import a module from the Node.js standard library.\n * Exposed for testing.\n *\n * @param error\n * @returns error message or null if not a module resolution error\n */\nexport function formatUsingNodeStandardLibraryError(\n projectRoot: string,\n error: SnippetError\n): string | null {\n if (!error.message) {\n return null;\n }\n const { targetModuleName, originModulePath } = error;\n if (!targetModuleName || !originModulePath) {\n return null;\n }\n const relativePath = path.relative(projectRoot, originModulePath);\n\n const DOCS_PAGE_URL =\n 'https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries';\n\n if (isNodeStdLibraryModule(targetModuleName)) {\n if (originModulePath.includes('node_modules')) {\n return [\n `The package at \"${chalk.bold(\n relativePath\n )}\" attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n } else {\n return [\n `You attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\" from \"${chalk.bold(relativePath)}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n }\n }\n return `Unable to resolve \"${targetModuleName}\" from \"${relativePath}\"`;\n}\n\nexport function isNodeStdLibraryModule(moduleName: string): boolean {\n return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);\n}\n\n/** If the code frame can be found then append it to the existing message. */\nfunction maybeAppendCodeFrame(message: string, rawMessage: string): string {\n const codeFrame = stripMetroInfo(rawMessage);\n if (codeFrame) {\n message += '\\n' + codeFrame;\n }\n return message;\n}\n\n/**\n * Remove the Metro cache clearing steps if they exist.\n * In future versions we won't need this.\n * Returns the remaining code frame logs.\n */\nexport function stripMetroInfo(errorMessage: string): string | null {\n // Newer versions of Metro don't include the list.\n if (!errorMessage.includes('4. Remove the cache')) {\n return null;\n }\n const lines = errorMessage.split('\\n');\n const index = lines.findIndex((line) => line.includes('4. Remove the cache'));\n if (index === -1) {\n return null;\n }\n return lines.slice(index + 1).join('\\n');\n}\n\n/** @returns if the message matches the initial startup log */\nfunction isAppRegistryStartupMessage(body: any[]): boolean {\n return (\n body.length === 1 &&\n (/^Running application \"main\" with appParams:/.test(body[0]) ||\n /^Running \"main\" with \\{/.test(body[0]))\n );\n}\n\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getPlatformTagForBuildDetails(bundleDetails?: BundleDetails | null): string {\n const platform = bundleDetails?.platform ?? null;\n if (platform) {\n const formatted = { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform;\n return `${chalk.bold(formatted)} `;\n }\n\n return '';\n}\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getEnvironmentForBuildDetails(bundleDetails?: BundleDetails | null): string {\n // Expo CLI will pass `customTransformOptions.environment = 'node'` when bundling for the server.\n const env = bundleDetails?.customTransformOptions?.environment ?? null;\n if (env === 'node') {\n return chalk.bold('λ') + ' ';\n } else if (env === 'react-server') {\n return chalk.bold(`RSC(${getPlatformTagForBuildDetails(bundleDetails).trim()})`) + ' ';\n }\n\n if (\n bundleDetails?.customTransformOptions?.dom &&\n typeof bundleDetails?.customTransformOptions?.dom === 'string'\n ) {\n return chalk.bold(`DOM`) + ' ';\n }\n\n return '';\n}\n"],"names":["MetroTerminalReporter","formatUsingNodeStandardLibraryError","isNodeStdLibraryModule","stripMetroInfo","debug","require","MAX_PROGRESS_BAR_CHAR_WIDTH","DARK_BLOCK_CHAR","LIGHT_BLOCK_CHAR","TerminalReporter","constructor","projectRoot","terminal","_log","event","type","data","message","match","env","EXPO_DEBUG","shouldFilterClientLog","level","mode","msg","join","includes","parsed","parseErrorStringToObject","maybeSymbolicateAndFormatReactErrorLogAsync","then","res","logLikeMetro","log","bind","catch","e","_getElapsedTime","startTime","process","hrtime","bigint","_getBundleStatusMessage","progress","phase","getEnvironmentForBuildDetails","bundleDetails","platform","getPlatformTagForBuildDetails","inProgress","localPath","customTransformOptions","dom","path","sep","replace","inputFile","entryFile","isAbsolute","relative","status","color","chalk","green","red","_bundleTimers","get","buildID","time","elapsed","micro","Number","converted","tenthFractionOfMicro","toFixed","cyan","bold","dim","plural","totalFileCount","reset","filledBar","Math","floor","ratio","_progress","bgGreen","repeat","bgWhite","white","padStart","transformedFileCount","toString","length","dirname","basename","_logInitializing","port","hasReducedPerformance","isAppRegistryStartupMessage","shouldFilterBundleEvent","bundleType","transformCacheReset","logWarning","dependencyGraphLoading","_logBundlingError","error","moduleResolutionError","cause","maybeAppendCodeFrame","_expoImportStack","targetModuleName","originModulePath","relativePath","DOCS_PAGE_URL","learnMore","moduleName","test","NODE_STDLIB_MODULES","rawMessage","codeFrame","errorMessage","lines","split","index","findIndex","line","slice","body","formatted","ios","android","web","environment","trim"],"mappings":";;;;;;;;;;;IA8BaA,qBAAqB;eAArBA;;IAoOGC,mCAAmC;eAAnCA;;IAwCAC,sBAAsB;eAAtBA;;IAkBAC,cAAc;eAAdA;;;;gEA5TE;;;;;;;gEAED;;;;;;kCAE4B;2BAQT;qBAChB;sBACM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ACEA,KAAKnC,MAAM,KAAK,KACf,CAAA,8CAA8CwB,IAAI,CAACW,IAAI,CAAC,EAAE,KACzD,0BAA0BX,IAAI,CAACW,IAAI,CAAC,EAAE,CAAA;AAE5C;AAEA,gEAAgE,GAChE,SAAShF,8BAA8BF,aAAoC;IACzE,MAAMC,WAAWD,CAAAA,iCAAAA,cAAeC,QAAQ,KAAI;IAC5C,IAAIA,UAAU;QACZ,MAAMkF,YAAY;YAAEC,KAAK;YAAOC,SAAS;YAAWC,KAAK;QAAM,CAAC,CAACrF,SAAS,IAAIA;QAC9E,OAAO,GAAGe,gBAAK,CAACc,IAAI,CAACqD,WAAW,CAAC,CAAC;IACpC;IAEA,OAAO;AACT;AACA,gEAAgE,GAChE,SAASpF,8BAA8BC,aAAoC;QAE7DA,uCAQVA,wCACOA;IAVT,iGAAiG;IACjG,MAAM3B,MAAM2B,CAAAA,kCAAAA,wCAAAA,cAAeK,sBAAsB,qBAArCL,sCAAuCuF,WAAW,KAAI;IAClE,IAAIlH,QAAQ,QAAQ;QAClB,OAAO2C,gBAAK,CAACc,IAAI,CAAC,OAAO;IAC3B,OAAO,IAAIzD,QAAQ,gBAAgB;QACjC,OAAO2C,gBAAK,CAACc,IAAI,CAAC,CAAC,IAAI,EAAE5B,8BAA8BF,eAAewF,IAAI,GAAG,CAAC,CAAC,IAAI;IACrF;IAEA,IACExF,CAAAA,kCAAAA,yCAAAA,cAAeK,sBAAsB,qBAArCL,uCAAuCM,GAAG,KAC1C,QAAON,kCAAAA,yCAAAA,cAAeK,sBAAsB,qBAArCL,uCAAuCM,GAAG,MAAK,UACtD;QACA,OAAOU,gBAAK,CAACc,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI;IAC7B;IAEA,OAAO;AACT"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/MetroTerminalReporter.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Terminal } from 'metro-core';\nimport path from 'path';\n\nimport { logWarning, TerminalReporter } from './TerminalReporter';\nimport {\n BuildPhase,\n BundleDetails,\n BundleProgress,\n SnippetError,\n TerminalReportableEvent,\n} from './TerminalReporter.types';\nimport { NODE_STDLIB_MODULES } from './externals';\nimport { env } from '../../../utils/env';\nimport { learnMore } from '../../../utils/link';\nimport {\n logLikeMetro,\n maybeSymbolicateAndFormatReactErrorLogAsync,\n parseErrorStringToObject,\n} from '../serverLogLikeMetro';\n\nconst debug = require('debug')('expo:metro:logger') as typeof console.log;\n\nconst MAX_PROGRESS_BAR_CHAR_WIDTH = 16;\nconst DARK_BLOCK_CHAR = '\\u2593';\nconst LIGHT_BLOCK_CHAR = '\\u2591';\n/**\n * Extends the default Metro logger and adds some additional features.\n * Also removes the giant Metro logo from the output.\n */\nexport class MetroTerminalReporter extends TerminalReporter {\n constructor(\n public projectRoot: string,\n terminal: Terminal\n ) {\n super(terminal);\n }\n\n _log(event: TerminalReportableEvent): void {\n switch (event.type) {\n case 'unstable_server_log':\n if (typeof event.data?.[0] === 'string') {\n const message = event.data[0];\n if (message.match(/JavaScript logs have moved/)) {\n // Hide this very loud message from upstream React Native in favor of the note in the terminal UI:\n // The \"› Press j │ open debugger\"\n\n // logger?.info(\n // '\\u001B[1m\\u001B[7m💡 JavaScript logs have moved!\\u001B[22m They can now be ' +\n // 'viewed in React Native DevTools. Tip: Type \\u001B[1mj\\u001B[22m in ' +\n // 'the terminal to open (requires Google Chrome or Microsoft Edge).' +\n // '\\u001B[27m',\n // );\n return;\n }\n\n if (!env.EXPO_DEBUG) {\n // In the context of developing an iOS app or website, the MetroInspectorProxy \"connection\" logs are very confusing.\n // Here we'll hide them behind EXPO_DEBUG or DEBUG=expo:*. In the future we can reformat them to clearly indicate that the \"Connection\" is regarding the debugger.\n // These logs are also confusing because they can say \"connection established\" even when the debugger is not in a usable state. Really they belong in a UI or behind some sort of debug logging.\n if (message.match(/Connection (closed|established|failed|terminated)/i)) {\n // Skip logging.\n return;\n }\n }\n }\n break;\n case 'client_log': {\n if (this.shouldFilterClientLog(event)) {\n return;\n }\n const { level } = event;\n\n if (!level) {\n break;\n }\n\n const mode = event.mode === 'NOBRIDGE' || event.mode === 'BRIDGE' ? '' : (event.mode ?? '');\n // @ts-expect-error\n if (level === 'warn' || level === 'error') {\n // Quick check to see if an unsymbolicated stack is being logged.\n const msg = event.data.join('\\n');\n if (msg.includes('.bundle//&platform=')) {\n const parsed = parseErrorStringToObject(msg);\n\n if (parsed) {\n maybeSymbolicateAndFormatReactErrorLogAsync(this.projectRoot, level, parsed)\n .then((res) => {\n // Overwrite the Metro terminal logging so we can improve the warnings, symbolicate stacks, and inject extra info.\n logLikeMetro(this.terminal.log.bind(this.terminal), level, mode, res);\n })\n .catch((e) => {\n // Fallback on the original error message if we can't symbolicate the stack.\n debug('Error formatting stack', e);\n\n // Overwrite the Metro terminal logging so we can improve the warnings, symbolicate stacks, and inject extra info.\n logLikeMetro(this.terminal.log.bind(this.terminal), level, mode, ...event.data);\n });\n\n return;\n }\n }\n }\n\n // Overwrite the Metro terminal logging so we can improve the warnings, symbolicate stacks, and inject extra info.\n logLikeMetro(this.terminal.log.bind(this.terminal), level, mode, ...event.data);\n return;\n }\n }\n return super._log(event);\n }\n\n // Used for testing\n _getElapsedTime(startTime: bigint): bigint {\n return process.hrtime.bigint() - startTime;\n }\n /**\n * Extends the bundle progress to include the current platform that we're bundling.\n *\n * @returns `iOS path/to/bundle.js ▓▓▓▓▓░░░░░░░░░░░ 36.6% (4790/7922)`\n */\n _getBundleStatusMessage(progress: BundleProgress, phase: BuildPhase): string {\n const env = getEnvironmentForBuildDetails(progress.bundleDetails);\n const platform = env || getPlatformTagForBuildDetails(progress.bundleDetails);\n const inProgress = phase === 'in_progress';\n\n let localPath: string;\n\n if (\n typeof progress.bundleDetails?.customTransformOptions?.dom === 'string' &&\n progress.bundleDetails.customTransformOptions.dom.includes(path.sep)\n ) {\n // Because we use a generated entry file for DOM components, we need to adjust the logging path so it\n // shows a unique path for each component.\n // Here, we take the relative import path and remove all the starting slashes.\n localPath = progress.bundleDetails.customTransformOptions.dom.replace(/^(\\.?\\.[\\\\/])+/, '');\n } else {\n const inputFile = progress.bundleDetails.entryFile;\n\n localPath = path.isAbsolute(inputFile)\n ? path.relative(this.projectRoot, inputFile)\n : inputFile;\n }\n\n if (!inProgress) {\n const status = phase === 'done' ? `Bundled ` : `Bundling failed `;\n const color = phase === 'done' ? chalk.green : chalk.red;\n\n const startTime = this._bundleTimers.get(progress.bundleDetails.buildID!);\n\n let time: string = '';\n\n if (startTime != null) {\n const elapsed: bigint = this._getElapsedTime(startTime);\n const micro = Number(elapsed) / 1000;\n const converted = Number(elapsed) / 1e6;\n // If the milliseconds are < 0.5 then it will display as 0, so we display in microseconds.\n if (converted <= 0.5) {\n const tenthFractionOfMicro = ((micro * 10) / 1000).toFixed(0);\n // Format as microseconds to nearest tenth\n time = chalk.cyan.bold(`0.${tenthFractionOfMicro}ms`);\n } else {\n time = chalk.dim(converted.toFixed(0) + 'ms');\n }\n }\n\n // iOS Bundled 150ms\n const plural = progress.totalFileCount === 1 ? '' : 's';\n return (\n color(platform + status) +\n time +\n chalk.reset.dim(` ${localPath} (${progress.totalFileCount} module${plural})`)\n );\n }\n\n const filledBar = Math.floor(progress.ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);\n\n const _progress = inProgress\n ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +\n chalk.bgWhite.white(LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar)) +\n chalk.bold(` ${(100 * progress.ratio).toFixed(1).padStart(4)}% `) +\n chalk.dim(\n `(${progress.transformedFileCount\n .toString()\n .padStart(progress.totalFileCount.toString().length)}/${progress.totalFileCount})`\n )\n : '';\n\n return (\n platform +\n chalk.reset.dim(`${path.dirname(localPath)}${path.sep}`) +\n chalk.bold(path.basename(localPath)) +\n ' ' +\n _progress\n );\n }\n\n _logInitializing(port: number, hasReducedPerformance: boolean): void {\n // Don't print a giant logo...\n this.terminal.log(chalk.dim('Starting Metro Bundler'));\n }\n\n shouldFilterClientLog(event: { type: 'client_log'; data: unknown[] }): boolean {\n return isAppRegistryStartupMessage(event.data);\n }\n\n shouldFilterBundleEvent(event: TerminalReportableEvent): boolean {\n return 'bundleDetails' in event && event.bundleDetails?.bundleType === 'map';\n }\n\n /** Print the cache clear message. */\n transformCacheReset(): void {\n logWarning(\n this.terminal,\n chalk`Bundler cache is empty, rebuilding {dim (this may take a minute)}`\n );\n }\n\n /** One of the first logs that will be printed */\n dependencyGraphLoading(hasReducedPerformance: boolean): void {\n // this.terminal.log('Dependency graph is loading...');\n if (hasReducedPerformance) {\n // Extends https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/lib/TerminalReporter.js#L283-L290\n this.terminal.log(\n chalk.red(\n [\n 'Metro is operating with reduced performance.',\n 'Fix the problem above and restart Metro.',\n ].join('\\n')\n )\n );\n }\n }\n\n _logBundlingError(error: SnippetError): void {\n const moduleResolutionError = formatUsingNodeStandardLibraryError(this.projectRoot, error);\n const cause = error.cause as undefined | { _expoImportStack?: string };\n if (moduleResolutionError) {\n let message = maybeAppendCodeFrame(moduleResolutionError, error.message);\n if (cause?._expoImportStack) {\n message += `\\n\\n${cause?._expoImportStack}`;\n }\n return this.terminal.log(message);\n }\n if (cause?._expoImportStack) {\n error.message += `\\n\\n${cause._expoImportStack}`;\n }\n return super._logBundlingError(error);\n }\n}\n\n/**\n * Formats an error where the user is attempting to import a module from the Node.js standard library.\n * Exposed for testing.\n *\n * @param error\n * @returns error message or null if not a module resolution error\n */\nexport function formatUsingNodeStandardLibraryError(\n projectRoot: string,\n error: SnippetError\n): string | null {\n if (!error.message) {\n return null;\n }\n const { targetModuleName, originModulePath } = error;\n if (!targetModuleName || !originModulePath) {\n return null;\n }\n const relativePath = path.relative(projectRoot, originModulePath);\n\n const DOCS_PAGE_URL =\n 'https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries';\n\n if (isNodeStdLibraryModule(targetModuleName)) {\n if (originModulePath.includes('node_modules')) {\n return [\n `The package at \"${chalk.bold(\n relativePath\n )}\" attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n } else {\n return [\n `You attempted to import the Node standard library module \"${chalk.bold(\n targetModuleName\n )}\" from \"${chalk.bold(relativePath)}\".`,\n `It failed because the native React runtime does not include the Node standard library.`,\n learnMore(DOCS_PAGE_URL),\n ].join('\\n');\n }\n }\n return `Unable to resolve \"${targetModuleName}\" from \"${relativePath}\"`;\n}\n\nexport function isNodeStdLibraryModule(moduleName: string): boolean {\n return /^node:/.test(moduleName) || NODE_STDLIB_MODULES.includes(moduleName);\n}\n\n/** If the code frame can be found then append it to the existing message. */\nfunction maybeAppendCodeFrame(message: string, rawMessage: string): string {\n const codeFrame = stripMetroInfo(rawMessage);\n if (codeFrame) {\n message += '\\n' + codeFrame;\n }\n return message;\n}\n\n/**\n * Remove the Metro cache clearing steps if they exist.\n * In future versions we won't need this.\n * Returns the remaining code frame logs.\n */\nexport function stripMetroInfo(errorMessage: string): string | null {\n // Newer versions of Metro don't include the list.\n if (!errorMessage.includes('4. Remove the cache')) {\n return null;\n }\n const lines = errorMessage.split('\\n');\n const index = lines.findIndex((line) => line.includes('4. Remove the cache'));\n if (index === -1) {\n return null;\n }\n return lines.slice(index + 1).join('\\n');\n}\n\n/** @returns if the message matches the initial startup log */\nfunction isAppRegistryStartupMessage(body: any[]): boolean {\n return (\n body.length === 1 &&\n (/^Running application \"main\" with appParams:/.test(body[0]) ||\n /^Running \"main\" with \\{/.test(body[0]))\n );\n}\n\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getPlatformTagForBuildDetails(bundleDetails?: BundleDetails | null): string {\n const platform = bundleDetails?.platform ?? null;\n if (platform) {\n const formatted = { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform;\n return `${chalk.bold(formatted)} `;\n }\n\n return '';\n}\n/** @returns platform specific tag for a `BundleDetails` object */\nfunction getEnvironmentForBuildDetails(bundleDetails?: BundleDetails | null): string {\n // Expo CLI will pass `customTransformOptions.environment = 'node'` when bundling for the server.\n const env = bundleDetails?.customTransformOptions?.environment ?? null;\n if (env === 'node') {\n return chalk.bold('λ') + ' ';\n } else if (env === 'react-server') {\n return chalk.bold(`RSC(${getPlatformTagForBuildDetails(bundleDetails).trim()})`) + ' ';\n }\n\n if (\n bundleDetails?.customTransformOptions?.dom &&\n typeof bundleDetails?.customTransformOptions?.dom === 'string'\n ) {\n return chalk.bold(`DOM`) + ' ';\n }\n\n return '';\n}\n"],"names":["MetroTerminalReporter","formatUsingNodeStandardLibraryError","isNodeStdLibraryModule","stripMetroInfo","debug","require","MAX_PROGRESS_BAR_CHAR_WIDTH","DARK_BLOCK_CHAR","LIGHT_BLOCK_CHAR","TerminalReporter","constructor","projectRoot","terminal","_log","event","type","data","message","match","env","EXPO_DEBUG","shouldFilterClientLog","level","mode","msg","join","includes","parsed","parseErrorStringToObject","maybeSymbolicateAndFormatReactErrorLogAsync","then","res","logLikeMetro","log","bind","catch","e","_getElapsedTime","startTime","process","hrtime","bigint","_getBundleStatusMessage","progress","phase","getEnvironmentForBuildDetails","bundleDetails","platform","getPlatformTagForBuildDetails","inProgress","localPath","customTransformOptions","dom","path","sep","replace","inputFile","entryFile","isAbsolute","relative","status","color","chalk","green","red","_bundleTimers","get","buildID","time","elapsed","micro","Number","converted","tenthFractionOfMicro","toFixed","cyan","bold","dim","plural","totalFileCount","reset","filledBar","Math","floor","ratio","_progress","bgGreen","repeat","bgWhite","white","padStart","transformedFileCount","toString","length","dirname","basename","_logInitializing","port","hasReducedPerformance","isAppRegistryStartupMessage","shouldFilterBundleEvent","bundleType","transformCacheReset","logWarning","dependencyGraphLoading","_logBundlingError","error","moduleResolutionError","cause","maybeAppendCodeFrame","_expoImportStack","targetModuleName","originModulePath","relativePath","DOCS_PAGE_URL","learnMore","moduleName","test","NODE_STDLIB_MODULES","rawMessage","codeFrame","errorMessage","lines","split","index","findIndex","line","slice","body","formatted","ios","android","web","environment","trim"],"mappings":";;;;;;;;;;;IA8BaA,qBAAqB;eAArBA;;IAoOGC,mCAAmC;eAAnCA;;IAwCAC,sBAAsB;eAAtBA;;IAkBAC,cAAc;eAAdA;;;;gEA5TE;;;;;;;gEAED;;;;;;kCAE4B;2BAQT;qBAChB;sBACM;oCAKnB;;;;;;AAEP,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,8BAA8B;AACpC,MAAMC,kBAAkB;AACxB,MAAMC,mBAAmB;AAKlB,MAAMR,8BAA8BS,kCAAgB;IACzDC,YACE,AAAOC,WAAmB,EAC1BC,QAAkB,CAClB;QACA,KAAK,CAACA,gBAHCD,cAAAA;IAIT;IAEAE,KAAKC,KAA8B,EAAQ;QACzC,OAAQA,MAAMC,IAAI;YAChB,KAAK;oBACQD;gBAAX,IAAI,SAAOA,cAAAA,MAAME,IAAI,qBAAVF,WAAY,CAAC,EAAE,MAAK,UAAU;oBACvC,MAAMG,UAAUH,MAAME,IAAI,CAAC,EAAE;oBAC7B,IAAIC,QAAQC,KAAK,CAAC,+BAA+B;wBAC/C,kGAAkG;wBAClG,kCAAkC;wBAElC,gBAAgB;wBAChB,oFAAoF;wBACpF,8EAA8E;wBAC9E,2EAA2E;wBAC3E,oBAAoB;wBACpB,KAAK;wBACL;oBACF;oBAEA,IAAI,CAACC,QAAG,CAACC,UAAU,EAAE;wBACnB,oHAAoH;wBACpH,kKAAkK;wBAClK,gMAAgM;wBAChM,IAAIH,QAAQC,KAAK,CAAC,uDAAuD;4BACvE,gBAAgB;4BAChB;wBACF;oBACF;gBACF;gBACA;YACF,KAAK;gBAAc;oBACjB,IAAI,IAAI,CAACG,qBAAqB,CAACP,QAAQ;wBACrC;oBACF;oBACA,MAAM,EAAEQ,KAAK,EAAE,GAAGR;oBAElB,IAAI,CAACQ,OAAO;wBACV;oBACF;oBAEA,MAAMC,OAAOT,M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uCM,GAAG,MAAK,UACtD;QACA,OAAOU,gBAAK,CAACc,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI;IAC7B;IAEA,OAAO;AACT"}
@@ -142,7 +142,7 @@ const _default = defaultResolver;
142
142
  return (0, _path().resolve)((0, _path().dirname)(closestPackageJson), resolved[0]);
143
143
  }
144
144
  if (pkg.exports) {
145
- throw new Error("`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue");
145
+ throw new Error("`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Report an issue: https://github.com/expo/expo/issues");
146
146
  }
147
147
  }
148
148
  }
@@ -162,7 +162,7 @@ const _default = defaultResolver;
162
162
  return (0, _path().resolve)((0, _path().dirname)(packageJsonPath), resolved[0]);
163
163
  }
164
164
  if (pkg.exports) {
165
- throw new Error("`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue");
165
+ throw new Error("`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Report an issue: https://github.com/expo/expo/issues");
166
166
  }
167
167
  return path;
168
168
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/createJResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Fork of the jest resolver but with additional settings for Metro and pnp removed.\n * https://github.com/jestjs/jest/blob/d1a2ed7fea4bdc19836274cd810c8360e3ab62f3/packages/jest-resolve/src/defaultResolver.ts#L1\n */\nimport type { JSONObject as PackageJSON } from '@expo/json-file';\nimport assert from 'assert';\nimport { dirname, isAbsolute, resolve as pathResolve } from 'path';\nimport { sync as resolveSync, SyncOpts as UpstreamResolveOptions } from 'resolve';\nimport * as resolve from 'resolve.exports';\n\n/**\n * Allows transforming parsed `package.json` contents.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param file - Path to `package.json` file.\n * @param dir - Directory that contains the `package.json`.\n *\n * @returns Transformed `package.json` contents.\n */\ntype PackageFilter = (pkg: PackageJSON, file: string, dir: string) => PackageJSON;\n\n/**\n * Allows transforming a path within a package.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param path - Path being resolved.\n * @param relativePath - Path relative from the `package.json` location.\n *\n * @returns Relative path that will be joined from the `package.json` location.\n */\ntype PathFilter = (pkg: PackageJSON, path: string, relativePath: string) => string;\n\ntype ResolverOptions = {\n /** Directory to begin resolving from. */\n basedir: string;\n /** List of export conditions. */\n conditions?: string[];\n /** Instance of default resolver. */\n defaultResolver: typeof defaultResolver;\n /** List of file extensions to search in order. */\n extensions?: string[];\n /**\n * List of directory names to be looked up for modules recursively.\n *\n * @defaultValue\n * The default is `['node_modules']`.\n */\n moduleDirectory?: string[];\n /**\n * List of `require.paths` to use if nothing is found in `node_modules`.\n *\n * @defaultValue\n * The default is `undefined`.\n */\n paths?: string[];\n /** Allows transforming parsed `package.json` contents. */\n packageFilter?: PackageFilter;\n /** Allows transforms a path within a package. */\n pathFilter?: PathFilter;\n /** Current root directory. */\n rootDir?: string;\n\n enablePackageExports?: boolean;\n\n blockList: RegExp[];\n\n getPackageForModule: import('metro-resolver').CustomResolutionContext['getPackageForModule'];\n} & Pick<\n UpstreamResolveOptions,\n | 'readPackageSync'\n | 'realpathSync'\n | 'moduleDirectory'\n | 'extensions'\n | 'preserveSymlinks'\n | 'includeCoreModules'\n>;\n\ntype UpstreamResolveOptionsWithConditions = UpstreamResolveOptions &\n ResolverOptions & {\n pathExists: (file: string) => boolean;\n };\n\nconst defaultResolver = (\n path: string,\n {\n enablePackageExports,\n blockList = [],\n ...options\n }: Omit<ResolverOptions, 'defaultResolver' | 'getPackageForModule'> & {\n isDirectory: (file: string) => boolean;\n isFile: (file: string) => boolean;\n pathExists: (file: string) => boolean;\n }\n): string => {\n // @ts-expect-error\n const resolveOptions: UpstreamResolveOptionsWithConditions = {\n ...options,\n preserveSymlinks: options.preserveSymlinks,\n defaultResolver,\n };\n\n // resolveSync dereferences symlinks to ensure we don't create a separate\n // module instance depending on how it was referenced.\n const result = resolveSync(enablePackageExports ? getPathInModule(path, resolveOptions) : path, {\n ...resolveOptions,\n preserveSymlinks: !options.preserveSymlinks,\n });\n\n return result;\n};\n\nexport default defaultResolver;\n\n/*\n * helper functions\n */\n\nfunction getPathInModule(path: string, options: UpstreamResolveOptionsWithConditions): string {\n if (shouldIgnoreRequestForExports(path)) {\n return path;\n }\n\n const segments = path.split('/');\n\n let moduleName = segments.shift();\n\n if (!moduleName) {\n return path;\n }\n\n if (moduleName.startsWith('@')) {\n moduleName = `${moduleName}/${segments.shift()}`;\n }\n\n // self-reference\n const closestPackageJson = findClosestPackageJson(options.basedir, options);\n if (closestPackageJson) {\n const pkg = options.readPackageSync!(options.readFileSync!, closestPackageJson);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n // Added support for the package.json \"imports\" field (#-prefixed paths)\n if (path.startsWith('#')) {\n const resolved = resolve.imports(pkg, path, createResolveOptions(options.conditions));\n if (resolved) {\n // TODO: Should we attempt to resolve every path in the array?\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n // NOTE: resolve.imports would have thrown by this point.\n return path;\n }\n\n if (pkg.name === moduleName) {\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue\"\n );\n }\n }\n }\n\n let packageJsonPath = '';\n\n try {\n packageJsonPath = resolveSync(`${moduleName}/package.json`, options);\n } catch {\n // ignore if package.json cannot be found\n }\n\n if (!packageJsonPath) {\n return path;\n }\n\n const pkg = options.readPackageSync!(options.readFileSync!, packageJsonPath);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(packageJsonPath), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Please report an issue\"\n );\n }\n\n return path;\n}\n\nfunction createResolveOptions(conditions: string[] | undefined): resolve.Options {\n return conditions\n ? { conditions, unsafe: true }\n : // no conditions were passed - let's assume this is Jest internal and it should be `require`\n { browser: false, require: true };\n}\n\n// if it's a relative import or an absolute path, imports/exports are ignored\nconst shouldIgnoreRequestForExports = (path: string) => path.startsWith('.') || isAbsolute(path);\n\n// adapted from\n// https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js\nfunction findClosestPackageJson(\n start: string,\n options: UpstreamResolveOptionsWithConditions\n): string | undefined {\n let dir = pathResolve('.', start);\n if (!options.isDirectory!(dir)) {\n dir = dirname(dir);\n }\n\n while (true) {\n const pkgJsonFile = pathResolve(dir, './package.json');\n const hasPackageJson = options.pathExists!(pkgJsonFile);\n\n if (hasPackageJson) {\n return pkgJsonFile;\n }\n\n const prevDir = dir;\n dir = dirname(dir);\n\n if (prevDir === dir) {\n return undefined;\n }\n }\n}\n"],"names":["defaultResolver","path","enablePackageExports","blockList","options","resolveOptions","preserveSymlinks","result","resolveSync","getPathInModule","shouldIgnoreRequestForExports","segments","split","moduleName","shift","startsWith","closestPackageJson","findClosestPackageJson","basedir","pkg","readPackageSync","readFileSync","assert","resolved","resolve","imports","createResolveOptions","conditions","pathResolve","dirname","name","exports","join","Error","packageJsonPath","unsafe","browser","require","isAbsolute","start","dir","isDirectory","pkgJsonFile","hasPackageJson","pathExists","prevDir","undefined"],"mappings":"AAAA;;;;;;;;;CASC;;;;+BA4GD;;;eAAA;;;;gEA1GmB;;;;;;;yBACyC;;;;;;;yBACY;;;;;;;iEAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EzB,MAA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KAAKW;IAC3B,IAAI,CAACnC,QAAQqC,WAAW,CAAED,MAAM;QAC9BA,MAAMX,IAAAA,eAAO,EAACW;IAChB;IAEA,MAAO,KAAM;QACX,MAAME,cAAcd,IAAAA,eAAW,EAACY,KAAK;QACrC,MAAMG,iBAAiBvC,QAAQwC,UAAU,CAAEF;QAE3C,IAAIC,gBAAgB;YAClB,OAAOD;QACT;QAEA,MAAMG,UAAUL;QAChBA,MAAMX,IAAAA,eAAO,EAACW;QAEd,IAAIK,YAAYL,KAAK;YACnB,OAAOM;QACT;IACF;AACF"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/createJResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Fork of the jest resolver but with additional settings for Metro and pnp removed.\n * https://github.com/jestjs/jest/blob/d1a2ed7fea4bdc19836274cd810c8360e3ab62f3/packages/jest-resolve/src/defaultResolver.ts#L1\n */\nimport type { JSONObject as PackageJSON } from '@expo/json-file';\nimport assert from 'assert';\nimport { dirname, isAbsolute, resolve as pathResolve } from 'path';\nimport { sync as resolveSync, SyncOpts as UpstreamResolveOptions } from 'resolve';\nimport * as resolve from 'resolve.exports';\n\n/**\n * Allows transforming parsed `package.json` contents.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param file - Path to `package.json` file.\n * @param dir - Directory that contains the `package.json`.\n *\n * @returns Transformed `package.json` contents.\n */\ntype PackageFilter = (pkg: PackageJSON, file: string, dir: string) => PackageJSON;\n\n/**\n * Allows transforming a path within a package.\n *\n * @param pkg - Parsed `package.json` contents.\n * @param path - Path being resolved.\n * @param relativePath - Path relative from the `package.json` location.\n *\n * @returns Relative path that will be joined from the `package.json` location.\n */\ntype PathFilter = (pkg: PackageJSON, path: string, relativePath: string) => string;\n\ntype ResolverOptions = {\n /** Directory to begin resolving from. */\n basedir: string;\n /** List of export conditions. */\n conditions?: string[];\n /** Instance of default resolver. */\n defaultResolver: typeof defaultResolver;\n /** List of file extensions to search in order. */\n extensions?: string[];\n /**\n * List of directory names to be looked up for modules recursively.\n *\n * @defaultValue\n * The default is `['node_modules']`.\n */\n moduleDirectory?: string[];\n /**\n * List of `require.paths` to use if nothing is found in `node_modules`.\n *\n * @defaultValue\n * The default is `undefined`.\n */\n paths?: string[];\n /** Allows transforming parsed `package.json` contents. */\n packageFilter?: PackageFilter;\n /** Allows transforms a path within a package. */\n pathFilter?: PathFilter;\n /** Current root directory. */\n rootDir?: string;\n\n enablePackageExports?: boolean;\n\n blockList: RegExp[];\n\n getPackageForModule: import('metro-resolver').CustomResolutionContext['getPackageForModule'];\n} & Pick<\n UpstreamResolveOptions,\n | 'readPackageSync'\n | 'realpathSync'\n | 'moduleDirectory'\n | 'extensions'\n | 'preserveSymlinks'\n | 'includeCoreModules'\n>;\n\ntype UpstreamResolveOptionsWithConditions = UpstreamResolveOptions &\n ResolverOptions & {\n pathExists: (file: string) => boolean;\n };\n\nconst defaultResolver = (\n path: string,\n {\n enablePackageExports,\n blockList = [],\n ...options\n }: Omit<ResolverOptions, 'defaultResolver' | 'getPackageForModule'> & {\n isDirectory: (file: string) => boolean;\n isFile: (file: string) => boolean;\n pathExists: (file: string) => boolean;\n }\n): string => {\n // @ts-expect-error\n const resolveOptions: UpstreamResolveOptionsWithConditions = {\n ...options,\n preserveSymlinks: options.preserveSymlinks,\n defaultResolver,\n };\n\n // resolveSync dereferences symlinks to ensure we don't create a separate\n // module instance depending on how it was referenced.\n const result = resolveSync(enablePackageExports ? getPathInModule(path, resolveOptions) : path, {\n ...resolveOptions,\n preserveSymlinks: !options.preserveSymlinks,\n });\n\n return result;\n};\n\nexport default defaultResolver;\n\n/*\n * helper functions\n */\n\nfunction getPathInModule(path: string, options: UpstreamResolveOptionsWithConditions): string {\n if (shouldIgnoreRequestForExports(path)) {\n return path;\n }\n\n const segments = path.split('/');\n\n let moduleName = segments.shift();\n\n if (!moduleName) {\n return path;\n }\n\n if (moduleName.startsWith('@')) {\n moduleName = `${moduleName}/${segments.shift()}`;\n }\n\n // self-reference\n const closestPackageJson = findClosestPackageJson(options.basedir, options);\n if (closestPackageJson) {\n const pkg = options.readPackageSync!(options.readFileSync!, closestPackageJson);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n // Added support for the package.json \"imports\" field (#-prefixed paths)\n if (path.startsWith('#')) {\n const resolved = resolve.imports(pkg, path, createResolveOptions(options.conditions));\n if (resolved) {\n // TODO: Should we attempt to resolve every path in the array?\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n // NOTE: resolve.imports would have thrown by this point.\n return path;\n }\n\n if (pkg.name === moduleName) {\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(closestPackageJson), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Report an issue: https://github.com/expo/expo/issues\"\n );\n }\n }\n }\n\n let packageJsonPath = '';\n\n try {\n packageJsonPath = resolveSync(`${moduleName}/package.json`, options);\n } catch {\n // ignore if package.json cannot be found\n }\n\n if (!packageJsonPath) {\n return path;\n }\n\n const pkg = options.readPackageSync!(options.readFileSync!, packageJsonPath);\n assert(pkg, 'package.json should be read by `readPackageSync`');\n\n const resolved = resolve.exports(\n pkg,\n (segments.join('/') || '.') as resolve.Exports.Entry,\n createResolveOptions(options.conditions)\n );\n\n if (resolved) {\n return pathResolve(dirname(packageJsonPath), resolved[0]);\n }\n\n if (pkg.exports) {\n throw new Error(\n \"`exports` exists, but no results - this is a bug in Expo CLI's Metro resolver. Report an issue: https://github.com/expo/expo/issues\"\n );\n }\n\n return path;\n}\n\nfunction createResolveOptions(conditions: string[] | undefined): resolve.Options {\n return conditions\n ? { conditions, unsafe: true }\n : // no conditions were passed - let's assume this is Jest internal and it should be `require`\n { browser: false, require: true };\n}\n\n// if it's a relative import or an absolute path, imports/exports are ignored\nconst shouldIgnoreRequestForExports = (path: string) => path.startsWith('.') || isAbsolute(path);\n\n// adapted from\n// https://github.com/lukeed/escalade/blob/2477005062cdbd8407afc90d3f48f4930354252b/src/sync.js\nfunction findClosestPackageJson(\n start: string,\n options: UpstreamResolveOptionsWithConditions\n): string | undefined {\n let dir = pathResolve('.', start);\n if (!options.isDirectory!(dir)) {\n dir = dirname(dir);\n }\n\n while (true) {\n const pkgJsonFile = pathResolve(dir, './package.json');\n const hasPackageJson = options.pathExists!(pkgJsonFile);\n\n if (hasPackageJson) {\n return pkgJsonFile;\n }\n\n const prevDir = dir;\n dir = dirname(dir);\n\n if (prevDir === dir) {\n return undefined;\n }\n }\n}\n"],"names":["defaultResolver","path","enablePackageExports","blockList","options","resolveOptions","preserveSymlinks","result","resolveSync","getPathInModule","shouldIgnoreRequestForExports","segments","split","moduleName","shift","startsWith","closestPackageJson","findClosestPackageJson","basedir","pkg","readPackageSync","readFileSync","assert","resolved","resolve","imports","createResolveOptions","conditions","pathResolve","dirname","name","exports","join","Error","packageJsonPath","unsafe","browser","require","isAbsolute","start","dir","isDirectory","pkgJsonFile","hasPackageJson","pathExists","prevDir","undefined"],"mappings":"AAAA;;;;;;;;;CASC;;;;+BA4GD;;;eAAA;;;;gEA1GmB;;;;;;;yBACyC;;;;;;;yBACY;;;;;;;iEAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EzB,MAAMA,kBAAkB,CACtBC,MACA,EACEC,oBAAoB,EACpBC,YAAY,EAAE,EACd,GAAGC,SAKJ;IAED,mBAAmB;IACnB,MAAMC,iBAAuD;QAC3D,GAAGD,OAAO;QACVE,kBAAkBF,QAAQE,gBAAgB;QAC1CN;IACF;IAEA,yEAAyE;IACzE,sDAAsD;IACtD,MAAMO,SAASC,IAAAA,eAAW,EAACN,uBAAuBO,gBAAgBR,MAAMI,kBAAkBJ,M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A,eAAO,EAACW;QAEd,IAAIK,YAAYL,KAAK;YACnB,OAAOM;QACT;IACF;AACF"}
@@ -407,7 +407,6 @@ function createServerComponentsMiddleware(projectRoot, { rscPath, instanceMetroO
407
407
  const serverRoot = getMetroServerRootMemo(projectRoot);
408
408
  debug('[SSR] loadServerModuleRsc:', urlFragment);
409
409
  const options = (0, _metroOptions.getMetroOptionsFromUrl)(urlFragment);
410
- console.log('loadServerModuleRsc:', serverRoot, options.mainModuleName);
411
410
  return ssrLoadModule(_path().default.join(serverRoot, options.mainModuleName), options, {
412
411
  hot: true
413
412
  });