@expo/cli 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/build/bin/cli +10 -3
  2. package/build/bin/cli.map +1 -1
  3. package/build/src/api/user/actions.js +1 -1
  4. package/build/src/api/user/actions.js.map +1 -1
  5. package/build/src/export/createMetadataJson.js +2 -1
  6. package/build/src/export/createMetadataJson.js.map +1 -1
  7. package/build/src/export/embed/exportEmbedAsync.js +50 -3
  8. package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
  9. package/build/src/export/embed/xcodeCompilerLogger.js +97 -0
  10. package/build/src/export/embed/xcodeCompilerLogger.js.map +1 -0
  11. package/build/src/export/exportApp.js +90 -103
  12. package/build/src/export/exportApp.js.map +1 -1
  13. package/build/src/export/exportAssets.js +18 -23
  14. package/build/src/export/exportAssets.js.map +1 -1
  15. package/build/src/export/exportAsync.js +1 -1
  16. package/build/src/export/exportAsync.js.map +1 -1
  17. package/build/src/export/exportHermes.js +0 -90
  18. package/build/src/export/exportHermes.js.map +1 -1
  19. package/build/src/export/exportStaticAsync.js +137 -108
  20. package/build/src/export/exportStaticAsync.js.map +1 -1
  21. package/build/src/export/favicon.js +12 -4
  22. package/build/src/export/favicon.js.map +1 -1
  23. package/build/src/export/fork-bundleAsync.js +74 -49
  24. package/build/src/export/fork-bundleAsync.js.map +1 -1
  25. package/build/src/export/metroAssetLocalPath.js +1 -1
  26. package/build/src/export/metroAssetLocalPath.js.map +1 -1
  27. package/build/src/export/persistMetroAssets.js +28 -17
  28. package/build/src/export/persistMetroAssets.js.map +1 -1
  29. package/build/src/export/publicFolder.js +7 -0
  30. package/build/src/export/publicFolder.js.map +1 -1
  31. package/build/src/export/saveAssets.js +176 -12
  32. package/build/src/export/saveAssets.js.map +1 -1
  33. package/build/src/export/writeContents.js +8 -107
  34. package/build/src/export/writeContents.js.map +1 -1
  35. package/build/src/install/installAsync.js +29 -10
  36. package/build/src/install/installAsync.js.map +1 -1
  37. package/build/src/prebuild/prebuildAsync.js +9 -2
  38. package/build/src/prebuild/prebuildAsync.js.map +1 -1
  39. package/build/src/run/hints.js +4 -0
  40. package/build/src/run/hints.js.map +1 -1
  41. package/build/src/run/index.js +101 -0
  42. package/build/src/run/index.js.map +1 -0
  43. package/build/src/start/doctor/dependencies/bundledNativeModules.js +2 -2
  44. package/build/src/start/doctor/dependencies/bundledNativeModules.js.map +1 -1
  45. package/build/src/start/doctor/dependencies/getVersionedPackages.js +10 -3
  46. package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
  47. package/build/src/start/doctor/dependencies/resolvePackages.js +66 -0
  48. package/build/src/start/doctor/dependencies/resolvePackages.js.map +1 -0
  49. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +2 -30
  50. package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
  51. package/build/src/start/interface/interactiveActions.js +24 -8
  52. package/build/src/start/interface/interactiveActions.js.map +1 -1
  53. package/build/src/start/server/getStaticRenderFunctions.js +8 -4
  54. package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
  55. package/build/src/start/server/metro/MetroBundlerDevServer.js +39 -16
  56. package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
  57. package/build/src/start/server/metro/MetroTerminalReporter.js +6 -2
  58. package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
  59. package/build/src/start/server/metro/TerminalReporter.js +18 -1
  60. package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
  61. package/build/src/start/server/metro/bundleApiRoutes.js +3 -2
  62. package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
  63. package/build/src/start/server/metro/createExpoMetroResolver.js +22 -5
  64. package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
  65. package/build/src/start/server/metro/createJResolver.js +5 -2
  66. package/build/src/start/server/metro/createJResolver.js.map +1 -1
  67. package/build/src/start/server/metro/createServerRouteMiddleware.js +2 -1
  68. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  69. package/build/src/start/server/metro/{inspector-proxy/device.js → debugging/InspectorDevice.js} +8 -38
  70. package/build/src/start/server/metro/debugging/InspectorDevice.js.map +1 -0
  71. package/build/src/start/server/metro/debugging/InspectorProxy.js +116 -0
  72. package/build/src/start/server/metro/debugging/InspectorProxy.js.map +1 -0
  73. package/build/src/start/server/metro/debugging/createDebugMiddleware.js +45 -0
  74. package/build/src/start/server/metro/debugging/createDebugMiddleware.js.map +1 -0
  75. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/NetworkResponse.js +3 -4
  76. package/build/src/start/server/metro/debugging/inspectorHandlers/NetworkResponse.js.map +1 -0
  77. package/build/src/start/server/metro/debugging/inspectorHandlers/PageReload.js.map +1 -0
  78. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerGetPossibleBreakpoints.js +2 -2
  79. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -0
  80. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerScriptParsed.js +3 -2
  81. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerScriptParsed.js.map +1 -0
  82. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeDebuggerSetBreakpointByUrl.js +3 -2
  83. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeDebuggerSetBreakpointByUrl.js.map +1 -0
  84. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeRuntimeCallFunctionOn.js +2 -2
  85. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
  86. package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/VscodeRuntimeGetProperties.js +5 -4
  87. package/build/src/start/server/metro/debugging/inspectorHandlers/VscodeRuntimeGetProperties.js.map +1 -0
  88. package/build/src/start/server/metro/debugging/inspectorHandlers/types.js.map +1 -0
  89. package/build/src/start/server/metro/debugging/inspectorHandlers/utils.js +20 -0
  90. package/build/src/start/server/metro/debugging/inspectorHandlers/utils.js.map +1 -0
  91. package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
  92. package/build/src/start/server/metro/instantiateMetro.js +8 -5
  93. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  94. package/build/src/start/server/metro/metroErrorInterface.js +3 -2
  95. package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
  96. package/build/src/start/server/metro/router.js +1 -5
  97. package/build/src/start/server/metro/router.js.map +1 -1
  98. package/build/src/start/server/metro/runServer-fork.js +0 -19
  99. package/build/src/start/server/metro/runServer-fork.js.map +1 -1
  100. package/build/src/start/server/metro/serializeHtml.js +20 -4
  101. package/build/src/start/server/metro/serializeHtml.js.map +1 -1
  102. package/build/src/start/server/metro/withMetroMultiPlatform.js +48 -85
  103. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  104. package/build/src/start/server/middleware/ManifestMiddleware.js +12 -5
  105. package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
  106. package/build/src/start/server/middleware/inspector/JsInspector.js +22 -1
  107. package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
  108. package/build/src/start/server/middleware/metroOptions.js +62 -9
  109. package/build/src/start/server/middleware/metroOptions.js.map +1 -1
  110. package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
  111. package/build/src/start/server/type-generation/__typetests__/route.test.js +11 -3
  112. package/build/src/start/server/type-generation/__typetests__/route.test.js.map +1 -1
  113. package/build/src/start/server/type-generation/routes.js +6 -4
  114. package/build/src/start/server/type-generation/routes.js.map +1 -1
  115. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js +1 -1
  116. package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
  117. package/build/src/utils/analytics/rudderstackClient.js +2 -2
  118. package/build/src/utils/codesigning.js +11 -1
  119. package/build/src/utils/codesigning.js.map +1 -1
  120. package/build/src/utils/env.js +7 -1
  121. package/build/src/utils/env.js.map +1 -1
  122. package/build/src/utils/tsconfig/loadTsConfigPaths.js +3 -11
  123. package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -1
  124. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +22 -12
  125. package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -1
  126. package/package.json +10 -10
  127. package/static/template/index.html +14 -95
  128. package/build/src/export/printBundleSizes.js +0 -101
  129. package/build/src/export/printBundleSizes.js.map +0 -1
  130. package/build/src/start/server/metro/inspector-proxy/device.js.map +0 -1
  131. package/build/src/start/server/metro/inspector-proxy/handlers/NetworkResponse.js.map +0 -1
  132. package/build/src/start/server/metro/inspector-proxy/handlers/PageReload.js.map +0 -1
  133. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +0 -1
  134. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerScriptParsed.js.map +0 -1
  135. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerSetBreakpointByUrl.js.map +0 -1
  136. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js.map +0 -1
  137. package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeGetProperties.js.map +0 -1
  138. package/build/src/start/server/metro/inspector-proxy/handlers/types.js.map +0 -1
  139. package/build/src/start/server/metro/inspector-proxy/handlers/utils.js +0 -11
  140. package/build/src/start/server/metro/inspector-proxy/handlers/utils.js.map +0 -1
  141. package/build/src/start/server/metro/inspector-proxy/index.js +0 -30
  142. package/build/src/start/server/metro/inspector-proxy/index.js.map +0 -1
  143. package/build/src/start/server/metro/inspector-proxy/proxy.js +0 -169
  144. package/build/src/start/server/metro/inspector-proxy/proxy.js.map +0 -1
  145. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js +0 -64
  146. package/build/src/start/server/middleware/inspector/createJsInspectorMiddleware.js.map +0 -1
  147. /package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/PageReload.js +0 -0
  148. /package/build/src/start/server/metro/{inspector-proxy/handlers → debugging/inspectorHandlers}/types.js +0 -0
@@ -21,7 +21,7 @@ function getUserDefinedFaviconFile(projectRoot) {
21
21
  "./favicon.ico"
22
22
  ]);
23
23
  }
