@expo/cli 0.3.2 → 0.4.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/README.md +48 -10
- package/build/bin/cli +2 -2
- package/build/src/api/graphql/client.js +3 -1
- package/build/src/api/graphql/client.js.map +1 -1
- package/build/src/api/rest/client.js +5 -2
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/api/rest/wrapFetchWithProxy.js +25 -0
- package/build/src/api/rest/wrapFetchWithProxy.js.map +1 -0
- package/build/src/export/fork-bundleAsync.js +2 -1
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/install/resolveOptions.js +6 -2
- package/build/src/install/resolveOptions.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +6 -33
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +2 -2
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +1 -3
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +3 -46
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/ios/XcodeBuild.js +2 -1
- package/build/src/run/ios/XcodeBuild.js.map +1 -1
- package/build/src/run/ios/codeSigning/simulatorCodeSigning.js +45 -0
- package/build/src/run/ios/codeSigning/simulatorCodeSigning.js.map +1 -0
- package/build/src/start/doctor/ngrok/NgrokResolver.js +5 -0
- package/build/src/start/doctor/ngrok/NgrokResolver.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +6 -1
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/adbReverse.js +10 -0
- package/build/src/start/platforms/android/adbReverse.js.map +1 -1
- package/build/src/start/resolveOptions.js +1 -1
- package/build/src/start/resolveOptions.js.map +1 -1
- package/build/src/start/server/AsyncNgrok.js +58 -14
- package/build/src/start/server/AsyncNgrok.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +4 -1
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +20 -5
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +1 -6
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +36 -5
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +4 -2
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +7 -3
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/RuntimeRedirectMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/resolveEntryPoint.js +2 -1
- package/build/src/start/server/middleware/resolveEntryPoint.js.map +1 -1
- package/build/src/start/server/middleware/resolvePlatform.js +3 -2
- package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +2 -8
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/codesigning.js +3 -0
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/downloadAppAsync.js +1 -2
- package/build/src/utils/downloadAppAsync.js.map +1 -1
- package/build/src/utils/env.js +37 -1
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/npm.js +4 -11
- package/build/src/utils/npm.js.map +1 -1
- package/build/src/utils/url.js +2 -2
- package/build/src/utils/url.js.map +1 -1
- package/build/src/utils/validateApplicationId.js +3 -3
- package/build/src/utils/validateApplicationId.js.map +1 -1
- package/build/src/utils/variadic.js +18 -0
- package/build/src/utils/variadic.js.map +1 -1
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.ts"],"sourcesContent":["import { prependMiddleware } from '@expo/dev-server';\n\nimport { getFreePortAsync } from '../../../utils/port';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport { CreateFileMiddleware } from '../middleware/CreateFileMiddleware';\nimport { HistoryFallbackMiddleware } from '../middleware/HistoryFallbackMiddleware';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport { RuntimeRedirectMiddleware } from '../middleware/RuntimeRedirectMiddleware';\nimport { ServeStaticMiddleware } from '../middleware/ServeStaticMiddleware';\nimport { instantiateMetroAsync } from './instantiateMetro';\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 19000;\n\n/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */\nconst DEV_CLIENT_METRO_PORT = 8081;\n\nexport class MetroBundlerDevServer extends BundlerDevServer {\n get name(): string {\n return 'metro';\n }\n\n async resolvePortAsync(options: Partial<BundlerStartOptions> = {}): Promise<number> {\n const port =\n // If the manually defined port is busy then an error should be thrown...\n options.port ??\n // Otherwise use the default port based on the runtime target.\n (options.devClient\n ? // Don't check if the port is busy if we're using the dev client since most clients are hardcoded to 8081.\n Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT\n : // Otherwise (running in Expo Go) use a free port that falls back on the classic 19000 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n options.port = await this.resolvePortAsync(options);\n this.urlCreator = this.getUrlCreator(options);\n\n const parsedOptions = {\n port: options.port,\n maxWorkers: options.maxWorkers,\n resetCache: options.resetDevServer,\n\n // Use the unversioned metro config.\n // TODO: Deprecate this property when expo-cli goes away.\n unversioned: false,\n };\n\n const { server, middleware, messageSocket } = await instantiateMetroAsync(\n this.projectRoot,\n parsedOptions\n );\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // We need the manifest handler to be the first middleware to run so our\n // routes take precedence over static files. For example, the manifest is\n // served from '/' and if the user has an index.html file in their project\n // then the manifest handler will never run, the static middleware will run\n // and serve index.html instead of the manifest.\n // https://github.com/expo/expo/issues/13114\n prependMiddleware(middleware, manifestMiddleware);\n\n middleware.use(\n new InterstitialPageMiddleware(this.projectRoot, {\n // TODO: Prevent this from becoming stale.\n scheme: options.location.scheme ?? null,\n }).getHandler()\n );\n\n const deepLinkMiddleware = new RuntimeRedirectMiddleware(this.projectRoot, {\n onDeepLink: ({ runtime }) => {\n // eslint-disable-next-line no-useless-return\n if (runtime === 'expo') return;\n // TODO: Some heavy analytics...\n },\n getLocation: ({ runtime }) => {\n if (runtime === 'custom') {\n return this.urlCreator?.constructDevClientUrl();\n } else {\n return this.urlCreator?.constructUrl({\n scheme: 'exp',\n });\n }\n },\n });\n middleware.use(deepLinkMiddleware.getHandler());\n\n middleware.use(new CreateFileMiddleware(this.projectRoot).getHandler());\n\n // Append support for redirecting unhandled requests to the index.html page on web.\n if (this.isTargetingWeb()) {\n // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.\n middleware.use(new ServeStaticMiddleware(this.projectRoot).getHandler());\n\n // This MUST run last since it's the fallback.\n middleware.use(new HistoryFallbackMiddleware(manifestMiddleware.internal).getHandler());\n }\n // Extend the close method to ensure that we clean up the local info.\n const originalClose = server.close.bind(server);\n\n server.close = (callback?: (err?: Error) => void) => {\n return originalClose((err?: Error) => {\n this.instance = null;\n callback?.(err);\n });\n };\n\n return {\n server,\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware,\n messageSocket,\n };\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./metro.config.js', './metro.config.json', './rn-cli.config.js'];\n }\n}\n"],"names":["EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","MetroBundlerDevServer","BundlerDevServer","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","startImplementationAsync","urlCreator","getUrlCreator","parsedOptions","maxWorkers","resetCache","resetDevServer","unversioned","server","middleware","messageSocket","instantiateMetroAsync","projectRoot","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","use","InterstitialPageMiddleware","scheme","location","getHandler","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","runtime","getLocation","constructDevClientUrl","constructUrl","CreateFileMiddleware","isTargetingWeb","ServeStaticMiddleware","HistoryFallbackMiddleware","internal","originalClose","close","bind","callback","err","instance","host","url","protocol","getConfigModuleIds"],"mappings":"AAAA;;;;AAAkC,IAAA,UAAkB,WAAlB,kBAAkB,CAAA;AAEnB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACmB,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACzD,IAAA,qBAAoC,WAApC,oCAAoC,CAAA;AAC/B,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AACxC,IAAA,2BAA0C,WAA1C,0CAA0C,CAAA;AAC3C,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AAC7C,IAAA,sBAAqC,WAArC,qCAAqC,CAAA;AACrC,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAE1D,uDAAuD,CACvD,MAAMA,kBAAkB,GAAG,KAAK,AAAC;AAEjC,mGAAmG,CACnG,MAAMC,qBAAqB,GAAG,IAAI,AAAC;AAE5B,MAAMC,qBAAqB,SAASC,iBAAgB,iBAAA;IACzD,IAAIC,IAAI,GAAW;QACjB,OAAO,OAAO,CAAC;KAChB;IAED,MAAMC,gBAAgB,CAACC,OAAqC,GAAG,EAAE,EAAmB;YAEhF,yEAAyE;QACzEA,MAAY;QAFd,MAAMC,IAAI,GAERD,CAAAA,MAAY,GAAZA,OAAO,CAACC,IAAI,YAAZD,MAAY,GACZ,8DAA8D;QAC9D,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B,QAAQ,CAAC,CAACZ,UAAU,EAAE,CAAC,CAAC;SACzF;QACD,qEAAqE;QACrE,MAAMa,aAAa,GAAGzB,MAAM,CAAC0B,KAAK,CAACC,IAAI,CAAC3B,MAAM,CAAC,AAAC;QAEhDA,MAAM,CAAC0B,KAAK,GAAG,CAACE,QAAgC,GAAK;YACnD,OAAOH,aAAa,CAAC,CAACI,GAAW,GAAK;gBACpC,IAAI,CAACC,QAAQ,GAAG,IAAI,CAAC;gBACrBF,QAAQ,QAAO,GAAfA,KAAAA,CAAe,GAAfA,QAAQ,CAAGC,GAAG,CAAC,AA5GvB,CA4GwB;aACjB,CAAC,CAAC;SACJ,CAAC;QAEF,OAAO;YACL7B,MAAM;YACNW,QAAQ,EAAE;gBACR,mDAAmD;gBACnD1B,IAAI,EAAED,OAAO,CAACC,IAAI;gBAClB,kCAAkC;gBAClC8C,IAAI,EAAE,WAAW;gBACjB,iDAAiD;gBACjDC,GAAG,EAAE,CAAC,iBAAiB,EAAEhD,OAAO,CAACC,IAAI,CAAC,CAAC;gBACvCgD,QAAQ,EAAE,MAAM;aACjB;YACDhC,UAAU;YACVC,aAAa;SACd,CAAC;KACH;IAED,AAAUgC,kBAAkB,GAAa;QACvC,OAAO;YAAC,mBAAmB;YAAE,qBAAqB;YAAE,oBAAoB;SAAC,CAAC;KAC3E;CACF;QAlHYtD,qBAAqB,GAArBA,qBAAqB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { prependMiddleware } from '@expo/dev-server';\n\nimport getDevClientProperties from '../../../utils/analytics/getDevClientProperties';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { getFreePortAsync } from '../../../utils/port';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport { CreateFileMiddleware } from '../middleware/CreateFileMiddleware';\nimport { HistoryFallbackMiddleware } from '../middleware/HistoryFallbackMiddleware';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport {\n DeepLinkHandler,\n RuntimeRedirectMiddleware,\n} from '../middleware/RuntimeRedirectMiddleware';\nimport { ServeStaticMiddleware } from '../middleware/ServeStaticMiddleware';\nimport { instantiateMetroAsync } from './instantiateMetro';\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 19000;\n\n/** Default port to use for apps that run in standard React Native projects or Expo Dev Clients. */\nconst DEV_CLIENT_METRO_PORT = 8081;\n\nexport class MetroBundlerDevServer extends BundlerDevServer {\n get name(): string {\n return 'metro';\n }\n\n async resolvePortAsync(options: Partial<BundlerStartOptions> = {}): Promise<number> {\n const port =\n // If the manually defined port is busy then an error should be thrown...\n options.port ??\n // Otherwise use the default port based on the runtime target.\n (options.devClient\n ? // Don't check if the port is busy if we're using the dev client since most clients are hardcoded to 8081.\n Number(process.env.RCT_METRO_PORT) || DEV_CLIENT_METRO_PORT\n : // Otherwise (running in Expo Go) use a free port that falls back on the classic 19000 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n protected async startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance> {\n options.port = await this.resolvePortAsync(options);\n this.urlCreator = this.getUrlCreator(options);\n\n const parsedOptions = {\n port: options.port,\n maxWorkers: options.maxWorkers,\n resetCache: options.resetDevServer,\n\n // Use the unversioned metro config.\n // TODO: Deprecate this property when expo-cli goes away.\n unversioned: false,\n };\n\n const { server, middleware, messageSocket } = await instantiateMetroAsync(\n this.projectRoot,\n parsedOptions\n );\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // We need the manifest handler to be the first middleware to run so our\n // routes take precedence over static files. For example, the manifest is\n // served from '/' and if the user has an index.html file in their project\n // then the manifest handler will never run, the static middleware will run\n // and serve index.html instead of the manifest.\n // https://github.com/expo/expo/issues/13114\n prependMiddleware(middleware, manifestMiddleware);\n\n middleware.use(\n new InterstitialPageMiddleware(this.projectRoot, {\n // TODO: Prevent this from becoming stale.\n scheme: options.location.scheme ?? null,\n }).getHandler()\n );\n\n const deepLinkMiddleware = new RuntimeRedirectMiddleware(this.projectRoot, {\n onDeepLink: getDeepLinkHandler(this.projectRoot),\n getLocation: ({ runtime }) => {\n if (runtime === 'custom') {\n return this.urlCreator?.constructDevClientUrl();\n } else {\n return this.urlCreator?.constructUrl({\n scheme: 'exp',\n });\n }\n },\n });\n middleware.use(deepLinkMiddleware.getHandler());\n\n middleware.use(new CreateFileMiddleware(this.projectRoot).getHandler());\n\n // Append support for redirecting unhandled requests to the index.html page on web.\n if (this.isTargetingWeb()) {\n // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.\n middleware.use(new ServeStaticMiddleware(this.projectRoot).getHandler());\n\n // This MUST run last since it's the fallback.\n middleware.use(new HistoryFallbackMiddleware(manifestMiddleware.internal).getHandler());\n }\n // Extend the close method to ensure that we clean up the local info.\n const originalClose = server.close.bind(server);\n\n server.close = (callback?: (err?: Error) => void) => {\n return originalClose((err?: Error) => {\n this.instance = null;\n callback?.(err);\n });\n };\n\n return {\n server,\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware,\n messageSocket,\n };\n }\n\n protected getConfigModuleIds(): string[] {\n return ['./metro.config.js', './metro.config.json', './rn-cli.config.js'];\n }\n}\n\nexport function getDeepLinkHandler(projectRoot: string): DeepLinkHandler {\n return async ({ runtime }) => {\n if (runtime === 'expo') return;\n const { exp } = getConfig(projectRoot);\n await logEventAsync('dev client start command', {\n status: 'started',\n ...getDevClientProperties(projectRoot, exp),\n });\n };\n}\n"],"names":["getDeepLinkHandler","EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","MetroBundlerDevServer","BundlerDevServer","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","startImplementationAsync","urlCreator","getUrlCreator","parsedOptions","maxWorkers","resetCache","resetDevServer","unversioned","server","middleware","messageSocket","instantiateMetroAsync","projectRoot","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","use","InterstitialPageMiddleware","scheme","location","getHandler","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","getLocation","runtime","constructDevClientUrl","constructUrl","CreateFileMiddleware","isTargetingWeb","ServeStaticMiddleware","HistoryFallbackMiddleware","internal","originalClose","close","bind","callback","err","instance","host","url","protocol","getConfigModuleIds","exp","getConfig","logEventAsync","status","getDevClientProperties"],"mappings":"AAAA;;;;QAuIgBA,kBAAkB,GAAlBA,kBAAkB;AAvIR,IAAA,OAAc,WAAd,cAAc,CAAA;AACN,IAAA,UAAkB,WAAlB,kBAAkB,CAAA;AAEjB,IAAA,uBAAiD,kCAAjD,iDAAiD,EAAA;AACtD,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AACzC,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACmB,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACzD,IAAA,qBAAoC,WAApC,oCAAoC,CAAA;AAC/B,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AACxC,IAAA,2BAA0C,WAA1C,0CAA0C,CAAA;AAI9E,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AACV,IAAA,sBAAqC,WAArC,qCAAqC,CAAA;AACrC,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;;;;;;AAE1D,uDAAuD,CACvD,MAAMC,kBAAkB,GAAG,KAAK,AAAC;AAEjC,mGAAmG,CACnG,MAAMC,qBAAqB,GAAG,IAAI,AAAC;AAE5B,MAAMC,qBAAqB,SAASC,iBAAgB,iBAAA;IACzD,IAAIC,IAAI,GAAW;QACjB,OAAO,OAAO,CAAC;KAChB;IAED,MAAMC,gBAAgB,CAACC,OAAqC,GAAG,EAAE,EAAmB;YAEhF,yEAAyE;QACzEA,MAAY;QAFd,MAAMC,IAA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AAGC,CAAAA,GAAAA,uBAAsB,AAAkB,CAAA,QAAlB,CAACnC,WAAW,EAAE+B,GAAG,CAAC;SAC5C,CAAC,CAAC;KACJ,CAAC;CACH"}
|
|
@@ -9,7 +9,6 @@ var _createDevServerMiddleware = require("../middleware/createDevServerMiddlewar
|
|
|
9
9
|
var _platformBundlers = require("../platformBundlers");
|
|
10
10
|
var _metroTerminalReporter = require("./MetroTerminalReporter");
|
|
11
11
|
var _resolveFromProject = require("./resolveFromProject");
|
|
12
|
-
var _router = require("./router");
|
|
13
12
|
var _withMetroMultiPlatform = require("./withMetroMultiPlatform");
|
|
14
13
|
async function instantiateMetroAsync(projectRoot, options) {
|
|
15
14
|
let reportEvent;
|
|
@@ -35,11 +34,7 @@ async function instantiateMetroAsync(projectRoot, options) {
|
|
|
35
34
|
skipPlugins: true
|
|
36
35
|
});
|
|
37
36
|
const platformBundlers = (0, _platformBundlers).getPlatformBundlers(exp);
|
|
38
|
-
metroConfig = (0, _withMetroMultiPlatform).
|
|
39
|
-
// Auto pick App entry: this is injected with Babel.
|
|
40
|
-
process.env.EXPO_ROUTER_APP_ROOT = (0, _router).getAppRouterRelativeEntryPath(projectRoot);
|
|
41
|
-
var _EXPO_PROJECT_ROOT;
|
|
42
|
-
process.env.EXPO_PROJECT_ROOT = (_EXPO_PROJECT_ROOT = process.env.EXPO_PROJECT_ROOT) != null ? _EXPO_PROJECT_ROOT : projectRoot;
|
|
37
|
+
metroConfig = await (0, _withMetroMultiPlatform).withMetroMultiPlatformAsync(projectRoot, metroConfig, platformBundlers);
|
|
43
38
|
const { middleware , attachToServer , // New
|
|
44
39
|
websocketEndpoints , eventsSocketEndpoint , messageSocketEndpoint , } = (0, _createDevServerMiddleware).createDevServerMiddleware(projectRoot, {
|
|
45
40
|
port: metroConfig.server.port,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { MetroDevServerOptions } from '@expo/dev-server';\nimport http from 'http';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { createDevServerMiddleware } from '../middleware/createDevServerMiddleware';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { importExpoMetroConfigFromProject, importMetroFromProject } from './resolveFromProject';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/instantiateMetro.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { MetroDevServerOptions } from '@expo/dev-server';\nimport http from 'http';\nimport Metro from 'metro';\nimport { Terminal } from 'metro-core';\n\nimport { createDevServerMiddleware } from '../middleware/createDevServerMiddleware';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { MetroTerminalReporter } from './MetroTerminalReporter';\nimport { importExpoMetroConfigFromProject, importMetroFromProject } from './resolveFromProject';\nimport { withMetroMultiPlatformAsync } from './withMetroMultiPlatform';\n\n// From expo/dev-server but with ability to use custom logger.\ntype MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\n/** The most generic possible setup for Metro bundler. */\nexport async function instantiateMetroAsync(\n projectRoot: string,\n options: Omit<MetroDevServerOptions, 'logger'>\n): Promise<{\n server: http.Server;\n middleware: any;\n messageSocket: MessageSocket;\n}> {\n let reportEvent: ((event: any) => void) | undefined;\n\n const Metro = importMetroFromProject(projectRoot);\n const ExpoMetroConfig = importExpoMetroConfigFromProject(projectRoot);\n\n const terminal = new Terminal(process.stdout);\n const terminalReporter = new MetroTerminalReporter(projectRoot, terminal);\n\n const reporter = {\n update(event: any) {\n terminalReporter.update(event);\n if (reportEvent) {\n reportEvent(event);\n }\n },\n };\n\n let metroConfig = await ExpoMetroConfig.loadAsync(projectRoot, { reporter, ...options });\n\n // TODO: When we bring expo/metro-config into the expo/expo repo, then we can upstream this.\n const { exp } = getConfig(projectRoot, {\n skipSDKVersionRequirement: true,\n skipPlugins: true,\n });\n const platformBundlers = getPlatformBundlers(exp);\n metroConfig = await withMetroMultiPlatformAsync(projectRoot, metroConfig, platformBundlers);\n\n const {\n middleware,\n attachToServer,\n\n // New\n websocketEndpoints,\n eventsSocketEndpoint,\n messageSocketEndpoint,\n } = createDevServerMiddleware(projectRoot, {\n port: metroConfig.server.port,\n watchFolders: metroConfig.watchFolders,\n });\n\n const customEnhanceMiddleware = metroConfig.server.enhanceMiddleware;\n // @ts-ignore can't mutate readonly config\n metroConfig.server.enhanceMiddleware = (metroMiddleware: any, server: Metro.Server) => {\n if (customEnhanceMiddleware) {\n metroMiddleware = customEnhanceMiddleware(metroMiddleware, server);\n }\n return middleware.use(metroMiddleware);\n };\n\n const server = await Metro.runServer(metroConfig, {\n hmrEnabled: true,\n websocketEndpoints,\n });\n\n if (attachToServer) {\n // Expo SDK 44 and lower\n const { messageSocket, eventsSocket } = attachToServer(server);\n reportEvent = eventsSocket.reportEvent;\n\n return {\n server,\n middleware,\n messageSocket,\n };\n } else {\n // RN +68 -- Expo SDK +45\n reportEvent = eventsSocketEndpoint.reportEvent;\n\n return {\n server,\n middleware,\n messageSocket: messageSocketEndpoint,\n };\n }\n}\n"],"names":["instantiateMetroAsync","projectRoot","options","reportEvent","Metro","importMetroFromProject","ExpoMetroConfig","importExpoMetroConfigFromProject","terminal","Terminal","process","stdout","terminalReporter","MetroTerminalReporter","reporter","update","event","metroConfig","loadAsync","exp","getConfig","skipSDKVersionRequirement","skipPlugins","platformBundlers","getPlatformBundlers","withMetroMultiPlatformAsync","middleware","attachToServer","websocketEndpoints","eventsSocketEndpoint","messageSocketEndpoint","createDevServerMiddleware","port","server","watchFolders","customEnhanceMiddleware","enhanceMiddleware","metroMiddleware","use","runServer","hmrEnabled","messageSocket","eventsSocket"],"mappings":"AAAA;;;;QAkBsBA,qBAAqB,GAArBA,qBAAqB;AAlBjB,IAAA,OAAc,WAAd,cAAc,CAAA;AAIf,IAAA,UAAY,WAAZ,YAAY,CAAA;AAEK,IAAA,0BAAyC,WA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0B,oBAAoB,CAAC1B,WAAW,CAAC;QAE/C,OAAO;YACL8B,MAAM,EAANA,OAAM;YACNP,UAAU;YACVe,aAAa,EAAEX,qBAAqB;SACrC,CAAC;KACH;CACF"}
|
|
@@ -3,11 +3,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.withWebResolvers = withWebResolvers;
|
|
6
|
-
exports.
|
|
6
|
+
exports.withMetroMultiPlatformAsync = withMetroMultiPlatformAsync;
|
|
7
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
10
|
+
var _env = require("../../../utils/env");
|
|
11
|
+
var _webSupportProjectPrerequisite = require("../../doctor/web/WebSupportProjectPrerequisite");
|
|
10
12
|
var _resolveFromProject = require("./resolveFromProject");
|
|
13
|
+
var _router = require("./router");
|
|
11
14
|
function _interopRequireDefault(obj) {
|
|
12
15
|
return obj && obj.__esModule ? obj : {
|
|
13
16
|
default: obj
|
|
@@ -69,6 +72,16 @@ function withWebResolvers(config, projectRoot) {
|
|
|
69
72
|
"react-native": _path.default.resolve(require.resolve("react-native-web/package.json"), "..")
|
|
70
73
|
}
|
|
71
74
|
};
|
|
75
|
+
const preferredMainFields = {
|
|
76
|
+
// Defaults from Expo Webpack. Most packages using `react-native` don't support web
|
|
77
|
+
// in the `react-native` field, so we should prefer the `browser` field.
|
|
78
|
+
// https://github.com/expo/router/issues/37
|
|
79
|
+
web: [
|
|
80
|
+
"browser",
|
|
81
|
+
"module",
|
|
82
|
+
"main"
|
|
83
|
+
]
|
|
84
|
+
};
|
|
72
85
|
return withCustomResolvers(config, projectRoot, [
|
|
73
86
|
// Add a resolver to alias the web asset resolver.
|
|
74
87
|
(immutableContext, moduleName, platform)=>{
|
|
@@ -79,10 +92,19 @@ function withWebResolvers(config, projectRoot) {
|
|
|
79
92
|
if (platform && platform in extraNodeModules) {
|
|
80
93
|
context.extraNodeModules = extraNodeModules[platform];
|
|
81
94
|
}
|
|
95
|
+
const mainFields = _env.env.EXPO_METRO_NO_MAIN_FIELD_OVERRIDE ? context.mainFields : platform && platform in preferredMainFields ? preferredMainFields[platform] : context.mainFields;
|
|
82
96
|
const result = resolve({
|
|
83
97
|
...context,
|
|
84
98
|
preferNativePlatform: platform !== "web",
|
|
85
|
-
resolveRequest: undefined
|
|
99
|
+
resolveRequest: undefined,
|
|
100
|
+
// Passing `mainFields` directly won't be considered
|
|
101
|
+
// we need to extend the `getPackageMainPath` directly to
|
|
102
|
+
// use platform specific `mainFields`.
|
|
103
|
+
getPackageMainPath (packageJsonPath) {
|
|
104
|
+
// @ts-expect-error: mainFields is not on type
|
|
105
|
+
const package_ = context.moduleCache.getPackage(packageJsonPath);
|
|
106
|
+
return package_.getMain(mainFields);
|
|
107
|
+
}
|
|
86
108
|
}, moduleName, platform);
|
|
87
109
|
// Replace the web resolver with the original one.
|
|
88
110
|
// This is basically an alias for web-only.
|
|
@@ -94,11 +116,20 @@ function withWebResolvers(config, projectRoot) {
|
|
|
94
116
|
},
|
|
95
117
|
]);
|
|
96
118
|
}
|
|
97
|
-
function
|
|
98
|
-
//
|
|
99
|
-
|
|
119
|
+
async function withMetroMultiPlatformAsync(projectRoot, config, platformBundlers) {
|
|
120
|
+
// Auto pick App entry: this is injected with Babel.
|
|
121
|
+
process.env.EXPO_ROUTER_APP_ROOT = (0, _router).getAppRouterRelativeEntryPath(projectRoot);
|
|
122
|
+
var _EXPO_PROJECT_ROOT;
|
|
123
|
+
process.env.EXPO_PROJECT_ROOT = (_EXPO_PROJECT_ROOT = process.env.EXPO_PROJECT_ROOT) != null ? _EXPO_PROJECT_ROOT : projectRoot;
|
|
124
|
+
if (platformBundlers.web === "metro") {
|
|
125
|
+
await new _webSupportProjectPrerequisite.WebSupportProjectPrerequisite(projectRoot).assertAsync();
|
|
126
|
+
} else {
|
|
127
|
+
// Bail out early for performance enhancements if web is not enabled.
|
|
100
128
|
return config;
|
|
101
129
|
}
|
|
130
|
+
return withMetroMultiPlatform(projectRoot, config, platformBundlers);
|
|
131
|
+
}
|
|
132
|
+
function withMetroMultiPlatform(projectRoot, config, platformBundlers) {
|
|
102
133
|
let expoConfigPlatforms = Object.entries(platformBundlers).filter(([, bundler])=>bundler === "metro"
|
|
103
134
|
).map(([platform])=>platform
|
|
104
135
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/withMetroMultiPlatform.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport { ConfigT } from 'metro-config';\nimport { ResolutionContext } from 'metro-resolver';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { PlatformBundlers } from '../platformBundlers';\nimport { importMetroResolverFromProject } from './resolveFromProject';\n\nfunction withWebPolyfills(config: ConfigT): ConfigT {\n const originalGetPolyfills = config.serializer.getPolyfills\n ? config.serializer.getPolyfills.bind(config.serializer)\n : () => [];\n\n const getPolyfills = (ctx: { platform: string | null | undefined }): readonly string[] => {\n if (ctx.platform === 'web') {\n return [\n // TODO: runtime polyfills, i.e. Fast Refresh, error overlay, React Dev Tools...\n ];\n }\n // Generally uses `rn-get-polyfills`\n return originalGetPolyfills(ctx);\n };\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n getPolyfills,\n },\n };\n}\n\nfunction getDefaultResolveRequest(projectRoot: string) {\n const { resolve } = importMetroResolverFromProject(projectRoot);\n return (context: ResolutionContext, moduleName: string, platform: string | null) => {\n return resolve(context, moduleName, platform);\n };\n}\n\nexport type ExpoCustomMetroResolver = (\n ...args: Parameters<import('metro-resolver').CustomResolver>\n) => import('metro-resolver').Resolution | null;\n\n/** Extend the `resolver.resolveRequest` method with custom methods that can exit early by returning a `Resolution`. */\nfunction withCustomResolvers(\n config: ConfigT,\n projectRoot: string,\n resolvers: ExpoCustomMetroResolver[]\n): ConfigT {\n const originalResolveRequest =\n config.resolver.resolveRequest || getDefaultResolveRequest(projectRoot);\n\n return {\n ...config,\n resolver: {\n ...config.resolver,\n resolveRequest(...args: Parameters<import('metro-resolver').CustomResolver>) {\n for (const resolver of resolvers) {\n const resolution = resolver(...args);\n if (resolution) {\n return resolution;\n }\n }\n return originalResolveRequest(...args);\n },\n },\n };\n}\n\n/**\n * Apply custom resolvers to do the following:\n * - Disable `.native.js` extensions on web.\n * - Alias `react-native` to `react-native-web` on web.\n * - Redirect `react-native-web/dist/modules/AssetRegistry/index.js` to `@react-native/assets/registry.js` on web.\n */\nexport function withWebResolvers(config: ConfigT, projectRoot: string) {\n // Get the `transformer.assetRegistryPath`\n // this needs to be unified since you can't dynamically\n // swap out the transformer based on platform.\n const assetRegistryPath = fs.realpathSync(\n // This is the native asset registry alias for native.\n path.resolve(resolveFrom(projectRoot, 'react-native/Libraries/Image/AssetRegistry'))\n // NOTE(EvanBacon): This is the newer import but it doesn't work in the expo/expo monorepo.\n // path.resolve(resolveFrom(projectRoot, '@react-native/assets/registry.js'))\n );\n\n // Create a resolver which dynamically disables support for\n // `*.native.*` extensions on web.\n\n const { resolve } = importMetroResolverFromProject(projectRoot);\n\n const extraNodeModules: { [key: string]: Record<string, string> } = {\n web: {\n 'react-native': path.resolve(require.resolve('react-native-web/package.json'), '..'),\n },\n };\n\n return withCustomResolvers(config, projectRoot, [\n // Add a resolver to alias the web asset resolver.\n (immutableContext: ResolutionContext, moduleName: string, platform: string | null) => {\n const context = { ...immutableContext };\n\n // Conditionally remap `react-native` to `react-native-web`\n if (platform && platform in extraNodeModules) {\n context.extraNodeModules = extraNodeModules[platform];\n }\n\n const result = resolve(\n {\n ...context,\n preferNativePlatform: platform !== 'web',\n resolveRequest: undefined,\n },\n moduleName,\n platform\n );\n\n // Replace the web resolver with the original one.\n // This is basically an alias for web-only.\n if (\n platform === 'web' &&\n result?.type === 'sourceFile' &&\n typeof result?.filePath === 'string' &&\n result.filePath.endsWith('react-native-web/dist/modules/AssetRegistry/index.js')\n ) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = assetRegistryPath;\n }\n\n return result;\n },\n ]);\n}\n\n/** Add support for `react-native-web` and the Web platform. */\nexport function withMetroMultiPlatform(\n projectRoot: string,\n config: ConfigT,\n platformBundlers: PlatformBundlers\n) {\n // Bail out early for performance enhancements if web is not enabled.\n if (platformBundlers.web !== 'metro') {\n return config;\n }\n\n let expoConfigPlatforms = Object.entries(platformBundlers)\n .filter(([, bundler]) => bundler === 'metro')\n .map(([platform]) => platform);\n\n if (Array.isArray(config.resolver.platforms)) {\n expoConfigPlatforms = [...new Set(expoConfigPlatforms.concat(config.resolver.platforms))];\n }\n\n // @ts-expect-error: typed as `readonly`.\n config.resolver.platforms = expoConfigPlatforms;\n\n config = withWebPolyfills(config);\n\n return withWebResolvers(config, projectRoot);\n}\n"],"names":["withWebResolvers","withMetroMultiPlatform","withWebPolyfills","config","originalGetPolyfills","serializer","getPolyfills","bind","ctx","platform","getDefaultResolveRequest","projectRoot","resolve","importMetroResolverFromProject","context","moduleName","withCustomResolvers","resolvers","originalResolveRequest","resolver","resolveRequest","args","resolution","assetRegistryPath","fs","realpathSync","path","resolveFrom","extraNodeModules","web","require","immutableContext","result","preferNativePlatform","undefined","type","filePath","endsWith","platformBundlers","expoConfigPlatforms","Object","entries","filter","bundler","map","Array","isArray","platforms","Set","concat"],"mappings":"AAMA;;;;QA4EgBA,gBAAgB,GAAhBA,gBAAgB;QA4DhBC,sBAAsB,GAAtBA,sBAAsB;AAxIvB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAGF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAGS,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;;;;;;AAErE,SAASC,gBAAgB,CAACC,MAAe,EAAW;IAClD,MAAMC,oBAAoB,GAAGD,MAAM,CAAC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AAC;CAC9C"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/withMetroMultiPlatform.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport { ConfigT } from 'metro-config';\nimport { ResolutionContext } from 'metro-resolver';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { env } from '../../../utils/env';\nimport { WebSupportProjectPrerequisite } from '../../doctor/web/WebSupportProjectPrerequisite';\nimport { PlatformBundlers } from '../platformBundlers';\nimport { importMetroResolverFromProject } from './resolveFromProject';\nimport { getAppRouterRelativeEntryPath } from './router';\n\nfunction withWebPolyfills(config: ConfigT): ConfigT {\n const originalGetPolyfills = config.serializer.getPolyfills\n ? config.serializer.getPolyfills.bind(config.serializer)\n : () => [];\n\n const getPolyfills = (ctx: { platform: string | null | undefined }): readonly string[] => {\n if (ctx.platform === 'web') {\n return [\n // TODO: runtime polyfills, i.e. Fast Refresh, error overlay, React Dev Tools...\n ];\n }\n // Generally uses `rn-get-polyfills`\n return originalGetPolyfills(ctx);\n };\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n getPolyfills,\n },\n };\n}\n\nfunction getDefaultResolveRequest(projectRoot: string) {\n const { resolve } = importMetroResolverFromProject(projectRoot);\n return (context: ResolutionContext, moduleName: string, platform: string | null) => {\n return resolve(context, moduleName, platform);\n };\n}\n\nexport type ExpoCustomMetroResolver = (\n ...args: Parameters<import('metro-resolver').CustomResolver>\n) => import('metro-resolver').Resolution | null;\n\n/** Extend the `resolver.resolveRequest` method with custom methods that can exit early by returning a `Resolution`. */\nfunction withCustomResolvers(\n config: ConfigT,\n projectRoot: string,\n resolvers: ExpoCustomMetroResolver[]\n): ConfigT {\n const originalResolveRequest =\n config.resolver.resolveRequest || getDefaultResolveRequest(projectRoot);\n\n return {\n ...config,\n resolver: {\n ...config.resolver,\n resolveRequest(...args: Parameters<import('metro-resolver').CustomResolver>) {\n for (const resolver of resolvers) {\n const resolution = resolver(...args);\n if (resolution) {\n return resolution;\n }\n }\n return originalResolveRequest(...args);\n },\n },\n };\n}\n\n/**\n * Apply custom resolvers to do the following:\n * - Disable `.native.js` extensions on web.\n * - Alias `react-native` to `react-native-web` on web.\n * - Redirect `react-native-web/dist/modules/AssetRegistry/index.js` to `@react-native/assets/registry.js` on web.\n */\nexport function withWebResolvers(config: ConfigT, projectRoot: string) {\n // Get the `transformer.assetRegistryPath`\n // this needs to be unified since you can't dynamically\n // swap out the transformer based on platform.\n const assetRegistryPath = fs.realpathSync(\n // This is the native asset registry alias for native.\n path.resolve(resolveFrom(projectRoot, 'react-native/Libraries/Image/AssetRegistry'))\n // NOTE(EvanBacon): This is the newer import but it doesn't work in the expo/expo monorepo.\n // path.resolve(resolveFrom(projectRoot, '@react-native/assets/registry.js'))\n );\n\n // Create a resolver which dynamically disables support for\n // `*.native.*` extensions on web.\n\n const { resolve } = importMetroResolverFromProject(projectRoot);\n\n const extraNodeModules: { [key: string]: Record<string, string> } = {\n web: {\n 'react-native': path.resolve(require.resolve('react-native-web/package.json'), '..'),\n },\n };\n\n const preferredMainFields: { [key: string]: string[] } = {\n // Defaults from Expo Webpack. Most packages using `react-native` don't support web\n // in the `react-native` field, so we should prefer the `browser` field.\n // https://github.com/expo/router/issues/37\n web: ['browser', 'module', 'main'],\n };\n\n return withCustomResolvers(config, projectRoot, [\n // Add a resolver to alias the web asset resolver.\n (immutableContext: ResolutionContext, moduleName: string, platform: string | null) => {\n const context = { ...immutableContext } as ResolutionContext & { mainFields: string[] };\n\n // Conditionally remap `react-native` to `react-native-web`\n if (platform && platform in extraNodeModules) {\n context.extraNodeModules = extraNodeModules[platform];\n }\n\n const mainFields = env.EXPO_METRO_NO_MAIN_FIELD_OVERRIDE\n ? context.mainFields\n : platform && platform in preferredMainFields\n ? preferredMainFields[platform]\n : context.mainFields;\n\n const result = resolve(\n {\n ...context,\n preferNativePlatform: platform !== 'web',\n resolveRequest: undefined,\n\n // Passing `mainFields` directly won't be considered\n // we need to extend the `getPackageMainPath` directly to\n // use platform specific `mainFields`.\n getPackageMainPath(packageJsonPath) {\n // @ts-expect-error: mainFields is not on type\n const package_ = context.moduleCache.getPackage(packageJsonPath);\n return package_.getMain(mainFields);\n },\n },\n moduleName,\n platform\n );\n\n // Replace the web resolver with the original one.\n // This is basically an alias for web-only.\n if (\n platform === 'web' &&\n result?.type === 'sourceFile' &&\n typeof result?.filePath === 'string' &&\n result.filePath.endsWith('react-native-web/dist/modules/AssetRegistry/index.js')\n ) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = assetRegistryPath;\n }\n\n return result;\n },\n ]);\n}\n\n/** Add support for `react-native-web` and the Web platform. */\nexport async function withMetroMultiPlatformAsync(\n projectRoot: string,\n config: ConfigT,\n platformBundlers: PlatformBundlers\n) {\n // Auto pick App entry: this is injected with Babel.\n process.env.EXPO_ROUTER_APP_ROOT = getAppRouterRelativeEntryPath(projectRoot);\n process.env.EXPO_PROJECT_ROOT = process.env.EXPO_PROJECT_ROOT ?? projectRoot;\n\n if (platformBundlers.web === 'metro') {\n await new WebSupportProjectPrerequisite(projectRoot).assertAsync();\n } else {\n // Bail out early for performance enhancements if web is not enabled.\n return config;\n }\n\n return withMetroMultiPlatform(projectRoot, config, platformBundlers);\n}\n\nfunction withMetroMultiPlatform(\n projectRoot: string,\n config: ConfigT,\n platformBundlers: PlatformBundlers\n) {\n let expoConfigPlatforms = Object.entries(platformBundlers)\n .filter(([, bundler]) => bundler === 'metro')\n .map(([platform]) => platform);\n\n if (Array.isArray(config.resolver.platforms)) {\n expoConfigPlatforms = [...new Set(expoConfigPlatforms.concat(config.resolver.platforms))];\n }\n\n // @ts-expect-error: typed as `readonly`.\n config.resolver.platforms = expoConfigPlatforms;\n\n config = withWebPolyfills(config);\n\n return withWebResolvers(config, projectRoot);\n}\n"],"names":["withWebResolvers","withMetroMultiPlatformAsync","withWebPolyfills","config","originalGetPolyfills","serializer","getPolyfills","bind","ctx","platform","getDefaultResolveRequest","projectRoot","resolve","importMetroResolverFromProject","context","moduleName","withCustomResolvers","resolvers","originalResolveRequest","resolver","resolveRequest","args","resolution","assetRegistryPath","fs","realpathSync","path","resolveFrom","extraNodeModules","web","require","preferredMainFields","immutableContext","mainFields","env","EXPO_METRO_NO_MAIN_FIELD_OVERRIDE","result","preferNativePlatform","undefined","getPackageMainPath","packageJsonPath","package_","moduleCache","getPackage","getMain","type","filePath","endsWith","platformBundlers","process","EXPO_ROUTER_APP_ROOT","getAppRouterRelativeEntryPath","EXPO_PROJECT_ROOT","WebSupportProjectPrerequisite","assertAsync","withMetroMultiPlatform","expoConfigPlatforms","Object","entries","filter","bundler","map","Array","isArray","platforms","Set","concat"],"mappings":"AAMA;;;;QA+EgBA,gBAAgB,GAAhBA,gBAAgB;QAkFVC,2BAA2B,GAA3BA,2BAA2B;AAjKlC,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAGF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAElB,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACM,IAAA,8BAAgD,WAAhD,gDAAgD,CAAA;AAE/C,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACvB,IAAA,OAAU,WAAV,UAAU,CAAA;;;;;;AAExD,SAASC,gBAAgB,CAACC,MAAe,EAAW;IAClD,MAAMC,oBAAoB,GAAGD,MAAM,CAACE,UAAU,CAACC,YAAY,GACvDH,MAAM,CAACE,UAAU,CAACC,YAAY,CAACC,IAAI,CAACJ,MAAM,CAACE,UAAU,CAAC,GACtD,IAAM,EAAE;IAAC;IAEb,MAAMC,YAAY,GAAG,CAACE,GAA4C,GAAwB;QACxF,IAAIA,GAAG,CAACC,QAAQ,KAAK,KAAK,EAAE;YAC1B,OAAO,EAEN,CAAC;SACH;QACD,oCAAoC;QACpC,OAAOL,oBAAoB,CAACI,GAAG,CAAC,CAAC;KAClC,AAAC;I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OnD,MAAM,CAAC;KACf;IAED,OAAOoD,sBAAsB,CAAC5C,WAAW,EAAER,MAAM,EAAE6C,gBAAgB,CAAC,CAAC;CACtE;AAED,SAASO,sBAAsB,CAC7B5C,WAAmB,EACnBR,MAAe,EACf6C,gBAAkC,EAClC;IACA,IAAIQ,mBAAmB,GAAGC,MAAM,CAACC,OAAO,CAACV,gBAAgB,CAAC,CACvDW,MAAM,CAAC,CAAC,GAAGC,OAAO,CAAC,GAAKA,OAAO,KAAK,OAAO;IAAA,CAAC,CAC5CC,GAAG,CAAC,CAAC,CAACpD,QAAQ,CAAC,GAAKA,QAAQ;IAAA,CAAC,AAAC;IAEjC,IAAIqD,KAAK,CAACC,OAAO,CAAC5D,MAAM,CAACgB,QAAQ,CAAC6C,SAAS,CAAC,EAAE;QAC5CR,mBAAmB,GAAG;eAAI,IAAIS,GAAG,CAACT,mBAAmB,CAACU,MAAM,CAAC/D,MAAM,CAACgB,QAAQ,CAAC6C,SAAS,CAAC,CAAC;SAAC,CAAC;KAC3F;IAED,yCAAyC;IACzC7D,MAAM,CAACgB,QAAQ,CAAC6C,SAAS,GAAGR,mBAAmB,CAAC;IAEhDrD,MAAM,GAAGD,gBAAgB,CAACC,MAAM,CAAC,CAAC;IAElC,OAAOH,gBAAgB,CAACG,MAAM,EAAEQ,WAAW,CAAC,CAAC;CAC9C"}
|
|
@@ -41,6 +41,7 @@ function _interopRequireWildcard(obj) {
|
|
|
41
41
|
return newObj;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
const debug = require("debug")("expo:start:server:middleware:ClassicManifestMiddleware");
|
|
44
45
|
class ClassicManifestMiddleware extends _manifestMiddleware.ManifestMiddleware {
|
|
45
46
|
getParsedHeaders(req) {
|
|
46
47
|
const platform = (0, _resolvePlatform).parsePlatformHeader(req) || "ios";
|
|
@@ -99,7 +100,8 @@ class ClassicManifestMiddleware extends _manifestMiddleware.ManifestMiddleware {
|
|
|
99
100
|
try {
|
|
100
101
|
return await this._getManifestStringAsync(props);
|
|
101
102
|
} catch (error) {
|
|
102
|
-
|
|
103
|
+
debug(`Error getting manifest:`, error);
|
|
104
|
+
if (error.code === "UNAUTHORIZED" && props.manifest.owner) {
|
|
103
105
|
// Don't have permissions for siging, warn and enable offline mode.
|
|
104
106
|
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"));
|
|
105
107
|
_settings.APISettings.isOffline = true;
|
|
@@ -128,7 +130,7 @@ async function createHostInfoAsync() {
|
|
|
128
130
|
host: await _userSettings.default.getAnonymousIdentifierAsync(),
|
|
129
131
|
server: "expo",
|
|
130
132
|
// Defined in the build step
|
|
131
|
-
serverVersion: "0.
|
|
133
|
+
serverVersion: "0.4.0",
|
|
132
134
|
serverDriver: _manifestMiddleware.DEVELOPER_TOOL,
|
|
133
135
|
serverOS: _os.default.platform(),
|
|
134
136
|
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\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: Boolean(req.headers['exponent-accept-signature']),\n hostname: stripPort(req.headers['host']),\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', 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 if (error.code === 'UNAUTHORIZED_ERROR' && 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","ClassicManifestMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertRuntimePlatform","acceptSignature","Boolean","headers","hostname","stripPort","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","manifest","hostInfo","createHostInfoAsync","Map","set","body","_fetchComputedManifestStringAsync","hostId","host","version","sdkVersion","trackManifest","logEventAsync","_getManifestStringAsync","currentSession","getUserAsync","APISettings","isOffline","id","ANONYMOUS_USERNAME","slug","JSON","stringify","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,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;AAClD,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;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWvE,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,QA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D,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,EAAE9B,IAAI,CAACC,SAAS,CAACtB,QAAQ,CAAC;QACxCoD,SAAS,EAAE,UAAU;KACtB,AAAC;IACF,OAAO/B,IAAI,CAACC,SAAS,CAAC4B,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 { 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\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: Boolean(req.headers['exponent-accept-signature']),\n hostname: stripPort(req.headers['host']),\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', 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","Boolean","headers","hostname","stripPort","_getManifestResponseAsync","requestOptions","exp","hostUri","expoGoConfig","bundleUrl","_resolveProjectSettingsAsync","manifest","hostInfo","createHostInfoAsync","Map","set","body","_fetchComputedManifestStringAsync","hostId","host","version","sdkVersion","trackManifest","logEventAsync","_getManifestStringAsync","currentSession","getUserAsync","APISettings","isOffline","id","ANONYMOUS_USERNAME","slug","JSON","stringify","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,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;AAClD,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;;;;;;;;;;;;;;;;;;;;;;;;;;;AAW9E,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,EAAEC,OAAO,CAACL,GAAG,CAACM,OAAO,CAAC,2BAA2B,CAAC,CAAC;YAClEC,QAAQ,EAAEC,CAAAA,GAAAA,IAAS,AAAqB,CAAA,UAArB,CAACR,GAAG,CAACM,OAAO,CAA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BAAgB,GAAG;QACvBC,cAAc,EAAE9B,IAAI,CAACC,SAAS,CAACtB,QAAQ,CAAC;QACxCoD,SAAS,EAAE,UAAU;KACtB,AAAC;IACF,OAAO/B,IAAI,CAACC,SAAS,CAAC4B,gBAAgB,CAAC,CAAC;CACzC"}
|
|
@@ -25,10 +25,14 @@ function _interopRequireDefault(obj) {
|
|
|
25
25
|
default: obj
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
const debug = require("debug")("expo:start:server:middleware:ExpoGoManifestHandlerMiddleware");
|
|
28
29
|
class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddleware {
|
|
29
30
|
getParsedHeaders(req) {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
let platform = (0, _resolvePlatform).parsePlatformHeader(req);
|
|
32
|
+
if (!platform) {
|
|
33
|
+
debug(`No "expo-platform" header or "platform" query parameter specified. Falling back to "none".`);
|
|
34
|
+
platform = "none";
|
|
35
|
+
}
|
|
32
36
|
(0, _resolvePlatform).assertRuntimePlatform(platform);
|
|
33
37
|
// Expo Updates clients explicitly accept "multipart/mixed" responses while browsers implicitly
|
|
34
38
|
// accept them with "accept: */*". To make it easier to debug manifest responses by visiting their
|
|
@@ -112,7 +116,7 @@ class ExpoGoManifestHandlerMiddleware extends _manifestMiddleware.ManifestMiddle
|
|
|
112
116
|
const signature = (0, _codesigning).signManifestString(stringifiedManifest, codeSigningInfo);
|
|
113
117
|
manifestPartHeaders = {
|
|
114
118
|
"expo-signature": (0, _structuredHeaders).serializeDictionary(convertToDictionaryItemsRepresentation({
|
|
115
|
-
keyid:
|
|
119
|
+
keyid: codeSigningInfo.keyId,
|
|
116
120
|
sig: signature,
|
|
117
121
|
alg: "rsa-v1_5-sha256"
|
|
118
122
|
}))
|
|
@@ -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 FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\nimport { v4 as uuidv4 } from 'uuid';\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 {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n} from './resolvePlatform';\nimport { ServerHeaders, ServerRequest } from './server.types';\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 const platform = parsePlatformHeader(req);\n assertMissingRuntimePlatform(platform);\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: !!req.headers['expo-accept-signature'],\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: uuidv4(),\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: 'expo-go',\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":["ExpoGoManifestHandlerMiddleware","ManifestMiddleware","getParsedHeaders","req","platform","parsePlatformHeader","assertMissingRuntimePlatform","assertRuntimePlatform","accept","accepts","explicitlyPrefersMultipartMixed","types","expectSignature","headers","acceptSignature","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","uuidv4","createdAt","Date","toISOString","launchAsset","key","contentType","url","assets","metadata","undefined","expoClient","expoGo","manifestSignature","getSignedManifestStringAsync","stringifiedManifest","JSON","stringify","manifestPartHeaders","certificateChainBody","signature","signManifestString","serializeDictionary","convertToDictionaryItemsRepresentation","keyid","sig","alg","certificateChainForResponse","join","form","getFormData","getBoundary","body","getBuffer","toString","version","FormData","append","header","length","trackManifest","logEventAsync","memoize","signExpoGoManifestAsync","APISettings","isOffline","getUserAsync","project","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9C,4BAA4B,GAAG6C,CAAAA,GAAAA,GAAO,AAA8B,CAAA,QAA9B,CAAC7C,4BAA4B,CAAC,CAAC;CAC9E;QA9KYlD,+BAA+B,GAA/BA,+BAA+B;AAgL5C;;;;;GAKG,CACH,eAAe0C,+BAA+B,CAC5CL,YAAuC,EACvCJ,eAAuC,EACrB;IAClB,IAAI,CAACI,YAAY,IAAK4D,SAAW,YAAA,CAACC,SAAS,IAAIjE,eAAe,KAAK,IAAI,AAAC,EAAE;QACxE,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CAAE,MAAMkE,CAAAA,GAAAA,KAAY,AAAE,CAAA,aAAF,EAAE,AAAC,CAAC;CAChC;AAED,eAAejD,4BAA4B,CAACV,SAAiB,EAAmB;IAC9E,MAAM4D,OAAO,GAAG,MAAMC,CAAAA,GAAAA,WAAe,AAAW,CAAA,gBAAX,CAAC7D,SAAS,CAAC,AAAC;IACjD,OAAO4D,OAAO,CAACrD,QAAQ,CAAC;CACzB;AAED,SAAS6B,sCAAsC,CAAC0B,GAA8B,EAAc;IAC1F,OAAO,IAAInF,GAAG,CACZoF,MAAM,CAACC,OAAO,CAACF,GAAG,CAAC,CAACG,GAAG,CAAC,CAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAK;QAClC,OAAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAIxF,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 assert from 'assert';\nimport FormData from 'form-data';\nimport { serializeDictionary, Dictionary } from 'structured-headers';\nimport { v4 as uuidv4 } from 'uuid';\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: !!req.headers['expo-accept-signature'],\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: uuidv4(),\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","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","uuidv4","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;A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;IAExE,AAAQ/C,4BAA4B,GAAG8C,CAAAA,GAAAA,GAAO,AAA8B,CAAA,QAA9B,CAAC9C,4BAA4B,CAAC,CAAC;CAC9E;QArLYjD,+BAA+B,GAA/BA,+BAA+B;AAuL5C;;;;;GAKG,CACH,eAAeyC,+BAA+B,CAC5CL,YAAuC,EACvCJ,eAAuC,EACrB;IAClB,IAAI,CAACI,YAAY,IAAK6D,SAAW,YAAA,CAACC,SAAS,IAAIlE,eAAe,KAAK,IAAI,AAAC,EAAE;QACxE,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CAAE,MAAMmE,CAAAA,GAAAA,KAAY,AAAE,CAAA,aAAF,EAAE,AAAC,CAAC;CAChC;AAED,eAAelD,4BAA4B,CAACV,SAAiB,EAAmB;IAC9E,MAAM6D,OAAO,GAAG,MAAMC,CAAAA,GAAAA,WAAe,AAAW,CAAA,gBAAX,CAAC9D,SAAS,CAAC,AAAC;IACjD,OAAO6D,OAAO,CAACtD,QAAQ,CAAC;CACzB;AAED,SAAS6B,sCAAsC,CAAC2B,GAA8B,EAAc;IAC1F,OAAO,IAAIpF,GAAG,CACZqF,MAAM,CAACC,OAAO,CAACF,GAAG,CAAC,CAACG,GAAG,CAAC,CAAC,CAACC,CAAC,EAAEC,CAAC,CAAC,GAAK;QAClC,OAAO;YAACD,CAAC;YAAE;gBAACC,CAAC;gBAAE,IAAIzF,GAAG,EAAE;aAAC;SAAC,CAAC;KAC5B,CAAC,CACH,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/RuntimeRedirectMiddleware.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport * as Log from '../../../log';\nimport { disableResponseCache, ExpoMiddleware } from './ExpoMiddleware';\nimport {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n resolvePlatformFromUserAgentHeader,\n RuntimePlatform,\n} from './resolvePlatform';\nimport { ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:runtimeRedirect'\n) as typeof console.log;\n\n/** Runtime to target: expo = Expo Go, custom = Dev Client. */\ntype RuntimeTarget = 'expo' | 'custom';\n\nexport class RuntimeRedirectMiddleware extends ExpoMiddleware {\n constructor(\n protected projectRoot: string,\n protected options: {\n onDeepLink:
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/RuntimeRedirectMiddleware.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport * as Log from '../../../log';\nimport { disableResponseCache, ExpoMiddleware } from './ExpoMiddleware';\nimport {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n resolvePlatformFromUserAgentHeader,\n RuntimePlatform,\n} from './resolvePlatform';\nimport { ServerRequest, ServerResponse } from './server.types';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:runtimeRedirect'\n) as typeof console.log;\n\n/** Runtime to target: expo = Expo Go, custom = Dev Client. */\ntype RuntimeTarget = 'expo' | 'custom';\n\nexport type DeepLinkHandler = (props: {\n runtime: RuntimeTarget;\n platform: RuntimePlatform;\n}) => void | Promise<void>;\n\nexport class RuntimeRedirectMiddleware extends ExpoMiddleware {\n constructor(\n protected projectRoot: string,\n protected options: {\n onDeepLink: DeepLinkHandler;\n getLocation: (props: { runtime: RuntimeTarget }) => string | null | undefined;\n }\n ) {\n super(projectRoot, ['/_expo/link']);\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n const { query } = parse(req.url!, true);\n const isDevClient = query['choice'] === 'expo-dev-client';\n const platform = parsePlatformHeader(req) ?? resolvePlatformFromUserAgentHeader(req);\n assertMissingRuntimePlatform(platform);\n assertRuntimePlatform(platform);\n const runtime = isDevClient ? 'custom' : 'expo';\n\n debug(`props:`, { platform, runtime });\n\n this.options.onDeepLink({ runtime, platform });\n\n const redirect = this.options.getLocation({ runtime });\n if (!redirect) {\n Log.warn(\n `[redirect middleware]: Unable to determine redirect location for runtime '${runtime}' and platform '${platform}'`\n );\n res.statusCode = 404;\n res.end();\n return;\n }\n debug('Redirect ->', redirect);\n res.setHeader('Location', redirect);\n\n // Disable caching\n disableResponseCache(res);\n\n // 'Temporary Redirect'\n res.statusCode = 307;\n res.end();\n }\n}\n"],"names":["Log","debug","require","RuntimeRedirectMiddleware","ExpoMiddleware","constructor","projectRoot","options","handleRequestAsync","req","res","query","parse","url","isDevClient","parsePlatformHeader","platform","resolvePlatformFromUserAgentHeader","assertMissingRuntimePlatform","assertRuntimePlatform","runtime","onDeepLink","redirect","getLocation","warn","statusCode","end","setHeader","disableResponseCache"],"mappings":"AAAA;;;;AAAsB,IAAA,IAAK,WAAL,KAAK,CAAA;AAEfA,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACsC,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAOhE,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;;;;;;;;;;;;;;;;;;;;;;AAG1B,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,8CAA8C,CAC/C,AAAsB,AAAC;AAUjB,MAAMC,yBAAyB,SAASC,eAAc,eAAA;IAC3DC,YACYC,WAAmB,EACnBC,OAGT,CACD;QACA,KAAK,CAACD,WAAW,EAAE;YAAC,aAAa;SAAC,CAAC,CAAC;aAN1BA,WAAmB,GAAnBA,WAAmB;aACnBC,OAGT,GAHSA,OAGT;KAGF;IAED,MAAMC,kBAAkB,CAACC,GAAkB,EAAEC,GAAmB,EAAiB;QAC/E,MAAM,EAAEC,KAAK,CAAA,EAAE,GAAGC,CAAAA,GAAAA,IAAK,AAAgB,CAAA,MAAhB,CAACH,GAAG,CAACI,GAAG,EAAG,IAAI,CAAC,AAAC;QACxC,MAAMC,WAAW,GAAGH,KAAK,CAAC,QAAQ,CAAC,KAAK,iBAAiB,AAAC;YACzCI,GAAwB;QAAzC,MAAMC,QAAQ,GAAGD,CAAAA,GAAwB,GAAxBA,CAAAA,GAAAA,gBAAmB,AAAK,CAA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_interopRequireDefault(obj) {
|
|
|
15
15
|
const supportedPlatforms = [
|
|
16
16
|
"ios",
|
|
17
17
|
"android",
|
|
18
|
-
"web"
|
|
18
|
+
"web",
|
|
19
|
+
"none"
|
|
19
20
|
];
|
|
20
21
|
function resolveEntryPoint(projectRoot, platform, projectConfig) {
|
|
21
22
|
if (platform && !supportedPlatforms.includes(platform)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/resolveEntryPoint.ts"],"sourcesContent":["import { ProjectConfig } from '@expo/config';\nimport { getEntryPoint } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport path from 'path';\n\nimport { CommandError } from '../../../utils/errors';\n\nconst supportedPlatforms = ['ios', 'android', 'web'];\n\n/** Returns the relative entry file for the project. */\nexport function resolveEntryPoint(\n projectRoot: string,\n platform?: string,\n projectConfig?: ProjectConfig\n): string {\n if (platform && !supportedPlatforms.includes(platform)) {\n throw new CommandError(\n `Failed to resolve the project's entry file: The platform \"${platform}\" is not supported.`\n );\n }\n // TODO(Bacon): support platform extension resolution like .ios, .native\n // const platforms = [platform, 'native'].filter(Boolean) as string[];\n const platforms: string[] = [];\n\n const entry = getEntryPoint(projectRoot, ['./index'], platforms, projectConfig);\n if (!entry) {\n // NOTE(Bacon): I purposefully don't mention all possible resolutions here since the package.json is the most standard and users should opt towards that.\n throw new CommandError(\n chalk`The project entry file could not be resolved. Please define it in the {bold package.json} \"main\" field.`\n );\n }\n\n return path.relative(projectRoot, entry);\n}\n"],"names":["resolveEntryPoint","supportedPlatforms","projectRoot","platform","projectConfig","includes","CommandError","platforms","entry","getEntryPoint","chalk","path","relative"],"mappings":"AAAA;;;;QAUgBA,iBAAiB,GAAjBA,iBAAiB;AATH,IAAA,MAAoB,WAApB,oBAAoB,CAAA;AAChC,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEM,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;;;;;;AAEpD,MAAMC,kBAAkB,GAAG;IAAC,KAAK;IAAE,SAAS;IAAE,KAAK;CAAC,AAAC;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/resolveEntryPoint.ts"],"sourcesContent":["import { ProjectConfig } from '@expo/config';\nimport { getEntryPoint } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport path from 'path';\n\nimport { CommandError } from '../../../utils/errors';\n\nconst supportedPlatforms = ['ios', 'android', 'web', 'none'];\n\n/** Returns the relative entry file for the project. */\nexport function resolveEntryPoint(\n projectRoot: string,\n platform?: string,\n projectConfig?: ProjectConfig\n): string {\n if (platform && !supportedPlatforms.includes(platform)) {\n throw new CommandError(\n `Failed to resolve the project's entry file: The platform \"${platform}\" is not supported.`\n );\n }\n // TODO(Bacon): support platform extension resolution like .ios, .native\n // const platforms = [platform, 'native'].filter(Boolean) as string[];\n const platforms: string[] = [];\n\n const entry = getEntryPoint(projectRoot, ['./index'], platforms, projectConfig);\n if (!entry) {\n // NOTE(Bacon): I purposefully don't mention all possible resolutions here since the package.json is the most standard and users should opt towards that.\n throw new CommandError(\n chalk`The project entry file could not be resolved. Please define it in the {bold package.json} \"main\" field.`\n );\n }\n\n return path.relative(projectRoot, entry);\n}\n"],"names":["resolveEntryPoint","supportedPlatforms","projectRoot","platform","projectConfig","includes","CommandError","platforms","entry","getEntryPoint","chalk","path","relative"],"mappings":"AAAA;;;;QAUgBA,iBAAiB,GAAjBA,iBAAiB;AATH,IAAA,MAAoB,WAApB,oBAAoB,CAAA;AAChC,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEM,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;;;;;;AAEpD,MAAMC,kBAAkB,GAAG;IAAC,KAAK;IAAE,SAAS;IAAE,KAAK;IAAE,MAAM;CAAC,AAAC;AAGtD,SAASD,iBAAiB,CAC/BE,WAAmB,EACnBC,QAAiB,EACjBC,aAA6B,EACrB;IACR,IAAID,QAAQ,IAAI,CAACF,kBAAkB,CAACI,QAAQ,CAACF,QAAQ,CAAC,EAAE;QACtD,MAAM,IAAIG,OAAY,aAAA,CACpB,CAAC,0DAA0D,EAAEH,QAAQ,CAAC,mBAAmB,CAAC,CAC3F,CAAC;KACH;IACD,wEAAwE;IACxE,sEAAsE;IACtE,MAAMI,SAAS,GAAa,EAAE,AAAC;IAE/B,MAAMC,KAAK,GAAGC,CAAAA,GAAAA,MAAa,AAAoD,CAAA,cAApD,CAACP,WAAW,EAAE;QAAC,SAAS;KAAC,EAAEK,SAAS,EAAEH,aAAa,CAAC,AAAC;IAChF,IAAI,CAACI,KAAK,EAAE;QACV,yJAAyJ;QACzJ,MAAM,IAAIF,OAAY,aAAA,CACpBI,MAAK,QAAA,CAAC,uGAAuG,CAAC,CAC/G,CAAC;KACH;IAED,OAAOC,KAAI,QAAA,CAACC,QAAQ,CAACV,WAAW,EAAEM,KAAK,CAAC,CAAC;CAC1C"}
|
|
@@ -37,9 +37,10 @@ function assertRuntimePlatform(platform) {
|
|
|
37
37
|
const stringifiedPlatform = String(platform);
|
|
38
38
|
if (![
|
|
39
39
|
"android",
|
|
40
|
-
"ios"
|
|
40
|
+
"ios",
|
|
41
|
+
"none"
|
|
41
42
|
].includes(stringifiedPlatform)) {
|
|
42
|
-
throw new _errors.CommandError("PLATFORM_HEADER", `platform must be "android" or "
|
|
43
|
+
throw new _errors.CommandError("PLATFORM_HEADER", `platform must be "android", "ios", or "none". Received: "${platform}"`);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/resolvePlatform.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport { CommandError } from '../../../utils/errors';\nimport { ServerRequest } from './server.types';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:resolvePlatform'\n) as typeof console.log;\n\n/** Supported platforms */\nexport type RuntimePlatform = 'ios' | 'android';\n\n/**\n * Extract the runtime platform from the server request.\n * 1. Query param `platform`: `?platform=ios`\n * 2. Header `expo-platform`: `'expo-platform': ios`\n * 3. Legacy header `exponent-platform`: `'exponent-platform': ios`\n *\n * Returns first item in the case of an array.\n */\nexport function parsePlatformHeader(req: ServerRequest): string | null {\n const url = parse(req.url!, /* parseQueryString */ true);\n const platform =\n url.query?.platform || req.headers['expo-platform'] || req.headers['exponent-platform'];\n return (Array.isArray(platform) ? platform[0] : platform) ?? null;\n}\n\n/** Guess the platform from the user-agent header. */\nexport function resolvePlatformFromUserAgentHeader(req: ServerRequest): string | null {\n let platform = null;\n const userAgent = req.headers['user-agent'];\n if (userAgent?.match(/Android/i)) {\n platform = 'android';\n }\n if (userAgent?.match(/iPhone|iPad/i)) {\n platform = 'ios';\n }\n debug(`Resolved platform ${platform} from user-agent header: ${userAgent}`);\n return platform;\n}\n\n/** Assert if the runtime platform is not included. */\nexport function assertMissingRuntimePlatform(platform?: any): asserts platform {\n if (!platform) {\n throw new CommandError(\n 'PLATFORM_HEADER',\n `Must specify \"expo-platform\" header or \"platform\" query parameter`\n );\n }\n}\n\n/** Assert if the runtime platform is not correct. */\nexport function assertRuntimePlatform(platform: string): asserts platform is RuntimePlatform {\n const stringifiedPlatform = String(platform);\n if (!['android', 'ios'].includes(stringifiedPlatform)) {\n throw new CommandError(\n 'PLATFORM_HEADER',\n `platform must be \"android\" or \"
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/resolvePlatform.ts"],"sourcesContent":["import { parse } from 'url';\n\nimport { CommandError } from '../../../utils/errors';\nimport { ServerRequest } from './server.types';\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:resolvePlatform'\n) as typeof console.log;\n\n/** Supported platforms */\nexport type RuntimePlatform = 'ios' | 'android';\n\n/**\n * Extract the runtime platform from the server request.\n * 1. Query param `platform`: `?platform=ios`\n * 2. Header `expo-platform`: `'expo-platform': ios`\n * 3. Legacy header `exponent-platform`: `'exponent-platform': ios`\n *\n * Returns first item in the case of an array.\n */\nexport function parsePlatformHeader(req: ServerRequest): string | null {\n const url = parse(req.url!, /* parseQueryString */ true);\n const platform =\n url.query?.platform || req.headers['expo-platform'] || req.headers['exponent-platform'];\n return (Array.isArray(platform) ? platform[0] : platform) ?? null;\n}\n\n/** Guess the platform from the user-agent header. */\nexport function resolvePlatformFromUserAgentHeader(req: ServerRequest): string | null {\n let platform = null;\n const userAgent = req.headers['user-agent'];\n if (userAgent?.match(/Android/i)) {\n platform = 'android';\n }\n if (userAgent?.match(/iPhone|iPad/i)) {\n platform = 'ios';\n }\n debug(`Resolved platform ${platform} from user-agent header: ${userAgent}`);\n return platform;\n}\n\n/** Assert if the runtime platform is not included. */\nexport function assertMissingRuntimePlatform(platform?: any): asserts platform {\n if (!platform) {\n throw new CommandError(\n 'PLATFORM_HEADER',\n `Must specify \"expo-platform\" header or \"platform\" query parameter`\n );\n }\n}\n\n/** Assert if the runtime platform is not correct. */\nexport function assertRuntimePlatform(platform: string): asserts platform is RuntimePlatform {\n const stringifiedPlatform = String(platform);\n if (!['android', 'ios', 'none'].includes(stringifiedPlatform)) {\n throw new CommandError(\n 'PLATFORM_HEADER',\n `platform must be \"android\", \"ios\", or \"none\". Received: \"${platform}\"`\n );\n }\n}\n"],"names":["parsePlatformHeader","resolvePlatformFromUserAgentHeader","assertMissingRuntimePlatform","assertRuntimePlatform","debug","require","req","url","parse","platform","query","headers","Array","isArray","userAgent","match","CommandError","stringifiedPlatform","String","includes"],"mappings":"AAAA;;;;QAoBgBA,mBAAmB,GAAnBA,mBAAmB;QAQnBC,kCAAkC,GAAlCA,kCAAkC;QAclCC,4BAA4B,GAA5BA,4BAA4B;QAU5BC,qBAAqB,GAArBA,qBAAqB;AApDf,IAAA,IAAK,WAAL,KAAK,CAAA;AAEE,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AAGpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAC5B,8CAA8C,CAC/C,AAAsB,AAAC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BAAiB,EACjB,CAAC,iEAAiE,CAAC,CACpE,CAAC;KACH;CACF;AAGM,SAASb,qBAAqB,CAACM,QAAgB,EAAuC;IAC3F,MAAMQ,mBAAmB,GAAGC,MAAM,CAACT,QAAQ,CAAC,AAAC;IAC7C,IAAI,CAAC;QAAC,SAAS;QAAE,KAAK;QAAE,MAAM;KAAC,CAACU,QAAQ,CAACF,mBAAmB,CAAC,EAAE;QAC7D,MAAM,IAAID,OAAY,aAAA,CACpB,iBAAiB,EACjB,CAAC,yDAAyD,EAAEP,QAAQ,CAAC,CAAC,CAAC,CACxE,CAAC;KACH;CACF"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.getProjectWebpackConfigFilePath = getProjectWebpackConfigFilePath;
|
|
6
|
-
var _symbolicateMiddleware = require("@expo/dev-server/build/webpack/symbolicateMiddleware");
|
|
7
6
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
8
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
8
|
var path = _interopRequireWildcard(require("path"));
|
|
@@ -102,7 +101,7 @@ class WebpackBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
102
101
|
"android"
|
|
103
102
|
].includes(process.env.EXPO_WEBPACK_PLATFORM || "");
|
|
104
103
|
}
|
|
105
|
-
async createNativeDevServerMiddleware({ port ,
|
|
104
|
+
async createNativeDevServerMiddleware({ port , options }) {
|
|
106
105
|
if (!this.isTargetingNative()) {
|
|
107
106
|
return null;
|
|
108
107
|
}
|
|
@@ -118,11 +117,7 @@ class WebpackBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
118
117
|
// Add manifest middleware to the other middleware.
|
|
119
118
|
// TODO: Move this in to expo/dev-server.
|
|
120
119
|
const middleware = await this.getManifestMiddlewareAsync(options);
|
|
121
|
-
nativeMiddleware.middleware.use(middleware)
|
|
122
|
-
projectRoot: this.projectRoot,
|
|
123
|
-
compiler,
|
|
124
|
-
logger: nativeMiddleware.logger
|
|
125
|
-
}));
|
|
120
|
+
nativeMiddleware.middleware.use(middleware);
|
|
126
121
|
return nativeMiddleware;
|
|
127
122
|
}
|
|
128
123
|
async getAvailablePortAsync(options) {
|
|
@@ -216,7 +211,6 @@ class WebpackBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
216
211
|
// Create the middleware required for interacting with a native runtime (Expo Go, or a development build).
|
|
217
212
|
nativeMiddleware = await this.createNativeDevServerMiddleware({
|
|
218
213
|
port,
|
|
219
|
-
compiler: compiler1,
|
|
220
214
|
options
|
|
221
215
|
});
|
|
222
216
|
// Inject the native manifest middleware.
|