@expo/cli 1.0.0-canary-20250219-4a5dade → 1.0.0-canary-20250303-4dba60e

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 (31) hide show
  1. package/build/bin/cli +1 -1
  2. package/build/metro-require/require.js +11 -11
  3. package/build/src/customize/generate.js +1 -4
  4. package/build/src/customize/generate.js.map +1 -1
  5. package/build/src/export/exportDomComponents.js +17 -4
  6. package/build/src/export/exportDomComponents.js.map +1 -1
  7. package/build/src/export/exportHermes.js +21 -21
  8. package/build/src/export/exportHermes.js.map +1 -1
  9. package/build/src/export/publicFolder.js +1 -3
  10. package/build/src/export/publicFolder.js.map +1 -1
  11. package/build/src/prebuild/renameTemplateAppName.js +9 -9
  12. package/build/src/prebuild/renameTemplateAppName.js.map +1 -1
  13. package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js +2 -1
  14. package/build/src/run/ios/appleDevice/client/UsbmuxdClient.js.map +1 -1
  15. package/build/src/start/server/metro/createServerRouteMiddleware.js +1 -1
  16. package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
  17. package/build/src/start/server/metro/instantiateMetro.js +10 -9
  18. package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
  19. package/build/src/start/server/metro/withMetroMultiPlatform.js +4 -0
  20. package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
  21. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +17 -20
  22. package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
  23. package/build/src/start/server/type-generation/routes.js +8 -8
  24. package/build/src/start/server/type-generation/routes.js.map +1 -1
  25. package/build/src/utils/dir.js +32 -7
  26. package/build/src/utils/dir.js.map +1 -1
  27. package/build/src/utils/multipartMixed.js +54 -0
  28. package/build/src/utils/multipartMixed.js.map +1 -0
  29. package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
  30. package/build/src/utils/telemetry/utils/context.js +1 -1
  31. package/package.json +16 -24
package/build/bin/cli CHANGED
@@ -121,7 +121,7 @@ const args = (0, _arg().default)({
121
121
  });
122
122
  if (args["--version"]) {
123
123
  // Version is added in the build script.
124
- console.log("1.0.0-canary-20250219-4a5dade");
124
+ console.log("1.0.0-canary-20250303-4dba60e");
125
125
  process.exit(0);
126
126
  }
127
127
  if (args["--non-interactive"]) {
@@ -47,7 +47,7 @@ function define(factory, moduleId, dependencyMap) {
47
47
  }
48
48
  }
49
49
  }
