@expo/cli 56.1.6 → 56.1.8

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 (50) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/api/rest/client.js +27 -12
  3. package/build/src/api/rest/client.js.map +1 -1
  4. package/build/src/api/user/UserSettings.js +17 -4
  5. package/build/src/api/user/UserSettings.js.map +1 -1
  6. package/build/src/events/index.js +1 -1
  7. package/build/src/export/embed/exportEmbedAsync.js +2 -2
  8. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  9. package/build/src/install/utils/checkPackagesCompatibility.js +32 -16
  10. package/build/src/install/utils/checkPackagesCompatibility.js.map +1 -1
  11. package/build/src/prebuild/resolveTemplate.js +10 -5
  12. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  13. package/build/src/start/platforms/AppIdResolver.js +4 -0
  14. package/build/src/start/platforms/AppIdResolver.js.map +1 -1
  15. package/build/src/start/platforms/android/adb.js +16 -15
  16. package/build/src/start/platforms/android/adb.js.map +1 -1
  17. package/build/src/start/server/UrlCreator.js +10 -1
  18. package/build/src/start/server/UrlCreator.js.map +1 -1
  19. package/build/src/start/server/getStaticRenderFunctions.js +2 -1
  20. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  21. package/build/src/start/server/metro/debugging/createDebugMiddleware.js +5 -4
  22. package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
  23. package/build/src/start/server/metro/debugging/messageHandlers/NetworkResponse.js +17 -1
  24. package/build/src/start/server/metro/debugging/messageHandlers/NetworkResponse.js.map +1 -1
  25. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +7 -1
  26. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
  27. package/build/src/start/server/metro/instantiateMetro.js +3 -1
  28. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  29. package/build/src/start/server/metro/metroErrorInterface.js +5 -2
  30. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  31. package/build/src/start/server/metro/withMetroMultiPlatform.js +8 -0
  32. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  33. package/build/src/start/server/middleware/InterstitialPageMiddleware.js +7 -4
  34. package/build/src/start/server/middleware/InterstitialPageMiddleware.js.map +1 -1
  35. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +14 -24
  36. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +1 -1
  37. package/build/src/utils/codesigning.js +6 -0
  38. package/build/src/utils/codesigning.js.map +1 -1
  39. package/build/src/utils/env.js +29 -6
  40. package/build/src/utils/env.js.map +1 -1
  41. package/build/src/utils/net.js +13 -0
  42. package/build/src/utils/net.js.map +1 -1
  43. package/build/src/utils/open.js +2 -5
  44. package/build/src/utils/open.js.map +1 -1
  45. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  46. package/build/src/utils/telemetry/utils/context.js +1 -1
  47. package/build/src/utils/url.js +0 -12
  48. package/build/src/utils/url.js.map +1 -1
  49. package/package.json +22 -22
  50. package/static/loading-page/index.html +10 -2
