@expo/cli 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +1 -1
  2. package/build/bin/cli +12 -3
  3. package/build/bin/cli.map +1 -1
  4. package/build/src/api/getExpoGoIntermediateCertificate.js +0 -2
  5. package/build/src/api/getExpoGoIntermediateCertificate.js.map +1 -1
  6. package/build/src/api/getProjectDevelopmentCertificate.js +0 -2
  7. package/build/src/api/getProjectDevelopmentCertificate.js.map +1 -1
  8. package/build/src/api/graphql/queries/AppQuery.js +39 -0
  9. package/build/src/api/graphql/queries/AppQuery.js.map +1 -0
  10. package/build/src/api/graphql/queries/UserQuery.js +10 -3
  11. package/build/src/api/graphql/queries/UserQuery.js.map +1 -1
  12. package/build/src/api/graphql/types/App.js +23 -0
  13. package/build/src/api/graphql/types/App.js.map +1 -0
  14. package/build/src/api/signManifest.js +0 -12
  15. package/build/src/api/signManifest.js.map +1 -1
  16. package/build/src/api/user/UserSettings.js.map +1 -1
  17. package/build/src/api/user/user.js.map +1 -1
  18. package/build/src/config/configAsync.js +3 -0
  19. package/build/src/config/configAsync.js.map +1 -1
  20. package/build/src/customize/customizeAsync.js +3 -0
  21. package/build/src/customize/customizeAsync.js.map +1 -1
  22. package/build/src/export/createBundles.js +7 -3
  23. package/build/src/export/createBundles.js.map +1 -1
  24. package/build/src/export/embed/exportEmbedAsync.js +24 -0
  25. package/build/src/export/embed/exportEmbedAsync.js.map +1 -0
  26. package/build/src/export/embed/index.js +117 -0
  27. package/build/src/export/embed/index.js.map +1 -0
  28. package/build/src/export/embed/resolveOptions.js +63 -0
  29. package/build/src/export/embed/resolveOptions.js.map +1 -0
  30. package/build/src/export/exportApp.js +56 -29
  31. package/build/src/export/exportApp.js.map +1 -1
  32. package/build/src/export/exportAssets.js +17 -0
  33. package/build/src/export/exportAssets.js.map +1 -1
  34. package/build/src/export/exportAsync.js +3 -0
  35. package/build/src/export/exportAsync.js.map +1 -1
  36. package/build/src/export/exportStaticAsync.js +179 -0
  37. package/build/src/export/exportStaticAsync.js.map +1 -0
  38. package/build/src/export/fork-bundleAsync.js +15 -42
  39. package/build/src/export/fork-bundleAsync.js.map +1 -1
  40. package/build/src/export/html.js +21 -0
  41. package/build/src/export/html.js.map +1 -0
  42. package/build/src/export/printBundleSizes.js +2 -2
  43. package/build/src/export/printBundleSizes.js.map +1 -1
  44. package/build/src/export/web/exportWebAsync.js +3 -0
  45. package/build/src/export/web/exportWebAsync.js.map +1 -1
  46. package/build/src/export/writeContents.js +5 -2
  47. package/build/src/export/writeContents.js.map +1 -1
  48. package/build/src/graphql/generated.js +462 -0
  49. package/build/src/graphql/generated.js.map +1 -0
  50. package/build/src/install/installAsync.js +3 -0
  51. package/build/src/install/installAsync.js.map +1 -1
  52. package/build/src/prebuild/clearNativeFolder.js +6 -1
  53. package/build/src/prebuild/clearNativeFolder.js.map +1 -1
  54. package/build/src/prebuild/ensureConfigAsync.js +1 -12
  55. package/build/src/prebuild/ensureConfigAsync.js.map +1 -1
  56. package/build/src/prebuild/prebuildAsync.js +7 -2
  57. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  58. package/build/src/prebuild/resolveOptions.js +7 -8
  59. package/build/src/prebuild/resolveOptions.js.map +1 -1
  60. package/build/src/prebuild/resolveTemplate.js +5 -0
  61. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  62. package/build/src/prebuild/updateFromTemplate.js +6 -1
  63. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  64. package/build/src/prebuild/validateTemplatePlatforms.js +48 -0
  65. package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -0
  66. package/build/src/run/android/runAndroidAsync.js +4 -0
  67. package/build/src/run/android/runAndroidAsync.js.map +1 -1
  68. package/build/src/run/ios/appleDevice/AppleDevice.js +25 -19
  69. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  70. package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -1
  71. package/build/src/run/ios/options/resolveNativeScheme.js +13 -4
  72. package/build/src/run/ios/options/resolveNativeScheme.js.map +1 -1
  73. package/build/src/run/ios/runIosAsync.js +3 -0
  74. package/build/src/run/ios/runIosAsync.js.map +1 -1
  75. package/build/src/run/startBundler.js +4 -0
  76. package/build/src/run/startBundler.js.map +1 -1
  77. package/build/src/start/doctor/Prerequisite.js.map +1 -1
  78. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +12 -6
  79. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  80. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +1 -3
  81. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  82. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +31 -5
  83. package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
  84. package/build/src/start/doctor/typescript/updateTSConfig.js +6 -0
  85. package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
  86. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +1 -0
  87. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
  88. package/build/src/start/platforms/android/adb.js +1 -1
  89. package/build/src/start/platforms/android/adb.js.map +1 -1
  90. package/build/src/start/platforms/ios/AppleDeviceManager.js +1 -1
  91. package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
  92. package/build/src/start/server/BundlerDevServer.js +16 -2
  93. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  94. package/build/src/start/server/DevServerManager.js +33 -2
  95. package/build/src/start/server/DevServerManager.js.map +1 -1
  96. package/build/src/start/server/getStaticRenderFunctions.js +166 -0
  97. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -0
  98. package/build/src/start/server/metro/MetroBundlerDevServer.js +279 -3
  99. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  100. package/build/src/start/server/metro/MetroTerminalReporter.js +2 -34
  101. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  102. package/build/src/start/server/metro/externals.js +95 -0
  103. package/build/src/start/server/metro/externals.js.map +1 -0
  104. package/build/src/start/server/metro/getCssModulesFromBundler.js +77 -0
  105. package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -0
  106. package/build/src/start/server/metro/inspector-proxy/index.js +2 -2
  107. package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
  108. package/build/src/start/server/metro/inspector-proxy/proxy.js +1 -3
  109. package/build/src/start/server/metro/inspector-proxy/proxy.js.map +1 -1
  110. package/build/src/start/server/metro/instantiateMetro.js +44 -48
  111. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  112. package/build/src/start/server/metro/metroErrorInterface.js +114 -0
  113. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -0
  114. package/build/src/start/server/metro/metroWatchTypeScriptFiles.js +51 -0
  115. package/build/src/start/server/metro/metroWatchTypeScriptFiles.js.map +1 -0
  116. package/build/src/start/server/metro/resolveFromProject.js +26 -3
  117. package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
  118. package/build/src/start/server/metro/router.js +4 -0
  119. package/build/src/start/server/metro/router.js.map +1 -1
  120. package/build/src/start/server/metro/runServer-fork.js +108 -0
  121. package/build/src/start/server/metro/runServer-fork.js.map +1 -0
  122. package/build/src/start/server/metro/symbolicate.js +6 -0
  123. package/build/src/start/server/metro/symbolicate.js.map +1 -0
  124. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +70 -0
  125. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -0
  126. package/build/src/start/server/metro/withMetroMultiPlatform.js +181 -44
  127. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  128. package/build/src/start/server/middleware/ClassicManifestMiddleware.js +8 -1
  129. package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
  130. package/build/src/start/server/middleware/CreateFileMiddleware.js.map +1 -1
  131. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +38 -32
  132. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
  133. package/build/src/start/server/middleware/ManifestMiddleware.js +53 -19
  134. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  135. package/build/src/start/server/type-generation/expo-env.js +27 -0
  136. package/build/src/start/server/type-generation/expo-env.js.map +1 -0
  137. package/build/src/start/server/type-generation/index.js +49 -0
  138. package/build/src/start/server/type-generation/index.js.map +1 -0
  139. package/build/src/start/server/type-generation/routes.js +292 -0
  140. package/build/src/start/server/type-generation/routes.js.map +1 -0
  141. package/build/src/start/server/type-generation/tsconfig.js +89 -0
  142. package/build/src/start/server/type-generation/tsconfig.js.map +1 -0
  143. package/build/src/start/server/webTemplate.js +20 -4
  144. package/build/src/start/server/webTemplate.js.map +1 -1
  145. package/build/src/start/server/webpack/WebpackBundlerDevServer.js +4 -6
  146. package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
  147. package/build/src/start/startAsync.js +30 -8
  148. package/build/src/start/startAsync.js.map +1 -1
  149. package/build/src/utils/FileNotifier.js +11 -4
  150. package/build/src/utils/FileNotifier.js.map +1 -1
  151. package/build/src/utils/analytics/getMetroProperties.js +1 -1
  152. package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
  153. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  154. package/build/src/utils/codesigning.js +31 -7
  155. package/build/src/utils/codesigning.js.map +1 -1
  156. package/build/src/utils/env.js +3 -0
  157. package/build/src/utils/env.js.map +1 -1
  158. package/build/src/utils/mergeGitIgnorePaths.js +42 -0
  159. package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
  160. package/build/src/utils/nodeEnv.js +11 -0
  161. package/build/src/utils/nodeEnv.js.map +1 -0
  162. package/build/src/utils/resolveArgs.js +43 -0
  163. package/build/src/utils/resolveArgs.js.map +1 -1
  164. package/build/src/utils/template.js +21 -0
  165. package/build/src/utils/template.js.map +1 -0
  166. package/build/src/utils/tsconfig/evaluateTsConfig.js +61 -0
  167. package/build/src/utils/tsconfig/evaluateTsConfig.js.map +1 -0
  168. package/build/src/utils/tsconfig/loadTsConfigPaths.js +69 -0
  169. package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -0
  170. package/build/src/utils/tsconfig/matchTsConfigPathAlias.js +88 -0
  171. package/build/src/utils/tsconfig/matchTsConfigPathAlias.js.map +1 -0
  172. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +41 -0
  173. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -0
  174. package/package.json +16 -8
  175. package/static/template/metro.config.js +4 -1
  176. package/build/src/api/getProject.js +0 -19
  177. package/build/src/api/getProject.js.map +0 -1
  178. package/build/src/api/graphql/generated.js +0 -113
  179. package/build/src/api/graphql/generated.js.map +0 -1
