@expo/cli 0.18.18 → 0.18.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/export/exportApp.js +6 -3
  3. package/build/src/export/exportApp.js.map +1 -1
  4. package/build/src/export/exportStaticAsync.js +3 -2
  5. package/build/src/export/exportStaticAsync.js.map +1 -1
  6. package/build/src/export/favicon.js +5 -4
  7. package/build/src/export/favicon.js.map +1 -1
  8. package/build/src/start/server/BundlerDevServer.js +1 -1
  9. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  10. package/build/src/start/server/DevServerManager.js +6 -3
  11. package/build/src/start/server/DevServerManager.js.map +1 -1
  12. package/build/src/start/server/DevelopmentSession.js +21 -11
  13. package/build/src/start/server/DevelopmentSession.js.map +1 -1
  14. package/build/src/start/server/metro/MetroBundlerDevServer.js +85 -82
  15. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  16. package/build/src/start/server/metro/instantiateMetro.js +25 -25
  17. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  18. package/build/src/start/server/metro/runServer-fork.js +3 -1
  19. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  20. package/build/src/start/server/metro/withMetroMultiPlatform.js +13 -4
  21. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  22. package/build/src/start/server/middleware/ManifestMiddleware.js +1 -1
  23. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  24. package/build/src/start/server/middleware/metroOptions.js +5 -1
  25. package/build/src/start/server/middleware/metroOptions.js.map +1 -1
  26. package/build/src/utils/telemetry/getContext.js +1 -1
  27. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { getPlatformBundlers } from './platformBundlers';\nimport { Log } from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { env } from '../../utils/env';\nimport { logEventAsync } from '../../utils/telemetry';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport { TypeScriptProjectPrerequisite } from '../doctor/typescript/TypeScriptProjectPrerequisite';\nimport { printItem } from '../interface/commandsTable';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { resolveSchemeAsync } from '../resolveOptions';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst devServers: BundlerDevServer[] = [];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n static async startMetroAsync(projectRoot: string, startOptions: BundlerStartOptions) {\n const devServerManager = new DevServerManager(projectRoot, startOptions);\n\n await devServerManager.startAsync([\n {\n type: 'metro',\n options: startOptions,\n },\n ]);\n return devServerManager;\n }\n\n private projectPrerequisites: ProjectPrerequisite<any, void>[] = [];\n public readonly devtoolsPluginManager: DevToolsPluginManager;\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n if (!options.isExporting) {\n this.notifier = this.watchBabelConfig();\n }\n this.devtoolsPluginManager = new DevToolsPluginManager(projectRoot);\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite<any, any>) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n return await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(this.projectRoot, exp).web;\n debug(`Starting ${bundler} dev server for web`);\n return this.startAsync([\n {\n type: bundler,\n options: this.options,\n },\n ]);\n }\n\n /** Switch between Expo Go and Expo Dev Clients. */\n async toggleRuntimeMode(isUsingDevClient: boolean = !this.options.devClient): Promise<boolean> {\n const nextMode = isUsingDevClient ? '--dev-client' : '--go';\n Log.log(printItem(chalk`Switching to {bold ${nextMode}}`));\n\n const nextScheme = await resolveSchemeAsync(this.projectRoot, {\n devClient: isUsingDevClient,\n // NOTE: The custom `--scheme` argument is lost from this point on.\n });\n\n this.options.location.scheme = nextScheme;\n this.options.devClient = isUsingDevClient;\n for (const devServer of devServers) {\n devServer.isDevClient = isUsingDevClient;\n const urlCreator = devServer.getUrlCreator();\n urlCreator.defaults ??= {};\n urlCreator.defaults.scheme = nextScheme;\n }\n\n debug(`New runtime options (runtime: ${nextMode}):`, this.options);\n return true;\n }\n\n /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n\n await logEventAsync('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\n\n const platformBundlers = getPlatformBundlers(this.projectRoot, exp);\n\n // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(this.projectRoot, platformBundlers, {\n devToolsPluginManager: this.devtoolsPluginManager,\n isDevClient: !!options?.devClient,\n });\n await server.startAsync(options ?? this.options);\n devServers.push(server);\n }\n\n return exp;\n }\n\n async bootstrapTypeScriptAsync() {\n const typescriptPrerequisite = await this.ensureProjectPrerequisiteAsync(\n TypeScriptProjectPrerequisite\n );\n\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n return;\n }\n\n // Optionally, wait for the user to add TypeScript during the\n // development cycle.\n const server = devServers.find((server) => server.name === 'metro');\n if (!server) {\n return;\n }\n\n // The dev server shouldn't wait for the typescript services\n if (!typescriptPrerequisite) {\n server.waitForTypeScriptAsync().then(async (success) => {\n if (success) {\n server.startTypeScriptServices();\n }\n });\n } else {\n server.startTypeScriptServices();\n }\n }\n\n async watchEnvironmentVariables() {\n await devServers.find((server) => server.name === 'metro')?.watchEnvironmentVariables();\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n this.notifier?.stopObserving(),\n // Stop all dev servers\n ...devServers.map((server) => server.stopAsync()),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n ]);\n }\n}\n"],"names":["DevServerManager","urlCreator","debug","require","devServers","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","startMetroAsync","projectRoot","startOptions","devServerManager","startAsync","type","options","constructor","projectPrerequisites","notifier","isExporting","watchBabelConfig","devtoolsPluginManager","DevToolsPluginManager","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","toggleRuntimeMode","isUsingDevClient","devClient","nextMode","Log","log","printItem","nextScheme","resolveSchemeAsync","scheme","devServer","isDevClient","getUrlCreator","defaults","logEventAsync","sdkVersion","platformBundlers","BundlerDevServerClass","devToolsPluginManager","bootstrapTypeScriptAsync","typescriptPrerequisite","TypeScriptProjectPrerequisite","env","EXPO_NO_TYPESCRIPT_SETUP","name","waitForTypeScriptAsync","then","success","startTypeScriptServices","watchEnvironmentVariables","stopAsync","Promise","allSettled","stopObserving","map","AndroidDebugBridge","getServer"],"mappings":"AAAA;;;;+BAoCaA,kBAAgB;;aAAhBA,gBAAgB;;;yBApCS,cAAc;;;;;;;8DACjC,QAAQ;;;;;;;8DACT,OAAO;;;;;;4EAGS,yBAAyB;kCACvB,oBAAoB;qBACpC,WAAW;8BACF,0BAA0B;qBACnC,iBAAiB;2BACP,uBAAuB;+CAEP,oDAAoD;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I,KAAK,OAAO,CAAC,AAAC;QACpE,IAAI,CAAC5C,MAAM,EAAE;YACX,OAAO;QACT,CAAC;QAED,4DAA4D;QAC5D,IAAI,CAACwC,sBAAsB,EAAE;YAC3BxC,MAAM,CAAC6C,sBAAsB,EAAE,CAACC,IAAI,CAAC,OAAOC,OAAO,GAAK;gBACtD,IAAIA,OAAO,EAAE;oBACX/C,MAAM,CAACgD,uBAAuB,EAAE,CAAC;gBACnC,CAAC;YACH,CAAC,CAAC,CAAC;QACL,OAAO;YACLhD,MAAM,CAACgD,uBAAuB,EAAE,CAAC;QACnC,CAAC;IACH;UAEMC,yBAAyB,GAAG;YAC1BnF,GAAoD;QAA1D,OAAMA,CAAAA,GAAoD,GAApDA,UAAU,CAAC2B,IAAI,CAAC,CAACO,MAAM,GAAKA,MAAM,CAAC4C,IAAI,KAAK,OAAO,CAAC,SAA2B,GAA/E9E,KAAAA,CAA+E,GAA/EA,GAAoD,CAAEmF,yBAAyB,EAAE,CAAA,CAAC;IAC1F;IAEA,oCAAoC,SAC9BC,SAAS,GAAkB;YAE7B,GAAa;QADf,MAAMC,OAAO,CAACC,UAAU,CAAC;YACvB,CAAA,GAAa,GAAb,IAAI,CAACvE,QAAQ,SAAe,GAA5B,KAAA,CAA4B,GAA5B,GAAa,CAAEwE,aAAa,EAAE;YAC9B,uBAAuB;eACpBvF,UAAU,CAACwF,GAAG,CAAC,CAACtD,MAAM,GAAKA,MAAM,CAACkD,SAAS,EAAE,CAAC;YACjD,WAAW;YACXK,IAAkB,CAACC,SAAS,EAAE,CAACN,SAAS,EAAE;SAC3C,CAAC,CAAC;IACL;CACD"}
1
+ {"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { getPlatformBundlers } from './platformBundlers';\nimport { Log } from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { env } from '../../utils/env';\nimport { logEventAsync } from '../../utils/telemetry';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport { TypeScriptProjectPrerequisite } from '../doctor/typescript/TypeScriptProjectPrerequisite';\nimport { printItem } from '../interface/commandsTable';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { resolveSchemeAsync } from '../resolveOptions';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst devServers: BundlerDevServer[] = [];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n static async startMetroAsync(projectRoot: string, startOptions: BundlerStartOptions) {\n const devServerManager = new DevServerManager(projectRoot, startOptions);\n\n await devServerManager.startAsync([\n {\n type: 'metro',\n options: startOptions,\n },\n ]);\n return devServerManager;\n }\n\n private projectPrerequisites: ProjectPrerequisite<any, void>[] = [];\n public readonly devtoolsPluginManager: DevToolsPluginManager;\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n if (!options.isExporting) {\n this.notifier = this.watchBabelConfig();\n }\n this.devtoolsPluginManager = new DevToolsPluginManager(projectRoot);\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite<any, any>) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n return await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(this.projectRoot, exp).web;\n debug(`Starting ${bundler} dev server for web`);\n return this.startAsync([\n {\n type: bundler,\n options: this.options,\n },\n ]);\n }\n\n /** Switch between Expo Go and Expo Dev Clients. */\n async toggleRuntimeMode(isUsingDevClient: boolean = !this.options.devClient): Promise<boolean> {\n const nextMode = isUsingDevClient ? '--dev-client' : '--go';\n Log.log(printItem(chalk`Switching to {bold ${nextMode}}`));\n\n const nextScheme = await resolveSchemeAsync(this.projectRoot, {\n devClient: isUsingDevClient,\n // NOTE: The custom `--scheme` argument is lost from this point on.\n });\n\n this.options.location.scheme = nextScheme;\n this.options.devClient = isUsingDevClient;\n for (const devServer of devServers) {\n devServer.isDevClient = isUsingDevClient;\n const urlCreator = devServer.getUrlCreator();\n urlCreator.defaults ??= {};\n urlCreator.defaults.scheme = nextScheme;\n }\n\n debug(`New runtime options (runtime: ${nextMode}):`, this.options);\n return true;\n }\n\n /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n\n await logEventAsync('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\n\n const platformBundlers = getPlatformBundlers(this.projectRoot, exp);\n\n // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(this.projectRoot, platformBundlers, {\n devToolsPluginManager: this.devtoolsPluginManager,\n isDevClient: !!options?.devClient,\n });\n await server.startAsync(options ?? this.options);\n devServers.push(server);\n }\n\n return exp;\n }\n\n async bootstrapTypeScriptAsync() {\n const typescriptPrerequisite = await this.ensureProjectPrerequisiteAsync(\n TypeScriptProjectPrerequisite\n );\n\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n return;\n }\n\n // Optionally, wait for the user to add TypeScript during the\n // development cycle.\n const server = devServers.find((server) => server.name === 'metro');\n if (!server) {\n return;\n }\n\n // The dev server shouldn't wait for the typescript services\n if (!typescriptPrerequisite) {\n server.waitForTypeScriptAsync().then(async (success) => {\n if (success) {\n server.startTypeScriptServices();\n }\n });\n } else {\n server.startTypeScriptServices();\n }\n }\n\n async watchEnvironmentVariables() {\n await devServers.find((server) => server.name === 'metro')?.watchEnvironmentVariables();\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n this.notifier?.stopObserving(),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n // Stop all dev servers\n ...devServers.map((server) =>\n server.stopAsync().catch((error) => {\n Log.error(`Failed to stop dev server (bundler: ${server.name})`);\n Log.exception(error);\n })\n ),\n ]);\n }\n}\n"],"names":["DevServerManager","urlCreator","debug","require","devServers","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","startMetroAsync","projectRoot","startOptions","devServerManager","startAsync","type","options","constructor","projectPrerequisites","notifier","isExporting","watchBabelConfig","devtoolsPluginManager","DevToolsPluginManager","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","toggleRuntimeMode","isUsingDevClient","devClient","nextMode","Log","log","printItem","nextScheme","resolveSchemeAsync","scheme","devServer","isDevClient","getUrlCreator","defaults","logEventAsync","sdkVersion","platformBundlers","BundlerDevServerClass","devToolsPluginManager","bootstrapTypeScriptAsync","typescriptPrerequisite","TypeScriptProjectPrerequisite","env","EXPO_NO_TYPESCRIPT_SETUP","name","waitForTypeScriptAsync","then","success","startTypeScriptServices","watchEnvironmentVariables","stopAsync","Promise","allSettled","stopObserving","AndroidDebugBridge","getServer","map","catch","error","exception"],"mappings":"AAAA;;;;+BAoCaA,kBAAgB;;aAAhBA,gBAAgB;;;yBApCS,cAAc;;;;;;;8DACjC,QAAQ;;;;;;;8DACT,OAAO;;;;;;4EAGS,yBAAyB;kCACvB,oBAAoB;qBACpC,WAAW;8BACF,0BAA0B;qBACnC,iBAAiB;2BACP,uBAAuB;+CAEP,oDAA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CACD"}
@@ -79,8 +79,8 @@ class DevelopmentSession {
79
79
  * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.
80
80
  */ async startAsync({ exp =(0, _config().getConfig)(this.projectRoot).exp , runtime }) {
81
81
  try {
82
- if (_env.env.EXPO_OFFLINE) {
83
- debug("This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.");
82
+ if (_env.env.CI || _env.env.EXPO_OFFLINE) {
83
+ debug(_env.env.CI ? "This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in CI." : "This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.");
84
84
  this.stopNotifying();
85
85
  return;
86
86
  }
@@ -120,17 +120,27 @@ class DevelopmentSession {
120
120
  }
121
121
  this.timeout = null;
122
122
  }
123
- async closeAsync() {
123
+ /** Try to close any pending development sessions, but always resolve */ async closeAsync() {
124
124
  this.stopNotifying();
125
- const deviceIds = await this.getDeviceInstallationIdsAsync();
126
- if (!await isAuthenticatedAsync() && !(deviceIds == null ? void 0 : deviceIds.length)) {
127
- return;
125
+ if (_env.env.CI || _env.env.EXPO_OFFLINE) {
126
+ return false;
128
127
  }
129
- if (this.url) {
130
- await (0, _updateDevelopmentSession.closeDevelopmentSessionAsync)({
131
- url: this.url,
132
- deviceIds
133
- });
128
+ try {
129
+ const deviceIds = await this.getDeviceInstallationIdsAsync();
130
+ if (!await isAuthenticatedAsync() && !(deviceIds == null ? void 0 : deviceIds.length)) {
131
+ return false;
132
+ }
133
+ if (this.url) {
134
+ await (0, _updateDevelopmentSession.closeDevelopmentSessionAsync)({
135
+ url: this.url,
136
+ deviceIds
137
+ });
138
+ }
139
+ return true;
140
+ } catch (error) {
141
+ debug(`Error closing development session API: ${error}`);
142
+ this.onError(error);
143
+ return false;
134
144
  }
135
145
  }
136
146
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport { env } from '../../utils/env';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nconst UPDATE_FREQUENCY = 20 * 1000; // 20 seconds\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n protected timeout: NodeJS.Timeout | null = null;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null,\n /** Catch any errors that may occur during the `startAsync` method. */\n private onError: (error: Error) => void\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * This method starts an interval that will continue to ping the servers until we stop it.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n try {\n if (env.EXPO_OFFLINE) {\n debug(\n 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.'\n );\n this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n // debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n }\n\n this.stopNotifying();\n\n this.timeout = setTimeout(() => this.startAsync({ exp, runtime }), UPDATE_FREQUENCY);\n } catch (error: any) {\n debug(`Error updating development session API: ${error}`);\n this.stopNotifying();\n this.onError(error);\n }\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Stop notifying the Expo servers that the development session is running. */\n public stopNotifying() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = null;\n }\n\n public async closeAsync(): Promise<void> {\n this.stopNotifying();\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n return;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n }\n}\n"],"names":["DevelopmentSession","debug","require","UPDATE_FREQUENCY","isAuthenticatedAsync","getUserAsync","catch","constructor","projectRoot","url","onError","timeout","startAsync","exp","getConfig","runtime","env","EXPO_OFFLINE","stopNotifying","deviceIds","getDeviceInstallationIdsAsync","length","updateDevelopmentSessionAsync","setTimeout","error","devices","ProjectDevices","getDevicesInfoAsync","map","installationId","clearTimeout","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;+BAkBaA,oBAAkB;;aAAlBA,kBAAkB;;;yBAlBO,cAAc;;;;;;0CAK7C,oCAAoC;sBACd,qBAAqB;qBAC9B,iBAAiB;+DACL,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAE7F,MAAMC,gBAAgB,GAAG,EAAE,GAAG,IAAI,AAAC,EAAC,aAAa;AAEjD,eAAeC,oBAAoB,GAAqB;IACtD,OAAO,CAAC,CAAE,MAAMC,IAAAA,KAAY,aAAA,GAAE,CAACC,KAAK,CAAC,IAAM,IA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gB,CAAC,CAAC;QACvF,EAAE,OAAOqB,KAAK,EAAO;YACnBvB,KAAK,CAAC,CAAC,wCAAwC,EAAEuB,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1D,IAAI,CAACN,aAAa,EAAE,CAAC;YACrB,IAAI,CAACR,OAAO,CAACc,KAAK,CAAC,CAAC;QACtB,CAAC;IACH;IAEA,4CAA4C,SAC9BJ,6BAA6B,GAAsB;QAC/D,MAAM,EAAEK,OAAO,CAAA,EAAE,GAAG,MAAMC,QAAc,CAACC,mBAAmB,CAAC,IAAI,CAACnB,WAAW,CAAC,AAAC;QAC/E,OAAOiB,OAAO,CAACG,GAAG,CAAC,CAAC,EAAEC,cAAc,CAAA,EAAE,GAAKA,cAAc,CAAC,CAAC;IAC7D;IAEA,6EAA6E,GACtEX,aAAa,GAAG;QACrB,IAAI,IAAI,CAACP,OAAO,EAAE;YAChBmB,YAAY,CAAC,IAAI,CAACnB,OAAO,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,CAACA,OAAO,GAAG,IAAI,CAAC;IACtB;UAEaoB,UAAU,GAAkB;QACvC,IAAI,CAACb,aAAa,EAAE,CAAC;QAErB,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACC,6BAA6B,EAAE,AAAC;QAE7D,IAAI,CAAE,MAAMhB,oBAAoB,EAAE,AAAC,IAAI,CAACe,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEE,MAAM,CAAA,EAAE;YACzD,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAACZ,GAAG,EAAE;YACZ,MAAMuB,IAAAA,yBAA4B,6BAAA,EAAC;gBACjCvB,GAAG,EAAE,IAAI,CAACA,GAAG;gBACbU,SAAS;aACV,CAAC,CAAC;QACL,CAAC;IACH;CACD"}
1
+ {"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport { env } from '../../utils/env';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nconst UPDATE_FREQUENCY = 20 * 1000; // 20 seconds\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n protected timeout: NodeJS.Timeout | null = null;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null,\n /** Catch any errors that may occur during the `startAsync` method. */\n private onError: (error: Error) => void\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * This method starts an interval that will continue to ping the servers until we stop it.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n try {\n if (env.CI || env.EXPO_OFFLINE) {\n debug(\n env.CI\n ? 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in CI.'\n : 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.'\n );\n this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n // debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n }\n\n this.stopNotifying();\n\n this.timeout = setTimeout(() => this.startAsync({ exp, runtime }), UPDATE_FREQUENCY);\n } catch (error: any) {\n debug(`Error updating development session API: ${error}`);\n this.stopNotifying();\n this.onError(error);\n }\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Stop notifying the Expo servers that the development session is running. */\n public stopNotifying() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = null;\n }\n\n /** Try to close any pending development sessions, but always resolve */\n public async closeAsync(): Promise<boolean> {\n this.stopNotifying();\n\n if (env.CI || env.EXPO_OFFLINE) {\n return false;\n }\n\n try {\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n return false;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n\n return true;\n } catch (error: any) {\n debug(`Error closing development session API: ${error}`);\n this.onError(error);\n return false;\n }\n }\n}\n"],"names":["DevelopmentSession","debug","require","UPDATE_FREQUENCY","isAuthenticatedAsync","getUserAsync","catch","constructor","projectRoot","url","onError","timeout","startAsync","exp","getConfig","runtime","env","CI","EXPO_OFFLINE","stopNotifying","deviceIds","getDeviceInstallationIdsAsync","length","updateDevelopmentSessionAsync","setTimeout","error","devices","ProjectDevices","getDevicesInfoAsync","map","installationId","clearTimeout","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;+BAkBaA,oBAAkB;;aAAlBA,kBAAkB;;;yBAlBO,cAAc;;;;;;0CAK7C,oCAAoC;sBACd,qBAAqB;qBAC9B,iBAAiB;+DACL,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,A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,CAAAA,SAAS,QAAQ,GAAjBA,KAAAA,CAAiB,GAAjBA,SAAS,CAAEE,MAAM,CAAA,EAAE;gBACzD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,IAAI,CAACb,GAAG,EAAE;gBACZ,MAAMwB,IAAAA,yBAA4B,6BAAA,EAAC;oBACjCxB,GAAG,EAAE,IAAI,CAACA,GAAG;oBACbW,SAAS;iBACV,CAAC,CAAC;YACL,CAAC;YAED,OAAO,IAAI,CAAC;QACd,EAAE,OAAOK,KAAK,EAAO;YACnBxB,KAAK,CAAC,CAAC,uCAAuC,EAAEwB,KAAK,CAAC,CAAC,CAAC,CAAC;YACzD,IAAI,CAACf,OAAO,CAACe,KAAK,CAAC,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC;IACH;CACD"}
@@ -189,7 +189,7 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
189
189
  version: parsedMap.version,
190
190
  sources: parsedMap.sources.map((source)=>{
191
191
  source = typeof source === "string" && source.startsWith(this.projectRoot) ? _path().default.relative(this.projectRoot, source) : source;
192
- return source.split(_path().default.sep).join("/");
192
+ return (0, _metroOptions.convertPathToModuleSpecifier)(source);
193
193
  }),
194
194
  sourcesContent: new Array(parsedMap.sources.length).fill(null),
195
195
  names: parsedMap.names,
@@ -250,7 +250,7 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
250
250
  const { mode , minify , isExporting , baseUrl , reactCompiler , routerRoot , asyncRoutes } = this.instanceMetroOptions;
251
251
  (0, _assert().default)(mode != null && isExporting != null && baseUrl != null && routerRoot != null && reactCompiler != null && asyncRoutes != null, "The server must be started before calling getStaticResourcesAsync.");
252
252
  const platform = "web";
253
- const resolvedMainModuleName = mainModuleName != null ? mainModuleName : "." + _path().default.sep + (0, _manifestMiddleware.resolveMainModuleName)(this.projectRoot, {
253
+ const resolvedMainModuleName = mainModuleName != null ? mainModuleName : "./" + (0, _manifestMiddleware.resolveMainModuleName)(this.projectRoot, {
254
254
  platform
255
255
  });
256
256
  return await this.metroImportAsArtifactsAsync(resolvedMainModuleName, {
@@ -418,7 +418,7 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
418
418
  (0, _assert().default)(baseUrl != null && routerRoot != null && isExporting != null, "The server must be started before calling ssrLoadModuleContents.");
419
419
  const opts = {
420
420
  // TODO: Possibly issues with using an absolute path here...
421
- mainModuleName: filePath,
421
+ mainModuleName: (0, _metroOptions.convertPathToModuleSpecifier)(filePath),
422
422
  lazy: false,
423
423
  asyncRoutes: false,
424
424
  inlineSourceMap: false,
@@ -470,8 +470,8 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
470
470
  serializerOutput: "static"
471
471
  };
472
472
  // https://github.com/facebook/metro/blob/2405f2f6c37a1b641cc379b9c733b1eff0c1c2a1/packages/metro/src/lib/parseOptionsFromUrl.js#L55-L87
473
- if (!opts.mainModuleName.startsWith(_path().default.sep)) {
474
- opts.mainModuleName = "." + _path().default.sep + opts.mainModuleName;
473
+ if (!opts.mainModuleName.startsWith("/")) {
474
+ opts.mainModuleName = "./" + opts.mainModuleName;
475
475
  }
476
476
  const output = await this.metroLoadModuleContents(opts.mainModuleName, opts, extraOptions);
477
477
  return {
@@ -539,86 +539,89 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
539
539
  // Required for symbolication:
540
540
  process.env.EXPO_DEV_SERVER_ORIGIN = `http://localhost:${options.port}`;
541
541
  const { metro , server , middleware , messageSocket } = await (0, _instantiateMetro.instantiateMetroAsync)(this, parsedOptions, {
542
- isExporting: !!options.isExporting
543
- });
544
- const manifestMiddleware = await this.getManifestMiddlewareAsync(options);
545
- // Important that we noop source maps for context modules as soon as possible.
546
- (0, _mutations.prependMiddleware)(middleware, new _contextModuleSourceMapsMiddleware.ContextModuleSourceMapsMiddleware().getHandler());
547
- // We need the manifest handler to be the first middleware to run so our
548
- // routes take precedence over static files. For example, the manifest is
549
- // served from '/' and if the user has an index.html file in their project
550
- // then the manifest handler will never run, the static middleware will run
551
- // and serve index.html instead of the manifest.
552
- // https://github.com/expo/expo/issues/13114
553
- (0, _mutations.prependMiddleware)(middleware, manifestMiddleware.getHandler());
554
- var _scheme;
555
- middleware.use(new _interstitialPageMiddleware.InterstitialPageMiddleware(this.projectRoot, {
556
- // TODO: Prevent this from becoming stale.
557
- scheme: (_scheme = options.location.scheme) != null ? _scheme : null
558
- }).getHandler());
559
- middleware.use(new _reactDevToolsPageMiddleware.ReactDevToolsPageMiddleware(this.projectRoot).getHandler());
560
- middleware.use(new _devToolsPluginMiddleware.DevToolsPluginMiddleware(this.projectRoot, this.devToolsPluginManager).getHandler());
561
- const deepLinkMiddleware = new _runtimeRedirectMiddleware.RuntimeRedirectMiddleware(this.projectRoot, {
562
- onDeepLink: getDeepLinkHandler(this.projectRoot),
563
- getLocation: ({ runtime })=>{
564
- if (runtime === "custom") {
565
- var ref;
566
- return (ref = this.urlCreator) == null ? void 0 : ref.constructDevClientUrl();
567
- } else {
568
- var ref1;
569
- return (ref1 = this.urlCreator) == null ? void 0 : ref1.constructUrl({
570
- scheme: "exp"
571
- });
572
- }
573
- }
542
+ isExporting: !!options.isExporting,
543
+ exp
574
544
  });
575
- middleware.use(deepLinkMiddleware.getHandler());
576
- middleware.use(new _createFileMiddleware.CreateFileMiddleware(this.projectRoot).getHandler());
577
- // Append support for redirecting unhandled requests to the index.html page on web.
578
- if (this.isTargetingWeb()) {
579
- // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.
580
- middleware.use(new _serveStaticMiddleware.ServeStaticMiddleware(this.projectRoot).getHandler());
581
- // This should come after the static middleware so it doesn't serve the favicon from `public/favicon.ico`.
582
- middleware.use(new _faviconMiddleware.FaviconMiddleware(this.projectRoot).getHandler());
583
- if (useServerRendering) {
584
- var ref3;
585
- middleware.use((0, _createServerRouteMiddleware.createRouteHandlerMiddleware)(this.projectRoot, {
586
- appDir,
587
- routerRoot,
588
- config,
589
- ...(ref3 = config.exp.extra) == null ? void 0 : ref3.router,
590
- bundleApiRoute: (functionFilePath)=>this.ssrImportApiRoute(functionFilePath),
591
- getStaticPageAsync: (pathname)=>{
592
- return this.getStaticPageAsync(pathname);
545
+ if (!options.isExporting) {
546
+ const manifestMiddleware = await this.getManifestMiddlewareAsync(options);
547
+ // Important that we noop source maps for context modules as soon as possible.
548
+ (0, _mutations.prependMiddleware)(middleware, new _contextModuleSourceMapsMiddleware.ContextModuleSourceMapsMiddleware().getHandler());
549
+ // We need the manifest handler to be the first middleware to run so our
550
+ // routes take precedence over static files. For example, the manifest is
551
+ // served from '/' and if the user has an index.html file in their project
552
+ // then the manifest handler will never run, the static middleware will run
553
+ // and serve index.html instead of the manifest.
554
+ // https://github.com/expo/expo/issues/13114
555
+ (0, _mutations.prependMiddleware)(middleware, manifestMiddleware.getHandler());
556
+ var _scheme;
557
+ middleware.use(new _interstitialPageMiddleware.InterstitialPageMiddleware(this.projectRoot, {
558
+ // TODO: Prevent this from becoming stale.
559
+ scheme: (_scheme = options.location.scheme) != null ? _scheme : null
560
+ }).getHandler());
561
+ middleware.use(new _reactDevToolsPageMiddleware.ReactDevToolsPageMiddleware(this.projectRoot).getHandler());
562
+ middleware.use(new _devToolsPluginMiddleware.DevToolsPluginMiddleware(this.projectRoot, this.devToolsPluginManager).getHandler());
563
+ const deepLinkMiddleware = new _runtimeRedirectMiddleware.RuntimeRedirectMiddleware(this.projectRoot, {
564
+ onDeepLink: getDeepLinkHandler(this.projectRoot),
565
+ getLocation: ({ runtime })=>{
566
+ if (runtime === "custom") {
567
+ var ref;
568
+ return (ref = this.urlCreator) == null ? void 0 : ref.constructDevClientUrl();
569
+ } else {
570
+ var ref1;
571
+ return (ref1 = this.urlCreator) == null ? void 0 : ref1.constructUrl({
572
+ scheme: "exp"
573
+ });
593
574
  }
594
- }));
595
- (0, _waitForMetroToObserveTypeScriptFile.observeAnyFileChanges)({
596
- metro,
597
- server
598
- }, (events)=>{
599
- var ref;
600
- if (((ref = exp.web) == null ? void 0 : ref.output) === "server") {
601
- // NOTE(EvanBacon): We aren't sure what files the API routes are using so we'll just invalidate
602
- // aggressively to ensure we always have the latest. The only caching we really get here is for
603
- // cases where the user is making subsequent requests to the same API route without changing anything.
604
- // This is useful for testing but pretty suboptimal. Luckily our caching is pretty aggressive so it makes
605
- // up for a lot of the overhead.
606
- this.invalidateApiRouteCache();
607
- } else if (!(0, _router.hasWarnedAboutApiRoutes)()) {
608
- for (const event of events){
609
- var // If the user did not delete a file that matches the Expo Router API Route convention, then we should warn that
610
- // API Routes are not enabled in the project.
611
- ref1;
612
- if (((ref1 = event.metadata) == null ? void 0 : ref1.type) !== "d" && // Ensure the file is in the project's routes directory to prevent false positives in monorepos.
613
- event.filePath.startsWith(appDir) && (0, _router.isApiRouteConvention)(event.filePath)) {
614
- (0, _router.warnInvalidWebOutput)();
575
+ }
576
+ });
577
+ middleware.use(deepLinkMiddleware.getHandler());
578
+ middleware.use(new _createFileMiddleware.CreateFileMiddleware(this.projectRoot).getHandler());
579
+ // Append support for redirecting unhandled requests to the index.html page on web.
580
+ if (this.isTargetingWeb()) {
581
+ // This MUST be after the manifest middleware so it doesn't have a chance to serve the template `public/index.html`.
582
+ middleware.use(new _serveStaticMiddleware.ServeStaticMiddleware(this.projectRoot).getHandler());
583
+ // This should come after the static middleware so it doesn't serve the favicon from `public/favicon.ico`.
584
+ middleware.use(new _faviconMiddleware.FaviconMiddleware(this.projectRoot).getHandler());
585
+ if (useServerRendering) {
586
+ var ref3;
587
+ middleware.use((0, _createServerRouteMiddleware.createRouteHandlerMiddleware)(this.projectRoot, {
588
+ appDir,
589
+ routerRoot,
590
+ config,
591
+ ...(ref3 = config.exp.extra) == null ? void 0 : ref3.router,
592
+ bundleApiRoute: (functionFilePath)=>this.ssrImportApiRoute(functionFilePath),
593
+ getStaticPageAsync: (pathname)=>{
594
+ return this.getStaticPageAsync(pathname);
595
+ }
596
+ }));
597
+ (0, _waitForMetroToObserveTypeScriptFile.observeAnyFileChanges)({
598
+ metro,
599
+ server
600
+ }, (events)=>{
601
+ var ref;
602
+ if (((ref = exp.web) == null ? void 0 : ref.output) === "server") {
603
+ // NOTE(EvanBacon): We aren't sure what files the API routes are using so we'll just invalidate
604
+ // aggressively to ensure we always have the latest. The only caching we really get here is for
605
+ // cases where the user is making subsequent requests to the same API route without changing anything.
606
+ // This is useful for testing but pretty suboptimal. Luckily our caching is pretty aggressive so it makes
607
+ // up for a lot of the overhead.
608
+ this.invalidateApiRouteCache();
609
+ } else if (!(0, _router.hasWarnedAboutApiRoutes)()) {
610
+ for (const event of events){
611
+ var // If the user did not delete a file that matches the Expo Router API Route convention, then we should warn that
612
+ // API Routes are not enabled in the project.
613
+ ref1;
614
+ if (((ref1 = event.metadata) == null ? void 0 : ref1.type) !== "d" && // Ensure the file is in the project's routes directory to prevent false positives in monorepos.
615
+ event.filePath.startsWith(appDir) && (0, _router.isApiRouteConvention)(event.filePath)) {
616
+ (0, _router.warnInvalidWebOutput)();
617
+ }
615
618
  }
616
619
  }
617
- }
618
- });
619
- } else {
620
- // This MUST run last since it's the fallback.
621
- middleware.use(new _historyFallbackMiddleware.HistoryFallbackMiddleware(manifestMiddleware.getHandler().internal).getHandler());
620
+ });
621
+ } else {
622
+ // This MUST run last since it's the fallback.
623
+ middleware.use(new _historyFallbackMiddleware.HistoryFallbackMiddleware(manifestMiddleware.getHandler().internal).getHandler());
624
+ }
622
625
  }
623
626
  }
624
627
  // Extend the close method to ensure that we clean up the local info.
@@ -943,7 +946,7 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
943
946
  }
944
947
  async resolveRelativePathAsync(moduleId, { resolverOptions , transformOptions }) {
945
948
  (0, _assert().default)(this.metro, "cannot invoke resolveRelativePathAsync without metro instance");
946
- return await this.metro._resolveRelativePath(moduleId, {
949
+ return await this.metro._resolveRelativePath((0, _metroOptions.convertPathToModuleSpecifier)(moduleId), {
947
950
  relativeTo: "server",
948
951
  resolverOptions,
949
952
  transformOptions