@expo/cli 0.1.5 → 0.2.2

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 (192) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/build/bin/cli +83 -4
  3. package/build/bin/cli.map +1 -1
  4. package/build/src/api/getNativeModuleVersions.js.map +1 -1
  5. package/build/src/api/rest/wrapFetchWithOffline.js +2 -23
  6. package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
  7. package/build/src/customize/customizeAsync.js +40 -0
  8. package/build/src/customize/customizeAsync.js.map +1 -0
  9. package/build/src/customize/generate.js +77 -0
  10. package/build/src/customize/generate.js.map +1 -0
  11. package/build/src/customize/index.js +41 -0
  12. package/build/src/customize/index.js.map +1 -0
  13. package/build/src/customize/resolveOptions.js +18 -0
  14. package/build/src/customize/resolveOptions.js.map +1 -0
  15. package/build/src/customize/templates.js +118 -0
  16. package/build/src/customize/templates.js.map +1 -0
  17. package/build/src/export/createMetadataJson.js +10 -7
  18. package/build/src/export/createMetadataJson.js.map +1 -1
  19. package/build/src/export/exportApp.js +32 -0
  20. package/build/src/export/exportApp.js.map +1 -1
  21. package/build/src/export/exportAssets.js +2 -3
  22. package/build/src/export/exportAssets.js.map +1 -1
  23. package/build/src/export/fork-bundleAsync.js +52 -35
  24. package/build/src/export/fork-bundleAsync.js.map +1 -1
  25. package/build/src/export/index.js +14 -10
  26. package/build/src/export/index.js.map +1 -1
  27. package/build/src/export/printBundleSizes.js +27 -48
  28. package/build/src/export/printBundleSizes.js.map +1 -1
  29. package/build/src/export/resolveOptions.js +44 -5
  30. package/build/src/export/resolveOptions.js.map +1 -1
  31. package/build/src/export/saveAssets.js +2 -1
  32. package/build/src/export/saveAssets.js.map +1 -1
  33. package/build/src/export/web/exportWebAsync.js +37 -0
  34. package/build/src/export/web/exportWebAsync.js.map +1 -0
  35. package/build/src/export/web/index.js +66 -0
  36. package/build/src/export/web/index.js.map +1 -0
  37. package/build/src/export/web/resolveOptions.js +13 -0
  38. package/build/src/export/web/resolveOptions.js.map +1 -0
  39. package/build/src/export/writeContents.js.map +1 -1
  40. package/build/src/install/checkPackages.js +2 -1
  41. package/build/src/install/checkPackages.js.map +1 -1
  42. package/build/src/install/index.js +1 -0
  43. package/build/src/install/index.js.map +1 -1
  44. package/build/src/install/installAsync.js +13 -5
  45. package/build/src/install/installAsync.js.map +1 -1
  46. package/build/src/install/resolveOptions.js +12 -65
  47. package/build/src/install/resolveOptions.js.map +1 -1
  48. package/build/src/install/utils/autoAddConfigPlugins.js +5 -26
  49. package/build/src/install/utils/autoAddConfigPlugins.js.map +1 -1
  50. package/build/src/log.js.map +1 -1
  51. package/build/src/prebuild/copyTemplateFiles.js +5 -23
  52. package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
  53. package/build/src/prebuild/index.js +18 -12
  54. package/build/src/prebuild/index.js.map +1 -1
  55. package/build/src/prebuild/prebuildAsync.js +11 -12
  56. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  57. package/build/src/prebuild/resolveOptions.js +17 -0
  58. package/build/src/prebuild/resolveOptions.js.map +1 -1
  59. package/build/src/prebuild/resolveTemplate.js +2 -1
  60. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  61. package/build/src/prebuild/updatePackageJson.js +5 -5
  62. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  63. package/build/src/run/android/resolveInstallApkName.js +5 -26
  64. package/build/src/run/android/resolveInstallApkName.js.map +1 -1
  65. package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js +2 -0
  66. package/build/src/start/doctor/apple/SimulatorAppPrerequisite.js.map +1 -1
  67. package/build/src/start/doctor/apple/XcodePrerequisite.js +2 -0
  68. package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
  69. package/build/src/start/doctor/dependencies/bundledNativeModules.js +3 -2
  70. package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
  71. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +7 -13
  72. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  73. package/build/src/start/doctor/dependencies/getMissingPackages.js +3 -24
  74. package/build/src/start/doctor/dependencies/getMissingPackages.js.map +1 -1
  75. package/build/src/start/doctor/dependencies/getVersionedPackages.js +2 -23
  76. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  77. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +17 -9
  78. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  79. package/build/src/start/doctor/ngrok/ExternalModule.js +2 -1
  80. package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
  81. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +4 -3
  82. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
  83. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +29 -31
  84. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
  85. package/build/src/start/interface/KeyPressHandler.js +2 -0
  86. package/build/src/start/interface/KeyPressHandler.js.map +1 -1
  87. package/build/src/start/interface/interactiveActions.js +5 -5
  88. package/build/src/start/interface/interactiveActions.js.map +1 -1
  89. package/build/src/start/interface/startInterface.js +3 -2
  90. package/build/src/start/interface/startInterface.js.map +1 -1
  91. package/build/src/start/platforms/ExpoGoInstaller.js +2 -1
  92. package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
  93. package/build/src/start/platforms/PlatformManager.js +4 -24
  94. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  95. package/build/src/start/platforms/android/ADBServer.js +17 -32
  96. package/build/src/start/platforms/android/ADBServer.js.map +1 -1
  97. package/build/src/start/platforms/android/AndroidSdk.js +41 -0
  98. package/build/src/start/platforms/android/AndroidSdk.js.map +1 -0
  99. package/build/src/start/platforms/android/activateWindow.js +4 -4
  100. package/build/src/start/platforms/android/activateWindow.js.map +1 -1
  101. package/build/src/start/platforms/android/adb.js +8 -3
  102. package/build/src/start/platforms/android/adb.js.map +1 -1
  103. package/build/src/start/platforms/android/adbReverse.js +3 -2
  104. package/build/src/start/platforms/android/adbReverse.js.map +1 -1
  105. package/build/src/start/platforms/android/gradle.js +2 -2
  106. package/build/src/start/platforms/android/gradle.js.map +1 -1
  107. package/build/src/start/platforms/ios/getBestSimulator.js +4 -4
  108. package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
  109. package/build/src/start/platforms/ios/xcrun.js +2 -23
  110. package/build/src/start/platforms/ios/xcrun.js.map +1 -1
  111. package/build/src/start/project/devices.js +2 -0
  112. package/build/src/start/project/devices.js.map +1 -1
  113. package/build/src/start/server/AsyncNgrok.js +6 -5
  114. package/build/src/start/server/AsyncNgrok.js.map +1 -1
  115. package/build/src/start/server/BundlerDevServer.js +15 -8
  116. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  117. package/build/src/start/server/DevServerManager.js +15 -5
  118. package/build/src/start/server/DevServerManager.js.map +1 -1
  119. package/build/src/start/server/DevelopmentSession.js +4 -0
  120. package/build/src/start/server/DevelopmentSession.js.map +1 -1
  121. package/build/src/start/server/UrlCreator.js +10 -3
  122. package/build/src/start/server/UrlCreator.js.map +1 -1
  123. package/build/src/start/server/metro/MetroBundlerDevServer.js +9 -0
  124. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  125. package/build/src/start/server/metro/TerminalReporter.js +5 -0
  126. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  127. package/build/src/start/server/metro/instantiateMetro.js +11 -2
  128. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  129. package/build/src/start/server/metro/resolveFromProject.js +8 -0
  130. package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
  131. package/build/src/start/server/metro/withMetroMultiPlatform.js +115 -0
  132. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -0
  133. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +1 -1
  134. package/build/src/start/server/middleware/ExpoMiddleware.js +9 -4
  135. package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
  136. package/build/src/start/server/middleware/HistoryFallbackMiddleware.js +24 -0
  137. package/build/src/start/server/middleware/HistoryFallbackMiddleware.js.map +1 -0
  138. package/build/src/start/server/middleware/InterstitialPageMiddleware.js +2 -0
  139. package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
  140. package/build/src/start/server/middleware/ManifestMiddleware.js +57 -6
  141. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  142. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +6 -1
  143. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
  144. package/build/src/start/server/middleware/ServeStaticMiddleware.js +62 -0
  145. package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -0
  146. package/build/src/start/server/platformBundlers.js +18 -0
  147. package/build/src/start/server/platformBundlers.js.map +1 -0
  148. package/build/src/start/server/webTemplate.js +68 -0
  149. package/build/src/start/server/webTemplate.js.map +1 -0
  150. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +59 -19
  151. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  152. package/build/src/start/server/webpack/compile.js +64 -0
  153. package/build/src/start/server/webpack/compile.js.map +1 -0
  154. package/build/src/start/startAsync.js +21 -17
  155. package/build/src/start/startAsync.js.map +1 -1
  156. package/build/src/utils/FileNotifier.js +5 -2
  157. package/build/src/utils/FileNotifier.js.map +1 -1
  158. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  159. package/build/src/utils/downloadAppAsync.js +3 -2
  160. package/build/src/utils/downloadAppAsync.js.map +1 -1
  161. package/build/src/utils/downloadExpoGoAsync.js +7 -32
  162. package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
  163. package/build/src/utils/editor.js +3 -2
  164. package/build/src/utils/editor.js.map +1 -1
  165. package/build/src/utils/env.js +3 -0
  166. package/build/src/utils/env.js.map +1 -1
  167. package/build/src/utils/exit.js +4 -25
  168. package/build/src/utils/exit.js.map +1 -1
  169. package/build/src/utils/getRunningProcess.js +6 -2
  170. package/build/src/utils/getRunningProcess.js.map +1 -1
  171. package/build/src/utils/nodeModules.js +13 -102
  172. package/build/src/utils/nodeModules.js.map +1 -1
  173. package/build/src/utils/npm.js +3 -24
  174. package/build/src/utils/npm.js.map +1 -1
  175. package/build/src/utils/ora.js +1 -13
  176. package/build/src/utils/ora.js.map +1 -1
  177. package/build/src/utils/progress.js +46 -0
  178. package/build/src/utils/progress.js.map +1 -1
  179. package/build/src/utils/prompts.js +4 -4
  180. package/build/src/utils/prompts.js.map +1 -1
  181. package/build/src/utils/tar.js +3 -0
  182. package/build/src/utils/tar.js.map +1 -1
  183. package/build/src/utils/validateApplicationId.js +9 -2
  184. package/build/src/utils/validateApplicationId.js.map +1 -1
  185. package/build/src/utils/variadic.js +47 -0
  186. package/build/src/utils/variadic.js.map +1 -0
  187. package/package.json +13 -8
  188. package/static/template/babel.config.js +6 -0
  189. package/static/template/index.html +117 -0
  190. package/static/template/metro.config.js +4 -0
  191. package/static/template/serve.json +13 -0
  192. package/static/template/webpack.config.js +7 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/ios/getBestSimulator.ts"],"sourcesContent":["import { execSync } from 'child_process';\n\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\nimport * as SimControl from './simctl';\n\ntype DeviceContext = Partial<Pick<SimControl.Device, 'osType'>>;\n\n/**\n * Returns the default device stored in the Simulator.app settings.\n * This helps us to get the device that the user opened most recently regardless of which tool they used.\n */\nfunction getDefaultSimulatorDeviceUDID() {\n try {\n const defaultDeviceUDID = execSync(\n `defaults read com.apple.iphonesimulator CurrentDeviceUDID`,\n { stdio: 'pipe' }\n ).toString();\n return defaultDeviceUDID.trim();\n } catch {\n return null;\n }\n}\n\nexport async function getBestBootedSimulatorAsync({\n osType,\n}: DeviceContext = {}): Promise<SimControl.Device | null> {\n const [simulatorOpenedByApp] = await SimControl.getBootedSimulatorsAsync();\n // This should prevent opening a second simulator in the chance that default\n // simulator doesn't match what the Simulator app would open by default.\n if (\n simulatorOpenedByApp?.udid &&\n (!osType || (osType && simulatorOpenedByApp.osType === osType))\n ) {\n Log.debug(`First booted simulator: ${simulatorOpenedByApp?.windowName}`);\n return simulatorOpenedByApp;\n }\n\n Log.debug(`No booted simulator matching requirements (osType: ${osType}).`);\n return null;\n}\n\n/**\n * Returns the most preferred simulator UDID without booting anything.\n *\n * 1. If the simulator app defines a default simulator and the osType is not defined.\n * 2. If the osType is defined, then check if the default udid matches the osType.\n * 3. If all else fails, return the first found simulator.\n */\nexport async function getBestUnbootedSimulatorAsync({ osType }: DeviceContext = {}): Promise<\n string | null\n> {\n const defaultId = getDefaultSimulatorDeviceUDID();\n Log.debug(`Default simulator ID: ${defaultId}`);\n\n if (defaultId && !osType) {\n return defaultId;\n }\n\n const simulators = await getSelectableSimulatorsAsync({ osType });\n\n if (!simulators.length) {\n // TODO: Prompt to install the simulators\n throw new CommandError(\n 'UNSUPPORTED_OS_TYPE',\n `No ${osType || 'iOS'} devices available in Simulator.app`\n );\n }\n\n // If the default udid is defined, then check to ensure its osType matches the required os.\n if (defaultId) {\n const defaultSimulator = simulators.find((device) => device.udid === defaultId);\n if (defaultSimulator?.osType === osType) {\n return defaultId;\n }\n }\n\n // Return first selectable device.\n return simulators[0]?.udid ?? null;\n}\n\n/**\n * Get all simulators supported by Expo Go (iOS only).\n */\nexport async function getSelectableSimulatorsAsync({ osType = 'iOS' }: DeviceContext = {}): Promise<\n SimControl.Device[]\n> {\n const simulators = await SimControl.getDevicesAsync();\n return simulators.filter((device) => device.isAvailable && device.osType === osType);\n}\n\n/**\n * Get 'best' simulator for the user based on:\n * 1. Currently booted simulator.\n * 2. Last simulator that was opened.\n * 3. First simulator that was opened.\n */\nexport async function getBestSimulatorAsync({ osType }: DeviceContext): Promise<string | null> {\n const simulatorOpenedByApp = await getBestBootedSimulatorAsync({ osType });\n\n if (simulatorOpenedByApp) {\n return simulatorOpenedByApp.udid;\n }\n\n return await getBestUnbootedSimulatorAsync({ osType });\n}\n"],"names":["getBestBootedSimulatorAsync","getBestUnbootedSimulatorAsync","getSelectableSimulatorsAsync","getBestSimulatorAsync","Log","SimControl","getDefaultSimulatorDeviceUDID","defaultDeviceUDID","execSync","stdio","toString","trim","osType","simulatorOpenedByApp","getBootedSimulatorsAsync","udid","debug","windowName","simulators","defaultId","length","CommandError","defaultSimulator","find","device","getDevicesAsync","filter","isAvailable"],"mappings":"AAAA;;;;QAwBsBA,2BAA2B,GAA3BA,2BAA2B;QAyB3BC,6BAA6B,GAA7BA,6BAA6B;QAmC7BC,4BAA4B,GAA5BA,4BAA4B;QAa5BC,qBAAqB,GAArBA,qBAAqB;AAjGlB,IAAA,aAAe,WAAf,eAAe,CAAA;AAE5BC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACxCC,IAAAA,UAAU,mCAAM,UAAU,EAAhB;;;;;;;;;;;;;;;;;;;;;;AAItB;;;GAGG,CACH,SAASC,6BAA6B,GAAG;IACvC,IAAI;QACF,MAAMC,iBAAiB,GAAGC,CAAAA,GAAAA,aAAQ,AAGjC,CAAA,SAHiC,CAChC,CAAC,yDAAyD,CAAC,EAC3D;YAAEC,KAAK,EAAE,MAAM;SAAE,CAClB,CAACC,QAAQ,EAAE,AAAC;QACb,OAAOH,iBAAiB,CAACI,IAAI,EAAE,CAAC;KACjC,CAAC,OAAM;QACN,OAAO,IAAI,CAAC;KACb;CACF;AAEM,eAAeX,2BAA2B,CAAC,EAChDY,MAAM,CAAA,EACQ,GAAG,EAAE,EAAqC;IACxD,MAAM,CAACC,oBAAoB,CAAC,GAAG,MAAMR,UAAU,CAACS,wBAAwB,EAAE,AAAC;IAC3E,4EAA4E;IAC5E,wEAAwE;IACxE,IACED,CAAAA,oBAAoB,QAAM,GAA1BA,KAAAA,CAA0B,GAA1BA,oBAAoB,CAAEE,IAAI,C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E;YACvC,OAAOO,SAAS,CAAC;SAClB;KACF;QAGMD,IAAmB;IAD1B,kCAAkC;IAClC,OAAOA,CAAAA,IAAmB,GAAnBA,CAAAA,GAAa,GAAbA,UAAU,CAAC,CAAC,CAAC,SAAM,GAAnBA,KAAAA,CAAmB,GAAnBA,GAAa,CAAEH,IAAI,YAAnBG,IAAmB,GAAI,IAAI,CAAC;CACpC;AAKM,eAAehB,4BAA4B,CAAC,EAAEU,MAAM,EAAG,KAAK,CAAA,EAAiB,GAAG,EAAE,EAEvF;IACA,MAAMM,UAAU,GAAG,MAAMb,UAAU,CAACoB,eAAe,EAAE,AAAC;IACtD,OAAOP,UAAU,CAACQ,MAAM,CAAC,CAACF,MAAM,GAAKA,MAAM,CAACG,WAAW,IAAIH,MAAM,CAACZ,MAAM,KAAKA,MAAM;IAAA,CAAC,CAAC;CACtF;AAQM,eAAeT,qBAAqB,CAAC,EAAES,MAAM,CAAA,EAAiB,EAA0B;IAC7F,MAAMC,oBAAoB,GAAG,MAAMb,2BAA2B,CAAC;QAAEY,MAAM;KAAE,CAAC,AAAC;IAE3E,IAAIC,oBAAoB,EAAE;QACxB,OAAOA,oBAAoB,CAACE,IAAI,CAAC;KAClC;IAED,OAAO,MAAMd,6BAA6B,CAAC;QAAEW,MAAM;KAAE,CAAC,CAAC;CACxD"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/ios/getBestSimulator.ts"],"sourcesContent":["import { execSync } from 'child_process';\n\nimport { CommandError } from '../../../utils/errors';\nimport * as SimControl from './simctl';\n\nconst debug = require('debug')('expo:start:platforms:ios:getBestSimulator') as typeof console.log;\n\ntype DeviceContext = Partial<Pick<SimControl.Device, 'osType'>>;\n\n/**\n * Returns the default device stored in the Simulator.app settings.\n * This helps us to get the device that the user opened most recently regardless of which tool they used.\n */\nfunction getDefaultSimulatorDeviceUDID() {\n try {\n const defaultDeviceUDID = execSync(\n `defaults read com.apple.iphonesimulator CurrentDeviceUDID`,\n { stdio: 'pipe' }\n ).toString();\n return defaultDeviceUDID.trim();\n } catch {\n return null;\n }\n}\n\nexport async function getBestBootedSimulatorAsync({\n osType,\n}: DeviceContext = {}): Promise<SimControl.Device | null> {\n const [simulatorOpenedByApp] = await SimControl.getBootedSimulatorsAsync();\n // This should prevent opening a second simulator in the chance that default\n // simulator doesn't match what the Simulator app would open by default.\n if (\n simulatorOpenedByApp?.udid &&\n (!osType || (osType && simulatorOpenedByApp.osType === osType))\n ) {\n debug(`First booted simulator: ${simulatorOpenedByApp?.windowName}`);\n return simulatorOpenedByApp;\n }\n\n debug(`No booted simulator matching requirements (osType: ${osType}).`);\n return null;\n}\n\n/**\n * Returns the most preferred simulator UDID without booting anything.\n *\n * 1. If the simulator app defines a default simulator and the osType is not defined.\n * 2. If the osType is defined, then check if the default udid matches the osType.\n * 3. If all else fails, return the first found simulator.\n */\nexport async function getBestUnbootedSimulatorAsync({ osType }: DeviceContext = {}): Promise<\n string | null\n> {\n const defaultId = getDefaultSimulatorDeviceUDID();\n debug(`Default simulator ID: ${defaultId}`);\n\n if (defaultId && !osType) {\n return defaultId;\n }\n\n const simulators = await getSelectableSimulatorsAsync({ osType });\n\n if (!simulators.length) {\n // TODO: Prompt to install the simulators\n throw new CommandError(\n 'UNSUPPORTED_OS_TYPE',\n `No ${osType || 'iOS'} devices available in Simulator.app`\n );\n }\n\n // If the default udid is defined, then check to ensure its osType matches the required os.\n if (defaultId) {\n const defaultSimulator = simulators.find((device) => device.udid === defaultId);\n if (defaultSimulator?.osType === osType) {\n return defaultId;\n }\n }\n\n // Return first selectable device.\n return simulators[0]?.udid ?? null;\n}\n\n/**\n * Get all simulators supported by Expo Go (iOS only).\n */\nexport async function getSelectableSimulatorsAsync({ osType = 'iOS' }: DeviceContext = {}): Promise<\n SimControl.Device[]\n> {\n const simulators = await SimControl.getDevicesAsync();\n return simulators.filter((device) => device.isAvailable && device.osType === osType);\n}\n\n/**\n * Get 'best' simulator for the user based on:\n * 1. Currently booted simulator.\n * 2. Last simulator that was opened.\n * 3. First simulator that was opened.\n */\nexport async function getBestSimulatorAsync({ osType }: DeviceContext): Promise<string | null> {\n const simulatorOpenedByApp = await getBestBootedSimulatorAsync({ osType });\n\n if (simulatorOpenedByApp) {\n return simulatorOpenedByApp.udid;\n }\n\n return await getBestUnbootedSimulatorAsync({ osType });\n}\n"],"names":["getBestBootedSimulatorAsync","getBestUnbootedSimulatorAsync","getSelectableSimulatorsAsync","getBestSimulatorAsync","SimControl","debug","require","getDefaultSimulatorDeviceUDID","defaultDeviceUDID","execSync","stdio","toString","trim","osType","simulatorOpenedByApp","getBootedSimulatorsAsync","udid","windowName","simulators","defaultId","length","CommandError","defaultSimulator","find","device","getDevicesAsync","filter","isAvailable"],"mappings":"AAAA;;;;QAyBsBA,2BAA2B,GAA3BA,2BAA2B;QAyB3BC,6BAA6B,GAA7BA,6BAA6B;QAmC7BC,4BAA4B,GAA5BA,4BAA4B;QAa5BC,qBAAqB,GAArBA,qBAAqB;AAlGlB,IAAA,aAAe,WAAf,eAAe,CAAA;AAEX,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACxCC,IAAAA,UAAU,mCAAM,UAAU,EAAhB;;;;;;;;;;;;;;;;;;;;;;AAEtB,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,2CAA2C,CAAC,AAAsB,AAAC;AAIlG;;;GAGG,CACH,SAASC,6BAA6B,GAAG;IACvC,IAAI;QACF,MAAMC,iBAAiB,GAAGC,CAAAA,GAAAA,aAAQ,AAGjC,CAAA,SAHiC,CAChC,CAAC,yDAAyD,CAAC,EAC3D;YAAEC,KAAK,EAAE,MAAM;SAAE,CAClB,CAACC,QAAQ,EAAE,AAAC;QACb,OAAOH,iBAAiB,CAACI,IAAI,EAAE,CAAC;KACjC,CAAC,OAAM;QACN,OAAO,IAAI,CAAC;KACb;CACF;AAEM,eAAeZ,2BAA2B,CAAC,EAChDa,MAAM,CAAA,EACQ,GAAG,EAAE,EAAqC;IACxD,MAAM,CAACC,oB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G,SAAS;QAAA,CAAC,AAAC;QAChF,IAAIG,CAAAA,gBAAgB,QAAQ,GAAxBA,KAAAA,CAAwB,GAAxBA,gBAAgB,CAAET,MAAM,CAAA,KAAKA,MAAM,EAAE;YACvC,OAAOM,SAAS,CAAC;SAClB;KACF;QAGMD,IAAmB;IAD1B,kCAAkC;IAClC,OAAOA,CAAAA,IAAmB,GAAnBA,CAAAA,GAAa,GAAbA,UAAU,CAAC,CAAC,CAAC,SAAM,GAAnBA,KAAAA,CAAmB,GAAnBA,GAAa,CAAEF,IAAI,YAAnBE,IAAmB,GAAI,IAAI,CAAC;CACpC;AAKM,eAAehB,4BAA4B,CAAC,EAAEW,MAAM,EAAG,KAAK,CAAA,EAAiB,GAAG,EAAE,EAEvF;IACA,MAAMK,UAAU,GAAG,MAAMd,UAAU,CAACqB,eAAe,EAAE,AAAC;IACtD,OAAOP,UAAU,CAACQ,MAAM,CAAC,CAACF,MAAM,GAAKA,MAAM,CAACG,WAAW,IAAIH,MAAM,CAACX,MAAM,KAAKA,MAAM;IAAA,CAAC,CAAC;CACtF;AAQM,eAAeV,qBAAqB,CAAC,EAAEU,MAAM,CAAA,EAAiB,EAA0B;IAC7F,MAAMC,oBAAoB,GAAG,MAAMd,2BAA2B,CAAC;QAAEa,MAAM;KAAE,CAAC,AAAC;IAE3E,IAAIC,oBAAoB,EAAE;QACxB,OAAOA,oBAAoB,CAACE,IAAI,CAAC;KAClC;IAED,OAAO,MAAMf,6BAA6B,CAAC;QAAEY,MAAM;KAAE,CAAC,CAAC;CACxD"}
@@ -5,36 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.xcrunAsync = xcrunAsync;
6
6
  var _spawnAsync = _interopRequireDefault(require("@expo/spawn-async"));
7
7
  var _chalk = _interopRequireDefault(require("chalk"));
8
- var Log = _interopRequireWildcard(require("../../../log"));
9
8
  var _errors = require("../../../utils/errors");
10
9
  function _interopRequireDefault(obj) {
11
10
  return obj && obj.__esModule ? obj : {
12
11
  default: obj
13
12
  };
14
13
  }
15
- function _interopRequireWildcard(obj) {
16
- if (obj && obj.__esModule) {
17
- return obj;
18
- } else {
19
- var newObj = {};
20
- if (obj != null) {
21
- for(var key in obj){
22
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
23
- var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
24
- if (desc.get || desc.set) {
25
- Object.defineProperty(newObj, key, desc);
26
- } else {
27
- newObj[key] = obj[key];
28
- }
29
- }
30
- }
31
- }
32
- newObj.default = obj;
33
- return newObj;
34
- }
35
- }
14
+ const debug = require("debug")("expo:start:platforms:ios:xcrun");
36
15
  async function xcrunAsync(args, options) {
37
- Log.debug("Running: xcrun " + args.join(" "));
16
+ debug("Running: xcrun " + args.join(" "));
38
17
  try {
39
18
  return await (0, _spawnAsync).default("xcrun", args.filter(Boolean), options);
40
19
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/platforms/ios/xcrun.ts"],"sourcesContent":["import spawnAsync, { SpawnOptions } from '@expo/spawn-async';\nimport chalk from 'chalk';\n\nimport * as Log from '../../../log';\nimport { CommandError } from '../../../utils/errors';\n\nexport async function xcrunAsync(args: (string | undefined)[], options?: SpawnOptions) {\n Log.debug('Running: xcrun ' + args.join(' '));\n try {\n return await spawnAsync('xcrun', args.filter(Boolean) as string[], options);\n } catch (e) {\n throwXcrunError(e);\n }\n}\n\nfunction throwXcrunError(e: any): never {\n if (isLicenseOutOfDate(e.stdout) || isLicenseOutOfDate(e.stderr)) {\n throw new CommandError(\n 'XCODE_LICENSE_NOT_ACCEPTED',\n 'Xcode license is not accepted. Please run `sudo xcodebuild -license`.'\n );\n } else if (e.stderr?.includes('not a developer tool or in PATH')) {\n throw new CommandError(\n 'SIMCTL_NOT_AVAILABLE',\n `You may need to run ${chalk.bold(\n 'sudo xcode-select -s /Applications/Xcode.app'\n )} and try again.`\n );\n }\n // Attempt to craft a better error message...\n if (Array.isArray(e.output)) {\n e.message += '\\n' + e.output.join('\\n').trim();\n } else if (e.stderr) {\n e.message += '\\n' + e.stderr;\n }\n throw e;\n}\n\nfunction isLicenseOutOfDate(text: string) {\n if (!text) {\n return false;\n }\n\n const lower = text.toLowerCase();\n return lower.includes('xcode') && lower.includes('license');\n}\n"],"names":["xcrunAsync","Log","args","options","debug","join","spawnAsync","filter","Boolean","e","throwXcrunError","isLicenseOutOfDate","stdout","stderr","CommandError","includes","chalk","bold","Array","isArray","output","message","trim","text","lower","toLowerCase"],"mappings":"AAAA;;;;QAMsBA,UAAU,GAAVA,UAAU;AANS,IAAA,WAAmB,kCAAnB,mBAAmB,EAAA;AAC1C,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEbC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACc,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,eAAeD,UAAU,CAACE,IAA4B,EAAEC,OAAsB,EAAE;IACrFF,GAAG,CAACG,KAAK,CAAC,iBAAiB,GAAGF,IAAI,CAACG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9C,IAAI;QACF,OAAO,MAAMC,CAAAA,GAAAA,WAAU,AAAoD,CAAA,QAApD,CAAC,OAAO,EAAEJ,IAAI,CAACK,MAAM,CAACC,OAAO,CAAC,EAAcL,OAAO,CAAC,CAAC;KAC7E,CAAC,OAAOM,CAAC,EAAE;QACVC,eAAe,CAACD,CAAC,CAAC,CAAC;KACpB;CACF;AAED,SAASC,eAAe,CAACD,CAAM,EAAS;QAM3BA,GAAQ;IALnB,IAAIE,kBAAkB,CAACF,CAAC,CAACG,MAAM,CAAC,IAAID,kBAAkB,CAACF,CAAC,CAACI,MAAM,CAAC,EAAE;QAChE,MAAM,IAAIC,OAAY,aAAA,CACpB,4BAA4B,EAC5B,uEAAuE,CACxE,CAAC;KACH,MAAM,IAAIL,CAAAA,GAAQ,GAARA,CAAC,CAACI,MAAM,SAAU,GAAlBJ,KAAAA,CAAkB,GAAlBA,GAAQ,CAAEM,QAAQ,CAAC,iCAAiC,CAAC,EAAE;QAChE,MAAM,IAAID,OAAY,aAAA,CACpB,sBAAsB,EACtB,CAAC,oBAAoB,EAAEE,MAAK,QAAA,CAACC,IAAI,CAC/B,8CAA8C,CAC/C,CAAC,eAAe,CAAC,CACnB,CAAC;KACH;IACD,6CAA6C;IAC7C,IAAIC,KAAK,CAACC,OAAO,CAACV,CAAC,CAACW,MAAM,CAAC,EAAE;QAC3BX,CAAC,CAACY,OAAO,IAAI,IAAI,GAAGZ,CAAC,CAACW,MAAM,CAACf,IAAI,CAAC,IAAI,CAAC,CAACiB,IAAI,EAAE,CAAC;KAChD,MAAM,IAAIb,CAAC,CAACI,MAAM,EAAE;QACnBJ,CAAC,CAACY,OAAO,IAAI,IAAI,GAAGZ,CAAC,CAACI,MAAM,CAAC;KAC9B;IACD,MAAMJ,CAAC,CAAC;CACT;AAED,SAASE,kBAAkB,CAACY,IAAY,EAAE;IACxC,IAAI,CAACA,IAAI,EAAE;QACT,OAAO,KAAK,CAAC;KACd;IAED,MAAMC,KAAK,GAAGD,IAAI,CAACE,WAAW,EAAE,AAAC;IACjC,OAAOD,KAAK,CAACT,QAAQ,CAAC,OAAO,CAAC,IAAIS,KAAK,CAACT,QAAQ,CAAC,SAAS,CAAC,CAAC;CAC7D"}
1
+ {"version":3,"sources":["../../../../../src/start/platforms/ios/xcrun.ts"],"sourcesContent":["import spawnAsync, { SpawnOptions } from '@expo/spawn-async';\nimport chalk from 'chalk';\n\nimport { CommandError } from '../../../utils/errors';\n\nconst debug = require('debug')('expo:start:platforms:ios:xcrun') as typeof console.log;\n\nexport async function xcrunAsync(args: (string | undefined)[], options?: SpawnOptions) {\n debug('Running: xcrun ' + args.join(' '));\n try {\n return await spawnAsync('xcrun', args.filter(Boolean) as string[], options);\n } catch (e) {\n throwXcrunError(e);\n }\n}\n\nfunction throwXcrunError(e: any): never {\n if (isLicenseOutOfDate(e.stdout) || isLicenseOutOfDate(e.stderr)) {\n throw new CommandError(\n 'XCODE_LICENSE_NOT_ACCEPTED',\n 'Xcode license is not accepted. Please run `sudo xcodebuild -license`.'\n );\n } else if (e.stderr?.includes('not a developer tool or in PATH')) {\n throw new CommandError(\n 'SIMCTL_NOT_AVAILABLE',\n `You may need to run ${chalk.bold(\n 'sudo xcode-select -s /Applications/Xcode.app'\n )} and try again.`\n );\n }\n // Attempt to craft a better error message...\n if (Array.isArray(e.output)) {\n e.message += '\\n' + e.output.join('\\n').trim();\n } else if (e.stderr) {\n e.message += '\\n' + e.stderr;\n }\n throw e;\n}\n\nfunction isLicenseOutOfDate(text: string) {\n if (!text) {\n return false;\n }\n\n const lower = text.toLowerCase();\n return lower.includes('xcode') && lower.includes('license');\n}\n"],"names":["xcrunAsync","debug","require","args","options","join","spawnAsync","filter","Boolean","e","throwXcrunError","isLicenseOutOfDate","stdout","stderr","CommandError","includes","chalk","bold","Array","isArray","output","message","trim","text","lower","toLowerCase"],"mappings":"AAAA;;;;QAOsBA,UAAU,GAAVA,UAAU;AAPS,IAAA,WAAmB,kCAAnB,mBAAmB,EAAA;AAC1C,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEI,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;;;;;;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,gCAAgC,CAAC,AAAsB,AAAC;AAEhF,eAAeF,UAAU,CAACG,IAA4B,EAAEC,OAAsB,EAAE;IACrFH,KAAK,CAAC,iBAAiB,GAAGE,IAAI,CAACE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,IAAI;QACF,OAAO,MAAMC,CAAAA,GAAAA,WAAU,AAAoD,CAAA,QAApD,CAAC,OAAO,EAAEH,IAAI,CAACI,MAAM,CAACC,OAAO,CAAC,EAAcJ,OAAO,CAAC,CAAC;KAC7E,CAAC,OAAOK,CAAC,EAAE;QACVC,eAAe,CAACD,CAAC,CAAC,CA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icesAsync;
9
9
  exports.DevicesFile = void 0;
10
10
  var _dotExpo = require("./dotExpo");
11
+ const debug = require("debug")("expo:start:project:devices");
11
12
  const DEVICES_FILE_NAME = "devices.json";
12
13
  const MILLISECONDS_IN_30_DAYS = 30 * 24 * 60 * 60 * 1000;
13
14
  const DevicesFile = (0, _dotExpo).createTemporaryProjectFile(DEVICES_FILE_NAME, {
@@ -54,6 +55,7 @@ async function saveDevicesAsync(projectRoot, deviceIds) {
54
55
  const newDeviceIds = typeof deviceIds === "string" ? [
55
56
  deviceIds
56
57
  ] : deviceIds;
58
+ debug(`Saving devices: ${newDeviceIds}`);
57
59
  const { devices } = await getDevicesInfoAsync(projectRoot);
58
60
  const newDevicesJson = devices.filter((device)=>!newDeviceIds.includes(device.installationId)
59
61
  ).concat(newDeviceIds.map((deviceId)=>({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/project/devices.ts"],"sourcesContent":["import { createTemporaryProjectFile } from './dotExpo';\n\nexport type DeviceInfo = {\n installationId: string;\n lastUsed: number;\n};\n\nexport type DevicesInfo = {\n devices: DeviceInfo[];\n};\n\nconst DEVICES_FILE_NAME = 'devices.json';\n\nconst MILLISECONDS_IN_30_DAYS = 30 * 24 * 60 * 60 * 1000;\n\nexport const DevicesFile = createTemporaryProjectFile<DevicesInfo>(DEVICES_FILE_NAME, {\n devices: [],\n});\n\nlet devicesInfo: DevicesInfo | null = null;\n\nexport async function getDevicesInfoAsync(projectRoot: string): Promise<DevicesInfo> {\n if (devicesInfo) {\n return devicesInfo;\n }\n return readDevicesInfoAsync(projectRoot);\n}\n\nexport async function readDevicesInfoAsync(projectRoot: string): Promise<DevicesInfo> {\n try {\n devicesInfo = await DevicesFile.readAsync(projectRoot);\n\n // if the file on disk has old devices, filter them out here before we use them\n const filteredDevices = filterOldDevices(devicesInfo.devices);\n if (filteredDevices.length < devicesInfo.devices.length) {\n devicesInfo = {\n ...devicesInfo,\n devices: filteredDevices,\n };\n // save the newly filtered list for consistency\n try {\n await setDevicesInfoAsync(projectRoot, devicesInfo);\n } catch {\n // do nothing here, we'll just keep using the filtered list in memory for now\n }\n }\n\n return devicesInfo;\n } catch {\n return await DevicesFile.setAsync(projectRoot, { devices: [] });\n }\n}\n\nexport async function setDevicesInfoAsync(\n projectRoot: string,\n json: DevicesInfo\n): Promise<DevicesInfo> {\n devicesInfo = json;\n return await DevicesFile.setAsync(projectRoot, json);\n}\n\nexport async function saveDevicesAsync(\n projectRoot: string,\n deviceIds: string | string[]\n): Promise<void> {\n const currentTime = Date.now();\n const newDeviceIds = typeof deviceIds === 'string' ? [deviceIds] : deviceIds;\n\n const { devices } = await getDevicesInfoAsync(projectRoot);\n const newDevicesJson = devices\n .filter((device) => !newDeviceIds.includes(device.installationId))\n .concat(newDeviceIds.map((deviceId) => ({ installationId: deviceId, lastUsed: currentTime })));\n await setDevicesInfoAsync(projectRoot, { devices: filterOldDevices(newDevicesJson) });\n}\n\nfunction filterOldDevices(devices: DeviceInfo[]) {\n const currentTime = Date.now();\n return (\n devices\n // filter out any devices that haven't been used to open this project in 30 days\n .filter((device) => currentTime - device.lastUsed <= MILLISECONDS_IN_30_DAYS)\n // keep only the 10 most recently used devices\n .sort((a, b) => b.lastUsed - a.lastUsed)\n .slice(0, 10)\n );\n}\n"],"names":["getDevicesInfoAsync","readDevicesInfoAsync","setDevicesInfoAsync","saveDevicesAsync","DEVICES_FILE_NAME","MILLISECONDS_IN_30_DAYS","DevicesFile","createTemporaryProjectFile","devices","devicesInfo","projectRoot","readAsync","filteredDevices","filterOldDevices","length","setAsync","json","deviceIds","currentTime","Date","now","newDeviceIds","newDevicesJson","filter","device","includes","installationId","concat","map","deviceId","lastUsed","sort","a","b","slice"],"mappings":"AAAA;;;;QAqBsBA,mBAAmB,GAAnBA,mBAAmB;QAOnBC,oBAAoB,GAApBA,oBAAoB;QAyBpBC,mBAAmB,GAAnBA,mBAAmB;QAQnBC,gBAAgB,GAAhBA,gBAAgB;;AA7DK,IAAA,QAAW,WAA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"],"sourcesContent":["import { createTemporaryProjectFile } from './dotExpo';\n\nconst debug = require('debug')('expo:start:project:devices') as typeof console.log;\n\nexport type DeviceInfo = {\n installationId: string;\n lastUsed: number;\n};\n\nexport type DevicesInfo = {\n devices: DeviceInfo[];\n};\n\nconst DEVICES_FILE_NAME = 'devices.json';\n\nconst MILLISECONDS_IN_30_DAYS = 30 * 24 * 60 * 60 * 1000;\n\nexport const DevicesFile = createTemporaryProjectFile<DevicesInfo>(DEVICES_FILE_NAME, {\n devices: [],\n});\n\nlet devicesInfo: DevicesInfo | null = null;\n\nexport async function getDevicesInfoAsync(projectRoot: string): Promise<DevicesInfo> {\n if (devicesInfo) {\n return devicesInfo;\n }\n return readDevicesInfoAsync(projectRoot);\n}\n\nexport async function readDevicesInfoAsync(projectRoot: string): Promise<DevicesInfo> {\n try {\n devicesInfo = await DevicesFile.readAsync(projectRoot);\n\n // if the file on disk has old devices, filter them out here before we use them\n const filteredDevices = filterOldDevices(devicesInfo.devices);\n if (filteredDevices.length < devicesInfo.devices.length) {\n devicesInfo = {\n ...devicesInfo,\n devices: filteredDevices,\n };\n // save the newly filtered list for consistency\n try {\n await setDevicesInfoAsync(projectRoot, devicesInfo);\n } catch {\n // do nothing here, we'll just keep using the filtered list in memory for now\n }\n }\n\n return devicesInfo;\n } catch {\n return await DevicesFile.setAsync(projectRoot, { devices: [] });\n }\n}\n\nexport async function setDevicesInfoAsync(\n projectRoot: string,\n json: DevicesInfo\n): Promise<DevicesInfo> {\n devicesInfo = json;\n return await DevicesFile.setAsync(projectRoot, json);\n}\n\nexport async function saveDevicesAsync(\n projectRoot: string,\n deviceIds: string | string[]\n): Promise<void> {\n const currentTime = Date.now();\n const newDeviceIds = typeof deviceIds === 'string' ? [deviceIds] : deviceIds;\n\n debug(`Saving devices: ${newDeviceIds}`);\n const { devices } = await getDevicesInfoAsync(projectRoot);\n const newDevicesJson = devices\n .filter((device) => !newDeviceIds.includes(device.installationId))\n .concat(newDeviceIds.map((deviceId) => ({ installationId: deviceId, lastUsed: currentTime })));\n await setDevicesInfoAsync(projectRoot, { devices: filterOldDevices(newDevicesJson) });\n}\n\nfunction filterOldDevices(devices: DeviceInfo[]) {\n const currentTime = Date.now();\n return (\n devices\n // filter out any devices that haven't been used to open this project in 30 days\n .filter((device) => currentTime - device.lastUsed <= MILLISECONDS_IN_30_DAYS)\n // keep only the 10 most recently used devices\n .sort((a, b) => b.lastUsed - a.lastUsed)\n .slice(0, 10)\n );\n}\n"],"names":["getDevicesInfoAsync","readDevicesInfoAsync","setDevicesInfoAsync","saveDevicesAsync","debug","require","DEVICES_FILE_NAME","MILLISECONDS_IN_30_DAYS","DevicesFile","createTemporaryProjectFile","devices","devicesInfo","projectRoot","readAsync","filteredDevices","filterOldDevices","length","setAsync","json","deviceIds","currentTime","Date","now","newDeviceIds","newDevicesJson","filter","device","includes","installationId","concat","map","deviceId","lastUsed","sort","a","b","slice"],"mappings":"AAAA;;;;QAuBsBA,mBAAmB,GAAnBA,mBAAmB;QAOnBC,oBAAoB,GAApBA,oBAAoB;QAyBpBC,mBAAmB,GAAnBA,mBAAmB;QAQnBC,gBAAgB,GAAhBA,gBAAgB;;AA/DK,IAAA,QAAW,WAAX,WAAW,CAAA;AAEtD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,4BAA4B,CAAC,AAAsB,AAAC;AAWnF,MAAMC,iBAAiB,GAAG,cAAc,AAAC;AAEzC,MAAMC,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,AAAC;AAElD,MAAMC,WAAW,GAAGC,CAAAA,GAAAA,QAA0B,AAEnD,CAAA,2BAFmD,CAAcH,iBAAiB,EAAE;IACpFI,OAAO,EAAE,EAAE;CACZ,CAAC,AAAC;QAFUF,WAAW,GAAXA,WAAW;AAIxB,IAAIG,WAAW,GAAuB,IAAI,AAAC;AAEpC,eAAeX,mBAAmB,CAACY,WAAmB,EAAwB;IACnF,IAAID,WA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MV,mBAAmB,CAACY,WAAW,CAAC,AAAC;IAC3D,MAAMY,cAAc,GAAGd,OAAO,CAC3Be,MAAM,CAAC,CAACC,MAAM,GAAK,CAACH,YAAY,CAACI,QAAQ,CAACD,MAAM,CAACE,cAAc,CAAC;IAAA,CAAC,CACjEC,MAAM,CAACN,YAAY,CAACO,GAAG,CAAC,CAACC,QAAQ,GAAK,CAAC;YAAEH,cAAc,EAAEG,QAAQ;YAAEC,QAAQ,EAAEZ,WAAW;SAAE,CAAC;IAAA,CAAC,CAAC,AAAC;IACjG,MAAMlB,mBAAmB,CAACU,WAAW,EAAE;QAAEF,OAAO,EAAEK,gBAAgB,CAACS,cAAc,CAAC;KAAE,CAAC,CAAC;CACvF;AAED,SAAST,gBAAgB,CAACL,OAAqB,EAAE;IAC/C,MAAMU,WAAW,GAAGC,IAAI,CAACC,GAAG,EAAE,AAAC;IAC/B,OACEZ,OAAO,AACL,gFAAgF;KAC/Ee,MAAM,CAAC,CAACC,MAAM,GAAKN,WAAW,GAAGM,MAAM,CAACM,QAAQ,IAAIzB,uBAAuB;IAAA,CAAC,AAC7E,8CAA8C;KAC7C0B,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,GAAKA,CAAC,CAACH,QAAQ,GAAGE,CAAC,CAACF,QAAQ;IAAA,CAAC,CACvCI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CACf;CACH"}
@@ -39,6 +39,7 @@ function _interopRequireWildcard(obj) {
39
39
  return newObj;
40
40
  }
41
41
  }
42
+ const debug = require("debug")("expo:start:server:ngrok");
42
43
  const NGROK_CONFIG = {
43
44
  authToken: "5W1bR67GNbWcXqmxZzBG1_56GezNeaX6sSRvn8npeQ8",
44
45
  domain: "exp.direct"
@@ -85,12 +86,12 @@ class AsyncNgrok {
85
86
  this.serverUrl = await this._connectToNgrokAsync({
86
87
  timeout
87
88
  });
88
- Log.debug("[ngrok] Tunnel URL:", this.serverUrl);
89
+ debug("Tunnel URL:", this.serverUrl);
89
90
  Log.log("Tunnel ready.");
90
91
  }
91
92
  /** Stop the ngrok process if it's running. */ async stopAsync() {
92
93
  var ref;
93
- Log.debug("[ngrok] Stopping Tunnel");
94
+ debug("Stopping Tunnel");
94
95
  await ((ref = this.resolver.get()) == null ? void 0 : ref.kill == null ? void 0 : ref.kill());
95
96
  this.serverUrl = null;
96
97
  }
@@ -121,9 +122,9 @@ class AsyncNgrok {
121
122
  try {
122
123
  // Global config path.
123
124
  const configPath = path.join(_userSettings.default.getDirectory(), "ngrok.yml");
124
- Log.debug("[ngrok] Global config path:", configPath);
125
+ debug("Global config path:", configPath);
125
126
  const hostname = await this._getProjectHostnameAsync();
126
- Log.debug("[ngrok] Hostname:", hostname);
127
+ debug("Hostname:", hostname);
127
128
  const url = await instance.connect({
128
129
  authtoken: NGROK_CONFIG.authToken,
129
130
  proto: "http",
@@ -164,7 +165,7 @@ class AsyncNgrok {
164
165
  await _settings.ProjectSettings.setAsync(this.projectRoot, {
165
166
  urlRandomness: randomness
166
167
  });
167
- Log.debug("[ngrok] Resetting project randomness:", randomness);
168
+ debug("Resetting project randomness:", randomness);
168
169
  return randomness;
169
170
  }
170
171
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/AsyncNgrok.ts"],"sourcesContent":["import crypto from 'crypto';\nimport * as path from 'path';\nimport slugify from 'slugify';\n\nimport UserSettings from '../../api/user/UserSettings';\nimport { getActorDisplayName, getUserAsync } from '../../api/user/user';\nimport * as Log from '../../log';\nimport { delayAsync, resolveWithTimeout } from '../../utils/delay';\nimport { CommandError } from '../../utils/errors';\nimport { NgrokInstance, NgrokResolver } from '../doctor/ngrok/NgrokResolver';\nimport { startAdbReverseAsync } from '../platforms/android/adbReverse';\nimport { ProjectSettings } from '../project/settings';\n\nconst NGROK_CONFIG = {\n authToken: '5W1bR67GNbWcXqmxZzBG1_56GezNeaX6sSRvn8npeQ8',\n domain: 'exp.direct',\n};\n\nconst TUNNEL_TIMEOUT = 10 * 1000;\n\nexport class AsyncNgrok {\n /** Resolves the best instance of ngrok, exposed for testing. */\n resolver: NgrokResolver;\n\n /** Info about the currently running instance of ngrok. */\n private serverUrl: string | null = null;\n\n constructor(private projectRoot: string, private port: number) {\n this.resolver = new NgrokResolver(projectRoot);\n }\n\n public getActiveUrl(): string | null {\n return this.serverUrl;\n }\n\n /** Exposed for testing. */\n async _getProjectHostnameAsync() {\n const user = await getUserAsync();\n if (user?.__typename === 'Robot') {\n throw new CommandError('NGROK_ROBOT', 'Cannot use ngrok with a robot user.');\n }\n const username = getActorDisplayName(user);\n\n return [\n // NOTE: https://github.com/expo/expo/pull/16556#discussion_r822944286\n await this.getProjectRandomnessAsync(),\n slugify(username),\n // Use the port to distinguish between multiple tunnels (webpack, metro).\n this.port,\n NGROK_CONFIG.domain,\n ].join('.');\n }\n\n /** Start ngrok on the given port for the project. */\n async startAsync({ timeout }: { timeout?: number } = {}): Promise<void> {\n // Ensure the instance is loaded first, this can linger so we should run it before the timeout.\n await this.resolver.resolveAsync({\n // For now, prefer global install since the package has native code (harder to install) and doesn't change very often.\n prefersGlobalInstall: true,\n });\n\n // Ensure ADB reverse is running.\n if (!(await startAdbReverseAsync([this.port]))) {\n // TODO: Better error message.\n throw new CommandError(\n 'NGROK_ADB',\n `Cannot start tunnel URL because \\`adb reverse\\` failed for the connected Android device(s).`\n );\n }\n\n this.serverUrl = await this._connectToNgrokAsync({ timeout });\n\n Log.debug('[ngrok] Tunnel URL:', this.serverUrl);\n Log.log('Tunnel ready.');\n }\n\n /** Stop the ngrok process if it's running. */\n public async stopAsync(): Promise<void> {\n Log.debug('[ngrok] Stopping Tunnel');\n\n await this.resolver.get()?.kill?.();\n this.serverUrl = null;\n }\n\n /** Exposed for testing. */\n async _connectToNgrokAsync(\n options: { timeout?: number } = {},\n attempts: number = 0\n ): Promise<string> {\n // Attempt to stop any hanging processes, this increases the chances of a successful connection.\n await this.stopAsync();\n\n // Get the instance quietly or assert otherwise.\n const instance = await this.resolver.resolveAsync({\n shouldPrompt: false,\n autoInstall: false,\n });\n\n // TODO(Bacon): Consider dropping the timeout functionality:\n // https://github.com/expo/expo/pull/16556#discussion_r822307373\n const results = await resolveWithTimeout(\n () => this.connectToNgrokInternalAsync(instance, attempts),\n {\n timeout: options.timeout ?? TUNNEL_TIMEOUT,\n errorMessage: 'ngrok tunnel took too long to connect.',\n }\n );\n if (typeof results === 'string') {\n return results;\n }\n\n // Wait 100ms and then try again\n await delayAsync(100);\n\n return this._connectToNgrokAsync(options, attempts + 1);\n }\n\n private async connectToNgrokInternalAsync(\n instance: NgrokInstance,\n attempts: number = 0\n ): Promise<string | false> {\n try {\n // Global config path.\n const configPath = path.join(UserSettings.getDirectory(), 'ngrok.yml');\n Log.debug('[ngrok] Global config path:', configPath);\n const hostname = await this._getProjectHostnameAsync();\n Log.debug('[ngrok] Hostname:', hostname);\n\n const url = await instance.connect({\n authtoken: NGROK_CONFIG.authToken,\n proto: 'http',\n hostname,\n configPath,\n onStatusChange(status) {\n if (status === 'closed') {\n Log.error(\n 'We noticed your tunnel is having issues. ' +\n 'This may be due to intermittent problems with ngrok. ' +\n 'If you have trouble connecting to your app, try to restart the project, ' +\n 'or switch the host to `lan`.'\n );\n } else if (status === 'connected') {\n Log.log('Tunnel connected.');\n }\n },\n port: this.port,\n });\n return url;\n } catch (error: any) {\n // Attempt to connect 3 times\n if (attempts >= 2) {\n throw new CommandError('NGROK_CONNECT', error.toString());\n }\n\n // Attempt to fix the issue\n if (error?.error_code === 103) {\n // Change randomness to avoid conflict if killing ngrok doesn't help\n await this._resetProjectRandomnessAsync();\n }\n return false;\n }\n }\n\n private async getProjectRandomnessAsync() {\n const { urlRandomness: randomness } = await ProjectSettings.readAsync(this.projectRoot);\n if (randomness) {\n return randomness;\n }\n return await this._resetProjectRandomnessAsync();\n }\n\n async _resetProjectRandomnessAsync() {\n const randomness = crypto.randomBytes(5).toString('base64url');\n await ProjectSettings.setAsync(this.projectRoot, { urlRandomness: randomness });\n Log.debug('[ngrok] Resetting project randomness:', randomness);\n return randomness;\n }\n}\n"],"names":["path","Log","NGROK_CONFIG","authToken","domain","TUNNEL_TIMEOUT","AsyncNgrok","constructor","projectRoot","port","serverUrl","resolver","NgrokResolver","getActiveUrl","_getProjectHostnameAsync","user","getUserAsync","__typename","CommandError","username","getActorDisplayName","getProjectRandomnessAsync","slugify","join","startAsync","timeout","resolveAsync","prefersGlobalInstall","startAdbReverseAsync","_connectToNgrokAsync","debug","log","stopAsync","get","kill","options","attempts","instance","shouldPrompt","autoInstall","results","resolveWithTimeout","connectToNgrokInternalAsync","errorMessage","delayAsync","configPath","UserSettings","getDirectory","hostname","url","connect","authtoken","proto","onStatusChange","status","error","toString","error_code","_resetProjectRandomnessAsync","urlRandomness","randomness","ProjectSettings","readAsync","crypto","randomBytes","setAsync"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACfA,IAAAA,IAAI,mCAAM,MAAM,EAAZ;AACI,IAAA,QAAS,kCAAT,SAAS,EAAA;AAEJ,IAAA,aAA6B,kCAA7B,6BAA6B,EAAA;AACJ,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AAC3DC,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACgC,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AACrC,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACJ,IAAA,cAA+B,WAA/B,+BAA+B,CAAA;AACvC,IAAA,WAAiC,WAAjC,iCAAiC,CAAA;AACtC,IAAA,SAAqB,WAArB,qBAAqB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD,MAAMC,YAAY,GAAG;IACnBC,SAAS,EAAE,6CAA6C;IACxDC,MAAM,EAAE,YAAY;CACrB,AAAC;AAEF,MAAMC,cAAc,GAAG,EAAE,GAAG,IAAI,AAAC;AAE1B,MAAMC,UAAU;IAOrBC,YAAoBC,WAAmB,EAAUC,IAAY,CAAE;aAA3CD,WAAmB,GAAnBA,WAAmB;aAAUC,IAAY,G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AAC;SACZ,CAAC,OAAOM,KAAK,EAAO;YACnB,6BAA6B;YAC7B,IAAInB,QAAQ,IAAI,CAAC,EAAE;gBACjB,MAAM,IAAIlB,OAAY,aAAA,CAAC,eAAe,EAAEqC,KAAK,CAACC,QAAQ,EAAE,CAAC,CAAC;aAC3D;YAED,2BAA2B;YAC3B,IAAID,CAAAA,KAAK,QAAY,GAAjBA,KAAAA,CAAiB,GAAjBA,KAAK,CAAEE,UAAU,CAAA,KAAK,GAAG,EAAE;gBAC7B,oEAAoE;gBACpE,MAAM,IAAI,CAACC,4BAA4B,EAAE,CAAC;aAC3C;YACD,OAAO,KAAK,CAAC;SACd;KACF;IAED,MAAcrC,yBAAyB,GAAG;QACxC,MAAM,EAAEsC,aAAa,EAAEC,UAAU,CAAA,EAAE,GAAG,MAAMC,SAAe,gBAAA,CAACC,SAAS,CAAC,IAAI,CAACtD,WAAW,CAAC,AAAC;QACxF,IAAIoD,UAAU,EAAE;YACd,OAAOA,UAAU,CAAC;SACnB;QACD,OAAO,MAAM,IAAI,CAACF,4BAA4B,EAAE,CAAC;KAClD;IAED,MAAMA,4BAA4B,GAAG;QACnC,MAAME,UAAU,GAAGG,OAAM,QAAA,CAACC,WAAW,CAAC,CAAC,CAAC,CAACR,QAAQ,CAAC,WAAW,CAAC,AAAC;QAC/D,MAAMK,SAAe,gBAAA,CAACI,QAAQ,CAAC,IAAI,CAACzD,WAAW,EAAE;YAAEmD,aAAa,EAAEC,UAAU;SAAE,CAAC,CAAC;QAChF3D,GAAG,CAAC6B,KAAK,CAAC,uCAAuC,EAAE8B,UAAU,CAAC,CAAC;QAC/D,OAAOA,UAAU,CAAC;KACnB;CACF;QA7JYtD,UAAU,GAAVA,UAAU"}
1
+ {"version":3,"sources":["../../../../src/start/server/AsyncNgrok.ts"],"sourcesContent":["import crypto from 'crypto';\nimport * as path from 'path';\nimport slugify from 'slugify';\n\nimport UserSettings from '../../api/user/UserSettings';\nimport { getActorDisplayName, getUserAsync } from '../../api/user/user';\nimport * as Log from '../../log';\nimport { delayAsync, resolveWithTimeout } from '../../utils/delay';\nimport { CommandError } from '../../utils/errors';\nimport { NgrokInstance, NgrokResolver } from '../doctor/ngrok/NgrokResolver';\nimport { startAdbReverseAsync } from '../platforms/android/adbReverse';\nimport { ProjectSettings } from '../project/settings';\n\nconst debug = require('debug')('expo:start:server:ngrok') as typeof console.log;\n\nconst NGROK_CONFIG = {\n authToken: '5W1bR67GNbWcXqmxZzBG1_56GezNeaX6sSRvn8npeQ8',\n domain: 'exp.direct',\n};\n\nconst TUNNEL_TIMEOUT = 10 * 1000;\n\nexport class AsyncNgrok {\n /** Resolves the best instance of ngrok, exposed for testing. */\n resolver: NgrokResolver;\n\n /** Info about the currently running instance of ngrok. */\n private serverUrl: string | null = null;\n\n constructor(private projectRoot: string, private port: number) {\n this.resolver = new NgrokResolver(projectRoot);\n }\n\n public getActiveUrl(): string | null {\n return this.serverUrl;\n }\n\n /** Exposed for testing. */\n async _getProjectHostnameAsync() {\n const user = await getUserAsync();\n if (user?.__typename === 'Robot') {\n throw new CommandError('NGROK_ROBOT', 'Cannot use ngrok with a robot user.');\n }\n const username = getActorDisplayName(user);\n\n return [\n // NOTE: https://github.com/expo/expo/pull/16556#discussion_r822944286\n await this.getProjectRandomnessAsync(),\n slugify(username),\n // Use the port to distinguish between multiple tunnels (webpack, metro).\n this.port,\n NGROK_CONFIG.domain,\n ].join('.');\n }\n\n /** Start ngrok on the given port for the project. */\n async startAsync({ timeout }: { timeout?: number } = {}): Promise<void> {\n // Ensure the instance is loaded first, this can linger so we should run it before the timeout.\n await this.resolver.resolveAsync({\n // For now, prefer global install since the package has native code (harder to install) and doesn't change very often.\n prefersGlobalInstall: true,\n });\n\n // Ensure ADB reverse is running.\n if (!(await startAdbReverseAsync([this.port]))) {\n // TODO: Better error message.\n throw new CommandError(\n 'NGROK_ADB',\n `Cannot start tunnel URL because \\`adb reverse\\` failed for the connected Android device(s).`\n );\n }\n\n this.serverUrl = await this._connectToNgrokAsync({ timeout });\n\n debug('Tunnel URL:', this.serverUrl);\n Log.log('Tunnel ready.');\n }\n\n /** Stop the ngrok process if it's running. */\n public async stopAsync(): Promise<void> {\n debug('Stopping Tunnel');\n\n await this.resolver.get()?.kill?.();\n this.serverUrl = null;\n }\n\n /** Exposed for testing. */\n async _connectToNgrokAsync(\n options: { timeout?: number } = {},\n attempts: number = 0\n ): Promise<string> {\n // Attempt to stop any hanging processes, this increases the chances of a successful connection.\n await this.stopAsync();\n\n // Get the instance quietly or assert otherwise.\n const instance = await this.resolver.resolveAsync({\n shouldPrompt: false,\n autoInstall: false,\n });\n\n // TODO(Bacon): Consider dropping the timeout functionality:\n // https://github.com/expo/expo/pull/16556#discussion_r822307373\n const results = await resolveWithTimeout(\n () => this.connectToNgrokInternalAsync(instance, attempts),\n {\n timeout: options.timeout ?? TUNNEL_TIMEOUT,\n errorMessage: 'ngrok tunnel took too long to connect.',\n }\n );\n if (typeof results === 'string') {\n return results;\n }\n\n // Wait 100ms and then try again\n await delayAsync(100);\n\n return this._connectToNgrokAsync(options, attempts + 1);\n }\n\n private async connectToNgrokInternalAsync(\n instance: NgrokInstance,\n attempts: number = 0\n ): Promise<string | false> {\n try {\n // Global config path.\n const configPath = path.join(UserSettings.getDirectory(), 'ngrok.yml');\n debug('Global config path:', configPath);\n const hostname = await this._getProjectHostnameAsync();\n debug('Hostname:', hostname);\n\n const url = await instance.connect({\n authtoken: NGROK_CONFIG.authToken,\n proto: 'http',\n hostname,\n configPath,\n onStatusChange(status) {\n if (status === 'closed') {\n Log.error(\n 'We noticed your tunnel is having issues. ' +\n 'This may be due to intermittent problems with ngrok. ' +\n 'If you have trouble connecting to your app, try to restart the project, ' +\n 'or switch the host to `lan`.'\n );\n } else if (status === 'connected') {\n Log.log('Tunnel connected.');\n }\n },\n port: this.port,\n });\n return url;\n } catch (error: any) {\n // Attempt to connect 3 times\n if (attempts >= 2) {\n throw new CommandError('NGROK_CONNECT', error.toString());\n }\n\n // Attempt to fix the issue\n if (error?.error_code === 103) {\n // Change randomness to avoid conflict if killing ngrok doesn't help\n await this._resetProjectRandomnessAsync();\n }\n return false;\n }\n }\n\n private async getProjectRandomnessAsync() {\n const { urlRandomness: randomness } = await ProjectSettings.readAsync(this.projectRoot);\n if (randomness) {\n return randomness;\n }\n return await this._resetProjectRandomnessAsync();\n }\n\n async _resetProjectRandomnessAsync() {\n const randomness = crypto.randomBytes(5).toString('base64url');\n await ProjectSettings.setAsync(this.projectRoot, { urlRandomness: randomness });\n debug('Resetting project randomness:', randomness);\n return randomness;\n }\n}\n"],"names":["path","Log","debug","require","NGROK_CONFIG","authToken","domain","TUNNEL_TIMEOUT","AsyncNgrok","constructor","projectRoot","port","serverUrl","resolver","NgrokResolver","getActiveUrl","_getProjectHostnameAsync","user","getUserAsync","__typename","CommandError","username","getActorDisplayName","getProjectRandomnessAsync","slugify","join","startAsync","timeout","resolveAsync","prefersGlobalInstall","startAdbReverseAsync","_connectToNgrokAsync","log","stopAsync","get","kill","options","attempts","instance","shouldPrompt","autoInstall","results","resolveWithTimeout","connectToNgrokInternalAsync","errorMessage","delayAsync","configPath","UserSettings","getDirectory","hostname","url","connect","authtoken","proto","onStatusChange","status","error","toString","error_code","_resetProjectRandomnessAsync","urlRandomness","randomness","ProjectSettings","readAsync","crypto","randomBytes","setAsync"],"mappings":"AAAA;;;;AAAmB,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACfA,IAAAA,IAAI,mCAAM,MAAM,EAAZ;AACI,IAAA,QAAS,kCAAT,SAAS,EAAA;AAEJ,IAAA,aAA6B,kCAA7B,6BAA6B,EAAA;AACJ,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AAC3DC,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACgC,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AACrC,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACJ,IAAA,cAA+B,WAA/B,+BAA+B,CAAA;AACvC,IAAA,WAAiC,WAAjC,iCAAiC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EkD,aAAa,EAAEC,UAAU;SAAE,CAAC,CAAC;QAChF3D,KAAK,CAAC,+BAA+B,EAAE2D,UAAU,CAAC,CAAC;QACnD,OAAOA,UAAU,CAAC;KACnB;CACF;QA7JYrD,UAAU,GAAVA,UAAU"}
@@ -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;AAMtB,IAAA,WAAc,WAAd,cAAc,CAAA;AACN,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACZ,IAAA,WAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqD3D,MAAMC,iBAAiB,GAAG;IACxBC,SAAS,EAAE,IACTC,OAAO,CAAC,uCAAuC,CAAC,CAC7CC,oBAAoB;IAA+E;IACxGC,QAAQ,EAAE,IACRF,OAAO,CAAC,6CAA6C,CAAC,CACnDG,sBAAsB;CAC5B,AAAC;AAEF,MAAMC,WAAW,GAAG;IAClBC,OAAO,EAAE,IACPL,OAAO,CAAC,wCAAwC,CAAC,CAC9CM,yBAAyB;IAAqF;IACnH,cAAc,EAAE,IACdN,OAAO,CAAC,8CAA8C,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AAY,CAAC;YAAE8D,MAAM,EAAE,KAAK;SAAE,CAAC,YAAhD,IAAgD,GAAI,IAAI,CAAC;KACjE;IAED,MAAgBO,uBAAuB,CAACW,QAAwC,EAAE;QAChF,IAAI,CAAC,IAAI,CAAC3F,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;YACD,IAAI,CAAC3B,gBAAgB,CAAC2F,QAAQ,CAAC,GAAG,IAAIG,OAAO,CAAC,IAAI,CAACnG,WAAW,EAAE+B,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;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","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;AAMtB,IAAA,WAAc,WAAd,cAAc,CAAA;AACN,IAAA,mBAAsB,WAAtB,sBAAsB,C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Q,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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AI,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,WA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