@@ -4,19 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  var _configPlugins = require("@expo/config-plugins");
6
6
  var _accepts = _interopRequireDefault(require("accepts"));
7
- var _assert = _interopRequireDefault(require("assert"));
8
7
  var _crypto = _interopRequireDefault(require("crypto"));
9
8
  var _formData = _interopRequireDefault(require("form-data"));
10
9
  var _structuredHeaders = require("structured-headers");
11
- var _getProject = require("../../../api/getProject");
12
10
  var _settings = require("../../../api/settings");
13
- var _signManifest = require("../../../api/signManifest");
14
11
  var _userSettings = _interopRequireDefault(require("../../../api/user/UserSettings"));
15
12
  var _user = require("../../../api/user/user");
13
+ var Log = _interopRequireWildcard(require("../../../log"));
16
14
  var _rudderstackClient = require("../../../utils/analytics/rudderstackClient");
17
15
  var _codesigning = require("../../../utils/codesigning");
18
16
  var _errors = require("../../../utils/errors");
19
- var _fn = require("../../../utils/fn");
20
17
  var _url = require("../../../utils/url");
21
18
  var _manifestMiddleware = require("./ManifestMiddleware");
22
19
  var _resolvePlatform = require("./resolvePlatform");
@@ -25,6 +22,27 @@ function _interopRequireDefault(obj) {
25
22
  default: obj
26
23
  };
