@expo/cli 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/build/bin/cli +27 -25
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/config/configAsync.js +1 -1
  4. package/build/src/config/configAsync.js.map +1 -1
  5. package/build/src/config/index.js +2 -2
  6. package/build/src/config/index.js.map +1 -1
  7. package/build/src/customize/generate.js +1 -1
  8. package/build/src/customize/generate.js.map +1 -1
  9. package/build/src/customize/typescript.js +3 -3
  10. package/build/src/customize/typescript.js.map +1 -1
  11. package/build/src/export/createMetadataJson.js.map +1 -1
  12. package/build/src/export/embed/index.js +4 -4
  13. package/build/src/export/embed/index.js.map +1 -1
  14. package/build/src/export/exportApp.js +10 -5
  15. package/build/src/export/exportApp.js.map +1 -1
  16. package/build/src/export/exportHermes.js +20 -10
  17. package/build/src/export/exportHermes.js.map +1 -1
  18. package/build/src/export/exportStaticAsync.js +55 -39
  19. package/build/src/export/exportStaticAsync.js.map +1 -1
  20. package/build/src/export/fork-bundleAsync.js +44 -13
  21. package/build/src/export/fork-bundleAsync.js.map +1 -1
  22. package/build/src/export/getPublicExpoManifest.js +2 -2
  23. package/build/src/export/getPublicExpoManifest.js.map +1 -1
  24. package/build/src/export/index.js +2 -2
  25. package/build/src/export/index.js.map +1 -1
  26. package/build/src/export/web/index.js +2 -2
  27. package/build/src/export/web/index.js.map +1 -1
  28. package/build/src/export/writeContents.js +3 -1
  29. package/build/src/export/writeContents.js.map +1 -1
  30. package/build/src/install/installAsync.js +1 -1
  31. package/build/src/install/installAsync.js.map +1 -1
  32. package/build/src/login/index.js +1 -1
  33. package/build/src/login/index.js.map +1 -1
  34. package/build/src/logout/index.js +1 -1
  35. package/build/src/logout/index.js.map +1 -1
  36. package/build/src/prebuild/index.js +3 -3
  37. package/build/src/prebuild/index.js.map +1 -1
  38. package/build/src/prebuild/prebuildAsync.js +2 -2
  39. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  40. package/build/src/register/index.js +1 -1
  41. package/build/src/register/index.js.map +1 -1
  42. package/build/src/run/android/index.js +2 -2
  43. package/build/src/run/android/index.js.map +1 -1
  44. package/build/src/run/ios/appleDevice/AppleDevice.js +35 -2
  45. package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
  46. package/build/src/run/ios/index.js +2 -2
  47. package/build/src/run/ios/index.js.map +1 -1
  48. package/build/src/start/index.js +3 -3
  49. package/build/src/start/index.js.map +1 -1
  50. package/build/src/start/server/getStaticRenderFunctions.js +4 -1
  51. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  52. package/build/src/start/server/metro/MetroBundlerDevServer.js +70 -49
  53. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  54. package/build/src/start/server/metro/bundleApiRoutes.js +0 -16
  55. package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
  56. package/build/src/start/server/metro/createExpoMetroResolver.js +170 -0
  57. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -0
  58. package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
  59. package/build/src/start/server/metro/formatFileCandidates.js +72 -0
  60. package/build/src/start/server/metro/formatFileCandidates.js.map +1 -0
  61. package/build/src/start/server/metro/instantiateMetro.js +6 -7
  62. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  63. package/build/src/start/server/metro/metroErrorInterface.js +2 -1
  64. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  65. package/build/src/start/server/metro/router.js +2 -2
  66. package/build/src/start/server/metro/router.js.map +1 -1
  67. package/build/src/start/server/metro/withMetroMultiPlatform.js +31 -14
  68. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  69. package/build/src/start/server/middleware/ManifestMiddleware.js +43 -15
  70. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  71. package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
  72. package/build/src/start/server/type-generation/expo-env.js +1 -1
  73. package/build/src/start/server/type-generation/expo-env.js.map +1 -1
  74. package/build/src/start/server/type-generation/routes.js +1 -0
  75. package/build/src/start/server/type-generation/routes.js.map +1 -1
  76. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  77. package/build/src/utils/cocoapods.js +1 -0
  78. package/build/src/utils/cocoapods.js.map +1 -1
  79. package/build/src/utils/env.js +3 -0
  80. package/build/src/utils/env.js.map +1 -1
  81. package/build/src/whoami/index.js +1 -1
  82. package/build/src/whoami/index.js.map +1 -1
  83. package/package.json +7 -8
  84. package/static/shims/react-native-web/dist/cjs/exports/BackHandler/index.js +10 -0
  85. package/static/shims/react-native-web/dist/exports/BackHandler/index.js +7 -0
  86. package/build/src/export/createBundles.js +0 -37
  87. package/build/src/export/createBundles.js.map +0 -1
  88. package/build/src/start/server/middleware/resolveEntryPoint.js +0 -42
  89. package/build/src/start/server/middleware/resolveEntryPoint.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.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 { getConfig } from '@expo/config';\nimport * as runtimeEnv from '@expo/env';\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport chalk from 'chalk';\nimport fetch from 'node-fetch';\nimport path from 'path';\n\nimport { exportAllApiRoutesAsync, rebundleApiRoute } from './bundleApiRoutes';\nimport { createRouteHandlerMiddleware } from './createServerRouteMiddleware';\nimport { fetchManifest } from './fetchRouterManifest';\nimport { instantiateMetroAsync } from './instantiateMetro';\nimport { metroWatchTypeScriptFiles } from './metroWatchTypeScriptFiles';\nimport { getRouterDirectoryWithManifest, isApiRouteConvention } from './router';\nimport { observeApiRouteChanges, observeFileChanges } from './waitForMetroToObserveTypeScriptFile';\nimport { Log } from '../../../log';\nimport getDevClientProperties from '../../../utils/analytics/getDevClientProperties';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { CommandError } from '../../../utils/errors';\nimport { getFreePortAsync } from '../../../utils/port';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport { getStaticRenderFunctions } from '../getStaticRenderFunctions';\nimport { ContextModuleSourceMapsMiddleware } from '../middleware/ContextModuleSourceMapsMiddleware';\nimport { CreateFileMiddleware } from '../middleware/CreateFileMiddleware';\nimport { FaviconMiddleware } from '../middleware/FaviconMiddleware';\nimport { HistoryFallbackMiddleware } from '../middleware/HistoryFallbackMiddleware';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport {\n createBundleUrlPath,\n resolveMainModuleName,\n shouldEnableAsyncImports,\n} from '../middleware/ManifestMiddleware';\nimport { ReactDevToolsPageMiddleware } from '../middleware/ReactDevToolsPageMiddleware';\nimport {\n DeepLinkHandler,\n RuntimeRedirectMiddleware,\n} from '../middleware/RuntimeRedirectMiddleware';\nimport { ServeStaticMiddleware } from '../middleware/ServeStaticMiddleware';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { startTypescriptTypeGenerationAsync } from '../type-generation/startTypescriptTypeGeneration';\n\nexport class ForwardHtmlError extends CommandError {\n constructor(\n message: string,\n public html: string,\n public statusCode: number\n ) {\n super(message);\n }\n}\n\nconst debug = require('debug')('expo:start:server:metro') as typeof console.log;\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 8081;\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 private metro: import('metro').Server | null = null;\n\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 8081 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n async getExpoRouterRoutesManifestAsync({ appDir }: { appDir: string }) {\n const manifest = await fetchManifest(this.projectRoot, {\n asJson: true,\n appDir,\n });\n\n if (!manifest) {\n throw new CommandError(\n 'EXPO_ROUTER_SERVER_MANIFEST',\n 'Unexpected error: server manifest could not be fetched.'\n );\n }\n\n return manifest;\n }\n\n async exportExpoRouterApiRoutesAsync({\n mode,\n appDir,\n }: {\n mode: 'development' | 'production';\n appDir: string;\n }) {\n return exportAllApiRoutesAsync(this.projectRoot, {\n mode,\n appDir,\n port: this.getInstance()?.location.port,\n shouldThrow: true,\n });\n }\n\n async composeResourcesWithHtml({\n mode,\n resources,\n template,\n devBundleUrl,\n basePath,\n }: {\n mode: 'development' | 'production';\n resources: SerialAsset[];\n template: string;\n /** asset prefix used for deploying to non-standard origins like GitHub pages. */\n basePath: string;\n devBundleUrl?: string;\n }): Promise<string> {\n if (!resources) {\n return '';\n }\n const isDev = mode === 'development';\n return htmlFromSerialAssets(resources, {\n dev: isDev,\n template,\n basePath,\n bundleUrl: isDev ? devBundleUrl : undefined,\n });\n }\n\n async getStaticRenderFunctionAsync({\n mode,\n minify = mode !== 'development',\n }: {\n mode: 'development' | 'production';\n minify?: boolean;\n }) {\n const url = this.getDevServerUrl()!;\n\n const { getStaticContent, getManifest } = await getStaticRenderFunctions(\n this.projectRoot,\n url,\n {\n minify,\n dev: mode !== 'production',\n // Ensure the API Routes are included\n environment: 'node',\n }\n );\n return {\n // Get routes from Expo Router.\n manifest: await getManifest({ fetchData: true, preserveApiRoutes: false }),\n // Get route generating function\n async renderAsync(path: string) {\n return await getStaticContent(new URL(path, url));\n },\n };\n }\n\n async getStaticResourcesAsync({\n mode,\n minify = mode !== 'development',\n includeMaps,\n }: {\n mode: string;\n minify?: boolean;\n includeMaps?: boolean;\n }): Promise<SerialAsset[]> {\n const devBundleUrlPathname = createBundleUrlPath({\n platform: 'web',\n mode,\n minify,\n environment: 'client',\n serializerOutput: 'static',\n serializerIncludeMaps: includeMaps,\n mainModuleName: resolveMainModuleName(this.projectRoot, getConfig(this.projectRoot), 'web'),\n lazy: shouldEnableAsyncImports(this.projectRoot),\n });\n\n const bundleUrl = new URL(devBundleUrlPathname, this.getDevServerUrl()!);\n\n // Fetch the generated HTML from our custom Metro serializer\n const results = await fetch(bundleUrl.toString());\n\n const txt = await results.text();\n\n // console.log('STAT:', results.status, results.statusText);\n let data: any;\n try {\n data = JSON.parse(txt);\n } catch (error: any) {\n debug(txt);\n\n // Metro can throw this error when the initial module id cannot be resolved.\n if (!results.ok && txt.startsWith('<!DOCTYPE html>')) {\n throw new ForwardHtmlError(\n `Metro failed to bundle the project. Check the console for more information.`,\n txt,\n results.status\n );\n }\n\n Log.error(\n 'Failed to generate resources with Metro, the Metro config may not be using the correct serializer. Ensure the metro.config.js is extending the expo/metro-config and is not overriding the serializer.'\n );\n throw error;\n }\n\n // NOTE: This could potentially need more validation in the future.\n if (Array.isArray(data)) {\n return data;\n }\n\n if (data != null && (data.errors || data.type?.match(/.*Error$/))) {\n // {\n // type: 'InternalError',\n // errors: [],\n // message: 'Metro has encountered an error: While trying to resolve module `stylis` from file `/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js`, the package `/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs`. Indeed, none of these files exist:\\n' +\n // '\\n' +\n // ' * /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css)\\n' +\n // ' * /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs/index(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css): /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/metro/src/node-haste/DependencyGraph.js (289:17)\\n' +\n // '\\n' +\n // '\\x1B[0m \\x1B[90m 287 |\\x1B[39m }\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 288 |\\x1B[39m \\x1B[36mif\\x1B[39m (error \\x1B[36minstanceof\\x1B[39m \\x1B[33mInvalidPackageError\\x1B[39m) {\\x1B[0m\\n' +\n // '\\x1B[0m\\x1B[31m\\x1B[1m>\\x1B[22m\\x1B[39m\\x1B[90m 289 |\\x1B[39m \\x1B[36mthrow\\x1B[39m \\x1B[36mnew\\x1B[39m \\x1B[33mPackageResolutionError\\x1B[39m({\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m |\\x1B[39m \\x1B[31m\\x1B[1m^\\x1B[22m\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 290 |\\x1B[39m packageError\\x1B[33m:\\x1B[39m error\\x1B[33m,\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 291 |\\x1B[39m originModulePath\\x1B[33m:\\x1B[39m \\x1B[36mfrom\\x1B[39m\\x1B[33m,\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 292 |\\x1B[39m targetModuleName\\x1B[33m:\\x1B[39m to\\x1B[33m,\\x1B[39m\\x1B[0m'\n // }\n // The Metro logger already showed this error.\n throw new Error(data.message);\n }\n\n throw new Error(\n 'Invalid resources returned from the Metro serializer. Expected array, found: ' + data\n );\n }\n\n async getStaticPageAsync(\n pathname: string,\n {\n mode,\n minify = mode !== 'development',\n basePath,\n }: {\n mode: 'development' | 'production';\n minify?: boolean;\n basePath: string;\n }\n ) {\n const devBundleUrlPathname = createBundleUrlPath({\n platform: 'web',\n mode,\n environment: 'client',\n mainModuleName: resolveMainModuleName(this.projectRoot, getConfig(this.projectRoot), 'web'),\n lazy: shouldEnableAsyncImports(this.projectRoot),\n });\n\n const bundleStaticHtml = async (): Promise<string> => {\n const { getStaticContent } = await getStaticRenderFunctions(\n this.projectRoot,\n this.getDevServerUrl()!,\n {\n minify: false,\n dev: mode !== 'production',\n // Ensure the API Routes are included\n environment: 'node',\n }\n );\n\n const location = new URL(pathname, this.getDevServerUrl()!);\n return await getStaticContent(location);\n };\n\n const [resources, staticHtml] = await Promise.all([\n this.getStaticResourcesAsync({ mode, minify }),\n bundleStaticHtml(),\n ]);\n const content = await this.composeResourcesWithHtml({\n mode,\n resources,\n template: staticHtml,\n devBundleUrl: devBundleUrlPathname,\n basePath,\n });\n return {\n content,\n resources,\n };\n }\n\n async watchEnvironmentVariables() {\n if (!this.instance) {\n throw new Error(\n 'Cannot observe environment variable changes without a running Metro instance.'\n );\n }\n if (!this.metro) {\n // This can happen when the run command is used and the server is already running in another\n // process.\n debug('Skipping Environment Variable observation because Metro is not running (headless).');\n return;\n }\n\n const envFiles = runtimeEnv\n .getFiles(process.env.NODE_ENV)\n .map((fileName) => path.join(this.projectRoot, fileName));\n\n observeFileChanges(\n {\n metro: this.metro,\n server: this.instance.server,\n },\n envFiles,\n () => {\n debug('Reloading environment variables...');\n // Force reload the environment variables.\n runtimeEnv.load(this.projectRoot, { force: true });\n }\n );\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 // Required for symbolication:\n process.env.EXPO_DEV_SERVER_ORIGIN = `http://localhost:${options.port}`;\n\n const { metro, server, middleware, messageSocket } = await instantiateMetroAsync(\n this,\n parsedOptions,\n {\n isExporting: !!options.isExporting,\n }\n );\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // Important that we noop source maps for context modules as soon as possible.\n prependMiddleware(middleware, new ContextModuleSourceMapsMiddleware().getHandler());\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.getHandler());\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 middleware.use(new ReactDevToolsPageMiddleware(this.projectRoot).getHandler());\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 const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n\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 should come after the static middleware so it doesn't serve the favicon from `public/favicon.ico`.\n middleware.use(new FaviconMiddleware(this.projectRoot).getHandler());\n\n const appDir = getRouterDirectoryWithManifest(this.projectRoot, exp);\n\n middleware.use(\n createRouteHandlerMiddleware(this.projectRoot, {\n ...options,\n appDir,\n getWebBundleUrl: manifestMiddleware.getWebBundleUrl.bind(manifestMiddleware),\n getStaticPageAsync: (pathname) => {\n return this.getStaticPageAsync(pathname, {\n mode: options.mode ?? 'development',\n minify: options.minify,\n // No base path in development\n basePath: '',\n });\n },\n })\n );\n\n // @ts-expect-error: TODO\n if (exp.web?.output === 'server') {\n // Cache observation for API Routes...\n observeApiRouteChanges(\n this.projectRoot,\n {\n metro,\n server,\n },\n async (filepath, op) => {\n if (isApiRouteConvention(filepath)) {\n debug(`[expo-cli] ${op} ${filepath}`);\n if (op === 'change' || op === 'add') {\n rebundleApiRoute(this.projectRoot, filepath, {\n ...options,\n appDir,\n });\n }\n\n if (op === 'delete') {\n // TODO: Cancel the bundling of the deleted route.\n }\n }\n }\n );\n }\n\n // This MUST run last since it's the fallback.\n if (!useServerRendering) {\n middleware.use(\n new HistoryFallbackMiddleware(manifestMiddleware.getHandler().internal).getHandler()\n );\n }\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 this.metro = null;\n callback?.(err);\n });\n };\n\n this.metro = metro;\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 public async waitForTypeScriptAsync(): Promise<boolean> {\n if (!this.instance) {\n throw new Error('Cannot wait for TypeScript without a running server.');\n }\n\n return new Promise<boolean>((resolve) => {\n if (!this.metro) {\n // This can happen when the run command is used and the server is already running in another\n // process. In this case we can't wait for the TypeScript check to complete because we don't\n // have access to the Metro server.\n debug('Skipping TypeScript check because Metro is not running (headless).');\n return resolve(false);\n }\n\n const off = metroWatchTypeScriptFiles({\n projectRoot: this.projectRoot,\n server: this.instance!.server,\n metro: this.metro,\n tsconfig: true,\n throttle: true,\n eventTypes: ['change', 'add'],\n callback: async () => {\n // Run once, this prevents the TypeScript project prerequisite from running on every file change.\n off();\n const { TypeScriptProjectPrerequisite } = await import(\n '../../doctor/typescript/TypeScriptProjectPrerequisite'\n );\n\n try {\n const req = new TypeScriptProjectPrerequisite(this.projectRoot);\n await req.bootstrapAsync();\n resolve(true);\n } catch (error: any) {\n // Ensure the process doesn't fail if the TypeScript check fails.\n // This could happen during the install.\n Log.log();\n Log.error(\n chalk.red`Failed to automatically setup TypeScript for your project. Try restarting the dev server to fix.`\n );\n Log.exception(error);\n resolve(false);\n }\n },\n });\n });\n }\n\n public async startTypeScriptServices() {\n return startTypescriptTypeGenerationAsync({\n server: this.instance?.server,\n metro: this.metro,\n projectRoot: this.projectRoot,\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\nfunction htmlFromSerialAssets(\n assets: SerialAsset[],\n {\n dev,\n template,\n basePath,\n bundleUrl,\n }: {\n dev: boolean;\n template: string;\n basePath: string;\n /** This is dev-only. */\n bundleUrl?: string;\n }\n) {\n // Combine the CSS modules into tags that have hot refresh data attributes.\n const styleString = assets\n .filter((asset) => asset.type === 'css')\n .map(({ metadata, filename, source }) => {\n if (dev) {\n return `<style data-expo-css-hmr=\"${metadata.hmrId}\">` + source + '\\n</style>';\n } else {\n return [\n `<link rel=\"preload\" href=\"${basePath}/${filename}\" as=\"style\">`,\n `<link rel=\"stylesheet\" href=\"${basePath}/${filename}\">`,\n ].join('');\n }\n })\n .join('');\n\n const jsAssets = assets.filter((asset) => asset.type === 'js');\n\n const scripts = bundleUrl\n ? `<script src=\"${bundleUrl}\" defer></script>`\n : jsAssets\n .map(({ filename }) => {\n return `<script src=\"${basePath}/${filename}\" defer></script>`;\n })\n .join('');\n\n return template\n .replace('</head>', `${styleString}</head>`)\n .replace('</body>', `${scripts}\\n</body>`);\n}\n"],"names":["getDeepLinkHandler","runtimeEnv","ForwardHtmlError","CommandError","constructor","message","html","statusCode","debug","require","EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","MetroBundlerDevServer","BundlerDevServer","metro","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","getExpoRouterRoutesManifestAsync","appDir","manifest","fetchManifest","projectRoot","asJson","exportExpoRouterApiRoutesAsync","mode","exportAllApiRoutesAsync","getInstance","location","shouldThrow","composeResourcesWithHtml","resources","template","devBundleUrl","basePath","isDev","htmlFromSerialAssets","dev","bundleUrl","undefined","getStaticRenderFunctionAsync","minify","url","getDevServerUrl","getStaticContent","getManifest","getStaticRenderFunctions","environment","fetchData","preserveApiRoutes","renderAsync","path","URL","getStaticResourcesAsync","includeMaps","data","devBundleUrlPathname","createBundleUrlPath","platform","serializerOutput","serializerIncludeMaps","mainModuleName","resolveMainModuleName","getConfig","lazy","shouldEnableAsyncImports","results","fetch","toString","txt","text","JSON","parse","error","ok","startsWith","status","Log","Array","isArray","errors","type","match","Error","getStaticPageAsync","pathname","bundleStaticHtml","staticHtml","Promise","all","content","watchEnvironmentVariables","instance","envFiles","getFiles","NODE_ENV","map","fileName","join","observeFileChanges","server","load","force","startImplementationAsync","urlCreator","getUrlCreator","parsedOptions","maxWorkers","resetCache","resetDevServer","unversioned","EXPO_DEV_SERVER_ORIGIN","middleware","messageSocket","instantiateMetroAsync","isExporting","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","ContextModuleSourceMapsMiddleware","getHandler","use","InterstitialPageMiddleware","scheme","ReactDevToolsPageMiddleware","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","getLocation","runtime","constructDevClientUrl","constructUrl","CreateFileMiddleware","isTargetingWeb","exp","skipSDKVersionRequirement","useServerRendering","includes","web","output","ServeStaticMiddleware","FaviconMiddleware","getRouterDirectoryWithManifest","createRouteHandlerMiddleware","getWebBundleUrl","bind","observeApiRouteChanges","filepath","op","isApiRouteConvention","rebundleApiRoute","HistoryFallbackMiddleware","internal","originalClose","close","callback","err","host","protocol","waitForTypeScriptAsync","resolve","off","metroWatchTypeScriptFiles","tsconfig","throttle","eventTypes","TypeScriptProjectPrerequisite","req","bootstrapAsync","log","chalk","red","exception","startTypeScriptServices","startTypescriptTypeGenerationAsync","getConfigModuleIds","logEventAsync","getDevClientProperties","assets","styleString","filter","asset","metadata","filename","source","hmrId","jsAssets","scripts","replace"],"mappings":"AAMA;;;;QAgiBgBA,kBAAkB,GAAlBA,kBAAkB;AAhiBR,IAAA,OAAc,WAAd,cAAc,CAAA;AAC5BC,IAAAA,UAAU,mCAAM,WAAW,EAAjB;AAEJ,IAAA,MAAO,kCAAP,OAAO,EAAA;AACP,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACb,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEmC,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AAChC,IAAA,4BAA+B,WAA/B,+BAA+B,CAAA;AAC9C,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AACf,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAChB,IAAA,0BAA6B,WAA7B,6BAA6B,CAAA;AACF,IAAA,OAAU,WAAV,UAAU,CAAA;AACpB,IAAA,oCAAuC,WAAvC,uCAAuC,CAAA;AAC9E,IAAA,IAAc,WAAd,cAAc,CAAA;AACC,IAAA,uBAAiD,kCAAjD,iDAAiD,EAAA;AACtD,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AAC7C,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACnB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACmB,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACrD,IAAA,yBAA6B,WAA7B,6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":3,"sources":["../../../../../src/start/server/metro/MetroBundlerDevServer.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 { getConfig } from '@expo/config';\nimport * as runtimeEnv from '@expo/env';\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport chalk from 'chalk';\nimport fetch from 'node-fetch';\nimport path from 'path';\n\nimport { bundleApiRoute, rebundleApiRoute } from './bundleApiRoutes';\nimport { createRouteHandlerMiddleware } from './createServerRouteMiddleware';\nimport { fetchManifest } from './fetchRouterManifest';\nimport { instantiateMetroAsync } from './instantiateMetro';\nimport { metroWatchTypeScriptFiles } from './metroWatchTypeScriptFiles';\nimport { getRouterDirectoryWithManifest, isApiRouteConvention } from './router';\nimport { observeApiRouteChanges, observeFileChanges } from './waitForMetroToObserveTypeScriptFile';\nimport { Log } from '../../../log';\nimport getDevClientProperties from '../../../utils/analytics/getDevClientProperties';\nimport { logEventAsync } from '../../../utils/analytics/rudderstackClient';\nimport { CommandError } from '../../../utils/errors';\nimport { getFreePortAsync } from '../../../utils/port';\nimport { BundlerDevServer, BundlerStartOptions, DevServerInstance } from '../BundlerDevServer';\nimport { getStaticRenderFunctions } from '../getStaticRenderFunctions';\nimport { ContextModuleSourceMapsMiddleware } from '../middleware/ContextModuleSourceMapsMiddleware';\nimport { CreateFileMiddleware } from '../middleware/CreateFileMiddleware';\nimport { FaviconMiddleware } from '../middleware/FaviconMiddleware';\nimport { HistoryFallbackMiddleware } from '../middleware/HistoryFallbackMiddleware';\nimport { InterstitialPageMiddleware } from '../middleware/InterstitialPageMiddleware';\nimport {\n createBundleUrlPath,\n resolveMainModuleName,\n shouldEnableAsyncImports,\n} from '../middleware/ManifestMiddleware';\nimport { ReactDevToolsPageMiddleware } from '../middleware/ReactDevToolsPageMiddleware';\nimport {\n DeepLinkHandler,\n RuntimeRedirectMiddleware,\n} from '../middleware/RuntimeRedirectMiddleware';\nimport { ServeStaticMiddleware } from '../middleware/ServeStaticMiddleware';\nimport { prependMiddleware } from '../middleware/mutations';\nimport { startTypescriptTypeGenerationAsync } from '../type-generation/startTypescriptTypeGeneration';\n\nexport class ForwardHtmlError extends CommandError {\n constructor(\n message: string,\n public html: string,\n public statusCode: number\n ) {\n super(message);\n }\n}\n\nconst debug = require('debug')('expo:start:server:metro') as typeof console.log;\n\n/** Default port to use for apps running in Expo Go. */\nconst EXPO_GO_METRO_PORT = 8081;\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 private metro: import('metro').Server | null = null;\n\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 8081 port.\n await getFreePortAsync(EXPO_GO_METRO_PORT));\n\n return port;\n }\n\n async getExpoRouterRoutesManifestAsync({ appDir }: { appDir: string }) {\n const manifest = await fetchManifest(this.projectRoot, {\n asJson: true,\n appDir,\n });\n\n if (!manifest) {\n throw new CommandError(\n 'EXPO_ROUTER_SERVER_MANIFEST',\n 'Unexpected error: server manifest could not be fetched.'\n );\n }\n\n return manifest;\n }\n\n async exportExpoRouterApiRoutesAsync({\n mode,\n appDir,\n outputDir,\n }: {\n mode: 'development' | 'production';\n appDir: string;\n outputDir: string;\n }) {\n const manifest = await this.getExpoRouterRoutesManifestAsync({\n appDir,\n });\n\n const files: Map<string, string> = new Map();\n\n for (const route of manifest.apiRoutes) {\n const filepath = path.join(appDir, route.file);\n const contents = await bundleApiRoute(this.projectRoot, filepath, {\n mode,\n appDir,\n port: this.getInstance()?.location.port,\n shouldThrow: true,\n });\n const artifactFilename = path.join(\n outputDir,\n path.relative(appDir, filepath.replace(/\\.[tj]sx?$/, '.js'))\n );\n files.set(artifactFilename, contents!);\n // Remap the manifest files to represent the output files.\n route.file = artifactFilename;\n }\n\n return { manifest, files };\n }\n\n async composeResourcesWithHtml({\n mode,\n resources,\n template,\n devBundleUrl,\n basePath,\n }: {\n mode: 'development' | 'production';\n resources: SerialAsset[];\n template: string;\n /** asset prefix used for deploying to non-standard origins like GitHub pages. */\n basePath: string;\n devBundleUrl?: string;\n }): Promise<string> {\n if (!resources) {\n return '';\n }\n const isDev = mode === 'development';\n return htmlFromSerialAssets(resources, {\n dev: isDev,\n template,\n basePath,\n bundleUrl: isDev ? devBundleUrl : undefined,\n });\n }\n\n async getStaticRenderFunctionAsync({\n mode,\n minify = mode !== 'development',\n }: {\n mode: 'development' | 'production';\n minify?: boolean;\n }) {\n const url = this.getDevServerUrl()!;\n\n const { getStaticContent, getManifest } = await getStaticRenderFunctions(\n this.projectRoot,\n url,\n {\n minify,\n dev: mode !== 'production',\n // Ensure the API Routes are included\n environment: 'node',\n }\n );\n return {\n // Get routes from Expo Router.\n manifest: await getManifest({ fetchData: true, preserveApiRoutes: false }),\n // Get route generating function\n async renderAsync(path: string) {\n return await getStaticContent(new URL(path, url));\n },\n };\n }\n\n async getStaticResourcesAsync({\n mode,\n minify = mode !== 'development',\n includeMaps,\n }: {\n mode: string;\n minify?: boolean;\n includeMaps?: boolean;\n }): Promise<SerialAsset[]> {\n const devBundleUrlPathname = createBundleUrlPath({\n platform: 'web',\n mode,\n minify,\n environment: 'client',\n serializerOutput: 'static',\n serializerIncludeMaps: includeMaps,\n mainModuleName: resolveMainModuleName(this.projectRoot, { platform: 'web' }),\n lazy: shouldEnableAsyncImports(this.projectRoot),\n });\n\n const bundleUrl = new URL(devBundleUrlPathname, this.getDevServerUrl()!);\n\n // Fetch the generated HTML from our custom Metro serializer\n const results = await fetch(bundleUrl.toString());\n\n const txt = await results.text();\n\n // console.log('STAT:', results.status, results.statusText);\n let data: any;\n try {\n data = JSON.parse(txt);\n } catch (error: any) {\n debug(txt);\n\n // Metro can throw this error when the initial module id cannot be resolved.\n if (!results.ok && txt.startsWith('<!DOCTYPE html>')) {\n throw new ForwardHtmlError(\n `Metro failed to bundle the project. Check the console for more information.`,\n txt,\n results.status\n );\n }\n\n Log.error(\n 'Failed to generate resources with Metro, the Metro config may not be using the correct serializer. Ensure the metro.config.js is extending the expo/metro-config and is not overriding the serializer.'\n );\n throw error;\n }\n\n // NOTE: This could potentially need more validation in the future.\n if (Array.isArray(data)) {\n return data;\n }\n\n if (data != null && (data.errors || data.type?.match(/.*Error$/))) {\n // {\n // type: 'InternalError',\n // errors: [],\n // message: 'Metro has encountered an error: While trying to resolve module `stylis` from file `/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/@emotion/cache/dist/emotion-cache.browser.esm.js`, the package `/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs`. Indeed, none of these files exist:\\n' +\n // '\\n' +\n // ' * /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css)\\n' +\n // ' * /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/stylis/dist/stylis.mjs/index(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css): /Users/evanbacon/Documents/GitHub/lab/emotion-error-test/node_modules/metro/src/node-haste/DependencyGraph.js (289:17)\\n' +\n // '\\n' +\n // '\\x1B[0m \\x1B[90m 287 |\\x1B[39m }\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 288 |\\x1B[39m \\x1B[36mif\\x1B[39m (error \\x1B[36minstanceof\\x1B[39m \\x1B[33mInvalidPackageError\\x1B[39m) {\\x1B[0m\\n' +\n // '\\x1B[0m\\x1B[31m\\x1B[1m>\\x1B[22m\\x1B[39m\\x1B[90m 289 |\\x1B[39m \\x1B[36mthrow\\x1B[39m \\x1B[36mnew\\x1B[39m \\x1B[33mPackageResolutionError\\x1B[39m({\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m |\\x1B[39m \\x1B[31m\\x1B[1m^\\x1B[22m\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 290 |\\x1B[39m packageError\\x1B[33m:\\x1B[39m error\\x1B[33m,\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 291 |\\x1B[39m originModulePath\\x1B[33m:\\x1B[39m \\x1B[36mfrom\\x1B[39m\\x1B[33m,\\x1B[39m\\x1B[0m\\n' +\n // '\\x1B[0m \\x1B[90m 292 |\\x1B[39m targetModuleName\\x1B[33m:\\x1B[39m to\\x1B[33m,\\x1B[39m\\x1B[0m'\n // }\n // The Metro logger already showed this error.\n throw new Error(data.message);\n }\n\n throw new Error(\n 'Invalid resources returned from the Metro serializer. Expected array, found: ' + data\n );\n }\n\n async getStaticPageAsync(\n pathname: string,\n {\n mode,\n minify = mode !== 'development',\n basePath,\n }: {\n mode: 'development' | 'production';\n minify?: boolean;\n basePath: string;\n }\n ) {\n const devBundleUrlPathname = createBundleUrlPath({\n platform: 'web',\n mode,\n environment: 'client',\n mainModuleName: resolveMainModuleName(this.projectRoot, { platform: 'web' }),\n lazy: shouldEnableAsyncImports(this.projectRoot),\n });\n\n const bundleStaticHtml = async (): Promise<string> => {\n const { getStaticContent } = await getStaticRenderFunctions(\n this.projectRoot,\n this.getDevServerUrl()!,\n {\n minify: false,\n dev: mode !== 'production',\n // Ensure the API Routes are included\n environment: 'node',\n }\n );\n\n const location = new URL(pathname, this.getDevServerUrl()!);\n return await getStaticContent(location);\n };\n\n const [resources, staticHtml] = await Promise.all([\n this.getStaticResourcesAsync({ mode, minify }),\n bundleStaticHtml(),\n ]);\n const content = await this.composeResourcesWithHtml({\n mode,\n resources,\n template: staticHtml,\n devBundleUrl: devBundleUrlPathname,\n basePath,\n });\n return {\n content,\n resources,\n };\n }\n\n async watchEnvironmentVariables() {\n if (!this.instance) {\n throw new Error(\n 'Cannot observe environment variable changes without a running Metro instance.'\n );\n }\n if (!this.metro) {\n // This can happen when the run command is used and the server is already running in another\n // process.\n debug('Skipping Environment Variable observation because Metro is not running (headless).');\n return;\n }\n\n const envFiles = runtimeEnv\n .getFiles(process.env.NODE_ENV)\n .map((fileName) => path.join(this.projectRoot, fileName));\n\n observeFileChanges(\n {\n metro: this.metro,\n server: this.instance.server,\n },\n envFiles,\n () => {\n debug('Reloading environment variables...');\n // Force reload the environment variables.\n runtimeEnv.load(this.projectRoot, { force: true });\n }\n );\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 // Required for symbolication:\n process.env.EXPO_DEV_SERVER_ORIGIN = `http://localhost:${options.port}`;\n\n const { metro, server, middleware, messageSocket } = await instantiateMetroAsync(\n this,\n parsedOptions,\n {\n isExporting: !!options.isExporting,\n }\n );\n\n const manifestMiddleware = await this.getManifestMiddlewareAsync(options);\n\n // Important that we noop source maps for context modules as soon as possible.\n prependMiddleware(middleware, new ContextModuleSourceMapsMiddleware().getHandler());\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.getHandler());\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 middleware.use(new ReactDevToolsPageMiddleware(this.projectRoot).getHandler());\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 const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n\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 should come after the static middleware so it doesn't serve the favicon from `public/favicon.ico`.\n middleware.use(new FaviconMiddleware(this.projectRoot).getHandler());\n\n if (useServerRendering) {\n const appDir = getRouterDirectoryWithManifest(this.projectRoot, exp);\n middleware.use(\n createRouteHandlerMiddleware(this.projectRoot, {\n ...options,\n appDir,\n getWebBundleUrl: manifestMiddleware.getWebBundleUrl.bind(manifestMiddleware),\n getStaticPageAsync: (pathname) => {\n return this.getStaticPageAsync(pathname, {\n mode: options.mode ?? 'development',\n minify: options.minify,\n // No base path in development\n basePath: '',\n });\n },\n })\n );\n\n // @ts-expect-error: TODO\n if (exp.web?.output === 'server') {\n // Cache observation for API Routes...\n observeApiRouteChanges(\n this.projectRoot,\n {\n metro,\n server,\n },\n async (filepath, op) => {\n if (isApiRouteConvention(filepath)) {\n debug(`[expo-cli] ${op} ${filepath}`);\n if (op === 'change' || op === 'add') {\n rebundleApiRoute(this.projectRoot, filepath, {\n ...options,\n appDir,\n });\n }\n\n if (op === 'delete') {\n // TODO: Cancel the bundling of the deleted route.\n }\n }\n }\n );\n }\n } else {\n // This MUST run last since it's the fallback.\n middleware.use(\n new HistoryFallbackMiddleware(manifestMiddleware.getHandler().internal).getHandler()\n );\n }\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 this.metro = null;\n callback?.(err);\n });\n };\n\n this.metro = metro;\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 public async waitForTypeScriptAsync(): Promise<boolean> {\n if (!this.instance) {\n throw new Error('Cannot wait for TypeScript without a running server.');\n }\n\n return new Promise<boolean>((resolve) => {\n if (!this.metro) {\n // This can happen when the run command is used and the server is already running in another\n // process. In this case we can't wait for the TypeScript check to complete because we don't\n // have access to the Metro server.\n debug('Skipping TypeScript check because Metro is not running (headless).');\n return resolve(false);\n }\n\n const off = metroWatchTypeScriptFiles({\n projectRoot: this.projectRoot,\n server: this.instance!.server,\n metro: this.metro,\n tsconfig: true,\n throttle: true,\n eventTypes: ['change', 'add'],\n callback: async () => {\n // Run once, this prevents the TypeScript project prerequisite from running on every file change.\n off();\n const { TypeScriptProjectPrerequisite } = await import(\n '../../doctor/typescript/TypeScriptProjectPrerequisite.js'\n );\n\n try {\n const req = new TypeScriptProjectPrerequisite(this.projectRoot);\n await req.bootstrapAsync();\n resolve(true);\n } catch (error: any) {\n // Ensure the process doesn't fail if the TypeScript check fails.\n // This could happen during the install.\n Log.log();\n Log.error(\n chalk.red`Failed to automatically setup TypeScript for your project. Try restarting the dev server to fix.`\n );\n Log.exception(error);\n resolve(false);\n }\n },\n });\n });\n }\n\n public async startTypeScriptServices() {\n return startTypescriptTypeGenerationAsync({\n server: this.instance?.server,\n metro: this.metro,\n projectRoot: this.projectRoot,\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\nfunction htmlFromSerialAssets(\n assets: SerialAsset[],\n {\n dev,\n template,\n basePath,\n bundleUrl,\n }: {\n dev: boolean;\n template: string;\n basePath: string;\n /** This is dev-only. */\n bundleUrl?: string;\n }\n) {\n // Combine the CSS modules into tags that have hot refresh data attributes.\n const styleString = assets\n .filter((asset) => asset.type === 'css')\n .map(({ metadata, filename, source }) => {\n if (dev) {\n return `<style data-expo-css-hmr=\"${metadata.hmrId}\">` + source + '\\n</style>';\n } else {\n return [\n `<link rel=\"preload\" href=\"${basePath}/${filename}\" as=\"style\">`,\n `<link rel=\"stylesheet\" href=\"${basePath}/${filename}\">`,\n ].join('');\n }\n })\n .join('');\n\n const jsAssets = assets.filter((asset) => asset.type === 'js');\n\n const scripts = bundleUrl\n ? `<script src=\"${bundleUrl}\" defer></script>`\n : jsAssets\n .map(({ filename }) => {\n return `<script src=\"${basePath}/${filename}\" defer></script>`;\n })\n .join('');\n\n return template\n .replace('</head>', `${styleString}</head>`)\n .replace('</body>', `${scripts}\\n</body>`);\n}\n"],"names":["getDeepLinkHandler","runtimeEnv","ForwardHtmlError","CommandError","constructor","message","html","statusCode","debug","require","EXPO_GO_METRO_PORT","DEV_CLIENT_METRO_PORT","MetroBundlerDevServer","BundlerDevServer","metro","name","resolvePortAsync","options","port","devClient","Number","process","env","RCT_METRO_PORT","getFreePortAsync","getExpoRouterRoutesManifestAsync","appDir","manifest","fetchManifest","projectRoot","asJson","exportExpoRouterApiRoutesAsync","mode","outputDir","files","Map","route","apiRoutes","filepath","path","join","file","contents","bundleApiRoute","getInstance","location","shouldThrow","artifactFilename","relative","replace","set","composeResourcesWithHtml","resources","template","devBundleUrl","basePath","isDev","htmlFromSerialAssets","dev","bundleUrl","undefined","getStaticRenderFunctionAsync","minify","url","getDevServerUrl","getStaticContent","getManifest","getStaticRenderFunctions","environment","fetchData","preserveApiRoutes","renderAsync","URL","getStaticResourcesAsync","includeMaps","data","devBundleUrlPathname","createBundleUrlPath","platform","serializerOutput","serializerIncludeMaps","mainModuleName","resolveMainModuleName","lazy","shouldEnableAsyncImports","results","fetch","toString","txt","text","JSON","parse","error","ok","startsWith","status","Log","Array","isArray","errors","type","match","Error","getStaticPageAsync","pathname","bundleStaticHtml","staticHtml","Promise","all","content","watchEnvironmentVariables","instance","envFiles","getFiles","NODE_ENV","map","fileName","observeFileChanges","server","load","force","startImplementationAsync","urlCreator","getUrlCreator","parsedOptions","maxWorkers","resetCache","resetDevServer","unversioned","EXPO_DEV_SERVER_ORIGIN","middleware","messageSocket","instantiateMetroAsync","isExporting","manifestMiddleware","getManifestMiddlewareAsync","prependMiddleware","ContextModuleSourceMapsMiddleware","getHandler","use","InterstitialPageMiddleware","scheme","ReactDevToolsPageMiddleware","deepLinkMiddleware","RuntimeRedirectMiddleware","onDeepLink","getLocation","runtime","constructDevClientUrl","constructUrl","CreateFileMiddleware","isTargetingWeb","exp","getConfig","skipSDKVersionRequirement","useServerRendering","includes","web","output","ServeStaticMiddleware","FaviconMiddleware","getRouterDirectoryWithManifest","createRouteHandlerMiddleware","getWebBundleUrl","bind","observeApiRouteChanges","op","isApiRouteConvention","rebundleApiRoute","HistoryFallbackMiddleware","internal","originalClose","close","callback","err","host","protocol","waitForTypeScriptAsync","resolve","off","metroWatchTypeScriptFiles","tsconfig","throttle","eventTypes","TypeScriptProjectPrerequisite","req","bootstrapAsync","log","chalk","red","exception","startTypeScriptServices","startTypescriptTypeGenerationAsync","getConfigModuleIds","logEventAsync","getDevClientProperties","assets","styleString","filter","asset","metadata","filename","source","hmrId","jsAssets","scripts"],"mappings":"AAMA;;;;QAmjBgBA,kBAAkB,GAAlBA,kBAAkB;AAnjBR,IAAA,OAAc,WAAd,cAAc,CAAA;AAC5BC,IAAAA,UAAU,mCAAM,WAAW,EAAjB;AAEJ,IAAA,MAAO,kCAAP,OAAO,EAAA;AACP,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACb,IAAA,KAAM,kCAAN,MAAM,EAAA;AAE0B,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AACvB,IAAA,4BAA+B,WAA/B,+BAA+B,CAAA;AAC9C,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AACf,IAAA,iBAAoB,WAApB,oBAAoB,CAAA;AAChB,IAAA,0BAA6B,WAA7B,6BAA6B,CAAA;AACF,IAAA,OAAU,WAAV,UAAU,CAAA;AACpB,IAAA,oCAAuC,WAAvC,uCAAuC,CAAA;AAC9E,IAAA,IAAc,WAAd,cAAc,CAAA;AACC,IAAA,uBAAiD,kCAAjD,iDAAiD,EAAA;AACtD,IAAA,kBAA4C,WAA5C,4CAA4C,CAAA;AAC7C,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACnB,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACmB,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACrD,IAAA,yBAA6B,WAA7B,6BAA6B,CAAA;AACpB,IAAA,kCAAiD,WAAjD,iDAAiD,CAAA;AAC9D,IAAA,qBAAoC,WAApC,oCAAoC,CAAA;AACvC,IAAA,kBAAiC,WAAjC,iCAAiC,CAAA;AACzB,IAAA,0BAAyC,WAAzC,yCAAyC,CAAA;AACxC,IAAA,2BAA0C,WAA1C,0CAA0C,CAAA;AAK9E,IAAA,mBAAkC,WAAlC,kCAAkC,CAAA;AACG,IAAA,4BAA2C,WAA3C,2CAA2C,CA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B,OAAO,CAAC,aAAa,EAAElJ,QAAQ,CAAC,CAAC,EAAEkJ,QAAQ,CAAC,iBAAiB,CAAC,CAAC;KAChE,CAAC,CACDjK,IAAI,CAAC,EAAE,CAAC,AAAC;IAEhB,OAAOa,QAAQ,CACZJ,OAAO,CAAC,SAAS,EAAE,CAAC,EAAEoJ,WAAW,CAAC,OAAO,CAAC,CAAC,CAC3CpJ,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE4J,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;CAC9C"}
@@ -4,16 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.bundleApiRoute = bundleApiRoute;
6
6
  exports.rebundleApiRoute = rebundleApiRoute;
7
- exports.exportAllApiRoutesAsync = exportAllApiRoutesAsync;
8
- var _nodePath = _interopRequireDefault(require("node:path"));
9
7
  var _metroErrorInterface = require("./metroErrorInterface");
10
- var _router = require("./router");
11
8
  var _getStaticRenderFunctions = require("../getStaticRenderFunctions");
12
- function _interopRequireDefault(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
15
- };
16
- }
17
9
  const debug = require("debug")("expo:server-routes");
18
10
  const pendingRouteOperations = new Map();
19
11
  async function bundleApiRoute(projectRoot, filepath, options) {
@@ -55,13 +47,5 @@ async function rebundleApiRoute(projectRoot, filepath, options) {
55
47
  pendingRouteOperations.delete(filepath);
56
48
  return bundleApiRoute(projectRoot, filepath, options);
57
49
  }
58
- async function exportAllApiRoutesAsync(projectRoot, options) {
59
- const files = new Map();
60
- await Promise.all((0, _router).getApiRoutesForDirectory(options.appDir).map(async (filepath)=>{
61
- const contents = await bundleApiRoute(projectRoot, filepath, options);
62
- files.set(_nodePath.default.relative(options.appDir, filepath.replace(/\.[tj]sx?$/, ".js")), contents);
63
- }));
64
- return files;
65
- }
66
50
 
67
51
  //# sourceMappingURL=bundleApiRoutes.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/bundleApiRoutes.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 path from 'node:path';\n\nimport { logMetroErrorAsync } from './metroErrorInterface';\nimport { getApiRoutesForDirectory } from './router';\nimport { requireFileContentsWithMetro } from '../getStaticRenderFunctions';\n\nconst debug = require('debug')('expo:server-routes') as typeof console.log;\n\nconst pendingRouteOperations = new Map<string, Promise<string | null>>();\n\nexport type ApiRouteOptions = {\n mode?: string;\n appDir: string;\n port?: number;\n shouldThrow?: boolean;\n};\n\n// Bundle the API Route with Metro and return the string contents to be evaluated in the server.\nexport async function bundleApiRoute(\n projectRoot: string,\n filepath: string,\n options: ApiRouteOptions\n): Promise<string | null | undefined> {\n if (pendingRouteOperations.has(filepath)) {\n return pendingRouteOperations.get(filepath);\n }\n\n const devServerUrl = `http://localhost:${options.port}`;\n\n async function bundleAsync() {\n try {\n debug('Check API route:', options.appDir, filepath);\n\n const middleware = await requireFileContentsWithMetro(projectRoot, devServerUrl, filepath, {\n minify: options.mode === 'production',\n dev: options.mode !== 'production',\n // Ensure Node.js\n environment: 'node',\n });\n\n return middleware;\n } catch (error: any) {\n if (error instanceof Error) {\n await logMetroErrorAsync({ error, projectRoot });\n }\n if (options.shouldThrow) {\n throw error;\n }\n // TODO: improve error handling, maybe have this be a mock function which returns the static error html\n return null;\n } finally {\n // pendingRouteOperations.delete(filepath);\n }\n }\n const route = bundleAsync();\n\n pendingRouteOperations.set(filepath, route);\n return route;\n}\n\nexport async function rebundleApiRoute(\n projectRoot: string,\n filepath: string,\n options: ApiRouteOptions\n) {\n pendingRouteOperations.delete(filepath);\n return bundleApiRoute(projectRoot, filepath, options);\n}\n\nexport async function exportAllApiRoutesAsync(projectRoot: string, options: ApiRouteOptions) {\n const files: Map<string, string> = new Map();\n\n await Promise.all(\n getApiRoutesForDirectory(options.appDir).map(async (filepath) => {\n const contents = await bundleApiRoute(projectRoot, filepath, options);\n files.set(path.relative(options.appDir, filepath.replace(/\\.[tj]sx?$/, '.js')), contents!);\n })\n );\n\n return files;\n}\n"],"names":["bundleApiRoute","rebundleApiRoute","exportAllApiRoutesAsync","debug","require","pendingRouteOperations","Map","projectRoot","filepath","options","has","get","devServerUrl","port","bundleAsync","appDir","middleware","requireFileContentsWithMetro","minify","mode","dev","environment","error","Error","logMetroErrorAsync","shouldThrow","route","set","delete","files","Promise","all","getApiRoutesForDirectory","map","contents","path","relative","replace"],"mappings":"AAMA;;;;QAkBsBA,cAAc,GAAdA,cAAc;QA0CdC,gBAAgB,GAAhBA,gBAAgB;QAShBC,uBAAuB,GAAvBA,uBAAuB;AArE5B,IAAA,SAAW,kCAAX,WAAW,EAAA;AAEO,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AACjB,IAAA,OAAU,WAAV,UAAU,CAAA;AACN,IAAA,yBAA6B,WAA7B,6BAA6B,CAAA;;;;;;AAE1E,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAsB,AAAC;AAE3E,MAAMC,sBAAsB,GAAG,IAAIC,GAAG,EAAkC,AAAC;AAUlE,eAAeN,cAAc,CAClCO,WAAmB,EACnBC,QAAgB,EAChBC,OAAwB,EACY;IACpC,IAAIJ,sBAAsB,CAACK,GAAG,CAACF,QAAQ,CAAC,EAAE;QACxC,OAAOH,sBAAsB,CAACM,GAAG,CAACH,QAAQ,CAAC,CAAC;KAC7C;IAED,MAAMI,YAAY,GAAG,CAAC,iBAAiB,EAAEH,OAAO,CAACI,IAAI,CAAC,CAAC,AAAC;IAExD,eAAeC,WAAW,GAAG;QAC3B,IAAI;YACFX,KAAK,CAAC,kBAAkB,EAAEM,OAAO,CAACM,MAAM,EAAEP,QAAQ,CAAC,CAAC;YAEpD,MAAMQ,UAAU,GAAG,MAAMC,CAAAA,GAAAA,yBAA4B,AAKnD,CAAA,6BALmD,CAACV,WAAW,EAAEK,YAAY,EAAEJ,QAAQ,EAAE;gBACzFU,M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AK,CAACF,GAAG,CAACQ,SAAI,QAAA,CAACC,QAAQ,CAAC3B,OAAO,CAACM,MAAM,EAAEP,QAAQ,CAAC6B,OAAO,eAAe,KAAK,CAAC,CAAC,EAAEH,QAAQ,CAAE,CAAC;KAC5F,CAAC,CACH,CAAC;IAEF,OAAOL,KAAK,CAAC;CACd"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/bundleApiRoutes.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 */\n\nimport { logMetroErrorAsync } from './metroErrorInterface';\nimport { requireFileContentsWithMetro } from '../getStaticRenderFunctions';\n\nconst debug = require('debug')('expo:server-routes') as typeof console.log;\n\nconst pendingRouteOperations = new Map<string, Promise<string | null>>();\n\nexport type ApiRouteOptions = {\n mode?: string;\n appDir: string;\n port?: number;\n shouldThrow?: boolean;\n};\n\n// Bundle the API Route with Metro and return the string contents to be evaluated in the server.\nexport async function bundleApiRoute(\n projectRoot: string,\n filepath: string,\n options: ApiRouteOptions\n): Promise<string | null | undefined> {\n if (pendingRouteOperations.has(filepath)) {\n return pendingRouteOperations.get(filepath);\n }\n\n const devServerUrl = `http://localhost:${options.port}`;\n\n async function bundleAsync() {\n try {\n debug('Check API route:', options.appDir, filepath);\n\n const middleware = await requireFileContentsWithMetro(projectRoot, devServerUrl, filepath, {\n minify: options.mode === 'production',\n dev: options.mode !== 'production',\n // Ensure Node.js\n environment: 'node',\n });\n\n return middleware;\n } catch (error: any) {\n if (error instanceof Error) {\n await logMetroErrorAsync({ error, projectRoot });\n }\n if (options.shouldThrow) {\n throw error;\n }\n // TODO: improve error handling, maybe have this be a mock function which returns the static error html\n return null;\n } finally {\n // pendingRouteOperations.delete(filepath);\n }\n }\n const route = bundleAsync();\n\n pendingRouteOperations.set(filepath, route);\n return route;\n}\n\nexport async function rebundleApiRoute(\n projectRoot: string,\n filepath: string,\n options: ApiRouteOptions\n) {\n pendingRouteOperations.delete(filepath);\n return bundleApiRoute(projectRoot, filepath, options);\n}\n"],"names":["bundleApiRoute","rebundleApiRoute","debug","require","pendingRouteOperations","Map","projectRoot","filepath","options","has","get","devServerUrl","port","bundleAsync","appDir","middleware","requireFileContentsWithMetro","minify","mode","dev","environment","error","Error","logMetroErrorAsync","shouldThrow","route","set","delete"],"mappings":"AAOA;;;;QAesBA,cAAc,GAAdA,cAAc;QA0CdC,gBAAgB,GAAhBA,gBAAgB;AAzDH,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AACb,IAAA,yBAA6B,WAA7B,6BAA6B,CAAA;AAE1E,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAsB,AAAC;AAE3E,MAAMC,sBAAsB,GAAG,IAAIC,GAAG,EAAkC,AAAC;AAUlE,eAAeL,cAAc,CAClCM,WAAmB,EACnBC,QAAgB,EAChBC,OAAwB,EACY;IACpC,IAAIJ,sBAAsB,CAACK,GAAG,CAACF,QAAQ,CAAC,EAAE;QACxC,OAAOH,sBAAsB,CAACM,GAAG,CAACH,QAAQ,CAAC,CAAC;KAC7C;IAED,MAAMI,YAAY,GAAG,CAAC,iBAAiB,EAAEH,OAAO,CAACI,IAAI,CAAC,CAAC,AAAC;IAExD,eAAeC,WAAW,GAAG;QAC3B,IAAI;YACFX,KAAK,CAAC,kBAAkB,EAAEM,OAAO,CAACM,MAAM,EAAEP,QAAQ,CAAC,CAAC;YAEpD,MAAMQ,UAAU,GAAG,MAAMC,CAAAA,GAAAA,yBAA4B,AAKnD,CAAA,6BALmD,CAACV,WAAW,EAAEK,YAAY,EAAEJ,QAAQ,EAAE;gBACzFU,MAAM,EAAET,OAAO,CAACU,IAAI,KAAK,YAAY;gBACrCC,GAAG,EAAEX,OAAO,CAACU,IAAI,KAAK,YAAY;gBAClC,iBAAiB;gBACjBE,WAAW,EAAE,MAAM;aACpB,CAAC,AAAC;YAEH,OAAOL,UAAU,CAAC;SACnB,CAAC,OAAOM,KAAK,EAAO;YACnB,IAAIA,KAAK,YAAYC,KAAK,EAAE;gBAC1B,MAAMC,CAAAA,GAAAA,oBAAkB,AAAwB,CAAA,mBAAxB,CAAC;oBAAEF,KAAK;oBAAEf,WAAW;iBAAE,CAAC,CAAC;aAClD;YACD,IAAIE,OAAO,CAACgB,WAAW,EAAE;gBACvB,MAAMH,KAAK,CAAC;aACb;YACD,uGAAuG;YACvG,OAAO,IAAI,CAAC;SACb,QAAS;QACR,2CAA2C;SAC5C;KACF;IACD,MAAMI,KAAK,GAAGZ,WAAW,EAAE,AAAC;IAE5BT,sBAAsB,CAACsB,GAAG,CAACnB,QAAQ,EAAEkB,KAAK,CAAC,CAAC;IAC5C,OAAOA,KAAK,CAAC;CACd;AAEM,eAAexB,gBAAgB,CACpCK,WAAmB,EACnBC,QAAgB,EAChBC,OAAwB,EACxB;IACAJ,sBAAsB,CAACuB,MAAM,CAACpB,QAAQ,CAAC,CAAC;IACxC,OAAOP,cAAc,CAACM,WAAW,EAAEC,QAAQ,EAAEC,OAAO,CAAC,CAAC;CACvD"}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.createFastResolver = createFastResolver;
6
+ var _path = _interopRequireDefault(require("path"));
7
+ var _resolve = _interopRequireDefault(require("resolve"));
8
+ var _externals = require("./externals");
9
+ var _formatFileCandidates = require("./formatFileCandidates");
10
+ var _errors = require("../../../utils/errors");
11
+ function _interopRequireDefault(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ class FailedToResolvePathError extends Error {
17
+ }
18
+ class ShimModuleError extends Error {
19
+ }
20
+ function createFastResolver({ preserveSymlinks }) {
21
+ const cachedExtensions = new Map();
22
+ function getAdjustedExtensions({ metroSourceExtensions , platform , isNative }) {
23
+ const key = JSON.stringify({
24
+ metroSourceExtensions,
25
+ platform,
26
+ isNative
27
+ });
28
+ if (cachedExtensions.has(key)) {
29
+ return cachedExtensions.get(key);
30
+ }
31
+ let output = metroSourceExtensions;
32
+ if (platform) {
33
+ const nextOutput = [];
34
+ output.forEach((ext)=>{
35
+ nextOutput.push(`${platform}.${ext}`);
36
+ if (isNative) {
37
+ nextOutput.push(`native.${ext}`);
38
+ }
39
+ nextOutput.push(ext);
40
+ });
41
+ output = nextOutput;
42
+ }
43
+ output = Array.from(new Set(output));
44
+ // resolve expects these to start with a dot.
45
+ output = output.map((ext)=>`.${ext}`
46
+ );
47
+ cachedExtensions.set(key, output);
48
+ return output;
49
+ }
50
+ function fastResolve(context, moduleName, platform) {
51
+ var ref2;
52
+ // TODO: Support extraNodeModules for tsconfig basePath support
53
+ // TODO: Support package exports import { resolve as resolveExports } from 'resolve.exports'
54
+ // TODO: Support `resolver.blockList`
55
+ if (context.unstable_enablePackageExports) {
56
+ throw new _errors.CommandError("package exports are not supported with EXPO_USE_FAST_RESOLVER=1");
57
+ }
58
+ const environment = (ref2 = context.customResolverOptions) == null ? void 0 : ref2.environment;
59
+ const isServer = environment === "node";
60
+ const extensions = getAdjustedExtensions({
61
+ metroSourceExtensions: context.sourceExts,
62
+ platform,
63
+ isNative: context.preferNativePlatform
64
+ });
65
+ let fp;
66
+ try {
67
+ fp = _resolve.default.sync(moduleName, {
68
+ basedir: _path.default.dirname(context.originModulePath),
69
+ extensions,
70
+ // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and
71
+ // the app doesn't finish without it.
72
+ preserveSymlinks,
73
+ readPackageSync (readFileSync, pkgFile) {
74
+ var ref;
75
+ return (ref = context.getPackage(pkgFile)) != null ? ref : JSON.parse(// @ts-expect-error
76
+ readFileSync(pkgfile));
77
+ },
78
+ moduleDirectory: context.nodeModulesPaths,
79
+ packageFilter (pkg) {
80
+ // set the pkg.main to the first available field in context.mainFields
81
+ for (const field of context.mainFields){
82
+ if (pkg[field] && // object-inspect uses browser: {} in package.json
83
+ typeof pkg[field] === "string") {
84
+ return {
85
+ ...pkg,
86
+ main: pkg[field]
87
+ };
88
+ }
89
+ }
90
+ return pkg;
91
+ },
92
+ pathFilter: isServer ? undefined : (pkg, _resolvedPath, relativePathIn)=>{
93
+ let relativePath = relativePathIn;
94
+ if (relativePath[0] !== ".") {
95
+ relativePath = `./${relativePath}`;
96
+ }
97
+ const replacements = pkg.browser;
98
+ if (replacements === undefined) {
99
+ return "";
100
+ }
101
+ var _relativePath;
102
+ // TODO: Probably use a better extension matching system here.
103
+ // This was added for `uuid/v4` -> `./lib/rng` -> `./lib/rng-browser.js`
104
+ const mappedPath = (_relativePath = replacements[relativePath]) != null ? _relativePath : replacements[relativePath + ".js"];
105
+ if (mappedPath === false) {
106
+ throw new ShimModuleError();
107
+ }
108
+ return mappedPath;
109
+ },
110
+ // Not needed but added for parity...
111
+ // @ts-ignore
112
+ realpathSync: context.unstable_getRealPath
113
+ });
114
+ if (!isServer && (0, _externals).isNodeExternal(fp)) {
115
+ // In this case, mock the file to use an empty module.
116
+ return {
117
+ type: "empty"
118
+ };
119
+ }
120
+ } catch (error) {
121
+ if (error instanceof ShimModuleError) {
122
+ return {
123
+ type: "empty"
124
+ };
125
+ }
126
+ if ("code" in error && error.code === "MODULE_NOT_FOUND") {
127
+ // TODO: Add improved error handling.
128
+ throw new FailedToResolvePathError("The module could not be resolved because no file or module matched the pattern:\n" + ` ${(0, _formatFileCandidates).formatFileCandidates({
129
+ type: "sourceFile",
130
+ filePathPrefix: moduleName,
131
+ candidateExts: extensions
132
+ }, true)}\n\n`);
133
+ }
134
+ throw error;
135
+ }
136
+ if (context.sourceExts.some((ext)=>fp.endsWith(ext)
137
+ )) {
138
+ return {
139
+ type: "sourceFile",
140
+ filePath: fp
141
+ };
142
+ } else {
143
+ // NOTE: platform extensions may not be supported on assets.
144
+ if (platform === "web") {
145
+ // Skip multi-resolution on web/server bundles. Only consideration here is that
146
+ // we may still need it in case the only image is a multi-resolution image.
147
+ return {
148
+ type: "assetFiles",
149
+ filePaths: [
150
+ fp
151
+ ]
152
+ };
153
+ }
154
+ const dirPath = _path.default.dirname(fp);
155
+ const extension = _path.default.extname(fp);
156
+ const basename = _path.default.basename(fp, extension);
157
+ var ref1;
158
+ return {
159
+ type: "assetFiles",
160
+ // Support multi-resolution asset extensions...
161
+ filePaths: (ref1 = context.resolveAsset(dirPath, basename, extension)) != null ? ref1 : [
162
+ fp
163
+ ]
164
+ };
165
+ }
166
+ }
167
+ return fastResolve;
168
+ }
169
+
170
+ //# sourceMappingURL=createExpoMetroResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/createExpoMetroResolver.ts"],"sourcesContent":["/**\n * Copyright © 2023 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 { Resolution, ResolutionContext } from 'metro-resolver';\nimport path from 'path';\nimport nodeResolve from 'resolve';\n\nimport { isNodeExternal } from './externals';\nimport { formatFileCandidates } from './formatFileCandidates';\nimport { CommandError } from '../../../utils/errors';\n\nclass FailedToResolvePathError extends Error {}\n\nclass ShimModuleError extends Error {}\n\nexport function createFastResolver({ preserveSymlinks }: { preserveSymlinks: boolean }) {\n const cachedExtensions: Map<string, readonly string[]> = new Map();\n\n function getAdjustedExtensions({\n metroSourceExtensions,\n platform,\n isNative,\n }: {\n metroSourceExtensions: readonly string[];\n platform: string | null;\n isNative: boolean;\n }): readonly string[] {\n const key = JSON.stringify({ metroSourceExtensions, platform, isNative });\n if (cachedExtensions.has(key)) {\n return cachedExtensions.get(key)!;\n }\n\n let output = metroSourceExtensions;\n if (platform) {\n const nextOutput: string[] = [];\n\n output.forEach((ext) => {\n nextOutput.push(`${platform}.${ext}`);\n if (isNative) {\n nextOutput.push(`native.${ext}`);\n }\n nextOutput.push(ext);\n });\n\n output = nextOutput;\n }\n\n output = Array.from(new Set<string>(output));\n\n // resolve expects these to start with a dot.\n output = output.map((ext) => `.${ext}`);\n\n cachedExtensions.set(key, output);\n\n return output;\n }\n\n function fastResolve(\n context: Pick<\n ResolutionContext,\n | 'unstable_enablePackageExports'\n | 'customResolverOptions'\n | 'sourceExts'\n | 'preferNativePlatform'\n | 'originModulePath'\n | 'getPackage'\n | 'nodeModulesPaths'\n | 'mainFields'\n | 'resolveAsset'\n >,\n moduleName: string,\n platform: string | null\n ): Resolution {\n // TODO: Support extraNodeModules for tsconfig basePath support\n // TODO: Support package exports import { resolve as resolveExports } from 'resolve.exports'\n // TODO: Support `resolver.blockList`\n if (context.unstable_enablePackageExports) {\n throw new CommandError('package exports are not supported with EXPO_USE_FAST_RESOLVER=1');\n }\n\n const environment = context.customResolverOptions?.environment;\n const isServer = environment === 'node';\n\n const extensions = getAdjustedExtensions({\n metroSourceExtensions: context.sourceExts,\n platform,\n isNative: context.preferNativePlatform,\n });\n\n let fp: string;\n\n try {\n fp = nodeResolve.sync(moduleName, {\n basedir: path.dirname(context.originModulePath),\n extensions,\n // Used to ensure files trace to packages instead of node_modules in expo/expo. This is how Metro works and\n // the app doesn't finish without it.\n preserveSymlinks,\n readPackageSync(readFileSync, pkgFile) {\n return (\n context.getPackage(pkgFile) ??\n JSON.parse(\n // @ts-expect-error\n readFileSync(pkgfile)\n )\n );\n },\n moduleDirectory: context.nodeModulesPaths,\n packageFilter(pkg) {\n // set the pkg.main to the first available field in context.mainFields\n for (const field of context.mainFields) {\n if (\n pkg[field] &&\n // object-inspect uses browser: {} in package.json\n typeof pkg[field] === 'string'\n ) {\n return {\n ...pkg,\n main: pkg[field],\n };\n }\n }\n return pkg;\n },\n\n pathFilter: isServer\n ? undefined\n : (pkg: any, _resolvedPath: string, relativePathIn: string): string => {\n let relativePath = relativePathIn;\n if (relativePath[0] !== '.') {\n relativePath = `./${relativePath}`;\n }\n\n const replacements = pkg.browser;\n if (replacements === undefined) {\n return '';\n }\n\n // TODO: Probably use a better extension matching system here.\n // This was added for `uuid/v4` -> `./lib/rng` -> `./lib/rng-browser.js`\n const mappedPath = replacements[relativePath] ?? replacements[relativePath + '.js'];\n if (mappedPath === false) {\n throw new ShimModuleError();\n }\n return mappedPath;\n },\n\n // Not needed but added for parity...\n\n // @ts-ignore\n realpathSync: context.unstable_getRealPath,\n });\n\n if (!isServer && isNodeExternal(fp)) {\n // In this case, mock the file to use an empty module.\n return {\n type: 'empty',\n };\n }\n } catch (error: any) {\n if (error instanceof ShimModuleError) {\n return {\n type: 'empty',\n };\n }\n\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n // TODO: Add improved error handling.\n throw new FailedToResolvePathError(\n 'The module could not be resolved because no file or module matched the pattern:\\n' +\n ` ${formatFileCandidates(\n {\n type: 'sourceFile',\n filePathPrefix: moduleName,\n candidateExts: extensions,\n },\n true\n )}\\n\\n`\n );\n }\n throw error;\n }\n\n if (context.sourceExts.some((ext) => fp.endsWith(ext))) {\n return {\n type: 'sourceFile',\n filePath: fp,\n };\n } else {\n // NOTE: platform extensions may not be supported on assets.\n\n if (platform === 'web') {\n // Skip multi-resolution on web/server bundles. Only consideration here is that\n // we may still need it in case the only image is a multi-resolution image.\n return {\n type: 'assetFiles',\n filePaths: [fp],\n };\n }\n\n const dirPath = path.dirname(fp);\n const extension = path.extname(fp);\n const basename = path.basename(fp, extension);\n return {\n type: 'assetFiles',\n // Support multi-resolution asset extensions...\n filePaths: context.resolveAsset(dirPath, basename, extension) ?? [fp],\n };\n }\n }\n\n return fastResolve;\n}\n"],"names":["createFastResolver","FailedToResolvePathError","Error","ShimModuleError","preserveSymlinks","cachedExtensions","Map","getAdjustedExtensions","metroSourceExtensions","platform","isNative","key","JSON","stringify","has","get","output","nextOutput","forEach","ext","push","Array","from","Set","map","set","fastResolve","context","moduleName","unstable_enablePackageExports","CommandError","environment","customResolverOptions","isServer","extensions","sourceExts","preferNativePlatform","fp","nodeResolve","sync","basedir","path","dirname","originModulePath","readPackageSync","readFileSync","pkgFile","getPackage","parse","pkgfile","moduleDirectory","nodeModulesPaths","packageFilter","pkg","field","mainFields","main","pathFilter","undefined","_resolvedPath","relativePathIn","relativePath","replacements","browser","mappedPath","realpathSync","unstable_getRealPath","isNodeExternal","type","error","code","formatFileCandidates","filePathPrefix","candidateExts","some","endsWith","filePath","filePaths","dirPath","extension","extname","basename","resolveAsset"],"mappings":"AAMA;;;;QAYgBA,kBAAkB,GAAlBA,kBAAkB;AAXjB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,QAAS,kCAAT,SAAS,EAAA;AAEF,IAAA,UAAa,WAAb,aAAa,CAAA;AACP,IAAA,qBAAwB,WAAxB,wBAAwB,CAAA;AAChC,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;;;;;;AAEpD,MAAMC,wBAAwB,SAASC,KAAK;CAAG;AAE/C,MAAMC,eAAe,SAASD,KAAK;CAAG;AAE/B,SAASF,kBAAkB,CAAC,EAAEI,gBAAgB,CAAA,EAAiC,EAAE;IACtF,MAAMC,gBAAgB,GAAmC,IAAIC,GAAG,EAAE,AAAC;IAEnE,SAASC,qBAAqB,CAAC,EAC7BC,qBAAqB,CAAA,EACrBC,QAAQ,CAAA,EACRC,QAAQ,CAAA,EAKT,EAAqB;QACpB,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAAC;YAAEL,qBAAqB;YAAEC,QAAQ;YAAEC,QAAQ;SAAE,CAAC,AAAC;QAC1E,IAAIL,gBAAgB,CAACS,GAAG,CAACH,GAAG,CAAC,EAAE;YAC7B,OAAON,gBAAgB,CAACU,GAAG,CAACJ,GAAG,CAAC,CAAE;SACnC;QAED,IAAIK,MAAM,GAAGR,qBAAqB,AAAC;QACnC,IAAIC,QAAQ,EAAE;YACZ,MAAMQ,UAAU,GAAa,EAAE,AAAC;YAEhCD,MAAM,CAACE,OAAO,CAAC,CAACC,GAAG,GAAK;gBACtBF,UAAU,CAACG,IAAI,CAAC,CAAC,EAAEX,QAAQ,CAAC,CAAC,EAAEU,GAAG,CAAC,CAAC,CAAC,CAAC;gBACtC,IAAIT,QAAQ,EAAE;oBACZO,UAAU,CAACG,IAAI,CAAC,CAAC,OAA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tB,+EAA+E;gBAC/E,2EAA2E;gBAC3E,OAAO;oBACL2D,IAAI,EAAE,YAAY;oBAClBS,SAAS,EAAE;wBAACxC,EAAE;qBAAC;iBAChB,CAAC;aACH;YAED,MAAMyC,OAAO,GAAGrC,KAAI,QAAA,CAACC,OAAO,CAACL,EAAE,CAAC,AAAC;YACjC,MAAM0C,SAAS,GAAGtC,KAAI,QAAA,CAACuC,OAAO,CAAC3C,EAAE,CAAC,AAAC;YACnC,MAAM4C,QAAQ,GAAGxC,KAAI,QAAA,CAACwC,QAAQ,CAAC5C,EAAE,EAAE0C,SAAS,CAAC,AAAC;gBAIjCpD,IAAkD;YAH/D,OAAO;gBACLyC,IAAI,EAAE,YAAY;gBAClB,+CAA+C;gBAC/CS,SAAS,EAAElD,CAAAA,IAAkD,GAAlDA,OAAO,CAACuD,YAAY,CAACJ,OAAO,EAAEG,QAAQ,EAAEF,SAAS,CAAC,YAAlDpD,IAAkD,GAAI;oBAACU,EAAE;iBAAC;aACtE,CAAC;SACH;KACF;IAED,OAAOX,WAAW,CAAC;CACpB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/fetchRouterManifest.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 resolveFrom from 'resolve-from';\n\nimport { getRoutePaths } from './router';\n\nexport type ExpoRouterServerManifestV1Route<TRegex = string> = {\n page: string;\n routeKeys: Record<string, string>;\n namedRegex: TRegex;\n generated?: boolean;\n};\n\nexport type ExpoRouterServerManifestV1<TRegex = string> = {\n apiRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n htmlRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n notFoundRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n};\n\nfunction getExpoRouteManifestBuilderAsync(projectRoot: string) {\n return require(resolveFrom(projectRoot, 'expo-router/build/routes-manifest'))\n .createRoutesManifest as typeof import('expo-router/build/routes-manifest').createRoutesManifest;\n}\n\n// TODO: Simplify this now that we use Node.js directly, no need for the Metro bundler caching layer.\nexport async function fetchManifest<TRegex = string>(\n projectRoot: string,\n options: { asJson?: boolean; appDir: string }\n): Promise<ExpoRouterServerManifestV1<TRegex> | null> {\n const getManifest = getExpoRouteManifestBuilderAsync(projectRoot);\n const paths = getRoutePaths(options.appDir);\n // Get the serialized manifest\n const jsonManifest = getManifest(paths);\n\n if (!jsonManifest) {\n return null;\n }\n\n if (!jsonManifest.htmlRoutes || !jsonManifest.apiRoutes) {\n throw new Error('Routes manifest is malformed: ' + JSON.stringify(jsonManifest, null, 2));\n }\n\n if (!options.asJson) {\n // @ts-expect-error\n return inflateManifest(jsonManifest);\n }\n // @ts-expect-error\n return jsonManifest;\n}\n\n// Convert the serialized manifest to a usable format\nexport function inflateManifest(\n json: ExpoRouterServerManifestV1<string>\n): ExpoRouterServerManifestV1<RegExp> {\n return {\n ...json,\n htmlRoutes: json.htmlRoutes?.map((value) => {\n return {\n ...value,\n namedRegex: new RegExp(value.namedRegex),\n };\n }),\n apiRoutes: json.apiRoutes?.map((value) => {\n return {\n ...value,\n namedRegex: new RegExp(value.namedRegex),\n };\n }),\n notFoundRoutes: json.notFoundRoutes?.map((value) => {\n return {\n ...value,\n namedRegex: new RegExp(value.namedRegex),\n };\n }),\n };\n}\n"],"names":["fetchManifest","inflateManifest","getExpoRouteManifestBuilderAsync","projectRoot","require","resolveFrom","createRoutesManifest","options","getManifest","paths","getRoutePaths","appDir","jsonManifest","htmlRoutes","apiRoutes","Error","JSON","stringify","asJson","json","map","value","namedRegex","RegExp","notFoundRoutes"],"mappings":"AAMA;;;;QAuBsBA,aAAa,GAAbA,aAAa;QA0BnBC,eAAe,GAAfA,eAAe;AAjDP,IAAA,YAAc,kCAAd,cAAc,EAAA;AAER,IAAA,OAAU,WAAV,UAAU,CAAA;;;;;;AAexC,SAASC,gCAAgC,CAACC,WAAmB,EAAE;IAC7D,OAAOC,OAAO,C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SAAS,SAAK,GAAnBK,KAAAA,CAAmB,GAAnBA,IAAc,CAAEC,GAAG,CAAC,CAACC,KAAK,GAAK;YACxC,OAAO;gBACL,GAAGA,KAAK;gBACRC,UAAU,EAAE,IAAIC,MAAM,CAACF,KAAK,CAACC,UAAU,CAAC;aACzC,CAAC;SACH,CAAC;QACFE,cAAc,EAAEL,CAAAA,IAAmB,GAAnBA,IAAI,CAACK,cAAc,SAAK,GAAxBL,KAAAA,CAAwB,GAAxBA,IAAmB,CAAEC,GAAG,CAAC,CAACC,KAAK,GAAK;YAClD,OAAO;gBACL,GAAGA,KAAK;gBACRC,UAAU,EAAE,IAAIC,MAAM,CAACF,KAAK,CAACC,UAAU,CAAC;aACzC,CAAC;SACH,CAAC;KACH,CAAC;CACH"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/fetchRouterManifest.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 resolveFrom from 'resolve-from';\n\nimport { getRoutePaths } from './router';\n\nexport type ExpoRouterServerManifestV1Route<TRegex = string> = {\n file: string;\n page: string;\n routeKeys: Record<string, string>;\n namedRegex: TRegex;\n generated?: boolean;\n};\n\nexport type ExpoRouterServerManifestV1<TRegex = string> = {\n apiRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n htmlRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n notFoundRoutes: ExpoRouterServerManifestV1Route<TRegex>[];\n};\n\nfunction getExpoRouteManifestBuilderAsync(projectRoot: string) {\n return require(resolveFrom(projectRoot, 'expo-router/build/routes-manifest'))\n .createRoutesManifest as typeof import('expo-router/build/routes-manifest').createRoutesManifest;\n}\n\n// TODO: Simplify this now that we use Node.js directly, no need for the Metro bundler caching layer.\nexport async function fetchManifest<TRegex = string>(\n projectRoot: string,\n options: { asJson?: boolean; appDir: string }\n): Promise<ExpoRouterServerManifestV1<TRegex> | null> {\n const getManifest = getExpoRouteManifestBuilderAsync(projectRoot);\n const paths = getRoutePaths(options.appDir);\n // Get the serialized manifest\n const jsonManifest = getManifest(paths);\n\n if (!jsonManifest) {\n return null;\n }\n\n if (!jsonManifest.htmlRoutes || !jsonManifest.apiRoutes) {\n throw new Error('Routes manifest is malformed: ' + JSON.stringify(jsonManifest, null, 2));\n }\n\n if (!options.asJson) {\n // @ts-expect-error\n return inflateManifest(jsonManifest);\n }\n // @ts-expect-error\n return jsonManifest;\n}\n\n// Convert the serialized manifest to a usable format\nexport function inflateManifest(\n json: ExpoRouterServerManifestV1<string>\n): ExpoRouterServerManifestV1<RegExp> {\n return {\n ...json,\n htmlRoutes: json.htmlRoutes?.map((value) => {\n return {\n ...value,\n namedRegex: new RegExp(value.namedRegex),\n };\n }),\n apiRoutes: json.apiRoutes?.map((value) => {\n return {\n ...value,\n namedRegex: new RegExp(value.namedRegex),\n };\n }),\n notFoundRoutes: json.notFoundRoutes?.map((value) => {\n return {\n ...value,\n namedRegex: new RegExp(value.namedRegex),\n };\n }),\n };\n}\n"],"names":["fetchManifest","inflateManifest","getExpoRouteManifestBuilderAsync","projectRoot","require","resolveFrom","createRoutesManifest","options","getManifest","paths","getRoutePaths","appDir","jsonManifest","htmlRoutes","apiRoutes","Error","JSON","stringify","asJson","json","map","value","namedRegex","RegExp","notFoundRoutes"],"mappings":"AAMA;;;;QAwBsBA,aAAa,GAAbA,aAAa;QA0BnBC,eAAe,GAAfA,eAAe;AAlDP,IAAA,YAAc,kCAAd,cAAc,EAAA;AAER,IAAA,OAAU,WAAV,UAAU,CAAA;;;;;;AAgBxC,SAASC,gCAAgC,CAACC,WAAmB,EAAE;IAC7D,OAAOC,OAAO,CAACC,CAAAA,GAAAA,YAAW,AAAkD,CAAA,QAAlD,CAACF,WAAW,EAAE,mCAAmC,CAAC,CAAC,CAC1EG,oBAAoB,CAA4E;CACpG;AAGM,eAAeN,aAAa,CACjCG,WAAmB,EACnBI,OAA6C,EACO;IACpD,MAAMC,WAAW,GAA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C;SACH,CAAC;QACFE,cAAc,EAAEL,CAAAA,IAAmB,GAAnBA,IAAI,CAACK,cAAc,SAAK,GAAxBL,KAAAA,CAAwB,GAAxBA,IAAmB,CAAEC,GAAG,CAAC,CAACC,KAAK,GAAK;YAClD,OAAO;gBACL,GAAGA,KAAK;gBACRC,UAAU,EAAE,IAAIC,MAAM,CAACF,KAAK,CAACC,UAAU,CAAC;aACzC,CAAC;SACH,CAAC;KACH,CAAC;CACH"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.formatFileCandidates = formatFileCandidates;
6
+ var _path = _interopRequireDefault(require("path"));
7
+ function _interopRequireDefault(obj) {
8
+ return obj && obj.__esModule ? obj : {
9
+ default: obj
10
+ };
11
+ }
12
+ function groupExtensions(exts) {
13
+ // Reverse the extensions and split into parts
14
+ const extParts = exts.map((ext)=>ext.split(".").reverse()
15
+ );
16
+ // Find the maximum depth of extension parts
17
+ const maxDepth = Math.max(...extParts.map((parts)=>parts.length
18
+ ));
19
+ // Initialize groups based on the max depth
20
+ const groups = Array.from({
21
+ length: maxDepth
22
+ }, ()=>new Set()
23
+ );
24
+ extParts.forEach((parts)=>{
25
+ parts.forEach((part, i)=>{
26
+ // Add parts to the corresponding group based on their depth
27
+ groups[i].add(part);
28
+ });
29
+ });
30
+ // Cycle groups and remove duplicates that appear forwards
31
+ groups.forEach((group, index)=>{
32
+ // Remove duplicates that appear forwards
33
+ // NOTE: This doesn't support extensions like `.native.native.js`
34
+ groups.forEach((otherGroup, otherIndex)=>{
35
+ if (index < otherIndex) {
36
+ otherGroup.forEach((part)=>group.delete(part)
37
+ );
38
+ }
39
+ });
40
+ });
41
+ // Convert sets back to arrays and reverse groups to correct order
42
+ return groups.map((group)=>Array.from(group)
43
+ ).reverse();
44
+ }
45
+ function createMatcherPatternForExtensions(exts) {
46
+ let formatted = "";
47
+ if (exts.length) {
48
+ // Apply grouping function
49
+ const groups = groupExtensions(exts);
50
+ formatted += groups.map((group, index)=>{
51
+ return index < groups.length - 1 ? `(${group.map((ext)=>`.${ext}`
52
+ ).join("|")})?` : `.(${group.join("|")})`;
53
+ }).join("");
54
+ }
55
+ return formatted;
56
+ }
57
+ function formatFileCandidates(candidates, allowIndex = false) {
58
+ if (candidates.type === "asset") {
59
+ return candidates.name;
60
+ }
61
+ let formatted = candidates.filePathPrefix;
62
+ if (allowIndex) {
63
+ formatted += `(${_path.default.sep}index)?`;
64
+ }
65
+ const extensions = candidates.candidateExts// Drop additional dots, the first character if it is a dot, and remove empty strings.
66
+ .map((ext)=>ext.replace(/\.+/g, ".").replace(/^\./g, "")
67
+ ).filter(Boolean);
68
+ formatted += createMatcherPatternForExtensions(extensions);
69
+ return formatted;
70
+ }
71
+
72
+ //# sourceMappingURL=formatFileCandidates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/formatFileCandidates.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\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 *\n * A fork of my proposed Metro change https://github.com/facebook/metro/pull/1036/files\n */\n\nimport type { FileCandidates } from 'metro-resolver';\nimport path from 'path';\n\nfunction groupExtensions(exts: readonly string[]): string[][] {\n // Reverse the extensions and split into parts\n const extParts = exts.map((ext) => ext.split('.').reverse());\n\n // Find the maximum depth of extension parts\n const maxDepth = Math.max(...extParts.map((parts) => parts.length));\n\n // Initialize groups based on the max depth\n const groups = Array.from({ length: maxDepth }, () => new Set<string>());\n\n extParts.forEach((parts) => {\n parts.forEach((part, i) => {\n // Add parts to the corresponding group based on their depth\n groups[i].add(part);\n });\n });\n\n // Cycle groups and remove duplicates that appear forwards\n groups.forEach((group, index) => {\n // Remove duplicates that appear forwards\n // NOTE: This doesn't support extensions like `.native.native.js`\n groups.forEach((otherGroup, otherIndex) => {\n if (index < otherIndex) {\n otherGroup.forEach((part) => group.delete(part));\n }\n });\n });\n\n // Convert sets back to arrays and reverse groups to correct order\n return groups.map((group) => Array.from(group)).reverse();\n}\n\nfunction createMatcherPatternForExtensions(exts: readonly string[]): string {\n let formatted = '';\n\n if (exts.length) {\n // Apply grouping function\n const groups = groupExtensions(exts);\n\n formatted += groups\n .map((group, index) => {\n return index < groups.length - 1\n ? `(${group.map((ext) => `.${ext}`).join('|')})?`\n : `.(${group.join('|')})`;\n })\n .join('');\n }\n\n return formatted;\n}\n\nexport function formatFileCandidates(\n candidates: FileCandidates,\n allowIndex: boolean = false\n): string {\n if (candidates.type === 'asset') {\n return candidates.name;\n }\n\n let formatted = candidates.filePathPrefix;\n\n if (allowIndex) {\n formatted += `(${path.sep}index)?`;\n }\n\n const extensions = candidates.candidateExts\n // Drop additional dots, the first character if it is a dot, and remove empty strings.\n .map((ext) => ext.replace(/\\.+/g, '.').replace(/^\\./g, ''))\n .filter(Boolean);\n\n formatted += createMatcherPatternForExtensions(extensions);\n\n return formatted;\n}\n"],"names":["formatFileCandidates","groupExtensions","exts","extParts","map","ext","split","reverse","maxDepth","Math","max","parts","length","groups","Array","from","Set","forEach","part","i","add","group","index","otherGroup","otherIndex","delete","createMatcherPatternForExtensions","formatted","join","candidates","allowIndex","type","name","filePathPrefix","path","sep","extensions","candidateExts","replace","filter","Boolean"],"mappings":"AAUA;;;;QAsDgBA,oBAAoB,GAApBA,oBAAoB;AArDnB,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAEvB,SAASC,eAAe,CAACC,IAAuB,EAAc;IAC5D,8CAA8C;IAC9C,MAAMC,QAAQ,GAAGD,IAAI,CAACE,GAAG,CAAC,CAACC,GAAG,GAAKA,GAAG,CAACC,KAAK,CAAC,GAAG,CAAC,CAACC,OAAO,EAAE;IAAA,CAAC,AAAC;IAE7D,4CAA4C;IAC5C,MAAMC,QAAQ,GAAGC,IAAI,CAACC,GAAG,IAAIP,QAAQ,CAACC,GAAG,CAAC,CAACO,KAAK,G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