@expo/cli 0.16.7 → 0.17.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 (67) hide show
  1. package/build/bin/cli +4 -3
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/customize/customizeAsync.js +2 -1
  4. package/build/src/customize/customizeAsync.js.map +1 -1
  5. package/build/src/customize/typescript.js +1 -1
  6. package/build/src/customize/typescript.js.map +1 -1
  7. package/build/src/export/resolveOptions.js +7 -5
  8. package/build/src/export/resolveOptions.js.map +1 -1
  9. package/build/src/export/web/exportWebAsync.js +1 -1
  10. package/build/src/export/web/exportWebAsync.js.map +1 -1
  11. package/build/src/export/web/index.js +1 -1
  12. package/build/src/export/web/index.js.map +1 -1
  13. package/build/src/install/installAsync.js +1 -5
  14. package/build/src/install/installAsync.js.map +1 -1
  15. package/build/src/prebuild/configureProjectAsync.js +7 -1
  16. package/build/src/prebuild/configureProjectAsync.js.map +1 -1
  17. package/build/src/prebuild/prebuildAsync.js +3 -2
  18. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  19. package/build/src/prebuild/resolveTemplate.js +41 -48
  20. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  21. package/build/src/prebuild/updateFromTemplate.js +9 -8
  22. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  23. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +4 -12
  24. package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
  25. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +6 -1
  26. package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
  27. package/build/src/start/platforms/android/ADBServer.js +7 -0
  28. package/build/src/start/platforms/android/ADBServer.js.map +1 -1
  29. package/build/src/start/platforms/android/adb.js +4 -3
  30. package/build/src/start/platforms/android/adb.js.map +1 -1
  31. package/build/src/start/server/DevServerManager.js +2 -2
  32. package/build/src/start/server/DevServerManager.js.map +1 -1
  33. package/build/src/start/server/metro/MetroBundlerDevServer.js +30 -18
  34. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  35. package/build/src/start/server/metro/createServerRouteMiddleware.js +18 -7
  36. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  37. package/build/src/start/server/metro/instantiateMetro.js +5 -7
  38. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  39. package/build/src/start/server/metro/router.js +17 -0
  40. package/build/src/start/server/metro/router.js.map +1 -1
  41. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +1 -1
  42. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
  43. package/build/src/start/server/metro/withMetroMultiPlatform.js +7 -4
  44. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  45. package/build/src/start/server/middleware/CorsMiddleware.js +55 -0
  46. package/build/src/start/server/middleware/CorsMiddleware.js.map +1 -0
  47. package/build/src/start/server/middleware/ManifestMiddleware.js +5 -5
  48. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  49. package/build/src/start/server/platformBundlers.js +18 -5
  50. package/build/src/start/server/platformBundlers.js.map +1 -1
  51. package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
  52. package/build/src/start/server/type-generation/routes.js +1 -1
  53. package/build/src/start/server/type-generation/routes.js.map +1 -1
  54. package/build/src/start/startAsync.js +1 -1
  55. package/build/src/start/startAsync.js.map +1 -1
  56. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  57. package/build/src/utils/env.js +3 -0
  58. package/build/src/utils/env.js.map +1 -1
  59. package/build/src/utils/npm.js +12 -4
  60. package/build/src/utils/npm.js.map +1 -1
  61. package/build/src/utils/resolveArgs.js +8 -2
  62. package/build/src/utils/resolveArgs.js.map +1 -1
  63. package/package.json +3 -3
  64. package/build/src/start/server/middleware/remoteDevtoolsCorsMiddleware.js +0 -31
  65. package/build/src/start/server/middleware/remoteDevtoolsCorsMiddleware.js.map +0 -1
  66. package/build/src/start/server/middleware/remoteDevtoolsSecurityHeadersMiddleware.js +0 -17
  67. package/build/src/start/server/middleware/remoteDevtoolsSecurityHeadersMiddleware.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/metro/withMetroMultiPlatform.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport { ConfigT } from 'metro-config';\nimport { Resolution, ResolutionContext, CustomResolutionContext } from 'metro-resolver';\nimport * as metroResolver from 'metro-resolver';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { createFastResolver } from './createExpoMetroResolver';\nimport {\n EXTERNAL_REQUIRE_NATIVE_POLYFILL,\n EXTERNAL_REQUIRE_POLYFILL,\n METRO_SHIMS_FOLDER,\n getNodeExternalModuleId,\n isNodeExternal,\n setupNodeExternals,\n setupShimFiles,\n} from './externals';\nimport { isFailedToResolveNameError, isFailedToResolvePathError } from './metroErrors';\nimport {\n withMetroErrorReportingResolver,\n withMetroMutatedResolverContext,\n withMetroResolvers,\n} from './withMetroResolvers';\nimport { Log } from '../../../log';\nimport { FileNotifier } from '../../../utils/FileNotifier';\nimport { env } from '../../../utils/env';\nimport { installExitHooks } from '../../../utils/exit';\nimport { isInteractive } from '../../../utils/interactive';\nimport { loadTsConfigPathsAsync, TsConfigPaths } from '../../../utils/tsconfig/loadTsConfigPaths';\nimport { resolveWithTsConfigPaths } from '../../../utils/tsconfig/resolveWithTsConfigPaths';\nimport { WebSupportProjectPrerequisite } from '../../doctor/web/WebSupportProjectPrerequisite';\nimport { PlatformBundlers } from '../platformBundlers';\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\nconst debug = require('debug')('expo:start:server:metro:multi-platform') as typeof console.log;\n\nfunction withWebPolyfills(config: ConfigT): ConfigT {\n const originalGetPolyfills = config.serializer.getPolyfills\n ? config.serializer.getPolyfills.bind(config.serializer)\n : () => [];\n\n const getPolyfills = (ctx: { platform: string | null }): readonly string[] => {\n if (ctx.platform === 'web') {\n return [\n // NOTE: We might need this for all platforms\n path.join(config.projectRoot, EXTERNAL_REQUIRE_POLYFILL),\n // TODO: runtime polyfills, i.e. Fast Refresh, error overlay, React Dev Tools...\n ];\n }\n // Generally uses `rn-get-polyfills`\n const polyfills = originalGetPolyfills(ctx);\n\n return [...polyfills, path.join(config.projectRoot, EXTERNAL_REQUIRE_NATIVE_POLYFILL)];\n };\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n getPolyfills,\n },\n };\n}\n\nfunction normalizeSlashes(p: string) {\n return p.replace(/\\\\/g, '/');\n}\n\nexport function getNodejsExtensions(srcExts: readonly string[]): string[] {\n const mjsExts = srcExts.filter((ext) => /mjs$/.test(ext));\n const nodejsSourceExtensions = srcExts.filter((ext) => !/mjs$/.test(ext));\n // find index of last `*.js` extension\n const jsIndex = nodejsSourceExtensions.reduce((index, ext, i) => {\n return /jsx?$/.test(ext) ? i : index;\n }, -1);\n\n // insert `*.mjs` extensions after `*.js` extensions\n nodejsSourceExtensions.splice(jsIndex + 1, 0, ...mjsExts);\n\n return nodejsSourceExtensions;\n}\n\n/**\n * Apply custom resolvers to do the following:\n * - Disable `.native.js` extensions on web.\n * - Alias `react-native` to `react-native-web` on web.\n * - Redirect `react-native-web/dist/modules/AssetRegistry/index.js` to `@react-native/assets/registry.js` on web.\n * - Add support for `tsconfig.json`/`jsconfig.json` aliases via `compilerOptions.paths`.\n */\nexport function withExtendedResolver(\n config: ConfigT,\n {\n tsconfig,\n isTsconfigPathsEnabled,\n isFastResolverEnabled,\n isExporting,\n }: {\n tsconfig: TsConfigPaths | null;\n isTsconfigPathsEnabled?: boolean;\n isFastResolverEnabled?: boolean;\n isExporting?: boolean;\n }\n) {\n if (isFastResolverEnabled) {\n Log.warn(`Experimental bundling features are enabled.`);\n }\n\n // Get the `transformer.assetRegistryPath`\n // this needs to be unified since you can't dynamically\n // swap out the transformer based on platform.\n const assetRegistryPath = fs.realpathSync(\n path.resolve(resolveFrom(config.projectRoot, '@react-native/assets-registry/registry.js'))\n );\n\n const defaultResolver = metroResolver.resolve;\n const resolver = isFastResolverEnabled\n ? createFastResolver({\n preserveSymlinks: config.resolver?.unstable_enableSymlinks ?? true,\n blockList: Array.isArray(config.resolver?.blockList)\n ? config.resolver?.blockList\n : [config.resolver?.blockList],\n })\n : defaultResolver;\n\n const aliases: { [key: string]: Record<string, string> } = {\n web: {\n 'react-native': 'react-native-web',\n 'react-native/index': 'react-native-web',\n },\n };\n\n const universalAliases: [RegExp, string][] = [];\n\n // This package is currently always installed as it is included in the `expo` package.\n if (resolveFrom.silent(config.projectRoot, '@expo/vector-icons')) {\n debug('Enabling alias: react-native-vector-icons -> @expo/vector-icons');\n universalAliases.push([/^react-native-vector-icons(\\/.*)?/, '@expo/vector-icons$1']);\n }\n\n const preferredMainFields: { [key: string]: string[] } = {\n // Defaults from Expo Webpack. Most packages using `react-native` don't support web\n // in the `react-native` field, so we should prefer the `browser` field.\n // https://github.com/expo/router/issues/37\n web: ['browser', 'module', 'main'],\n };\n\n let tsConfigResolve = tsconfig?.paths\n ? resolveWithTsConfigPaths.bind(resolveWithTsConfigPaths, {\n paths: tsconfig.paths ?? {},\n baseUrl: tsconfig.baseUrl ?? config.projectRoot,\n hasBaseUrl: !!tsconfig.baseUrl,\n })\n : null;\n\n // TODO: Move this to be a transform key for invalidation.\n if (!isExporting && isInteractive()) {\n if (isTsconfigPathsEnabled) {\n // TODO: We should track all the files that used imports and invalidate them\n // currently the user will need to save all the files that use imports to\n // use the new aliases.\n const configWatcher = new FileNotifier(config.projectRoot, [\n './tsconfig.json',\n './jsconfig.json',\n ]);\n configWatcher.startObserving(() => {\n debug('Reloading tsconfig.json');\n loadTsConfigPathsAsync(config.projectRoot).then((tsConfigPaths) => {\n if (tsConfigPaths?.paths && !!Object.keys(tsConfigPaths.paths).length) {\n debug('Enabling tsconfig.json paths support');\n tsConfigResolve = resolveWithTsConfigPaths.bind(resolveWithTsConfigPaths, {\n paths: tsConfigPaths.paths ?? {},\n baseUrl: tsConfigPaths.baseUrl ?? config.projectRoot,\n hasBaseUrl: !!tsConfigPaths.baseUrl,\n });\n } else {\n debug('Disabling tsconfig.json paths support');\n tsConfigResolve = null;\n }\n });\n });\n\n // TODO: This probably prevents the process from exiting.\n installExitHooks(() => {\n configWatcher.stopObserving();\n });\n } else {\n debug('Skipping tsconfig.json paths support');\n }\n }\n\n let nodejsSourceExtensions: string[] | null = null;\n\n const shimsFolder = path.join(config.projectRoot, METRO_SHIMS_FOLDER);\n\n function getStrictResolver(\n { resolveRequest, ...context }: ResolutionContext,\n platform: string | null\n ) {\n return function doResolve(moduleName: string): Resolution {\n return resolver(context, moduleName, platform);\n };\n }\n\n function getOptionalResolver(context: ResolutionContext, platform: string | null) {\n const doResolve = getStrictResolver(context, platform);\n return function optionalResolve(moduleName: string): Resolution | null {\n try {\n return doResolve(moduleName);\n } catch (error) {\n // If the error is directly related to a resolver not being able to resolve a module, then\n // we can ignore the error and try the next resolver. Otherwise, we should throw the error.\n const isResolutionError =\n isFailedToResolveNameError(error) || isFailedToResolvePathError(error);\n if (!isResolutionError) {\n throw error;\n }\n }\n return null;\n };\n }\n\n const metroConfigWithCustomResolver = withMetroResolvers(config, [\n // tsconfig paths\n (context: ResolutionContext, moduleName: string, platform: string | null) => {\n return (\n tsConfigResolve?.(\n {\n originModulePath: context.originModulePath,\n moduleName,\n },\n getOptionalResolver(context, platform)\n ) ?? null\n );\n },\n\n // Node.js externals support\n (context: ResolutionContext, moduleName: string, platform: string | null) => {\n // This is a web-only feature, we may extend the shimming to native platforms in the future.\n if (platform !== 'web') {\n return null;\n }\n\n const moduleId = isNodeExternal(moduleName);\n if (!moduleId) {\n return null;\n }\n\n if (\n // In browser runtimes, we want to either resolve a local node module by the same name, or shim the module to\n // prevent crashing when Node.js built-ins are imported.\n context.customResolverOptions?.environment !== 'node'\n ) {\n // Perform optional resolve first. If the module doesn't exist (no module in the node_modules)\n // then we can mock the file to use an empty module.\n const result = getOptionalResolver(context, platform)(moduleName);\n return (\n result ?? {\n // In this case, mock the file to use an empty module.\n type: 'empty',\n }\n );\n }\n\n const redirectedModuleName = getNodeExternalModuleId(context.originModulePath, moduleId);\n debug(`Redirecting Node.js external \"${moduleId}\" to \"${redirectedModuleName}\"`);\n return getStrictResolver(context, platform)(redirectedModuleName);\n },\n\n // Basic moduleId aliases\n (context: ResolutionContext, moduleName: string, platform: string | null) => {\n // Conditionally remap `react-native` to `react-native-web` on web in\n // a way that doesn't require Babel to resolve the alias.\n if (platform && platform in aliases && aliases[platform][moduleName]) {\n const redirectedModuleName = aliases[platform][moduleName];\n return getStrictResolver(context, platform)(redirectedModuleName);\n }\n\n for (const [matcher, alias] of universalAliases) {\n const match = moduleName.match(matcher);\n if (match) {\n const aliasedModule = alias.replace(\n /\\$(\\d+)/g,\n (_, index) => match[parseInt(index, 10)] ?? ''\n );\n const doResolve = getStrictResolver(context, platform);\n debug(`Alias \"${moduleName}\" to \"${aliasedModule}\"`);\n return doResolve(aliasedModule);\n }\n }\n\n return null;\n },\n\n // HACK(EvanBacon):\n // React Native uses `event-target-shim` incorrectly and this causes the native runtime\n // to fail to load. This is a temporary workaround until we can fix this upstream.\n // https://github.com/facebook/react-native/pull/38628\n (context: ResolutionContext, moduleName: string, platform: string | null) => {\n if (platform !== 'web' && moduleName === 'event-target-shim') {\n debug('For event-target-shim to use js:', context.originModulePath);\n const doResolve = getStrictResolver(context, platform);\n return doResolve('event-target-shim/dist/event-target-shim.js');\n }\n\n return null;\n },\n\n // TODO: Reduce these as much as possible in the future.\n // Complex post-resolution rewrites.\n (context: ResolutionContext, moduleName: string, platform: string | null) => {\n const doResolve = getStrictResolver(context, platform);\n\n const result = doResolve(moduleName);\n\n if (result.type !== 'sourceFile') {\n return result;\n }\n\n // Replace the web resolver with the original one.\n // This is basically an alias for web-only.\n // TODO: Drop this in favor of the standalone asset registry module.\n if (shouldAliasAssetRegistryForWeb(platform, result)) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = assetRegistryPath;\n }\n\n if (platform === 'web' && result.filePath.includes('node_modules')) {\n // Replace with static shims\n\n const normalName = normalizeSlashes(result.filePath)\n // Drop everything up until the `node_modules` folder.\n .replace(/.*node_modules\\//, '');\n\n const shimPath = path.join(shimsFolder, normalName);\n if (fs.existsSync(shimPath)) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = shimPath;\n }\n }\n\n return result;\n },\n ]);\n\n // Ensure we mutate the resolution context to include the custom resolver options for server and web.\n const metroConfigWithCustomContext = withMetroMutatedResolverContext(\n metroConfigWithCustomResolver,\n (\n immutableContext: CustomResolutionContext,\n moduleName: string,\n platform: string | null\n ): CustomResolutionContext => {\n const context: Mutable<CustomResolutionContext> = {\n ...immutableContext,\n preferNativePlatform: platform !== 'web',\n };\n\n if (context.customResolverOptions?.environment === 'node') {\n // Adjust nodejs source extensions to sort mjs after js, including platform variants.\n if (nodejsSourceExtensions === null) {\n nodejsSourceExtensions = getNodejsExtensions(context.sourceExts);\n }\n context.sourceExts = nodejsSourceExtensions;\n\n context.unstable_enablePackageExports = true;\n context.unstable_conditionNames = ['node', 'require'];\n context.unstable_conditionsByPlatform = {};\n // Node.js runtimes should only be importing main at the moment.\n // This is a temporary fix until we can support the package.json exports.\n context.mainFields = ['main', 'module'];\n } else {\n // Non-server changes\n\n if (!env.EXPO_METRO_NO_MAIN_FIELD_OVERRIDE && platform && platform in preferredMainFields) {\n context.mainFields = preferredMainFields[platform];\n }\n }\n\n return context;\n }\n );\n\n return withMetroErrorReportingResolver(metroConfigWithCustomContext);\n}\n\n/** @returns `true` if the incoming resolution should be swapped on web. */\nexport function shouldAliasAssetRegistryForWeb(\n platform: string | null,\n result: Resolution\n): boolean {\n return (\n platform === 'web' &&\n result?.type === 'sourceFile' &&\n typeof result?.filePath === 'string' &&\n normalizeSlashes(result.filePath).endsWith(\n 'react-native-web/dist/modules/AssetRegistry/index.js'\n )\n );\n}\n/** @returns `true` if the incoming resolution should be swapped. */\nexport function shouldAliasModule(\n input: {\n platform: string | null;\n result: Resolution;\n },\n alias: { platform: string; output: string }\n): boolean {\n return (\n input.platform === alias.platform &&\n input.result?.type === 'sourceFile' &&\n typeof input.result?.filePath === 'string' &&\n normalizeSlashes(input.result.filePath).endsWith(alias.output)\n );\n}\n\n/** Add support for `react-native-web` and the Web platform. */\nexport async function withMetroMultiPlatformAsync(\n projectRoot: string,\n {\n config,\n platformBundlers,\n isTsconfigPathsEnabled,\n webOutput,\n isFastResolverEnabled,\n isExporting,\n }: {\n config: ConfigT;\n isTsconfigPathsEnabled: boolean;\n platformBundlers: PlatformBundlers;\n webOutput?: 'single' | 'static' | 'server';\n isFastResolverEnabled?: boolean;\n isExporting?: boolean;\n }\n) {\n if (!config.projectRoot) {\n // @ts-expect-error: read-only types\n config.projectRoot = projectRoot;\n }\n\n // Required for @expo/metro-runtime to format paths in the web LogBox.\n process.env.EXPO_PUBLIC_PROJECT_ROOT = process.env.EXPO_PUBLIC_PROJECT_ROOT ?? projectRoot;\n\n if (['static', 'server'].includes(webOutput ?? '')) {\n // Enable static rendering in runtime space.\n process.env.EXPO_PUBLIC_USE_STATIC = '1';\n }\n\n // This is used for running Expo CLI in development against projects outside the monorepo.\n if (!isDirectoryIn(__dirname, projectRoot)) {\n if (!config.watchFolders) {\n // @ts-expect-error: watchFolders is readonly\n config.watchFolders = [];\n }\n // @ts-expect-error: watchFolders is readonly\n config.watchFolders.push(path.join(require.resolve('metro-runtime/package.json'), '../..'));\n }\n\n // @ts-expect-error\n config.transformer._expoRouterWebRendering = webOutput;\n // @ts-expect-error: Invalidate the cache when the location of expo-router changes on-disk.\n config.transformer._expoRouterPath = resolveFrom.silent(projectRoot, 'expo-router');\n\n if (platformBundlers.web === 'metro') {\n await new WebSupportProjectPrerequisite(projectRoot).assertAsync();\n }\n\n let tsconfig: null | TsConfigPaths = null;\n\n if (isTsconfigPathsEnabled) {\n tsconfig = await loadTsConfigPathsAsync(projectRoot);\n }\n\n await setupShimFiles(projectRoot);\n await setupNodeExternals(projectRoot);\n\n let expoConfigPlatforms = Object.entries(platformBundlers)\n .filter(([, bundler]) => bundler === 'metro')\n .map(([platform]) => platform);\n\n if (Array.isArray(config.resolver.platforms)) {\n expoConfigPlatforms = [...new Set(expoConfigPlatforms.concat(config.resolver.platforms))];\n }\n\n // @ts-expect-error: typed as `readonly`.\n config.resolver.platforms = expoConfigPlatforms;\n\n config = withWebPolyfills(config);\n\n return withExtendedResolver(config, {\n tsconfig,\n isExporting,\n isTsconfigPathsEnabled,\n isFastResolverEnabled,\n });\n}\n\nfunction isDirectoryIn(a: string, b: string) {\n return b.startsWith(a) && b.length > a.length;\n}\n"],"names":["getNodejsExtensions","withExtendedResolver","shouldAliasAssetRegistryForWeb","shouldAliasModule","withMetroMultiPlatformAsync","metroResolver","debug","require","withWebPolyfills","config","originalGetPolyfills","serializer","getPolyfills","bind","ctx","platform","path","join","projectRoot","EXTERNAL_REQUIRE_POLYFILL","polyfills","EXTERNAL_REQUIRE_NATIVE_POLYFILL","normalizeSlashes","p","replace","srcExts","mjsExts","filter","ext","test","nodejsSourceExtensions","jsIndex","reduce","index","i","splice","tsconfig","isTsconfigPathsEnabled","isFastResolverEnabled","isExporting","Log","warn","assetRegistryPath","fs","realpathSync","resolve","resolveFrom","defaultResolver","resolver","createFastResolver","preserveSymlinks","unstable_enableSymlinks","blockList","Array","isArray","aliases","web","universalAliases","silent","push","preferredMainFields","tsConfigResolve","paths","resolveWithTsConfigPaths","baseUrl","hasBaseUrl","isInteractive","configWatcher","FileNotifier","startObserving","loadTsConfigPathsAsync","then","tsConfigPaths","Object","keys","length","installExitHooks","stopObserving","shimsFolder","METRO_SHIMS_FOLDER","getStrictResolver","resolveRequest","context","doResolve","moduleName","getOptionalResolver","optionalResolve","error","isResolutionError","isFailedToResolveNameError","isFailedToResolvePathError","metroConfigWithCustomResolver","withMetroResolvers","originModulePath","moduleId","isNodeExternal","customResolverOptions","environment","result","type","redirectedModuleName","getNodeExternalModuleId","matcher","alias","match","aliasedModule","_","parseInt","filePath","includes","normalName","shimPath","existsSync","metroConfigWithCustomContext","withMetroMutatedResolverContext","immutableContext","preferNativePlatform","sourceExts","unstable_enablePackageExports","unstable_conditionNames","unstable_conditionsByPlatform","mainFields","env","EXPO_METRO_NO_MAIN_FIELD_OVERRIDE","withMetroErrorReportingResolver","endsWith","input","output","platformBundlers","webOutput","process","EXPO_PUBLIC_PROJECT_ROOT","EXPO_PUBLIC_USE_STATIC","isDirectoryIn","__dirname","watchFolders","transformer","_expoRouterWebRendering","_expoRouterPath","WebSupportProjectPrerequisite","assertAsync","setupShimFiles","setupNodeExternals","expoConfigPlatforms","entries","bundler","map","platforms","Set","concat","a","b","startsWith"],"mappings":"AAMA;;;;QAqEgBA,mBAAmB,GAAnBA,mBAAmB;QAqBnBC,oBAAoB,GAApBA,oBAAoB;QAySpBC,8BAA8B,GAA9BA,8BAA8B;QAc9BC,iBAAiB,GAAjBA,iBAAiB;QAgBXC,2BAA2B,GAA3BA,2BAA2B;AAjalC,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAGPC,IAAAA,aAAa,mCAAM,gBAAgB,EAAtB;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEH,IAAA,wBAA2B,WAA3B,2BAA2B,CAAA;AASvD,IAAA,UAAa,WAAb,aAAa,CAAA;AACmD,IAAA,YAAe,WAAf,eAAe,CAAA;AAK/E,IAAA,mBAAsB,WAAtB,sBAAsB,CAAA;AACT,IAAA,IAAc,WAAd,cAAc,CAAA;AACL,IAAA,aAA6B,WAA7B,6BAA6B,CAAA;AACtC,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACP,IAAA,KAAqB,WAArB,qBAAqB,CAAA;AACxB,IAAA,YAA4B,WAA5B,4BAA4B,CAAA;AACJ,IAAA,kBAA2C,WAA3C,2CAA2C,CAAA;AACxD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IAElC,OAAOR,oBAAoB,CAACQ,MAAM,EAAE;QAClC2B,QAAQ;QACRG,WAAW;QACXF,sBAAsB;QACtBC,qBAAqB;KACtB,CAAC,CAAC;CACJ;AAED,SAAS+F,aAAa,CAACiB,CAAS,EAAEC,CAAS,EAAE;IAC3C,OAAOA,CAAC,CAACC,UAAU,CAACF,CAAC,CAAC,IAAIC,CAAC,CAAC5E,MAAM,GAAG2E,CAAC,CAAC3E,MAAM,CAAC;CAC/C"}
1
+ {"version":3,"sources":["../../../../../src/start/server/metro/withMetroMultiPlatform.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { ExpoConfig, Platform } from '@expo/config';\nimport fs from 'fs';\nimport { ConfigT } from 'metro-config';\nimport { Resolution, ResolutionContext, CustomResolutionContext } from 'metro-resolver';\nimport * as metroResolver from 'metro-resolver';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { createFastResolver } from './createExpoMetroResolver';\nimport {\n EXTERNAL_REQUIRE_NATIVE_POLYFILL,\n EXTERNAL_REQUIRE_POLYFILL,\n METRO_SHIMS_FOLDER,\n getNodeExternalModuleId,\n isNodeExternal,\n setupNodeExternals,\n setupShimFiles,\n} from './externals';\nimport { isFailedToResolveNameError, isFailedToResolvePathError } from './metroErrors';\nimport {\n withMetroErrorReportingResolver,\n withMetroMutatedResolverContext,\n withMetroResolvers,\n} from './withMetroResolvers';\nimport { Log } from '../../../log';\nimport { FileNotifier } from '../../../utils/FileNotifier';\nimport { env } from '../../../utils/env';\nimport { installExitHooks } from '../../../utils/exit';\nimport { isInteractive } from '../../../utils/interactive';\nimport { loadTsConfigPathsAsync, TsConfigPaths } from '../../../utils/tsconfig/loadTsConfigPaths';\nimport { resolveWithTsConfigPaths } from '../../../utils/tsconfig/resolveWithTsConfigPaths';\nimport { WebSupportProjectPrerequisite } from '../../doctor/web/WebSupportProjectPrerequisite';\nimport { PlatformBundlers } from '../platformBundlers';\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\nconst debug = require('debug')('expo:start:server:metro:multi-platform') as typeof console.log;\n\nfunction withWebPolyfills(config: ConfigT): ConfigT {\n const originalGetPolyfills = config.serializer.getPolyfills\n ? config.serializer.getPolyfills.bind(config.serializer)\n : () => [];\n\n const getPolyfills = (ctx: { platform: string | null }): readonly string[] => {\n if (ctx.platform === 'web') {\n return [\n // NOTE: We might need this for all platforms\n path.join(config.projectRoot, EXTERNAL_REQUIRE_POLYFILL),\n // TODO: runtime polyfills, i.e. Fast Refresh, error overlay, React Dev Tools...\n ];\n }\n // Generally uses `rn-get-polyfills`\n const polyfills = originalGetPolyfills(ctx);\n\n return [...polyfills, path.join(config.projectRoot, EXTERNAL_REQUIRE_NATIVE_POLYFILL)];\n };\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n getPolyfills,\n },\n };\n}\n\nfunction normalizeSlashes(p: string) {\n return p.replace(/\\\\/g, '/');\n}\n\nexport function getNodejsExtensions(srcExts: readonly string[]): string[] {\n const mjsExts = srcExts.filter((ext) => /mjs$/.test(ext));\n const nodejsSourceExtensions = srcExts.filter((ext) => !/mjs$/.test(ext));\n // find index of last `*.js` extension\n const jsIndex = nodejsSourceExtensions.reduce((index, ext, i) => {\n return /jsx?$/.test(ext) ? i : index;\n }, -1);\n\n // insert `*.mjs` extensions after `*.js` extensions\n nodejsSourceExtensions.splice(jsIndex + 1, 0, ...mjsExts);\n\n return nodejsSourceExtensions;\n}\n\n/**\n * Apply custom resolvers to do the following:\n * - Disable `.native.js` extensions on web.\n * - Alias `react-native` to `react-native-web` on web.\n * - Redirect `react-native-web/dist/modules/AssetRegistry/index.js` to `@react-native/assets/registry.js` on web.\n * - Add support for `tsconfig.json`/`jsconfig.json` aliases via `compilerOptions.paths`.\n */\nexport function withExtendedResolver(\n config: ConfigT,\n {\n tsconfig,\n isTsconfigPathsEnabled,\n isFastResolverEnabled,\n isExporting,\n }: {\n tsconfig: TsConfigPaths | null;\n isTsconfigPathsEnabled?: boolean;\n isFastResolverEnabled?: boolean;\n isExporting?: boolean;\n }\n) {\n if (isFastResolverEnabled) {\n Log.warn(`Experimental bundling features are enabled.`);\n }\n\n // Get the `transformer.assetRegistryPath`\n // this needs to be unified since you can't dynamically\n // swap out the transformer based on platform.\n const assetRegistryPath = fs.realpathSync(\n path.resolve(resolveFrom(config.projectRoot, '@react-native/assets-registry/registry.js'))\n );\n\n const defaultResolver = metroResolver.resolve;\n const resolver = isFastResolverEnabled\n ? createFastResolver({\n preserveSymlinks: config.resolver?.unstable_enableSymlinks ?? true,\n blockList: Array.isArray(config.resolver?.blockList)\n ? config.resolver?.blockList\n : [config.resolver?.blockList],\n })\n : defaultResolver;\n\n const aliases: { [key: string]: Record<string, string> } = {\n web: {\n 'react-native': 'react-native-web',\n 'react-native/index': 'react-native-web',\n },\n };\n\n const universalAliases: [RegExp, string][] = [];\n\n // This package is currently always installed as it is included in the `expo` package.\n if (resolveFrom.silent(config.projectRoot, '@expo/vector-icons')) {\n debug('Enabling alias: react-native-vector-icons -> @expo/vector-icons');\n universalAliases.push([/^react-native-vector-icons(\\/.*)?/, '@expo/vector-icons$1']);\n }\n\n const preferredMainFields: { [key: string]: string[] } = {\n // Defaults from Expo Webpack. Most packages using `react-native` don't support web\n // in the `react-native` field, so we should prefer the `browser` field.\n // https://github.com/expo/router/issues/37\n web: ['browser', 'module', 'main'],\n };\n\n let tsConfigResolve = tsconfig?.paths\n ? resolveWithTsConfigPaths.bind(resolveWithTsConfigPaths, {\n paths: tsconfig.paths ?? {},\n baseUrl: tsconfig.baseUrl ?? config.projectRoot,\n hasBaseUrl: !!tsconfig.baseUrl,\n })\n : null;\n\n // TODO: Move this to be a transform key for invalidation.\n if (!isExporting && isInteractive()) {\n if (isTsconfigPathsEnabled) {\n // TODO: We should track all the files that used imports and invalidate them\n // currently the user will need to save all the files that use imports to\n // use the new aliases.\n const configWatcher = new FileNotifier(config.projectRoot, [\n './tsconfig.json',\n './jsconfig.json',\n ]);\n configWatcher.startObserving(() => {\n debug('Reloading tsconfig.json');\n loadTsConfigPathsAsync(config.projectRoot).then((tsConfigPaths) => {\n if (tsConfigPaths?.paths && !!Object.keys(tsConfigPaths.paths).length) {\n debug('Enabling tsconfig.json paths support');\n tsConfigResolve = resolveWithTsConfigPaths.bind(resolveWithTsConfigPaths, {\n paths: tsConfigPaths.paths ?? {},\n baseUrl: tsConfigPaths.baseUrl ?? config.projectRoot,\n hasBaseUrl: !!tsConfigPaths.baseUrl,\n });\n } else {\n debug('Disabling tsconfig.json paths support');\n tsConfigResolve = null;\n }\n });\n });\n\n // TODO: This probably prevents the process from exiting.\n installExitHooks(() => {\n configWatcher.stopObserving();\n });\n } else {\n debug('Skipping tsconfig.json paths support');\n }\n }\n\n let nodejsSourceExtensions: string[] | null = null;\n\n const shimsFolder = path.join(config.projectRoot, METRO_SHIMS_FOLDER);\n\n function getStrictResolver(\n { resolveRequest, ...context }: ResolutionContext,\n platform: string | null\n ) {\n return function doResolve(moduleName: string): Resolution {\n return resolver(context, moduleName, platform);\n };\n }\n\n function getOptionalResolver(context: ResolutionContext, platform: string | null) {\n const doResolve = getStrictResolver(context, platform);\n return function optionalResolve(moduleName: string): Resolution | null {\n try {\n return doResolve(moduleName);\n } catch (error) {\n // If the error is directly related to a resolver not being able to resolve a module, then\n // we can ignore the error and try the next resolver. Otherwise, we should throw the error.\n const isResolutionError =\n isFailedToResolveNameError(error) || isFailedToResolvePathError(error);\n if (!isResolutionError) {\n throw error;\n }\n }\n return null;\n };\n }\n\n const metroConfigWithCustomResolver = withMetroResolvers(config, [\n // tsconfig paths\n (context: ResolutionContext, moduleName: string, platform: string | null) => {\n return (\n tsConfigResolve?.(\n {\n originModulePath: context.originModulePath,\n moduleName,\n },\n getOptionalResolver(context, platform)\n ) ?? null\n );\n },\n\n // Node.js externals support\n (context: ResolutionContext, moduleName: string, platform: string | null) => {\n // This is a web-only feature, we may extend the shimming to native platforms in the future.\n if (platform !== 'web') {\n return null;\n }\n\n const moduleId = isNodeExternal(moduleName);\n if (!moduleId) {\n return null;\n }\n\n if (\n // In browser runtimes, we want to either resolve a local node module by the same name, or shim the module to\n // prevent crashing when Node.js built-ins are imported.\n context.customResolverOptions?.environment !== 'node'\n ) {\n // Perform optional resolve first. If the module doesn't exist (no module in the node_modules)\n // then we can mock the file to use an empty module.\n const result = getOptionalResolver(context, platform)(moduleName);\n return (\n result ?? {\n // In this case, mock the file to use an empty module.\n type: 'empty',\n }\n );\n }\n\n const redirectedModuleName = getNodeExternalModuleId(context.originModulePath, moduleId);\n debug(`Redirecting Node.js external \"${moduleId}\" to \"${redirectedModuleName}\"`);\n return getStrictResolver(context, platform)(redirectedModuleName);\n },\n\n // Basic moduleId aliases\n (context: ResolutionContext, moduleName: string, platform: string | null) => {\n // Conditionally remap `react-native` to `react-native-web` on web in\n // a way that doesn't require Babel to resolve the alias.\n if (platform && platform in aliases && aliases[platform][moduleName]) {\n const redirectedModuleName = aliases[platform][moduleName];\n return getStrictResolver(context, platform)(redirectedModuleName);\n }\n\n for (const [matcher, alias] of universalAliases) {\n const match = moduleName.match(matcher);\n if (match) {\n const aliasedModule = alias.replace(\n /\\$(\\d+)/g,\n (_, index) => match[parseInt(index, 10)] ?? ''\n );\n const doResolve = getStrictResolver(context, platform);\n debug(`Alias \"${moduleName}\" to \"${aliasedModule}\"`);\n return doResolve(aliasedModule);\n }\n }\n\n return null;\n },\n\n // HACK(EvanBacon):\n // React Native uses `event-target-shim` incorrectly and this causes the native runtime\n // to fail to load. This is a temporary workaround until we can fix this upstream.\n // https://github.com/facebook/react-native/pull/38628\n (context: ResolutionContext, moduleName: string, platform: string | null) => {\n if (platform !== 'web' && moduleName === 'event-target-shim') {\n debug('For event-target-shim to use js:', context.originModulePath);\n const doResolve = getStrictResolver(context, platform);\n return doResolve('event-target-shim/dist/event-target-shim.js');\n }\n\n return null;\n },\n\n // TODO: Reduce these as much as possible in the future.\n // Complex post-resolution rewrites.\n (context: ResolutionContext, moduleName: string, platform: string | null) => {\n const doResolve = getStrictResolver(context, platform);\n\n const result = doResolve(moduleName);\n\n if (result.type !== 'sourceFile') {\n return result;\n }\n\n // Replace the web resolver with the original one.\n // This is basically an alias for web-only.\n // TODO: Drop this in favor of the standalone asset registry module.\n if (shouldAliasAssetRegistryForWeb(platform, result)) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = assetRegistryPath;\n }\n\n if (platform === 'web' && result.filePath.includes('node_modules')) {\n // Replace with static shims\n\n const normalName = normalizeSlashes(result.filePath)\n // Drop everything up until the `node_modules` folder.\n .replace(/.*node_modules\\//, '');\n\n const shimPath = path.join(shimsFolder, normalName);\n if (fs.existsSync(shimPath)) {\n // @ts-expect-error: `readonly` for some reason.\n result.filePath = shimPath;\n }\n }\n\n return result;\n },\n ]);\n\n // Ensure we mutate the resolution context to include the custom resolver options for server and web.\n const metroConfigWithCustomContext = withMetroMutatedResolverContext(\n metroConfigWithCustomResolver,\n (\n immutableContext: CustomResolutionContext,\n moduleName: string,\n platform: string | null\n ): CustomResolutionContext => {\n const context: Mutable<CustomResolutionContext> = {\n ...immutableContext,\n preferNativePlatform: platform !== 'web',\n };\n\n if (context.customResolverOptions?.environment === 'node') {\n // Adjust nodejs source extensions to sort mjs after js, including platform variants.\n if (nodejsSourceExtensions === null) {\n nodejsSourceExtensions = getNodejsExtensions(context.sourceExts);\n }\n context.sourceExts = nodejsSourceExtensions;\n\n context.unstable_enablePackageExports = true;\n context.unstable_conditionNames = ['node', 'require'];\n context.unstable_conditionsByPlatform = {};\n // Node.js runtimes should only be importing main at the moment.\n // This is a temporary fix until we can support the package.json exports.\n context.mainFields = ['main', 'module'];\n } else {\n // Non-server changes\n\n if (!env.EXPO_METRO_NO_MAIN_FIELD_OVERRIDE && platform && platform in preferredMainFields) {\n context.mainFields = preferredMainFields[platform];\n }\n }\n\n return context;\n }\n );\n\n return withMetroErrorReportingResolver(metroConfigWithCustomContext);\n}\n\n/** @returns `true` if the incoming resolution should be swapped on web. */\nexport function shouldAliasAssetRegistryForWeb(\n platform: string | null,\n result: Resolution\n): boolean {\n return (\n platform === 'web' &&\n result?.type === 'sourceFile' &&\n typeof result?.filePath === 'string' &&\n normalizeSlashes(result.filePath).endsWith(\n 'react-native-web/dist/modules/AssetRegistry/index.js'\n )\n );\n}\n/** @returns `true` if the incoming resolution should be swapped. */\nexport function shouldAliasModule(\n input: {\n platform: string | null;\n result: Resolution;\n },\n alias: { platform: string; output: string }\n): boolean {\n return (\n input.platform === alias.platform &&\n input.result?.type === 'sourceFile' &&\n typeof input.result?.filePath === 'string' &&\n normalizeSlashes(input.result.filePath).endsWith(alias.output)\n );\n}\n\n/** Add support for `react-native-web` and the Web platform. */\nexport async function withMetroMultiPlatformAsync(\n projectRoot: string,\n {\n config,\n exp,\n platformBundlers,\n isTsconfigPathsEnabled,\n webOutput,\n isFastResolverEnabled,\n isExporting,\n }: {\n config: ConfigT;\n exp: ExpoConfig;\n isTsconfigPathsEnabled: boolean;\n platformBundlers: PlatformBundlers;\n webOutput?: 'single' | 'static' | 'server';\n isFastResolverEnabled?: boolean;\n isExporting?: boolean;\n }\n) {\n if (!config.projectRoot) {\n // @ts-expect-error: read-only types\n config.projectRoot = projectRoot;\n }\n\n // Required for @expo/metro-runtime to format paths in the web LogBox.\n process.env.EXPO_PUBLIC_PROJECT_ROOT = process.env.EXPO_PUBLIC_PROJECT_ROOT ?? projectRoot;\n\n if (['static', 'server'].includes(webOutput ?? '')) {\n // Enable static rendering in runtime space.\n process.env.EXPO_PUBLIC_USE_STATIC = '1';\n }\n\n // This is used for running Expo CLI in development against projects outside the monorepo.\n if (!isDirectoryIn(__dirname, projectRoot)) {\n if (!config.watchFolders) {\n // @ts-expect-error: watchFolders is readonly\n config.watchFolders = [];\n }\n // @ts-expect-error: watchFolders is readonly\n config.watchFolders.push(path.join(require.resolve('metro-runtime/package.json'), '../..'));\n }\n\n // @ts-expect-error\n config.transformer._expoRouterWebRendering = webOutput;\n // @ts-expect-error: Invalidate the cache when the location of expo-router changes on-disk.\n config.transformer._expoRouterPath = resolveFrom.silent(projectRoot, 'expo-router');\n\n if (exp.platforms?.includes('web') && platformBundlers.web === 'metro') {\n await new WebSupportProjectPrerequisite(projectRoot).assertAsync();\n }\n\n let tsconfig: null | TsConfigPaths = null;\n\n if (isTsconfigPathsEnabled) {\n tsconfig = await loadTsConfigPathsAsync(projectRoot);\n }\n\n await setupShimFiles(projectRoot);\n await setupNodeExternals(projectRoot);\n\n let expoConfigPlatforms = Object.entries(platformBundlers)\n .filter(\n ([platform, bundler]) => bundler === 'metro' && exp.platforms?.includes(platform as Platform)\n )\n .map(([platform]) => platform);\n\n if (Array.isArray(config.resolver.platforms)) {\n expoConfigPlatforms = [...new Set(expoConfigPlatforms.concat(config.resolver.platforms))];\n }\n\n // @ts-expect-error: typed as `readonly`.\n config.resolver.platforms = expoConfigPlatforms;\n\n config = withWebPolyfills(config);\n\n return withExtendedResolver(config, {\n tsconfig,\n isExporting,\n isTsconfigPathsEnabled,\n isFastResolverEnabled,\n });\n}\n\nfunction isDirectoryIn(a: string, b: string) {\n return b.startsWith(a) && b.length > a.length;\n}\n"],"names":["getNodejsExtensions","withExtendedResolver","shouldAliasAssetRegistryForWeb","shouldAliasModule","withMetroMultiPlatformAsync","metroResolver","debug","require","withWebPolyfills","config","originalGetPolyfills","serializer","getPolyfills","bind","ctx","platform","path","join","projectRoot","EXTERNAL_REQUIRE_POLYFILL","polyfills","EXTERNAL_REQUIRE_NATIVE_POLYFILL","normalizeSlashes","p","replace","srcExts","mjsExts","filter","ext","test","nodejsSourceExtensions","jsIndex","reduce","index","i","splice","tsconfig","isTsconfigPathsEnabled","isFastResolverEnabled","isExporting","Log","warn","assetRegistryPath","fs","realpathSync","resolve","resolveFrom","defaultResolver","resolver","createFastResolver","preserveSymlinks","unstable_enableSymlinks","blockList","Array","isArray","aliases","web","universalAliases","silent","push","preferredMainFields","tsConfigResolve","paths","resolveWithTsConfigPaths","baseUrl","hasBaseUrl","isInteractive","configWatcher","FileNotifier","startObserving","loadTsConfigPathsAsync","then","tsConfigPaths","Object","keys","length","installExitHooks","stopObserving","shimsFolder","METRO_SHIMS_FOLDER","getStrictResolver","resolveRequest","context","doResolve","moduleName","getOptionalResolver","optionalResolve","error","isResolutionError","isFailedToResolveNameError","isFailedToResolvePathError","metroConfigWithCustomResolver","withMetroResolvers","originModulePath","moduleId","isNodeExternal","customResolverOptions","environment","result","type","redirectedModuleName","getNodeExternalModuleId","matcher","alias","match","aliasedModule","_","parseInt","filePath","includes","normalName","shimPath","existsSync","metroConfigWithCustomContext","withMetroMutatedResolverContext","immutableContext","preferNativePlatform","sourceExts","unstable_enablePackageExports","unstable_conditionNames","unstable_conditionsByPlatform","mainFields","env","EXPO_METRO_NO_MAIN_FIELD_OVERRIDE","withMetroErrorReportingResolver","endsWith","input","output","exp","platformBundlers","webOutput","process","EXPO_PUBLIC_PROJECT_ROOT","EXPO_PUBLIC_USE_STATIC","isDirectoryIn","__dirname","watchFolders","transformer","_expoRouterWebRendering","_expoRouterPath","platforms","WebSupportProjectPrerequisite","assertAsync","setupShimFiles","setupNodeExternals","expoConfigPlatforms","entries","bundler","map","Set","concat","a","b","startsWith"],"mappings":"AAMA;;;;QAsEgBA,mBAAmB,GAAnBA,mBAAmB;QAqBnBC,oBAAoB,GAApBA,oBAAoB;QAySpBC,8BAA8B,GAA9BA,8BAA8B;QAc9BC,iBAAiB,GAAjBA,iBAAiB;QAgBXC,2BAA2B,GAA3BA,2BAA2B;AAjalC,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAGPC,IAAAA,aAAa,mCAAM,gBAAgB,EAAtB;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEH,IAAA,wBAA2B,WAA3B,2BAA2B,CAAA;AASvD,IAAA,UAAa,WAAb,aAAa,CAAA;AACmD,IAAA,YAAe,WAAf,eAAe,CAAA;AAK/E,IAAA,mBAAsB,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AK,OAAO,KAAInB,CAAAA,GAAa,GAAbA,GAAG,CAACY,SAAS,SAAU,GAAvBZ,KAAAA,CAAuB,GAAvBA,GAAa,CAAEnB,QAAQ,CAAC9F,QAAQ,CAAa,CAAA,CAAA;KAAA,CAC9F,CACAqI,GAAG,CAAC,CAAC,CAACrI,QAAQ,CAAC,GAAKA,QAAQ;IAAA,CAAC,AAAC;IAEjC,IAAIsC,KAAK,CAACC,OAAO,CAAC7C,MAAM,CAACuC,QAAQ,CAAC4F,SAAS,CAAC,EAAE;QAC5CK,mBAAmB,GAAG;eAAI,IAAII,GAAG,CAACJ,mBAAmB,CAACK,MAAM,CAAC7I,MAAM,CAACuC,QAAQ,CAAC4F,SAAS,CAAC,CAAC;SAAC,CAAC;KAC3F;IAED,yCAAyC;IACzCnI,MAAM,CAACuC,QAAQ,CAAC4F,SAAS,GAAGK,mBAAmB,CAAC;IAEhDxI,MAAM,GAAGD,gBAAgB,CAACC,MAAM,CAAC,CAAC;IAElC,OAAOR,oBAAoB,CAACQ,MAAM,EAAE;QAClC2B,QAAQ;QACRG,WAAW;QACXF,sBAAsB;QACtBC,qBAAqB;KACtB,CAAC,CAAC;CACJ;AAED,SAASgG,aAAa,CAACiB,CAAS,EAAEC,CAAS,EAAE;IAC3C,OAAOA,CAAC,CAACC,UAAU,CAACF,CAAC,CAAC,IAAIC,CAAC,CAAC7E,MAAM,GAAG4E,CAAC,CAAC5E,MAAM,CAAC;CAC/C"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.createCorsMiddleware = createCorsMiddleware;
6
+ const DEFAULT_ALLOWED_CORS_HOSTNAMES = [
7
+ "localhost",
8
+ "chrome-devtools-frontend.appspot.com",
9
+ "devtools"
10
+ ];
11
+ function createCorsMiddleware(exp) {
12
+ var ref, ref1, ref2, ref3;
13
+ const allowedHostnames = [
14
+ ...DEFAULT_ALLOWED_CORS_HOSTNAMES
15
+ ];
16
+ // Support for expo-router API routes
17
+ if ((ref = exp.extra) == null ? void 0 : (ref1 = ref.router) == null ? void 0 : ref1.headOrigin) {
18
+ allowedHostnames.push(new URL(exp.extra.router.headOrigin).hostname);
19
+ }
20
+ if ((ref2 = exp.extra) == null ? void 0 : (ref3 = ref2.router) == null ? void 0 : ref3.origin) {
21
+ allowedHostnames.push(new URL(exp.extra.router.origin).hostname);
22
+ }
23
+ return (req, res, next)=>{
24
+ if (typeof req.headers.origin === "string") {
25
+ const { hostname } = new URL(req.headers.origin);
26
+ if (!allowedHostnames.includes(hostname)) {
27
+ next(new Error(`Unauthorized request from ${req.headers.origin}. ` + "This may happen because of a conflicting browser extension to intercept HTTP requests. " + "Please try again without browser extensions or using incognito mode."));
28
+ return;
29
+ }
30
+ res.setHeader("Access-Control-Allow-Origin", req.headers.origin);
31
+ maybePreventMetroResetCorsHeader(req, res);
32
+ }
33
+ // Block MIME-type sniffing.
34
+ res.setHeader("X-Content-Type-Options", "nosniff");
35
+ next();
36
+ };
37
+ }
38
+ // When accessing source maps,
39
+ // metro will overwrite the `Access-Control-Allow-Origin` header with hardcoded `devtools://devtools` value.
40
+ // https://github.com/facebook/metro/blob/a7f8955e6d2424b0d5f73d4bcdaf22560e1d5f27/packages/metro/src/Server.js#L540
41
+ // This is a workaround to prevent this behavior.
42
+ function maybePreventMetroResetCorsHeader(req, res) {
43
+ const pathname = req.url ? new URL(req.url, `http://${req.headers.host}`).pathname : "";
44
+ if (pathname.endsWith(".map")) {
45
+ const setHeader = res.setHeader.bind(res);
46
+ res.setHeader = (key, ...args)=>{
47
+ if (key !== "Access-Control-Allow-Origin") {
48
+ setHeader(key, ...args);
49
+ }
50
+ return res;
51
+ };
52
+ }
53
+ }
54
+
55
+ //# sourceMappingURL=CorsMiddleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/CorsMiddleware.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\n\nimport type { ServerRequest, ServerResponse } from './server.types';\n\nconst DEFAULT_ALLOWED_CORS_HOSTNAMES = [\n 'localhost',\n 'chrome-devtools-frontend.appspot.com', // Support remote Chrome DevTools frontend\n 'devtools', // Support local Chrome DevTools `devtools://devtools`\n];\n\nexport function createCorsMiddleware(exp: ExpoConfig) {\n const allowedHostnames = [...DEFAULT_ALLOWED_CORS_HOSTNAMES];\n // Support for expo-router API routes\n if (exp.extra?.router?.headOrigin) {\n allowedHostnames.push(new URL(exp.extra.router.headOrigin).hostname);\n }\n if (exp.extra?.router?.origin) {\n allowedHostnames.push(new URL(exp.extra.router.origin).hostname);\n }\n\n return (req: ServerRequest, res: ServerResponse, next: (err?: Error) => void) => {\n if (typeof req.headers.origin === 'string') {\n const { hostname } = new URL(req.headers.origin);\n if (!allowedHostnames.includes(hostname)) {\n next(\n new Error(\n `Unauthorized request from ${req.headers.origin}. ` +\n 'This may happen because of a conflicting browser extension to intercept HTTP requests. ' +\n 'Please try again without browser extensions or using incognito mode.'\n )\n );\n return;\n }\n\n res.setHeader('Access-Control-Allow-Origin', req.headers.origin);\n maybePreventMetroResetCorsHeader(req, res);\n }\n\n // Block MIME-type sniffing.\n res.setHeader('X-Content-Type-Options', 'nosniff');\n\n next();\n };\n}\n\n// When accessing source maps,\n// metro will overwrite the `Access-Control-Allow-Origin` header with hardcoded `devtools://devtools` value.\n// https://github.com/facebook/metro/blob/a7f8955e6d2424b0d5f73d4bcdaf22560e1d5f27/packages/metro/src/Server.js#L540\n// This is a workaround to prevent this behavior.\nfunction maybePreventMetroResetCorsHeader(req: ServerRequest, res: ServerResponse) {\n const pathname = req.url ? new URL(req.url, `http://${req.headers.host}`).pathname : '';\n if (pathname.endsWith('.map')) {\n const setHeader = res.setHeader.bind(res);\n res.setHeader = (key, ...args) => {\n if (key !== 'Access-Control-Allow-Origin') {\n setHeader(key, ...args);\n }\n return res;\n };\n }\n}\n"],"names":["createCorsMiddleware","DEFAULT_ALLOWED_CORS_HOSTNAMES","exp","allowedHostnames","extra","router","headOrigin","push","URL","hostname","origin","req","res","next","headers","includes","Error","setHeader","maybePreventMetroResetCorsHeader","pathname","url","host","endsWith","bind","key","args"],"mappings":"AAAA;;;;QAUgBA,oBAAoB,GAApBA,oBAAoB;AANpC,MAAMC,8BAA8B,GAAG;IACrC,WAAW;IACX,sCAAsC;IACtC,UAAU;CACX,AAAC;AAEK,SAASD,oBAAoB,CAACE,GAAe,EAAE;QAGhDA,GAAS,QAGTA,IAAS;IALb,MAAMC,gBAAgB,GAAG;WAAIF,8BAA8B;KAAC,AAAC;IAC7D,qCAAqC;IACrC,IAAIC,CAAAA,GAAS,GAATA,GAAG,CAACE,KAAK,SAAQ,GAAjBF,KAAAA,CAAiB,GAAjBA,QAAAA,GAAS,CAAEG,MAAM,SAAA,GAAjBH,KAAAA,CAAiB,QAAEI,UAAU,AAAZ,EAAc;QACjCH,gBAAgB,CAACI,IAAI,CAAC,IAAIC,GAAG,CAACN,GAAG,CAACE,KAAK,CAACC,MAAM,CAACC,UAAU,CAAC,CAACG,QAAQ,CAAC,CAAC;KACtE;IACD,IAAIP,CAAAA,IAAS,GAATA,GAAG,CAACE,KAAK,SAAQ,GAAjBF,KAAAA,CAAiB,GAAjBA,QAAAA,IAAS,CAAEG,MAAM,SAAA,GAAjBH,KAAAA,CAAiB,QAAEQ,MAAM,AAAR,EAAU;QAC7BP,gBAAgB,CAACI,IAAI,CAAC,IAAIC,GAAG,CAACN,GAAG,CAACE,KAAK,CAACC,MAAM,CAACK,MAAM,CAAC,CAACD,QAAQ,CAAC,CAAC;KAClE;IAED,OAAO,CAACE,GAAkB,EAAEC,GAAmB,EAAEC,IAA2B,GAAK;QAC/E,IAAI,OAAOF,GAAG,CAACG,OAAO,CAACJ,MAAM,KAAK,QAAQ,EAAE;YAC1C,MAAM,EAAED,QAAQ,CAAA,EAAE,GAAG,IAAID,GAAG,CAACG,GAAG,CAACG,OAAO,CAACJ,MAAM,CAAC,AAAC;YACjD,IAAI,CAACP,gBAAgB,CAACY,QAAQ,CAACN,QAAQ,CAAC,EAAE;gBACxCI,IAAI,CACF,IAAIG,KAAK,CACP,CAAC,0BAA0B,EAAEL,GAAG,CAACG,OAAO,CAACJ,MAAM,CAAC,EAAE,CAAC,GACjD,yFAAyF,GACzF,sEAAsE,CACzE,CACF,CAAC;gBACF,OAAO;aACR;YAEDE,GAAG,CAACK,SAAS,CAAC,6BAA6B,EAAEN,GAAG,CAACG,OAAO,CAACJ,MAAM,CAAC,CAAC;YACjEQ,gCAAgC,CAACP,GAAG,EAAEC,GAAG,CAAC,CAAC;SAC5C;QAED,4BAA4B;QAC5BA,GAAG,CAACK,SAAS,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;QAEnDJ,IAAI,EAAE,CAAC;KACR,CAAC;CACH;AAED,8BAA8B;AAC9B,4GAA4G;AAC5G,oHAAoH;AACpH,iDAAiD;AACjD,SAASK,gCAAgC,CAACP,GAAkB,EAAEC,GAAmB,EAAE;IACjF,MAAMO,QAAQ,GAAGR,GAAG,CAACS,GAAG,GAAG,IAAIZ,GAAG,CAACG,GAAG,CAACS,GAAG,EAAE,CAAC,OAAO,EAAET,GAAG,CAACG,OAAO,CAACO,IAAI,CAAC,CAAC,CAAC,CAACF,QAAQ,GAAG,EAAE,AAAC;IACxF,IAAIA,QAAQ,CAACG,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC7B,MAAML,SAAS,GAAGL,GAAG,CAACK,SAAS,CAACM,IAAI,CAACX,GAAG,CAAC,AAAC;QAC1CA,GAAG,CAACK,SAAS,GAAG,CAACO,GAAG,EAAKC,GAAAA,IAAI,GAAK;YAChC,IAAID,GAAG,KAAK,6BAA6B,EAAE;gBACzCP,SAAS,CAACO,GAAG,KAAKC,IAAI,CAAC,CAAC;aACzB;YACD,OAAOb,GAAG,CAAC;SACZ,CAAC;KACH;CACF"}
@@ -100,6 +100,7 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
100
100
  this.projectRoot = projectRoot;
101
101
  this.options = options;
102
102
  this.initialProjectConfig = (0, _config).getConfig(projectRoot);
103
+ this.platformBundlers = (0, _platformBundlers).getPlatformBundlers(projectRoot, this.initialProjectConfig.exp);
103
104
  }
104
105
  /** Exposed for testing. */ async _resolveProjectSettingsAsync({ platform , hostname }) {
105
106
  // Read the config
@@ -256,21 +257,20 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
256
257
  }));
257
258
  }
258
259
  /** Exposed for testing. */ async checkBrowserRequestAsync(req, res, next) {
259
- // Read the config
260
- const bundlers = (0, _platformBundlers).getPlatformBundlers(this.initialProjectConfig.exp);
261
- if (bundlers.web === "metro") {
260
+ var ref;
261
+ if (this.platformBundlers.web === "metro" && ((ref = this.initialProjectConfig.exp.platforms) == null ? void 0 : ref.includes("web"))) {
262
262
  // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure
263
263
  // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo
264
264
  // code loading then they'll get a web bundle without a clear assertion of platform support.
265
265
  const platform = (0, _resolvePlatform).parsePlatformHeader(req);
266
266
  // On web, serve the public folder
267
267
  if (!platform || platform === "web") {
268
- var ref;
269
268
  var ref1;
269
+ var ref2;
270
270
  if ([
271
271
  "static",
272
272
  "server"
273
- ].includes((ref1 = (ref = this.initialProjectConfig.exp.web) == null ? void 0 : ref.output) != null ? ref1 : "")) {
273
+ ].includes((ref2 = (ref1 = this.initialProjectConfig.exp.web) == null ? void 0 : ref1.output) != null ? ref2 : "")) {
274
274
  // Skip the spa-styled index.html when static generation is enabled.
275
275
  next();
276
276
  return true;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import {\n ExpoConfig,\n ExpoGoConfig,\n getConfig,\n PackageJSONConfig,\n ProjectConfig,\n} from '@expo/config';\nimport { resolveEntryPoint } from '@expo/config/paths';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport path from 'path';\nimport { resolve } from 'url';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport {\n shouldEnableAsyncImports,\n createBundleUrlPath,\n getBaseUrlFromExpoConfig,\n getAsyncRoutesFromExpoConfig,\n createBundleUrlPathFromExpoConfig,\n} from './metroOptions';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\nimport { isEnableHermesManaged } from '../../../export/exportHermes';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getRouterDirectoryModuleIdWithManifest } from '../metro/router';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\n\nconst debug = require('debug')('expo:start:server:middleware:manifest') as typeof console.log;\n\n/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */\nexport function getWorkspaceRoot(projectRoot: string): string | null {\n try {\n return findWorkspaceRoot(projectRoot);\n } catch (error: any) {\n if (error.message.includes('Unexpected end of JSON input')) {\n return null;\n }\n throw error;\n }\n}\n\nconst supportedPlatforms = ['ios', 'android', 'web', 'none'];\n\nexport function getEntryWithServerRoot(\n projectRoot: string,\n props: { platform: string; pkg?: PackageJSONConfig }\n) {\n if (!supportedPlatforms.includes(props.platform)) {\n throw new CommandError(\n `Failed to resolve the project's entry file: The platform \"${props.platform}\" is not supported.`\n );\n }\n return path.relative(getMetroServerRoot(projectRoot), resolveEntryPoint(projectRoot, props));\n}\n\nexport function getMetroServerRoot(projectRoot: string) {\n if (env.EXPO_USE_METRO_WORKSPACE_ROOT) {\n return getWorkspaceRoot(projectRoot) ?? projectRoot;\n }\n\n return projectRoot;\n}\n\n/** Get the main entry module ID (file) relative to the project root. */\nexport function resolveMainModuleName(\n projectRoot: string,\n props: { platform: string; pkg?: PackageJSONConfig }\n): string {\n const entryPoint = getEntryWithServerRoot(projectRoot, props);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);\n\n return stripExtension(entryPoint, 'js');\n}\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo,\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n\n constructor(\n protected projectRoot: string,\n protected options: ManifestMiddlewareOptions\n ) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n }: Pick<TManifestRequestInfo, 'hostname' | 'platform'>): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName({\n pkg: projectConfig.pkg,\n platform,\n });\n\n const isHermesEnabled = isEnableHermesManaged(projectConfig.exp, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n engine: isHermesEnabled ? 'hermes' : undefined,\n baseUrl: getBaseUrlFromExpoConfig(projectConfig.exp),\n asyncRoutes: getAsyncRoutesFromExpoConfig(\n projectConfig.exp,\n this.options.mode ?? 'development',\n platform\n ),\n routerRoot: getRouterDirectoryModuleIdWithManifest(this.projectRoot, projectConfig.exp),\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(props: { pkg: PackageJSONConfig; platform: string }): string {\n let entryPoint = getEntryWithServerRoot(this.projectRoot, props);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);\n\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n engine,\n baseUrl,\n isExporting,\n asyncRoutes,\n routerRoot,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n engine?: 'hermes';\n baseUrl?: string;\n asyncRoutes: boolean;\n isExporting?: boolean;\n routerRoot: string;\n }): string {\n const path = createBundleUrlPath({\n mode: this.options.mode ?? 'development',\n minify: this.options.minify,\n platform,\n mainModuleName,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n engine,\n baseUrl,\n isExporting: !!isExporting,\n asyncRoutes,\n routerRoot,\n });\n\n return (\n this.options.constructUrl({\n scheme: 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n /** Log telemetry. */\n protected abstract trackManifest(version?: string): void;\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:8081\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=8081 open -a flipper.app`\n // Where 8081 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n public getWebBundleUrl() {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName({\n pkg: this.initialProjectConfig.pkg,\n platform,\n });\n\n return createBundleUrlPathFromExpoConfig(this.projectRoot, this.initialProjectConfig.exp, {\n platform,\n mainModuleName,\n minify: this.options.minify,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n mode: this.options.mode ?? 'development',\n // Hermes doesn't support more modern JS features than most, if not all, modern browser.\n engine: 'hermes',\n isExporting: false,\n });\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n // Read from headers\n const bundleUrl = this.getWebBundleUrl();\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n await createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n })\n );\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse, next: ServerNext) {\n // Read the config\n const bundlers = getPlatformBundlers(this.initialProjectConfig.exp);\n if (bundlers.web === 'metro') {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n if (['static', 'server'].includes(this.initialProjectConfig.exp.web?.output ?? '')) {\n // Skip the spa-styled index.html when static generation is enabled.\n next();\n return true;\n } else {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res, next)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, version, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n\n // Log analytics\n this.trackManifest(version ?? null);\n }\n}\n"],"names":["getWorkspaceRoot","getEntryWithServerRoot","getMetroServerRoot","resolveMainModuleName","Log","ProjectDevices","debug","require","projectRoot","findWorkspaceRoot","error","message","includes","supportedPlatforms","props","platform","CommandError","path","relative","resolveEntryPoint","env","EXPO_USE_METRO_WORKSPACE_ROOT","entryPoint","stripExtension","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","_resolveProjectSettingsAsync","hostname","projectConfig","mainModuleName","pkg","isHermesEnabled","isEnableHermesManaged","exp","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","engine","undefined","baseUrl","getBaseUrlFromExpoConfig","asyncRoutes","getAsyncRoutesFromExpoConfig","mode","routerRoot","getRouterDirectoryModuleIdWithManifest","mutateManifestWithAssetsAsync","isNativeWebpack","saveDevicesAsync","req","deviceIds","headers","catch","e","exception","isExporting","createBundleUrlPath","minify","lazy","shouldEnableAsyncImports","debuggerHost","developer","tool","packagerOpts","dev","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","getWebBundleUrl","createBundleUrlPathFromExpoConfig","handleWebRequestAsync","res","setHeader","end","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","next","bundlers","getPlatformBundlers","web","parsePlatformHeader","output","handleRequestAsync","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","trackManifest"],"mappings":"AAAA;;;;QAqCgBA,gBAAgB,GAAhBA,gBAAgB;QAahBC,sBAAsB,GAAtBA,sBAAsB;QAYtBC,kBAAkB,GAAlBA,kBAAkB;QASlBC,qBAAqB,GAArBA,qBAAqB;;AAjE9B,IAAA,OAAc,WAAd,cAAc,CAAA;AACa,IAAA,MAAoB,WAApB,oBAAoB,CAAA;AACxB,IAAA,sBAA0B,kCAA1B,0BAA0B,EAAA;AACvC,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,IAAK,WAAL,KAAK,CAAA;AAEE,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAO1C,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;AAC0C,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AAC7B,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AAElC,IAAA,aAA8B,WAA9B,8BAA8B,CAAA;AACxDC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACK,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACX,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACrB,IAAA,KAAoB,WAApB,oBAAoB,CAAA;AACvCC,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AAE6B,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AACpC,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACH,IAAA,YAAgB,WAAhB,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,uCAAuC,CAAC,AAAsB,AAAC;AAGvF,SAASP,gBAAgB,CAACQ,WAAmB,EAAiB;IACnE,IAAI;QACF,OAAOC,CAAAA,GAAAA,sBAAiB,AAAa,CAAA,QAAb,CAACD,WAAW,CAAC,CAAC;KACvC,CAAC,OAAOE,KAAK,EAAO;QACnB,IAAIA,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ACpB,MAAM9B,OAAO,GAAG,IAAI,CAACqE,gBAAgB,CAACvC,GAAG,CAAC,AAAC;QAC3C,MAAM,EAAEwC,IAAI,CAAA,EAAEC,OAAO,CAAA,EAAEvC,OAAO,CAAA,EAAE,GAAG,MAAM,IAAI,CAACwC,yBAAyB,CAACxE,OAAO,CAAC,AAAC;QACjF,KAAK,MAAM,CAACyE,UAAU,EAAEC,WAAW,CAAC,IAAI1C,OAAO,CAAE;YAC/CwB,GAAG,CAACC,SAAS,CAACgB,UAAU,EAAEC,WAAW,CAAC,CAAC;SACxC;QACDlB,GAAG,CAACE,GAAG,CAACY,IAAI,CAAC,CAAC;QAEd,gBAAgB;QAChB,IAAI,CAACK,aAAa,CAACJ,OAAO,WAAPA,OAAO,GAAI,IAAI,CAAC,CAAC;KACrC;CACF;QA9RqB1E,kBAAkB,GAAlBA,kBAAkB"}
1
+ {"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import {\n ExpoConfig,\n ExpoGoConfig,\n getConfig,\n PackageJSONConfig,\n ProjectConfig,\n} from '@expo/config';\nimport { resolveEntryPoint } from '@expo/config/paths';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport path from 'path';\nimport { resolve } from 'url';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport {\n shouldEnableAsyncImports,\n createBundleUrlPath,\n getBaseUrlFromExpoConfig,\n getAsyncRoutesFromExpoConfig,\n createBundleUrlPathFromExpoConfig,\n} from './metroOptions';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\nimport { isEnableHermesManaged } from '../../../export/exportHermes';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getRouterDirectoryModuleIdWithManifest } from '../metro/router';\nimport { getPlatformBundlers, PlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\n\nconst debug = require('debug')('expo:start:server:middleware:manifest') as typeof console.log;\n\n/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */\nexport function getWorkspaceRoot(projectRoot: string): string | null {\n try {\n return findWorkspaceRoot(projectRoot);\n } catch (error: any) {\n if (error.message.includes('Unexpected end of JSON input')) {\n return null;\n }\n throw error;\n }\n}\n\nconst supportedPlatforms = ['ios', 'android', 'web', 'none'];\n\nexport function getEntryWithServerRoot(\n projectRoot: string,\n props: { platform: string; pkg?: PackageJSONConfig }\n) {\n if (!supportedPlatforms.includes(props.platform)) {\n throw new CommandError(\n `Failed to resolve the project's entry file: The platform \"${props.platform}\" is not supported.`\n );\n }\n return path.relative(getMetroServerRoot(projectRoot), resolveEntryPoint(projectRoot, props));\n}\n\nexport function getMetroServerRoot(projectRoot: string) {\n if (env.EXPO_USE_METRO_WORKSPACE_ROOT) {\n return getWorkspaceRoot(projectRoot) ?? projectRoot;\n }\n\n return projectRoot;\n}\n\n/** Get the main entry module ID (file) relative to the project root. */\nexport function resolveMainModuleName(\n projectRoot: string,\n props: { platform: string; pkg?: PackageJSONConfig }\n): string {\n const entryPoint = getEntryWithServerRoot(projectRoot, props);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);\n\n return stripExtension(entryPoint, 'js');\n}\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo,\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n private platformBundlers: PlatformBundlers;\n\n constructor(\n protected projectRoot: string,\n protected options: ManifestMiddlewareOptions\n ) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n this.platformBundlers = getPlatformBundlers(projectRoot, this.initialProjectConfig.exp);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n }: Pick<TManifestRequestInfo, 'hostname' | 'platform'>): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName({\n pkg: projectConfig.pkg,\n platform,\n });\n\n const isHermesEnabled = isEnableHermesManaged(projectConfig.exp, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n engine: isHermesEnabled ? 'hermes' : undefined,\n baseUrl: getBaseUrlFromExpoConfig(projectConfig.exp),\n asyncRoutes: getAsyncRoutesFromExpoConfig(\n projectConfig.exp,\n this.options.mode ?? 'development',\n platform\n ),\n routerRoot: getRouterDirectoryModuleIdWithManifest(this.projectRoot, projectConfig.exp),\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(props: { pkg: PackageJSONConfig; platform: string }): string {\n let entryPoint = getEntryWithServerRoot(this.projectRoot, props);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);\n\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n engine,\n baseUrl,\n isExporting,\n asyncRoutes,\n routerRoot,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n engine?: 'hermes';\n baseUrl?: string;\n asyncRoutes: boolean;\n isExporting?: boolean;\n routerRoot: string;\n }): string {\n const path = createBundleUrlPath({\n mode: this.options.mode ?? 'development',\n minify: this.options.minify,\n platform,\n mainModuleName,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n engine,\n baseUrl,\n isExporting: !!isExporting,\n asyncRoutes,\n routerRoot,\n });\n\n return (\n this.options.constructUrl({\n scheme: 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n /** Log telemetry. */\n protected abstract trackManifest(version?: string): void;\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:8081\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=8081 open -a flipper.app`\n // Where 8081 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n public getWebBundleUrl() {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName({\n pkg: this.initialProjectConfig.pkg,\n platform,\n });\n\n return createBundleUrlPathFromExpoConfig(this.projectRoot, this.initialProjectConfig.exp, {\n platform,\n mainModuleName,\n minify: this.options.minify,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n mode: this.options.mode ?? 'development',\n // Hermes doesn't support more modern JS features than most, if not all, modern browser.\n engine: 'hermes',\n isExporting: false,\n });\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n // Read from headers\n const bundleUrl = this.getWebBundleUrl();\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n await createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n })\n );\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse, next: ServerNext) {\n if (\n this.platformBundlers.web === 'metro' &&\n this.initialProjectConfig.exp.platforms?.includes('web')\n ) {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n if (['static', 'server'].includes(this.initialProjectConfig.exp.web?.output ?? '')) {\n // Skip the spa-styled index.html when static generation is enabled.\n next();\n return true;\n } else {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res, next)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, version, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n\n // Log analytics\n this.trackManifest(version ?? null);\n }\n}\n"],"names":["getWorkspaceRoot","getEntryWithServerRoot","getMetroServerRoot","resolveMainModuleName","Log","ProjectDevices","debug","require","projectRoot","findWorkspaceRoot","error","message","includes","supportedPlatforms","props","platform","CommandError","path","relative","resolveEntryPoint","env","EXPO_USE_METRO_WORKSPACE_ROOT","entryPoint","stripExtension","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","platformBundlers","getPlatformBundlers","exp","_resolveProjectSettingsAsync","hostname","projectConfig","mainModuleName","pkg","isHermesEnabled","isEnableHermesManaged","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","engine","undefined","baseUrl","getBaseUrlFromExpoConfig","asyncRoutes","getAsyncRoutesFromExpoConfig","mode","routerRoot","getRouterDirectoryModuleIdWithManifest","mutateManifestWithAssetsAsync","isNativeWebpack","saveDevicesAsync","req","deviceIds","headers","catch","e","exception","isExporting","createBundleUrlPath","minify","lazy","shouldEnableAsyncImports","debuggerHost","developer","tool","packagerOpts","dev","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","getWebBundleUrl","createBundleUrlPathFromExpoConfig","handleWebRequestAsync","res","setHeader","end","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","next","web","platforms","parsePlatformHeader","output","handleRequestAsync","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","trackManifest"],"mappings":"AAAA;;;;QAqCgBA,gBAAgB,GAAhBA,gBAAgB;QAahBC,sBAAsB,GAAtBA,sBAAsB;QAYtBC,kBAAkB,GAAlBA,kBAAkB;QASlBC,qBAAqB,GAArBA,qBAAqB;;AAjE9B,IAAA,OAAc,WAAd,cAAc,CAAA;AACa,IAAA,MAAoB,WAApB,oBAAoB,CAAA;AACxB,IAAA,sBAA0B,kCAA1B,0BAA0B,EAAA;AACvC,IAAA,KAAM,kCAA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AAG,MAAM,IAAI,CAACuC,yBAAyB,CAACzE,OAAO,CAAC,AAAC;QACjF,KAAK,MAAM,CAAC0E,UAAU,EAAEC,WAAW,CAAC,IAAIzC,OAAO,CAAE;YAC/CwB,GAAG,CAACC,SAAS,CAACe,UAAU,EAAEC,WAAW,CAAC,CAAC;SACxC;QACDjB,GAAG,CAACE,GAAG,CAACW,IAAI,CAAC,CAAC;QAEd,gBAAgB;QAChB,IAAI,CAACK,aAAa,CAACJ,OAAO,WAAPA,OAAO,GAAI,IAAI,CAAC,CAAC;KACrC;CACF;QAjSqB3E,kBAAkB,GAAlBA,kBAAkB"}
@@ -3,15 +3,28 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.getPlatformBundlers = getPlatformBundlers;
6
- function getPlatformBundlers(exp) {
6
+ var _resolveFrom = _interopRequireDefault(require("resolve-from"));
7
+ function _interopRequireDefault(obj) {
8
+ return obj && obj.__esModule ? obj : {
9
+ default: obj
10
+ };
11
+ }
12
+ function getPlatformBundlers(projectRoot, exp) {
7
13
  var ref, ref1, ref2;
8
- var ref3, ref4, ref5;
14
+ /**
15
+ * SDK 50+: The web bundler is dynamic based upon the presence of the `@expo/webpack-config` package.
16
+ */ let web = (ref = exp.web) == null ? void 0 : ref.bundler;
17
+ if (!web) {
18
+ const resolved = _resolveFrom.default.silent(projectRoot, "@expo/webpack-config/package.json");
19
+ web = resolved ? "webpack" : "metro";
20
+ }
21
+ var ref3, ref4;
9
22
  return {
10
23
  // @ts-expect-error: not on type yet
11
- ios: (ref3 = (ref = exp.ios) == null ? void 0 : ref.bundler) != null ? ref3 : "metro",
24
+ ios: (ref3 = (ref1 = exp.ios) == null ? void 0 : ref1.bundler) != null ? ref3 : "metro",
12
25
  // @ts-expect-error: not on type yet
13
- android: (ref4 = (ref1 = exp.android) == null ? void 0 : ref1.bundler) != null ? ref4 : "metro",
14
- web: (ref5 = (ref2 = exp.web) == null ? void 0 : ref2.bundler) != null ? ref5 : "webpack"
26
+ android: (ref4 = (ref2 = exp.android) == null ? void 0 : ref2.bundler) != null ? ref4 : "metro",
27
+ web
15
28
  };
16
29
  }
17
30
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/start/server/platformBundlers.ts"],"sourcesContent":["import { ExpoConfig, Platform } from '@expo/config';\n\n/** Which bundler each platform should use. */\nexport type PlatformBundlers = Record<Platform, 'metro' | 'webpack'>;\n\n/** Get the platform bundlers mapping. */\nexport function getPlatformBundlers(exp: Partial<ExpoConfig>): PlatformBundlers {\n return {\n // @ts-expect-error: not on type yet\n ios: exp.ios?.bundler ?? 'metro',\n // @ts-expect-error: not on type yet\n android: exp.android?.bundler ?? 'metro',\n web: exp.web?.bundler ?? 'webpack',\n };\n}\n"],"names":["getPlatformBundlers","exp","ios","bundler","android","web"],"mappings":"AAAA;;;;QAMgBA,mBAAmB,GAAnBA,mBAAmB;AAA5B,SAASA,mBAAmB,CAACC,GAAwB,EAAoB;QAGvEA,GAAO,EAEHA,IAAW,EACfA,IAAO;QAHPA,IAAgB,EAEZA,IAAoB,EACxBA,IAAgB;IALvB,OAAO;QACL,oCAAoC;QACpCC,GAAG,EAAED,CAAAA,IAAgB,GAAhBA,CAAAA,GAAO,GAAPA,GAAG,CAACC,GAAG,SAAS,GAAhBD,KAAAA,CAAgB,GAAhBA,GAAO,CAAEE,OAAO,YAAhBF,IAAgB,GAAI,OAAO;QAChC,oCAAoC;QACpCG,OAAO,EAAEH,CAAAA,IAAoB,GAApBA,CAAAA,IAAW,GAAXA,GAAG,CAACG,OAAO,SAAS,GAApBH,KAAAA,CAAoB,GAApBA,IAAW,CAAEE,OAAO,YAApBF,IAAoB,GAAI,OAAO;QACxCI,GAAG,EAAEJ,CAAAA,IAAgB,GAAhBA,CAAAA,IAAO,GAAPA,GAAG,CAACI,GAAG,SAAS,GAAhBJ,KAAAA,CAAgB,GAAhBA,IAAO,CAAEE,OAAO,YAAhBF,IAAgB,GAAI,SAAS;KACnC,CAAC;CACH"}
1
+ {"version":3,"sources":["../../../../src/start/server/platformBundlers.ts"],"sourcesContent":["import { ExpoConfig, Platform } from '@expo/config';\nimport resolveFrom from 'resolve-from';\n\n/** Which bundler each platform should use. */\nexport type PlatformBundlers = Record<Platform, 'metro' | 'webpack'>;\n\n/** Get the platform bundlers mapping. */\nexport function getPlatformBundlers(\n projectRoot: string,\n exp: Partial<ExpoConfig>\n): PlatformBundlers {\n /**\n * SDK 50+: The web bundler is dynamic based upon the presence of the `@expo/webpack-config` package.\n */\n let web = exp.web?.bundler;\n if (!web) {\n const resolved = resolveFrom.silent(projectRoot, '@expo/webpack-config/package.json');\n web = resolved ? 'webpack' : 'metro';\n }\n\n return {\n // @ts-expect-error: not on type yet\n ios: exp.ios?.bundler ?? 'metro',\n // @ts-expect-error: not on type yet\n android: exp.android?.bundler ?? 'metro',\n web,\n };\n}\n"],"names":["getPlatformBundlers","projectRoot","exp","web","bundler","resolved","resolveFrom","silent","ios","android"],"mappings":"AAAA;;;;QAOgBA,mBAAmB,GAAnBA,mBAAmB;AANX,IAAA,YAAc,kCAAd,cAAc,EAAA;;;;;;AAM/B,SAASA,mBAAmB,CACjCC,WAAmB,EACnBC,GAAwB,EACN;QAIRA,GAAO,EAQVA,IAAO,EAEHA,IAAW;IAbtB;;KAEG,CACH,IAAIC,GAAG,GAAGD,CAAAA,GAAO,GAAPA,GAAG,CAACC,GAAG,SAAS,GAAhBD,KAAAA,CAAgB,GAAhBA,GAAO,CAAEE,OAAO,AAAC;IAC3B,IAAI,CAACD,GAAG,EAAE;QACR,MAAME,QAAQ,GAAGC,YAAW,QAAA,CAACC,MAAM,CAACN,WAAW,EAAE,mCAAmC,CAAC,AAAC;QACtFE,GAAG,GAAGE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;KACtC;QAIMH,IAAgB,EAEZA,IAAoB;IAJ/B,OAAO;QACL,oCAAoC;QACpCM,GAAG,EAAEN,CAAAA,IAAgB,GAAhBA,CAAAA,IAAO,GAAPA,GAAG,CAACM,GAAG,SAAS,GAAhBN,KAAAA,CAAgB,GAAhBA,IAAO,CAAEE,OAAO,YAAhBF,IAAgB,GAAI,OAAO;QAChC,oCAAoC;QACpCO,OAAO,EAAEP,CAAAA,IAAoB,GAApBA,CAAAA,IAAW,GAAXA,GAAG,CAACO,OAAO,SAAS,GAApBP,KAAAA,CAAoB,GAApBA,IAAW,CAAEE,OAAO,YAApBF,IAAoB,GAAI,OAAO;QACxCC,GAAG;KACJ,CAAC;CACH"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../src/start/server/type-generation/__typetests__/fixtures/basic.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable import/export */\n/* eslint-disable @typescript-eslint/ban-types */\n\nimport type { LinkProps as OriginalLinkProps } from 'expo-router/build/link/Link';\nimport type { Router as OriginalRouter } from 'expo-router/build/types';\nexport * from 'expo-router/build';\n\n// prettier-ignore\ntype StaticRoutes = `/apple` | `/banana`;\n// prettier-ignore\ntype DynamicRoutes<T extends string> = `/colors/${SingleRoutePart<T>}` | `/animals/${CatchAllRoutePart<T>}` | `/mix/${SingleRoutePart<T>}/${SingleRoutePart<T>}/${CatchAllRoutePart<T>}`;\n// prettier-ignore\ntype DynamicRouteTemplate = `/colors/[color]` | `/animals/[...animal]` | `/mix/[fruit]/[color]/[...animals]`;\n\ntype RelativePathString = `./${string}` | `../${string}` | '..';\ntype AbsoluteRoute = DynamicRouteTemplate | StaticRoutes;\ntype ExternalPathString = `${string}:${string}`;\n\ntype ExpoRouterRoutes = DynamicRouteTemplate | StaticRoutes | RelativePathString;\ntype AllRoutes = ExpoRouterRoutes | ExternalPathString;\n\n/****************\n * Route Utils *\n ****************/\n\ntype SearchOrHash = `?${string}` | `#${string}`;\ntype UnknownInputParams = Record<string, string | number | (string | number)[]>;\ntype UnknownOutputParams = Record<string, string | string[]>;\n\n/**\n * Return only the RoutePart of a string. If the string has multiple parts return never\n *\n * string | type\n * ---------|------\n * 123 | 123\n * /123/abc | never\n * 123?abc | never\n * ./123 | never\n * /123 | never\n * 123/../ | never\n */\ntype SingleRoutePart<S extends string> = S extends `${string}/${string}`\n ? never\n : S extends `${string}${SearchOrHash}`\n ? never\n : S extends ''\n ? never\n : S extends `(${string})`\n ? never\n : S extends `[${string}]`\n ? never\n : S;\n\n/**\n * Return only the CatchAll router part. If the string has search parameters or a hash return never\n */\ntype CatchAllRoutePart<S extends string> = S extends `${string}${SearchOrHash}`\n ? never\n : S extends ''\n ? never\n : S extends `${string}(${string})${string}`\n ? never\n : S extends `${string}[${string}]${string}`\n ? never\n : S;\n\n// type OptionalCatchAllRoutePart<S extends string> = S extends `${string}${SearchOrHash}` ? never : S\n\n/**\n * Return the name of a route parameter\n * '[test]' -> 'test'\n * 'test' -> never\n * '[...test]' -> '...test'\n */\ntype IsParameter<Part> = Part extends `[${infer ParamName}]` ? ParamName : never;\n\n/**\n * Return a union of all parameter names. If there are no names return never\n *\n * /[test] -> 'test'\n * /[abc]/[...def] -> 'abc'|'...def'\n */\ntype ParameterNames<Path> = Path extends `${infer PartA}/${infer PartB}`\n ? IsParameter<PartA> | ParameterNames<PartB>\n : IsParameter<Path>;\n\n/**\n * Returns all segements of a route.\n *\n * /(group)/123/abc/[id]/[...rest] -> ['(group)', '123', 'abc', '[id]', '[...rest]'\n */\ntype RouteSegments<Path> = Path extends `${infer PartA}/${infer PartB}`\n ? PartA extends '' | '.'\n ? [...RouteSegments<PartB>]\n : [PartA, ...RouteSegments<PartB>]\n : Path extends ''\n ? []\n : [Path];\n\n/**\n * Returns a Record of the routes parameters as strings and CatchAll parameters\n *\n * There are two versions, input and output, as you can input 'string | number' but\n * the output will always be 'string'\n *\n * /[id]/[...rest] -> { id: string, rest: string[] }\n * /no-params -> {}\n */\ntype InputRouteParams<Path> = {\n [Key in ParameterNames<Path> as Key extends `...${infer Name}`\n ? Name\n : Key]: Key extends `...${string}` ? (string | number)[] : string | number;\n} & UnknownInputParams;\n\ntype OutputRouteParams<Path> = {\n [Key in ParameterNames<Path> as Key extends `...${infer Name}`\n ? Name\n : Key]: Key extends `...${string}` ? string[] : string;\n} & UnknownOutputParams;\n\n/**\n * Returns the search parameters for a route.\n */\nexport type SearchParams<T extends AllRoutes> = T extends DynamicRouteTemplate\n ? OutputRouteParams<T>\n : T extends StaticRoutes\n ? never\n : UnknownOutputParams;\n\n/**\n * Route is mostly used as part of Href to ensure that a valid route is provided\n *\n * Given a dynamic route, this will return never. This is helpful for conditional logic\n *\n * /test -> /test, /test2, etc\n * /test/[abc] -> never\n * /test/resolve -> /test, /test2, etc\n *\n * Note that if we provide a value for [abc] then the route is allowed\n *\n * This is named Route to prevent confusion, as users they will often see it in tooltips\n */\nexport type Route<T> = T extends string\n ? T extends DynamicRouteTemplate\n ? never\n :\n | StaticRoutes\n | RelativePathString\n | ExternalPathString\n | (T extends `${infer P}${SearchOrHash}`\n ? P extends DynamicRoutes<infer _>\n ? T\n : never\n : T extends DynamicRoutes<infer _>\n ? T\n : never)\n : never;\n\n/*********\n * Href *\n *********/\n\nexport type Href<T> = T extends Record<'pathname', string> ? HrefObject<T> : Route<T>;\n\nexport type HrefObject<\n R extends Record<'pathname', string>,\n P = R['pathname'],\n> = P extends DynamicRouteTemplate\n ? { pathname: P; params: InputRouteParams<P> }\n : P extends Route<P>\n ? { pathname: Route<P> | DynamicRouteTemplate; params?: never | InputRouteParams<never> }\n : never;\n\n/***********************\n * Expo Router Exports *\n ***********************/\n\nexport type Router = Omit<OriginalRouter, 'push' | 'replace' | 'setParams'> & {\n /** Navigate to the provided href. */\n push: <T>(href: Href<T>) => void;\n /** Navigate to route without appending to the history. */\n replace: <T>(href: Href<T>) => void;\n /** Update the current route query params. */\n setParams: <T = ''>(params?: T extends '' ? Record<string, string> : InputRouteParams<T>) => void;\n};\n\n/** The imperative router. */\nexport declare const router: Router;\n\n/************\n * <Link /> *\n ************/\nexport interface LinkProps<T> extends OriginalLinkProps {\n href: Href<T>;\n}\n\nexport interface LinkComponent {\n <T>(props: React.PropsWithChildren<LinkProps<T>>): JSX.Element;\n /** Helper method to resolve an Href object into a string. */\n resolveHref: <T>(href: Href<T>) => string;\n}\n\n/**\n * Component to render link to another route using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.href Absolute path to route (e.g. `/feeds/hot`).\n * @param props.replace Should replace the current route without adding to the history.\n * @param props.asChild Forward props to child component. Useful for custom buttons.\n * @param props.children Child elements to render the content.\n * @param props.className On web, this sets the HTML `class` directly. On native, this can be used with CSS interop tools like Nativewind.\n */\nexport declare const Link: LinkComponent;\n\n/** Redirects to the href as soon as the component is mounted. */\nexport declare const Redirect: <T>(\n props: React.PropsWithChildren<{ href: Href<T> }>\n) => JSX.Element;\n\n/************\n * Hooks *\n ************/\nexport declare function useRouter(): Router;\n\nexport declare function useLocalSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n>(): T extends AllRoutes ? SearchParams<T> : T;\n\n/** @deprecated renamed to `useGlobalSearchParams` */\nexport declare function useSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n>(): T extends AllRoutes ? SearchParams<T> : T;\n\nexport declare function useGlobalSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n>(): T extends AllRoutes ? SearchParams<T> : T;\n\nexport declare function useSegments<\n T extends AbsoluteRoute | RouteSegments<AbsoluteRoute> | RelativePathString,\n>(): T extends AbsoluteRoute ? RouteSegments<T> : T extends string ? string[] : T;\n"],"names":[],"mappings":"AAIA;;;;6CAEc,mBAAmB;AAAjC,YAAA,MAAkC;;2CAAlC,MAAkC;;;;mBAAlC,MAAkC;;;EAAA"}
1
+ {"version":3,"sources":["../../../../../../../src/start/server/type-generation/__typetests__/fixtures/basic.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable import/export */\n/* eslint-disable @typescript-eslint/ban-types */\n\nimport type { LinkProps as OriginalLinkProps } from 'expo-router/build/link/Link';\nimport type { Router as OriginalRouter } from 'expo-router/build/types';\nexport * from 'expo-router/build';\n\n// prettier-ignore\ntype StaticRoutes = `/apple` | `/banana`;\n// prettier-ignore\ntype DynamicRoutes<T extends string> = `/colors/${SingleRoutePart<T>}` | `/animals/${CatchAllRoutePart<T>}` | `/mix/${SingleRoutePart<T>}/${SingleRoutePart<T>}/${CatchAllRoutePart<T>}`;\n// prettier-ignore\ntype DynamicRouteTemplate = `/colors/[color]` | `/animals/[...animal]` | `/mix/[fruit]/[color]/[...animals]`;\n\ntype RelativePathString = `./${string}` | `../${string}` | '..';\ntype AbsoluteRoute = DynamicRouteTemplate | StaticRoutes;\ntype ExternalPathString = `${string}:${string}`;\n\ntype ExpoRouterRoutes = DynamicRouteTemplate | StaticRoutes | RelativePathString;\nexport type AllRoutes = ExpoRouterRoutes | ExternalPathString;\n\n/****************\n * Route Utils *\n ****************/\n\ntype SearchOrHash = `?${string}` | `#${string}`;\ntype UnknownInputParams = Record<string, string | number | (string | number)[]>;\ntype UnknownOutputParams = Record<string, string | string[]>;\n\n/**\n * Return only the RoutePart of a string. If the string has multiple parts return never\n *\n * string | type\n * ---------|------\n * 123 | 123\n * /123/abc | never\n * 123?abc | never\n * ./123 | never\n * /123 | never\n * 123/../ | never\n */\ntype SingleRoutePart<S extends string> = S extends `${string}/${string}`\n ? never\n : S extends `${string}${SearchOrHash}`\n ? never\n : S extends ''\n ? never\n : S extends `(${string})`\n ? never\n : S extends `[${string}]`\n ? never\n : S;\n\n/**\n * Return only the CatchAll router part. If the string has search parameters or a hash return never\n */\ntype CatchAllRoutePart<S extends string> = S extends `${string}${SearchOrHash}`\n ? never\n : S extends ''\n ? never\n : S extends `${string}(${string})${string}`\n ? never\n : S extends `${string}[${string}]${string}`\n ? never\n : S;\n\n// type OptionalCatchAllRoutePart<S extends string> = S extends `${string}${SearchOrHash}` ? never : S\n\n/**\n * Return the name of a route parameter\n * '[test]' -> 'test'\n * 'test' -> never\n * '[...test]' -> '...test'\n */\ntype IsParameter<Part> = Part extends `[${infer ParamName}]` ? ParamName : never;\n\n/**\n * Return a union of all parameter names. If there are no names return never\n *\n * /[test] -> 'test'\n * /[abc]/[...def] -> 'abc'|'...def'\n */\ntype ParameterNames<Path> = Path extends `${infer PartA}/${infer PartB}`\n ? IsParameter<PartA> | ParameterNames<PartB>\n : IsParameter<Path>;\n\n/**\n * Returns all segements of a route.\n *\n * /(group)/123/abc/[id]/[...rest] -> ['(group)', '123', 'abc', '[id]', '[...rest]'\n */\ntype RouteSegments<Path> = Path extends `${infer PartA}/${infer PartB}`\n ? PartA extends '' | '.'\n ? [...RouteSegments<PartB>]\n : [PartA, ...RouteSegments<PartB>]\n : Path extends ''\n ? []\n : [Path];\n\n/**\n * Returns a Record of the routes parameters as strings and CatchAll parameters\n *\n * There are two versions, input and output, as you can input 'string | number' but\n * the output will always be 'string'\n *\n * /[id]/[...rest] -> { id: string, rest: string[] }\n * /no-params -> {}\n */\ntype InputRouteParams<Path> = {\n [Key in ParameterNames<Path> as Key extends `...${infer Name}`\n ? Name\n : Key]: Key extends `...${string}` ? (string | number)[] : string | number;\n} & UnknownInputParams;\n\ntype OutputRouteParams<Path> = {\n [Key in ParameterNames<Path> as Key extends `...${infer Name}`\n ? Name\n : Key]: Key extends `...${string}` ? string[] : string;\n} & UnknownOutputParams;\n\n/**\n * Returns the search parameters for a route.\n */\nexport type SearchParams<T extends AllRoutes> = T extends DynamicRouteTemplate\n ? OutputRouteParams<T>\n : T extends StaticRoutes\n ? never\n : UnknownOutputParams;\n\n/**\n * Route is mostly used as part of Href to ensure that a valid route is provided\n *\n * Given a dynamic route, this will return never. This is helpful for conditional logic\n *\n * /test -> /test, /test2, etc\n * /test/[abc] -> never\n * /test/resolve -> /test, /test2, etc\n *\n * Note that if we provide a value for [abc] then the route is allowed\n *\n * This is named Route to prevent confusion, as users they will often see it in tooltips\n */\nexport type Route<T> = T extends string\n ? T extends DynamicRouteTemplate\n ? never\n :\n | StaticRoutes\n | RelativePathString\n | ExternalPathString\n | (T extends `${infer P}${SearchOrHash}`\n ? P extends DynamicRoutes<infer _>\n ? T\n : never\n : T extends DynamicRoutes<infer _>\n ? T\n : never)\n : never;\n\n/*********\n * Href *\n *********/\n\nexport type Href<T> = T extends Record<'pathname', string> ? HrefObject<T> : Route<T>;\n\nexport type HrefObject<\n R extends Record<'pathname', string>,\n P = R['pathname'],\n> = P extends DynamicRouteTemplate\n ? { pathname: P; params: InputRouteParams<P> }\n : P extends Route<P>\n ? { pathname: Route<P> | DynamicRouteTemplate; params?: never | InputRouteParams<never> }\n : never;\n\n/***********************\n * Expo Router Exports *\n ***********************/\n\nexport type Router = Omit<OriginalRouter, 'push' | 'replace' | 'setParams'> & {\n /** Navigate to the provided href. */\n push: <T>(href: Href<T>) => void;\n /** Navigate to route without appending to the history. */\n replace: <T>(href: Href<T>) => void;\n /** Update the current route query params. */\n setParams: <T = ''>(params?: T extends '' ? Record<string, string> : InputRouteParams<T>) => void;\n};\n\n/** The imperative router. */\nexport declare const router: Router;\n\n/************\n * <Link /> *\n ************/\nexport interface LinkProps<T> extends OriginalLinkProps {\n href: Href<T>;\n}\n\nexport interface LinkComponent {\n <T>(props: React.PropsWithChildren<LinkProps<T>>): JSX.Element;\n /** Helper method to resolve an Href object into a string. */\n resolveHref: <T>(href: Href<T>) => string;\n}\n\n/**\n * Component to render link to another route using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.href Absolute path to route (e.g. `/feeds/hot`).\n * @param props.replace Should replace the current route without adding to the history.\n * @param props.asChild Forward props to child component. Useful for custom buttons.\n * @param props.children Child elements to render the content.\n * @param props.className On web, this sets the HTML `class` directly. On native, this can be used with CSS interop tools like Nativewind.\n */\nexport declare const Link: LinkComponent;\n\n/** Redirects to the href as soon as the component is mounted. */\nexport declare const Redirect: <T>(\n props: React.PropsWithChildren<{ href: Href<T> }>\n) => JSX.Element;\n\n/************\n * Hooks *\n ************/\nexport declare function useRouter(): Router;\n\nexport declare function useLocalSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n>(): T extends AllRoutes ? SearchParams<T> : T;\n\n/** @deprecated renamed to `useGlobalSearchParams` */\nexport declare function useSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n>(): T extends AllRoutes ? SearchParams<T> : T;\n\nexport declare function useGlobalSearchParams<\n T extends AllRoutes | UnknownOutputParams = UnknownOutputParams,\n>(): T extends AllRoutes ? SearchParams<T> : T;\n\nexport declare function useSegments<\n T extends AbsoluteRoute | RouteSegments<AbsoluteRoute> | RelativePathString,\n>(): T extends AbsoluteRoute ? RouteSegments<T> : T extends string ? string[] : T;\n"],"names":[],"mappings":"AAIA;;;;6CAEc,mBAAmB;AAAjC,YAAA,MAAkC;;2CAAlC,MAAkC;;;;mBAAlC,MAAkC;;;EAAA"}
@@ -249,7 +249,7 @@ declare module "expo-router" {
249
249
  type ExternalPathString = \`\${string}:\${string}\`;
250
250
 
251
251
  type ExpoRouterRoutes = DynamicRouteTemplate | StaticRoutes | RelativePathString;
252
- type AllRoutes = ExpoRouterRoutes | ExternalPathString;
252
+ export type AllRoutes = ExpoRouterRoutes | ExternalPathString;
253
253
 
254
254
  /****************
255
255
  * Route Utils *