27
24
  }
25
+ function _interopRequireWildcard(obj) {
26
+ if (obj && obj.__esModule) {
27
+ return obj;
28
+ } else {
29
+ var newObj = {};
30
+ if (obj != null) {
31
+ for(var key in obj){
32
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
33
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
34
+ if (desc.get || desc.set) {
35
+ Object.defineProperty(newObj, key, desc);
36
+ } else {
37
+ newObj[key] = obj[key];
38
+ }
39
+ }
40
+ }
41
+ }
42
+ newObj.default = obj;
43
+ return newObj;
44
+ }
45
+ }
28
46
  const debug = require("debug")("expo:start:server:middleware:ExpoGoManifestHandlerMiddleware");
29
47
  class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddleware {
30
48
  getParsedHeaders(req) {
@@ -47,7 +65,6 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
47
65
  return {
48
66
  explicitlyPrefersMultipartMixed,
49
67
  platform,
50
- acceptSignature: this.getLegacyAcceptSignatureHeader(req),
51
68
  expectSignature: expectSignature ? String(expectSignature) : null,
52
69
  hostname: (0, _url).stripPort(req.headers["host"])
53
70
  };
@@ -75,12 +92,10 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
75
92
  }
76
93
  const codeSigningInfo = await (0, _codesigning).getCodeSigningInfoAsync(exp, requestOptions.expectSignature, this.options.privateKeyPath);
77
94
  const easProjectId = (ref = exp.extra) == null ? void 0 : (ref1 = ref.eas) == null ? void 0 : ref1.projectId;
78
- const shouldUseAnonymousManifest = await shouldUseAnonymousManifestAsync(easProjectId, codeSigningInfo);
79
- const userAnonymousIdentifier = await _userSettings.default.getAnonymousIdentifierAsync();
80
- if (!shouldUseAnonymousManifest) {
81
- (0, _assert).default(easProjectId);
82
- }
83
- const scopeKey = shouldUseAnonymousManifest ? `@${_user.ANONYMOUS_USERNAME}/${exp.slug}-${userAnonymousIdentifier}` : await this.getScopeKeyForProjectIdAsync(easProjectId);
95
+ const scopeKey = await ExpoGoManifestHandlerMiddleware.getScopeKeyAsync({
96
+ slug: exp.slug,
97
+ codeSigningInfo
98
+ });
84
99
  const expoUpdatesManifest = {
85
100
  id: _crypto.default.randomUUID(),
86
101
  createdAt: new Date().toISOString(),
@@ -104,11 +119,6 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
104
119
  scopeKey
105
120
  }
106
121
  };
107
- const headers = this.getDefaultResponseHeaders();
108
- if (requestOptions.acceptSignature && !shouldUseAnonymousManifest) {
109
- const manifestSignature = await this.getSignedManifestStringAsync(expoUpdatesManifest);
110
- headers.set("expo-manifest-signature", manifestSignature);
111
- }
112
122
  const stringifiedManifest = JSON.stringify(expoUpdatesManifest);
113
123
  let manifestPartHeaders = null;
114
124
  let certificateChainBody = null;
@@ -128,6 +138,7 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
128
138
  manifestPartHeaders,
129
139
  certificateChainBody
130
140
  });
141
+ const headers = this.getDefaultResponseHeaders();
131
142
  headers.set("content-type", requestOptions.explicitlyPrefersMultipartMixed ? `multipart/mixed; boundary=${form.getBoundary()}` : "text/plain");
132
143
  return {
133
144
  body: form.getBuffer().toString(),
@@ -155,24 +166,19 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
155
166
  runtimeVersion: version
156
167
  });
157
168
  }