@@ -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 type { ExpoConfig, Platform } from '@expo/config';\nimport type Bundler from '@expo/metro/metro/Bundler';\nimport type { ConfigT } from '@expo/metro/metro-config';\nimport type {\n Resolution,\n ResolutionContext,\n CustomResolutionContext,\n} from '@expo/metro/metro-resolver';\nimport { resolve as resolver } from '@expo/metro/metro-resolver';\nimport type { SourceFileResolution } from '@expo/metro/metro-resolver/types';\nimport { resolveFrom } from '@expo/require-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport type {\n AutolinkingModuleResolverInput,\n AutolinkingPlatform,\n} from './createExpoAutolinkingResolver';\nimport {\n createAutolinkingModuleResolverInput,\n createAutolinkingModuleResolver,\n} from './createExpoAutolinkingResolver';\nimport { createFallbackModuleResolver } from './createExpoFallbackResolver';\nimport { FailedToResolveNativeOnlyModuleError } from './errors/FailedToResolveNativeOnlyModuleError';\nimport { isNodeExternal, shouldCreateVirtualShim } from './externals';\nimport { isFailedToResolveNameError, isFailedToResolvePathError } from './metroErrors';\nimport { getMetroBundlerWithVirtualModules } from './metroVirtualModules';\nimport { withMetroErrorReportingResolver } from './withMetroErrorReportingResolver';\nimport { withMetroMutatedResolverContext, withMetroResolvers } from './withMetroResolvers';\nimport { withMetroSupervisingTransformWorker } from './withMetroSupervisingTransformWorker';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { isServerEnvironment } from '../middleware/metroOptions';\nimport type { PlatformBundlers } from '../platformBundlers';\nimport { createTypescriptResolver } from './createTypescriptResolver';\n\nexport type StrictResolver = (moduleName: string) => Resolution;\nexport type StrictResolverFactory = (\n context: ResolutionContext,\n platform: string | null\n) => StrictResolver;\n\nconst ASSET_REGISTRY_SRC = `const assets=[];module.exports={registerAsset:s=>assets.push(s),getAssetByID:s=>assets[s-1]};`;\n\nconst debug = require('debug')('expo:start:server:metro:multi-platform') as typeof console.log;\n\nfunction asWritable<T>(input: T): { -readonly [K in keyof T]: T[K] } {\n return input;\n}\n\nfunction withWebPolyfills(\n config: ConfigT,\n {\n getMetroBundler,\n }: {\n getMetroBundler: () => Bundler;\n }\n): 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 const virtualEnvVarId = `\\0polyfill:environment-variables`;\n\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualEnvVarId,\n (() => {\n return `//`;\n })()\n );\n\n const virtualModuleId = `\\0polyfill:external-require`;\n\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualModuleId,\n (() => {\n if (ctx.platform === 'web') {\n // NOTE(@hassankhan): We need to wrap require in an arrow function rather than assigning\n // it directly because `workerd` loses its `this` context when `require` is dereferenced\n // and called later.\n return `global.$$require_external = typeof require !== \"undefined\" ? (m) => require(m) : () => null;`;\n } else {\n // Wrap in try/catch to support Android.\n return 'try { global.$$require_external = typeof expo === \"undefined\" ? require : (moduleId) => { throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);} } catch { global.$$require_external = (moduleId) => { throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);} }';\n }\n })()\n );\n\n const virtualModulesPolyfills = [virtualModuleId, virtualEnvVarId];\n\n if (ctx.platform === 'web') {\n try {\n const rnGetPolyfills: () => string[] = require('react-native/rn-get-polyfills');\n return [\n ...virtualModulesPolyfills,\n // Ensure that the error-guard polyfill is included in the web polyfills to\n // make metro-runtime work correctly.\n // TODO: This module is pretty big for a function that simply re-throws an error that doesn't need to be caught.\n // NOTE(@kitten): This is technically the public API to get polyfills rather than resolving directly into\n // `@react-native/js-polyfills`. We should really just start vendoring these, but for now, this exclusion works\n ...rnGetPolyfills().filter((x: string) => !x.includes('/console')),\n ];\n } catch (error: any) {\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n // If react-native is not installed, because we're targeting web, we still continue\n // This should be rare, but we add it so we don't unnecessarily have a fixed peer dependency on react-native\n debug(\n 'Skipping react-native/rn-get-polyfills from getPolyfills. react-native is not installed.'\n );\n return virtualModulesPolyfills;\n } else {\n throw error;\n }\n }\n }\n\n // Generally uses `@expo/metro-config`'s `getPolyfills` function, unless overridden\n const polyfills = originalGetPolyfills(ctx);\n return [\n ...polyfills,\n ...virtualModulesPolyfills,\n // Removed on server platforms during the transform.\n require.resolve('expo/virtual/streams.js'),\n ];\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 autolinkingModuleResolverInput,\n isTsconfigPathsEnabled,\n isExporting,\n isReactServerComponentsEnabled,\n getMetroBundler,\n }: {\n autolinkingModuleResolverInput?: AutolinkingModuleResolverInput;\n isTsconfigPathsEnabled?: boolean;\n isExporting?: boolean;\n isReactServerComponentsEnabled?: boolean;\n getMetroBundler: () => Bundler;\n }\n) {\n if (isReactServerComponentsEnabled) {\n Log.warn(`React Server Components (beta) is enabled.`);\n }\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 'react-native/Libraries/Image/resolveAssetSource': 'expo-asset/build/resolveAssetSource',\n },\n };\n\n const isExpoRouterInstalled = hasExpoRouterModule(\n config.projectRoot,\n autolinkingModuleResolverInput\n );\n\n let _universalAliases: [RegExp, string][] | null;\n\n function getUniversalAliases() {\n if (_universalAliases) {\n return _universalAliases;\n }\n\n _universalAliases = [];\n\n // This package is currently always installed as it is included in the `expo` package.\n if (resolveFrom(config.projectRoot, '@expo/vector-icons/package.json')) {\n debug('Enabling alias: react-native-vector-icons -> @expo/vector-icons');\n _universalAliases.push([/^react-native-vector-icons(\\/.*)?/, '@expo/vector-icons$1']);\n }\n if (isReactServerComponentsEnabled) {\n if (resolveFrom(config.projectRoot, 'expo-router/rsc')) {\n debug('Enabling bridge alias: expo-router -> expo-router/rsc');\n _universalAliases.push([/^expo-router$/, 'expo-router/rsc']);\n // Bridge the internal entry point which is a standalone import to ensure package.json resolution works as expected.\n _universalAliases.push([/^expo-router\\/entry-classic$/, 'expo-router/rsc/entry']);\n }\n }\n return _universalAliases;\n }\n\n // used to resolve externals in `requestCustomExternals` from the project root\n const projectRootOriginPath = path.join(config.projectRoot, 'package.json');\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 nodejsSourceExtensions: string[] | null = null;\n\n const getStrictResolver: StrictResolverFactory = (\n { resolveRequest, ...context },\n platform\n ): StrictResolver => {\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 // TODO: This is a hack to get resolveWeak working.\n const idFactory = (config.serializer?.createModuleIdFactory?.() ??\n ((id: number | string, context: { platform: string; environment?: string }): number | string =>\n id)) as (\n id: number | string,\n context: { platform: string; environment?: string }\n ) => number | string;\n\n // We're manually resolving the `asyncRequireModulePath` since it's a module request\n // However, in isolated installations it might not resolve from all paths, so we're resolving\n // it from the project root manually\n let _asyncRequireModuleResolvedPath: string | null | undefined;\n const getAsyncRequireModule = () => {\n if (_asyncRequireModuleResolvedPath === undefined) {\n _asyncRequireModuleResolvedPath =\n resolveFrom(config.projectRoot, config.transformer.asyncRequireModulePath) ?? null;\n }\n return _asyncRequireModuleResolvedPath\n ? ({ type: 'sourceFile', filePath: _asyncRequireModuleResolvedPath } as const)\n : null;\n };\n\n const getAssetRegistryModule = () => {\n const virtualModuleId = `\\0polyfill:assets-registry`;\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualModuleId,\n ASSET_REGISTRY_SRC\n );\n return {\n type: 'sourceFile',\n filePath: virtualModuleId,\n } as const;\n };\n\n // If Node.js pass-through, then remap to a module like `module.exports = $$require_external(<module>)`.\n // If module should be shimmed, remap to an empty module.\n const externals: {\n match: (context: ResolutionContext, moduleName: string, platform: string | null) => boolean;\n replace: 'empty' | 'node' | 'weak';\n }[] = [\n {\n match: (context: ResolutionContext, moduleName: string) => {\n if (\n // Disable internal externals when exporting for production.\n context.customResolverOptions.exporting ||\n // These externals are only for Node.js environments.\n !isServerEnvironment(context.customResolverOptions?.environment)\n ) {\n return false;\n }\n\n if (context.customResolverOptions?.environment === 'react-server') {\n // Ensure these non-react-server modules are excluded when bundling for React Server Components in development.\n return /^(@babel\\/runtime\\/.+|debug|metro-runtime\\/src\\/modules\\/HMRClient|metro|acorn-loose|acorn|chalk|ws|ansi-styles|supports-color|color-convert|has-flag|utf-8-validate|color-name|react-refresh\\/runtime|@remix-run\\/node\\/.+)$/.test(\n moduleName\n );\n }\n\n // TODO: Windows doesn't support externals somehow.\n if (process.platform === 'win32') {\n return false;\n }\n\n // Extern these modules in standard Node.js environments in development to prevent API routes side-effects\n // from leaking into the dev server process.\n return /^(react|@radix-ui\\/.+|@babel\\/runtime\\/.+|react-dom(\\/.+)?|debug|acorn-loose|acorn|css-in-js-utils\\/lib\\/.+|hyphenate-style-name|color|color-string|color-convert|color-name|fontfaceobserver|fast-deep-equal|query-string|escape-string-regexp|invariant|postcss-value-parser|memoize-one|nullthrows|strict-uri-encode|decode-uri-component|split-on-first|filter-obj|warn-once|simple-swizzle|is-arrayish|inline-style-prefixer\\/.+)$/.test(\n moduleName\n );\n },\n replace: 'node',\n },\n // Externals to speed up async split chunks by extern-ing common packages that appear in the root client chunk.\n {\n match: (context: ResolutionContext, moduleName: string, platform: string | null) => {\n if (\n // Disable internal externals when exporting for production.\n context.customResolverOptions.exporting ||\n // These externals are only for client environments.\n isServerEnvironment(context.customResolverOptions?.environment) ||\n // Only enable for client boundaries\n !context.customResolverOptions.clientboundary\n ) {\n return false;\n }\n\n // We don't support this in the resolver at the moment.\n if (moduleName.endsWith('/package.json')) {\n return false;\n }\n\n const isExternal = // Extern these modules in standard Node.js environments.\n /^(deprecated-react-native-prop-types|react|react\\/jsx-dev-runtime|scheduler|react-native|react-dom(\\/.+)?|metro-runtime(\\/.+)?)$/.test(\n moduleName\n ) ||\n // TODO: Add more\n /^@babel\\/runtime\\/helpers\\/(wrapNativeSuper)$/.test(moduleName);\n\n return isExternal;\n },\n replace: 'weak',\n },\n ];\n\n const skipMetroMainFieldOverride = env.EXPO_METRO_NO_MAIN_FIELD_OVERRIDE;\n const useExpoUnstableWebModule = env.EXPO_UNSTABLE_WEB_MODAL;\n const useExpoUnstableLogBox = env.EXPO_UNSTABLE_LOG_BOX;\n const disableReactNavigationCheck = env.EXPO_ROUTER_DISABLE_RN_NAVIGATION_CHECK;\n\n const metroConfigWithCustomResolver = withMetroResolvers(config, [\n // Mock out production react imports in development.\n function requestDevMockProdReact(\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n // This resolution is dev-only to prevent bundling the production React packages in development.\n if (!context.dev) return null;\n\n if (\n // Match react-native renderers.\n (platform !== 'web' &&\n context.originModulePath.match(/[\\\\/]node_modules[\\\\/]react-native[\\\\/]/) &&\n moduleName.match(/([\\\\/]ReactFabric|ReactNativeRenderer)-prod/)) ||\n // Match react production imports.\n (moduleName.match(/\\.production(\\.min)?\\.js$/) &&\n // Match if the import originated from a react package.\n context.originModulePath.match(/[\\\\/]node_modules[\\\\/](react[-\\\\/]|scheduler[\\\\/])/))\n ) {\n debug(`Skipping production module: ${moduleName}`);\n // /Users/path/to/expo/node_modules/react/index.js ./cjs/react.production.min.js\n // /Users/path/to/expo/node_modules/react/jsx-dev-runtime.js ./cjs/react-jsx-dev-runtime.production.min.js\n // /Users/path/to/expo/node_modules/react-is/index.js ./cjs/react-is.production.min.js\n // /Users/path/to/expo/node_modules/react-refresh/runtime.js ./cjs/react-refresh-runtime.production.min.js\n // /Users/path/to/expo/node_modules/react-native/node_modules/scheduler/index.native.js ./cjs/scheduler.native.production.min.js\n // /Users/path/to/expo/node_modules/react-native/node_modules/react-is/index.js ./cjs/react-is.production.min.js\n return {\n type: 'empty',\n };\n }\n return null;\n },\n\n isTsconfigPathsEnabled\n ? createTypescriptResolver({\n getStrictResolver,\n projectRoot: config.projectRoot,\n getMetroBundler,\n watch: !isExporting && !env.CI,\n })\n : undefined,\n\n // Node.js externals support\n function requestNodeExternals(\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n const isServer =\n context.customResolverOptions?.environment === 'node' ||\n context.customResolverOptions?.environment === 'react-server';\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 !isServer\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\n if (!result && platform !== 'web') {\n // Preserve previous behavior where native throws an error on node.js internals.\n return null;\n }\n\n return (\n result ?? {\n // In this case, mock the file to use an empty module.\n type: 'empty',\n }\n );\n }\n const contents = `module.exports=$$require_external('node:${moduleId}');`;\n debug(`Virtualizing Node.js \"${moduleId}\"`);\n const virtualModuleId = `\\0node:${moduleId}`;\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualModuleId,\n contents\n );\n return {\n type: 'sourceFile',\n filePath: virtualModuleId,\n };\n },\n\n // Custom externals support\n function requestCustomExternals(\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n // We don't support this in the resolver at the moment.\n if (moduleName.endsWith('/package.json')) {\n return null;\n }\n // Skip applying JS externals for CSS files.\n if (/\\.(s?css|sass)$/.test(context.originModulePath)) {\n return null;\n }\n\n for (const external of externals) {\n if (external.match(context, moduleName, platform)) {\n if (external.replace === 'empty') {\n debug(`Redirecting external \"${moduleName}\" to \"${external.replace}\"`);\n return {\n type: external.replace,\n };\n } else if (external.replace === 'weak') {\n // TODO: Make this use require.resolveWeak again. Previously this was just resolving to the same path.\n const realModule = getStrictResolver(context, platform)(moduleName);\n const realPath = realModule.type === 'sourceFile' ? realModule.filePath : moduleName;\n const opaqueId = idFactory(realPath, {\n platform: platform!,\n environment: context.customResolverOptions?.environment,\n });\n const contents =\n typeof opaqueId === 'number'\n ? `module.exports=/*${moduleName}*/__r(${opaqueId})`\n : `module.exports=/*${moduleName}*/__r(${JSON.stringify(opaqueId)})`;\n // const contents = `module.exports=/*${moduleName}*/__r(require.resolveWeak('${moduleName}'))`;\n // const generatedModuleId = fastHashMemoized(contents);\n const virtualModuleId = `\\0weak:${opaqueId}`;\n debug('Virtualizing module:', moduleName, '->', virtualModuleId);\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualModuleId,\n contents\n );\n return {\n type: 'sourceFile',\n filePath: virtualModuleId,\n };\n } else if (external.replace === 'node') {\n // TODO(@kitten): Temporary workaround. Our externals logic here isn't generic and only works\n // for development and not exports. We never intend to use it in exported production bundles,\n // however, this is still a dangerous implementation. To protect us from externalizing modules\n // that aren't available to the app, we force any resolution to happen via the project root\n const projectRootContext: ResolutionContext = {\n ...context,\n nodeModulesPaths: [],\n originModulePath: projectRootOriginPath,\n disableHierarchicalLookup: false,\n };\n const externModule = getStrictResolver(projectRootContext, platform)(moduleName);\n if (externModule.type !== 'sourceFile') {\n return null;\n }\n const contents = `module.exports=$$require_external('${moduleName}')`;\n const virtualModuleId = `\\0node:${moduleName}`;\n debug('Virtualizing Node.js (custom):', moduleName, '->', virtualModuleId);\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualModuleId,\n contents\n );\n return {\n type: 'sourceFile',\n filePath: virtualModuleId,\n };\n } else {\n external.replace satisfies never;\n }\n }\n }\n return null;\n },\n\n // Basic moduleId aliases\n function requestAlias(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 getUniversalAliases()) {\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 // Polyfill for asset registry (assetRegistryPath) and async require module (asyncRequireModulePath)\n function requestStableConfigModules(\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n if (moduleName === config.transformer.asyncRequireModulePath) {\n return getAsyncRequireModule();\n }\n\n // TODO(@kitten): Compare against `config.transformer.assetRegistryPath`\n if (/^@react-native\\/assets-registry\\/registry(\\.js)?$/.test(moduleName)) {\n return getAssetRegistryModule();\n }\n\n if (\n platform === 'web' &&\n context.originModulePath.match(/node_modules[\\\\/]react-native-web[\\\\/]/) &&\n moduleName.includes('/modules/AssetRegistry')\n ) {\n return getAssetRegistryModule();\n }\n\n return null;\n },\n\n createAutolinkingModuleResolver(autolinkingModuleResolverInput, {\n getStrictResolver,\n }),\n\n // TODO: Reduce these as much as possible in the future.\n // Complex post-resolution rewrites.\n function requestPostRewrites(\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n const doResolve = getStrictResolver(context, platform);\n\n const result = doResolve(moduleName);\n\n if (result.type !== 'sourceFile') {\n return result;\n }\n\n const normalizedPath = normalizeSlashes(result.filePath);\n\n const doReplace = (from: string, to: string | undefined, options?: { throws?: boolean }) =>\n doReplaceHelper(from, to, {\n normalizedPath,\n doResolve,\n ...options,\n });\n const doReplaceStrict = (from: string, to: string | undefined) =>\n doReplace(from, to, { throws: true });\n\n if (useExpoUnstableWebModule) {\n const webModalModule = doReplace(\n 'expo-router/build/layouts/_web-modal.js',\n 'expo-router/build/layouts/ExperimentalModalStack.js'\n );\n if (webModalModule) {\n debug('Using `_unstable-web-modal` implementation.');\n return webModalModule;\n }\n }\n\n if (!disableReactNavigationCheck) {\n // TODO(@ubax): Remove this rewrite once we published migration guide for library authors\n if (isExpoRouterInstalled && moduleName.startsWith('@react-navigation/')) {\n const filePath = context.originModulePath;\n if (!filePath.includes('node_modules')) {\n if (\n moduleName === '@react-navigation/native-stack' ||\n moduleName === '@react-navigation/drawer'\n ) {\n throw new Error(\n [\n 'As of SDK 56, expo-router is no longer compatible with react-navigation.',\n '',\n `Instead of ${moduleName}, use Stack or Drawer from expo-router instead:`,\n '',\n \" import { Stack } from 'expo-router';\",\n \" import { Drawer } from 'expo-router/drawer';\",\n '',\n 'For more information, see https://docs.expo.dev/router/migrate/sdk-55-to-56/.',\n 'You can disable this check by setting the environment variable EXPO_ROUTER_DISABLE_RN_NAVIGATION_CHECK=1.',\n ].join('\\n')\n );\n }\n throw new Error(\n 'As of SDK 56, expo-router is no longer compatible with react-navigation. For more information, see https://docs.expo.dev/router/migrate/sdk-55-to-56/. You can disable this check by setting the environment variable EXPO_ROUTER_DISABLE_RN_NAVIGATION_CHECK=1.'\n );\n }\n if (moduleName === '@react-navigation/core') {\n // We already checked if expo-router resolves\n return doResolve('expo-router/react-navigation');\n }\n }\n }\n\n if (platform === 'web') {\n if (result.filePath.includes('node_modules')) {\n // Disallow importing confusing native modules on web\n if (\n [\n 'react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore',\n 'react-native/Libraries/Utilities/codegenNativeCommands',\n 'react-native/Libraries/Utilities/codegenNativeComponent',\n ].some((matcher) =>\n // Support absolute and modules with .js extensions.\n moduleName.includes(matcher)\n )\n ) {\n throw new FailedToResolveNativeOnlyModuleError(\n moduleName,\n path.relative(config.projectRoot, context.originModulePath)\n );\n }\n\n // Replace with static shims\n\n // Drop everything up until the `node_modules` folder.\n const normalName = normalizedPath.replace(/.*node_modules\\//, '');\n\n const shimFile = shouldCreateVirtualShim(normalName);\n if (shimFile) {\n const virtualId = `\\0shim:${normalName}`;\n const bundler = getMetroBundlerWithVirtualModules(getMetroBundler());\n if (!bundler.hasVirtualModule(virtualId)) {\n bundler.setVirtualModule(virtualId, fs.readFileSync(shimFile, 'utf8'));\n }\n debug(`Redirecting module \"${result.filePath}\" to shim`);\n\n return {\n ...result,\n filePath: virtualId,\n };\n }\n }\n } else {\n const isServer =\n context.customResolverOptions?.environment === 'node' ||\n context.customResolverOptions?.environment === 'react-server';\n\n // Shim out React Native native runtime globals in server mode for native.\n if (isServer) {\n const emptyModule = doReplace('react-native/Libraries/Core/InitializeCore.js', undefined);\n if (emptyModule) {\n debug('Shimming out InitializeCore for React Native in native SSR bundle');\n return emptyModule;\n }\n }\n\n const hmrModule = doReplaceStrict(\n 'react-native/Libraries/Utilities/HMRClient.js',\n 'expo/src/async-require/hmr.ts'\n );\n if (hmrModule) return hmrModule;\n\n if (useExpoUnstableLogBox) {\n const logBoxModule = doReplace(\n 'react-native/Libraries/LogBox/LogBoxInspectorContainer.js',\n '@expo/log-box/swap-rn-logbox.js'\n );\n if (logBoxModule) return logBoxModule;\n\n const logBoxParserModule = doReplace(\n 'react-native/Libraries/LogBox/Data/parseLogBoxLog.js',\n '@expo/log-box/swap-rn-logbox-parser.js'\n );\n if (logBoxParserModule) return logBoxParserModule;\n }\n }\n\n return result;\n },\n\n // If at this point, we haven't resolved a module yet, if it's a module specifier for a known dependency\n // of either `expo` or `expo-router`, attempt to resolve it from these origin modules instead\n createFallbackModuleResolver({\n projectRoot: config.projectRoot,\n originModuleNames: ['expo', 'expo-router'],\n getStrictResolver,\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 = asWritable({\n ...immutableContext,\n preferNativePlatform: platform !== 'web',\n });\n\n if (isServerEnvironment(context.customResolverOptions?.environment)) {\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_conditionsByPlatform = {};\n\n const isReactServerComponents =\n context.customResolverOptions?.environment === 'react-server';\n\n if (isReactServerComponents) {\n // NOTE: Align the behavior across server and client. This is a breaking change so we'll just roll it out with React Server Components.\n // This ensures that react-server and client code both resolve `module` and `main` in the same order.\n if (platform === 'web') {\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 = ['module', 'main'];\n } else {\n // In Node.js + native, use the standard main fields.\n context.mainFields = ['react-native', 'module', 'main'];\n }\n } else {\n if (platform === 'web') {\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 // In Node.js + native, use the standard main fields.\n context.mainFields = ['react-native', 'main', 'module'];\n }\n }\n\n // Enable react-server import conditions.\n if (context.customResolverOptions?.environment === 'react-server') {\n context.unstable_conditionNames = ['node', 'react-server', 'workerd'];\n } else {\n context.unstable_conditionNames = ['node'];\n }\n } else {\n // Non-server changes\n\n if (!skipMetroMainFieldOverride && platform && platform in preferredMainFields) {\n context.mainFields = preferredMainFields[platform]!;\n }\n }\n\n return context;\n }\n );\n\n return withMetroErrorReportingResolver(\n withMetroSupervisingTransformWorker(metroConfigWithCustomContext)\n );\n}\n\nfunction doReplaceHelper(\n from: string,\n to: string | undefined,\n {\n throws = false,\n normalizedPath,\n doResolve,\n }: {\n throws?: boolean;\n normalizedPath: string;\n doResolve: StrictResolver;\n }\n): SourceFileResolution | { type: 'empty' } | undefined {\n if (!normalizedPath.endsWith(from)) {\n return undefined;\n }\n\n if (to === undefined) {\n return {\n type: 'empty',\n };\n }\n\n try {\n const hmrModule = doResolve(to);\n if (hmrModule.type === 'sourceFile') {\n debug(`Using \\`${to}\\` implementation.`);\n return hmrModule;\n }\n } catch (resolutionError) {\n if (throws) {\n throw new Error(`Failed to replace ${from} with ${to}. Resolution of ${to} failed.`, {\n cause: resolutionError,\n });\n }\n\n debug(`Failed to resolve ${to} when swapping from ${from}: ${resolutionError}`);\n }\n return undefined;\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\n isTsconfigPathsEnabled,\n isAutolinkingResolverEnabled,\n isExporting,\n isReactServerComponentsEnabled,\n\n getMetroBundler,\n }: {\n config: ConfigT;\n exp: ExpoConfig;\n isTsconfigPathsEnabled: boolean;\n platformBundlers: PlatformBundlers;\n serverRoot?: string | undefined;\n\n isAutolinkingResolverEnabled?: boolean;\n isExporting?: boolean;\n isReactServerComponentsEnabled: boolean;\n isNamedRequiresEnabled: boolean;\n\n getMetroBundler: () => Bundler;\n }\n) {\n const watchFolders = (config.watchFolders as string[]) || [];\n asWritable(config).watchFolders = watchFolders;\n\n // NOTE(@kitten): If the on-demand filesystem is enabled, we can aggressively cut down the `watchFolders`\n // to a minimum, since the files will be read lazily. This almost always speeds up exports\n if (isExporting && !!config.resolver.unstable_onDemandFilesystem) {\n watchFolders.length = 0;\n watchFolders.push(projectRoot);\n }\n\n // Change the default metro-runtime to a custom one that supports bundle splitting.\n // NOTE(@kitten): This is now always active and EXPO_USE_METRO_REQUIRE / isNamedRequiresEnabled is disregarded\n const metroDefaults: typeof import('@expo/metro/metro-config/defaults/defaults') = require('@expo/metro/metro-config/defaults/defaults');\n const metroRequirePolyfill = require.resolve('@expo/cli/build/metro-require/require');\n asWritable(metroDefaults).moduleSystem = metroRequirePolyfill;\n watchFolders.push(path.dirname(metroRequirePolyfill));\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 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 asWritable(config.resolver).platforms = expoConfigPlatforms;\n\n config = withWebPolyfills(config, { getMetroBundler });\n\n let autolinkingModuleResolverInput: AutolinkingModuleResolverInput | undefined;\n if (isAutolinkingResolverEnabled) {\n autolinkingModuleResolverInput = await createAutolinkingModuleResolverInput({\n platforms: expoConfigPlatforms,\n projectRoot,\n });\n }\n\n return withExtendedResolver(config, {\n autolinkingModuleResolverInput,\n isTsconfigPathsEnabled,\n isExporting,\n isReactServerComponentsEnabled,\n getMetroBundler,\n });\n}\n\nfunction hasExpoRouterModule(\n projectRoot: string,\n autolinkingModuleResolverInput: AutolinkingModuleResolverInput | undefined\n) {\n if (autolinkingModuleResolverInput) {\n // If we have autolinking enabled, we can skip resolution\n const platform = Object.keys(autolinkingModuleResolverInput)[0] as AutolinkingPlatform;\n return !!autolinkingModuleResolverInput[platform]?.resolvedModulePaths['expo-router'];\n } else {\n return !!resolveFrom(projectRoot, 'expo-router/package.json', {\n skipNodePath: true,\n });\n }\n}\n"],"names":["getNodejsExtensions","shouldAliasModule","withExtendedResolver","withMetroMultiPlatformAsync","ASSET_REGISTRY_SRC","debug","require","asWritable","input","withWebPolyfills","config","getMetroBundler","originalGetPolyfills","serializer","getPolyfills","bind","ctx","virtualEnvVarId","getMetroBundlerWithVirtualModules","setVirtualModule","virtualModuleId","platform","virtualModulesPolyfills","rnGetPolyfills","filter","x","includes","error","code","polyfills","resolve","normalizeSlashes","p","replace","srcExts","mjsExts","ext","test","nodejsSourceExtensions","jsIndex","reduce","index","i","splice","autolinkingModuleResolverInput","isTsconfigPathsEnabled","isExporting","isReactServerComponentsEnabled","Log","warn","aliases","web","isExpoRouterInstalled","hasExpoRouterModule","projectRoot","_universalAliases","getUniversalAliases","resolveFrom","push","projectRootOriginPath","path","join","preferredMainFields","getStrictResolver","resolveRequest","context","doResolve","moduleName","resolver","getOptionalResolver","optionalResolve","isResolutionError","isFailedToResolveNameError","isFailedToResolvePathError","idFactory","createModuleIdFactory","id","_asyncRequireModuleResolvedPath","getAsyncRequireModule","undefined","transformer","asyncRequireModulePath","type","filePath","getAssetRegistryModule","externals","match","customResolverOptions","exporting","isServerEnvironment","environment","process","clientboundary","endsWith","isExternal","skipMetroMainFieldOverride","env","EXPO_METRO_NO_MAIN_FIELD_OVERRIDE","useExpoUnstableWebModule","EXPO_UNSTABLE_WEB_MODAL","useExpoUnstableLogBox","EXPO_UNSTABLE_LOG_BOX","disableReactNavigationCheck","EXPO_ROUTER_DISABLE_RN_NAVIGATION_CHECK","metroConfigWithCustomResolver","withMetroResolvers","requestDevMockProdReact","dev","originModulePath","createTypescriptResolver","watch","CI","requestNodeExternals","isServer","moduleId","isNodeExternal","result","contents","requestCustomExternals","external","realModule","realPath","opaqueId","JSON","stringify","projectRootContext","nodeModulesPaths","disableHierarchicalLookup","externModule","requestAlias","redirectedModuleName","matcher","alias","aliasedModule","_","parseInt","requestStableConfigModules","createAutolinkingModuleResolver","requestPostRewrites","normalizedPath","doReplace","from","to","options","doReplaceHelper","doReplaceStrict","throws","webModalModule","startsWith","Error","some","FailedToResolveNativeOnlyModuleError","relative","normalName","shimFile","shouldCreateVirtualShim","virtualId","bundler","hasVirtualModule","fs","readFileSync","emptyModule","hmrModule","logBoxModule","logBoxParserModule","createFallbackModuleResolver","originModuleNames","metroConfigWithCustomContext","withMetroMutatedResolverContext","immutableContext","preferNativePlatform","sourceExts","unstable_enablePackageExports","unstable_conditionsByPlatform","isReactServerComponents","mainFields","unstable_conditionNames","withMetroErrorReportingResolver","withMetroSupervisingTransformWorker","resolutionError","cause","output","exp","platformBundlers","isAutolinkingResolverEnabled","watchFolders","unstable_onDemandFilesystem","length","metroDefaults","metroRequirePolyfill","moduleSystem","dirname","EXPO_PUBLIC_PROJECT_ROOT","expoConfigPlatforms","Object","entries","platforms","map","Array","isArray","Set","concat","createAutolinkingModuleResolverInput","keys","resolvedModulePaths","skipNodePath"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QA6IeA;eAAAA;;QAmtBAC;eAAAA;;QA9rBAC;eAAAA;;QA8sBMC;eAAAA;;;;yBAv2Bc;;;;;;;yBAER;;;;;;;gEACb;;;;;;;gEACE;;;;;;+CASV;4CACsC;sDACQ;2BACG;6BACe;qCACrB;iDACF;oCACoB;qDAChB;qBAChC;qBACA;8BACgB;0CAEK;;;;;;AAQzC,MAAMC,qBAAqB,CAAC,6FAA6F,CAAC;AAE1H,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,SAASC,WAAcC,KAAQ;IAC7B,OAAOA;AACT;AAEA,SAASC,iBACPC,MAAe,EACf,EACEC,eAAe,EAGhB;IAED,MAAMC,uBAAuBF,OAAOG,UAAU,CAACC,YAAY,GACvDJ,OAAOG,UAAU,CAACC,YAAY,CAACC,IAAI,CAACL,OAAOG,UAAU,IACrD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,kBACtC/J,MAAM,CACL,CAAC,CAACH,UAAUwI,QAAQ;YAA4ByB;eAAvBzB,YAAY,aAAWyB,iBAAAA,IAAIc,SAAS,qBAAbd,eAAe5J,QAAQ,CAACL;OAEzEgL,GAAG,CAAC,CAAC,CAAChL,SAAS,GAAKA;IAEvB,IAAIiL,MAAMC,OAAO,CAAC7L,OAAO0D,QAAQ,CAACgI,SAAS,GAAG;QAC5CH,sBAAsB;eAAI,IAAIO,IAAIP,oBAAoBQ,MAAM,CAAC/L,OAAO0D,QAAQ,CAACgI,SAAS;SAAG;IAC3F;IAEA7L,WAAWG,OAAO0D,QAAQ,EAAEgI,SAAS,GAAGH;IAExCvL,SAASD,iBAAiBC,QAAQ;QAAEC;IAAgB;IAEpD,IAAIiC;IACJ,IAAI4I,8BAA8B;QAChC5I,iCAAiC,MAAM8J,IAAAA,mEAAoC,EAAC;YAC1EN,WAAWH;YACX3I;QACF;IACF;IAEA,OAAOpD,qBAAqBQ,QAAQ;QAClCkC;QACAC;QACAC;QACAC;QACApC;IACF;AACF;AAEA,SAAS0C,oBACPC,WAAmB,EACnBV,8BAA0E;IAE1E,IAAIA,gCAAgC;YAGzBA;QAFT,yDAAyD;QACzD,MAAMvB,WAAW6K,OAAOS,IAAI,CAAC/J,+BAA+B,CAAC,EAAE;QAC/D,OAAO,CAAC,GAACA,2CAAAA,8BAA8B,CAACvB,SAAS,qBAAxCuB,yCAA0CgK,mBAAmB,CAAC,cAAc;IACvF,OAAO;QACL,OAAO,CAAC,CAACnJ,IAAAA,2BAAW,EAACH,aAAa,4BAA4B;YAC5DuJ,cAAc;QAChB;IACF;AACF"}
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 type { ExpoConfig, Platform } from '@expo/config';\nimport type Bundler from '@expo/metro/metro/Bundler';\nimport type { ConfigT } from '@expo/metro/metro-config';\nimport type {\n Resolution,\n ResolutionContext,\n CustomResolutionContext,\n} from '@expo/metro/metro-resolver';\nimport { resolve as resolver } from '@expo/metro/metro-resolver';\nimport type { SourceFileResolution } from '@expo/metro/metro-resolver/types';\nimport { resolveFrom } from '@expo/require-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport type {\n AutolinkingModuleResolverInput,\n AutolinkingPlatform,\n} from './createExpoAutolinkingResolver';\nimport {\n createAutolinkingModuleResolverInput,\n createAutolinkingModuleResolver,\n} from './createExpoAutolinkingResolver';\nimport { createFallbackModuleResolver } from './createExpoFallbackResolver';\nimport { FailedToResolveNativeOnlyModuleError } from './errors/FailedToResolveNativeOnlyModuleError';\nimport { isNodeExternal, shouldCreateVirtualShim } from './externals';\nimport { isFailedToResolveNameError, isFailedToResolvePathError } from './metroErrors';\nimport { getMetroBundlerWithVirtualModules } from './metroVirtualModules';\nimport { withMetroErrorReportingResolver } from './withMetroErrorReportingResolver';\nimport { withMetroMutatedResolverContext, withMetroResolvers } from './withMetroResolvers';\nimport { withMetroSupervisingTransformWorker } from './withMetroSupervisingTransformWorker';\nimport { Log } from '../../../log';\nimport { env } from '../../../utils/env';\nimport { isServerEnvironment } from '../middleware/metroOptions';\nimport type { PlatformBundlers } from '../platformBundlers';\nimport { createTypescriptResolver } from './createTypescriptResolver';\n\nexport type StrictResolver = (moduleName: string) => Resolution;\nexport type StrictResolverFactory = (\n context: ResolutionContext,\n platform: string | null\n) => StrictResolver;\n\nconst ASSET_REGISTRY_SRC = `const assets=[];module.exports={registerAsset:s=>assets.push(s),getAssetByID:s=>assets[s-1]};`;\n\nconst debug = require('debug')('expo:start:server:metro:multi-platform') as typeof console.log;\n\nfunction asWritable<T>(input: T): { -readonly [K in keyof T]: T[K] } {\n return input;\n}\n\nfunction withWebPolyfills(\n config: ConfigT,\n {\n getMetroBundler,\n }: {\n getMetroBundler: () => Bundler;\n }\n): 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 const virtualEnvVarId = `\\0polyfill:environment-variables`;\n\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualEnvVarId,\n (() => {\n return `//`;\n })()\n );\n\n const virtualModuleId = `\\0polyfill:external-require`;\n\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualModuleId,\n (() => {\n if (ctx.platform === 'web') {\n // NOTE(@hassankhan): We need to wrap require in an arrow function rather than assigning\n // it directly because `workerd` loses its `this` context when `require` is dereferenced\n // and called later.\n return `global.$$require_external = typeof require !== \"undefined\" ? (m) => require(m) : () => null;`;\n } else {\n // Wrap in try/catch to support Android.\n return 'try { global.$$require_external = typeof expo === \"undefined\" ? require : (moduleId) => { throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);} } catch { global.$$require_external = (moduleId) => { throw new Error(`Node.js standard library module ${moduleId} is not available in this JavaScript environment`);} }';\n }\n })()\n );\n\n const virtualModulesPolyfills = [virtualModuleId, virtualEnvVarId];\n\n if (ctx.platform === 'web') {\n try {\n const rnGetPolyfills: () => string[] = require('react-native/rn-get-polyfills');\n return [\n ...virtualModulesPolyfills,\n // Ensure that the error-guard polyfill is included in the web polyfills to\n // make metro-runtime work correctly.\n // TODO: This module is pretty big for a function that simply re-throws an error that doesn't need to be caught.\n // NOTE(@kitten): This is technically the public API to get polyfills rather than resolving directly into\n // `@react-native/js-polyfills`. We should really just start vendoring these, but for now, this exclusion works\n ...rnGetPolyfills().filter((x: string) => !x.includes('/console')),\n ];\n } catch (error: any) {\n if ('code' in error && error.code === 'MODULE_NOT_FOUND') {\n // If react-native is not installed, because we're targeting web, we still continue\n // This should be rare, but we add it so we don't unnecessarily have a fixed peer dependency on react-native\n debug(\n 'Skipping react-native/rn-get-polyfills from getPolyfills. react-native is not installed.'\n );\n return virtualModulesPolyfills;\n } else {\n throw error;\n }\n }\n }\n\n // Generally uses `@expo/metro-config`'s `getPolyfills` function, unless overridden\n const polyfills = originalGetPolyfills(ctx);\n return [\n ...polyfills,\n ...virtualModulesPolyfills,\n // Removed on server platforms during the transform.\n require.resolve('expo/virtual/streams.js'),\n ];\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 autolinkingModuleResolverInput,\n isTsconfigPathsEnabled,\n isExporting,\n isReactServerComponentsEnabled,\n getMetroBundler,\n }: {\n autolinkingModuleResolverInput?: AutolinkingModuleResolverInput;\n isTsconfigPathsEnabled?: boolean;\n isExporting?: boolean;\n isReactServerComponentsEnabled?: boolean;\n getMetroBundler: () => Bundler;\n }\n) {\n if (isReactServerComponentsEnabled) {\n Log.warn(`React Server Components (beta) is enabled.`);\n }\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 'react-native/Libraries/Image/resolveAssetSource': 'expo-asset/build/resolveAssetSource',\n },\n };\n\n const isExpoRouterInstalled = hasExpoRouterModule(\n config.projectRoot,\n autolinkingModuleResolverInput\n );\n\n let _universalAliases: [RegExp, string][] | null;\n\n function getUniversalAliases() {\n if (_universalAliases) {\n return _universalAliases;\n }\n\n _universalAliases = [];\n\n // This package is currently always installed as it is included in the `expo` package.\n if (resolveFrom(config.projectRoot, '@expo/vector-icons/package.json')) {\n debug('Enabling alias: react-native-vector-icons -> @expo/vector-icons');\n _universalAliases.push([/^react-native-vector-icons(\\/.*)?/, '@expo/vector-icons$1']);\n }\n if (isReactServerComponentsEnabled) {\n if (resolveFrom(config.projectRoot, 'expo-router/rsc')) {\n debug('Enabling bridge alias: expo-router -> expo-router/rsc');\n _universalAliases.push([/^expo-router$/, 'expo-router/rsc']);\n // Bridge the internal entry point which is a standalone import to ensure package.json resolution works as expected.\n _universalAliases.push([/^expo-router\\/entry-classic$/, 'expo-router/rsc/entry']);\n }\n }\n return _universalAliases;\n }\n\n // used to resolve externals in `requestCustomExternals` from the project root\n const projectRootOriginPath = path.join(config.projectRoot, 'package.json');\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 nodejsSourceExtensions: string[] | null = null;\n\n const getStrictResolver: StrictResolverFactory = (\n { resolveRequest, ...context },\n platform\n ): StrictResolver => {\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 // TODO: This is a hack to get resolveWeak working.\n const idFactory = (config.serializer?.createModuleIdFactory?.() ??\n ((id: number | string, context: { platform: string; environment?: string }): number | string =>\n id)) as (\n id: number | string,\n context: { platform: string; environment?: string }\n ) => number | string;\n\n // We're manually resolving the `asyncRequireModulePath` since it's a module request\n // However, in isolated installations it might not resolve from all paths, so we're resolving\n // it from the project root manually\n let _asyncRequireModuleResolvedPath: string | null | undefined;\n const getAsyncRequireModule = () => {\n if (_asyncRequireModuleResolvedPath === undefined) {\n _asyncRequireModuleResolvedPath =\n resolveFrom(config.projectRoot, config.transformer.asyncRequireModulePath) ?? null;\n }\n return _asyncRequireModuleResolvedPath\n ? ({ type: 'sourceFile', filePath: _asyncRequireModuleResolvedPath } as const)\n : null;\n };\n\n const getAssetRegistryModule = () => {\n const virtualModuleId = `\\0polyfill:assets-registry`;\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualModuleId,\n ASSET_REGISTRY_SRC\n );\n return {\n type: 'sourceFile',\n filePath: virtualModuleId,\n } as const;\n };\n\n // If Node.js pass-through, then remap to a module like `module.exports = $$require_external(<module>)`.\n // If module should be shimmed, remap to an empty module.\n const externals: {\n match: (context: ResolutionContext, moduleName: string, platform: string | null) => boolean;\n replace: 'empty' | 'node' | 'weak';\n }[] = [\n {\n match: (context: ResolutionContext, moduleName: string) => {\n if (\n // Disable internal externals when exporting for production.\n context.customResolverOptions.exporting ||\n // These externals are only for Node.js environments.\n !isServerEnvironment(context.customResolverOptions?.environment)\n ) {\n return false;\n }\n\n if (context.customResolverOptions?.environment === 'react-server') {\n // Ensure these non-react-server modules are excluded when bundling for React Server Components in development.\n return /^(@babel\\/runtime\\/.+|debug|metro-runtime\\/src\\/modules\\/HMRClient|metro|acorn-loose|acorn|chalk|ws|ansi-styles|supports-color|color-convert|has-flag|utf-8-validate|color-name|react-refresh\\/runtime|@remix-run\\/node\\/.+)$/.test(\n moduleName\n );\n }\n\n // TODO: Windows doesn't support externals somehow.\n if (process.platform === 'win32') {\n return false;\n }\n\n // Extern these modules in standard Node.js environments in development to prevent API routes side-effects\n // from leaking into the dev server process.\n return /^(react|@radix-ui\\/.+|@babel\\/runtime\\/.+|react-dom(\\/.+)?|debug|acorn-loose|acorn|css-in-js-utils\\/lib\\/.+|hyphenate-style-name|color|color-string|color-convert|color-name|fontfaceobserver|fast-deep-equal|query-string|escape-string-regexp|invariant|postcss-value-parser|memoize-one|nullthrows|strict-uri-encode|decode-uri-component|split-on-first|filter-obj|warn-once|simple-swizzle|is-arrayish|inline-style-prefixer\\/.+)$/.test(\n moduleName\n );\n },\n replace: 'node',\n },\n // Externals to speed up async split chunks by extern-ing common packages that appear in the root client chunk.\n {\n match: (context: ResolutionContext, moduleName: string, platform: string | null) => {\n if (\n // Disable internal externals when exporting for production.\n context.customResolverOptions.exporting ||\n // These externals are only for client environments.\n isServerEnvironment(context.customResolverOptions?.environment) ||\n // Only enable for client boundaries\n !context.customResolverOptions.clientboundary\n ) {\n return false;\n }\n\n // We don't support this in the resolver at the moment.\n if (moduleName.endsWith('/package.json')) {\n return false;\n }\n\n const isExternal = // Extern these modules in standard Node.js environments.\n /^(deprecated-react-native-prop-types|react|react\\/jsx-dev-runtime|scheduler|react-native|react-dom(\\/.+)?|metro-runtime(\\/.+)?)$/.test(\n moduleName\n ) ||\n // TODO: Add more\n /^@babel\\/runtime\\/helpers\\/(wrapNativeSuper)$/.test(moduleName);\n\n return isExternal;\n },\n replace: 'weak',\n },\n ];\n\n const skipMetroMainFieldOverride = env.EXPO_METRO_NO_MAIN_FIELD_OVERRIDE;\n const useExpoUnstableWebModule = env.EXPO_UNSTABLE_WEB_MODAL;\n const useExpoUnstableLogBox = env.EXPO_UNSTABLE_LOG_BOX;\n const disableReactNavigationCheck = env.EXPO_ROUTER_DISABLE_RN_NAVIGATION_CHECK;\n const disableNativeTabsMaterialSymbols = env.EXPO_ROUTER_DISABLE_NATIVE_TABS_MD;\n\n const metroConfigWithCustomResolver = withMetroResolvers(config, [\n // Mock out production react imports in development.\n function requestDevMockProdReact(\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n // This resolution is dev-only to prevent bundling the production React packages in development.\n if (!context.dev) return null;\n\n if (\n // Match react-native renderers.\n (platform !== 'web' &&\n context.originModulePath.match(/[\\\\/]node_modules[\\\\/]react-native[\\\\/]/) &&\n moduleName.match(/([\\\\/]ReactFabric|ReactNativeRenderer)-prod/)) ||\n // Match react production imports.\n (moduleName.match(/\\.production(\\.min)?\\.js$/) &&\n // Match if the import originated from a react package.\n context.originModulePath.match(/[\\\\/]node_modules[\\\\/](react[-\\\\/]|scheduler[\\\\/])/))\n ) {\n debug(`Skipping production module: ${moduleName}`);\n // /Users/path/to/expo/node_modules/react/index.js ./cjs/react.production.min.js\n // /Users/path/to/expo/node_modules/react/jsx-dev-runtime.js ./cjs/react-jsx-dev-runtime.production.min.js\n // /Users/path/to/expo/node_modules/react-is/index.js ./cjs/react-is.production.min.js\n // /Users/path/to/expo/node_modules/react-refresh/runtime.js ./cjs/react-refresh-runtime.production.min.js\n // /Users/path/to/expo/node_modules/react-native/node_modules/scheduler/index.native.js ./cjs/scheduler.native.production.min.js\n // /Users/path/to/expo/node_modules/react-native/node_modules/react-is/index.js ./cjs/react-is.production.min.js\n return {\n type: 'empty',\n };\n }\n return null;\n },\n\n isTsconfigPathsEnabled\n ? createTypescriptResolver({\n getStrictResolver,\n projectRoot: config.projectRoot,\n getMetroBundler,\n watch: !isExporting && !env.CI,\n })\n : undefined,\n\n // Node.js externals support\n function requestNodeExternals(\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n const isServer =\n context.customResolverOptions?.environment === 'node' ||\n context.customResolverOptions?.environment === 'react-server';\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 !isServer\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\n if (!result && platform !== 'web') {\n // Preserve previous behavior where native throws an error on node.js internals.\n return null;\n }\n\n return (\n result ?? {\n // In this case, mock the file to use an empty module.\n type: 'empty',\n }\n );\n }\n const contents = `module.exports=$$require_external('node:${moduleId}');`;\n debug(`Virtualizing Node.js \"${moduleId}\"`);\n const virtualModuleId = `\\0node:${moduleId}`;\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualModuleId,\n contents\n );\n return {\n type: 'sourceFile',\n filePath: virtualModuleId,\n };\n },\n\n // Custom externals support\n function requestCustomExternals(\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n // We don't support this in the resolver at the moment.\n if (moduleName.endsWith('/package.json')) {\n return null;\n }\n // Skip applying JS externals for CSS files.\n if (/\\.(s?css|sass)$/.test(context.originModulePath)) {\n return null;\n }\n\n for (const external of externals) {\n if (external.match(context, moduleName, platform)) {\n if (external.replace === 'empty') {\n debug(`Redirecting external \"${moduleName}\" to \"${external.replace}\"`);\n return {\n type: external.replace,\n };\n } else if (external.replace === 'weak') {\n // TODO: Make this use require.resolveWeak again. Previously this was just resolving to the same path.\n const realModule = getStrictResolver(context, platform)(moduleName);\n const realPath = realModule.type === 'sourceFile' ? realModule.filePath : moduleName;\n const opaqueId = idFactory(realPath, {\n platform: platform!,\n environment: context.customResolverOptions?.environment,\n });\n const contents =\n typeof opaqueId === 'number'\n ? `module.exports=/*${moduleName}*/__r(${opaqueId})`\n : `module.exports=/*${moduleName}*/__r(${JSON.stringify(opaqueId)})`;\n // const contents = `module.exports=/*${moduleName}*/__r(require.resolveWeak('${moduleName}'))`;\n // const generatedModuleId = fastHashMemoized(contents);\n const virtualModuleId = `\\0weak:${opaqueId}`;\n debug('Virtualizing module:', moduleName, '->', virtualModuleId);\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualModuleId,\n contents\n );\n return {\n type: 'sourceFile',\n filePath: virtualModuleId,\n };\n } else if (external.replace === 'node') {\n // TODO(@kitten): Temporary workaround. Our externals logic here isn't generic and only works\n // for development and not exports. We never intend to use it in exported production bundles,\n // however, this is still a dangerous implementation. To protect us from externalizing modules\n // that aren't available to the app, we force any resolution to happen via the project root\n const projectRootContext: ResolutionContext = {\n ...context,\n nodeModulesPaths: [],\n originModulePath: projectRootOriginPath,\n disableHierarchicalLookup: false,\n };\n const externModule = getStrictResolver(projectRootContext, platform)(moduleName);\n if (externModule.type !== 'sourceFile') {\n return null;\n }\n const contents = `module.exports=$$require_external('${moduleName}')`;\n const virtualModuleId = `\\0node:${moduleName}`;\n debug('Virtualizing Node.js (custom):', moduleName, '->', virtualModuleId);\n getMetroBundlerWithVirtualModules(getMetroBundler()).setVirtualModule(\n virtualModuleId,\n contents\n );\n return {\n type: 'sourceFile',\n filePath: virtualModuleId,\n };\n } else {\n external.replace satisfies never;\n }\n }\n }\n return null;\n },\n\n // Basic moduleId aliases\n function requestAlias(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 getUniversalAliases()) {\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 // Polyfill for asset registry (assetRegistryPath) and async require module (asyncRequireModulePath)\n function requestStableConfigModules(\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n if (moduleName === config.transformer.asyncRequireModulePath) {\n return getAsyncRequireModule();\n }\n\n // TODO(@kitten): Compare against `config.transformer.assetRegistryPath`\n if (/^@react-native\\/assets-registry\\/registry(\\.js)?$/.test(moduleName)) {\n return getAssetRegistryModule();\n }\n\n if (\n platform === 'web' &&\n context.originModulePath.match(/node_modules[\\\\/]react-native-web[\\\\/]/) &&\n moduleName.includes('/modules/AssetRegistry')\n ) {\n return getAssetRegistryModule();\n }\n\n return null;\n },\n\n createAutolinkingModuleResolver(autolinkingModuleResolverInput, {\n getStrictResolver,\n }),\n\n // TODO: Reduce these as much as possible in the future.\n // Complex post-resolution rewrites.\n function requestPostRewrites(\n context: ResolutionContext,\n moduleName: string,\n platform: string | null\n ) {\n const doResolve = getStrictResolver(context, platform);\n\n const result = doResolve(moduleName);\n\n if (result.type !== 'sourceFile') {\n return result;\n }\n\n const normalizedPath = normalizeSlashes(result.filePath);\n\n const doReplace = (from: string, to: string | undefined, options?: { throws?: boolean }) =>\n doReplaceHelper(from, to, {\n normalizedPath,\n doResolve,\n ...options,\n });\n const doReplaceStrict = (from: string, to: string | undefined) =>\n doReplace(from, to, { throws: true });\n\n if (useExpoUnstableWebModule) {\n const webModalModule = doReplace(\n 'expo-router/build/layouts/_web-modal.js',\n 'expo-router/build/layouts/ExperimentalModalStack.js'\n );\n if (webModalModule) {\n debug('Using `_unstable-web-modal` implementation.');\n return webModalModule;\n }\n }\n\n if (disableNativeTabsMaterialSymbols && platform === 'android') {\n const materialIconConverterModule = doReplace(\n 'expo-router/build/native-tabs/utils/materialIconConverter.android.js',\n 'expo-router/build/native-tabs/utils/materialIconConverter-not-implemented.js'\n );\n if (materialIconConverterModule) {\n debug(\n 'Disabling md support in NativeTabs to tree-shake `expo-symbols` from the Android bundle.'\n );\n return materialIconConverterModule;\n }\n }\n\n if (!disableReactNavigationCheck) {\n // TODO(@ubax): Remove this rewrite once we published migration guide for library authors\n if (isExpoRouterInstalled && moduleName.startsWith('@react-navigation/')) {\n const filePath = context.originModulePath;\n if (!filePath.includes('node_modules')) {\n if (\n moduleName === '@react-navigation/native-stack' ||\n moduleName === '@react-navigation/drawer'\n ) {\n throw new Error(\n [\n 'As of SDK 56, expo-router is no longer compatible with react-navigation.',\n '',\n `Instead of ${moduleName}, use Stack or Drawer from expo-router instead:`,\n '',\n \" import { Stack } from 'expo-router';\",\n \" import { Drawer } from 'expo-router/drawer';\",\n '',\n 'For more information, see https://docs.expo.dev/router/migrate/sdk-55-to-56/.',\n 'You can disable this check by setting the environment variable EXPO_ROUTER_DISABLE_RN_NAVIGATION_CHECK=1.',\n ].join('\\n')\n );\n }\n throw new Error(\n 'As of SDK 56, expo-router is no longer compatible with react-navigation. For more information, see https://docs.expo.dev/router/migrate/sdk-55-to-56/. You can disable this check by setting the environment variable EXPO_ROUTER_DISABLE_RN_NAVIGATION_CHECK=1.'\n );\n }\n if (moduleName === '@react-navigation/core') {\n // We already checked if expo-router resolves\n return doResolve('expo-router/react-navigation');\n }\n }\n }\n\n if (platform === 'web') {\n if (result.filePath.includes('node_modules')) {\n // Disallow importing confusing native modules on web\n if (\n [\n 'react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore',\n 'react-native/Libraries/Utilities/codegenNativeCommands',\n 'react-native/Libraries/Utilities/codegenNativeComponent',\n ].some((matcher) =>\n // Support absolute and modules with .js extensions.\n moduleName.includes(matcher)\n )\n ) {\n throw new FailedToResolveNativeOnlyModuleError(\n moduleName,\n path.relative(config.projectRoot, context.originModulePath)\n );\n }\n\n // Replace with static shims\n\n // Drop everything up until the `node_modules` folder.\n const normalName = normalizedPath.replace(/.*node_modules\\//, '');\n\n const shimFile = shouldCreateVirtualShim(normalName);\n if (shimFile) {\n const virtualId = `\\0shim:${normalName}`;\n const bundler = getMetroBundlerWithVirtualModules(getMetroBundler());\n if (!bundler.hasVirtualModule(virtualId)) {\n bundler.setVirtualModule(virtualId, fs.readFileSync(shimFile, 'utf8'));\n }\n debug(`Redirecting module \"${result.filePath}\" to shim`);\n\n return {\n ...result,\n filePath: virtualId,\n };\n }\n }\n } else {\n const isServer =\n context.customResolverOptions?.environment === 'node' ||\n context.customResolverOptions?.environment === 'react-server';\n\n // Shim out React Native native runtime globals in server mode for native.\n if (isServer) {\n const emptyModule = doReplace('react-native/Libraries/Core/InitializeCore.js', undefined);\n if (emptyModule) {\n debug('Shimming out InitializeCore for React Native in native SSR bundle');\n return emptyModule;\n }\n }\n\n const hmrModule = doReplaceStrict(\n 'react-native/Libraries/Utilities/HMRClient.js',\n 'expo/src/async-require/hmr.ts'\n );\n if (hmrModule) return hmrModule;\n\n if (useExpoUnstableLogBox) {\n const logBoxModule = doReplace(\n 'react-native/Libraries/LogBox/LogBoxInspectorContainer.js',\n '@expo/log-box/swap-rn-logbox.js'\n );\n if (logBoxModule) return logBoxModule;\n\n const logBoxParserModule = doReplace(\n 'react-native/Libraries/LogBox/Data/parseLogBoxLog.js',\n '@expo/log-box/swap-rn-logbox-parser.js'\n );\n if (logBoxParserModule) return logBoxParserModule;\n }\n }\n\n return result;\n },\n\n // If at this point, we haven't resolved a module yet, if it's a module specifier for a known dependency\n // of either `expo` or `expo-router`, attempt to resolve it from these origin modules instead\n createFallbackModuleResolver({\n projectRoot: config.projectRoot,\n originModuleNames: ['expo', 'expo-router'],\n getStrictResolver,\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 = asWritable({\n ...immutableContext,\n preferNativePlatform: platform !== 'web',\n });\n\n if (isServerEnvironment(context.customResolverOptions?.environment)) {\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_conditionsByPlatform = {};\n\n const isReactServerComponents =\n context.customResolverOptions?.environment === 'react-server';\n\n if (isReactServerComponents) {\n // NOTE: Align the behavior across server and client. This is a breaking change so we'll just roll it out with React Server Components.\n // This ensures that react-server and client code both resolve `module` and `main` in the same order.\n if (platform === 'web') {\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 = ['module', 'main'];\n } else {\n // In Node.js + native, use the standard main fields.\n context.mainFields = ['react-native', 'module', 'main'];\n }\n } else {\n if (platform === 'web') {\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 // In Node.js + native, use the standard main fields.\n context.mainFields = ['react-native', 'main', 'module'];\n }\n }\n\n // Enable react-server import conditions.\n if (context.customResolverOptions?.environment === 'react-server') {\n context.unstable_conditionNames = ['node', 'react-server', 'workerd'];\n } else {\n context.unstable_conditionNames = ['node'];\n }\n } else {\n // Non-server changes\n\n if (!skipMetroMainFieldOverride && platform && platform in preferredMainFields) {\n context.mainFields = preferredMainFields[platform]!;\n }\n }\n\n return context;\n }\n );\n\n return withMetroErrorReportingResolver(\n withMetroSupervisingTransformWorker(metroConfigWithCustomContext)\n );\n}\n\nfunction doReplaceHelper(\n from: string,\n to: string | undefined,\n {\n throws = false,\n normalizedPath,\n doResolve,\n }: {\n throws?: boolean;\n normalizedPath: string;\n doResolve: StrictResolver;\n }\n): SourceFileResolution | { type: 'empty' } | undefined {\n if (!normalizedPath.endsWith(from)) {\n return undefined;\n }\n\n if (to === undefined) {\n return {\n type: 'empty',\n };\n }\n\n try {\n const hmrModule = doResolve(to);\n if (hmrModule.type === 'sourceFile') {\n debug(`Using \\`${to}\\` implementation.`);\n return hmrModule;\n }\n } catch (resolutionError) {\n if (throws) {\n throw new Error(`Failed to replace ${from} with ${to}. Resolution of ${to} failed.`, {\n cause: resolutionError,\n });\n }\n\n debug(`Failed to resolve ${to} when swapping from ${from}: ${resolutionError}`);\n }\n return undefined;\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\n isTsconfigPathsEnabled,\n isAutolinkingResolverEnabled,\n isExporting,\n isReactServerComponentsEnabled,\n\n getMetroBundler,\n }: {\n config: ConfigT;\n exp: ExpoConfig;\n isTsconfigPathsEnabled: boolean;\n platformBundlers: PlatformBundlers;\n serverRoot?: string | undefined;\n\n isAutolinkingResolverEnabled?: boolean;\n isExporting?: boolean;\n isReactServerComponentsEnabled: boolean;\n isNamedRequiresEnabled: boolean;\n\n getMetroBundler: () => Bundler;\n }\n) {\n const watchFolders = (config.watchFolders as string[]) || [];\n asWritable(config).watchFolders = watchFolders;\n\n // NOTE(@kitten): If the on-demand filesystem is enabled, we can aggressively cut down the `watchFolders`\n // to a minimum, since the files will be read lazily. This almost always speeds up exports\n if (isExporting && !!config.resolver.unstable_onDemandFilesystem) {\n watchFolders.length = 0;\n watchFolders.push(projectRoot);\n }\n\n // Change the default metro-runtime to a custom one that supports bundle splitting.\n // NOTE(@kitten): This is now always active and EXPO_USE_METRO_REQUIRE / isNamedRequiresEnabled is disregarded\n const metroDefaults: typeof import('@expo/metro/metro-config/defaults/defaults') = require('@expo/metro/metro-config/defaults/defaults');\n const metroRequirePolyfill = require.resolve('@expo/cli/build/metro-require/require');\n asWritable(metroDefaults).moduleSystem = metroRequirePolyfill;\n watchFolders.push(path.dirname(metroRequirePolyfill));\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 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 asWritable(config.resolver).platforms = expoConfigPlatforms;\n\n config = withWebPolyfills(config, { getMetroBundler });\n\n let autolinkingModuleResolverInput: AutolinkingModuleResolverInput | undefined;\n if (isAutolinkingResolverEnabled) {\n autolinkingModuleResolverInput = await createAutolinkingModuleResolverInput({\n platforms: expoConfigPlatforms,\n projectRoot,\n });\n }\n\n return withExtendedResolver(config, {\n autolinkingModuleResolverInput,\n isTsconfigPathsEnabled,\n isExporting,\n isReactServerComponentsEnabled,\n getMetroBundler,\n });\n}\n\nfunction hasExpoRouterModule(\n projectRoot: string,\n autolinkingModuleResolverInput: AutolinkingModuleResolverInput | undefined\n) {\n if (autolinkingModuleResolverInput) {\n // If we have autolinking enabled, we can skip resolution\n const platform = Object.keys(autolinkingModuleResolverInput)[0] as AutolinkingPlatform;\n return !!autolinkingModuleResolverInput[platform]?.resolvedModulePaths['expo-router'];\n } else {\n return !!resolveFrom(projectRoot, 'expo-router/package.json', {\n skipNodePath: true,\n });\n }\n}\n"],"names":["getNodejsExtensions","shouldAliasModule","withExtendedResolver","withMetroMultiPlatformAsync","ASSET_REGISTRY_SRC","debug","require","asWritable","input","withWebPolyfills","config","getMetroBundler","originalGetPolyfills","serializer","getPolyfills","bind","ctx","virtualEnvVarId","getMetroBundlerWithVirtualModules","setVirtualModule","virtualModuleId","platform","virtualModulesPolyfills","rnGetPolyfills","filter","x","includes","error","code","polyfills","resolve","normalizeSlashes","p","replace","srcExts","mjsExts","ext","test","nodejsSourceExtensions","jsIndex","reduce","index","i","splice","autolinkingModuleResolverInput","isTsconfigPathsEnabled","isExporting","isReactServerComponentsEnabled","Log","warn","aliases","web","isExpoRouterInstalled","hasExpoRouterModule","projectRoot","_universalAliases","getUniversalAliases","resolveFrom","push","projectRootOriginPath","path","join","preferredMainFields","getStrictResolver","resolveRequest","context","doResolve","moduleName","resolver","getOptionalResolver","optionalResolve","isResolutionError","isFailedToResolveNameError","isFailedToResolvePathError","idFactory","createModuleIdFactory","id","_asyncRequireModuleResolvedPath","getAsyncRequireModule","undefined","transformer","asyncRequireModulePath","type","filePath","getAssetRegistryModule","externals","match","customResolverOptions","exporting","isServerEnvironment","environment","process","clientboundary","endsWith","isExternal","skipMetroMainFieldOverride","env","EXPO_METRO_NO_MAIN_FIELD_OVERRIDE","useExpoUnstableWebModule","EXPO_UNSTABLE_WEB_MODAL","useExpoUnstableLogBox","EXPO_UNSTABLE_LOG_BOX","disableReactNavigationCheck","EXPO_ROUTER_DISABLE_RN_NAVIGATION_CHECK","disableNativeTabsMaterialSymbols","EXPO_ROUTER_DISABLE_NATIVE_TABS_MD","metroConfigWithCustomResolver","withMetroResolvers","requestDevMockProdReact","dev","originModulePath","createTypescriptResolver","watch","CI","requestNodeExternals","isServer","moduleId","isNodeExternal","result","contents","requestCustomExternals","external","realModule","realPath","opaqueId","JSON","stringify","projectRootContext","nodeModulesPaths","disableHierarchicalLookup","externModule","requestAlias","redirectedModuleName","matcher","alias","aliasedModule","_","parseInt","requestStableConfigModules","createAutolinkingModuleResolver","requestPostRewrites","normalizedPath","doReplace","from","to","options","doReplaceHelper","doReplaceStrict","throws","webModalModule","materialIconConverterModule","startsWith","Error","some","FailedToResolveNativeOnlyModuleError","relative","normalName","shimFile","shouldCreateVirtualShim","virtualId","bundler","hasVirtualModule","fs","readFileSync","emptyModule","hmrModule","logBoxModule","logBoxParserModule","createFallbackModuleResolver","originModuleNames","metroConfigWithCustomContext","withMetroMutatedResolverContext","immutableContext","preferNativePlatform","sourceExts","unstable_enablePackageExports","unstable_conditionsByPlatform","isReactServerComponents","mainFields","unstable_conditionNames","withMetroErrorReportingResolver","withMetroSupervisingTransformWorker","resolutionError","cause","output","exp","platformBundlers","isAutolinkingResolverEnabled","watchFolders","unstable_onDemandFilesystem","length","metroDefaults","metroRequirePolyfill","moduleSystem","dirname","EXPO_PUBLIC_PROJECT_ROOT","expoConfigPlatforms","Object","entries","platforms","map","Array","isArray","Set","concat","createAutolinkingModuleResolverInput","keys","resolvedModulePaths","skipNodePath"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;QA6IeA;eAAAA;;QAiuBAC;eAAAA;;QA5sBAC;eAAAA;;QA4tBMC;eAAAA;;;;yBAr3Bc;;;;;;;yBAER;;;;;;;gEACb;;;;;;;gEACE;;;;;;+CASV;4CACsC;sDACQ;2BACG;6BACe;qCACrB;iDACF;oCACoB;qDAChB;qBAChC;qBACA;8BACgB;0CAEK;;;;;;AAQzC,MAAMC,qBAAqB,CAAC,6FAA6F,CAAC;AAE1H,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,SAASC,WAAcC,KAAQ;IAC7B,OAAOA;AACT;AAEA,SAASC,iBACPC,MAAe,EACf,EACEC,eAAe,EAGhB;IAED,MAAMC,uBAAuBF,OAAOG,UAAU,CAACC,YAAY,GACvDJ,OAAOG,UAAU,CAACC,YAAY,CAACC,IAAI,CAACL,OAAOG,UAAU,IACrD,IAAM,EAAE;IAEZ,MAAMC,eAAe,CAACE;QACpB,MAAMC,kBAAkB,CAAC,gCAAgC,CAAC;QAE1DC,IAAAA,sDAAiC,EAACP,mBAAmBQ,gBAAgB,CACnEF,iBACA,AAAC,CAAA;YACC,OAAO,CAAC,EAAE,CAAC;QACb,CAAA;QAGF,MAAMG,kBAAkB,CAAC,2BAA2B,CAAC;QAErDF,IAAAA,sDAAiC,EAACP,mBAAmBQ,gBAAgB,CACnEC,iBACA,AAAC,CAAA;YACC,IAAIJ,IAAIK,QAAQ,KAAK,OAAO;gBAC1B,wFAAwF;gBACxF,wFAAwF;gBACxF,oBAAoB;gBACpB,OAAO,CAAC,4FAA4F,CAAC;YACvG,OAAO;gBACL,wCAAwC;gBACxC,OAAO;YACT;QACF,CAAA;QAGF,MAAMC,0BAA0B;YAACF;YAAiBH;SAAgB;QAElE,IAAID,IAAIK,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0D,QAAQ,EAAEmI,SAAS,GAAGH;IAExC1L,SAASD,iBAAiBC,QAAQ;QAAEC;IAAgB;IAEpD,IAAIiC;IACJ,IAAI+I,8BAA8B;QAChC/I,iCAAiC,MAAMiK,IAAAA,mEAAoC,EAAC;YAC1EN,WAAWH;YACX9I;QACF;IACF;IAEA,OAAOpD,qBAAqBQ,QAAQ;QAClCkC;QACAC;QACAC;QACAC;QACApC;IACF;AACF;AAEA,SAAS0C,oBACPC,WAAmB,EACnBV,8BAA0E;IAE1E,IAAIA,gCAAgC;YAGzBA;QAFT,yDAAyD;QACzD,MAAMvB,WAAWgL,OAAOS,IAAI,CAAClK,+BAA+B,CAAC,EAAE;QAC/D,OAAO,CAAC,GAACA,2CAAAA,8BAA8B,CAACvB,SAAS,qBAAxCuB,yCAA0CmK,mBAAmB,CAAC,cAAc;IACvF,OAAO;QACL,OAAO,CAAC,CAACtJ,IAAAA,2BAAW,EAACH,aAAa,4BAA4B;YAC5D0J,cAAc;QAChB;IACF;AACF"}
@@ -59,6 +59,9 @@ function _interop_require_default(obj) {
59
59
  };
60
60
  }
61
61
  const debug = require('debug')('expo:start:server:middleware:interstitialPage');
62
+ function escapeHtml(value) {
63
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
64
+ }
62
65
  const LoadingEndpoint = '/_expo/loading';
63
66
  class InterstitialPageMiddleware extends _ExpoMiddleware.ExpoMiddleware {
64
67
  constructor(projectRoot, options = {
@@ -73,11 +76,11 @@ class InterstitialPageMiddleware extends _ExpoMiddleware.ExpoMiddleware {
73
76
  _resolvefrom().default.silent(this.projectRoot, 'expo/static/loading-page/index.html') ?? // Development: This will resolve when testing locally.
74
77
  _path().default.resolve(__dirname, '../../../../../static/loading-page/index.html');
75
78
  let content = (await (0, _promises().readFile)(templatePath)).toString('utf-8');
76
- content = content.replace(/{{\s*AppName\s*}}/, appName);
77
- content = content.replace(/{{\s*Path\s*}}/, this.projectRoot);
78
- content = content.replace(/{{\s*Scheme\s*}}/, this.options.scheme ?? 'Unknown');
79
+ content = content.replace(/{{\s*AppName\s*}}/, escapeHtml(appName));
80
+ content = content.replace(/{{\s*Path\s*}}/, escapeHtml(this.projectRoot));
81
+ content = content.replace(/{{\s*Scheme\s*}}/, escapeHtml(this.options.scheme ?? 'Unknown'));
79
82
  content = content.replace(/{{\s*ProjectVersionType\s*}}/, `${projectVersion.type === 'sdk' ? 'SDK' : 'Runtime'} version`);
80
- content = content.replace(/{{\s*ProjectVersion\s*}}/, projectVersion.version ?? 'Undetected');
83
+ content = content.replace(/{{\s*ProjectVersion\s*}}/, escapeHtml(projectVersion.version ?? 'Undetected'));
81
84
  return content;
82
85
  }
83
86
  /** Get settings for the page from the project config. */ async _getProjectOptionsAsync(platform) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/start/server/middleware/InterstitialPageMiddleware.ts"],"sourcesContent":["import { getConfig, getNameFromConfig } from '@expo/config';\nimport { getRuntimeVersionNullableAsync } from '@expo/config-plugins/build/utils/Updates';\nimport { readFile } from 'fs/promises';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { disableResponseCache, ExpoMiddleware } from './ExpoMiddleware';\nimport type { RuntimePlatform } from './resolvePlatform';\nimport {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n resolvePlatformFromUserAgentHeader,\n} from './resolvePlatform';\nimport type { ServerRequest, ServerResponse } from './server.types';\n\ntype ProjectVersion = {\n type: 'sdk' | 'runtime';\n version: string | null;\n};\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:interstitialPage'\n) as typeof console.log;\n\nexport const LoadingEndpoint = '/_expo/loading';\n\nexport class InterstitialPageMiddleware extends ExpoMiddleware {\n constructor(\n projectRoot: string,\n protected options: { scheme: string | null } = { scheme: null }\n ) {\n super(projectRoot, [LoadingEndpoint]);\n }\n\n /** Get the template HTML page and inject values. */\n async _getPageAsync({\n appName,\n projectVersion,\n }: {\n appName: string;\n projectVersion: ProjectVersion;\n }): Promise<string> {\n const templatePath =\n // Production: This will resolve when installed in the project.\n resolveFrom.silent(this.projectRoot, 'expo/static/loading-page/index.html') ??\n // Development: This will resolve when testing locally.\n path.resolve(__dirname, '../../../../../static/loading-page/index.html');\n let content = (await readFile(templatePath)).toString('utf-8');\n\n content = content.replace(/{{\\s*AppName\\s*}}/, appName);\n content = content.replace(/{{\\s*Path\\s*}}/, this.projectRoot);\n content = content.replace(/{{\\s*Scheme\\s*}}/, this.options.scheme ?? 'Unknown');\n content = content.replace(\n /{{\\s*ProjectVersionType\\s*}}/,\n `${projectVersion.type === 'sdk' ? 'SDK' : 'Runtime'} version`\n );\n content = content.replace(/{{\\s*ProjectVersion\\s*}}/, projectVersion.version ?? 'Undetected');\n\n return content;\n }\n\n /** Get settings for the page from the project config. */\n async _getProjectOptionsAsync(platform: RuntimePlatform): Promise<{\n appName: string;\n projectVersion: ProjectVersion;\n }> {\n assertRuntimePlatform(platform);\n\n const { exp } = getConfig(this.projectRoot);\n const { appName } = getNameFromConfig(exp);\n const runtimeVersion = await getRuntimeVersionNullableAsync(this.projectRoot, exp, platform);\n const sdkVersion = exp.sdkVersion ?? null;\n\n return {\n appName: appName ?? 'App',\n projectVersion:\n sdkVersion && !runtimeVersion\n ? { type: 'sdk', version: sdkVersion }\n : { type: 'runtime', version: runtimeVersion },\n };\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n res = disableResponseCache(res);\n res.setHeader('Content-Type', 'text/html');\n\n const platform = parsePlatformHeader(req) ?? resolvePlatformFromUserAgentHeader(req);\n assertMissingRuntimePlatform(platform);\n assertRuntimePlatform(platform);\n\n const { appName, projectVersion } = await this._getProjectOptionsAsync(platform);\n debug(\n `Create loading page. (platform: ${platform}, appName: ${appName}, projectVersion: ${projectVersion.version}, type: ${projectVersion.type})`\n );\n const content = await this._getPageAsync({ appName, projectVersion });\n res.end(content);\n }\n}\n"],"names":["InterstitialPageMiddleware","LoadingEndpoint","debug","require","ExpoMiddleware","projectRoot","options","scheme","_getPageAsync","appName","projectVersion","templatePath","resolveFrom","silent","path","resolve","__dirname","content","readFile","toString","replace","type","version","_getProjectOptionsAsync","platform","assertRuntimePlatform","exp","getConfig","getNameFromConfig","runtimeVersion","getRuntimeVersionNullableAsync","sdkVersion","handleRequestAsync","req","res","disableResponseCache","setHeader","parsePlatformHeader","resolvePlatformFromUserAgentHeader","assertMissingRuntimePlatform","end"],"mappings":";;;;;;;;;;;QA2BaA;eAAAA;;QAFAC;eAAAA;;;;yBAzBgC;;;;;;;yBACE;;;;;;;yBACtB;;;;;;;gEACR;;;;;;;gEACO;;;;;;gCAE6B;iCAO9C;;;;;;AAQP,MAAMC,QAAQC,QAAQ,SACpB;AAGK,MAAMF,kBAAkB;AAExB,MAAMD,mCAAmCI,8BAAc;IAC5D,YACEC,WAAmB,EACnB,AAAUC,UAAqC;QAAEC,QAAQ;IAAK,CAAC,CAC/D;QACA,KAAK,CAACF,aAAa;YAACJ;SAAgB,QAF1BK,UAAAA;IAGZ;IAEA,kDAAkD,GAClD,MAAME,cAAc,EAClBC,OAAO,EACPC,cAAc,EAIf,EAAmB;QAClB,MAAMC,eACJ,+DAA+D;QAC/DC,sBAAW,CAACC,MAAM,CAAC,IAAI,CAACR,WAAW,EAAE,0CACrC,uDAAuD;QACvDS,eAAI,CAACC,OAAO,CAACC,WAAW;QAC1B,IAAIC,UAAU,AAAC,CAAA,MAAMC,IAAAA,oBAAQ,EAACP,aAAY,EAAGQ,QAAQ,CAAC;QAEtDF,UAAUA,QAAQG,OAAO,CAAC,qBAAqBX;QAC/CQ,UAAUA,QAAQG,OAAO,CAAC,kBAAkB,IAAI,CAACf,WAAW;QAC5DY,UAAUA,QAAQG,OAAO,CAAC,oBAAoB,IAAI,CAACd,OAAO,CAACC,MAAM,IAAI;QACrEU,UAAUA,QAAQG,OAAO,CACvB,gCACA,GAAGV,eAAeW,IAAI,KAAK,QAAQ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src/start/server/middleware/InterstitialPageMiddleware.ts"],"sourcesContent":["import { getConfig, getNameFromConfig } from '@expo/config';\nimport { getRuntimeVersionNullableAsync } from '@expo/config-plugins/build/utils/Updates';\nimport { readFile } from 'fs/promises';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { disableResponseCache, ExpoMiddleware } from './ExpoMiddleware';\nimport type { RuntimePlatform } from './resolvePlatform';\nimport {\n assertMissingRuntimePlatform,\n assertRuntimePlatform,\n parsePlatformHeader,\n resolvePlatformFromUserAgentHeader,\n} from './resolvePlatform';\nimport type { ServerRequest, ServerResponse } from './server.types';\n\ntype ProjectVersion = {\n type: 'sdk' | 'runtime';\n version: string | null;\n};\n\nconst debug = require('debug')(\n 'expo:start:server:middleware:interstitialPage'\n) as typeof console.log;\n\nfunction escapeHtml(value: string): string {\n return value\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;');\n}\n\nexport const LoadingEndpoint = '/_expo/loading';\n\nexport class InterstitialPageMiddleware extends ExpoMiddleware {\n constructor(\n projectRoot: string,\n protected options: { scheme: string | null } = { scheme: null }\n ) {\n super(projectRoot, [LoadingEndpoint]);\n }\n\n /** Get the template HTML page and inject values. */\n async _getPageAsync({\n appName,\n projectVersion,\n }: {\n appName: string;\n projectVersion: ProjectVersion;\n }): Promise<string> {\n const templatePath =\n // Production: This will resolve when installed in the project.\n resolveFrom.silent(this.projectRoot, 'expo/static/loading-page/index.html') ??\n // Development: This will resolve when testing locally.\n path.resolve(__dirname, '../../../../../static/loading-page/index.html');\n let content = (await readFile(templatePath)).toString('utf-8');\n\n content = content.replace(/{{\\s*AppName\\s*}}/, escapeHtml(appName));\n content = content.replace(/{{\\s*Path\\s*}}/, escapeHtml(this.projectRoot));\n content = content.replace(/{{\\s*Scheme\\s*}}/, escapeHtml(this.options.scheme ?? 'Unknown'));\n content = content.replace(\n /{{\\s*ProjectVersionType\\s*}}/,\n `${projectVersion.type === 'sdk' ? 'SDK' : 'Runtime'} version`\n );\n content = content.replace(\n /{{\\s*ProjectVersion\\s*}}/,\n escapeHtml(projectVersion.version ?? 'Undetected')\n );\n\n return content;\n }\n\n /** Get settings for the page from the project config. */\n async _getProjectOptionsAsync(platform: RuntimePlatform): Promise<{\n appName: string;\n projectVersion: ProjectVersion;\n }> {\n assertRuntimePlatform(platform);\n\n const { exp } = getConfig(this.projectRoot);\n const { appName } = getNameFromConfig(exp);\n const runtimeVersion = await getRuntimeVersionNullableAsync(this.projectRoot, exp, platform);\n const sdkVersion = exp.sdkVersion ?? null;\n\n return {\n appName: appName ?? 'App',\n projectVersion:\n sdkVersion && !runtimeVersion\n ? { type: 'sdk', version: sdkVersion }\n : { type: 'runtime', version: runtimeVersion },\n };\n }\n\n async handleRequestAsync(req: ServerRequest, res: ServerResponse): Promise<void> {\n res = disableResponseCache(res);\n res.setHeader('Content-Type', 'text/html');\n\n const platform = parsePlatformHeader(req) ?? resolvePlatformFromUserAgentHeader(req);\n assertMissingRuntimePlatform(platform);\n assertRuntimePlatform(platform);\n\n const { appName, projectVersion } = await this._getProjectOptionsAsync(platform);\n debug(\n `Create loading page. (platform: ${platform}, appName: ${appName}, projectVersion: ${projectVersion.version}, type: ${projectVersion.type})`\n );\n const content = await this._getPageAsync({ appName, projectVersion });\n res.end(content);\n }\n}\n"],"names":["InterstitialPageMiddleware","LoadingEndpoint","debug","require","escapeHtml","value","replace","ExpoMiddleware","projectRoot","options","scheme","_getPageAsync","appName","projectVersion","templatePath","resolveFrom","silent","path","resolve","__dirname","content","readFile","toString","type","version","_getProjectOptionsAsync","platform","assertRuntimePlatform","exp","getConfig","getNameFromConfig","runtimeVersion","getRuntimeVersionNullableAsync","sdkVersion","handleRequestAsync","req","res","disableResponseCache","setHeader","parsePlatformHeader","resolvePlatformFromUserAgentHeader","assertMissingRuntimePlatform","end"],"mappings":";;;;;;;;;;;QAoCaA;eAAAA;;QAFAC;eAAAA;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C,IAAAA,sCAAqB,EAACD;QAEtB,MAAM,EAAEE,GAAG,EAAE,GAAGC,IAAAA,mBAAS,EAAC,IAAI,CAACrB,WAAW;QAC1C,MAAM,EAAEI,OAAO,EAAE,GAAGkB,IAAAA,2BAAiB,EAACF;QACtC,MAAMG,iBAAiB,MAAMC,IAAAA,yCAA8B,EAAC,IAAI,CAACxB,WAAW,EAAEoB,KAAKF;QACnF,MAAMO,aAAaL,IAAIK,UAAU,IAAI;QAErC,OAAO;YACLrB,SAASA,WAAW;YACpBC,gBACEoB,cAAc,CAACF,iBACX;gBAAER,MAAM;gBAAOC,SAASS;YAAW,IACnC;gBAAEV,MAAM;gBAAWC,SAASO;YAAe;QACnD;IACF;IAEA,MAAMG,mBAAmBC,GAAkB,EAAEC,GAAmB,EAAiB;QAC/EA,MAAMC,IAAAA,oCAAoB,EAACD;QAC3BA,IAAIE,SAAS,CAAC,gBAAgB;QAE9B,MAAMZ,WAAWa,IAAAA,oCAAmB,EAACJ,QAAQK,IAAAA,mDAAkC,EAACL;QAChFM,IAAAA,6CAA4B,EAACf;QAC7BC,IAAAA,sCAAqB,EAACD;QAEtB,MAAM,EAAEd,OAAO,EAAEC,cAAc,EAAE,GAAG,MAAM,IAAI,CAACY,uBAAuB,CAACC;QACvExB,MACE,CAAC,gCAAgC,EAAEwB,SAAS,WAAW,EAAEd,QAAQ,kBAAkB,EAAEC,eAAeW,OAAO,CAAC,QAAQ,EAAEX,eAAeU,IAAI,CAAC,CAAC,CAAC;QAE9I,MAAMH,UAAU,MAAM,IAAI,CAACT,aAAa,CAAC;YAAEC;YAASC;QAAe;QACnEuB,IAAIM,GAAG,CAACtB;IACV;AACF"}
@@ -15,20 +15,6 @@ function _chalk() {
15
15
  };
16
16
  return data;
17
17
  }
18
- function _net() {
19
- const data = /*#__PURE__*/ _interop_require_default(require("net"));
20
- _net = function() {
21
- return data;
22
- };
23
- return data;
24
- }
25
- function _tls() {
26
- const data = require("tls");
27
- _tls = function() {
28
- return data;
29
- };
30
- return data;
31
- }
32
18
  function _url() {
33
19
  const data = require("url");
34
20
  _url = function() {
@@ -37,20 +23,26 @@ function _url() {
37
23
  return data;
38
24
  }
39
25
  const _JsInspector = require("./JsInspector");
26
+ const _net = require("../../../../utils/net");
40
27
  function _interop_require_default(obj) {
41
28
  return obj && obj.__esModule ? obj : {
42
29
  default: obj
43
30
  };
44
31
  }
45
- function createJsInspectorMiddleware() {
32
+ function createJsInspectorMiddleware({ serverBaseUrl }) {
46
33
  return async function(req, res, next) {
47
- const { origin, searchParams } = new (_url()).URL(req.url ?? '/', getServerBase(req));
34
+ if (!(0, _net.isMatchingOrigin)(req, serverBaseUrl)) {
35
+ res.writeHead(403).end();
36
+ return;
37
+ }
38
+ // `req.url` may be absolute-form (HTTP/1.1) — only take search params from it.
39
+ const { searchParams } = new (_url()).URL(req.url ?? '/', serverBaseUrl);
48
40
  const appId = searchParams.get('appId') || searchParams.get('applicationId');
49
41
  if (!appId) {
50
42
  res.writeHead(400).end('Missing application identifier ("?appId=...")');
51
43
  return;
52
44
  }
53
- const app = await (0, _JsInspector.queryInspectorAppAsync)(origin, appId);
45
+ const app = await (0, _JsInspector.queryInspectorAppAsync)(serverBaseUrl, appId);
54
46
  if (!app) {
55
47
  res.writeHead(404).end('Unable to find inspector target from @react-native/dev-middleware');
56
48
  console.warn(_chalk().default.yellow('No compatible apps connected. JavaScript Debugging can only be used with the Hermes engine.'));
@@ -65,8 +57,12 @@ function createJsInspectorMiddleware() {
65
57
  });
66
58
  res.end(data);
67
59
  } else if (req.method === 'POST' || req.method === 'PUT') {
60
+ if ((0, _net.shouldThrottleRemoteDevCall)()) {
61
+ res.writeHead(429).end();
62
+ return;
63
+ }
68
64
  try {
69
- await (0, _JsInspector.openJsInspector)(origin, app);
65
+ await (0, _JsInspector.openJsInspector)(serverBaseUrl, app);
70
66
  } catch (error) {
71
67
  // abort(Error: Command failed: osascript -e POSIX path of (path to application "google chrome")
72
68
  // 15:50: execution error: Google Chrome got an error: Application isn’t running. (-600)
@@ -81,11 +77,5 @@ function createJsInspectorMiddleware() {
81
77
  }
82
78
  };
83
79
  }
84
- function getServerBase(req) {
85
- const scheme = req.socket instanceof _tls().TLSSocket && req.socket.encrypted === true ? 'https' : 'http';
86
- const { localAddress, localPort } = req.socket;
87
- const address = localAddress && _net().default.isIPv6(localAddress) ? `[${localAddress}]` : localAddress;
88
- return `${scheme}:${address}:${localPort}`;
89
- }
90
80
 
91
81
  //# sourceMappingURL=createJsInspectorMiddleware.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/createJsInspectorMiddleware.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { NextHandleFunction } from 'connect';\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport net from 'net';\nimport { TLSSocket } from 'tls';\nimport { URL } from 'url';\n\nimport { openJsInspector, queryInspectorAppAsync } from './JsInspector';\n\n/**\n * Create a middleware that handles new requests to open the debugger from the dev menu.\n * @todo(cedric): delete this middleware once we fully swap over to the new React Native JS Inspector.\n */\nexport function createJsInspectorMiddleware(): NextHandleFunction {\n return async function (req: IncomingMessage, res: ServerResponse, next: (err?: Error) => void) {\n const { origin, searchParams } = new URL(req.url ?? '/', getServerBase(req));\n const appId = searchParams.get('appId') || searchParams.get('applicationId');\n if (!appId) {\n res.writeHead(400).end('Missing application identifier (\"?appId=...\")');\n return;\n }\n\n const app = await queryInspectorAppAsync(origin, appId);\n if (!app) {\n res.writeHead(404).end('Unable to find inspector target from @react-native/dev-middleware');\n console.warn(\n chalk.yellow(\n 'No compatible apps connected. JavaScript Debugging can only be used with the Hermes engine.'\n )\n );\n return;\n }\n\n if (req.method === 'GET') {\n const data = JSON.stringify(app);\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=UTF-8',\n 'Cache-Control': 'no-cache',\n 'Content-Length': data.length.toString(),\n });\n res.end(data);\n } else if (req.method === 'POST' || req.method === 'PUT') {\n try {\n await openJsInspector(origin, app);\n } catch (error: any) {\n // abort(Error: Command failed: osascript -e POSIX path of (path to application \"google chrome\")\n // 15:50: execution error: Google Chrome got an error: Application isn’t running. (-600)\n\n console.error(\n chalk.red('Error launching JS inspector: ' + (error?.message ?? 'Unknown error occurred'))\n );\n res.writeHead(500);\n res.end();\n return;\n }\n res.end();\n } else {\n res.writeHead(405);\n }\n };\n}\n\nfunction getServerBase(req: IncomingMessage): string {\n const scheme =\n req.socket instanceof TLSSocket && req.socket.encrypted === true ? 'https' : 'http';\n const { localAddress, localPort } = req.socket;\n const address = localAddress && net.isIPv6(localAddress) ? `[${localAddress}]` : localAddress;\n return `${scheme}:${address}:${localPort}`;\n}\n"],"names":["createJsInspectorMiddleware","req","res","next","origin","searchParams","URL","url","getServerBase","appId","get","writeHead","end","app","queryInspectorAppAsync","console","warn","chalk","yellow","method","data","JSON","stringify","length","toString","openJsInspector","error","red","message","scheme","socket","TLSSocket","encrypted","localAddress","localPort","address","net","isIPv6"],"mappings":";;;;+BAagBA;;;eAAAA;;;;gEAbE;;;;;;;gEAGF;;;;;;;yBACU;;;;;;;yBACN;;;;;;6BAEoC;;;;;;AAMjD,SAASA;IACd,OAAO,eAAgBC,GAAoB,EAAEC,GAAmB,EAAEC,IAA2B;QAC3F,MAAM,EAAEC,MAAM,EAAEC,YAAY,EAAE,GAAG,IAAIC,CAAAA,MAAE,KAAC,CAACL,IAAIM,GAAG,IAAI,KAAKC,cAAcP;QACvE,MAAMQ,QAAQJ,aAAaK,GAAG,CAAC,YAAYL,aAAaK,GAAG,CAAC;QAC5D,IAAI,CAACD,OAAO;YACVP,IAAIS,SAAS,CAAC,KAAKC,GAAG,CAAC;YACvB;QACF;QAEA,MAAMC,MAAM,MAAMC,IAAAA,mCAAsB,EAACV,QAAQK;QACjD,IAAI,CAACI,KAAK;YACRX,IAAIS,SAAS,CAAC,KAAKC,GAAG,CAAC;YACvBG,QAAQC,IAAI,CACVC,gBAAK,CAACC,MAAM,CACV;YAGJ;QACF;QAEA,IAAIjB,IAAIkB,MAAM,KAAK,OAAO;YACxB,MAAMC,OAAOC,KAAKC,SAAS,CAACT;YAC5BX,IAAIS,SAAS,CAAC,KAAK;gBACjB,gBAAgB;gBAChB,iBAAiB;gBACjB,kBAAkBS,KAAKG,MAAM,CAACC,QAAQ;YACxC;YACAtB,IAAIU,GAAG,CAACQ;QACV,OAAO,IAAInB,IAAIkB,MAAM,KAAK,UAAUlB,IAAIkB,MAAM,KAAK,OAAO;YACxD,IAAI;gBACF,MAAMM,IAAAA,4BAAe,EAACrB,QAAQS;YAChC,EAAE,OAAOa,OAAY;gBACnB,gGAAgG;gBAChG,wFAAwF;gBAExFX,QAAQW,KAAK,CACXT,gBAAK,CAACU,GAAG,CAAC,mCAAoCD,CAAAA,CAAAA,yBAAAA,MAAOE,OAAO,KAAI,wBAAuB;gBAEzF1B,IAAIS,SAAS,CAAC;gBACdT,IAAIU,GAAG;gBACP;YACF;YACAV,IAAIU,GAAG;QACT,OAAO;YACLV,IAAIS,SAAS,CAAC;QAChB;IACF;AACF;AAEA,SAASH,cAAcP,GAAoB;IACzC,MAAM4B,SACJ5B,IAAI6B,MAAM,YAAYC,gBAAS,IAAI9B,IAAI6B,MAAM,CAACE,SAAS,KAAK,OAAO,UAAU;IAC/E,MAAM,EAAEC,YAAY,EAAEC,SAAS,EAAE,GAAGjC,IAAI6B,MAAM;IAC9C,MAAMK,UAAUF,gBAAgBG,cAAG,CAACC,MAAM,CAACJ,gBAAgB,CAAC,CAAC,EAAEA,aAAa,CAAC,CAAC,GAAGA;IACjF,OAAO,GAAGJ,OAAO,CAAC,EAAEM,QAAQ,CAAC,EAAED,WAAW;AAC5C"}
1
+ {"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/createJsInspectorMiddleware.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { NextHandleFunction } from 'connect';\nimport type { IncomingMessage, ServerResponse } from 'http';\nimport { URL } from 'url';\n\nimport { openJsInspector, queryInspectorAppAsync } from './JsInspector';\nimport { isMatchingOrigin, shouldThrottleRemoteDevCall } from '../../../../utils/net';\n\ninterface JsInspectorMiddlewareOptions {\n serverBaseUrl: string;\n}\n\n/**\n * Create a middleware that handles new requests to open the debugger from the dev menu.\n * @todo(cedric): delete this middleware once we fully swap over to the new React Native JS Inspector.\n */\nexport function createJsInspectorMiddleware({\n serverBaseUrl,\n}: JsInspectorMiddlewareOptions): NextHandleFunction {\n return async function (req: IncomingMessage, res: ServerResponse, next: (err?: Error) => void) {\n if (!isMatchingOrigin(req, serverBaseUrl)) {\n res.writeHead(403).end();\n return;\n }\n\n // `req.url` may be absolute-form (HTTP/1.1) — only take search params from it.\n const { searchParams } = new URL(req.url ?? '/', serverBaseUrl);\n const appId = searchParams.get('appId') || searchParams.get('applicationId');\n if (!appId) {\n res.writeHead(400).end('Missing application identifier (\"?appId=...\")');\n return;\n }\n\n const app = await queryInspectorAppAsync(serverBaseUrl, appId);\n if (!app) {\n res.writeHead(404).end('Unable to find inspector target from @react-native/dev-middleware');\n console.warn(\n chalk.yellow(\n 'No compatible apps connected. JavaScript Debugging can only be used with the Hermes engine.'\n )\n );\n return;\n }\n\n if (req.method === 'GET') {\n const data = JSON.stringify(app);\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=UTF-8',\n 'Cache-Control': 'no-cache',\n 'Content-Length': data.length.toString(),\n });\n res.end(data);\n } else if (req.method === 'POST' || req.method === 'PUT') {\n if (shouldThrottleRemoteDevCall()) {\n res.writeHead(429).end();\n return;\n }\n try {\n await openJsInspector(serverBaseUrl, app);\n } catch (error: any) {\n // abort(Error: Command failed: osascript -e POSIX path of (path to application \"google chrome\")\n // 15:50: execution error: Google Chrome got an error: Application isn’t running. (-600)\n\n console.error(\n chalk.red('Error launching JS inspector: ' + (error?.message ?? 'Unknown error occurred'))\n );\n res.writeHead(500);\n res.end();\n return;\n }\n res.end();\n } else {\n res.writeHead(405);\n }\n };\n}\n"],"names":["createJsInspectorMiddleware","serverBaseUrl","req","res","next","isMatchingOrigin","writeHead","end","searchParams","URL","url","appId","get","app","queryInspectorAppAsync","console","warn","chalk","yellow","method","data","JSON","stringify","length","toString","shouldThrottleRemoteDevCall","openJsInspector","error","red","message"],"mappings":";;;;+BAgBgBA;;;eAAAA;;;;gEAhBE;;;;;;;yBAGE;;;;;;6BAEoC;qBACM;;;;;;AAUvD,SAASA,4BAA4B,EAC1CC,aAAa,EACgB;IAC7B,OAAO,eAAgBC,GAAoB,EAAEC,GAAmB,EAAEC,IAA2B;QAC3F,IAAI,CAACC,IAAAA,qBAAgB,EAACH,KAAKD,gBAAgB;YACzCE,IAAIG,SAAS,CAAC,KAAKC,GAAG;YACtB;QACF;QAEA,+EAA+E;QAC/E,MAAM,EAAEC,YAAY,EAAE,GAAG,IAAIC,CAAAA,MAAE,KAAC,CAACP,IAAIQ,GAAG,IAAI,KAAKT;QACjD,MAAMU,QAAQH,aAAaI,GAAG,CAAC,YAAYJ,aAAaI,GAAG,CAAC;QAC5D,IAAI,CAACD,OAAO;YACVR,IAAIG,SAAS,CAAC,KAAKC,GAAG,CAAC;YACvB;QACF;QAEA,MAAMM,MAAM,MAAMC,IAAAA,mCAAsB,EAACb,eAAeU;QACxD,IAAI,CAACE,KAAK;YACRV,IAAIG,SAAS,CAAC,KAAKC,GAAG,CAAC;YACvBQ,QAAQC,IAAI,CACVC,gBAAK,CAACC,MAAM,CACV;YAGJ;QACF;QAEA,IAAIhB,IAAIiB,MAAM,KAAK,OAAO;YACxB,MAAMC,OAAOC,KAAKC,SAAS,CAACT;YAC5BV,IAAIG,SAAS,CAAC,KAAK;gBACjB,gBAAgB;gBAChB,iBAAiB;gBACjB,kBAAkBc,KAAKG,MAAM,CAACC,QAAQ;YACxC;YACArB,IAAII,GAAG,CAACa;QACV,OAAO,IAAIlB,IAAIiB,MAAM,KAAK,UAAUjB,IAAIiB,MAAM,KAAK,OAAO;YACxD,IAAIM,IAAAA,gCAA2B,KAAI;gBACjCtB,IAAIG,SAAS,CAAC,KAAKC,GAAG;gBACtB;YACF;YACA,IAAI;gBACF,MAAMmB,IAAAA,4BAAe,EAACzB,eAAeY;YACvC,EAAE,OAAOc,OAAY;gBACnB,gGAAgG;gBAChG,wFAAwF;gBAExFZ,QAAQY,KAAK,CACXV,gBAAK,CAACW,GAAG,CAAC,mCAAoCD,CAAAA,CAAAA,yBAAAA,MAAOE,OAAO,KAAI,wBAAuB;gBAEzF1B,IAAIG,SAAS,CAAC;gBACdH,IAAII,GAAG;gBACP;YACF;YACAJ,IAAII,GAAG;QACT,OAAO;YACLJ,IAAIG,SAAS,CAAC;QAChB;IACF;AACF"}
@@ -118,8 +118,14 @@ const DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME = 'development-code-signing-se
118
118
  function getDevelopmentCodeSigningDirectory() {
119
119
  return _path().default.join((0, _UserSettings.getExpoHomeDirectory)(), 'codesigning');
120
120
  }
121
+ function assertBasenameValue(input) {
122
+ if (!input || input === '.' || input === '..' || input !== _path().default.basename(input)) {
123
+ throw new _errors.CommandError('Invalid EAS project ID for development code signing cache');
124
+ }
125
+ }
121
126
  function getProjectDevelopmentCodeSigningInfoFile(defaults) {
122
127
  function getFile(easProjectId) {
128
+ assertBasenameValue(easProjectId);
123
129
  const filePath = _path().default.join(getDevelopmentCodeSigningDirectory(), easProjectId, DEVELOPMENT_CODE_SIGNING_SETTINGS_FILE_NAME);
124
130
  return new (_jsonfile()).default(filePath);
125
131
  }