50
- function metroRequire(moduleId) {
50
+ function metroRequire(moduleId, moduleIdHint) {
51
51
  if (__DEV__) {
52
52
  const initializingIndex = initializingModuleIds.indexOf(moduleId);
53
53
  if (initializingIndex !== -1) {
@@ -62,7 +62,7 @@ function metroRequire(moduleId) {
62
62
  }
63
63
  }
64
64
  const module = modules.get(moduleId);
65
- return module && module.isInitialized ? module.publicModule.exports : guardedLoadModule(moduleId, module);
65
+ return module && module.isInitialized ? module.publicModule.exports : guardedLoadModule(moduleId, module, moduleIdHint);
66
66
  }
67
67
  function shouldPrintRequireCycle(modules) {
68
68
  const rcip = __METRO_GLOBAL_PREFIX__ + "__requireCycleIgnorePatterns";
@@ -121,7 +121,7 @@ metroRequire.resolveWeak = function fallbackRequireResolveWeak() {
121
121
  }
122
122
  throw new Error("require.resolveWeak cannot be called dynamically.");
123
123
  };
124
- metroRequire.unguarded = function requireUnguarded(moduleId) {
124
+ metroRequire.unguarded = function requireUnguarded(moduleId, moduleIdHint) {
125
125
  if (__DEV__) {
126
126
  const initializingIndex = initializingModuleIds.indexOf(moduleId);
127
127
  if (initializingIndex !== -1) {
@@ -136,22 +136,22 @@ metroRequire.unguarded = function requireUnguarded(moduleId) {
136
136
  }
137
137
  }
138
138
  const module = modules.get(moduleId);
139
- return module && module.isInitialized ? module.publicModule.exports : loadModuleImplementation(moduleId, module);
139
+ return module && module.isInitialized ? module.publicModule.exports : loadModuleImplementation(moduleId, module, moduleIdHint);
140
140
  };
141
141
  let inGuard = false;
142
- function guardedLoadModule(moduleId, module) {
142
+ function guardedLoadModule(moduleId, module, moduleIdHint) {
143
143
  if (!inGuard && global.ErrorUtils) {
144
144
  inGuard = true;
145
145
  let returnValue;
146
146
  try {
147
- returnValue = loadModuleImplementation(moduleId, module);
147
+ returnValue = loadModuleImplementation(moduleId, module, moduleIdHint);
148
148
  } catch (e) {
149
149
  global.ErrorUtils.reportFatalError(e);
150
150
  }
151
151
  inGuard = false;
152
152
  return returnValue;
153
153
  } else {
154
- return loadModuleImplementation(moduleId, module);
154
+ return loadModuleImplementation(moduleId, module, moduleIdHint);
155
155
  }
156
156
  }
157
157
  const ID_MASK_SHIFT = 16;
@@ -192,7 +192,7 @@ function registerSegment(segmentId, moduleDefiner, moduleIds) {
192
192
  });
193
193
  }
194
194
  }
195
- function loadModuleImplementation(moduleId, module) {
195
+ function loadModuleImplementation(moduleId, module, moduleIdHint) {
196
196
  if (!module && moduleDefinersBySegmentID.length > 0) {
197
197
  const segmentId = definingSegmentByModuleID.get(moduleId) ?? 0;
198
198
  const definer = moduleDefinersBySegmentID[segmentId];
@@ -203,7 +203,7 @@ function loadModuleImplementation(moduleId, module) {
203
203
  }
204
204
  }
205
205
  if (!module) {
206
- throw unknownModuleError(moduleId);
206
+ throw unknownModuleError(moduleId, moduleIdHint);
207
207
  }
208
208
  if (module.hasError) {
209
209
  throw module.error;
@@ -263,8 +263,8 @@ function loadModuleImplementation(moduleId, module) {
263
263
  }
264
264
  }
265
265
  }
266
- function unknownModuleError(id) {
267
- let message = 'Requiring unknown module "' + id + '".';
266
+ function unknownModuleError(id, moduleIdHint) {
267
+ let message = 'Requiring unknown module "' + (id ?? moduleIdHint ?? `[unknown optional import]`) + '".';
268
268
  if (__DEV__) {
269
269
  message += " If you are sure the module exists, try restarting Metro. " + "You may also want to run `yarn` or `npm install`.";
270
270
  }
@@ -74,10 +74,7 @@ async function generateAsync(projectRoot, { answer , props , extras }) {
74
74
  }
75
75
  const projectFilePath = _path().default.resolve(projectRoot, template.destination(props));
76
76
  // copy the file from template
77
- return (0, _dir.copyAsync)(template.file(projectRoot), projectFilePath, {
78
- overwrite: true,
79
- recursive: true
80
- });
77
+ return (0, _dir.copyAsync)(template.file(projectRoot), projectFilePath);
81
78
  }));
82
79
  // Install dependencies
83
80
  const packages = answer.map((file)=>_templates.TEMPLATES[file].dependencies).flat().filter((pkg)=>!_resolveFrom().default.silent(projectRoot, pkg));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/customize/generate.ts"],"sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { DestinationResolutionProps, selectTemplatesAsync, TEMPLATES } from './templates';\nimport { installAsync } from '../install/installAsync';\nimport { Log } from '../log';\nimport { copyAsync } from '../utils/dir';\nimport { CommandError } from '../utils/errors';\n\nexport async function queryAndGenerateAsync(\n projectRoot: string,\n {\n files,\n props,\n extras,\n }: {\n files: string[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const valid = files.filter(\n (file) => !!TEMPLATES.find((template) => template.destination(props) === file)\n );\n\n if (valid.length !== files.length) {\n const diff = files.filter(\n (file) => !TEMPLATES.find((template) => template.destination(props) === file)\n );\n throw new CommandError(\n `Invalid files: ${diff.join(', ')}. Allowed: ${TEMPLATES.map((template) =>\n template.destination(props)\n ).join(', ')}`\n );\n }\n\n if (!valid.length) {\n return;\n }\n Log.log(`Generating: ${valid.join(', ')}`);\n return generateAsync(projectRoot, {\n answer: files.map((file) =>\n TEMPLATES.findIndex((template) => template.destination(props) === file)\n ),\n props,\n extras,\n });\n}\n\n/** Select templates to generate then generate and install. */\nexport async function selectAndGenerateAsync(\n projectRoot: string,\n {\n props,\n extras,\n }: {\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const answer = await selectTemplatesAsync(projectRoot, props);\n\n if (!answer?.length) {\n Log.exit('\\n\\u203A Exiting with no change...', 0);\n }\n\n await generateAsync(projectRoot, {\n answer,\n props,\n extras,\n });\n}\n\nasync function generateAsync(\n projectRoot: string,\n {\n answer,\n props,\n extras,\n }: {\n answer: number[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n // Copy files\n await Promise.all(\n answer.map(async (file) => {\n const template = TEMPLATES[file];\n\n if (template.configureAsync) {\n if (await template.configureAsync(projectRoot)) {\n return;\n }\n }\n\n const projectFilePath = path.resolve(projectRoot, template.destination(props));\n // copy the file from template\n return copyAsync(template.file(projectRoot), projectFilePath, {\n overwrite: true,\n recursive: true,\n });\n })\n );\n\n // Install dependencies\n const packages = answer\n .map((file) => TEMPLATES[file].dependencies)\n .flat()\n .filter((pkg) => !resolveFrom.silent(projectRoot, pkg));\n if (packages.length) {\n Log.debug('Installing ' + packages.join(', '));\n await installAsync(packages, {}, ['--dev', ...extras]);\n }\n}\n"],"names":["queryAndGenerateAsync","selectAndGenerateAsync","projectRoot","files","props","extras","valid","filter","file","TEMPLATES","find","template","destination","length","diff","CommandError","join","map","Log","log","generateAsync","answer","findIndex","selectTemplatesAsync","exit","Promise","all","configureAsync","projectFilePath","path","resolve","copyAsync","overwrite","recursive","packages","dependencies","flat","pkg","resolveFrom","silent","debug","installAsync"],"mappings":"AAAA;;;;;;;;;;;IASsBA,qBAAqB,MAArBA,qBAAqB;IA0CrBC,sBAAsB,MAAtBA,sBAAsB;;;8DAnD3B,MAAM;;;;;;;8DACC,cAAc;;;;;;2BAEsC,aAAa;8BAC5D,yBAAyB;qBAClC,QAAQ;qBACF,cAAc;wBACX,iBAAiB;;;;;;AAEvC,eAAeD,qBAAqB,CACzCE,WAAmB,EACnB,EACEC,KAAK,CAAA,EACLC,KAAK,CAAA,EACLC,MAAM,CAAA,EAMP,EACD;IACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CACxB,CAACC,IAAI,GAAK,CAAC,CAACC,UAAS,UAAA,CAACC,IAAI,CAAC,CAACC,QAAQ,GAAKA,QAAQ,CAACC,WAAW,CAACR,KAAK,C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M,CAACrC,WAAW,EAAEmC,GAAG,CAAC,CAAC,AAAC;IAC1D,IAAIH,QAAQ,CAACrB,MAAM,EAAE;QACnBK,IAAG,IAAA,CAACsB,KAAK,CAAC,aAAa,GAAGN,QAAQ,CAAClB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,MAAMyB,IAAAA,aAAY,aAAA,EAACP,QAAQ,EAAE,EAAE,EAAE;YAAC,OAAO;eAAK7B,MAAM;SAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
1
+ {"version":3,"sources":["../../../src/customize/generate.ts"],"sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { DestinationResolutionProps, selectTemplatesAsync, TEMPLATES } from './templates';\nimport { installAsync } from '../install/installAsync';\nimport { Log } from '../log';\nimport { copyAsync } from '../utils/dir';\nimport { CommandError } from '../utils/errors';\n\nexport async function queryAndGenerateAsync(\n projectRoot: string,\n {\n files,\n props,\n extras,\n }: {\n files: string[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const valid = files.filter(\n (file) => !!TEMPLATES.find((template) => template.destination(props) === file)\n );\n\n if (valid.length !== files.length) {\n const diff = files.filter(\n (file) => !TEMPLATES.find((template) => template.destination(props) === file)\n );\n throw new CommandError(\n `Invalid files: ${diff.join(', ')}. Allowed: ${TEMPLATES.map((template) =>\n template.destination(props)\n ).join(', ')}`\n );\n }\n\n if (!valid.length) {\n return;\n }\n Log.log(`Generating: ${valid.join(', ')}`);\n return generateAsync(projectRoot, {\n answer: files.map((file) =>\n TEMPLATES.findIndex((template) => template.destination(props) === file)\n ),\n props,\n extras,\n });\n}\n\n/** Select templates to generate then generate and install. */\nexport async function selectAndGenerateAsync(\n projectRoot: string,\n {\n props,\n extras,\n }: {\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n const answer = await selectTemplatesAsync(projectRoot, props);\n\n if (!answer?.length) {\n Log.exit('\\n\\u203A Exiting with no change...', 0);\n }\n\n await generateAsync(projectRoot, {\n answer,\n props,\n extras,\n });\n}\n\nasync function generateAsync(\n projectRoot: string,\n {\n answer,\n props,\n extras,\n }: {\n answer: number[];\n props: DestinationResolutionProps;\n /** Any extra props to pass to the install command. */\n extras: any[];\n }\n) {\n // Copy files\n await Promise.all(\n answer.map(async (file) => {\n const template = TEMPLATES[file];\n\n if (template.configureAsync) {\n if (await template.configureAsync(projectRoot)) {\n return;\n }\n }\n\n const projectFilePath = path.resolve(projectRoot, template.destination(props));\n // copy the file from template\n return copyAsync(template.file(projectRoot), projectFilePath);\n })\n );\n\n // Install dependencies\n const packages = answer\n .map((file) => TEMPLATES[file].dependencies)\n .flat()\n .filter((pkg) => !resolveFrom.silent(projectRoot, pkg));\n if (packages.length) {\n Log.debug('Installing ' + packages.join(', '));\n await installAsync(packages, {}, ['--dev', ...extras]);\n }\n}\n"],"names":["queryAndGenerateAsync","selectAndGenerateAsync","projectRoot","files","props","extras","valid","filter","file","TEMPLATES","find","template","destination","length","diff","CommandError","join","map","Log","log","generateAsync","answer","findIndex","selectTemplatesAsync","exit","Promise","all","configureAsync","projectFilePath","path","resolve","copyAsync","packages","dependencies","flat","pkg","resolveFrom","silent","debug","installAsync"],"mappings":"AAAA;;;;;;;;;;;IASsBA,qBAAqB,MAArBA,qBAAqB;IA0CrBC,sBAAsB,MAAtBA,sBAAsB;;;8DAnD3B,MAAM;;;;;;;8DACC,cAAc;;;;;;2BAEsC,aAAa;8BAC5D,yBAAyB;qBAClC,QAAQ;qBACF,cAAc;wBACX,iBAAiB;;;;;;AAEvC,eAAeD,qBAAqB,CACzCE,WAAmB,EACnB,EACEC,KAAK,CAAA,EACLC,KAAK,CAAA,EACLC,MAAM,CAAA,EAMP,EACD;IACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,MAAM,CACxB,CAACC,IAAI,GAAK,CAAC,CAACC,UAAS,UAAA,CAACC,IAAI,CAAC,CAACC,QAAQ,GAAKA,QA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AC,CAAC,AAAC;IAC1D,IAAIH,QAAQ,CAACnB,MAAM,EAAE;QACnBK,IAAG,IAAA,CAACoB,KAAK,CAAC,aAAa,GAAGN,QAAQ,CAAChB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,MAAMuB,IAAAA,aAAY,aAAA,EAACP,QAAQ,EAAE,EAAE,EAAE;YAAC,OAAO;eAAK3B,MAAM;SAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
@@ -63,7 +63,7 @@ async function exportDomComponentAsync({ filePath , projectRoot , dev , devServe
63
63
  const virtualEntry = (0, _filePath.toPosixPath)((0, _resolveFrom().default)(projectRoot, "expo/dom/entry.js"));
64
64
  debug("Bundle DOM Component:", filePath);
65
65
  // MUST MATCH THE BABEL PLUGIN!
66
- const hash = _crypto().default.createHash("sha1").update(filePath).digest("hex");
66
+ const hash = _crypto().default.createHash("md5").update(filePath).digest("hex");
67
67
  const outputName = `${_domComponentsMiddleware.DOM_COMPONENTS_BUNDLE_DIR}/${hash}.html`;
68
68
  const generatedEntryPath = (0, _filePath.toPosixPath)(filePath.startsWith("file://") ? _url().default.fileURLToPath(filePath) : filePath);
69
69
  const baseUrl = `/${_domComponentsMiddleware.DOM_COMPONENTS_BUNDLE_DIR}`;
@@ -144,15 +144,28 @@ function updateDomComponentAssetsForMD5Naming({ domComponentReference , nativeBu
144
144
  const htmlContent = files.get(htmlOutputName);
145
145
  (0, _assert().default)(htmlContent);
146
146
  const htmlMd5 = _crypto().default.createHash("md5").update(htmlContent.contents.toString()).digest("hex");
147
- const hash = _crypto().default.createHash("sha1").update(domComponentReference).digest("hex");
147
+ const hash = _crypto().default.createHash("md5").update(domComponentReference).digest("hex");
148
148
  for (const artifact1 of nativeBundle.artifacts){
149
149
  if (artifact1.type !== "js") {
150
150
  continue;
151
151
  }
152
152
  const assetEntity = files.get(artifact1.filename);
153
153
  (0, _assert().default)(assetEntity);
154
- const regexp2 = new RegExp(`(['"])${hash}\\.html(['"])`, "g");
155
- assetEntity.contents = assetEntity.contents.toString().replace(regexp2, `$1${htmlMd5}.html$2`);
154
+ if (Buffer.isBuffer(assetEntity.contents)) {
155
+ const searchBuffer = Buffer.from(`${hash}.html`, "utf8");
156
+ const replaceBuffer = Buffer.from(`${htmlMd5}.html`, "utf8");
157
+ (0, _assert().default)(searchBuffer.length === replaceBuffer.length);
158
+ let index1 = assetEntity.contents.indexOf(searchBuffer, 0);
159
+ while(index1 !== -1){
160
+ replaceBuffer.copy(assetEntity.contents, index1);
161
+ index1 = assetEntity.contents.indexOf(searchBuffer, index1 + searchBuffer.length);
162
+ }
163
+ } else {
164
+ const search = `${hash}.html`;
165
+ const replace = `${htmlMd5}.html`;
166
+ (0, _assert().default)(search.length === replace.length);
167
+ assetEntity.contents = assetEntity.contents.toString().replaceAll(search, replace);
168
+ }
156
169
  }
157
170
  assetsMetadata.push({
158
171
  path: htmlOutputName,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportDomComponents.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport assert from 'assert';\nimport crypto from 'crypto';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport url from 'url';\n\nimport { type PlatformMetadata } from './createMetadataJson';\nimport { type BundleOutput, type ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { type MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport {\n getDomComponentHtml,\n DOM_COMPONENTS_BUNDLE_DIR,\n} from '../start/server/middleware/DomComponentsMiddleware';\nimport { env } from '../utils/env';\nimport { resolveRealEntryFilePath, toPosixPath } from '../utils/filePath';\n\nconst debug = require('debug')('expo:export:exportDomComponents') as typeof console.log;\n\n// TODO(EvanBacon): determine how to support DOM Components with hosting.\nexport async function exportDomComponentAsync({\n filePath,\n projectRoot,\n dev,\n devServer,\n isHermes,\n includeSourceMaps,\n exp,\n files,\n}: {\n filePath: string;\n projectRoot: string;\n dev: boolean;\n devServer: MetroBundlerDevServer;\n isHermes: boolean;\n includeSourceMaps: boolean;\n exp: ExpoConfig;\n files: ExportAssetMap;\n}): Promise<{\n bundle: BundleOutput;\n htmlOutputName: string;\n}> {\n const virtualEntry = toPosixPath(resolveFrom(projectRoot, 'expo/dom/entry.js'));\n debug('Bundle DOM Component:', filePath);\n // MUST MATCH THE BABEL PLUGIN!\n const hash = crypto.createHash('sha1').update(filePath).digest('hex');\n const outputName = `${DOM_COMPONENTS_BUNDLE_DIR}/${hash}.html`;\n const generatedEntryPath = toPosixPath(\n filePath.startsWith('file://') ? url.fileURLToPath(filePath) : filePath\n );\n const baseUrl = `/${DOM_COMPONENTS_BUNDLE_DIR}`;\n // The relative import path will be used like URI so it must be POSIX.\n const relativeImport = './' + path.posix.relative(path.dirname(virtualEntry), generatedEntryPath);\n // Run metro bundler and create the JS bundles/source maps.\n const bundle = await devServer.legacySinglePageExportBundleAsync({\n platform: 'web',\n domRoot: encodeURI(relativeImport),\n splitChunks: !env.EXPO_NO_BUNDLE_SPLITTING,\n mainModuleName: resolveRealEntryFilePath(projectRoot, virtualEntry),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: includeSourceMaps,\n bytecode: false,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: './',\n // Minify may be false because it's skipped on native when Hermes is enabled, default to true.\n minify: true,\n });\n\n const html = await serializeHtmlWithAssets({\n isExporting: true,\n resources: bundle.artifacts,\n template: getDomComponentHtml(),\n baseUrl: './',\n });\n\n const serialAssets = bundle.artifacts.map((a) => {\n return {\n ...a,\n filename: path.join(baseUrl, a.filename),\n };\n });\n\n getFilesFromSerialAssets(serialAssets, {\n includeSourceMaps,\n files,\n platform: 'web',\n });\n\n files.set(outputName, {\n contents: html,\n });\n\n return {\n bundle,\n htmlOutputName: outputName,\n };\n}\n\n/**\n * For EAS Updates exports,\n * post-processes the DOM component bundle and updates the asset paths to use flattened MD5 naming.\n */\nexport function updateDomComponentAssetsForMD5Naming({\n domComponentReference,\n nativeBundle,\n domComponentBundle,\n files,\n htmlOutputName,\n}: {\n domComponentReference: string;\n nativeBundle: BundleOutput;\n domComponentBundle: BundleOutput;\n files: ExportAssetMap;\n htmlOutputName: string;\n}): PlatformMetadata['assets'] {\n const assetsMetadata: PlatformMetadata['assets'] = [];\n\n for (const artifact of domComponentBundle.artifacts) {\n if (artifact.type !== 'js') {\n continue;\n }\n const artifactAssetName = `/${DOM_COMPONENTS_BUNDLE_DIR}/${artifact.filename}`;\n let source = artifact.source;\n\n // [0] Updates asset paths in the DOM component JS bundle (which is a web bundle)\n for (const asset of domComponentBundle.assets) {\n const prefix = asset.httpServerLocation.startsWith('./')\n ? asset.httpServerLocation.slice(2)\n : asset.httpServerLocation;\n const uri = `${prefix}/${asset.name}.${asset.type}`;\n const regexp = new RegExp(`(uri:\")(${uri})(\")`, 'g');\n const index = asset.scales.findIndex((s) => s === 1) ?? 0; // DOM components (web) uses 1x assets\n const md5 = asset.fileHashes[index];\n source = source.replace(regexp, `$1${md5}.${asset.type}$3`);\n\n const domJsAssetEntity = files.get(artifactAssetName);\n assert(domJsAssetEntity);\n domJsAssetEntity.contents = source;\n }\n\n // [1] Updates JS artifacts in HTML\n const md5 = crypto.createHash('md5').update(source).digest('hex');\n const htmlAssetEntity = files.get(htmlOutputName);\n assert(htmlAssetEntity);\n const regexp = new RegExp(`(<script src=\")(.*${artifact.filename})(\" defer></script>)`, 'g');\n htmlAssetEntity.contents = htmlAssetEntity.contents.toString().replace(regexp, `$1${md5}.js$3`);\n\n assetsMetadata.push({\n path: artifactAssetName.slice(1),\n ext: 'js',\n });\n }\n\n // [2] Updates HTML names from native bundle\n const htmlContent = files.get(htmlOutputName);\n assert(htmlContent);\n const htmlMd5 = crypto.createHash('md5').update(htmlContent.contents.toString()).digest('hex');\n const hash = crypto.createHash('sha1').update(domComponentReference).digest('hex');\n for (const artifact of nativeBundle.artifacts) {\n if (artifact.type !== 'js') {\n continue;\n }\n const assetEntity = files.get(artifact.filename);\n assert(assetEntity);\n const regexp = new RegExp(`(['\"])${hash}\\\\.html(['\"])`, 'g');\n assetEntity.contents = assetEntity.contents.toString().replace(regexp, `$1${htmlMd5}.html$2`);\n }\n assetsMetadata.push({\n path: htmlOutputName,\n ext: 'html',\n });\n\n return assetsMetadata;\n}\n"],"names":["exportDomComponentAsync","updateDomComponentAssetsForMD5Naming","debug","require","filePath","projectRoot","dev","devServer","isHermes","includeSourceMaps","exp","files","virtualEntry","toPosixPath","resolveFrom","hash","crypto","createHash","update","digest","outputName","DOM_COMPONENTS_BUNDLE_DIR","generatedEntryPath","startsWith","url","fileURLToPath","baseUrl","relativeImport","path","posix","relative","dirname","bundle","legacySinglePageExportBundleAsync","platform","domRoot","encodeURI","splitChunks","env","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","resolveRealEntryFilePath","mode","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","minify","html","serializeHtmlWithAssets","isExporting","resources","artifacts","template","getDomComponentHtml","serialAssets","map","a","filename","join","getFilesFromSerialAssets","set","contents","htmlOutputName","domComponentReference","nativeBundle","domComponentBundle","assetsMetadata","artifact","type","artifactAssetName","source","asset","assets","prefix","httpServerLocation","slice","uri","name","regexp","RegExp","index","scales","findIndex","s","md5","fileHashes","replace","domJsAssetEntity","get","assert","htmlAssetEntity","toString","push","ext","htmlContent","htmlMd5","assetEntity"],"mappings":"AAAA;;;;;;;;;;;IAqBsBA,uBAAuB,MAAvBA,uBAAuB;IAmF7BC,oCAAoC,MAApCA,oCAAoC;;;8DAvGjC,QAAQ;;;;;;;8DACR,QAAQ;;;;;;;8DACV,MAAM;;;;;;;8DACC,cAAc;;;;;;;8DACtB,KAAK;;;;;;4BAG4D,cAAc;+BAEvD,qCAAqC;yCAItE,oDAAoD;qBACvC,cAAc;0BACoB,mBAAmB;;;;;;AAEzE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCA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AC;IAC9C2B,IAAAA,OAAM,EAAA,QAAA,EAACK,WAAW,CAAC,CAAC;IACpB,MAAMC,OAAO,GAAGlF,OAAM,EAAA,QAAA,CAACC,UAAU,CAAC,KAAK,CAAC,CAACC,MAAM,CAAC+E,WAAW,CAACjC,QAAQ,CAAC8B,QAAQ,EAAE,CAAC,CAAC3E,MAAM,CAAC,KAAK,CAAC,AAAC;IAC/F,MAAMJ,IAAI,GAAGC,OAAM,EAAA,QAAA,CAACC,UAAU,CAAC,MAAM,CAAC,CAACC,MAAM,CAACgD,qBAAqB,CAAC,CAAC/C,MAAM,CAAC,KAAK,CAAC,AAAC;IACnF,KAAK,MAAMmD,SAAQ,IAAIH,YAAY,CAACb,SAAS,CAAE;QAC7C,IAAIgB,SAAQ,CAACC,IAAI,KAAK,IAAI,EAAE;YAC1B,SAAS;QACX,CAAC;QACD,MAAM4B,WAAW,GAAGxF,KAAK,CAACgF,GAAG,CAACrB,SAAQ,CAACV,QAAQ,CAAC,AAAC;QACjDgC,IAAAA,OAAM,EAAA,QAAA,EAACO,WAAW,CAAC,CAAC;QACpB,MAAMlB,OAAM,GAAG,IAAIC,MAAM,CAAC,CAAC,MAAM,EAAEnE,IAAI,CAAC,aAAa,CAAC,EAAE,GAAG,CAAC,AAAC;QAC7DoF,WAAW,CAACnC,QAAQ,GAAGmC,WAAW,CAACnC,QAAQ,CAAC8B,QAAQ,EAAE,CAACL,OAAO,CAACR,OAAM,EAAE,CAAC,EAAE,EAAEiB,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAChG,CAAC;IACD7B,cAAc,CAAC0B,IAAI,CAAC;QAClBnE,IAAI,EAAEqC,cAAc;QACpB+B,GAAG,EAAE,MAAM;KACZ,CAAC,CAAC;IAEH,OAAO3B,cAAc,CAAC;AACxB,CAAC"}
1
+ {"version":3,"sources":["../../../src/export/exportDomComponents.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config';\nimport assert from 'assert';\nimport crypto from 'crypto';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport url from 'url';\n\nimport { type PlatformMetadata } from './createMetadataJson';\nimport { type BundleOutput, type ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { type MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport {\n getDomComponentHtml,\n DOM_COMPONENTS_BUNDLE_DIR,\n} from '../start/server/middleware/DomComponentsMiddleware';\nimport { env } from '../utils/env';\nimport { resolveRealEntryFilePath, toPosixPath } from '../utils/filePath';\n\nconst debug = require('debug')('expo:export:exportDomComponents') as typeof console.log;\n\n// TODO(EvanBacon): determine how to support DOM Components with hosting.\nexport async function exportDomComponentAsync({\n filePath,\n projectRoot,\n dev,\n devServer,\n isHermes,\n includeSourceMaps,\n exp,\n files,\n}: {\n filePath: string;\n projectRoot: string;\n dev: boolean;\n devServer: MetroBundlerDevServer;\n isHermes: boolean;\n includeSourceMaps: boolean;\n exp: ExpoConfig;\n files: ExportAssetMap;\n}): Promise<{\n bundle: BundleOutput;\n htmlOutputName: string;\n}> {\n const virtualEntry = toPosixPath(resolveFrom(projectRoot, 'expo/dom/entry.js'));\n debug('Bundle DOM Component:', filePath);\n // MUST MATCH THE BABEL PLUGIN!\n const hash = crypto.createHash('md5').update(filePath).digest('hex');\n const outputName = `${DOM_COMPONENTS_BUNDLE_DIR}/${hash}.html`;\n const generatedEntryPath = toPosixPath(\n filePath.startsWith('file://') ? url.fileURLToPath(filePath) : filePath\n );\n const baseUrl = `/${DOM_COMPONENTS_BUNDLE_DIR}`;\n // The relative import path will be used like URI so it must be POSIX.\n const relativeImport = './' + path.posix.relative(path.dirname(virtualEntry), generatedEntryPath);\n // Run metro bundler and create the JS bundles/source maps.\n const bundle = await devServer.legacySinglePageExportBundleAsync({\n platform: 'web',\n domRoot: encodeURI(relativeImport),\n splitChunks: !env.EXPO_NO_BUNDLE_SPLITTING,\n mainModuleName: resolveRealEntryFilePath(projectRoot, virtualEntry),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: includeSourceMaps,\n bytecode: false,\n reactCompiler: !!exp.experiments?.reactCompiler,\n baseUrl: './',\n // Minify may be false because it's skipped on native when Hermes is enabled, default to true.\n minify: true,\n });\n\n const html = await serializeHtmlWithAssets({\n isExporting: true,\n resources: bundle.artifacts,\n template: getDomComponentHtml(),\n baseUrl: './',\n });\n\n const serialAssets = bundle.artifacts.map((a) => {\n return {\n ...a,\n filename: path.join(baseUrl, a.filename),\n };\n });\n\n getFilesFromSerialAssets(serialAssets, {\n includeSourceMaps,\n files,\n platform: 'web',\n });\n\n files.set(outputName, {\n contents: html,\n });\n\n return {\n bundle,\n htmlOutputName: outputName,\n };\n}\n\n/**\n * For EAS Updates exports,\n * post-processes the DOM component bundle and updates the asset paths to use flattened MD5 naming.\n */\nexport function updateDomComponentAssetsForMD5Naming({\n domComponentReference,\n nativeBundle,\n domComponentBundle,\n files,\n htmlOutputName,\n}: {\n domComponentReference: string;\n nativeBundle: BundleOutput;\n domComponentBundle: BundleOutput;\n files: ExportAssetMap;\n htmlOutputName: string;\n}): PlatformMetadata['assets'] {\n const assetsMetadata: PlatformMetadata['assets'] = [];\n\n for (const artifact of domComponentBundle.artifacts) {\n if (artifact.type !== 'js') {\n continue;\n }\n const artifactAssetName = `/${DOM_COMPONENTS_BUNDLE_DIR}/${artifact.filename}`;\n let source = artifact.source;\n\n // [0] Updates asset paths in the DOM component JS bundle (which is a web bundle)\n for (const asset of domComponentBundle.assets) {\n const prefix = asset.httpServerLocation.startsWith('./')\n ? asset.httpServerLocation.slice(2)\n : asset.httpServerLocation;\n const uri = `${prefix}/${asset.name}.${asset.type}`;\n const regexp = new RegExp(`(uri:\")(${uri})(\")`, 'g');\n const index = asset.scales.findIndex((s) => s === 1) ?? 0; // DOM components (web) uses 1x assets\n const md5 = asset.fileHashes[index];\n source = source.replace(regexp, `$1${md5}.${asset.type}$3`);\n\n const domJsAssetEntity = files.get(artifactAssetName);\n assert(domJsAssetEntity);\n domJsAssetEntity.contents = source;\n }\n\n // [1] Updates JS artifacts in HTML\n const md5 = crypto.createHash('md5').update(source).digest('hex');\n const htmlAssetEntity = files.get(htmlOutputName);\n assert(htmlAssetEntity);\n const regexp = new RegExp(`(<script src=\")(.*${artifact.filename})(\" defer></script>)`, 'g');\n htmlAssetEntity.contents = htmlAssetEntity.contents.toString().replace(regexp, `$1${md5}.js$3`);\n\n assetsMetadata.push({\n path: artifactAssetName.slice(1),\n ext: 'js',\n });\n }\n\n // [2] Updates HTML names from native bundle\n const htmlContent = files.get(htmlOutputName);\n assert(htmlContent);\n const htmlMd5 = crypto.createHash('md5').update(htmlContent.contents.toString()).digest('hex');\n const hash = crypto.createHash('md5').update(domComponentReference).digest('hex');\n for (const artifact of nativeBundle.artifacts) {\n if (artifact.type !== 'js') {\n continue;\n }\n const assetEntity = files.get(artifact.filename);\n assert(assetEntity);\n if (Buffer.isBuffer(assetEntity.contents)) {\n const searchBuffer = Buffer.from(`${hash}.html`, 'utf8');\n const replaceBuffer = Buffer.from(`${htmlMd5}.html`, 'utf8');\n assert(searchBuffer.length === replaceBuffer.length);\n let index = assetEntity.contents.indexOf(searchBuffer, 0);\n while (index !== -1) {\n replaceBuffer.copy(assetEntity.contents, index);\n index = assetEntity.contents.indexOf(searchBuffer, index + searchBuffer.length);\n }\n } else {\n const search = `${hash}.html`;\n const replace = `${htmlMd5}.html`;\n assert(search.length === replace.length);\n assetEntity.contents = assetEntity.contents.toString().replaceAll(search, replace);\n }\n }\n assetsMetadata.push({\n path: htmlOutputName,\n ext: 'html',\n });\n\n return assetsMetadata;\n}\n"],"names":["exportDomComponentAsync","updateDomComponentAssetsForMD5Naming","debug","require","filePath","projectRoot","dev","devServer","isHermes","includeSourceMaps","exp","files","virtualEntry","toPosixPath","resolveFrom","hash","crypto","createHash","update","digest","outputName","DOM_COMPONENTS_BUNDLE_DIR","generatedEntryPath","startsWith","url","fileURLToPath","baseUrl","relativeImport","path","posix","relative","dirname","bundle","legacySinglePageExportBundleAsync","platform","domRoot","encodeURI","splitChunks","env","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","resolveRealEntryFilePath","mode","engine","undefined","serializerIncludeMaps","bytecode","reactCompiler","experiments","minify","html","serializeHtmlWithAssets","isExporting","resources","artifacts","template","getDomComponentHtml","serialAssets","map","a","filename","join","getFilesFromSerialAssets","set","contents","htmlOutputName","domComponentReference","nativeBundle","domComponentBundle","assetsMetadata","artifact","type","artifactAssetName","source","asset","assets","prefix","httpServerLocation","slice","uri","name","regexp","RegExp","index","scales","findIndex","s","md5","fileHashes","replace","domJsAssetEntity","get","assert","htmlAssetEntity","toString","push","ext","htmlContent","htmlMd5","assetEntity","Buffer","isBuffer","searchBuffer","from","replaceBuffer","length","indexOf","copy","search","replaceAll"],"mappings":"AAAA;;;;;;;;;;;IAqBsBA,uBAAuB,MAAvBA,uBAAuB;IAmF7BC,oCAAoC,MAApCA,oCAAoC;;;8DAvGjC,QAAQ;;;;;;;8DACR,QAAQ;;;;;;;8DACV,MAAM;;;;;;;8DACC,cAAc;;;;;;;8DACtB,KAAK;;;;;;4BAG4D,cAAc;+BAEvD,qCAAqC;yCAItE,oDAAoD;qBACvC,cAAc;0BACoB,mBAAmB;;;;;;AAEzE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAGjF,eAAeH,uBAAuB,CAAC,EAC5CI,QAAQ,CAAA,EACRC,WAAW,CAAA,EACXC,GAAG,CAAA,EACHC,SAAS,CAAA,EACTC,QAAQ,CAAA,EACRC,iBAAiB,CAAA,EACjBC,GAAG,CAAA,EACHC,KAAK,CAAA,EAUN,EAGE;QAsBkBD,GAAe;IArBlC,MAAME,YAAY,GAAGC,IAAAA,SAAW,YAAA,EAACC,IAAAA,YAAW,EAAA,QAAA,EAACT,WAAW,EAAE,mBAAmB,CAAC,CAAC,AAAC;IAChFH,KAAK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,EAAA,QAAA,EAACgB,MAAM,CAACH,MAAM,KAAKhB,OAAO,CAACgB,MAAM,CAAC,CAAC;YACzCN,WAAW,CAACnC,QAAQ,GAAGmC,WAAW,CAACnC,QAAQ,CAAC8B,QAAQ,EAAE,CAACe,UAAU,CAACD,MAAM,EAAEnB,OAAO,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IACDpB,cAAc,CAAC0B,IAAI,CAAC;QAClBnE,IAAI,EAAEqC,cAAc;QACpB+B,GAAG,EAAE,MAAM;KACZ,CAAC,CAAC;IAEH,OAAO3B,cAAc,CAAC;AACxB,CAAC"}
@@ -35,9 +35,9 @@ function _jsonFile() {
35
35
  };
36
36
  return data;
37
37
  }
38
- function _fsExtra() {
39
- const data = /*#__PURE__*/ _interopRequireDefault(require("fs-extra"));
40
- _fsExtra = function() {
38
+ function _fs() {
39
+ const data = /*#__PURE__*/ _interopRequireDefault(require("fs"));
40
+ _fs = function() {
41
41
  return data;
42
42
  };
43
43
  return data;
@@ -84,8 +84,8 @@ function parseGradleProperties(content) {
84
84
  continue;
85
85
  }
86
86
  const sepIndex = line.indexOf("=");
87
- const key = line.substr(0, sepIndex);
88
- const value = line.substr(sepIndex + 1);
87
+ const key = line.slice(0, sepIndex);
88
+ const value = line.slice(sepIndex + 1);
89
89
  result[key] = value;
90
90
  }
91
91
  return result;
@@ -103,8 +103,8 @@ async function maybeInconsistentEngineAndroidAsync(projectRoot, isHermesManaged)
103
103
  // Trying best to check android native project if by chance to be consistent between app config
104
104
  // Check gradle.properties from prebuild template
105
105
  const gradlePropertiesPath = _path().default.join(projectRoot, "android", "gradle.properties");
106
- if (_fsExtra().default.existsSync(gradlePropertiesPath)) {
107
- const props = parseGradleProperties(await _fsExtra().default.readFile(gradlePropertiesPath, "utf8"));
106
+ if (_fs().default.existsSync(gradlePropertiesPath)) {
107
+ const props = parseGradleProperties(await _fs().default.promises.readFile(gradlePropertiesPath, "utf8"));
108
108
  const isHermesBare = props["hermesEnabled"] === "true";
109
109
  if (isHermesManaged !== isHermesBare) {
110
110
  return true;
@@ -116,8 +116,8 @@ function isHermesPossiblyEnabled(projectRoot) {
116
116
  // Trying best to check ios native project if by chance to be consistent between app config
117
117
  // Check ios/Podfile for ":hermes_enabled => true"
118
118
  const podfilePath = _path().default.join(projectRoot, "ios", "Podfile");
119
- if (_fsExtra().default.existsSync(podfilePath)) {
120
- const content = _fsExtra().default.readFileSync(podfilePath, "utf8");
119
+ if (_fs().default.existsSync(podfilePath)) {
120
+ const content = _fs().default.readFileSync(podfilePath, "utf8");
121
121
  const isPropsReference = content.search(/^\s*:hermes_enabled\s*=>\s*podfile_properties\['expo.jsEngine'\]\s*==\s*nil\s*\|\|\s*podfile_properties\['expo.jsEngine'\]\s*==\s*'hermes',?/m) >= 0;
122
122
  const isHermesBare = content.search(/^\s*:hermes_enabled\s*=>\s*true,?\s+/m) >= 0;
123
123
  if (!isPropsReference && isHermesBare) {
@@ -126,7 +126,7 @@ function isHermesPossiblyEnabled(projectRoot) {
126
126
  }
127
127
  // Check Podfile.properties.json from prebuild template
128
128
  const podfilePropertiesPath = _path().default.join(projectRoot, "ios", "Podfile.properties.json");
129
- if (_fsExtra().default.existsSync(podfilePropertiesPath)) {
129
+ if (_fs().default.existsSync(podfilePropertiesPath)) {
130
130
  try {
131
131
  const props = _jsonFile().default.read(podfilePropertiesPath);
132
132
  return props["expo.jsEngine"] === "hermes";
@@ -140,8 +140,8 @@ async function maybeInconsistentEngineIosAsync(projectRoot, isHermesManaged) {
140
140
  // Trying best to check ios native project if by chance to be consistent between app config
141
141
  // Check ios/Podfile for ":hermes_enabled => true"
142
142
  const podfilePath = _path().default.join(projectRoot, "ios", "Podfile");
143
- if (_fsExtra().default.existsSync(podfilePath)) {
144
- const content = await _fsExtra().default.readFile(podfilePath, "utf8");
143
+ if (_fs().default.existsSync(podfilePath)) {
144
+ const content = await _fs().default.promises.readFile(podfilePath, "utf8");
145
145
  const isPropsReference = content.search(/^\s*:hermes_enabled\s*=>\s*podfile_properties\['expo.jsEngine'\]\s*==\s*nil\s*\|\|\s*podfile_properties\['expo.jsEngine'\]\s*==\s*'hermes',?/m) >= 0;
146
146
  const isHermesBare = content.search(/^\s*:hermes_enabled\s*=>\s*true,?\s+/m) >= 0;
147
147
  if (!isPropsReference && isHermesManaged !== isHermesBare) {
@@ -150,7 +150,7 @@ async function maybeInconsistentEngineIosAsync(projectRoot, isHermesManaged) {
150
150
  }
151
151
  // Check Podfile.properties.json from prebuild template
152
152
  const podfilePropertiesPath = _path().default.join(projectRoot, "ios", "Podfile.properties.json");
153
- if (_fsExtra().default.existsSync(podfilePropertiesPath)) {
153
+ if (_fs().default.existsSync(podfilePropertiesPath)) {
154
154
  const props = await parsePodfilePropertiesAsync(podfilePropertiesPath);
155
155
  const isHermesBare1 = props["expo.jsEngine"] === "hermes";
156
156
  if (isHermesManaged !== isHermesBare1) {
@@ -163,25 +163,25 @@ async function maybeInconsistentEngineIosAsync(projectRoot, isHermesManaged) {
163
163
  const HERMES_MAGIC_HEADER = "c61fbc03c103191f";
164
164
  async function isHermesBytecodeBundleAsync(file) {
165
165
  const header = await readHermesHeaderAsync(file);
166
- return header.slice(0, 8).toString("hex") === HERMES_MAGIC_HEADER;
166
+ return header.subarray(0, 8).toString("hex") === HERMES_MAGIC_HEADER;
167
167
  }
168
168
  async function getHermesBytecodeBundleVersionAsync(file) {
169
169
  const header = await readHermesHeaderAsync(file);
170
- if (header.slice(0, 8).toString("hex") !== HERMES_MAGIC_HEADER) {
170
+ if (header.subarray(0, 8).toString("hex") !== HERMES_MAGIC_HEADER) {
171
171
  throw new Error("Invalid hermes bundle file");
172
172
  }
173
173
  return header.readUInt32LE(8);
174
174
  }
175
175
  async function readHermesHeaderAsync(file) {
176
- const fd = await _fsExtra().default.open(file, "r");
176
+ const fd = await _fs().default.promises.open(file, "r");
177
177
  const buffer = Buffer.alloc(12);
178
- await _fsExtra().default.read(fd, buffer, 0, 12, null);
179
- await _fsExtra().default.close(fd);
178
+ await fd.read(buffer, 0, 12, null);
179
+ await fd.close();
180
180
  return buffer;
181
181
  }
182
182
  async function parsePodfilePropertiesAsync(podfilePropertiesPath) {
183
183
  try {
184
- return JSON.parse(await _fsExtra().default.readFile(podfilePropertiesPath, "utf8"));
184
+ return JSON.parse(await _fs().default.promises.readFile(podfilePropertiesPath, "utf8"));
185
185
  } catch {
186
186
  return {};
187
187
  }
@@ -189,8 +189,8 @@ async function parsePodfilePropertiesAsync(podfilePropertiesPath) {
189
189
  function isAndroidUsingHermes(projectRoot) {
190
190
  // Check gradle.properties from prebuild template
191
191
  const gradlePropertiesPath = _path().default.join(projectRoot, "android", "gradle.properties");
192
- if (_fsExtra().default.existsSync(gradlePropertiesPath)) {
193
- const props = parseGradleProperties(_fsExtra().default.readFileSync(gradlePropertiesPath, "utf8"));
192
+ if (_fs().default.existsSync(gradlePropertiesPath)) {
193
+ const props = parseGradleProperties(_fs().default.readFileSync(gradlePropertiesPath, "utf8"));
194
194
  return props["hermesEnabled"] === "true";
195
195
  }
196
196
  // Assume Hermes is used by default.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/export/exportHermes.ts"],"sourcesContent":["import { ExpoConfig, getConfigFilePaths, Platform } from '@expo/config';\nimport JsonFile from '@expo/json-file';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nexport async function assertEngineMismatchAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'ios' | 'android' | 'jsEngine'>,\n platform: Platform\n) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\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 function isEnableHermesManaged(\n expoConfig: Partial<Pick<ExpoConfig, 'ios' | 'android' | 'jsEngine'>>,\n platform: string\n): boolean {\n switch (platform) {\n case 'android': {\n return (expoConfig.android?.jsEngine ?? expoConfig.jsEngine) !== 'jsc';\n }\n case 'ios': {\n return (expoConfig.ios?.jsEngine ?? expoConfig.jsEngine) !== 'jsc';\n }\n default:\n return false;\n }\n}\n\nexport function parseGradleProperties(content: string): Record<string, string> {\n const result: Record<string, string> = {};\n for (let line of content.split('\\n')) {\n line = line.trim();\n if (!line || line.startsWith('#')) {\n continue;\n }\n\n const sepIndex = line.indexOf('=');\n const key = line.substr(0, sepIndex);\n const value = line.substr(sepIndex + 1);\n result[key] = value;\n }\n return result;\n}\n\nexport async function maybeThrowFromInconsistentEngineAsync(\n projectRoot: string,\n configFilePath: string,\n platform: string,\n isHermesManaged: boolean\n): Promise<void> {\n const configFileName = path.basename(configFilePath);\n if (\n platform === 'android' &&\n (await maybeInconsistentEngineAndroidAsync(projectRoot, isHermesManaged))\n ) {\n throw new Error(\n `JavaScript engine configuration is inconsistent between ${configFileName} and Android native project.\\n` +\n `In ${configFileName}: Hermes is ${isHermesManaged ? 'enabled' : 'not enabled'}\\n` +\n `In Android native project: Hermes is ${isHermesManaged ? 'not enabled' : 'enabled'}\\n` +\n `Please check the following files for inconsistencies:\\n` +\n ` - ${configFilePath}\\n` +\n ` - ${path.join(projectRoot, 'android', 'gradle.properties')}\\n` +\n ` - ${path.join(projectRoot, 'android', 'app', 'build.gradle')}\\n` +\n 'Learn more: https://expo.fyi/hermes-android-config'\n );\n }\n\n if (platform === 'ios' && (await maybeInconsistentEngineIosAsync(projectRoot, isHermesManaged))) {\n throw new Error(\n `JavaScript engine configuration is inconsistent between ${configFileName} and iOS native project.\\n` +\n `In ${configFileName}: Hermes is ${isHermesManaged ? 'enabled' : 'not enabled'}\\n` +\n `In iOS native project: Hermes is ${isHermesManaged ? 'not enabled' : 'enabled'}\\n` +\n `Please check the following files for inconsistencies:\\n` +\n ` - ${configFilePath}\\n` +\n ` - ${path.join(projectRoot, 'ios', 'Podfile')}\\n` +\n ` - ${path.join(projectRoot, 'ios', 'Podfile.properties.json')}\\n` +\n 'Learn more: https://expo.fyi/hermes-ios-config'\n );\n }\n}\n\nexport async function maybeInconsistentEngineAndroidAsync(\n projectRoot: string,\n isHermesManaged: boolean\n): Promise<boolean> {\n // Trying best to check android native project if by chance to be consistent between app config\n\n // Check gradle.properties from prebuild template\n const gradlePropertiesPath = path.join(projectRoot, 'android', 'gradle.properties');\n if (fs.existsSync(gradlePropertiesPath)) {\n const props = parseGradleProperties(await fs.readFile(gradlePropertiesPath, 'utf8'));\n const isHermesBare = props['hermesEnabled'] === 'true';\n if (isHermesManaged !== isHermesBare) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function isHermesPossiblyEnabled(projectRoot: string): boolean | null {\n // Trying best to check ios native project if by chance to be consistent between app config\n\n // Check ios/Podfile for \":hermes_enabled => true\"\n const podfilePath = path.join(projectRoot, 'ios', 'Podfile');\n if (fs.existsSync(podfilePath)) {\n const content = fs.readFileSync(podfilePath, 'utf8');\n const isPropsReference =\n content.search(\n /^\\s*:hermes_enabled\\s*=>\\s*podfile_properties\\['expo.jsEngine'\\]\\s*==\\s*nil\\s*\\|\\|\\s*podfile_properties\\['expo.jsEngine'\\]\\s*==\\s*'hermes',?/m\n ) >= 0;\n const isHermesBare = content.search(/^\\s*:hermes_enabled\\s*=>\\s*true,?\\s+/m) >= 0;\n if (!isPropsReference && isHermesBare) {\n return true;\n }\n }\n\n // Check Podfile.properties.json from prebuild template\n const podfilePropertiesPath = path.join(projectRoot, 'ios', 'Podfile.properties.json');\n if (fs.existsSync(podfilePropertiesPath)) {\n try {\n const props = JsonFile.read(podfilePropertiesPath);\n return props['expo.jsEngine'] === 'hermes';\n } catch {\n // ignore\n }\n }\n\n return null;\n}\n\nexport async function maybeInconsistentEngineIosAsync(\n projectRoot: string,\n isHermesManaged: boolean\n): Promise<boolean> {\n // Trying best to check ios native project if by chance to be consistent between app config\n\n // Check ios/Podfile for \":hermes_enabled => true\"\n const podfilePath = path.join(projectRoot, 'ios', 'Podfile');\n if (fs.existsSync(podfilePath)) {\n const content = await fs.readFile(podfilePath, 'utf8');\n const isPropsReference =\n content.search(\n /^\\s*:hermes_enabled\\s*=>\\s*podfile_properties\\['expo.jsEngine'\\]\\s*==\\s*nil\\s*\\|\\|\\s*podfile_properties\\['expo.jsEngine'\\]\\s*==\\s*'hermes',?/m\n ) >= 0;\n const isHermesBare = content.search(/^\\s*:hermes_enabled\\s*=>\\s*true,?\\s+/m) >= 0;\n if (!isPropsReference && isHermesManaged !== isHermesBare) {\n return true;\n }\n }\n\n // Check Podfile.properties.json from prebuild template\n const podfilePropertiesPath = path.join(projectRoot, 'ios', 'Podfile.properties.json');\n if (fs.existsSync(podfilePropertiesPath)) {\n const props = await parsePodfilePropertiesAsync(podfilePropertiesPath);\n const isHermesBare = props['expo.jsEngine'] === 'hermes';\n if (isHermesManaged !== isHermesBare) {\n return true;\n }\n }\n\n return false;\n}\n\n// https://github.com/facebook/hermes/blob/release-v0.5/include/hermes/BCGen/HBC/BytecodeFileFormat.h#L24-L25\nconst HERMES_MAGIC_HEADER = 'c61fbc03c103191f';\n\nexport async function isHermesBytecodeBundleAsync(file: string): Promise<boolean> {\n const header = await readHermesHeaderAsync(file);\n return header.slice(0, 8).toString('hex') === HERMES_MAGIC_HEADER;\n}\n\nexport async function getHermesBytecodeBundleVersionAsync(file: string): Promise<number> {\n const header = await readHermesHeaderAsync(file);\n if (header.slice(0, 8).toString('hex') !== HERMES_MAGIC_HEADER) {\n throw new Error('Invalid hermes bundle file');\n }\n return header.readUInt32LE(8);\n}\n\nasync function readHermesHeaderAsync(file: string): Promise<Buffer> {\n const fd = await fs.open(file, 'r');\n const buffer = Buffer.alloc(12);\n await fs.read(fd, buffer, 0, 12, null);\n await fs.close(fd);\n return buffer;\n}\n\nasync function parsePodfilePropertiesAsync(\n podfilePropertiesPath: string\n): Promise<Record<string, string>> {\n try {\n return JSON.parse(await fs.readFile(podfilePropertiesPath, 'utf8'));\n } catch {\n return {};\n }\n}\n\nexport function isAndroidUsingHermes(projectRoot: string) {\n // Check gradle.properties from prebuild template\n const gradlePropertiesPath = path.join(projectRoot, 'android', 'gradle.properties');\n if (fs.existsSync(gradlePropertiesPath)) {\n const props = parseGradleProperties(fs.readFileSync(gradlePropertiesPath, 'utf8'));\n return props['hermesEnabled'] === 'true';\n }\n\n // Assume Hermes is used by default.\n return true;\n}\n\nexport function isIosUsingHermes(projectRoot: string) {\n // If nullish, then assume Hermes is used.\n return isHermesPossiblyEnabled(projectRoot) !== false;\n}\n"],"names":["assertEngineMismatchAsync","isEnableHermesManaged","parseGradleProperties","maybeThrowFromInconsistentEngineAsync","maybeInconsistentEngineAndroidAsync","isHermesPossiblyEnabled","maybeInconsistentEngineIosAsync","isHermesBytecodeBundleAsync","getHermesBytecodeBundleVersionAsync","isAndroidUsingHermes","isIosUsingHermes","projectRoot","exp","platform","isHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","expoConfig","android","jsEngine","ios","content","result","line","split","trim","startsWith","sepIndex","indexOf","key","substr","value","configFileName","path","basename","Error","join","gradlePropertiesPath","fs","existsSync","props","readFile","isHermesBare","podfilePath","readFileSync","isPropsReference","search","podfilePropertiesPath","JsonFile","read","parsePodfilePropertiesAsync","HERMES_MAGIC_HEADER","file","header","readHermesHeaderAsync","slice","toString","readUInt32LE","fd","open","buffer","Buffer","alloc","close","JSON","parse"],"mappings":"AAAA;;;;;;;;;;;IAKsBA,yBAAyB,MAAzBA,yBAAyB;IAgB/BC,qBAAqB,MAArBA,qBAAqB;IAgBrBC,qBAAqB,MAArBA,qBAAqB;IAgBfC,qCAAqC,MAArCA,qCAAqC;IAqCrCC,mCAAmC,MAAnCA,mCAAmC;IAmBzCC,uBAAuB,MAAvBA,uBAAuB;IA+BjBC,+BAA+B,MAA/BA,+BAA+B;IAoC/BC,2BAA2B,MAA3BA,2BAA2B;IAK3BC,mCAAmC,MAAnCA,mCAAmC;IA0BzCC,oBAAoB,MAApBA,oBAAoB;IAYpBC,gBAAgB,MAAhBA,gBAAgB;;;yBA3NyB,cAAc;;;;;;;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AAGJ,KAAI,EAAA,QAAA,CAACG,IAAI,CAAC5B,WAAW,EAAE,SAAS,EAAE,mBAAmB,CAAC,AAAC;IACpF,IAAI8B,QAAE,EAAA,QAAA,CAACC,UAAU,CAACF,oBAAoB,CAAC,EAAE;QACvC,MAAMG,KAAK,GAAGzC,qBAAqB,CAACuC,QAAE,EAAA,QAAA,CAACM,YAAY,CAACP,oBAAoB,EAAE,MAAM,CAAC,CAAC,AAAC;QACnF,OAAOG,KAAK,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;IAC3C,CAAC;IAED,oCAAoC;IACpC,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,SAASjC,gBAAgB,CAACC,WAAmB,EAAE;IACpD,0CAA0C;IAC1C,OAAON,uBAAuB,CAACM,WAAW,CAAC,KAAK,KAAK,CAAC;AACxD,CAAC"}
1
+ {"version":3,"sources":["../../../src/export/exportHermes.ts"],"sourcesContent":["import { ExpoConfig, getConfigFilePaths, Platform } from '@expo/config';\nimport JsonFile from '@expo/json-file';\nimport fs from 'fs';\nimport path from 'path';\n\nexport async function assertEngineMismatchAsync(\n projectRoot: string,\n exp: Pick<ExpoConfig, 'ios' | 'android' | 'jsEngine'>,\n platform: Platform\n) {\n const isHermesManaged = isEnableHermesManaged(exp, platform);\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 function isEnableHermesManaged(\n expoConfig: Partial<Pick<ExpoConfig, 'ios' | 'android' | 'jsEngine'>>,\n platform: string\n): boolean {\n switch (platform) {\n case 'android': {\n return (expoConfig.android?.jsEngine ?? expoConfig.jsEngine) !== 'jsc';\n }\n case 'ios': {\n return (expoConfig.ios?.jsEngine ?? expoConfig.jsEngine) !== 'jsc';\n }\n default:\n return false;\n }\n}\n\nexport function parseGradleProperties(content: string): Record<string, string> {\n const result: Record<string, string> = {};\n for (let line of content.split('\\n')) {\n line = line.trim();\n if (!line || line.startsWith('#')) {\n continue;\n }\n\n const sepIndex = line.indexOf('=');\n const key = line.slice(0, sepIndex);\n const value = line.slice(sepIndex + 1);\n result[key] = value;\n }\n return result;\n}\n\nexport async function maybeThrowFromInconsistentEngineAsync(\n projectRoot: string,\n configFilePath: string,\n platform: string,\n isHermesManaged: boolean\n): Promise<void> {\n const configFileName = path.basename(configFilePath);\n if (\n platform === 'android' &&\n (await maybeInconsistentEngineAndroidAsync(projectRoot, isHermesManaged))\n ) {\n throw new Error(\n `JavaScript engine configuration is inconsistent between ${configFileName} and Android native project.\\n` +\n `In ${configFileName}: Hermes is ${isHermesManaged ? 'enabled' : 'not enabled'}\\n` +\n `In Android native project: Hermes is ${isHermesManaged ? 'not enabled' : 'enabled'}\\n` +\n `Please check the following files for inconsistencies:\\n` +\n ` - ${configFilePath}\\n` +\n ` - ${path.join(projectRoot, 'android', 'gradle.properties')}\\n` +\n ` - ${path.join(projectRoot, 'android', 'app', 'build.gradle')}\\n` +\n 'Learn more: https://expo.fyi/hermes-android-config'\n );\n }\n\n if (platform === 'ios' && (await maybeInconsistentEngineIosAsync(projectRoot, isHermesManaged))) {\n throw new Error(\n `JavaScript engine configuration is inconsistent between ${configFileName} and iOS native project.\\n` +\n `In ${configFileName}: Hermes is ${isHermesManaged ? 'enabled' : 'not enabled'}\\n` +\n `In iOS native project: Hermes is ${isHermesManaged ? 'not enabled' : 'enabled'}\\n` +\n `Please check the following files for inconsistencies:\\n` +\n ` - ${configFilePath}\\n` +\n ` - ${path.join(projectRoot, 'ios', 'Podfile')}\\n` +\n ` - ${path.join(projectRoot, 'ios', 'Podfile.properties.json')}\\n` +\n 'Learn more: https://expo.fyi/hermes-ios-config'\n );\n }\n}\n\nexport async function maybeInconsistentEngineAndroidAsync(\n projectRoot: string,\n isHermesManaged: boolean\n): Promise<boolean> {\n // Trying best to check android native project if by chance to be consistent between app config\n\n // Check gradle.properties from prebuild template\n const gradlePropertiesPath = path.join(projectRoot, 'android', 'gradle.properties');\n if (fs.existsSync(gradlePropertiesPath)) {\n const props = parseGradleProperties(await fs.promises.readFile(gradlePropertiesPath, 'utf8'));\n const isHermesBare = props['hermesEnabled'] === 'true';\n if (isHermesManaged !== isHermesBare) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function isHermesPossiblyEnabled(projectRoot: string): boolean | null {\n // Trying best to check ios native project if by chance to be consistent between app config\n\n // Check ios/Podfile for \":hermes_enabled => true\"\n const podfilePath = path.join(projectRoot, 'ios', 'Podfile');\n if (fs.existsSync(podfilePath)) {\n const content = fs.readFileSync(podfilePath, 'utf8');\n const isPropsReference =\n content.search(\n /^\\s*:hermes_enabled\\s*=>\\s*podfile_properties\\['expo.jsEngine'\\]\\s*==\\s*nil\\s*\\|\\|\\s*podfile_properties\\['expo.jsEngine'\\]\\s*==\\s*'hermes',?/m\n ) >= 0;\n const isHermesBare = content.search(/^\\s*:hermes_enabled\\s*=>\\s*true,?\\s+/m) >= 0;\n if (!isPropsReference && isHermesBare) {\n return true;\n }\n }\n\n // Check Podfile.properties.json from prebuild template\n const podfilePropertiesPath = path.join(projectRoot, 'ios', 'Podfile.properties.json');\n if (fs.existsSync(podfilePropertiesPath)) {\n try {\n const props = JsonFile.read(podfilePropertiesPath);\n return props['expo.jsEngine'] === 'hermes';\n } catch {\n // ignore\n }\n }\n\n return null;\n}\n\nexport async function maybeInconsistentEngineIosAsync(\n projectRoot: string,\n isHermesManaged: boolean\n): Promise<boolean> {\n // Trying best to check ios native project if by chance to be consistent between app config\n\n // Check ios/Podfile for \":hermes_enabled => true\"\n const podfilePath = path.join(projectRoot, 'ios', 'Podfile');\n if (fs.existsSync(podfilePath)) {\n const content = await fs.promises.readFile(podfilePath, 'utf8');\n const isPropsReference =\n content.search(\n /^\\s*:hermes_enabled\\s*=>\\s*podfile_properties\\['expo.jsEngine'\\]\\s*==\\s*nil\\s*\\|\\|\\s*podfile_properties\\['expo.jsEngine'\\]\\s*==\\s*'hermes',?/m\n ) >= 0;\n const isHermesBare = content.search(/^\\s*:hermes_enabled\\s*=>\\s*true,?\\s+/m) >= 0;\n if (!isPropsReference && isHermesManaged !== isHermesBare) {\n return true;\n }\n }\n\n // Check Podfile.properties.json from prebuild template\n const podfilePropertiesPath = path.join(projectRoot, 'ios', 'Podfile.properties.json');\n if (fs.existsSync(podfilePropertiesPath)) {\n const props = await parsePodfilePropertiesAsync(podfilePropertiesPath);\n const isHermesBare = props['expo.jsEngine'] === 'hermes';\n if (isHermesManaged !== isHermesBare) {\n return true;\n }\n }\n\n return false;\n}\n\n// https://github.com/facebook/hermes/blob/release-v0.5/include/hermes/BCGen/HBC/BytecodeFileFormat.h#L24-L25\nconst HERMES_MAGIC_HEADER = 'c61fbc03c103191f';\n\nexport async function isHermesBytecodeBundleAsync(file: string): Promise<boolean> {\n const header = await readHermesHeaderAsync(file);\n return header.subarray(0, 8).toString('hex') === HERMES_MAGIC_HEADER;\n}\n\nexport async function getHermesBytecodeBundleVersionAsync(file: string): Promise<number> {\n const header = await readHermesHeaderAsync(file);\n if (header.subarray(0, 8).toString('hex') !== HERMES_MAGIC_HEADER) {\n throw new Error('Invalid hermes bundle file');\n }\n return header.readUInt32LE(8);\n}\n\nasync function readHermesHeaderAsync(file: string): Promise<Buffer> {\n const fd = await fs.promises.open(file, 'r');\n const buffer = Buffer.alloc(12);\n await fd.read(buffer, 0, 12, null);\n await fd.close();\n return buffer;\n}\n\nasync function parsePodfilePropertiesAsync(\n podfilePropertiesPath: string\n): Promise<Record<string, string>> {\n try {\n return JSON.parse(await fs.promises.readFile(podfilePropertiesPath, 'utf8'));\n } catch {\n return {};\n }\n}\n\nexport function isAndroidUsingHermes(projectRoot: string) {\n // Check gradle.properties from prebuild template\n const gradlePropertiesPath = path.join(projectRoot, 'android', 'gradle.properties');\n if (fs.existsSync(gradlePropertiesPath)) {\n const props = parseGradleProperties(fs.readFileSync(gradlePropertiesPath, 'utf8'));\n return props['hermesEnabled'] === 'true';\n }\n\n // Assume Hermes is used by default.\n return true;\n}\n\nexport function isIosUsingHermes(projectRoot: string) {\n // If nullish, then assume Hermes is used.\n return isHermesPossiblyEnabled(projectRoot) !== false;\n}\n"],"names":["assertEngineMismatchAsync","isEnableHermesManaged","parseGradleProperties","maybeThrowFromInconsistentEngineAsync","maybeInconsistentEngineAndroidAsync","isHermesPossiblyEnabled","maybeInconsistentEngineIosAsync","isHermesBytecodeBundleAsync","getHermesBytecodeBundleVersionAsync","isAndroidUsingHermes","isIosUsingHermes","projectRoot","exp","platform","isHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","expoConfig","android","jsEngine","ios","content","result","line","split","trim","startsWith","sepIndex","indexOf","key","slice","value","configFileName","path","basename","Error","join","gradlePropertiesPath","fs","existsSync","props","promises","readFile","isHermesBare","podfilePath","readFileSync","isPropsReference","search","podfilePropertiesPath","JsonFile","read","parsePodfilePropertiesAsync","HERMES_MAGIC_HEADER","file","header","readHermesHeaderAsync","subarray","toString","readUInt32LE","fd","open","buffer","Buffer","alloc","close","JSON","parse"],"mappings":"AAAA;;;;;;;;;;;IAKsBA,yBAAyB,MAAzBA,yBAAyB;IAgB/BC,qBAAqB,MAArBA,qBAAqB;IAgBrBC,qBAAqB,MAArBA,qBAAqB;IAgBfC,qCAAqC,MAArCA,qCAAqC;IAqCrCC,mCAAmC,MAAnCA,mCAAmC;IAmBzCC,uBAAuB,MAAvBA,uBAAuB;IA+BjBC,+BAA+B,MAA/BA,+BAA+B;IAoC/BC,2BAA2B,MAA3BA,2BAA2B;IAK3BC,mCAAmC,MAAnCA,mCAAmC;IA0BzCC,oBAAoB,MAApBA,oBAAoB;IAYpBC,gBAAgB,MAAhBA,gBAAgB;;;yBA3NyB,cAAc;;;;;;;8DAClD,iBAAiB;;;;;;;8DACvB,IAAI;;;;;;;8DACF,MAAM;;;;;;;;;;;AAEhB,eAAeV,yBAAyB,CAC7CW,WAAmB,EACnBC,GAAqD,EACrDC,Q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ACC,UAAU,CAACF,oBAAoB,CAAC,EAAE;QACvC,MAAMG,KAAK,GAAGzC,qBAAqB,CAACuC,GAAE,EAAA,QAAA,CAACO,YAAY,CAACR,oBAAoB,EAAE,MAAM,CAAC,CAAC,AAAC;QACnF,OAAOG,KAAK,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;IAC3C,CAAC;IAED,oCAAoC;IACpC,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,SAASjC,gBAAgB,CAACC,WAAmB,EAAE;IACpD,0CAA0C;IAC1C,OAAON,uBAAuB,CAACM,WAAW,CAAC,KAAK,KAAK,CAAC;AACxD,CAAC"}
@@ -50,9 +50,7 @@ async function copyPublicFolderAsync(publicFolder, outputFolder) {
50
50
  await _fs().default.promises.mkdir(outputFolder, {
51
51
  recursive: true
52
52
  });
53
- await (0, _dir.copyAsync)(publicFolder, outputFolder, {
54
- overwrite: true
55
- });
53
+ await (0, _dir.copyAsync)(publicFolder, outputFolder);
56
54
  }
57
55
  }
58
56
 
@@ -1 +1 @@
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`.\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 fs.promises.mkdir(outputFolder, { recursive: true });\n await copyAsync(publicFolder, outputFolder, {\n overwrite: true,\n });\n }\n}\n"],"names":["getUserDefinedFile","copyPublicFolderAsync","debug","require","projectRoot","possiblePaths","publicPath","path","join","env","EXPO_PUBLIC_FOLDER","possiblePath","fullPath","fs","existsSync","publicFolder","outputFolder","promises","mkdir","recursive","copyAsync","overwrite"],"mappings":"AAAA;;;;;;;;;;;IASgBA,kBAAkB,MAAlBA,kBAAkB;IAsBZC,qBAAqB,MAArBA,qBAAqB;;;8DA/B5B,IAAI;;;;;;;8DACF,MAAM;;;;;;qBAEG,cAAc;qBACpB,cAAc;;;;;;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,EAAA,QAAA,CAACC,IAAI,CAACJ,WAAW,EAAEK,IAAG,IAAA,CAACC,kBAAkB,CAAC,AAAC;IAElE,KAAK,MAAMC,YAAY,IAAIN,aAAa,CAAE;QACxC,MAAMO,QAAQ,GAAGL,KAAI,EAAA,QAAA,CAACC,IAAI,CAACF,UAAU,EAAEK,YAAY,CAAC,AAAC;QACrD,IAAIE,GAAE,EAAA,QAAA,CAACC,UAAU,CAACF,QAAQ,CAAC,EAAE;YAC3BV,KAAK,CAAC,CAAC,gCAAgC,CAAC,GAAGS,YAAY,CAAC,CAAC;YACzD,OAAOC,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAUM,eAAeX,qBAAqB,CAACc,YAAoB,EAAEC,YAAoB,EAAE;IACtF,IAAIH,GAAE,EAAA,QAAA,CAACC,UAAU,CAACC,YAAY,CAAC,EAAE;QAC/B,MAAMF,GAAE,EAAA,QAAA,CAACI,QAAQ,CAACC,KAAK,CAACF,YAAY,EAAE;YAAEG,SAAS,EAAE,IAAI;SAAE,CAAC,CAAC;QAC3D,MAAMC,IAAAA,IAAS,UAAA,EAACL,YAAY,EAAEC,YAAY,EAAE;YAC1CK,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
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`.\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 fs.promises.mkdir(outputFolder, { recursive: true });\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","promises","mkdir","recursive","copyAsync"],"mappings":"AAAA;;;;;;;;;;;IASgBA,kBAAkB,MAAlBA,kBAAkB;IAsBZC,qBAAqB,MAArBA,qBAAqB;;;8DA/B5B,IAAI;;;;;;;8DACF,MAAM;;;;;;qBAEG,cAAc;qBACpB,cAAc;;;;;;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,EAAA,QAAA,CAACC,IAAI,CAACJ,WAAW,EAAEK,IAAG,IAAA,CAACC,kBAAkB,CAAC,AAAC;IAElE,KAAK,MAAMC,YAAY,IAAIN,aAAa,CAAE;QACxC,MAAMO,QAAQ,GAAGL,KAAI,EAAA,QAAA,CAACC,IAAI,CAACF,UAAU,EAAEK,YAAY,CAAC,AAAC;QACrD,IAAIE,GAAE,EAAA,QAAA,CAACC,UAAU,CAACF,QAAQ,CAAC,EAAE;YAC3BV,KAAK,CAAC,CAAC,gCAAgC,CAAC,GAAGS,YAAY,CAAC,CAAC;YACzD,OAAOC,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAUM,eAAeX,qBAAqB,CAACc,YAAoB,EAAEC,YAAoB,EAAE;IACtF,IAAIH,GAAE,EAAA,QAAA,CAACC,UAAU,CAACC,YAAY,CAAC,EAAE;QAC/B,MAAMF,GAAE,EAAA,QAAA,CAACI,QAAQ,CAACC,KAAK,CAACF,YAAY,EAAE;YAAEG,SAAS,EAAE,IAAI;SAAE,CAAC,CAAC;QAC3D,MAAMC,IAAAA,IAAS,UAAA,EAACL,YAAY,EAAEC,YAAY,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
@@ -20,16 +20,16 @@ function _configPlugins() {
20
20
  };
21
21
  return data;
22
22
  }
23
- function _fastGlob() {
24
- const data = require("fast-glob");
25
- _fastGlob = function() {
23
+ function _fs() {
24
+ const data = /*#__PURE__*/ _interopRequireDefault(require("fs"));
25
+ _fs = function() {
26
26
  return data;
27
27
  };
28
28
  return data;
29
29
  }
30
- function _fs() {
31
- const data = /*#__PURE__*/ _interopRequireDefault(require("fs"));
32
- _fs = function() {
30
+ function _glob() {
31
+ const data = require("glob");
32
+ _glob = function() {
33
33
  return data;
34
34
  };
35
35
  return data;
@@ -83,15 +83,15 @@ async function getTemplateFilesToRenameAsync({ cwd , /**
83
83
  let config = userConfig ?? defaultRenameConfig;
84
84
  // Strip comments, trim whitespace, and remove empty lines.
85
85
  config = config.map((line)=>line.split(/(?<!\\)#/, 2)[0].trim()).filter((line)=>line !== "");
86
- return await (0, _fastGlob().glob)(config, {
86
+ return await (0, _glob().glob)(config, {
87
87
  cwd,
88
88
  // `true` is consistent with .gitignore. Allows `*.xml` to match .xml files
89
89
  // in all subdirs.
90
- baseNameMatch: true,
90
+ matchBase: true,
91
91
  dot: true,
92
92
  // Prevent climbing out of the template directory in case a template
93
93
  // includes a symlink to an external directory.
94
- followSymbolicLinks: false
94
+ follow: false
95
95
  });
96
96
  }
97
97
  async function renameTemplateAppNameAsync({ cwd , name , files }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/prebuild/renameTemplateAppName.ts"],"sourcesContent":["import { IOSConfig } from '@expo/config-plugins';\nimport { glob } from 'fast-glob';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { ExtractProps } from '../utils/npm';\n\nconst debug = require('debug')('expo:prebuild:copyTemplateFiles') as typeof console.log;\n\nfunction escapeXMLCharacters(original: string): string {\n const noAmps = original.replace('&', '&amp;');\n const noLt = noAmps.replace('<', '&lt;');\n const noGt = noLt.replace('>', '&gt;');\n const noApos = noGt.replace('\"', '\\\\\"');\n return noApos.replace(\"'\", \"\\\\'\");\n}\n\n/**\n * # Background\n *\n * `@expo/cli` and `create-expo` extract a template from a tarball (whether from\n * a local npm project or a GitHub repository), but these templates have a\n * static name that needs to be updated to match whatever app name the user\n * specified.\n *\n * By convention, the app name of all templates is \"HelloWorld\". During\n * extraction, filepaths are transformed via `createEntryResolver()` in\n * `createFileTransform.ts`, but the contents of files are left untouched.\n * Technically, the contents used to be transformed during extraction as well,\n * but due to poor configurability, we've moved to a post-extraction approach.\n *\n * # The new approach: Renaming the app post-extraction\n *\n * In this new approach, we take a list of file patterns, otherwise known as the\n * \"rename config\" to determine explicitly which files – relative to the root of\n * the template – to perform find-and-replace on, to update the app name.\n *\n * ## The rename config\n *\n * The rename config can be passed directly as a string array to\n * `getTemplateFilesToRenameAsync()`.\n *\n * The file patterns are formatted as glob expressions to be interpreted by\n * [fast-glob](https://github.com/mrmlnc/fast-glob). Comments are supported with\n * the `#` symbol, both in the plain-text file and string array formats.\n * Whitespace is trimmed and whitespace-only lines are ignored.\n *\n * If no rename config has been passed directly to\n * `getTemplateFilesToRenameAsync()` then this default rename config will be\n * used instead.\n */\nexport const defaultRenameConfig = [\n // Common\n '!**/node_modules',\n 'app.json',\n\n // Android\n 'android/**/*.gradle',\n 'android/app/BUCK',\n 'android/app/src/**/*.java',\n 'android/app/src/**/*.kt',\n 'android/app/src/**/*.xml',\n\n // iOS\n 'ios/Podfile',\n 'ios/**/*.xcodeproj/project.pbxproj',\n 'ios/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme',\n 'ios/**/*.xcworkspace/contents.xcworkspacedata',\n\n // macOS\n 'macos/Podfile',\n 'macos/**/*.xcodeproj/project.pbxproj',\n 'macos/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme',\n 'macos/**/*.xcworkspace/contents.xcworkspacedata',\n] as const;\n\n/**\n * Returns a list of files within a template matched by the resolved rename\n * config.\n *\n * The rename config is resolved in the order of preference:\n * Config provided as function param > defaultRenameConfig\n */\nexport async function getTemplateFilesToRenameAsync({\n cwd,\n /**\n * An array of patterns following the rename config format. If omitted, then\n * we fall back to defaultRenameConfig.\n * @see defaultRenameConfig\n */\n renameConfig: userConfig,\n}: Pick<ExtractProps, 'cwd'> & { renameConfig?: string[] }) {\n let config = userConfig ?? defaultRenameConfig;\n\n // Strip comments, trim whitespace, and remove empty lines.\n config = config.map((line) => line.split(/(?<!\\\\)#/, 2)[0].trim()).filter((line) => line !== '');\n\n return await glob(config, {\n cwd,\n // `true` is consistent with .gitignore. Allows `*.xml` to match .xml files\n // in all subdirs.\n baseNameMatch: true,\n dot: true,\n // Prevent climbing out of the template directory in case a template\n // includes a symlink to an external directory.\n followSymbolicLinks: false,\n });\n}\n\nexport async function renameTemplateAppNameAsync({\n cwd,\n name,\n files,\n}: Pick<ExtractProps, 'cwd' | 'name'> & {\n /**\n * An array of files to transform. Usually provided by calling\n * getTemplateFilesToRenameAsync().\n * @see getTemplateFilesToRenameAsync\n */\n files: string[];\n}) {\n debug(`Got files to transform: ${JSON.stringify(files)}`);\n\n await Promise.all(\n files.map(async (file) => {\n const absoluteFilePath = path.resolve(cwd, file);\n\n let contents: string;\n try {\n contents = await fs.promises.readFile(absoluteFilePath, { encoding: 'utf-8' });\n } catch (error) {\n throw new Error(\n `Failed to read template file: \"${absoluteFilePath}\". Was it removed mid-operation?`,\n { cause: error }\n );\n }\n\n debug(`Renaming app name in file: ${absoluteFilePath}`);\n\n const safeName = ['.xml', '.plist'].includes(path.extname(file))\n ? escapeXMLCharacters(name)\n : name;\n\n try {\n const replacement = contents\n .replace(/Hello App Display Name/g, safeName)\n .replace(/HelloWorld/g, IOSConfig.XcodeUtils.sanitizedName(safeName))\n .replace(/helloworld/g, IOSConfig.XcodeUtils.sanitizedName(safeName.toLowerCase()));\n\n if (replacement === contents) {\n return;\n }\n\n await fs.promises.writeFile(absoluteFilePath, replacement);\n } catch (error) {\n throw new Error(\n `Failed to overwrite template file: \"${absoluteFilePath}\". Was it removed mid-operation?`,\n { cause: error }\n );\n }\n })\n );\n}\n"],"names":["defaultRenameConfig","getTemplateFilesToRenameAsync","renameTemplateAppNameAsync","debug","require","escapeXMLCharacters","original","noAmps","replace","noLt","noGt","noApos","cwd","renameConfig","userConfig","config","map","line","split","trim","filter","glob","baseNameMatch","dot","followSymbolicLinks","name","files","JSON","stringify","Promise","all","file","absoluteFilePath","path","resolve","contents","fs","promises","readFile","encoding","error","Error","cause","safeName","includes","extname","replacement","IOSConfig","XcodeUtils","sanitizedName","toLowerCase","writeFile"],"mappings":"AAAA;;;;;;;;;;;IAmDaA,mBAAmB,MAAnB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AAG;YAAC,MAAM;YAAE,QAAQ;SAAC,CAACC,QAAQ,CAACX,KAAI,EAAA,QAAA,CAACY,OAAO,CAACd,IAAI,CAAC,CAAC,GAC5D1B,mBAAmB,CAACoB,IAAI,CAAC,GACzBA,IAAI,AAAC;QAET,IAAI;YACF,MAAMqB,WAAW,GAAGX,QAAQ,CACzB3B,OAAO,4BAA4BmC,QAAQ,CAAC,CAC5CnC,OAAO,gBAAgBuC,cAAS,EAAA,UAAA,CAACC,UAAU,CAACC,aAAa,CAACN,QAAQ,CAAC,CAAC,CACpEnC,OAAO,gBAAgBuC,cAAS,EAAA,UAAA,CAACC,UAAU,CAACC,aAAa,CAACN,QAAQ,CAACO,WAAW,EAAE,CAAC,CAAC,AAAC;YAEtF,IAAIJ,WAAW,KAAKX,QAAQ,EAAE;gBAC5B,OAAO;YACT,CAAC;YAED,MAAMC,GAAE,EAAA,QAAA,CAACC,QAAQ,CAACc,SAAS,CAACnB,gBAAgB,EAAEc,WAAW,CAAC,CAAC;QAC7D,EAAE,OAAON,MAAK,EAAE;YACd,MAAM,IAAIC,KAAK,CACb,CAAC,oCAAoC,EAAET,gBAAgB,CAAC,gCAAgC,CAAC,EACzF;gBAAEU,KAAK,EAAEF,MAAK;aAAE,CACjB,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/prebuild/renameTemplateAppName.ts"],"sourcesContent":["import { IOSConfig } from '@expo/config-plugins';\nimport fs from 'fs';\nimport { glob } from 'glob';\nimport path from 'path';\n\nimport { ExtractProps } from '../utils/npm';\n\nconst debug = require('debug')('expo:prebuild:copyTemplateFiles') as typeof console.log;\n\nfunction escapeXMLCharacters(original: string): string {\n const noAmps = original.replace('&', '&amp;');\n const noLt = noAmps.replace('<', '&lt;');\n const noGt = noLt.replace('>', '&gt;');\n const noApos = noGt.replace('\"', '\\\\\"');\n return noApos.replace(\"'\", \"\\\\'\");\n}\n\n/**\n * # Background\n *\n * `@expo/cli` and `create-expo` extract a template from a tarball (whether from\n * a local npm project or a GitHub repository), but these templates have a\n * static name that needs to be updated to match whatever app name the user\n * specified.\n *\n * By convention, the app name of all templates is \"HelloWorld\". During\n * extraction, filepaths are transformed via `createEntryResolver()` in\n * `createFileTransform.ts`, but the contents of files are left untouched.\n * Technically, the contents used to be transformed during extraction as well,\n * but due to poor configurability, we've moved to a post-extraction approach.\n *\n * # The new approach: Renaming the app post-extraction\n *\n * In this new approach, we take a list of file patterns, otherwise known as the\n * \"rename config\" to determine explicitly which files – relative to the root of\n * the template – to perform find-and-replace on, to update the app name.\n *\n * ## The rename config\n *\n * The rename config can be passed directly as a string array to\n * `getTemplateFilesToRenameAsync()`.\n *\n * The file patterns are formatted as glob expressions to be interpreted by\n * [glob](https://github.com/isaacs/node-glob). Comments are supported with\n * the `#` symbol, both in the plain-text file and string array formats.\n * Whitespace is trimmed and whitespace-only lines are ignored.\n *\n * If no rename config has been passed directly to\n * `getTemplateFilesToRenameAsync()` then this default rename config will be\n * used instead.\n */\nexport const defaultRenameConfig = [\n // Common\n '!**/node_modules',\n 'app.json',\n\n // Android\n 'android/**/*.gradle',\n 'android/app/BUCK',\n 'android/app/src/**/*.java',\n 'android/app/src/**/*.kt',\n 'android/app/src/**/*.xml',\n\n // iOS\n 'ios/Podfile',\n 'ios/**/*.xcodeproj/project.pbxproj',\n 'ios/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme',\n 'ios/**/*.xcworkspace/contents.xcworkspacedata',\n\n // macOS\n 'macos/Podfile',\n 'macos/**/*.xcodeproj/project.pbxproj',\n 'macos/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme',\n 'macos/**/*.xcworkspace/contents.xcworkspacedata',\n] as const;\n\n/**\n * Returns a list of files within a template matched by the resolved rename\n * config.\n *\n * The rename config is resolved in the order of preference:\n * Config provided as function param > defaultRenameConfig\n */\nexport async function getTemplateFilesToRenameAsync({\n cwd,\n /**\n * An array of patterns following the rename config format. If omitted, then\n * we fall back to defaultRenameConfig.\n * @see defaultRenameConfig\n */\n renameConfig: userConfig,\n}: Pick<ExtractProps, 'cwd'> & { renameConfig?: string[] }) {\n let config = userConfig ?? defaultRenameConfig;\n\n // Strip comments, trim whitespace, and remove empty lines.\n config = config.map((line) => line.split(/(?<!\\\\)#/, 2)[0].trim()).filter((line) => line !== '');\n\n return await glob(config, {\n cwd,\n // `true` is consistent with .gitignore. Allows `*.xml` to match .xml files\n // in all subdirs.\n matchBase: true,\n dot: true,\n // Prevent climbing out of the template directory in case a template\n // includes a symlink to an external directory.\n follow: false,\n });\n}\n\nexport async function renameTemplateAppNameAsync({\n cwd,\n name,\n files,\n}: Pick<ExtractProps, 'cwd' | 'name'> & {\n /**\n * An array of files to transform. Usually provided by calling\n * getTemplateFilesToRenameAsync().\n * @see getTemplateFilesToRenameAsync\n */\n files: string[];\n}) {\n debug(`Got files to transform: ${JSON.stringify(files)}`);\n\n await Promise.all(\n files.map(async (file) => {\n const absoluteFilePath = path.resolve(cwd, file);\n\n let contents: string;\n try {\n contents = await fs.promises.readFile(absoluteFilePath, { encoding: 'utf-8' });\n } catch (error) {\n throw new Error(\n `Failed to read template file: \"${absoluteFilePath}\". Was it removed mid-operation?`,\n { cause: error }\n );\n }\n\n debug(`Renaming app name in file: ${absoluteFilePath}`);\n\n const safeName = ['.xml', '.plist'].includes(path.extname(file))\n ? escapeXMLCharacters(name)\n : name;\n\n try {\n const replacement = contents\n .replace(/Hello App Display Name/g, safeName)\n .replace(/HelloWorld/g, IOSConfig.XcodeUtils.sanitizedName(safeName))\n .replace(/helloworld/g, IOSConfig.XcodeUtils.sanitizedName(safeName.toLowerCase()));\n\n if (replacement === contents) {\n return;\n }\n\n await fs.promises.writeFile(absoluteFilePath, replacement);\n } catch (error) {\n throw new Error(\n `Failed to overwrite template file: \"${absoluteFilePath}\". Was it removed mid-operation?`,\n { cause: error }\n );\n }\n })\n );\n}\n"],"names":["defaultRenameConfig","getTemplateFilesToRenameAsync","renameTemplateAppNameAsync","debug","require","escapeXMLCharacters","original","noAmps","replace","noLt","noGt","noApos","cwd","renameConfig","userConfig","config","map","line","split","trim","filter","glob","matchBase","dot","follow","name","files","JSON","stringify","Promise","all","file","absoluteFilePath","path","resolve","contents","fs","promises","readFile","encoding","error","Error","cause","safeName","includes","extname","replacement","IOSConfig","XcodeUtils","sanitizedName","toLowerCase","writeFile"],"mappings":"AAAA;;;;;;;;;;;IAmDaA,mBAAmB,MAAnBA,mBAAmB;IAgCVC,6BAA6B,MAA7BA,6BAA6B;IA0B7BC,0BAA0B,MAA1BA,0BAA0B;;;yBA7GtB,sBAAsB;;;;;;;8DACjC,IAAI;;;;;;;yBACE,MAAM;;;;;;;8DACV,MAAM;;;;;;;;;;;AAIvB,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAExF,SAASC,mBAAmB,CAACC,QAAgB,EAAU;IACrD,MAAMC,MAAM,GAAGD,QAAQ,CAACE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,AAAC;IAC9C,MAAMC,IAAI,GAAGF,MAAM,CAACC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,AAAC;IACzC,MAAME,IAAI,GAAGD,IAAI,CAACD,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,AAAC;IACvC,MAAMG,MAAM,GAAGD,IAAI,CAACF,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,AAAC;IACxC,OAAOG,MAAM,CAACH,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC;AAoCM,MAAMR,mBAAmB,GAAG;IACjC,SAAS;IACT,kBAAkB;IAClB,UAAU;IAEV,UAAU;IACV,qBAAqB;IACrB,kBAAkB;IAClB,2BAA2B;IAC3B,yBAAyB;IACzB,0BAA0B;IAE1B,MAAM;IACN,aAAa;IACb,oCAAoC;IACpC,sDAAsD;IACtD,+CAA+C;IAE/C,QAAQ;IACR,eAAe;I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compare(resp.PairRecordData, 0, 8) === 0) {
129
129
  debug("Binary plist pair record detected.");
130
- return (0, _plist1.parsePlistBuffer)(resp.PairRecordData)[0];
130
+ const pairRecords = (0, _plist1.parsePlistBuffer)(resp.PairRecordData);
131
+ return Array.isArray(pairRecords) ? pairRecords[0] : pairRecords;
131
132
  } else {
132
133
  // TODO: use parsePlistBuffer
133
134
  return _plist().default.parse(resp.PairRecordData.toString()); // TODO: type guard