158
- getSignedManifestStringAsync = (0, _fn).memoize(_signManifest.signExpoGoManifestAsync);
159
- getScopeKeyForProjectIdAsync = (0, _fn).memoize(getScopeKeyForProjectIdAsync);
160
- }
161
- exports.ExpoGoManifestHandlerMiddleware = ExpoGoManifestHandlerMiddleware;
162
- /**
163
- * 1. No EAS project ID in config, then use anonymous scope key
164
- * 2. When offline or not logged in
165
- * a. If code signing not accepted by client (only legacy manifest signing is supported), then use anonymous scope key
166
- * b. If code signing accepted by client and no development code signing certificate is cached, then use anonymous scope key
167
- */ async function shouldUseAnonymousManifestAsync(easProjectId, codeSigningInfo) {
168
- if (!easProjectId || _settings.APISettings.isOffline && codeSigningInfo === null) {
169
- return true;
169
+ static async getScopeKeyAsync({ slug , codeSigningInfo }) {
170
+ const scopeKeyFromCodeSigningInfo = codeSigningInfo == null ? void 0 : codeSigningInfo.scopeKey;
171
+ if (scopeKeyFromCodeSigningInfo) {
172
+ return scopeKeyFromCodeSigningInfo;
173
+ }
174
+ Log.warn(_settings.APISettings.isOffline ? "Using anonymous scope key in manifest for offline mode." : "Using anonymous scope key in manifest.");
175
+ return await getAnonymousScopeKeyAsync(slug);
170
176
  }
171
- return !await (0, _user).getUserAsync();
172
177
  }
173
- async function getScopeKeyForProjectIdAsync(projectId) {
174
- const project = await (0, _getProject).getProjectAsync(projectId);
175
- return project.scopeKey;
178
+ exports.ExpoGoManifestHandlerMiddleware = ExpoGoManifestHandlerMiddleware;
179
+ async function getAnonymousScopeKeyAsync(slug) {
180
+ const userAnonymousIdentifier = await _userSettings.default.getAnonymousIdentifierAsync();
181
+ return `@${_user.ANONYMOUS_USERNAME}/${slug}-${userAnonymousIdentifier}`;
176
182
  }
177
183
  function convertToDictionaryItemsRepresentation(obj) {
178
184
  return new Map(Object.entries(obj).map(([k, v])=>{
@@ -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 assert from 'assert';\nimport crypto from 'crypto';\nimport FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\n\nimport { getProjectAsync } from '../../../api/getProject';\nimport { APISettings } from '../../../api/settings';\nimport { signExpoGoManifestAsync } from '../../../api/signManifest';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME, getUserAsync } 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 { memoize } from '../../../utils/fn';\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\ninterface ExpoGoManifestRequestInfo extends ManifestRequestInfo {\n explicitlyPrefersMultipartMixed: boolean;\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 \"none\".`\n );\n platform = 'none';\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 explicitlyPrefersMultipartMixed =\n accept.types(['unknown/unknown', 'multipart/mixed']) === 'multipart/mixed';\n\n const expectSignature = req.headers['expo-expect-signature'];\n\n return {\n explicitlyPrefersMultipartMixed,\n platform,\n acceptSignature: this.getLegacyAcceptSignatureHeader(req),\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;\n const shouldUseAnonymousManifest = await shouldUseAnonymousManifestAsync(\n easProjectId,\n codeSigningInfo\n );\n const userAnonymousIdentifier = await UserSettings.getAnonymousIdentifierAsync();\n if (!shouldUseAnonymousManifest) {\n assert(easProjectId);\n }\n const scopeKey = shouldUseAnonymousManifest\n ? `@${ANONYMOUS_USERNAME}/${exp.slug}-${userAnonymousIdentifier}`\n : await this.getScopeKeyForProjectIdAsync(easProjectId);\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 headers = this.getDefaultResponseHeaders();\n if (requestOptions.acceptSignature && !shouldUseAnonymousManifest) {\n const manifestSignature = await this.getSignedManifestStringAsync(expoUpdatesManifest);\n headers.set('expo-manifest-signature', manifestSignature);\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 form = this.getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n });\n\n headers.set(\n 'content-type',\n requestOptions.explicitlyPrefersMultipartMixed\n ? `multipart/mixed; boundary=${form.getBoundary()}`\n : 'text/plain'\n );\n\n return {\n body: form.getBuffer().toString(),\n version: runtimeVersion,\n headers,\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 getSignedManifestStringAsync = memoize(signExpoGoManifestAsync);\n\n private getScopeKeyForProjectIdAsync = memoize(getScopeKeyForProjectIdAsync);\n}\n\n/**\n * 1. No EAS project ID in config, then use anonymous scope key\n * 2. When offline or not logged in\n * a. If code signing not accepted by client (only legacy manifest signing is supported), then use anonymous scope key\n * b. If code signing accepted by client and no development code signing certificate is cached, then use anonymous scope key\n */\nasync function shouldUseAnonymousManifestAsync(\n easProjectId: string | undefined | null,\n codeSigningInfo: CodeSigningInfo | null\n): Promise<boolean> {\n if (!easProjectId || (APISettings.isOffline && codeSigningInfo === null)) {\n return true;\n }\n\n return !(await getUserAsync());\n}\n\nasync function getScopeKeyForProjectIdAsync(projectId: string): Promise<string> {\n const project = await getProjectAsync(projectId);\n return project.scopeKey;\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","ExpoGoManifestHandlerMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","accept","accepts","explicitlyPrefersMultipartMixed","types","expectSignature","headers","acceptSignature","getLegacyAcceptSignatureHeader","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","shouldUseAnonymousManifest","shouldUseAnonymousManifestAsync","userAnonymousIdentifier","UserSettings","getAnonymousIdentifierAsync","assert","scopeKey","ANONYMOUS_USERNAME","slug","getScopeKeyForProjectIdAsync","expoUpdatesManifest","id","crypto","randomUUID","createdAt","Date","toISOString","launchAsset","key","contentType","url","assets","metadata","undefined","expoClient","expoGo","manifestSignature","getSignedManifestStringAsync","stringifiedManifest","JSON","stringify","manifestPartHeaders","certificateChainBody","signature","signManifestString","serializeDictionary","convertToDictionaryItemsRepresentation","keyid","keyId","sig","alg","certificateChainForResponse","join","form","getFormData","getBoundary","body","getBuffer","toString","version","FormData","append","header","length","trackManifest","logEventAsync","memoize","signExpoGoManifestAsync","APISettings","isOffline","getUserAsync","project","getProjectAsync","obj","Object","entries","map","k","v"],"mappings":"AAAA;;;;AACwB,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC1B,IAAA,QAAS,kCAAT,SAAS,EAAA;AACV,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACR,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACN,IAAA,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AAC;CAC9E;QArLYlD,+BAA+B,GAA/BA,+BAA+B;AAuL5C;;;;;GAKG,CACH,eAAe0C,+BAA+B,CAC5CL,YAAuC,EACvCJ,eAAuC,EACrB;IAClB,IAAI,CAACI,YAAY,IAAK8D,SAAW,YAAA,CAACC,SAAS,IAAInE,eAAe,KAAK,IAAI,AAAC,EAAE;QACxE,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CAAE,MAAMoE,CAAAA,GAAAA,KAAY,AAAE,CAAA,aAAF,EAAE,AAAC,CAAC;CAChC;AAED,eAAenD,4BAA4B,CAACV,SAAiB,EAAmB;IAC9E,MAAM8D,OAAO,GAAG,MAAMC,CAAAA,GAAAA,WAAe,AAAW,CAAA,gBAAX,CAAC/D,SAAS,CAAC,AAAC;IACjD,OAAO8D,OAAO,CAACvD,QAAQ,CAAC;CACzB;AAED,SAAS8B,sCAAsC,CAAC2B,GAA8B,EAAc;IAC1F,OAAO,IAAIrF,GAAG,CACZsF,MAAM,CAACC,OAAO,CAACF,GAAG,CAAC,CAACG,GAAG,CAAC,CAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAK;QAClC,OAAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAI1F,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 { APISettings } from '../../../api/settings';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME } from '../../../api/user/user';\nimport * as Log from '../../../log';\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\ninterface ExpoGoManifestRequestInfo extends ManifestRequestInfo {\n explicitlyPrefersMultipartMixed: boolean;\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 \"none\".`\n );\n platform = 'none';\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 explicitlyPrefersMultipartMixed =\n accept.types(['unknown/unknown', 'multipart/mixed']) === 'multipart/mixed';\n\n const expectSignature = req.headers['expo-expect-signature'];\n\n return {\n explicitlyPrefersMultipartMixed,\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 form = this.getFormData({\n stringifiedManifest,\n manifestPartHeaders,\n certificateChainBody,\n });\n\n const headers = this.getDefaultResponseHeaders();\n headers.set(\n 'content-type',\n requestOptions.explicitlyPrefersMultipartMixed\n ? `multipart/mixed; boundary=${form.getBoundary()}`\n : 'text/plain'\n );\n\n return {\n body: form.getBuffer().toString(),\n version: runtimeVersion,\n headers,\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 APISettings.isOffline\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":["Log","debug","require","ExpoGoManifestHandlerMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","accept","accepts","explicitlyPrefersMultipartMixed","types","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","FormData","append","header","length","trackManifest","logEventAsync","scopeKeyFromCodeSigningInfo","warn","APISettings","isOffline","getAnonymousScopeKeyAsync","userAnonymousIdentifier","UserSettings","getAnonymousIdentifierAsync","ANONYMOUS_USERNAME","obj","Object","entries","map","k","v"],"mappings":"AAAA;;;;AACwB,IAAA,cAAsB,WAAtB,sBAAsB,CAAA;AAC1B,IAAA,QAAS,kCAAT,SAAS,EAAA;AACV,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACN,IAAA,SAAW,kCAAX,WAAW,EAAA;AACgB,IAAA,kBAAoB,WAApB,oBAAoB,CAAA;AAExC,IAAA,SAAuB,WAAvB,uBAAuB,CAAA;AAC1B,IAAA,aAAgC,kCAAhC,gCAAgC,EAAA;AACtB,IAAA,KAAwB,WAAxB,wBAAwB,CAAA;AAC/CA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACe,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AAKnE,IAAA,YAA4B,WAA5B,4BAA4B,CAAA;AACN,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAC1B,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACU,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACnB,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG9E,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,8DAA8D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OA,2BAA2B,CAAC;SACpC;QAEDzF,GAAG,CAAC0F,IAAI,CACNC,SAAW,YAAA,CAACC,SAAS,GACjB,yDAAyD,GACzD,wCAAwC,CAC7C,CAAC;QACF,OAAO,MAAMC,yBAAyB,CAACjD,IAAI,CAAC,CAAC;KAC9C;CACF;QAxLYzC,+BAA+B,GAA/BA,+BAA+B;AA0L5C,eAAe0F,yBAAyB,CAACjD,IAAY,EAAmB;IACtE,MAAMkD,uBAAuB,GAAG,MAAMC,aAAY,QAAA,CAACC,2BAA2B,EAAE,AAAC;IACjF,OAAO,CAAC,CAAC,EAAEC,KAAkB,mBAAA,CAAC,CAAC,EAAErD,IAAI,CAAC,CAAC,EAAEkD,uBAAuB,CAAC,CAAC,CAAC;CACpE;AAED,SAASzB,sCAAsC,CAAC6B,GAA8B,EAAc;IAC1F,OAAO,IAAI9E,GAAG,CACZ+E,MAAM,CAACC,OAAO,CAACF,GAAG,CAAC,CAACG,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"}
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.getWorkspaceRoot = getWorkspaceRoot;
6
+ exports.getEntryWithServerRoot = getEntryWithServerRoot;
6
7
  exports.getMetroServerRoot = getMetroServerRoot;
8
+ exports.resolveMainModuleName = resolveMainModuleName;
9
+ exports.createBundleUrlPath = createBundleUrlPath;
7
10
  exports.DEVELOPER_TOOL = void 0;
8
11
  var _config = require("@expo/config");
9
12
  var _findYarnWorkspaceRoot = _interopRequireDefault(require("find-yarn-workspace-root"));
@@ -56,6 +59,9 @@ function getWorkspaceRoot(projectRoot) {
56
59
  throw error;
57
60
  }
58
61
  }
62
+ function getEntryWithServerRoot(projectRoot, projectConfig, platform) {
63
+ return _path.default.relative(getMetroServerRoot(projectRoot), (0, _resolveEntryPoint).resolveAbsoluteEntryPoint(projectRoot, platform, projectConfig));
64
+ }
59
65
  function getMetroServerRoot(projectRoot) {
60
66
  if (_env.env.EXPO_USE_METRO_WORKSPACE_ROOT) {
61
67
  var ref;
@@ -63,6 +69,27 @@ function getMetroServerRoot(projectRoot) {
63
69
  }
64
70
  return projectRoot;
65
71
  }
72
+ function resolveMainModuleName(projectRoot, projectConfig, platform) {
73
+ const entryPoint = getEntryWithServerRoot(projectRoot, projectConfig, platform);
74
+ debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);
75
+ return (0, _url1).stripExtension(entryPoint, "js");
76
+ }
77
+ function createBundleUrlPath({ platform , mainModuleName , mode , minify =mode === "production" , environment }) {
78
+ const queryParams = new URLSearchParams({
79
+ platform: encodeURIComponent(platform),
80
+ dev: String(mode !== "production"),
81
+ // TODO: Is this still needed?
82
+ hot: String(false)
83
+ });
84
+ if (minify) {
85
+ queryParams.append("minify", String(minify));
86
+ }
87
+ if (environment) {
88
+ queryParams.append("resolver.environment", environment);
89
+ queryParams.append("transform.environment", environment);
90
+ }
91
+ return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;
92
+ }
66
93
  const DEVELOPER_TOOL = "expo-cli";
67
94
  exports.DEVELOPER_TOOL = DEVELOPER_TOOL;
68
95
  class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
@@ -107,7 +134,7 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
107
134
  };
108
135
  }
109
136
  /** Get the main entry module ID (file) relative to the project root. */ resolveMainModuleName(projectConfig, platform) {
110
- let entryPoint = _path.default.relative(getMetroServerRoot(this.projectRoot), (0, _resolveEntryPoint).resolveAbsoluteEntryPoint(this.projectRoot, platform, projectConfig));
137
+ let entryPoint = getEntryWithServerRoot(this.projectRoot, projectConfig, platform);
111
138
  debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);
112
139
  // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native
113
140
  // in the future (TODO) we should move this logic into a Webpack plugin and use
@@ -120,13 +147,6 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
120
147
  }
