@expo/cli 0.1.5 → 0.2.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 (190) hide show
  1. package/build/bin/cli +83 -4
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/api/rest/wrapFetchWithOffline.js +2 -23
  4. package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
  5. package/build/src/customize/customizeAsync.js +40 -0
  6. package/build/src/customize/customizeAsync.js.map +1 -0
  7. package/build/src/customize/generate.js +77 -0
  8. package/build/src/customize/generate.js.map +1 -0
  9. package/build/src/customize/index.js +41 -0
  10. package/build/src/customize/index.js.map +1 -0
  11. package/build/src/customize/resolveOptions.js +18 -0
  12. package/build/src/customize/resolveOptions.js.map +1 -0
  13. package/build/src/customize/templates.js +118 -0
  14. package/build/src/customize/templates.js.map +1 -0
  15. package/build/src/export/createMetadataJson.js +10 -7
  16. package/build/src/export/createMetadataJson.js.map +1 -1
  17. package/build/src/export/exportApp.js +32 -0
  18. package/build/src/export/exportApp.js.map +1 -1
  19. package/build/src/export/exportAssets.js +2 -3
  20. package/build/src/export/exportAssets.js.map +1 -1
  21. package/build/src/export/fork-bundleAsync.js +51 -34
  22. package/build/src/export/fork-bundleAsync.js.map +1 -1
  23. package/build/src/export/index.js +14 -10
  24. package/build/src/export/index.js.map +1 -1
  25. package/build/src/export/printBundleSizes.js +27 -48
  26. package/build/src/export/printBundleSizes.js.map +1 -1
  27. package/build/src/export/resolveOptions.js +44 -5
  28. package/build/src/export/resolveOptions.js.map +1 -1
  29. package/build/src/export/saveAssets.js +2 -1
  30. package/build/src/export/saveAssets.js.map +1 -1
  31. package/build/src/export/web/exportWebAsync.js +37 -0
  32. package/build/src/export/web/exportWebAsync.js.map +1 -0
  33. package/build/src/export/web/index.js +66 -0
  34. package/build/src/export/web/index.js.map +1 -0
  35. package/build/src/export/web/resolveOptions.js +13 -0
  36. package/build/src/export/web/resolveOptions.js.map +1 -0
  37. package/build/src/export/writeContents.js.map +1 -1
  38. package/build/src/install/checkPackages.js +2 -1
  39. package/build/src/install/checkPackages.js.map +1 -1
  40. package/build/src/install/index.js +1 -0
  41. package/build/src/install/index.js.map +1 -1
  42. package/build/src/install/installAsync.js +13 -5
  43. package/build/src/install/installAsync.js.map +1 -1
  44. package/build/src/install/resolveOptions.js +12 -65
  45. package/build/src/install/resolveOptions.js.map +1 -1
  46. package/build/src/install/utils/autoAddConfigPlugins.js +5 -26
  47. package/build/src/install/utils/autoAddConfigPlugins.js.map +1 -1
  48. package/build/src/log.js.map +1 -1
  49. package/build/src/prebuild/copyTemplateFiles.js +5 -23
  50. package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
  51. package/build/src/prebuild/index.js +18 -12
  52. package/build/src/prebuild/index.js.map +1 -1
  53. package/build/src/prebuild/prebuildAsync.js +11 -12
  54. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  55. package/build/src/prebuild/resolveOptions.js +17 -0
  56. package/build/src/prebuild/resolveOptions.js.map +1 -1
  57. package/build/src/prebuild/resolveTemplate.js +2 -1
  58. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  59. package/build/src/prebuild/updatePackageJson.js +5 -5
  60. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  61. package/build/src/run/android/resolveInstallApkName.js +5 -26
  62. package/build/src/run/android/resolveInstallApkName.js.map +1 -1
  63. package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js +2 -0
  64. package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js.map +1 -1
  65. package/build/src/start/doctor/apple/XcodePrerequisite.js +2 -0
  66. package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
  67. package/build/src/start/doctor/dependencies/bundledNativeModules.js +3 -2
  68. package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
  69. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +7 -13
  70. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  71. package/build/src/start/doctor/dependencies/getMissingPackages.js +3 -24
  72. package/build/src/start/doctor/dependencies/getMissingPackages.js.map +1 -1
  73. package/build/src/start/doctor/dependencies/getVersionedPackages.js +2 -23
  74. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  75. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +17 -9
  76. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  77. package/build/src/start/doctor/ngrok/ExternalModule.js +2 -1
  78. package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
  79. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +4 -3
  80. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
  81. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +32 -31
  82. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
  83. package/build/src/start/interface/KeyPressHandler.js +2 -0
  84. package/build/src/start/interface/KeyPressHandler.js.map +1 -1
  85. package/build/src/start/interface/interactiveActions.js +5 -5
  86. package/build/src/start/interface/interactiveActions.js.map +1 -1
  87. package/build/src/start/interface/startInterface.js +3 -2
  88. package/build/src/start/interface/startInterface.js.map +1 -1
  89. package/build/src/start/platforms/ExpoGoInstaller.js +2 -1
  90. package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
  91. package/build/src/start/platforms/PlatformManager.js +4 -24
  92. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  93. package/build/src/start/platforms/android/ADBServer.js +17 -32
  94. package/build/src/start/platforms/android/ADBServer.js.map +1 -1
  95. package/build/src/start/platforms/android/AndroidSdk.js +41 -0
  96. package/build/src/start/platforms/android/AndroidSdk.js.map +1 -0
  97. package/build/src/start/platforms/android/activateWindow.js +4 -4
  98. package/build/src/start/platforms/android/activateWindow.js.map +1 -1
  99. package/build/src/start/platforms/android/adb.js +8 -3
  100. package/build/src/start/platforms/android/adb.js.map +1 -1
  101. package/build/src/start/platforms/android/adbReverse.js +3 -2
  102. package/build/src/start/platforms/android/adbReverse.js.map +1 -1
  103. package/build/src/start/platforms/android/gradle.js +2 -2
  104. package/build/src/start/platforms/android/gradle.js.map +1 -1
  105. package/build/src/start/platforms/ios/getBestSimulator.js +4 -4
  106. package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
  107. package/build/src/start/platforms/ios/xcrun.js +2 -23
  108. package/build/src/start/platforms/ios/xcrun.js.map +1 -1
  109. package/build/src/start/project/devices.js +2 -0
  110. package/build/src/start/project/devices.js.map +1 -1
  111. package/build/src/start/server/AsyncNgrok.js +6 -5
  112. package/build/src/start/server/AsyncNgrok.js.map +1 -1
  113. package/build/src/start/server/BundlerDevServer.js +15 -8
  114. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  115. package/build/src/start/server/DevServerManager.js +15 -5
  116. package/build/src/start/server/DevServerManager.js.map +1 -1
  117. package/build/src/start/server/DevelopmentSession.js +4 -0
  118. package/build/src/start/server/DevelopmentSession.js.map +1 -1
  119. package/build/src/start/server/UrlCreator.js +10 -3
  120. package/build/src/start/server/UrlCreator.js.map +1 -1
  121. package/build/src/start/server/metro/MetroBundlerDevServer.js +9 -0
  122. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  123. package/build/src/start/server/metro/TerminalReporter.js +5 -0
  124. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  125. package/build/src/start/server/metro/instantiateMetro.js +11 -1
  126. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  127. package/build/src/start/server/metro/resolveFromProject.js +8 -0
  128. package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
  129. package/build/src/start/server/metro/withMetroMultiPlatform.js +115 -0
  130. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -0
  131. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
  132. package/build/src/start/server/middleware/ExpoMiddleware.js +9 -4
  133. package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
  134. package/build/src/start/server/middleware/HistoryFallbackMiddleware.js +24 -0
  135. package/build/src/start/server/middleware/HistoryFallbackMiddleware.js.map +1 -0
  136. package/build/src/start/server/middleware/InterstitialPageMiddleware.js +2 -0
  137. package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
  138. package/build/src/start/server/middleware/ManifestMiddleware.js +57 -6
  139. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  140. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +6 -1
  141. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
  142. package/build/src/start/server/middleware/ServeStaticMiddleware.js +62 -0
  143. package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -0
  144. package/build/src/start/server/platformBundlers.js +18 -0
  145. package/build/src/start/server/platformBundlers.js.map +1 -0
  146. package/build/src/start/server/webTemplate.js +68 -0
  147. package/build/src/start/server/webTemplate.js.map +1 -0
  148. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +59 -19
  149. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  150. package/build/src/start/server/webpack/compile.js +64 -0
  151. package/build/src/start/server/webpack/compile.js.map +1 -0
  152. package/build/src/start/startAsync.js +21 -17
  153. package/build/src/start/startAsync.js.map +1 -1
  154. package/build/src/utils/FileNotifier.js +5 -2
  155. package/build/src/utils/FileNotifier.js.map +1 -1
  156. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  157. package/build/src/utils/downloadAppAsync.js +3 -2
  158. package/build/src/utils/downloadAppAsync.js.map +1 -1
  159. package/build/src/utils/downloadExpoGoAsync.js +7 -32
  160. package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
  161. package/build/src/utils/editor.js +3 -2
  162. package/build/src/utils/editor.js.map +1 -1
  163. package/build/src/utils/env.js +3 -0
  164. package/build/src/utils/env.js.map +1 -1
  165. package/build/src/utils/exit.js +4 -25
  166. package/build/src/utils/exit.js.map +1 -1
  167. package/build/src/utils/getRunningProcess.js +6 -2
  168. package/build/src/utils/getRunningProcess.js.map +1 -1
  169. package/build/src/utils/nodeModules.js +13 -102
  170. package/build/src/utils/nodeModules.js.map +1 -1
  171. package/build/src/utils/npm.js +3 -24
  172. package/build/src/utils/npm.js.map +1 -1
  173. package/build/src/utils/ora.js +1 -13
  174. package/build/src/utils/ora.js.map +1 -1
  175. package/build/src/utils/progress.js +46 -0
  176. package/build/src/utils/progress.js.map +1 -1
  177. package/build/src/utils/prompts.js +4 -4
  178. package/build/src/utils/prompts.js.map +1 -1
  179. package/build/src/utils/tar.js +3 -0
  180. package/build/src/utils/tar.js.map +1 -1
  181. package/build/src/utils/validateApplicationId.js +9 -2
  182. package/build/src/utils/validateApplicationId.js.map +1 -1
  183. package/build/src/utils/variadic.js +47 -0
  184. package/build/src/utils/variadic.js.map +1 -0
  185. package/package.json +12 -7
  186. package/static/template/babel.config.js +6 -0
  187. package/static/template/index.html +117 -0
  188. package/static/template/metro.config.js +4 -0
  189. package/static/template/serve.json +13 -0
  190. package/static/template/webpack.config.js +7 -0
