@expo/cli 0.7.1 → 0.8.0

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 (179) hide show
  1. package/README.md +1 -1
  2. package/build/bin/cli +12 -3
  3. package/build/bin/cli.map +1 -1
  4. package/build/src/api/getExpoGoIntermediateCertificate.js +0 -2
  5. package/build/src/api/getExpoGoIntermediateCertificate.js.map +1 -1
  6. package/build/src/api/getProjectDevelopmentCertificate.js +0 -2
  7. package/build/src/api/getProjectDevelopmentCertificate.js.map +1 -1
  8. package/build/src/api/graphql/queries/AppQuery.js +39 -0
  9. package/build/src/api/graphql/queries/AppQuery.js.map +1 -0
  10. package/build/src/api/graphql/queries/UserQuery.js +10 -3
  11. package/build/src/api/graphql/queries/UserQuery.js.map +1 -1
  12. package/build/src/api/graphql/types/App.js +23 -0
  13. package/build/src/api/graphql/types/App.js.map +1 -0
  14. package/build/src/api/signManifest.js +0 -12
  15. package/build/src/api/signManifest.js.map +1 -1
  16. package/build/src/api/user/UserSettings.js.map +1 -1
  17. package/build/src/api/user/user.js.map +1 -1
  18. package/build/src/config/configAsync.js +3 -0
  19. package/build/src/config/configAsync.js.map +1 -1
  20. package/build/src/customize/customizeAsync.js +3 -0
  21. package/build/src/customize/customizeAsync.js.map +1 -1
  22. package/build/src/export/createBundles.js +7 -3
  23. package/build/src/export/createBundles.js.map +1 -1
  24. package/build/src/export/embed/exportEmbedAsync.js +24 -0
  25. package/build/src/export/embed/exportEmbedAsync.js.map +1 -0
  26. package/build/src/export/embed/index.js +117 -0
  27. package/build/src/export/embed/index.js.map +1 -0
  28. package/build/src/export/embed/resolveOptions.js +63 -0
  29. package/build/src/export/embed/resolveOptions.js.map +1 -0
  30. package/build/src/export/exportApp.js +56 -29
  31. package/build/src/export/exportApp.js.map +1 -1
  32. package/build/src/export/exportAssets.js +17 -0
  33. package/build/src/export/exportAssets.js.map +1 -1
  34. package/build/src/export/exportAsync.js +3 -0
  35. package/build/src/export/exportAsync.js.map +1 -1
  36. package/build/src/export/exportStaticAsync.js +179 -0
  37. package/build/src/export/exportStaticAsync.js.map +1 -0
  38. package/build/src/export/fork-bundleAsync.js +15 -42
  39. package/build/src/export/fork-bundleAsync.js.map +1 -1
  40. package/build/src/export/html.js +21 -0
  41. package/build/src/export/html.js.map +1 -0
  42. package/build/src/export/printBundleSizes.js +2 -2
  43. package/build/src/export/printBundleSizes.js.map +1 -1
  44. package/build/src/export/web/exportWebAsync.js +3 -0
  45. package/build/src/export/web/exportWebAsync.js.map +1 -1
  46. package/build/src/export/writeContents.js +5 -2
  47. package/build/src/export/writeContents.js.map +1 -1
  48. package/build/src/graphql/generated.js +462 -0
  49. package/build/src/graphql/generated.js.map +1 -0
  50. package/build/src/install/installAsync.js +3 -0
  51. package/build/src/install/installAsync.js.map +1 -1
  52. package/build/src/prebuild/clearNativeFolder.js +6 -1
  53. package/build/src/prebuild/clearNativeFolder.js.map +1 -1
  54. package/build/src/prebuild/ensureConfigAsync.js +1 -12
  55. package/build/src/prebuild/ensureConfigAsync.js.map +1 -1
  56. package/build/src/prebuild/prebuildAsync.js +7 -2
  57. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  58. package/build/src/prebuild/resolveOptions.js +7 -8
  59. package/build/src/prebuild/resolveOptions.js.map +1 -1
  60. package/build/src/prebuild/resolveTemplate.js +5 -0
  61. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  62. package/build/src/prebuild/updateFromTemplate.js +6 -1
  63. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  64. package/build/src/prebuild/validateTemplatePlatforms.js +48 -0
  65. package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -0
  66. package/build/src/run/android/runAndroidAsync.js +4 -0
  67. package/build/src/run/android/runAndroidAsync.js.map +1 -1
  68. package/build/src/run/ios/appleDevice/AppleDevice.js +25 -19
  69. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  70. package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -1
  71. package/build/src/run/ios/options/resolveNativeScheme.js +13 -4
  72. package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -1
  73. package/build/src/run/ios/runIosAsync.js +3 -0
  74. package/build/src/run/ios/runIosAsync.js.map +1 -1
  75. package/build/src/run/startBundler.js +4 -0
  76. package/build/src/run/startBundler.js.map +1 -1
  77. package/build/src/start/doctor/Prerequisite.js.map +1 -1
  78. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +12 -6
  79. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  80. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +1 -3
  81. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  82. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +31 -5
  83. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
  84. package/build/src/start/doctor/typescript/updateTSConfig.js +6 -0
  85. package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
  86. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +1 -0
  87. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
  88. package/build/src/start/platforms/android/adb.js +1 -1
  89. package/build/src/start/platforms/android/adb.js.map +1 -1
  90. package/build/src/start/platforms/ios/AppleDeviceManager.js +1 -1
  91. package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
  92. package/build/src/start/server/BundlerDevServer.js +16 -2
  93. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  94. package/build/src/start/server/DevServerManager.js +33 -2
  95. package/build/src/start/server/DevServerManager.js.map +1 -1
  96. package/build/src/start/server/getStaticRenderFunctions.js +166 -0
  97. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -0
  98. package/build/src/start/server/metro/MetroBundlerDevServer.js +279 -3
  99. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  100. package/build/src/start/server/metro/MetroTerminalReporter.js +2 -34
  101. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  102. package/build/src/start/server/metro/externals.js +95 -0
  103. package/build/src/start/server/metro/externals.js.map +1 -0
  104. package/build/src/start/server/metro/getCssModulesFromBundler.js +77 -0
  105. package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -0
  106. package/build/src/start/server/metro/inspector-proxy/index.js +2 -2
  107. package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
  108. package/build/src/start/server/metro/inspector-proxy/proxy.js +1 -3
  109. package/build/src/start/server/metro/inspector-proxy/proxy.js.map +1 -1
  110. package/build/src/start/server/metro/instantiateMetro.js +44 -48
  111. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  112. package/build/src/start/server/metro/metroErrorInterface.js +114 -0
  113. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -0
  114. package/build/src/start/server/metro/metroWatchTypeScriptFiles.js +51 -0
  115. package/build/src/start/server/metro/metroWatchTypeScriptFiles.js.map +1 -0
  116. package/build/src/start/server/metro/resolveFromProject.js +26 -3
  117. package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
  118. package/build/src/start/server/metro/router.js +4 -0
  119. package/build/src/start/server/metro/router.js.map +1 -1
  120. package/build/src/start/server/metro/runServer-fork.js +108 -0
  121. package/build/src/start/server/metro/runServer-fork.js.map +1 -0
  122. package/build/src/start/server/metro/symbolicate.js +6 -0
  123. package/build/src/start/server/metro/symbolicate.js.map +1 -0
  124. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +70 -0
  125. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -0
  126. package/build/src/start/server/metro/withMetroMultiPlatform.js +181 -44
  127. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  128. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +8 -1
  129. package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
  130. package/build/src/start/server/middleware/CreateFileMiddleware.js.map +1 -1
  131. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +38 -32
  132. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
  133. package/build/src/start/server/middleware/ManifestMiddleware.js +53 -19
  134. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  135. package/build/src/start/server/type-generation/expo-env.js +27 -0
  136. package/build/src/start/server/type-generation/expo-env.js.map +1 -0
  137. package/build/src/start/server/type-generation/index.js +49 -0
  138. package/build/src/start/server/type-generation/index.js.map +1 -0
  139. package/build/src/start/server/type-generation/routes.js +292 -0
  140. package/build/src/start/server/type-generation/routes.js.map +1 -0
  141. package/build/src/start/server/type-generation/tsconfig.js +89 -0
  142. package/build/src/start/server/type-generation/tsconfig.js.map +1 -0
  143. package/build/src/start/server/webTemplate.js +20 -4
  144. package/build/src/start/server/webTemplate.js.map +1 -1
  145. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +4 -6
  146. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  147. package/build/src/start/startAsync.js +30 -8
  148. package/build/src/start/startAsync.js.map +1 -1
  149. package/build/src/utils/FileNotifier.js +11 -4
  150. package/build/src/utils/FileNotifier.js.map +1 -1
  151. package/build/src/utils/analytics/getMetroProperties.js +1 -1
  152. package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
  153. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  154. package/build/src/utils/codesigning.js +31 -7
  155. package/build/src/utils/codesigning.js.map +1 -1
  156. package/build/src/utils/env.js +3 -0
  157. package/build/src/utils/env.js.map +1 -1
  158. package/build/src/utils/mergeGitIgnorePaths.js +42 -0
  159. package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
  160. package/build/src/utils/nodeEnv.js +11 -0
  161. package/build/src/utils/nodeEnv.js.map +1 -0
  162. package/build/src/utils/resolveArgs.js +43 -0
  163. package/build/src/utils/resolveArgs.js.map +1 -1
  164. package/build/src/utils/template.js +21 -0
  165. package/build/src/utils/template.js.map +1 -0
  166. package/build/src/utils/tsconfig/evaluateTsConfig.js +61 -0
  167. package/build/src/utils/tsconfig/evaluateTsConfig.js.map +1 -0
  168. package/build/src/utils/tsconfig/loadTsConfigPaths.js +69 -0
  169. package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -0
  170. package/build/src/utils/tsconfig/matchTsConfigPathAlias.js +88 -0
  171. package/build/src/utils/tsconfig/matchTsConfigPathAlias.js.map +1 -0
  172. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +41 -0
  173. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -0
  174. package/package.json +16 -8
  175. package/static/template/metro.config.js +4 -1
  176. package/build/src/api/getProject.js +0 -19
  177. package/build/src/api/getProject.js.map +0 -1
  178. package/build/src/api/graphql/generated.js +0 -113
  179. package/build/src/api/graphql/generated.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import { MessageSocket } from '@expo/dev-server';\nimport assert from 'assert';\nimport openBrowserAsync from 'better-opn';\nimport resolveFrom from 'resolve-from';\n\nimport { APISettings } from '../../api/settings';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\nimport { AsyncNgrok } from './AsyncNgrok';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\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 /** Which manifest type to serve. */\n forceManifestType?: 'expo-updates' | 'classic';\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 // 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\nconst MIDDLEWARES = {\n classic: () =>\n require('./middleware/ClassicManifestMiddleware')\n .ClassicManifestMiddleware as typeof import('./middleware/ClassicManifestMiddleware').ClassicManifestMiddleware,\n 'expo-updates': () =>\n require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Ngrok instance for managing tunnel connections. */\n protected ngrok: AsyncNgrok | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n // TODO: Replace with custom scheme maybe...\n public isDevClient?: boolean\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<\n BundlerStartOptions,\n 'minify' | 'mode' | 'forceManifestType' | 'privateKeyPath'\n > = {}\n ) {\n const manifestType = options.forceManifestType || 'classic';\n assert(manifestType in MIDDLEWARES, `Manifest middleware for type '${manifestType}' not found`);\n const Middleware = MIDDLEWARES[manifestType]();\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.getHandler();\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 /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: () => {\n this.instance = null;\n },\n },\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 !APISettings.isOffline &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n }\n await this.startDevSessionAsync();\n\n this.watchConfig();\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n this.notifier?.stopObserving();\n this.notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n this.notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[ngrok] connect to port: ' + port);\n this.ngrok = new AsyncNgrok(this.projectRoot, port);\n await this.ngrok.startAsync();\n return this.ngrok;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n this.devSession?.stopNotifying?.();\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' }),\n () => {\n // TODO: This appears to be happening consistently after an hour.\n // We should investigate why this is happening and fix it on our servers.\n // Log.error(\n // chalk.red(\n // '\\nAn unexpected error occurred while updating the Dev Session API. This project will not appear in the \"Development servers\" section of the Expo Go app until this process has been restarted.'\n // )\n // );\n // Log.exception(error);\n this.devSession?.closeAsync().catch((error) => {\n debug('[dev-session] error closing: ' + error.message);\n });\n }\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop file watching.\n this.notifier?.stopObserving();\n\n // Stop the dev session timer and tell Expo API to remove dev session.\n await this.devSession?.closeAsync();\n\n // Stop ngrok if running.\n await this.ngrok?.stopAsync().catch((e) => {\n Log.error(`Error stopping ngrok:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n protected getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl()\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n return location.url ?? null;\n }\n\n /** Get the base URL for JS inspector */\n public getJsInspectorBaseUrl(): string {\n if (this.name !== 'metro') {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the JS inspector base url - bundler[${this.name}]`\n );\n }\n return this.getUrlCreator().constructUrl({ scheme: 'http' });\n }\n\n /** Get the tunnel URL from ngrok. */\n public getTunnelUrl(): string | null {\n return this.ngrok?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const serverUrl = this.getDevServerUrl({ hostType: 'localhost' });\n // Allow opening the tunnel URL when using Metro web.\n const url = this.name === 'metro' ? this.getTunnelUrl() ?? serverUrl : serverUrl;\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<BaseOpenInCustomProps> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(): string {\n return this.getUrlCreator().constructUrl({ scheme: 'exp' });\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected isRedirectPageEnabled(): boolean {\n return (\n !env.EXPO_NO_REDIRECT_PAGE &&\n // if user passed --dev-client flag, skip interstitial page\n !this.isDevClient &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-client')\n );\n }\n\n /** Get the redirect URL when redirecting is enabled. */\n public getRedirectUrl(platform: keyof typeof PLATFORM_MANAGERS | null = null): string | null {\n if (!this.isRedirectPageEnabled()) {\n debug('Redirect page is disabled');\n return null;\n }\n\n return (\n this.getUrlCreator().constructLoadingUrl(\n {},\n platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null\n ) ?? null\n );\n }\n\n public getReactDevToolsUrl(): string {\n return new URL(\n '_expo/react-devtools',\n this.getUrlCreator().constructUrl({ scheme: 'http' })\n ).toString();\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this),\n getRedirectUrl: this.getRedirectUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["Log","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","MIDDLEWARES","classic","ClassicManifestMiddleware","ExpoGoManifestHandlerMiddleware","BundlerDevServer","constructor","projectRoot","platformBundlers","isDevClient","ngrok","devSession","instance","platformManagers","urlCreator","notifier","setInstance","getManifestMiddlewareAsync","options","manifestType","forceManifestType","assert","Middleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","getHandler","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","port","CommandError","server","close","location","host","url","protocol","messageSocket","broadcast","hostType","APISettings","isOffline","_startTunnelAsync","startDevSessionAsync","watchConfig","stopObserving","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncNgrok","stopNotifying","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","closeAsync","catch","error","message","runtime","isTargetingWeb","web","broadcastMessage","method","params","e","exception","resolveWithTimeout","Promise","resolve","reject","timeout","errorMessage","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getJsInspectorBaseUrl","getActiveUrl","openPlatformAsync","launchTarget","resolver","serverUrl","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","getExpoGoUrl","isRedirectPageEnabled","env","EXPO_NO_REDIRECT_PAGE","resolveFrom","silent","getRedirectUrl","platform","constructLoadingUrl","getReactDevToolsUrl","URL","toString","Manager","getCustomRuntimeUrl"],"mappings":"AAAA;;;;AACmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACE,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACjB,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEV,IAAA,SAAoB,WAApB,oBAAoB,CAAA;AACpCA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACc,IAAA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G,CAAA,GAAkB,GAAlB,IAAI,CAACoB,WAAW,EAAE,SAAU,GAA5B,KAAA,CAA4B,GAA5B,GAAkB,CAAEhB,QAAQ,CAACJ,IAAI,AAAC;YAC/C,IAAI,CAACA,IAAI,IAAI,CAAC,IAAI,CAAC1B,UAAU,EAAE;gBAC7B,MAAM,IAAI2B,OAAY,aAAA,CACpB,YAAY,EACZ,oEAAoE,CACrE,CAAC;aACH;YACD/C,KAAK,CAAC,CAAC,qCAAqC,EAAEmH,QAAQ,CAAC,QAAQ,EAAErE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1E,IAAI,CAAC3B,gBAAgB,CAACgG,QAAQ,CAAC,GAAG,IAAIK,OAAO,CAAC,IAAI,CAAC3G,WAAW,EAAEiC,IAAI,EAAE;gBACpE2E,mBAAmB,EAAE,IAAI,CAACrG,UAAU,CAACyE,qBAAqB,CAAC7D,IAAI,CAAC,IAAI,CAACZ,UAAU,CAAC;gBAChFwF,YAAY,EAAE,IAAI,CAACA,YAAY,CAAC5E,IAAI,CAAC,IAAI,CAAC;gBAC1CkF,cAAc,EAAE,IAAI,CAACA,cAAc,CAAClF,IAAI,CAAC,IAAI,EAAEmF,QAAQ,CAAC;gBACxD5C,eAAe,EAAE,IAAI,CAACA,eAAe,CAACvC,IAAI,CAAC,IAAI,EAAE;oBAAEwB,QAAQ,EAAE,WAAW;iBAAE,CAAC;aAC5E,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAACrC,gBAAgB,CAACgG,QAAQ,CAAC,CAAC;KACxC;CACF;QA/XqBxG,gBAAgB,GAAhBA,gBAAgB"}