121
148
  return (0, _url1).stripExtension(entryPoint, "js");
122
149
  }
123
- /**
124
- * This header is specified as a string "true" or "false", in one of two headers:
125
- * - exponent-accept-signature
126
- * - expo-accept-signature
127
- */ getLegacyAcceptSignatureHeader(req) {
128
- return req.headers["exponent-accept-signature"] === "true" || req.headers["expo-accept-signature"] === "true";
129
- }
130
150
  /** Store device IDs that were sent in the request headers. */ async saveDevicesAsync(req) {
131
151
  var ref;
132
152
  const deviceIds = (ref = req.headers) == null ? void 0 : ref["expo-dev-client-id"];
@@ -136,7 +156,10 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
136
156
  }
137
157
  }
138
158
  /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */ _getBundleUrl({ platform , mainModuleName , hostname }) {
139
- const path = this._getBundleUrlPath({
159
+ var _mode;
160
+ const path = createBundleUrlPath({
161
+ mode: (_mode = this.options.mode) != null ? _mode : "development",
162
+ minify: this.options.minify,
140
163
  platform,
141
164
  mainModuleName
142
165
  });
@@ -204,19 +227,23 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
204
227
  // The server normally inserts this but if we're offline we'll do it here
205
228
  await (0, _resolveAssets).resolveGoogleServicesFile(this.projectRoot, manifest);
206
229
  }
230
+ getWebBundleUrl() {
231
+ const platform = "web";
232
+ // Read from headers
233
+ const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);
234
+ return this._getBundleUrlPath({
235
+ platform,
236
+ mainModuleName
237
+ });
238
+ }
207
239
  /**
208
240
  * Web platforms should create an index.html response using the same script resolution as native.
209
241
  *
210
242
  * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src="">`
211
243
  * to an `index.html`, this enables the web platform to load JavaScript from the server.
212
244
  */ async handleWebRequestAsync(req, res) {
213
- const platform = "web";
214
245
  // Read from headers
215
- const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);
216
- const bundleUrl = this._getBundleUrlPath({
217
- platform,
218
- mainModuleName
219
- });
246
+ const bundleUrl = this.getWebBundleUrl();
220
247
  res.setHeader("Content-Type", "text/html");
221
248
  res.end(await (0, _webTemplate).createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {
222
249
  exp: this.initialProjectConfig.exp,
@@ -225,7 +252,7 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
225
252
  ]
226
253
  }));
