@expo/cli 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/build/bin/cli +2 -2
  2. package/build/src/api/getExpoGoIntermediateCertificate.js +1 -1
  3. package/build/src/api/getExpoGoIntermediateCertificate.js.map +1 -1
  4. package/build/src/api/getExpoSchema.js +1 -1
  5. package/build/src/api/getExpoSchema.js.map +1 -1
  6. package/build/src/api/getNativeModuleVersions.js +1 -1
  7. package/build/src/api/getNativeModuleVersions.js.map +1 -1
  8. package/build/src/api/getProjectDevelopmentCertificate.js +1 -1
  9. package/build/src/api/getProjectDevelopmentCertificate.js.map +1 -1
  10. package/build/src/api/getVersions.js +1 -1
  11. package/build/src/api/getVersions.js.map +1 -1
  12. package/build/src/api/rest/cache/wrapFetchWithCache.js.map +1 -1
  13. package/build/src/api/rest/client.js +5 -5
  14. package/build/src/api/rest/client.js.map +1 -1
  15. package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
  16. package/build/src/api/rest/wrapFetchWithProgress.js.map +1 -1
  17. package/build/src/api/rest/wrapFetchWithProxy.js.map +1 -1
  18. package/build/src/api/updateDevelopmentSession.js +1 -1
  19. package/build/src/api/updateDevelopmentSession.js.map +1 -1
  20. package/build/src/api/user/actions.js +2 -2
  21. package/build/src/api/user/actions.js.map +1 -1
  22. package/build/src/api/user/otp.js +1 -1
  23. package/build/src/api/user/otp.js.map +1 -1
  24. package/build/src/api/user/user.js +2 -2
  25. package/build/src/api/user/user.js.map +1 -1
  26. package/build/src/config/configAsync.js +17 -1
  27. package/build/src/config/configAsync.js.map +1 -1
  28. package/build/src/customize/customizeAsync.js +1 -1
  29. package/build/src/customize/customizeAsync.js.map +1 -1
  30. package/build/src/customize/generate.js +29 -2
  31. package/build/src/customize/generate.js.map +1 -1
  32. package/build/src/customize/templates.js +8 -0
  33. package/build/src/customize/templates.js.map +1 -1
  34. package/build/src/customize/typescript.js +54 -0
  35. package/build/src/customize/typescript.js.map +1 -0
  36. package/build/src/export/createBundles.js +1 -1
  37. package/build/src/export/createBundles.js.map +1 -1
  38. package/build/src/export/createMetadataJson.js.map +1 -1
  39. package/build/src/export/embed/exportEmbedAsync.js +50 -4
  40. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  41. package/build/src/export/embed/index.js +1 -3
  42. package/build/src/export/embed/index.js.map +1 -1
  43. package/build/src/export/embed/resolveOptions.js +6 -10
  44. package/build/src/export/embed/resolveOptions.js.map +1 -1
  45. package/build/src/export/exportApp.js +50 -41
  46. package/build/src/export/exportApp.js.map +1 -1
  47. package/build/src/export/exportAssets.js +2 -2
  48. package/build/src/export/exportAssets.js.map +1 -1
  49. package/build/src/export/exportAsync.js +1 -1
  50. package/build/src/export/exportAsync.js.map +1 -1
  51. package/build/src/export/exportStaticAsync.js +42 -12
  52. package/build/src/export/exportStaticAsync.js.map +1 -1
  53. package/build/src/export/fork-bundleAsync.js +27 -2
  54. package/build/src/export/fork-bundleAsync.js.map +1 -1
  55. package/build/src/export/getPublicExpoManifest.js +1 -1
  56. package/build/src/export/getPublicExpoManifest.js.map +1 -1
  57. package/build/src/export/getResolvedLocales.js.map +1 -1
  58. package/build/src/export/printBundleSizes.js.map +1 -1
  59. package/build/src/export/web/exportWebAsync.js.map +1 -1
  60. package/build/src/export/writeContents.js +5 -1
  61. package/build/src/export/writeContents.js.map +1 -1
  62. package/build/src/install/checkPackages.js +1 -1
  63. package/build/src/install/checkPackages.js.map +1 -1
  64. package/build/src/install/installAsync.js +1 -1
  65. package/build/src/install/installAsync.js.map +1 -1
  66. package/build/src/prebuild/configureProjectAsync.js +5 -9
  67. package/build/src/prebuild/configureProjectAsync.js.map +1 -1
  68. package/build/src/prebuild/prebuildAsync.js +5 -5
  69. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  70. package/build/src/prebuild/updateFromTemplate.js +8 -5
  71. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  72. package/build/src/register/registerAsync.js +0 -1
  73. package/build/src/register/registerAsync.js.map +1 -1
  74. package/build/src/run/android/resolveInstallApkName.js.map +1 -1
  75. package/build/src/run/android/resolveOptions.js +1 -1
  76. package/build/src/run/android/resolveOptions.js.map +1 -1
  77. package/build/src/run/android/runAndroidAsync.js +2 -2
  78. package/build/src/run/android/runAndroidAsync.js.map +1 -1
  79. package/build/src/run/ios/XcodeBuild.js +2 -2
  80. package/build/src/run/ios/XcodeBuild.js.map +1 -1
  81. package/build/src/run/ios/appleDevice/AppleDevice.js +4 -4
  82. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  83. package/build/src/run/ios/appleDevice/ClientManager.js +1 -1
  84. package/build/src/run/ios/appleDevice/ClientManager.js.map +1 -1
  85. package/build/src/run/ios/appleDevice/client/AFCClient.js +1 -1
  86. package/build/src/run/ios/appleDevice/client/AFCClient.js.map +1 -1
  87. package/build/src/run/ios/appleDevice/client/DebugserverClient.js +1 -1
  88. package/build/src/run/ios/appleDevice/client/DebugserverClient.js.map +1 -1
  89. package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js +1 -1
  90. package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -1
  91. package/build/src/run/ios/appleDevice/client/LockdowndClient.js +1 -1
  92. package/build/src/run/ios/appleDevice/client/LockdowndClient.js.map +1 -1
  93. package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js +1 -1
  94. package/build/src/run/ios/appleDevice/client/MobileImageMounterClient.js.map +1 -1
  95. package/build/src/run/ios/appleDevice/client/ServiceClient.js.map +1 -1
  96. package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js +1 -1
  97. package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js.map +1 -1
  98. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js +1 -1
  99. package/build/src/run/ios/appleDevice/installOnDeviceAsync.js.map +1 -1
  100. package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js +1 -1
  101. package/build/src/run/ios/appleDevice/protocol/AFCProtocol.js.map +1 -1
  102. package/build/src/run/ios/appleDevice/protocol/AbstractProtocol.js.map +1 -1
  103. package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js +1 -1
  104. package/build/src/run/ios/appleDevice/protocol/GDBProtocol.js.map +1 -1
  105. package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js +1 -1
  106. package/build/src/run/ios/appleDevice/protocol/LockdownProtocol.js.map +1 -1
  107. package/build/src/run/ios/codeSigning/configureCodeSigning.js +1 -1
  108. package/build/src/run/ios/codeSigning/configureCodeSigning.js.map +1 -1
  109. package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js +2 -2
  110. package/build/src/run/ios/codeSigning/resolveCertificateSigningIdentity.js.map +1 -1
  111. package/build/src/run/ios/codeSigning/xcodeCodeSigning.js +3 -0
  112. package/build/src/run/ios/codeSigning/xcodeCodeSigning.js.map +1 -1
  113. package/build/src/run/ios/index.js.map +1 -1
  114. package/build/src/run/ios/launchApp.js +2 -2
  115. package/build/src/run/ios/launchApp.js.map +1 -1
  116. package/build/src/run/ios/options/resolveDevice.js +1 -1
  117. package/build/src/run/ios/options/resolveDevice.js.map +1 -1
  118. package/build/src/run/ios/options/resolveOptions.js +2 -2
  119. package/build/src/run/ios/options/resolveOptions.js.map +1 -1
  120. package/build/src/run/ios/runIosAsync.js +3 -3
  121. package/build/src/run/ios/runIosAsync.js.map +1 -1
  122. package/build/src/start/doctor/apple/XcodePrerequisite.js +43 -2
  123. package/build/src/start/doctor/apple/XcodePrerequisite.js.map +1 -1
  124. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +1 -1
  125. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  126. package/build/src/start/doctor/dependencies/getVersionedPackages.js +5 -3
  127. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  128. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +1 -1
  129. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  130. package/build/src/start/doctor/ngrok/ExternalModule.js.map +1 -1
  131. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +7 -7
  132. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
  133. package/build/src/start/doctor/typescript/updateTSConfig.js +11 -10
  134. package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
  135. package/build/src/start/index.js +0 -2
  136. package/build/src/start/index.js.map +1 -1
  137. package/build/src/start/interface/interactiveActions.js +1 -1
  138. package/build/src/start/interface/interactiveActions.js.map +1 -1
  139. package/build/src/start/interface/startInterface.js +3 -3
  140. package/build/src/start/interface/startInterface.js.map +1 -1
  141. package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
  142. package/build/src/start/platforms/PlatformManager.js.map +1 -1
  143. package/build/src/start/platforms/android/ADBServer.js +1 -1
  144. package/build/src/start/platforms/android/ADBServer.js.map +1 -1
  145. package/build/src/start/platforms/android/AndroidDeviceManager.js +5 -5
  146. package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -1
  147. package/build/src/start/platforms/android/AndroidPlatformManager.js +1 -1
  148. package/build/src/start/platforms/android/AndroidPlatformManager.js.map +1 -1
  149. package/build/src/start/platforms/android/adb.js +1 -1
  150. package/build/src/start/platforms/android/adb.js.map +1 -1
  151. package/build/src/start/platforms/android/adbReverse.js +2 -2
  152. package/build/src/start/platforms/android/adbReverse.js.map +1 -1
  153. package/build/src/start/platforms/android/emulator.js +1 -1
  154. package/build/src/start/platforms/android/emulator.js.map +1 -1
  155. package/build/src/start/platforms/android/getDevices.js +1 -1
  156. package/build/src/start/platforms/android/getDevices.js.map +1 -1
  157. package/build/src/start/platforms/android/promptAndroidDevice.js +1 -1
  158. package/build/src/start/platforms/android/promptAndroidDevice.js.map +1 -1
  159. package/build/src/start/platforms/ios/AppleDeviceManager.js +5 -5
  160. package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
  161. package/build/src/start/platforms/ios/ApplePlatformManager.js +1 -1
  162. package/build/src/start/platforms/ios/ApplePlatformManager.js.map +1 -1
  163. package/build/src/start/platforms/ios/ensureSimulatorAppRunning.js.map +1 -1
  164. package/build/src/start/platforms/ios/getBestSimulator.js +1 -1
  165. package/build/src/start/platforms/ios/getBestSimulator.js.map +1 -1
  166. package/build/src/start/platforms/ios/promptAppleDevice.js +1 -1
  167. package/build/src/start/platforms/ios/promptAppleDevice.js.map +1 -1
  168. package/build/src/start/platforms/ios/simctl.js +1 -1
  169. package/build/src/start/platforms/ios/simctl.js.map +1 -1
  170. package/build/src/start/platforms/ios/simctlLogging.js +1 -1
  171. package/build/src/start/platforms/ios/simctlLogging.js.map +1 -1
  172. package/build/src/start/resolveOptions.js +0 -5
  173. package/build/src/start/resolveOptions.js.map +1 -1
  174. package/build/src/start/server/AsyncNgrok.js +4 -3
  175. package/build/src/start/server/AsyncNgrok.js.map +1 -1
  176. package/build/src/start/server/BundlerDevServer.js +4 -11
  177. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  178. package/build/src/start/server/DevServerManager.js +3 -2
  179. package/build/src/start/server/DevServerManager.js.map +1 -1
  180. package/build/src/start/server/UrlCreator.js +2 -1
  181. package/build/src/start/server/UrlCreator.js.map +1 -1
  182. package/build/src/start/server/getStaticRenderFunctions.js +2 -2
  183. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  184. package/build/src/start/server/metro/MetroBundlerDevServer.js +42 -25
  185. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  186. package/build/src/start/server/metro/MetroTerminalReporter.js +14 -3
  187. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  188. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  189. package/build/src/start/server/metro/TerminalReporter.types.js.map +1 -1
  190. package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
  191. package/build/src/start/server/metro/inspector-proxy/handlers/NetworkResponse.js.map +1 -1
  192. package/build/src/start/server/metro/inspector-proxy/handlers/PageReload.js.map +1 -1
  193. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -1
  194. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerScriptParsed.js.map +1 -1
  195. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerSetBreakpointByUrl.js.map +1 -1
  196. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeGetProperties.js.map +1 -1
  197. package/build/src/start/server/metro/inspector-proxy/handlers/types.js.map +1 -1
  198. package/build/src/start/server/metro/inspector-proxy/index.js +1 -1
  199. package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
  200. package/build/src/start/server/metro/instantiateMetro.js +49 -8
  201. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  202. package/build/src/start/server/metro/resolveFromProject.js +0 -4
  203. package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
  204. package/build/src/start/server/metro/runServer-fork.js +1 -1
  205. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  206. package/build/src/start/server/metro/withMetroMultiPlatform.js +29 -5
  207. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  208. package/build/src/start/server/metro/withMetroResolvers.js +1 -1
  209. package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
  210. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +2 -2
  211. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
  212. package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
  213. package/build/src/start/server/middleware/FaviconMiddleware.js +1 -1
  214. package/build/src/start/server/middleware/FaviconMiddleware.js.map +1 -1
  215. package/build/src/start/server/middleware/ManifestMiddleware.js +8 -5
  216. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  217. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js +1 -1
  218. package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
  219. package/build/src/start/server/middleware/ServeStaticMiddleware.js +1 -1
  220. package/build/src/start/server/middleware/ServeStaticMiddleware.js.map +1 -1
  221. package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
  222. package/build/src/start/server/middleware/server.types.js.map +1 -1
  223. package/build/src/start/server/openPlatforms.js.map +1 -1
  224. package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
  225. package/build/src/start/server/type-generation/routes.js +6 -6
  226. package/build/src/start/server/type-generation/routes.js.map +1 -1
  227. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js +3 -3
  228. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
  229. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +10 -5
  230. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  231. package/build/src/start/server/webpack/compile.js +1 -1
  232. package/build/src/start/server/webpack/compile.js.map +1 -1
  233. package/build/src/start/startAsync.js +10 -32
  234. package/build/src/start/startAsync.js.map +1 -1
  235. package/build/src/utils/FileNotifier.js +1 -1
  236. package/build/src/utils/FileNotifier.js.map +1 -1
  237. package/build/src/utils/analytics/metroDebuggerMiddleware.js +1 -1
  238. package/build/src/utils/analytics/metroDebuggerMiddleware.js.map +1 -1
  239. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  240. package/build/src/utils/array.js.map +1 -1
  241. package/build/src/utils/cocoapods.js +2 -2
  242. package/build/src/utils/cocoapods.js.map +1 -1
  243. package/build/src/utils/codesigning.js +2 -2
  244. package/build/src/utils/codesigning.js.map +1 -1
  245. package/build/src/utils/downloadAppAsync.js +1 -1
  246. package/build/src/utils/downloadAppAsync.js.map +1 -1
  247. package/build/src/utils/downloadExpoGoAsync.js +2 -2
  248. package/build/src/utils/downloadExpoGoAsync.js.map +1 -1
  249. package/build/src/utils/editor.js +1 -1
  250. package/build/src/utils/editor.js.map +1 -1
  251. package/build/src/utils/env.js +1 -1
  252. package/build/src/utils/env.js.map +1 -1
  253. package/build/src/utils/errors.js.map +1 -1
  254. package/build/src/utils/getOrPromptApplicationId.js +2 -2
  255. package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
  256. package/build/src/utils/git.js +1 -1
  257. package/build/src/utils/git.js.map +1 -1
  258. package/build/src/utils/modifyConfigAsync.js +1 -1
  259. package/build/src/utils/modifyConfigAsync.js.map +1 -1
  260. package/build/src/utils/modifyConfigPlugins.js +1 -1
  261. package/build/src/utils/modifyConfigPlugins.js.map +1 -1
  262. package/build/src/utils/npm.js +1 -1
  263. package/build/src/utils/npm.js.map +1 -1
  264. package/build/src/utils/obj.js.map +1 -1
  265. package/build/src/utils/plist.js +1 -1
  266. package/build/src/utils/plist.js.map +1 -1
  267. package/build/src/utils/port.js +1 -1
  268. package/build/src/utils/port.js.map +1 -1
  269. package/build/src/utils/profile.js +1 -1
  270. package/build/src/utils/profile.js.map +1 -1
  271. package/build/src/utils/scheme.js +1 -1
  272. package/build/src/utils/scheme.js.map +1 -1
  273. package/build/src/utils/tsconfig/loadTsConfigPaths.js +1 -1
  274. package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -1
  275. package/build/src/utils/validateApplicationId.js +85 -5
  276. package/build/src/utils/validateApplicationId.js.map +1 -1
  277. package/package.json +11 -8
  278. package/build/src/api/signManifest.js +0 -26
  279. package/build/src/api/signManifest.js.map +0 -1
  280. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +0 -155
  281. package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/withMetroResolvers.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport chalk from 'chalk';\nimport { ConfigT as MetroConfig } from 'metro-config';\nimport { ResolutionContext } from 'metro-resolver';\nimport path from 'path';\n\nimport { env } from '../../../utils/env';\nimport { isFailedToResolveNameError, isFailedToResolvePathError } from './metroErrors';\nimport { importMetroResolverFromProject } from './resolveFromProject';\n\nconst debug = require('debug')('expo:metro:withMetroResolvers') as typeof console.log;\n\nexport type MetroResolver = NonNullable<MetroConfig['resolver']['resolveRequest']>;\n\n/** Expo Metro Resolvers can return `null` to skip without throwing an error. Metro Resolvers will throw either a `FailedToResolveNameError` or `FailedToResolvePathError`. */\nexport type ExpoCustomMetroResolver = (\n ...args: Parameters<MetroResolver>\n) => ReturnType<MetroResolver> | null;\n\n/** @returns `MetroResolver` utilizing the upstream `resolve` method. */\nexport function getDefaultMetroResolver(projectRoot: string): MetroResolver {\n const { resolve } = importMetroResolverFromProject(projectRoot);\n return (context: ResolutionContext, moduleName: string, platform: string | null) => {\n return resolve(context, moduleName, platform);\n };\n}\n\nfunction optionsKeyForContext(context: ResolutionContext) {\n const canonicalize = require('metro-core/src/canonicalize');\n\n // Compound key for the resolver cache\n return JSON.stringify(context.customResolverOptions ?? {}, canonicalize) ?? '';\n}\n\n/**\n * Extend the Metro config `resolver.resolveRequest` method with additional resolvers that can\n * exit early by returning a `Resolution` or skip to the next resolver by returning `null`.\n *\n * @param config Metro config.\n * @param projectRoot path to the project root used to resolve the default Metro resolver.\n * @param resolvers custom MetroResolver to chain.\n * @returns a new `MetroConfig` with the `resolver.resolveRequest` method chained.\n */\nexport function withMetroResolvers(\n config: MetroConfig,\n projectRoot: string,\n resolvers: ExpoCustomMetroResolver[]\n): MetroConfig {\n debug(\n `Appending ${\n resolvers.length\n } custom resolvers to Metro config. (has custom resolver: ${!!config.resolver?.resolveRequest})`\n );\n const originalResolveRequest =\n config.resolver?.resolveRequest || getDefaultMetroResolver(projectRoot);\n\n function mutateResolutionError(\n error: Error,\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n if (!env.EXPO_METRO_UNSTABLE_ERRORS || !platform) {\n debug('Cannot mutate resolution error');\n return error;\n }\n\n const mapByOrigin = depGraph.get(optionsKeyForContext(context));\n const mapByPlatform = mapByOrigin?.get(platform);\n\n if (!mapByPlatform) {\n return error;\n }\n\n // collect all references inversely using some expensive lookup\n\n const getReferences = (origin: string) => {\n const inverseOrigin: { origin: string; previous: string; request: string }[] = [];\n\n if (!mapByPlatform) {\n return inverseOrigin;\n }\n\n for (const [originKey, mapByTarget] of mapByPlatform) {\n // search comparing origin to path\n\n const found = [...mapByTarget.values()].find((resolution) => resolution.path === origin);\n if (found) {\n inverseOrigin.push({\n origin,\n previous: originKey,\n request: found.request,\n });\n }\n }\n\n return inverseOrigin;\n };\n\n const pad = (num: number) => {\n return new Array(num).fill(' ').join('');\n };\n\n const root = config.server?.unstable_serverRoot ?? config.projectRoot ?? projectRoot;\n\n type InverseDepResult = {\n origin: string;\n request: string;\n previous: InverseDepResult[];\n };\n const recurseBackWithLimit = (\n req: { origin: string; request: string },\n limit: number,\n count: number = 0\n ) => {\n const results: InverseDepResult = {\n origin: req.origin,\n request: req.request,\n previous: [],\n };\n\n if (count >= limit) {\n return results;\n }\n\n const inverse = getReferences(req.origin);\n for (const match of inverse) {\n // Use more qualified name if possible\n // results.origin = match.origin;\n // Found entry point\n if (req.origin === match.previous) {\n continue;\n }\n results.previous.push(\n recurseBackWithLimit({ origin: match.previous, request: match.request }, limit, count + 1)\n );\n }\n return results;\n };\n\n const inverseTree = recurseBackWithLimit(\n { origin: context.originModulePath, request: moduleName },\n // TODO: Do we need to expose this?\n 35\n );\n\n if (inverseTree.previous.length > 0) {\n debug('Found inverse graph:', JSON.stringify(inverseTree, null, 2));\n let extraMessage = chalk.bold('Import stack:');\n const printRecursive = (tree: InverseDepResult, depth: number = 0) => {\n let filename = path.relative(root, tree.origin);\n if (filename.match(/\\?ctx=[\\w\\d]+$/)) {\n filename = filename.replace(/\\?ctx=[\\w\\d]+$/, chalk.dim(' (require.context)'));\n } else {\n let formattedRequest = chalk.green(`\"${tree.request}\"`);\n\n if (\n // If bundling for web and the import is pulling internals from outside of react-native\n // then mark it as an invalid import.\n platform === 'web' &&\n !/^(node_modules\\/)?react-native\\//.test(filename) &&\n tree.request.match(/^react-native\\/.*/)\n ) {\n formattedRequest =\n formattedRequest +\n chalk`\\n {yellow Importing react-native internals is not supported on web.}`;\n }\n\n filename = filename + chalk`\\n{gray |} {cyan import} ${formattedRequest}\\n`;\n }\n let line = '\\n' + pad(depth) + chalk.gray(' ') + filename;\n if (filename.match(/node_modules/)) {\n line = chalk.gray(\n // Bold the node module name\n line.replace(/node_modules\\/([^/]+)/, (_match, p1) => {\n return 'node_modules/' + chalk.bold(p1);\n })\n );\n }\n extraMessage += line;\n for (const child of tree.previous) {\n printRecursive(\n child,\n // Only add depth if there are multiple children\n tree.previous.length > 1 ? depth + 1 : depth\n );\n }\n };\n printRecursive(inverseTree);\n\n // @ts-expect-error\n error._expoImportStack = extraMessage;\n } else {\n debug('Found no inverse tree for:', context.originModulePath);\n }\n\n return error;\n }\n\n const depGraph: Map<\n // custom options\n string,\n Map<\n // platform\n string,\n Map<\n // origin module name\n string,\n Set<{\n // required module name\n path: string;\n // This isn't entirely accurate since a module can be imported multiple times in a file,\n // and use different names. But it's good enough for now.\n request: string;\n }>\n >\n >\n > = new Map();\n\n return {\n ...config,\n resolver: {\n ...config.resolver,\n resolveRequest(context, moduleName, platform) {\n const storeResult = (res: NonNullable<ReturnType<ExpoCustomMetroResolver>>) => {\n if (!env.EXPO_METRO_UNSTABLE_ERRORS || !platform) return;\n\n const key = optionsKeyForContext(context);\n if (!depGraph.has(key)) depGraph.set(key, new Map());\n const mapByTarget = depGraph.get(key);\n if (!mapByTarget!.has(platform)) mapByTarget!.set(platform, new Map());\n const mapByPlatform = mapByTarget!.get(platform);\n if (!mapByPlatform!.has(context.originModulePath))\n mapByPlatform!.set(context.originModulePath, new Set());\n const setForModule = mapByPlatform!.get(context.originModulePath)!;\n\n const qualifiedModuleName = res?.type === 'sourceFile' ? res.filePath : moduleName;\n setForModule.add({ path: qualifiedModuleName, request: moduleName });\n };\n\n const universalContext = {\n ...context,\n preferNativePlatform: platform !== 'web',\n };\n\n try {\n for (const resolver of resolvers) {\n try {\n const resolution = resolver(universalContext, moduleName, platform);\n if (resolution) {\n storeResult(resolution);\n return resolution;\n }\n } catch (error: any) {\n // If no user-defined resolver, use Expo's default behavior.\n // This prevents extraneous resolution attempts on failure.\n if (!config.resolver.resolveRequest) {\n throw error;\n }\n\n // If the error is directly related to a resolver not being able to resolve a module, then\n // we can ignore the error and try the next resolver. Otherwise, we should throw the error.\n const isResolutionError =\n isFailedToResolveNameError(error) || isFailedToResolvePathError(error);\n if (!isResolutionError) {\n throw error;\n }\n debug(\n `Custom resolver threw: ${error.constructor.name}. (module: ${moduleName}, platform: ${platform})`\n );\n }\n }\n // If we haven't returned by now, use the original resolver or upstream resolver.\n const res = originalResolveRequest(universalContext, moduleName, platform);\n storeResult(res);\n return res;\n } catch (error: any) {\n throw mutateResolutionError(error, universalContext, moduleName, platform);\n }\n },\n },\n };\n}\n"],"names":["getDefaultMetroResolver","withMetroResolvers","debug","require","projectRoot","resolve","importMetroResolverFromProject","context","moduleName","platform","optionsKeyForContext","canonicalize","JSON","stringify","customResolverOptions","config","resolvers","length","resolver","resolveRequest","originalResolveRequest","mutateResolutionError","error","env","EXPO_METRO_UNSTABLE_ERRORS","mapByOrigin","depGraph","get","mapByPlatform","getReferences","origin","inverseOrigin","originKey","mapByTarget","found","values","find","resolution","path","push","previous","request","pad","num","Array","fill","join","root","server","unstable_serverRoot","recurseBackWithLimit","req","limit","count","results","inverse","match","inverseTree","originModulePath","extraMessage","chalk","bold","printRecursive","tree","depth","filename","relative","replace","dim","formattedRequest","green","test","line","gray","_match","p1","child","_expoImportStack","Map","storeResult","res","key","has","set","Set","setForModule","qualifiedModuleName","type","filePath","add","universalContext","preferNativePlatform","isResolutionError","isFailedToResolveNameError","isFailedToResolvePathError","constructor","name"],"mappings":"AAMA;;;;QAmBgBA,uBAAuB,GAAvBA,uBAAuB;QAuBvBC,kBAAkB,GAAlBA,kBAAkB;AA1ChB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAGR,IAAA,KAAM,kC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Content":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport chalk from 'chalk';\nimport { ConfigT as MetroConfig } from 'metro-config';\nimport { ResolutionContext } from 'metro-resolver';\nimport path from 'path';\n\nimport { isFailedToResolveNameError, isFailedToResolvePathError } from './metroErrors';\nimport { importMetroResolverFromProject } from './resolveFromProject';\nimport { env } from '../../../utils/env';\n\nconst debug = require('debug')('expo:metro:withMetroResolvers') as typeof console.log;\n\nexport type MetroResolver = NonNullable<MetroConfig['resolver']['resolveRequest']>;\n\n/** Expo Metro Resolvers can return `null` to skip without throwing an error. Metro Resolvers will throw either a `FailedToResolveNameError` or `FailedToResolvePathError`. */\nexport type ExpoCustomMetroResolver = (\n ...args: Parameters<MetroResolver>\n) => ReturnType<MetroResolver> | null;\n\n/** @returns `MetroResolver` utilizing the upstream `resolve` method. */\nexport function getDefaultMetroResolver(projectRoot: string): MetroResolver {\n const { resolve } = importMetroResolverFromProject(projectRoot);\n return (context: ResolutionContext, moduleName: string, platform: string | null) => {\n return resolve(context, moduleName, platform);\n };\n}\n\nfunction optionsKeyForContext(context: ResolutionContext) {\n const canonicalize = require('metro-core/src/canonicalize');\n\n // Compound key for the resolver cache\n return JSON.stringify(context.customResolverOptions ?? {}, canonicalize) ?? '';\n}\n\n/**\n * Extend the Metro config `resolver.resolveRequest` method with additional resolvers that can\n * exit early by returning a `Resolution` or skip to the next resolver by returning `null`.\n *\n * @param config Metro config.\n * @param projectRoot path to the project root used to resolve the default Metro resolver.\n * @param resolvers custom MetroResolver to chain.\n * @returns a new `MetroConfig` with the `resolver.resolveRequest` method chained.\n */\nexport function withMetroResolvers(\n config: MetroConfig,\n projectRoot: string,\n resolvers: ExpoCustomMetroResolver[]\n): MetroConfig {\n debug(\n `Appending ${\n resolvers.length\n } custom resolvers to Metro config. (has custom resolver: ${!!config.resolver?.resolveRequest})`\n );\n const originalResolveRequest =\n config.resolver?.resolveRequest || getDefaultMetroResolver(projectRoot);\n\n function mutateResolutionError(\n error: Error,\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n if (!env.EXPO_METRO_UNSTABLE_ERRORS || !platform) {\n debug('Cannot mutate resolution error');\n return error;\n }\n\n const mapByOrigin = depGraph.get(optionsKeyForContext(context));\n const mapByPlatform = mapByOrigin?.get(platform);\n\n if (!mapByPlatform) {\n return error;\n }\n\n // collect all references inversely using some expensive lookup\n\n const getReferences = (origin: string) => {\n const inverseOrigin: { origin: string; previous: string; request: string }[] = [];\n\n if (!mapByPlatform) {\n return inverseOrigin;\n }\n\n for (const [originKey, mapByTarget] of mapByPlatform) {\n // search comparing origin to path\n\n const found = [...mapByTarget.values()].find((resolution) => resolution.path === origin);\n if (found) {\n inverseOrigin.push({\n origin,\n previous: originKey,\n request: found.request,\n });\n }\n }\n\n return inverseOrigin;\n };\n\n const pad = (num: number) => {\n return new Array(num).fill(' ').join('');\n };\n\n const root = config.server?.unstable_serverRoot ?? config.projectRoot ?? projectRoot;\n\n type InverseDepResult = {\n origin: string;\n request: string;\n previous: InverseDepResult[];\n };\n const recurseBackWithLimit = (\n req: { origin: string; request: string },\n limit: number,\n count: number = 0\n ) => {\n const results: InverseDepResult = {\n origin: req.origin,\n request: req.request,\n previous: [],\n };\n\n if (count >= limit) {\n return results;\n }\n\n const inverse = getReferences(req.origin);\n for (const match of inverse) {\n // Use more qualified name if possible\n // results.origin = match.origin;\n // Found entry point\n if (req.origin === match.previous) {\n continue;\n }\n results.previous.push(\n recurseBackWithLimit({ origin: match.previous, request: match.request }, limit, count + 1)\n );\n }\n return results;\n };\n\n const inverseTree = recurseBackWithLimit(\n { origin: context.originModulePath, request: moduleName },\n // TODO: Do we need to expose this?\n 35\n );\n\n if (inverseTree.previous.length > 0) {\n debug('Found inverse graph:', JSON.stringify(inverseTree, null, 2));\n let extraMessage = chalk.bold('Import stack:');\n const printRecursive = (tree: InverseDepResult, depth: number = 0) => {\n let filename = path.relative(root, tree.origin);\n if (filename.match(/\\?ctx=[\\w\\d]+$/)) {\n filename = filename.replace(/\\?ctx=[\\w\\d]+$/, chalk.dim(' (require.context)'));\n } else {\n let formattedRequest = chalk.green(`\"${tree.request}\"`);\n\n if (\n // If bundling for web and the import is pulling internals from outside of react-native\n // then mark it as an invalid import.\n platform === 'web' &&\n !/^(node_modules\\/)?react-native\\//.test(filename) &&\n tree.request.match(/^react-native\\/.*/)\n ) {\n formattedRequest =\n formattedRequest +\n chalk`\\n {yellow Importing react-native internals is not supported on web.}`;\n }\n\n filename = filename + chalk`\\n{gray |} {cyan import} ${formattedRequest}\\n`;\n }\n let line = '\\n' + pad(depth) + chalk.gray(' ') + filename;\n if (filename.match(/node_modules/)) {\n line = chalk.gray(\n // Bold the node module name\n line.replace(/node_modules\\/([^/]+)/, (_match, p1) => {\n return 'node_modules/' + chalk.bold(p1);\n })\n );\n }\n extraMessage += line;\n for (const child of tree.previous) {\n printRecursive(\n child,\n // Only add depth if there are multiple children\n tree.previous.length > 1 ? depth + 1 : depth\n );\n }\n };\n printRecursive(inverseTree);\n\n // @ts-expect-error\n error._expoImportStack = extraMessage;\n } else {\n debug('Found no inverse tree for:', context.originModulePath);\n }\n\n return error;\n }\n\n const depGraph: Map<\n // custom options\n string,\n Map<\n // platform\n string,\n Map<\n // origin module name\n string,\n Set<{\n // required module name\n path: string;\n // This isn't entirely accurate since a module can be imported multiple times in a file,\n // and use different names. But it's good enough for now.\n request: string;\n }>\n >\n >\n > = new Map();\n\n return {\n ...config,\n resolver: {\n ...config.resolver,\n resolveRequest(context, moduleName, platform) {\n const storeResult = (res: NonNullable<ReturnType<ExpoCustomMetroResolver>>) => {\n if (!env.EXPO_METRO_UNSTABLE_ERRORS || !platform) return;\n\n const key = optionsKeyForContext(context);\n if (!depGraph.has(key)) depGraph.set(key, new Map());\n const mapByTarget = depGraph.get(key);\n if (!mapByTarget!.has(platform)) mapByTarget!.set(platform, new Map());\n const mapByPlatform = mapByTarget!.get(platform);\n if (!mapByPlatform!.has(context.originModulePath))\n mapByPlatform!.set(context.originModulePath, new Set());\n const setForModule = mapByPlatform!.get(context.originModulePath)!;\n\n const qualifiedModuleName = res?.type === 'sourceFile' ? res.filePath : moduleName;\n setForModule.add({ path: qualifiedModuleName, request: moduleName });\n };\n\n const universalContext = {\n ...context,\n preferNativePlatform: platform !== 'web',\n };\n\n try {\n for (const resolver of resolvers) {\n try {\n const resolution = resolver(universalContext, moduleName, platform);\n if (resolution) {\n storeResult(resolution);\n return resolution;\n }\n } catch (error: any) {\n // If no user-defined resolver, use Expo's default behavior.\n // This prevents extraneous resolution attempts on failure.\n if (!config.resolver.resolveRequest) {\n throw error;\n }\n\n // If the error is directly related to a resolver not being able to resolve a module, then\n // we can ignore the error and try the next resolver. Otherwise, we should throw the error.\n const isResolutionError =\n isFailedToResolveNameError(error) || isFailedToResolvePathError(error);\n if (!isResolutionError) {\n throw error;\n }\n debug(\n `Custom resolver threw: ${error.constructor.name}. (module: ${moduleName}, platform: ${platform})`\n );\n }\n }\n // If we haven't returned by now, use the original resolver or upstream resolver.\n const res = originalResolveRequest(universalContext, moduleName, platform);\n storeResult(res);\n return res;\n } catch (error: any) {\n throw mutateResolutionError(error, universalContext, moduleName, platform);\n }\n },\n },\n };\n}\n"],"names":["getDefaultMetroResolver","withMetroResolvers","debug","require","projectRoot","resolve","importMetroResolverFromProject","context","moduleName","platform","optionsKeyForContext","canonicalize","JSON","stringify","customResolverOptions","config","resolvers","length","resolver","resolveRequest","originalResolveRequest","mutateResolutionError","error","env","EXPO_METRO_UNSTABLE_ERRORS","mapByOrigin","depGraph","get","mapByPlatform","getReferences","origin","inverseOrigin","originKey","mapByTarget","found","values","find","resolution","path","push","previous","request","pad","num","Array","fill","join","root","server","unstable_serverRoot","recurseBackWithLimit","req","limit","count","results","inverse","match","inverseTree","originModulePath","extraMessage","chalk","bold","printRecursive","tree","depth","filename","relative","replace","dim","formattedRequest","green","test","line","gray","_match","p1","child","_expoImportStack","Map","storeResult","res","key","has","set","Set","setForModule","qualifiedModuleName","type","filePath","add","universalContext","preferNativePlatform","isResolutionError","isFailedToResolveNameError","isFailedToResolvePathError","constructor","name"],"mappings":"AAMA;;;;QAmBgBA,uBAAuB,GAAvBA,uBAAuB;QAuBvBC,kBAAkB,GAAlBA,kBAAkB;AA1ChB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAGR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEgD,IAAA,YAAe,WAAf,eAAe,CAAA;AACvC,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACjD,IAAA,IAAoB,WAApB,oBAAoB,CAAA;;;;;;AAExC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,+BAA+B,CAAC,AAAsB,AAAC;AAU/E,SAASH,uBAAuB,CAACI,WAAmB,EAAiB;IAC1E,MAAM,EAAEC,OAAO,CAAA,EAAE,GAAGC,CAAAA,GAAAA,mBAA8B,AAAa,CAAA,+BAAb,CAACF,WAAW,CAAC,AAAC;IAChE,OAAO,CAACG,OAA0B,EAAEC,UAAkB,EAAEC,QAAuB,GAAK;QAClF,OAAOJ,OAAO,CAACE,OAAO,EAAEC,UAAU,EAAEC,QAAQ,CAAC,CAAC;KAC/C,CAAC;CACH;AAED,SAASC,oBAAoB,CAACH,OAA0B,EAAE;IACxD,MAAMI,YAAY,GAAGR,OAAO,CAAC,6BAA6B,CAAC,AAAC;QAGtCI,sBAA6B,EAA5CK,GAAiE;IADxE,sCAAsC;IACtC,OAAOA,CAAAA,GAAiE,GAAjEA,IAAI,CAACC,SAAS,CAACN,CAAAA,sBAA6B,GAA7BA,OAAO,CAACO,qBAAqB,YAA7BP,sBAA6B,GAAI,EAAE,EAAEI,YAAY,CAAC,YAAjEC,GAAiE,GAAI,EAAE,CAAC;CAChF;AAWM,SAASX,kBAAkB,CAChCc,MAAmB,EACnBX,WAAmB,EACnBY,SAAoC,EACvB;QAImDD,IAAe,EAG7EA,IAAe;IANjBb,KAAK,CACH,CAAC,U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ACjB,OAAOA,GAAG,CAAC;iBACZ,CAAC,OAAO1D,KAAK,EAAO;oBACnB,MAAMD,qBAAqB,CAACC,KAAK,EAAEoE,gBAAgB,EAAElF,UAAU,EAAEC,QAAQ,CAAC,CAAC;iBAC5E;aACF;SACF;KACF,CAAC;CACH"}
@@ -8,14 +8,14 @@ var _accepts = _interopRequireDefault(require("accepts"));
8
8
  var _crypto = _interopRequireDefault(require("crypto"));
9
9
  var _formData = _interopRequireDefault(require("form-data"));
10
10
  var _structuredHeaders = require("structured-headers");
11
+ var _manifestMiddleware = require("./ManifestMiddleware");
12
+ var _resolvePlatform = require("./resolvePlatform");
11
13
  var _userSettings = _interopRequireDefault(require("../../../api/user/UserSettings"));
12
14
  var _user = require("../../../api/user/user");
13
15
  var _rudderstackClient = require("../../../utils/analytics/rudderstackClient");
14
16
  var _codesigning = require("../../../utils/codesigning");
15
17
  var _errors = require("../../../utils/errors");
16
18
  var _url = require("../../../utils/url");
17
- var _manifestMiddleware = require("./ManifestMiddleware");
18
- var _resolvePlatform = require("./resolvePlatform");
19
19
  function _interopRequireDefault(obj) {
20
20
  return obj && obj.__esModule ? obj : {
21
21
  default: obj
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/ExpoGoManifestHandlerMiddleware.ts"],"sourcesContent":["import { ExpoUpdatesManifest } from '@expo/config';\nimport { Updates } from '@expo/config-plugins';\nimport accepts from 'accepts';\nimport crypto from 'crypto';\nimport FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\n\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME } from '../../../api/user/user';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport {\n CodeSigningInfo,\n getCodeSigningInfoAsync,\n signManifestString,\n} from '../../../utils/codesigning';\nimport { CommandError } from '../../../utils/errors';\nimport { stripPort } from '../../../utils/url';\nimport { ManifestMiddleware, ManifestRequestInfo } from './ManifestMiddleware';\nimport { assertRuntimePlatform, parsePlatformHeader } from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:ExpoGoManifestHandlerMiddleware');\n\nexport enum ResponseContentType {\n TEXT_PLAIN,\n APPLICATION_JSON,\n APPLICATION_EXPO_JSON,\n MULTIPART_MIXED,\n}\n\ninterface ExpoGoManifestRequestInfo extends ManifestRequestInfo {\n responseContentType: ResponseContentType;\n expectSignature: string | null;\n}\n\nexport class ExpoGoManifestHandlerMiddleware extends ManifestMiddleware<ExpoGoManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ExpoGoManifestRequestInfo {\n let platform = parsePlatformHeader(req);\n\n if (!platform) {\n debug(\n `No \"expo-platform\" header or \"platform\" query parameter specified. Falling back to \"ios\".`\n );\n platform = 'ios';\n }\n\n assertRuntimePlatform(platform);\n\n // Expo Updates clients explicitly accept \"multipart/mixed\" responses while browsers implicitly\n // accept them with \"accept: */*\". To make it easier to debug manifest responses by visiting their\n // URLs in a browser, we denote the response as \"text/plain\" if the user agent appears not to be\n // an Expo Updates client.\n const accept = accepts(req);\n const acceptedType = accept.types([\n 'unknown/unknown',\n 'multipart/mixed',\n 'application/json',\n 'application/expo+json',\n 'text/plain',\n ]);\n\n let responseContentType;\n switch (acceptedType) {\n case 'multipart/mixed':\n responseContentType = ResponseContentType.MULTIPART_MIXED;\n break;\n case 'application/json':\n responseContentType = ResponseContentType.APPLICATION_JSON;\n break;\n case 'application/expo+json':\n responseContentType = ResponseContentType.APPLICATION_EXPO_JSON;\n break;\n default:\n responseContentType = ResponseContentType.TEXT_PLAIN;\n break;\n }\n\n const expectSignature = req.headers['expo-expect-signature'];\n\n return {\n responseContentType,\n platform,\n expectSignature: expectSignature ? String(expectSignature) : null,\n hostname: stripPort(req.headers['host']),\n };\n }\n\n private getDefaultResponseHeaders(): ServerHeaders {\n const headers = new Map<string, number | string | readonly string[]>();\n // set required headers for Expo Updates manifest specification\n headers.set('expo-protocol-version', 0);\n headers.set('expo-sfv-version', 0);\n headers.set('cache-control', 'private, max-age=0');\n return headers;\n }\n\n public async _getManifestResponseAsync(requestOptions: ExpoGoManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }> {\n const { exp, hostUri, expoGoConfig, bundleUrl } = await this._resolveProjectSettingsAsync(\n requestOptions\n );\n\n const runtimeVersion = Updates.getRuntimeVersion(\n { ...exp, runtimeVersion: exp.runtimeVersion ?? { policy: 'sdkVersion' } },\n requestOptions.platform\n );\n if (!runtimeVersion) {\n throw new CommandError(\n 'MANIFEST_MIDDLEWARE',\n `Unable to determine runtime version for platform '${requestOptions.platform}'`\n );\n }\n\n const codeSigningInfo = await getCodeSigningInfoAsync(\n exp,\n requestOptions.expectSignature,\n this.options.privateKeyPath\n );\n\n const easProjectId = exp.extra?.eas?.projectId as string | undefined | null;\n const scopeKey = await ExpoGoManifestHandlerMiddleware.getScopeKeyAsync({\n slug: exp.slug,\n codeSigningInfo,\n });\n\n const expoUpdatesManifest: ExpoUpdatesManifest = {\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n runtimeVersion,\n launchAsset: {\n key: 'bundle',\n contentType: 'application/javascript',\n url: bundleUrl,\n },\n assets: [], // assets are not used in development\n metadata: {}, // required for the client to detect that this is an expo-updates manifest\n extra: {\n eas: {\n projectId: easProjectId ?? undefined,\n },\n expoClient: {\n ...exp,\n hostUri,\n },\n expoGo: expoGoConfig,\n scopeKey,\n },\n };\n\n const stringifiedManifest = JSON.stringify(expoUpdatesManifest);\n\n let manifestPartHeaders: { 'expo-signature': string } | null = null;\n let certificateChainBody: string | null = null;\n if (codeSigningInfo) {\n const signature = signManifestString(stringifiedManifest, codeSigningInfo);\n manifestPartHeaders = {\n 'expo-signature': serializeDictionary(\n convertToDictionaryItemsRepresentation({\n keyid: codeSigningInfo.keyId,\n sig: signature,\n alg: 'rsa-v1_5-sha256',\n })\n ),\n };\n certificateChainBody = codeSigningInfo.certificateChainForResponse.join('\\n');\n }\n\n const headers = this.getDefaultResponseHeaders();\n\n switch (requestOptions.responseContentType) {\n case ResponseContentType.MULTIPART_MIXED: {\n const form = this.getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n });\n headers.set('content-type', `multipart/mixed; boundary=${form.getBoundary()}`);\n return {\n body: form.getBuffer().toString(),\n version: runtimeVersion,\n headers,\n };\n }\n case ResponseContentType.APPLICATION_EXPO_JSON:\n case ResponseContentType.APPLICATION_JSON:\n case ResponseContentType.TEXT_PLAIN: {\n headers.set(\n 'content-type',\n ExpoGoManifestHandlerMiddleware.getContentTypeForResponseContentType(\n requestOptions.responseContentType\n )\n );\n if (manifestPartHeaders) {\n Object.entries(manifestPartHeaders).forEach(([key, value]) => {\n headers.set(key, value);\n });\n }\n\n return {\n body: stringifiedManifest,\n version: runtimeVersion,\n headers,\n };\n }\n }\n }\n\n private static getContentTypeForResponseContentType(\n responseContentType: ResponseContentType\n ): string {\n switch (responseContentType) {\n case ResponseContentType.MULTIPART_MIXED:\n return 'multipart/mixed';\n case ResponseContentType.APPLICATION_EXPO_JSON:\n return 'application/expo+json';\n case ResponseContentType.APPLICATION_JSON:\n return 'application/json';\n case ResponseContentType.TEXT_PLAIN:\n return 'text/plain';\n }\n }\n\n private getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n }: {\n stringifiedManifest: string;\n manifestPartHeaders: { 'expo-signature': string } | null;\n certificateChainBody: string | null;\n }): FormData {\n const form = new FormData();\n form.append('manifest', stringifiedManifest, {\n contentType: 'application/json',\n header: {\n ...manifestPartHeaders,\n },\n });\n if (certificateChainBody && certificateChainBody.length > 0) {\n form.append('certificate_chain', certificateChainBody, {\n contentType: 'application/x-pem-file',\n });\n }\n return form;\n }\n\n protected trackManifest(version?: string) {\n logEventAsync('Serve Expo Updates Manifest', {\n runtimeVersion: version,\n });\n }\n\n private static async getScopeKeyAsync({\n slug,\n codeSigningInfo,\n }: {\n slug: string;\n codeSigningInfo: CodeSigningInfo | null;\n }): Promise<string> {\n const scopeKeyFromCodeSigningInfo = codeSigningInfo?.scopeKey;\n if (scopeKeyFromCodeSigningInfo) {\n return scopeKeyFromCodeSigningInfo;\n }\n\n // Log.warn(\n // env.EXPO_OFFLINE\n // ? 'Using anonymous scope key in manifest for offline mode.'\n // : 'Using anonymous scope key in manifest.'\n // );\n return await getAnonymousScopeKeyAsync(slug);\n }\n}\n\nasync function getAnonymousScopeKeyAsync(slug: string): Promise<string> {\n const userAnonymousIdentifier = await UserSettings.getAnonymousIdentifierAsync();\n return `@${ANONYMOUS_USERNAME}/${slug}-${userAnonymousIdentifier}`;\n}\n\nfunction convertToDictionaryItemsRepresentation(obj: { [key: string]: string }): Dictionary {\n return new Map(\n Object.entries(obj).map(([k, v]) => {\n return [k, [v, new Map()]];\n })\n );\n}\n"],"names":["debug","require","ResponseContentType","TEXT_PLAIN","APPLICATION_JSON","APPLICATION_EXPO_JSON","MULTIPART_MIXED","ExpoGoManifestHandlerMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","accept","accepts","acceptedType","types","responseContentType","expectSignature","headers","String","hostname","stripPort","getDefaultResponseHeaders","Map","set","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","runtimeVersion","Updates","getRuntimeVersion","policy","CommandError","codeSigningInfo","getCodeSigningInfoAsync","options","privateKeyPath","easProjectId","extra","eas","projectId","scopeKey","getScopeKeyAsync","slug","expoUpdatesManifest","id","crypto","randomUUID","createdAt","Date","toISOString","launchAsset","key","contentType","url","assets","metadata","undefined","expoClient","expoGo","stringifiedManifest","JSON","stringify","manifestPartHeaders","certificateChainBody","signature","signManifestString","serializeDictionary","convertToDictionaryItemsRepresentation","keyid","keyId","sig","alg","certificateChainForResponse","join","form","getFormData","getBoundary","body","getBuffer","toString","version","getContentTypeForResponseContentType","Object","entries","forEach","value","FormData","append","header","length","trackManifest","logEventAsync","scopeKeyFromCodeSigningInfo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,IAAI,CAAC,CAAC;KAC9C;CACF;QA/OY1C,+BAA+B,GAA/BA,+BAA+B;AAiP5C,eAAe6F,yBAAyB,CAACnD,IAAY,EAAmB;IACtE,MAAMoD,uBAAuB,GAAG,MAAMC,aAAY,QAAA,CAACC,2BAA2B,EAAE,AAAC;IACjF,OAAO,CAAC,CAAC,EAAEC,KAAkB,mBAAA,CAAC,CAAC,EAAEvD,IAAI,CAAC,CAAC,EAAEoD,uBAAuB,CAAC,CAAC,CAAC;CACpE;AAED,SAAS3B,sCAAsC,CAAC+B,GAA8B,EAAc;IAC1F,OAAO,IAAIhF,GAAG,CACZgE,MAAM,CAACC,OAAO,CAACe,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAK;QAClC,OAAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAInF,GAAG,EAAE;aAAC;SAAC,CAAC;KAC5B,CAAC,CACH,CAAC;CACH"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/ExpoGoManifestHandlerMiddleware.ts"],"sourcesContent":["import { ExpoUpdatesManifest } from '@expo/config';\nimport { Updates } from '@expo/config-plugins';\nimport accepts from 'accepts';\nimport crypto from 'crypto';\nimport FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\n\nimport { ManifestMiddleware, ManifestRequestInfo } from './ManifestMiddleware';\nimport { assertRuntimePlatform, parsePlatformHeader } from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME } from '../../../api/user/user';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport {\n CodeSigningInfo,\n getCodeSigningInfoAsync,\n signManifestString,\n} from '../../../utils/codesigning';\nimport { CommandError } from '../../../utils/errors';\nimport { stripPort } from '../../../utils/url';\n\nconst debug = require('debug')('expo:start:server:middleware:ExpoGoManifestHandlerMiddleware');\n\nexport enum ResponseContentType {\n TEXT_PLAIN,\n APPLICATION_JSON,\n APPLICATION_EXPO_JSON,\n MULTIPART_MIXED,\n}\n\ninterface ExpoGoManifestRequestInfo extends ManifestRequestInfo {\n responseContentType: ResponseContentType;\n expectSignature: string | null;\n}\n\nexport class ExpoGoManifestHandlerMiddleware extends ManifestMiddleware<ExpoGoManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ExpoGoManifestRequestInfo {\n let platform = parsePlatformHeader(req);\n\n if (!platform) {\n debug(\n `No \"expo-platform\" header or \"platform\" query parameter specified. Falling back to \"ios\".`\n );\n platform = 'ios';\n }\n\n assertRuntimePlatform(platform);\n\n // Expo Updates clients explicitly accept \"multipart/mixed\" responses while browsers implicitly\n // accept them with \"accept: */*\". To make it easier to debug manifest responses by visiting their\n // URLs in a browser, we denote the response as \"text/plain\" if the user agent appears not to be\n // an Expo Updates client.\n const accept = accepts(req);\n const acceptedType = accept.types([\n 'unknown/unknown',\n 'multipart/mixed',\n 'application/json',\n 'application/expo+json',\n 'text/plain',\n ]);\n\n let responseContentType;\n switch (acceptedType) {\n case 'multipart/mixed':\n responseContentType = ResponseContentType.MULTIPART_MIXED;\n break;\n case 'application/json':\n responseContentType = ResponseContentType.APPLICATION_JSON;\n break;\n case 'application/expo+json':\n responseContentType = ResponseContentType.APPLICATION_EXPO_JSON;\n break;\n default:\n responseContentType = ResponseContentType.TEXT_PLAIN;\n break;\n }\n\n const expectSignature = req.headers['expo-expect-signature'];\n\n return {\n responseContentType,\n platform,\n expectSignature: expectSignature ? String(expectSignature) : null,\n hostname: stripPort(req.headers['host']),\n };\n }\n\n private getDefaultResponseHeaders(): ServerHeaders {\n const headers = new Map<string, number | string | readonly string[]>();\n // set required headers for Expo Updates manifest specification\n headers.set('expo-protocol-version', 0);\n headers.set('expo-sfv-version', 0);\n headers.set('cache-control', 'private, max-age=0');\n return headers;\n }\n\n public async _getManifestResponseAsync(requestOptions: ExpoGoManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }> {\n const { exp, hostUri, expoGoConfig, bundleUrl } = await this._resolveProjectSettingsAsync(\n requestOptions\n );\n\n const runtimeVersion = Updates.getRuntimeVersion(\n { ...exp, runtimeVersion: exp.runtimeVersion ?? { policy: 'sdkVersion' } },\n requestOptions.platform\n );\n if (!runtimeVersion) {\n throw new CommandError(\n 'MANIFEST_MIDDLEWARE',\n `Unable to determine runtime version for platform '${requestOptions.platform}'`\n );\n }\n\n const codeSigningInfo = await getCodeSigningInfoAsync(\n exp,\n requestOptions.expectSignature,\n this.options.privateKeyPath\n );\n\n const easProjectId = exp.extra?.eas?.projectId as string | undefined | null;\n const scopeKey = await ExpoGoManifestHandlerMiddleware.getScopeKeyAsync({\n slug: exp.slug,\n codeSigningInfo,\n });\n\n const expoUpdatesManifest: ExpoUpdatesManifest = {\n id: crypto.randomUUID(),\n createdAt: new Date().toISOString(),\n runtimeVersion,\n launchAsset: {\n key: 'bundle',\n contentType: 'application/javascript',\n url: bundleUrl,\n },\n assets: [], // assets are not used in development\n metadata: {}, // required for the client to detect that this is an expo-updates manifest\n extra: {\n eas: {\n projectId: easProjectId ?? undefined,\n },\n expoClient: {\n ...exp,\n hostUri,\n },\n expoGo: expoGoConfig,\n scopeKey,\n },\n };\n\n const stringifiedManifest = JSON.stringify(expoUpdatesManifest);\n\n let manifestPartHeaders: { 'expo-signature': string } | null = null;\n let certificateChainBody: string | null = null;\n if (codeSigningInfo) {\n const signature = signManifestString(stringifiedManifest, codeSigningInfo);\n manifestPartHeaders = {\n 'expo-signature': serializeDictionary(\n convertToDictionaryItemsRepresentation({\n keyid: codeSigningInfo.keyId,\n sig: signature,\n alg: 'rsa-v1_5-sha256',\n })\n ),\n };\n certificateChainBody = codeSigningInfo.certificateChainForResponse.join('\\n');\n }\n\n const headers = this.getDefaultResponseHeaders();\n\n switch (requestOptions.responseContentType) {\n case ResponseContentType.MULTIPART_MIXED: {\n const form = this.getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n });\n headers.set('content-type', `multipart/mixed; boundary=${form.getBoundary()}`);\n return {\n body: form.getBuffer().toString(),\n version: runtimeVersion,\n headers,\n };\n }\n case ResponseContentType.APPLICATION_EXPO_JSON:\n case ResponseContentType.APPLICATION_JSON:\n case ResponseContentType.TEXT_PLAIN: {\n headers.set(\n 'content-type',\n ExpoGoManifestHandlerMiddleware.getContentTypeForResponseContentType(\n requestOptions.responseContentType\n )\n );\n if (manifestPartHeaders) {\n Object.entries(manifestPartHeaders).forEach(([key, value]) => {\n headers.set(key, value);\n });\n }\n\n return {\n body: stringifiedManifest,\n version: runtimeVersion,\n headers,\n };\n }\n }\n }\n\n private static getContentTypeForResponseContentType(\n responseContentType: ResponseContentType\n ): string {\n switch (responseContentType) {\n case ResponseContentType.MULTIPART_MIXED:\n return 'multipart/mixed';\n case ResponseContentType.APPLICATION_EXPO_JSON:\n return 'application/expo+json';\n case ResponseContentType.APPLICATION_JSON:\n return 'application/json';\n case ResponseContentType.TEXT_PLAIN:\n return 'text/plain';\n }\n }\n\n private getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n }: {\n stringifiedManifest: string;\n manifestPartHeaders: { 'expo-signature': string } | null;\n certificateChainBody: string | null;\n }): FormData {\n const form = new FormData();\n form.append('manifest', stringifiedManifest, {\n contentType: 'application/json',\n header: {\n ...manifestPartHeaders,\n },\n });\n if (certificateChainBody && certificateChainBody.length > 0) {\n form.append('certificate_chain', certificateChainBody, {\n contentType: 'application/x-pem-file',\n });\n }\n return form;\n }\n\n protected trackManifest(version?: string) {\n logEventAsync('Serve Expo Updates Manifest', {\n runtimeVersion: version,\n });\n }\n\n private static async getScopeKeyAsync({\n slug,\n codeSigningInfo,\n }: {\n slug: string;\n codeSigningInfo: CodeSigningInfo | null;\n }): Promise<string> {\n const scopeKeyFromCodeSigningInfo = codeSigningInfo?.scopeKey;\n if (scopeKeyFromCodeSigningInfo) {\n return scopeKeyFromCodeSigningInfo;\n }\n\n // Log.warn(\n // env.EXPO_OFFLINE\n // ? 'Using anonymous scope key in manifest for offline mode.'\n // : 'Using anonymous scope key in manifest.'\n // );\n return await getAnonymousScopeKeyAsync(slug);\n }\n}\n\nasync function getAnonymousScopeKeyAsync(slug: string): Promise<string> {\n const userAnonymousIdentifier = await UserSettings.getAnonymousIdentifierAsync();\n return `@${ANONYMOUS_USERNAME}/${slug}-${userAnonymousIdentifier}`;\n}\n\nfunction convertToDictionaryItemsRepresentation(obj: { [key: string]: string }): Dictionary {\n return new Map(\n Object.entries(obj).map(([k, v]) => {\n return [k, [v, new Map()]];\n })\n );\n}\n"],"names":["debug","require","ResponseContentType","TEXT_PLAIN","APPLICATION_JSON","APPLICATION_EXPO_JSON","MULTIPART_MIXED","ExpoGoManifestHandlerMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","accept","accepts","acceptedType","types","responseContentType","expectSignature","headers","String","hostname","stripPort","getDefaultResponseHeaders","Map","set","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","runtimeVersion","Updates","getRuntimeVersion","policy","CommandError","codeSigningInfo","getCodeSigningInfoAsync","options","privateKeyPath","easProjectId","extra","eas","projectId","scopeKey","getScopeKeyAsync","slug","expoUpdatesManifest","id","crypto","randomUUID","createdAt","Date","toISOString","launchAsset","key","contentType","url","assets","metadata","undefined","expoClient","expoGo","stringifiedManifest","JSON","stringify","manifestPartHeaders","certificateChainBody","signature","signManifestString","serializeDictionary","convertToDictionaryItemsRepresentation","keyid","keyId","sig","alg","certificateChainForResponse","join","form","getFormData","getBoundary","body","getBuffer","toString","version","getContentTypeForResponseContentType","Object","entries","forEach","value","FormData","append","header","length","trackManifest","logEventAsync","scopeKeyFromCodeSigningInfo","getAnonymousScopeKeyAsync","userAnonymousIdentifier","UserSettings","getAnonymousIdentifierAsync","ANONYMOUS_USERNAME","obj","map","k","v"],"mappings":"AAAA;;;;;AACwB,IAAA,cAAsB,WA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AAuB,GAAG,MAAMC,aAAY,QAAA,CAACC,2BAA2B,EAAE,AAAC;IACjF,OAAO,CAAC,CAAC,EAAEC,KAAkB,mBAAA,CAAC,CAAC,EAAEvD,IAAI,CAAC,CAAC,EAAEoD,uBAAuB,CAAC,CAAC,CAAC;CACpE;AAED,SAAS3B,sCAAsC,CAAC+B,GAA8B,EAAc;IAC1F,OAAO,IAAIhF,GAAG,CACZgE,MAAM,CAACC,OAAO,CAACe,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAK;QAClC,OAAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAInF,GAAG,EAAE;aAAC;SAAC,CAAC;KAC5B,CAAC,CACH,CAAC;CACH"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/ExpoMiddleware.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport * as Log from '../../../log';\nimport { ServerNext, ServerRequest, ServerResponse } from './server.types';\n\n/** Base middleware creator for Expo dev servers. */\nexport abstract class ExpoMiddleware {\n constructor(protected projectRoot: string, protected supportedPaths: string[]) {}\n\n /**\n * Returns true when the middleware should handle the incoming server request.\n * Exposed for testing.\n */\n _shouldHandleRequest(req: ServerRequest): boolean {\n if (!req.url) {\n return false;\n }\n const parsed = parse(req.url);\n // Strip the query params\n if (!parsed.pathname) {\n return false;\n }\n\n return this.supportedPaths.includes(parsed.pathname);\n }\n\n abstract handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void>;\n\n /** Create a server middleware handler. */\n public getHandler() {\n const internalMiddleware = async (\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ) => {\n try {\n return await this.handleRequestAsync(req, res, next);\n } catch (error: any) {\n Log.exception(error);\n // 5xx = Server Error HTTP code\n res.statusCode = 500;\n if (typeof error === 'object' && error !== null) {\n res.end(\n JSON.stringify({\n error: error.toString(),\n })\n );\n } else {\n res.end(`Unexpected error: ${error}`);\n }\n }\n };\n const middleware = async (req: ServerRequest, res: ServerResponse, next: ServerNext) => {\n if (!this._shouldHandleRequest(req)) {\n return next();\n }\n return internalMiddleware(req, res, next);\n };\n\n middleware.internal = internalMiddleware;\n\n return middleware;\n }\n}\n\nexport function disableResponseCache(res: ServerResponse): ServerResponse {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, must-revalidate');\n res.setHeader('Expires', '-1');\n res.setHeader('Pragma', 'no-cache');\n return res;\n}\n"],"names":["disableResponseCache","Log","ExpoMiddleware","constructor","projectRoot","supportedPaths","_shouldHandleRequest","req","url","parsed","parse","pathname","includes","getHandler","internalMiddleware","res","next","handleRequestAsync","error","exception","statusCode","end","JSON","stringify","toString","middleware","internal","setHeader"],"mappings":"AAAA;;;;QAqEgBA,oBAAoB,GAApBA,oBAAoB;AArEd,IAAA,IAAK,WAAL,KAAK,CAAA;AAEfC,IAAAA,GAAG,mCAAM,cAAc,EAApB;;;;;;;;;;;;;;;;;;;;;;AAIR,MAAeC,cAAc;IAClCC,YAAsBC,WAAmB,EAAYC,cAAwB,CAAE;aAAzDD,WAAmB,GAAnBA,WAAmB;aAAYC,cAAwB,GAAxBA,cAAwB;KAAI;IAEjF;;;KAGG,CACHC,oBAAoB,CAACC,GAAkB,EAAW;QAChD,IAAI,CAACA,GAAG,CAACC,GAAG,EAAE;YACZ,OAAO,KAAK,CAAC;SACd;QACD,MAAMC,MAAM,GAAGC,CAAAA,GAAAA,IAAK,AAAS,CAAA,MAAT,CAACH,GAAG,CAACC,GAAG,CAAC,AAAC;QAC9B,yBAAyB;QACzB,IAAI,CAACC,MAAM,CAACE,QAAQ,EAAE;YACpB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,IAAI,CAACN,cAAc,CAACO,QAAQ,CAACH,MAAM,CAACE,QAAQ,CAAC,CAAC;KACtD;IAQD,0CAA0C,CAC1C,AAAOE,UAAU,GAAG;QAClB,MAAMC,kBAAkB,GAAG,OACzBP,GAAkB,EACl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C;CACZ"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/ExpoMiddleware.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport { ServerNext, ServerRequest, ServerResponse } from './server.types';\nimport * as Log from '../../../log';\n\n/** Base middleware creator for Expo dev servers. */\nexport abstract class ExpoMiddleware {\n constructor(\n protected projectRoot: string,\n protected supportedPaths: string[]\n ) {}\n\n /**\n * Returns true when the middleware should handle the incoming server request.\n * Exposed for testing.\n */\n _shouldHandleRequest(req: ServerRequest): boolean {\n if (!req.url) {\n return false;\n }\n const parsed = parse(req.url);\n // Strip the query params\n if (!parsed.pathname) {\n return false;\n }\n\n return this.supportedPaths.includes(parsed.pathname);\n }\n\n abstract handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void>;\n\n /** Create a server middleware handler. */\n public getHandler() {\n const internalMiddleware = async (\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ) => {\n try {\n return await this.handleRequestAsync(req, res, next);\n } catch (error: any) {\n Log.exception(error);\n // 5xx = Server Error HTTP code\n res.statusCode = 500;\n if (typeof error === 'object' && error !== null) {\n res.end(\n JSON.stringify({\n error: error.toString(),\n })\n );\n } else {\n res.end(`Unexpected error: ${error}`);\n }\n }\n };\n const middleware = async (req: ServerRequest, res: ServerResponse, next: ServerNext) => {\n if (!this._shouldHandleRequest(req)) {\n return next();\n }\n return internalMiddleware(req, res, next);\n };\n\n middleware.internal = internalMiddleware;\n\n return middleware;\n }\n}\n\nexport function disableResponseCache(res: ServerResponse): ServerResponse {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, must-revalidate');\n res.setHeader('Expires', '-1');\n res.setHeader('Pragma', 'no-cache');\n return res;\n}\n"],"names":["disableResponseCache","Log","ExpoMiddleware","constructor","projectRoot","supportedPaths","_shouldHandleRequest","req","url","parsed","parse","pathname","includes","getHandler","internalMiddleware","res","next","handleRequestAsync","error","exception","statusCode","end","JSON","stringify","toString","middleware","internal","setHeader"],"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C;iBACH,MAAM;oBACLT,GAAG,CAACM,GAAG,CAAC,CAAC,kBAAkB,EAAEH,KAAK,CAAC,CAAC,CAAC,CAAC;iBACvC;aACF;SACF,AAAC;QACF,MAAMO,UAAU,GAAG,OAAOlB,GAAkB,EAAEQ,GAAmB,EAAEC,IAAgB,GAAK;YACtF,IAAI,CAAC,IAAI,CAACV,oBAAoB,CAACC,GAAG,CAAC,EAAE;gBACnC,OAAOS,IAAI,EAAE,CAAC;aACf;YACD,OAAOF,kBAAkB,CAACP,GAAG,EAAEQ,GAAG,EAAEC,IAAI,CAAC,CAAC;SAC3C,AAAC;QAEFS,UAAU,CAACC,QAAQ,GAAGZ,kBAAkB,CAAC;QAEzC,OAAOW,UAAU,CAAC;KACnB;CACF;QAhEqBvB,cAAc,GAAdA,cAAc;AAkE7B,SAASF,oBAAoB,CAACe,GAAmB,EAAkB;IACxEA,GAAG,CAACY,SAAS,CAAC,eAAe,EAAE,8CAA8C,CAAC,CAAC;IAC/EZ,GAAG,CAACY,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/BZ,GAAG,CAACY,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACpC,OAAOZ,GAAG,CAAC;CACZ"}
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- var _favicon = require("../../../export/favicon");
6
5
  var _expoMiddleware = require("./ExpoMiddleware");