24
- async function getVirtualFaviconAssetsAsync(projectRoot, { baseUrl , outputDir }) {
24
+ async function getVirtualFaviconAssetsAsync(projectRoot, { baseUrl , outputDir , files }) {
25
25
  const existing = getUserDefinedFaviconFile(projectRoot);
26
26
  if (existing) {
27
27
  debug("Using user-defined favicon.ico file.");
@@ -33,10 +33,18 @@ async function getVirtualFaviconAssetsAsync(projectRoot, { baseUrl , outputDir
33
33
  }
34
34
  await Promise.all([
35
35
  data
36
- ].map((asset)=>{
36
+ ].map(async (asset)=>{
37
37
  const assetPath = _path.default.join(outputDir, asset.path);
38
- debug("Writing asset to disk: " + assetPath);
39
- return _fs.default.promises.writeFile(assetPath, asset.source);
38
+ if (files) {
39
+ debug("Storing asset for persisting: " + assetPath);
40
+ files == null ? void 0 : files.set(asset.path, {
41
+ contents: asset.source,
42
+ targetDomain: "client"
43
+ });
44
+ } else {
45
+ debug("Writing asset to disk: " + assetPath);
46
+ await _fs.default.promises.writeFile(assetPath, asset.source);
47
+ }
40
48
  }));
41
49
  function injectFaviconTag(html) {
42
50
  if (!html.includes("</head>")) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/favicon.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { generateFaviconAsync, generateImageAsync } from '@expo/image-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { getUserDefinedFile } from './publicFolder';\n\nconst debug = require('debug')('expo:favicon') as typeof console.log;\n\n/** @returns the file system path for a user-defined favicon.ico file in the public folder. */\nexport function getUserDefinedFaviconFile(projectRoot: string): string | null {\n return getUserDefinedFile(projectRoot, ['./favicon.ico']);\n}\n\nexport async function getVirtualFaviconAssetsAsync(\n projectRoot: string,\n { baseUrl, outputDir }: { outputDir: string; baseUrl: string }\n): Promise<((html: string) => string) | null> {\n const existing = getUserDefinedFaviconFile(projectRoot);\n if (existing) {\n debug('Using user-defined favicon.ico file.');\n return null;\n }\n\n const data = await getFaviconFromExpoConfigAsync(projectRoot);\n\n if (!data) {\n return null;\n }\n\n await Promise.all(\n [data].map((asset) => {\n const assetPath = path.join(outputDir, asset.path);\n debug('Writing asset to disk: ' + assetPath);\n return fs.promises.writeFile(assetPath, asset.source);\n })\n );\n\n function injectFaviconTag(html: string): string {\n if (!html.includes('</head>')) {\n return html;\n }\n return html.replace(\n '</head>',\n `<link rel=\"shortcut icon\" href=\"${baseUrl}/favicon.ico\" /></head>`\n );\n }\n\n return injectFaviconTag;\n}\n\nexport async function getFaviconFromExpoConfigAsync(projectRoot: string) {\n const { exp } = getConfig(projectRoot);\n\n const src = exp.web?.favicon ?? null;\n if (!src) {\n return null;\n }\n\n const dims = [16, 32, 48];\n const cacheType = 'favicon';\n\n const size = dims[dims.length - 1];\n const { source } = await generateImageAsync(\n { projectRoot, cacheType },\n {\n resizeMode: 'contain',\n src,\n backgroundColor: 'transparent',\n width: size,\n height: size,\n name: `favicon-${size}.png`,\n }\n );\n\n const faviconBuffer = await generateFaviconAsync(source, dims);\n\n return { source: faviconBuffer, path: 'favicon.ico' };\n}\n"],"names":["getUserDefinedFaviconFile","getVirtualFaviconAssetsAsync","getFaviconFromExpoConfigAsync","debug","require","projectRoot","getUserDefinedFile","baseUrl","outputDir","existing","data","Promise","all","map","asset","assetPath","path","join","fs","promises","writeFile","source","injectFaviconTag","html","includes","replace","exp","getConfig","src","web","favicon","dims","cacheType","size","length","generateImageAsync","resizeMode","backgroundColor","width","height","name","faviconBuffer","generateFaviconAsync"],"mappings":"AAAA;;;;QAUgBA,yBAAyB,GAAzBA,yBAAyB;QAIn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AAC;IAEF,MAAMQ,aAAa,GAAG,MAAMC,CAAAA,GAAAA,WAAoB,AAAc,CAAA,qBAAd,CAACrB,MAAM,EAAEU,IAAI,CAAC,AAAC;IAE/D,OAAO;QAAEV,MAAM,EAAEoB,aAAa;QAAEzB,IAAI,EAAE,aAAa;KAAE,CAAC;CACvD"}
1
+ {"version":3,"sources":["../../../src/export/favicon.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport { generateFaviconAsync, generateImageAsync } from '@expo/image-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { getUserDefinedFile } from './publicFolder';\nimport { ExportAssetMap } from './saveAssets';\n\nconst debug = require('debug')('expo:favicon') as typeof console.log;\n\n/** @returns the file system path for a user-defined favicon.ico file in the public folder. */\nexport function getUserDefinedFaviconFile(projectRoot: string): string | null {\n return getUserDefinedFile(projectRoot, ['./favicon.ico']);\n}\n\nexport async function getVirtualFaviconAssetsAsync(\n projectRoot: string,\n { baseUrl, outputDir, files }: { outputDir: string; baseUrl: string; files?: ExportAssetMap }\n): Promise<((html: string) => string) | null> {\n const existing = getUserDefinedFaviconFile(projectRoot);\n if (existing) {\n debug('Using user-defined favicon.ico file.');\n return null;\n }\n\n const data = await getFaviconFromExpoConfigAsync(projectRoot);\n\n if (!data) {\n return null;\n }\n\n await Promise.all(\n [data].map(async (asset) => {\n const assetPath = path.join(outputDir, asset.path);\n if (files) {\n debug('Storing asset for persisting: ' + assetPath);\n files?.set(asset.path, {\n contents: asset.source,\n targetDomain: 'client',\n });\n } else {\n debug('Writing asset to disk: ' + assetPath);\n await fs.promises.writeFile(assetPath, asset.source);\n }\n })\n );\n\n function injectFaviconTag(html: string): string {\n if (!html.includes('</head>')) {\n return html;\n }\n return html.replace(\n '</head>',\n `<link rel=\"shortcut icon\" href=\"${baseUrl}/favicon.ico\" /></head>`\n );\n }\n\n return injectFaviconTag;\n}\n\nexport async function getFaviconFromExpoConfigAsync(projectRoot: string) {\n const { exp } = getConfig(projectRoot);\n\n const src = exp.web?.favicon ?? null;\n if (!src) {\n return null;\n }\n\n const dims = [16, 32, 48];\n const cacheType = 'favicon';\n\n const size = dims[dims.length - 1];\n const { source } = await generateImageAsync(\n { projectRoot, cacheType },\n {\n resizeMode: 'contain',\n src,\n backgroundColor: 'transparent',\n width: size,\n height: size,\n name: `favicon-${size}.png`,\n }\n );\n\n const faviconBuffer = await generateFaviconAsync(source, dims);\n\n return { source: faviconBuffer, path: 'favicon.ico' };\n}\n"],"names":["getUserDefinedFaviconFile","getVirtualFaviconAssetsAsync","getFaviconFromExpoConfigAsync","debug","require","projectRoot","getUserDefinedFile","baseUrl","outputDir","files","existing","data","Promise","all","map","asset","assetPath","path","join","set","contents","source","targetDomain","fs","promises","writeFile","injectFaviconTag","html","includes","replace","exp","getConfig","src","web","favicon","dims","cacheType","size","length","generateImageAsync","resizeMode","backgroundColor","width","height","name","faviconBuffer","generateFaviconAsync"],"mappings":"AAAA;;;;QAWgBA,yBAAyB,GAAzBA,yBAAyB;QAInBC,4BAA4B,GAA5BA,4BAA4B;QA6C5BC,6BAA6B,GAA7BA,6BAA6B;AA5DzB,IAAA,OAAc,WAAd,cAAc,CAAA;AACiB,IAAA,WAAmB,WAAnB,mBAAmB,CAAA;AAC7D,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEY,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;;;;;;AAGnD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,AAAsB,AAAC;AAG9D,SAASJ,yBAAyB,CAACK,WAAmB,EAAiB;IAC5E,OAAOC,CAAAA,GAAAA,aAAkB,AAAgC,CAAA,mBAAhC,CAACD,WAAW,EAAE;QAAC,eAAe;KAAC,CAAC,CAAC;CAC3D;AAEM,eAAeJ,4BAA4B,CAChDI,WAAmB,EACnB,EAAEE,OAAO,CAAA,EAAEC,SAAS,CAAA,EAAEC,KAAK,CAAA,EAAkE,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Assets;
7
7
  var _config = require("@expo/config");
8
- var _chalk = _interopRequireDefault(require("chalk"));
8
+ var _getAssets = _interopRequireDefault(require("@expo/metro-config/build/transform-worker/getAssets"));
9
+ var _assert = _interopRequireDefault(require("assert"));
9
10
  var _metro = _interopRequireDefault(require("metro"));
10
- var _getAssets = _interopRequireDefault(require("metro/src/DeltaBundler/Serializers/getAssets"));
11
11
  var _server = _interopRequireDefault(require("metro/src/Server"));
12
12
  var _splitBundleOptions = _interopRequireDefault(require("metro/src/lib/splitBundleOptions"));
13
+ var _path = _interopRequireDefault(require("path"));
13
14
  var _exportHermes = require("./exportHermes");
14
- var _getCssModulesFromBundler = require("../start/server/metro/getCssModulesFromBundler");
15
15
  var _instantiateMetro = require("../start/server/metro/instantiateMetro");
16
16
  var _manifestMiddleware = require("../start/server/middleware/ManifestMiddleware");
17
17
  var _metroOptions = require("../start/server/middleware/metroOptions");
@@ -33,13 +33,14 @@ async function createBundlesAsync(projectRoot, projectConfig, bundleOptions) {
33
33
  return {};
34
34
  }
35
35
  const { exp , pkg } = projectConfig;
36
+ var _entryPoint;
36
37
  const bundles = await bundleProductionMetroClientAsync(projectRoot, exp, {
37
38
  // If not legacy, ignore the target option to prevent warnings from being thrown.
38
39
  resetCache: bundleOptions.clear,
39
40
  maxWorkers: bundleOptions.maxWorkers
40
41
  }, bundleOptions.platforms.map((platform)=>({
41
42
  platform,
42
- entryPoint: (0, _manifestMiddleware).getEntryWithServerRoot(projectRoot, {
43
+ entryPoint: (_entryPoint = bundleOptions.entryPoint) != null ? _entryPoint : (0, _manifestMiddleware).getEntryWithServerRoot(projectRoot, {
43
44
  platform,
44
45
  pkg
45
46
  }),
@@ -70,18 +71,26 @@ async function bundleProductionMetroClientAsync(projectRoot, expoConfig, metroOp
70
71
  const buildAsync = async (bundle)=>{
71
72
  const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;
72
73
  const isHermes = (0, _exportHermes).isEnableHermesManaged(expoConfig, bundle.platform);
74
+ if (isHermes) {
75
+ await assertEngineMismatchAsync(projectRoot, expoConfig, bundle.platform);
76
+ }
73
77
  const bundleOptions = {
74
78
  ..._server.default.DEFAULT_BUNDLE_OPTIONS,
75
- ...(0, _metroOptions).getMetroDirectBundleOptions({
79
+ sourceMapUrl: bundle.sourceMapUrl,
80
+ ...(0, _metroOptions).getMetroDirectBundleOptionsForExpoConfig(projectRoot, expoConfig, {
76
81
  mainModuleName: bundle.entryPoint,
77
82
  platform: bundle.platform,
78
83
  mode: bundle.dev ? "development" : "production",
79
84
  engine: isHermes ? "hermes" : undefined,
80
- baseUrl: (0, _metroOptions).getBaseUrlFromExpoConfig(expoConfig)
85
+ serializerIncludeMaps: bundle.sourcemaps,
86
+ // Bundle splitting on web-only for now.
87
+ // serializerOutput: bundle.platform === 'web' ? 'static' : undefined,
88
+ serializerOutput: "static",
89
+ serializerIncludeBytecode: isHermes,
90
+ isExporting: true
81
91
  }),
82
92
  bundleType: "bundle",
83
93
  inlineSourceMap: false,
84
- sourceMapUrl: bundle.sourceMapUrl,
85
94
  createModuleIdFactory: config.serializer.createModuleIdFactory,
86
95
  onProgress: (transformedFileCount, totalFileCount)=>{
87
96
  reporter.update({
@@ -102,21 +111,12 @@ async function bundleProductionMetroClientAsync(projectRoot, expoConfig, metroOp
102
111
  bundleDetails
103
112
  });
104
113
  try {
105
- const { code , map } = await metroServer.build(bundleOptions);
106
- const [assets, css] = await Promise.all([
107
- getAssets(metroServer, bundleOptions),
108
- (0, _getCssModulesFromBundler).getCssModulesFromBundler(config, metroServer.getBundler(), bundleOptions),
109
- ]);
114
+ const artifacts = await forkMetroBuildAsync(metroServer, bundleOptions);
110
115
  reporter.update({
111
116
  buildID,
112
117
  type: "bundle_build_done"
113
118
  });
114
- return {
115
- code,
116
- map,
117
- assets: assets,
118
- css
119
- };
119
+ return artifacts;
120
120
  } catch (error) {
121
121
  reporter.update({
122
122
  buildID,
@@ -125,38 +125,9 @@ async function bundleProductionMetroClientAsync(projectRoot, expoConfig, metroOp
125
125
  throw error;
126
126
  }
127
127
  };
128
- const maybeAddHermesBundleAsync = async (bundle, bundleOutput)=>{
129
- const { platform } = bundle;
130
- const isHermesManaged = (0, _exportHermes).isEnableHermesManaged(expoConfig, platform);
131
- if (isHermesManaged) {
132
- const platformTag = _chalk.default.bold({
133
- ios: "iOS",
134
- android: "Android",
135
- web: "Web"
136
- }[platform] || platform);
137
- reporter.terminal.log(`${platformTag} Building Hermes bytecode for the bundle`);
138
- var _minify;
139
- const hermesBundleOutput = await (0, _exportHermes).buildHermesBundleAsync(projectRoot, {
140
- code: bundleOutput.code,
141
- map: bundle.sourcemaps ? bundleOutput.map : null,
142
- minify: (_minify = bundle.minify) != null ? _minify : !bundle.dev
143
- });
144
- bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;
145
- var _sourcemap;
146
- bundleOutput.hermesSourcemap = (_sourcemap = hermesBundleOutput.sourcemap) != null ? _sourcemap : undefined;
147
- }
148
- return bundleOutput;
149
- };
150
128
  try {
151
- const intermediateOutputs = await Promise.all(bundles.map((bundle)=>buildAsync(bundle)
129
+ return await Promise.all(bundles.map((bundle)=>buildAsync(bundle)
152
130
  ));
153
- const bundleOutputs = [];
154
- for(let i = 0; i < bundles.length; ++i){
155
- // hermesc does not support parallel building even we spawn processes.
156
- // we should build them sequentially.
157
- bundleOutputs.push(await maybeAddHermesBundleAsync(bundles[i], intermediateOutputs[i]));
158
- }
159
- return bundleOutputs;
160
131
  } catch (error) {
161
132
  // New line so errors don't show up inline with the progress bar
162
133
  console.log("");
@@ -177,7 +148,7 @@ async function getAssets(metro, options) {
177
148
  });
178
149
  // @ts-expect-error
179
150
  const _config1 = metro._config;
180
- return await (0, _getAssets).default(dependencies, {
151
+ return (0, _getAssets).default(dependencies, {
181
152
  processModuleFilter: _config1.serializer.processModuleFilter,
182
153
  assetPlugins: _config1.transformer.assetPlugins,
183
154
  platform: transformOptions.platform,
@@ -185,5 +156,59 @@ async function getAssets(metro, options) {
185
156
  publicPath: _config1.transformer.publicPath
186
157
  });
187
158
  }
159
+ function isMetroServerInstance(metro) {
160
+ return "_shouldAddModuleToIgnoreList" in metro;
161
+ }
162
+ async function forkMetroBuildAsync(metro, options) {
163
+ var ref;
164
+ if (!isMetroServerInstance(metro)) {
165
+ throw new Error("Expected Metro server instance to have private functions exposed.");
166
+ }
167
+ if (((ref = options.serializerOptions) == null ? void 0 : ref.output) !== "static") {
168
+ throw new Error("Only multi-serializer output is supported.");
169
+ }
170
+ const { entryFile , graphOptions , onProgress , resolverOptions , serializerOptions , transformOptions , } = (0, _splitBundleOptions).default(options);
171
+ const { prepend , graph } = await metro._bundler.buildGraph(entryFile, transformOptions, resolverOptions, {
172
+ onProgress,
173
+ shallow: graphOptions.shallow,
174
+ // @ts-expect-error
175
+ lazy: graphOptions.lazy
176
+ });
177
+ const entryPoint = metro._getEntryPointAbsolutePath(entryFile);
178
+ var _unstable_serverRoot;
179
+ const bundleOptions = {
180
+ asyncRequireModulePath: await metro._resolveRelativePath(metro._config.transformer.asyncRequireModulePath, {
181
+ relativeTo: "project",
182
+ resolverOptions,
183
+ transformOptions
184
+ }),
185
+ processModuleFilter: metro._config.serializer.processModuleFilter,
186
+ createModuleId: metro._createModuleId,
187
+ getRunModuleStatement: metro._config.serializer.getRunModuleStatement,
188
+ dev: transformOptions.dev,
189
+ includeAsyncPaths: graphOptions.lazy,
190
+ projectRoot: metro._config.projectRoot,
191
+ modulesOnly: serializerOptions.modulesOnly,
192
+ runBeforeMainModule: metro._config.serializer.getModulesRunBeforeMainModule(_path.default.relative(metro._config.projectRoot, entryPoint)),
193
+ runModule: serializerOptions.runModule,
194
+ sourceMapUrl: serializerOptions.sourceMapUrl,
195
+ sourceUrl: serializerOptions.sourceUrl,
196
+ inlineSourceMap: serializerOptions.inlineSourceMap,
197
+ serverRoot: (_unstable_serverRoot = metro._config.server.unstable_serverRoot) != null ? _unstable_serverRoot : metro._config.projectRoot,
198
+ shouldAddToIgnoreList: (module)=>metro._shouldAddModuleToIgnoreList(module)
199
+ ,
200
+ // Custom options we pass to the serializer to emulate the URL query parameters.
201
+ serializerOptions: options.serializerOptions
202
+ };
203
+ const bundle = await metro._config.serializer.customSerializer(entryPoint, // @ts-expect-error: Metro is typed incorrectly
204
+ prepend, graph, bundleOptions);
205
+ try {
206
+ const parsed = typeof bundle === "string" ? JSON.parse(bundle) : bundle;
207
+ (0, _assert).default("artifacts" in parsed && Array.isArray(parsed.artifacts), "Expected serializer to return an object with key artifacts to contain an array of serial assets.");
208
+ return parsed;
209
+ } catch (error) {
210
+ throw new Error("Serializer did not return expected format. The project copy of `expo/metro-config` may be out of date. Error: " + error.message);
211
+ }
212
+ }
188
213
 
189
214
  //# sourceMappingURL=fork-bundleAsync.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/fork-bundleAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfigFilePaths, Platform, ProjectConfig } from '@expo/config';\nimport type { LoadOptions } from '@expo/metro-config';\nimport chalk from 'chalk';\nimport Metro, { AssetData } from 'metro';\nimport getMetroAssets from 'metro/src/DeltaBundler/Serializers/getAssets';\nimport Server from 'metro/src/Server';\nimport splitBundleOptions from 'metro/src/lib/splitBundleOptions';\nimport type { BundleOptions as MetroBundleOptions } from 'metro/src/shared/types';\nimport { ConfigT } from 'metro-config';\n\nimport {\n buildHermesBundleAsync,\n isEnableHermesManaged,\n maybeThrowFromInconsistentEngineAsync,\n} from './exportHermes';\nimport { CSSAsset, getCssModulesFromBundler } from '../start/server/metro/getCssModulesFromBundler';\nimport { loadMetroConfigAsync } from '../start/server/metro/instantiateMetro';\nimport { getEntryWithServerRoot } from '../start/server/middleware/ManifestMiddleware';\nimport {\n getBaseUrlFromExpoConfig,\n getMetroDirectBundleOptions,\n} from '../start/server/middleware/metroOptions';\n\nexport type MetroDevServerOptions = LoadOptions;\n\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n sourceMapUrl?: string;\n sourcemaps?: boolean;\n};\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\nexport type BundleOutput = {\n code: string;\n map: string;\n hermesBytecodeBundle?: Uint8Array;\n hermesSourcemap?: string;\n css: CSSAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nlet nextBuildID = 0;\n\nasync function assertEngineMismatchAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'ios' | 'android' | 'jsEngine'>,\n platform: Platform\n) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\n\n const paths = getConfigFilePaths(projectRoot);\n const configFilePath = paths.dynamicConfigPath ?? paths.staticConfigPath ?? 'app.json';\n await maybeThrowFromInconsistentEngineAsync(\n projectRoot,\n configFilePath,\n platform,\n isHermesManaged\n );\n}\n\nexport async function createBundlesAsync(\n projectRoot: string,\n projectConfig: ProjectConfig,\n bundleOptions: {\n clear?: boolean;\n maxWorkers?: number;\n platforms: Platform[];\n dev?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n }\n): Promise<Partial<Record<Platform, BundleOutput>>> {\n if (!bundleOptions.platforms.length) {\n return {};\n }\n const { exp, pkg } = projectConfig;\n\n const bundles = await bundleProductionMetroClientAsync(\n projectRoot,\n exp,\n {\n // If not legacy, ignore the target option to prevent warnings from being thrown.\n resetCache: bundleOptions.clear,\n maxWorkers: bundleOptions.maxWorkers,\n },\n bundleOptions.platforms.map((platform: Platform) => ({\n platform,\n entryPoint: getEntryWithServerRoot(projectRoot, { platform, pkg }),\n sourcemaps: bundleOptions.sourcemaps,\n minify: bundleOptions.minify,\n dev: bundleOptions.dev,\n }))\n );\n\n // { ios: bundle, android: bundle }\n return bundleOptions.platforms.reduce<Partial<Record<Platform, BundleOutput>>>(\n (prev, platform, index) => ({\n ...prev,\n [platform]: bundles[index],\n }),\n {}\n );\n}\n\nasync function bundleProductionMetroClientAsync(\n projectRoot: string,\n expoConfig: ExpoConfig,\n metroOptions: MetroDevServerOptions,\n bundles: BundleOptions[]\n): Promise<BundleOutput[]> {\n // Assert early so the user doesn't have to wait until bundling is complete to find out that\n // Hermes won't be available.\n await Promise.all(\n bundles.map(({ platform }) => assertEngineMismatchAsync(projectRoot, expoConfig, platform))\n );\n\n const { config, reporter } = await loadMetroConfigAsync(projectRoot, metroOptions, {\n exp: expoConfig,\n isExporting: true,\n });\n\n const metroServer = await Metro.runMetro(config, {\n watch: false,\n });\n\n const buildAsync = async (bundle: BundleOptions): Promise<BundleOutput> => {\n const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;\n const isHermes = isEnableHermesManaged(expoConfig, bundle.platform);\n const bundleOptions: MetroBundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n ...getMetroDirectBundleOptions({\n mainModuleName: bundle.entryPoint,\n platform: bundle.platform,\n mode: bundle.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n baseUrl: getBaseUrlFromExpoConfig(expoConfig),\n }),\n bundleType: 'bundle',\n inlineSourceMap: false,\n sourceMapUrl: bundle.sourceMapUrl,\n createModuleIdFactory: config.serializer.createModuleIdFactory,\n onProgress: (transformedFileCount: number, totalFileCount: number) => {\n reporter.update({\n buildID,\n type: 'bundle_transform_progressed',\n transformedFileCount,\n totalFileCount,\n });\n },\n };\n const bundleDetails = {\n ...bundleOptions,\n buildID,\n };\n reporter.update({\n buildID,\n type: 'bundle_build_started',\n bundleDetails,\n });\n try {\n const { code, map } = await metroServer.build(bundleOptions);\n const [assets, css] = await Promise.all([\n getAssets(metroServer, bundleOptions),\n getCssModulesFromBundler(config, metroServer.getBundler(), bundleOptions),\n ]);\n\n reporter.update({\n buildID,\n type: 'bundle_build_done',\n });\n return { code, map, assets: assets as readonly BundleAssetWithFileHashes[], css };\n } catch (error) {\n reporter.update({\n buildID,\n type: 'bundle_build_failed',\n });\n\n throw error;\n }\n };\n\n const maybeAddHermesBundleAsync = async (\n bundle: BundleOptions,\n bundleOutput: BundleOutput\n ): Promise<BundleOutput> => {\n const { platform } = bundle;\n const isHermesManaged = isEnableHermesManaged(expoConfig, platform);\n if (isHermesManaged) {\n const platformTag = chalk.bold(\n { ios: 'iOS', android: 'Android', web: 'Web' }[platform] || platform\n );\n\n reporter.terminal.log(`${platformTag} Building Hermes bytecode for the bundle`);\n\n const hermesBundleOutput = await buildHermesBundleAsync(projectRoot, {\n code: bundleOutput.code,\n map: bundle.sourcemaps ? bundleOutput.map : null,\n minify: bundle.minify ?? !bundle.dev,\n });\n bundleOutput.hermesBytecodeBundle = hermesBundleOutput.hbc;\n bundleOutput.hermesSourcemap = hermesBundleOutput.sourcemap ?? undefined;\n }\n return bundleOutput;\n };\n\n try {\n const intermediateOutputs = await Promise.all(bundles.map((bundle) => buildAsync(bundle)));\n const bundleOutputs: BundleOutput[] = [];\n for (let i = 0; i < bundles.length; ++i) {\n // hermesc does not support parallel building even we spawn processes.\n // we should build them sequentially.\n bundleOutputs.push(await maybeAddHermesBundleAsync(bundles[i], intermediateOutputs[i]));\n }\n return bundleOutputs;\n } catch (error) {\n // New line so errors don't show up inline with the progress bar\n console.log('');\n throw error;\n } finally {\n metroServer.end();\n }\n}\n\n// Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n// behavior.\nexport async function getAssets(\n metro: Metro.Server,\n options: MetroBundleOptions\n): Promise<readonly AssetData[]> {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions(options);\n\n // @ts-expect-error: _bundler isn't exposed on the type.\n const dependencies = await metro._bundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n // @ts-expect-error\n const _config = metro._config as ConfigT;\n\n return await getMetroAssets(dependencies, {\n processModuleFilter: _config.serializer.processModuleFilter,\n assetPlugins: _config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n projectRoot: _config.projectRoot, // this._getServerRootDir(),\n publicPath: _config.transformer.publicPath,\n });\n}\n"],"names":["createBundlesAsync","getAssets","nextBuildID","assertEngineMismatchAsync","projectRoot","exp","platform","isHermesManaged","isEnableHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","maybeThrowFromInconsistentEngineAsync","projectConfig","bundleOptions","platforms","length","pkg","bundles","bundleProductionMetroClientAsync","resetCache","clear","maxWorkers","map","entryPoint","getEntryWithServerRoot","sourcemaps","minify","dev","reduce","prev","index","expoConfig","metroOptions","Promise","all","config","reporter","loadMetroConfigAsync","isExporting","metroServer","Metro","runMetro","watch","buildAsync","bundle","buildID","isHermes","Server","DEFAULT_BUNDLE_OPTIONS","getMetroDirectBundleOptions","mainModuleName","mode","engine","undefined","baseUrl","getBaseUrlFromExpoConfig","bundleType","inlineSourceMap","sourceMapUrl","createModuleIdFactory","serializer","onProgress","transformedFileCount","totalFileCount","update","type","bundleDetails","code","build","assets","css","getCssModulesFromBundler","getBundler","error","maybeAddHermesBundleAsync","bundleOutput","platformTag","chalk","bold","ios","android","web","terminal","log","hermesBundleOutput","buildHermesBundleAsync","hermesBytecodeBundle","hbc","hermesSourcemap","sourcemap","intermediateOutputs","bundleOutputs","i","push","console","end","metro","options","entryFile","resolverOptions","transformOptions","splitBundleOptions","dependencies","_bundler","getDependencies","shallow","lazy","_config","getMetroAssets","processModuleFilter","assetPlugins","transformer","publicPath"],"mappings":"AAAA;;;;QAgEsBA,kBAAkB,GAAlBA,kBAAkB;QAqKlBC,SAAS,GAATA,SAAS;AArOyC,IAAA,OAAc,WAAd,cAAc,CAAA;AAEpE,IAAA,MAAO,kCAAP,OAAO,EAAA;AACQ,IAAA,MAAO,kCAAP,OAAO,EAAA;AACb,IAAA,UAA8C,kCAA9C,8CAA8C,EAAA;AACtD,IAAA,OAAkB,kCAAlB,kBAAkB,EAAA;AACN,IAAA,mBAAkC,kCAAlC,kCAAkC,EAAA;AAQ1D,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;AAC4B,IAAA,yBAAgD,WAAhD,gDAAgD,CAAA;AAC9D,IAAA,iBAAwC,WAAxC,wCA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E,CAAC,CAAC;QAChB,MAAMV,KAAK,CAAC;KACb,QAAS;QACRlC,WAAW,CAACwD,GAAG,EAAE,CAAC;KACnB;CACF;AAIM,eAAejG,SAAS,CAC7BkG,KAAmB,EACnBC,OAA2B,EACI;IAC/B,MAAM,EAAEC,SAAS,CAAA,EAAErC,UAAU,CAAA,EAAEsC,eAAe,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAGC,CAAAA,GAAAA,mBAAkB,AAAS,CAAA,QAAT,CAACJ,OAAO,CAAC,AAAC;IAEjG,wDAAwD;IACxD,MAAMK,YAAY,GAAG,MAAMN,KAAK,CAACO,QAAQ,CAACC,eAAe,CACvD;QAACN,SAAS;KAAC,EACXE,gBAAgB,EAChBD,eAAe,EACf;QAAEtC,UAAU;QAAE4C,OAAO,EAAE,KAAK;QAAEC,IAAI,EAAE,KAAK;KAAE,CAC5C,AAAC;IAEF,mBAAmB;IACnB,MAAMC,QAAO,GAAGX,KAAK,CAACW,OAAO,AAAW,AAAC;IAEzC,OAAO,MAAMC,CAAAA,GAAAA,UAAc,AAMzB,CAAA,QANyB,CAACN,YAAY,EAAE;QACxCO,mBAAmB,EAAEF,QAAO,CAAC/C,UAAU,CAACiD,mBAAmB;QAC3DC,YAAY,EAAEH,QAAO,CAACI,WAAW,CAACD,YAAY;QAC9C3G,QAAQ,EAAEiG,gBAAgB,CAACjG,QAAQ;QACnCF,WAAW,EAAE0G,QAAO,CAAC1G,WAAW;QAChC+G,UAAU,EAAEL,QAAO,CAACI,WAAW,CAACC,UAAU;KAC3C,CAAC,CAAC;CACJ"}
1
+ {"version":3,"sources":["../../../src/export/fork-bundleAsync.ts"],"sourcesContent":["import { ExpoConfig, getConfigFilePaths, Platform, ProjectConfig } from '@expo/config';\nimport { LoadOptions } from '@expo/metro-config';\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport getMetroAssets from '@expo/metro-config/build/transform-worker/getAssets';\nimport assert from 'assert';\nimport Metro, { MixedOutput, Module, ReadOnlyGraph } from 'metro';\nimport type { TransformInputOptions } from 'metro/src/DeltaBundler/types';\nimport IncrementalBundler from 'metro/src/IncrementalBundler';\nimport Server from 'metro/src/Server';\nimport splitBundleOptions from 'metro/src/lib/splitBundleOptions';\nimport type {\n ResolverInputOptions,\n BundleOptions as MetroBundleOptions,\n} from 'metro/src/shared/types';\nimport { ConfigT } from 'metro-config';\nimport path from 'path';\n\nimport { isEnableHermesManaged, maybeThrowFromInconsistentEngineAsync } from './exportHermes';\nimport { loadMetroConfigAsync } from '../start/server/metro/instantiateMetro';\nimport { getEntryWithServerRoot } from '../start/server/middleware/ManifestMiddleware';\nimport {\n ExpoMetroBundleOptions,\n getMetroDirectBundleOptionsForExpoConfig,\n} from '../start/server/middleware/metroOptions';\n\nexport type MetroDevServerOptions = LoadOptions;\n\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n sourceMapUrl?: string;\n sourcemaps?: boolean;\n};\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\nexport type BundleOutput = {\n artifacts: SerialAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nlet nextBuildID = 0;\n\nasync function assertEngineMismatchAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'ios' | 'android' | 'jsEngine'>,\n platform: Platform\n) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\n\n const paths = getConfigFilePaths(projectRoot);\n const configFilePath = paths.dynamicConfigPath ?? paths.staticConfigPath ?? 'app.json';\n await maybeThrowFromInconsistentEngineAsync(\n projectRoot,\n configFilePath,\n platform,\n isHermesManaged\n );\n}\n\nexport async function createBundlesAsync(\n projectRoot: string,\n projectConfig: ProjectConfig,\n bundleOptions: {\n clear?: boolean;\n maxWorkers?: number;\n platforms: Platform[];\n dev?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n entryPoint?: string;\n }\n): Promise<Partial<Record<Platform, BundleOutput>>> {\n if (!bundleOptions.platforms.length) {\n return {};\n }\n const { exp, pkg } = projectConfig;\n\n const bundles = await bundleProductionMetroClientAsync(\n projectRoot,\n exp,\n {\n // If not legacy, ignore the target option to prevent warnings from being thrown.\n resetCache: bundleOptions.clear,\n maxWorkers: bundleOptions.maxWorkers,\n },\n bundleOptions.platforms.map((platform: Platform) => ({\n platform,\n entryPoint:\n bundleOptions.entryPoint ?? getEntryWithServerRoot(projectRoot, { platform, pkg }),\n sourcemaps: bundleOptions.sourcemaps,\n minify: bundleOptions.minify,\n dev: bundleOptions.dev,\n }))\n );\n\n // { ios: bundle, android: bundle }\n return bundleOptions.platforms.reduce<Partial<Record<Platform, BundleOutput>>>(\n (prev, platform, index) => ({\n ...prev,\n [platform]: bundles[index],\n }),\n {}\n );\n}\n\nasync function bundleProductionMetroClientAsync(\n projectRoot: string,\n expoConfig: ExpoConfig,\n metroOptions: MetroDevServerOptions,\n bundles: BundleOptions[]\n): Promise<BundleOutput[]> {\n // Assert early so the user doesn't have to wait until bundling is complete to find out that\n // Hermes won't be available.\n await Promise.all(\n bundles.map(({ platform }) => assertEngineMismatchAsync(projectRoot, expoConfig, platform))\n );\n\n const { config, reporter } = await loadMetroConfigAsync(projectRoot, metroOptions, {\n exp: expoConfig,\n isExporting: true,\n });\n\n const metroServer = await Metro.runMetro(config, {\n watch: false,\n });\n\n const buildAsync = async (bundle: BundleOptions): Promise<BundleOutput> => {\n const buildID = `bundle_${nextBuildID++}_${bundle.platform}`;\n const isHermes = isEnableHermesManaged(expoConfig, bundle.platform);\n if (isHermes) {\n await assertEngineMismatchAsync(projectRoot, expoConfig, bundle.platform);\n }\n const bundleOptions: MetroBundleOptions = {\n ...Server.DEFAULT_BUNDLE_OPTIONS,\n sourceMapUrl: bundle.sourceMapUrl,\n ...getMetroDirectBundleOptionsForExpoConfig(projectRoot, expoConfig, {\n mainModuleName: bundle.entryPoint,\n platform: bundle.platform,\n mode: bundle.dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: bundle.sourcemaps,\n // Bundle splitting on web-only for now.\n // serializerOutput: bundle.platform === 'web' ? 'static' : undefined,\n serializerOutput: 'static',\n serializerIncludeBytecode: isHermes,\n isExporting: true,\n }),\n bundleType: 'bundle',\n inlineSourceMap: false,\n createModuleIdFactory: config.serializer.createModuleIdFactory,\n onProgress: (transformedFileCount: number, totalFileCount: number) => {\n reporter.update({\n buildID,\n type: 'bundle_transform_progressed',\n transformedFileCount,\n totalFileCount,\n });\n },\n };\n\n const bundleDetails = {\n ...bundleOptions,\n buildID,\n };\n reporter.update({\n buildID,\n type: 'bundle_build_started',\n bundleDetails,\n });\n try {\n const artifacts = await forkMetroBuildAsync(metroServer, bundleOptions);\n reporter.update({\n buildID,\n type: 'bundle_build_done',\n });\n return artifacts;\n } catch (error) {\n reporter.update({\n buildID,\n type: 'bundle_build_failed',\n });\n\n throw error;\n }\n };\n\n try {\n return await Promise.all(bundles.map((bundle) => buildAsync(bundle)));\n } catch (error) {\n // New line so errors don't show up inline with the progress bar\n console.log('');\n throw error;\n } finally {\n metroServer.end();\n }\n}\n\n// Forked out of Metro because the `this._getServerRootDir()` doesn't match the development\n// behavior.\nexport async function getAssets(metro: Metro.Server, options: MetroBundleOptions) {\n const { entryFile, onProgress, resolverOptions, transformOptions } = splitBundleOptions(options);\n\n // @ts-expect-error: _bundler isn't exposed on the type.\n const dependencies = await metro._bundler.getDependencies(\n [entryFile],\n transformOptions,\n resolverOptions,\n { onProgress, shallow: false, lazy: false }\n );\n\n // @ts-expect-error\n const _config = metro._config as ConfigT;\n\n return getMetroAssets(dependencies, {\n processModuleFilter: _config.serializer.processModuleFilter,\n assetPlugins: _config.transformer.assetPlugins,\n platform: transformOptions.platform!,\n projectRoot: _config.projectRoot, // this._getServerRootDir(),\n publicPath: _config.transformer.publicPath,\n });\n}\n\nfunction isMetroServerInstance(metro: Metro.Server): metro is Metro.Server & {\n _shouldAddModuleToIgnoreList: (module: Module<MixedOutput>) => boolean;\n _bundler: IncrementalBundler;\n _config: ConfigT;\n _createModuleId: (path: string) => number;\n _resolveRelativePath(\n filePath: string,\n {\n relativeTo,\n resolverOptions,\n transformOptions,\n }: {\n relativeTo: 'project' | 'server';\n resolverOptions: ResolverInputOptions;\n transformOptions: TransformInputOptions;\n }\n ): Promise<string>;\n _getEntryPointAbsolutePath(entryFile: string): string;\n _getSortedModules(graph: ReadOnlyGraph): Module<MixedOutput>[];\n} {\n return '_shouldAddModuleToIgnoreList' in metro;\n}\n\nasync function forkMetroBuildAsync(\n metro: Metro.Server,\n options: ExpoMetroBundleOptions\n): Promise<{ artifacts: SerialAsset[]; assets: readonly BundleAssetWithFileHashes[] }> {\n if (!isMetroServerInstance(metro)) {\n throw new Error('Expected Metro server instance to have private functions exposed.');\n }\n\n if (options.serializerOptions?.output !== 'static') {\n throw new Error('Only multi-serializer output is supported.');\n }\n\n const {\n entryFile,\n graphOptions,\n onProgress,\n resolverOptions,\n serializerOptions,\n transformOptions,\n } = splitBundleOptions(options);\n\n const { prepend, graph } = await metro._bundler.buildGraph(\n entryFile,\n transformOptions,\n resolverOptions,\n {\n onProgress,\n shallow: graphOptions.shallow,\n // @ts-expect-error\n lazy: graphOptions.lazy,\n }\n );\n\n const entryPoint = metro._getEntryPointAbsolutePath(entryFile);\n\n const bundleOptions = {\n asyncRequireModulePath: await metro._resolveRelativePath(\n metro._config.transformer.asyncRequireModulePath,\n {\n relativeTo: 'project',\n resolverOptions,\n transformOptions,\n }\n ),\n processModuleFilter: metro._config.serializer.processModuleFilter,\n createModuleId: metro._createModuleId,\n getRunModuleStatement: metro._config.serializer.getRunModuleStatement,\n dev: transformOptions.dev,\n includeAsyncPaths: graphOptions.lazy,\n projectRoot: metro._config.projectRoot,\n modulesOnly: serializerOptions.modulesOnly,\n runBeforeMainModule: metro._config.serializer.getModulesRunBeforeMainModule(\n path.relative(metro._config.projectRoot, entryPoint)\n ),\n runModule: serializerOptions.runModule,\n sourceMapUrl: serializerOptions.sourceMapUrl,\n sourceUrl: serializerOptions.sourceUrl,\n inlineSourceMap: serializerOptions.inlineSourceMap,\n serverRoot: metro._config.server.unstable_serverRoot ?? metro._config.projectRoot,\n shouldAddToIgnoreList: (module: Module<MixedOutput>) =>\n metro._shouldAddModuleToIgnoreList(module),\n // Custom options we pass to the serializer to emulate the URL query parameters.\n serializerOptions: options.serializerOptions,\n };\n\n const bundle = await metro._config.serializer.customSerializer!(\n entryPoint,\n // @ts-expect-error: Metro is typed incorrectly\n prepend,\n graph,\n bundleOptions\n );\n\n try {\n const parsed = typeof bundle === 'string' ? JSON.parse(bundle) : bundle;\n\n assert(\n 'artifacts' in parsed && Array.isArray(parsed.artifacts),\n 'Expected serializer to return an object with key artifacts to contain an array of serial assets.'\n );\n return parsed;\n } catch (error: any) {\n throw new Error(\n 'Serializer did not return expected format. The project copy of `expo/metro-config` may be out of date. Error: ' +\n error.message\n );\n }\n}\n"],"names":["createBundlesAsync","getAssets","nextBuildID","assertEngineMismatchAsync","projectRoot","exp","platform","isHermesManaged","isEnableHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","maybeThrowFromInconsistentEngineAsync","projectConfig","bundleOptions","platforms","length","pkg","bundles","bundleProductionMetroClientAsync","resetCache","clear","maxWorkers","map","entryPoint","getEntryWithServerRoot","sourcemaps","minify","dev","reduce","prev","index","expoConfig","metroOptions","Promise","all","config","reporter","loadMetroConfigAsync","isExporting","metroServer","Metro","runMetro","watch","buildAsync","bundle","buildID","isHermes","Server","DEFAULT_BUNDLE_OPTIONS","sourceMapUrl","getMetroDirectBundleOptionsForExpoConfig","mainModuleName","mode","engine","undefined","serializerIncludeMaps","serializerOutput","serializerIncludeBytecode","bundleType","inlineSourceMap","createModuleIdFactory","serializer","onProgress","transformedFileCount","totalFileCount","update","type","bundleDetails","artifacts","forkMetroBuildAsync","error","console","log","end","metro","options","entryFile","resolverOptions","transformOptions","splitBundleOptions","dependencies","_bundler","getDependencies","shallow","lazy","_config","getMetroAssets","processModuleFilter","assetPlugins","transformer","publicPath","isMetroServerInstance","Error","serializerOptions","output","graphOptions","prepend","graph","buildGraph","_getEntryPointAbsolutePath","asyncRequireModulePath","_resolveRelativePath","relativeTo","createModuleId","_createModuleId","getRunModuleStatement","includeAsyncPaths","modulesOnly","runBeforeMainModule","getModulesRunBeforeMainModule","path","relative","runModule","sourceUrl","serverRoot","server","unstable_serverRoot","shouldAddToIgnoreList","module","_shouldAddModuleToIgnoreList","customSerializer","parsed","JSON","parse","assert","Array","isArray","message"],"mappings":"AAAA;;;;QA8DsBA,kBAAkB,GAAlBA,kBAAkB;QA4IlBC,SAAS,GAATA,SAAS;AA1MyC,IAAA,OAAc,WAAd,cAAc,CAAA;AAG3D,IAAA,UAAqD,kCAArD,qDAAqD,EAAA;AAC7D,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAC+B,IAAA,MAAO,kCAAP,OAAO,EAAA;AAG9C,IAAA,OAAkB,kCAAlB,kBAAkB,EAAA;AACN,IAAA,mBAAkC,kCAAlC,kCAAkC,EAAA;AAMhD,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEsD,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;AACxD,IAAA,iBAAwC,WAAxC,wCAAwC,CAAA;AACtC,IAAA,mBAA+C,WAA/C,+CAA+C,CAAA;AAI/E,IAAA,aAAyC,WAAzC,yCAAyC,CAAA;;;;;;AAoBhD,IAAIC,WAAW,GAAG,CAAC,AAAC;AAEpB,eAAeC,yBAAyB,CACtCC,WAAmB,EACnBC,GAAqD,EACrDC,QAAkB,EAClB;IACA,MAAMC,eAAe,GAAGC,CAAAA,GAAAA,aAAqB,AAAe,CAAA,sBAAf,CAACH,GAAG,EAAEC,QAAQ,CAAC,AAAC;IAE7D,MAAMG,KAAK,GAAGC,CAAAA,GAAAA,OAAkB,AAAa,CAAA,mBAAb,CAACN,WAAW,CAAC,AAAC;QACvBK,kBAAuB,EAAvBA,GAAiD;IAAxE,MAA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,MAAMjD,MAAM,GAAG,MAAM8B,KAAK,CAACW,OAAO,CAACxB,UAAU,CAAC2D,gBAAgB,CAC5DjG,UAAU,EACV,+CAA+C;IAC/CyE,OAAO,EACPC,KAAK,EACLpF,aAAa,CACd,AAAC;IAEF,IAAI;QACF,MAAM4G,MAAM,GAAG,OAAO7E,MAAM,KAAK,QAAQ,GAAG8E,IAAI,CAACC,KAAK,CAAC/E,MAAM,CAAC,GAAGA,MAAM,AAAC;QAExEgF,CAAAA,GAAAA,OAAM,AAGL,CAAA,QAHK,CACJ,WAAW,IAAIH,MAAM,IAAII,KAAK,CAACC,OAAO,CAACL,MAAM,CAACrD,SAAS,CAAC,EACxD,kGAAkG,CACnG,CAAC;QACF,OAAOqD,MAAM,CAAC;KACf,CAAC,OAAOnD,KAAK,EAAO;QACnB,MAAM,IAAIsB,KAAK,CACb,gHAAgH,GAC9GtB,KAAK,CAACyD,OAAO,CAChB,CAAC;KACH;CACF"}
@@ -29,7 +29,7 @@ function getAssetLocalPathAndroid(asset, { baseUrl , scale }) {
29
29
  }
30
30
  function getAssetLocalPathDefault(asset, { baseUrl , scale }) {
31
31
  const suffix = scale === 1 ? "" : `@${scale}x`;
32
- const fileName = `${asset.name + suffix}.${asset.type}`;
32
+ const fileName = `${asset.name}${suffix}.${asset.type}`;
33
33
  const adjustedHttpServerLocation = stripAssetPrefix(asset.httpServerLocation, baseUrl);
34
34
  return _path.default.join(// Assets can have relative paths outside of the project root.
35
35
  // Replace `../` with `_` to make sure they don't end up outside of
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/metroAssetLocalPath.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport type { AssetData } from 'metro';\nimport path from 'path';\n\nexport function getAssetLocalPath(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale, platform }: { baseUrl?: string; scale: number; platform: string }\n): string {\n if (platform === 'android') {\n return getAssetLocalPathAndroid(asset, { baseUrl, scale });\n }\n return getAssetLocalPathDefault(asset, { baseUrl, scale });\n}\n\nfunction getAssetLocalPathAndroid(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n {\n baseUrl,\n scale,\n }: {\n // TODO: baseUrl support\n baseUrl?: string;\n scale: number;\n }\n): string {\n const androidFolder = getAndroidResourceFolderName(asset, scale);\n const fileName = getResourceIdentifier(asset);\n return path.join(androidFolder, `${fileName}.${asset.type}`);\n}\n\nfunction getAssetLocalPathDefault(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale }: { baseUrl?: string; scale: number }\n): string {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n const fileName = `${asset.name + suffix}.${asset.type}`;\n\n const adjustedHttpServerLocation = stripAssetPrefix(asset.httpServerLocation, baseUrl);\n return path.join(\n // Assets can have relative paths outside of the project root.\n // Replace `../` with `_` to make sure they don't end up outside of\n // the expected assets directory.\n adjustedHttpServerLocation.replace(/^\\/+/g, '').replace(/\\.\\.\\//g, '_'),\n fileName\n );\n}\n\nexport function stripAssetPrefix(path: string, baseUrl?: string) {\n path = path.replace(/\\/assets\\?export_path=(.*)/, '$1');\n\n // TODO: Windows?\n if (baseUrl) {\n return path.replace(/^\\/+/g, '').replace(\n new RegExp(\n `^${baseUrl\n .replace(/^\\/+/g, '')\n .replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&')\n .replace(/-/g, '\\\\x2d')}`,\n 'g'\n ),\n ''\n );\n }\n return path;\n}\n\n/**\n * FIXME: using number to represent discrete scale numbers is fragile in essence because of\n * floating point numbers imprecision.\n */\nfunction getAndroidAssetSuffix(scale: number): string | null {\n switch (scale) {\n case 0.75:\n return 'ldpi';\n case 1:\n return 'mdpi';\n case 1.5:\n return 'hdpi';\n case 2:\n return 'xhdpi';\n case 3:\n return 'xxhdpi';\n case 4:\n return 'xxxhdpi';\n default:\n return null;\n }\n}\n\n// See https://developer.android.com/guide/topics/resources/drawable-resource.html\nconst drawableFileTypes = new Set<string>(['gif', 'jpeg', 'jpg', 'png', 'webp', 'xml']);\n\nfunction getAndroidResourceFolderName(asset: Pick<AssetData, 'type'>, scale: number): string {\n if (!drawableFileTypes.has(asset.type)) {\n return 'raw';\n }\n const suffix = getAndroidAssetSuffix(scale);\n if (!suffix) {\n throw new Error(\n `Asset \"${JSON.stringify(asset)}\" does not use a supported Android resolution suffix`\n );\n }\n return `drawable-${suffix}`;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["getAssetLocalPath","stripAssetPrefix","asset","baseUrl","scale","platform","getAssetLocalPathAndroid","getAssetLocalPathDefault","androidFolder","getAndroidResourceFolderName","fileName","getResourceIdentifier","path","join","type","suffix","name","adjustedHttpServerLocation","httpServerLocation","replace","RegExp","getAndroidAssetSuffix","drawableFileTypes","Set","has","Error","JSON","stringify","folderPath","getBaseUrl","toLowerCase","substring"],"mappings":"AAUA;;;;QAGgBA,iBAAiB,GAAjBA,iBAAiB;QA2CjBC,gBAAgB,GAAhBA,gBAAgB;AA7Cf,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAEhB,SA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CAACjB,KAAK,CAAC,AAAC;IAC5C,IAAI,CAACW,MAAM,EAAE;QACX,MAAM,IAAIU,KAAK,CACb,CAAC,OAAO,EAAEC,IAAI,CAACC,SAAS,CAACzB,KAAK,CAAC,CAAC,oDAAoD,CAAC,CACtF,CAAC;KACH;IACD,OAAO,CAAC,SAAS,EAAEa,MAAM,CAAC,CAAC,CAAC;CAC7B;AAED,SAASJ,qBAAqB,CAACT,KAAqD,EAAU;IAC5F,MAAM0B,UAAU,GAAGC,UAAU,CAAC3B,KAAK,CAAC,AAAC;IACrC,OAAO,CAAC,EAAE0B,UAAU,CAAC,CAAC,EAAE1B,KAAK,CAACc,IAAI,CAAC,CAAC,CACjCc,WAAW,EAAE,CACbX,OAAO,QAAQ,GAAG,CAAC,CAAC,uCAAuC;KAC3DA,OAAO,kBAAkB,EAAE,CAAC,CAAC,uBAAuB;KACpDA,OAAO,aAAa,EAAE,CAAC,CAAC,CAAC,0BAA0B;CACvD;AAED,SAASU,UAAU,CAAC3B,KAA4C,EAAU;IACxE,IAAIC,OAAO,GAAGD,KAAK,CAACgB,kBAAkB,AAAC;IACvC,IAAIf,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACtBA,OAAO,GAAGA,OAAO,CAAC4B,SAAS,CAAC,CAAC,CAAC,CAAC;KAChC;IACD,OAAO5B,OAAO,CAAC;CAChB"}
1
+ {"version":3,"sources":["../../../src/export/metroAssetLocalPath.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport type { AssetData } from 'metro';\nimport path from 'path';\n\nexport function getAssetLocalPath(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale, platform }: { baseUrl?: string; scale: number; platform: string }\n): string {\n if (platform === 'android') {\n return getAssetLocalPathAndroid(asset, { baseUrl, scale });\n }\n return getAssetLocalPathDefault(asset, { baseUrl, scale });\n}\n\nfunction getAssetLocalPathAndroid(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n {\n baseUrl,\n scale,\n }: {\n // TODO: baseUrl support\n baseUrl?: string;\n scale: number;\n }\n): string {\n const androidFolder = getAndroidResourceFolderName(asset, scale);\n const fileName = getResourceIdentifier(asset);\n return path.join(androidFolder, `${fileName}.${asset.type}`);\n}\n\nfunction getAssetLocalPathDefault(\n asset: Pick<AssetData, 'type' | 'httpServerLocation' | 'name'>,\n { baseUrl, scale }: { baseUrl?: string; scale: number }\n): string {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n const fileName = `${asset.name}${suffix}.${asset.type}`;\n\n const adjustedHttpServerLocation = stripAssetPrefix(asset.httpServerLocation, baseUrl);\n\n return path.join(\n // Assets can have relative paths outside of the project root.\n // Replace `../` with `_` to make sure they don't end up outside of\n // the expected assets directory.\n adjustedHttpServerLocation.replace(/^\\/+/g, '').replace(/\\.\\.\\//g, '_'),\n fileName\n );\n}\n\nexport function stripAssetPrefix(path: string, baseUrl?: string) {\n path = path.replace(/\\/assets\\?export_path=(.*)/, '$1');\n\n // TODO: Windows?\n if (baseUrl) {\n return path.replace(/^\\/+/g, '').replace(\n new RegExp(\n `^${baseUrl\n .replace(/^\\/+/g, '')\n .replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&')\n .replace(/-/g, '\\\\x2d')}`,\n 'g'\n ),\n ''\n );\n }\n return path;\n}\n\n/**\n * FIXME: using number to represent discrete scale numbers is fragile in essence because of\n * floating point numbers imprecision.\n */\nfunction getAndroidAssetSuffix(scale: number): string | null {\n switch (scale) {\n case 0.75:\n return 'ldpi';\n case 1:\n return 'mdpi';\n case 1.5:\n return 'hdpi';\n case 2:\n return 'xhdpi';\n case 3:\n return 'xxhdpi';\n case 4:\n return 'xxxhdpi';\n default:\n return null;\n }\n}\n\n// See https://developer.android.com/guide/topics/resources/drawable-resource.html\nconst drawableFileTypes = new Set<string>(['gif', 'jpeg', 'jpg', 'png', 'webp', 'xml']);\n\nfunction getAndroidResourceFolderName(asset: Pick<AssetData, 'type'>, scale: number): string {\n if (!drawableFileTypes.has(asset.type)) {\n return 'raw';\n }\n const suffix = getAndroidAssetSuffix(scale);\n if (!suffix) {\n throw new Error(\n `Asset \"${JSON.stringify(asset)}\" does not use a supported Android resolution suffix`\n );\n }\n return `drawable-${suffix}`;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["getAssetLocalPath","stripAssetPrefix","asset","baseUrl","scale","platform","getAssetLocalPathAndroid","getAssetLocalPathDefault","androidFolder","getAndroidResourceFolderName","fileName","getResourceIdentifier","path","join","type","suffix","name","adjustedHttpServerLocation","httpServerLocation","replace","RegExp","getAndroidAssetSuffix","drawableFileTypes","Set","has","Error","JSON","stringify","folderPath","getBaseUrl","toLowerCase","substring"],"mappings":"AAUA;;;;QAGgBA,iBAAiB,GAAjBA,iBAAiB;QA4CjBC,gBAAgB,GAAhBA,gBAAgB;AA9Cf,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAEhB,SAASD,iBAAiB,CAC/BE,KAA8D,EAC9D,EAAEC,OAAO,CAAA,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAy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AAO,EAAEC,IAAI,CAACC,SAAS,CAACzB,KAAK,CAAC,CAAC,oDAAoD,CAAC,CACtF,CAAC;KACH;IACD,OAAO,CAAC,SAAS,EAAEa,MAAM,CAAC,CAAC,CAAC;CAC7B;AAED,SAASJ,qBAAqB,CAACT,KAAqD,EAAU;IAC5F,MAAM0B,UAAU,GAAGC,UAAU,CAAC3B,KAAK,CAAC,AAAC;IACrC,OAAO,CAAC,EAAE0B,UAAU,CAAC,CAAC,EAAE1B,KAAK,CAACc,IAAI,CAAC,CAAC,CACjCc,WAAW,EAAE,CACbX,OAAO,QAAQ,GAAG,CAAC,CAAC,uCAAuC;KAC3DA,OAAO,kBAAkB,EAAE,CAAC,CAAC,uBAAuB;KACpDA,OAAO,aAAa,EAAE,CAAC,CAAC,CAAC,0BAA0B;CACvD;AAED,SAASU,UAAU,CAAC3B,KAA4C,EAAU;IACxE,IAAIC,OAAO,GAAGD,KAAK,CAACgB,kBAAkB,AAAC;IACvC,IAAIf,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACtBA,OAAO,GAAGA,OAAO,CAAC4B,SAAS,CAAC,CAAC,CAAC,CAAC;KAChC;IACD,OAAO5B,OAAO,CAAC;CAChB"}
@@ -21,12 +21,13 @@ function cleanAssetCatalog(catalogDir) {
21
21
  _fs.default.rmSync(_path.default.join(catalogDir, file1));
22
22
  }
23
23
  }
24
- function persistMetroAssetsAsync(assets, { platform , outputDirectory , baseUrl , iosAssetCatalogDirectory }) {
24
+ async function persistMetroAssetsAsync(assets, { platform , outputDirectory , baseUrl , iosAssetCatalogDirectory , files }) {
25
25
  if (outputDirectory == null) {
26
26
  _log.Log.warn("Assets destination folder is not set, skipping...");
27
27
  return;
28
28
  }
29
29
  let assetsToCopy = [];
30
+ // TODO: Use `files` as below to defer writing files
30
31
  if (platform === "ios" && iosAssetCatalogDirectory != null) {
31
32
  // Use iOS Asset Catalog for images. This will allow Apple app thinning to
32
33
  // remove unused scales from the optimized bundle.
@@ -51,23 +52,34 @@ function persistMetroAssetsAsync(assets, { platform , outputDirectory , baseUrl
51
52
  ...assets
52
53
  ];
53
54
  }
54
- const files = assetsToCopy.reduce((acc, asset)=>{
55
+ const batches = {};
56
+ async function write(src, dest) {
57
+ if (files) {
58
+ const data = await _fs.default.promises.readFile(src);
59
+ files.set(dest, {
60
+ contents: data,
61
+ targetDomain: platform === "web" ? "client" : undefined
62
+ });
63
+ } else {
64
+ batches[src] = _path.default.join(outputDirectory, dest);
65
+ }
66
+ }
67
+ for (const asset of assetsToCopy){
55
68
  const validScales = new Set(filterPlatformAssetScales(platform, asset.scales));
56
- asset.scales.forEach((scale, idx)=>{
57
- if (!validScales.has(scale)) {
58
- return;
69
+ for(let idx = 0; idx < asset.scales.length; idx++){
70
+ const scale = asset.scales[idx];
71
+ if (validScales.has(scale)) {
72
+ await write(asset.files[idx], (0, _metroAssetLocalPath).getAssetLocalPath(asset, {
73
+ platform,
74
+ scale,
75
+ baseUrl
76
+ }));
59
77
  }
60
- const src = asset.files[idx];
61
- const dest = _path.default.join(outputDirectory, (0, _metroAssetLocalPath).getAssetLocalPath(asset, {
62
- platform,
63
- scale,
64
- baseUrl
65
- }));
66
- acc[src] = dest;
67
- });
68
- return acc;
69
- }, {});
70
- return copyInBatchesAsync(files);
78
+ }
79
+ }
80
+ if (!files) {
81
+ await copyInBatchesAsync(batches);
82
+ }
71
83
  }
72
84
  function writeImageSet(imageSet) {
73
85
  _fs.default.mkdirSync(imageSet.baseUrl, {
@@ -124,7 +136,6 @@ function copyInBatchesAsync(filesToCopy) {
124
136
  const dest = filesToCopy[src];
125
137
  copy(src, dest, copyNext);
126
138
  } else {
127
- _log.Log.log("Persisted assets");
128
139
  resolve();
129
140
  }
130
141
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/persistMetroAssets.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport fs from 'fs';\nimport type { AssetData } from 'metro';\nimport path from 'path';\n\nimport { getAssetLocalPath } from './metroAssetLocalPath';\nimport { Log } from '../log';\n\nfunction cleanAssetCatalog(catalogDir: string): void {\n const files = fs.readdirSync(catalogDir).filter((file) => file.endsWith('.imageset'));\n for (const file of files) {\n fs.rmSync(path.join(catalogDir, file));\n }\n}\n\nexport function persistMetroAssetsAsync(\n assets: readonly AssetData[],\n {\n platform,\n outputDirectory,\n baseUrl,\n iosAssetCatalogDirectory,\n }: {\n platform: string;\n outputDirectory: string;\n baseUrl?: string;\n iosAssetCatalogDirectory?: string;\n }\n) {\n if (outputDirectory == null) {\n Log.warn('Assets destination folder is not set, skipping...');\n return;\n }\n\n let assetsToCopy: AssetData[] = [];\n\n if (platform === 'ios' && iosAssetCatalogDirectory != null) {\n // Use iOS Asset Catalog for images. This will allow Apple app thinning to\n // remove unused scales from the optimized bundle.\n const catalogDir = path.join(iosAssetCatalogDirectory, 'RNAssets.xcassets');\n if (!fs.existsSync(catalogDir)) {\n Log.error(\n `Could not find asset catalog 'RNAssets.xcassets' in ${iosAssetCatalogDirectory}. Make sure to create it if it does not exist.`\n );\n return;\n }\n\n Log.log('Adding images to asset catalog', catalogDir);\n cleanAssetCatalog(catalogDir);\n for (const asset of assets) {\n if (isCatalogAsset(asset)) {\n const imageSet = getImageSet(\n catalogDir,\n asset,\n filterPlatformAssetScales(platform, asset.scales)\n );\n writeImageSet(imageSet);\n } else {\n assetsToCopy.push(asset);\n }\n }\n Log.log('Done adding images to asset catalog');\n } else {\n assetsToCopy = [...assets];\n }\n\n const files = assetsToCopy.reduce<Record<string, string>>((acc, asset) => {\n const validScales = new Set(filterPlatformAssetScales(platform, asset.scales));\n\n asset.scales.forEach((scale, idx) => {\n if (!validScales.has(scale)) {\n return;\n }\n const src = asset.files[idx];\n const dest = path.join(\n outputDirectory,\n getAssetLocalPath(asset, { platform, scale, baseUrl })\n );\n acc[src] = dest;\n });\n return acc;\n }, {});\n\n return copyInBatchesAsync(files);\n}\n\nfunction writeImageSet(imageSet: ImageSet): void {\n fs.mkdirSync(imageSet.baseUrl, { recursive: true });\n\n for (const file of imageSet.files) {\n const dest = path.join(imageSet.baseUrl, file.name);\n fs.copyFileSync(file.src, dest);\n }\n\n fs.writeFileSync(\n path.join(imageSet.baseUrl, 'Contents.json'),\n JSON.stringify({\n images: imageSet.files.map((file) => ({\n filename: file.name,\n idiom: 'universal',\n scale: `${file.scale}x`,\n })),\n info: {\n author: 'expo',\n version: 1,\n },\n })\n );\n}\n\nfunction isCatalogAsset(asset: Pick<AssetData, 'type'>): boolean {\n return asset.type === 'png' || asset.type === 'jpg' || asset.type === 'jpeg';\n}\n\ntype ImageSet = {\n baseUrl: string;\n files: { name: string; src: string; scale: number }[];\n};\n\nfunction getImageSet(\n catalogDir: string,\n asset: Pick<AssetData, 'httpServerLocation' | 'name' | 'type' | 'files'>,\n scales: number[]\n): ImageSet {\n const fileName = getResourceIdentifier(asset);\n return {\n baseUrl: path.join(catalogDir, `${fileName}.imageset`),\n files: scales.map((scale, idx) => {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n return {\n name: `${fileName + suffix}.${asset.type}`,\n scale,\n src: asset.files[idx],\n };\n }),\n };\n}\n\nexport function copyInBatchesAsync(filesToCopy: Record<string, string>) {\n const queue = Object.keys(filesToCopy);\n if (queue.length === 0) {\n return;\n }\n\n Log.log(`Copying ${queue.length} asset files`);\n return new Promise<void>((resolve, reject) => {\n const copyNext = (error?: NodeJS.ErrnoException) => {\n if (error) {\n return reject(error);\n }\n if (queue.length) {\n // queue.length === 0 is checked in previous branch, so this is string\n const src = queue.shift() as string;\n const dest = filesToCopy[src];\n copy(src, dest, copyNext);\n } else {\n Log.log('Persisted assets');\n resolve();\n }\n };\n copyNext();\n });\n}\n\nfunction copy(src: string, dest: string, callback: (error: NodeJS.ErrnoException) => void): void {\n fs.mkdir(path.dirname(dest), { recursive: true }, (err?) => {\n if (err) {\n callback(err);\n return;\n }\n fs.createReadStream(src).pipe(fs.createWriteStream(dest)).on('finish', callback);\n });\n}\n\nconst ALLOWED_SCALES: { [key: string]: number[] } = {\n ios: [1, 2, 3],\n};\n\nexport function filterPlatformAssetScales(platform: string, scales: number[]): number[] {\n const whitelist: number[] = ALLOWED_SCALES[platform];\n if (!whitelist) {\n return scales;\n }\n const result = scales.filter((scale) => whitelist.includes(scale));\n if (!result.length && scales.length) {\n // No matching scale found, but there are some available. Ideally we don't\n // want to be in this situation and should throw, but for now as a fallback\n // let's just use the closest larger image\n const maxScale = whitelist[whitelist.length - 1];\n for (const scale of scales) {\n if (scale > maxScale) {\n result.push(scale);\n break;\n }\n }\n\n // There is no larger scales available, use the largest we have\n if (!result.length) {\n result.push(scales[scales.length - 1]);\n }\n }\n return result;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["persistMetroAssetsAsync","copyInBatchesAsync","filterPlatformAssetScales","cleanAssetCatalog","catalogDir","files","fs","readdirSync","filter","file","endsWith","rmSync","path","join","assets","platform","outputDirectory","baseUrl","iosAssetCatalogDirectory","Log","warn","assetsToCopy","existsSync","error","log","asset","isCatalogAsset","imageSet","getImageSet","scales","writeImageSet","push","reduce","acc","validScales","Set","forEach","scale","idx","has","src","dest","getAssetLocalPath","mkdirSync","recursive","name","copyFileSync","writeFileSync","JSON","stringify","images","map","filename","idiom","info","author","version","type","fileName","getResourceIdentifier","suffix","filesToCopy","queue","Object","keys","length","Promise","resolve","reject","copyNext","shift","copy","callback","mkdir","dirname","err","createReadStream","pipe","createWriteStream","on","ALLOWED_SCALES","ios","whitelist","result","includes","maxScale","folderPath","getBaseUrl","toLowerCase","replace","httpServerLocation","substring"],"mappings":"AAUA;;;;QAcgBA,uBAAuB,GAAvBA,uBAAuB;QA2HvBC,kBAAkB,GAAlBA,kBAAkB;QAwClBC,yBAAyB,GAAzBA,yBAAyB;AAjL1B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEW,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AACrC,IAAA,IAAQ,WAAR,QAAQ,CAAA;;;;;;AAE5B,SAASC,iBAAiB,CAACC,UAAkB,EAAQ;IACnD,MAAMC,KAAK,GAAGC,GAAE,QAAA,CAACC,WAAW,CAACH,UAAU,CAAC,CAACI,MAAM,CAAC,CAACC,IAAI,GAAKA,IAAI,CAACC,QAAQ,CAAC,WAAW,CAAC;IAAA,CAAC,AAAC;IACtF,KAAK,MAAMD,KAAI,IAAIJ,KAAK,CAAE;QACxBC,GAAE,QAAA,CAACK,MAAM,CAACC,KAAI,QAAA,CAACC,IAAI,CAACT,UAAU,EAAEK,KAAI,CAAC,CAAC,CAAC;KACxC;CACF;AAEM,SAAST,uBAAuB,CACrCc,MAA4B,EAC5B,EACEC,QAAQ,CAAA,EACRC,eAAe,CAAA,EACfC,OAAO,CAAA,EACPC,wBAAwB,CAAA,EAMzB,EACD;IACA,IAAIF,eAAe,IAAI,IAAI,EAAE;QAC3BG,IAAG,IAAA,CAACC,IAAI,CAAC,mDAAmD,CAAC,CAAC;QAC9D,OAAO;KACR;IAED,IAAIC,YAAY,GAAgB,EAAE,AAAC;IAEnC,IAAIN,QAAQ,KAAK,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,CAAC,uBAAuB;KACpDA,OAAO,aAAa,EAAE,CAAC,CAAC,CAAC,0BAA0B;CACvD;AAED,SAASF,UAAU,CAAC9D,KAA4C,EAAU;IACxE,IAAIR,OAAO,GAAGQ,KAAK,CAACiE,kBAAkB,AAAC;IACvC,IAAIzE,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACtBA,OAAO,GAAGA,OAAO,CAAC0E,SAAS,CAAC,CAAC,CAAC,CAAC;KAChC;IACD,OAAO1E,OAAO,CAAC;CAChB"}
1
+ {"version":3,"sources":["../../../src/export/persistMetroAssets.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on the community asset persisting for Metro but with base path and web support:\n * https://github.com/facebook/react-native/blob/d6e0bc714ad4d215ede4949d3c4f44af6dea5dd3/packages/community-cli-plugin/src/commands/bundle/saveAssets.js#L1\n */\nimport fs from 'fs';\nimport type { AssetData } from 'metro';\nimport path from 'path';\n\nimport { getAssetLocalPath } from './metroAssetLocalPath';\nimport { ExportAssetMap } from './saveAssets';\nimport { Log } from '../log';\n\nfunction cleanAssetCatalog(catalogDir: string): void {\n const files = fs.readdirSync(catalogDir).filter((file) => file.endsWith('.imageset'));\n for (const file of files) {\n fs.rmSync(path.join(catalogDir, file));\n }\n}\n\nexport async function persistMetroAssetsAsync(\n assets: readonly AssetData[],\n {\n platform,\n outputDirectory,\n baseUrl,\n iosAssetCatalogDirectory,\n files,\n }: {\n platform: string;\n outputDirectory: string;\n baseUrl?: string;\n iosAssetCatalogDirectory?: string;\n files?: ExportAssetMap;\n }\n) {\n if (outputDirectory == null) {\n Log.warn('Assets destination folder is not set, skipping...');\n return;\n }\n\n let assetsToCopy: AssetData[] = [];\n\n // TODO: Use `files` as below to defer writing files\n if (platform === 'ios' && iosAssetCatalogDirectory != null) {\n // Use iOS Asset Catalog for images. This will allow Apple app thinning to\n // remove unused scales from the optimized bundle.\n const catalogDir = path.join(iosAssetCatalogDirectory, 'RNAssets.xcassets');\n if (!fs.existsSync(catalogDir)) {\n Log.error(\n `Could not find asset catalog 'RNAssets.xcassets' in ${iosAssetCatalogDirectory}. Make sure to create it if it does not exist.`\n );\n return;\n }\n\n Log.log('Adding images to asset catalog', catalogDir);\n cleanAssetCatalog(catalogDir);\n for (const asset of assets) {\n if (isCatalogAsset(asset)) {\n const imageSet = getImageSet(\n catalogDir,\n asset,\n filterPlatformAssetScales(platform, asset.scales)\n );\n writeImageSet(imageSet);\n } else {\n assetsToCopy.push(asset);\n }\n }\n Log.log('Done adding images to asset catalog');\n } else {\n assetsToCopy = [...assets];\n }\n\n const batches: Record<string, string> = {};\n\n async function write(src: string, dest: string) {\n if (files) {\n const data = await fs.promises.readFile(src);\n files.set(dest, {\n contents: data,\n targetDomain: platform === 'web' ? 'client' : undefined,\n });\n } else {\n batches[src] = path.join(outputDirectory, dest);\n }\n }\n\n for (const asset of assetsToCopy) {\n const validScales = new Set(filterPlatformAssetScales(platform, asset.scales));\n for (let idx = 0; idx < asset.scales.length; idx++) {\n const scale = asset.scales[idx];\n if (validScales.has(scale)) {\n await write(asset.files[idx], getAssetLocalPath(asset, { platform, scale, baseUrl }));\n }\n }\n }\n\n if (!files) {\n await copyInBatchesAsync(batches);\n }\n}\n\nfunction writeImageSet(imageSet: ImageSet): void {\n fs.mkdirSync(imageSet.baseUrl, { recursive: true });\n\n for (const file of imageSet.files) {\n const dest = path.join(imageSet.baseUrl, file.name);\n fs.copyFileSync(file.src, dest);\n }\n\n fs.writeFileSync(\n path.join(imageSet.baseUrl, 'Contents.json'),\n JSON.stringify({\n images: imageSet.files.map((file) => ({\n filename: file.name,\n idiom: 'universal',\n scale: `${file.scale}x`,\n })),\n info: {\n author: 'expo',\n version: 1,\n },\n })\n );\n}\n\nfunction isCatalogAsset(asset: Pick<AssetData, 'type'>): boolean {\n return asset.type === 'png' || asset.type === 'jpg' || asset.type === 'jpeg';\n}\n\ntype ImageSet = {\n baseUrl: string;\n files: { name: string; src: string; scale: number }[];\n};\n\nfunction getImageSet(\n catalogDir: string,\n asset: Pick<AssetData, 'httpServerLocation' | 'name' | 'type' | 'files'>,\n scales: number[]\n): ImageSet {\n const fileName = getResourceIdentifier(asset);\n return {\n baseUrl: path.join(catalogDir, `${fileName}.imageset`),\n files: scales.map((scale, idx) => {\n const suffix = scale === 1 ? '' : `@${scale}x`;\n return {\n name: `${fileName + suffix}.${asset.type}`,\n scale,\n src: asset.files[idx],\n };\n }),\n };\n}\n\nexport function copyInBatchesAsync(filesToCopy: Record<string, string>) {\n const queue = Object.keys(filesToCopy);\n if (queue.length === 0) {\n return;\n }\n\n Log.log(`Copying ${queue.length} asset files`);\n return new Promise<void>((resolve, reject) => {\n const copyNext = (error?: NodeJS.ErrnoException) => {\n if (error) {\n return reject(error);\n }\n if (queue.length) {\n // queue.length === 0 is checked in previous branch, so this is string\n const src = queue.shift() as string;\n const dest = filesToCopy[src];\n copy(src, dest, copyNext);\n } else {\n resolve();\n }\n };\n copyNext();\n });\n}\n\nfunction copy(src: string, dest: string, callback: (error: NodeJS.ErrnoException) => void): void {\n fs.mkdir(path.dirname(dest), { recursive: true }, (err?) => {\n if (err) {\n callback(err);\n return;\n }\n fs.createReadStream(src).pipe(fs.createWriteStream(dest)).on('finish', callback);\n });\n}\n\nconst ALLOWED_SCALES: { [key: string]: number[] } = {\n ios: [1, 2, 3],\n};\n\nexport function filterPlatformAssetScales(platform: string, scales: number[]): number[] {\n const whitelist: number[] = ALLOWED_SCALES[platform];\n if (!whitelist) {\n return scales;\n }\n const result = scales.filter((scale) => whitelist.includes(scale));\n if (!result.length && scales.length) {\n // No matching scale found, but there are some available. Ideally we don't\n // want to be in this situation and should throw, but for now as a fallback\n // let's just use the closest larger image\n const maxScale = whitelist[whitelist.length - 1];\n for (const scale of scales) {\n if (scale > maxScale) {\n result.push(scale);\n break;\n }\n }\n\n // There is no larger scales available, use the largest we have\n if (!result.length) {\n result.push(scales[scales.length - 1]);\n }\n }\n return result;\n}\n\nfunction getResourceIdentifier(asset: Pick<AssetData, 'httpServerLocation' | 'name'>): string {\n const folderPath = getBaseUrl(asset);\n return `${folderPath}/${asset.name}`\n .toLowerCase()\n .replace(/\\//g, '_') // Encode folder structure in file name\n .replace(/([^a-z0-9_])/g, '') // Remove illegal chars\n .replace(/^assets_/, ''); // Remove \"assets_\" prefix\n}\n\nfunction getBaseUrl(asset: Pick<AssetData, 'httpServerLocation'>): string {\n let baseUrl = asset.httpServerLocation;\n if (baseUrl[0] === '/') {\n baseUrl = baseUrl.substring(1);\n }\n return baseUrl;\n}\n"],"names":["persistMetroAssetsAsync","copyInBatchesAsync","filterPlatformAssetScales","cleanAssetCatalog","catalogDir","files","fs","readdirSync","filter","file","endsWith","rmSync","path","join","assets","platform","outputDirectory","baseUrl","iosAssetCatalogDirectory","Log","warn","assetsToCopy","existsSync","error","log","asset","isCatalogAsset","imageSet","getImageSet","scales","writeImageSet","push","batches","write","src","dest","data","promises","readFile","set","contents","targetDomain","undefined","validScales","Set","idx","length","scale","has","getAssetLocalPath","mkdirSync","recursive","name","copyFileSync","writeFileSync","JSON","stringify","images","map","filename","idiom","info","author","version","type","fileName","getResourceIdentifier","suffix","filesToCopy","queue","Object","keys","Promise","resolve","reject","copyNext","shift","copy","callback","mkdir","dirname","err","createReadStream","pipe","createWriteStream","on","ALLOWED_SCALES","ios","whitelist","result","includes","maxScale","folderPath","getBaseUrl","toLowerCase","replace","httpServerLocation","substring"],"mappings":"AAUA;;;;QAesBA,uBAAuB,GAAvBA,uBAAuB;QAuI7BC,kBAAkB,GAAlBA,kBAAkB;QAuClBC,yBAAyB,GAAzBA,yBAAyB;AA7L1B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEW,IAAA,oBAAuB,WAAvB,uBAAuB,CAAA;AAErC,IAAA,IAAQ,WAAR,QAAQ,CAAA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C;IACvC,IAAI/E,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACtBA,OAAO,GAAGA,OAAO,CAACgF,SAAS,CAAC,CAAC,CAAC,CAAC;KAChC;IACD,OAAOhF,OAAO,CAAC;CAChB"}
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.getUserDefinedFile = getUserDefinedFile;
6
+ exports.copyPublicFolderAsync = copyPublicFolderAsync;
6
7
  var _fs = _interopRequireDefault(require("fs"));
7
8
  var _path = _interopRequireDefault(require("path"));
9
+ var _dir = require("../utils/dir");
8
10
  var _env = require("../utils/env");
9
11
  function _interopRequireDefault(obj) {
10
12
  return obj && obj.__esModule ? obj : {
@@ -23,5 +25,10 @@ function getUserDefinedFile(projectRoot, possiblePaths) {
23
25
  }
24
26
  return null;
25
27
  }
28
+ async function copyPublicFolderAsync(publicFolder, outputFolder) {
29
+ if (_fs.default.existsSync(publicFolder)) {
30
+ await (0, _dir).copyAsync(publicFolder, outputFolder);
31
+ }
32
+ }
26
33
 
27
34
  //# sourceMappingURL=publicFolder.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/publicFolder.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { env } from '../utils/env';\n\nconst debug = require('debug')('expo:public-folder') as typeof console.log;\n\n/** @returns the file system path for a user-defined file in the public folder. */\nexport function getUserDefinedFile(projectRoot: string, possiblePaths: string[]): string | null {\n const publicPath = path.join(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n for (const possiblePath of possiblePaths) {\n const fullPath = path.join(publicPath, possiblePath);\n if (fs.existsSync(fullPath)) {\n debug(`Found user-defined public file: ` + possiblePath);\n return fullPath;\n }\n }\n\n return null;\n}\n"],"names":["getUserDefinedFile","debug","require","projectRoot","possiblePaths","publicPath","path","join","env","EXPO_PUBLIC_FOLDER","possiblePath","fullPath","fs","existsSync"],"mappings":"AAAA;;;;QAQgBA,kBAAkB,GAAlBA,kBAAkB;AARnB,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEH,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;AAElC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAsB,AAAC;AAGpE,SAASF,kBAAkB,CAACG,WAAmB,EAAEC,aAAuB,EAAiB;IAC9F,MAAMC,UAAU,GAAGC,KAAI,QAAA,CAACC,IAAI,CAACJ,WAAW,EAAEK,IAAG,IAAA,CAACC,kBAAkB,CAAC,AAAC;IAElE,KAAK,MAAMC,YAAY,IAAIN,aAAa,CAAE;QACxC,MAAMO,QAAQ,GAAGL,KAAI,QAAA,CAACC,IAAI,CAACF,UAAU,EAAEK,YAAY,CAAC,AAAC;QACrD,IAAIE,GAAE,QAAA,CAACC,UAAU,CAACF,QAAQ,CAAC,EAAE;YAC3BV,KAAK,CAAC,CAAC,gCAAgC,CAAC,GAAGS,YAAY,CAAC,CAAC;YACzD,OAAOC,QAAQ,CAAC;SACjB;KACF;IAED,OAAO,IAAI,CAAC;CACb"}
1
+ {"version":3,"sources":["../../../src/export/publicFolder.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { copyAsync } from '../utils/dir';\nimport { env } from '../utils/env';\n\nconst debug = require('debug')('expo:public-folder') as typeof console.log;\n\n/** @returns the file system path for a user-defined file in the public folder. */\nexport function getUserDefinedFile(projectRoot: string, possiblePaths: string[]): string | null {\n const publicPath = path.join(projectRoot, env.EXPO_PUBLIC_FOLDER);\n\n for (const possiblePath of possiblePaths) {\n const fullPath = path.join(publicPath, possiblePath);\n if (fs.existsSync(fullPath)) {\n debug(`Found user-defined public file: ` + possiblePath);\n return fullPath;\n }\n }\n\n return null;\n}\n\n/**\n * Copy the contents of the public folder into the output folder.\n * This enables users to add static files like `favicon.ico` or `serve.json`.\n *\n * The contents of this folder are completely universal since they refer to\n * static network requests which fall outside the scope of React Native's magic\n * platform resolution patterns.\n */\nexport async function copyPublicFolderAsync(publicFolder: string, outputFolder: string) {\n if (fs.existsSync(publicFolder)) {\n await copyAsync(publicFolder, outputFolder);\n }\n}\n"],"names":["getUserDefinedFile","copyPublicFolderAsync","debug","require","projectRoot","possiblePaths","publicPath","path","join","env","EXPO_PUBLIC_FOLDER","possiblePath","fullPath","fs","existsSync","publicFolder","outputFolder","copyAsync"],"mappings":"AAAA;;;;QASgBA,kBAAkB,GAAlBA,kBAAkB;QAsBZC,qBAAqB,GAArBA,qBAAqB;AA/B5B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AAEG,IAAA,IAAc,WAAd,cAAc,CAAA;AACpB,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;AAElC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC,AAAsB,AAAC;AAGpE,SAASH,kBAAkB,CAACI,WAAmB,EAAEC,aAAuB,EAAiB;IAC9F,MAAMC,UAAU,GAAGC,KAAI,QAAA,CAACC,IAAI,CAACJ,WAAW,EAAEK,IAAG,IAAA,CAACC,kBAAkB,CAAC,AAAC;IAElE,KAAK,MAAMC,YAAY,IAAIN,aAAa,CAAE;QACxC,MAAMO,QAAQ,GAAGL,KAAI,QAAA,CAACC,IAAI,CAACF,UAAU,EAAEK,YAAY,CAAC,AAAC;QACrD,IAAIE,GAAE,QAAA,CAACC,UAAU,CAACF,QAAQ,CAAC,EAAE;YAC3BV,KAAK,CAAC,CAAC,gCAAgC,CAAC,GAAGS,YAAY,CAAC,CAAC;YACzD,OAAOC,QAAQ,CAAC;SACjB;KACF;IAED,OAAO,IAAI,CAAC;CACb;AAUM,eAAeX,qBAAqB,CAACc,YAAoB,EAAEC,YAAoB,EAAE;IACtF,IAAIH,GAAE,QAAA,CAACC,UAAU,CAACC,YAAY,CAAC,EAAE;QAC/B,MAAME,CAAAA,GAAAA,IAAS,AAA4B,CAAA,UAA5B,CAACF,YAAY,EAAEC,YAAY,CAAC,CAAC;KAC7C;CACF"}