1
+ {"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import { MessageSocket } from '@expo/dev-server';\nimport assert from 'assert';\nimport openBrowserAsync from 'better-opn';\nimport resolveFrom from 'resolve-from';\n\nimport { APISettings } from '../../api/settings';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\nimport { AsyncNgrok } from './AsyncNgrok';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\nimport { typescriptTypeGeneration } from './type-generation';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\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 /** Which manifest type to serve. */\n forceManifestType?: 'expo-updates' | 'classic';\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 // 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\nconst MIDDLEWARES = {\n classic: () =>\n require('./middleware/ClassicManifestMiddleware')\n .ClassicManifestMiddleware as typeof import('./middleware/ClassicManifestMiddleware').ClassicManifestMiddleware,\n 'expo-updates': () =>\n require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Ngrok instance for managing tunnel connections. */\n protected ngrok: AsyncNgrok | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n // TODO: Replace with custom scheme maybe...\n public isDevClient?: boolean\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<\n BundlerStartOptions,\n 'minify' | 'mode' | 'forceManifestType' | 'privateKeyPath'\n > = {}\n ) {\n const manifestType = options.forceManifestType || 'classic';\n assert(manifestType in MIDDLEWARES, `Manifest middleware for type '${manifestType}' not found`);\n const Middleware = MIDDLEWARES[manifestType]();\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 async startTypeScriptServices(): Promise<void> {\n return typescriptTypeGeneration({\n server: this.instance!.server,\n projectRoot: this.projectRoot,\n });\n }\n\n public async watchEnvironmentVariables(): Promise<void> {\n // noop -- We've only implemented this functionality in Metro.\n }\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: () => {\n this.instance = null;\n },\n addListener() {},\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n /**\n * Runs after the `startAsync` function, performing any additional common operations.\n * You can assume the dev server is started by the time this function is called.\n */\n protected async postStartAsync(options: BundlerStartOptions) {\n if (\n options.location.hostType === 'tunnel' &&\n !APISettings.isOffline &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n }\n await this.startDevSessionAsync();\n\n this.watchConfig();\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n this.notifier?.stopObserving();\n this.notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n this.notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[ngrok] connect to port: ' + port);\n this.ngrok = new AsyncNgrok(this.projectRoot, port);\n await this.ngrok.startAsync();\n return this.ngrok;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n this.devSession?.stopNotifying?.();\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' }),\n () => {\n // TODO: This appears to be happening consistently after an hour.\n // We should investigate why this is happening and fix it on our servers.\n // Log.error(\n // chalk.red(\n // '\\nAn unexpected error occurred while updating the Dev Session API. This project will not appear in the \"Development servers\" section of the Expo Go app until this process has been restarted.'\n // )\n // );\n // Log.exception(error);\n this.devSession?.closeAsync().catch((error) => {\n debug('[dev-session] error closing: ' + error.message);\n });\n }\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop file watching.\n this.notifier?.stopObserving();\n\n // Stop the dev session timer and tell Expo API to remove dev session.\n await this.devSession?.closeAsync();\n\n // Stop ngrok if running.\n await this.ngrok?.stopAsync().catch((e) => {\n Log.error(`Error stopping ngrok:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n protected getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl()\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n return location.url ?? null;\n }\n\n /** Get the base URL for JS inspector */\n public getJsInspectorBaseUrl(): string {\n if (this.name !== 'metro') {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the JS inspector base url - bundler[${this.name}]`\n );\n }\n return this.getUrlCreator().constructUrl({ scheme: 'http' });\n }\n\n /** Get the tunnel URL from ngrok. */\n public getTunnelUrl(): string | null {\n return this.ngrok?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const serverUrl = this.getDevServerUrl({ hostType: 'localhost' });\n // Allow opening the tunnel URL when using Metro web.\n const url = this.name === 'metro' ? this.getTunnelUrl() ?? serverUrl : serverUrl;\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<BaseOpenInCustomProps> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(): string {\n return this.getUrlCreator().constructUrl({ scheme: 'exp' });\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected isRedirectPageEnabled(): boolean {\n return (\n !env.EXPO_NO_REDIRECT_PAGE &&\n // if user passed --dev-client flag, skip interstitial page\n !this.isDevClient &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-client')\n );\n }\n\n /** Get the redirect URL when redirecting is enabled. */\n public getRedirectUrl(platform: keyof typeof PLATFORM_MANAGERS | null = null): string | null {\n if (!this.isRedirectPageEnabled()) {\n debug('Redirect page is disabled');\n return null;\n }\n\n return (\n this.getUrlCreator().constructLoadingUrl(\n {},\n platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null\n ) ?? null\n );\n }\n\n public getReactDevToolsUrl(): string {\n return new URL(\n '_expo/react-devtools',\n this.getUrlCreator().constructUrl({ scheme: 'http' })\n ).toString();\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this),\n getRedirectUrl: this.getRedirectUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["Log","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","MIDDLEWARES","classic","ClassicManifestMiddleware","ExpoGoManifestHandlerMiddleware","BundlerDevServer","constructor","projectRoot","platformBundlers","isDevClient","ngrok","devSession","instance","platformManagers","urlCreator","notifier","setInstance","getManifestMiddlewareAsync","options","manifestType","forceManifestType","assert","Middleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","waitForTypeScriptAsync","startTypeScriptServices","typescriptTypeGeneration","server","watchEnvironmentVariables","port","CommandError","close","addListener","location","host","url","protocol","messageSocket","broadcast","hostType","APISettings","isOffline","_startTunnelAsync","startDevSessionAsync","watchConfig","stopObserving","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncNgrok","stopNotifying","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","closeAsync","catch","error","message","runtime","isTargetingWeb","web","broadcastMessage","method","params","e","exception","resolveWithTimeout","Promise","resolve","reject","timeout","errorMessage","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getJsInspectorBaseUrl","getActiveUrl","openPlatformAsync","launchTarget","resolver","serverUrl","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","getExpoGoUrl","isRedirectPageEnabled","env","EXPO_NO_REDIRECT_PAGE","resolveFrom","silent","getRedirectUrl","platform","constructLoadingUrl","getReactDevToolsUrl","URL","toString","Manager","getCustomRuntimeUrl"],"mappings":"AAAA;;;;AACmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACE,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACjB,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEV,IAAA,SAAoB,WAApB,oBAAoB,CAAA;AACpCA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACc,IAAA,aAA0B,WAA1B,0BAA0B,CAAA;AACpB,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AAClC,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AACR,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AAMtB,IAAA,WAAc,WAAd,cAAc,CAAA;AACN,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACZ,IAAA,WAAc,WAAd,cAAc,CAAA;AAElB,IAAA,eAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5D,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,6BAA6B,CAAC,AAAsB,AAAC;AAsDpF,MAAMC,iBAAiB,GAAG;IACxBC,SAAS,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CAAEhB,QAAQ,CAACJ,IAAI,AAAC;YAC/C,IAAI,CAACA,IAAI,IAAI,CAAC,IAAI,CAAC9B,UAAU,EAAE;gBAC7B,MAAM,IAAI+B,OAAY,aAAA,CACpB,YAAY,EACZ,oEAAoE,CACrE,CAAC;aACH;YACDnD,KAAK,CAAC,CAAC,qCAAqC,EAAEuH,QAAQ,CAAC,QAAQ,EAAErE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1E,IAAI,CAAC/B,gBAAgB,CAACoG,QAAQ,CAAC,GAAG,IAAIK,OAAO,CAAC,IAAI,CAAC/G,WAAW,EAAEqC,IAAI,EAAE;gBACpE2E,mBAAmB,EAAE,IAAI,CAACzG,UAAU,CAAC6E,qBAAqB,CAACjE,IAAI,CAAC,IAAI,CAACZ,UAAU,CAAC;gBAChF4F,YAAY,EAAE,IAAI,CAACA,YAAY,CAAChF,IAAI,CAAC,IAAI,CAAC;gBAC1CsF,cAAc,EAAE,IAAI,CAACA,cAAc,CAACtF,IAAI,CAAC,IAAI,EAAEuF,QAAQ,CAAC;gBACxD5C,eAAe,EAAE,IAAI,CAACA,eAAe,CAAC3C,IAAI,CAAC,IAAI,EAAE;oBAAE4B,QAAQ,EAAE,WAAW;iBAAE,CAAC;aAC5E,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAACzC,gBAAgB,CAACoG,QAAQ,CAAC,CAAC;KACxC;CACF;QA/YqB5G,gBAAgB,GAAhBA,gBAAgB"}
@@ -7,6 +7,8 @@ var _assert = _interopRequireDefault(require("assert"));
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _fileNotifier = require("../../utils/FileNotifier");
9
9
  var _rudderstackClient = require("../../utils/analytics/rudderstackClient");
10
+ var _env = require("../../utils/env");
11
+ var _typeScriptProjectPrerequisite = require("../doctor/typescript/TypeScriptProjectPrerequisite");
10
12
  var AndroidDebugBridge = _interopRequireWildcard(require("../platforms/android/adb"));
11
13
  var _platformBundlers = require("./platformBundlers");
12
14
  function _interopRequireDefault(obj) {
@@ -70,7 +72,7 @@ class DevServerManager {
70
72
  prerequisite1 = new PrerequisiteClass(this.projectRoot);
71
73
  this.projectPrerequisites.push(prerequisite1);
72
74
  }
73
- await prerequisite1.assertAsync();
75
+ return await prerequisite1.assertAsync();
74
76
  }
75
77
  /**
76
78
  * Sends a message over web sockets to all connected devices,
@@ -123,7 +125,9 @@ class DevServerManager {
123
125
  ]);
124
126
  }
125
127
  /** Start all dev servers. */ async startAsync(startOptions) {
126
- const { exp } = (0, _config).getConfig(this.projectRoot);
128
+ const { exp } = (0, _config).getConfig(this.projectRoot, {
129
+ skipSDKVersionRequirement: true
130
+ });
127
131
  var _sdkVersion;
128
132
  await (0, _rudderstackClient).logEventAsync("Start Project", {
129
133
  sdkVersion: (_sdkVersion = exp.sdkVersion) != null ? _sdkVersion : null
@@ -138,6 +142,33 @@ class DevServerManager {
138
142
  }
139
143
  return exp;
140
144
  }
145
+ async bootstrapTypeScriptAsync() {
146
+ const typescriptPrerequisite = await this.ensureProjectPrerequisiteAsync(_typeScriptProjectPrerequisite.TypeScriptProjectPrerequisite);
147
+ if (_env.env.EXPO_NO_TYPESCRIPT_SETUP) {
148
+ return;
149
+ }
150
+ // Optionally, wait for the user to add TypeScript during the
151
+ // development cycle.
152
+ const server5 = devServers.find((server)=>server.name === "metro"
153
+ );
154
+ if (!server5) {
155
+ return;
156
+ }
157
+ if (!typescriptPrerequisite) {
158
+ server5.waitForTypeScriptAsync().then(async (success)=>{
159
+ if (success) {
160
+ await server5.startTypeScriptServices();
161
+ }
162
+ });
163
+ } else {
164
+ server5.startTypeScriptServices();
165
+ }
166
+ }
167
+ async watchEnvironmentVariables() {
168
+ var ref;
169
+ await ((ref = devServers.find((server)=>server.name === "metro"
170
+ )) == null ? void 0 : ref.watchEnvironmentVariables());
171
+ }
141
172
  /** Stop all servers including ADB. */ async stopAsync() {
142
173
  var ref;
143
174
  await Promise.allSettled([
@@ -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 { FileNotifier } from '../../utils/FileNotifier';\nimport { logEventAsync } from '../../utils/analytics/rudderstackClient';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport { getPlatformBundlers } from './platformBundlers';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst devServers: BundlerDevServer[] = [];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n private projectPrerequisites: ProjectPrerequisite[] = [];\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n this.notifier = this.watchBabelConfig();\n }\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) {\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 await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(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 /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot);\n\n await logEventAsync('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\n\n const platformBundlers = getPlatformBundlers(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(\n this.projectRoot,\n platformBundlers,\n !!options?.devClient\n );\n await server.startAsync(options ?? this.options);\n devServers.push(server);\n }\n\n return exp;\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n this.notifier?.stopObserving(),\n // Stop all dev servers\n ...devServers.map((server) => server.stopAsync()),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n ]);\n }\n}\n"],"names":["AndroidDebugBridge","debug","require","devServers","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","DevServerManager","constructor","projectRoot","options","projectPrerequisites","notifier","watchBabelConfig","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","startAsync","type","startOptions","logEventAsync","sdkVersion","platformBundlers","BundlerDevServerClass","devClient","stopAsync","Promise","allSettled","stopObserving","map","getServer"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc,CAAA;AACjC,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEI,IAAA,aAA0B,WAA1B,0BAA0B,CAAA;AACzB,IAAA,kBAAyC,WAAzC,yCAAyC,CAAA;AAE3DA,IAAAA,kBAAkB,mCAAM,0BAA0B,EAAhC;AAEM,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oCAAoC,CAAC,AAAsB,AAAC;AAO3F,MAAMC,UAAU,GAAuB,EAAE,AAAC;AAE1C,MAAMC,QAAQ,GAAG;IACfC,OAAO,EAAE,IACPH,OAAO,CAAC,mCAAmC,CAAC,CACzCI,uBA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QAAW,GAAlBA,KAAAA,CAAkB,GAAlBA,OAAO,CAAE6C,SAAS,CAAA,CACrB,AAAC;YACF,MAAM3B,MAAM,CAACoB,UAAU,CAACtC,OAAO,WAAPA,OAAO,GAAI,IAAI,CAACA,OAAO,CAAC,CAAC;YACjDT,UAAU,CAACqB,IAAI,CAACM,MAAM,CAAC,CAAC;SACzB;QAED,OAAOa,GAAG,CAAC;KACZ;IAED,sCAAsC,CACtC,MAAMe,SAAS,GAAkB;YAE7B,GAAa;QADf,MAAMC,OAAO,CAACC,UAAU,CAAC;YACvB,CAAA,GAAa,GAAb,IAAI,CAAC9C,QAAQ,SAAe,GAA5B,KAAA,CAA4B,GAA5B,GAAa,CAAE+C,aAAa,EAAE;YAC9B,uBAAuB;eACpB1D,UAAU,CAAC2D,GAAG,CAAC,CAAChC,MAAM,GAAKA,MAAM,CAAC4B,SAAS,EAAE;YAAA,CAAC;YACjD,WAAW;YACX1D,kBAAkB,CAAC+D,SAAS,EAAE,CAACL,SAAS,EAAE;SAC3C,CAAC,CAAC;KACJ;CACF;QApIYjD,gBAAgB,GAAhBA,gBAAgB"}
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 { FileNotifier } from '../../utils/FileNotifier';\nimport { logEventAsync } from '../../utils/analytics/rudderstackClient';\nimport { env } from '../../utils/env';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport { TypeScriptProjectPrerequisite } from '../doctor/typescript/TypeScriptProjectPrerequisite';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport { getPlatformBundlers } from './platformBundlers';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst devServers: BundlerDevServer[] = [];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n private projectPrerequisites: ProjectPrerequisite<any, void>[] = [];\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n this.notifier = this.watchBabelConfig();\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite<any, any>) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n return await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(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 /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n\n await logEventAsync('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\n\n const platformBundlers = getPlatformBundlers(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(\n this.projectRoot,\n platformBundlers,\n !!options?.devClient\n );\n await server.startAsync(options ?? this.options);\n devServers.push(server);\n }\n\n return exp;\n }\n\n async bootstrapTypeScriptAsync() {\n const typescriptPrerequisite = await this.ensureProjectPrerequisiteAsync(\n TypeScriptProjectPrerequisite\n );\n\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n return;\n }\n\n // Optionally, wait for the user to add TypeScript during the\n // development cycle.\n const server = devServers.find((server) => server.name === 'metro');\n if (!server) {\n return;\n }\n\n if (!typescriptPrerequisite) {\n server.waitForTypeScriptAsync().then(async (success) => {\n if (success) {\n await server.startTypeScriptServices();\n }\n });\n } else {\n server.startTypeScriptServices();\n }\n }\n\n async watchEnvironmentVariables() {\n await devServers.find((server) => server.name === 'metro')?.watchEnvironmentVariables();\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n this.notifier?.stopObserving(),\n // Stop all dev servers\n ...devServers.map((server) => server.stopAsync()),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n ]);\n }\n}\n"],"names":["AndroidDebugBridge","debug","require","devServers","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","DevServerManager","constructor","projectRoot","options","projectPrerequisites","notifier","watchBabelConfig","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","startAsync","type","startOptions","logEventAsync","sdkVersion","platformBundlers","BundlerDevServerClass","devClient","bootstrapTypeScriptAsync","typescriptPrerequisite","TypeScriptProjectPrerequisite","env","EXPO_NO_TYPESCRIPT_SETUP","name","waitForTypeScriptAsync","then","success","startTypeScriptServices","watchEnvironmentVariables","stopAsync","Promise","allSettled","stopObserving","map","getServer"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc,CAAA;AACjC,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEI,IAAA,aAA0B,WAA1B,0BAA0B,CAAA;AACzB,IAAA,kBAAyC,WAAzC,yCAAyC,CAAA;AACnD,IAAA,IAAiB,WAAjB,iBAAiB,CAAA;AAES,IAAA,8BAAoD,WAApD,oDAAoD,CAAA;AACtFA,IAAAA,kBAAkB,mCAAM,0BAA0B,EAAhC;AAEM,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExD,M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D,GAApDA,UAAU,CAACoB,IAAI,CAAC,CAACO,MAAM,GAAKA,MAAM,CAACiC,IAAI,KAAK,OAAO;QAAA,CAAC,SAA2B,GAA/E5D,KAAAA,CAA+E,GAA/EA,GAAoD,CAAEiE,yBAAyB,EAAE,CAAA,CAAC;KACzF;IAED,sCAAsC,CACtC,MAAMC,SAAS,GAAkB;YAE7B,GAAa;QADf,MAAMC,OAAO,CAACC,UAAU,CAAC;YACvB,CAAA,GAAa,GAAb,IAAI,CAACzD,QAAQ,SAAe,GAA5B,KAAA,CAA4B,GAA5B,GAAa,CAAE0D,aAAa,EAAE;YAC9B,uBAAuB;eACpBrE,UAAU,CAACsE,GAAG,CAAC,CAAC3C,MAAM,GAAKA,MAAM,CAACuC,SAAS,EAAE;YAAA,CAAC;YACjD,WAAW;YACXrE,kBAAkB,CAAC0E,SAAS,EAAE,CAACL,SAAS,EAAE;SAC3C,CAAC,CAAC;KACJ;CACF;QAnKY5D,gBAAgB,GAAhBA,gBAAgB"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.getStaticRenderFunctionsContentAsync = getStaticRenderFunctionsContentAsync;
6
+ exports.createMetroEndpointAsync = createMetroEndpointAsync;
7
+ exports.requireFileContentsWithMetro = requireFileContentsWithMetro;
8
+ exports.requireWithMetro = requireWithMetro;
9
+ exports.getStaticRenderFunctions = getStaticRenderFunctions;
10
+ var _fs = _interopRequireDefault(require("fs"));
11
+ var _nodeFetch = _interopRequireDefault(require("node-fetch"));
12
+ var _path = _interopRequireDefault(require("path"));
13
+ var _requireFromString = _interopRequireDefault(require("require-from-string"));
14
+ var _resolveFrom = _interopRequireDefault(require("resolve-from"));
15
+ var _ansi = require("../../utils/ansi");
16
+ var _delay = require("../../utils/delay");
17
+ var _errors = require("../../utils/errors");
18
+ var _fn = require("../../utils/fn");
19
+ var _profile = require("../../utils/profile");
20
+ var _metroErrorInterface = require("./metro/metroErrorInterface");
21
+ var _manifestMiddleware = require("./middleware/ManifestMiddleware");
22
+ function _interopRequireDefault(obj) {
23
+ return obj && obj.__esModule ? obj : {
24
+ default: obj
25
+ };
26
+ }
27
+ const debug = require("debug")("expo:start:server:node-renderer");
28
+ function wrapBundle(str) {
29
+ // Skip the metro runtime so debugging is a bit easier.
30
+ // Replace the __r() call with an export statement.
31
+ return str.replace(/^(__r\(.*\);)$/m, "module.exports = $1");
32
+ }
33
+ function stripProcess(str) {
34
+ // TODO: Remove from the metro prelude
35
+ return str.replace(/process=this\.process\|\|{},/m, "");
36
+ }
37
+ // TODO(EvanBacon): Group all the code together and version.
38
+ const getRenderModuleId = (projectRoot)=>{
39
+ const moduleId = _resolveFrom.default.silent(projectRoot, "expo-router/node/render.js");
40
+ if (!moduleId) {
41
+ throw new Error(`A version of expo-router with Node.js support is not installed in the project.`);
42
+ }
43
+ return moduleId;
44
+ };
45
+ const moveStaticRenderFunction = (0, _fn).memoize(async (projectRoot, requiredModuleId)=>{
46
+ // Copy the file into the project to ensure it works in monorepos.
47
+ // This means the file cannot have any relative imports.
48
+ const tempDir = _path.default.join(projectRoot, ".expo/static");
49
+ await _fs.default.promises.mkdir(tempDir, {
50
+ recursive: true
51
+ });
52
+ const moduleId = _path.default.join(tempDir, "render.js");
53
+ await _fs.default.promises.writeFile(moduleId, await _fs.default.promises.readFile(requiredModuleId, "utf8"));
54
+ // Sleep to give watchman time to register the file.
55
+ await (0, _delay).delayAsync(50);
56
+ return moduleId;
57
+ });
58
+ async function getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, { dev =false , minify =false , environment } = {}) {
59
+ const root = (0, _manifestMiddleware).getMetroServerRoot(projectRoot);
60
+ const requiredModuleId = getRenderModuleId(root);
61
+ let moduleId = requiredModuleId;
62
+ // Cannot be accessed using Metro's server API, we need to move the file
63
+ // into the project root and try again.
64
+ if (_path.default.relative(root, moduleId).startsWith("..")) {
65
+ moduleId = await moveStaticRenderFunction(projectRoot, requiredModuleId);
66
+ }
67
+ return requireFileContentsWithMetro(root, devServerUrl, moduleId, {
68
+ dev,
69
+ minify,
70
+ environment
71
+ });
72
+ }
73
+ async function ensureFileInRootDirectory(projectRoot, otherFile) {
74
+ // Cannot be accessed using Metro's server API, we need to move the file
75
+ // into the project root and try again.
76
+ if (!_path.default.relative(projectRoot, otherFile).startsWith("../")) {
77
+ return otherFile;
78
+ }
79
+ // Copy the file into the project to ensure it works in monorepos.
80
+ // This means the file cannot have any relative imports.
81
+ const tempDir = _path.default.join(projectRoot, ".expo/static-tmp");
82
+ await _fs.default.promises.mkdir(tempDir, {
83
+ recursive: true
84
+ });
85
+ const moduleId = _path.default.join(tempDir, _path.default.basename(otherFile));
86
+ await _fs.default.promises.writeFile(moduleId, await _fs.default.promises.readFile(otherFile, "utf8"));
87
+ // Sleep to give watchman time to register the file.
88
+ await (0, _delay).delayAsync(50);
89
+ return moduleId;
90
+ }
91
+ async function createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, { dev =false , platform ="web" , minify =false , environment } = {}) {
92
+ const root = (0, _manifestMiddleware).getMetroServerRoot(projectRoot);
93
+ const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);
94
+ const serverPath = _path.default.relative(root, safeOtherFile).replace(/\.[jt]sx?$/, ".bundle");
95
+ debug("fetching from Metro:", root, serverPath);
96
+ let url = `${devServerUrl}/${serverPath}?platform=${platform}&dev=${dev}&minify=${minify}`;
97
+ if (environment) {
98
+ url += `&resolver.environment=${environment}&transform.environment=${environment}`;
99
+ }
100
+ return url;
101
+ }
102
+ class MetroNodeError extends Error {
103
+ constructor(message, rawObject){
104
+ super(message);
105
+ this.rawObject = rawObject;
106
+ }
107
+ }
108
+ exports.MetroNodeError = MetroNodeError;
109
+ async function requireFileContentsWithMetro(projectRoot, devServerUrl, absoluteFilePath, props = {}) {
110
+ const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);
111
+ const res = await (0, _nodeFetch).default(url);
112
+ // TODO: Improve error handling
113
+ if (res.status === 500) {
114
+ const text = await res.text();
115
+ if (text.startsWith('{"originModulePath"') || text.startsWith('{"type":"TransformError"')) {
116
+ const errorObject = JSON.parse(text);
117
+ var ref;
118
+ throw new MetroNodeError((ref = (0, _ansi).stripAnsi(errorObject.message)) != null ? ref : errorObject.message, errorObject);
119
+ }
120
+ throw new Error(`[${res.status}]: ${res.statusText}\n${text}`);
121
+ }
122
+ if (!res.ok) {
123
+ throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);
124
+ }
125
+ const content = await res.text();
126
+ let bun = wrapBundle(content);
127
+ // This exposes the entire environment to the bundle.
128
+ if (props.environment === "node") {
129
+ bun = stripProcess(bun);
130
+ }
131
+ return bun;
132
+ }
133
+ async function requireWithMetro(projectRoot, devServerUrl, absoluteFilePath, options = {}) {
134
+ const content = await requireFileContentsWithMetro(projectRoot, devServerUrl, absoluteFilePath, options);
135
+ return evalMetro(content);
136
+ }
137
+ async function getStaticRenderFunctions(projectRoot, devServerUrl, options = {}) {
138
+ const scriptContents = await getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, options);
139
+ const contents = evalMetro(scriptContents);
140
+ // wrap each function with a try/catch that uses Metro's error formatter
141
+ return Object.keys(contents).reduce((acc, key)=>{
142
+ const fn = contents[key];
143
+ if (typeof fn !== "function") {
144
+ return {
145
+ ...acc,
146
+ [key]: fn
147
+ };
148
+ }
149
+ acc[key] = async function(...props) {
150
+ try {
151
+ return await fn.apply(this, props);
152
+ } catch (error) {
153
+ await (0, _metroErrorInterface).logMetroError(projectRoot, {
154
+ error
155
+ });
156
+ throw new _errors.SilentError(error);
157
+ }
158
+ };
159
+ return acc;
160
+ }, {});
161
+ }
162
+ function evalMetro(src) {
163
+ return (0, _profile).profile(_requireFromString.default, "eval-metro-bundle")(src);
164
+ }
165
+
166
+ //# sourceMappingURL=getStaticRenderFunctions.js.map
@@ -0,0 +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 fs from 'fs';\nimport fetch from 'node-fetch';\nimport path from 'path';\nimport requireString from 'require-from-string';\nimport resolveFrom from 'resolve-from';\n\nimport { stripAnsi } from '../../utils/ansi';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { memoize } from '../../utils/fn';\nimport { profile } from '../../utils/profile';\nimport { logMetroError } from './metro/metroErrorInterface';\nimport { getMetroServerRoot } from './middleware/ManifestMiddleware';\n\nconst debug = require('debug')('expo:start:server:node-renderer') as typeof console.log;\n\nfunction wrapBundle(str: string) {\n // Skip the metro runtime so debugging is a bit easier.\n // Replace the __r() call with an export statement.\n return str.replace(/^(__r\\(.*\\);)$/m, 'module.exports = $1');\n}\n\nfunction stripProcess(str: string) {\n // TODO: Remove from the metro prelude\n return str.replace(/process=this\\.process\\|\\|{},/m, '');\n}\n\n// TODO(EvanBacon): Group all the code together and version.\nconst getRenderModuleId = (projectRoot: string): string => {\n const moduleId = resolveFrom.silent(projectRoot, 'expo-router/node/render.js');\n if (!moduleId) {\n throw new Error(\n `A version of expo-router with Node.js support is not installed in the project.`\n );\n }\n\n return moduleId;\n};\n\ntype StaticRenderOptions = {\n // Ensure the style format is `css-xxxx` (prod) instead of `css-view-xxxx` (dev)\n dev?: boolean;\n minify?: boolean;\n platform?: string;\n environment?: 'node';\n};\n\nconst moveStaticRenderFunction = memoize(async (projectRoot: string, requiredModuleId: string) => {\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');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, 'render.js');\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(requiredModuleId, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n});\n\n/** @returns the js file contents required to generate the static generation function. */\nexport async function getStaticRenderFunctionsContentAsync(\n projectRoot: string,\n devServerUrl: string,\n { dev = false, minify = false, environment }: StaticRenderOptions = {}\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const requiredModuleId = getRenderModuleId(root);\n let moduleId = requiredModuleId;\n\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(root, moduleId).startsWith('..')) {\n moduleId = await moveStaticRenderFunction(projectRoot, requiredModuleId);\n }\n\n return requireFileContentsWithMetro(root, devServerUrl, moduleId, { dev, minify, environment });\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('../')) {\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 { dev = false, platform = 'web', minify = false, environment }: StaticRenderOptions = {}\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?$/, '.bundle');\n debug('fetching from Metro:', root, serverPath);\n\n let url = `${devServerUrl}/${serverPath}?platform=${platform}&dev=${dev}&minify=${minify}`;\n\n if (environment) {\n url += `&resolver.environment=${environment}&transform.environment=${environment}`;\n }\n return url;\n}\n\nexport class MetroNodeError extends Error {\n constructor(message: string, public rawObject: any) {\n super(message);\n }\n}\n\nexport async function requireFileContentsWithMetro(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: StaticRenderOptions = {}\n): Promise<string> {\n const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);\n\n const res = await fetch(url);\n\n // TODO: Improve error handling\n if (res.status === 500) {\n const text = await res.text();\n if (text.startsWith('{\"originModulePath\"') || text.startsWith('{\"type\":\"TransformError\"')) {\n const errorObject = JSON.parse(text);\n\n throw new MetroNodeError(stripAnsi(errorObject.message) ?? errorObject.message, errorObject);\n }\n throw new Error(`[${res.status}]: ${res.statusText}\\n${text}`);\n }\n\n if (!res.ok) {\n throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);\n }\n\n const content = await res.text();\n\n let bun = wrapBundle(content);\n\n // This exposes the entire environment to the bundle.\n if (props.environment === 'node') {\n bun = stripProcess(bun);\n }\n\n return bun;\n}\nexport async function requireWithMetro<T>(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n options: StaticRenderOptions = {}\n): Promise<T> {\n const content = await requireFileContentsWithMetro(\n projectRoot,\n devServerUrl,\n absoluteFilePath,\n options\n );\n return evalMetro(content);\n}\n\nexport async function getStaticRenderFunctions(\n projectRoot: string,\n devServerUrl: string,\n options: StaticRenderOptions = {}\n): Promise<Record<string, (...args: any[]) => Promise<any>>> {\n const scriptContents = await getStaticRenderFunctionsContentAsync(\n projectRoot,\n devServerUrl,\n options\n );\n\n const contents = evalMetro(scriptContents);\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 throw new SilentError(error);\n }\n };\n return acc;\n }, {} as any);\n}\n\nfunction evalMetro(src: string) {\n return profile(requireString, 'eval-metro-bundle')(src);\n}\n"],"names":["getStaticRenderFunctionsContentAsync","createMetroEndpointAsync","requireFileContentsWithMetro","requireWithMetro","getStaticRenderFunctions","debug","require","wrapBundle","str","replace","stripProcess","getRenderModuleId","projectRoot","moduleId","resolveFrom","silent","Error","moveStaticRenderFunction","memoize","requiredModuleId","tempDir","path","join","fs","promises","mkdir","recursive","writeFile","readFile","delayAsync","devServerUrl","dev","minify","environment","root","getMetroServerRoot","relative","startsWith","ensureFileInRootDirectory","otherFile","basename","absoluteFilePath","platform","safeOtherFile","serverPath","url","MetroNodeError","constructor","message","rawObject","props","res","fetch","status","text","errorObject","JSON","parse","stripAnsi","statusText","ok","content","bun","options","evalMetro","scriptContents","contents","Object","keys","reduce","acc","key","fn","apply","error","logMetroError","SilentError","src","profile","requireString"],"mappings":"AAMA;;;;QA4DsBA,oCAAoC,GAApCA,oCAAoC;QAoCpCC,wBAAwB,GAAxBA,wBAAwB;QAyBxBC,4BAA4B,GAA5BA,4BAA4B;QAoC5BC,gBAAgB,GAAhBA,gBAAgB;QAehBC,wBAAwB,GAAxBA,wBAAwB;AA5K/B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACD,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACb,IAAA,KAAM,kCAAN,MAAM,EAAA;AACG,IAAA,kBAAqB,kCAArB,qBAAqB,EAAA;AACvB,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEZ,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AACjB,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AAClB,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACxB,IAAA,GAAgB,WAAhB,gBAAgB,CAAA;AAChB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AACf,IAAA,oBAA6B,WAA7B,6BAA6B,CAAA;AACxB,IAAA,mBAAiC,WAAjC,iCAAiC,CAAA;;;;;;AAEpE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAExF,SAASC,UAAU,CAACC,GAAW,EAAE;IAC/B,uDAAu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