6
+ var _favicon = require("../../../export/favicon");
7
7
  const debug = require("debug")("expo:start:server:middleware:favicon");
8
8
  class FaviconMiddleware extends _expoMiddleware.ExpoMiddleware {
9
9
  constructor(projectRoot){
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/FaviconMiddleware.ts"],"sourcesContent":["import { getFaviconFromExpoConfigAsync } from '../../../export/favicon';\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport { ServerNext, ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:favicon') as typeof console.log;\n\n/**\n * Middleware for generating a favicon.ico file for the current project if one doesn't exist.\n *\n * Test by making a get request with:\n * curl -v http://localhost:8081/favicon.ico\n */\nexport class FaviconMiddleware extends ExpoMiddleware {\n constructor(protected projectRoot: string) {\n super(projectRoot, ['/favicon.ico']);\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n if (!['GET', 'HEAD'].includes(req.method || '')) {\n return next();\n }\n\n let faviconImageData: Buffer | null;\n try {\n const data = await getFaviconFromExpoConfigAsync(this.projectRoot);\n if (!data) {\n debug('No favicon defined in the Expo Config, skipping generation.');\n return next();\n }\n faviconImageData = data.source;\n debug('✅ Generated favicon successfully.');\n } catch (error: any) {\n debug('Failed to generate favicon from Expo config:', error);\n return next(error);\n }\n // Respond with the generated favicon file\n res.setHeader('Content-Type', 'image/x-icon');\n res.end(faviconImageData);\n }\n}\n"],"names":["debug","require","FaviconMiddleware","ExpoMiddleware","constructor","projectRoot","handleRequestAsync","req","res","next","includes","method","faviconImageData","data","getFaviconFromExpoConfigAsync","source","error","setHeader","end"],"mappings":"AAAA;;;;AAA8C,IAAA,QAAyB,WAAzB,yBAAyB,CAAA;AACxC,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAGjD,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAQtF,MAAMC,iBAAiB,SAASC,eAAc,eAAA;IACnDC,YAAsBC,WAAmB,CAAE;QACzC,KAAK,CAACA,WAAW,EAAE;YAAC,cAAc;SAAC,CAAC,CAAC;aADjBA,WAAmB,GAAnBA,WAAmB;KAExC;IAED,MAAMC,kBAAkB,CACtBC,GAAkB,EAClBC,GAAmB,EACnBC,IAAgB,EACD;QACf,IAAI,CAAC;YAAC,KAAK;YAAE,MAAM;SAAC,CAACC,QAAQ,CAACH,GAAG,CAACI,MAAM,IAAI,EAAE,CAAC,EAAE;YAC/C,OAAOF,IAAI,EAAE,CAAC;SACf;QAED,IAAIG,gBAAgB,AAAe,AAAC;QACpC,IAAI;YACF,MAAMC,IAAI,GAAG,MAAMC,CAAAA,GAAAA,QAA6B,AAAkB,CAAA,8BAAlB,CAAC,IAAI,CAACT,WAAW,CAAC,AAAC;YACnE,IAAI,CAACQ,IAAI,EAAE;gBACTb,KAAK,CAAC,6DAA6D,CAAC,CAAC;gBACrE,OAAOS,IAAI,EAAE,CAAC;aACf;YACDG,gBAAgB,GAAGC,IAAI,CAACE,MAAM,CAAC;YAC/Bf,KAAK,CAAC,wCAAmC,CAAC,CAAC;SAC5C,CAAC,OAAOgB,KAAK,EAAO;YACnBhB,KAAK,CAAC,8CAA8C,EAAEgB,KAAK,CAAC,CAAC;YAC7D,OAAOP,IAAI,CAACO,KAAK,CAAC,CAAC;SACpB;QACD,0CAA0C;QAC1CR,GAAG,CAACS,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QAC9CT,GAAG,CAACU,GAAG,CAACN,gBAAgB,CAAC,CAAC;KAC3B;CACF;QA/BYV,iBAAiB,GAAjBA,iBAAiB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/FaviconMiddleware.ts"],"sourcesContent":["import { ExpoMiddleware } from './ExpoMiddleware';\nimport { ServerNext, ServerRequest, ServerResponse } from './server.types';\nimport { getFaviconFromExpoConfigAsync } from '../../../export/favicon';\n\nconst debug = require('debug')('expo:start:server:middleware:favicon') as typeof console.log;\n\n/**\n * Middleware for generating a favicon.ico file for the current project if one doesn't exist.\n *\n * Test by making a get request with:\n * curl -v http://localhost:8081/favicon.ico\n */\nexport class FaviconMiddleware extends ExpoMiddleware {\n constructor(protected projectRoot: string) {\n super(projectRoot, ['/favicon.ico']);\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n if (!['GET', 'HEAD'].includes(req.method || '')) {\n return next();\n }\n\n let faviconImageData: Buffer | null;\n try {\n const data = await getFaviconFromExpoConfigAsync(this.projectRoot);\n if (!data) {\n debug('No favicon defined in the Expo Config, skipping generation.');\n return next();\n }\n faviconImageData = data.source;\n debug('✅ Generated favicon successfully.');\n } catch (error: any) {\n debug('Failed to generate favicon from Expo config:', error);\n return next(error);\n }\n // Respond with the generated favicon file\n res.setHeader('Content-Type', 'image/x-icon');\n res.end(faviconImageData);\n }\n}\n"],"names":["debug","require","FaviconMiddleware","ExpoMiddleware","constructor","projectRoot","handleRequestAsync","req","res","next","includes","method","faviconImageData","data","getFaviconFromExpoConfigAsync","source","error","setHeader","end"],"mappings":"AAAA;;;;AAA+B,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAEH,IAAA,QAAyB,WAAzB,yBAAyB,CAAA;AAEvE,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAQtF,MAAMC,iBAAiB,SAASC,eAAc,eAAA;IACnDC,YAAsBC,WAAmB,CAAE;QACzC,KAAK,CAACA,WAAW,EAAE;YAAC,cAAc;SAAC,CAAC,CAAC;aADjBA,WAAmB,GAAnBA,WAAmB;KAExC;IAED,MAAMC,kBAAkB,CACtBC,GAAkB,EAClBC,GAAmB,EACnBC,IAAgB,EACD;QACf,IAAI,CAAC;YAAC,KAAK;YAAE,MAAM;SAAC,CAACC,QAAQ,CAACH,GAAG,CAACI,MAAM,IAAI,EAAE,CAAC,EAAE;YAC/C,OAAOF,IAAI,EAAE,CAAC;SACf;QAED,IAAIG,gBAAgB,AAAe,AAAC;QACpC,IAAI;YACF,MAAMC,IAAI,GAAG,MAAMC,CAAAA,GAAAA,QAA6B,AAAkB,CAAA,8BAAlB,CAAC,IAAI,CAACT,WAAW,CAAC,AAAC;YACnE,IAAI,CAACQ,IAAI,EAAE;gBACTb,KAAK,CAAC,6DAA6D,CAAC,CAAC;gBACrE,OAAOS,IAAI,EAAE,CAAC;aACf;YACDG,gBAAgB,GAAGC,IAAI,CAACE,MAAM,CAAC;YAC/Bf,KAAK,CAAC,wCAAmC,CAAC,CAAC;SAC5C,CAAC,OAAOgB,KAAK,EAAO;YACnBhB,KAAK,CAAC,8CAA8C,EAAEgB,KAAK,CAAC,CAAC;YAC7D,OAAOP,IAAI,CAACO,KAAK,CAAC,CAAC;SACpB;QACD,0CAA0C;QAC1CR,GAAG,CAACS,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QAC9CT,GAAG,CAACU,GAAG,CAACN,gBAAgB,CAAC,CAAC;KAC3B;CACF;QA/BYV,iBAAiB,GAAjBA,iBAAiB"}
@@ -14,16 +14,16 @@ var _findYarnWorkspaceRoot = _interopRequireDefault(require("find-yarn-workspace
14
14
  var _path = _interopRequireDefault(require("path"));
15
15
  var _resolveFrom = _interopRequireDefault(require("resolve-from"));
16
16
  var _url = require("url");
17
+ var _expoMiddleware = require("./ExpoMiddleware");
18
+ var _resolveAssets = require("./resolveAssets");
19
+ var _resolveEntryPoint = require("./resolveEntryPoint");
20
+ var _resolvePlatform = require("./resolvePlatform");
17
21
  var Log = _interopRequireWildcard(require("../../../log"));
18
22
  var _env = require("../../../utils/env");
19
23
  var _url1 = require("../../../utils/url");
20
24
  var ProjectDevices = _interopRequireWildcard(require("../../project/devices"));
21
25
  var _platformBundlers = require("../platformBundlers");
22
26
  var _webTemplate = require("../webTemplate");
23
- var _expoMiddleware = require("./ExpoMiddleware");
24
- var _resolveAssets = require("./resolveAssets");
25
- var _resolveEntryPoint = require("./resolveEntryPoint");
26
- var _resolvePlatform = require("./resolvePlatform");
27
27
  function _interopRequireDefault(obj) {
28
28
  return obj && obj.__esModule ? obj : {
29
29
  default: obj
@@ -86,7 +86,7 @@ function shouldEnableAsyncImports(projectRoot) {
86
86
  // Expo Router automatically pulls this in, so we can check for it.
87
87
  return _resolveFrom.default.silent(projectRoot, "@expo/metro-runtime") != null;
88
88
  }
89
- function createBundleUrlPath({ platform , mainModuleName , mode , minify =mode === "production" , environment , serializerOutput , lazy }) {
89
+ function createBundleUrlPath({ platform , mainModuleName , mode , minify =mode === "production" , environment , serializerOutput , serializerIncludeMaps , lazy }) {
90
90
  const queryParams = new URLSearchParams({
91
91
  platform: encodeURIComponent(platform),
92
92
  dev: String(mode !== "production"),
@@ -106,6 +106,9 @@ function createBundleUrlPath({ platform , mainModuleName , mode , minify =mode =
106
106
  if (serializerOutput) {
107
107
  queryParams.append("serializer.output", serializerOutput);
108
108
  }
109
+ if (serializerIncludeMaps) {
110
+ queryParams.append("serializer.map", String(serializerIncludeMaps));
111
+ }
109
112
  return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;
110
113
  }
111
114
  const DEVELOPER_TOOL = "expo-cli";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import { ExpoConfig, ExpoGoConfig, getConfig, ProjectConfig } from '@expo/config';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { resolve } from 'url';\n\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { resolveAbsoluteEntryPoint } from './resolveEntryPoint';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:manifest') as typeof console.log;\n\n/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */\nexport function getWorkspaceRoot(projectRoot: string): string | null {\n try {\n return findWorkspaceRoot(projectRoot);\n } catch (error: any) {\n if (error.message.includes('Unexpected end of JSON input')) {\n return null;\n }\n throw error;\n }\n}\n\nexport function getEntryWithServerRoot(\n projectRoot: string,\n projectConfig: ProjectConfig,\n platform: string\n) {\n return path.relative(\n getMetroServerRoot(projectRoot),\n resolveAbsoluteEntryPoint(projectRoot, platform, projectConfig)\n );\n}\n\nexport function getMetroServerRoot(projectRoot: string) {\n if (env.EXPO_USE_METRO_WORKSPACE_ROOT) {\n return getWorkspaceRoot(projectRoot) ?? projectRoot;\n }\n\n return projectRoot;\n}\n\n/** Get the main entry module ID (file) relative to the project root. */\nexport function resolveMainModuleName(\n projectRoot: string,\n projectConfig: ProjectConfig,\n platform: string\n): string {\n const entryPoint = getEntryWithServerRoot(projectRoot, projectConfig, platform);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);\n\n return stripExtension(entryPoint, 'js');\n}\n\nexport function shouldEnableAsyncImports(projectRoot: string): boolean {\n if (env.EXPO_NO_METRO_LAZY) {\n return false;\n }\n\n // `@expo/metro-runtime` includes support for the fetch + eval runtime code required\n // to support async imports. If it's not installed, we can't support async imports.\n // If it is installed, the user MUST import it somewhere in their project.\n // Expo Router automatically pulls this in, so we can check for it.\n return resolveFrom.silent(projectRoot, '@expo/metro-runtime') != null;\n}\n\nexport function createBundleUrlPath({\n platform,\n mainModuleName,\n mode,\n minify = mode === 'production',\n environment,\n serializerOutput,\n lazy,\n}: {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: string;\n serializerOutput?: 'static';\n lazy?: boolean;\n}): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n });\n\n if (lazy) {\n queryParams.append('lazy', String(lazy));\n }\n\n if (minify) {\n queryParams.append('minify', String(minify));\n }\n if (environment) {\n queryParams.append('resolver.environment', environment);\n queryParams.append('transform.environment', environment);\n }\n if (serializerOutput) {\n queryParams.append('serializer.output', serializerOutput);\n }\n\n return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n}\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n\n constructor(protected projectRoot: string, protected options: ManifestMiddlewareOptions) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n }: Pick<TManifestRequestInfo, 'hostname' | 'platform'>): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(projectConfig, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(projectConfig: ProjectConfig, platform: string): string {\n let entryPoint = getEntryWithServerRoot(this.projectRoot, projectConfig, platform);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);\n\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n }): string {\n const path = createBundleUrlPath({\n mode: this.options.mode ?? 'development',\n minify: this.options.minify,\n platform,\n mainModuleName,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n });\n\n return (\n this.options.constructUrl({\n scheme: 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n public _getBundleUrlPath({\n platform,\n mainModuleName,\n }: {\n platform: string;\n mainModuleName: string;\n }): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(this.options.mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n });\n if (shouldEnableAsyncImports(this.projectRoot)) {\n queryParams.append('lazy', String(true));\n }\n\n if (this.options.minify) {\n queryParams.append('minify', String(this.options.minify));\n }\n\n return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n }\n\n /** Log telemetry. */\n protected abstract trackManifest(version?: string): void;\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:8081\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=8081 open -a flipper.app`\n // Where 8081 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n public getWebBundleUrl() {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);\n return this._getBundleUrlPath({\n platform,\n mainModuleName,\n });\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n // Read from headers\n const bundleUrl = this.getWebBundleUrl();\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n await createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n })\n );\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse, next: ServerNext) {\n // Read the config\n const bundlers = getPlatformBundlers(this.initialProjectConfig.exp);\n if (bundlers.web === 'metro') {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n if (this.initialProjectConfig.exp.web?.output === 'static') {\n // Skip the spa-styled index.html when static generation is enabled.\n next();\n return true;\n } else {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res, next)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, version, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n\n // Log analytics\n this.trackManifest(version ?? null);\n }\n}\n"],"names":["getWorkspaceRoot","getEntryWithServerRoot","getMetroServerRoot","resolveMainModuleName","shouldEnableAsyncImports","createBundleUrlPath","Log","ProjectDevices","debug","require","projectRoot","findWorkspaceRoot","error","message","includes","projectConfig","platform","path","relative","resolveAbsoluteEntryPoint","env","EXPO_USE_METRO_WORKSPACE_ROOT","entryPoint","stripExtension","EXPO_NO_METRO_LAZY","resolveFrom","silent","mainModuleName","mode","minify","environment","serializerOutput","lazy","queryParams","URLSearchParams","encodeURIComponent","dev","String","hot","append","encodeURI","toString","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","_resolveProjectSettingsAsync","hostname","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","mutateManifestWithAssetsAsync","exp","isNativeWebpack","saveDevicesAsync","req","deviceIds","headers","catch","e","exception","_getBundleUrlPath","debuggerHost","developer","tool","packagerOpts","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","getWebBundleUrl","handleWebRequestAsync","res","setHeader","end","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","next","bundlers","getPlatformBundlers","web","parsePlatformHeader","output","handleRequestAsync","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","trackManifest"],"mappings":"AAAA;;;;QAsBgBA,gBAAgB,GAAhBA,gBAAgB;QAWhBC,sBAAsB,GAAtBA,sBAAsB;QAWtBC,kBAAkB,GAAlBA,kBAAkB;QASlBC,qBAAqB,GAArBA,qBAAqB;QAYrBC,wBAAwB,GAAxBA,wBAAwB;QAYxBC,mBAAmB,GAAnBA,mBAAmB;;AA7EgC,IAAA,OAAc,WAAd,cAAc,CAAA;AACnD,IAAA,sBAA0B,kCAA1B,0BAA0B,EAAA;AACvC,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AACd,IAAA,IAAK,WAAL,KAAK,CAAA;AAEjBC,IAAAA,GAAG,mCAAM,cAA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AA,EAAEjC,OAAO,CAAA,EAAE,GAAG,MAAM,IAAI,CAACkC,yBAAyB,CAACpD,OAAO,CAAC,AAAC;QACjF,KAAK,MAAM,CAACqD,UAAU,EAAEC,WAAW,CAAC,IAAIpC,OAAO,CAAE;YAC/CkB,GAAG,CAACC,SAAS,CAACgB,UAAU,EAAEC,WAAW,CAAC,CAAC;SACxC;QACDlB,GAAG,CAACE,GAAG,CAACY,IAAI,CAAC,CAAC;QAEd,gBAAgB;QAChB,IAAI,CAACK,aAAa,CAACJ,OAAO,WAAPA,OAAO,GAAI,IAAI,CAAC,CAAC;KACrC;CACF;QA7QqBtD,kBAAkB,GAAlBA,kBAAkB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import { ExpoConfig, ExpoGoConfig, getConfig, ProjectConfig } from '@expo/config';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { resolve } from 'url';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { resolveAbsoluteEntryPoint } from './resolveEntryPoint';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\n\nconst debug = require('debug')('expo:start:server:middleware:manifest') as typeof console.log;\n\n/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */\nexport function getWorkspaceRoot(projectRoot: string): string | null {\n try {\n return findWorkspaceRoot(projectRoot);\n } catch (error: any) {\n if (error.message.includes('Unexpected end of JSON input')) {\n return null;\n }\n throw error;\n }\n}\n\nexport function getEntryWithServerRoot(\n projectRoot: string,\n projectConfig: ProjectConfig,\n platform: string\n) {\n return path.relative(\n getMetroServerRoot(projectRoot),\n resolveAbsoluteEntryPoint(projectRoot, platform, projectConfig)\n );\n}\n\nexport function getMetroServerRoot(projectRoot: string) {\n if (env.EXPO_USE_METRO_WORKSPACE_ROOT) {\n return getWorkspaceRoot(projectRoot) ?? projectRoot;\n }\n\n return projectRoot;\n}\n\n/** Get the main entry module ID (file) relative to the project root. */\nexport function resolveMainModuleName(\n projectRoot: string,\n projectConfig: ProjectConfig,\n platform: string\n): string {\n const entryPoint = getEntryWithServerRoot(projectRoot, projectConfig, platform);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);\n\n return stripExtension(entryPoint, 'js');\n}\n\nexport function shouldEnableAsyncImports(projectRoot: string): boolean {\n if (env.EXPO_NO_METRO_LAZY) {\n return false;\n }\n\n // `@expo/metro-runtime` includes support for the fetch + eval runtime code required\n // to support async imports. If it's not installed, we can't support async imports.\n // If it is installed, the user MUST import it somewhere in their project.\n // Expo Router automatically pulls this in, so we can check for it.\n return resolveFrom.silent(projectRoot, '@expo/metro-runtime') != null;\n}\n\nexport function createBundleUrlPath({\n platform,\n mainModuleName,\n mode,\n minify = mode === 'production',\n environment,\n serializerOutput,\n serializerIncludeMaps,\n lazy,\n}: {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: string;\n serializerOutput?: 'static';\n serializerIncludeMaps?: boolean;\n lazy?: boolean;\n}): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n });\n\n if (lazy) {\n queryParams.append('lazy', String(lazy));\n }\n\n if (minify) {\n queryParams.append('minify', String(minify));\n }\n if (environment) {\n queryParams.append('resolver.environment', environment);\n queryParams.append('transform.environment', environment);\n }\n if (serializerOutput) {\n queryParams.append('serializer.output', serializerOutput);\n }\n if (serializerIncludeMaps) {\n queryParams.append('serializer.map', String(serializerIncludeMaps));\n }\n\n return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n}\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo,\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n\n constructor(\n protected projectRoot: string,\n protected options: ManifestMiddlewareOptions\n ) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n }: Pick<TManifestRequestInfo, 'hostname' | 'platform'>): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(projectConfig, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(projectConfig: ProjectConfig, platform: string): string {\n let entryPoint = getEntryWithServerRoot(this.projectRoot, projectConfig, platform);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);\n\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n }): string {\n const path = createBundleUrlPath({\n mode: this.options.mode ?? 'development',\n minify: this.options.minify,\n platform,\n mainModuleName,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n });\n\n return (\n this.options.constructUrl({\n scheme: 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n public _getBundleUrlPath({\n platform,\n mainModuleName,\n }: {\n platform: string;\n mainModuleName: string;\n }): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(this.options.mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n });\n if (shouldEnableAsyncImports(this.projectRoot)) {\n queryParams.append('lazy', String(true));\n }\n\n if (this.options.minify) {\n queryParams.append('minify', String(this.options.minify));\n }\n\n return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n }\n\n /** Log telemetry. */\n protected abstract trackManifest(version?: string): void;\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:8081\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=8081 open -a flipper.app`\n // Where 8081 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n public getWebBundleUrl() {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);\n return this._getBundleUrlPath({\n platform,\n mainModuleName,\n });\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n // Read from headers\n const bundleUrl = this.getWebBundleUrl();\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n await createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n })\n );\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse, next: ServerNext) {\n // Read the config\n const bundlers = getPlatformBundlers(this.initialProjectConfig.exp);\n if (bundlers.web === 'metro') {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n if (this.initialProjectConfig.exp.web?.output === 'static') {\n // Skip the spa-styled index.html when static generation is enabled.\n next();\n return true;\n } else {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res, next)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, version, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n\n // Log analytics\n this.trackManifest(version ?? null);\n }\n}\n"],"names":["getWorkspaceRoot","getEntryWithServerRoot","getMetroServerRoot","resolveMainModuleName","shouldEnableAsyncImports","createBundleUrlPath","Log","ProjectDevices","debug","require","projectRoot","findWorkspaceRoot","error","message","includes","projectConfig","platform","path","relative","resolveAbsoluteEntryPoint","env","EXPO_USE_METRO_WORKSPACE_ROOT","entryPoint","stripExtension","EXPO_NO_METRO_LAZY","resolveFrom","silent","mainModuleName","mode","minify","environment","serializerOutput","serializerIncludeMaps","lazy","queryParams","URLSearchParams","encodeURIComponent","dev","String","hot","append","encodeURI","toString","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","_resolveProjectSettingsAsync","hostname","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","mutateManifestWithAssetsAsync","exp","isNativeWebpack","saveDevicesAsync","req","deviceIds","headers","catch","e","exception","_getBundleUrlPath","debuggerHost","developer","tool","packagerOpts","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","getWebBundleUrl","handleWebRequestAsync","res","setHeader","end","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","next","bundlers","getPlatformBundlers","web","parsePlatformHeader","output","handleRequestAsync","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","trackManifest"],"mappings":"AAAA;;;;QAsBgBA,gBAAgB,GAAhBA,gBAAgB;QAWhBC,sBAAsB,GAAtBA,sBAAsB;QAWtBC,kBAAkB,GAAlBA,kBAAkB;QASlBC,qBAAqB,GAArBA,qBAAqB;QAYrBC,wBAAwB,GAAxBA,wBAAwB;QAYxBC,mBAAmB,GAAnBA,mBAAmB;;AA7EgC,IAAA,OAAc,WAAd,cAAc,CAAA;AACnD,IAAA,sBAA0B,kCAA1B,0BAA0B,EAAA;AACvC,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAA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CAAC,EAAE;YACvD,OAAO;SACR;QAED,kCAAkC;QAClC,MAAM,IAAI,CAAC3B,gBAAgB,CAACC,GAAG,CAAC,CAAC;QAEjC,oBAAoB;QACpB,MAAMhB,OAAO,GAAG,IAAI,CAACiD,gBAAgB,CAACjC,GAAG,CAAC,AAAC;QAC3C,MAAM,EAAEkC,IAAI,CAAA,EAAEC,OAAO,CAAA,EAAEjC,OAAO,CAAA,EAAE,GAAG,MAAM,IAAI,CAACkC,yBAAyB,CAACpD,OAAO,CAAC,AAAC;QACjF,KAAK,MAAM,CAACqD,UAAU,EAAEC,WAAW,CAAC,IAAIpC,OAAO,CAAE;YAC/CkB,GAAG,CAACC,SAAS,CAACgB,UAAU,EAAEC,WAAW,CAAC,CAAC;SACxC;QACDlB,GAAG,CAACE,GAAG,CAACY,IAAI,CAAC,CAAC;QAEd,gBAAgB;QAChB,IAAI,CAACK,aAAa,CAACJ,OAAO,WAAPA,OAAO,GAAI,IAAI,CAAC,CAAC;KACrC;CACF;QAhRqBtD,kBAAkB,GAAlBA,kBAAkB"}
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  var _url = require("url");
6
- var Log = _interopRequireWildcard(require("../../../log"));
7
6
  var _expoMiddleware = require("./ExpoMiddleware");
8
7
  var _resolvePlatform = require("./resolvePlatform");
8
+ var Log = _interopRequireWildcard(require("../../../log"));
9
9
  function _interopRequireWildcard(obj) {
10
10
  if (obj && obj.__esModule) {
11
11
  return obj;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/RuntimeRedirectMiddleware.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport * as Log from '../../../log';\nimport { disableResponseCache, ExpoMiddleware } from './ExpoMiddleware';\nimport {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n resolvePlatformFromUserAgentHeader,\n RuntimePlatform,\n} from './resolvePlatform';\nimport { ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:runtimeRedirect'\n) as typeof console.log;\n\n/** Runtime to target: expo = Expo Go, custom = Dev Client. */\ntype RuntimeTarget = 'expo' | 'custom';\n\nexport type DeepLinkHandler = (props: {\n runtime: RuntimeTarget;\n platform: RuntimePlatform;\n}) => void | Promise<void>;\n\nexport class RuntimeRedirectMiddleware extends ExpoMiddleware {\n constructor(\n protected projectRoot: string,\n protected options: {\n onDeepLink: DeepLinkHandler;\n getLocation: (props: { runtime: RuntimeTarget }) => string | null | undefined;\n }\n ) {\n super(projectRoot, ['/_expo/link']);\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n const { query } = parse(req.url!, true);\n const isDevClient = query['choice'] === 'expo-dev-client';\n const platform = parsePlatformHeader(req) ?? resolvePlatformFromUserAgentHeader(req);\n assertMissingRuntimePlatform(platform);\n assertRuntimePlatform(platform);\n const runtime = isDevClient ? 'custom' : 'expo';\n\n debug(`props:`, { platform, runtime });\n\n this.options.onDeepLink({ runtime, platform });\n\n const redirect = this.options.getLocation({ runtime });\n if (!redirect) {\n Log.warn(\n `[redirect middleware]: Unable to determine redirect location for runtime '${runtime}' and platform '${platform}'`\n );\n res.statusCode = 404;\n res.end();\n return;\n }\n debug('Redirect ->', redirect);\n res.setHeader('Location', redirect);\n\n // Disable caching\n disableResponseCache(res);\n\n // 'Temporary Redirect'\n res.statusCode = 307;\n res.end();\n }\n}\n"],"names":["Log","debug","require","RuntimeRedirectMiddleware","ExpoMiddleware","constructor","projectRoot","options","handleRequestAsync","req","res","query","parse","url","isDevClient","parsePlatformHeader","platform","resolvePlatformFromUserAgentHeader","assertMissingRuntimePlatform","assertRuntimePlatform","runtime","onDeepLink","redirect","getLocation","warn","statusCode","end","setHeader","disableResponseCache"],"mappings":"AAAA;;;;AAAsB,IAAA,IAAK,WAAL,KAAK,CAAA;AAEfA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACsC,IAAA,eAAkB,WAAlB,kB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AC,CAAC;QAE/C,MAAMM,QAAQ,GAAG,IAAI,CAACf,OAAO,CAACgB,WAAW,CAAC;YAAEH,OAAO;SAAE,CAAC,AAAC;QACvD,IAAI,CAACE,QAAQ,EAAE;YACbtB,GAAG,CAACwB,IAAI,CACN,CAAC,0EAA0E,EAAEJ,OAAO,CAAC,gBAAgB,EAAEJ,QAAQ,CAAC,CAAC,CAAC,CACnH,CAAC;YACFN,GAAG,CAACe,UAAU,GAAG,GAAG,CAAC;YACrBf,GAAG,CAACgB,GAAG,EAAE,CAAC;YACV,OAAO;SACR;QACDzB,KAAK,CAAC,aAAa,EAAEqB,QAAQ,CAAC,CAAC;QAC/BZ,GAAG,CAACiB,SAAS,CAAC,UAAU,EAAEL,QAAQ,CAAC,CAAC;QAEpC,kBAAkB;QAClBM,CAAAA,GAAAA,eAAoB,AAAK,CAAA,qBAAL,CAAClB,GAAG,CAAC,CAAC;QAE1B,uBAAuB;QACvBA,GAAG,CAACe,UAAU,GAAG,GAAG,CAAC;QACrBf,GAAG,CAACgB,GAAG,EAAE,CAAC;KACX;CACF;QA1CYvB,yBAAyB,GAAzBA,yBAAyB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/RuntimeRedirectMiddleware.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport { disableResponseCache, ExpoMiddleware } from './ExpoMiddleware';\nimport {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n resolvePlatformFromUserAgentHeader,\n RuntimePlatform,\n} from './resolvePlatform';\nimport { ServerRequest, ServerResponse } from './server.types';\nimport * as Log from '../../../log';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:runtimeRedirect'\n) as typeof console.log;\n\n/** Runtime to target: expo = Expo Go, custom = Dev Client. */\ntype RuntimeTarget = 'expo' | 'custom';\n\nexport type DeepLinkHandler = (props: {\n runtime: RuntimeTarget;\n platform: RuntimePlatform;\n}) => void | Promise<void>;\n\nexport class RuntimeRedirectMiddleware extends ExpoMiddleware {\n constructor(\n protected projectRoot: string,\n protected options: {\n onDeepLink: DeepLinkHandler;\n getLocation: (props: { runtime: RuntimeTarget }) => string | null | undefined;\n }\n ) {\n super(projectRoot, ['/_expo/link']);\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n const { query } = parse(req.url!, true);\n const isDevClient = query['choice'] === 'expo-dev-client';\n const platform = parsePlatformHeader(req) ?? resolvePlatformFromUserAgentHeader(req);\n assertMissingRuntimePlatform(platform);\n assertRuntimePlatform(platform);\n const runtime = isDevClient ? 'custom' : 'expo';\n\n debug(`props:`, { platform, runtime });\n\n this.options.onDeepLink({ runtime, platform });\n\n const redirect = this.options.getLocation({ runtime });\n if (!redirect) {\n Log.warn(\n `[redirect middleware]: Unable to determine redirect location for runtime '${runtime}' and platform '${platform}'`\n );\n res.statusCode = 404;\n res.end();\n return;\n }\n debug('Redirect ->', redirect);\n res.setHeader('Location', redirect);\n\n // Disable caching\n disableResponseCache(res);\n\n // 'Temporary Redirect'\n res.statusCode = 307;\n res.end();\n }\n}\n"],"names":["Log","debug","require","RuntimeRedirectMiddleware","ExpoMiddleware","constructor","projectRoot","options","handleRequestAsync","req","res","query","parse","url","isDevClient","parsePlatformHeader","platform","resolvePlatformFromUserAgentHeader","assertMissingRuntimePlatform","assertRuntimePlatform","runtime","onDeepLink","redirect","getLocation","warn","statusCode","end","setHeader","disableResponseCache"],"mappings":"AAAA;;;;AAAsB,IAAA,IAAK,WAAL,KAAK,CAAA;AAE0B,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAOhE,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AAEdA,IAAAA,GAAG,mCAAM,cAAc,EAApB;;;;;;;;;;;;;;;;;;;;;;AAEf,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,8CAA8C,CAC/C,AAAsB,AAAC;AAUjB,MAAMC,yBAAyB,SAASC,eAAc,eAAA;IAC3DC,YACYC,WAAmB,EACnBC,OA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AAC,CACnH,CAAC;YACFN,GAAG,CAACe,UAAU,GAAG,GAAG,CAAC;YACrBf,GAAG,CAACgB,GAAG,EAAE,CAAC;YACV,OAAO;SACR;QACDzB,KAAK,CAAC,aAAa,EAAEqB,QAAQ,CAAC,CAAC;QAC/BZ,GAAG,CAACiB,SAAS,CAAC,UAAU,EAAEL,QAAQ,CAAC,CAAC;QAEpC,kBAAkB;QAClBM,CAAAA,GAAAA,eAAoB,AAAK,CAAA,qBAAL,CAAClB,GAAG,CAAC,CAAC;QAE1B,uBAAuB;QACvBA,GAAG,CAACe,UAAU,GAAG,GAAG,CAAC;QACrBf,GAAG,CAACgB,GAAG,EAAE,CAAC;KACX;CACF;QA1CYvB,yBAAyB,GAAzBA,yBAAyB"}
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  var _path = _interopRequireDefault(require("path"));
6
6
  var _send = _interopRequireDefault(require("send"));
7
7
  var _url = require("url");
8
- var _env = require("../../../utils/env");
9
8
  var _resolvePlatform = require("./resolvePlatform");
9
+ var _env = require("../../../utils/env");
10
10
  function _interopRequireDefault(obj) {
11
11
  return obj && obj.__esModule ? obj : {
12
12
  default: obj
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/ServeStaticMiddleware.ts"],"sourcesContent":["import path from 'path';\nimport send from 'send';\nimport { parse } from 'url';\n\nimport { env } from '../../../utils/env';\nimport { parsePlatformHeader } from './resolvePlatform';\nimport { ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')('expo:start:server:middleware:serveStatic') as typeof console.log;\n\n/**\n * Adds support for serving the files in the static `public/` folder to web apps.\n */\nexport class ServeStaticMiddleware {\n constructor(private projectRoot: string) {}\n getHandler() {\n const publicPath = path.join(this.projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n debug(`Serving static files from:`, publicPath);\n const opts = {\n root: publicPath,\n };\n return (req: ServerRequest, res: ServerResponse, next: any) => {\n if (!req?.url || (req.method !== 'GET' && req.method !== 'HEAD')) {\n return next();\n }\n\n const platform = parsePlatformHeader(req);\n // Currently this is web-only\n if (platform && platform !== 'web') {\n return next();\n }\n\n const pathname = parse(req.url).pathname;\n if (!pathname) {\n return next();\n }\n\n debug(`Maybe serve static:`, pathname);\n const stream = send(req, pathname, opts);\n\n // add file listener for fallthrough\n let forwardError = false;\n stream.on('file', function onFile() {\n // once file is determined, always forward error\n forwardError = true;\n });\n\n // forward errors\n stream.on('error', function error(err: any) {\n if (forwardError || !(err.statusCode < 500)) {\n next(err);\n return;\n }\n\n next();\n });\n\n // pipe\n stream.pipe(res);\n };\n }\n}\n"],"names":["debug","require","ServeStaticMiddleware","constructor","projectRoot","getHandler","publicPath","path","join","env","EXPO_PUBLIC_FOLDER","opts","root","req","res","next","url","method","platform","parsePlatformHeader","pathname","parse","stream","send","forwardError","on","onFile","error","err","statusCode","pipe"],"mappings":"AAAA;;;;AAAiB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACN,IAAA,KAAM,kCAAN,MAAM,EAAA;AACD,IAAA,IAAK,WAAL,KAAK,CAAA;AAEP,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACJ,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;AAGvD,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,0CAA0C,CAAC,AAAsB,AAAC;AAK1F,MAAMC,qBAAqB;IAChCC,YAAoBC,WAAmB,CAAE;aAArBA,WAAmB,GAAnBA,WAAmB;KAAI;IAC3CC,UAAU,GAAG;QACX,MAAMC,UAAU,GAAGC,KAAI,QAAA,CAACC,IAAI,CAAC,IAAI,CAACJ,WAAW,EAAEK,IAAG,IAAA,CAACC,kBAAkB,CAAC,AAAC;QAEvEV,KAAK,CAAC,CAAC,0BAA0B,CAAC,EAAEM,UAAU,CAAC,CAAC;QAChD,MAAMK,IAAI,GAAG;YACXC,IAAI,EAAEN,UAAU;SACjB,AAAC;QACF,OAAO,CAACO,GAAkB,EAAEC,GAAmB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CAAC;aACR,CAAC,CAAC;YAEH,OAAO;YACPO,MAAM,CAACQ,IAAI,CAAChB,GAAG,CAAC,CAAC;SAClB,CAAC;KACH;CACF;QAjDYZ,qBAAqB,GAArBA,qBAAqB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/ServeStaticMiddleware.ts"],"sourcesContent":["import path from 'path';\nimport send from 'send';\nimport { parse } from 'url';\n\nimport { parsePlatformHeader } from './resolvePlatform';\nimport { ServerRequest, ServerResponse } from './server.types';\nimport { env } from '../../../utils/env';\n\nconst debug = require('debug')('expo:start:server:middleware:serveStatic') as typeof console.log;\n\n/**\n * Adds support for serving the files in the static `public/` folder to web apps.\n */\nexport class ServeStaticMiddleware {\n constructor(private projectRoot: string) {}\n getHandler() {\n const publicPath = path.join(this.projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n debug(`Serving static files from:`, publicPath);\n const opts = {\n root: publicPath,\n };\n return (req: ServerRequest, res: ServerResponse, next: any) => {\n if (!req?.url || (req.method !== 'GET' && req.method !== 'HEAD')) {\n return next();\n }\n\n const platform = parsePlatformHeader(req);\n // Currently this is web-only\n if (platform && platform !== 'web') {\n return next();\n }\n\n const pathname = parse(req.url).pathname;\n if (!pathname) {\n return next();\n }\n\n debug(`Maybe serve static:`, pathname);\n const stream = send(req, pathname, opts);\n\n // add file listener for fallthrough\n let forwardError = false;\n stream.on('file', function onFile() {\n // once file is determined, always forward error\n forwardError = true;\n });\n\n // forward errors\n stream.on('error', function error(err: any) {\n if (forwardError || !(err.statusCode < 500)) {\n next(err);\n return;\n }\n\n next();\n });\n\n // pipe\n stream.pipe(res);\n };\n }\n}\n"],"names":["debug","require","ServeStaticMiddleware","constructor","projectRoot","getHandler","publicPath","path","join","env","EXPO_PUBLIC_FOLDER","opts","root","req","res","next","url","method","platform","parsePlatformHeader","pathname","parse","stream","send","forwardError","on","onFile","error","err","statusCode","pipe"],"mappings":"AAAA;;;;AAAiB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACN,I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EAAE,CAAC;aACf;YAEDf,KAAK,CAAC,CAAC,mBAAmB,CAAC,EAAEoB,QAAQ,CAAC,CAAC;YACvC,MAAME,MAAM,GAAGC,CAAAA,GAAAA,KAAI,AAAqB,CAAA,QAArB,CAACV,GAAG,EAAEO,QAAQ,EAAET,IAAI,CAAC,AAAC;YAEzC,oCAAoC;YACpC,IAAIa,YAAY,GAAG,KAAK,AAAC;YACzBF,MAAM,CAACG,EAAE,CAAC,MAAM,EAAE,SAASC,MAAM,GAAG;gBAClC,gDAAgD;gBAChDF,YAAY,GAAG,IAAI,CAAC;aACrB,CAAC,CAAC;YAEH,iBAAiB;YACjBF,MAAM,CAACG,EAAE,CAAC,OAAO,EAAE,SAASE,KAAK,CAACC,GAAQ,EAAE;gBAC1C,IAAIJ,YAAY,IAAI,CAAC,CAACI,GAAG,CAACC,UAAU,GAAG,GAAG,CAAC,EAAE;oBAC3Cd,IAAI,CAACa,GAAG,CAAC,CAAC;oBACV,OAAO;iBACR;gBAEDb,IAAI,EAAE,CAAC;aACR,CAAC,CAAC;YAEH,OAAO;YACPO,MAAM,CAACQ,IAAI,CAAChB,GAAG,CAAC,CAAC;SAClB,CAAC;KACH;CACF;QAjDYZ,qBAAqB,GAArBA,qBAAqB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/resolvePlatform.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport { CommandError } from '../../../utils/errors';\nimport { ServerRequest } from './server.types';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:resolvePlatform'\n) as typeof console.log;\n\n/** Supported platforms */\nexport type RuntimePlatform = 'ios' | 'android';\n\n/**\n * Extract the runtime platform from the server request.\n * 1. Query param `platform`: `?platform=ios`\n * 2. Header `expo-platform`: `'expo-platform': ios`\n * 3. Legacy header `exponent-platform`: `'exponent-platform': ios`\n *\n * Returns first item in the case of an array.\n */\nexport function parsePlatformHeader(req: ServerRequest): string | null {\n const url = parse(req.url!, /* parseQueryString */ true);\n const platform =\n url.query?.platform || req.headers['expo-platform'] || req.headers['exponent-platform'];\n return (Array.isArray(platform) ? platform[0] : platform) ?? null;\n}\n\n/** Guess the platform from the user-agent header. */\nexport function resolvePlatformFromUserAgentHeader(req: ServerRequest): string | null {\n let platform = null;\n const userAgent = req.headers['user-agent'];\n if (userAgent?.match(/Android/i)) {\n platform = 'android';\n }\n if (userAgent?.match(/iPhone|iPad/i)) {\n platform = 'ios';\n }\n debug(`Resolved platform ${platform} from user-agent header: ${userAgent}`);\n return platform;\n}\n\n/** Assert if the runtime platform is not included. */\nexport function assertMissingRuntimePlatform(platform?: any): asserts platform {\n if (!platform) {\n throw new CommandError(\n 'PLATFORM_HEADER',\n `Must specify \"expo-platform\" header or \"platform\" query parameter`\n );\n }\n}\n\n/** Assert if the runtime platform is not correct. */\nexport function assertRuntimePlatform(platform: string): asserts platform is RuntimePlatform {\n const stringifiedPlatform = String(platform);\n if (!['android', 'ios', 'web'].includes(stringifiedPlatform)) {\n throw new CommandError(\n 'PLATFORM_HEADER',\n `platform must be \"android\", \"ios\", or \"web\". Received: \"${platform}\"`\n );\n }\n}\n"],"names":["parsePlatformHeader","resolvePlatformFromUserAgentHeader","assertMissingRuntimePlatform","assertRuntimePlatform","debug","require","req","url","parse","platform","query","headers","Array","isArray","userAgent","match","CommandError","stringifiedPlatform","String","includes"],"mappings":"AAAA;;;;QAoBgBA,mBAAmB,GAAnBA,mBAAmB;QAQnBC,kCAAkC,GAAlCA,kCAAkC;QAclCC,4BAA4B,GAA5BA,4BAA4B;QAU5BC,qBAAqB,GAArBA,qBAAqB;AApDf,IAAA,IAAK,WAAL,KAAK,CAAA;AAEE,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAGpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,8CAA8C,CAC/C,AAAsB,AAAC;AAajB,SAASL,mBAAmB,CAACM,GAAkB,EAAiB;QAGnEC,GAAS;IAFX,MAAMA,GAAG,GAAGC,CAAA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,EAAuC;IAC3F,MAAMQ,mBAAmB,GAAGC,MAAM,CAACT,QAAQ,CAAC,AAAC;IAC7C,IAAI,CAAC;QAAC,SAAS;QAAE,KAAK;QAAE,KAAK;KAAC,CAACU,QAAQ,CAACF,mBAAmB,CAAC,EAAE;QAC5D,MAAM,IAAID,OAAY,aAAA,CACpB,iBAAiB,EACjB,CAAC,wDAAwD,EAAEP,QAAQ,CAAC,CAAC,CAAC,CACvE,CAAC;KACH;CACF"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/resolvePlatform.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport { ServerRequest } from './server.types';\nimport { CommandError } from '../../../utils/errors';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:resolvePlatform'\n) as typeof console.log;\n\n/** Supported platforms */\nexport type RuntimePlatform = 'ios' | 'android';\n\n/**\n * Extract the runtime platform from the server request.\n * 1. Query param `platform`: `?platform=ios`\n * 2. Header `expo-platform`: `'expo-platform': ios`\n * 3. Legacy header `exponent-platform`: `'exponent-platform': ios`\n *\n * Returns first item in the case of an array.\n */\nexport function parsePlatformHeader(req: ServerRequest): string | null {\n const url = parse(req.url!, /* parseQueryString */ true);\n const platform =\n url.query?.platform || req.headers['expo-platform'] || req.headers['exponent-platform'];\n return (Array.isArray(platform) ? platform[0] : platform) ?? null;\n}\n\n/** Guess the platform from the user-agent header. */\nexport function resolvePlatformFromUserAgentHeader(req: ServerRequest): string | null {\n let platform = null;\n const userAgent = req.headers['user-agent'];\n if (userAgent?.match(/Android/i)) {\n platform = 'android';\n }\n if (userAgent?.match(/iPhone|iPad/i)) {\n platform = 'ios';\n }\n debug(`Resolved platform ${platform} from user-agent header: ${userAgent}`);\n return platform;\n}\n\n/** Assert if the runtime platform is not included. */\nexport function assertMissingRuntimePlatform(platform?: any): asserts platform {\n if (!platform) {\n throw new CommandError(\n 'PLATFORM_HEADER',\n `Must specify \"expo-platform\" header or \"platform\" query parameter`\n );\n }\n}\n\n/** Assert if the runtime platform is not correct. */\nexport function assertRuntimePlatform(platform: string): asserts platform is RuntimePlatform {\n const stringifiedPlatform = String(platform);\n if (!['android', 'ios', 'web'].includes(stringifiedPlatform)) {\n throw new CommandError(\n 'PLATFORM_HEADER',\n `platform must be \"android\", \"ios\", or \"web\". Received: \"${platform}\"`\n );\n }\n}\n"],"names":["parsePlatformHeader","resolvePlatformFromUserAgentHeader","assertMissingRuntimePlatform","assertRuntimePlatform","debug","require","req","url","parse","platform","query","headers","Array","isArray","userAgent","match","CommandError","stringifiedPlatform","String","includes"],"mappings":"AAAA;;;;QAoBgBA,mBAAmB,GAAnBA,mBAAmB;QAQnBC,kCAAkC,GAAlCA,kCAAkC;QAclCC,4BAA4B,GAA5BA,4BAA4B;QAU5BC,qBAAqB,GAArBA,qBAAqB;AApDf,IAAA,IAAK,WAAL,KAAK,CAAA;AAGE,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,8CAA8C,CAC/C,AAAsB,AAAC;AAajB,SAASL,mBAAmB,CAACM,GAAkB,EAAiB;QAGnEC,GAAS;IAFX,MAAMA,GAAG,GAAGC,CAAAA,GAAAA,IAAK,AAAuC,CAAA,MAAvC,CAACF,GAAG,CAACC,GAAG,EAAG,sBAAsB,CAAC,IAAI,CAAC,AAAC;IACzD,MAAME,QAAQ,GACZF,CAAAA,CAAAA,GAAS,GAATA,GAAG,CAACG,KAAK,SAAU,GAAnBH,KAAAA,CAAmB,GAAnBA,GAAS,CAAEE,QAAQ,CAAA,IAAIH,GAAG,CAACK,OAAO,CAAC,eAAe,CAAC,IAAIL,GAAG,CAACK,OAAO,CAAC,mBAAmB,CAAC,AAAC;QACnF,IAAkD;IAAzD,OAAO,CAAA,IAAkD,GAAjDC,KAAK,CAACC,OAAO,CAACJ,QAAQ,CAAC,GAAGA,QAAQ,CAAC,CAAC,CAAC,GAAGA,QAAQ,YAAjD,IAAkD,GAAI,IAAI,CAAC;CACnE;AAGM,SAASR,kCAAkC,CAACK,GAAkB,EAAiB;IACpF,IAAIG,QAAQ,GAAG,IAAI,AAAC;IACpB,MAAMK,SAAS,GAAGR,GAAG,CAACK,OAAO,CAAC,YAAY,CAAC,AAAC;IAC5C,IAAIG,SAAS,QAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEC,KAAK,YAAY,EAAE;QAChCN,QAAQ,GAAG,SAAS,CAAC;KACtB;IACD,IAAIK,SAAS,QAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEC,KAAK,gBAAgB,EAAE;QACpCN,QAAQ,GAAG,KAAK,CAAC;KAClB;IACDL,KAAK,CAAC,CAAC,kBAAkB,EAAEK,QAAQ,CAAC,yBAAyB,EAAEK,SAAS,CAAC,CAAC,CAAC,CAAC;IAC5E,OAAOL,QAAQ,CAAC;CACjB;AAGM,SAASP,4BAA4B,CAACO,QAAc,EAAoB;IAC7E,IAAI,CAACA,QAAQ,EAAE;QACb,MAAM,IAAIO,OAAY,aAAA,CACpB,iBAAiB,EACjB,CAAC,iEAAiE,CAAC,CACpE,CAAC;KACH;CACF;AAGM,SAASb,qBAAqB,CAACM,QAAgB,EAAuC;IAC3F,MAAMQ,mBAAmB,GAAGC,MAAM,CAACT,QAAQ,CAAC,AAAC;IAC7C,IAAI,CAAC;QAAC,SAAS;QAAE,KAAK;QAAE,KAAK;KAAC,CAACU,QAAQ,CAACF,mBAAmB,CAAC,EAAE;QAC5D,MAAM,IAAID,OAAY,aAAA,CACpB,iBAAiB,EACjB,CAAC,wDAAwD,EAAEP,QAAQ,CAAC,CAAC,CAAC,CACvE,CAAC;KACH;CACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/server.types.ts"],"sourcesContent":["import express from 'express';\nimport http from 'http';\n\n/** Headers */\nexport type ServerHeaders = Map<string, number | string | readonly string[]>;\n/** Request */\nexport type ServerRequest = express.Request | http.IncomingMessage;\n/** Response */\nexport type ServerResponse = express.Response | http.ServerResponse;\n/** Next function */\nexport type ServerNext = (err?: Error) => void;\n\n/** The `connect()` app that is a http.RequestListener and having the `use()` function for middlewares. */\nexport interface ConnectAppType extends http.RequestListener {\n use: Function;\n}\n"],"names":[],"mappings":"AAAA"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/server.types.ts"],"sourcesContent":["import express from 'express';\nimport http from 'http';\n\n/** Headers */\nexport type ServerHeaders = Map<string, number | string | readonly string[]>;\n/** Request */\nexport type ServerRequest = express.Request | http.IncomingMessage;\n/** Response */\nexport type ServerResponse = express.Response | http.ServerResponse;\n/** Next function */\nexport type ServerNext = (err?: Error | null) => void;\n\n/** The `connect()` app that is a http.RequestListener and having the `use()` function for middlewares. */\nexport interface ConnectAppType extends http.RequestListener {\n use: Function;\n}\n"],"names":[],"mappings":"AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/openPlatforms.ts"],"sourcesContent":["import { AbortCommandError } from '../../utils/errors';\nimport { Options } from '../resolveOptions';\nimport { DevServerManager } from './DevServerManager';\n\n/** Launch the app on various platforms in parallel. */\nexport async function openPlatformsAsync(\n devServerManager: DevServerManager,\n options: Pick<Options, 'ios' | 'android' | 'web'>\n) {\n const results = await Promise.allSettled([\n options.android ? devServerManager.getDefaultDevServer().openPlatformAsync('emulator') : null,\n options.ios ? devServerManager.getDefaultDevServer().openPlatformAsync('simulator') : null,\n options.web\n ? devServerManager\n .ensureWebDevServerRunningAsync()\n .then(() => devServerManager.getWebDevServer()?.openPlatformAsync('desktop'))\n : null,\n ]);\n\n const errors = results\n .map((result) => (result.status === 'rejected' ? result.reason : null))\n .filter(Boolean);\n\n if (errors.length) {\n // ctrl+c\n const isEscapedError = errors.some((error: any) => error.code === 'ABORTED');\n if (isEscapedError) {\n throw new AbortCommandError();\n }\n throw errors[0];\n }\n\n return !!options.android || !!options.ios;\n}\n"],"names":["openPlatformsAsync","devServerManager","options","results","Promise","allSettled","android","getDefaultDevServer","openPlatformAsync","ios","web","ensureWebDevServerRunningAsync","then","getWebDevServer","errors","map","result","status","reason","filter","Boolean","length","isEscapedError","some","error","code","AbortCommandError"],"mappings":"AAAA;;;;QAKsBA,kBAAkB,GAAlBA,kBAAkB;AALN,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AAK/C,eAAeA,kBAAkB,CACtCC,gBAAkC,EAClCC,OAAiD,EACjD;IACA,MAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,UAAU,CAAC;QACvCH,OAAO,CAACI,OAAO,GAAGL,gBAAgB,CAACM,mBAAmB,EAAE,CAACC,iBAAiB,CAAC,UAAU,CAAC,GAAG,IAAI;QAC7FN,OAAO,CAACO,GAAG,GAAGR,gBAAgB,CAACM,mBAAmB,EAAE,CAACC,iBAAiB,CAAC,WAAW,CAAC,GAAG,IAAI;QAC1FN,OAAO,CAACQ,GAAG,GACPT,gBAAgB,CACbU,8BAA8B,EAAE,CAChCC,IAAI,CAAC;gBAAMX,GAAkC;YAAlCA,OAAAA,CAAAA,GAAkC,GAAlCA,gBAAgB,CAACY,eAAe,EAAE,SAAmB,GAArDZ,KAAAA,CAAqD,GAArDA,GAAkC,CAAEO,iBAAiB,CAAC,SAAS,CAAC,CAAA;SAAA,CAAC,GAC/E,IAAI;KACT,CAAC,AAAC;IAEH,MAAMM,MAAM,GAAGX,OAAO,CACnBY,GAAG,CAAC,CAACC,MAAM,GAAMA,MAAM,CAACC,MAAM,KAAK,UAAU,GAAGD,MAAM,CAACE,MAAM,GAAG,IAAI;IAAC,CAAC,CACtEC,MAAM,CAACC,OAAO,CAAC,AAAC;IAEnB,IAAIN,MAAM,CAACO,MAAM,EAAE;QACjB,SAAS;QACT,MAAMC,cAAc,GAAGR,MAAM,CAACS,IAAI,CAAC,CAACC,KAAU,GAAKA,KAAK,CAACC,IAAI,KAAK,SAAS;QAAA,CAAC,AAAC;QAC7E,IAAIH,cAAc,EAAE;YAClB,MAAM,IAAII,OAAiB,kBAAA,EAAE,CAAC;SAC/B;QACD,MAAMZ,MAAM,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,OAAO,CAAC,CAACZ,OAAO,CAACI,OAAO,IAAI,CAAC,CAACJ,OAAO,CAACO,GAAG,CAAC;CAC3C"}
1
+ {"version":3,"sources":["../../../../src/start/server/openPlatforms.ts"],"sourcesContent":["import { DevServerManager } from './DevServerManager';\nimport { AbortCommandError } from '../../utils/errors';\nimport { Options } from '../resolveOptions';\n\n/** Launch the app on various platforms in parallel. */\nexport async function openPlatformsAsync(\n devServerManager: DevServerManager,\n options: Pick<Options, 'ios' | 'android' | 'web'>\n) {\n const results = await Promise.allSettled([\n options.android ? devServerManager.getDefaultDevServer().openPlatformAsync('emulator') : null,\n options.ios ? devServerManager.getDefaultDevServer().openPlatformAsync('simulator') : null,\n options.web\n ? devServerManager\n .ensureWebDevServerRunningAsync()\n .then(() => devServerManager.getWebDevServer()?.openPlatformAsync('desktop'))\n : null,\n ]);\n\n const errors = results\n .map((result) => (result.status === 'rejected' ? result.reason : null))\n .filter(Boolean);\n\n if (errors.length) {\n // ctrl+c\n const isEscapedError = errors.some((error: any) => error.code === 'ABORTED');\n if (isEscapedError) {\n throw new AbortCommandError();\n }\n throw errors[0];\n }\n\n return !!options.android || !!options.ios;\n}\n"],"names":["openPlatformsAsync","devServerManager","options","results","Promise","allSettled","android","getDefaultDevServer","openPlatformAsync","ios","web","ensureWebDevServerRunningAsync","then","getWebDevServer","errors","map","result","status","reason","filter","Boolean","length","isEscapedError","some","error","code","AbortCommandError"],"mappings":"AAAA;;;;QAKsBA,kBAAkB,GAAlBA,kBAAkB;AAJN,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AAI/C,eAAeA,kBAAkB,CACtCC,gBAAkC,EAClCC,OAAiD,EACjD;IACA,MAAMC,OAAO,GAAG,MAAMC,OAAO,CAACC,UAAU,CAAC;QACvCH,OAAO,CAACI,OAAO,GAAGL,gBAAgB,CAACM,mBAAmB,EAAE,CAACC,iBAAiB,CAAC,UAAU,CAAC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