@@ -40,6 +40,7 @@ function _interopRequireWildcard(obj) {
40
40
  return newObj;
41
41
  }
42
42
  }
43
+ const debug = require("debug")("expo:start:server:devServer");
43
44
  const PLATFORM_MANAGERS = {
44
45
  simulator: ()=>require("../platforms/ios/ApplePlatformManager").ApplePlatformManager
45
46
  ,
@@ -51,8 +52,9 @@ const MIDDLEWARES = {
51
52
  "expo-updates": ()=>require("./middleware/ExpoGoManifestHandlerMiddleware").ExpoGoManifestHandlerMiddleware
52
53
  };
53
54
  class BundlerDevServer {
54
- constructor(projectRoot, isDevClient){
55
+ constructor(projectRoot, platformBundlers, isDevClient){
55
56
  this.projectRoot = projectRoot;
57
+ this.platformBundlers = platformBundlers;
56
58
  this.isDevClient = isDevClient;
57
59
  this.ngrok = null;
58
60
  this.devSession = null;
@@ -119,8 +121,12 @@ class BundlerDevServer {
119
121
  }
120
122
  };
121
123
  }
122
- async postStartAsync(options) {
123
- if (options.location.hostType === "tunnel" && !_settings.APISettings.isOffline) {
124
+ /**
125
+ * Runs after the `startAsync` function, performing any additional common operations.
126
+ * You can assume the dev server is started by the time this function is called.
127
+ */ async postStartAsync(options) {
128
+ if (options.location.hostType === "tunnel" && !_settings.APISettings.isOffline && // This is a hack to prevent using tunnel on web since we block it upstream for some reason.
129
+ this.isTargetingNative()) {
124
130
  await this._startTunnelAsync();
125
131
  }
126
132
  await this.startDevSessionAsync();
@@ -134,7 +140,7 @@ class BundlerDevServer {
134
140
  var ref;
135
141
  const port = (ref = this.getInstance()) == null ? void 0 : ref.location.port;
136
142
  if (!port) return null;
137
- Log.debug("[ngrok] connect to port: " + port);
143
+ debug("[ngrok] connect to port: " + port);
138
144
  this.ngrok = new _asyncNgrok.AsyncNgrok(this.projectRoot, port);
139
145
  await this.ngrok.startAsync();
140
146
  return this.ngrok;
@@ -158,7 +164,7 @@ class BundlerDevServer {
158
164
  return true;
159
165
  }
160
166
  isTargetingWeb() {
161
- return false;
167
+ return this.platformBundlers.web === this.name;
162
168
  }
163
169
  /**
164
170
  * Sends a message over web sockets to any connected device,
@@ -186,10 +192,10 @@ class BundlerDevServer {
186
192
  return new Promise((resolve, reject)=>{
187
193
  var ref;
188
194
  // Close the server.
189
- Log.debug(`Stopping dev server (bundler: ${this.name})`);
195
+ debug(`Stopping dev server (bundler: ${this.name})`);
190
196
  if ((ref = this.instance) == null ? void 0 : ref.server) {
191
197
  this.instance.server.close((error)=>{
192
- Log.debug(`Stopped dev server (bundler: ${this.name})`);
198
+ debug(`Stopped dev server (bundler: ${this.name})`);
193
199
  this.instance = null;
194
200
  if (error) {
195
201
  reject(error);
@@ -198,7 +204,7 @@ class BundlerDevServer {
198
204
  }
199
205
  });
200
206
  } else {
201
- Log.debug(`Stopped dev server (bundler: ${this.name})`);
207
+ debug(`Stopped dev server (bundler: ${this.name})`);
202
208
  this.instance = null;
203
209
  resolve();
204
210
  }
@@ -296,6 +302,7 @@ class BundlerDevServer {
296
302
  if (!port || !this.urlCreator) {
297
303
  throw new _errors.CommandError("DEV_SERVER", "Cannot interact with native platforms until dev server has started");
298
304
  }
305
+ debug(`Creating platform manager (platform: ${platform}, port: ${port})`);
299
306
  this.platformManagers[platform] = new Manager(this.projectRoot, port, {
300
307
  getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),
301
308
  getExpoGoUrl: this.getExpoGoUrl.bind(this, platform),
@@ -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';\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 constructor(\n /** Project root folder. */\n public projectRoot: string,\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 protected async postStartAsync(options: BundlerStartOptions) {\n if (options.location.hostType === 'tunnel' && !APISettings.isOffline) {\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 const notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n 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 Log.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\n if (this.devSession) {\n this.devSession.stopNotifying();\n }\n\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 public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return false;\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 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 Log.debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n this.instance.server.close((error) => {\n Log.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 Log.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 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 url = this.getDevServerUrl({ hostType: 'localhost' });\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 /** Should use the interstitial page for selecting which runtime to use. */\n protected shouldUseInterstitialPage(): boolean {\n return (\n env.EXPO_ENABLE_INTERSTITIAL_PAGE &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-launcher')\n );\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(platform: keyof typeof PLATFORM_MANAGERS): string | null {\n if (this.shouldUseInterstitialPage()) {\n const loadingUrl =\n platform === 'emulator'\n ? this.urlCreator?.constructLoadingUrl({}, 'android')\n : this.urlCreator?.constructLoadingUrl({ hostType: 'localhost' }, 'ios');\n return loadingUrl ?? null;\n }\n\n return this.urlCreator?.constructUrl({ scheme: 'exp' }) ?? null;\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 this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["Log","PLATFORM_MANAGERS","simulator","require","ApplePlatformManager","emulator","AndroidPlatformManager","MIDDLEWARES","classic","ClassicManifestMiddleware","ExpoGoManifestHandlerMiddleware","BundlerDevServer","constructor","projectRoot","isDevClient","ngrok","devSession","instance","platformManagers","urlCreator","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","notifier","FileNotifier","getConfigModuleIds","startObserving","getInstance","debug","AsyncNgrok","stopNotifying","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","runtime","isTargetingWeb","broadcastMessage","method","params","closeAsync","catch","e","error","exception","resolveWithTimeout","Promise","resolve","reject","timeout","errorMessage","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getActiveUrl","openPlatformAsync","launchTarget","resolver","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","shouldUseInterstitialPage","env","EXPO_ENABLE_INTERSTITIAL_PAGE","resolveFrom","silent","getExpoGoUrl","platform","loadingUrl","constructLoadingUrl","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;AA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,IAAI,CAAC,IAAI,CAACX,UAAU,CAAC;gBAChFyF,YAAY,EAAE,IAAI,CAACA,YAAY,CAAC9E,IAAI,CAAC,IAAI,EAAE+E,QAAQ,CAAC;gBACpDvC,eAAe,EAAE,IAAI,CAACA,eAAe,CAACxC,IAAI,CAAC,IAAI,EAAE;oBAAEwB,QAAQ,EAAE,WAAW;iBAAE,CAAC;aAC5E,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAACpC,gBAAgB,CAAC2F,QAAQ,CAAC,CAAC;KACxC;CACF;QAtUqBlG,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';\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 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 const notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n 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\n if (this.devSession) {\n this.devSession.stopNotifying();\n }\n\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 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 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 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 url = this.getDevServerUrl({ hostType: 'localhost' });\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 /** Should use the interstitial page for selecting which runtime to use. */\n protected shouldUseInterstitialPage(): boolean {\n return (\n env.EXPO_ENABLE_INTERSTITIAL_PAGE &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-launcher')\n );\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(platform: keyof typeof PLATFORM_MANAGERS): string | null {\n if (this.shouldUseInterstitialPage()) {\n const loadingUrl =\n platform === 'emulator'\n ? this.urlCreator?.constructLoadingUrl({}, 'android')\n : this.urlCreator?.constructLoadingUrl({ hostType: 'localhost' }, 'ios');\n return loadingUrl ?? null;\n }\n\n return this.urlCreator?.constructUrl({ scheme: 'exp' }) ?? null;\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, 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","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","notifier","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncNgrok","stopNotifying","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","runtime","isTargetingWeb","web","broadcastMessage","method","params","closeAsync","catch","e","error","exception","resolveWithTimeout","Promise","resolve","reject","timeout","errorMessage","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getActiveUrl","openPlatformAsync","launchTarget","resolver","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","shouldUseInterstitialPage","env","EXPO_ENABLE_INTERSTITIAL_PAGE","resolveFrom","silent","getExpoGoUrl","platform","loadingUrl","construct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C3F,gBAAgB,CAAC2F,QAAQ,CAAC,EAAE;gBAEvB,GAAkB;YAD/B,MAAMG,OAAO,GAAG/G,iBAAiB,CAAC4G,QAAQ,CAAC,EAAE,AAAC;YAC9C,MAAMjE,IAAI,GAAG,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,CAACzB,UAAU,EAAE;gBAC7B,MAAM,IAAI0B,OAAY,aAAA,CACpB,YAAY,EACZ,oEAAoE,CACrE,CAAC;aACH;YACD9C,KAAK,CAAC,CAAC,qCAAqC,EAAE8G,QAAQ,CAAC,QAAQ,EAAEjE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1E,IAAI,CAAC1B,gBAAgB,CAAC2F,QAAQ,CAAC,GAAG,IAAIG,OAAO,CAAC,IAAI,CAACpG,WAAW,EAAEgC,IAAI,EAAE;gBACpEqE,mBAAmB,EAAE,IAAI,CAAC9F,UAAU,CAACuE,qBAAqB,CAAC5D,IAAI,CAAC,IAAI,CAACX,UAAU,CAAC;gBAChFyF,YAAY,EAAE,IAAI,CAACA,YAAY,CAAC9E,IAAI,CAAC,IAAI,EAAE+E,QAAQ,CAAC;gBACpDxC,eAAe,EAAE,IAAI,CAACA,eAAe,CAACvC,IAAI,CAAC,IAAI,EAAE;oBAAEwB,QAAQ,EAAE,WAAW;iBAAE,CAAC;aAC5E,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAACpC,gBAAgB,CAAC2F,QAAQ,CAAC,CAAC;KACxC;CACF;QAlVqBnG,gBAAgB,GAAhBA,gBAAgB"}
@@ -4,10 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  var _config = require("@expo/config");
6
6
  var _assert = _interopRequireDefault(require("assert"));
7
- var Log = _interopRequireWildcard(require("../../log"));
7
+ var _chalk = _interopRequireDefault(require("chalk"));
8
8
  var _fileNotifier = require("../../utils/FileNotifier");
9
9
  var _rudderstackClient = require("../../utils/analytics/rudderstackClient");
10
10
  var AndroidDebugBridge = _interopRequireWildcard(require("../platforms/android/adb"));
11
+ var _platformBundlers = require("./platformBundlers");
11
12
  function _interopRequireDefault(obj) {
12
13
  return obj && obj.__esModule ? obj : {
13
14
  default: obj
@@ -34,6 +35,7 @@ function _interopRequireWildcard(obj) {
34
35
  return newObj;
35
36
  }
36
37
  }
38
+ const debug = require("debug")("expo:start:server:devServerManager");
37
39
  const devServers = [];
38
40
  const BUNDLERS = {
39
41
  webpack: ()=>require("./webpack/WebpackBundlerDevServer").WebpackBundlerDevServer
@@ -54,7 +56,9 @@ class DevServerManager {
54
56
  "./.babelrc.json",
55
57
  "./.babelrc",
56
58
  "./.babelrc.js",
57
- ]);
59
+ ], {
60
+ additionalWarning: _chalk.default` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`
61
+ });
58
62
  notifier.startObserving();
59
63
  return notifier;
60
64
  }
@@ -104,10 +108,15 @@ class DevServerManager {
104
108
  if (server4) {
105
109
  return;
106
110
  }
107
- Log.debug("Starting webpack dev server");
111
+ const { exp } = (0, _config).getConfig(this.projectRoot, {
112
+ skipPlugins: true,
113
+ skipSDKVersionRequirement: true
114
+ });
115
+ const bundler = (0, _platformBundlers).getPlatformBundlers(exp).web;
116
+ debug(`Starting ${bundler} dev server for web`);
108
117
  return this.startAsync([
109
118
  {
110
- type: "webpack",
119
+ type: bundler,
111
120
  options: this.options
112
121
  },
113
122
  ]);
@@ -118,10 +127,11 @@ class DevServerManager {
118
127
  (0, _rudderstackClient).logEvent("Start Project", {
119
128
  sdkVersion: (_sdkVersion = exp.sdkVersion) != null ? _sdkVersion : null
120
129
  });
130
+ const platformBundlers = (0, _platformBundlers).getPlatformBundlers(exp);
121
131
  // Start all dev servers...
122
132
  for (const { type , options } of startOptions){
123
133
  const BundlerDevServerClass = await BUNDLERS[type]();
124
- const server = new BundlerDevServerClass(this.projectRoot, !!(options == null ? void 0 : options.devClient));
134
+ const server = new BundlerDevServerClass(this.projectRoot, platformBundlers, !!(options == null ? void 0 : options.devClient));
125
135
  await server.startAsync(options != null ? options : this.options);
126
136
  devServers.push(server);
127
137
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\n\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { logEvent } from '../../utils/analytics/rudderstackClient';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\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 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.watchBabelConfig();\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(this.projectRoot, [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\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 Log.debug('Starting webpack dev server');\n return this.startAsync([\n {\n type: 'webpack',\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 logEvent('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\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, !!options?.devClient);\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 // Stop all dev servers\n ...devServers.map((server) => server.stopAsync()),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n ]);\n }\n}\n"],"names":["Log","AndroidDebugBridge","devServers","BUNDLERS","webpack","require","WebpackBundlerDevServer","metro","MetroBundlerDevServer","DevServerManager","constructor","projectRoot","options","projectPrerequisites","watchBabelConfig","notifier","FileNotifier","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","debug","startAsync","type","startOptions","exp","getConfig","logEvent","sdkVersion","BundlerDevServerClass","devClient","stopAsync","Promise","allSettled","map","getServer"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc,CAAA;AACjC,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEfA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACc,IAAA,aAA0B,WAA1B,0BAA0B,CAAA;AAC9B,IAAA,kBAAyC,WAAzC,yCAAyC,CAAA;AAEtDC,IAAAA,kBAAkB,mCAAM,0BAA0B,EAAhC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQ9B,MAAMC,UAAU,GAAuB,EAAE,AAAC;AAE1C,MAAMC,QAAQ,GAAG;IACfC,OAAO,EAAE,IACPC,OAAO,CAAC,mCAAmC,CAAC,CACzCC,uBAAuB;IAA8E;IAC1GC,KAAK,EAAE,IACLF,OAAO,CAAC,+BAA+B,CAAC,CACrCG,qBAAqB;CAC3B,AAAC;AAGK,MAAMC,gBAAgB;IAG3BC,YACSC,WAAmB,EAEnBC,OAA4B,CACnC;aAHOD,WAAmB,GAAnBA,WAAmB;aAEnBC,OAA4B,GAA5BA,OAA4B;aAL7BC,oBAAoB,GAA0B,EAAE;QAOtD,IAAI,CAACC,gBAAgB,EAAE,CAAC;KACzB;IAED,AAAQA,gBAAgB,GAAG;QACzB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A,GAAG,CAACG,UAAU,YAAdH,WAAc,GAAI,IAAI;SACnC,CAAC,CAAC;QAEH,2BAA2B;QAC3B,KAAK,MAAM,EAAEF,IAAI,CAAA,EAAE/B,OAAO,CAAA,EAAE,IAAIgC,YAAY,CAAE;YAC5C,MAAMK,qBAAqB,GAAG,MAAM9C,QAAQ,CAACwC,IAAI,CAAC,EAAE,AAAC;YACrD,MAAMf,MAAM,GAAG,IAAIqB,qBAAqB,CAAC,IAAI,CAACtC,WAAW,EAAE,CAAC,CAACC,CAAAA,OAAO,QAAW,GAAlBA,KAAAA,CAAkB,GAAlBA,OAAO,CAAEsC,SAAS,CAAA,CAAC,AAAC;YACjF,MAAMtB,MAAM,CAACc,UAAU,CAAC9B,OAAO,WAAPA,OAAO,GAAI,IAAI,CAACA,OAAO,CAAC,CAAC;YACjDV,UAAU,CAACoB,IAAI,CAACM,MAAM,CAAC,CAAC;SACzB;QAED,OAAOiB,GAAG,CAAC;KACZ;IAED,sCAAsC,CACtC,MAAMM,SAAS,GAAkB;QAC/B,MAAMC,OAAO,CAACC,UAAU,CAAC;YACvB,uBAAuB;eACpBnD,UAAU,CAACoD,GAAG,CAAC,CAAC1B,MAAM,GAAKA,MAAM,CAACuB,SAAS,EAAE;YAAA,CAAC;YACjD,WAAW;YACXlD,kBAAkB,CAACsD,SAAS,EAAE,CAACJ,SAAS,EAAE;SAC3C,CAAC,CAAC;KACJ;CACF;QAhHY1C,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 { logEvent } 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 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.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 logEvent('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 // 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","watchBabelConfig","notifier","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","logEvent","sdkVersion","platformBundlers","BundlerDevServerClass","devClient","stopAsync","Promise","allSettled","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;AAC9B,IAAA,kBAAyC,WAAzC,yCAAyC,CAAA;AAEtDA,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,uBAAuB;IAA8E;IAC1GC,KAAK,EAAE,IACLL,OAAO,CAAC,+BAA+B,CAAC,CACrCM,qBAAqB;CAC3B,AAAC;AAGK,MAAMC,gBAAgB;IAG3BC,YACSC,WAAmB,EAEnBC,OAA4B,CACnC;aAHOD,WAAmB,GAAnBA,WAAmB;aAEnBC,OAA4B,GAA5BA,OAA4B;aAL7BC,oBAAoB,GAA0B,EAAE;QAOtD,IAAI,CAACC,gBAAgB,EAAE,CAAC;KACzB;IAED,AAAQA,gBAAgB,GAAG;QACzB,MAAMC,QAAQ,GAAG,IAAIC,aAAY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AAS,EAAE;YAAA,CAAC;YACjD,WAAW;YACX1D,kBAAkB,CAAC8D,SAAS,EAAE,CAACJ,SAAS,EAAE;SAC3C,CAAC,CAAC;KACJ;CACF;QAjIYjD,gBAAgB,GAAhBA,gBAAgB"}
@@ -28,6 +28,7 @@ function _interopRequireWildcard(obj) {
28
28
  return newObj;
29
29
  }
30
30
  }
31
+ const debug = require("debug")("expo:start:server:developmentSession");
31
32
  const UPDATE_FREQUENCY = 20 * 1000; // 20 seconds
32
33
  async function isAuthenticatedAsync() {
33
34
  return !!await (0, _user).getUserAsync().catch(()=>null
@@ -51,15 +52,18 @@ class DevelopmentSession {
51
52
  * @returns
52
53
  */ async startAsync({ exp =(0, _config).getConfig(this.projectRoot).exp , runtime }) {
53
54
  if (_settings.APISettings.isOffline) {
55
+ debug("Development session will not ping because the server is offline.");
54
56
  this.stopNotifying();
55
57
  return;
56
58
  }
57
59
  const deviceIds = await this.getDeviceInstallationIdsAsync();
58
60
  if (!await isAuthenticatedAsync() && !(deviceIds == null ? void 0 : deviceIds.length)) {
61
+ debug("Development session will not ping because the user is not authenticated and there are no devices.");
59
62
  this.stopNotifying();
60
63
  return;
61
64
  }
62
65
  if (this.url) {
66
+ debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);
63
67
  await (0, _updateDevelopmentSession).updateDevelopmentSessionAsync({
64
68
  url: this.url,
65
69
  runtime,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport { APISettings } from '../../api/settings';\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport * as ProjectDevices from '../project/devices';\n\nconst UPDATE_FREQUENCY = 20 * 1000; // 20 seconds\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n private timeout: NodeJS.Timeout | null = null;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * This method starts an interval that will continue to ping the servers until we stop it.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n * @returns\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n if (APISettings.isOffline) {\n this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n }\n\n this.stopNotifying();\n\n this.timeout = setTimeout(() => this.startAsync({ exp, runtime }), UPDATE_FREQUENCY);\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Stop notifying the Expo servers that the development session is running. */\n public stopNotifying() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = null;\n }\n\n public async closeAsync(): Promise<void> {\n this.stopNotifying();\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n return;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n }\n}\n"],"names":["ProjectDevices","UPDATE_FREQUENCY","isAuthenticatedAsync","getUserAsync","catch","DevelopmentSession","constructor","projectRoot","url","timeout","startAsync","exp","getConfig","runtime","APISettings","isOffline","stopNotifying","deviceIds","getDeviceInstallationIdsAsync","length","updateDevelopmentSessionAsync","setTimeout","devices","getDevicesInfoAsync","map","installationId","clearTimeout","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc,CAAA;AAExB,IAAA,SAAoB,WAApB,oBAAoB,CAAA;AAIzC,IAAA,yBAAoC,WAApC,oCAAoC,CAAA;AACd,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACtCA,IAAAA,cAAc,mCAAM,oBAAoB,EAA1B;;;;;;;;;;;;;;;;;;;;;;AAE1B,MAAMC,gBAAgB,GAAG,EAAE,GAAG,IAAI,AAAC,EAAC,aAAa;AAEjD,eAAeC,oBAAoB,GAAqB;IACtD,OAAO,CAAC,CAAE,MAAMC,CAAAA,GAAAA,KAAY,AAAE,CAAA,aAAF,EAAE,CAACC,KAAK,CAAC,IAAM,IAAI;IAAA,CAAC,AAAC,CAAC;CACnD;AAEM,MAAMC,kBAAkB;IAG7BC,YAEUC,WAAmB,EAEpBC,GAAkB,CACzB;aAHQD,WAAmB,GAAnBA,WAAmB;aAEpBC,GAAkB,GAAlBA,GAAkB;aANnBC,OAAO,GAA0B,IAAI;KAOzC;IAEJ;;;;;;;;;;KAUG,CACH,MAAaC,UAAU,CAAC,EACtBC,GAAG,EAAGC,CAAAA,GAAAA,OAAS,AAAkB,CAAA,UAAlB,CAAC,IAAI,CAACL,WAAW,CAAC,CAACI,GAAG,CAAA,EACrCE,OAAO,CAAA,EAIR,EAAiB;QAChB,IAAIC,SAAW,YAAA,CAACC,SAAS,EAAE;YACzB,IAAI,CAACC,aAAa,EAAE,CAAC;YACrB,OAAO;SACR;QAED,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACC,6BAA6B,EAAE,AAAC;QAE7D,IAAI,CAAE,MAAMhB,oBAAoB,EAAE,AAAC,IAAI,CA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AAA,EAAE;YACzD,OAAO;SACR;QAED,IAAI,IAAI,CAACX,GAAG,EAAE;YACZ,MAAMoB,CAAAA,GAAAA,yBAA4B,AAGhC,CAAA,6BAHgC,CAAC;gBACjCpB,GAAG,EAAE,IAAI,CAACA,GAAG;gBACbS,SAAS;aACV,CAAC,CAAC;SACJ;KACF;CACF;QApFYZ,kBAAkB,GAAlBA,kBAAkB"}
1
+ {"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport { APISettings } from '../../api/settings';\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nconst UPDATE_FREQUENCY = 20 * 1000; // 20 seconds\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n private timeout: NodeJS.Timeout | null = null;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * This method starts an interval that will continue to ping the servers until we stop it.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n * @returns\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n if (APISettings.isOffline) {\n debug('Development session will not ping because the server is offline.');\n this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n }\n\n this.stopNotifying();\n\n this.timeout = setTimeout(() => this.startAsync({ exp, runtime }), UPDATE_FREQUENCY);\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Stop notifying the Expo servers that the development session is running. */\n public stopNotifying() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = null;\n }\n\n public async closeAsync(): Promise<void> {\n this.stopNotifying();\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n return;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n }\n}\n"],"names":["ProjectDevices","debug","require","UPDATE_FREQUENCY","isAuthenticatedAsync","getUserAsync","catch","DevelopmentSession","constructor","projectRoot","url","timeout","startAsync","exp","getConfig","runtime","APISettings","isOffline","stopNotifying","deviceIds","getDeviceInstallationIdsAsync","length","updateDevelopmentSessionAsync","setTimeout","devices","getDevicesInfoAsync","map","installationId","clearTimeout","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;AAAsC,IAAA,OAAc,WAAd,cAAc,CAAA;AAExB,IAAA,SAAoB,WAApB,oBAAoB,CAAA;AAIzC,IAAA,yBAAoC,WAApC,oCAAoC,CAAA;AACd,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACtCA,IAAAA,cAAc,mCAAM,oBAAoB,EAA1B;;;;;;;;;;;;;;;;;;;;;;AAE1B,MAAMC,KAAK,GAAGC,OAAO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CAAC,CAAC;SACJ;KACF;CACF;QAzFYZ,kBAAkB,GAAlBA,kBAAkB"}
@@ -32,6 +32,7 @@ function _interopRequireWildcard(obj) {
32
32
  return newObj;
33
33
  }
34
34
  }
35
+ const debug = require("debug")("expo:start:server:urlCreator");
35
36
  class UrlCreator {
36
37
  constructor(defaults, bundlerInfo){
37
38
  this.defaults = defaults;
@@ -47,7 +48,9 @@ class UrlCreator {
47
48
  url.search = new URLSearchParams({
48
49
  platform
49
50
  }).toString();
50
- return url.toString();
51
+ const loadingUrl = url.toString();
52
+ debug(`Loading URL: ${loadingUrl}`);
53
+ return loadingUrl;
51
54
  }
52
55
  /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */ constructDevClientUrl(options) {
53
56
  var ref;
@@ -63,14 +66,18 @@ class UrlCreator {
63
66
  ...options,
64
67
  scheme: "http"
65
68
  });
66
- return `${protocol}://expo-development-client/?url=${encodeURIComponent(manifestUrl)}`;
69
+ const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(manifestUrl)}`;
70
+ debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);
71
+ return devClientUrl;
67
72
  }
68
73
  /** Create a generic URL. */ constructUrl(options) {
69
74
  const urlComponents = this.getUrlComponents({
70
75
  ...this.defaults,
71
76
  ...options
72
77
  });
73
- return joinUrlComponents(urlComponents);
78
+ const url = joinUrlComponents(urlComponents);
79
+ debug(`URL: ${url}`);
80
+ return url;
74
81
  }
75
82
  /** Get the URL components from the Ngrok server URL. */ getTunnelUrlComponents(options) {
76
83
  var _bundlerInfo, ref;
@@ -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\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\nexport class UrlCreator {\n constructor(\n private defaults: CreateURLOptions | undefined,\n private bundlerInfo: { port: number; getTunnelUrl?: () => string | null }\n ) {}\n\n /**\n * @returns URL like `http://localhost:19000/_expo/loading?platform=ios`\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n url.search = new URLSearchParams({ platform }).toString();\n return url.toString();\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase())\n ) {\n return null;\n }\n\n const manifestUrl = this.constructUrl({ ...options, scheme: 'http' });\n return `${protocol}://expo-development-client/?url=${encodeURIComponent(manifestUrl)}`;\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 return joinUrlComponents(urlComponents);\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nfunction getDefaultHostname(options: Pick<CreateURLOptions, 'hostname'>) {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // Restrict the use of `localhost`\n // TODO: Note why we do this.\n return '127.0.0.1';\n }\n\n return options.hostname || getIpAddress();\n}\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n // Android HMR breaks without this port 80.\n // This is because Android React Native WebSocket implementation is not spec compliant and fails without a port:\n // `E unknown:ReactNative: java.lang.IllegalArgumentException: Invalid URL port: \"-1\"`\n // Invoked first in `metro-runtime/src/modules/HMRClient.js`\n const validPort = port || '80';\n const validProtocol = protocol ? `${protocol}://` : '';\n\n return `${validProtocol}${hostname}:${validPort}`;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["Log","UrlCreator","constructor","defaults","bundlerInfo","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","hostType","components","warn","getDefaultHostname","parsedProxyUrl","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","getIpAddress","assert","validPort","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACP,IAAA,IAAK,WAAL,KAAK,CAAA;AAEbA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACc,IAAA,GAAgB,WAAhB,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBtC,MAAMC,UAAU;IACrBC,YACUC,QAAsC,EACtCC,WAAiE,CACzE;aAFQD,QAAsC,GAAtCA,QAAsC;aACtCC,WAAiE,GAAjEA,WAAiE;KACvE;IAEJ;;KAEG,CACH,AAAOC,mBAAmB,CAACC,OAAyB,EAAEC,QAAgB,EAAU;QAC9E,MAAMC,GAAG,GAAG,IAAIC,IAAG,IAAA,CAAC,eAAe,EAAE,IAAI,CAACC,YAAY,CAAC;YAAEC,MAAM,EAAE,MAAM;YAAE,GAAGL,OAAO;SAAE,CAAC,CAAC,AAAC;QACxFE,GAAG,CAACI,MAAM,GAAG,IAAIC,eAAe,CAAC;YAAEN,QAAQ;SAAE,CAAC,CAACO,QAAQ,EAAE,CAAC;QAC1D,OAAON,GAAG,CAACM,QAAQ,EAAE,CAAC;KACvB;IAED,0GAA0G,CAC1G,AAAOC,qBAAqB,CAACT,OAA0B,EAAiB;YAClC,GAAa;QAAjD,MAAMU,QAAQ,GAAGV,CAAAA,OAAO,QAAQ,GAAfA,KAAAA,CAAe,GAAfA,OAAO,CAAEK,MA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C,CAAC;CACnD;AAED,kBAAkB,CAClB,SAASb,WAAW,GAAuB;IACzC,OAAOO,OAAO,CAACC,GAAG,CAACO,uBAAuB,CAAC;CAC5C,CAED,6CAA6C;CAC7C,iCAAiC;CACjC,0BAA0B"}
1
+ {"version":3,"sources":["../../../../src/start/server/UrlCreator.ts"],"sourcesContent":["import assert from 'assert';\nimport { URL } from 'url';\n\nimport * as Log from '../../log';\nimport { getIpAddress } from '../../utils/ip';\n\nconst debug = require('debug')('expo:start:server:urlCreator') as typeof console.log;\n\nexport interface CreateURLOptions {\n /** URL scheme to use when opening apps in custom runtimes. */\n scheme?: string | null;\n /** Type of dev server host to use. */\n hostType?: 'localhost' | 'lan' | 'tunnel';\n /** Requested hostname. */\n hostname?: string | null;\n}\n\ninterface UrlComponents {\n port: string;\n hostname: string;\n protocol: string;\n}\nexport class UrlCreator {\n constructor(\n private defaults: CreateURLOptions | undefined,\n private bundlerInfo: { port: number; getTunnelUrl?: () => string | null }\n ) {}\n\n /**\n * @returns URL like `http://localhost:19000/_expo/loading?platform=ios`\n */\n public constructLoadingUrl(options: CreateURLOptions, platform: string): string {\n const url = new URL('_expo/loading', this.constructUrl({ scheme: 'http', ...options }));\n url.search = new URLSearchParams({ platform }).toString();\n const loadingUrl = url.toString();\n debug(`Loading URL: ${loadingUrl}`);\n return loadingUrl;\n }\n\n /** Create a URI for launching in a native dev client. Returns `null` when no `scheme` can be resolved. */\n public constructDevClientUrl(options?: CreateURLOptions): null | string {\n const protocol = options?.scheme || this.defaults?.scheme;\n\n if (\n !protocol ||\n // Prohibit the use of http(s) in dev client URIs since they'll never be valid.\n ['http', 'https'].includes(protocol.toLowerCase())\n ) {\n return null;\n }\n\n const manifestUrl = this.constructUrl({ ...options, scheme: 'http' });\n const devClientUrl = `${protocol}://expo-development-client/?url=${encodeURIComponent(\n manifestUrl\n )}`;\n debug(`Dev client URL: ${devClientUrl} -- manifestUrl: ${manifestUrl} -- %O`, options);\n return devClientUrl;\n }\n\n /** Create a generic URL. */\n public constructUrl(options?: Partial<CreateURLOptions> | null): string {\n const urlComponents = this.getUrlComponents({\n ...this.defaults,\n ...options,\n });\n const url = joinUrlComponents(urlComponents);\n debug(`URL: ${url}`);\n return url;\n }\n\n /** Get the URL components from the Ngrok server URL. */\n private getTunnelUrlComponents(options: Pick<CreateURLOptions, 'scheme'>): UrlComponents | null {\n const tunnelUrl = this.bundlerInfo.getTunnelUrl?.();\n if (!tunnelUrl) {\n return null;\n }\n const parsed = new URL(tunnelUrl);\n return {\n port: parsed.port,\n hostname: parsed.hostname,\n protocol: options.scheme ?? 'http',\n };\n }\n\n private getUrlComponents(options: CreateURLOptions): UrlComponents {\n // Proxy comes first.\n const proxyURL = getProxyUrl();\n if (proxyURL) {\n return getUrlComponentsFromProxyUrl(options, proxyURL);\n }\n\n // Ngrok.\n if (options.hostType === 'tunnel') {\n const components = this.getTunnelUrlComponents(options);\n if (components) {\n return components;\n }\n Log.warn('Tunnel URL not found (it might not be ready yet), falling back to LAN URL.');\n } else if (options.hostType === 'localhost' && !options.hostname) {\n options.hostname = 'localhost';\n }\n\n return {\n hostname: getDefaultHostname(options),\n port: this.bundlerInfo.port.toString(),\n protocol: options.scheme ?? 'http',\n };\n }\n}\n\nfunction getUrlComponentsFromProxyUrl(\n options: Pick<CreateURLOptions, 'scheme'>,\n url: string\n): UrlComponents {\n const parsedProxyUrl = new URL(url);\n let protocol = options.scheme ?? 'http';\n if (parsedProxyUrl.protocol === 'https:') {\n if (protocol === 'http') {\n protocol = 'https';\n }\n if (!parsedProxyUrl.port) {\n parsedProxyUrl.port = '443';\n }\n }\n return {\n port: parsedProxyUrl.port,\n hostname: parsedProxyUrl.hostname,\n protocol,\n };\n}\n\nfunction getDefaultHostname(options: Pick<CreateURLOptions, 'hostname'>) {\n // TODO: Drop REACT_NATIVE_PACKAGER_HOSTNAME\n if (process.env.REACT_NATIVE_PACKAGER_HOSTNAME) {\n return process.env.REACT_NATIVE_PACKAGER_HOSTNAME.trim();\n } else if (options.hostname === 'localhost') {\n // Restrict the use of `localhost`\n // TODO: Note why we do this.\n return '127.0.0.1';\n }\n\n return options.hostname || getIpAddress();\n}\n\nfunction joinUrlComponents({ protocol, hostname, port }: Partial<UrlComponents>): string {\n assert(hostname, 'hostname cannot be inferred.');\n // Android HMR breaks without this port 80.\n // This is because Android React Native WebSocket implementation is not spec compliant and fails without a port:\n // `E unknown:ReactNative: java.lang.IllegalArgumentException: Invalid URL port: \"-1\"`\n // Invoked first in `metro-runtime/src/modules/HMRClient.js`\n const validPort = port || '80';\n const validProtocol = protocol ? `${protocol}://` : '';\n\n return `${validProtocol}${hostname}:${validPort}`;\n}\n\n/** @deprecated */\nfunction getProxyUrl(): string | undefined {\n return process.env.EXPO_PACKAGER_PROXY_URL;\n}\n\n// TODO: Drop the undocumented env variables:\n// REACT_NATIVE_PACKAGER_HOSTNAME\n// EXPO_PACKAGER_PROXY_URL\n"],"names":["Log","debug","require","UrlCreator","constructor","defaults","bundlerInfo","constructLoadingUrl","options","platform","url","URL","constructUrl","scheme","search","URLSearchParams","toString","loadingUrl","constructDevClientUrl","protocol","includes","toLowerCase","manifestUrl","devClientUrl","encodeURIComponent","urlComponents","getUrlComponents","joinUrlComponents","getTunnelUrlComponents","tunnelUrl","getTunnelUrl","parsed","port","hostname","proxyURL","getProxyUrl","getUrlComponentsFromProxyUrl","hostType","components","warn","getDefaultHostname","parsedProxyUrl","process","env","REACT_NATIVE_PACKAGER_HOSTNAME","trim","getIpAddress","assert","validPort","validProtocol","EXPO_PACKAGER_PROXY_URL"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACP,IAAA,IAAK,WAAL,KAAK,CAAA;AAEbA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACc,IAAA,GAAgB,WAAhB,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,8BAA8B,C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5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  var _devServer = require("@expo/dev-server");
6
6
  var _port = require("../../../utils/port");
7
7
  var _bundlerDevServer = require("../BundlerDevServer");
8
+ var _historyFallbackMiddleware = require("../middleware/HistoryFallbackMiddleware");
8
9
  var _interstitialPageMiddleware = require("../middleware/InterstitialPageMiddleware");
9
10
  var _runtimeRedirectMiddleware = require("../middleware/RuntimeRedirectMiddleware");
11
+ var _serveStaticMiddleware = require("../middleware/ServeStaticMiddleware");
10
12
  var _instantiateMetro = require("./instantiateMetro");
11
13
  /** Default port to use for apps running in Expo Go. */ const EXPO_GO_METRO_PORT = 19000;
12
14
  /** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */ const DEV_CLIENT_METRO_PORT = 8081;
@@ -61,6 +63,13 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
61
63
  }
62
64
  });
63
65
  middleware.use(deepLinkMiddleware.getHandler());
66
+ // Append support for redirecting unhandled requests to the index.html page on web.
67
+ if (this.isTargetingWeb()) {
68
+ // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.
69
+ middleware.use(new _serveStaticMiddleware.ServeStaticMiddleware(this.projectRoot).getHandler());
70
+ // This MUST run last since it's the fallback.
71
+ middleware.use(new _historyFallbackMiddleware.HistoryFallbackMiddleware(manifestMiddleware.internal).getHandler());
72
+ }
64
73
  // Extend the close method to ensure that we clean up the local info.
65
74
  const originalClose = server.close.bind(server);
66
75
  server.close = (callback)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.ts"],"sourcesContent":["import { prependMiddleware } from '@expo/dev-server';\n\nimport { getFreePortAsync } from '../../../utils/port';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport { RuntimeRedirectMiddleware } from '../middleware/RuntimeRedirectMiddleware';\nimport { instantiateMetroAsync } from './instantiateMetro';\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 19000;\n\n/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */\nconst DEV_CLIENT_METRO_PORT = 8081;\n\nexport class MetroBundlerDevServer extends BundlerDevServer {\n get name(): string {\n return 'metro';\n }\n\n async resolvePortAsync(options: Partial<BundlerStartOptions> = {}): Promise<number> {\n const port =\n // If the manually defined port is busy then an error should be thrown...\n options.port ??\n // Otherwise use the default port based on the runtime target.\n (options.devClient\n ? // Don't check if the port is busy if we're using the dev client since most clients are hardcoded to 8081.\n Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT\n : // Otherwise (running in Expo Go) use a free port that falls back on the classic 19000 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n options.port = await this.resolvePortAsync(options);\n this.urlCreator = this.getUrlCreator(options);\n\n const parsedOptions = {\n port: options.port,\n maxWorkers: options.maxWorkers,\n resetCache: options.resetDevServer,\n\n // Use the unversioned metro config.\n // TODO: Deprecate this property when expo-cli goes away.\n unversioned: false,\n };\n\n const { server, middleware, messageSocket } = await instantiateMetroAsync(\n this.projectRoot,\n parsedOptions\n );\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // We need the manifest handler to be the first middleware to run so our\n // routes take precedence over static files. For example, the manifest is\n // served from '/' and if the user has an index.html file in their project\n // then the manifest handler will never run, the static middleware will run\n // and serve index.html instead of the manifest.\n // https://github.com/expo/expo/issues/13114\n prependMiddleware(middleware, manifestMiddleware);\n\n middleware.use(new InterstitialPageMiddleware(this.projectRoot).getHandler());\n\n const deepLinkMiddleware = new RuntimeRedirectMiddleware(this.projectRoot, {\n onDeepLink: ({ runtime }) => {\n // eslint-disable-next-line no-useless-return\n if (runtime === 'expo') return;\n // TODO: Some heavy analytics...\n },\n getLocation: ({ runtime }) => {\n if (runtime === 'custom') {\n return this.urlCreator?.constructDevClientUrl();\n } else {\n return this.urlCreator?.constructUrl({\n scheme: 'exp',\n });\n }\n },\n });\n middleware.use(deepLinkMiddleware.getHandler());\n\n // Extend the close method to ensure that we clean up the local info.\n const originalClose = server.close.bind(server);\n\n server.close = (callback?: (err?: Error) => void) => {\n return originalClose((err?: Error) => {\n this.instance = null;\n callback?.(err);\n });\n };\n\n return {\n server,\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 };\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./metro.config.js', './metro.config.json', './rn-cli.config.js'];\n }\n}\n"],"names":["EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","MetroBundlerDevServer","BundlerDevServer","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","startImplementationAsync","urlCreator","getUrlCreator","parsedOptions","maxWorkers","resetCache","resetDevServer","unversioned","server","middleware","messageSocket","instantiateMetroAsync","projectRoot","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","use","InterstitialPageMiddleware","getHandler","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","runtime","getLocation","constructDevClientUrl","constructUrl","scheme","originalClose","close","bind","callback","err","instance","location","host","url","protocol","getConfigModuleIds"],"mappings":"AAAA;;;;AAAkC,IAAA,UAAkB,WAAlB,kBAAkB,CAAA;AAEnB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACmB,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACnD,IAAA,2BAA0C,WAA1C,0CAA0C,CAAA;AAC3C,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AAC7C,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAE1D,uDAAuD,CACvD,MAAMA,kBAAkB,GAAG,KAAK,AAAC;AAEjC,mGAAmG,CACnG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C;gBACrBF,QAAQ,QAAO,GAAfA,KAAAA,CAAe,GAAfA,QAAQ,CAAGC,GAAG,CAAC,AA1FvB,CA0FwB;aACjB,CAAC,CAAC;SACJ,CAAC;QAEF,OAAO;YACLvB,MAAM;YACNyB,QAAQ,EAAE;gBACR,mDAAmD;gBACnDxC,IAAI,EAAED,OAAO,CAACC,IAAI;gBAClB,kCAAkC;gBAClCyC,IAAI,EAAE,WAAW;gBACjB,iDAAiD;gBACjDC,GAAG,EAAE,CAAC,iBAAiB,EAAE3C,OAAO,CAACC,IAAI,CAAC,CAAC;gBACvC2C,QAAQ,EAAE,MAAM;aACjB;YACD3B,UAAU;YACVC,aAAa;SACd,CAAC;KACH;IAED,AAAU2B,kBAAkB,GAAa;QACvC,OAAO;YAAC,mBAAmB;YAAE,qBAAqB;YAAE,oBAAoB;SAAC,CAAC;KAC3E;CACF;QAnGYjD,qBAAqB,GAArBA,qBAAqB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.ts"],"sourcesContent":["import { prependMiddleware } from '@expo/dev-server';\n\nimport { getFreePortAsync } from '../../../utils/port';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport { HistoryFallbackMiddleware } from '../middleware/HistoryFallbackMiddleware';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport { RuntimeRedirectMiddleware } from '../middleware/RuntimeRedirectMiddleware';\nimport { ServeStaticMiddleware } from '../middleware/ServeStaticMiddleware';\nimport { instantiateMetroAsync } from './instantiateMetro';\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 19000;\n\n/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */\nconst DEV_CLIENT_METRO_PORT = 8081;\n\nexport class MetroBundlerDevServer extends BundlerDevServer {\n get name(): string {\n return 'metro';\n }\n\n async resolvePortAsync(options: Partial<BundlerStartOptions> = {}): Promise<number> {\n const port =\n // If the manually defined port is busy then an error should be thrown...\n options.port ??\n // Otherwise use the default port based on the runtime target.\n (options.devClient\n ? // Don't check if the port is busy if we're using the dev client since most clients are hardcoded to 8081.\n Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT\n : // Otherwise (running in Expo Go) use a free port that falls back on the classic 19000 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n options.port = await this.resolvePortAsync(options);\n this.urlCreator = this.getUrlCreator(options);\n\n const parsedOptions = {\n port: options.port,\n maxWorkers: options.maxWorkers,\n resetCache: options.resetDevServer,\n\n // Use the unversioned metro config.\n // TODO: Deprecate this property when expo-cli goes away.\n unversioned: false,\n };\n\n const { server, middleware, messageSocket } = await instantiateMetroAsync(\n this.projectRoot,\n parsedOptions\n );\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // We need the manifest handler to be the first middleware to run so our\n // routes take precedence over static files. For example, the manifest is\n // served from '/' and if the user has an index.html file in their project\n // then the manifest handler will never run, the static middleware will run\n // and serve index.html instead of the manifest.\n // https://github.com/expo/expo/issues/13114\n prependMiddleware(middleware, manifestMiddleware);\n\n middleware.use(new InterstitialPageMiddleware(this.projectRoot).getHandler());\n\n const deepLinkMiddleware = new RuntimeRedirectMiddleware(this.projectRoot, {\n onDeepLink: ({ runtime }) => {\n // eslint-disable-next-line no-useless-return\n if (runtime === 'expo') return;\n // TODO: Some heavy analytics...\n },\n getLocation: ({ runtime }) => {\n if (runtime === 'custom') {\n return this.urlCreator?.constructDevClientUrl();\n } else {\n return this.urlCreator?.constructUrl({\n scheme: 'exp',\n });\n }\n },\n });\n middleware.use(deepLinkMiddleware.getHandler());\n\n // Append support for redirecting unhandled requests to the index.html page on web.\n if (this.isTargetingWeb()) {\n // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.\n middleware.use(new ServeStaticMiddleware(this.projectRoot).getHandler());\n\n // This MUST run last since it's the fallback.\n middleware.use(new HistoryFallbackMiddleware(manifestMiddleware.internal).getHandler());\n }\n // Extend the close method to ensure that we clean up the local info.\n const originalClose = server.close.bind(server);\n\n server.close = (callback?: (err?: Error) => void) => {\n return originalClose((err?: Error) => {\n this.instance = null;\n callback?.(err);\n });\n };\n\n return {\n server,\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 };\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./metro.config.js', './metro.config.json', './rn-cli.config.js'];\n }\n}\n"],"names":["EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","MetroBundlerDevServer","BundlerDevServer","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","startImplementationAsync","urlCreator","getUrlCreator","parsedOptions","maxWorkers","resetCache","resetDevServer","unversioned","server","middleware","messageSocket","instantiateMetroAsync","projectRoot","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","use","InterstitialPageMiddleware","getHandler","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","runtime","getLocation","constructDevClientUrl","constructUrl","scheme","isTargetingWeb","ServeStaticMiddleware","HistoryFallbackMiddleware","internal","originalClose","close","bind","callback","err","instance","location","host","url","protocol","getConfigModuleIds"],"mappings":"AAAA;;;;AAAkC,IAAA,UAAkB,WAAlB,kBAAkB,CAAA;AAEnB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACmB,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACpD,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AACxC,IAAA,2BAA0C,WAA1C,0CAA0C,CAAA;AAC3C,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AAC7C,IAAA,sBAAqC,WAArC,qCAAqC,CAAA;AACrC,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAE1D,uD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AAE,CAAC,CAAC;YAEzE,8CAA8C;YAC9CT,UAAU,CAACO,GAAG,CAAC,IAAIa,0BAAyB,0BAAA,CAAChB,kBAAkB,CAACiB,QAAQ,CAAC,CAACZ,UAAU,EAAE,CAAC,CAAC;SACzF;QACD,qEAAqE;QACrE,MAAMa,aAAa,GAAGvB,MAAM,CAACwB,KAAK,CAACC,IAAI,CAACzB,MAAM,CAAC,AAAC;QAEhDA,MAAM,CAACwB,KAAK,GAAG,CAACE,QAAgC,GAAK;YACnD,OAAOH,aAAa,CAAC,CAACI,GAAW,GAAK;gBACpC,IAAI,CAACC,QAAQ,GAAG,IAAI,CAAC;gBACrBF,QAAQ,QAAO,GAAfA,KAAAA,CAAe,GAAfA,QAAQ,CAAGC,GAAG,CAAC,AApGvB,CAoGwB;aACjB,CAAC,CAAC;SACJ,CAAC;QAEF,OAAO;YACL3B,MAAM;YACN6B,QAAQ,EAAE;gBACR,mDAAmD;gBACnD5C,IAAI,EAAED,OAAO,CAACC,IAAI;gBAClB,kCAAkC;gBAClC6C,IAAI,EAAE,WAAW;gBACjB,iDAAiD;gBACjDC,GAAG,EAAE,CAAC,iBAAiB,EAAE/C,OAAO,CAACC,IAAI,CAAC,CAAC;gBACvC+C,QAAQ,EAAE,MAAM;aACjB;YACD/B,UAAU;YACVC,aAAa;SACd,CAAC;KACH;IAED,AAAU+B,kBAAkB,GAAa;QACvC,OAAO;YAAC,mBAAmB;YAAE,qBAAqB;YAAE,oBAAoB;SAAC,CAAC;KAC3E;CACF;QA3GYrD,qBAAqB,GAArBA,qBAAqB"}
@@ -71,6 +71,11 @@ class TerminalReporter extends XTerminalReporter {
71
71
  case "bundle_build_failed":
72
72
  {
73
73
  const startTime = this._bundleTimers.get(event.buildID);
74
+ // Observed a bug in Metro where the `bundle_build_done` is invoked twice during a static bundle
75
+ // i.e. `expo export`.
76
+ if (startTime == null) {
77
+ break;
78
+ }
74
79
  this.bundleBuildEnded(event, startTime ? Date.now() - startTime : 0);
75
80
  this._bundleTimers.delete(event.buildID);
76
81
  break;