@expo/cli 55.0.6 → 55.0.8

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 (87) hide show
  1. package/build/bin/cli +13 -1
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/api/user/actions.js +5 -2
  4. package/build/src/api/user/actions.js.map +1 -1
  5. package/build/src/api/user/expoSsoLauncher.js +22 -49
  6. package/build/src/api/user/expoSsoLauncher.js.map +1 -1
  7. package/build/src/api/user/user.js +6 -5
  8. package/build/src/api/user/user.js.map +1 -1
  9. package/build/src/config/configAsync.js +1 -1
  10. package/build/src/config/configAsync.js.map +1 -1
  11. package/build/src/customize/customizeAsync.js +1 -1
  12. package/build/src/customize/customizeAsync.js.map +1 -1
  13. package/build/src/export/embed/exportEmbedAsync.js +1 -1
  14. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  15. package/build/src/export/exportApp.js +1 -1
  16. package/build/src/export/exportApp.js.map +1 -1
  17. package/build/src/export/exportStaticAsync.js +7 -11
  18. package/build/src/export/exportStaticAsync.js.map +1 -1
  19. package/build/src/export/web/exportWebAsync.js +1 -1
  20. package/build/src/export/web/exportWebAsync.js.map +1 -1
  21. package/build/src/install/installAsync.js +1 -1
  22. package/build/src/install/installAsync.js.map +1 -1
  23. package/build/src/lint/lintAsync.js +1 -1
  24. package/build/src/lint/lintAsync.js.map +1 -1
  25. package/build/src/login/index.js +6 -2
  26. package/build/src/login/index.js.map +1 -1
  27. package/build/src/prebuild/prebuildAsync.js +1 -1
  28. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  29. package/build/src/run/android/runAndroidAsync.js +1 -1
  30. package/build/src/run/android/runAndroidAsync.js.map +1 -1
  31. package/build/src/run/ios/runIosAsync.js +1 -1
  32. package/build/src/run/ios/runIosAsync.js.map +1 -1
  33. package/build/src/serve/serveAsync.js +1 -1
  34. package/build/src/serve/serveAsync.js.map +1 -1
  35. package/build/src/start/interface/commandsTable.js +89 -69
  36. package/build/src/start/interface/commandsTable.js.map +1 -1
  37. package/build/src/start/interface/interactiveActions.js +29 -14
  38. package/build/src/start/interface/interactiveActions.js.map +1 -1
  39. package/build/src/start/platforms/ios/devicectl.js +4 -1
  40. package/build/src/start/platforms/ios/devicectl.js.map +1 -1
  41. package/build/src/start/server/BundlerDevServer.js +16 -9
  42. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  43. package/build/src/start/server/DevServerManager.js +5 -1
  44. package/build/src/start/server/DevServerManager.js.map +1 -1
  45. package/build/src/start/server/UrlCreator.js +17 -7
  46. package/build/src/start/server/UrlCreator.js.map +1 -1
  47. package/build/src/start/server/getStaticRenderFunctions.js +8 -8
  48. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  49. package/build/src/start/server/metro/MetroBundlerDevServer.js +20 -20
  50. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  51. package/build/src/start/server/metro/MetroTerminalReporter.js +1 -1
  52. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  53. package/build/src/start/server/metro/createServerComponentsMiddleware.js +1 -1
  54. package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
  55. package/build/src/start/server/metro/debugging/createDebugMiddleware.js +5 -1
  56. package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
  57. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +18 -18
  58. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
  59. package/build/src/start/server/metro/instantiateMetro.js +9 -5
  60. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  61. package/build/src/start/server/metro/log-box/LogBoxSymbolication.js +5 -1
  62. package/build/src/start/server/metro/log-box/LogBoxSymbolication.js.map +1 -1
  63. package/build/src/start/server/metro/resolveLoader.js +2 -0
  64. package/build/src/start/server/metro/resolveLoader.js.map +1 -1
  65. package/build/src/start/server/metro/runServer-fork.js +6 -5
  66. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  67. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +4 -4
  68. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  69. package/build/src/utils/downloadExpoGoAsync.js +36 -0
  70. package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
  71. package/build/src/utils/editor.js +404 -31
  72. package/build/src/utils/editor.js.map +1 -1
  73. package/build/src/utils/env.js +13 -11
  74. package/build/src/utils/env.js.map +1 -1
  75. package/build/src/utils/getRunningProcess.js +80 -41
  76. package/build/src/utils/getRunningProcess.js.map +1 -1
  77. package/build/src/utils/ip.js +44 -8
  78. package/build/src/utils/ip.js.map +1 -1
  79. package/build/src/utils/nodeEnv.js +66 -1
  80. package/build/src/utils/nodeEnv.js.map +1 -1
  81. package/build/src/utils/port.js +2 -2
  82. package/build/src/utils/port.js.map +1 -1
  83. package/build/src/utils/qr.js +186 -0
  84. package/build/src/utils/qr.js.map +1 -0
  85. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  86. package/build/src/utils/telemetry/utils/context.js +1 -1
  87. package/package.json +16 -17
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import assert from 'assert';\nimport resolveFrom from 'resolve-from';\n\nimport { AsyncNgrok } from './AsyncNgrok';\nimport { AsyncWsTunnel } from './AsyncWsTunnel';\nimport { Bonjour } from './Bonjour';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env, envIsWebcontainer } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { openBrowserAsync } from '../../utils/open';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\n\nexport type MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\n addListener?(event: string, listener: (...args: any[]) => void): unknown;\n};\n\nexport type DevServerInstance = {\n /** Bundler dev server instance. */\n server: ServerLike;\n /** Dev server URL location properties. */\n location: {\n url: string;\n port: number;\n protocol: 'http' | 'https';\n host?: string;\n };\n /** Additional middleware that's attached to the `server`. */\n middleware: any;\n /** Message socket for communicating with the runtime. */\n messageSocket: MessageSocket;\n};\n\nexport interface BundlerStartOptions {\n /** Should the dev server use `https` protocol. */\n https?: boolean;\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Is dev client enabled. */\n devClient?: boolean;\n /** Should run dev servers with clean caches. */\n resetDevServer?: boolean;\n /** Code signing private key path (defaults to same directory as certificate) */\n privateKeyPath?: string;\n\n /** Max amount of workers (threads) to use with Metro bundler, defaults to undefined for max workers. */\n maxWorkers?: number;\n /** Port to start the dev server on. */\n port?: number;\n\n /** Should start a headless dev server e.g. mock representation to approximate info from a server running in a different process. */\n headless?: boolean;\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n\n /** Will the bundler be used for exporting. NOTE: This is an odd option to pass to the dev server. */\n isExporting?: boolean;\n\n // Webpack options\n /** Should modify and create PWA icons. */\n isImageEditingEnabled?: boolean;\n\n location: CreateURLOptions;\n}\n\nconst PLATFORM_MANAGERS = {\n simulator: () =>\n require('../platforms/ios/ApplePlatformManager')\n .ApplePlatformManager as typeof import('../platforms/ios/ApplePlatformManager').ApplePlatformManager,\n emulator: () =>\n require('../platforms/android/AndroidPlatformManager')\n .AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Tunnel instance for managing tunnel connections. */\n protected tunnel: AsyncNgrok | AsyncWsTunnel | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Announces dev server via Bonjour */\n protected bonjour: Bonjour | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n private notifier: FileNotifier | null = null;\n protected readonly devToolsPluginManager: DevToolsPluginManager;\n public isDevClient: boolean;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n /** Advanced options */\n options?: {\n /**\n * The instance of DevToolsPluginManager\n * @default new DevToolsPluginManager(projectRoot)\n */\n devToolsPluginManager?: DevToolsPluginManager;\n // TODO: Replace with custom scheme maybe...\n isDevClient?: boolean;\n }\n ) {\n this.devToolsPluginManager =\n options?.devToolsPluginManager ?? new DevToolsPluginManager(projectRoot);\n this.isDevClient = options?.isDevClient ?? false;\n }\n\n protected setInstance(instance: DevServerInstance) {\n this.instance = instance;\n }\n\n /** Get the manifest middleware function. */\n protected async getManifestMiddlewareAsync(\n options: Pick<BundlerStartOptions, 'minify' | 'mode' | 'privateKeyPath'> = {}\n ) {\n const Middleware = require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware;\n\n const urlCreator = this.getUrlCreator();\n const middleware = new Middleware(this.projectRoot, {\n constructUrl: urlCreator.constructUrl.bind(urlCreator),\n mode: options.mode,\n minify: options.minify,\n isNativeWebpack: this.name === 'webpack' && this.isTargetingNative(),\n privateKeyPath: options.privateKeyPath,\n });\n return middleware;\n }\n\n /** Start the dev server using settings defined in the start command. */\n public async startAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n await this.stopAsync();\n\n let instance: DevServerInstance;\n if (options.headless) {\n instance = await this.startHeadlessAsync(options);\n } else {\n instance = await this.startImplementationAsync(options);\n }\n\n this.setInstance(instance);\n await this.postStartAsync(options);\n return instance;\n }\n\n protected abstract startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance>;\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n return false;\n }\n\n public abstract startTypeScriptServices(): Promise<void>;\n\n public async watchEnvironmentVariables(): Promise<void> {\n // noop -- We've only implemented this functionality in Metro.\n }\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: (callback: () => void) => {\n this.instance = null;\n callback?.();\n },\n addListener() {},\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n /**\n * Runs after the `startAsync` function, performing any additional common operations.\n * You can assume the dev server is started by the time this function is called.\n */\n protected async postStartAsync(options: BundlerStartOptions) {\n if (\n options.location.hostType === 'tunnel' &&\n !env.EXPO_OFFLINE &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n } else if (envIsWebcontainer()) {\n await this._startTunnelAsync();\n }\n\n if (!options.isExporting) {\n await Promise.all([this.startDevSessionAsync(), this.startBonjourAsync()]);\n this.watchConfig();\n }\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n this.notifier?.stopObserving();\n this.notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n this.notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | AsyncWsTunnel | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[tunnel] connect to port: ' + port);\n this.tunnel = envIsWebcontainer()\n ? new AsyncWsTunnel(this.projectRoot, port)\n : new AsyncNgrok(this.projectRoot, port);\n await this.tunnel.startAsync();\n return this.tunnel;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' })\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n protected async startBonjourAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n if (!this.bonjour) {\n this.bonjour = new Bonjour(this.projectRoot, this.getInstance()?.location.port);\n }\n\n await this.bonjour.announceAsync({});\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop file watching.\n this.notifier?.stopObserving();\n\n await Promise.all([\n // Stop the bonjour advertiser\n this.bonjour?.closeAsync(),\n // Stop the dev session timer and tell Expo API to remove dev session.\n this.devSession?.closeAsync(),\n ]);\n\n // Stop tunnel if running.\n await this.tunnel?.stopAsync().catch((e) => {\n Log.error(`Error stopping tunnel:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n // Check if server is even running.\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n if ('code' in error && error.code === 'ERR_SERVER_NOT_RUNNING') {\n resolve();\n } else {\n reject(error);\n }\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n public getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? (this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl())\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n\n // If we have an active WS tunnel instance, we always need to return the tunnel location.\n if (this.tunnel && this.tunnel instanceof AsyncWsTunnel) {\n return this.getUrlCreator().constructUrl();\n }\n\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n\n return location.url ?? null;\n }\n\n public getDevServerUrlOrAssert(options: { hostType?: 'localhost' } = {}): string {\n const instance = this.getDevServerUrl(options);\n if (!instance) {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the dev server URL before the server has started - bundler[${this.name}]`\n );\n }\n\n return instance;\n }\n\n /** Get the base URL for JS inspector */\n public getJsInspectorBaseUrl(): string {\n if (this.name !== 'metro') {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the JS inspector base url - bundler[${this.name}]`\n );\n }\n return this.getUrlCreator().constructUrl({ scheme: 'http' });\n }\n\n /** Get the tunnel URL from the tunnel. */\n public getTunnelUrl(): string | null {\n return this.tunnel?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const serverUrl = this.getDevServerUrl({ hostType: 'localhost' });\n // Allow opening the tunnel URL when using Metro web.\n const url = this.name === 'metro' ? (this.getTunnelUrl() ?? serverUrl) : serverUrl;\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync<T extends BaseOpenInCustomProps = BaseOpenInCustomProps>(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<T> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(): string {\n return this.getUrlCreator().constructUrl({ scheme: 'exp' });\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected isRedirectPageEnabled(): boolean {\n return (\n !env.EXPO_NO_REDIRECT_PAGE &&\n // if user passed --dev-client flag, skip interstitial page\n !this.isDevClient &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-client')\n );\n }\n\n /** Get the redirect URL when redirecting is enabled. */\n public getRedirectUrl(platform: keyof typeof PLATFORM_MANAGERS | null = null): string | null {\n if (!this.isRedirectPageEnabled()) {\n debug('Redirect page is disabled');\n return null;\n }\n\n return (\n this.getUrlCreator().constructLoadingUrl(\n {},\n platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null\n ) ?? null\n );\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this),\n getRedirectUrl: this.getRedirectUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["BundlerDevServer","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","constructor","projectRoot","platformBundlers","options","tunnel","devSession","bonjour","instance","platformManagers","urlCreator","notifier","devToolsPluginManager","DevToolsPluginManager","isDevClient","setInstance","getManifestMiddlewareAsync","Middleware","ExpoGoManifestHandlerMiddleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","waitForTypeScriptAsync","watchEnvironmentVariables","port","CommandError","server","close","callback","addListener","location","host","url","protocol","messageSocket","broadcast","hostType","env","EXPO_OFFLINE","_startTunnelAsync","envIsWebcontainer","isExporting","Promise","all","startDevSessionAsync","startBonjourAsync","watchConfig","stopObserving","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncWsTunnel","AsyncNgrok","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","runtime","Bonjour","announceAsync","isTargetingWeb","web","broadcastMessage","method","params","closeAsync","catch","e","Log","error","exception","resolveWithTimeout","resolve","reject","code","timeout","errorMessage","assert","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getDevServerUrlOrAssert","getJsInspectorBaseUrl","getActiveUrl","openPlatformAsync","launchTarget","resolver","serverUrl","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","getExpoGoUrl","isRedirectPageEnabled","EXPO_NO_REDIRECT_PAGE","resolveFrom","silent","getRedirectUrl","platform","constructLoadingUrl","Manager","getCustomRuntimeUrl"],"mappings":";;;;+BA0FsBA;;;eAAAA;;;;gEA1FH;;;;;;;gEACK;;;;;;4BAEG;+BACG;yBACN;8EACU;oCACC;4BACU;6DAExB;8BACQ;uBACM;qBACI;wBACV;sBACI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOjC,MAAMC,QAAQC,QAAQ,SAAS;AA2D/B,MAAMC,oBAAoB;IACxBC,WAAW,IACTF,QAAQ,yCACLG,oBAAoB;IACzBC,UAAU,IACRJ,QAAQ,+CACLK,sBAAsB;AAC7B;AAEO,MAAeP;IAqBpBQ,YACE,yBAAyB,GACzB,AAAOC,WAAmB,EAC1B,wCAAwC,GACxC,AAAOC,gBAAkC,EACzC,qBAAqB,GACrBC,OAQC,CACD;aAbOF,cAAAA;aAEAC,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MAAgBX,wBAAwBW,QAAwC,EAAE;QAChF,IAAI,CAAC,IAAI,CAAC3G,gBAAgB,CAAC2G,SAAS,EAAE;gBAEvB;YADb,MAAME,UAAU1H,iBAAiB,CAACwH,SAAS;YAC3C,MAAM/E,QAAO,oBAAA,IAAI,CAAC2B,WAAW,uBAAhB,kBAAoBrB,QAAQ,CAACN,IAAI;YAC9C,IAAI,CAACA,QAAQ,CAAC,IAAI,CAAC3B,UAAU,EAAE;gBAC7B,MAAM,IAAI4B,oBAAY,CACpB,cACA;YAEJ;YACA5C,MAAM,CAAC,qCAAqC,EAAE0H,SAAS,QAAQ,EAAE/E,KAAK,CAAC,CAAC;YACxE,IAAI,CAAC5B,gBAAgB,CAAC2G,SAAS,GAAG,IAAIE,QAAQ,IAAI,CAACpH,WAAW,EAAEmC,MAAM;gBACpEkF,qBAAqB,IAAI,CAAC7G,UAAU,CAACoF,qBAAqB,CAACxE,IAAI,CAAC,IAAI,CAACZ,UAAU;gBAC/EoG,cAAc,IAAI,CAACA,YAAY,CAACxF,IAAI,CAAC,IAAI;gBACzC6F,gBAAgB,IAAI,CAACA,cAAc,CAAC7F,IAAI,CAAC,IAAI,EAAE8F;gBAC/C/C,iBAAiB,IAAI,CAACA,eAAe,CAAC/C,IAAI,CAAC,IAAI,EAAE;oBAAE2B,UAAU;gBAAY;YAC3E;QACF;QACA,OAAO,IAAI,CAACxC,gBAAgB,CAAC2G,SAAS;IACxC;AACF"}
1
+ {"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import assert from 'assert';\nimport resolveFrom from 'resolve-from';\n\nimport { AsyncNgrok } from './AsyncNgrok';\nimport { AsyncWsTunnel } from './AsyncWsTunnel';\nimport { Bonjour } from './Bonjour';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env, envIsWebcontainer } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { openBrowserAsync } from '../../utils/open';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\n\nexport type MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\n addListener?(event: string, listener: (...args: any[]) => void): unknown;\n};\n\nexport type DevServerInstance = {\n /** Bundler dev server instance. */\n server: ServerLike;\n /** Dev server URL location properties. */\n location: {\n url: string;\n port: number;\n protocol: 'http' | 'https';\n host?: string;\n };\n /** Additional middleware that's attached to the `server`. */\n middleware: any;\n /** Message socket for communicating with the runtime. */\n messageSocket: MessageSocket;\n};\n\nexport interface BundlerStartOptions {\n /** Should the dev server use `https` protocol. */\n https?: boolean;\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Is dev client enabled. */\n devClient?: boolean;\n /** Should run dev servers with clean caches. */\n resetDevServer?: boolean;\n /** Code signing private key path (defaults to same directory as certificate) */\n privateKeyPath?: string;\n\n /** Max amount of workers (threads) to use with Metro bundler, defaults to undefined for max workers. */\n maxWorkers?: number;\n /** Port to start the dev server on. */\n port?: number;\n\n /** Should start a headless dev server e.g. mock representation to approximate info from a server running in a different process. */\n headless?: boolean;\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n\n /** Will the bundler be used for exporting. NOTE: This is an odd option to pass to the dev server. */\n isExporting?: boolean;\n\n // Webpack options\n /** Should modify and create PWA icons. */\n isImageEditingEnabled?: boolean;\n\n location: CreateURLOptions;\n}\n\nconst PLATFORM_MANAGERS = {\n simulator: () =>\n require('../platforms/ios/ApplePlatformManager')\n .ApplePlatformManager as typeof import('../platforms/ios/ApplePlatformManager').ApplePlatformManager,\n emulator: () =>\n require('../platforms/android/AndroidPlatformManager')\n .AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Tunnel instance for managing tunnel connections. */\n protected tunnel: AsyncNgrok | AsyncWsTunnel | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Announces dev server via Bonjour */\n protected bonjour: Bonjour | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n private notifier: FileNotifier | null = null;\n protected readonly devToolsPluginManager: DevToolsPluginManager;\n public isDevClient: boolean;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n /** Advanced options */\n options?: {\n /**\n * The instance of DevToolsPluginManager\n * @default new DevToolsPluginManager(projectRoot)\n */\n devToolsPluginManager?: DevToolsPluginManager;\n // TODO: Replace with custom scheme maybe...\n isDevClient?: boolean;\n }\n ) {\n this.devToolsPluginManager =\n options?.devToolsPluginManager ?? new DevToolsPluginManager(projectRoot);\n this.isDevClient = options?.isDevClient ?? false;\n }\n\n protected setInstance(instance: DevServerInstance) {\n this.instance = instance;\n }\n\n /** Get the manifest middleware function. */\n protected async getManifestMiddlewareAsync(\n options: Pick<BundlerStartOptions, 'minify' | 'mode' | 'privateKeyPath'> = {}\n ) {\n const Middleware = require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware;\n\n const urlCreator = this.getUrlCreator();\n const middleware = new Middleware(this.projectRoot, {\n constructUrl: urlCreator.constructUrl.bind(urlCreator),\n mode: options.mode,\n minify: options.minify,\n isNativeWebpack: this.name === 'webpack' && this.isTargetingNative(),\n privateKeyPath: options.privateKeyPath,\n });\n return middleware;\n }\n\n /** Start the dev server using settings defined in the start command. */\n public async startAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n await this.stopAsync();\n\n let instance: DevServerInstance;\n if (options.headless) {\n instance = await this.startHeadlessAsync(options);\n } else {\n instance = await this.startImplementationAsync(options);\n }\n\n this.setInstance(instance);\n await this.postStartAsync(options);\n return instance;\n }\n\n protected abstract startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance>;\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n return false;\n }\n\n public abstract startTypeScriptServices(): Promise<void>;\n\n public async watchEnvironmentVariables(): Promise<void> {\n // noop -- We've only implemented this functionality in Metro.\n }\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n await this.initUrlCreator(options);\n return {\n // Create a mock server\n server: {\n close: (callback: () => void) => {\n this.instance = null;\n callback?.();\n },\n addListener() {},\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n /**\n * Runs after the `startAsync` function, performing any additional common operations.\n * You can assume the dev server is started by the time this function is called.\n */\n protected async postStartAsync(options: BundlerStartOptions) {\n if (\n options.location.hostType === 'tunnel' &&\n !env.EXPO_OFFLINE &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n } else if (envIsWebcontainer()) {\n await this._startTunnelAsync();\n }\n\n if (!options.isExporting) {\n await Promise.all([this.startDevSessionAsync(), this.startBonjourAsync()]);\n this.watchConfig();\n }\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n this.notifier?.stopObserving();\n this.notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n this.notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | AsyncWsTunnel | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[tunnel] connect to port: ' + port);\n this.tunnel = envIsWebcontainer()\n ? new AsyncWsTunnel(this.projectRoot, port)\n : new AsyncNgrok(this.projectRoot, port);\n await this.tunnel.startAsync();\n return this.tunnel;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' })\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n protected async startBonjourAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n if (!this.bonjour) {\n this.bonjour = new Bonjour(this.projectRoot, this.getInstance()?.location.port);\n }\n\n await this.bonjour.announceAsync({});\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Reset url creator\n this.urlCreator = undefined;\n\n // Stop file watching.\n this.notifier?.stopObserving();\n\n await Promise.all([\n // Stop the bonjour advertiser\n this.bonjour?.closeAsync(),\n // Stop the dev session timer and tell Expo API to remove dev session.\n this.devSession?.closeAsync(),\n ]);\n\n // Stop tunnel if running.\n await this.tunnel?.stopAsync().catch((e) => {\n Log.error(`Error stopping tunnel:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n // Check if server is even running.\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n if ('code' in error && error.code === 'ERR_SERVER_NOT_RUNNING') {\n resolve();\n } else {\n reject(error);\n }\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n // TODO(@kitten): This should be created top-down rather than bottom up from implementors\n protected async initUrlCreator(\n options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}\n ) {\n assert(options?.port, 'Dev server instance not found');\n assert(!this.urlCreator, 'Dev server is already initialized');\n const urlCreator = await UrlCreator.init(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n this.urlCreator = urlCreator;\n return urlCreator;\n }\n\n public getUrlCreator() {\n assert(this.urlCreator, 'Dev server is uninitialized');\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? (this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl())\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n\n // If we have an active WS tunnel instance, we always need to return the tunnel location.\n if (this.tunnel && this.tunnel instanceof AsyncWsTunnel) {\n return this.getUrlCreator().constructUrl();\n }\n\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n\n return location.url ?? null;\n }\n\n public getDevServerUrlOrAssert(options: { hostType?: 'localhost' } = {}): string {\n const instance = this.getDevServerUrl(options);\n if (!instance) {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the dev server URL before the server has started - bundler[${this.name}]`\n );\n }\n\n return instance;\n }\n\n /** Get the base URL for JS inspector */\n public getJsInspectorBaseUrl(): string {\n if (this.name !== 'metro') {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the JS inspector base url - bundler[${this.name}]`\n );\n }\n return this.getUrlCreator().constructUrl({ scheme: 'http' });\n }\n\n /** Get the tunnel URL from the tunnel. */\n public getTunnelUrl(): string | null {\n return this.tunnel?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const serverUrl = this.getDevServerUrl({ hostType: 'localhost' });\n // Allow opening the tunnel URL when using Metro web.\n const url = this.name === 'metro' ? (this.getTunnelUrl() ?? serverUrl) : serverUrl;\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync<T extends BaseOpenInCustomProps = BaseOpenInCustomProps>(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<T> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(): string {\n return this.getUrlCreator().constructUrl({ scheme: 'exp' });\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected isRedirectPageEnabled(): boolean {\n return (\n !env.EXPO_NO_REDIRECT_PAGE &&\n // if user passed --dev-client flag, skip interstitial page\n !this.isDevClient &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-client')\n );\n }\n\n /** Get the redirect URL when redirecting is enabled. */\n public getRedirectUrl(platform: keyof typeof PLATFORM_MANAGERS | null = null): string | null {\n if (!this.isRedirectPageEnabled()) {\n debug('Redirect page is disabled');\n return null;\n }\n\n return (\n this.getUrlCreator().constructLoadingUrl(\n {},\n platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null\n ) ?? null\n );\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this),\n getRedirectUrl: this.getRedirectUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["BundlerDevServer","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","constructor","projectRoot","platformBundlers","options","tunnel","devSession","bonjour","instance","platformManagers","urlCreator","notifier","devToolsPluginManager","DevToolsPluginManager","isDevClient","setInstance","getManifestMiddlewareAsync","Middleware","ExpoGoManifestHandlerMiddleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","waitForTypeScriptAsync","watchEnvironmentVariables","port","CommandError","initUrlCreator","server","close","callback","addListener","location","host","url","protocol","messageSocket","broadcast","hostType","env","EXPO_OFFLINE","_startTunnelAsync","envIsWebcontainer","isExporting","Promise","all","startDevSessionAsync","startBonjourAsync","watchConfig","stopObserving","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncWsTunnel","AsyncNgrok","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","runtime","Bonjour","announceAsync","isTargetingWeb","web","broadcastMessage","method","params","undefined","closeAsync","catch","e","Log","error","exception","resolveWithTimeout","resolve","reject","code","timeout","errorMessage","assert","UrlCreator","init","getTunnelUrl","opts","constructDevClientUrl","scheme","getDevServerUrlOrAssert","getJsInspectorBaseUrl","getActiveUrl","openPlatformAsync","launchTarget","resolver","serverUrl","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","getExpoGoUrl","isRedirectPageEnabled","EXPO_NO_REDIRECT_PAGE","resolveFrom","silent","getRedirectUrl","platform","constructLoadingUrl","Manager","getCustomRuntimeUrl"],"mappings":";;;;+BA0FsBA;;;eAAAA;;;;gEA1FH;;;;;;;gEACK;;;;;;4BAEG;+BACG;yBACN;8EACU;oCACC;4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AAC,IAAI;gBACzCgG,gBAAgB,IAAI,CAACA,cAAc,CAAChG,IAAI,CAAC,IAAI,EAAEiG;gBAC/CjD,iBAAiB,IAAI,CAACA,eAAe,CAAChD,IAAI,CAAC,IAAI,EAAE;oBAAE4B,UAAU;gBAAY;YAC3E;QACF;QACA,OAAO,IAAI,CAACzC,gBAAgB,CAAC8G,SAAS;IACxC;AACF"}
@@ -179,7 +179,10 @@ class DevServerManager {
179
179
  }
180
180
  /** Switch between Expo Go and Expo Dev Clients. */ async toggleRuntimeMode(isUsingDevClient = !this.options.devClient) {
181
181
  const nextMode = isUsingDevClient ? '--dev-client' : '--go';
182
- _log.Log.log((0, _commandsTable.printItem)((0, _chalk().default)`Switching to {bold ${nextMode}}`));
182
+ _log.Log.log((0, _commandsTable.printItem)(`Switching to ${(0, _chalk().default)`{bold ${nextMode}}`}`, {
183
+ dim: true
184
+ }));
185
+ _log.Log.log();
183
186
  const nextScheme = await (0, _resolveOptions.resolveSchemeAsync)(this.projectRoot, {
184
187
  devClient: isUsingDevClient
185
188
  });
@@ -187,6 +190,7 @@ class DevServerManager {
187
190
  this.options.devClient = isUsingDevClient;
188
191
  for (const devServer of this.devServers){
189
192
  devServer.isDevClient = isUsingDevClient;
193
+ // TODO(@kitten): Clean up mode switching better
190
194
  const urlCreator = devServer.getUrlCreator();
191
195
  urlCreator.defaults ??= {};
192
196
  urlCreator.defaults.scheme = nextScheme;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { getPlatformBundlers } from './platformBundlers';\nimport { Log } from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { env } from '../../utils/env';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport { TypeScriptProjectPrerequisite } from '../doctor/typescript/TypeScriptProjectPrerequisite';\nimport { printItem } from '../interface/commandsTable';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { resolveSchemeAsync } from '../resolveOptions';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n private devServers: BundlerDevServer[] = [];\n\n static async startMetroAsync(projectRoot: string, startOptions: BundlerStartOptions) {\n const devServerManager = new DevServerManager(projectRoot, startOptions);\n\n await devServerManager.startAsync([\n {\n type: 'metro',\n options: startOptions,\n },\n ]);\n return devServerManager;\n }\n\n private projectPrerequisites: ProjectPrerequisite<any, void>[] = [];\n public readonly devtoolsPluginManager: DevToolsPluginManager;\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n if (!options.isExporting) {\n this.notifier = this.watchBabelConfig();\n }\n this.devtoolsPluginManager = new DevToolsPluginManager(projectRoot);\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite<any, any>) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n return await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n this.devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = this.devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = this.devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = this.devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? this.devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = this.devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(this.projectRoot, exp).web;\n debug(`Starting ${bundler} dev server for web`);\n return this.startAsync([\n {\n type: bundler,\n options: this.options,\n },\n ]);\n }\n\n /** Switch between Expo Go and Expo Dev Clients. */\n async toggleRuntimeMode(isUsingDevClient: boolean = !this.options.devClient): Promise<boolean> {\n const nextMode = isUsingDevClient ? '--dev-client' : '--go';\n Log.log(printItem(chalk`Switching to {bold ${nextMode}}`));\n\n const nextScheme = await resolveSchemeAsync(this.projectRoot, {\n devClient: isUsingDevClient,\n // NOTE: The custom `--scheme` argument is lost from this point on.\n });\n\n this.options.location.scheme = nextScheme;\n this.options.devClient = isUsingDevClient;\n for (const devServer of this.devServers) {\n devServer.isDevClient = isUsingDevClient;\n const urlCreator = devServer.getUrlCreator();\n urlCreator.defaults ??= {};\n urlCreator.defaults.scheme = nextScheme;\n }\n\n debug(`New runtime options (runtime: ${nextMode}):`, this.options);\n return true;\n }\n\n /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n const platformBundlers = getPlatformBundlers(this.projectRoot, exp);\n\n // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(this.projectRoot, platformBundlers, {\n devToolsPluginManager: this.devtoolsPluginManager,\n isDevClient: !!options?.devClient,\n });\n await server.startAsync(options ?? this.options);\n this.devServers.push(server);\n }\n\n return exp;\n }\n\n async bootstrapTypeScriptAsync() {\n const typescriptPrerequisite = await this.ensureProjectPrerequisiteAsync(\n TypeScriptProjectPrerequisite\n );\n\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n return;\n }\n\n // Optionally, wait for the user to add TypeScript during the\n // development cycle.\n const server = this.devServers.find((server) => server.name === 'metro');\n if (!server) {\n return;\n }\n\n // The dev server shouldn't wait for the typescript services\n if (!typescriptPrerequisite) {\n server.waitForTypeScriptAsync().then(async (success) => {\n if (success) {\n server.startTypeScriptServices();\n }\n });\n } else {\n server.startTypeScriptServices();\n }\n }\n\n async watchEnvironmentVariables() {\n await this.devServers.find((server) => server.name === 'metro')?.watchEnvironmentVariables();\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n this.notifier?.stopObserving(),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n // Stop all dev servers\n ...this.devServers.map((server) =>\n server.stopAsync().catch((error) => {\n Log.error(`Failed to stop dev server (bundler: ${server.name})`);\n Log.exception(error);\n })\n ),\n ]);\n }\n}\n"],"names":["DevServerManager","debug","require","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","startMetroAsync","projectRoot","startOptions","devServerManager","startAsync","type","options","constructor","devServers","projectPrerequisites","notifier","isExporting","watchBabelConfig","devtoolsPluginManager","DevToolsPluginManager","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","toggleRuntimeMode","isUsingDevClient","devClient","nextMode","Log","log","printItem","nextScheme","resolveSchemeAsync","scheme","devServer","isDevClient","urlCreator","getUrlCreator","defaults","platformBundlers","BundlerDevServerClass","devToolsPluginManager","bootstrapTypeScriptAsync","typescriptPrerequisite","TypeScriptProjectPrerequisite","env","EXPO_NO_TYPESCRIPT_SETUP","name","waitForTypeScriptAsync","then","success","startTypeScriptServices","watchEnvironmentVariables","stopAsync","Promise","allSettled","stopObserving","AndroidDebugBridge","getServer","map","catch","error","exception"],"mappings":";;;;+BAiCaA;;;eAAAA;;;;yBAjCyB;;;;;;;gEACnB;;;;;;;gEACD;;;;;;8EAGgB;kCACE;qBAChB;8BACS;qBACT;+CAE0B;+BACpB;6DACU;gCACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnC,MAAMC,QAAQC,QAAQ,SAAS;AAO/B,MAAMC,WAAW;IACfC,SAAS,IACPF,QAAQ,qCACLG,uBAAuB;IAC5BC,OAAO,IACLJ,QAAQ,iCACLK,qBAAqB;AAC5B;AAGO,MAAMP;IAGX,aAAaQ,gBAAgBC,WAAmB,EAAEC,YAAiC,EAAE;QAC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,yBAAyB,MAAM,IAAI,CAACjD,8BAA8B,CACtEkD,4DAA6B;QAG/B,IAAIC,QAAG,CAACC,wBAAwB,EAAE;YAChC;QACF;QAEA,6DAA6D;QAC7D,qBAAqB;QACrB,MAAM1C,SAAS,IAAI,CAACrB,UAAU,CAACc,IAAI,CAAC,CAACO,SAAWA,OAAO2C,IAAI,KAAK;QAChE,IAAI,CAAC3C,QAAQ;YACX;QACF;QAEA,4DAA4D;QAC5D,IAAI,CAACuC,wBAAwB;YAC3BvC,OAAO4C,sBAAsB,GAAGC,IAAI,CAAC,OAAOC;gBAC1C,IAAIA,SAAS;oBACX9C,OAAO+C,uBAAuB;gBAChC;YACF;QACF,OAAO;YACL/C,OAAO+C,uBAAuB;QAChC;IACF;IAEA,MAAMC,4BAA4B;YAC1B;QAAN,QAAM,wBAAA,IAAI,CAACrE,UAAU,CAACc,IAAI,CAAC,CAACO,SAAWA,OAAO2C,IAAI,KAAK,6BAAjD,sBAA2DK,yBAAyB;IAC5F;IAEA,oCAAoC,GACpC,MAAMC,YAA2B;YAE7B;QADF,MAAMC,QAAQC,UAAU,CAAC;aACvB,iBAAA,IAAI,CAACtE,QAAQ,qBAAb,eAAeuE,aAAa;YAC5B,WAAW;YACXC,KAAmBC,SAAS,GAAGL,SAAS;YACxC,uBAAuB;eACpB,IAAI,CAACtE,UAAU,CAAC4E,GAAG,CAAC,CAACvD,SACtBA,OAAOiD,SAAS,GAAGO,KAAK,CAAC,CAACC;oBACxBjC,QAAG,CAACiC,KAAK,CAAC,CAAC,oCAAoC,EAAEzD,OAAO2C,IAAI,CAAC,CAAC,CAAC;oBAC/DnB,QAAG,CAACkC,SAAS,CAACD;gBAChB;SAEH;IACH;AACF"}
1
+ {"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { getPlatformBundlers } from './platformBundlers';\nimport { Log } from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { env } from '../../utils/env';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport { TypeScriptProjectPrerequisite } from '../doctor/typescript/TypeScriptProjectPrerequisite';\nimport { printItem } from '../interface/commandsTable';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { resolveSchemeAsync } from '../resolveOptions';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n private devServers: BundlerDevServer[] = [];\n\n static async startMetroAsync(projectRoot: string, startOptions: BundlerStartOptions) {\n const devServerManager = new DevServerManager(projectRoot, startOptions);\n\n await devServerManager.startAsync([\n {\n type: 'metro',\n options: startOptions,\n },\n ]);\n return devServerManager;\n }\n\n private projectPrerequisites: ProjectPrerequisite<any, void>[] = [];\n public readonly devtoolsPluginManager: DevToolsPluginManager;\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n if (!options.isExporting) {\n this.notifier = this.watchBabelConfig();\n }\n this.devtoolsPluginManager = new DevToolsPluginManager(projectRoot);\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite<any, any>) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n return await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n this.devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = this.devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = this.devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = this.devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? this.devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = this.devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(this.projectRoot, exp).web;\n debug(`Starting ${bundler} dev server for web`);\n return this.startAsync([\n {\n type: bundler,\n options: this.options,\n },\n ]);\n }\n\n /** Switch between Expo Go and Expo Dev Clients. */\n async toggleRuntimeMode(isUsingDevClient: boolean = !this.options.devClient): Promise<boolean> {\n const nextMode = isUsingDevClient ? '--dev-client' : '--go';\n Log.log(printItem(`Switching to ${chalk`{bold ${nextMode}}`}`, { dim: true }));\n Log.log();\n\n const nextScheme = await resolveSchemeAsync(this.projectRoot, {\n devClient: isUsingDevClient,\n // NOTE: The custom `--scheme` argument is lost from this point on.\n });\n\n this.options.location.scheme = nextScheme;\n this.options.devClient = isUsingDevClient;\n for (const devServer of this.devServers) {\n devServer.isDevClient = isUsingDevClient;\n // TODO(@kitten): Clean up mode switching better\n const urlCreator = devServer.getUrlCreator();\n urlCreator.defaults ??= {};\n urlCreator.defaults.scheme = nextScheme;\n }\n\n debug(`New runtime options (runtime: ${nextMode}):`, this.options);\n return true;\n }\n\n /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n const platformBundlers = getPlatformBundlers(this.projectRoot, exp);\n\n // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(this.projectRoot, platformBundlers, {\n devToolsPluginManager: this.devtoolsPluginManager,\n isDevClient: !!options?.devClient,\n });\n await server.startAsync(options ?? this.options);\n this.devServers.push(server);\n }\n\n return exp;\n }\n\n async bootstrapTypeScriptAsync() {\n const typescriptPrerequisite = await this.ensureProjectPrerequisiteAsync(\n TypeScriptProjectPrerequisite\n );\n\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n return;\n }\n\n // Optionally, wait for the user to add TypeScript during the\n // development cycle.\n const server = this.devServers.find((server) => server.name === 'metro');\n if (!server) {\n return;\n }\n\n // The dev server shouldn't wait for the typescript services\n if (!typescriptPrerequisite) {\n server.waitForTypeScriptAsync().then(async (success) => {\n if (success) {\n server.startTypeScriptServices();\n }\n });\n } else {\n server.startTypeScriptServices();\n }\n }\n\n async watchEnvironmentVariables() {\n await this.devServers.find((server) => server.name === 'metro')?.watchEnvironmentVariables();\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n this.notifier?.stopObserving(),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n // Stop all dev servers\n ...this.devServers.map((server) =>\n server.stopAsync().catch((error) => {\n Log.error(`Failed to stop dev server (bundler: ${server.name})`);\n Log.exception(error);\n })\n ),\n ]);\n }\n}\n"],"names":["DevServerManager","debug","require","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","startMetroAsync","projectRoot","startOptions","devServerManager","startAsync","type","options","constructor","devServers","projectPrerequisites","notifier","isExporting","watchBabelConfig","devtoolsPluginManager","DevToolsPluginManager","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","toggleRuntimeMode","isUsingDevClient","devClient","nextMode","Log","log","printItem","dim","nextScheme","resolveSchemeAsync","scheme","devServer","isDevClient","urlCreator","getUrlCreator","defaults","platformBundlers","BundlerDevServerClass","devToolsPluginManager","bootstrapTypeScriptAsync","typescriptPrerequisite","TypeScriptProjectPrerequisite","env","EXPO_NO_TYPESCRIPT_SETUP","name","waitForTypeScriptAsync","then","success","startTypeScriptServices","watchEnvironmentVariables","stopAsync","Promise","allSettled","stopObserving","AndroidDebugBridge","getServer","map","catch","error","exception"],"mappings":";;;;+BAiCaA;;;eAAAA;;;;yBAjCyB;;;;;;;gEACnB;;;;;;;gEACD;;;;;;8EAGgB;kCACE;qBAChB;8BACS;qBACT;+CAE0B;+BACpB;6DACU;gCACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAACkC,KAAK,CAAC,CAAC,oCAAoC,EAAE1D,OAAO4C,IAAI,CAAC,CAAC,CAAC;oBAC/DpB,QAAG,CAACmC,SAAS,CAACD;gBAChB;SAEH;IACH;AACF"}
@@ -72,9 +72,14 @@ function _interop_require_wildcard(obj, nodeInterop) {
72
72
  }
73
73
  const debug = require('debug')('expo:start:server:urlCreator');
74
74
  class UrlCreator {
75
- constructor(defaults, bundlerInfo){
75
+ constructor(defaults, bundlerInfo, gatewayInfo = (0, _ip.getGateway)()){
76
76
  this.defaults = defaults;
77
77
  this.bundlerInfo = bundlerInfo;
78
+ this.gatewayInfo = gatewayInfo;
79
+ }
80
+ static async init(defaults, bundlerInfo) {
81
+ const gatewayInfo = await (0, _ip.getGatewayAsync)();
82
+ return new UrlCreator(defaults || {}, bundlerInfo, gatewayInfo);
78
83
  }
79
84
  /**
80
85
  * Return a URL for the "loading" interstitial page that is used to disambiguate which
@@ -128,6 +133,9 @@ class UrlCreator {
128
133
  debug(`URL: ${url}`);
129
134
  return url;
130
135
  }
136
+ getDefaultRouteAddress() {
137
+ return this.gatewayInfo.address;
138
+ }
131
139
  /** Get the URL components from the Ngrok server URL. */ getTunnelUrlComponents(options) {
132
140
  const tunnelUrl = this.bundlerInfo.getTunnelUrl == null ? void 0 : this.bundlerInfo.getTunnelUrl.call(this.bundlerInfo);
133
141
  if (!tunnelUrl) {
@@ -157,7 +165,7 @@ class UrlCreator {
157
165
  options.hostname = 'localhost';
158
166
  }
159
167
  return {
160
- hostname: getDefaultHostname(options),
168
+ hostname: getDefaultHostname(options, this.gatewayInfo),
161
169
  port: this.bundlerInfo.port.toString(),
162
170
  protocol: options.scheme ?? 'http'
163
171
  };
@@ -180,17 +188,19 @@ function getUrlComponentsFromProxyUrl(options, url) {
180
188
  protocol
181
189
  };
182
190
  }
183
- function getDefaultHostname(options) {
191
+ const getDefaultHostname = (options, gateway)=>{
184
192
  // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME
185
193
  if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {
186
194
  return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();
187
195
  } else if (options.hostname === 'localhost') {
188
- // Restrict the use of `localhost`
189
- // TODO: Note why we do this.
196
+ // NOTE: We always convert "localhost" as a request to 127.0.0.1,
197
+ // to normalize to an address that's consistent
190
198
  return '127.0.0.1';
199
+ } else {
200
+ // Fall back to local address
201
+ return options.hostname || gateway.address;
191
202
  }
192
- return options.hostname || (0, _ip.getIpAddress)();
193
- }
203
+ };
194
204
  function joinUrlComponents({ protocol, hostname, port }) {
195
205
  (0, _assert().default)(hostname, 'hostname cannot be inferred.');
196
206
  const validProtocol = protocol ? `${protocol}://` : '';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport { getIpAddress } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\nexport class UrlCreator {\n constructor(\n public defaults: CreateURLOptions | undefined,\n private bundlerInfo: { port: number; getTunnelUrl?: () => string | null }\n ) {}\n\n /**\n * Return a URL for the \"loading\" interstitial page that is used to disambiguate which\n * native runtime to open the dev server with.\n *\n * @param options options for creating the URL\n * @param platform when opening the URL from the CLI to a connected device we can specify the platform as a query parameter, otherwise it will be inferred from the unsafe user agent sniffing.\n *\n * @returns URL like `http://localhost:8081/_expo/loading?platform=ios`\n * @returns URL like `http://localhost:8081/_expo/loading` when no platform is provided.\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string | null): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n if (platform) {\n url.search = new URLSearchParams({ platform }).toString();\n }\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase()) ||\n // Prohibit the use of `_` characters in the protocol, Node will throw an error when parsing these URLs\n protocol.includes('_')\n ) {\n debug(`Invalid protocol for dev client URL: ${protocol}`);\n return null;\n }\n\n const manifestUrl = this.constructUrl({\n ...options,\n scheme: this.defaults?.hostType === 'tunnel' ? 'https' : 'http',\n });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nfunction getDefaultHostname(options: Pick<CreateURLOptions, 'hostname'>) {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // Restrict the use of `localhost`\n // TODO: Note why we do this.\n return '127.0.0.1';\n }\n\n return options.hostname || getIpAddress();\n}\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n const validProtocol = protocol ? `${protocol}://` : '';\n\n const url = `${validProtocol}${hostname}`;\n\n if (port) {\n return url + `:${port}`;\n }\n\n return url;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["UrlCreator","debug","require","constructor","defaults","bundlerInfo","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","hostType","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","components","Log","warn","getDefaultHostname","parsedProxyUrl","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","getIpAddress","assert","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":";;;;+BAsBaA;;;eAAAA;;;;gEAtBM;;;;;;;yBACC;;;;;;6DAEC;oBACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7B,MAAMC,QAAQC,QAAQ,SAAS;AAgBxB,MAAMF;IACXG,YACE,AAAOC,QAAsC,EAC7C,AAAQC,WAAiE,CACzE;aAFOD,WAAAA;aACCC,cAAAA;IACP;IAEH;;;;;;;;;GASC,GACD,AAAOC,oBAAoBC,OAAyB,EAAEC,QAAuB,EAAU;QACrF,MAAMC,MAAM,IAAIC,CAAAA,MAAE,KAAC,CAAC,iBAAiB,IAAI,CAACC,YAAY,CAAC;YAAEC,QAAQ;YAAQ,GAAGL,OAAO;QAAC;QACpF,IAAIC,UAAU;YACZC,IAAII,MAAM,GAAG,IAAIC,gBAAgB;gBAAEN;YAAS,GAAGO,QAAQ;QACzD;QACA,MAAMC,aAAaP,IAAIM,QAAQ;QAC/Bd,MAAM,CAAC,aAAa,EAAEe,YAAY;QAClC,OAAOA;IACT;IAEA,wGAAwG,GACxG,AAAOC,sBAAsBV,OAA0B,EAAiB;YAClC,gBAe1B;QAfV,MAAMW,WAAWX,CAAAA,2BAAAA,QAASK,MAAM,OAAI,iBAAA,IAAI,CAACR,QAAQ,qBAAb,eAAeQ,MAAM;QAEzD,IACE,CAACM,YACD,+EAA+E;QAC/E;YAAC;YAAQ;SAAQ,CAACC,QAAQ,CAACD,SAASE,WAAW,OAC/C,uGAAuG;QACvGF,SAASC,QAAQ,CAAC,MAClB;YACAlB,MAAM,CAAC,qCAAqC,EAAEiB,UAAU;YACxD,OAAO;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B,MAAM;IACzB;IAEA,OAAOvB;AACT;AAEA,gBAAgB,GAChB,SAAS0B;IACP,OAAOO,QAAQC,GAAG,CAACM,uBAAuB;AAC5C,EAEA,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
1
+ {"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport { GatewayInfo, getGateway, getGatewayAsync } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\n\ninterface BundlerInfo {\n port: number;\n getTunnelUrl?(): string | null;\n}\n\nexport class UrlCreator {\n constructor(\n public defaults: CreateURLOptions,\n private bundlerInfo: BundlerInfo,\n private gatewayInfo: GatewayInfo = getGateway()\n ) {}\n\n static async init(defaults: CreateURLOptions | undefined | null, bundlerInfo: BundlerInfo) {\n const gatewayInfo = await getGatewayAsync();\n return new UrlCreator(defaults || {}, bundlerInfo, gatewayInfo);\n }\n\n /**\n * Return a URL for the \"loading\" interstitial page that is used to disambiguate which\n * native runtime to open the dev server with.\n *\n * @param options options for creating the URL\n * @param platform when opening the URL from the CLI to a connected device we can specify the platform as a query parameter, otherwise it will be inferred from the unsafe user agent sniffing.\n *\n * @returns URL like `http://localhost:8081/_expo/loading?platform=ios`\n * @returns URL like `http://localhost:8081/_expo/loading` when no platform is provided.\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string | null): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n if (platform) {\n url.search = new URLSearchParams({ platform }).toString();\n }\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase()) ||\n // Prohibit the use of `_` characters in the protocol, Node will throw an error when parsing these URLs\n protocol.includes('_')\n ) {\n debug(`Invalid protocol for dev client URL: ${protocol}`);\n return null;\n }\n\n const manifestUrl = this.constructUrl({\n ...options,\n scheme: this.defaults?.hostType === 'tunnel' ? 'https' : 'http',\n });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n public getDefaultRouteAddress(): string {\n return this.gatewayInfo.address;\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options, this.gatewayInfo),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nconst getDefaultHostname = (options: CreateURLOptions, gateway: GatewayInfo) => {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // NOTE: We always convert \"localhost\" as a request to 127.0.0.1,\n // to normalize to an address that's consistent\n return '127.0.0.1';\n } else {\n // Fall back to local address\n return options.hostname || gateway.address;\n }\n};\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n const validProtocol = protocol ? `${protocol}://` : '';\n\n const url = `${validProtocol}${hostname}`;\n\n if (port) {\n return url + `:${port}`;\n }\n\n return url;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["UrlCreator","debug","require","constructor","defaults","bundlerInfo","gatewayInfo","getGateway","init","getGatewayAsync","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","hostType","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getDefaultRouteAddress","address","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","components","Log","warn","getDefaultHostname","parsedProxyUrl","gateway","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","assert","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":";;;;+BA4BaA;;;eAAAA;;;;gEA5BM;;;;;;;yBACC;;;;;;6DAEC;oBACoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzD,MAAMC,QAAQC,QAAQ,SAAS;AAsBxB,MAAMF;IACXG,YACE,AAAOC,QAA0B,EACjC,AAAQC,WAAwB,EAChC,AAAQC,cAA2BC,IAAAA,cAAU,GAAE,CAC/C;aAHOH,WAAAA;aACCC,cAAAA;aACAC,cAAAA;IACP;IAEH,aAAaE,KAAKJ,QAA6C,EAAEC,WAAwB,EAAE;QACzF,MAAMC,cAAc,MAAMG,IAAAA,mBAAe;QACzC,OAAO,IAAIT,WAAWI,YAAY,CAAC,GAAGC,aAAaC;IACrD;IAEA;;;;;;;;;GASC,GACD,AAAOI,oBAAoBC,OAAyB,EAAEC,QAAuB,EAAU;QACrF,MAAMC,MAAM,IAAIC,CAAAA,MAAE,KAAC,CAAC,iBAAiB,IAAI,CAACC,YAAY,CAAC;YAAEC,QAAQ;YAAQ,GAAGL,OAAO;QAAC;QACpF,IAAIC,UAAU;YACZC,IAAII,MAAM,GAAG,IAAIC,gBAAgB;gBAAEN;YAAS,GAAGO,QAAQ;QACzD;QACA,MAAMC,aAAaP,IAAIM,QAAQ;QAC/BlB,MAAM,CAAC,aAAa,EAAEmB,YAAY;QAClC,OAAOA;IACT;IAEA,wGAAwG,GACxG,AAAOC,sBAAsBV,OAA0B,EAAiB;YAClC,gBAe1B;QAfV,MAAMW,WAAWX,CAAAA,2BAAAA,QAASK,MAA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E;QACjE,+CAA+C;QAC/C,OAAO;IACT,OAAO;QACL,6BAA6B;QAC7B,OAAO5B,QAAQ4B,QAAQ,IAAIS,QAAQf,OAAO;IAC5C;AACF;AAEA,SAASF,kBAAkB,EAAET,QAAQ,EAAEiB,QAAQ,EAAED,IAAI,EAA0B;IAC7Ee,IAAAA,iBAAM,EAACd,UAAU;IACjB,MAAMe,gBAAgBhC,WAAW,GAAGA,SAAS,GAAG,CAAC,GAAG;IAEpD,MAAMT,MAAM,GAAGyC,gBAAgBf,UAAU;IAEzC,IAAID,MAAM;QACR,OAAOzB,MAAM,CAAC,CAAC,EAAEyB,MAAM;IACzB;IAEA,OAAOzB;AACT;AAEA,gBAAgB,GAChB,SAAS4B;IACP,OAAOQ,QAAQC,GAAG,CAACK,uBAAuB;AAC5C,EAEA,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
@@ -34,6 +34,13 @@ function _paths() {
34
34
  };
35
35
  return data;
36
36
  }
37
+ function _requireutils() {
38
+ const data = require("@expo/require-utils");
39
+ _requireutils = function() {
40
+ return data;
41
+ };
42
+ return data;
43
+ }
37
44
  function _fs() {
38
45
  const data = /*#__PURE__*/ _interop_require_default(require("fs"));
39
46
  _fs = function() {
@@ -48,13 +55,6 @@ function _path() {
48
55
  };
49
56
  return data;
50
57
  }
51
- function _requirefromstring() {
52
- const data = /*#__PURE__*/ _interop_require_default(require("require-from-string"));
53
- _requirefromstring = function() {
54
- return data;
55
- };
56
- return data;
57
- }
58
58
  const _metroErrorInterface = require("./metro/metroErrorInterface");
59
59
  const _metroOptions = require("./middleware/metroOptions");
60
60
  const _serverLogLikeMetro = require("./serverLogLikeMetro");
@@ -165,7 +165,7 @@ function evalMetroNoHandling(projectRoot, src, filename) {
165
165
  } else if (!(0, _filePath.toPosixPath)(_path().default.dirname(filename)).startsWith((0, _filePath.toPosixPath)(projectRoot))) {
166
166
  debug(`evalMetroNoHandling received filename outside of the project root: ${filename}`);
167
167
  }
168
- return (0, _profile.profile)(_requirefromstring().default, 'eval-metro-bundle')(src, filename);
168
+ return (0, _profile.profile)(_requireutils().evalModule, 'eval-metro-bundle')(src, filename);
169
169
  }
170
170
 
171
171
  //# sourceMappingURL=getStaticRenderFunctions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/getStaticRenderFunctions.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport fs from 'fs';\nimport path from 'path';\nimport requireString from 'require-from-string';\n\nimport { IS_METRO_BUNDLE_ERROR_SYMBOL, logMetroError } from './metro/metroErrorInterface';\nimport { createBundleUrlPath, ExpoMetroOptions } from './middleware/metroOptions';\nimport { augmentLogs } from './serverLogLikeMetro';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { toPosixPath } from '../../utils/filePath';\nimport { profile } from '../../utils/profile';\n\nconst debug = require('debug')('expo:start:server:getStaticRenderFunctions') as typeof console.log;\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport const cachedSourceMaps: Map<string, { url: string; map: string }> = new Map();\n\n// Support unhandled rejections\n\ndeclare global {\n namespace NodeJS {\n interface Process {\n isBun?: boolean;\n }\n }\n}\n\n// Detect if running in Bun\nif (!process.isBun) {\n require('source-map-support').install({\n retrieveSourceMap(source: string) {\n if (cachedSourceMaps.has(source)) {\n return cachedSourceMaps.get(source);\n }\n return null;\n },\n });\n}\n\nasync function ensureFileInRootDirectory(projectRoot: string, otherFile: string) {\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (!path.relative(projectRoot, otherFile).startsWith('..' + path.sep)) {\n return otherFile;\n }\n\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static-tmp');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, path.basename(otherFile));\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(otherFile, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n}\n\nexport async function createMetroEndpointAsync(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);\n const serverPath = path.relative(root, safeOtherFile).replace(/\\.[jt]sx?$/, '');\n\n const urlFragment = createBundleUrlPath({\n mainModuleName: serverPath,\n lazy: false,\n asyncRoutes: false,\n inlineSourceMap: false,\n engine: 'hermes',\n minify: false,\n bytecode: false,\n ...props,\n });\n\n let url: string;\n if (devServerUrl) {\n url = new URL(urlFragment.replace(/^\\//, ''), devServerUrl).toString();\n } else {\n url = '/' + urlFragment.replace(/^\\/+/, '');\n }\n return url;\n}\n\nexport function evalMetroAndWrapFunctions<T = Record<string, any>>(\n projectRoot: string,\n script: string,\n filename: string,\n isExporting: boolean\n): T {\n // TODO: Add back stack trace logic that hides traces from metro-runtime and other internal modules.\n const contents = evalMetroNoHandling(projectRoot, script, filename);\n\n if (!contents) {\n // This can happen if ErrorUtils isn't working correctly on web and failing to throw an error when a module throws.\n // This is unexpected behavior and should not be pretty formatted, therefore we're avoiding CommandError.\n throw new Error(\n '[Expo SSR] Module returned undefined, this could be due to a misconfiguration in Metro error handling'\n );\n }\n // wrap each function with a try/catch that uses Metro's error formatter\n return Object.keys(contents).reduce((acc, key) => {\n const fn = contents[key];\n if (typeof fn !== 'function') {\n return { ...acc, [key]: fn };\n }\n\n acc[key] = async function (...props: any[]) {\n try {\n return await fn.apply(this, props);\n } catch (error: any) {\n await logMetroError(projectRoot, { error });\n\n if (isExporting || error[IS_METRO_BUNDLE_ERROR_SYMBOL]) {\n throw error;\n } else {\n // TODO: When does this happen?\n throw new SilentError(error);\n }\n }\n };\n return acc;\n }, {} as any);\n}\n\nexport function evalMetroNoHandling(projectRoot: string, src: string, filename: string) {\n augmentLogs(projectRoot);\n\n // NOTE(@kitten): `require-from-string` derives a base path from the filename we pass it,\n // but doesn't validate that the filename exists. These debug messages should help identify\n // these problems, if they occur in user projects without reproductions\n if (!fs.existsSync(path.dirname(filename))) {\n debug(`evalMetroNoHandling received filename in a directory that does not exist: ${filename}`);\n } else if (!toPosixPath(path.dirname(filename)).startsWith(toPosixPath(projectRoot))) {\n debug(`evalMetroNoHandling received filename outside of the project root: ${filename}`);\n }\n\n return profile(requireString, 'eval-metro-bundle')(src, filename);\n}\n"],"names":["cachedSourceMaps","createMetroEndpointAsync","evalMetroAndWrapFunctions","evalMetroNoHandling","debug","require","Map","process","isBun","install","retrieveSourceMap","source","has","get","ensureFileInRootDirectory","projectRoot","otherFile","path","relative","startsWith","sep","tempDir","join","fs","promises","mkdir","recursive","moduleId","basename","writeFile","readFile","delayAsync","devServerUrl","absoluteFilePath","props","root","getMetroServerRoot","safeOtherFile","serverPath","replace","urlFragment","createBundleUrlPath","mainModuleName","lazy","asyncRoutes","inlineSourceMap","engine","minify","bytecode","url","URL","toString","script","filename","isExporting","contents","Error","Object","keys","reduce","acc","key","fn","apply","error","logMetroError","IS_METRO_BUNDLE_ERROR_SYMBOL","SilentError","src","augmentLogs","existsSync","dirname","toPosixPath","profile","requireString"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAmBYA,gBAAgB;eAAhBA;;IA0CSC,wBAAwB;eAAxBA;;IA8BNC,yBAAyB;eAAzBA;;IAyCAC,mBAAmB;eAAnBA;;;;yBAnImB;;;;;;;gEACpB;;;;;;;gEACE;;;;;;;gEACS;;;;;;qCAEkC;8BACN;oCAC1B;uBACD;wBACC;0BACA;yBACJ;;;;;;AAExB,MAAMC,QAAQC,QAAQ,SAAS;AAKxB,MAAML,mBAA8D,IAAIM;AAY/E,2BAA2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;QAC1CjD,MAAM,CAAC,0EAA0E,EAAEiD,UAAU;IAC/F,OAAO,IAAI,CAACmB,IAAAA,qBAAW,EAACvD,eAAI,CAACsD,OAAO,CAAClB,WAAWlC,UAAU,CAACqD,IAAAA,qBAAW,EAACzD,eAAe;QACpFX,MAAM,CAAC,mEAAmE,EAAEiD,UAAU;IACxF;IAEA,OAAOoB,IAAAA,gBAAO,EAACC,4BAAa,EAAE,qBAAqBN,KAAKf;AAC1D"}
1
+ {"version":3,"sources":["../../../../src/start/server/getStaticRenderFunctions.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { getMetroServerRoot } from '@expo/config/paths';\nimport { evalModule } from '@expo/require-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { IS_METRO_BUNDLE_ERROR_SYMBOL, logMetroError } from './metro/metroErrorInterface';\nimport { createBundleUrlPath, ExpoMetroOptions } from './middleware/metroOptions';\nimport { augmentLogs } from './serverLogLikeMetro';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { toPosixPath } from '../../utils/filePath';\nimport { profile } from '../../utils/profile';\n\nconst debug = require('debug')('expo:start:server:getStaticRenderFunctions') as typeof console.log;\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport const cachedSourceMaps: Map<string, { url: string; map: string }> = new Map();\n\n// Support unhandled rejections\n\ndeclare global {\n namespace NodeJS {\n interface Process {\n isBun?: boolean;\n }\n }\n}\n\n// Detect if running in Bun\nif (!process.isBun) {\n require('source-map-support').install({\n retrieveSourceMap(source: string) {\n if (cachedSourceMaps.has(source)) {\n return cachedSourceMaps.get(source);\n }\n return null;\n },\n });\n}\n\nasync function ensureFileInRootDirectory(projectRoot: string, otherFile: string) {\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (!path.relative(projectRoot, otherFile).startsWith('..' + path.sep)) {\n return otherFile;\n }\n\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static-tmp');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, path.basename(otherFile));\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(otherFile, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n}\n\nexport async function createMetroEndpointAsync(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);\n const serverPath = path.relative(root, safeOtherFile).replace(/\\.[jt]sx?$/, '');\n\n const urlFragment = createBundleUrlPath({\n mainModuleName: serverPath,\n lazy: false,\n asyncRoutes: false,\n inlineSourceMap: false,\n engine: 'hermes',\n minify: false,\n bytecode: false,\n ...props,\n });\n\n let url: string;\n if (devServerUrl) {\n url = new URL(urlFragment.replace(/^\\//, ''), devServerUrl).toString();\n } else {\n url = '/' + urlFragment.replace(/^\\/+/, '');\n }\n return url;\n}\n\nexport function evalMetroAndWrapFunctions<T = Record<string, any>>(\n projectRoot: string,\n script: string,\n filename: string,\n isExporting: boolean\n): T {\n // TODO: Add back stack trace logic that hides traces from metro-runtime and other internal modules.\n const contents = evalMetroNoHandling(projectRoot, script, filename);\n\n if (!contents) {\n // This can happen if ErrorUtils isn't working correctly on web and failing to throw an error when a module throws.\n // This is unexpected behavior and should not be pretty formatted, therefore we're avoiding CommandError.\n throw new Error(\n '[Expo SSR] Module returned undefined, this could be due to a misconfiguration in Metro error handling'\n );\n }\n // wrap each function with a try/catch that uses Metro's error formatter\n return Object.keys(contents).reduce((acc, key) => {\n const fn = contents[key];\n if (typeof fn !== 'function') {\n return { ...acc, [key]: fn };\n }\n\n acc[key] = async function (...props: any[]) {\n try {\n return await fn.apply(this, props);\n } catch (error: any) {\n await logMetroError(projectRoot, { error });\n\n if (isExporting || error[IS_METRO_BUNDLE_ERROR_SYMBOL]) {\n throw error;\n } else {\n // TODO: When does this happen?\n throw new SilentError(error);\n }\n }\n };\n return acc;\n }, {} as any);\n}\n\nexport function evalMetroNoHandling(projectRoot: string, src: string, filename: string) {\n augmentLogs(projectRoot);\n\n // NOTE(@kitten): `require-from-string` derives a base path from the filename we pass it,\n // but doesn't validate that the filename exists. These debug messages should help identify\n // these problems, if they occur in user projects without reproductions\n if (!fs.existsSync(path.dirname(filename))) {\n debug(`evalMetroNoHandling received filename in a directory that does not exist: ${filename}`);\n } else if (!toPosixPath(path.dirname(filename)).startsWith(toPosixPath(projectRoot))) {\n debug(`evalMetroNoHandling received filename outside of the project root: ${filename}`);\n }\n\n return profile(evalModule, 'eval-metro-bundle')(src, filename);\n}\n"],"names":["cachedSourceMaps","createMetroEndpointAsync","evalMetroAndWrapFunctions","evalMetroNoHandling","debug","require","Map","process","isBun","install","retrieveSourceMap","source","has","get","ensureFileInRootDirectory","projectRoot","otherFile","path","relative","startsWith","sep","tempDir","join","fs","promises","mkdir","recursive","moduleId","basename","writeFile","readFile","delayAsync","devServerUrl","absoluteFilePath","props","root","getMetroServerRoot","safeOtherFile","serverPath","replace","urlFragment","createBundleUrlPath","mainModuleName","lazy","asyncRoutes","inlineSourceMap","engine","minify","bytecode","url","URL","toString","script","filename","isExporting","contents","Error","Object","keys","reduce","acc","key","fn","apply","error","logMetroError","IS_METRO_BUNDLE_ERROR_SYMBOL","SilentError","src","augmentLogs","existsSync","dirname","toPosixPath","profile","evalModule"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAmBYA,gBAAgB;eAAhBA;;IA0CSC,wBAAwB;eAAxBA;;IA8BNC,yBAAyB;eAAzBA;;IAyCAC,mBAAmB;eAAnBA;;;;yBAnImB;;;;;;;yBACR;;;;;;;gEACZ;;;;;;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AAA,+BAAW,EAACtD;IAEZ,yFAAyF;IACzF,2FAA2F;IAC3F,uEAAuE;IACvE,IAAI,CAACQ,aAAE,CAAC+C,UAAU,CAACrD,eAAI,CAACsD,OAAO,CAAClB,YAAY;QAC1CjD,MAAM,CAAC,0EAA0E,EAAEiD,UAAU;IAC/F,OAAO,IAAI,CAACmB,IAAAA,qBAAW,EAACvD,eAAI,CAACsD,OAAO,CAAClB,WAAWlC,UAAU,CAACqD,IAAAA,qBAAW,EAACzD,eAAe;QACpFX,MAAM,CAAC,mEAAmE,EAAEiD,UAAU;IACxF;IAEA,OAAOoB,IAAAA,gBAAO,EAACC,0BAAU,EAAE,qBAAqBN,KAAKf;AACvD"}
@@ -27,13 +27,6 @@ function _paths() {
27
27
  };
28
28
  return data;
29
29
  }
30
- function _env() {
31
- const data = /*#__PURE__*/ _interop_require_wildcard(require("@expo/env"));
32
- _env = function() {
33
- return data;
34
- };
35
- return data;
36
- }
37
30
  function _baseJSBundle() {
38
31
  const data = /*#__PURE__*/ _interop_require_default(require("@expo/metro/metro/DeltaBundler/Serializers/baseJSBundle"));
39
32
  _baseJSBundle = function() {
@@ -76,6 +69,13 @@ function _chalk() {
76
69
  };
77
70
  return data;
78
71
  }
72
+ function _private() {
73
+ const data = require("expo-server/private");
74
+ _private = function() {
75
+ return data;
76
+ };
77
+ return data;
78
+ }
79
79
  function _path() {
80
80
  const data = /*#__PURE__*/ _interop_require_default(require("path"));
81
81
  _path = function() {
@@ -93,9 +93,10 @@ const _router = require("./router");
93
93
  const _serializeHtml = require("./serializeHtml");
94
94
  const _waitForMetroToObserveTypeScriptFile = require("./waitForMetroToObserveTypeScriptFile");
95
95
  const _log = require("../../../log");
96
- const _env1 = require("../../../utils/env");
96
+ const _env = require("../../../utils/env");
97
97
  const _errors = require("../../../utils/errors");
98
98
  const _filePath = require("../../../utils/filePath");
99
+ const _nodeEnv = require("../../../utils/nodeEnv");
99
100
  const _port = require("../../../utils/port");
100
101
  const _BundlerDevServer = require("../BundlerDevServer");
101
102
  const _getStaticRenderFunctions = require("../getStaticRenderFunctions");
@@ -413,14 +414,14 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
413
414
  platform
414
415
  });
415
416
  return await this.metroImportAsArtifactsAsync(resolvedMainModuleName, {
416
- splitChunks: isExporting && !_env1.env.EXPO_NO_BUNDLE_SPLITTING,
417
+ splitChunks: isExporting && !_env.env.EXPO_NO_BUNDLE_SPLITTING,
417
418
  platform,
418
419
  mode,
419
420
  minify,
420
421
  environment: 'client',
421
422
  serializerIncludeMaps: includeSourceMaps,
422
423
  mainModuleName: resolvedMainModuleName,
423
- lazy: !_env1.env.EXPO_NO_METRO_LAZY,
424
+ lazy: !_env.env.EXPO_NO_METRO_LAZY,
424
425
  asyncRoutes,
425
426
  baseUrl,
426
427
  isExporting,
@@ -438,7 +439,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
438
439
  (0, _assert().default)(mode != null && isExporting != null && baseUrl != null && reactCompiler != null && routerRoot != null && asyncRoutes != null, 'The server must be started before calling getStaticPageAsync.');
439
440
  const platform = 'web';
440
441
  const devBundleUrlPathname = (0, _metroOptions.createBundleUrlPath)({
441
- splitChunks: isExporting && !_env1.env.EXPO_NO_BUNDLE_SPLITTING,
442
+ splitChunks: isExporting && !_env.env.EXPO_NO_BUNDLE_SPLITTING,
442
443
  platform,
443
444
  mode,
444
445
  environment: 'client',
@@ -446,7 +447,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
446
447
  mainModuleName: (0, _ManifestMiddleware.resolveMainModuleName)(this.projectRoot, {
447
448
  platform
448
449
  }),
449
- lazy: !_env1.env.EXPO_NO_METRO_LAZY,
450
+ lazy: !_env.env.EXPO_NO_METRO_LAZY,
450
451
  baseUrl,
451
452
  isExporting,
452
453
  asyncRoutes,
@@ -478,9 +479,11 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
478
479
  return await getStaticContent(location);
479
480
  }
480
481
  const loaderData = await loaderResult.json();
482
+ const resolvedLoaderKey = (0, _private().resolveLoaderContextKey)(resolvedLoaderRoute.contextKey, resolvedLoaderRoute.params);
481
483
  return await getStaticContent(location, {
482
484
  loader: {
483
- data: loaderData
485
+ data: loaderData,
486
+ key: resolvedLoaderKey
484
487
  }
485
488
  });
486
489
  };
@@ -496,7 +499,7 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
496
499
  template: staticHtml,
497
500
  devBundleUrl: devBundleUrlPathname,
498
501
  baseUrl,
499
- hydrate: _env1.env.EXPO_WEB_DEV_HYDRATE
502
+ hydrate: _env.env.EXPO_WEB_DEV_HYDRATE
500
503
  });
501
504
  return {
502
505
  content,
@@ -780,22 +783,19 @@ class MetroBundlerDevServer extends _BundlerDevServer.BundlerDevServer {
780
783
  debug('Skipping Environment Variable observation because Metro is not running (headless).');
781
784
  return;
782
785
  }
783
- const envFiles = _env().getFiles(process.env.NODE_ENV).map((fileName)=>_path().default.join(this.projectRoot, fileName));
784
786
  (0, _waitForMetroToObserveTypeScriptFile.observeFileChanges)({
785
787
  metro: this.metro,
786
788
  server: this.instance.server
787
- }, envFiles, ()=>{
789
+ }, (0, _nodeEnv.getEnvFiles)(this.projectRoot), ()=>{
788
790
  debug('Reloading environment variables...');
789
791
  // Force reload the environment variables.
790
- _env().load(this.projectRoot, {
791
- force: true
792
- });
792
+ (0, _nodeEnv.reloadEnvFiles)(this.projectRoot);
793
793
  });
794
794
  }
795
795
  async startImplementationAsync(options) {
796
796
  var _exp_experiments, _exp_experiments1, _exp_experiments2, _exp_experiments3, _exp_experiments4, _exp_web, _exp_web1, _exp_experiments5, _exp_extra, _exp_web2, _exp_extra_router, _exp_extra1;
797
797
  options.port = await this.resolvePortAsync(options);
798
- this.urlCreator = this.getUrlCreator(options);
798
+ await this.initUrlCreator(options);
799
799
  const config = (0, _config().getConfig)(this.projectRoot, {
800
800
  skipSDKVersionRequirement: true
801
801
  });