@expo/cli 0.24.20 → 0.24.22
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.
- package/build/bin/cli +1 -1
- package/build/src/api/getExpoSchema.js +8 -7
- package/build/src/api/getExpoSchema.js.map +1 -1
- package/build/src/export/exportApp.js +1 -0
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportHermes.js +34 -9
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +3 -1
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/package.json +6 -5
- package/build/src/utils/jsonSchemaDeref.js +0 -150
- package/build/src/utils/jsonSchemaDeref.js.map +0 -1
package/build/bin/cli
CHANGED
|
@@ -16,6 +16,13 @@ _export(exports, {
|
|
|
16
16
|
return getAssetSchemasAsync;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
+
function _schemautils() {
|
|
20
|
+
const data = require("@expo/schema-utils");
|
|
21
|
+
_schemautils = function() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
19
26
|
function _fs() {
|
|
20
27
|
const data = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
21
28
|
_fs = function() {
|
|
@@ -33,7 +40,6 @@ function _path() {
|
|
|
33
40
|
const _client = require("./rest/client");
|
|
34
41
|
const _env = require("../utils/env");
|
|
35
42
|
const _errors = require("../utils/errors");
|
|
36
|
-
const _jsonSchemaDeref = require("../utils/jsonSchemaDeref");
|
|
37
43
|
function _interop_require_default(obj) {
|
|
38
44
|
return obj && obj.__esModule ? obj : {
|
|
39
45
|
default: obj
|
|
@@ -42,12 +48,7 @@ function _interop_require_default(obj) {
|
|
|
42
48
|
const schemaJson = {};
|
|
43
49
|
async function _getSchemaAsync(sdkVersion) {
|
|
44
50
|
const json = await getSchemaJSONAsync(sdkVersion);
|
|
45
|
-
|
|
46
|
-
// We re-implemented it locally to remove it, since it comes with heavy dependencies
|
|
47
|
-
// and a large install time impact.
|
|
48
|
-
// The tests have been ported to match the behaviour closely, but we removed
|
|
49
|
-
// local file ref support. For our purposes the behaviour should be identical.
|
|
50
|
-
return (0, _jsonSchemaDeref.jsonSchemaDeref)(json.schema);
|
|
51
|
+
return (0, _schemautils().derefSchema)(json.schema);
|
|
51
52
|
}
|
|
52
53
|
async function getAssetSchemasAsync(sdkVersion = 'UNVERSIONED') {
|
|
53
54
|
// If no SDK version is available then fall back to unversioned
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api/getExpoSchema.ts"],"sourcesContent":["import { JSONObject } from '@expo/json-file';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { createCachedFetch, getResponseDataOrThrow } from './rest/client';\nimport { env } from '../utils/env';\nimport { CommandError } from '../utils/errors';\
|
|
1
|
+
{"version":3,"sources":["../../../src/api/getExpoSchema.ts"],"sourcesContent":["import type { JSONObject } from '@expo/json-file';\nimport { derefSchema } from '@expo/schema-utils';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { createCachedFetch, getResponseDataOrThrow } from './rest/client';\nimport { env } from '../utils/env';\nimport { CommandError } from '../utils/errors';\n\nexport type Schema = any;\n\nexport type AssetSchema = {\n fieldPath: string;\n};\n\nconst schemaJson: { [sdkVersion: string]: Schema } = {};\n\nexport async function _getSchemaAsync(sdkVersion: string): Promise<Schema> {\n const json = await getSchemaJSONAsync(sdkVersion);\n return derefSchema(json.schema);\n}\n\n/**\n * Array of schema nodes that refer to assets along with their field path (eg. 'notification.icon')\n *\n * @param sdkVersion\n */\nexport async function getAssetSchemasAsync(sdkVersion: string = 'UNVERSIONED'): Promise<string[]> {\n // If no SDK version is available then fall back to unversioned\n const schema = await _getSchemaAsync(sdkVersion);\n const assetSchemas: string[] = [];\n const visit = (node: Schema, fieldPath: string) => {\n if (node.meta && node.meta.asset) {\n assetSchemas.push(fieldPath);\n }\n const properties = node.properties;\n if (properties) {\n Object.keys(properties).forEach((property) =>\n visit(properties[property], `${fieldPath}${fieldPath.length > 0 ? '.' : ''}${property}`)\n );\n }\n };\n visit(schema, '');\n\n return assetSchemas;\n}\n\nasync function getSchemaJSONAsync(sdkVersion: string): Promise<{ schema: Schema }> {\n if (env.EXPO_UNIVERSE_DIR) {\n return JSON.parse(\n fs\n .readFileSync(\n path.join(\n env.EXPO_UNIVERSE_DIR,\n 'server',\n 'www',\n 'xdl-schemas',\n 'UNVERSIONED-schema.json'\n )\n )\n .toString()\n );\n }\n\n if (!schemaJson[sdkVersion]) {\n try {\n schemaJson[sdkVersion] = await getConfigurationSchemaAsync(sdkVersion);\n } catch (e: any) {\n if (e.code === 'INVALID_JSON') {\n throw new CommandError('INVALID_JSON', `Couldn't read schema from server`);\n }\n\n throw e;\n }\n }\n\n return schemaJson[sdkVersion];\n}\n\nasync function getConfigurationSchemaAsync(sdkVersion: string): Promise<JSONObject> {\n // Reconstruct the cached fetch since caching could be disabled.\n const fetchAsync = createCachedFetch({\n cacheDirectory: 'schema-cache',\n // We'll use a 1 week cache for versions so older versions get flushed out eventually.\n ttl: 1000 * 60 * 60 * 24 * 7,\n });\n const response = await fetchAsync(`project/configuration/schema/${sdkVersion}`);\n const json = await response.json();\n\n return getResponseDataOrThrow<JSONObject>(json);\n}\n"],"names":["_getSchemaAsync","getAssetSchemasAsync","schemaJson","sdkVersion","json","getSchemaJSONAsync","derefSchema","schema","assetSchemas","visit","node","fieldPath","meta","asset","push","properties","Object","keys","forEach","property","length","env","EXPO_UNIVERSE_DIR","JSON","parse","fs","readFileSync","path","join","toString","getConfigurationSchemaAsync","e","code","CommandError","fetchAsync","createCachedFetch","cacheDirectory","ttl","response","getResponseDataOrThrow"],"mappings":";;;;;;;;;;;IAiBsBA,eAAe;eAAfA;;IAUAC,oBAAoB;eAApBA;;;;yBA1BM;;;;;;;gEACb;;;;;;;gEACE;;;;;;wBAEy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gEAAgE;IAChE,MAAM+B,aAAaC,IAAAA,yBAAiB,EAAC;QACnCC,gBAAgB;QAChB,sFAAsF;QACtFC,KAAK,OAAO,KAAK,KAAK,KAAK;IAC7B;IACA,MAAMC,WAAW,MAAMJ,WAAW,CAAC,6BAA6B,EAAE/B,YAAY;IAC9E,MAAMC,OAAO,MAAMkC,SAASlC,IAAI;IAEhC,OAAOmC,IAAAA,8BAAsB,EAAanC;AAC5C"}
|
|
@@ -249,6 +249,7 @@ async function exportAppAsync(projectRoot, { platforms, outputDir, clear, dev, d
|
|
|
249
249
|
htmlOutputName
|
|
250
250
|
});
|
|
251
251
|
domComponentAssetsMetadata[platform] = [
|
|
252
|
+
...domComponentAssetsMetadata[platform] || [],
|
|
252
253
|
...await (0, _exportDomComponents.addDomBundleToMetadataAsync)(platformDomComponentsBundle),
|
|
253
254
|
...(0, _exportDomComponents.transformDomEntryForMd5Filename)({
|
|
254
255
|
files,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport type { Platform } from '@expo/config';\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { type PlatformMetadata, createMetadataJson } from './createMetadataJson';\nimport { exportAssetsAsync } from './exportAssets';\nimport {\n addDomBundleToMetadataAsync,\n exportDomComponentAsync,\n transformNativeBundleForMd5Filename,\n transformDomEntryForMd5Filename,\n} from './exportDomComponents';\nimport { assertEngineMismatchAsync, isEnableHermesManaged } from './exportHermes';\nimport { exportApiRoutesStandaloneAsync, exportFromServerAsync } from './exportStaticAsync';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { copyPublicFolderAsync } from './publicFolder';\nimport { Options } from './resolveOptions';\nimport {\n ExportAssetMap,\n BundleOutput,\n getFilesFromSerialAssets,\n persistMetroFilesAsync,\n BundleAssetWithFileHashes,\n} from './saveAssets';\nimport { createAssetMap } from './writeContents';\nimport * as Log from '../log';\nimport { WebSupportProjectPrerequisite } from '../start/doctor/web/WebSupportProjectPrerequisite';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { getRouterDirectoryModuleIdWithManifest } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { getEntryWithServerRoot } from '../start/server/middleware/ManifestMiddleware';\nimport { getBaseUrlFromExpoConfig } from '../start/server/middleware/metroOptions';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { env } from '../utils/env';\nimport { CommandError } from '../utils/errors';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n sourceMaps,\n minify,\n bytecode,\n maxWorkers,\n skipSSG,\n }: Pick<\n Options,\n | 'dumpAssetmap'\n | 'sourceMaps'\n | 'dev'\n | 'clear'\n | 'outputDir'\n | 'platforms'\n | 'minify'\n | 'bytecode'\n | 'maxWorkers'\n | 'skipSSG'\n >\n): Promise<void> {\n // Force the environment during export and do not allow overriding it.\n const environment = dev ? 'development' : 'production';\n process.env.NODE_ENV = environment;\n setNodeEnv(environment);\n\n require('@expo/env').load(projectRoot);\n\n const projectConfig = getConfig(projectRoot);\n const exp = await getPublicExpoManifestAsync(projectRoot, {\n // Web doesn't require validation.\n skipValidation: platforms.length === 1 && platforms[0] === 'web',\n });\n\n if (platforms.includes('web')) {\n await new WebSupportProjectPrerequisite(projectRoot).assertAsync();\n }\n\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n\n if (skipSSG && exp.web?.output !== 'server') {\n throw new CommandError('--no-ssg can only be used with `web.output: server`');\n }\n\n const baseUrl = getBaseUrlFromExpoConfig(exp);\n\n if (!bytecode && (platforms.includes('ios') || platforms.includes('android'))) {\n Log.warn(\n `Bytecode makes the app startup faster, disabling bytecode is highly discouraged and should only be used for debugging purposes.`\n );\n }\n\n // Print out logs\n if (baseUrl) {\n Log.log();\n Log.log(chalk.gray`Using (experimental) base path: ${baseUrl}`);\n // Warn if not using an absolute path.\n if (!baseUrl.startsWith('/')) {\n Log.log(\n chalk.yellow` Base path does not start with a slash. Requests will not be absolute.`\n );\n }\n }\n\n const mode = dev ? 'development' : 'production';\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n const outputPath = path.resolve(projectRoot, outputDir);\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n\n const files: ExportAssetMap = new Map();\n\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify,\n mode,\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: clear,\n maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const bundles: Partial<Record<Platform, BundleOutput>> = {};\n const domComponentAssetsMetadata: Partial<Record<Platform, PlatformMetadata['assets']>> = {};\n\n const spaPlatforms =\n // TODO: Support server and static rendering for server component exports.\n useServerRendering && !devServer.isReactServerComponentsEnabled\n ? platforms.filter((platform) => platform !== 'web')\n : platforms;\n\n try {\n if (devServer.isReactServerComponentsEnabled) {\n // In RSC mode, we only need these to be in the client dir.\n // TODO: Merge back with other copy after we add SSR.\n try {\n await copyPublicFolderAsync(publicPath, path.join(outputPath, 'client'));\n } catch (error) {\n Log.error('Failed to copy public directory to dist directory');\n throw error;\n }\n } else {\n // NOTE(kitten): The public folder is currently always copied, regardless of targetDomain\n // split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`\n await copyPublicFolderAsync(publicPath, outputPath);\n }\n\n let templateHtml: string | undefined;\n // Can be empty during web-only SSG.\n if (spaPlatforms.length) {\n await Promise.all(\n spaPlatforms.map(async (platform) => {\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 const isHermes = isEnableHermesManaged(exp, platform);\n if (isHermes) {\n await assertEngineMismatchAsync(projectRoot, exp, platform);\n }\n\n let bundle: {\n artifacts: SerialAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n files?: ExportAssetMap;\n };\n\n try {\n // Run metro bundler and create the JS bundles/source maps.\n bundle = await devServer.nativeExportBundleAsync(\n exp,\n {\n platform,\n splitChunks:\n !env.EXPO_NO_BUNDLE_SPLITTING &&\n ((devServer.isReactServerComponentsEnabled && !bytecode) || platform === 'web'),\n mainModuleName: getEntryWithServerRoot(projectRoot, {\n platform,\n pkg: projectConfig.pkg,\n }),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: sourceMaps,\n bytecode: bytecode && isHermes,\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n files\n );\n } catch (error) {\n Log.log('');\n if (error instanceof Error) {\n Log.exception(error);\n } else {\n Log.error('Failed to bundle the app');\n Log.log(error as any);\n }\n process.exit(1);\n }\n\n bundles[platform] = bundle;\n\n getFilesFromSerialAssets(bundle.artifacts, {\n includeSourceMaps: sourceMaps,\n files,\n isServerHosted: devServer.isReactServerComponentsEnabled,\n });\n\n // TODO: Remove duplicates...\n const expoDomComponentReferences = bundle.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat();\n await Promise.all(\n // TODO: Make a version of this which uses `this.metro.getBundler().buildGraphForEntries([])` to bundle all the DOM components at once.\n expoDomComponentReferences.map(async (filePath) => {\n const { bundle: platformDomComponentsBundle, htmlOutputName } =\n await exportDomComponentAsync({\n filePath,\n projectRoot,\n dev,\n devServer,\n isHermes,\n includeSourceMaps: sourceMaps,\n exp,\n files,\n useMd5Filename: true,\n });\n\n // Merge the assets from the DOM component into the output assets.\n // @ts-expect-error: mutate assets\n bundle.assets.push(...platformDomComponentsBundle.assets);\n\n transformNativeBundleForMd5Filename({\n domComponentReference: filePath,\n nativeBundle: bundle,\n files,\n htmlOutputName,\n });\n domComponentAssetsMetadata[platform] = [\n ...(await addDomBundleToMetadataAsync(platformDomComponentsBundle)),\n ...transformDomEntryForMd5Filename({\n files,\n htmlOutputName,\n }),\n ];\n })\n );\n\n if (platform === 'web') {\n // TODO: Unify with exportStaticAsync\n // TODO: Maybe move to the serializer.\n let html = await serializeHtmlWithAssets({\n isExporting: true,\n resources: bundle.artifacts,\n template: await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [],\n cssLinks: [],\n exp: projectConfig.exp,\n }),\n baseUrl,\n });\n\n // Add the favicon assets to the HTML.\n const modifyHtml = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n exp: projectConfig.exp,\n });\n if (modifyHtml) {\n html = modifyHtml(html);\n }\n\n // HACK: This is used for adding SSR shims in React Server Components.\n templateHtml = html;\n\n // Generate SPA-styled HTML file.\n // If web exists, then write the template HTML file.\n files.set('index.html', {\n contents: html,\n targetDomain: devServer.isReactServerComponentsEnabled ? 'server' : 'client',\n });\n }\n })\n );\n\n if (devServer.isReactServerComponentsEnabled) {\n const isWeb = platforms.includes('web');\n\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: !isWeb,\n templateHtml,\n });\n }\n\n // TODO: Use same asset system across platforms again.\n const { assets, embeddedHashSet } = await exportAssetsAsync(projectRoot, {\n files,\n exp,\n outputDir: outputPath,\n bundles,\n baseUrl,\n });\n\n if (dumpAssetmap) {\n Log.log('Creating asset map');\n files.set('assetmap.json', { contents: JSON.stringify(createAssetMap({ assets })) });\n }\n\n const targetDomain = devServer.isReactServerComponentsEnabled ? 'client/' : '';\n const fileNames = Object.fromEntries(\n Object.entries(bundles).map(([platform, bundle]) => [\n platform,\n bundle.artifacts\n .filter((asset) => asset.type === 'js')\n .map((asset) => targetDomain + asset.filename),\n ])\n );\n\n // Generate a `metadata.json` for EAS Update.\n const contents = createMetadataJson({\n bundles,\n fileNames,\n embeddedHashSet,\n domComponentAssetsMetadata,\n });\n files.set('metadata.json', { contents: JSON.stringify(contents) });\n }\n\n // Additional web-only steps...\n\n if (platforms.includes('web') && useServerRendering) {\n const exportServer = exp.web?.output === 'server';\n\n if (exportServer) {\n // TODO: Remove when this is abstracted into the files map\n await copyPublicFolderAsync(publicPath, path.resolve(outputPath, 'client'));\n }\n\n if (skipSSG) {\n Log.log('Skipping static site generation');\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: true,\n });\n\n // Output a placeholder index.html if one doesn't exist in the public directory.\n // This ensures native + API routes have some content at the root URL.\n const placeholderIndex = path.resolve(outputPath, 'client/index.html');\n if (!fs.existsSync(placeholderIndex)) {\n files.set('index.html', {\n contents: `<html><body></body></html>`,\n targetDomain: 'client',\n });\n }\n } else if (\n // TODO: Support static export with RSC.\n !devServer.isReactServerComponentsEnabled\n ) {\n await exportFromServerAsync(projectRoot, devServer, {\n mode,\n files,\n clear: !!clear,\n outputDir: outputPath,\n minify,\n baseUrl,\n includeSourceMaps: sourceMaps,\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n reactCompiler: !!exp.experiments?.reactCompiler,\n exportServer,\n maxWorkers,\n isExporting: true,\n exp: projectConfig.exp,\n });\n }\n }\n } finally {\n await devServerManager.stopAsync();\n }\n\n // Write all files at the end for unified logging.\n await persistMetroFilesAsync(files, outputPath);\n}\n"],"names":["exportAppAsync","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","sourceMaps","minify","bytecode","maxWorkers","skipSSG","exp","environment","process","env","NODE_ENV","setNodeEnv","require","load","projectConfig","getConfig","getPublicExpoManifestAsync","skipValidation","length","includes","WebSupportProjectPrerequisite","assertAsync","useServerRendering","web","output","CommandError","baseUrl","getBaseUrlFromExpoConfig","Log","warn","log","chalk","gray","startsWith","yellow","mode","publicPath","path","resolve","EXPO_PUBLIC_FOLDER","outputPath","files","Map","devServerManager","DevServerManager","startMetroAsync","port","isExporting","location","resetDevServer","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","bundles","domComponentAssetsMetadata","spaPlatforms","isReactServerComponentsEnabled","filter","platform","copyPublicFolderAsync","join","error","templateHtml","Promise","all","map","isHermes","isEnableHermesManaged","assertEngineMismatchAsync","bundle","nativeExportBundleAsync","splitChunks","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","getEntryWithServerRoot","pkg","engine","undefined","serializerIncludeMaps","reactCompiler","experiments","Error","exception","exit","getFilesFromSerialAssets","artifacts","includeSourceMaps","isServerHosted","expoDomComponentReferences","artifact","Array","isArray","metadata","flat","filePath","platformDomComponentsBundle","htmlOutputName","exportDomComponentAsync","useMd5Filename","assets","push","transformNativeBundleForMd5Filename","domComponentReference","nativeBundle","addDomBundleToMetadataAsync","transformDomEntryForMd5Filename","html","serializeHtmlWithAssets","resources","template","createTemplateHtmlFromExpoConfigAsync","scripts","cssLinks","modifyHtml","getVirtualFaviconAssetsAsync","set","contents","targetDomain","isWeb","exportApiRoutesStandaloneAsync","apiRoutesOnly","embeddedHashSet","exportAssetsAsync","JSON","stringify","createAssetMap","fileNames","Object","fromEntries","entries","asset","type","filename","createMetadataJson","exportServer","placeholderIndex","fs","existsSync","exportFromServerAsync","routerRoot","getRouterDirectoryModuleIdWithManifest","stopAsync","persistMetroFilesAsync"],"mappings":";;;;+BA2CsBA;;;eAAAA;;;;yBA3CI;;;;;;;gEAGP;;;;;;;gEACD;;;;;;;gEACH;;;;;;;gEACE;;;;;;oCAEyC;8BACxB;qCAM3B;8BAC0D;mCACK;yBACzB;uCACF;8BACL;4BAQ/B;+BACwB;6DACV;+CACyB;kCACb;uCACK;wBACiB;+BACf;oCACD;8BACE;6BACa;qBAClC;wBACS;yBACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpB,eAAeA,eACpBC,WAAmB,EACnB,EACEC,SAAS,E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AAqB,EAACxB,YAAYC,eAAI,CAACC,OAAO,CAACE,YAAY;YACnE;YAEA,IAAInC,SAAS;gBACXuB,KAAIE,GAAG,CAAC;gBACR,MAAM0F,IAAAA,iDAA8B,EAACtE,WAAW;oBAC9CT;oBACAkB,UAAU;oBACV8D,eAAe;gBACjB;gBAEA,gFAAgF;gBAChF,sEAAsE;gBACtE,MAAMe,mBAAmBnG,eAAI,CAACC,OAAO,CAACE,YAAY;gBAClD,IAAI,CAACiG,aAAE,CAACC,UAAU,CAACF,mBAAmB;oBACpC/F,MAAM2E,GAAG,CAAC,cAAc;wBACtBC,UAAU,CAAC,0BAA0B,CAAC;wBACtCC,cAAc;oBAChB;gBACF;YACF,OAAO,IACL,wCAAwC;YACxC,CAACpE,UAAUO,8BAA8B,EACzC;oBAUmBnD;gBATnB,MAAMqI,IAAAA,wCAAqB,EAAChJ,aAAauD,WAAW;oBAClDf;oBACAM;oBACA3C,OAAO,CAAC,CAACA;oBACTD,WAAW2C;oBACXtC;oBACAwB;oBACA6D,mBAAmBtF;oBACnB2I,YAAYC,IAAAA,8CAAsC,EAAClJ,aAAaW;oBAChE0E,eAAe,CAAC,GAAC1E,mBAAAA,IAAI2E,WAAW,qBAAf3E,iBAAiB0E,aAAa;oBAC/CuD;oBACAnI;oBACA2C,aAAa;oBACbzC,KAAKQ,cAAcR,GAAG;gBACxB;YACF;QACF;IACF,SAAU;QACR,MAAMqC,iBAAiBmG,SAAS;IAClC;IAEA,kDAAkD;IAClD,MAAMC,IAAAA,kCAAsB,EAACtG,OAAOD;AACtC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/export/exportApp.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport type { Platform } from '@expo/config';\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { type PlatformMetadata, createMetadataJson } from './createMetadataJson';\nimport { exportAssetsAsync } from './exportAssets';\nimport {\n addDomBundleToMetadataAsync,\n exportDomComponentAsync,\n transformNativeBundleForMd5Filename,\n transformDomEntryForMd5Filename,\n} from './exportDomComponents';\nimport { assertEngineMismatchAsync, isEnableHermesManaged } from './exportHermes';\nimport { exportApiRoutesStandaloneAsync, exportFromServerAsync } from './exportStaticAsync';\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { getPublicExpoManifestAsync } from './getPublicExpoManifest';\nimport { copyPublicFolderAsync } from './publicFolder';\nimport { Options } from './resolveOptions';\nimport {\n ExportAssetMap,\n BundleOutput,\n getFilesFromSerialAssets,\n persistMetroFilesAsync,\n BundleAssetWithFileHashes,\n} from './saveAssets';\nimport { createAssetMap } from './writeContents';\nimport * as Log from '../log';\nimport { WebSupportProjectPrerequisite } from '../start/doctor/web/WebSupportProjectPrerequisite';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { MetroBundlerDevServer } from '../start/server/metro/MetroBundlerDevServer';\nimport { getRouterDirectoryModuleIdWithManifest } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { getEntryWithServerRoot } from '../start/server/middleware/ManifestMiddleware';\nimport { getBaseUrlFromExpoConfig } from '../start/server/middleware/metroOptions';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../start/server/webTemplate';\nimport { env } from '../utils/env';\nimport { CommandError } from '../utils/errors';\nimport { setNodeEnv } from '../utils/nodeEnv';\n\nexport async function exportAppAsync(\n projectRoot: string,\n {\n platforms,\n outputDir,\n clear,\n dev,\n dumpAssetmap,\n sourceMaps,\n minify,\n bytecode,\n maxWorkers,\n skipSSG,\n }: Pick<\n Options,\n | 'dumpAssetmap'\n | 'sourceMaps'\n | 'dev'\n | 'clear'\n | 'outputDir'\n | 'platforms'\n | 'minify'\n | 'bytecode'\n | 'maxWorkers'\n | 'skipSSG'\n >\n): Promise<void> {\n // Force the environment during export and do not allow overriding it.\n const environment = dev ? 'development' : 'production';\n process.env.NODE_ENV = environment;\n setNodeEnv(environment);\n\n require('@expo/env').load(projectRoot);\n\n const projectConfig = getConfig(projectRoot);\n const exp = await getPublicExpoManifestAsync(projectRoot, {\n // Web doesn't require validation.\n skipValidation: platforms.length === 1 && platforms[0] === 'web',\n });\n\n if (platforms.includes('web')) {\n await new WebSupportProjectPrerequisite(projectRoot).assertAsync();\n }\n\n const useServerRendering = ['static', 'server'].includes(exp.web?.output ?? '');\n\n if (skipSSG && exp.web?.output !== 'server') {\n throw new CommandError('--no-ssg can only be used with `web.output: server`');\n }\n\n const baseUrl = getBaseUrlFromExpoConfig(exp);\n\n if (!bytecode && (platforms.includes('ios') || platforms.includes('android'))) {\n Log.warn(\n `Bytecode makes the app startup faster, disabling bytecode is highly discouraged and should only be used for debugging purposes.`\n );\n }\n\n // Print out logs\n if (baseUrl) {\n Log.log();\n Log.log(chalk.gray`Using (experimental) base path: ${baseUrl}`);\n // Warn if not using an absolute path.\n if (!baseUrl.startsWith('/')) {\n Log.log(\n chalk.yellow` Base path does not start with a slash. Requests will not be absolute.`\n );\n }\n }\n\n const mode = dev ? 'development' : 'production';\n const publicPath = path.resolve(projectRoot, env.EXPO_PUBLIC_FOLDER);\n const outputPath = path.resolve(projectRoot, outputDir);\n\n // Write the JS bundles to disk, and get the bundle file names (this could change with async chunk loading support).\n\n const files: ExportAssetMap = new Map();\n\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, {\n minify,\n mode,\n port: 8081,\n isExporting: true,\n location: {},\n resetDevServer: clear,\n maxWorkers,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const bundles: Partial<Record<Platform, BundleOutput>> = {};\n const domComponentAssetsMetadata: Partial<Record<Platform, PlatformMetadata['assets']>> = {};\n\n const spaPlatforms =\n // TODO: Support server and static rendering for server component exports.\n useServerRendering && !devServer.isReactServerComponentsEnabled\n ? platforms.filter((platform) => platform !== 'web')\n : platforms;\n\n try {\n if (devServer.isReactServerComponentsEnabled) {\n // In RSC mode, we only need these to be in the client dir.\n // TODO: Merge back with other copy after we add SSR.\n try {\n await copyPublicFolderAsync(publicPath, path.join(outputPath, 'client'));\n } catch (error) {\n Log.error('Failed to copy public directory to dist directory');\n throw error;\n }\n } else {\n // NOTE(kitten): The public folder is currently always copied, regardless of targetDomain\n // split. Hence, there's another separate `copyPublicFolderAsync` call below for `web`\n await copyPublicFolderAsync(publicPath, outputPath);\n }\n\n let templateHtml: string | undefined;\n // Can be empty during web-only SSG.\n if (spaPlatforms.length) {\n await Promise.all(\n spaPlatforms.map(async (platform) => {\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 const isHermes = isEnableHermesManaged(exp, platform);\n if (isHermes) {\n await assertEngineMismatchAsync(projectRoot, exp, platform);\n }\n\n let bundle: {\n artifacts: SerialAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n files?: ExportAssetMap;\n };\n\n try {\n // Run metro bundler and create the JS bundles/source maps.\n bundle = await devServer.nativeExportBundleAsync(\n exp,\n {\n platform,\n splitChunks:\n !env.EXPO_NO_BUNDLE_SPLITTING &&\n ((devServer.isReactServerComponentsEnabled && !bytecode) || platform === 'web'),\n mainModuleName: getEntryWithServerRoot(projectRoot, {\n platform,\n pkg: projectConfig.pkg,\n }),\n mode: dev ? 'development' : 'production',\n engine: isHermes ? 'hermes' : undefined,\n serializerIncludeMaps: sourceMaps,\n bytecode: bytecode && isHermes,\n reactCompiler: !!exp.experiments?.reactCompiler,\n },\n files\n );\n } catch (error) {\n Log.log('');\n if (error instanceof Error) {\n Log.exception(error);\n } else {\n Log.error('Failed to bundle the app');\n Log.log(error as any);\n }\n process.exit(1);\n }\n\n bundles[platform] = bundle;\n\n getFilesFromSerialAssets(bundle.artifacts, {\n includeSourceMaps: sourceMaps,\n files,\n isServerHosted: devServer.isReactServerComponentsEnabled,\n });\n\n // TODO: Remove duplicates...\n const expoDomComponentReferences = bundle.artifacts\n .map((artifact) =>\n Array.isArray(artifact.metadata.expoDomComponentReferences)\n ? artifact.metadata.expoDomComponentReferences\n : []\n )\n .flat();\n await Promise.all(\n // TODO: Make a version of this which uses `this.metro.getBundler().buildGraphForEntries([])` to bundle all the DOM components at once.\n expoDomComponentReferences.map(async (filePath) => {\n const { bundle: platformDomComponentsBundle, htmlOutputName } =\n await exportDomComponentAsync({\n filePath,\n projectRoot,\n dev,\n devServer,\n isHermes,\n includeSourceMaps: sourceMaps,\n exp,\n files,\n useMd5Filename: true,\n });\n\n // Merge the assets from the DOM component into the output assets.\n // @ts-expect-error: mutate assets\n bundle.assets.push(...platformDomComponentsBundle.assets);\n\n transformNativeBundleForMd5Filename({\n domComponentReference: filePath,\n nativeBundle: bundle,\n files,\n htmlOutputName,\n });\n domComponentAssetsMetadata[platform] = [\n ...(domComponentAssetsMetadata[platform] || []),\n ...(await addDomBundleToMetadataAsync(platformDomComponentsBundle)),\n ...transformDomEntryForMd5Filename({\n files,\n htmlOutputName,\n }),\n ];\n })\n );\n\n if (platform === 'web') {\n // TODO: Unify with exportStaticAsync\n // TODO: Maybe move to the serializer.\n let html = await serializeHtmlWithAssets({\n isExporting: true,\n resources: bundle.artifacts,\n template: await createTemplateHtmlFromExpoConfigAsync(projectRoot, {\n scripts: [],\n cssLinks: [],\n exp: projectConfig.exp,\n }),\n baseUrl,\n });\n\n // Add the favicon assets to the HTML.\n const modifyHtml = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n exp: projectConfig.exp,\n });\n if (modifyHtml) {\n html = modifyHtml(html);\n }\n\n // HACK: This is used for adding SSR shims in React Server Components.\n templateHtml = html;\n\n // Generate SPA-styled HTML file.\n // If web exists, then write the template HTML file.\n files.set('index.html', {\n contents: html,\n targetDomain: devServer.isReactServerComponentsEnabled ? 'server' : 'client',\n });\n }\n })\n );\n\n if (devServer.isReactServerComponentsEnabled) {\n const isWeb = platforms.includes('web');\n\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: !isWeb,\n templateHtml,\n });\n }\n\n // TODO: Use same asset system across platforms again.\n const { assets, embeddedHashSet } = await exportAssetsAsync(projectRoot, {\n files,\n exp,\n outputDir: outputPath,\n bundles,\n baseUrl,\n });\n\n if (dumpAssetmap) {\n Log.log('Creating asset map');\n files.set('assetmap.json', { contents: JSON.stringify(createAssetMap({ assets })) });\n }\n\n const targetDomain = devServer.isReactServerComponentsEnabled ? 'client/' : '';\n const fileNames = Object.fromEntries(\n Object.entries(bundles).map(([platform, bundle]) => [\n platform,\n bundle.artifacts\n .filter((asset) => asset.type === 'js')\n .map((asset) => targetDomain + asset.filename),\n ])\n );\n\n // Generate a `metadata.json` for EAS Update.\n const contents = createMetadataJson({\n bundles,\n fileNames,\n embeddedHashSet,\n domComponentAssetsMetadata,\n });\n files.set('metadata.json', { contents: JSON.stringify(contents) });\n }\n\n // Additional web-only steps...\n\n if (platforms.includes('web') && useServerRendering) {\n const exportServer = exp.web?.output === 'server';\n\n if (exportServer) {\n // TODO: Remove when this is abstracted into the files map\n await copyPublicFolderAsync(publicPath, path.resolve(outputPath, 'client'));\n }\n\n if (skipSSG) {\n Log.log('Skipping static site generation');\n await exportApiRoutesStandaloneAsync(devServer, {\n files,\n platform: 'web',\n apiRoutesOnly: true,\n });\n\n // Output a placeholder index.html if one doesn't exist in the public directory.\n // This ensures native + API routes have some content at the root URL.\n const placeholderIndex = path.resolve(outputPath, 'client/index.html');\n if (!fs.existsSync(placeholderIndex)) {\n files.set('index.html', {\n contents: `<html><body></body></html>`,\n targetDomain: 'client',\n });\n }\n } else if (\n // TODO: Support static export with RSC.\n !devServer.isReactServerComponentsEnabled\n ) {\n await exportFromServerAsync(projectRoot, devServer, {\n mode,\n files,\n clear: !!clear,\n outputDir: outputPath,\n minify,\n baseUrl,\n includeSourceMaps: sourceMaps,\n routerRoot: getRouterDirectoryModuleIdWithManifest(projectRoot, exp),\n reactCompiler: !!exp.experiments?.reactCompiler,\n exportServer,\n maxWorkers,\n isExporting: true,\n exp: projectConfig.exp,\n });\n }\n }\n } finally {\n await devServerManager.stopAsync();\n }\n\n // Write all files at the end for unified logging.\n await persistMetroFilesAsync(files, outputPath);\n}\n"],"names":["exportAppAsync","projectRoot","platforms","outputDir","clear","dev","dumpAssetmap","sourceMaps","minify","bytecode","maxWorkers","skipSSG","exp","environment","process","env","NODE_ENV","setNodeEnv","require","load","projectConfig","getConfig","getPublicExpoManifestAsync","skipValidation","length","includes","WebSupportProjectPrerequisite","assertAsync","useServerRendering","web","output","CommandError","baseUrl","getBaseUrlFromExpoConfig","Log","warn","log","chalk","gray","startsWith","yellow","mode","publicPath","path","resolve","EXPO_PUBLIC_FOLDER","outputPath","files","Map","devServerManager","DevServerManager","startMetroAsync","port","isExporting","location","resetDevServer","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","bundles","domComponentAssetsMetadata","spaPlatforms","isReactServerComponentsEnabled","filter","platform","copyPublicFolderAsync","join","error","templateHtml","Promise","all","map","isHermes","isEnableHermesManaged","assertEngineMismatchAsync","bundle","nativeExportBundleAsync","splitChunks","EXPO_NO_BUNDLE_SPLITTING","mainModuleName","getEntryWithServerRoot","pkg","engine","undefined","serializerIncludeMaps","reactCompiler","experiments","Error","exception","exit","getFilesFromSerialAssets","artifacts","includeSourceMaps","isServerHosted","expoDomComponentReferences","artifact","Array","isArray","metadata","flat","filePath","platformDomComponentsBundle","htmlOutputName","exportDomComponentAsync","useMd5Filename","assets","push","transformNativeBundleForMd5Filename","domComponentReference","nativeBundle","addDomBundleToMetadataAsync","transformDomEntryForMd5Filename","html","serializeHtmlWithAssets","resources","template","createTemplateHtmlFromExpoConfigAsync","scripts","cssLinks","modifyHtml","getVirtualFaviconAssetsAsync","set","contents","targetDomain","isWeb","exportApiRoutesStandaloneAsync","apiRoutesOnly","embeddedHashSet","exportAssetsAsync","JSON","stringify","createAssetMap","fileNames","Object","fromEntries","entries","asset","type","filename","createMetadataJson","exportServer","placeholderIndex","fs","existsSync","exportFromServerAsync","routerRoot","getRouterDirecto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oBACA2C,aAAa;oBACbzC,KAAKQ,cAAcR,GAAG;gBACxB;YACF;QACF;IACF,SAAU;QACR,MAAMqC,iBAAiBmG,SAAS;IAClC;IAEA,kDAAkD;IAClD,MAAMC,IAAAA,kCAAsB,EAACtG,OAAOD;AACtC"}
|
|
@@ -76,6 +76,23 @@ function _interop_require_default(obj) {
|
|
|
76
76
|
default: obj
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
|
+
const PODFILE_HERMES_LHS = /(?::hermes_enabled\s*=>|hermes_enabled\s*:)/;
|
|
80
|
+
const PODFILE_HERMES_PROPS_REFERENCE_RE = new RegExp(String.raw`^\s*${PODFILE_HERMES_LHS.source}\s*podfile_properties\['expo\.jsEngine'\]\s*==\s*nil\s*\|\|\s*podfile_properties\['expo\.jsEngine'\]\s*==\s*'hermes'\s*,?\s*(?:#.*)?$`, 'm');
|
|
81
|
+
const PODFILE_HERMES_TRUE_RE = new RegExp(String.raw`^\s*${PODFILE_HERMES_LHS.source}\s*true\s*(?:,\s*)?(?:[^\n]*)?$`, 'm');
|
|
82
|
+
const PODFILE_HERMES_FALSE_RE = new RegExp(String.raw`^\s*${PODFILE_HERMES_LHS.source}\s*false\s*(?:,\s*)?(?:[^\n]*)?$`, 'm');
|
|
83
|
+
function getLiteralHermesSettingFromPodfile(content) {
|
|
84
|
+
const isPropsReference = content.search(PODFILE_HERMES_PROPS_REFERENCE_RE) >= 0;
|
|
85
|
+
if (isPropsReference) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
if (PODFILE_HERMES_TRUE_RE.test(content)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
if (PODFILE_HERMES_FALSE_RE.test(content)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
79
96
|
async function assertEngineMismatchAsync(projectRoot, exp, platform) {
|
|
80
97
|
const isHermesManaged = isEnableHermesManaged(exp, platform);
|
|
81
98
|
const paths = (0, _config().getConfigFilePaths)(projectRoot);
|
|
@@ -136,13 +153,15 @@ async function maybeInconsistentEngineAndroidAsync(projectRoot, isHermesManaged)
|
|
|
136
153
|
}
|
|
137
154
|
function isHermesPossiblyEnabled(projectRoot) {
|
|
138
155
|
// Trying best to check ios native project if by chance to be consistent between app config
|
|
139
|
-
// Check ios/Podfile for
|
|
156
|
+
// Check ios/Podfile for a literal :hermes_enabled => (true|false) or hermes_enabled: (true|false)
|
|
140
157
|
const podfilePath = _path().default.join(projectRoot, 'ios', 'Podfile');
|
|
141
158
|
if (_fs().default.existsSync(podfilePath)) {
|
|
142
159
|
const content = _fs().default.readFileSync(podfilePath, 'utf8');
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
160
|
+
const literal = getLiteralHermesSettingFromPodfile(content);
|
|
161
|
+
if (literal != null) return literal;
|
|
162
|
+
// If there is no props reference and no literal, assume Hermes is enabled by default
|
|
163
|
+
const hasPropsReference = PODFILE_HERMES_PROPS_REFERENCE_RE.test(content);
|
|
164
|
+
if (!hasPropsReference) {
|
|
146
165
|
return true;
|
|
147
166
|
}
|
|
148
167
|
}
|
|
@@ -160,14 +179,20 @@ function isHermesPossiblyEnabled(projectRoot) {
|
|
|
160
179
|
}
|
|
161
180
|
async function maybeInconsistentEngineIosAsync(projectRoot, isHermesManaged) {
|
|
162
181
|
// Trying best to check ios native project if by chance to be consistent between app config
|
|
163
|
-
// Check ios/Podfile for
|
|
182
|
+
// Check ios/Podfile for a literal :hermes_enabled => (true|false)
|
|
164
183
|
const podfilePath = _path().default.join(projectRoot, 'ios', 'Podfile');
|
|
165
184
|
if (_fs().default.existsSync(podfilePath)) {
|
|
166
185
|
const content = await _fs().default.promises.readFile(podfilePath, 'utf8');
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
186
|
+
const literal = getLiteralHermesSettingFromPodfile(content);
|
|
187
|
+
if (literal != null) {
|
|
188
|
+
if (isHermesManaged !== literal) return true;
|
|
189
|
+
} else {
|
|
190
|
+
// If there is no props reference and no literal, assume Hermes is enabled by default
|
|
191
|
+
const hasPropsReference = PODFILE_HERMES_PROPS_REFERENCE_RE.test(content);
|
|
192
|
+
if (!hasPropsReference) {
|
|
193
|
+
const assumedEnabled = true;
|
|
194
|
+
if (isHermesManaged !== assumedEnabled) return true;
|
|
195
|
+
}
|
|
171
196
|
}
|
|
172
197
|
}
|
|
173
198
|
// Check Podfile.properties.json from prebuild template
|
|
@@ -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';\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 `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 `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","getHermesBytecodeBundleVersionAsync","isAndroidUsingHermes","isEnableHermesManaged","isHermesBytecodeBundleAsync","isHermesPossiblyEnabled","isIosUsingHermes","maybeInconsistentEngineAndroidAsync","maybeInconsistentEngineIosAsync","maybeThrowFromInconsistentEngineAsync","parseGradleProperties","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":";;;;;;;;;;;IAKsBA,yBAAyB;eAAzBA;;IAgLAC,mCAAmC;eAAnCA;;IA0BNC,oBAAoB;eAApBA;;IA1LAC,qBAAqB;eAArBA;;IA2JMC,2BAA2B;eAA3BA;;IAnENC,uBAAuB;eAAvBA;;IA8GAC,gBAAgB;eAAhBA;;IAjIMC,mCAAmC;eAAnCA;;IAkDAC,+BAA+B;eAA/BA;;IAvFAC,qCAAqC;eAArCA;;IAhBNC,qBAAqB;eAArBA;;;;yBArCyC;;;;;;;gEACpC;;;;;;;gEACN;;;;;;;gEACE;;;;;;;;;;;AAEV,eAAeV,0BACpBW,WAAmB,EACnBC,GAAqD,EACrDC,QAAkB;IAElB,MAAMC,kBAAkBX,sBAAsBS,KAAKC;IACnD,MAAME,QAAQC,IAAAA,4BAAkB,EAACL;IACjC,MAAMM,iBAAiBF,MAAMG,iBAAiB,IAAIH,MAAMI,gBAAgB,IAAI;IAC5E,MAAMV,sCACJE,aACAM,gBACAJ,UACAC;AAEJ;AAEO,SAASX,sBACdiB,UAAqE,EACrEP,QAAgB;IAEhB,OAAQA;QACN,KAAK;YAAW;oBACNO;gBAAR,OAAO,AAACA,CAAAA,EAAAA,sBAAAA,WAAWC,OAAO,qBAAlB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;AAEO,eAAetD,oCAAoCuD,IAAY;IACpE,MAAMC,SAAS,MAAMC,sBAAsBF;IAC3C,IAAIC,OAAOE,QAAQ,CAAC,GAAG,GAAGC,QAAQ,CAAC,WAAWL,qBAAqB;QACjE,MAAM,IAAIjB,MAAM;IAClB;IACA,OAAOmB,OAAOI,YAAY,CAAC;AAC7B;AAEA,eAAeH,sBAAsBF,IAAY;IAC/C,MAAMM,KAAK,MAAMrB,aAAE,CAACG,QAAQ,CAACmB,IAAI,CAACP,MAAM;IACxC,MAAMQ,SAASC,OAAOC,KAAK,CAAC;IAC5B,MAAMJ,GAAGT,IAAI,CAACW,QAAQ,GAAG,IAAI;IAC7B,MAAMF,GAAGK,KAAK;IACd,OAAOH;AACT;AAEA,eAAeV,4BACbH,qBAA6B;IAE7B,IAAI;QACF,OAAOiB,KAAKC,KAAK,CAAC,MAAM5B,aAAE,CAACG,QAAQ,CAACC,QAAQ,CAACM,uBAAuB;IACtE,EAAE,OAAM;QACN,OAAO,CAAC;IACV;AACF;AAEO,SAASjD,qBAAqBS,WAAmB;IACtD,iDAAiD;IACjD,MAAM6B,uBAAuBJ,eAAI,CAACG,IAAI,CAAC5B,aAAa,WAAW;IAC/D,IAAI8B,aAAE,CAACC,UAAU,CAACF,uBAAuB;QACvC,MAAMG,QAAQjC,sBAAsB+B,aAAE,CAACO,YAAY,CAACR,sBAAsB;QAC1E,OAAOG,KAAK,CAAC,gBAAgB,KAAK;IACpC;IAEA,oCAAoC;IACpC,OAAO;AACT;AAEO,SAASrC,iBAAiBK,WAAmB;IAClD,0CAA0C;IAC1C,OAAON,wBAAwBM,iBAAiB;AAClD"}
|
|
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\nconst PODFILE_HERMES_LHS = /(?::hermes_enabled\\s*=>|hermes_enabled\\s*:)/;\nconst PODFILE_HERMES_PROPS_REFERENCE_RE = new RegExp(\n String.raw`^\\s*${PODFILE_HERMES_LHS.source}\\s*podfile_properties\\['expo\\.jsEngine'\\]\\s*==\\s*nil\\s*\\|\\|\\s*podfile_properties\\['expo\\.jsEngine'\\]\\s*==\\s*'hermes'\\s*,?\\s*(?:#.*)?$`,\n 'm'\n);\nconst PODFILE_HERMES_TRUE_RE = new RegExp(\n String.raw`^\\s*${PODFILE_HERMES_LHS.source}\\s*true\\s*(?:,\\s*)?(?:[^\\n]*)?$`,\n 'm'\n);\nconst PODFILE_HERMES_FALSE_RE = new RegExp(\n String.raw`^\\s*${PODFILE_HERMES_LHS.source}\\s*false\\s*(?:,\\s*)?(?:[^\\n]*)?$`,\n 'm'\n);\n\nfunction getLiteralHermesSettingFromPodfile(content: string): boolean | null {\n const isPropsReference = content.search(PODFILE_HERMES_PROPS_REFERENCE_RE) >= 0;\n if (isPropsReference) {\n return null;\n }\n if (PODFILE_HERMES_TRUE_RE.test(content)) {\n return true;\n }\n if (PODFILE_HERMES_FALSE_RE.test(content)) {\n return false;\n }\n return null;\n}\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 `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 `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 a literal :hermes_enabled => (true|false) or hermes_enabled: (true|false)\n const podfilePath = path.join(projectRoot, 'ios', 'Podfile');\n if (fs.existsSync(podfilePath)) {\n const content = fs.readFileSync(podfilePath, 'utf8');\n const literal = getLiteralHermesSettingFromPodfile(content);\n if (literal != null) return literal;\n\n // If there is no props reference and no literal, assume Hermes is enabled by default\n const hasPropsReference = PODFILE_HERMES_PROPS_REFERENCE_RE.test(content);\n if (!hasPropsReference) {\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 a literal :hermes_enabled => (true|false)\n const podfilePath = path.join(projectRoot, 'ios', 'Podfile');\n if (fs.existsSync(podfilePath)) {\n const content = await fs.promises.readFile(podfilePath, 'utf8');\n const literal = getLiteralHermesSettingFromPodfile(content);\n if (literal != null) {\n if (isHermesManaged !== literal) return true;\n } else {\n // If there is no props reference and no literal, assume Hermes is enabled by default\n const hasPropsReference = PODFILE_HERMES_PROPS_REFERENCE_RE.test(content);\n if (!hasPropsReference) {\n const assumedEnabled = true;\n if (isHermesManaged !== assumedEnabled) return true;\n }\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","getHermesBytecodeBundleVersionAsync","isAndroidUsingHermes","isEnableHermesManaged","isHermesBytecodeBundleAsync","isHermesPossiblyEnabled","isIosUsingHermes","maybeInconsistentEngineAndroidAsync","maybeInconsistentEngineIosAsync","maybeThrowFromInconsistentEngineAsync","parseGradleProperties","PODFILE_HERMES_LHS","PODFILE_HERMES_PROPS_REFERENCE_RE","RegExp","String","raw","source","PODFILE_HERMES_TRUE_RE","PODFILE_HERMES_FALSE_RE","getLiteralHermesSettingFromPodfile","content","isPropsReference","search","test","projectRoot","exp","platform","isHermesManaged","paths","getConfigFilePaths","configFilePath","dynamicConfigPath","staticConfigPath","expoConfig","android","jsEngine","ios","result","line","split","trim","startsWith","sepIndex","indexOf","key","slice","value","configFileName","path","basename","Error","join","gradlePropertiesPath","fs","existsSync","props","promises","readFile","isHermesBare","podfilePath","readFileSync","literal","hasPropsReference","podfilePropertiesPath","JsonFile","read","assumedEnabled","parsePodfilePropertiesAsync","HERMES_MAGIC_HEADER","file","header","readHermesHeaderAsync","subarray","toString","readUInt32LE","fd","open","buffer","Buffer","alloc","close","JSON","parse"],"mappings":";;;;;;;;;;;IAiCsBA,yBAAyB;eAAzBA;;IAmLAC,mCAAmC;eAAnCA;;IA0BNC,oBAAoB;eAApBA;;IA7LAC,qBAAqB;eAArBA;;IA8JMC,2BAA2B;eAA3BA;;IAtENC,uBAAuB;eAAvBA;;IAiHAC,gBAAgB;eAAhBA;;IApIMC,mCAAmC;eAAnCA;;IAkDAC,+BAA+B;eAA/BA;;IAvFAC,qCAAqC;eAArCA;;IAhBNC,qBAAqB;eAArBA;;;;yBAjEyC;;;;;;;gEACpC;;;;;;;gEACN;;;;;;;gEACE;;;;;;;;;;;AAEjB,MAAMC,qBAAqB;AAC3B,MAAMC,oCAAoC,IAAIC,OAC5CC,OAAOC,GAAG,CAAC,IAAI,EAAEJ,mBAAmBK,MAAM,CAAC,qIAAqI,CAAC,EACj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,CAAC;AAC7B;AAEA,eAAeH,sBAAsBF,IAAY;IAC/C,MAAMM,KAAK,MAAMtB,aAAE,CAACG,QAAQ,CAACoB,IAAI,CAACP,MAAM;IACxC,MAAMQ,SAASC,OAAOC,KAAK,CAAC;IAC5B,MAAMJ,GAAGV,IAAI,CAACY,QAAQ,GAAG,IAAI;IAC7B,MAAMF,GAAGK,KAAK;IACd,OAAOH;AACT;AAEA,eAAeV,4BACbJ,qBAA6B;IAE7B,IAAI;QACF,OAAOkB,KAAKC,KAAK,CAAC,MAAM7B,aAAE,CAACG,QAAQ,CAACC,QAAQ,CAACM,uBAAuB;IACtE,EAAE,OAAM;QACN,OAAO,CAAC;IACV;AACF;AAEO,SAAS7D,qBAAqBsB,WAAmB;IACtD,iDAAiD;IACjD,MAAM4B,uBAAuBJ,eAAI,CAACG,IAAI,CAAC3B,aAAa,WAAW;IAC/D,IAAI6B,aAAE,CAACC,UAAU,CAACF,uBAAuB;QACvC,MAAMG,QAAQ7C,sBAAsB2C,aAAE,CAACO,YAAY,CAACR,sBAAsB;QAC1E,OAAOG,KAAK,CAAC,gBAAgB,KAAK;IACpC;IAEA,oCAAoC;IACpC,OAAO;AACT;AAEO,SAASjD,iBAAiBkB,WAAmB;IAClD,0CAA0C;IAC1C,OAAOnB,wBAAwBmB,iBAAiB;AAClD"}
|
|
@@ -123,6 +123,7 @@ async function runIosAsync(projectRoot, options) {
|
|
|
123
123
|
// Resolve the CLI arguments into useable options.
|
|
124
124
|
const props = await (0, _profile.profile)(_resolveOptions.resolveOptionsAsync)(projectRoot, options);
|
|
125
125
|
const projectConfig = (0, _config().getConfig)(projectRoot);
|
|
126
|
+
// We only support build cache for simulator builds for now.
|
|
126
127
|
if (!options.binary && props.buildCacheProvider && props.isSimulator) {
|
|
127
128
|
const localPath = await (0, _buildcacheproviders.resolveBuildCache)({
|
|
128
129
|
projectRoot,
|
|
@@ -197,7 +198,8 @@ async function runIosAsync(projectRoot, options) {
|
|
|
197
198
|
// Find the path to the built app binary, this will be used to install the binary
|
|
198
199
|
// on a device.
|
|
199
200
|
binaryPath = await (0, _profile.profile)(_XcodeBuild.getAppBinaryPath)(buildOutput);
|
|
200
|
-
|
|
201
|
+
// We only support build cache for simulator builds for now.
|
|
202
|
+
shouldUpdateBuildCache = props.isSimulator;
|
|
201
203
|
}
|
|
202
204
|
debug('Binary path:', binaryPath);
|
|
203
205
|
// Ensure the port hasn't become busy during the build.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/run/ios/runIosAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as XcodeBuild from './XcodeBuild';\nimport { Options } from './XcodeBuild.types';\nimport { getLaunchInfoForBinaryAsync, launchAppAsync } from './launchApp';\nimport { resolveOptionsAsync } from './options/resolveOptions';\nimport { getValidBinaryPathAsync } from './validateExternalBinary';\nimport { exportEagerAsync } from '../../export/embed/exportEager';\nimport * as Log from '../../log';\nimport { AppleAppIdResolver } from '../../start/platforms/ios/AppleAppIdResolver';\nimport { getContainerPathAsync, simctlAsync } from '../../start/platforms/ios/simctl';\nimport { resolveBuildCache, uploadBuildCache } from '../../utils/build-cache-providers';\nimport { maybePromptToSyncPodsAsync } from '../../utils/cocoapods';\nimport { CommandError } from '../../utils/errors';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { ensurePortAvailabilityAsync } from '../../utils/port';\nimport { profile } from '../../utils/profile';\nimport { getSchemesForIosAsync } from '../../utils/scheme';\nimport { ensureNativeProjectAsync } from '../ensureNativeProject';\nimport { logProjectLogsLocation } from '../hints';\nimport { startBundlerAsync } from '../startBundler';\n\nconst debug = require('debug')('expo:run:ios');\n\nexport async function runIosAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.configuration === 'Release' ? 'production' : 'development');\n require('@expo/env').load(projectRoot);\n\n assertPlatform();\n\n const install = !!options.install;\n\n if ((await ensureNativeProjectAsync(projectRoot, { platform: 'ios', install })) && install) {\n await maybePromptToSyncPodsAsync(projectRoot);\n }\n\n // Resolve the CLI arguments into useable options.\n const props = await profile(resolveOptionsAsync)(projectRoot, options);\n\n const projectConfig = getConfig(projectRoot);\n if (!options.binary && props.buildCacheProvider && props.isSimulator) {\n const localPath = await resolveBuildCache({\n projectRoot,\n platform: 'ios',\n runOptions: options,\n provider: props.buildCacheProvider,\n });\n if (localPath) {\n options.binary = localPath;\n }\n }\n\n if (options.rebundle) {\n Log.warn(`The --unstable-rebundle flag is experimental and may not work as expected.`);\n // Get the existing binary path to re-bundle the app.\n\n let binaryPath: string;\n if (!options.binary) {\n if (!props.isSimulator) {\n throw new Error('Re-bundling on physical devices requires the --binary flag.');\n }\n const appId = await new AppleAppIdResolver(projectRoot).getAppIdAsync();\n const possibleBinaryPath = await getContainerPathAsync(props.device, {\n appId,\n });\n if (!possibleBinaryPath) {\n throw new CommandError(\n `Cannot rebundle because no --binary was provided and no existing binary was found on the device for ID: ${appId}.`\n );\n }\n binaryPath = possibleBinaryPath;\n Log.log('Re-using existing binary path:', binaryPath);\n // Set the binary path to the existing binary path.\n options.binary = binaryPath;\n }\n\n Log.log('Rebundling the Expo config file');\n // Re-bundle the config file the same way the app was originally bundled.\n await spawnAsync('node', [\n path.join(require.resolve('expo-constants/package.json'), '../scripts/getAppConfig.js'),\n projectRoot,\n path.join(options.binary, 'EXConstants.bundle'),\n ]);\n // Re-bundle the app.\n\n const possibleBundleOutput = path.join(options.binary, 'main.jsbundle');\n\n if (fs.existsSync(possibleBundleOutput)) {\n Log.log('Rebundling the app...');\n await exportEagerAsync(projectRoot, {\n resetCache: false,\n dev: false,\n platform: 'ios',\n assetsDest: path.join(options.binary, 'assets'),\n bundleOutput: possibleBundleOutput,\n });\n } else {\n Log.warn('Bundle output not found at expected location:', possibleBundleOutput);\n }\n }\n\n let binaryPath: string;\n let shouldUpdateBuildCache = false;\n if (options.binary) {\n binaryPath = await getValidBinaryPathAsync(options.binary, props);\n Log.log('Using custom binary path:', binaryPath);\n } else {\n let eagerBundleOptions: string | undefined;\n\n if (options.configuration === 'Release') {\n eagerBundleOptions = JSON.stringify(\n await exportEagerAsync(projectRoot, {\n dev: false,\n platform: 'ios',\n })\n );\n }\n\n // Spawn the `xcodebuild` process to create the app binary.\n const buildOutput = await XcodeBuild.buildAsync({\n ...props,\n eagerBundleOptions,\n });\n\n // Find the path to the built app binary, this will be used to install the binary\n // on a device.\n binaryPath = await profile(XcodeBuild.getAppBinaryPath)(buildOutput);\n shouldUpdateBuildCache = true;\n }\n debug('Binary path:', binaryPath);\n\n // Ensure the port hasn't become busy during the build.\n if (props.shouldStartBundler && !(await ensurePortAvailabilityAsync(projectRoot, props))) {\n props.shouldStartBundler = false;\n }\n\n const launchInfo = await getLaunchInfoForBinaryAsync(binaryPath);\n const isCustomBinary = !!options.binary;\n\n // Always close the app before launching on a simulator. Otherwise certain cached resources like the splashscreen will not be available.\n if (props.isSimulator) {\n try {\n await simctlAsync(['terminate', props.device.udid, launchInfo.bundleId]);\n } catch (error) {\n // If we failed it's likely that the app was not running to begin with and we will get an `invalid device` error\n debug('Failed to terminate app (possibly because it was not running):', error);\n }\n }\n\n // Start the dev server which creates all of the required info for\n // launching the app on a simulator.\n const manager = await startBundlerAsync(projectRoot, {\n port: props.port,\n headless: !props.shouldStartBundler,\n // If a scheme is specified then use that instead of the package name.\n\n scheme: isCustomBinary\n ? // If launching a custom binary, use the schemes in the Info.plist.\n launchInfo.schemes[0]\n : // If a scheme is specified then use that instead of the package name.\n (await getSchemesForIosAsync(projectRoot))?.[0],\n });\n\n // Install and launch the app binary on a device.\n await launchAppAsync(\n binaryPath,\n manager,\n {\n isSimulator: props.isSimulator,\n device: props.device,\n shouldStartBundler: props.shouldStartBundler,\n },\n launchInfo.bundleId\n );\n\n // Log the location of the JS logs for the device.\n if (props.shouldStartBundler) {\n logProjectLogsLocation();\n } else {\n await manager.stopAsync();\n }\n\n if (shouldUpdateBuildCache && props.buildCacheProvider) {\n await uploadBuildCache({\n projectRoot,\n platform: 'ios',\n provider: props.buildCacheProvider,\n buildPath: binaryPath,\n runOptions: options,\n });\n }\n}\n\nfunction assertPlatform() {\n if (process.platform !== 'darwin') {\n Log.exit(\n chalk`iOS apps can only be built on macOS devices. Use {cyan eas build -p ios} to build in the cloud.`\n );\n }\n}\n"],"names":["runIosAsync","debug","require","projectRoot","options","setNodeEnv","configuration","load","assertPlatform","install","ensureNativeProjectAsync","platform","maybePromptToSyncPodsAsync","props","profile","resolveOptionsAsync","projectConfig","getConfig","binary","buildCacheProvider","isSimulator","localPath","resolveBuildCache","runOptions","provider","rebundle","Log","warn","binaryPath","Error","appId","AppleAppIdResolver","getAppIdAsync","possibleBinaryPath","getContainerPathAsync","device","CommandError","log","spawnAsync","path","join","resolve","possibleBundleOutput","fs","existsSync","exportEagerAsync","resetCache","dev","assetsDest","bundleOutput","shouldUpdateBuildCache","getValidBinaryPathAsync","eagerBundleOptions","JSON","stringify","buildOutput","XcodeBuild","buildAsync","getAppBinaryPath","shouldStartBundler","ensurePortAvailabilityAsync","launchInfo","getLaunchInfoForBinaryAsync","isCustomBinary","simctlAsync","udid","bundleId","error","manager","startBundlerAsync","port","headless","scheme","schemes","getSchemesForIosAsync","launchAppAsync","logProjectLogsLocation","stopAsync","uploadBuildCache","buildPath","process","exit","chalk"],"mappings":";;;;+BA4BsBA;;;eAAAA;;;;yBA5BI;;;;;;;gEACH;;;;;;;gEACL;;;;;;;gEACH;;;;;;;gEACE;;;;;;oEAEW;2BAEgC;gCACxB;wCACI;6BACP;6DACZ;oCACc;wBACgB;qCACC;2BACT;wBACd;yBACF;sBACiB;yBACpB;wBACc;qCACG;uBACF;8BACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,MAAMC,QAAQC,QAAQ,SAAS;AAExB,eAAeF,YAAYG,WAAmB,EAAEC,OAAgB;QAwI9D;IAvIPC,IAAAA,mBAAU,EA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P,IAAIwE,QAAQrE,QAAQ,KAAK,UAAU;QACjCe,KAAIuD,IAAI,CACNC,IAAAA,gBAAK,CAAA,CAAC,+FAA+F,CAAC;IAE1G;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/run/ios/runIosAsync.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport * as XcodeBuild from './XcodeBuild';\nimport { Options } from './XcodeBuild.types';\nimport { getLaunchInfoForBinaryAsync, launchAppAsync } from './launchApp';\nimport { resolveOptionsAsync } from './options/resolveOptions';\nimport { getValidBinaryPathAsync } from './validateExternalBinary';\nimport { exportEagerAsync } from '../../export/embed/exportEager';\nimport * as Log from '../../log';\nimport { AppleAppIdResolver } from '../../start/platforms/ios/AppleAppIdResolver';\nimport { getContainerPathAsync, simctlAsync } from '../../start/platforms/ios/simctl';\nimport { resolveBuildCache, uploadBuildCache } from '../../utils/build-cache-providers';\nimport { maybePromptToSyncPodsAsync } from '../../utils/cocoapods';\nimport { CommandError } from '../../utils/errors';\nimport { setNodeEnv } from '../../utils/nodeEnv';\nimport { ensurePortAvailabilityAsync } from '../../utils/port';\nimport { profile } from '../../utils/profile';\nimport { getSchemesForIosAsync } from '../../utils/scheme';\nimport { ensureNativeProjectAsync } from '../ensureNativeProject';\nimport { logProjectLogsLocation } from '../hints';\nimport { startBundlerAsync } from '../startBundler';\n\nconst debug = require('debug')('expo:run:ios');\n\nexport async function runIosAsync(projectRoot: string, options: Options) {\n setNodeEnv(options.configuration === 'Release' ? 'production' : 'development');\n require('@expo/env').load(projectRoot);\n\n assertPlatform();\n\n const install = !!options.install;\n\n if ((await ensureNativeProjectAsync(projectRoot, { platform: 'ios', install })) && install) {\n await maybePromptToSyncPodsAsync(projectRoot);\n }\n\n // Resolve the CLI arguments into useable options.\n const props = await profile(resolveOptionsAsync)(projectRoot, options);\n\n const projectConfig = getConfig(projectRoot);\n // We only support build cache for simulator builds for now.\n if (!options.binary && props.buildCacheProvider && props.isSimulator) {\n const localPath = await resolveBuildCache({\n projectRoot,\n platform: 'ios',\n runOptions: options,\n provider: props.buildCacheProvider,\n });\n if (localPath) {\n options.binary = localPath;\n }\n }\n\n if (options.rebundle) {\n Log.warn(`The --unstable-rebundle flag is experimental and may not work as expected.`);\n // Get the existing binary path to re-bundle the app.\n\n let binaryPath: string;\n if (!options.binary) {\n if (!props.isSimulator) {\n throw new Error('Re-bundling on physical devices requires the --binary flag.');\n }\n const appId = await new AppleAppIdResolver(projectRoot).getAppIdAsync();\n const possibleBinaryPath = await getContainerPathAsync(props.device, {\n appId,\n });\n if (!possibleBinaryPath) {\n throw new CommandError(\n `Cannot rebundle because no --binary was provided and no existing binary was found on the device for ID: ${appId}.`\n );\n }\n binaryPath = possibleBinaryPath;\n Log.log('Re-using existing binary path:', binaryPath);\n // Set the binary path to the existing binary path.\n options.binary = binaryPath;\n }\n\n Log.log('Rebundling the Expo config file');\n // Re-bundle the config file the same way the app was originally bundled.\n await spawnAsync('node', [\n path.join(require.resolve('expo-constants/package.json'), '../scripts/getAppConfig.js'),\n projectRoot,\n path.join(options.binary, 'EXConstants.bundle'),\n ]);\n // Re-bundle the app.\n\n const possibleBundleOutput = path.join(options.binary, 'main.jsbundle');\n\n if (fs.existsSync(possibleBundleOutput)) {\n Log.log('Rebundling the app...');\n await exportEagerAsync(projectRoot, {\n resetCache: false,\n dev: false,\n platform: 'ios',\n assetsDest: path.join(options.binary, 'assets'),\n bundleOutput: possibleBundleOutput,\n });\n } else {\n Log.warn('Bundle output not found at expected location:', possibleBundleOutput);\n }\n }\n\n let binaryPath: string;\n let shouldUpdateBuildCache = false;\n if (options.binary) {\n binaryPath = await getValidBinaryPathAsync(options.binary, props);\n Log.log('Using custom binary path:', binaryPath);\n } else {\n let eagerBundleOptions: string | undefined;\n\n if (options.configuration === 'Release') {\n eagerBundleOptions = JSON.stringify(\n await exportEagerAsync(projectRoot, {\n dev: false,\n platform: 'ios',\n })\n );\n }\n\n // Spawn the `xcodebuild` process to create the app binary.\n const buildOutput = await XcodeBuild.buildAsync({\n ...props,\n eagerBundleOptions,\n });\n\n // Find the path to the built app binary, this will be used to install the binary\n // on a device.\n binaryPath = await profile(XcodeBuild.getAppBinaryPath)(buildOutput);\n // We only support build cache for simulator builds for now.\n shouldUpdateBuildCache = props.isSimulator;\n }\n debug('Binary path:', binaryPath);\n\n // Ensure the port hasn't become busy during the build.\n if (props.shouldStartBundler && !(await ensurePortAvailabilityAsync(projectRoot, props))) {\n props.shouldStartBundler = false;\n }\n\n const launchInfo = await getLaunchInfoForBinaryAsync(binaryPath);\n const isCustomBinary = !!options.binary;\n\n // Always close the app before launching on a simulator. Otherwise certain cached resources like the splashscreen will not be available.\n if (props.isSimulator) {\n try {\n await simctlAsync(['terminate', props.device.udid, launchInfo.bundleId]);\n } catch (error) {\n // If we failed it's likely that the app was not running to begin with and we will get an `invalid device` error\n debug('Failed to terminate app (possibly because it was not running):', error);\n }\n }\n\n // Start the dev server which creates all of the required info for\n // launching the app on a simulator.\n const manager = await startBundlerAsync(projectRoot, {\n port: props.port,\n headless: !props.shouldStartBundler,\n // If a scheme is specified then use that instead of the package name.\n\n scheme: isCustomBinary\n ? // If launching a custom binary, use the schemes in the Info.plist.\n launchInfo.schemes[0]\n : // If a scheme is specified then use that instead of the package name.\n (await getSchemesForIosAsync(projectRoot))?.[0],\n });\n\n // Install and launch the app binary on a device.\n await launchAppAsync(\n binaryPath,\n manager,\n {\n isSimulator: props.isSimulator,\n device: props.device,\n shouldStartBundler: props.shouldStartBundler,\n },\n launchInfo.bundleId\n );\n\n // Log the location of the JS logs for the device.\n if (props.shouldStartBundler) {\n logProjectLogsLocation();\n } else {\n await manager.stopAsync();\n }\n\n if (shouldUpdateBuildCache && props.buildCacheProvider) {\n await uploadBuildCache({\n projectRoot,\n platform: 'ios',\n provider: props.buildCacheProvider,\n buildPath: binaryPath,\n runOptions: options,\n });\n }\n}\n\nfunction assertPlatform() {\n if (process.platform !== 'darwin') {\n Log.exit(\n chalk`iOS apps can only be built on macOS devices. Use {cyan eas build -p ios} to build in the cloud.`\n );\n }\n}\n"],"names":["runIosAsync","debug","require","projectRoot","options","setNodeEnv","configuration","load","assertPlatform","install","ensureNativeProjectAsync","platform","maybePromptToSyncPodsAsync","props","profile","resolveOptionsAsync","projectConfig","getConfig","binary","buildCacheProvider","isSimulator","localPath","resolveBuildCache","runOptions","provider","rebundle","Log","warn","binaryPath","Error","appId","AppleAppIdResolver","getAppIdAsync","possibleBinaryPath","getContainerPathAsync","device","CommandError","log","spawnAsync","path","join","resolve","possibleBundleOutput","fs","existsSync","exportEagerAsync","resetCache","dev","assetsDest","bundleOutput","shouldUpdateBuildCache","getValidBinaryPathAsync","eagerBundleOptions","JSON","stringify","buildOutput","XcodeBuild","buildAsync","getAppBinaryPath","shouldStartBundler","ensurePortAvailabilityAsync","launchInfo","getLaunchInfoForBinaryAsync","isCustomBinary","simctlAsync","udid","bundleId","error","manager","startBundlerAsync","port","headless","scheme","schemes","getSchemesForIosAsync","launchAppAsync","logProjectLogsLocation","stopAsync","uploadBuildCache","buildPath","process","exit","chalk"],"mappings":";;;;+BA4BsBA;;;eAAAA;;;;yBA5BI;;;;;;;gEACH;;;;;;;gEACL;;;;;;;gEACH;;;;;;;gEACE;;;;;;oEAEW;2BAEgC;gCACxB;wCACI;6BACP;6DACZ;oCACc;wBACgB;qCACC;2BACT;wBACd;yBACF;sBACiB;yBACpB;wBACc;qCACG;uBACF;8BACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElC,MAAMC,QAAQC,QAAQ,SAAS;AAExB,eAAeF,YAAYG,WAAmB,EAAEC,OAAgB;QA0I9D;IAzIPC,IAAAA,mBAAU,EAACD,QAAQE,aAAa,KAAK,YAAY,eAAe;IAChEJ,QAAQ,aAAaK,IAAI,CAACJ;IAE1BK;IAEA,MAAMC,UAAU,CAAC,CAACL,QAAQK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AA,gBAAK,CAAA,CAAC,+FAA+F,CAAC;IAE1G;AACF"}
|
|
@@ -33,7 +33,7 @@ class FetchClient {
|
|
|
33
33
|
this.headers = {
|
|
34
34
|
accept: 'application/json',
|
|
35
35
|
'content-type': 'application/json',
|
|
36
|
-
'user-agent': `expo-cli/${"0.24.
|
|
36
|
+
'user-agent': `expo-cli/${"0.24.22"}`,
|
|
37
37
|
authorization: 'Basic ' + _nodebuffer().Buffer.from(`${target}:`).toString('base64')
|
|
38
38
|
};
|
|
39
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/cli",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.22",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "build/bin/cli",
|
|
6
6
|
"bin": {
|
|
@@ -52,11 +52,12 @@
|
|
|
52
52
|
"@expo/osascript": "^2.2.5",
|
|
53
53
|
"@expo/package-manager": "^1.8.6",
|
|
54
54
|
"@expo/plist": "^0.3.5",
|
|
55
|
-
"@expo/prebuild-config": "^9.0.
|
|
55
|
+
"@expo/prebuild-config": "^9.0.12",
|
|
56
|
+
"@expo/schema-utils": "^0.1.0",
|
|
56
57
|
"@expo/spawn-async": "^1.7.2",
|
|
57
58
|
"@expo/ws-tunnel": "^1.0.1",
|
|
58
59
|
"@expo/xcpretty": "^4.3.0",
|
|
59
|
-
"@react-native/dev-middleware": "0.79.
|
|
60
|
+
"@react-native/dev-middleware": "0.79.6",
|
|
60
61
|
"@urql/core": "^5.0.6",
|
|
61
62
|
"@urql/exchange-retry": "^1.3.0",
|
|
62
63
|
"accepts": "^1.3.8",
|
|
@@ -139,7 +140,7 @@
|
|
|
139
140
|
"@types/ws": "^8.5.4",
|
|
140
141
|
"devtools-protocol": "^0.0.1113120",
|
|
141
142
|
"expo-atlas": "^0.4.1",
|
|
142
|
-
"expo-module-scripts": "^4.1.
|
|
143
|
+
"expo-module-scripts": "^4.1.10",
|
|
143
144
|
"find-process": "^1.4.7",
|
|
144
145
|
"jest-runner-tsd": "^6.0.0",
|
|
145
146
|
"klaw-sync": "^6.0.0",
|
|
@@ -152,5 +153,5 @@
|
|
|
152
153
|
"tree-kill": "^1.2.2",
|
|
153
154
|
"tsd": "^0.28.1"
|
|
154
155
|
},
|
|
155
|
-
"gitHead": "
|
|
156
|
+
"gitHead": "05061c8953e61b3eb0be9344c69683c190a04213"
|
|
156
157
|
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "jsonSchemaDeref", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return jsonSchemaDeref;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
/** Return JSON schema ref if input is of `NodeRef` type */ const getRef = (node)=>node != null && typeof node === 'object' && '$ref' in node && typeof node.$ref === 'string' ? node.$ref : undefined;
|
|
12
|
-
/** Parse a JSON schema ref into a path array, or return undefined */ const parseRefMaybe = (ref)=>{
|
|
13
|
-
if (ref[0] !== '#') {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
const props = [];
|
|
17
|
-
let startIndex = 1;
|
|
18
|
-
let index = 1;
|
|
19
|
-
let char;
|
|
20
|
-
while(index < ref.length){
|
|
21
|
-
while((char = ref.charCodeAt(index++)) && char !== 47 /*'/'*/ );
|
|
22
|
-
const prop = ref.slice(startIndex, index - 1);
|
|
23
|
-
startIndex = index;
|
|
24
|
-
if (prop) props.push(prop);
|
|
25
|
-
}
|
|
26
|
-
return props.length ? props : undefined;
|
|
27
|
-
};
|
|
28
|
-
const NOT_FOUND_SYMBOL = Symbol();
|
|
29
|
-
/** Get value at given JSON schema path or return `NOT_FOUND_SYMBOL` */ const getValueAtPath = (input, ref)=>{
|
|
30
|
-
let node = input;
|
|
31
|
-
for(let index = 0; index < ref.length; index++){
|
|
32
|
-
const part = ref[index];
|
|
33
|
-
if (node != null && typeof node === 'object' && part in node) {
|
|
34
|
-
node = node[part];
|
|
35
|
-
} else {
|
|
36
|
-
node = NOT_FOUND_SYMBOL;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return node;
|
|
41
|
-
};
|
|
42
|
-
/** Find all JSON schema refs recursively and add them to `refs` Map */ const findRefsRec = (node, refs, path)=>{
|
|
43
|
-
if (node == null || typeof node !== 'object') {} else if (Array.isArray(node)) {
|
|
44
|
-
for(let index = 0, l = node.length; index < l; index++){
|
|
45
|
-
const value = node[index];
|
|
46
|
-
const ref = getRef(value);
|
|
47
|
-
if (ref) {
|
|
48
|
-
const targetRef = parseRefMaybe(ref);
|
|
49
|
-
if (targetRef) refs.set([
|
|
50
|
-
...path,
|
|
51
|
-
index
|
|
52
|
-
], targetRef);
|
|
53
|
-
} else if (value != null && typeof value === 'object') {
|
|
54
|
-
path.push(index);
|
|
55
|
-
findRefsRec(value, refs, path);
|
|
56
|
-
path.pop();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
const record = node;
|
|
61
|
-
for(const key in record){
|
|
62
|
-
const value = record[key];
|
|
63
|
-
const ref = getRef(value);
|
|
64
|
-
if (ref) {
|
|
65
|
-
const targetRef = parseRefMaybe(ref);
|
|
66
|
-
if (targetRef) refs.set([
|
|
67
|
-
...path,
|
|
68
|
-
key
|
|
69
|
-
], targetRef);
|
|
70
|
-
} else if (value != null && typeof value === 'object') {
|
|
71
|
-
path.push(key);
|
|
72
|
-
findRefsRec(value, refs, path);
|
|
73
|
-
path.pop();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
/** Detect whether target (where we set the source value) is a nested path inside the source path */ const isSelfReferencingRefEntry = (target, source)=>{
|
|
79
|
-
for(let index = 0; index < source.length; index++){
|
|
80
|
-
if (source[index] !== target[index]) return false;
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
};
|
|
84
|
-
/** Return sorted refs entries. Longest target paths will be returned first */ const getSortedRefEntries = (refs)=>{
|
|
85
|
-
const entries = [
|
|
86
|
-
...refs.entries()
|
|
87
|
-
].sort((a, b)=>b[1].length - a[1].length);
|
|
88
|
-
// Filter out self-referenceing paths. If we set nested targets to source values, we'd
|
|
89
|
-
// create unserializable circular references
|
|
90
|
-
return entries.filter((entry)=>!isSelfReferencingRefEntry(entry[0], entry[1]));
|
|
91
|
-
};
|
|
92
|
-
function jsonSchemaDeref(input) {
|
|
93
|
-
// Find all JSON schema refs paths
|
|
94
|
-
const refs = new Map();
|
|
95
|
-
findRefsRec(input, refs, []);
|
|
96
|
-
// Shallow copy output
|
|
97
|
-
const output = {
|
|
98
|
-
...input
|
|
99
|
-
};
|
|
100
|
-
// Process all ref entries with deepest targets first
|
|
101
|
-
nextRef: for (const [target, source] of getSortedRefEntries(refs)){
|
|
102
|
-
let inputNode = input;
|
|
103
|
-
let outputNode = output;
|
|
104
|
-
let targetIndex = 0;
|
|
105
|
-
// For each path part on the target, traverse the output and clone the input
|
|
106
|
-
// to not pollute it
|
|
107
|
-
for(; targetIndex < target.length - 1; targetIndex++){
|
|
108
|
-
const part = target[targetIndex];
|
|
109
|
-
if (inputNode == null || typeof inputNode !== 'object' || !(part in inputNode)) {
|
|
110
|
-
break;
|
|
111
|
-
} else if (outputNode[part] === inputNode[part]) {
|
|
112
|
-
// Copy the input on the output if references are equal
|
|
113
|
-
outputNode[part] = Array.isArray(inputNode[part]) ? [
|
|
114
|
-
...inputNode[part]
|
|
115
|
-
] : {
|
|
116
|
-
...inputNode[part]
|
|
117
|
-
};
|
|
118
|
-
inputNode = inputNode[part];
|
|
119
|
-
outputNode = outputNode[part];
|
|
120
|
-
} else {
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// For each remaining part on the target, continue traversing the output
|
|
125
|
-
for(; targetIndex < target.length - 1; targetIndex++){
|
|
126
|
-
const part = target[targetIndex];
|
|
127
|
-
if (outputNode == null || typeof outputNode !== 'object' || !(part in outputNode)) {
|
|
128
|
-
continue nextRef;
|
|
129
|
-
} else {
|
|
130
|
-
outputNode = outputNode[part];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// Get value from output
|
|
134
|
-
let sourceValue = getValueAtPath(output, source);
|
|
135
|
-
if (sourceValue === NOT_FOUND_SYMBOL) {
|
|
136
|
-
// If no value was found, try to get a value from the input instead
|
|
137
|
-
sourceValue = getValueAtPath(input, source);
|
|
138
|
-
// Otherwise, skip this ref
|
|
139
|
-
if (sourceValue === NOT_FOUND_SYMBOL) continue;
|
|
140
|
-
}
|
|
141
|
-
// Set the source value on the target path
|
|
142
|
-
// The for-loops prior have made sure that the output has already been deeply
|
|
143
|
-
// cloned and traversed for the entire path
|
|
144
|
-
outputNode[target[target.length - 1]] = sourceValue;
|
|
145
|
-
}
|
|
146
|
-
// Return the output with resolved refs
|
|
147
|
-
return output;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
//# sourceMappingURL=jsonSchemaDeref.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/jsonSchemaDeref.ts"],"sourcesContent":["type RefPath = readonly (string | number)[];\n\ninterface NodeRef {\n $ref: string;\n}\n\n/** Return JSON schema ref if input is of `NodeRef` type */\nconst getRef = (node: NodeRef | unknown): string | undefined =>\n node != null && typeof node === 'object' && '$ref' in node && typeof node.$ref === 'string'\n ? node.$ref\n : undefined;\n\n/** Parse a JSON schema ref into a path array, or return undefined */\nconst parseRefMaybe = (ref: string): RefPath | undefined => {\n if (ref[0] !== '#') {\n return undefined;\n }\n const props = [];\n let startIndex = 1;\n let index = 1;\n let char: number;\n while (index < ref.length) {\n while ((char = ref.charCodeAt(index++)) && char !== 47 /*'/'*/);\n const prop = ref.slice(startIndex, index - 1);\n startIndex = index;\n if (prop) props.push(prop);\n }\n return props.length ? props : undefined;\n};\n\nconst NOT_FOUND_SYMBOL = Symbol();\n\n/** Get value at given JSON schema path or return `NOT_FOUND_SYMBOL` */\nconst getValueAtPath = (input: unknown, ref: RefPath): unknown | typeof NOT_FOUND_SYMBOL => {\n let node = input;\n for (let index = 0; index < ref.length; index++) {\n const part = ref[index];\n if (node != null && typeof node === 'object' && part in node) {\n node = (node as Record<string, unknown>)[part];\n } else {\n node = NOT_FOUND_SYMBOL;\n break;\n }\n }\n return node;\n};\n\n/** Find all JSON schema refs recursively and add them to `refs` Map */\nconst findRefsRec = (\n node: unknown,\n refs: Map<RefPath, RefPath>,\n path: (string | number)[]\n): void => {\n if (node == null || typeof node !== 'object') {\n } else if (Array.isArray(node)) {\n for (let index = 0, l = node.length; index < l; index++) {\n const value = node[index];\n const ref = getRef(value);\n if (ref) {\n const targetRef = parseRefMaybe(ref);\n if (targetRef) refs.set([...path, index], targetRef);\n } else if (value != null && typeof value === 'object') {\n path.push(index);\n findRefsRec(value, refs, path);\n path.pop();\n }\n }\n } else {\n const record = node as Record<string, unknown>;\n for (const key in record) {\n const value = record[key];\n const ref = getRef(value);\n if (ref) {\n const targetRef = parseRefMaybe(ref);\n if (targetRef) refs.set([...path, key], targetRef);\n } else if (value != null && typeof value === 'object') {\n path.push(key);\n findRefsRec(value, refs, path);\n path.pop();\n }\n }\n }\n};\n\n/** Detect whether target (where we set the source value) is a nested path inside the source path */\nconst isSelfReferencingRefEntry = (target: RefPath, source: RefPath) => {\n for (let index = 0; index < source.length; index++) {\n if (source[index] !== target[index]) return false;\n }\n return true;\n};\n\n/** Return sorted refs entries. Longest target paths will be returned first */\nconst getSortedRefEntries = (refs: Map<RefPath, RefPath>): readonly [RefPath, RefPath][] => {\n const entries = [...refs.entries()].sort((a, b) => b[1].length - a[1].length);\n // Filter out self-referenceing paths. If we set nested targets to source values, we'd\n // create unserializable circular references\n return entries.filter((entry) => !isSelfReferencingRefEntry(entry[0], entry[1]));\n};\n\n/** Dereference JSON schema pointers.\n *\n * @remarks\n * This is a minimal reimplementation of `json-schema-deref-sync` without\n * file reference, URL/web reference, and loader support.\n *\n * @see https://github.com/cvent/json-schema-deref-sync\n */\nexport function jsonSchemaDeref(input: any): any {\n // Find all JSON schema refs paths\n const refs = new Map<RefPath, RefPath>();\n findRefsRec(input, refs, []);\n // Shallow copy output\n const output = { ...input };\n // Process all ref entries with deepest targets first\n nextRef: for (const [target, source] of getSortedRefEntries(refs)) {\n let inputNode = input;\n let outputNode = output;\n let targetIndex = 0;\n // For each path part on the target, traverse the output and clone the input\n // to not pollute it\n for (; targetIndex < target.length - 1; targetIndex++) {\n const part = target[targetIndex];\n if (inputNode == null || typeof inputNode !== 'object' || !(part in inputNode)) {\n // If the part doesn't exist, we abort\n break;\n } else if (outputNode[part] === inputNode[part]) {\n // Copy the input on the output if references are equal\n outputNode[part] = Array.isArray(inputNode[part])\n ? [...inputNode[part]]\n : { ...inputNode[part] };\n inputNode = inputNode[part];\n outputNode = outputNode[part];\n } else {\n // If this part has already been copied, abort\n break;\n }\n }\n // For each remaining part on the target, continue traversing the output\n for (; targetIndex < target.length - 1; targetIndex++) {\n const part = target[targetIndex];\n if (outputNode == null || typeof outputNode !== 'object' || !(part in outputNode)) {\n // If the part doesn't exist, skip the entire ref\n continue nextRef;\n } else {\n outputNode = outputNode[part];\n }\n }\n // Get value from output\n let sourceValue = getValueAtPath(output, source);\n if (sourceValue === NOT_FOUND_SYMBOL) {\n // If no value was found, try to get a value from the input instead\n sourceValue = getValueAtPath(input, source);\n // Otherwise, skip this ref\n if (sourceValue === NOT_FOUND_SYMBOL) continue;\n }\n // Set the source value on the target path\n // The for-loops prior have made sure that the output has already been deeply\n // cloned and traversed for the entire path\n outputNode[target[target.length - 1]] = sourceValue;\n }\n // Return the output with resolved refs\n return output;\n}\n"],"names":["jsonSchemaDeref","getRef","node","$ref","undefined","parseRefMaybe","ref","props","startIndex","index","char","length","charCodeAt","prop","slice","push","NOT_FOUND_SYMBOL","Symbol","getValueAtPath","input","part","findRefsRec","refs","path","Array","isArray","l","value","targetRef","set","pop","record","key","isSelfReferencingRefEntry","target","source","getSortedRefEntries","entries","sort","a","b","filter","entry","Map","output","nextRef","inputNode","outputNode","targetIndex","sourceValue"],"mappings":";;;;+BA4GgBA;;;eAAAA;;;AAtGhB,yDAAyD,GACzD,MAAMC,SAAS,CAACC,OACdA,QAAQ,QAAQ,OAAOA,SAAS,YAAY,UAAUA,QAAQ,OAAOA,KAAKC,IAAI,KAAK,WAC/ED,KAAKC,IAAI,GACTC;AAEN,mEAAmE,GACnE,MAAMC,gBAAgB,CAACC;IACrB,IAAIA,GAAG,CAAC,EAAE,KAAK,KAAK;QAClB,OAAOF;IACT;IACA,MAAMG,QAAQ,EAAE;IAChB,IAAIC,aAAa;IACjB,IAAIC,QAAQ;IACZ,IAAIC;IACJ,MAAOD,QAAQH,IAAIK,MAAM,CAAE;QACzB,MAAO,AAACD,CAAAA,OAAOJ,IAAIM,UAAU,CAACH,QAAO,KAAMC,SAAS,GAAG,KAAK;QAC5D,MAAMG,OAAOP,IAAIQ,KAAK,CAACN,YAAYC,QAAQ;QAC3CD,aAAaC;QACb,IAAII,MAAMN,MAAMQ,IAAI,CAACF;IACvB;IACA,OAAON,MAAMI,MAAM,GAAGJ,QAAQH;AAChC;AAEA,MAAMY,mBAAmBC;AAEzB,qEAAqE,GACrE,MAAMC,iBAAiB,CAACC,OAAgBb;IACtC,IAAIJ,OAAOiB;IACX,IAAK,IAAIV,QAAQ,GAAGA,QAAQH,IAAIK,MAAM,EAAEF,QAAS;QAC/C,MAAMW,OAAOd,GAAG,CAACG,MAAM;QACvB,IAAIP,QAAQ,QAAQ,OAAOA,SAAS,YAAYkB,QAAQlB,MAAM;YAC5DA,OAAO,AAACA,IAAgC,CAACkB,KAAK;QAChD,OAAO;YACLlB,OAAOc;YACP;QACF;IACF;IACA,OAAOd;AACT;AAEA,qEAAqE,GACrE,MAAMmB,cAAc,CAClBnB,MACAoB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