227
254
  }
228
- /** Exposed for testing. */ async checkBrowserRequestAsync(req, res) {
255
+ /** Exposed for testing. */ async checkBrowserRequestAsync(req, res, next) {
229
256
  // Read the config
230
257
  const bundlers = (0, _platformBundlers).getPlatformBundlers(this.initialProjectConfig.exp);
231
258
  if (bundlers.web === "metro") {
@@ -235,15 +262,22 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
235
262
  const platform = (0, _resolvePlatform).parsePlatformHeader(req);
236
263
  // On web, serve the public folder
237
264
  if (!platform || platform === "web") {
238
- await this.handleWebRequestAsync(req, res);
239
- return true;
265
+ var ref;
266
+ if (((ref = this.initialProjectConfig.exp.web) == null ? void 0 : ref.output) === "static") {
267
+ // Skip the spa-styled index.html when static generation is enabled.
268
+ next();
269
+ return true;
270
+ } else {
271
+ await this.handleWebRequestAsync(req, res);
272
+ return true;
273
+ }
240
274
  }
241
275
  }
242
276
  return false;
243
277
  }
244
278
  async handleRequestAsync(req, res, next) {
245
279
  // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).
246
- if (await this.checkBrowserRequestAsync(req, res)) {
280
+ if (await this.checkBrowserRequestAsync(req, res, next)) {
247
281
  return;
248
282
  }
249
283
  // Save device IDs for dev client.
@@ -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 { 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 getMetroServerRoot(projectRoot: string) {\n if (env.EXPO_USE_METRO_WORKSPACE_ROOT) {\n return getWorkspaceRoot(projectRoot) ?? projectRoot;\n }\n\n return projectRoot;\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 /** Should return the signed manifest. */\n acceptSignature: boolean;\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 = path.relative(\n getMetroServerRoot(this.projectRoot),\n resolveAbsoluteEntryPoint(this.projectRoot, platform, projectConfig)\n );\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 /**\n * This header is specified as a string \"true\" or \"false\", in one of two headers:\n * - exponent-accept-signature\n * - expo-accept-signature\n */\n protected getLegacyAcceptSignatureHeader(req: ServerRequest): boolean {\n return (\n req.headers['exponent-accept-signature'] === 'true' ||\n req.headers['expo-accept-signature'] === 'true'\n );\n }\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 = this._getBundleUrlPath({ platform, mainModuleName });\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\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:19000\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // http://localhost:19000/logs -- used to send logs to the CLI for displaying in the terminal.\n // This is deprecated in favor of the WebSocket connection setup in Metro.\n logUrl: this.options.constructUrl({ scheme: 'http', hostname }) + '/logs',\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=19000 open -a flipper.app`\n // Where 19000 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 /**\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 const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);\n const bundleUrl = this._getBundleUrlPath({\n platform,\n mainModuleName,\n });\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) {\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 await this.handleWebRequestAsync(req, res);\n return true;\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)) {\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","getMetroServerRoot","Log","ProjectDevices","debug","require","projectRoot","findWorkspaceRoot","error","message","includes","env","EXPO_USE_METRO_WORKSPACE_ROOT","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","_resolveProjectSettingsAsync","platform","hostname","projectConfig","mainModuleName","resolveMainModuleName","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","mutateManifestWithAssetsAsync","exp","entryPoint","path","relative","resolveAbsoluteEntryPoint","isNativeWebpack","stripExtension","getLegacyAcceptSignatureHeader","req","headers","saveDevicesAsync","deviceIds","catch","e","exception","_getBundleUrlPath","queryParams","URLSearchParams","encodeURIComponent","dev","String","mode","hot","minify","append","encodeURI","toString","debuggerHost","logUrl","developer","tool","packagerOpts","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","handleWebRequestAsync","res","setHeader","end","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","bundlers","getPlatformBundlers","web","parsePlatformHeader","handleRequestAsync","next","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","trackManifest"],"mappings":"AAAA;;;;QAqBgBA,gBAAgB,GAAhBA,gBAAgB;QAWhBC,kBAAkB,GAAlBA,kBAAkB;;AAhCiC,IAAA,OAAc,WAAd,cAAc,CAAA;AACnD,IAAA,sBAA0B,kCAA1B,0BAA0B,EAAA;AACvC,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,IAAK,WAAL,KAAK,CAAA;AAEjBC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACK,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACT,IAAA,KAAoB,WAApB,oBAAoB,CAAA;AACvCC,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AAEU,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACH,IAAA,YAAgB,WAAhB,gBAAgB,CAAA;AACvC,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AACgB,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AACxC,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACV,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGxE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,uCAAuC,CAAC,AAAsB,AAAC;AAGvF,SAASL,gBAAgB,CAACM,WAAmB,EAAiB;IACnE,IAAI;QACF,OAAOC,CAAAA,GAAAA,sBAAiB,AA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AAI,IAAI,CAAC,CAAC;KACrC;CACF;QA3QqB1E,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 { 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 createBundleUrlPath({\n platform,\n mainModuleName,\n mode,\n minify = mode === 'production',\n environment,\n}: {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: string;\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 (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\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 });\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\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:19000\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // http://localhost:19000/logs -- used to send logs to the CLI for displaying in the terminal.\n // This is deprecated in favor of the WebSocket connection setup in Metro.\n logUrl: this.options.constructUrl({ scheme: 'http', hostname }) + '/logs',\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=19000 open -a flipper.app`\n // Where 19000 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","createBundleUrlPath","Log","ProjectDevices","debug","require","projectRoot","findWorkspaceRoot","error","message","includes","projectConfig","platform","path","relative","resolveAbsoluteEntryPoint","env","EXPO_USE_METRO_WORKSPACE_ROOT","entryPoint","stripExtension","mainModuleName","mode","minify","environment","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","logUrl","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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U,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;QA5QqBvD,kBAAkB,GAAlBA,kBAAkB"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.writeExpoEnvDTS = writeExpoEnvDTS;
6
+ exports.removeExpoEnvDTS = removeExpoEnvDTS;
7
+ var _promises = _interopRequireDefault(require("fs/promises"));
8
+ var _path = _interopRequireDefault(require("path"));
9
+ function _interopRequireDefault(obj) {
10
+ return obj && obj.__esModule ? obj : {
11
+ default: obj
12
+ };
13
+ }
14
+ const template = `/// <reference types="expo-router/types" />
15
+
16
+ // NOTE: This file should not be edited and should be in your git ignore`;
17
+ async function writeExpoEnvDTS(projectRoot) {
18
+ return _promises.default.writeFile(_path.default.join(projectRoot, "expo-env.d.ts"), template);
19
+ }
20
+ async function removeExpoEnvDTS(projectRoot) {
21
+ // Force removal of expo-env.d.ts - Ignore any errors if the file does not exist
22
+ return _promises.default.rm(_path.default.join(projectRoot, "expo-env.d.ts"), {
23
+ force: true
24
+ });
25
+ }
26
+
27
+ //# sourceMappingURL=expo-env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/type-generation/expo-env.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport path from 'path';\n\nconst template = `/// <reference types=\"expo-router/types\" />\n\n// NOTE: This file should not be edited and should be in your git ignore`;\n\nexport async function writeExpoEnvDTS(projectRoot: string) {\n return fs.writeFile(path.join(projectRoot, 'expo-env.d.ts'), template);\n}\n\nexport async function removeExpoEnvDTS(projectRoot: string) {\n // Force removal of expo-env.d.ts - Ignore any errors if the file does not exist\n return fs.rm(path.join(projectRoot, 'expo-env.d.ts'), { force: true });\n}\n"],"names":["writeExpoEnvDTS","removeExpoEnvDTS","template","projectRoot","fs","writeFile","path","join","rm","force"],"mappings":"AAAA;;;;QAOsBA,eAAe,GAAfA,eAAe;QAIfC,gBAAgB,GAAhBA,gBAAgB;AAXvB,IAAA,SAAa,kCAAb,aAAa,EAAA;AACX,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAEvB,MAAMC,QAAQ,GAAG,CAAC;;wEAEsD,CAAC,AAAC;AAEnE,eAAeF,eAAe,CAACG,WAAmB,EAAE;IACzD,OAAOC,SAAE,QAAA,CAACC,SAAS,CAACC,KAAI,QAAA,CAACC,IAAI,CAACJ,WAAW,EAAE,eAAe,CAAC,EAAED,QAAQ,CAAC,CAAC;CACxE;AAEM,eAAeD,gBAAgB,CAACE,WAAmB,EAAE;IAC1D,gFAAgF;IAChF,OAAOC,SAAE,QAAA,CAACI,EAAE,CAACF,KAAI,QAAA,CAACC,IAAI,CAACJ,WAAW,EAAE,eAAe,CAAC,EAAE;QAAEM,KAAK,EAAE,IAAI;KAAE,CAAC,CAAC;CACxE"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.typescriptTypeGeneration = typescriptTypeGeneration;
6
+ var _promises = _interopRequireDefault(require("fs/promises"));
7
+ var _path = _interopRequireDefault(require("path"));
8
+ var _env = require("../../../utils/env");
9
+ var _mergeGitIgnorePaths = require("../../../utils/mergeGitIgnorePaths");
10
+ var _dotExpo = require("../../project/dotExpo");
11
+ var _expoEnv = require("./expo-env");
12
+ var _routes = require("./routes");
13
+ var _tsconfig = require("./tsconfig");
14
+ function _interopRequireDefault(obj) {
15
+ return obj && obj.__esModule ? obj : {
16
+ default: obj
17
+ };
18
+ }
19
+ async function typescriptTypeGeneration({ metro , projectRoot , server }) {
20
+ const gitIgnorePath = _path.default.join(projectRoot, ".gitignore");
21
+ // If typed routes are disabled, remove any files that were added.
22
+ if (!_env.env.EXPO_USE_TYPED_ROUTES) {
23
+ await Promise.all([
24
+ (0, _tsconfig).forceRemovalTSConfig(projectRoot),
25
+ (0, _expoEnv).removeExpoEnvDTS(projectRoot),
26
+ (0, _mergeGitIgnorePaths).removeFromGitIgnore(gitIgnorePath, "expo-env.d.ts"),
27
+ ]);
28
+ } else {
29
+ const dotExpoDir = (0, _dotExpo).ensureDotExpoProjectDirectoryInitialized(projectRoot);
30
+ const typesDirectory = _path.default.resolve(dotExpoDir, "./types");
31
+ // Ensure the types directory exists.
32
+ await _promises.default.mkdir(typesDirectory, {
33
+ recursive: true
34
+ });
35
+ await Promise.all([
36
+ (0, _mergeGitIgnorePaths).upsertGitIgnoreContents(_path.default.join(projectRoot, ".gitignore"), "expo-env.d.ts"),
37
+ (0, _expoEnv).writeExpoEnvDTS(projectRoot),
38
+ (0, _tsconfig).forceUpdateTSConfig(projectRoot),
39
+ (0, _routes).setupTypedRoutes({
40
+ metro,
41
+ server,
42
+ typesDirectory,
43
+ projectRoot
44
+ }),
45
+ ]);
46
+ }
47
+ }
48
+
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/type-generation/index.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport { Server } from 'metro';\nimport path from 'path';\n\nimport { env } from '../../../utils/env';\nimport { upsertGitIgnoreContents, removeFromGitIgnore } from '../../../utils/mergeGitIgnorePaths';\nimport { ensureDotExpoProjectDirectoryInitialized } from '../../project/dotExpo';\nimport { ServerLike } from '../BundlerDevServer';\nimport { removeExpoEnvDTS, writeExpoEnvDTS } from './expo-env';\nimport { setupTypedRoutes } from './routes';\nimport { forceRemovalTSConfig, forceUpdateTSConfig } from './tsconfig';\n\nexport interface TypeScriptTypeGenerationOptions {\n server: ServerLike;\n metro?: Server | null;\n projectRoot: string;\n}\n\nexport async function typescriptTypeGeneration({\n metro,\n projectRoot,\n server,\n}: TypeScriptTypeGenerationOptions) {\n const gitIgnorePath = path.join(projectRoot, '.gitignore');\n\n // If typed routes are disabled, remove any files that were added.\n if (!env.EXPO_USE_TYPED_ROUTES) {\n await Promise.all([\n forceRemovalTSConfig(projectRoot),\n removeExpoEnvDTS(projectRoot),\n removeFromGitIgnore(gitIgnorePath, 'expo-env.d.ts'),\n ]);\n } else {\n const dotExpoDir = ensureDotExpoProjectDirectoryInitialized(projectRoot);\n const typesDirectory = path.resolve(dotExpoDir, './types');\n\n // Ensure the types directory exists.\n await fs.mkdir(typesDirectory, { recursive: true });\n\n await Promise.all([\n upsertGitIgnoreContents(path.join(projectRoot, '.gitignore'), 'expo-env.d.ts'),\n writeExpoEnvDTS(projectRoot),\n forceUpdateTSConfig(projectRoot),\n setupTypedRoutes({ metro, server, typesDirectory, projectRoot }),\n ]);\n }\n}\n"],"names":["typescriptTypeGeneration","metro","projectRoot","server","gitIgnorePath","path","join","env","EXPO_USE_TYPED_ROUTES","Promise","all","forceRemovalTSConfig","removeExpoEnvDTS","removeFromGitIgnore","dotExpoDir","ensureDotExpoProjectDirectoryInitialized","typesDirectory","resolve","fs","mkdir","recursive","upsertGitIgnoreContents","writeExpoEnvDTS","forceUpdateTSConfig","setupTypedRoutes"],"mappings":"AAAA;;;;QAkBsBA,wBAAwB,GAAxBA,wBAAwB;AAlB/B,IAAA,SAAa,kCAAb,aAAa,EAAA;AAEX,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEH,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACqB,IAAA,oBAAoC,WAApC,oCAAoC,CAAA;AACxC,IAAA,QAAuB,WAAvB,uBAAuB,CAAA;AAE9B,IAAA,QAAY,WAAZ,YAAY,CAAA;AAC7B,IAAA,OAAU,WAAV,UAAU,CAAA;AACe,IAAA,SAAY,WAAZ,YAAY,CAAA;;;;;;AAQ/D,eAAeA,wBAAwB,CAAC,EAC7CC,KAAK,CAAA,EACLC,WAAW,CAAA,EACXC,MAAM,CAAA,EAC0B,EAAE;IAClC,MAAMC,aAAa,GAAGC,KAAI,QAAA,CAACC,IAAI,C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