@expo/cli 1.0.0-canary-20250722-599a28f → 54.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/metro-require/require.js +24 -13
  3. package/build/src/api/getExpoSchema.js +8 -7
  4. package/build/src/api/getExpoSchema.js.map +1 -1
  5. package/build/src/expoUpdatesExports.js +28 -0
  6. package/build/src/expoUpdatesExports.js.map +1 -0
  7. package/build/src/export/embed/exportEmbedAsync.js +26 -25
  8. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  9. package/build/src/export/embed/resolveOptions.js +1 -1
  10. package/build/src/export/embed/resolveOptions.js.map +1 -1
  11. package/build/src/export/exportApp.js +7 -4
  12. package/build/src/export/exportApp.js.map +1 -1
  13. package/build/src/export/exportAssets.js +20 -4
  14. package/build/src/export/exportAssets.js.map +1 -1
  15. package/build/src/export/exportAsync.js +2 -2
  16. package/build/src/export/exportAsync.js.map +1 -1
  17. package/build/src/export/exportHermes.js +34 -9
  18. package/build/src/export/exportHermes.js.map +1 -1
  19. package/build/src/export/exportStaticAsync.js +23 -2
  20. package/build/src/export/exportStaticAsync.js.map +1 -1
  21. package/build/src/export/index.js +1 -0
  22. package/build/src/export/index.js.map +1 -1
  23. package/build/src/export/metroAssetLocalPath.js.map +1 -1
  24. package/build/src/export/persistMetroAssets.js.map +1 -1
  25. package/build/src/export/resolveOptions.js +1 -0
  26. package/build/src/export/resolveOptions.js.map +1 -1
  27. package/build/src/export/saveAssets.js +12 -0
  28. package/build/src/export/saveAssets.js.map +1 -1
  29. package/build/src/install/checkPackages.js +9 -1
  30. package/build/src/install/checkPackages.js.map +1 -1
  31. package/build/src/lint/lintAsync.js +2 -0
  32. package/build/src/lint/lintAsync.js.map +1 -1
  33. package/build/src/prebuild/prebuildAsync.js +18 -0
  34. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  35. package/build/src/prebuild/resolveLocalTemplate.js +42 -0
  36. package/build/src/prebuild/resolveLocalTemplate.js.map +1 -0
  37. package/build/src/prebuild/resolveTemplate.js +17 -7
  38. package/build/src/prebuild/resolveTemplate.js.map +1 -1
  39. package/build/src/prebuild/updateFromTemplate.js +1 -0
  40. package/build/src/prebuild/updateFromTemplate.js.map +1 -1
  41. package/build/src/prebuild/updatePackageJson.js +5 -3
  42. package/build/src/prebuild/updatePackageJson.js.map +1 -1
  43. package/build/src/run/android/resolveOptions.js +2 -2
  44. package/build/src/run/android/resolveOptions.js.map +1 -1
  45. package/build/src/run/ios/options/resolveOptions.js +2 -2
  46. package/build/src/run/ios/options/resolveOptions.js.map +1 -1
  47. package/build/src/run/ios/runIosAsync.js +3 -0
  48. package/build/src/run/ios/runIosAsync.js.map +1 -1
  49. package/build/src/serve/serveAsync.js +5 -2
  50. package/build/src/serve/serveAsync.js.map +1 -1
  51. package/build/src/start/platforms/ExpoGoInstaller.js +1 -1
  52. package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
  53. package/build/src/start/server/DevToolsPluginManager.js +7 -35
  54. package/build/src/start/server/DevToolsPluginManager.js.map +1 -1
  55. package/build/src/start/server/metro/MetroBundlerDevServer.js +88 -56
  56. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  57. package/build/src/start/server/metro/MetroTerminalReporter.js +66 -25
  58. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  59. package/build/src/start/server/metro/TerminalReporter.js +6 -6
  60. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  61. package/build/src/start/server/metro/createExpoAutolinkingResolver.js +121 -0
  62. package/build/src/start/server/metro/createExpoAutolinkingResolver.js.map +1 -0
  63. package/build/src/start/server/metro/createExpoFallbackResolver.js +1 -0
  64. package/build/src/start/server/metro/createExpoFallbackResolver.js.map +1 -1
  65. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
  66. package/build/src/start/server/metro/createJResolver.js.map +1 -1
  67. package/build/src/start/server/metro/createServerComponentsMiddleware.js +4 -4
  68. package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
  69. package/build/src/start/server/metro/createServerRouteMiddleware.js +54 -8
  70. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  71. package/build/src/start/server/metro/debugging/attachAtlas.js +2 -0
  72. package/build/src/start/server/metro/debugging/attachAtlas.js.map +1 -1
  73. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +1 -1
  74. package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
  75. package/build/src/start/server/metro/fetchRouterManifest.js +1 -0
  76. package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
  77. package/build/src/start/server/metro/formatFileCandidates.js.map +1 -1
  78. package/build/src/start/server/metro/getCssModulesFromBundler.js +10 -9
  79. package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
  80. package/build/src/start/server/metro/instantiateMetro.js +44 -40
  81. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  82. package/build/src/start/server/metro/metroErrorInterface.js +79 -12
  83. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  84. package/build/src/start/server/metro/metroVirtualModules.js.map +1 -1
  85. package/build/src/start/server/metro/metroWatchTypeScriptFiles.js.map +1 -1
  86. package/build/src/start/server/metro/router.js +75 -0
  87. package/build/src/start/server/metro/router.js.map +1 -1
  88. package/build/src/start/server/metro/runServer-fork.js +19 -19
  89. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  90. package/build/src/start/server/metro/serializeHtml.js +45 -5
  91. package/build/src/start/server/metro/serializeHtml.js.map +1 -1
  92. package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
  93. package/build/src/start/server/metro/withMetroErrorReportingResolver.js +267 -0
  94. package/build/src/start/server/metro/withMetroErrorReportingResolver.js.map +1 -0
  95. package/build/src/start/server/metro/withMetroMultiPlatform.js +58 -82
  96. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  97. package/build/src/start/server/metro/withMetroResolvers.js +2 -219
  98. package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
  99. package/build/src/start/server/metro/withMetroSupervisingTransformWorker.js +63 -0
  100. package/build/src/start/server/metro/withMetroSupervisingTransformWorker.js.map +1 -0
  101. package/build/src/start/server/middleware/createBuiltinAPIRequestHandler.js +1 -1
  102. package/build/src/start/server/middleware/createBuiltinAPIRequestHandler.js.map +1 -1
  103. package/build/src/start/server/middleware/metroOptions.js +7 -2
  104. package/build/src/start/server/middleware/metroOptions.js.map +1 -1
  105. package/build/src/start/server/middleware/resolvePlatform.js +3 -0
  106. package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
  107. package/build/src/start/server/serverLogLikeMetro.js +13 -11
  108. package/build/src/start/server/serverLogLikeMetro.js.map +1 -1
  109. package/build/src/start/server/type-generation/routes.js.map +1 -1
  110. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
  111. package/build/src/types.d.ts +2 -0
  112. package/build/src/utils/build-cache-providers/index.js.map +1 -1
  113. package/build/src/utils/dir.js +7 -0
  114. package/build/src/utils/dir.js.map +1 -1
  115. package/build/src/utils/env.js +9 -4
  116. package/build/src/utils/env.js.map +1 -1
  117. package/build/src/utils/errors.js +1 -1
  118. package/build/src/utils/errors.js.map +1 -1
  119. package/build/src/utils/git.js +2 -2
  120. package/build/src/utils/git.js.map +1 -1
  121. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  122. package/build/src/utils/telemetry/utils/context.js +1 -1
  123. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -1
  124. package/internal/unstable-expo-updates-exports.d.ts +31 -0
  125. package/internal/unstable-expo-updates-exports.js +3 -0
  126. package/package.json +33 -17
  127. package/static/template/[...rsc]+api.ts +1 -1
  128. package/build/src/start/server/metro/createExpoStickyResolver.js +0 -137
  129. package/build/src/start/server/metro/createExpoStickyResolver.js.map +0 -1
  130. package/build/src/start/server/metro/metroPrivateServer.js +0 -28
  131. package/build/src/start/server/metro/metroPrivateServer.js.map +0 -1
  132. package/build/src/utils/jsonSchemaDeref.js +0 -150
  133. package/build/src/utils/jsonSchemaDeref.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportStaticAsync.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport { RouteNode } from 'expo-router/build/Route';\nimport { stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport { shouldLinkExternally } from 'expo-router/build/utils/url';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { Log } from '../log';\nimport {\n ExpoRouterRuntimeManifest,\n MetroBundlerDevServer,\n} from '../start/server/metro/MetroBundlerDevServer';\nimport { ExpoRouterServerManifestV1 } from '../start/server/metro/fetchRouterManifest';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getApiRoutesForDirectory } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = {\n mode: 'production' | 'development';\n files?: ExportAssetMap;\n outputDir: string;\n minify: boolean;\n exportServer: boolean;\n baseUrl: string;\n includeSourceMaps: boolean;\n entryPoint?: string;\n clear: boolean;\n routerRoot: string;\n reactCompiler: boolean;\n maxWorkers?: number;\n isExporting: boolean;\n exp?: ExpoConfig;\n};\n\ntype HtmlRequestLocation = {\n /** The output file path name to use relative to the static folder. */\n filePath: string;\n /** The pathname to make requests to in order to fetch the HTML. */\n pathname: string;\n /** The runtime route node object, used to associate async modules with the static HTML. */\n route: RouteNode;\n};\n\n/** Match `(page)` -> `page` */\nfunction matchGroupName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport async function getFilesToExportFromServerAsync(\n projectRoot: string,\n {\n manifest,\n renderAsync,\n // Servers can handle group routes automatically and therefore\n // don't require the build-time generation of every possible group\n // variation.\n exportServer,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations: !exportServer }).map(\n async ({ route, filePath, pathname }) => {\n try {\n const targetDomain = exportServer ? 'server' : 'client';\n files.set(filePath, { contents: '', targetDomain });\n const data = await renderAsync({ route, filePath, pathname });\n files.set(filePath, {\n contents: data,\n routeId: pathname,\n targetDomain,\n });\n } catch (e: any) {\n await logMetroErrorAsync({ error: e, projectRoot });\n throw new Error('Failed to statically export route: ' + pathname);\n }\n }\n )\n );\n\n return files;\n}\n\nfunction modifyRouteNodeInRuntimeManifest(\n manifest: ExpoRouterRuntimeManifest,\n callback: (route: RouteNode) => any\n) {\n const iterateScreens = (screens: ExpoRouterRuntimeManifest['screens']) => {\n Object.values(screens).map((value) => {\n if (typeof value !== 'string') {\n if (value._route) callback(value._route);\n iterateScreens(value.screens);\n }\n });\n };\n\n iterateScreens(manifest.screens);\n}\n\n// TODO: Do this earlier in the process.\nfunction makeRuntimeEntryPointsAbsolute(manifest: ExpoRouterRuntimeManifest, appDir: string) {\n modifyRouteNodeInRuntimeManifest(manifest, (route) => {\n if (Array.isArray(route.entryPoints)) {\n route.entryPoints = route.entryPoints.map((entryPoint) => {\n // TODO(@hassankhan): ENG-16577\n if (shouldLinkExternally(entryPoint)) {\n return entryPoint;\n }\n\n if (entryPoint.startsWith('.')) {\n return path.resolve(appDir, entryPoint);\n } else if (!path.isAbsolute(entryPoint)) {\n return resolveFrom(appDir, entryPoint);\n }\n return entryPoint;\n });\n }\n });\n}\n\n/** Perform all fs commits */\nexport async function exportFromServerAsync(\n projectRoot: string,\n devServer: MetroBundlerDevServer,\n {\n outputDir,\n baseUrl,\n exportServer,\n includeSourceMaps,\n routerRoot,\n files = new Map(),\n exp,\n }: Options\n): Promise<ExportAssetMap> {\n Log.log(\n `Static rendering is enabled. ` +\n learnMore('https://docs.expo.dev/router/reference/static-rendering/')\n );\n\n const platform = 'web';\n const isExporting = true;\n const appDir = path.join(projectRoot, routerRoot);\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n exp,\n });\n\n const [resources, { manifest, serverManifest, renderAsync }] = await Promise.all([\n devServer.getStaticResourcesAsync({\n includeSourceMaps,\n }),\n devServer.getStaticRenderFunctionAsync(),\n ]);\n\n makeRuntimeEntryPointsAbsolute(manifest, appDir);\n\n debug('Routes:\\n', inspect(manifest, { colors: true, depth: null }));\n\n await getFilesToExportFromServerAsync(projectRoot, {\n files,\n manifest,\n exportServer,\n async renderAsync({ pathname, route }) {\n const template = await renderAsync(pathname);\n let html = await serializeHtmlWithAssets({\n isExporting,\n resources: resources.artifacts,\n template,\n baseUrl,\n route,\n hydrate: true,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n platform,\n includeSourceMaps,\n files,\n isServerHosted: true,\n });\n\n if (resources.assets) {\n // TODO: Collect files without writing to disk.\n // NOTE(kitten): Re. above, this is now using `files` except for iOS catalog output, which isn't used here\n await persistMetroAssetsAsync(projectRoot, resources.assets, {\n files,\n platform,\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n if (exportServer) {\n const apiRoutes = await exportApiRoutesAsync({\n platform: 'web',\n server: devServer,\n manifest: serverManifest,\n // NOTE(kitten): For now, we always output source maps for API route exports\n includeSourceMaps: true,\n });\n\n // Add the api routes to the files to export.\n for (const [route, contents] of apiRoutes) {\n files.set(route, contents);\n }\n } else {\n warnPossibleInvalidExportType(appDir);\n }\n\n return files;\n}\n\nexport function getHtmlFiles({\n manifest,\n includeGroupVariations,\n}: {\n manifest: ExpoRouterRuntimeManifest;\n includeGroupVariations?: boolean;\n}): HtmlRequestLocation[] {\n const htmlFiles = new Set<Omit<HtmlRequestLocation, 'pathname'>>();\n\n function traverseScreens(\n screens: ExpoRouterRuntimeManifest['screens'],\n route: RouteNode | null,\n baseUrl = ''\n ) {\n for (const [key, value] of Object.entries(screens)) {\n let leaf: string | null = null;\n if (typeof value === 'string') {\n leaf = value;\n } else if (Object.keys(value.screens).length === 0) {\n // Ensure the trailing index is accounted for.\n if (key === value.path + '/index') {\n leaf = key;\n } else {\n leaf = value.path;\n }\n\n route = value._route ?? null;\n }\n\n if (leaf != null) {\n let filePath = baseUrl + leaf;\n\n if (leaf === '') {\n filePath =\n baseUrl === ''\n ? 'index'\n : baseUrl.endsWith('/')\n ? baseUrl + 'index'\n : baseUrl.slice(0, -1);\n } else if (\n // If the path is a collection of group segments leading to an index route, append `/index`.\n stripGroupSegmentsFromPath(filePath) === ''\n ) {\n filePath += '/index';\n }\n\n // This should never happen, the type of `string | object` originally comes from React Navigation.\n if (!route) {\n throw new Error(\n `Internal error: Route not found for \"${filePath}\" while collecting static export paths.`\n );\n }\n\n if (includeGroupVariations) {\n // TODO: Dedupe requests for alias routes.\n addOptionalGroups(filePath, route);\n } else {\n htmlFiles.add({\n filePath,\n route,\n });\n }\n } else if (typeof value === 'object' && value?.screens) {\n // The __root slot has no path.\n const newPath = value.path ? baseUrl + value.path + '/' : baseUrl;\n traverseScreens(value.screens, value._route ?? null, newPath);\n }\n }\n }\n\n function addOptionalGroups(path: string, route: RouteNode) {\n const variations = getPathVariations(path);\n for (const variation of variations) {\n htmlFiles.add({ filePath: variation, route });\n }\n }\n\n traverseScreens(manifest.screens, null);\n\n return uniqueBy(Array.from(htmlFiles), (value) => value.filePath).map((value) => {\n const parts = value.filePath.split('/');\n // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`\n const partsWithGroups = parts.map((part) => {\n if (part === '*not-found') {\n return `+not-found`;\n } else if (part.startsWith(':')) {\n return `[${part.slice(1)}]`;\n } else if (part.startsWith('*')) {\n return `[...${part.slice(1)}]`;\n }\n return part;\n });\n const filePathLocation = partsWithGroups.join('/');\n const filePath = filePathLocation + '.html';\n return {\n ...value,\n filePath,\n pathname: filePathLocation.replace(/(\\/?index)?$/, ''),\n };\n });\n}\n\nfunction uniqueBy<T>(array: T[], key: (value: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const value of array) {\n const id = key(value);\n if (!seen.has(id)) {\n seen.add(id);\n result.push(value);\n }\n }\n return result;\n}\n\n// Given a route like `(foo)/bar/(baz)`, return all possible variations of the route.\n// e.g. `(foo)/bar/(baz)`, `(foo)/bar/baz`, `foo/bar/(baz)`, `foo/bar/baz`,\nexport function getPathVariations(routePath: string): string[] {\n const variations = new Set<string>();\n const segments = routePath.split('/');\n\n function generateVariations(segments: string[], current = ''): void {\n if (segments.length === 0) {\n if (current) variations.add(current);\n return;\n }\n\n const [head, ...rest] = segments;\n\n if (matchGroupName(head)) {\n const groups = head.slice(1, -1).split(',');\n\n if (groups.length > 1) {\n for (const group of groups) {\n // If there are multiple groups, recurse on each group.\n generateVariations([`(${group.trim()})`, ...rest], current);\n }\n return;\n } else {\n // Start a fork where this group is included\n generateVariations(rest, current ? `${current}/(${groups[0]})` : `(${groups[0]})`);\n // This code will continue and add paths without this group included`\n }\n } else if (current) {\n current = `${current}/${head}`;\n } else {\n current = head;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\nexport async function exportApiRoutesStandaloneAsync(\n devServer: MetroBundlerDevServer,\n {\n files = new Map(),\n platform,\n apiRoutesOnly,\n templateHtml,\n }: {\n files?: ExportAssetMap;\n platform: string;\n apiRoutesOnly: boolean;\n templateHtml?: string;\n }\n) {\n const { serverManifest, htmlManifest } = await devServer.getServerManifestAsync();\n\n const apiRoutes = await exportApiRoutesAsync({\n server: devServer,\n manifest: serverManifest,\n // NOTE(kitten): For now, we always output source maps for API route exports\n includeSourceMaps: true,\n platform,\n apiRoutesOnly,\n });\n\n // Add the api routes to the files to export.\n for (const [route, contents] of apiRoutes) {\n files.set(route, contents);\n }\n\n if (templateHtml && devServer.isReactServerComponentsEnabled) {\n // TODO: Export an HTML entry for each file. This is a temporary solution until we have SSR/SSG for RSC.\n await getFilesToExportFromServerAsync(devServer.projectRoot, {\n manifest: htmlManifest,\n exportServer: true,\n files,\n renderAsync: async ({ pathname, filePath }) => {\n files.set(filePath, {\n contents: templateHtml!,\n routeId: pathname,\n targetDomain: 'server',\n });\n return templateHtml!;\n },\n });\n }\n\n return files;\n}\n\nasync function exportApiRoutesAsync({\n includeSourceMaps,\n server,\n platform,\n apiRoutesOnly,\n ...props\n}: Pick<Options, 'includeSourceMaps'> & {\n server: MetroBundlerDevServer;\n manifest: ExpoRouterServerManifestV1;\n platform: string;\n apiRoutesOnly?: boolean;\n}): Promise<ExportAssetMap> {\n const { manifest, files } = await server.exportExpoRouterApiRoutesAsync({\n outputDir: '_expo/functions',\n prerenderManifest: props.manifest,\n includeSourceMaps,\n platform,\n });\n\n // HACK: Clear out the HTML and 404 routes if we're only exporting API routes. This is used for native apps that are using API routes but haven't implemented web support yet.\n if (apiRoutesOnly) {\n manifest.htmlRoutes = [];\n manifest.notFoundRoutes = [];\n }\n\n files.set('_expo/routes.json', {\n contents: JSON.stringify(manifest, null, 2),\n targetDomain: 'server',\n });\n\n return files;\n}\n\nfunction warnPossibleInvalidExportType(appDir: string) {\n const apiRoutes = getApiRoutesForDirectory(appDir);\n if (apiRoutes.length) {\n // TODO: Allow API Routes for native-only.\n Log.warn(\n chalk.yellow`Skipping export for API routes because \\`web.output\\` is not \"server\". You may want to remove the routes: ${apiRoutes\n .map((v) => path.relative(appDir, v))\n .join(', ')}`\n );\n }\n}\n"],"names":["exportApiRoutesStandaloneAsync","exportFromServerAsync","getFilesToExportFromServerAsync","getHtmlFiles","getPathVariations","debug","require","matchGroupName","name","match","projectRoot","manifest","renderAsync","exportServer","files","Map","Promise","all","includeGroupVariations","map","route","filePath","pathname","targetDomain","set","contents","data","routeId","e","logMetroErrorAsync","error","Error","modifyRouteNodeInRuntimeManifest","callback","iterateScreens","screens","Object","values","value","_route","makeRuntimeEntryPointsAbsolute","appDir","Array","isArray","entryPoints","entryPoint","shouldLinkExternally","startsWith","path","resolve","isAbsolute","resolveFrom","devServer","outputDir","baseUrl","includeSourceMaps","routerRoot","exp","Log","log","learnMore","platform","isExporting","join","injectFaviconTag","getVirtualFaviconAssetsAsync","resources","serverManifest","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","serializeHtmlWithAssets","artifacts","hydrate","getFilesFromSerialAssets","isServerHosted","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","key","entries","leaf","keys","length","endsWith","slice","stripGroupSegmentsFromPath","addOptionalGroups","add","newPath","variations","variation","uniqueBy","from","parts","split","partsWithGroups","part","filePathLocation","replace","array","seen","result","id","has","push","routePath","segments","generateVariations","current","head","rest","groups","group","trim","apiRoutesOnly","templateHtml","htmlManifest","getServerManifestAsync","isReactServerComponentsEnabled","props","exportExpoRouterApiRoutesAsync","prerenderManifest","htmlRoutes","notFoundRoutes","JSON","stringify","getApiRoutesForDirectory","warn","chalk","yellow","v","relative"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAyYqBA,8BAA8B;eAA9BA;;IAjQAC,qBAAqB;eAArBA;;IA/EAC,+BAA+B;eAA/BA;;IAmLNC,YAAY;eAAZA;;IAqHAC,iBAAiB;eAAjBA;;;;gEA/VE;;;;;;;yBAEyB;;;;;;;yBACN;;;;;;;gEACpB;;;;;;;gEACO;;;;;;;yBACA;;;;;;yBAEqB;oCACL;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,gBAAgB3E,UAAU8E,8BAA8B,EAAE;QAC5D,wGAAwG;QACxG,MAAMhI,gCAAgCkD,UAAU1C,WAAW,EAAE;YAC3DC,UAAUqH;YACVnH,cAAc;YACdC;YACAF,aAAa,OAAO,EAAEU,QAAQ,EAAED,QAAQ,EAAE;gBACxCP,MAAMU,GAAG,CAACH,UAAU;oBAClBI,UAAUsG;oBACVpG,SAASL;oBACTC,cAAc;gBAChB;gBACA,OAAOwG;YACT;QACF;IACF;IAEA,OAAOjH;AACT;AAEA,eAAesE,qBAAqB,EAClC7B,iBAAiB,EACjB8B,MAAM,EACNxB,QAAQ,EACRiE,aAAa,EACb,GAAGK,OAMJ;IACC,MAAM,EAAExH,QAAQ,EAAEG,KAAK,EAAE,GAAG,MAAMuE,OAAO+C,8BAA8B,CAAC;QACtE/E,WAAW;QACXgF,mBAAmBF,MAAMxH,QAAQ;QACjC4C;QACAM;IACF;IAEA,8KAA8K;IAC9K,IAAIiE,eAAe;QACjBnH,SAAS2H,UAAU,GAAG,EAAE;QACxB3H,SAAS4H,cAAc,GAAG,EAAE;IAC9B;IAEAzH,MAAMU,GAAG,CAAC,qBAAqB;QAC7BC,UAAU+G,KAAKC,SAAS,CAAC9H,UAAU,MAAM;QACzCY,cAAc;IAChB;IAEA,OAAOT;AACT;AAEA,SAASwE,8BAA8B7C,MAAc;IACnD,MAAM0C,YAAYuD,IAAAA,gCAAwB,EAACjG;IAC3C,IAAI0C,UAAUW,MAAM,EAAE;QACpB,0CAA0C;QAC1CpC,QAAG,CAACiF,IAAI,CACNC,gBAAK,CAACC,MAAM,CAAC,0GAA0G,EAAE1D,UACtHhE,GAAG,CAAC,CAAC2H,IAAM9F,eAAI,CAAC+F,QAAQ,CAACtG,QAAQqG,IACjC/E,IAAI,CAAC,MAAM,CAAC;IAEnB;AACF"}
1
+ {"version":3,"sources":["../../../src/export/exportStaticAsync.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport { RouteNode } from 'expo-router/build/Route';\nimport { stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport { shouldLinkExternally } from 'expo-router/build/utils/url';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { Log } from '../log';\nimport {\n ExpoRouterRuntimeManifest,\n MetroBundlerDevServer,\n} from '../start/server/metro/MetroBundlerDevServer';\nimport { ExpoRouterServerManifestV1 } from '../start/server/metro/fetchRouterManifest';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getApiRoutesForDirectory, getMiddlewareForDirectory } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype ExtraScriptTag = {\n platform: string;\n src: string;\n};\n\ntype Options = {\n mode: 'production' | 'development';\n files?: ExportAssetMap;\n outputDir: string;\n minify: boolean;\n exportServer: boolean;\n baseUrl: string;\n includeSourceMaps: boolean;\n entryPoint?: string;\n clear: boolean;\n routerRoot: string;\n reactCompiler: boolean;\n maxWorkers?: number;\n isExporting: boolean;\n exp?: ExpoConfig;\n // <script type=\"type/expo\" data-platform=\"ios\" src=\"...\" />\n scriptTags?: ExtraScriptTag[];\n};\n\ntype HtmlRequestLocation = {\n /** The output file path name to use relative to the static folder. */\n filePath: string;\n /** The pathname to make requests to in order to fetch the HTML. */\n pathname: string;\n /** The runtime route node object, used to associate async modules with the static HTML. */\n route: RouteNode;\n};\n\nexport function injectScriptTags(html: string, scriptTags: ExtraScriptTag[]): string {\n const scriptTagsHtml = scriptTags\n .map((tag) =>\n tag.platform === 'web'\n ? `<script src=\"${tag.src}\"></script>`\n : `<script type=\"type/expo\" src=\"${tag.src}\" data-platform=\"${tag.platform}\"></script>`\n )\n .join('\\n');\n html = html.replace('</head>', `${scriptTagsHtml}\\n</head>`);\n return html;\n}\n\n/** Match `(page)` -> `page` */\nfunction matchGroupName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport async function getFilesToExportFromServerAsync(\n projectRoot: string,\n {\n manifest,\n renderAsync,\n // Servers can handle group routes automatically and therefore\n // don't require the build-time generation of every possible group\n // variation.\n exportServer,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations: !exportServer }).map(\n async ({ route, filePath, pathname }) => {\n // Rewrite routes should not be statically generated\n if (route.type === 'rewrite') {\n return;\n }\n\n try {\n const targetDomain = exportServer ? 'server' : 'client';\n files.set(filePath, { contents: '', targetDomain });\n const data = await renderAsync({ route, filePath, pathname });\n files.set(filePath, {\n contents: data,\n routeId: pathname,\n targetDomain,\n });\n } catch (e: any) {\n await logMetroErrorAsync({ error: e, projectRoot });\n throw new Error('Failed to statically export route: ' + pathname);\n }\n }\n )\n );\n\n return files;\n}\n\nfunction modifyRouteNodeInRuntimeManifest(\n manifest: ExpoRouterRuntimeManifest,\n callback: (route: RouteNode) => any\n) {\n const iterateScreens = (screens: ExpoRouterRuntimeManifest['screens']) => {\n Object.values(screens).map((value) => {\n if (typeof value !== 'string') {\n if (value._route) callback(value._route);\n iterateScreens(value.screens);\n }\n });\n };\n\n iterateScreens(manifest.screens);\n}\n\n// TODO: Do this earlier in the process.\nfunction makeRuntimeEntryPointsAbsolute(manifest: ExpoRouterRuntimeManifest, appDir: string) {\n modifyRouteNodeInRuntimeManifest(manifest, (route) => {\n if (Array.isArray(route.entryPoints)) {\n route.entryPoints = route.entryPoints.map((entryPoint) => {\n // TODO(@hassankhan): ENG-16577\n if (shouldLinkExternally(entryPoint)) {\n return entryPoint;\n }\n\n if (entryPoint.startsWith('.')) {\n return path.resolve(appDir, entryPoint);\n } else if (!path.isAbsolute(entryPoint)) {\n return resolveFrom(appDir, entryPoint);\n }\n return entryPoint;\n });\n }\n });\n}\n\n/** Perform all fs commits */\nexport async function exportFromServerAsync(\n projectRoot: string,\n devServer: MetroBundlerDevServer,\n {\n outputDir,\n baseUrl,\n exportServer,\n includeSourceMaps,\n routerRoot,\n files = new Map(),\n exp,\n scriptTags,\n }: Options\n): Promise<ExportAssetMap> {\n Log.log(\n `Static rendering is enabled. ` +\n learnMore('https://docs.expo.dev/router/reference/static-rendering/')\n );\n\n const platform = 'web';\n const isExporting = true;\n const appDir = path.join(projectRoot, routerRoot);\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n exp,\n });\n\n const [resources, { manifest, serverManifest, renderAsync }] = await Promise.all([\n devServer.getStaticResourcesAsync({\n includeSourceMaps,\n }),\n devServer.getStaticRenderFunctionAsync(),\n ]);\n\n makeRuntimeEntryPointsAbsolute(manifest, appDir);\n\n debug('Routes:\\n', inspect(manifest, { colors: true, depth: null }));\n\n await getFilesToExportFromServerAsync(projectRoot, {\n files,\n manifest,\n exportServer,\n async renderAsync({ pathname, route }) {\n const template = await renderAsync(pathname);\n let html = await serializeHtmlWithAssets({\n isExporting,\n resources: resources.artifacts,\n template,\n baseUrl,\n route,\n hydrate: true,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n if (scriptTags) {\n // Inject script tags into the HTML.\n // <script type=\"type/expo\" data-platform=\"ios\" src=\"...\" />\n html = injectScriptTags(html, scriptTags);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n platform,\n includeSourceMaps,\n files,\n isServerHosted: true,\n });\n\n if (resources.assets) {\n // TODO: Collect files without writing to disk.\n // NOTE(kitten): Re. above, this is now using `files` except for iOS catalog output, which isn't used here\n await persistMetroAssetsAsync(projectRoot, resources.assets, {\n files,\n platform,\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n if (exportServer) {\n const apiRoutes = await exportApiRoutesAsync({\n platform: 'web',\n server: devServer,\n manifest: serverManifest,\n // NOTE(kitten): For now, we always output source maps for API route exports\n includeSourceMaps: true,\n });\n\n // Add the api routes to the files to export.\n for (const [route, contents] of apiRoutes) {\n files.set(route, contents);\n }\n } else {\n warnPossibleInvalidExportType(appDir);\n }\n\n return files;\n}\n\nexport function getHtmlFiles({\n manifest,\n includeGroupVariations,\n}: {\n manifest: ExpoRouterRuntimeManifest;\n includeGroupVariations?: boolean;\n}): HtmlRequestLocation[] {\n const htmlFiles = new Set<Omit<HtmlRequestLocation, 'pathname'>>();\n\n function traverseScreens(\n screens: ExpoRouterRuntimeManifest['screens'],\n route: RouteNode | null,\n baseUrl = ''\n ) {\n for (const [key, value] of Object.entries(screens)) {\n let leaf: string | null = null;\n if (typeof value === 'string') {\n leaf = value;\n } else if (value.screens && Object.keys(value.screens).length === 0) {\n // Ensure the trailing index is accounted for.\n if (key === value.path + '/index') {\n leaf = key;\n } else {\n leaf = value.path;\n }\n\n route = value._route ?? null;\n }\n\n if (leaf != null) {\n let filePath = baseUrl + leaf;\n\n if (leaf === '') {\n filePath =\n baseUrl === ''\n ? 'index'\n : baseUrl.endsWith('/')\n ? baseUrl + 'index'\n : baseUrl.slice(0, -1);\n } else if (\n // If the path is a collection of group segments leading to an index route, append `/index`.\n stripGroupSegmentsFromPath(filePath) === ''\n ) {\n filePath += '/index';\n }\n\n // This should never happen, the type of `string | object` originally comes from React Navigation.\n if (!route) {\n throw new Error(\n `Internal error: Route not found for \"${filePath}\" while collecting static export paths.`\n );\n }\n\n if (includeGroupVariations) {\n // TODO: Dedupe requests for alias routes.\n addOptionalGroups(filePath, route);\n } else {\n htmlFiles.add({\n filePath,\n route,\n });\n }\n } else if (typeof value === 'object' && value?.screens) {\n // The __root slot has no path.\n const newPath = value.path ? baseUrl + value.path + '/' : baseUrl;\n traverseScreens(value.screens, value._route ?? null, newPath);\n }\n }\n }\n\n function addOptionalGroups(path: string, route: RouteNode) {\n const variations = getPathVariations(path);\n for (const variation of variations) {\n htmlFiles.add({ filePath: variation, route });\n }\n }\n\n traverseScreens(manifest.screens, null);\n\n return uniqueBy(Array.from(htmlFiles), (value) => value.filePath).map((value) => {\n const parts = value.filePath.split('/');\n // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`\n const partsWithGroups = parts.map((part) => {\n if (part === '*not-found') {\n return `+not-found`;\n } else if (part.startsWith(':')) {\n return `[${part.slice(1)}]`;\n } else if (part.startsWith('*')) {\n return `[...${part.slice(1)}]`;\n }\n return part;\n });\n const filePathLocation = partsWithGroups.join('/');\n const filePath = filePathLocation + '.html';\n return {\n ...value,\n filePath,\n pathname: filePathLocation.replace(/(\\/?index)?$/, ''),\n };\n });\n}\n\nfunction uniqueBy<T>(array: T[], key: (value: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const value of array) {\n const id = key(value);\n if (!seen.has(id)) {\n seen.add(id);\n result.push(value);\n }\n }\n return result;\n}\n\n// Given a route like `(foo)/bar/(baz)`, return all possible variations of the route.\n// e.g. `(foo)/bar/(baz)`, `(foo)/bar/baz`, `foo/bar/(baz)`, `foo/bar/baz`,\nexport function getPathVariations(routePath: string): string[] {\n const variations = new Set<string>();\n const segments = routePath.split('/');\n\n function generateVariations(segments: string[], current = ''): void {\n if (segments.length === 0) {\n if (current) variations.add(current);\n return;\n }\n\n const [head, ...rest] = segments;\n\n if (matchGroupName(head)) {\n const groups = head.slice(1, -1).split(',');\n\n if (groups.length > 1) {\n for (const group of groups) {\n // If there are multiple groups, recurse on each group.\n generateVariations([`(${group.trim()})`, ...rest], current);\n }\n return;\n } else {\n // Start a fork where this group is included\n generateVariations(rest, current ? `${current}/(${groups[0]})` : `(${groups[0]})`);\n // This code will continue and add paths without this group included`\n }\n } else if (current) {\n current = `${current}/${head}`;\n } else {\n current = head;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\nexport async function exportApiRoutesStandaloneAsync(\n devServer: MetroBundlerDevServer,\n {\n files = new Map(),\n platform,\n apiRoutesOnly,\n templateHtml,\n }: {\n files?: ExportAssetMap;\n platform: string;\n apiRoutesOnly: boolean;\n templateHtml?: string;\n }\n) {\n const { serverManifest, htmlManifest } = await devServer.getServerManifestAsync();\n\n const apiRoutes = await exportApiRoutesAsync({\n server: devServer,\n manifest: serverManifest,\n // NOTE(kitten): For now, we always output source maps for API route exports\n includeSourceMaps: true,\n platform,\n apiRoutesOnly,\n });\n\n // Add the api routes to the files to export.\n for (const [route, contents] of apiRoutes) {\n files.set(route, contents);\n }\n\n if (templateHtml && devServer.isReactServerComponentsEnabled) {\n // TODO: Export an HTML entry for each file. This is a temporary solution until we have SSR/SSG for RSC.\n await getFilesToExportFromServerAsync(devServer.projectRoot, {\n manifest: htmlManifest,\n exportServer: true,\n files,\n renderAsync: async ({ pathname, filePath }) => {\n files.set(filePath, {\n contents: templateHtml!,\n routeId: pathname,\n targetDomain: 'server',\n });\n return templateHtml!;\n },\n });\n }\n\n return files;\n}\n\nasync function exportApiRoutesAsync({\n includeSourceMaps,\n server,\n platform,\n apiRoutesOnly,\n ...props\n}: Pick<Options, 'includeSourceMaps'> & {\n server: MetroBundlerDevServer;\n manifest: ExpoRouterServerManifestV1;\n platform: string;\n apiRoutesOnly?: boolean;\n}): Promise<ExportAssetMap> {\n const { manifest, files } = await server.exportExpoRouterApiRoutesAsync({\n outputDir: '_expo/functions',\n prerenderManifest: props.manifest,\n includeSourceMaps,\n platform,\n });\n\n // HACK: Clear out the HTML and 404 routes if we're only exporting API routes. This is used for native apps that are using API routes but haven't implemented web support yet.\n if (apiRoutesOnly) {\n manifest.htmlRoutes = [];\n manifest.notFoundRoutes = [];\n }\n\n files.set('_expo/routes.json', {\n contents: JSON.stringify(manifest, null, 2),\n targetDomain: 'server',\n });\n\n return files;\n}\n\nfunction warnPossibleInvalidExportType(appDir: string) {\n const apiRoutes = getApiRoutesForDirectory(appDir);\n if (apiRoutes.length) {\n // TODO: Allow API Routes for native-only.\n Log.warn(\n chalk.yellow`Skipping export for API routes because \\`web.output\\` is not \"server\". You may want to remove the routes: ${apiRoutes\n .map((v) => path.relative(appDir, v))\n .join(', ')}`\n );\n }\n\n const middlewareFile = getMiddlewareForDirectory(appDir);\n if (middlewareFile) {\n Log.warn(\n chalk.yellow`Skipping export for middleware because \\`web.output\\` is not \"server\". You may want to remove ${path.relative(appDir, middlewareFile)}`\n );\n }\n}\n"],"names":["exportApiRoutesStandaloneAsync","exportFromServerAsync","getFilesToExportFromServerAsync","getHtmlFiles","getPathVariations","injectScriptTags","debug","require","html","scriptTags","scriptTagsHtml","map","tag","platform","src","join","replace","matchGroupName","name","match","projectRoot","manifest","renderAsync","exportServer","files","Map","Promise","all","includeGroupVariations","route","filePath","pathname","type","targetDomain","set","contents","data","routeId","e","logMetroErrorAsync","error","Error","modifyRouteNodeInRuntimeManifest","callback","iterateScreens","screens","Object","values","value","_route","makeRuntimeEntryPointsAbsolute","appDir","Array","isArray","entryPoints","entryPoint","shouldLinkExternally","startsWith","path","resolve","isAbsolute","resolveFrom","devServer","outputDir","baseUrl","includeSourceMaps","routerRoot","exp","Log","log","learnMore","isExporting","injectFaviconTag","getVirtualFaviconAssetsAsync","resources","serverManifest","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","serializeHtmlWithAssets","artifacts","hydrate","getFilesFromSerialAssets","isServerHosted","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","key","entries","leaf","keys","length","endsWith","slice","stripGroupSegmentsFromPath","addOptionalGroups","add","newPath","variations","variation","uniqueBy","from","parts","split","partsWithGroups","part","filePathLocation","array","seen","result","id","has","push","routePath","segments","generateVariations","current","head","rest","groups","group","trim","apiRoutesOnly","templateHtml","htmlManifest","getServerManifestAsync","isReactServerComponentsEnabled","props","exportExpoRouterApiRoutesAsync","prerenderManifest","htmlRoutes","notFoundRoutes","JSON","stringify","getApiRoutesForDirectory","warn","chalk","yellow","v","relative","middlewareFile","getMiddlewareForDirectory"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAwaqBA,8BAA8B;eAA9BA;;IAxQAC,qBAAqB;eAArBA;;IApFAC,+BAA+B;eAA/BA;;IA+LNC,YAAY;eAAZA;;IAqHAC,iBAAiB;eAAjBA;;IArUAC,gBAAgB;eAAhBA;;;;gEAzDE;;;;;;;yBAEyB;;;;;;;yBACN;;;;;;;gEACpB;;;;;;;gEACO;;;;;;;yBACA;;;;;;yBAEqB;oCACL;4BACiB;qBACrC;qCAMe;wBACiC;+BAC5B;sBACd;;;;;;AAE1B,MAAMC,QAAQC,QAAQ,SAAS;AAmCxB,SAASF,iBAAiBG,IAAY,EAAEC,UAA4B;IACzE,MAAMC,iBAAiBD,WACpBE,GAAG,CAAC,CAACC,MACJA,IAAIC,QAAQ,KAAK,QACb,CAAC,aAAa,EAAED,IAAIE,GAAG,CAAC,WAAW,CAAC,GACpC,CAAC,8BAA8B,EAAEF,IAAIE,GAAG,CAAC,iBAAiB,EAAEF,IAAIC,QAAQ,CAAC,WAAW,CAAC,EAE1FE,IAAI,CAAC;IACRP,OAAOA,KAAKQ,OAAO,CAAC,WAAW,GAAGN,eAAe,SAAS,CAAC;IAC3D,OAAOF;AACT;AAEA,6BAA6B,GAC7B,SAASS,eAAeC,IAAY;QAC3BA;IAAP,QAAOA,cAAAA,KAAKC,KAAK,CAAC,sCAAXD,WAA8B,CAAC,EAAE;AAC1C;AAEO,eAAehB,gCACpBkB,WAAmB,EACnB,EACEC,QAAQ,EACRC,WAAW,EACX,8DAA8D;AAC9D,kEAAkE;AAClE,aAAa;AACbC,YAAY,EACZ,kBAAkB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80
  '--no-minify': Boolean,
81
81
  '--no-bytecode': Boolean,
82
82
  '--no-ssg': Boolean,
83
+ '--unstable-hosted-native': Boolean,
83
84
  // Hack: This is added because EAS CLI always includes the flag.
84
85
  // If supplied, we'll do nothing with the value, but at least the process won't crash.
85
86
  // Note that we also don't show this value in the `--help` prompt since we don't want people to use it.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk';\n\nimport { Command } from '../../bin/cli';\nimport { assertArgs, getProjectRoot, printHelp } from '../utils/args';\nimport { logCmdError } from '../utils/errors';\n\nexport const expoExport: Command = async (argv) => {\n const args = assertArgs(\n {\n // Types\n '--help': Boolean,\n '--clear': Boolean,\n '--dump-assetmap': Boolean,\n '--dev': Boolean,\n '--source-maps': Boolean,\n '--max-workers': Number,\n '--output-dir': String,\n '--platform': [String],\n '--no-minify': Boolean,\n '--no-bytecode': Boolean,\n '--no-ssg': Boolean,\n\n // Hack: This is added because EAS CLI always includes the flag.\n // If supplied, we'll do nothing with the value, but at least the process won't crash.\n // Note that we also don't show this value in the `--help` prompt since we don't want people to use it.\n '--experimental-bundle': Boolean,\n\n // Aliases\n '-h': '--help',\n '-s': '--source-maps',\n // '-d': '--dump-assetmap',\n '-c': '--clear',\n '-p': '--platform',\n // Interop with Metro docs and RedBox errors.\n '--reset-cache': '--clear',\n\n // Deprecated\n '--dump-sourcemap': '--source-maps',\n },\n argv\n );\n\n if (args['--help']) {\n printHelp(\n `Export the static files of the app for hosting it on a web server`,\n chalk`npx expo export {dim <dir>}`,\n [\n chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`,\n chalk`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`,\n `--dev Configure static files for developing locally using a non-https server`,\n `--no-minify Prevent minifying source`,\n `--no-bytecode Prevent generating Hermes bytecode`,\n `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`,\n `--dump-assetmap Emit an asset map for further processing`,\n `--no-ssg Skip exporting static HTML files for web routes`,\n chalk`-p, --platform <platform> Options: android, ios, web, all. {dim Default: all}`,\n `-s, --source-maps Emit JavaScript source maps`,\n `-c, --clear Clear the bundler cache`,\n `-h, --help Usage info`,\n ].join('\\n')\n );\n }\n\n const projectRoot = getProjectRoot(args);\n const { resolveOptionsAsync } = await import('./resolveOptions.js');\n const options = await resolveOptionsAsync(projectRoot, args).catch(logCmdError);\n\n const { exportAsync } = await import('./exportAsync.js');\n return exportAsync(projectRoot, options).catch(logCmdError);\n};\n"],"names":["expoExport","argv","args","assertArgs","Boolean","Number","String","printHelp","chalk","join","projectRoot","getProjectRoot","resolveOptionsAsync","options","catch","logCmdError","exportAsync"],"mappings":";;;;;+BAOaA;;;eAAAA;;;;gEANK;;;;;;sBAGoC;wBAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErB,MAAMA,aAAsB,OAAOC;IACxC,MAAMC,OAAOC,IAAAA,gBAAU,EACrB;QACE,QAAQ;QACR,UAAUC;QACV,WAAWA;QACX,mBAAmBA;QACnB,SAASA;QACT,iBAAiBA;QACjB,iBAAiBC;QACjB,gBAAgBC;QAChB,cAAc;YAACA;SAAO;QACtB,eAAeF;QACf,iBAAiBA;QACjB,YAAYA;QAEZ,gEAAgE;QAChE,sFAAsF;QACtF,uGAAuG;QACvG,yBAAyBA;QAEzB,UAAU;QACV,MAAM;QACN,MAAM;QACN,2BAA2B;QAC3B,MAAM;QACN,MAAM;QACN,6CAA6C;QAC7C,iBAAiB;QAEjB,aAAa;QACb,oBAAoB;IACtB,GACAH;IAGF,IAAIC,IAAI,CAAC,SAAS,EAAE;QAClBK,IAAAA,eAAS,EACP,CAAC,iEAAiE,CAAC,EACnEC,IAAAA,gBAAK,CAAA,CAAC,2BAA2B,CAAC,EAClC;YACEA,IAAAA,gBAAK,CAAA,CAAC,kGAAkG,CAAC;YACzGA,IAAAA,gBAAK,CAAA,CAAC,2FAA2F,CAAC;YAClG,CAAC,iGAAiG,CAAC;YACnG,CAAC,mDAAmD,CAAC;YACrD,CAAC,6DAA6D,CAAC;YAC/D,CAAC,gFAAgF,CAAC;YAClF,CAAC,mEAAmE,CAAC;YACrE,CAAC,0EAA0E,CAAC;YAC5EA,IAAAA,gBAAK,CAAA,CAAC,8EAA8E,CAAC;YACrF,CAAC,sDAAsD,CAAC;YACxD,CAAC,kDAAkD,CAAC;YACpD,CAAC,qCAAqC,CAAC;SACxC,CAACC,IAAI,CAAC;IAEX;IAEA,MAAMC,cAAcC,IAAAA,oBAAc,EAACT;IACnC,MAAM,EAAEU,mBAAmB,EAAE,GAAG,MAAM,mEAAA,QAAO;IAC7C,MAAMC,UAAU,MAAMD,oBAAoBF,aAAaR,MAAMY,KAAK,CAACC,mBAAW;IAE9E,MAAM,EAAEC,WAAW,EAAE,GAAG,MAAM,mEAAA,QAAO;IACrC,OAAOA,YAAYN,aAAaG,SAASC,KAAK,CAACC,mBAAW;AAC5D"}
1
+ {"version":3,"sources":["../../../src/export/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport chalk from 'chalk';\n\nimport { Command } from '../../bin/cli';\nimport { assertArgs, getProjectRoot, printHelp } from '../utils/args';\nimport { logCmdError } from '../utils/errors';\n\nexport const expoExport: Command = async (argv) => {\n const args = assertArgs(\n {\n // Types\n '--help': Boolean,\n '--clear': Boolean,\n '--dump-assetmap': Boolean,\n '--dev': Boolean,\n '--source-maps': Boolean,\n '--max-workers': Number,\n '--output-dir': String,\n '--platform': [String],\n '--no-minify': Boolean,\n '--no-bytecode': Boolean,\n '--no-ssg': Boolean,\n '--unstable-hosted-native': Boolean,\n\n // Hack: This is added because EAS CLI always includes the flag.\n // If supplied, we'll do nothing with the value, but at least the process won't crash.\n // Note that we also don't show this value in the `--help` prompt since we don't want people to use it.\n '--experimental-bundle': Boolean,\n\n // Aliases\n '-h': '--help',\n '-s': '--source-maps',\n // '-d': '--dump-assetmap',\n '-c': '--clear',\n '-p': '--platform',\n // Interop with Metro docs and RedBox errors.\n '--reset-cache': '--clear',\n\n // Deprecated\n '--dump-sourcemap': '--source-maps',\n },\n argv\n );\n\n if (args['--help']) {\n printHelp(\n `Export the static files of the app for hosting it on a web server`,\n chalk`npx expo export {dim <dir>}`,\n [\n chalk`<dir> Directory of the Expo project. {dim Default: Current working directory}`,\n chalk`--output-dir <dir> The directory to export the static files to. {dim Default: dist}`,\n `--dev Configure static files for developing locally using a non-https server`,\n `--no-minify Prevent minifying source`,\n `--no-bytecode Prevent generating Hermes bytecode`,\n `--max-workers <number> Maximum number of tasks to allow the bundler to spawn`,\n `--dump-assetmap Emit an asset map for further processing`,\n `--no-ssg Skip exporting static HTML files for web routes`,\n chalk`-p, --platform <platform> Options: android, ios, web, all. {dim Default: all}`,\n `-s, --source-maps Emit JavaScript source maps`,\n `-c, --clear Clear the bundler cache`,\n `-h, --help Usage info`,\n ].join('\\n')\n );\n }\n\n const projectRoot = getProjectRoot(args);\n const { resolveOptionsAsync } = await import('./resolveOptions.js');\n const options = await resolveOptionsAsync(projectRoot, args).catch(logCmdError);\n\n const { exportAsync } = await import('./exportAsync.js');\n return exportAsync(projectRoot, options).catch(logCmdError);\n};\n"],"names":["expoExport","argv","args","assertArgs","Boolean","Number","String","printHelp","chalk","join","projectRoot","getProjectRoot","resolveOptionsAsync","options","catch","logCmdError","exportAsync"],"mappings":";;;;;+BAOaA;;;eAAAA;;;;gEANK;;;;;;sBAGoC;wBAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErB,MAAMA,aAAsB,OAAOC;IACxC,MAAMC,OAAOC,IAAAA,gBAAU,EACrB;QACE,QAAQ;QACR,UAAUC;QACV,WAAWA;QACX,mBAAmBA;QACnB,SAASA;QACT,iBAAiBA;QACjB,iBAAiBC;QACjB,gBAAgBC;QAChB,cAAc;YAACA;SAAO;QACtB,eAAeF;QACf,iBAAiBA;QACjB,YAAYA;QACZ,4BAA4BA;QAE5B,gEAAgE;QAChE,sFAAsF;QACtF,uGAAuG;QACvG,yBAAyBA;QAEzB,UAAU;QACV,MAAM;QACN,MAAM;QACN,2BAA2B;QAC3B,MAAM;QACN,MAAM;QACN,6CAA6C;QAC7C,iBAAiB;QAEjB,aAAa;QACb,oBAAoB;IACtB,GACAH;IAGF,IAAIC,IAAI,CAAC,SAAS,EAAE;QAClBK,IAAAA,eAAS,EACP,CAAC,iEAAiE,CAAC,EACnEC,IAAAA,gBAAK,CAAA,CAAC,2BAA2B,CAAC,EAClC;YACEA,IAAAA,gBAAK,CAAA,CAAC,kGAAkG,CAAC;YACzGA,IAAAA,gBAAK,CAAA,CAAC,2FAA2F,CAAC;YAClG,CAAC,iGAAiG,CAAC;YACnG,CAAC,mDAAmD,CAAC;YACrD,CAAC,6DAA6D,CAAC;YAC/D,CAAC,gFAAgF,CAAC;YAClF,CAAC,mEAAmE,CAAC;YACrE,CAAC,0EAA0E,CAAC;YAC5EA,IAAAA,gBAAK,CAAA,CAAC,8EAA8E,CAAC;YACrF,CAAC,sDAAsD,CAAC;YACxD,CAAC,kDAAkD,CAAC;YACpD,CAAC,qCAAqC,CAAC;SACxC,CAACC,IAAI,CAAC;IAEX;IAEA,MAAMC,cAAcC,IAAAA,oBAAc,EAACT;IACnC,MAAM,EAAEU,mBAAmB,EAAE,GAAG,MAAM,mEAAA,QAAO;IAC7C,MAAMC,UAAU,MAAMD,oBAAoBF,aAAaR,MAAMY,KAAK,CAACC,mBAAW;IAE9E,MAAM,EAAEC,WAAW,EAAE,GAAG,MAAM,mEAAA,QAAO;IACrC,OAAOA,YAAYN,aAAaG,SAASC,KAAK,CAACC,mBAAW;AAC5D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/metroAssetLocalPath.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport type { AssetData } from 'metro';\nimport path from 'path';\n\nexport function getAssetLocalPath(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale, platform }: { baseUrl?: string; scale: number; platform: string }\n): string {\n if (platform === 'android') {\n return getAssetLocalPathAndroid(asset, { baseUrl, scale });\n }\n return getAssetLocalPathDefault(asset, { baseUrl, scale });\n}\n\nfunction getAssetLocalPathAndroid(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n {\n baseUrl,\n scale,\n }: {\n // TODO: baseUrl support\n baseUrl?: string;\n scale: number;\n }\n): string {\n const androidFolder = getAndroidResourceFolderName(asset, scale);\n const fileName = getResourceIdentifier(asset);\n return path.join(androidFolder, `${fileName}.${asset.type}`);\n}\n\nfunction getAssetLocalPathDefault(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale }: { baseUrl?: string; scale: number }\n): string {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n const fileName = `${asset.name}${suffix}.${asset.type}`;\n\n const adjustedHttpServerLocation = stripAssetPrefix(asset.httpServerLocation, baseUrl);\n\n return path.join(\n // Assets can have relative paths outside of the project root.\n // Replace `../` with `_` to make sure they don't end up outside of\n // the expected assets directory.\n adjustedHttpServerLocation.replace(/^\\/+/g, '').replace(/\\.\\.\\//g, '_'),\n fileName\n );\n}\n\nexport function stripAssetPrefix(path: string, baseUrl?: string) {\n path = path.replace(/\\/assets\\?export_path=(.*)/, '$1');\n\n // TODO: Windows?\n if (baseUrl) {\n return path.replace(/^\\/+/g, '').replace(\n new RegExp(\n `^${baseUrl\n .replace(/^\\/+/g, '')\n .replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&')\n .replace(/-/g, '\\\\x2d')}`,\n 'g'\n ),\n ''\n );\n }\n return path;\n}\n\n/**\n * FIXME: using number to represent discrete scale numbers is fragile in essence because of\n * floating point numbers imprecision.\n */\nfunction getAndroidAssetSuffix(scale: number): string | null {\n switch (scale) {\n case 0.75:\n return 'ldpi';\n case 1:\n return 'mdpi';\n case 1.5:\n return 'hdpi';\n case 2:\n return 'xhdpi';\n case 3:\n return 'xxhdpi';\n case 4:\n return 'xxxhdpi';\n default:\n return null;\n }\n}\n\n// See https://developer.android.com/guide/topics/resources/drawable-resource.html\nexport const drawableFileTypes = new Set<string>(['gif', 'jpeg', 'jpg', 'png', 'webp', 'xml']);\n\nfunction getAndroidResourceFolderName(asset: Pick<AssetData, 'type'>, scale: number): string {\n if (!drawableFileTypes.has(asset.type)) {\n return 'raw';\n }\n const suffix = getAndroidAssetSuffix(scale);\n if (!suffix) {\n throw new Error(\n `Asset \"${JSON.stringify(asset)}\" does not use a supported Android resolution suffix`\n );\n }\n return `drawable-${suffix}`;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["drawableFileTypes","getAssetLocalPath","stripAssetPrefix","asset","baseUrl","scale","platform","getAssetLocalPathAndroid","getAssetLocalPathDefault","androidFolder","getAndroidResourceFolderName","fileName","getResourceIdentifier","path","join","type","suffix","name","adjustedHttpServerLocation","httpServerLocation","replace","RegExp","getAndroidAssetSuffix","Set","has","Error","JSON","stringify","folderPath","getBaseUrl","toLowerCase","substring"],"mappings":"AAAA;;;;;;;;;CASC;;;;;;;;;;;IA2FYA,iBAAiB;eAAjBA;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A,OAAO,CAAC,MAAM,UAAU,EAC3B,MAEF;IAEJ;IACA,OAAOP;AACT;AAEA;;;CAGC,GACD,SAASS,sBAAsBjB,KAAa;IAC1C,OAAQA;QACN,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE,OAAO;IACX;AACF;AAGO,MAAML,oBAAoB,IAAIuB,IAAY;IAAC;IAAO;IAAQ;IAAO;IAAO;IAAQ;CAAM;AAE7F,SAASb,6BAA6BP,KAA8B,EAAEE,KAAa;IACjF,IAAI,CAACL,kBAAkBwB,GAAG,CAACrB,MAAMY,IAAI,GAAG;QACtC,OAAO;IACT;IACA,MAAMC,SAASM,sBAAsBjB;IACrC,IAAI,CAACW,QAAQ;QACX,MAAM,IAAIS,MACR,CAAC,OAAO,EAAEC,KAAKC,SAAS,CAACxB,OAAO,oDAAoD,CAAC;IAEzF;IACA,OAAO,CAAC,SAAS,EAAEa,QAAQ;AAC7B;AAEA,SAASJ,sBAAsBT,KAAqD;IAClF,MAAMyB,aAAaC,WAAW1B;IAC9B,OAAO,GAAGyB,WAAW,CAAC,EAAEzB,MAAMc,IAAI,EAAE,CACjCa,WAAW,GACXV,OAAO,CAAC,OAAO,KAAK,uCAAuC;KAC3DA,OAAO,CAAC,iBAAiB,IAAI,uBAAuB;KACpDA,OAAO,CAAC,YAAY,KAAK,0BAA0B;AACxD;AAEA,SAASS,WAAW1B,KAA4C;IAC9D,IAAIC,UAAUD,MAAMgB,kBAAkB;IACtC,IAAIf,OAAO,CAAC,EAAE,KAAK,KAAK;QACtBA,UAAUA,QAAQ2B,SAAS,CAAC;IAC9B;IACA,OAAO3B;AACT"}
1
+ {"version":3,"sources":["../../../src/export/metroAssetLocalPath.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport type { AssetData } from '@expo/metro/metro';\nimport path from 'path';\n\nexport function getAssetLocalPath(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale, platform }: { baseUrl?: string; scale: number; platform: string }\n): string {\n if (platform === 'android') {\n return getAssetLocalPathAndroid(asset, { baseUrl, scale });\n }\n return getAssetLocalPathDefault(asset, { baseUrl, scale });\n}\n\nfunction getAssetLocalPathAndroid(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n {\n baseUrl,\n scale,\n }: {\n // TODO: baseUrl support\n baseUrl?: string;\n scale: number;\n }\n): string {\n const androidFolder = getAndroidResourceFolderName(asset, scale);\n const fileName = getResourceIdentifier(asset);\n return path.join(androidFolder, `${fileName}.${asset.type}`);\n}\n\nfunction getAssetLocalPathDefault(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale }: { baseUrl?: string; scale: number }\n): string {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n const fileName = `${asset.name}${suffix}.${asset.type}`;\n\n const adjustedHttpServerLocation = stripAssetPrefix(asset.httpServerLocation, baseUrl);\n\n return path.join(\n // Assets can have relative paths outside of the project root.\n // Replace `../` with `_` to make sure they don't end up outside of\n // the expected assets directory.\n adjustedHttpServerLocation.replace(/^\\/+/g, '').replace(/\\.\\.\\//g, '_'),\n fileName\n );\n}\n\nexport function stripAssetPrefix(path: string, baseUrl?: string) {\n path = path.replace(/\\/assets\\?export_path=(.*)/, '$1');\n\n // TODO: Windows?\n if (baseUrl) {\n return path.replace(/^\\/+/g, '').replace(\n new RegExp(\n `^${baseUrl\n .replace(/^\\/+/g, '')\n .replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&')\n .replace(/-/g, '\\\\x2d')}`,\n 'g'\n ),\n ''\n );\n }\n return path;\n}\n\n/**\n * FIXME: using number to represent discrete scale numbers is fragile in essence because of\n * floating point numbers imprecision.\n */\nfunction getAndroidAssetSuffix(scale: number): string | null {\n switch (scale) {\n case 0.75:\n return 'ldpi';\n case 1:\n return 'mdpi';\n case 1.5:\n return 'hdpi';\n case 2:\n return 'xhdpi';\n case 3:\n return 'xxhdpi';\n case 4:\n return 'xxxhdpi';\n default:\n return null;\n }\n}\n\n// See https://developer.android.com/guide/topics/resources/drawable-resource.html\nexport const drawableFileTypes = new Set<string>(['gif', 'jpeg', 'jpg', 'png', 'webp', 'xml']);\n\nfunction getAndroidResourceFolderName(asset: Pick<AssetData, 'type'>, scale: number): string {\n if (!drawableFileTypes.has(asset.type)) {\n return 'raw';\n }\n const suffix = getAndroidAssetSuffix(scale);\n if (!suffix) {\n throw new Error(\n `Asset \"${JSON.stringify(asset)}\" does not use a supported Android resolution suffix`\n );\n }\n return `drawable-${suffix}`;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["drawableFileTypes","getAssetLocalPath","stripAssetPrefix","asset","baseUrl","scale","platform","getAssetLocalPathAndroid","getAssetLocalPathDefault","androidFolder","getAndroidResourceFolderName","fileName","getResourceIdentifier","path","join","type","suffix","name","adjustedHttpServerLocation","httpServerLocation","replace","RegExp","getAndroidAssetSuffix","Set","has","Error","JSON","stringify","folderPath","getB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Assets.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport fs from 'fs';\nimport type { AssetData } from 'metro';\nimport path from 'path';\n\nimport { drawableFileTypes, getAssetLocalPath } from './metroAssetLocalPath';\nimport { ExportAssetMap } from './saveAssets';\nimport { Log } from '../log';\n\nfunction cleanAssetCatalog(catalogDir: string): void {\n const files = fs.readdirSync(catalogDir).filter((file) => file.endsWith('.imageset'));\n for (const file of files) {\n fs.rmSync(path.join(catalogDir, file));\n }\n}\n\nexport async function persistMetroAssetsAsync(\n projectRoot: string,\n assets: readonly AssetData[],\n {\n platform,\n outputDirectory,\n baseUrl,\n iosAssetCatalogDirectory,\n files,\n }: {\n platform: string;\n outputDirectory: string;\n baseUrl?: string;\n iosAssetCatalogDirectory?: string;\n files?: ExportAssetMap;\n }\n) {\n if (outputDirectory == null) {\n Log.warn('Assets destination folder is not set, skipping...');\n return;\n }\n\n // For iOS, we need to ensure that the outputDirectory exists.\n // The bundle code and images build phase script always tries to access this folder\n if (platform === 'ios' && !fs.existsSync(outputDirectory)) {\n fs.mkdirSync(outputDirectory, { recursive: true });\n }\n\n let assetsToCopy: AssetData[] = [];\n\n // TODO: Use `files` as below to defer writing files\n if (platform === 'ios' && iosAssetCatalogDirectory != null) {\n // Use iOS Asset Catalog for images. This will allow Apple app thinning to\n // remove unused scales from the optimized bundle.\n const catalogDir = path.join(iosAssetCatalogDirectory, 'RNAssets.xcassets');\n if (!fs.existsSync(catalogDir)) {\n Log.error(\n `Could not find asset catalog 'RNAssets.xcassets' in ${iosAssetCatalogDirectory}. Make sure to create it if it does not exist.`\n );\n return;\n }\n\n Log.log('Adding images to asset catalog', catalogDir);\n cleanAssetCatalog(catalogDir);\n for (const asset of assets) {\n if (isCatalogAsset(asset)) {\n const imageSet = getImageSet(\n catalogDir,\n asset,\n filterPlatformAssetScales(platform, asset.scales)\n );\n writeImageSet(imageSet);\n } else {\n assetsToCopy.push(asset);\n }\n }\n Log.log('Done adding images to asset catalog');\n } else {\n assetsToCopy = [...assets];\n }\n if (platform === 'android') {\n await createKeepFileAsync(assetsToCopy, outputDirectory);\n }\n\n const batches: Record<string, string> = {};\n\n for (const asset of assetsToCopy) {\n const validScales = new Set(filterPlatformAssetScales(platform, asset.scales));\n for (let idx = 0; idx < asset.scales.length; idx++) {\n const scale = asset.scales[idx];\n if (validScales.has(scale)) {\n const src = asset.files[idx];\n const dest = getAssetLocalPath(asset, { platform, scale, baseUrl });\n if (files) {\n const data = await fs.promises.readFile(src);\n files.set(dest, {\n contents: data,\n assetId: getAssetIdForLogGrouping(projectRoot, asset),\n targetDomain: platform === 'web' ? 'client' : undefined,\n });\n } else {\n batches[src] = path.join(outputDirectory, dest);\n }\n }\n }\n }\n\n if (!files) {\n await copyInBatchesAsync(batches);\n }\n}\n\nexport async function createKeepFileAsync(\n assets: AssetData[],\n outputDirectory: string\n): Promise<void> {\n if (!assets.length) {\n return;\n }\n const assetsList = [];\n for (const asset of assets) {\n const prefix = drawableFileTypes.has(asset.type) ? 'drawable' : 'raw';\n assetsList.push(`@${prefix}/${getResourceIdentifier(asset)}`);\n }\n const keepPath = path.join(outputDirectory, 'raw/keep.xml');\n const content = `<resources xmlns:tools=\"http://schemas.android.com/tools\" tools:keep=\"${assetsList.join(',')}\" />`;\n await fs.promises.mkdir(path.dirname(keepPath), { recursive: true });\n await fs.promises.writeFile(keepPath, content);\n}\n\nexport function getAssetIdForLogGrouping(\n projectRoot: string,\n asset: Partial<Pick<AssetData, 'fileSystemLocation' | 'name' | 'type'>>\n): string | undefined {\n return 'fileSystemLocation' in asset && asset.fileSystemLocation != null && asset.name != null\n ? path.relative(projectRoot, path.join(asset.fileSystemLocation, asset.name)) +\n (asset.type ? '.' + asset.type : '')\n : undefined;\n}\n\nfunction writeImageSet(imageSet: ImageSet): void {\n fs.mkdirSync(imageSet.baseUrl, { recursive: true });\n\n for (const file of imageSet.files) {\n const dest = path.join(imageSet.baseUrl, file.name);\n fs.copyFileSync(file.src, dest);\n }\n\n fs.writeFileSync(\n path.join(imageSet.baseUrl, 'Contents.json'),\n JSON.stringify({\n images: imageSet.files.map((file) => ({\n filename: file.name,\n idiom: 'universal',\n scale: `${file.scale}x`,\n })),\n info: {\n author: 'expo',\n version: 1,\n },\n })\n );\n}\n\nfunction isCatalogAsset(asset: Pick<AssetData, 'type'>): boolean {\n return asset.type === 'png' || asset.type === 'jpg' || asset.type === 'jpeg';\n}\n\ntype ImageSet = {\n baseUrl: string;\n files: { name: string; src: string; scale: number }[];\n};\n\nfunction getImageSet(\n catalogDir: string,\n asset: Pick<AssetData, 'httpServerLocation' | 'name' | 'type' | 'files'>,\n scales: number[]\n): ImageSet {\n const fileName = getResourceIdentifier(asset);\n return {\n baseUrl: path.join(catalogDir, `${fileName}.imageset`),\n files: scales.map((scale, idx) => {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n return {\n name: `${fileName + suffix}.${asset.type}`,\n scale,\n src: asset.files[idx],\n };\n }),\n };\n}\n\nexport function copyInBatchesAsync(filesToCopy: Record<string, string>) {\n const queue = Object.keys(filesToCopy);\n if (queue.length === 0) {\n return;\n }\n\n Log.log(`Copying ${queue.length} asset files`);\n return new Promise<void>((resolve, reject) => {\n const copyNext = (error?: NodeJS.ErrnoException) => {\n if (error) {\n return reject(error);\n }\n if (queue.length) {\n // queue.length === 0 is checked in previous branch, so this is string\n const src = queue.shift() as string;\n const dest = filesToCopy[src];\n copy(src, dest, copyNext);\n } else {\n resolve();\n }\n };\n copyNext();\n });\n}\n\nfunction copy(src: string, dest: string, callback: (error?: NodeJS.ErrnoException) => void): void {\n fs.mkdir(path.dirname(dest), { recursive: true }, (err?) => {\n if (err) {\n callback(err);\n return;\n }\n fs.createReadStream(src).pipe(fs.createWriteStream(dest)).on('finish', callback);\n });\n}\n\nconst ALLOWED_SCALES: { [key: string]: number[] } = {\n ios: [1, 2, 3],\n};\n\nexport function filterPlatformAssetScales(platform: string, scales: number[]): number[] {\n const whitelist: number[] = ALLOWED_SCALES[platform];\n if (!whitelist) {\n return scales;\n }\n const result = scales.filter((scale) => whitelist.includes(scale));\n if (!result.length && scales.length) {\n // No matching scale found, but there are some available. Ideally we don't\n // want to be in this situation and should throw, but for now as a fallback\n // let's just use the closest larger image\n const maxScale = whitelist[whitelist.length - 1];\n for (const scale of scales) {\n if (scale > maxScale) {\n result.push(scale);\n break;\n }\n }\n\n // There is no larger scales available, use the largest we have\n if (!result.length) {\n result.push(scales[scales.length - 1]);\n }\n }\n return result;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["copyInBatchesAsync","createKeepFileAsync","filterPlatformAssetScales","getAssetIdForLogGrouping","persistMetroAssetsAsync","cleanAssetCatalog","catalogDir","files","fs","readdirSync","filter","file","endsWith","rmSync","path","join","projectRoot","assets","platform","outputDirectory","baseUrl","iosAssetCatalogDirectory","Log","warn","existsSync","mkdirSync","recursive","assetsToCopy","error","log","asset","isCatalogAsset","imageSet","getImageSet","scales","writeImageSet","push","batches","validScales","Set","idx","length","scale","has","src","dest","getAssetLocalPath","data","promises","readFile","set","contents","assetId","targetDomain","undefined","assetsList","prefix","drawableFileTypes","type","getResourceIdentifier","keepPath","content","mkdir","dirname","writeFile","fileSystemLocation","name","relative","copyFileSync","writeFileSync","JSON","stringify","images","map","filename","idiom","info","author","version","fileName","suffix","filesToCopy","queue","Object","keys","Promise","resolve","reject","copyNext","shift","copy","callback","err","createReadStream","pipe","createWriteStream","on","ALLOWED_SCALES","ios","whitelist","result","includes","maxScale","folderPath","getBaseUrl","toLowerCase","replace","httpServerLocation","substring"],"mappings":"AAAA;;;;;;;;;CASC;;;;;;;;;;;IA4LeA,kBAAkB;eAAlBA;;IAhFMC,mBAAmB;eAAnBA;;IAuHNC,yBAAyB;eAAzBA;;IArGAC,wBAAwB;eAAxBA;;IA9GMC,uBAAuB;eAAvBA;;;;gEAfP;;;;;;;gEAEE;;;;;;qCAEoC;qBAEjC;;;;;;AAEpB,SAASC,kBAAkBC,UAAkB;IAC3C,MAAMC,QAAQC,aAAE,CAACC,WAAW,CAACH,YAAYI,MAAM,CAAC,CAACC,OAASA,KAAKC,QAAQ,CAAC;IACxE,KAAK,MAAMD,QAAQJ,MAAO;QACxBC,aAAE,CAACK,MAAM,CAACC,eAAI,CAACC,IAAI,CAACT,YAAYK;IAClC;AACF;AAEO,eAAeP,wBACpBY,WAAmB,EACnBC,MAA4B,EAC5B,EACEC,QAAQ,EACRC,eAAe,EACfC,OAAO,EACPC,wBAAwB,EACxBd,KAAK,EAON;IAED,IAAIY,mBAAmB,MAAM;QAC3BG,QAAG,CAACC,IAAI,CAAC;QACT;IACF;IAEA,8DAA8D;IAC9D,mFAAmF;IACnF,IAAIL,aAAa,SAAS,CAACV,aAAE,CAACgB,UAAU,CAACL,kBAAkB;QACzDX,aAAE,CAACiB,SAAS,CAACN,iBAAiB;YAAEO,WAAW;QAAK;IAClD;IAEA,IAAIC,eAA4B,EAAE;IAElC,oDAAoD;IACpD,IAAIT,aAAa,SAASG,4BAA4B,MAAM;QAC1D,0EAA0E;QAC1E,kDAAkD;QAClD,MAAMf,aAAaQ,eAAI,CAACC,IAAI,CAAC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BACZ;YACF;QACF;QAEA,+DAA+D;QAC/D,IAAI,CAAC0D,OAAO3D,MAAM,EAAE;YAClB2D,OAAOhE,IAAI,CAACF,MAAM,CAACA,OAAOO,MAAM,GAAG,EAAE;QACvC;IACF;IACA,OAAO2D;AACT;AAEA,SAASzC,sBAAsB7B,KAAqD;IAClF,MAAMyE,aAAaC,WAAW1E;IAC9B,OAAO,GAAGyE,WAAW,CAAC,EAAEzE,MAAMoC,IAAI,EAAE,CACjCuC,WAAW,GACXC,OAAO,CAAC,OAAO,KAAK,uCAAuC;KAC3DA,OAAO,CAAC,iBAAiB,IAAI,uBAAuB;KACpDA,OAAO,CAAC,YAAY,KAAK,0BAA0B;AACxD;AAEA,SAASF,WAAW1E,KAA4C;IAC9D,IAAIV,UAAUU,MAAM6E,kBAAkB;IACtC,IAAIvF,OAAO,CAAC,EAAE,KAAK,KAAK;QACtBA,UAAUA,QAAQwF,SAAS,CAAC;IAC9B;IACA,OAAOxF;AACT"}
1
+ {"version":3,"sources":["../../../src/export/persistMetroAssets.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport type { AssetData } from '@expo/metro/metro';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { drawableFileTypes, getAssetLocalPath } from './metroAssetLocalPath';\nimport { ExportAssetMap } from './saveAssets';\nimport { Log } from '../log';\n\nfunction cleanAssetCatalog(catalogDir: string): void {\n const files = fs.readdirSync(catalogDir).filter((file) => file.endsWith('.imageset'));\n for (const file of files) {\n fs.rmSync(path.join(catalogDir, file));\n }\n}\n\nexport async function persistMetroAssetsAsync(\n projectRoot: string,\n assets: readonly AssetData[],\n {\n platform,\n outputDirectory,\n baseUrl,\n iosAssetCatalogDirectory,\n files,\n }: {\n platform: string;\n outputDirectory: string;\n baseUrl?: string;\n iosAssetCatalogDirectory?: string;\n files?: ExportAssetMap;\n }\n) {\n if (outputDirectory == null) {\n Log.warn('Assets destination folder is not set, skipping...');\n return;\n }\n\n // For iOS, we need to ensure that the outputDirectory exists.\n // The bundle code and images build phase script always tries to access this folder\n if (platform === 'ios' && !fs.existsSync(outputDirectory)) {\n fs.mkdirSync(outputDirectory, { recursive: true });\n }\n\n let assetsToCopy: AssetData[] = [];\n\n // TODO: Use `files` as below to defer writing files\n if (platform === 'ios' && iosAssetCatalogDirectory != null) {\n // Use iOS Asset Catalog for images. This will allow Apple app thinning to\n // remove unused scales from the optimized bundle.\n const catalogDir = path.join(iosAssetCatalogDirectory, 'RNAssets.xcassets');\n if (!fs.existsSync(catalogDir)) {\n Log.error(\n `Could not find asset catalog 'RNAssets.xcassets' in ${iosAssetCatalogDirectory}. Make sure to create it if it does not exist.`\n );\n return;\n }\n\n Log.log('Adding images to asset catalog', catalogDir);\n cleanAssetCatalog(catalogDir);\n for (const asset of assets) {\n if (isCatalogAsset(asset)) {\n const imageSet = getImageSet(\n catalogDir,\n asset,\n filterPlatformAssetScales(platform, asset.scales)\n );\n writeImageSet(imageSet);\n } else {\n assetsToCopy.push(asset);\n }\n }\n Log.log('Done adding images to asset catalog');\n } else {\n assetsToCopy = [...assets];\n }\n if (platform === 'android') {\n await createKeepFileAsync(assetsToCopy, outputDirectory);\n }\n\n const batches: Record<string, string> = {};\n\n for (const asset of assetsToCopy) {\n const validScales = new Set(filterPlatformAssetScales(platform, asset.scales));\n for (let idx = 0; idx < asset.scales.length; idx++) {\n const scale = asset.scales[idx];\n if (validScales.has(scale)) {\n const src = asset.files[idx];\n const dest = getAssetLocalPath(asset, { platform, scale, baseUrl });\n if (files) {\n const data = await fs.promises.readFile(src);\n files.set(dest, {\n contents: data,\n assetId: getAssetIdForLogGrouping(projectRoot, asset),\n targetDomain: platform === 'web' ? 'client' : undefined,\n });\n } else {\n batches[src] = path.join(outputDirectory, dest);\n }\n }\n }\n }\n\n if (!files) {\n await copyInBatchesAsync(batches);\n }\n}\n\nexport async function createKeepFileAsync(\n assets: AssetData[],\n outputDirectory: string\n): Promise<void> {\n if (!assets.length) {\n return;\n }\n const assetsList = [];\n for (const asset of assets) {\n const prefix = drawableFileTypes.has(asset.type) ? 'drawable' : 'raw';\n assetsList.push(`@${prefix}/${getResourceIdentifier(asset)}`);\n }\n const keepPath = path.join(outputDirectory, 'raw/keep.xml');\n const content = `<resources xmlns:tools=\"http://schemas.android.com/tools\" tools:keep=\"${assetsList.join(',')}\" />`;\n await fs.promises.mkdir(path.dirname(keepPath), { recursive: true });\n await fs.promises.writeFile(keepPath, content);\n}\n\nexport function getAssetIdForLogGrouping(\n projectRoot: string,\n asset: Partial<Pick<AssetData, 'fileSystemLocation' | 'name' | 'type'>>\n): string | undefined {\n return 'fileSystemLocation' in asset && asset.fileSystemLocation != null && asset.name != null\n ? path.relative(projectRoot, path.join(asset.fileSystemLocation, asset.name)) +\n (asset.type ? '.' + asset.type : '')\n : undefined;\n}\n\nfunction writeImageSet(imageSet: ImageSet): void {\n fs.mkdirSync(imageSet.baseUrl, { recursive: true });\n\n for (const file of imageSet.files) {\n const dest = path.join(imageSet.baseUrl, file.name);\n fs.copyFileSync(file.src, dest);\n }\n\n fs.writeFileSync(\n path.join(imageSet.baseUrl, 'Contents.json'),\n JSON.stringify({\n images: imageSet.files.map((file) => ({\n filename: file.name,\n idiom: 'universal',\n scale: `${file.scale}x`,\n })),\n info: {\n author: 'expo',\n version: 1,\n },\n })\n );\n}\n\nfunction isCatalogAsset(asset: Pick<AssetData, 'type'>): boolean {\n return asset.type === 'png' || asset.type === 'jpg' || asset.type === 'jpeg';\n}\n\ntype ImageSet = {\n baseUrl: string;\n files: { name: string; src: string; scale: number }[];\n};\n\nfunction getImageSet(\n catalogDir: string,\n asset: Pick<AssetData, 'httpServerLocation' | 'name' | 'type' | 'files'>,\n scales: number[]\n): ImageSet {\n const fileName = getResourceIdentifier(asset);\n return {\n baseUrl: path.join(catalogDir, `${fileName}.imageset`),\n files: scales.map((scale, idx) => {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n return {\n name: `${fileName + suffix}.${asset.type}`,\n scale,\n src: asset.files[idx],\n };\n }),\n };\n}\n\nexport function copyInBatchesAsync(filesToCopy: Record<string, string>) {\n const queue = Object.keys(filesToCopy);\n if (queue.length === 0) {\n return;\n }\n\n Log.log(`Copying ${queue.length} asset files`);\n return new Promise<void>((resolve, reject) => {\n const copyNext = (error?: NodeJS.ErrnoException) => {\n if (error) {\n return reject(error);\n }\n if (queue.length) {\n // queue.length === 0 is checked in previous branch, so this is string\n const src = queue.shift() as string;\n const dest = filesToCopy[src];\n copy(src, dest, copyNext);\n } else {\n resolve();\n }\n };\n copyNext();\n });\n}\n\nfunction copy(src: string, dest: string, callback: (error?: NodeJS.ErrnoException) => void): void {\n fs.mkdir(path.dirname(dest), { recursive: true }, (err?) => {\n if (err) {\n callback(err);\n return;\n }\n fs.createReadStream(src).pipe(fs.createWriteStream(dest)).on('finish', callback);\n });\n}\n\nconst ALLOWED_SCALES: { [key: string]: number[] } = {\n ios: [1, 2, 3],\n};\n\nexport function filterPlatformAssetScales(platform: string, scales: number[]): number[] {\n const whitelist: number[] = ALLOWED_SCALES[platform];\n if (!whitelist) {\n return scales;\n }\n const result = scales.filter((scale) => whitelist.includes(scale));\n if (!result.length && scales.length) {\n // No matching scale found, but there are some available. Ideally we don't\n // want to be in this situation and should throw, but for now as a fallback\n // let's just use the closest larger image\n const maxScale = whitelist[whitelist.length - 1];\n for (const scale of scales) {\n if (scale > maxScale) {\n result.push(scale);\n break;\n }\n }\n\n // There is no larger scales available, use the largest we have\n if (!result.length) {\n result.push(scales[scales.length - 1]);\n }\n }\n return result;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["copyInBatchesAsync","createKeepFileAsync","filterPlatformAssetScales","getAssetIdForLogGrouping","persistMetroAssetsAsync","cleanAssetCatalog","catalogDir","files","fs","readdirSync","filter","file","endsWith","rmSync","path","join","projectRoot","assets","platform","outputDirectory","baseUrl","iosAssetCatalogDirectory","Log","warn","existsSync","mkdirSync","recursive","assetsToCopy","error","log","asset","isCatalogAsset","imageSet","getImageSet","scales","writeImageSet","push","batches","validScales","Set","idx","length","scale","has","src","dest","getAssetLocalPath","data","promises","readFile","set","contents","assetId","targetDomain","undefined","assetsList","prefix","drawableFileTypes","type","getResourceIdentifier","keepPath","content","mkdir","dirname","writeFile","fileSystemLocation","name","relative","copyFileSync","writeFileSync","JSON","stringify","images","map","filename","idiom","info","author","version","fileName","suffix","filesToCopy","queue","Object","keys","Promise","resolve","reject","copyNext","shift","copy","callback","err","createReadStream","pipe","createWriteStream","on","ALLOWED_SCALES","ios","whitelist","result","includes","maxScale","folderPath","getBaseUrl","toLowerCase","replace","httpServerLocation","substring"],"mappings":"AAAA;;;;;;;;;CASC;;;;;;;;;;;IA4LeA,kBAAkB;eAAlBA;;IAhFMC,mBAAmB;eAAnBA;;IAuHNC,yBAAyB;eAAzBA;;IArGAC,wBAAwB;eAAxBA;;IA9GMC,uBAAuB;eAAvBA;;;;gEAdP;;;;;;;gEACE;;;;;;qCAEoC;qBAEjC;;;;;;AAEpB,SAASC,kBAAkBC,UAAkB;IAC3C,MAAMC,QAAQC,aAAE,CAACC,WAAW,CAACH,YAAYI,MAAM,CAAC,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ACA,OAAOxF;AACT"}
@@ -71,6 +71,7 @@ async function resolveOptionsAsync(projectRoot, args) {
71
71
  const platforms = resolvePlatformOption(exp, platformBundlers, args['--platform']);
72
72
  return {
73
73
  platforms,
74
+ hostedNative: !!args['--unstable-hosted-native'],
74
75
  outputDir: args['--output-dir'] ?? 'dist',
75
76
  minify: !args['--no-minify'],
76
77
  bytecode: !args['--no-bytecode'],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/resolveOptions.ts"],"sourcesContent":["import { ExpoConfig, getConfig, Platform } from '@expo/config';\n\nimport { getPlatformBundlers, PlatformBundlers } from '../start/server/platformBundlers';\nimport { CommandError } from '../utils/errors';\n\nexport type Options = {\n outputDir: string;\n platforms: Platform[];\n maxWorkers?: number;\n dev: boolean;\n clear: boolean;\n minify: boolean;\n bytecode: boolean;\n dumpAssetmap: boolean;\n sourceMaps: boolean;\n skipSSG: boolean;\n};\n\n/** Returns an array of platforms based on the input platform identifier and runtime constraints. */\nexport function resolvePlatformOption(\n exp: ExpoConfig,\n platformBundlers: PlatformBundlers,\n platform: string[] = ['all']\n): Platform[] {\n const platformsAvailable: Partial<PlatformBundlers> = Object.fromEntries(\n Object.entries(platformBundlers).filter(\n ([platform, bundler]) => bundler === 'metro' && exp.platforms?.includes(platform as Platform)\n )\n );\n\n if (!Object.keys(platformsAvailable).length) {\n throw new CommandError(\n `No platforms are configured to use the Metro bundler in the project Expo config.`\n );\n }\n\n const assertPlatformBundler = (platform: Platform): Platform => {\n if (!platformsAvailable[platform]) {\n if (!exp.platforms?.includes(platform) && platform === 'web') {\n // Pass through so the more robust error message is shown.\n return platform;\n }\n throw new CommandError(\n 'BAD_ARGS',\n `Platform \"${platform}\" is not configured to use the Metro bundler in the project Expo config, or is missing from the supported platforms in the platforms array: [${exp.platforms?.join(\n ', '\n )}].`\n );\n }\n\n return platform;\n };\n\n const knownPlatforms = ['android', 'ios', 'web'] as Platform[];\n const assertPlatformIsKnown = (platform: string): Platform => {\n if (!knownPlatforms.includes(platform as Platform)) {\n throw new CommandError(\n `Unsupported platform \"${platform}\". Options are: ${knownPlatforms.join(',')},all`\n );\n }\n\n return platform as Platform;\n };\n\n return (\n platform\n // Expand `all` to all available platforms.\n .map((platform) => (platform === 'all' ? Object.keys(platformsAvailable) : platform))\n .flat()\n // Remove duplicated platforms\n .filter((platform, index, list) => list.indexOf(platform) === index)\n // Assert platforms are valid\n .map((platform) => assertPlatformIsKnown(platform))\n .map((platform) => assertPlatformBundler(platform))\n );\n}\n\nexport async function resolveOptionsAsync(projectRoot: string, args: any): Promise<Options> {\n const { exp } = getConfig(projectRoot, { skipPlugins: true, skipSDKVersionRequirement: true });\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n const platforms = resolvePlatformOption(exp, platformBundlers, args['--platform']);\n return {\n platforms,\n outputDir: args['--output-dir'] ?? 'dist',\n minify: !args['--no-minify'],\n bytecode: !args['--no-bytecode'],\n clear: !!args['--clear'],\n dev: !!args['--dev'],\n maxWorkers: args['--max-workers'],\n dumpAssetmap: !!args['--dump-assetmap'],\n sourceMaps: !!args['--source-maps'],\n skipSSG: !!args['--no-ssg'],\n };\n}\n"],"names":["resolveOptionsAsync","resolvePlatformOption","exp","platformBundlers","platform","platformsAvailable","Object","fromEntries","entries","filter","bundler","platforms","includes","keys","length","CommandError","assertPlatformBundler","join","knownPlatforms","assertPlatformIsKnown","map","flat","index","list","indexOf","projectRoot","args","getConfig","skipPlugins","skipSDKVersionRequirement","getPlatformBundlers","outputDir","minify","bytecode","clear","dev","maxWorkers","dumpAssetmap","sourceMaps","skipSSG"],"mappings":";;;;;;;;;;;IA6EsBA,mBAAmB;eAAnBA;;IA1DNC,qBAAqB;eAArBA;;;;yBAnBgC;;;;;;kCAEM;wBACzB;AAgBtB,SAASA,sBACdC,GAAe,EACfC,gBAAkC,EAClCC,WAAqB;IAAC;CAAM;IAE5B,MAAMC,qBAAgDC,OAAOC,WAAW,CACtED,OAAOE,OAAO,CAACL,kBAAkBM,MAAM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B,EAAEC,IAAS;IACtE,MAAM,EAAExB,GAAG,EAAE,GAAGyB,IAAAA,mBAAS,EAACF,aAAa;QAAEG,aAAa;QAAMC,2BAA2B;IAAK;IAC5F,MAAM1B,mBAAmB2B,IAAAA,qCAAmB,EAACL,aAAavB;IAE1D,MAAMS,YAAYV,sBAAsBC,KAAKC,kBAAkBuB,IAAI,CAAC,aAAa;IACjF,OAAO;QACLf;QACAoB,WAAWL,IAAI,CAAC,eAAe,IAAI;QACnCM,QAAQ,CAACN,IAAI,CAAC,cAAc;QAC5BO,UAAU,CAACP,IAAI,CAAC,gBAAgB;QAChCQ,OAAO,CAAC,CAACR,IAAI,CAAC,UAAU;QACxBS,KAAK,CAAC,CAACT,IAAI,CAAC,QAAQ;QACpBU,YAAYV,IAAI,CAAC,gBAAgB;QACjCW,cAAc,CAAC,CAACX,IAAI,CAAC,kBAAkB;QACvCY,YAAY,CAAC,CAACZ,IAAI,CAAC,gBAAgB;QACnCa,SAAS,CAAC,CAACb,IAAI,CAAC,WAAW;IAC7B;AACF"}
1
+ {"version":3,"sources":["../../../src/export/resolveOptions.ts"],"sourcesContent":["import { ExpoConfig, getConfig, Platform } from '@expo/config';\n\nimport { getPlatformBundlers, PlatformBundlers } from '../start/server/platformBundlers';\nimport { CommandError } from '../utils/errors';\n\nexport type Options = {\n outputDir: string;\n platforms: Platform[];\n maxWorkers?: number;\n dev: boolean;\n clear: boolean;\n minify: boolean;\n bytecode: boolean;\n dumpAssetmap: boolean;\n sourceMaps: boolean;\n skipSSG: boolean;\n hostedNative: boolean;\n};\n\n/** Returns an array of platforms based on the input platform identifier and runtime constraints. */\nexport function resolvePlatformOption(\n exp: ExpoConfig,\n platformBundlers: PlatformBundlers,\n platform: string[] = ['all']\n): Platform[] {\n const platformsAvailable: Partial<PlatformBundlers> = Object.fromEntries(\n Object.entries(platformBundlers).filter(\n ([platform, bundler]) => bundler === 'metro' && exp.platforms?.includes(platform as Platform)\n )\n );\n\n if (!Object.keys(platformsAvailable).length) {\n throw new CommandError(\n `No platforms are configured to use the Metro bundler in the project Expo config.`\n );\n }\n\n const assertPlatformBundler = (platform: Platform): Platform => {\n if (!platformsAvailable[platform]) {\n if (!exp.platforms?.includes(platform) && platform === 'web') {\n // Pass through so the more robust error message is shown.\n return platform;\n }\n throw new CommandError(\n 'BAD_ARGS',\n `Platform \"${platform}\" is not configured to use the Metro bundler in the project Expo config, or is missing from the supported platforms in the platforms array: [${exp.platforms?.join(\n ', '\n )}].`\n );\n }\n\n return platform;\n };\n\n const knownPlatforms = ['android', 'ios', 'web'] as Platform[];\n const assertPlatformIsKnown = (platform: string): Platform => {\n if (!knownPlatforms.includes(platform as Platform)) {\n throw new CommandError(\n `Unsupported platform \"${platform}\". Options are: ${knownPlatforms.join(',')},all`\n );\n }\n\n return platform as Platform;\n };\n\n return (\n platform\n // Expand `all` to all available platforms.\n .map((platform) => (platform === 'all' ? Object.keys(platformsAvailable) : platform))\n .flat()\n // Remove duplicated platforms\n .filter((platform, index, list) => list.indexOf(platform) === index)\n // Assert platforms are valid\n .map((platform) => assertPlatformIsKnown(platform))\n .map((platform) => assertPlatformBundler(platform))\n );\n}\n\nexport async function resolveOptionsAsync(projectRoot: string, args: any): Promise<Options> {\n const { exp } = getConfig(projectRoot, { skipPlugins: true, skipSDKVersionRequirement: true });\n const platformBundlers = getPlatformBundlers(projectRoot, exp);\n\n const platforms = resolvePlatformOption(exp, platformBundlers, args['--platform']);\n return {\n platforms,\n hostedNative: !!args['--unstable-hosted-native'],\n outputDir: args['--output-dir'] ?? 'dist',\n minify: !args['--no-minify'],\n bytecode: !args['--no-bytecode'],\n clear: !!args['--clear'],\n dev: !!args['--dev'],\n maxWorkers: args['--max-workers'],\n dumpAssetmap: !!args['--dump-assetmap'],\n sourceMaps: !!args['--source-maps'],\n skipSSG: !!args['--no-ssg'],\n };\n}\n"],"names":["resolveOptionsAsync","resolvePlatformOption","exp","platformBundlers","platform","platformsAvailable","Object","fromEntries","entries","filter","bundler","platforms","includes","keys","length","CommandError","assertPlatformBundler","join","knownPlatforms","assertPlatformIsKnown","map","flat","index","list","indexOf","projectRoot","args","getConfig","skipPlugins","skipSDKVersionRequirement","getPlatformBundlers","hostedNative","outputDir","minify","bytecode","clear","dev","maxWorkers","dumpAssetmap","sourceMaps","skipSSG"],"mappings":";;;;;;;;;;;IA8EsBA,mBAAmB;eAAnBA;;IA1DNC,qBAAqB;eAArBA;;;;yBApBgC;;;;;;kCAEM;wBACzB;AAiBtB,SAASA,sBACdC,GAAe,EACfC,gBAAkC,EAClCC,WAAqB;IAAC;CAAM;IAE5B,MAAMC,qBAAgDC,OAAOC,WAAW,CACtED,OAAOE,OAAO,CAACL,kBAAkBM,MAAM,CACrC,CAAC,CAACL,UAAUM,QAAQ;YAA4BR;eAAvBQ,YAAY,aAAWR,iBAAAA,IAAIS,SAAS,qBAAbT,eAAeU,QAAQ,CAACR;;IAI5E,IAAI,CAACE,OAAOO,IAAI,CAACR,oBAAoBS,MAAM,EAAE;QAC3C,MAAM,IAAIC,oBAAY,CACpB,CAAC,gFAAgF,CAAC;IAEtF;IAEA,MAAMC,wBAAwB,CAACZ;QAC7B,IAAI,CAACC,kBAAkB,CAACD,SAAS,EAAE;gBAC5BF,gBAMkKA;YANvK,IAAI,GAACA,iBAAAA,IAAIS,SAAS,qBAAbT,eAAeU,QAAQ,CAACR,cAAaA,aAAa,OAAO;gBAC5D,0DAA0D;gBAC1D,OAAOA;YACT;YACA,MAAM,IAAIW,oBAAY,CACpB,YACA,CAAC,UAAU,EAAEX,SAAS,6IAA6I,GAAEF,kBAAAA,IAAIS,SAAS,qBAAbT,gBAAee,IAAI,CACtL,MACA,EAAE,CAAC;QAET;QAEA,OAAOb;IACT;IAEA,MAAMc,iBAAiB;QAAC;QAAW;QAAO;KAAM;IAChD,MAAMC,wBAAwB,CAACf;QAC7B,IAAI,CAACc,eAAeN,QAAQ,CAACR,WAAuB;YAClD,MAAM,IAAIW,oBAAY,CACpB,CAAC,sBAAsB,EAAEX,SAAS,gBAAgB,EAAEc,eAAeD,IAAI,CAAC,KAAK,IAAI,CAAC;QAEtF;QAEA,OAAOb;IACT;IAEA,OACEA,QACE,2CAA2C;KAC1CgB,GAAG,CAAC,CAAChB,WAAcA,aAAa,QAAQE,OAAOO,IAAI,CAACR,sBAAsBD,UAC1EiB,IAAI,EACL,8BAA8B;KAC7BZ,MAAM,CAAC,CAACL,UAAUkB,OAAOC,OAASA,KAAKC,OAAO,CAACpB,cAAckB,MAC9D,6BAA6B;KAC5BF,GAAG,CAAC,CAAChB,WAAae,sBAAsBf,WACxCgB,GAAG,CAAC,CAAChB,WAAaY,sBAAsBZ;AAE/C;AAEO,eAAeJ,oBAAoByB,WAAmB,EAAEC,IAAS;IACtE,MAAM,EAAExB,GAAG,EAAE,GAAGyB,IAAAA,mBAAS,EAACF,aAAa;QAAEG,aAAa;QAAMC,2BAA2B;IAAK;IAC5F,MAAM1B,mBAAmB2B,IAAAA,qCAAmB,EAACL,aAAavB;IAE1D,MAAMS,YAAYV,sBAAsBC,KAAKC,kBAAkBuB,IAAI,CAAC,aAAa;IACjF,OAAO;QACLf;QACAoB,cAAc,CAAC,CAACL,IAAI,CAAC,2BAA2B;QAChDM,WAAWN,IAAI,CAAC,eAAe,IAAI;QACnCO,QAAQ,CAACP,IAAI,CAAC,cAAc;QAC5BQ,UAAU,CAACR,IAAI,CAAC,gBAAgB;QAChCS,OAAO,CAAC,CAACT,IAAI,CAAC,UAAU;QACxBU,KAAK,CAAC,CAACV,IAAI,CAAC,QAAQ;QACpBW,YAAYX,IAAI,CAAC,gBAAgB;QACjCY,cAAc,CAAC,CAACZ,IAAI,CAAC,kBAAkB;QACvCa,YAAY,CAAC,CAACb,IAAI,CAAC,gBAAgB;QACnCc,SAAS,CAAC,CAACd,IAAI,CAAC,WAAW;IAC7B;AACF"}
@@ -72,6 +72,7 @@ async function persistMetroFilesAsync(files, outputDir) {
72
72
  // );
73
73
  const assetEntries = [];
74
74
  const apiRouteEntries = [];
75
+ const middlewareEntries = [];
75
76
  const routeEntries = [];
76
77
  const rscEntries = [];
77
78
  const remainingEntries = [];
@@ -80,6 +81,7 @@ async function persistMetroFilesAsync(files, outputDir) {
80
81
  hasServerOutput = hasServerOutput || asset[1].targetDomain === 'server';
81
82
  if (asset[1].assetId) assetEntries.push(asset);
82
83
  else if (asset[1].routeId != null) routeEntries.push(asset);
84
+ else if (asset[1].middlewareId != null) middlewareEntries.push(asset);
83
85
  else if (asset[1].apiRouteId != null) apiRouteEntries.push(asset);
84
86
  else if (asset[1].rscId != null) rscEntries.push(asset);
85
87
  else remainingEntries.push(asset);
@@ -189,6 +191,16 @@ async function persistMetroFilesAsync(files, outputDir) {
189
191
  _log.Log.log(id === '' ? _chalk().default.gray(' (index)') : id, sizeStr(assets.contents), hasSourceMap ? _chalk().default.gray(`(source map ${sizeStr(hasSourceMap[1].contents)})`) : '');
190
192
  }
191
193
  }
194
+ if (middlewareEntries.length) {
195
+ const middlewareWithoutSourcemaps = middlewareEntries.filter((route)=>!route[0].endsWith('.map'));
196
+ _log.Log.log('');
197
+ _log.Log.log(_chalk().default.bold`${BLT} Middleware:`);
198
+ for (const [middlewareFilename, assets] of middlewareWithoutSourcemaps.sort((a, b)=>a[0].length - b[0].length)){
199
+ const id = assets.middlewareId;
200
+ const hasSourceMap = middlewareEntries.find(([filename, route])=>filename !== middlewareFilename && route.middlewareId === assets.middlewareId && filename.endsWith('.map'));
201
+ _log.Log.log(id, sizeStr(assets.contents), hasSourceMap ? _chalk().default.gray(`(source map ${sizeStr(hasSourceMap[1].contents)})`) : '');
202
+ }
203
+ }
192
204
  // Decouple logging from writing for better performance.
193
205
  await Promise.all([
194
206
  ...files.entries()
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/saveAssets.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport type { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport Metro from 'metro';\nimport path from 'path';\nimport prettyBytes from 'pretty-bytes';\n\nimport { Log } from '../log';\nimport { env } from '../utils/env';\n\nconst BLT = '\\u203A';\n\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n bytecode: boolean;\n sourceMapUrl?: string;\n sourcemaps?: boolean;\n};\n\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\n\nexport type BundleOutput = {\n artifacts: SerialAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nexport type ManifestAsset = { fileHashes: string[]; files: string[]; hash: string };\n\nexport type Asset = ManifestAsset | BundleAssetWithFileHashes;\n\nexport type ExportAssetDescriptor = {\n contents: string | Buffer;\n originFilename?: string;\n /** An identifier for grouping together variations of the same asset. */\n assetId?: string;\n /** Expo Router route path for formatting the HTML output. */\n routeId?: string;\n /** Expo Router API route path for formatting the server function output. */\n apiRouteId?: string;\n /** Expo Router route path for formatting the RSC output. */\n rscId?: string;\n /** A key for grouping together output files by server- or client-side. */\n targetDomain?: 'server' | 'client';\n};\n\nexport type ExportAssetMap = Map<string, ExportAssetDescriptor>;\n\nexport async function persistMetroFilesAsync(files: ExportAssetMap, outputDir: string) {\n if (!files.size) {\n return;\n }\n await fs.promises.mkdir(path.join(outputDir), { recursive: true });\n\n // Test fixtures:\n // Log.log(\n // JSON.stringify(\n // Object.fromEntries([...files.entries()].map(([k, v]) => [k, { ...v, contents: '' }]))\n // )\n // );\n\n const assetEntries: [string, ExportAssetDescriptor][] = [];\n const apiRouteEntries: [string, ExportAssetDescriptor][] = [];\n const routeEntries: [string, ExportAssetDescriptor][] = [];\n const rscEntries: [string, ExportAssetDescriptor][] = [];\n const remainingEntries: [string, ExportAssetDescriptor][] = [];\n\n let hasServerOutput = false;\n for (const asset of files.entries()) {\n hasServerOutput = hasServerOutput || asset[1].targetDomain === 'server';\n if (asset[1].assetId) assetEntries.push(asset);\n else if (asset[1].routeId != null) routeEntries.push(asset);\n else if (asset[1].apiRouteId != null) apiRouteEntries.push(asset);\n else if (asset[1].rscId != null) rscEntries.push(asset);\n else remainingEntries.push(asset);\n }\n\n const groups = groupBy(assetEntries, ([, { assetId }]) => assetId!);\n\n const contentSize = (contents: string | Buffer) => {\n const length =\n typeof contents === 'string' ? Buffer.byteLength(contents, 'utf8') : contents.length;\n return length;\n };\n\n const sizeStr = (contents: string | Buffer) => {\n const length = contentSize(contents);\n const size = chalk.gray`(${prettyBytes(length)})`;\n return size;\n };\n\n // TODO: If any Expo Router is used, then use a new style which is more simple:\n // `chalk.gray(/path/to/) + chalk.cyan('route')`\n // | index.html (1.2kb)\n // | /path\n // | other.html (1.2kb)\n\n const isExpoRouter = routeEntries.length;\n\n // Phase out printing all the assets as users can simply check the file system for more info.\n const showAdditionalInfo = !isExpoRouter || env.EXPO_DEBUG;\n\n const assetGroups = [...groups.entries()].sort((a, b) => a[0].localeCompare(b[0])) as [\n string,\n [string, ExportAssetDescriptor][],\n ][];\n\n if (showAdditionalInfo) {\n if (assetGroups.length) {\n const totalAssets = assetGroups.reduce((sum, [, assets]) => sum + assets.length, 0);\n\n Log.log('');\n Log.log(chalk.bold`${BLT} Assets (${totalAssets}):`);\n\n for (const [assetId, assets] of assetGroups) {\n const averageContentSize =\n assets.reduce((sum, [, { contents }]) => sum + contentSize(contents), 0) / assets.length;\n Log.log(\n assetId,\n chalk.gray(\n `(${[\n assets.length > 1 ? `${assets.length} variations` : '',\n `${prettyBytes(averageContentSize)}`,\n ]\n .filter(Boolean)\n .join(' | ')})`\n )\n );\n }\n }\n }\n\n const bundles: Map<string, [string, ExportAssetDescriptor][]> = new Map();\n const other: [string, ExportAssetDescriptor][] = [];\n\n remainingEntries.forEach(([filepath, asset]) => {\n if (!filepath.match(/_expo\\/static\\//)) {\n other.push([filepath, asset]);\n } else {\n const platform = filepath.match(/_expo\\/static\\/js\\/([^/]+)\\//)?.[1] ?? 'web';\n if (!bundles.has(platform)) bundles.set(platform, []);\n\n bundles.get(platform)!.push([filepath, asset]);\n }\n });\n\n [...bundles.entries()].forEach(([platform, assets]) => {\n Log.log('');\n Log.log(chalk.bold`${BLT} ${platform} bundles (${assets.length}):`);\n\n const allAssets = assets.sort((a, b) => a[0].localeCompare(b[0]));\n while (allAssets.length) {\n const [filePath, asset] = allAssets.shift()!;\n Log.log(filePath, sizeStr(asset.contents));\n if (filePath.match(/\\.(js|hbc)$/)) {\n // Get source map\n const sourceMapIndex = allAssets.findIndex(([fp]) => fp === filePath + '.map');\n if (sourceMapIndex !== -1) {\n const [sourceMapFilePath, sourceMapAsset] = allAssets.splice(sourceMapIndex, 1)[0];\n Log.log(chalk.gray(sourceMapFilePath), sizeStr(sourceMapAsset.contents));\n }\n }\n }\n });\n\n if (showAdditionalInfo && other.length) {\n Log.log('');\n Log.log(chalk.bold`${BLT} Files (${other.length}):`);\n\n for (const [filePath, asset] of other.sort((a, b) => a[0].localeCompare(b[0]))) {\n Log.log(filePath, sizeStr(asset.contents));\n }\n }\n\n if (rscEntries.length) {\n Log.log('');\n Log.log(chalk.bold`${BLT} React Server Components (${rscEntries.length}):`);\n\n for (const [filePath, assets] of rscEntries.sort((a, b) => a[0].length - b[0].length)) {\n const id = assets.rscId!;\n Log.log(\n '/' + (id === '' ? chalk.gray(' (index)') : id),\n sizeStr(assets.contents),\n chalk.gray(filePath)\n );\n }\n }\n\n if (routeEntries.length) {\n Log.log('');\n Log.log(chalk.bold`${BLT} Static routes (${routeEntries.length}):`);\n\n for (const [, assets] of routeEntries.sort((a, b) => a[0].length - b[0].length)) {\n const id = assets.routeId!;\n Log.log('/' + (id === '' ? chalk.gray(' (index)') : id), sizeStr(assets.contents));\n }\n }\n\n if (apiRouteEntries.length) {\n const apiRoutesWithoutSourcemaps = apiRouteEntries.filter(\n (route) => !route[0].endsWith('.map')\n );\n Log.log('');\n Log.log(chalk.bold`${BLT} API routes (${apiRoutesWithoutSourcemaps.length}):`);\n\n for (const [apiRouteFilename, assets] of apiRoutesWithoutSourcemaps.sort(\n (a, b) => a[0].length - b[0].length\n )) {\n const id = assets.apiRouteId!;\n const hasSourceMap = apiRouteEntries.find(\n ([filename, route]) =>\n filename !== apiRouteFilename &&\n route.apiRouteId === assets.apiRouteId &&\n filename.endsWith('.map')\n );\n Log.log(\n id === '' ? chalk.gray(' (index)') : id,\n sizeStr(assets.contents),\n hasSourceMap ? chalk.gray(`(source map ${sizeStr(hasSourceMap[1].contents)})`) : ''\n );\n }\n }\n\n // Decouple logging from writing for better performance.\n\n await Promise.all(\n [...files.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(async ([file, { contents, targetDomain }]) => {\n // NOTE: Only use `targetDomain` if we have at least one server asset\n const domain = (hasServerOutput && targetDomain) || '';\n const outputPath = path.join(outputDir, domain, file);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.promises.writeFile(outputPath, contents);\n })\n );\n\n Log.log('');\n}\n\nfunction groupBy<T>(array: T[], key: (item: T) => string): Map<string, T[]> {\n const map = new Map<string, T[]>();\n array.forEach((item) => {\n const group = key(item);\n const list = map.get(group) ?? [];\n list.push(item);\n map.set(group, list);\n });\n return map;\n}\n\n// TODO: Move source map modification to the serializer\nexport function getFilesFromSerialAssets(\n resources: SerialAsset[],\n {\n includeSourceMaps,\n files = new Map(),\n platform,\n isServerHosted = platform === 'web',\n }: {\n includeSourceMaps: boolean;\n files?: ExportAssetMap;\n platform?: string;\n isServerHosted?: boolean;\n }\n) {\n resources.forEach((resource) => {\n if (resource.type === 'css-external') {\n return;\n }\n files.set(resource.filename, {\n contents: resource.source,\n originFilename: resource.originFilename,\n targetDomain: isServerHosted ? 'client' : undefined,\n });\n });\n\n return files;\n}\n"],"names":["getFilesFromSerialAssets","persistMetroFilesAsync","BLT","files","outputDir","size","fs","promises","mkdir","path","join","recursive","assetEntries","apiRouteEntries","routeEntries","rscEntries","remainingEntries","hasServerOutput","asset","entries","targetDomain","assetId","push","routeId","apiRouteId","rscId","groups","groupBy","contentSize","contents","length","Buffer","byteLength","sizeStr","chalk","gray","prettyBytes","isExpoRouter","showAdditionalInfo","env","EXPO_DEBUG","assetGroups","sort","a","b","localeCompare","totalAssets","reduce","sum","assets","Log","log","bold","averageContentSize","filter","Boolean","bundles","Map","other","forEach","filepath","match","platform","has","set","get","allAssets","filePath","shift","sourceMapIndex","findIndex","fp","sourceMapFilePath","sourceMapAsset","splice","id","apiRoutesWithoutSourcemaps","route","endsWith","apiRouteFilename","hasSourceMap","find","filename","Promise","all","map","file","domain","outputPath","dirname","writeFile","array","key","item","group","list","resources","includeSourceMaps","isServerHosted","resource","type","source","originFilename","undefined"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAiQeA,wBAAwB;eAAxBA;;IA5MMC,sBAAsB;eAAtBA;;;;gEAnDJ;;;;;;;gEACH;;;;;;;gEAEE;;;;;;;gEACO;;;;;;qBAEJ;qBACA;;;;;;AAEpB,MAAMC,MAAM;AA0CL,eAAeD,uBAAuBE,KAAqB,EAAEC,SAAiB;IACnF,IAAI,CAACD,MAAME,IAAI,EAAE;QACf;IACF;IACA,MAAMC,aAAE,CAACC,QAAQ,CAACC,KAAK,CAACC,eAAI,CAACC,IAAI,CAACN,YAAY;QAAEO,WAAW;IAAK;IAEhE,iBAAiB;IACjB,WAAW;IACX,oBAAoB;IACpB,4FAA4F;IAC5F,MAAM;IACN,KAAK;IAEL,MAAMC,eAAkD,EAAE;IAC1D,MAAMC,kBAAqD,EAAE;IAC7D,MAAMC,eAAkD,EAAE;IAC1D,MAAMC,aAAgD,EAAE;IACxD,MAAMC,mBAAsD,EAAE;IAE9D,IAAIC,kBAAkB;IACtB,KAAK,MAAMC,SAASf,MAAMgB,OAAO,GAAI;QACnCF,kBAAkBA,mBAAmBC,KAAK,CAAC,EAAE,CAACE,YAAY,KAAK;QAC/D,IAAIF,KAAK,CAAC,EAAE,CAACG,OAAO,EAAET,a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E,KAAU,EAAEC,GAAwB;IACtD,MAAMP,MAAM,IAAI5B;IAChBkC,MAAMhC,OAAO,CAAC,CAACkC;QACb,MAAMC,QAAQF,IAAIC;QAClB,MAAME,OAAOV,IAAIpB,GAAG,CAAC6B,UAAU,EAAE;QACjCC,KAAKzE,IAAI,CAACuE;QACVR,IAAIrB,GAAG,CAAC8B,OAAOC;IACjB;IACA,OAAOV;AACT;AAGO,SAASrF,yBACdgG,SAAwB,EACxB,EACEC,iBAAiB,EACjB9F,QAAQ,IAAIsD,KAAK,EACjBK,QAAQ,EACRoC,iBAAiBpC,aAAa,KAAK,EAMpC;IAEDkC,UAAUrC,OAAO,CAAC,CAACwC;QACjB,IAAIA,SAASC,IAAI,KAAK,gBAAgB;YACpC;QACF;QACAjG,MAAM6D,GAAG,CAACmC,SAASjB,QAAQ,EAAE;YAC3BrD,UAAUsE,SAASE,MAAM;YACzBC,gBAAgBH,SAASG,cAAc;YACvClF,cAAc8E,iBAAiB,WAAWK;QAC5C;IACF;IAEA,OAAOpG;AACT"}
1
+ {"version":3,"sources":["../../../src/export/saveAssets.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport type { AssetData } from '@expo/metro/metro';\nimport type { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\nimport prettyBytes from 'pretty-bytes';\n\nimport { Log } from '../log';\nimport { env } from '../utils/env';\n\nconst BLT = '\\u203A';\n\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n bytecode: boolean;\n sourceMapUrl?: string;\n sourcemaps?: boolean;\n};\n\nexport type BundleAssetWithFileHashes = AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\n\nexport type BundleOutput = {\n artifacts: SerialAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nexport type ManifestAsset = { fileHashes: string[]; files: string[]; hash: string };\n\nexport type Asset = ManifestAsset | BundleAssetWithFileHashes;\n\nexport type ExportAssetDescriptor = {\n contents: string | Buffer;\n originFilename?: string;\n /** An identifier for grouping together variations of the same asset. */\n assetId?: string;\n /** Expo Router route path for formatting the HTML output. */\n routeId?: string;\n /** Expo Router route path for formatting the middleware function output. */\n middlewareId?: string;\n /** Expo Router API route path for formatting the server function output. */\n apiRouteId?: string;\n /** Expo Router route path for formatting the RSC output. */\n rscId?: string;\n /** A key for grouping together output files by server- or client-side. */\n targetDomain?: 'server' | 'client';\n};\n\nexport type ExportAssetMap = Map<string, ExportAssetDescriptor>;\n\nexport async function persistMetroFilesAsync(files: ExportAssetMap, outputDir: string) {\n if (!files.size) {\n return;\n }\n await fs.promises.mkdir(path.join(outputDir), { recursive: true });\n\n // Test fixtures:\n // Log.log(\n // JSON.stringify(\n // Object.fromEntries([...files.entries()].map(([k, v]) => [k, { ...v, contents: '' }]))\n // )\n // );\n\n const assetEntries: [string, ExportAssetDescriptor][] = [];\n const apiRouteEntries: [string, ExportAssetDescriptor][] = [];\n const middlewareEntries: [string, ExportAssetDescriptor][] = [];\n const routeEntries: [string, ExportAssetDescriptor][] = [];\n const rscEntries: [string, ExportAssetDescriptor][] = [];\n const remainingEntries: [string, ExportAssetDescriptor][] = [];\n\n let hasServerOutput = false;\n for (const asset of files.entries()) {\n hasServerOutput = hasServerOutput || asset[1].targetDomain === 'server';\n if (asset[1].assetId) assetEntries.push(asset);\n else if (asset[1].routeId != null) routeEntries.push(asset);\n else if (asset[1].middlewareId != null) middlewareEntries.push(asset);\n else if (asset[1].apiRouteId != null) apiRouteEntries.push(asset);\n else if (asset[1].rscId != null) rscEntries.push(asset);\n else remainingEntries.push(asset);\n }\n\n const groups = groupBy(assetEntries, ([, { assetId }]) => assetId!);\n\n const contentSize = (contents: string | Buffer) => {\n const length =\n typeof contents === 'string' ? Buffer.byteLength(contents, 'utf8') : contents.length;\n return length;\n };\n\n const sizeStr = (contents: string | Buffer) => {\n const length = contentSize(contents);\n const size = chalk.gray`(${prettyBytes(length)})`;\n return size;\n };\n\n // TODO: If any Expo Router is used, then use a new style which is more simple:\n // `chalk.gray(/path/to/) + chalk.cyan('route')`\n // | index.html (1.2kb)\n // | /path\n // | other.html (1.2kb)\n\n const isExpoRouter = routeEntries.length;\n\n // Phase out printing all the assets as users can simply check the file system for more info.\n const showAdditionalInfo = !isExpoRouter || env.EXPO_DEBUG;\n\n const assetGroups = [...groups.entries()].sort((a, b) => a[0].localeCompare(b[0])) as [\n string,\n [string, ExportAssetDescriptor][],\n ][];\n\n if (showAdditionalInfo) {\n if (assetGroups.length) {\n const totalAssets = assetGroups.reduce((sum, [, assets]) => sum + assets.length, 0);\n\n Log.log('');\n Log.log(chalk.bold`${BLT} Assets (${totalAssets}):`);\n\n for (const [assetId, assets] of assetGroups) {\n const averageContentSize =\n assets.reduce((sum, [, { contents }]) => sum + contentSize(contents), 0) / assets.length;\n Log.log(\n assetId,\n chalk.gray(\n `(${[\n assets.length > 1 ? `${assets.length} variations` : '',\n `${prettyBytes(averageContentSize)}`,\n ]\n .filter(Boolean)\n .join(' | ')})`\n )\n );\n }\n }\n }\n\n const bundles: Map<string, [string, ExportAssetDescriptor][]> = new Map();\n const other: [string, ExportAssetDescriptor][] = [];\n\n remainingEntries.forEach(([filepath, asset]) => {\n if (!filepath.match(/_expo\\/static\\//)) {\n other.push([filepath, asset]);\n } else {\n const platform = filepath.match(/_expo\\/static\\/js\\/([^/]+)\\//)?.[1] ?? 'web';\n if (!bundles.has(platform)) bundles.set(platform, []);\n\n bundles.get(platform)!.push([filepath, asset]);\n }\n });\n\n [...bundles.entries()].forEach(([platform, assets]) => {\n Log.log('');\n Log.log(chalk.bold`${BLT} ${platform} bundles (${assets.length}):`);\n\n const allAssets = assets.sort((a, b) => a[0].localeCompare(b[0]));\n while (allAssets.length) {\n const [filePath, asset] = allAssets.shift()!;\n Log.log(filePath, sizeStr(asset.contents));\n if (filePath.match(/\\.(js|hbc)$/)) {\n // Get source map\n const sourceMapIndex = allAssets.findIndex(([fp]) => fp === filePath + '.map');\n if (sourceMapIndex !== -1) {\n const [sourceMapFilePath, sourceMapAsset] = allAssets.splice(sourceMapIndex, 1)[0];\n Log.log(chalk.gray(sourceMapFilePath), sizeStr(sourceMapAsset.contents));\n }\n }\n }\n });\n\n if (showAdditionalInfo && other.length) {\n Log.log('');\n Log.log(chalk.bold`${BLT} Files (${other.length}):`);\n\n for (const [filePath, asset] of other.sort((a, b) => a[0].localeCompare(b[0]))) {\n Log.log(filePath, sizeStr(asset.contents));\n }\n }\n\n if (rscEntries.length) {\n Log.log('');\n Log.log(chalk.bold`${BLT} React Server Components (${rscEntries.length}):`);\n\n for (const [filePath, assets] of rscEntries.sort((a, b) => a[0].length - b[0].length)) {\n const id = assets.rscId!;\n Log.log(\n '/' + (id === '' ? chalk.gray(' (index)') : id),\n sizeStr(assets.contents),\n chalk.gray(filePath)\n );\n }\n }\n\n if (routeEntries.length) {\n Log.log('');\n Log.log(chalk.bold`${BLT} Static routes (${routeEntries.length}):`);\n\n for (const [, assets] of routeEntries.sort((a, b) => a[0].length - b[0].length)) {\n const id = assets.routeId!;\n Log.log('/' + (id === '' ? chalk.gray(' (index)') : id), sizeStr(assets.contents));\n }\n }\n\n if (apiRouteEntries.length) {\n const apiRoutesWithoutSourcemaps = apiRouteEntries.filter(\n (route) => !route[0].endsWith('.map')\n );\n Log.log('');\n Log.log(chalk.bold`${BLT} API routes (${apiRoutesWithoutSourcemaps.length}):`);\n\n for (const [apiRouteFilename, assets] of apiRoutesWithoutSourcemaps.sort(\n (a, b) => a[0].length - b[0].length\n )) {\n const id = assets.apiRouteId!;\n const hasSourceMap = apiRouteEntries.find(\n ([filename, route]) =>\n filename !== apiRouteFilename &&\n route.apiRouteId === assets.apiRouteId &&\n filename.endsWith('.map')\n );\n Log.log(\n id === '' ? chalk.gray(' (index)') : id,\n sizeStr(assets.contents),\n hasSourceMap ? chalk.gray(`(source map ${sizeStr(hasSourceMap[1].contents)})`) : ''\n );\n }\n }\n\n if (middlewareEntries.length) {\n const middlewareWithoutSourcemaps = middlewareEntries.filter(\n (route) => !route[0].endsWith('.map')\n );\n Log.log('');\n Log.log(chalk.bold`${BLT} Middleware:`);\n\n for (const [middlewareFilename, assets] of middlewareWithoutSourcemaps.sort(\n (a, b) => a[0].length - b[0].length\n )) {\n const id = assets.middlewareId!;\n const hasSourceMap = middlewareEntries.find(\n ([filename, route]) =>\n filename !== middlewareFilename &&\n route.middlewareId === assets.middlewareId &&\n filename.endsWith('.map')\n );\n Log.log(\n id,\n sizeStr(assets.contents),\n hasSourceMap ? chalk.gray(`(source map ${sizeStr(hasSourceMap[1].contents)})`) : ''\n );\n }\n }\n\n // Decouple logging from writing for better performance.\n\n await Promise.all(\n [...files.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(async ([file, { contents, targetDomain }]) => {\n // NOTE: Only use `targetDomain` if we have at least one server asset\n const domain = (hasServerOutput && targetDomain) || '';\n const outputPath = path.join(outputDir, domain, file);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.promises.writeFile(outputPath, contents);\n })\n );\n\n Log.log('');\n}\n\nfunction groupBy<T>(array: T[], key: (item: T) => string): Map<string, T[]> {\n const map = new Map<string, T[]>();\n array.forEach((item) => {\n const group = key(item);\n const list = map.get(group) ?? [];\n list.push(item);\n map.set(group, list);\n });\n return map;\n}\n\n// TODO: Move source map modification to the serializer\nexport function getFilesFromSerialAssets(\n resources: SerialAsset[],\n {\n includeSourceMaps,\n files = new Map(),\n platform,\n isServerHosted = platform === 'web',\n }: {\n includeSourceMaps: boolean;\n files?: ExportAssetMap;\n platform?: string;\n isServerHosted?: boolean;\n }\n) {\n resources.forEach((resource) => {\n if (resource.type === 'css-external') {\n return;\n }\n files.set(resource.filename, {\n contents: resource.source,\n originFilename: resource.originFilename,\n targetDomain: isServerHosted ? 'client' : undefined,\n });\n });\n\n return files;\n}\n"],"names":["getFilesFromSerialAssets","persistMetroFilesAsync","BLT","files","outputDir","size","fs","promises","mkdir","path","join","recursive","assetEntries","apiRouteEntries","middlewareEntries","routeEntries","rscEntries","remainingEntries","hasServerOutput","asset","entries","targetDomain","assetId","push","routeId","middlewareId","apiRouteId","rscId","groups","groupBy","contentSize","contents","length","Buffer","byteLength","sizeStr","chalk","gray","prettyBytes","isExpoRouter","showAdditionalInfo","env","EXPO_DEBUG","assetGroups","sort","a","b","localeCompare","totalAssets","reduce","sum","assets","Log","log","bold","averageContentSize","filter","Boolean","bundles","Map","other","forEach","filepath","match","platform","has","set","get","allAssets","filePath","shift","sourceMapIndex","findIndex","fp","sourceMapFilePath","sourceMapAsset","splice","id","apiRoutesWithoutSourcemaps","route","endsWith","apiRouteFilename","hasSourceMap","find","filename","middlewareWithoutSourcemaps","middlewareFilename","Promise","all","map","file","domain","outputPath","dirname","writeFile","array","key","item","group","list","resources","includeSourceMaps","isServerHosted","resource","type","source","originFilename","undefined"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IA8ReA,wBAAwB;eAAxBA;;IAvOMC,sBAAsB;eAAtBA;;;;gEApDJ;;;;;;;gEACH;;;;;;;gEACE;;;;;;;gEACO;;;;;;qBAEJ;qBACA;;;;;;AAEpB,MAAMC,MAAM;AA4CL,eAAeD,uBAAuBE,KAAqB,EAAEC,SAAiB;IACnF,IAAI,CAACD,MAAME,IAAI,EAAE;QACf;IACF;IACA,MAAMC,aAAE,CAACC,QAAQ,CAACC,KAAK,CAACC,eAAI,CAACC,IAAI,CAACN,YAAY;QAAEO,WAAW;IAAK;IAEhE,iBAAiB;IACjB,WAAW;IACX,oBAAoB;IACpB,4FAA4F;IAC5F,MAAM;IACN,KAAK;IAEL,MAAMC,eAAkD,EAAE;IAC1D,MAAMC,kBAAqD,EAAE;IAC7D,MAAMC,oBAAuD,EAAE;IAC/D,MAAMC,eAAkD,EAAE;IAC1D,MAAMC,aAAgD,EAAE;IACxD,MAAMC,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QAAQF,IAAIC;QAClB,MAAME,OAAOV,IAAItB,GAAG,CAAC+B,UAAU,EAAE;QACjCC,KAAK5E,IAAI,CAAC0E;QACVR,IAAIvB,GAAG,CAACgC,OAAOC;IACjB;IACA,OAAOV;AACT;AAGO,SAASzF,yBACdoG,SAAwB,EACxB,EACEC,iBAAiB,EACjBlG,QAAQ,IAAIwD,KAAK,EACjBK,QAAQ,EACRsC,iBAAiBtC,aAAa,KAAK,EAMpC;IAEDoC,UAAUvC,OAAO,CAAC,CAAC0C;QACjB,IAAIA,SAASC,IAAI,KAAK,gBAAgB;YACpC;QACF;QACArG,MAAM+D,GAAG,CAACqC,SAASnB,QAAQ,EAAE;YAC3BrD,UAAUwE,SAASE,MAAM;YACzBC,gBAAgBH,SAASG,cAAc;YACvCrF,cAAciF,iBAAiB,WAAWK;QAC5C;IACF;IAEA,OAAOxG;AACT"}
@@ -22,6 +22,13 @@ function _chalk() {
22
22
  };
23
23
  return data;
24
24
  }
25
+ function _resolvefrom() {
26
+ const data = /*#__PURE__*/ _interop_require_default(require("resolve-from"));
27
+ _resolvefrom = function() {
28
+ return data;
29
+ };
30
+ return data;
31
+ }
25
32
  const _fixPackages = require("./fixPackages");
26
33
  const _log = /*#__PURE__*/ _interop_require_wildcard(require("../log"));
27
34
  const _validateDependenciesVersions = require("../start/doctor/dependencies/validateDependenciesVersions");
@@ -94,9 +101,10 @@ async function checkPackagesAsync(projectRoot, { packages, packageManager, optio
94
101
  * For that reason, you cannot use nexpo to test for the sub-dependency check,
95
102
  * and you cannot replace this guard with a try/catch around the import('expo-router')
96
103
  */ if ((_pkg_dependencies = pkg.dependencies) == null ? void 0 : _pkg_dependencies['expo-router']) {
104
+ // TODO(@kitten): This should be removed. None of the checks apply anymore
97
105
  try {
98
106
  const { doctor: routerDoctor } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("expo-router/doctor.js")));
99
- dependencies.push(...routerDoctor(pkg, require.resolve('@react-navigation/native'), {
107
+ dependencies.push(...routerDoctor(pkg, _resolvefrom().default.silent(projectRoot, '@react-navigation/native'), {
100
108
  bold: _chalk().default.bold,
101
109
  learnMore: _link.learnMore
102
110
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/install/checkPackages.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport * as PackageManager from '@expo/package-manager';\nimport chalk from 'chalk';\n\nimport { fixPackagesAsync } from './fixPackages';\nimport { Options } from './resolveOptions';\nimport * as Log from '../log';\nimport {\n getVersionedDependenciesAsync,\n logIncorrectDependencies,\n} from '../start/doctor/dependencies/validateDependenciesVersions';\nimport { isInteractive } from '../utils/interactive';\nimport { learnMore } from '../utils/link';\nimport { confirmAsync } from '../utils/prompts';\nimport { joinWithCommasAnd } from '../utils/strings';\n\nconst debug = require('debug')('expo:install:check') as typeof console.log;\n\n/**\n * Handles `expo install --fix|check'.\n * Checks installed dependencies against bundledNativeModules and versions endpoints to find any incompatibilities.\n * If `--fix` is passed, it will install the correct versions of the dependencies.\n * If `--check` is passed, it will prompt the user to install the correct versions of the dependencies (on interactive terminal).\n */\nexport async function checkPackagesAsync(\n projectRoot: string,\n {\n packages,\n packageManager,\n options: { fix, json },\n packageManagerArguments,\n }: {\n /**\n * List of packages to version\n * @example ['uuid', 'react-native-reanimated@latest']\n */\n packages: string[];\n /** Package manager to use when installing the versioned packages. */\n packageManager: PackageManager.NodePackageManager;\n\n /** How the check should resolve */\n options: Pick<Options, 'fix' | 'json'>;\n /**\n * Extra parameters to pass to the `packageManager` when installing versioned packages.\n * @example ['--no-save']\n */\n packageManagerArguments: string[];\n }\n) {\n // Read the project Expo config without plugins.\n const { exp, pkg } = getConfig(projectRoot, {\n // Sometimes users will add a plugin to the config before installing the library,\n // this wouldn't work unless we dangerously disable plugin serialization.\n skipPlugins: true,\n });\n\n if (pkg.expo?.install?.exclude?.length && !json) {\n Log.log(\n chalk`Skipped ${fix ? 'fixing' : 'checking'} dependencies: ${joinWithCommasAnd(\n pkg.expo.install.exclude\n )}. These dependencies are listed in {bold expo.install.exclude} in package.json. ${learnMore(\n 'https://docs.expo.dev/more/expo-cli/#configuring-dependency-validation'\n )}`\n );\n }\n\n const dependencies = await getVersionedDependenciesAsync(projectRoot, exp, pkg, packages);\n\n /*\n * Expo Router projects will do this additional check\n * Note: The e2e tests use nexpo which will always resolve 'expo-router/doctor.js'\n * For that reason, you cannot use nexpo to test for the sub-dependency check,\n * and you cannot replace this guard with a try/catch around the import('expo-router')\n */\n if (pkg.dependencies?.['expo-router']) {\n try {\n const { doctor: routerDoctor } = await import('expo-router/doctor.js');\n dependencies.push(\n ...routerDoctor(pkg, require.resolve('@react-navigation/native'), {\n bold: chalk.bold,\n learnMore,\n })\n );\n } catch (error) {\n if (!json) {\n Log.log(`Skipped checking expo-router dependencies: expo-router/doctor.js not found.`);\n }\n debug('expo-router/doctor error:', error);\n }\n }\n\n if (!dependencies.length) {\n if (json) {\n console.log(JSON.stringify({ dependencies: [], upToDate: true }));\n } else {\n Log.exit(chalk.greenBright('Dependencies are up to date'), 0);\n }\n return;\n }\n\n if (json) {\n console.log(JSON.stringify({ dependencies, upToDate: false }, null, 2));\n // Exit with non-zero exit code to indicate outdated dependencies\n process.exit(1);\n }\n\n logIncorrectDependencies(dependencies);\n\n const value =\n // If `--fix` then always fix.\n fix ||\n // Otherwise prompt to fix when not running in CI.\n (isInteractive() && (await confirmAsync({ message: 'Fix dependencies?' }).catch(() => false)));\n\n if (value) {\n debug('Installing fixed dependencies:', dependencies);\n // Install the corrected dependencies.\n return fixPackagesAsync(projectRoot, {\n packageManager,\n packages: dependencies,\n packageManagerArguments,\n sdkVersion: exp.sdkVersion!,\n });\n }\n\n // Exit with non-zero exit code if any of the dependencies are out of date.\n Log.exit(chalk.red('Found outdated dependencies'), 1);\n}\n"],"names":["checkPackagesAsync","debug","require","projectRoot","packages","packageManager","options","fix","json","packageManagerArguments","pkg","exp","getConfig","skipPlugins","expo","install","exclude","length","Log","log","chalk","joinWithCommasAnd","learnMore","dependencies","getVersionedDependenciesAsync","doctor","routerDoctor","push","resolve","bold","error","console","JSON","stringify","upToDate","exit","greenBright","process","logIncorrectDependencies","value","isInteractive","confirmAsync","message","catch","fixPackagesAsync","sdkVersion","red"],"mappings":";;;;+BAwBsBA;;;eAAAA;;;;yBAxBI;;;;;;;gEAER;;;;;;6BAEe;6DAEZ;8CAId;6BACuB;sBACJ;yBACG;yBACK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,MAAMC,QAAQC,QAAQ,SAAS;AAQxB,eAAeF,mBACpBG,WAAmB,EACnB,EACEC,QAAQ,EACRC,cAAc,EACdC,SAAS,EAAEC,GAAG,EAAEC,IAAI,EAAE,EACtBC,uBAAuB,EAiBxB;QASGC,2BAAAA,mBAAAA,WAkBAA;IAzBJ,gDAAgD;IAChD,MAAM,EAAEC,GAAG,EAAED,GAAG,EAAE,GAAGE,IAAAA,mBAAS,EAACT,aAAa;QAC1C,iFAAiF;QACjF,yEAAyE;QACzEU,aAAa;IACf;IAEA,IAAIH,EAAAA,YAAAA,IAAII,IAAI,sBAARJ,oBAAAA,UAAUK,OAAO,sBAAjBL,4BAAAA,kBAAmBM,OAAO,qBAA1BN,0BAA4BO,MAAM,KAAI,CAACT,MAAM;QAC/CU,KAAIC,GAAG,CACLC,IAAAA,gBAAK,CAAA,CAAC,QAAQ,EAAEb,MAAM,WAAW,WAAW,eAAe,EAAEc,IAAAA,0BAAiB,EAC5EX,IAAII,IAAI,CAACC,OAAO,CAACC,OAAO,EACxB,gFAAgF,EAAEM,IAAAA,eAAS,EAC3F,0EACA,CAAC;IAEP;IAEA,MAAMC,eAAe,MAAMC,IAAAA,2DAA6B,EAACrB,aAAaQ,KAAKD,KAAKN;IAEhF;;;;;GAKC,GACD,KAAIM,oBAAAA,IAAIa,YAAY,qBAAhBb,iBAAkB,CAAC,cAAc,EAAE;QACrC,IAAI;YACF,MAAM,EAAEe,QAAQC,YAAY,EAAE,GAAG,MAAM,mEAAA,QAAO;YAC9CH,aAAaI,IAAI,IACZD,aAAahB,KAAKR,QAAQ0B,OAAO,CAAC,6BAA6B;gBAChEC,MAAMT,gBAAK,CAACS,IAAI;gBAChBP,WAAAA,eAAS;YACX;QAEJ,EAAE,OAAOQ,OAAO;YACd,IAAI,CAACtB,MAAM;gBACTU,KAAIC,GAAG,CAAC,CAAC,2EAA2E,CAAC;YACvF;YACAlB,MAAM,6BAA6B6B;QACrC;IACF;IAEA,IAAI,CAACP,aAAaN,MAAM,EAAE;QACxB,IAAIT,MAAM;YACRuB,QAAQZ,GAAG,CAACa,KAAKC,SAAS,CAAC;gBAAEV,cAAc,EAAE;gBAAEW,UAAU;YAAK;QAChE,OAAO;YACLhB,KAAIiB,IAAI,CAACf,gBAAK,CAACgB,WAAW,CAAC,gCAAgC;QAC7D;QACA;IACF;IAEA,IAAI5B,MAAM;QACRuB,QAAQZ,GAAG,CAACa,KAAKC,SAAS,CAAC;YAAEV;YAAcW,UAAU;QAAM,GAAG,MAAM;QACpE,iEAAiE;QACjEG,QAAQF,IAAI,CAAC;IACf;IAEAG,IAAAA,sDAAwB,EAACf;IAEzB,MAAMgB,QACJ,8BAA8B;IAC9BhC,OACA,kDAAkD;IACjDiC,IAAAA,0BAAa,OAAO,MAAMC,IAAAA,qBAAY,EAAC;QAAEC,SAAS;IAAoB,GAAGC,KAAK,CAAC,IAAM;IAExF,IAAIJ,OAAO;QACTtC,MAAM,kCAAkCsB;QACxC,sCAAsC;QACtC,OAAOqB,IAAAA,6BAAgB,EAACzC,aAAa;YACnCE;YACAD,UAAUmB;YACVd;YACAoC,YAAYlC,IAAIkC,UAAU;QAC5B;IACF;IAEA,2EAA2E;IAC3E3B,KAAIiB,IAAI,CAACf,gBAAK,CAAC0B,GAAG,CAAC,gCAAgC;AACrD"}
1
+ {"version":3,"sources":["../../../src/install/checkPackages.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport * as PackageManager from '@expo/package-manager';\nimport chalk from 'chalk';\nimport resolveFrom from 'resolve-from';\n\nimport { fixPackagesAsync } from './fixPackages';\nimport { Options } from './resolveOptions';\nimport * as Log from '../log';\nimport {\n getVersionedDependenciesAsync,\n logIncorrectDependencies,\n} from '../start/doctor/dependencies/validateDependenciesVersions';\nimport { isInteractive } from '../utils/interactive';\nimport { learnMore } from '../utils/link';\nimport { confirmAsync } from '../utils/prompts';\nimport { joinWithCommasAnd } from '../utils/strings';\n\nconst debug = require('debug')('expo:install:check') as typeof console.log;\n\n/**\n * Handles `expo install --fix|check'.\n * Checks installed dependencies against bundledNativeModules and versions endpoints to find any incompatibilities.\n * If `--fix` is passed, it will install the correct versions of the dependencies.\n * If `--check` is passed, it will prompt the user to install the correct versions of the dependencies (on interactive terminal).\n */\nexport async function checkPackagesAsync(\n projectRoot: string,\n {\n packages,\n packageManager,\n options: { fix, json },\n packageManagerArguments,\n }: {\n /**\n * List of packages to version\n * @example ['uuid', 'react-native-reanimated@latest']\n */\n packages: string[];\n /** Package manager to use when installing the versioned packages. */\n packageManager: PackageManager.NodePackageManager;\n\n /** How the check should resolve */\n options: Pick<Options, 'fix' | 'json'>;\n /**\n * Extra parameters to pass to the `packageManager` when installing versioned packages.\n * @example ['--no-save']\n */\n packageManagerArguments: string[];\n }\n) {\n // Read the project Expo config without plugins.\n const { exp, pkg } = getConfig(projectRoot, {\n // Sometimes users will add a plugin to the config before installing the library,\n // this wouldn't work unless we dangerously disable plugin serialization.\n skipPlugins: true,\n });\n\n if (pkg.expo?.install?.exclude?.length && !json) {\n Log.log(\n chalk`Skipped ${fix ? 'fixing' : 'checking'} dependencies: ${joinWithCommasAnd(\n pkg.expo.install.exclude\n )}. These dependencies are listed in {bold expo.install.exclude} in package.json. ${learnMore(\n 'https://docs.expo.dev/more/expo-cli/#configuring-dependency-validation'\n )}`\n );\n }\n\n const dependencies = await getVersionedDependenciesAsync(projectRoot, exp, pkg, packages);\n\n /*\n * Expo Router projects will do this additional check\n * Note: The e2e tests use nexpo which will always resolve 'expo-router/doctor.js'\n * For that reason, you cannot use nexpo to test for the sub-dependency check,\n * and you cannot replace this guard with a try/catch around the import('expo-router')\n */\n if (pkg.dependencies?.['expo-router']) {\n // TODO(@kitten): This should be removed. None of the checks apply anymore\n try {\n const { doctor: routerDoctor } = await import('expo-router/doctor.js');\n dependencies.push(\n ...routerDoctor(pkg, resolveFrom.silent(projectRoot, '@react-navigation/native'), {\n bold: chalk.bold,\n learnMore,\n })\n );\n } catch (error) {\n if (!json) {\n Log.log(`Skipped checking expo-router dependencies: expo-router/doctor.js not found.`);\n }\n debug('expo-router/doctor error:', error);\n }\n }\n\n if (!dependencies.length) {\n if (json) {\n console.log(JSON.stringify({ dependencies: [], upToDate: true }));\n } else {\n Log.exit(chalk.greenBright('Dependencies are up to date'), 0);\n }\n return;\n }\n\n if (json) {\n console.log(JSON.stringify({ dependencies, upToDate: false }, null, 2));\n // Exit with non-zero exit code to indicate outdated dependencies\n process.exit(1);\n }\n\n logIncorrectDependencies(dependencies);\n\n const value =\n // If `--fix` then always fix.\n fix ||\n // Otherwise prompt to fix when not running in CI.\n (isInteractive() && (await confirmAsync({ message: 'Fix dependencies?' }).catch(() => false)));\n\n if (value) {\n debug('Installing fixed dependencies:', dependencies);\n // Install the corrected dependencies.\n return fixPackagesAsync(projectRoot, {\n packageManager,\n packages: dependencies,\n packageManagerArguments,\n sdkVersion: exp.sdkVersion!,\n });\n }\n\n // Exit with non-zero exit code if any of the dependencies are out of date.\n Log.exit(chalk.red('Found outdated dependencies'), 1);\n}\n"],"names":["checkPackagesAsync","debug","require","projectRoot","packages","packageManager","options","fix","json","packageManagerArguments","pkg","exp","getConfig","skipPlugins","expo","install","exclude","length","Log","log","chalk","joinWithCommasAnd","learnMore","dependencies","getVersionedDependenciesAsync","doctor","routerDoctor","push","resolveFrom","silent","bold","error","console","JSON","stringify","upToDate","exit","greenBright","process","logIncorrectDependencies","value","isInteractive","confirmAsync","message","catch","fixPackagesAsync","sdkVersion","red"],"mappings":";;;;+BAyBsBA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;gBAChBR,WAAAA,eAAS;YACX;QAEJ,EAAE,OAAOS,OAAO;YACd,IAAI,CAACvB,MAAM;gBACTU,KAAIC,GAAG,CAAC,CAAC,2EAA2E,CAAC;YACvF;YACAlB,MAAM,6BAA6B8B;QACrC;IACF;IAEA,IAAI,CAACR,aAAaN,MAAM,EAAE;QACxB,IAAIT,MAAM;YACRwB,QAAQb,GAAG,CAACc,KAAKC,SAAS,CAAC;gBAAEX,cAAc,EAAE;gBAAEY,UAAU;YAAK;QAChE,OAAO;YACLjB,KAAIkB,IAAI,CAAChB,gBAAK,CAACiB,WAAW,CAAC,gCAAgC;QAC7D;QACA;IACF;IAEA,IAAI7B,MAAM;QACRwB,QAAQb,GAAG,CAACc,KAAKC,SAAS,CAAC;YAAEX;YAAcY,UAAU;QAAM,GAAG,MAAM;QACpE,iEAAiE;QACjEG,QAAQF,IAAI,CAAC;IACf;IAEAG,IAAAA,sDAAwB,EAAChB;IAEzB,MAAMiB,QACJ,8BAA8B;IAC9BjC,OACA,kDAAkD;IACjDkC,IAAAA,0BAAa,OAAO,MAAMC,IAAAA,qBAAY,EAAC;QAAEC,SAAS;IAAoB,GAAGC,KAAK,CAAC,IAAM;IAExF,IAAIJ,OAAO;QACTvC,MAAM,kCAAkCsB;QACxC,sCAAsC;QACtC,OAAOsB,IAAAA,6BAAgB,EAAC1C,aAAa;YACnCE;YACAD,UAAUmB;YACVd;YACAqC,YAAYnC,IAAImC,UAAU;QAC5B;IACF;IAEA,2EAA2E;IAC3E5B,KAAIkB,IAAI,CAAChB,gBAAK,CAAC2B,GAAG,CAAC,gCAAgC;AACrD"}
@@ -103,6 +103,8 @@ const lintAsync = async (inputs, options, eslintArguments = [])=>{
103
103
  if (!await prerequisite.assertAsync()) {
104
104
  await prerequisite.bootstrapAsync();
105
105
  }
106
+ // TODO(@kitten): The direct require is fine, since we assume `expo > @expo/cli` does not depend on eslint
107
+ // However, it'd be safer to replace this with resolve-from, or another way of requiring via the project root
106
108
  const { loadESLint } = require('eslint');
107
109
  const mod = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("eslint")));
108
110
  let ESLint;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lint/lintAsync.ts"],"sourcesContent":["import { createForProject } from '@expo/package-manager';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport semver from 'semver';\n\nimport { ESLintProjectPrerequisite } from './ESlintPrerequisite';\nimport type { Options } from './resolveOptions';\nimport { CommandError } from '../utils/errors';\nimport { findUpProjectRootOrAssert } from '../utils/findUp';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\nconst debug = require('debug')('expo:lint');\n\nconst DEFAULT_INPUTS = ['src', 'app', 'components'];\n\nexport const lintAsync = async (\n inputs: string[],\n options: Options & { projectRoot?: string },\n eslintArguments: string[] = []\n) => {\n setNodeEnv('development');\n // Locate the project root based on the process current working directory.\n // This enables users to run `npx expo install` from a subdirectory of the project.\n const projectRoot = options?.projectRoot ?? findUpProjectRootOrAssert(process.cwd());\n require('@expo/env').load(projectRoot);\n\n // TODO: Perhaps we should assert that TypeScript is required.\n\n const prerequisite = new ESLintProjectPrerequisite(projectRoot);\n if (!(await prerequisite.assertAsync())) {\n await prerequisite.bootstrapAsync();\n }\n\n const { loadESLint } = require('eslint');\n\n const mod = await import('eslint');\n\n let ESLint: typeof import('eslint').ESLint;\n // loadESLint is >= 8.57.0 (https://github.com/eslint/eslint/releases/tag/v8.57.0) https://github.com/eslint/eslint/pull/18098\n if ('loadESLint' in mod) {\n ESLint = await loadESLint({ cwd: options.projectRoot });\n } else {\n throw new CommandError(\n 'npx expo lint requires ESLint version 8.57.0 or greater. Upgrade eslint or use npx eslint directly.'\n );\n }\n\n const version = ESLint?.version;\n\n if (!version || semver.lt(version, '8.57.0')) {\n throw new CommandError(\n 'npx expo lint requires ESLint version 8.57.0 or greater. Upgrade eslint or use npx eslint directly.'\n );\n }\n\n if (!inputs.length) {\n DEFAULT_INPUTS.map((input) => {\n const abs = path.join(projectRoot, input);\n if (fs.existsSync(abs)) {\n inputs.push(abs);\n }\n });\n }\n\n const eslintArgs: string[] = [];\n inputs.forEach((input) => {\n eslintArgs.push(input);\n });\n options.ext.forEach((ext) => {\n eslintArgs.push('--ext', ext);\n });\n\n eslintArgs.push(`--fix=${options.fix}`);\n eslintArgs.push(`--cache=${options.cache}`);\n\n if (options.config) {\n eslintArgs.push(`--config`, options.config);\n }\n if (!options.ignore) {\n eslintArgs.push('--no-ignore');\n }\n options.ignorePattern.forEach((pattern) => {\n eslintArgs.push(`--ignore-pattern=${pattern}`);\n });\n\n eslintArgs.push(...options.fixType.map((type) => `--fix-type=${type}`));\n\n if (options.quiet) {\n eslintArgs.push('--quiet');\n }\n\n if (options.maxWarnings != null && options.maxWarnings >= 0) {\n eslintArgs.push(`--max-warnings=${options.maxWarnings.toString()}`);\n }\n\n const cacheDir = path.join(projectRoot, '.expo', 'cache', 'eslint/');\n // Add other defaults\n eslintArgs.push(`--cache-location=${cacheDir}`);\n\n // Add passthrough arguments\n eslintArguments.forEach((arg) => {\n eslintArgs.push(arg);\n });\n\n debug('Running ESLint with args: %O', eslintArgs);\n\n const manager = createForProject(projectRoot, { silent: true });\n\n try {\n // TODO: Custom logger\n // - Use relative paths\n // - When react-hooks/exhaustive-deps is hit, notify about enabling React Compiler.\n // - Green check when no issues are found.\n await manager.runBinAsync(['eslint', ...eslintArgs], {\n stdio: 'inherit',\n });\n } catch (error: any) {\n process.exit(error.status);\n }\n};\n"],"names":["lintAsync","debug","require","DEFAULT_INPUTS","inputs","options","eslintArguments","setNodeEnv","projectRoot","findUpProjectRootOrAssert","process","cwd","load","prerequisite","ESLintProjectPrerequisite","assertAsync","bootstrapAsync","loadESLint","mod","ESLint","CommandError","version","semver","lt","length","map","input","abs","path","join","fs","existsSync","push","eslintArgs","forEach","ext","fix","cache","config","ignore","ignorePattern","pattern","fixType","type","quiet","maxWarnings","toString","cacheDir","arg","manager","createForProject","silent","runBinAsync","stdio","error","exit","status"],"mappings":";;;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a;QAAE2C,QAAQ;IAAK;IAE7D,IAAI;QACF,sBAAsB;QACtB,uBAAuB;QACvB,mFAAmF;QACnF,0CAA0C;QAC1C,MAAMF,QAAQG,WAAW,CAAC;YAAC;eAAanB;SAAW,EAAE;YACnDoB,OAAO;QACT;IACF,EAAE,OAAOC,OAAY;QACnB5C,QAAQ6C,IAAI,CAACD,MAAME,MAAM;IAC3B;AACF"}
1
+ {"version":3,"sources":["../../../src/lint/lintAsync.ts"],"sourcesContent":["import { createForProject } from '@expo/package-manager';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport semver from 'semver';\n\nimport { ESLintProjectPrerequisite } from './ESlintPrerequisite';\nimport type { Options } from './resolveOptions';\nimport { CommandError } from '../utils/errors';\nimport { findUpProjectRootOrAssert } from '../utils/findUp';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\nconst debug = require('debug')('expo:lint');\n\nconst DEFAULT_INPUTS = ['src', 'app', 'components'];\n\nexport const lintAsync = async (\n inputs: string[],\n options: Options & { projectRoot?: string },\n eslintArguments: string[] = []\n) => {\n setNodeEnv('development');\n // Locate the project root based on the process current working directory.\n // This enables users to run `npx expo install` from a subdirectory of the project.\n const projectRoot = options?.projectRoot ?? findUpProjectRootOrAssert(process.cwd());\n require('@expo/env').load(projectRoot);\n\n // TODO: Perhaps we should assert that TypeScript is required.\n\n const prerequisite = new ESLintProjectPrerequisite(projectRoot);\n if (!(await prerequisite.assertAsync())) {\n await prerequisite.bootstrapAsync();\n }\n\n // TODO(@kitten): The direct require is fine, since we assume `expo > @expo/cli` does not depend on eslint\n // However, it'd be safer to replace this with resolve-from, or another way of requiring via the project root\n const { loadESLint } = require('eslint');\n\n const mod = await import('eslint');\n\n let ESLint: typeof import('eslint').ESLint;\n // loadESLint is >= 8.57.0 (https://github.com/eslint/eslint/releases/tag/v8.57.0) https://github.com/eslint/eslint/pull/18098\n if ('loadESLint' in mod) {\n ESLint = await loadESLint({ cwd: options.projectRoot });\n } else {\n throw new CommandError(\n 'npx expo lint requires ESLint version 8.57.0 or greater. Upgrade eslint or use npx eslint directly.'\n );\n }\n\n const version = ESLint?.version;\n\n if (!version || semver.lt(version, '8.57.0')) {\n throw new CommandError(\n 'npx expo lint requires ESLint version 8.57.0 or greater. Upgrade eslint or use npx eslint directly.'\n );\n }\n\n if (!inputs.length) {\n DEFAULT_INPUTS.map((input) => {\n const abs = path.join(projectRoot, input);\n if (fs.existsSync(abs)) {\n inputs.push(abs);\n }\n });\n }\n\n const eslintArgs: string[] = [];\n inputs.forEach((input) => {\n eslintArgs.push(input);\n });\n options.ext.forEach((ext) => {\n eslintArgs.push('--ext', ext);\n });\n\n eslintArgs.push(`--fix=${options.fix}`);\n eslintArgs.push(`--cache=${options.cache}`);\n\n if (options.config) {\n eslintArgs.push(`--config`, options.config);\n }\n if (!options.ignore) {\n eslintArgs.push('--no-ignore');\n }\n options.ignorePattern.forEach((pattern) => {\n eslintArgs.push(`--ignore-pattern=${pattern}`);\n });\n\n eslintArgs.push(...options.fixType.map((type) => `--fix-type=${type}`));\n\n if (options.quiet) {\n eslintArgs.push('--quiet');\n }\n\n if (options.maxWarnings != null && options.maxWarnings >= 0) {\n eslintArgs.push(`--max-warnings=${options.maxWarnings.toString()}`);\n }\n\n const cacheDir = path.join(projectRoot, '.expo', 'cache', 'eslint/');\n // Add other defaults\n eslintArgs.push(`--cache-location=${cacheDir}`);\n\n // Add passthrough arguments\n eslintArguments.forEach((arg) => {\n eslintArgs.push(arg);\n });\n\n debug('Running ESLint with args: %O', eslintArgs);\n\n const manager = createForProject(projectRoot, { silent: true });\n\n try {\n // TODO: Custom logger\n // - Use relative paths\n // - When react-hooks/exhaustive-deps is hit, notify about enabling React Compiler.\n // - Green check when no issues are found.\n await manager.runBinAsync(['eslint', ...eslintArgs], {\n stdio: 'inherit',\n });\n } catch (error: any) {\n process.exit(error.status);\n }\n};\n"],"names":["lintAsync","debug","require","DEFAULT_INPUTS","inputs","options","eslintArguments","setNodeEnv","projectRoot","findUpProjectRootOrAssert","process","cwd","load","prerequisite","ESLintProjectPrerequisite","assertAsync","bootstrapAsync","loadESLint","mod","ESLint","CommandError","version","semver","lt","length","map","input","abs","path","join","fs","existsSync","push","eslintArgs","forEach","ext","fix","cache","config","ignore","ignorePattern","pattern","fixType","type","quiet","maxWarnings","toString","cacheDir","arg","manager","createForProject","silent","runBinAsync","stdio","error","exit","status"],"mappings":";;;;+BAeaA;;;eAAAA;;;;yBAfoB;;;;;;;gEAClB;;;;;;;gEACE;;;;;;;gEACE;;;;;;oCAEuB;wBAEb;wBACa;yBACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3B,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,iBAAiB;IAAC;IAAO;IAAO;CAAa;AAE5C,MAAMH,YAAY,OACvBI,QACAC,SACAC,kBAA4B,EAAE;IAE9BC,IAAAA,mBAAU,EAAC;IACX,0EAA0E;IAC1E,mFAAmF;IACnF,MAAMC,cAAcH,CAAAA,2BAAAA,QAASG,WAAW,KAAIC,IAAAA,iCAAyB,EAACC,QAAQC,GAAG;IACjFT,QAAQ,aAAaU,IAAI,CAACJ;IAE1B,8DAA8D;IAE9D,MAAMK,eAAe,IAAIC,6CAAyB,CAACN;IACnD,IAAI,CAAE,MAAMK,aAAaE,WAAW,IAAK;QACvC,MAAMF,aAAaG,cAAc;IACnC;IAEA,0GAA0G;IAC1G,6GAA6G;IAC7G,MAAM,EAAEC,UAAU,EAAE,GAAGf,QAAQ;IAE/B,MAAMgB,MAAM,MAAM,mEAAA,QAAO;IAEzB,IAAIC;IACJ,8HAA8H;IAC9H,IAAI,gBAAgBD,KAAK;QACvBC,SAAS,MAAMF,WAAW;YAAEN,KAAKN,QAAQG,WAAW;QAAC;IACvD,OAAO;QACL,MAAM,IAAIY,oBAAY,CACpB;IAEJ;IAEA,MAAMC,UAAUF,0BAAAA,OAAQE,OAAO;IAE/B,IAAI,CAACA,WAAWC,iBAAM,CAACC,EAAE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