@expo/cli 55.0.0-canary-20260114-d8e19f5 → 55.0.0-canary-20260119-70f7c28

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 (28) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/src/export/embed/exportEmbedAsync.js +1 -2
  3. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  4. package/build/src/export/exportStaticAsync.js +8 -7
  5. package/build/src/export/exportStaticAsync.js.map +1 -1
  6. package/build/src/start/server/Bonjour.js +100 -0
  7. package/build/src/start/server/Bonjour.js.map +1 -0
  8. package/build/src/start/server/BundlerDevServer.js +22 -4
  9. package/build/src/start/server/BundlerDevServer.js.map +1 -1
  10. package/build/src/start/server/metro/DevToolsPluginWebsocketEndpoint.js +10 -2
  11. package/build/src/start/server/metro/DevToolsPluginWebsocketEndpoint.js.map +1 -1
  12. package/build/src/start/server/metro/MetroBundlerDevServer.js +32 -26
  13. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  14. package/build/src/start/server/metro/createServerRouteMiddleware.js +25 -1
  15. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  16. package/build/src/start/server/metro/debugging/createDebugMiddleware.js +22 -8
  17. package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -1
  18. package/build/src/start/server/metro/instantiateMetro.js +17 -6
  19. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  20. package/build/src/utils/env.js +14 -0
  21. package/build/src/utils/env.js.map +1 -1
  22. package/build/src/utils/net.js +43 -0
  23. package/build/src/utils/net.js.map +1 -0
  24. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  25. package/build/src/utils/telemetry/utils/context.js +1 -1
  26. package/package.json +19 -18
  27. package/build/src/start/server/middleware/DataLoaderModuleMiddleware.js +0 -75
  28. package/build/src/start/server/middleware/DataLoaderModuleMiddleware.js.map +0 -1
package/build/bin/cli CHANGED
@@ -123,7 +123,7 @@ const args = (0, _arg().default)({
123
123
  });
124
124
  if (args['--version']) {
125
125
  // Version is added in the build script.
126
- console.log("55.0.0-canary-20260114-d8e19f5");
126
+ console.log("55.0.0-canary-20260119-70f7c28");
127
127
  process.exit(0);
128
128
  }
