@expo/cli 0.9.0 → 0.10.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.
- package/build/bin/cli +2 -2
- package/build/src/api/rest/client.js +29 -18
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/api/rest/wrapFetchWithOffline.js +2 -2
- package/build/src/api/rest/wrapFetchWithOffline.js.map +1 -1
- package/build/src/api/settings.js +14 -5
- package/build/src/api/settings.js.map +1 -1
- package/build/src/api/user/actions.js +5 -0
- package/build/src/api/user/actions.js.map +1 -1
- package/build/src/api/user/user.js +2 -2
- package/build/src/api/user/user.js.map +1 -1
- package/build/src/register/registerAsync.js +3 -0
- package/build/src/register/registerAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/bundledNativeModules.js +8 -4
- package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +25 -8
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +2 -2
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/index.js +18 -11
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/interface/commandsTable.js +12 -0
- package/build/src/start/interface/commandsTable.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +7 -2
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/interface/startInterface.js +9 -0
- package/build/src/start/interface/startInterface.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +7 -6
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/resolveOptions.js +17 -33
- package/build/src/start/resolveOptions.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +1 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +22 -0
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +3 -3
- package/build/src/start/server/DevelopmentSession.js.map +1 -1
- package/build/src/start/server/UrlCreator.js +2 -2
- package/build/src/start/server/UrlCreator.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +6 -3
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/device.js +19 -0
- package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/index.js +1 -1
- package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/proxy.js +22 -7
- package/build/src/start/server/metro/inspector-proxy/proxy.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +1 -1
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +8 -7
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ContextModuleSourceMapsMiddleware.js +27 -0
- package/build/src/start/server/middleware/ContextModuleSourceMapsMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +2 -2
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +4 -4
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/type-generation/{index.js → startTypescriptTypeGeneration.js} +13 -12
- package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -0
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +3 -0
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/utils/analytics/getDevClientProperties.js +6 -0
- package/build/src/utils/analytics/getDevClientProperties.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/ansi.js.map +1 -1
- package/build/src/utils/codesigning.js +4 -3
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/env.js +5 -5
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/mergeGitIgnorePaths.js +3 -3
- package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
- package/build/src/utils/validateApplicationId.js +21 -19
- package/build/src/utils/validateApplicationId.js.map +1 -1
- package/package.json +7 -7
- package/build/src/start/server/type-generation/index.js.map +0 -1
|
@@ -10,6 +10,7 @@ var _userSettings = _interopRequireDefault(require("../../../api/user/UserSettin
|
|
|
10
10
|
var _user = require("../../../api/user/user");
|
|
11
11
|
var Log = _interopRequireWildcard(require("../../../log"));
|
|
12
12
|
var _rudderstackClient = require("../../../utils/analytics/rudderstackClient");
|
|
13
|
+
var _env = require("../../../utils/env");
|
|
13
14
|
var _fn = require("../../../utils/fn");
|
|
14
15
|
var _link = require("../../../utils/link");
|
|
15
16
|
var _url = require("../../../utils/url");
|
|
@@ -91,12 +92,12 @@ class ClassicManifestMiddleware extends _manifestMiddleware.ManifestMiddleware {
|
|
|
91
92
|
}
|
|
92
93
|
/** Exposed for testing. */ async _getManifestStringAsync({ manifest , hostId , acceptSignature }) {
|
|
93
94
|
const currentSession = await (0, _user).getUserAsync();
|
|
94
|
-
if (!currentSession ||
|
|
95
|
+
if (!currentSession || _env.env.EXPO_OFFLINE) {
|
|
95
96
|
manifest.id = `@${_user.ANONYMOUS_USERNAME}/${manifest.slug}-${hostId}`;
|
|
96
97
|
}
|
|
97
98
|
if (!acceptSignature) {
|
|
98
99
|
return JSON.stringify(manifest);
|
|
99
|
-
} else if (!currentSession ||
|
|
100
|
+
} else if (!currentSession || _env.env.EXPO_OFFLINE) {
|
|
100
101
|
return getUnsignedManifestString(manifest);
|
|
101
102
|
} else {
|
|
102
103
|
return this.getSignedManifestStringAsync(manifest);
|
|
@@ -109,14 +110,14 @@ class ClassicManifestMiddleware extends _manifestMiddleware.ManifestMiddleware {
|
|
|
109
110
|
} catch (error) {
|
|
110
111
|
debug(`Error getting manifest:`, error);
|
|
111
112
|
if (error.code === "UNAUTHORIZED" && props.manifest.owner) {
|
|
112
|
-
// Don't have permissions for
|
|
113
|
+
// Don't have permissions for signing, warn and enable offline mode.
|
|
113
114
|
this.addSigningDisabledWarning(`This project belongs to ${_chalk.default.bold(`@${props.manifest.owner}`)} and you have not been granted the appropriate permissions.\n` + `Please request access from an admin of @${props.manifest.owner} or change the "owner" field to an account you belong to.\n` + (0, _link).learnMore("https://docs.expo.dev/versions/latest/config/app/#owner"));
|
|
114
|
-
_settings.
|
|
115
|
+
(0, _settings).disableNetwork();
|
|
115
116
|
return await this._getManifestStringAsync(props);
|
|
116
|
-
} else if (error.code === "ENOTFOUND") {
|
|
117
|
+
} else if (error.code === "ENOTFOUND" || error.code === "OFFLINE") {
|
|
117
118
|
// Got a DNS error, i.e. can't access exp.host, warn and enable offline mode.
|
|
118
119
|
this.addSigningDisabledWarning(`Could not reach Expo servers, please check if you can access ${error.hostname || "exp.host"}.`);
|
|
119
|
-
_settings.
|
|
120
|
+
(0, _settings).disableNetwork();
|
|
120
121
|
return await this._getManifestStringAsync(props);
|
|
121
122
|
} else {
|
|
122
123
|
throw error;
|
|
@@ -137,7 +138,7 @@ async function createHostInfoAsync() {
|
|
|
137
138
|
host: await _userSettings.default.getAnonymousIdentifierAsync(),
|
|
138
139
|
server: "expo",
|
|
139
140
|
// Defined in the build step
|
|
140
|
-
serverVersion: "0.
|
|
141
|
+
serverVersion: "0.10.0",
|
|
141
142
|
serverDriver: _manifestMiddleware.DEVELOPER_TOOL,
|
|
142
143
|
serverOS: _os.default.platform(),
|
|
143
144
|
serverOSVersion: _os.default.release()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/ClassicManifestMiddleware.ts"],"sourcesContent":["import { ExpoAppManifest, ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport os from 'os';\n\nimport { APISettings } from '../../../api/settings';\nimport { signClassicExpoGoManifestAsync } from '../../../api/signManifest';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME, getUserAsync } from '../../../api/user/user';\nimport * as Log from '../../../log';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { memoize } from '../../../utils/fn';\nimport { learnMore } from '../../../utils/link';\nimport { stripPort } from '../../../utils/url';\nimport {\n DEVELOPER_TOOL,\n HostInfo,\n ManifestMiddleware,\n ManifestRequestInfo,\n} from './ManifestMiddleware';\nimport { assertRuntimePlatform, parsePlatformHeader } from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\n\ntype SignManifestProps = {\n manifest: ExpoAppManifest;\n hostId: string;\n acceptSignature: boolean;\n};\n\ninterface ClassicManifestRequestInfo extends ManifestRequestInfo {\n /** Should return the signed manifest. */\n acceptSignature: boolean;\n}\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:ClassicManifestMiddleware'\n) as typeof console.log;\n\nexport class ClassicManifestMiddleware extends ManifestMiddleware<ClassicManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ClassicManifestRequestInfo {\n const platform = parsePlatformHeader(req) || 'ios';\n assertRuntimePlatform(platform);\n return {\n platform,\n acceptSignature: this.getLegacyAcceptSignatureHeader(req),\n hostname: stripPort(req.headers['host']),\n };\n }\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 private getLegacyAcceptSignatureHeader(req: ServerRequest): boolean {\n return (\n req.headers['exponent-accept-signature'] === 'true' ||\n req.headers['expo-accept-signature'] === 'true'\n );\n }\n\n public async _getManifestResponseAsync({\n acceptSignature,\n ...requestOptions\n }: ClassicManifestRequestInfo): 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 manifest: ExpoAppManifest = {\n ...(exp as ExpoAppManifest),\n ...expoGoConfig,\n hostUri,\n bundleUrl,\n };\n\n // Gather packager and host info\n const hostInfo = await createHostInfoAsync();\n\n const headers = new Map<string, any>();\n headers.set('Exponent-Server', JSON.stringify(hostInfo));\n\n // Create the final string\n const body = await this._fetchComputedManifestStringAsync({\n manifest,\n hostId: hostInfo.host,\n acceptSignature,\n });\n\n return {\n body,\n version: manifest.sdkVersion,\n headers,\n };\n }\n\n protected trackManifest(version?: string) {\n // Log analytics\n logEventAsync('Serve Manifest', {\n sdkVersion: version ?? null,\n });\n }\n\n /** Exposed for testing. */\n async _getManifestStringAsync({\n manifest,\n hostId,\n acceptSignature,\n }: SignManifestProps): Promise<string> {\n const currentSession = await getUserAsync();\n if (!currentSession || APISettings.isOffline) {\n manifest.id = `@${ANONYMOUS_USERNAME}/${manifest.slug}-${hostId}`;\n }\n if (!acceptSignature) {\n return JSON.stringify(manifest);\n } else if (!currentSession || APISettings.isOffline) {\n return getUnsignedManifestString(manifest);\n } else {\n return this.getSignedManifestStringAsync(manifest);\n }\n }\n\n private getSignedManifestStringAsync = memoize(signClassicExpoGoManifestAsync);\n\n /** Exposed for testing. */\n async _fetchComputedManifestStringAsync(props: SignManifestProps): Promise<string> {\n try {\n return await this._getManifestStringAsync(props);\n } catch (error: any) {\n debug(`Error getting manifest:`, error);\n if (error.code === 'UNAUTHORIZED' && props.manifest.owner) {\n // Don't have permissions for siging, warn and enable offline mode.\n this.addSigningDisabledWarning(\n `This project belongs to ${chalk.bold(\n `@${props.manifest.owner}`\n )} and you have not been granted the appropriate permissions.\\n` +\n `Please request access from an admin of @${props.manifest.owner} or change the \"owner\" field to an account you belong to.\\n` +\n learnMore('https://docs.expo.dev/versions/latest/config/app/#owner')\n );\n APISettings.isOffline = true;\n return await this._getManifestStringAsync(props);\n } else if (error.code === 'ENOTFOUND') {\n // Got a DNS error, i.e. can't access exp.host, warn and enable offline mode.\n this.addSigningDisabledWarning(\n `Could not reach Expo servers, please check if you can access ${\n error.hostname || 'exp.host'\n }.`\n );\n APISettings.isOffline = true;\n return await this._getManifestStringAsync(props);\n } else {\n throw error;\n }\n }\n }\n\n private addSigningDisabledWarning = memoize((reason: string) => {\n Log.warn(`${reason}\\nFalling back to offline mode.`);\n // For the memo\n return reason;\n });\n}\n\n// Passed to Expo Go and registered as telemetry.\n// TODO: it's unclear why we don't just send it from the CLI.\nasync function createHostInfoAsync(): Promise<HostInfo> {\n return {\n host: await UserSettings.getAnonymousIdentifierAsync(),\n server: 'expo',\n // Defined in the build step\n serverVersion: process.env.__EXPO_VERSION!,\n serverDriver: DEVELOPER_TOOL,\n serverOS: os.platform(),\n serverOSVersion: os.release(),\n };\n}\n\nfunction getUnsignedManifestString(manifest: ExpoConfig) {\n const unsignedManifest = {\n manifestString: JSON.stringify(manifest),\n signature: 'UNSIGNED',\n };\n return JSON.stringify(unsignedManifest);\n}\n"],"names":["Log","debug","require","ClassicManifestMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","acceptSignature","getLegacyAcceptSignatureHeader","hostname","stripPort","headers","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","manifest","hostInfo","createHostInfoAsync","Map","set","JSON","stringify","body","_fetchComputedManifestStringAsync","hostId","host","version","sdkVersion","trackManifest","logEventAsync","_getManifestStringAsync","currentSession","getUserAsync","APISettings","isOffline","id","ANONYMOUS_USERNAME","slug","getUnsignedManifestString","getSignedManifestStringAsync","memoize","signClassicExpoGoManifestAsync","props","error","code","owner","addSigningDisabledWarning","chalk","bold","learnMore","reason","warn","UserSettings","getAnonymousIdentifierAsync","server","serverVersion","process","env","__EXPO_VERSION","serverDriver","DEVELOPER_TOOL","serverOS","os","serverOSVersion","release","unsignedManifest","manifestString","signature"],"mappings":"AAAA;;;;AACkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAES,IAAA,SAAuB,WAAvB,uBAAuB,CAAA;AACJ,IA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CAACN,QAAQ,CAAC;QACxCoD,SAAS,EAAE,UAAU;KACtB,AAAC;IACF,OAAO/C,IAAI,CAACC,SAAS,CAAC4C,gBAAgB,CAAC,CAAC;CACzC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/ClassicManifestMiddleware.ts"],"sourcesContent":["import { ExpoAppManifest, ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport os from 'os';\n\nimport { disableNetwork } from '../../../api/settings';\nimport { signClassicExpoGoManifestAsync } from '../../../api/signManifest';\nimport UserSettings from '../../../api/user/UserSettings';\nimport { ANONYMOUS_USERNAME, getUserAsync } from '../../../api/user/user';\nimport * as Log from '../../../log';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { env } from '../../../utils/env';\nimport { memoize } from '../../../utils/fn';\nimport { learnMore } from '../../../utils/link';\nimport { stripPort } from '../../../utils/url';\nimport {\n DEVELOPER_TOOL,\n HostInfo,\n ManifestMiddleware,\n ManifestRequestInfo,\n} from './ManifestMiddleware';\nimport { assertRuntimePlatform, parsePlatformHeader } from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\n\ntype SignManifestProps = {\n manifest: ExpoAppManifest;\n hostId: string;\n acceptSignature: boolean;\n};\n\ninterface ClassicManifestRequestInfo extends ManifestRequestInfo {\n /** Should return the signed manifest. */\n acceptSignature: boolean;\n}\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:ClassicManifestMiddleware'\n) as typeof console.log;\n\nexport class ClassicManifestMiddleware extends ManifestMiddleware<ClassicManifestRequestInfo> {\n public getParsedHeaders(req: ServerRequest): ClassicManifestRequestInfo {\n const platform = parsePlatformHeader(req) || 'ios';\n assertRuntimePlatform(platform);\n return {\n platform,\n acceptSignature: this.getLegacyAcceptSignatureHeader(req),\n hostname: stripPort(req.headers['host']),\n };\n }\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 private getLegacyAcceptSignatureHeader(req: ServerRequest): boolean {\n return (\n req.headers['exponent-accept-signature'] === 'true' ||\n req.headers['expo-accept-signature'] === 'true'\n );\n }\n\n public async _getManifestResponseAsync({\n acceptSignature,\n ...requestOptions\n }: ClassicManifestRequestInfo): 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 manifest: ExpoAppManifest = {\n ...(exp as ExpoAppManifest),\n ...expoGoConfig,\n hostUri,\n bundleUrl,\n };\n\n // Gather packager and host info\n const hostInfo = await createHostInfoAsync();\n\n const headers = new Map<string, any>();\n headers.set('Exponent-Server', JSON.stringify(hostInfo));\n\n // Create the final string\n const body = await this._fetchComputedManifestStringAsync({\n manifest,\n hostId: hostInfo.host,\n acceptSignature,\n });\n\n return {\n body,\n version: manifest.sdkVersion,\n headers,\n };\n }\n\n protected trackManifest(version?: string) {\n // Log analytics\n logEventAsync('Serve Manifest', {\n sdkVersion: version ?? null,\n });\n }\n\n /** Exposed for testing. */\n async _getManifestStringAsync({\n manifest,\n hostId,\n acceptSignature,\n }: SignManifestProps): Promise<string> {\n const currentSession = await getUserAsync();\n if (!currentSession || env.EXPO_OFFLINE) {\n manifest.id = `@${ANONYMOUS_USERNAME}/${manifest.slug}-${hostId}`;\n }\n if (!acceptSignature) {\n return JSON.stringify(manifest);\n } else if (!currentSession || env.EXPO_OFFLINE) {\n return getUnsignedManifestString(manifest);\n } else {\n return this.getSignedManifestStringAsync(manifest);\n }\n }\n\n private getSignedManifestStringAsync = memoize(signClassicExpoGoManifestAsync);\n\n /** Exposed for testing. */\n async _fetchComputedManifestStringAsync(props: SignManifestProps): Promise<string> {\n try {\n return await this._getManifestStringAsync(props);\n } catch (error: any) {\n debug(`Error getting manifest:`, error);\n if (error.code === 'UNAUTHORIZED' && props.manifest.owner) {\n // Don't have permissions for signing, warn and enable offline mode.\n this.addSigningDisabledWarning(\n `This project belongs to ${chalk.bold(\n `@${props.manifest.owner}`\n )} and you have not been granted the appropriate permissions.\\n` +\n `Please request access from an admin of @${props.manifest.owner} or change the \"owner\" field to an account you belong to.\\n` +\n learnMore('https://docs.expo.dev/versions/latest/config/app/#owner')\n );\n\n disableNetwork();\n return await this._getManifestStringAsync(props);\n } else if (error.code === 'ENOTFOUND' || error.code === 'OFFLINE') {\n // Got a DNS error, i.e. can't access exp.host, warn and enable offline mode.\n this.addSigningDisabledWarning(\n `Could not reach Expo servers, please check if you can access ${\n error.hostname || 'exp.host'\n }.`\n );\n\n disableNetwork();\n return await this._getManifestStringAsync(props);\n } else {\n throw error;\n }\n }\n }\n\n private addSigningDisabledWarning = memoize((reason: string) => {\n Log.warn(`${reason}\\nFalling back to offline mode.`);\n // For the memo\n return reason;\n });\n}\n\n// Passed to Expo Go and registered as telemetry.\n// TODO: it's unclear why we don't just send it from the CLI.\nasync function createHostInfoAsync(): Promise<HostInfo> {\n return {\n host: await UserSettings.getAnonymousIdentifierAsync(),\n server: 'expo',\n // Defined in the build step\n serverVersion: process.env.__EXPO_VERSION!,\n serverDriver: DEVELOPER_TOOL,\n serverOS: os.platform(),\n serverOSVersion: os.release(),\n };\n}\n\nfunction getUnsignedManifestString(manifest: ExpoConfig) {\n const unsignedManifest = {\n manifestString: JSON.stringify(manifest),\n signature: 'UNSIGNED',\n };\n return JSON.stringify(unsignedManifest);\n}\n"],"names":["Log","debug","require","ClassicManifestMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","acceptSignature","getLegacyAcceptSignatureHeader","hostname","stripPort","headers","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","manifest","hostInfo","createHostInfoAsync","Map","set","JSON","stringify","body","_fetchComputedManifestStringAsync","hostId","host","version","sdkVersion","trackManifest","logEventAsync","_getManifestStringAsync","currentSession","getUserAsync","env","EXPO_OFFLINE","id","ANONYMOUS_USERNAME","slug","getUnsignedManifestString","getSignedManifestStringAsync","memoize","signClassicExpoGoManifestAsync","props","error","code","owner","addSigningDisabledWarning","chalk","bold","learnMore","disableNetwork","reason","warn","UserSettings","getAnonymousIdentifierAsync","server","serverVersion","process","__EXPO_VERSION","serverDriver","DEVELOPER_TOOL","serverOS","os","serverOSVersion","release","unsignedManifest","manifestString","signature"],"mappings":"AAAA;;;;AACkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEY,IAAA,SAAuB,WAAvB,uBAAuB,CAAA;AACP,IAAA,aAA2B,WAA3B,2BAA2B,CAAA;AACjD,IAAA,aAAgC,kCAAhC,gCAAgC,EAAA;AACR,IAAA,KAAwB,WAAxB,wBAAwB,CAAA;AAC7DA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACe,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AACtD,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AAChB,IAAA,GAAmB,WAAnB,mBAAmB,CAAA;AACjB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACrB,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AAMvC,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AAC8B,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAc9E,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,wDAAwD,CACzD,AAAsB,AAAC;AAEjB,MAAMC,yBAAyB,SAASC,mBAAkB,mBAAA;IAC/D,AAAOC,gBAAgB,CAACC,GAAkB,EAA8B;QACtE,MAAMC,QAAQ,GAAGC,CAAAA,GAAAA,gBAAmB,AAAK,CAAA,oBAAL,CAACF,GAAG,CAAC,IAAI,KAAK,AAAC;QACnDG,CAAAA,GAAAA,gBAAqB,AAAU,CAAA,sBAAV,CAACF,QAAQ,CAAC,CAAC;QAChC,OAAO;YACLA,QAAQ;YACRG,eAAe,EAAE,IAAI,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AAmB,GAAsB;IACtD,OAAO;QACLQ,IAAI,EAAE,MAAM4B,aAAY,QAAA,CAACC,2BAA2B,EAAE;QACtDC,MAAM,EAAE,MAAM;QACd,4BAA4B;QAC5BC,aAAa,EAAEC,OAAO,CAACxB,GAAG,CAACyB,cAAc;QACzCC,YAAY,EAAEC,mBAAc,eAAA;QAC5BC,QAAQ,EAAEC,GAAE,QAAA,CAAC9D,QAAQ,EAAE;QACvB+D,eAAe,EAAED,GAAE,QAAA,CAACE,OAAO,EAAE;KAC9B,CAAC;CACH;AAED,SAAS1B,yBAAyB,CAACvB,QAAoB,EAAE;IACvD,MAAMkD,gBAAgB,GAAG;QACvBC,cAAc,EAAE9C,IAAI,CAACC,SAAS,CAACN,QAAQ,CAAC;QACxCoD,SAAS,EAAE,UAAU;KACtB,AAAC;IACF,OAAO/C,IAAI,CAACC,SAAS,CAAC4C,gBAAgB,CAAC,CAAC;CACzC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const debug = require("debug")("expo:start:server:middleware:metro-context-modules");
|
|
6
|
+
class ContextModuleSourceMapsMiddleware {
|
|
7
|
+
getHandler() {
|
|
8
|
+
return (req, res, next)=>{
|
|
9
|
+
if (!(req == null ? void 0 : req.url) || req.method !== "GET" && req.method !== "HEAD") {
|
|
10
|
+
return next();
|
|
11
|
+
}
|
|
12
|
+
if (req.url.match(/%3Fctx=[\d\w\W]+\.map\?/)) {
|
|
13
|
+
debug("Skipping sourcemap request for context module %s", req.url);
|
|
14
|
+
// Return a noop response for the sourcemap
|
|
15
|
+
res.writeHead(200, {
|
|
16
|
+
"Content-Type": "application/json"
|
|
17
|
+
});
|
|
18
|
+
res.end("{}");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
next();
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ContextModuleSourceMapsMiddleware = ContextModuleSourceMapsMiddleware;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=ContextModuleSourceMapsMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/ContextModuleSourceMapsMiddleware.ts"],"sourcesContent":["import { ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:metro-context-modules'\n) as typeof console.log;\n\n/**\n * Source maps for `require.context` modules aren't supported in the Metro dev server\n * we should intercept the request and return a noop response to prevent Chrome/Metro\n * from erroring out.\n */\nexport class ContextModuleSourceMapsMiddleware {\n getHandler() {\n return (req: ServerRequest, res: ServerResponse, next: any) => {\n if (!req?.url || (req.method !== 'GET' && req.method !== 'HEAD')) {\n return next();\n }\n\n if (req.url.match(/%3Fctx=[\\d\\w\\W]+\\.map\\?/)) {\n debug('Skipping sourcemap request for context module %s', req.url);\n // Return a noop response for the sourcemap\n res.writeHead(200, {\n 'Content-Type': 'application/json',\n });\n res.end('{}');\n return;\n }\n\n next();\n };\n }\n}\n"],"names":["debug","require","ContextModuleSourceMapsMiddleware","getHandler","req","res","next","url","method","match","writeHead","end"],"mappings":"AAAA;;;;AAEA,MAAMA,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,oDAAoD,CACrD,AAAsB,AAAC;AAOjB,MAAMC,iCAAiC;IAC5CC,UAAU,GAAG;QACX,OAAO,CAACC,GAAkB,EAAEC,GAAmB,EAAEC,IAAS,GAAK;YAC7D,IAAI,CAACF,CAAAA,GAAG,QAAK,GAARA,KAAAA,CAAQ,GAARA,GAAG,CAAEG,GAAG,CAAA,IAAKH,GAAG,CAACI,MAAM,KAAK,KAAK,IAAIJ,GAAG,CAACI,MAAM,KAAK,MAAM,AAAC,EAAE;gBAChE,OAAOF,IAAI,EAAE,CAAC;aACf;YAED,IAAIF,GAAG,CAACG,GAAG,CAACE,KAAK,2BAA2B,EAAE;gBAC5CT,KAAK,CAAC,kDAAkD,EAAEI,GAAG,CAACG,GAAG,CAAC,CAAC;gBACnE,2CAA2C;gBAC3CF,GAAG,CAACK,SAAS,CAAC,GAAG,EAAE;oBACjB,cAAc,EAAE,kBAAkB;iBACnC,CAAC,CAAC;gBACHL,GAAG,CAACM,GAAG,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO;aACR;YAEDL,IAAI,EAAE,CAAC;SACR,CAAC;KACH;CACF;QApBYJ,iCAAiC,GAAjCA,iCAAiC"}
|
|
@@ -8,12 +8,12 @@ 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 _settings = require("../../../api/settings");
|
|
12
11
|
var _userSettings = _interopRequireDefault(require("../../../api/user/UserSettings"));
|
|
13
12
|
var _user = require("../../../api/user/user");
|
|
14
13
|
var Log = _interopRequireWildcard(require("../../../log"));
|
|
15
14
|
var _rudderstackClient = require("../../../utils/analytics/rudderstackClient");
|
|
16
15
|
var _codesigning = require("../../../utils/codesigning");
|
|
16
|
+
var _env = require("../../../utils/env");
|
|
17
17
|
var _errors = require("../../../utils/errors");
|
|
18
18
|
var _url = require("../../../utils/url");
|
|
19
19
|
var _manifestMiddleware = require("./ManifestMiddleware");
|
|
@@ -231,7 +231,7 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
|
|
|
231
231
|
if (scopeKeyFromCodeSigningInfo) {
|
|
232
232
|
return scopeKeyFromCodeSigningInfo;
|
|
233
233
|
}
|
|
234
|
-
Log.warn(
|
|
234
|
+
Log.warn(_env.env.EXPO_OFFLINE ? "Using anonymous scope key in manifest for offline mode." : "Using anonymous scope key in manifest.");
|
|
235
235
|
return await getAnonymousScopeKeyAsync(slug);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
@@ -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 { 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\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 \"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 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 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","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","warn","APISettings","isOffline","getAnonymousScopeKeyAsync","userAnonymousIdentifier","UserSettings","getAnonymousIdentifierAsync","ANONYMOUS_USERNAME","obj","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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G,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 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 { env } from '../../../utils/env';\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 \"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 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":["Log","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","warn","env","EXPO_OFFLINE","getAnonymousScopeKeyAsync","userAnonymousIdentifier","UserSettings","getAnonymousIdentifierAsync","ANONYMOUS_USERNAME","obj","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;AAE3C,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;AACf,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACX,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAC1B,IAAA,IAAoB,WAApB,o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AK;QAClC,OAAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAItF,GAAG,EAAE;aAAC;SAAC,CAAC;KAC5B,CAAC,CACH,CAAC;CACH"}
|
|
@@ -188,12 +188,12 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
188
188
|
}
|
|
189
189
|
getExpoGoConfig({ mainModuleName , hostname }) {
|
|
190
190
|
return {
|
|
191
|
-
// localhost:
|
|
191
|
+
// localhost:8081
|
|
192
192
|
debuggerHost: this.options.constructUrl({
|
|
193
193
|
scheme: "",
|
|
194
194
|
hostname
|
|
195
195
|
}),
|
|
196
|
-
// http://localhost:
|
|
196
|
+
// http://localhost:8081/logs -- used to send logs to the CLI for displaying in the terminal.
|
|
197
197
|
// This is deprecated in favor of the WebSocket connection setup in Metro.
|
|
198
198
|
logUrl: this.options.constructUrl({
|
|
199
199
|
scheme: "http",
|
|
@@ -212,8 +212,8 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
212
212
|
mainModuleName,
|
|
213
213
|
// Add this string to make Flipper register React Native / Metro as "running".
|
|
214
214
|
// Can be tested by running:
|
|
215
|
-
// `METRO_SERVER_PORT=
|
|
216
|
-
// Where
|
|
215
|
+
// `METRO_SERVER_PORT=8081 open -a flipper.app`
|
|
216
|
+
// Where 8081 is the port where the Expo project is being hosted.
|
|
217
217
|
__flipperHack: "React Native packager is running"
|
|
218
218
|
};
|
|
219
219
|
}
|
|
@@ -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 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 serializerOutput,\n}: {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: string;\n serializerOutput?: 'static';\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 lazy: String(!env.EXPO_NO_METRO_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 });\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 lazy: String(!env.EXPO_NO_METRO_LAZY),\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","serializerOutput","queryParams","URLSearchParams","encodeURIComponent","dev","String","hot","lazy","EXPO_NO_METRO_LAZY","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":"AAAA;;;;QAqBgBA,gBAAgB,GAAhBA,gBAAgB;QAWhBC,sBAAsB,GAAtBA,sBAAsB;QAWtBC,kBAAkB,GAAlBA,kBAAkB;QASlBC,qBAAqB,GAArBA,qBAAqB;QAYrBC,mBAAmB,GAAnBA,mBAAmB;;AAhEgC,IAAA,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D,UAAU,EAAEC,WAAW,CAAC,IAAIrC,OAAO,CAAE;YAC/CmB,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;QA7QqBvD,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 serializerOutput,\n}: {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: string;\n serializerOutput?: 'static';\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 lazy: String(!env.EXPO_NO_METRO_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 });\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 lazy: String(!env.EXPO_NO_METRO_LAZY),\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 // http://localhost:8081/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=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","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","serializerOutput","queryParams","URLSearchParams","encodeURIComponent","dev","String","hot","lazy","EXPO_NO_METRO_LAZY","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":"AAAA;;;;QAqBgBA,gBAAgB,GAAhBA,gBAAgB;QAWhBC,sBAAsB,GAAtBA,sBAAsB;QAWtBC,kBAAkB,GAAlBA,kBAAkB;QASlBC,qBAAqB,GAArBA,qBAAqB;QAYrBC,mBAAmB,GAAnBA,mBAAmB;;AAhEgC,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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,EAAEqB,GAAG,CAAC,CAAC;oBAC3C,OAAO,IAAI,CAAC;iBACb;aACF;SACF;QACD,OAAO,KAAK,CAAC;KACd;IAED,MAAMY,kBAAkB,CACtBjC,GAAkB,EAClBqB,GAAmB,EACnBM,IAAgB,EACD;QACf,kFAAkF;QAClF,IAAI,MAAM,IAAI,CAACD,wBAAwB,CAAC1B,GAAG,EAAEqB,GAAG,EAAEM,IAAI,CAAC,EAAE;YACvD,OAAO;SACR;QAED,kCAAkC;QAClC,MAAM,IAAI,CAAC5B,gBAAgB,CAACC,GAAG,CAAC,CAAC;QAEjC,oBAAoB;QACpB,MAAMhB,OAAO,GAAG,IAAI,CAACkD,gBAAgB,CAAClC,GAAG,CAAC,AAAC;QAC3C,MAAM,EAAEmC,IAAI,CAAA,EAAEC,OAAO,CAAA,EAAElC,OAAO,CAAA,EAAE,GAAG,MAAM,IAAI,CAACmC,yBAAyB,CAACrD,OAAO,CAAC,AAAC;QACjF,KAAK,MAAM,CAACsD,UAAU,EAAEC,WAAW,CAAC,IAAIrC,OAAO,CAAE;YAC/CmB,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;QA7QqBvD,kBAAkB,GAAlBA,kBAAkB"}
|
package/build/src/start/server/type-generation/{index.js → startTypescriptTypeGeneration.js}
RENAMED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.
|
|
5
|
+
exports.startTypescriptTypeGenerationAsync = startTypescriptTypeGenerationAsync;
|
|
6
6
|
var _config = require("@expo/config");
|
|
7
7
|
var _promises = _interopRequireDefault(require("fs/promises"));
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _env = require("../../../utils/env");
|
|
10
9
|
var _mergeGitIgnorePaths = require("../../../utils/mergeGitIgnorePaths");
|
|
11
10
|
var _dotExpo = require("../../project/dotExpo");
|
|
12
11
|
var _router = require("../metro/router");
|
|
@@ -18,27 +17,29 @@ function _interopRequireDefault(obj) {
|
|
|
18
17
|
default: obj
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const debug = require("debug")("expo:typed-routes");
|
|
21
|
+
async function startTypescriptTypeGenerationAsync({ metro , projectRoot , server }) {
|
|
22
|
+
var ref;
|
|
23
|
+
const { exp } = (0, _config).getConfig(projectRoot);
|
|
23
24
|
// If typed routes are disabled, remove any files that were added.
|
|
24
|
-
if (!
|
|
25
|
+
if (!((ref = exp.experiments) == null ? void 0 : ref.typedRoutes)) {
|
|
26
|
+
debug("Removing typed routes side-effects (experiments.typedRoutes: false)");
|
|
27
|
+
const gitIgnorePath = _path.default.join(projectRoot, ".gitignore");
|
|
25
28
|
await Promise.all([
|
|
26
29
|
(0, _tsconfig).forceRemovalTSConfig(projectRoot),
|
|
27
30
|
(0, _expoEnv).removeExpoEnvDTS(projectRoot),
|
|
28
31
|
(0, _mergeGitIgnorePaths).removeFromGitIgnore(gitIgnorePath, "expo-env.d.ts"),
|
|
29
32
|
]);
|
|
30
33
|
} else {
|
|
31
|
-
var
|
|
32
|
-
const { exp } = (0, _config).getConfig(projectRoot, {
|
|
33
|
-
skipSDKVersionRequirement: true
|
|
34
|
-
});
|
|
34
|
+
var ref1, ref2;
|
|
35
35
|
const dotExpoDir = (0, _dotExpo).ensureDotExpoProjectDirectoryInitialized(projectRoot);
|
|
36
36
|
const typesDirectory = _path.default.resolve(dotExpoDir, "./types");
|
|
37
|
+
debug("Ensuring typed routes side-effects are setup (experiments.typedRoutes: true, typesDirectory: %s)", typesDirectory);
|
|
37
38
|
// Ensure the types directory exists.
|
|
38
39
|
await _promises.default.mkdir(typesDirectory, {
|
|
39
40
|
recursive: true
|
|
40
41
|
});
|
|
41
|
-
var
|
|
42
|
+
var ref3;
|
|
42
43
|
await Promise.all([
|
|
43
44
|
(0, _mergeGitIgnorePaths).upsertGitIgnoreContents(_path.default.join(projectRoot, ".gitignore"), "expo-env.d.ts"),
|
|
44
45
|
(0, _expoEnv).writeExpoEnvDTS(projectRoot),
|
|
@@ -48,10 +49,10 @@ async function typescriptTypeGeneration({ metro , projectRoot , server }) {
|
|
|
48
49
|
server,
|
|
49
50
|
typesDirectory,
|
|
50
51
|
projectRoot,
|
|
51
|
-
routerDirectory: (
|
|
52
|
+
routerDirectory: (ref3 = (ref1 = exp.extra) == null ? void 0 : (ref2 = ref1.router) == null ? void 0 : ref2.unstable_src) != null ? ref3 : (0, _router).getRouterDirectory(projectRoot)
|
|
52
53
|
}),
|
|
53
54
|
]);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
//# sourceMappingURL=
|
|
58
|
+
//# sourceMappingURL=startTypescriptTypeGeneration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/type-generation/startTypescriptTypeGeneration.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport fs from 'fs/promises';\nimport { Server } from 'metro';\nimport path from 'path';\n\nimport { upsertGitIgnoreContents, removeFromGitIgnore } from '../../../utils/mergeGitIgnorePaths';\nimport { ensureDotExpoProjectDirectoryInitialized } from '../../project/dotExpo';\nimport { ServerLike } from '../BundlerDevServer';\nimport { getRouterDirectory } from '../metro/router';\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\nconst debug = require('debug')('expo:typed-routes') as typeof console.log;\n\n/** Setup all requisite features for statically typed routes in Expo Router v2 / SDK +49. */\nexport async function startTypescriptTypeGenerationAsync({\n metro,\n projectRoot,\n server,\n}: TypeScriptTypeGenerationOptions) {\n const { exp } = getConfig(projectRoot);\n\n // If typed routes are disabled, remove any files that were added.\n if (!exp.experiments?.typedRoutes) {\n debug('Removing typed routes side-effects (experiments.typedRoutes: false)');\n const gitIgnorePath = path.join(projectRoot, '.gitignore');\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 debug(\n 'Ensuring typed routes side-effects are setup (experiments.typedRoutes: true, typesDirectory: %s)',\n typesDirectory\n );\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({\n metro,\n server,\n typesDirectory,\n projectRoot,\n routerDirectory: exp.extra?.router?.unstable_src ?? getRouterDirectory(projectRoot),\n }),\n ]);\n }\n}\n"],"names":["startTypescriptTypeGenerationAsync","debug","require","metro","projectRoot","server","exp","getConfig","experiments","typedRoutes","gitIgnorePath","path","join","Promise","all","forceRemovalTSConfig","removeExpoEnvDTS","removeFromGitIgnore","dotExpoDir","ensureDotExpoProjectDirectoryInitialized","typesDirectory","resolve","fs","mkdir","recursive","upsertGitIgnoreContents","writeExpoEnvDTS","forceUpdateTSConfig","setupTypedRoutes","routerDirectory","extra","router","unstable_src","getRouterDirectory"],"mappings":"AAAA;;;;QAsBsBA,kCAAkC,GAAlCA,kCAAkC;AAtB9B,IAAA,OAAc,WAAd,cAAc,CAAA;AACzB,IAAA,SAAa,kCAAb,aAAa,EAAA;AAEX,IAAA,KAAM,kCAAN,MAAM,EAAA;A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cAAc,GAAGT,KAAI,QAAA,CAACU,OAAO,CAACH,UAAU,EAAE,SAAS,CAAC,AAAC;QAC3DjB,KAAK,CACH,kGAAkG,EAClGmB,cAAc,CACf,CAAC;QAEF,qCAAqC;QACrC,MAAME,SAAE,QAAA,CAACC,KAAK,CAACH,cAAc,EAAE;YAAEI,SAAS,EAAE,IAAI;SAAE,CAAC,CAAC;YAW/BlB,IAA+B;QATpD,MAAMO,OAAO,CAACC,GAAG,CAAC;YAChBW,CAAAA,GAAAA,oBAAuB,AAAuD,CAAA,wBAAvD,CAACd,KAAI,QAAA,CAACC,IAAI,CAACR,WAAW,EAAE,YAAY,CAAC,EAAE,eAAe,CAAC;YAC9EsB,CAAAA,GAAAA,QAAe,AAAa,CAAA,gBAAb,CAACtB,WAAW,CAAC;YAC5BuB,CAAAA,GAAAA,SAAmB,AAAa,CAAA,oBAAb,CAACvB,WAAW,CAAC;YAChCwB,CAAAA,GAAAA,OAAgB,AAMd,CAAA,iBANc,CAAC;gBACfzB,KAAK;gBACLE,MAAM;gBACNe,cAAc;gBACdhB,WAAW;gBACXyB,eAAe,EAAEvB,CAAAA,IAA+B,GAA/BA,CAAAA,IAAS,GAATA,GAAG,CAACwB,KAAK,SAAQ,GAAjBxB,KAAAA,CAAiB,GAAjBA,QAAAA,IAAS,CAAEyB,MAAM,SAAA,GAAjBzB,KAAAA,CAAiB,QAAE0B,YAAY,AAAd,YAAjB1B,IAA+B,GAAI2B,CAAAA,GAAAA,OAAkB,AAAa,CAAA,mBAAb,CAAC7B,WAAW,CAAC;aACpF,CAAC;SACH,CAAC,CAAC;KACJ;CACF"}
|
|
@@ -57,6 +57,9 @@ class WebpackBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
57
57
|
get name() {
|
|
58
58
|
return "webpack";
|
|
59
59
|
}
|
|
60
|
+
async startTypeScriptServices() {
|
|
61
|
+
// noop -- this feature is Metro-only.
|
|
62
|
+
}
|
|
60
63
|
broadcastMessage(method, params) {
|
|
61
64
|
var ref;
|
|
62
65
|
if (!this.instance) {
|