129
129
  if (args['--non-interactive']) {
@@ -363,8 +363,7 @@ async function createMetroServerAndBundleRequestAsync(projectRoot, options) {
363
363
  const { config } = await (0, _instantiateMetro.loadMetroConfigAsync)(projectRoot, {
364
364
  // TODO: This is always enabled in the native script and there's no way to disable it.
365
365
  resetCache: options.resetCache,
366
- maxWorkers: options.maxWorkers,
367
- config: options.config
366
+ maxWorkers: options.maxWorkers
368
367
  }, {
369
368
  exp,
370
369
  isExporting: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.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 { getConfig } from '@expo/config';\nimport Server from '@expo/metro/metro/Server';\nimport splitBundleOptions from '@expo/metro/metro/lib/splitBundleOptions';\nimport * as output from '@expo/metro/metro/shared/output/bundle';\nimport type { BundleOptions } from '@expo/metro/metro/shared/types';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\nimport { deserializeEagerKey, getExportEmbedOptionsKey, Options } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { DOM_COMPONENTS_BUNDLE_DIR } from '../../start/server/middleware/DomComponentsMiddleware';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { copyAsync, removeAsync } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { exportDomComponentAsync } from '../exportDomComponents';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\nimport { copyPublicFolderAsync } from '../publicFolder';\nimport { BundleAssetWithFileHashes, ExportAssetMap, persistMetroFilesAsync } from '../saveAssets';\nimport { exportStandaloneServerAsync } from './exportServer';\nimport { ensureProcessExitsAfterDelay } from '../../utils/exit';\nimport { resolveRealEntryFilePath } from '../../utils/filePath';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (\n !bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//) &&\n !bundleOutput.match(/\\/CoreSimulator\\/Devices\\/.*\\/data\\/Containers\\/Bundle\\/Application\\//)\n ) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(`*.app/${bundleName}`, {\n cwd: bundleParent,\n absolute: true,\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n // The React Native build scripts always enable the cache reset but we shouldn't need this in CI environments.\n // By disabling it, we can eagerly bundle code before the build and reuse the cached artifacts in subsequent builds.\n if (env.CI && options.resetCache) {\n debug('CI environment detected, disabling automatic cache reset');\n options.resetCache = false;\n }\n\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n // This is an optimized codepath that can occur during `npx expo run` and does not occur during builds from Xcode or Android Studio.\n // Here we reconcile a bundle pass that was run before the native build process. This order can fail faster and is show better errors since the logs won't be obscured by Xcode and Android Studio.\n // This path is also used for automatically deploying server bundles to a remote host.\n const eagerBundleOptions = env.__EXPO_EAGER_BUNDLE_OPTIONS\n ? deserializeEagerKey(env.__EXPO_EAGER_BUNDLE_OPTIONS)\n : null;\n if (eagerBundleOptions) {\n // Get the cache key for the current process to compare against the eager key.\n const inputKey = getExportEmbedOptionsKey(options);\n\n // If the app was bundled previously in the same process, then we should reuse the Metro cache.\n options.resetCache = false;\n\n if (eagerBundleOptions.key === inputKey) {\n // Copy the eager bundleOutput and assets to the new locations.\n await removeAsync(options.bundleOutput);\n\n copyAsync(eagerBundleOptions.options.bundleOutput, options.bundleOutput);\n\n if (eagerBundleOptions.options.assetsDest && options.assetsDest) {\n copyAsync(eagerBundleOptions.options.assetsDest, options.assetsDest);\n }\n\n console.log('info: Copied output to binary:', options.bundleOutput);\n return;\n }\n // TODO: sourcemapOutput is set on Android but not during eager. This is tolerable since it doesn't invalidate the Metro cache.\n console.log(' Eager key:', eagerBundleOptions.key);\n console.log('Request key:', inputKey);\n\n // TODO: We may want an analytic event here in the future to understand when this happens.\n console.warn('warning: Eager bundle does not match new options, bundling again.');\n }\n\n await exportEmbedInternalAsync(projectRoot, options);\n\n // Ensure the process closes after bundling\n ensureProcessExitsAfterDelay();\n}\n\nexport async function exportEmbedInternalAsync(projectRoot: string, options: Options) {\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets, files } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // On Android, dom components proxy files should write to the assets directory instead of the res directory.\n // We use the bundleOutput directory to get the assets directory.\n const domComponentProxyOutputDir =\n options.platform === 'android' ? path.dirname(options.bundleOutput) : options.assetsDest;\n const hasDomComponents = domComponentProxyOutputDir && files.size > 0;\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n\n // Write dom components proxy files.\n hasDomComponents ? persistMetroFilesAsync(files, domComponentProxyOutputDir) : null,\n // Copy public folder for dom components only if\n hasDomComponents\n ? copyPublicFolderAsync(\n path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER),\n path.join(domComponentProxyOutputDir, DOM_COMPONENTS_BUNDLE_DIR)\n )\n : null,\n\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(projectRoot, assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: readonly BundleAssetWithFileHashes[];\n files: ExportAssetMap;\n}> {\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: options.resetCache,\n maxWorkers: options.maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const { exp, pkg } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const files: ExportAssetMap = new Map();\n\n try {\n const bundles = await devServer.nativeExportBundleAsync(\n exp,\n {\n // TODO: Re-enable when we get bytecode chunk splitting working again.\n splitChunks: false, //devServer.isReactServerComponentsEnabled,\n mainModuleName: resolveRealEntryFilePath(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: !!sourceMapUrl,\n bytecode: options.bytecode ?? false,\n // source map inline\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n files,\n {\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n }\n );\n\n const apiRoutesEnabled =\n devServer.isReactServerComponentsEnabled || exp.web?.output === 'server';\n\n if (apiRoutesEnabled) {\n await exportStandaloneServerAsync(projectRoot, devServer, {\n exp,\n pkg,\n files,\n options,\n });\n }\n\n // TODO: Remove duplicates...\n const expoDomComponentReferences = bundles.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat();\n if (expoDomComponentReferences.length > 0) {\n await Promise.all(\n // TODO: Make a version of this which uses `this.metro.getBundler().buildGraphForEntries([])` to bundle all the DOM components at once.\n expoDomComponentReferences.map(async (filePath) => {\n const { bundle } = await exportDomComponentAsync({\n filePath,\n projectRoot,\n dev: options.dev,\n devServer,\n isHermes,\n includeSourceMaps: !!sourceMapUrl,\n exp,\n files,\n });\n\n if (options.assetsDest) {\n // Save assets like a typical bundler, preserving the file paths on web.\n // This is saving web-style inside of a native app's binary.\n await persistMetroAssetsAsync(\n projectRoot,\n bundle.assets.map((asset) => ({\n ...asset,\n httpServerLocation: path.join(DOM_COMPONENTS_BUNDLE_DIR, asset.httpServerLocation),\n })),\n {\n files,\n platform: 'web',\n outputDirectory: options.assetsDest,\n }\n );\n }\n })\n );\n }\n\n return {\n files,\n bundle: {\n code: bundles.artifacts.filter((a: any) => a.type === 'js')[0].source,\n // Can be optional when source maps aren't enabled.\n map: bundles.artifacts.filter((a: any) => a.type === 'map')[0]?.source.toString(),\n },\n assets: bundles.assets,\n };\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n } finally {\n devServerManager.stopAsync();\n }\n}\n\n// Exports for expo-updates\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'resetCache'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n // TODO: This is always enabled in the native script and there's no way to disable it.\n resetCache: options.resetCache,\n\n maxWorkers: options.maxWorkers,\n config: options.config,\n },\n {\n exp,\n isExporting: true,\n getMetroBundler() {\n return server.getBundler().getBundler();\n },\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const directBundleOptions = getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n splitChunks: false,\n mainModuleName: resolveRealEntryFilePath(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n hosted: false,\n });\n\n // TODO(cedric): check if we can use the proper `bundleType=bundle` and `entryPoint=mainModuleName` properties\n const bundleRequest: BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...directBundleOptions,\n\n // NOTE(@kitten): Cast non-optional defaults\n lazy: directBundleOptions.lazy ?? Server.DEFAULT_BUNDLE_OPTIONS.lazy,\n modulesOnly: directBundleOptions.modulesOnly ?? Server.DEFAULT_BUNDLE_OPTIONS.modulesOnly,\n runModule: directBundleOptions.runModule ?? Server.DEFAULT_BUNDLE_OPTIONS.runModule,\n\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const server = new Server(config, {\n watch: false,\n });\n\n return { server, bundleRequest };\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions({\n ...bundleRequest,\n // @ts-ignore-error TODO(@kitten): Very unclear why this is here. Remove?\n bundleType: 'todo',\n });\n\n const dependencies = await server._bundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n const config = server._config;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n // Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n // behavior.\n projectRoot: config.projectRoot, // this._getServerRootDir(),\n publicPath: config.transformer.publicPath,\n isHosted: false,\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n"],"names":["createMetroServerAndBundleRequestAsync","exportEmbedAssetsAsync","exportEmbedAsync","exportEmbedBundleAndAssetsAsync","exportEmbedInternalAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","cwd","absolute","dot","projectRoot","options","env","CI","resetCache","setNodeEnv","dev","load","eagerBundleOptions","__EXPO_EAGER_BUNDLE_OPTIONS","deserializeEagerKey","inputKey","getExportEmbedOptionsKey","key","removeAsync","copyAsync","assetsDest","console","log","warn","ensureProcessExitsAfterDelay","platform","previousPath","fs","existsSync","bundle","assets","files","mkdirSync","recursive","mode","domComponentProxyOutputDir","hasDomComponents","size","Promise","all","output","save","Log","persistMetroFilesAsync","copyPublicFolderAsync","resolve","EXPO_PUBLIC_FOLDER","join","DOM_COMPONENTS_BUNDLE_DIR","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","devServerManager","DevServerManager","startMetroAsync","minify","port","isExporting","location","resetDevServer","maxWorkers","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","exp","pkg","getConfig","skipSDKVersionRequirement","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","Map","bundles","nativeExportBundleAsync","splitChunks","mainModuleName","resolveRealEntryFilePath","entryFile","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","unstable_transformProfile","unstableTransformProfile","apiRoutesEnabled","isReactServerComponentsEnabled","web","exportStandaloneServerAsync","expoDomComponentReferences","artifacts","map","artifact","Array","isArray","metadata","flat","length","filePath","exportDomComponentAsync","includeSourceMaps","asset","httpServerLocation","code","filter","a","type","source","toString","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","stopAsync","config","loadMetroConfigAsync","getMetroBundler","server","getBundler","directBundleOptions","getMetroDirectBundleOptionsForExpoConfig","hosted","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","lazy","modulesOnly","runModule","watch","onProgress","resolverOptions","transformOptions","splitBundleOptions","bundleType","dependencies","_bundler","getDependencies","shallow","_config","getMetroAssets","processModuleFilter","serializer","assetPlugins","transformer","publicPath","isHosted","Error"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAuSqBA,sCAAsC;eAAtCA;;IA+EAC,sBAAsB;eAAtBA;;IA9TAC,gBAAgB;eAAhBA;;IAqGAC,+BAA+B;eAA/BA;;IAlDAC,wBAAwB;eAAxBA;;;;yBA1GI;;;;;;;gEACP;;;;;;;gEACY;;;;;;;iEACP;;;;;;;gEAEG;;;;;;;gEACR;;;;;;;gEACJ;;;;;;;yBACkB;;;;;;;gEAChB;;;;;;gCAEsD;qCACP;qBAC5C;kCACa;uCACK;kCACD;yCACK;8BACe;sBAC/B;qBACa;qBACnB;yBACO;qCACa;8BACF;oCACE;8BACF;4BAC4C;8BACtC;sBACC;0BACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,SAASC,2BAA2BC,YAAoB;IACtD,+CAA+C;IAC/C,IACE,CAACA,aAAaC,KAAK,CAAC,kDACpB,CAACD,aAAaC,KAAK,CAAC,0EACpB;QACAJ,MAAM,sCAAsCG;QAC5C,OAAO;IACT;IACA,MAAME,aAAaC,eAAI,CAACC,QAAQ,CAACJ;IACjC,MAAMK,eAAeF,eAAI,CAACG,OAAO,CAACN;IAClC,MAAMO,eAAeC,IAAAA,YAAQ,EAAC,CAAC,MAAM,EAAEN,YAAY,EAAE;QACnDO,KAAKJ;QACLK,UAAU;QACV,0CAA0C;QAC1CC,KAAK;IACP,EAAE,CAAC,EAAE;IACLd,MAAM,sCAAsCU;IAC5C,OAAOA;AACT;AAEO,eAAeb,iBAAiBkB,WAAmB,EAAEC,OAAgB;IAC1E,8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AED;YAAYQ,SAAS;YAAOZ,MAAM;QAAM;QAG5C,MAAMX,SAASG,OAAOqB,OAAO;QAE7B,OAAOC,IAAAA,oBAAc,EAACL,cAAc;YAClCM,qBAAqB1B,OAAO2B,UAAU,CAACD,mBAAmB;YAC1DE,cAAc5B,OAAO6B,WAAW,CAACD,YAAY;YAC7C5H,UAAUiH,iBAAiBjH,QAAQ;YACnC,2FAA2F;YAC3F,YAAY;YACZrB,aAAaqH,OAAOrH,WAAW;YAC/BmJ,YAAY9B,OAAO6B,WAAW,CAACC,UAAU;YACzCC,UAAU;QACZ;IACF,EAAE,OAAOtC,OAAY;QACnB,IAAIC,QAAQD,QAAQ;YAClB,0EAA0E;YAC1E,iIAAiI;YACjI,IAAI7G,QAAQoB,QAAQ,KAAK,OAAO;gBAC9B,8FAA8F;gBAC9F,IAAI,aAAayF,SAASE,IAAAA,8CAAyB,KAAI;oBACrDF,MAAMG,OAAO,GAAGC,IAAAA,eAAS,EAACJ,MAAMG,OAAO;gBACzC;gBACAE,IAAAA,yCAAoB,EAACnH,aAAa8G;YACpC;QACF;QACA,MAAMA;IACR;AACF;AAEA,SAASC,QAAQD,KAAU;IACzB,OAAOA,iBAAiBuC;AAC1B"}
1
+ {"version":3,"sources":["../../../../src/export/embed/exportEmbedAsync.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 { getConfig } from '@expo/config';\nimport Server from '@expo/metro/metro/Server';\nimport splitBundleOptions from '@expo/metro/metro/lib/splitBundleOptions';\nimport * as output from '@expo/metro/metro/shared/output/bundle';\nimport type { BundleOptions } from '@expo/metro/metro/shared/types';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport fs from 'fs';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\nimport { deserializeEagerKey, getExportEmbedOptionsKey, Options } from './resolveOptions';\nimport { isExecutingFromXcodebuild, logMetroErrorInXcode } from './xcodeCompilerLogger';\nimport { Log } from '../../log';\nimport { DevServerManager } from '../../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../../start/server/metro/MetroBundlerDevServer';\nimport { loadMetroConfigAsync } from '../../start/server/metro/instantiateMetro';\nimport { DOM_COMPONENTS_BUNDLE_DIR } from '../../start/server/middleware/DomComponentsMiddleware';\nimport { getMetroDirectBundleOptionsForExpoConfig } from '../../start/server/middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { copyAsync, removeAsync } from '../../utils/dir';\nimport { env } from '../../utils/env';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { exportDomComponentAsync } from '../exportDomComponents';\nimport { isEnableHermesManaged } from '../exportHermes';\nimport { persistMetroAssetsAsync } from '../persistMetroAssets';\nimport { copyPublicFolderAsync } from '../publicFolder';\nimport { BundleAssetWithFileHashes, ExportAssetMap, persistMetroFilesAsync } from '../saveAssets';\nimport { exportStandaloneServerAsync } from './exportServer';\nimport { ensureProcessExitsAfterDelay } from '../../utils/exit';\nimport { resolveRealEntryFilePath } from '../../utils/filePath';\n\nconst debug = require('debug')('expo:export:embed');\n\nfunction guessCopiedAppleBundlePath(bundleOutput: string) {\n // Ensure the path is familiar before guessing.\n if (\n !bundleOutput.match(/\\/Xcode\\/DerivedData\\/.*\\/Build\\/Products\\//) &&\n !bundleOutput.match(/\\/CoreSimulator\\/Devices\\/.*\\/data\\/Containers\\/Bundle\\/Application\\//)\n ) {\n debug('Bundling to non-standard location:', bundleOutput);\n return false;\n }\n const bundleName = path.basename(bundleOutput);\n const bundleParent = path.dirname(bundleOutput);\n const possiblePath = globSync(`*.app/${bundleName}`, {\n cwd: bundleParent,\n absolute: true,\n // bundle identifiers can start with dots.\n dot: true,\n })[0];\n debug('Possible path for previous bundle:', possiblePath);\n return possiblePath;\n}\n\nexport async function exportEmbedAsync(projectRoot: string, options: Options) {\n // The React Native build scripts always enable the cache reset but we shouldn't need this in CI environments.\n // By disabling it, we can eagerly bundle code before the build and reuse the cached artifacts in subsequent builds.\n if (env.CI && options.resetCache) {\n debug('CI environment detected, disabling automatic cache reset');\n options.resetCache = false;\n }\n\n setNodeEnv(options.dev ? 'development' : 'production');\n require('@expo/env').load(projectRoot);\n\n // This is an optimized codepath that can occur during `npx expo run` and does not occur during builds from Xcode or Android Studio.\n // Here we reconcile a bundle pass that was run before the native build process. This order can fail faster and is show better errors since the logs won't be obscured by Xcode and Android Studio.\n // This path is also used for automatically deploying server bundles to a remote host.\n const eagerBundleOptions = env.__EXPO_EAGER_BUNDLE_OPTIONS\n ? deserializeEagerKey(env.__EXPO_EAGER_BUNDLE_OPTIONS)\n : null;\n if (eagerBundleOptions) {\n // Get the cache key for the current process to compare against the eager key.\n const inputKey = getExportEmbedOptionsKey(options);\n\n // If the app was bundled previously in the same process, then we should reuse the Metro cache.\n options.resetCache = false;\n\n if (eagerBundleOptions.key === inputKey) {\n // Copy the eager bundleOutput and assets to the new locations.\n await removeAsync(options.bundleOutput);\n\n copyAsync(eagerBundleOptions.options.bundleOutput, options.bundleOutput);\n\n if (eagerBundleOptions.options.assetsDest && options.assetsDest) {\n copyAsync(eagerBundleOptions.options.assetsDest, options.assetsDest);\n }\n\n console.log('info: Copied output to binary:', options.bundleOutput);\n return;\n }\n // TODO: sourcemapOutput is set on Android but not during eager. This is tolerable since it doesn't invalidate the Metro cache.\n console.log(' Eager key:', eagerBundleOptions.key);\n console.log('Request key:', inputKey);\n\n // TODO: We may want an analytic event here in the future to understand when this happens.\n console.warn('warning: Eager bundle does not match new options, bundling again.');\n }\n\n await exportEmbedInternalAsync(projectRoot, options);\n\n // Ensure the process closes after bundling\n ensureProcessExitsAfterDelay();\n}\n\nexport async function exportEmbedInternalAsync(projectRoot: string, options: Options) {\n // Ensure we delete the old bundle to trigger a failure if the bundle cannot be created.\n await removeAsync(options.bundleOutput);\n\n // The iOS bundle is copied in to the Xcode project, so we need to remove the old one\n // to prevent Xcode from loading the old one after a build failure.\n if (options.platform === 'ios') {\n const previousPath = guessCopiedAppleBundlePath(options.bundleOutput);\n if (previousPath && fs.existsSync(previousPath)) {\n debug('Removing previous iOS bundle:', previousPath);\n await removeAsync(previousPath);\n }\n }\n\n const { bundle, assets, files } = await exportEmbedBundleAndAssetsAsync(projectRoot, options);\n\n fs.mkdirSync(path.dirname(options.bundleOutput), { recursive: true, mode: 0o755 });\n\n // On Android, dom components proxy files should write to the assets directory instead of the res directory.\n // We use the bundleOutput directory to get the assets directory.\n const domComponentProxyOutputDir =\n options.platform === 'android' ? path.dirname(options.bundleOutput) : options.assetsDest;\n const hasDomComponents = domComponentProxyOutputDir && files.size > 0;\n\n // Persist bundle and source maps.\n await Promise.all([\n output.save(bundle, options, Log.log),\n\n // Write dom components proxy files.\n hasDomComponents ? persistMetroFilesAsync(files, domComponentProxyOutputDir) : null,\n // Copy public folder for dom components only if\n hasDomComponents\n ? copyPublicFolderAsync(\n path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER),\n path.join(domComponentProxyOutputDir, DOM_COMPONENTS_BUNDLE_DIR)\n )\n : null,\n\n // NOTE(EvanBacon): This may need to be adjusted in the future if want to support baseUrl on native\n // platforms when doing production embeds (unlikely).\n options.assetsDest\n ? persistMetroAssetsAsync(projectRoot, assets, {\n platform: options.platform,\n outputDirectory: options.assetsDest,\n iosAssetCatalogDirectory: options.assetCatalogDest,\n })\n : null,\n ]);\n}\n\nexport async function exportEmbedBundleAndAssetsAsync(\n projectRoot: string,\n options: Options\n): Promise<{\n bundle: Awaited<ReturnType<Server['build']>>;\n assets: readonly BundleAssetWithFileHashes[];\n files: ExportAssetMap;\n}> {\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: options.resetCache,\n maxWorkers: options.maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const { exp, pkg } = getConfig(projectRoot, { skipSDKVersionRequirement: true });\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const files: ExportAssetMap = new Map();\n\n try {\n const bundles = await devServer.nativeExportBundleAsync(\n exp,\n {\n // TODO: Re-enable when we get bytecode chunk splitting working again.\n splitChunks: false, //devServer.isReactServerComponentsEnabled,\n mainModuleName: resolveRealEntryFilePath(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: !!sourceMapUrl,\n bytecode: options.bytecode ?? false,\n // source map inline\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n files,\n {\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n }\n );\n\n const apiRoutesEnabled =\n devServer.isReactServerComponentsEnabled || exp.web?.output === 'server';\n\n if (apiRoutesEnabled) {\n await exportStandaloneServerAsync(projectRoot, devServer, {\n exp,\n pkg,\n files,\n options,\n });\n }\n\n // TODO: Remove duplicates...\n const expoDomComponentReferences = bundles.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat();\n if (expoDomComponentReferences.length > 0) {\n await Promise.all(\n // TODO: Make a version of this which uses `this.metro.getBundler().buildGraphForEntries([])` to bundle all the DOM components at once.\n expoDomComponentReferences.map(async (filePath) => {\n const { bundle } = await exportDomComponentAsync({\n filePath,\n projectRoot,\n dev: options.dev,\n devServer,\n isHermes,\n includeSourceMaps: !!sourceMapUrl,\n exp,\n files,\n });\n\n if (options.assetsDest) {\n // Save assets like a typical bundler, preserving the file paths on web.\n // This is saving web-style inside of a native app's binary.\n await persistMetroAssetsAsync(\n projectRoot,\n bundle.assets.map((asset) => ({\n ...asset,\n httpServerLocation: path.join(DOM_COMPONENTS_BUNDLE_DIR, asset.httpServerLocation),\n })),\n {\n files,\n platform: 'web',\n outputDirectory: options.assetsDest,\n }\n );\n }\n })\n );\n }\n\n return {\n files,\n bundle: {\n code: bundles.artifacts.filter((a: any) => a.type === 'js')[0].source,\n // Can be optional when source maps aren't enabled.\n map: bundles.artifacts.filter((a: any) => a.type === 'map')[0]?.source.toString(),\n },\n assets: bundles.assets,\n };\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n } finally {\n devServerManager.stopAsync();\n }\n}\n\n// Exports for expo-updates\nexport async function createMetroServerAndBundleRequestAsync(\n projectRoot: string,\n options: Pick<\n Options,\n | 'maxWorkers'\n | 'config'\n | 'platform'\n | 'sourcemapOutput'\n | 'sourcemapUseAbsolutePath'\n | 'entryFile'\n | 'minify'\n | 'dev'\n | 'resetCache'\n | 'unstableTransformProfile'\n >\n): Promise<{ server: Server; bundleRequest: BundleOptions }> {\n const exp = getConfig(projectRoot, { skipSDKVersionRequirement: true }).exp;\n\n // TODO: This is slow ~40ms\n const { config } = await loadMetroConfigAsync(\n projectRoot,\n {\n // TODO: This is always enabled in the native script and there's no way to disable it.\n resetCache: options.resetCache,\n maxWorkers: options.maxWorkers,\n },\n {\n exp,\n isExporting: true,\n getMetroBundler() {\n return server.getBundler().getBundler();\n },\n }\n );\n\n const isHermes = isEnableHermesManaged(exp, options.platform);\n\n let sourceMapUrl = options.sourcemapOutput;\n if (sourceMapUrl && !options.sourcemapUseAbsolutePath) {\n sourceMapUrl = path.basename(sourceMapUrl);\n }\n\n const directBundleOptions = getMetroDirectBundleOptionsForExpoConfig(projectRoot, exp, {\n splitChunks: false,\n mainModuleName: resolveRealEntryFilePath(projectRoot, options.entryFile),\n platform: options.platform,\n minify: options.minify,\n mode: options.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n isExporting: true,\n // Never output bytecode in the exported bundle since that is hardcoded in the native run script.\n bytecode: false,\n hosted: false,\n });\n\n // TODO(cedric): check if we can use the proper `bundleType=bundle` and `entryPoint=mainModuleName` properties\n const bundleRequest: BundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...directBundleOptions,\n\n // NOTE(@kitten): Cast non-optional defaults\n lazy: directBundleOptions.lazy ?? Server.DEFAULT_BUNDLE_OPTIONS.lazy,\n modulesOnly: directBundleOptions.modulesOnly ?? Server.DEFAULT_BUNDLE_OPTIONS.modulesOnly,\n runModule: directBundleOptions.runModule ?? Server.DEFAULT_BUNDLE_OPTIONS.runModule,\n\n sourceMapUrl,\n unstable_transformProfile: (options.unstableTransformProfile ||\n (isHermes ? 'hermes-stable' : 'default')) as BundleOptions['unstable_transformProfile'],\n };\n\n const server = new Server(config, {\n watch: false,\n });\n\n return { server, bundleRequest };\n}\n\nexport async function exportEmbedAssetsAsync(\n server: Server,\n bundleRequest: BundleOptions,\n projectRoot: string,\n options: Pick<Options, 'platform'>\n) {\n try {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions({\n ...bundleRequest,\n // @ts-ignore-error TODO(@kitten): Very unclear why this is here. Remove?\n bundleType: 'todo',\n });\n\n const dependencies = await server._bundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n const config = server._config;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: config.serializer.processModuleFilter,\n assetPlugins: config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n // Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n // behavior.\n projectRoot: config.projectRoot, // this._getServerRootDir(),\n publicPath: config.transformer.publicPath,\n isHosted: false,\n });\n } catch (error: any) {\n if (isError(error)) {\n // Log using Xcode error format so the errors are picked up by xcodebuild.\n // https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Log-errors-and-warnings-from-your-script\n if (options.platform === 'ios') {\n // If the error is about to be presented in Xcode, strip the ansi characters from the message.\n if ('message' in error && isExecutingFromXcodebuild()) {\n error.message = stripAnsi(error.message) as string;\n }\n logMetroErrorInXcode(projectRoot, error);\n }\n }\n throw error;\n }\n}\n\nfunction isError(error: any): error is Error {\n return error instanceof Error;\n}\n"],"names":["createMetroServerAndBundleRequestAsync","exportEmbedAssetsAsync","exportEmbedAsync","exportEmbedBundleAndAssetsAsync","exportEmbedInternalAsync","debug","require","guessCopiedAppleBundlePath","bundleOutput","match","bundleName","path","basename","bundleParent","dirname","possiblePath","globSync","cwd","absolute","dot","projectRoot","options","env","CI","resetCache","setNodeEnv","dev","load","eagerBundleOptions","__EXPO_EAGER_BUNDLE_OPTIONS","deserializeEagerKey","inputKey","getExportEmbedOptionsKey","key","removeAsync","copyAsync","assetsDest","console","log","warn","ensureProcessExitsAfterDelay","platform","previousPath","fs","existsSync","bundle","assets","files","mkdirSync","recursive","mode","domComponentProxyOutputDir","hasDomComponents","size","Promise","all","output","save","Log","persistMetroFilesAsync","copyPublicFolderAsync","resolve","EXPO_PUBLIC_FOLDER","join","DOM_COMPONENTS_BUNDLE_DIR","persistMetroAssetsAsync","outputDirectory","iosAssetCatalogDirectory","assetCatalogDest","devServerManager","DevServerManager","startMetroAsync","minify","port","isExporting","location","resetDevServer","maxWorkers","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","exp","pkg","getConfig","skipSDKVersionRequirement","isHermes","isEnableHermesManaged","sourceMapUrl","sourcemapOutput","sourcemapUseAbsolutePath","Map","bundles","nativeExportBundleAsync","splitChunks","mainModuleName","resolveRealEntryFilePath","entryFile","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","unstable_transformProfile","unstableTransformProfile","apiRoutesEnabled","isReactServerComponentsEnabled","web","exportStandaloneServerAsync","expoDomComponentReferences","artifacts","map","artifact","Array","isArray","metadata","flat","length","filePath","exportDomComponentAsync","includeSourceMaps","asset","httpServerLocation","code","filter","a","type","source","toString","error","isError","isExecutingFromXcodebuild","message","stripAnsi","logMetroErrorInXcode","stopAsync","config","loadMetroConfigAsync","getMetroBundler","server","getBundler","directBundleOptions","getMetroDirectBundleOptionsForExpoConfig","hosted","bundleRequest","Server","DEFAULT_BUNDLE_OPTIONS","lazy","modulesOnly","runModule","watch","onProgress","resolverOptions","transformOptions","splitBundleOptions","bundleType","dependencies","_bundler","getDependencies","shallow","_config","getMetroAssets","processModuleFilter","serializer","assetPlugins","transformer","publicPath","isHosted","Error"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAuSqBA,sCAAsC;eAAtCA;;IA6EAC,sBAAsB;eAAtBA;;IA5TAC,gBAAgB;eAAhBA;;IAqGAC,+BAA+B;eAA/BA;;IAlDAC,wBAAwB;eAAxBA;;;;yBA1GI;;;;;;;gEACP;;;;;;;gEACY;;;;;;;iEACP;;;;;;;gEAEG;;;;;;;gEACR;;;;;;;gEACJ;;;;;;;yBACkB;;;;;;;gEAChB;;;;;;gCAEsD;qCACP;qBAC5C;kCACa;uCACK;kCACD;yCACK;8BACe;sBAC/B;qBACa;qBACnB;yBACO;qCACa;8BACF;oCACE;8BACF;4BAC4C;8BACtC;sBACC;0BACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,SAASC,2BAA2BC,YAAoB;IACtD,+CAA+C;IAC/C,IACE,CAACA,aAAaC,KAAK,CAAC,kDACpB,CAACD,aAAaC,KAAK,CAAC,0EACpB;QACAJ,MAAM,sCAAsCG;QAC5C,OAAO;IACT;IACA,MAAME,aAAaC,eAAI,CAACC,QAAQ,CAACJ;IAC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QACF,MAAM,EAAE4E,SAAS,EAAEuD,UAAU,EAAEC,eAAe,EAAEC,gBAAgB,EAAE,GAAGC,IAAAA,6BAAkB,EAAC;YACtF,GAAGV,aAAa;YAChB,yEAAyE;YACzEW,YAAY;QACd;QAEA,MAAMC,eAAe,MAAMjB,OAAOkB,QAAQ,CAACC,eAAe,CACxD;YAAC9D;SAAU,EACXyD,kBACAD,iBACA;YAAED;YAAYQ,SAAS;YAAOZ,MAAM;QAAM;QAG5C,MAAMX,SAASG,OAAOqB,OAAO;QAE7B,OAAOC,IAAAA,oBAAc,EAACL,cAAc;YAClCM,qBAAqB1B,OAAO2B,UAAU,CAACD,mBAAmB;YAC1DE,cAAc5B,OAAO6B,WAAW,CAACD,YAAY;YAC7C5H,UAAUiH,iBAAiBjH,QAAQ;YACnC,2FAA2F;YAC3F,YAAY;YACZrB,aAAaqH,OAAOrH,WAAW;YAC/BmJ,YAAY9B,OAAO6B,WAAW,CAACC,UAAU;YACzCC,UAAU;QACZ;IACF,EAAE,OAAOtC,OAAY;QACnB,IAAIC,QAAQD,QAAQ;YAClB,0EAA0E;YAC1E,iIAAiI;YACjI,IAAI7G,QAAQoB,QAAQ,KAAK,OAAO;gBAC9B,8FAA8F;gBAC9F,IAAI,aAAayF,SAASE,IAAAA,8CAAyB,KAAI;oBACrDF,MAAMG,OAAO,GAAGC,IAAAA,eAAS,EAACJ,MAAMG,OAAO;gBACzC;gBACAE,IAAAA,yCAAoB,EAACnH,aAAa8G;YACpC;QACF;QACA,MAAMA;IACR;AACF;AAEA,SAASC,QAAQD,KAAU;IACzB,OAAOA,iBAAiBuC;AAC1B"}
@@ -191,11 +191,12 @@ function makeRuntimeEntryPointsAbsolute(manifest, appDir) {
191
191
  });
192
192
  }
193
193
  async function exportFromServerAsync(projectRoot, devServer, { outputDir, baseUrl, exportServer, includeSourceMaps, routerRoot, files = new Map(), exp, scriptTags }) {
194
- var _exp_extra_router, _exp_extra;
195
- _log.Log.log(`Static rendering is enabled. ` + (0, _link.learnMore)('https://docs.expo.dev/router/reference/static-rendering/'));
194
+ var _exp_extra_router, _exp_extra, _exp_web;
195
+ const useServerRendering = (exp == null ? void 0 : (_exp_extra = exp.extra) == null ? void 0 : (_exp_extra_router = _exp_extra.router) == null ? void 0 : _exp_extra_router.unstable_useServerRendering) ?? false;
196
+ const logOutput = (exp == null ? void 0 : (_exp_web = exp.web) == null ? void 0 : _exp_web.output) === 'server' && useServerRendering ? `Server rendering is enabled. ${(0, _link.learnMore)('https://docs.expo.dev/router/web/server-rendering/')}` : `Static rendering is enabled. ${(0, _link.learnMore)('https://docs.expo.dev/router/web/static-rendering/')}`;
197
+ _log.Log.log(logOutput);
196
198
  const platform = 'web';
197
199
  const isExporting = true;
198
- const useServerRendering = (exp == null ? void 0 : (_exp_extra = exp.extra) == null ? void 0 : (_exp_extra_router = _exp_extra.router) == null ? void 0 : _exp_extra_router.unstable_useServerRendering) ?? false;
199
200
  const isExportingWithSSR = exportServer && useServerRendering && !devServer.isReactServerComponentsEnabled;
200
201
  const appDir = _path().default.join(projectRoot, routerRoot);
201
202
  const injectFaviconTag = await (0, _favicon.getVirtualFaviconAssetsAsync)(projectRoot, {
@@ -227,18 +228,18 @@ async function exportFromServerAsync(projectRoot, devServer, { outputDir, baseUr
227
228
  const useServerLoaders = exp == null ? void 0 : (_exp_extra = exp.extra) == null ? void 0 : (_exp_extra_router = _exp_extra.router) == null ? void 0 : _exp_extra_router.unstable_useServerDataLoaders;
228
229
  let renderOpts;
229
230
  if (useServerLoaders) {
230
- const loaderData = await executeLoaderAsync(normalizedPathname, route);
231
- if (loaderData != null) {
231
+ const loaderResult = await executeLoaderAsync(normalizedPathname, route);
232
+ if (loaderResult !== undefined) {
232
233
  const loaderPath = (0, _utils().getLoaderModulePath)(normalizedPathname);
233
234
  const fileSystemPath = loaderPath.startsWith('/') ? loaderPath.slice(1) : loaderPath;
234
235
  files.set(fileSystemPath, {
235
- contents: JSON.stringify(loaderData, null, 2),
236
+ contents: JSON.stringify(loaderResult.data, null, 2),
236
237
  targetDomain: 'client',
237
238
  loaderId: normalizedPathname
238
239
  });
239
240
  renderOpts = {
240
241
  loader: {
241
- data: loaderData
242
+ data: loaderResult.data
242
243
  }
243
244
  };
244
245
  }
@@ -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 { getLoaderModulePath } from 'expo-router/build/loaders/utils';\nimport { stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport { shouldLinkExternally } from 'expo-router/build/utils/url';\nimport { type RoutesManifest } from 'expo-server/private';\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 { 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 serverManifest,\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 skipHtmlPrerendering,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n serverManifest: RoutesManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n /**\n * Skip HTML pre-rendering when SSR is enabled (HTML will be rendered at runtime).\n *\n * This is separate from `exportServer` because RSC mode also uses `exportServer: true`,\n * but still needs placeholder HTML files.\n */\n skipHtmlPrerendering?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n if (!exportServer && serverManifest) {\n // When we're not exporting a `server` output, we provide a `_expo/.routes.json` for\n // EAS Hosting to recognize the `headers` and `redirects` configs\n const subsetServerManifest = {\n headers: serverManifest.headers,\n redirects: serverManifest.redirects,\n };\n files.set('_expo/.routes.json', {\n contents: JSON.stringify(subsetServerManifest, null, 2),\n targetDomain: 'client',\n });\n }\n\n // Skip HTML pre-rendering in SSR mode since HTML will be rendered at runtime.\n if (skipHtmlPrerendering) {\n return files;\n }\n\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 useServerRendering = exp?.extra?.router?.unstable_useServerRendering ?? false;\n const isExportingWithSSR =\n exportServer && useServerRendering && !devServer.isReactServerComponentsEnabled;\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, executeLoaderAsync }] =\n 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 serverManifest,\n exportServer,\n skipHtmlPrerendering: isExportingWithSSR,\n async renderAsync({ pathname, route }) {\n const normalizedPathname =\n pathname === '' ? '/' : pathname.startsWith('/') ? pathname : `/${pathname}`;\n\n const useServerLoaders = exp?.extra?.router?.unstable_useServerDataLoaders;\n let renderOpts;\n\n if (useServerLoaders) {\n const loaderData = await executeLoaderAsync(normalizedPathname, route);\n\n if (loaderData != null) {\n const loaderPath = getLoaderModulePath(normalizedPathname);\n const fileSystemPath = loaderPath.startsWith('/') ? loaderPath.slice(1) : loaderPath;\n files.set(fileSystemPath, {\n contents: JSON.stringify(loaderData, null, 2),\n targetDomain: 'client',\n loaderId: normalizedPathname,\n });\n\n renderOpts = { loader: { data: loaderData } };\n }\n }\n\n const template = await renderAsync(normalizedPathname, route, renderOpts);\n let html = 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\n // Export SSR render module and add SSR configuration to routes manifest\n if (isExportingWithSSR) {\n await devServer.exportExpoRouterRenderModuleAsync({\n files,\n includeSourceMaps: true,\n platform: 'web',\n });\n\n // Export loader bundles for routes that have loader exports\n const useServerLoaders = exp?.extra?.router?.unstable_useServerDataLoaders;\n if (useServerLoaders) {\n // Get `loaderReferences` from client bundle metadata to determine which routes have loaders\n const loaderReferences = resources.artifacts?.flatMap(\n (artifact) => artifact.metadata?.loaderReferences ?? []\n );\n\n await exportLoadersAsync({\n devServer,\n serverManifest,\n appDir,\n files,\n platform: 'web',\n loaderReferences,\n });\n }\n\n const cssAssets = resources.artifacts\n .filter((asset) => asset.type === 'css')\n .map((asset) => (baseUrl ? `${baseUrl}/${asset.filename}` : `/${asset.filename}`));\n const jsAssets = resources.artifacts\n .filter((asset) => asset.type === 'js')\n .map((asset) => (baseUrl ? `${baseUrl}/${asset.filename}` : `/${asset.filename}`));\n\n // Add assets and rendering config to the routes manifest\n updateExportManifestInFiles({\n files,\n callback: (manifest) => {\n manifest.assets = { css: cssAssets, js: jsAssets };\n manifest.rendering = {\n mode: 'ssr',\n file: '_expo/server/render.js',\n };\n },\n });\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 serverManifest,\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: RoutesManifest<string>;\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\n/**\n * Export loader bundles for routes that have loader exports and updates routes in the manifest\n * with a `loader` property.\n */\nasync function exportLoadersAsync({\n devServer,\n serverManifest,\n appDir,\n files,\n platform,\n loaderReferences,\n}: {\n devServer: MetroBundlerDevServer;\n serverManifest: RoutesManifest<string>;\n appDir: string;\n files: ExportAssetMap;\n platform: string;\n /** File paths of modules with loader exports from client bundle metadata */\n loaderReferences: string[];\n}): Promise<void> {\n const entryPoints: { file: string; page: string }[] = [];\n\n for (const route of serverManifest.htmlRoutes) {\n // Skip generated routes\n if (route.generated) {\n continue;\n }\n\n const filePath = path.isAbsolute(route.file) ? route.file : path.join(appDir, route.file);\n\n if (loaderReferences.includes(filePath)) {\n entryPoints.push({\n file: filePath,\n page: route.page,\n });\n }\n }\n\n if (entryPoints.length === 0) {\n debug('No routes with loaders to bundle');\n return;\n }\n\n const entryPointModules = entryPoints.map((e) => e.page);\n debug('Bundling loaders for routes:', entryPointModules);\n\n await devServer.exportExpoRouterLoadersAsync({\n platform,\n entryPoints,\n files,\n outputDir: '_expo/loaders',\n includeSourceMaps: true,\n });\n\n // Update `htmlRoutes` in routes manifest for routes that have loaders\n updateExportManifestInFiles({\n files,\n callback: (manifest) => {\n const routesWithLoaders = new Set(entryPointModules);\n for (const route of manifest.htmlRoutes) {\n if (routesWithLoaders.has(route.page)) {\n route.loader = `_expo/loaders${route.page}.js`;\n }\n }\n },\n });\n\n debug('Exported loaders for routes:', entryPointModules);\n}\n\n// NOTE(@hassankhan): We should ideally persist the manifest to `files` only once instead of\n// modifying it afterwards.\nfunction updateExportManifestInFiles({\n files,\n callback,\n}: {\n files: ExportAssetMap;\n callback: (manifest: RoutesManifest<string>) => void;\n}) {\n const routesJsonEntry = files.get('_expo/routes.json');\n if (routesJsonEntry) {\n const manifest = JSON.parse(routesJsonEntry.contents as string);\n callback(manifest);\n\n files.set('_expo/routes.json', {\n ...routesJsonEntry,\n contents: JSON.stringify(manifest, null, 2),\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","serverManifest","renderAsync","exportServer","skipHtmlPrerendering","files","Map","subsetServerManifest","headers","redirects","set","contents","JSON","stringify","targetDomain","Promise","all","includeGroupVariations","route","filePath","pathname","type","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","useServerRendering","extra","router","unstable_useServerRendering","isExportingWithSSR","isReactServerComponentsEnabled","injectFaviconTag","getVirtualFaviconAssetsAsync","resources","executeLoaderAsync","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","normalizedPathname","useServerLoaders","unstable_useServerDataLoaders","renderOpts","loaderData","loaderPath","getLoaderModulePath","fileSystemPath","slice","loaderId","loader","template","serializeHtmlWithAssets","artifacts","hydrate","getFilesFromSerialAssets","isServerHosted","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","exportExpoRouterRenderModuleAsync","loaderReferences","flatMap","artifact","metadata","exportLoadersAsync","cssAssets","filter","asset","filename","jsAssets","updateExportManifestInFiles","css","js","rendering","mode","file","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","key","entries","leaf","keys","length","endsWith","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","props","exportExpoRouterApiRoutesAsync","prerenderManifest","htmlRoutes","notFoundRoutes","getApiRoutesForDirectory","warn","chalk","yellow","v","relative","middlewareFile","getMiddlewareForDirectory","generated","includes","page","entryPointModules","exportExpoRouterLoadersAsync","routesWithLoaders","routesJsonEntry","get","parse"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IA+gBqBA,8BAA8B;eAA9BA;;IAlVAC,qBAAqB;eAArBA;;IAhHAC,+BAA+B;eAA/BA;;IAqSNC,YAAY;eAAZA;;IAqHAC,iBAAiB;eAAjBA;;IA3aAC,gBAAgB;eAAhBA;;;;gEA1DE;;;;;;;yBAEkB;;;;;;;yBACO;;;;;;;yBACN;;;;;;;gEAEpB;;;;;;;gEACO;;;;;;;yBACA;;;;;;yBAEqB;oCACL;4BACiB;qBACrC;qCAKe;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,cAAc,EACdC,WAAW,EACX,8DAA8D;AAC9D,kEAAkE;AAClE,aAAa;AACbC,YAAY,EACZC,oBAAoB,EACpB,kBAAkB;AAClBC,QAAQ,IAAIC,KAAK,EAclB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B,QAAQ,EAIT;IACC,MAAMiJ,kBAAkBzK,MAAM0K,GAAG,CAAC;IAClC,IAAID,iBAAiB;QACnB,MAAM9K,WAAWY,KAAKoK,KAAK,CAACF,gBAAgBnK,QAAQ;QACpDkB,SAAS7B;QAETK,MAAMK,GAAG,CAAC,qBAAqB;YAC7B,GAAGoK,eAAe;YAClBnK,UAAUC,KAAKC,SAAS,CAACb,UAAU,MAAM;QAC3C;IACF;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 { getLoaderModulePath } from 'expo-router/build/loaders/utils';\nimport { stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport { shouldLinkExternally } from 'expo-router/build/utils/url';\nimport { type RoutesManifest } from 'expo-server/private';\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 { 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 serverManifest,\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 skipHtmlPrerendering,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n serverManifest: RoutesManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n /**\n * Skip HTML pre-rendering when SSR is enabled (HTML will be rendered at runtime).\n *\n * This is separate from `exportServer` because RSC mode also uses `exportServer: true`,\n * but still needs placeholder HTML files.\n */\n skipHtmlPrerendering?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n if (!exportServer && serverManifest) {\n // When we're not exporting a `server` output, we provide a `_expo/.routes.json` for\n // EAS Hosting to recognize the `headers` and `redirects` configs\n const subsetServerManifest = {\n headers: serverManifest.headers,\n redirects: serverManifest.redirects,\n };\n files.set('_expo/.routes.json', {\n contents: JSON.stringify(subsetServerManifest, null, 2),\n targetDomain: 'client',\n });\n }\n\n // Skip HTML pre-rendering in SSR mode since HTML will be rendered at runtime.\n if (skipHtmlPrerendering) {\n return files;\n }\n\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 const useServerRendering = exp?.extra?.router?.unstable_useServerRendering ?? false;\n\n const logOutput =\n exp?.web?.output === 'server' && useServerRendering\n ? `Server rendering is enabled. ${learnMore('https://docs.expo.dev/router/web/server-rendering/')}`\n : `Static rendering is enabled. ${learnMore('https://docs.expo.dev/router/web/static-rendering/')}`;\n Log.log(logOutput);\n\n const platform = 'web';\n const isExporting = true;\n const isExportingWithSSR =\n exportServer && useServerRendering && !devServer.isReactServerComponentsEnabled;\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, executeLoaderAsync }] =\n 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 serverManifest,\n exportServer,\n skipHtmlPrerendering: isExportingWithSSR,\n async renderAsync({ pathname, route }) {\n const normalizedPathname =\n pathname === '' ? '/' : pathname.startsWith('/') ? pathname : `/${pathname}`;\n\n const useServerLoaders = exp?.extra?.router?.unstable_useServerDataLoaders;\n let renderOpts;\n\n if (useServerLoaders) {\n const loaderResult = await executeLoaderAsync(normalizedPathname, route);\n\n if (loaderResult !== undefined) {\n const loaderPath = getLoaderModulePath(normalizedPathname);\n const fileSystemPath = loaderPath.startsWith('/') ? loaderPath.slice(1) : loaderPath;\n files.set(fileSystemPath, {\n contents: JSON.stringify(loaderResult.data, null, 2),\n targetDomain: 'client',\n loaderId: normalizedPathname,\n });\n\n renderOpts = { loader: { data: loaderResult.data } };\n }\n }\n\n const template = await renderAsync(normalizedPathname, route, renderOpts);\n let html = 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\n // Export SSR render module and add SSR configuration to routes manifest\n if (isExportingWithSSR) {\n await devServer.exportExpoRouterRenderModuleAsync({\n files,\n includeSourceMaps: true,\n platform: 'web',\n });\n\n // Export loader bundles for routes that have loader exports\n const useServerLoaders = exp?.extra?.router?.unstable_useServerDataLoaders;\n if (useServerLoaders) {\n // Get `loaderReferences` from client bundle metadata to determine which routes have loaders\n const loaderReferences = resources.artifacts?.flatMap(\n (artifact) => artifact.metadata?.loaderReferences ?? []\n );\n\n await exportLoadersAsync({\n devServer,\n serverManifest,\n appDir,\n files,\n platform: 'web',\n loaderReferences,\n });\n }\n\n const cssAssets = resources.artifacts\n .filter((asset) => asset.type === 'css')\n .map((asset) => (baseUrl ? `${baseUrl}/${asset.filename}` : `/${asset.filename}`));\n const jsAssets = resources.artifacts\n .filter((asset) => asset.type === 'js')\n .map((asset) => (baseUrl ? `${baseUrl}/${asset.filename}` : `/${asset.filename}`));\n\n // Add assets and rendering config to the routes manifest\n updateExportManifestInFiles({\n files,\n callback: (manifest) => {\n manifest.assets = { css: cssAssets, js: jsAssets };\n manifest.rendering = {\n mode: 'ssr',\n file: '_expo/server/render.js',\n };\n },\n });\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 serverManifest,\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: RoutesManifest<string>;\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\n/**\n * Export loader bundles for routes that have loader exports and updates routes in the manifest\n * with a `loader` property.\n */\nasync function exportLoadersAsync({\n devServer,\n serverManifest,\n appDir,\n files,\n platform,\n loaderReferences,\n}: {\n devServer: MetroBundlerDevServer;\n serverManifest: RoutesManifest<string>;\n appDir: string;\n files: ExportAssetMap;\n platform: string;\n /** File paths of modules with loader exports from client bundle metadata */\n loaderReferences: string[];\n}): Promise<void> {\n const entryPoints: { file: string; page: string }[] = [];\n\n for (const route of serverManifest.htmlRoutes) {\n // Skip generated routes\n if (route.generated) {\n continue;\n }\n\n const filePath = path.isAbsolute(route.file) ? route.file : path.join(appDir, route.file);\n\n if (loaderReferences.includes(filePath)) {\n entryPoints.push({\n file: filePath,\n page: route.page,\n });\n }\n }\n\n if (entryPoints.length === 0) {\n debug('No routes with loaders to bundle');\n return;\n }\n\n const entryPointModules = entryPoints.map((e) => e.page);\n debug('Bundling loaders for routes:', entryPointModules);\n\n await devServer.exportExpoRouterLoadersAsync({\n platform,\n entryPoints,\n files,\n outputDir: '_expo/loaders',\n includeSourceMaps: true,\n });\n\n // Update `htmlRoutes` in routes manifest for routes that have loaders\n updateExportManifestInFiles({\n files,\n callback: (manifest) => {\n const routesWithLoaders = new Set(entryPointModules);\n for (const route of manifest.htmlRoutes) {\n if (routesWithLoaders.has(route.page)) {\n route.loader = `_expo/loaders${route.page}.js`;\n }\n }\n },\n });\n\n debug('Exported loaders for routes:', entryPointModules);\n}\n\n// NOTE(@hassankhan): We should ideally persist the manifest to `files` only once instead of\n// modifying it afterwards.\nfunction updateExportManifestInFiles({\n files,\n callback,\n}: {\n files: ExportAssetMap;\n callback: (manifest: RoutesManifest<string>) => void;\n}) {\n const routesJsonEntry = files.get('_expo/routes.json');\n if (routesJsonEntry) {\n const manifest = JSON.parse(routesJsonEntry.contents as string);\n callback(manifest);\n\n files.set('_expo/routes.json', {\n ...routesJsonEntry,\n contents: JSON.stringify(manifest, null, 2),\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","serverManifest","renderAsync","exportServer","skipHtmlPrerendering","files","Map","subsetServerManifest","headers","redirects","set","contents","JSON","stringify","targetDomain","Promise","all","includeGroupVariations","route","filePath","pathname","type","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","useServerRendering","extra","router","unstable_useServerRendering","logOutput","web","output","learnMore","Log","log","isExporting","isExportingWithSSR","isReactServerComponentsEnabled","injectFaviconTag","getVirtualFaviconAssetsAsync","resources","executeLoaderAsync","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","normalizedPathname","useServerLoaders","unstable_useServerDataLoaders","renderOpts","loaderResult","undefined","loaderPath","getLoaderModulePath","fileSystemPath","slice","loaderId","loader","template","serializeHtmlWithAssets","artifacts","hydrate","getFilesFromSerialAssets","isServerHosted","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","exportExpoRouterRenderModuleAsync","loaderReferences","flatMap","artifact","metadata","exportLoadersAsync","cssAssets","filter","asset","filename","jsAssets","updateExportManifestInFiles","css","js","rendering","mode","file","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","key","entries","leaf","keys","length","endsWith","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","props","exportExpoRouterApiRoutesAsync","prerenderManifest","htmlRoutes","notFoundRoutes","getApiRoutesForDirectory","warn","chalk","yellow","v","relative","middlewareFile","getMiddlewareForDirectory","generated","includes","page","entryPointModules","exportExpoRouterLoadersAsync","routesWithLoaders","routesJsonEntry","get","parse"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAihBqBA,8BAA8B;eAA9BA;;IApVAC,qBAAqB;eAArBA;;IAhHAC,+BAA+B;eAA/BA;;IAuSNC,YAAY;eAAZA;;IAqHAC,iBAAiB;eAAjBA;;IA7aAC,gBAAgB;eAAhBA;;;;gEA1DE;;;;;;;yBAEkB;;;;;;;yBACO;;;;;;;yBACN;;;;;;;gEAEpB;;;;;;;gEACO;;;;;;;yBACA;;;;;;yBAEqB;oCACL;4BACiB;qBACrC;qCAKe;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,K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;IACrB;IAEA,sEAAsE;IACtE4D,4BAA4B;QAC1B1G;QACAwB,UAAU,CAAC7B;YACT,MAAMiL,oBAAoB,IAAI1D,IAAIwD;YAClC,KAAK,MAAM7J,SAASlB,SAASkK,UAAU,CAAE;gBACvC,IAAIe,kBAAkBjC,GAAG,CAAC9H,MAAM4J,IAAI,GAAG;oBACrC5J,MAAMqE,MAAM,GAAG,CAAC,aAAa,EAAErE,MAAM4J,IAAI,CAAC,GAAG,CAAC;gBAChD;YACF;QACF;IACF;IAEA7L,MAAM,gCAAgC8L;AACxC;AAEA,4FAA4F;AAC5F,2BAA2B;AAC3B,SAAShE,4BAA4B,EACnC1G,KAAK,EACLwB,QAAQ,EAIT;IACC,MAAMqJ,kBAAkB7K,MAAM8K,GAAG,CAAC;IAClC,IAAID,iBAAiB;QACnB,MAAMlL,WAAWY,KAAKwK,KAAK,CAACF,gBAAgBvK,QAAQ;QACpDkB,SAAS7B;QAETK,MAAMK,GAAG,CAAC,qBAAqB;YAC7B,GAAGwK,eAAe;YAClBvK,UAAUC,KAAKC,SAAS,CAACb,UAAU,MAAM;QAC3C;IACF;AACF"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "Bonjour", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return Bonjour;
9
+ }
10
+ });
11
+ function _config() {
12
+ const data = require("@expo/config");
13
+ _config = function() {
14
+ return data;
15
+ };
16
+ return data;
17
+ }
18
+ const _env = require("../../utils/env");
19
+ function _getRequireWildcardCache(nodeInterop) {
20
+ if (typeof WeakMap !== "function") return null;
21
+ var cacheBabelInterop = new WeakMap();
22
+ var cacheNodeInterop = new WeakMap();
23
+ return (_getRequireWildcardCache = function(nodeInterop) {
24
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
25
+ })(nodeInterop);
26
+ }
27
+ function _interop_require_wildcard(obj, nodeInterop) {
28
+ if (!nodeInterop && obj && obj.__esModule) {
29
+ return obj;
30
+ }
31
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
32
+ return {
33
+ default: obj
34
+ };
35
+ }
36
+ var cache = _getRequireWildcardCache(nodeInterop);
37
+ if (cache && cache.has(obj)) {
38
+ return cache.get(obj);
39
+ }
40
+ var newObj = {
41
+ __proto__: null
42
+ };
43
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
44
+ for(var key in obj){
45
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
46
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
47
+ if (desc && (desc.get || desc.set)) {
48
+ Object.defineProperty(newObj, key, desc);
49
+ } else {
50
+ newObj[key] = obj[key];
51
+ }
52
+ }
53
+ }
54
+ newObj.default = obj;
55
+ if (cache) {
56
+ cache.set(obj, newObj);
57
+ }
58
+ return newObj;
59
+ }
60
+ const debug = require('debug')('expo:start:server:bonjour');
61
+ class Bonjour {
62
+ constructor(/** Project root directory */ projectRoot, /** Port to advertise, if any */ port){
63
+ this.projectRoot = projectRoot;
64
+ this.port = port;
65
+ }
66
+ async announceAsync({ exp = (0, _config().getConfig)(this.projectRoot).exp }) {
67
+ if (_env.env.CI || !_env.env.EXPO_UNSTABLE_BONJOUR) {
68
+ return;
69
+ } else if (!this.port) {
70
+ return;
71
+ }
72
+ const dnssd = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("dnssd-advertise")));
73
+ if (this.stopAdvertising) {
74
+ await this.stopAdvertising();
75
+ }
76
+ debug('Started Bonjour service');
77
+ this.stopAdvertising = dnssd.advertise({
78
+ name: `${exp.name}`,
79
+ type: 'expo',
80
+ protocol: 'tcp',
81
+ hostname: exp.slug,
82
+ port: this.port,
83
+ txt: {
84
+ slug: exp.slug
85
+ }
86
+ });
87
+ }
88
+ async closeAsync() {
89
+ if (!this.stopAdvertising) {
90
+ return false;
91
+ } else {
92
+ debug('Stopped Bonjour service');
93
+ await (this.stopAdvertising == null ? void 0 : this.stopAdvertising.call(this));
94
+ this.stopAdvertising = undefined;
95
+ return true;
96
+ }
97
+ }
98
+ }
99
+
100
+ //# sourceMappingURL=Bonjour.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/start/server/Bonjour.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport { env } from '../../utils/env';\n\nconst debug = require('debug')('expo:start:server:bonjour') as typeof console.log;\n\nexport class Bonjour {\n private stopAdvertising?: () => Promise<void>;\n\n constructor(\n /** Project root directory */\n private projectRoot: string,\n /** Port to advertise, if any */\n private port: number | undefined\n ) {}\n\n public async announceAsync({\n exp = getConfig(this.projectRoot).exp,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n }) {\n if (env.CI || !env.EXPO_UNSTABLE_BONJOUR) {\n return;\n } else if (!this.port) {\n return;\n }\n\n const dnssd: typeof import('dnssd-advertise') = await import('dnssd-advertise');\n if (this.stopAdvertising) {\n await this.stopAdvertising();\n }\n\n debug('Started Bonjour service');\n this.stopAdvertising = dnssd.advertise({\n name: `${exp.name}`,\n type: 'expo',\n protocol: 'tcp',\n hostname: exp.slug,\n port: this.port,\n txt: {\n slug: exp.slug,\n },\n });\n }\n\n public async closeAsync(): Promise<boolean> {\n if (!this.stopAdvertising) {\n return false;\n } else {\n debug('Stopped Bonjour service');\n await this.stopAdvertising?.();\n this.stopAdvertising = undefined;\n return true;\n }\n }\n}\n"],"names":["Bonjour","debug","require","constructor","projectRoot","port","announceAsync","exp","getConfig","env","CI","EXPO_UNSTABLE_BONJOUR","dnssd","stopAdvertising","advertise","name","type","protocol","hostname","slug","txt","closeAsync","undefined"],"mappings":";;;;+BAMaA;;;eAAAA;;;;yBANyB;;;;;;qBAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpB,MAAMC,QAAQC,QAAQ,SAAS;AAExB,MAAMF;IAGXG,YACE,2BAA2B,GAC3B,AAAQC,WAAmB,EAC3B,8BAA8B,GAC9B,AAAQC,IAAwB,CAChC;aAHQD,cAAAA;aAEAC,OAAAA;IACP;IAEH,MAAaC,cAAc,EACzBC,MAAMC,IAAAA,mBAAS,EAAC,IAAI,CAACJ,WAAW,EAAEG,GAAG,EAGtC,EAAE;QACD,IAAIE,QAAG,CAACC,EAAE,IAAI,CAACD,QAAG,CAACE,qBAAqB,EAAE;YACxC;QACF,OAAO,IAAI,CAAC,IAAI,CAACN,IAAI,EAAE;YACrB;QACF;QAEA,MAAMO,QAA0C,MAAM,mEAAA,QAAO;QAC7D,IAAI,IAAI,CAACC,eAAe,EAAE;YACxB,MAAM,IAAI,CAACA,eAAe;QAC5B;QAEAZ,MAAM;QACN,IAAI,CAACY,eAAe,GAAGD,MAAME,SAAS,CAAC;YACrCC,MAAM,GAAGR,IAAIQ,IAAI,EAAE;YACnBC,MAAM;YACNC,UAAU;YACVC,UAAUX,IAAIY,IAAI;YAClBd,MAAM,IAAI,CAACA,IAAI;YACfe,KAAK;gBACHD,MAAMZ,IAAIY,IAAI;YAChB;QACF;IACF;IAEA,MAAaE,aAA+B;QAC1C,IAAI,CAAC,IAAI,CAACR,eAAe,EAAE;YACzB,OAAO;QACT,OAAO;YACLZ,MAAM;YACN,OAAM,IAAI,CAACY,eAAe,oBAApB,IAAI,CAACA,eAAe,MAApB,IAAI;YACV,IAAI,CAACA,eAAe,GAAGS;YACvB,OAAO;QACT;IACF;AACF"}
@@ -24,6 +24,7 @@ function _resolvefrom() {
24
24
  }
25
25
  const _AsyncNgrok = require("./AsyncNgrok");
26
26
  const _AsyncWsTunnel = require("./AsyncWsTunnel");
27
+ const _Bonjour = require("./Bonjour");
27
28
  const _DevToolsPluginManager = /*#__PURE__*/ _interop_require_default(require("./DevToolsPluginManager"));
28
29
  const _DevelopmentSession = require("./DevelopmentSession");
29
30
  const _UrlCreator = require("./UrlCreator");
@@ -90,6 +91,7 @@ class BundlerDevServer {
90
91
  this.platformBundlers = platformBundlers;
91
92
  this.tunnel = null;
92
93
  this.devSession = null;
94
+ this.bonjour = null;
93
95
  this.instance = null;
94
96
  this.platformManagers = {};
95
97
  this.urlCreator = null;
@@ -173,7 +175,10 @@ class BundlerDevServer {
173
175
  await this._startTunnelAsync();
174
176
  }
175
177
  if (!options.isExporting) {
176
- await this.startDevSessionAsync();
178
+ await Promise.all([
179
+ this.startDevSessionAsync(),
180
+ this.startBonjourAsync()
181
+ ]);
177
182
  this.watchConfig();
178
183
  }
179
184
  }
@@ -203,6 +208,15 @@ class BundlerDevServer {
203
208
  runtime: this.isTargetingNative() ? 'native' : 'web'
204
209
  });
205
210
  }
211
+ async startBonjourAsync() {
212
+ // This is used to make Expo Go open the project in either Expo Go, or the web browser.
213
+ // Must come after ngrok (`startTunnelAsync`) setup.
214
+ if (!this.bonjour) {
215
+ var _this_getInstance;
216
+ this.bonjour = new _Bonjour.Bonjour(this.projectRoot, (_this_getInstance = this.getInstance()) == null ? void 0 : _this_getInstance.location.port);
217
+ }
218
+ await this.bonjour.announceAsync({});
219
+ }
206
220
  isTargetingNative() {
207
221
  // Temporary hack while we implement multi-bundler dev server proxy.
208
222
  return true;
@@ -225,10 +239,14 @@ class BundlerDevServer {
225
239
  }
226
240
  /** Stop the running dev server instance. */ async stopAsync() {
227
241
  var // Stop file watching.
228
- _this_notifier, _this_devSession, _this_tunnel;
242
+ _this_notifier, // Stop the bonjour advertiser
243
+ _this_bonjour, // Stop the dev session timer and tell Expo API to remove dev session.
244
+ _this_devSession, _this_tunnel;
229
245
  (_this_notifier = this.notifier) == null ? void 0 : _this_notifier.stopObserving();
230
- // Stop the dev session timer and tell Expo API to remove dev session.
231
- await ((_this_devSession = this.devSession) == null ? void 0 : _this_devSession.closeAsync());
246
+ await Promise.all([
247
+ (_this_bonjour = this.bonjour) == null ? void 0 : _this_bonjour.closeAsync(),
248
+ (_this_devSession = this.devSession) == null ? void 0 : _this_devSession.closeAsync()
249
+ ]);
232
250
  // Stop tunnel if running.
233
251
  await ((_this_tunnel = this.tunnel) == null ? void 0 : _this_tunnel.stopAsync().catch((e)=>{
234
252
  _log.error(`Error stopping tunnel:`);