@expo/cli 0.18.16 → 0.18.18
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/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +110 -41
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +0 -1
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +130 -92
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportHermes.js +15 -0
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +3 -48
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/run/startBundler.js +1 -8
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/platforms/DeviceManager.js.map +1 -1
- package/build/src/start/platforms/PlatformManager.js +7 -2
- package/build/src/start/platforms/PlatformManager.js.map +1 -1
- package/build/src/start/platforms/android/AndroidDeviceManager.js +3 -0
- package/build/src/start/platforms/android/AndroidDeviceManager.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +6 -2
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/platforms/ios/simctl.js +80 -0
- package/build/src/start/platforms/ios/simctl.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +9 -2
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +13 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +9 -123
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +391 -102
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +0 -9
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +19 -12
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +49 -2
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/metroPrivateServer.js +26 -0
- package/build/src/start/server/metro/metroPrivateServer.js.map +1 -0
- package/build/src/start/server/metro/runServer-fork.js +28 -20
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +5 -13
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +6 -3
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +11 -3
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
- package/build/src/utils/port.js +1 -1
- package/build/src/utils/port.js.map +1 -1
- package/build/src/utils/telemetry/getContext.js +1 -1
- package/package.json +5 -4
- package/build/src/export/fork-bundleAsync.js +0 -284
- package/build/src/export/fork-bundleAsync.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/export/exportStaticAsync.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport { RouteNode } from 'expo-router/build/Route';\nimport { stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { Log } from '../log';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport {\n ExpoRouterRuntimeManifest,\n MetroBundlerDevServer,\n} from '../start/server/metro/MetroBundlerDevServer';\nimport { ExpoRouterServerManifestV1 } from '../start/server/metro/fetchRouterManifest';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getApiRoutesForDirectory } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\nimport { getFreePortAsync } from '../utils/port';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = {\n mode: 'production' | 'development';\n files?: ExportAssetMap;\n outputDir: string;\n minify: boolean;\n exportServer: boolean;\n baseUrl: string;\n includeSourceMaps: boolean;\n entryPoint?: string;\n clear: boolean;\n routerRoot: string;\n maxWorkers?: number;\n isExporting: boolean;\n};\n\ntype HtmlRequestLocation = {\n /** The output file path name to use relative to the static folder. */\n filePath: string;\n /** The pathname to make requests to in order to fetch the HTML. */\n pathname: string;\n /** The runtime route node object, used to associate async modules with the static HTML. */\n route: RouteNode;\n};\n\n/** @private */\nexport async function unstable_exportStaticAsync(projectRoot: string, options: Options) {\n Log.log(\n `Static rendering is enabled. ` +\n learnMore('https://docs.expo.dev/router/reference/static-rendering/')\n );\n\n // Useful for running parallel e2e tests in CI.\n const port = await getFreePortAsync(8082);\n\n // TODO: Prevent starting the watcher.\n const devServerManager = new DevServerManager(projectRoot, {\n minify: options.minify,\n mode: options.mode,\n port,\n isExporting: true,\n location: {},\n resetDevServer: options.clear,\n maxWorkers: options.maxWorkers,\n });\n\n await devServerManager.startAsync([\n {\n type: 'metro',\n options: {\n port,\n mode: options.mode,\n location: {},\n isExporting: true,\n minify: options.minify,\n resetDevServer: options.clear,\n maxWorkers: options.maxWorkers,\n },\n },\n ]);\n\n try {\n return await exportFromServerAsync(projectRoot, devServerManager, options);\n } finally {\n await devServerManager.stopAsync();\n }\n}\n\n/** Match `(page)` -> `page` */\nfunction matchGroupName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport async function getFilesToExportFromServerAsync(\n projectRoot: string,\n {\n manifest,\n renderAsync,\n // Servers can handle group routes automatically and therefore\n // don't require the build-time generation of every possible group\n // variation.\n exportServer,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations: !exportServer }).map(\n async ({ route, filePath, pathname }) => {\n try {\n const targetDomain = exportServer ? 'server' : 'client';\n files.set(filePath, { contents: '', targetDomain });\n const data = await renderAsync({ route, filePath, pathname });\n files.set(filePath, {\n contents: data,\n routeId: pathname,\n targetDomain,\n });\n } catch (e: any) {\n await logMetroErrorAsync({ error: e, projectRoot });\n throw new Error('Failed to statically export route: ' + pathname);\n }\n }\n )\n );\n\n return files;\n}\n\nfunction modifyRouteNodeInRuntimeManifest(\n manifest: ExpoRouterRuntimeManifest,\n callback: (route: RouteNode) => any\n) {\n const iterateScreens = (screens: ExpoRouterRuntimeManifest['screens']) => {\n Object.values(screens).map((value) => {\n if (typeof value !== 'string') {\n if (value._route) callback(value._route);\n iterateScreens(value.screens);\n }\n });\n };\n\n iterateScreens(manifest.screens);\n}\n\n// TODO: Do this earlier in the process.\nfunction makeRuntimeEntryPointsAbsolute(manifest: ExpoRouterRuntimeManifest, appDir: string) {\n modifyRouteNodeInRuntimeManifest(manifest, (route) => {\n if (Array.isArray(route.entryPoints)) {\n route.entryPoints = route.entryPoints.map((entryPoint) => {\n if (entryPoint.startsWith('.')) {\n return path.resolve(appDir, entryPoint);\n } else if (!path.isAbsolute(entryPoint)) {\n return resolveFrom(appDir, entryPoint);\n }\n return entryPoint;\n });\n }\n });\n}\n\n/** Perform all fs commits */\nasync function exportFromServerAsync(\n projectRoot: string,\n devServerManager: DevServerManager,\n { outputDir, baseUrl, exportServer, includeSourceMaps, routerRoot, files = new Map() }: Options\n): Promise<ExportAssetMap> {\n const platform = 'web';\n const isExporting = true;\n const appDir = path.join(projectRoot, routerRoot);\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n });\n\n const devServer = devServerManager.getDefaultDevServer();\n assert(devServer instanceof MetroBundlerDevServer);\n\n const [resources, { manifest, serverManifest, renderAsync }] = await Promise.all([\n devServer.getStaticResourcesAsync({\n includeSourceMaps,\n }),\n devServer.getStaticRenderFunctionAsync(),\n ]);\n\n makeRuntimeEntryPointsAbsolute(manifest, appDir);\n\n debug('Routes:\\n', inspect(manifest, { colors: true, depth: null }));\n\n await getFilesToExportFromServerAsync(projectRoot, {\n files,\n manifest,\n exportServer,\n async renderAsync({ pathname, route }) {\n const template = await renderAsync(pathname);\n let html = await serializeHtmlWithAssets({\n isExporting,\n resources: resources.artifacts,\n template,\n baseUrl,\n route,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n platform,\n includeSourceMaps,\n files,\n });\n\n if (resources.assets) {\n // TODO: Collect files without writing to disk.\n // NOTE(kitten): Re. above, this is now using `files` except for iOS catalog output, which isn't used here\n await persistMetroAssetsAsync(resources.assets, {\n files,\n platform,\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n if (exportServer) {\n const apiRoutes = await exportApiRoutesAsync({\n outputDir,\n server: devServer,\n manifest: serverManifest,\n // NOTE(kitten): For now, we always output source maps for API route exports\n includeSourceMaps: true,\n });\n\n // Add the api routes to the files to export.\n for (const [route, contents] of apiRoutes) {\n files.set(route, contents);\n }\n } else {\n warnPossibleInvalidExportType(appDir);\n }\n\n return files;\n}\n\nexport function getHtmlFiles({\n manifest,\n includeGroupVariations,\n}: {\n manifest: ExpoRouterRuntimeManifest;\n includeGroupVariations?: boolean;\n}): HtmlRequestLocation[] {\n const htmlFiles = new Set<Omit<HtmlRequestLocation, 'pathname'>>();\n\n function traverseScreens(\n screens: ExpoRouterRuntimeManifest['screens'],\n route: RouteNode | null,\n baseUrl = ''\n ) {\n for (const value of Object.values(screens)) {\n let leaf: string | null = null;\n if (typeof value === 'string') {\n leaf = value;\n } else if (Object.keys(value.screens).length === 0) {\n leaf = value.path;\n route = value._route ?? null;\n }\n\n if (leaf != null) {\n let filePath = baseUrl + leaf;\n\n if (leaf === '') {\n filePath =\n baseUrl === ''\n ? 'index'\n : baseUrl.endsWith('/')\n ? baseUrl + 'index'\n : baseUrl.slice(0, -1);\n } else if (\n // If the path is a collection of group segments leading to an index route, append `/index`.\n stripGroupSegmentsFromPath(filePath) === ''\n ) {\n filePath += '/index';\n }\n\n // This should never happen, the type of `string | object` originally comes from React Navigation.\n if (!route) {\n throw new Error(\n `Internal error: Route not found for \"${filePath}\" while collecting static export paths.`\n );\n }\n\n if (includeGroupVariations) {\n // TODO: Dedupe requests for alias routes.\n addOptionalGroups(filePath, route);\n } else {\n htmlFiles.add({\n filePath,\n route,\n });\n }\n } else if (typeof value === 'object' && value?.screens) {\n const newPath = baseUrl + value.path + '/';\n traverseScreens(value.screens, value._route ?? null, newPath);\n }\n }\n }\n\n function addOptionalGroups(path: string, route: RouteNode) {\n const variations = getPathVariations(path);\n for (const variation of variations) {\n htmlFiles.add({ filePath: variation, route });\n }\n }\n\n traverseScreens(manifest.screens, null);\n\n return uniqueBy(Array.from(htmlFiles), (value) => value.filePath).map((value) => {\n const parts = value.filePath.split('/');\n // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`\n const partsWithGroups = parts.map((part) => {\n if (part === '*not-found') {\n return `+not-found`;\n } else if (part.startsWith(':')) {\n return `[${part.slice(1)}]`;\n } else if (part.startsWith('*')) {\n return `[...${part.slice(1)}]`;\n }\n return part;\n });\n const filePathLocation = partsWithGroups.join('/');\n const filePath = filePathLocation + '.html';\n return {\n ...value,\n filePath,\n pathname: filePathLocation.replace(/(\\/?index)?$/, ''),\n };\n });\n}\n\nfunction uniqueBy<T>(array: T[], key: (value: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const value of array) {\n const id = key(value);\n if (!seen.has(id)) {\n seen.add(id);\n result.push(value);\n }\n }\n return result;\n}\n\n// Given a route like `(foo)/bar/(baz)`, return all possible variations of the route.\n// e.g. `(foo)/bar/(baz)`, `(foo)/bar/baz`, `foo/bar/(baz)`, `foo/bar/baz`,\nexport function getPathVariations(routePath: string): string[] {\n const variations = new Set<string>();\n const segments = routePath.split('/');\n\n function generateVariations(segments: string[], current = ''): void {\n if (segments.length === 0) {\n if (current) variations.add(current);\n return;\n }\n\n const [head, ...rest] = segments;\n\n if (matchGroupName(head)) {\n const groups = head.slice(1, -1).split(',');\n\n if (groups.length > 1) {\n for (const group of groups) {\n // If there are multiple groups, recurse on each group.\n generateVariations([`(${group.trim()})`, ...rest], current);\n }\n return;\n } else {\n // Start a fork where this group is included\n generateVariations(rest, current ? `${current}/(${groups[0]})` : `(${groups[0]})`);\n // This code will continue and add paths without this group included`\n }\n } else if (current) {\n current = `${current}/${head}`;\n } else {\n current = head;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\nasync function exportApiRoutesAsync({\n includeSourceMaps,\n outputDir,\n server,\n ...props\n}: Pick<Options, 'outputDir' | 'includeSourceMaps'> & {\n server: MetroBundlerDevServer;\n manifest: ExpoRouterServerManifestV1;\n}): Promise<ExportAssetMap> {\n const { manifest, files } = await server.exportExpoRouterApiRoutesAsync({\n outputDir: '_expo/functions',\n prerenderManifest: props.manifest,\n includeSourceMaps,\n });\n\n Log.log(chalk.bold`Exporting ${files.size} API Routes.`);\n\n files.set('_expo/routes.json', {\n contents: JSON.stringify(manifest, null, 2),\n targetDomain: 'server',\n });\n\n return files;\n}\n\nfunction warnPossibleInvalidExportType(appDir: string) {\n const apiRoutes = getApiRoutesForDirectory(appDir);\n if (apiRoutes.length) {\n // TODO: Allow API Routes for native-only.\n Log.warn(\n chalk.yellow`Skipping export for API routes because \\`web.output\\` is not \"server\". You may want to remove the routes: ${apiRoutes\n .map((v) => path.relative(appDir, v))\n .join(', ')}`\n );\n }\n}\n"],"names":["unstable_exportStaticAsync","getFilesToExportFromServerAsync","getHtmlFiles","getPathVariations","debug","require","projectRoot","options","Log","log","learnMore","port","getFreePortAsync","devServerManager","DevServerManager","minify","mode","isExporting","location","resetDevServer","clear","maxWorkers","startAsync","type","exportFromServerAsync","stopAsync","matchGroupName","name","match","manifest","renderAsync","exportServer","files","Map","Promise","all","includeGroupVariations","map","route","filePath","pathname","targetDomain","set","contents","data","routeId","e","logMetroErrorAsync","error","Error","modifyRouteNodeInRuntimeManifest","callback","iterateScreens","screens","Object","values","value","_route","makeRuntimeEntryPointsAbsolute","appDir","Array","isArray","entryPoints","entryPoint","startsWith","path","resolve","isAbsolute","resolveFrom","outputDir","baseUrl","includeSourceMaps","routerRoot","platform","join","injectFaviconTag","getVirtualFaviconAssetsAsync","devServer","getDefaultDevServer","assert","MetroBundlerDevServer","resources","serverManifest","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","serializeHtmlWithAssets","artifacts","getFilesFromSerialAssets","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","leaf","keys","length","endsWith","slice","stripGroupSegmentsFromPath","addOptionalGroups","add","newPath","variations","variation","uniqueBy","from","parts","split","partsWithGroups","part","filePathLocation","replace","array","key","seen","result","id","has","push","routePath","segments","generateVariations","current","head","rest","groups","group","trim","props","exportExpoRouterApiRoutesAsync","prerenderManifest","chalk","bold","size","JSON","stringify","getApiRoutesForDirectory","warn","yellow","v","relative"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IAmDsBA,0BAA0B,MAA1BA,0BAA0B;IA+C1BC,+BAA+B,MAA/BA,+BAA+B;IAiKrCC,YAAY,MAAZA,YAAY;IA8GZC,iB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IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzD/G,KAAK,CAACU,GAAG,CAAC,mBAAmB,EAAE;QAC7BC,QAAQ,EAAEqG,IAAI,CAACC,SAAS,CAACpH,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3CY,YAAY,EAAE,QAAQ;KACvB,CAAC,CAAC;IAEH,OAAOT,KAAK,CAAC;AACf,CAAC;AAED,SAASmE,6BAA6B,CAACxC,MAAc,EAAE;IACrD,MAAMqC,SAAS,GAAGkD,IAAAA,OAAwB,yBAAA,EAACvF,MAAM,CAAC,AAAC;IACnD,IAAIqC,SAAS,CAACS,MAAM,EAAE;QACpB,0CAA0C;QAC1CjG,IAAG,IAAA,CAAC2I,IAAI,CACNN,MAAK,EAAA,QAAA,CAACO,MAAM,CAAC,0GAA0G,EAAEpD,SAAS,CAC/H3D,GAAG,CAAC,CAACgH,CAAC,GAAKpF,KAAI,EAAA,QAAA,CAACqF,QAAQ,CAAC3F,MAAM,EAAE0F,CAAC,CAAC,CAAC,CACpC3E,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAChB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/export/exportStaticAsync.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport chalk from 'chalk';\nimport { RouteNode } from 'expo-router/build/Route';\nimport { stripGroupSegmentsFromPath } from 'expo-router/build/matchers';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { inspect } from 'util';\n\nimport { getVirtualFaviconAssetsAsync } from './favicon';\nimport { persistMetroAssetsAsync } from './persistMetroAssets';\nimport { ExportAssetMap, getFilesFromSerialAssets } from './saveAssets';\nimport { Log } from '../log';\nimport {\n ExpoRouterRuntimeManifest,\n MetroBundlerDevServer,\n} from '../start/server/metro/MetroBundlerDevServer';\nimport { ExpoRouterServerManifestV1 } from '../start/server/metro/fetchRouterManifest';\nimport { logMetroErrorAsync } from '../start/server/metro/metroErrorInterface';\nimport { getApiRoutesForDirectory } from '../start/server/metro/router';\nimport { serializeHtmlWithAssets } from '../start/server/metro/serializeHtml';\nimport { learnMore } from '../utils/link';\n\nconst debug = require('debug')('expo:export:generateStaticRoutes') as typeof console.log;\n\ntype Options = {\n mode: 'production' | 'development';\n files?: ExportAssetMap;\n outputDir: string;\n minify: boolean;\n exportServer: boolean;\n baseUrl: string;\n includeSourceMaps: boolean;\n entryPoint?: string;\n clear: boolean;\n routerRoot: string;\n reactCompiler: boolean;\n maxWorkers?: number;\n isExporting: boolean;\n};\n\ntype HtmlRequestLocation = {\n /** The output file path name to use relative to the static folder. */\n filePath: string;\n /** The pathname to make requests to in order to fetch the HTML. */\n pathname: string;\n /** The runtime route node object, used to associate async modules with the static HTML. */\n route: RouteNode;\n};\n\n/** Match `(page)` -> `page` */\nfunction matchGroupName(name: string): string | undefined {\n return name.match(/^\\(([^/]+?)\\)$/)?.[1];\n}\n\nexport async function getFilesToExportFromServerAsync(\n projectRoot: string,\n {\n manifest,\n renderAsync,\n // Servers can handle group routes automatically and therefore\n // don't require the build-time generation of every possible group\n // variation.\n exportServer,\n // name : contents\n files = new Map(),\n }: {\n manifest: ExpoRouterRuntimeManifest;\n renderAsync: (requestLocation: HtmlRequestLocation) => Promise<string>;\n exportServer?: boolean;\n files?: ExportAssetMap;\n }\n): Promise<ExportAssetMap> {\n await Promise.all(\n getHtmlFiles({ manifest, includeGroupVariations: !exportServer }).map(\n async ({ route, filePath, pathname }) => {\n try {\n const targetDomain = exportServer ? 'server' : 'client';\n files.set(filePath, { contents: '', targetDomain });\n const data = await renderAsync({ route, filePath, pathname });\n files.set(filePath, {\n contents: data,\n routeId: pathname,\n targetDomain,\n });\n } catch (e: any) {\n await logMetroErrorAsync({ error: e, projectRoot });\n throw new Error('Failed to statically export route: ' + pathname);\n }\n }\n )\n );\n\n return files;\n}\n\nfunction modifyRouteNodeInRuntimeManifest(\n manifest: ExpoRouterRuntimeManifest,\n callback: (route: RouteNode) => any\n) {\n const iterateScreens = (screens: ExpoRouterRuntimeManifest['screens']) => {\n Object.values(screens).map((value) => {\n if (typeof value !== 'string') {\n if (value._route) callback(value._route);\n iterateScreens(value.screens);\n }\n });\n };\n\n iterateScreens(manifest.screens);\n}\n\n// TODO: Do this earlier in the process.\nfunction makeRuntimeEntryPointsAbsolute(manifest: ExpoRouterRuntimeManifest, appDir: string) {\n modifyRouteNodeInRuntimeManifest(manifest, (route) => {\n if (Array.isArray(route.entryPoints)) {\n route.entryPoints = route.entryPoints.map((entryPoint) => {\n if (entryPoint.startsWith('.')) {\n return path.resolve(appDir, entryPoint);\n } else if (!path.isAbsolute(entryPoint)) {\n return resolveFrom(appDir, entryPoint);\n }\n return entryPoint;\n });\n }\n });\n}\n\n/** Perform all fs commits */\nexport async function exportFromServerAsync(\n projectRoot: string,\n devServer: MetroBundlerDevServer,\n { outputDir, baseUrl, exportServer, includeSourceMaps, routerRoot, files = new Map() }: Options\n): Promise<ExportAssetMap> {\n Log.log(\n `Static rendering is enabled. ` +\n learnMore('https://docs.expo.dev/router/reference/static-rendering/')\n );\n\n const platform = 'web';\n const isExporting = true;\n const appDir = path.join(projectRoot, routerRoot);\n const injectFaviconTag = await getVirtualFaviconAssetsAsync(projectRoot, {\n outputDir,\n baseUrl,\n files,\n });\n\n const [resources, { manifest, serverManifest, renderAsync }] = await Promise.all([\n devServer.getStaticResourcesAsync({\n includeSourceMaps,\n }),\n devServer.getStaticRenderFunctionAsync(),\n ]);\n\n makeRuntimeEntryPointsAbsolute(manifest, appDir);\n\n debug('Routes:\\n', inspect(manifest, { colors: true, depth: null }));\n\n await getFilesToExportFromServerAsync(projectRoot, {\n files,\n manifest,\n exportServer,\n async renderAsync({ pathname, route }) {\n const template = await renderAsync(pathname);\n let html = await serializeHtmlWithAssets({\n isExporting,\n resources: resources.artifacts,\n template,\n baseUrl,\n route,\n });\n\n if (injectFaviconTag) {\n html = injectFaviconTag(html);\n }\n\n return html;\n },\n });\n\n getFilesFromSerialAssets(resources.artifacts, {\n platform,\n includeSourceMaps,\n files,\n });\n\n if (resources.assets) {\n // TODO: Collect files without writing to disk.\n // NOTE(kitten): Re. above, this is now using `files` except for iOS catalog output, which isn't used here\n await persistMetroAssetsAsync(resources.assets, {\n files,\n platform,\n outputDirectory: outputDir,\n baseUrl,\n });\n }\n\n if (exportServer) {\n const apiRoutes = await exportApiRoutesAsync({\n outputDir,\n server: devServer,\n manifest: serverManifest,\n // NOTE(kitten): For now, we always output source maps for API route exports\n includeSourceMaps: true,\n });\n\n // Add the api routes to the files to export.\n for (const [route, contents] of apiRoutes) {\n files.set(route, contents);\n }\n } else {\n warnPossibleInvalidExportType(appDir);\n }\n\n return files;\n}\n\nexport function getHtmlFiles({\n manifest,\n includeGroupVariations,\n}: {\n manifest: ExpoRouterRuntimeManifest;\n includeGroupVariations?: boolean;\n}): HtmlRequestLocation[] {\n const htmlFiles = new Set<Omit<HtmlRequestLocation, 'pathname'>>();\n\n function traverseScreens(\n screens: ExpoRouterRuntimeManifest['screens'],\n route: RouteNode | null,\n baseUrl = ''\n ) {\n for (const value of Object.values(screens)) {\n let leaf: string | null = null;\n if (typeof value === 'string') {\n leaf = value;\n } else if (Object.keys(value.screens).length === 0) {\n leaf = value.path;\n route = value._route ?? null;\n }\n\n if (leaf != null) {\n let filePath = baseUrl + leaf;\n\n if (leaf === '') {\n filePath =\n baseUrl === ''\n ? 'index'\n : baseUrl.endsWith('/')\n ? baseUrl + 'index'\n : baseUrl.slice(0, -1);\n } else if (\n // If the path is a collection of group segments leading to an index route, append `/index`.\n stripGroupSegmentsFromPath(filePath) === ''\n ) {\n filePath += '/index';\n }\n\n // This should never happen, the type of `string | object` originally comes from React Navigation.\n if (!route) {\n throw new Error(\n `Internal error: Route not found for \"${filePath}\" while collecting static export paths.`\n );\n }\n\n if (includeGroupVariations) {\n // TODO: Dedupe requests for alias routes.\n addOptionalGroups(filePath, route);\n } else {\n htmlFiles.add({\n filePath,\n route,\n });\n }\n } else if (typeof value === 'object' && value?.screens) {\n const newPath = baseUrl + value.path + '/';\n traverseScreens(value.screens, value._route ?? null, newPath);\n }\n }\n }\n\n function addOptionalGroups(path: string, route: RouteNode) {\n const variations = getPathVariations(path);\n for (const variation of variations) {\n htmlFiles.add({ filePath: variation, route });\n }\n }\n\n traverseScreens(manifest.screens, null);\n\n return uniqueBy(Array.from(htmlFiles), (value) => value.filePath).map((value) => {\n const parts = value.filePath.split('/');\n // Replace `:foo` with `[foo]` and `*foo` with `[...foo]`\n const partsWithGroups = parts.map((part) => {\n if (part === '*not-found') {\n return `+not-found`;\n } else if (part.startsWith(':')) {\n return `[${part.slice(1)}]`;\n } else if (part.startsWith('*')) {\n return `[...${part.slice(1)}]`;\n }\n return part;\n });\n const filePathLocation = partsWithGroups.join('/');\n const filePath = filePathLocation + '.html';\n return {\n ...value,\n filePath,\n pathname: filePathLocation.replace(/(\\/?index)?$/, ''),\n };\n });\n}\n\nfunction uniqueBy<T>(array: T[], key: (value: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const value of array) {\n const id = key(value);\n if (!seen.has(id)) {\n seen.add(id);\n result.push(value);\n }\n }\n return result;\n}\n\n// Given a route like `(foo)/bar/(baz)`, return all possible variations of the route.\n// e.g. `(foo)/bar/(baz)`, `(foo)/bar/baz`, `foo/bar/(baz)`, `foo/bar/baz`,\nexport function getPathVariations(routePath: string): string[] {\n const variations = new Set<string>();\n const segments = routePath.split('/');\n\n function generateVariations(segments: string[], current = ''): void {\n if (segments.length === 0) {\n if (current) variations.add(current);\n return;\n }\n\n const [head, ...rest] = segments;\n\n if (matchGroupName(head)) {\n const groups = head.slice(1, -1).split(',');\n\n if (groups.length > 1) {\n for (const group of groups) {\n // If there are multiple groups, recurse on each group.\n generateVariations([`(${group.trim()})`, ...rest], current);\n }\n return;\n } else {\n // Start a fork where this group is included\n generateVariations(rest, current ? `${current}/(${groups[0]})` : `(${groups[0]})`);\n // This code will continue and add paths without this group included`\n }\n } else if (current) {\n current = `${current}/${head}`;\n } else {\n current = head;\n }\n\n generateVariations(rest, current);\n }\n\n generateVariations(segments);\n\n return Array.from(variations);\n}\n\nasync function exportApiRoutesAsync({\n includeSourceMaps,\n outputDir,\n server,\n ...props\n}: Pick<Options, 'outputDir' | 'includeSourceMaps'> & {\n server: MetroBundlerDevServer;\n manifest: ExpoRouterServerManifestV1;\n}): Promise<ExportAssetMap> {\n const { manifest, files } = await server.exportExpoRouterApiRoutesAsync({\n outputDir: '_expo/functions',\n prerenderManifest: props.manifest,\n includeSourceMaps,\n });\n\n Log.log(chalk.bold`Exporting ${files.size} API Routes.`);\n\n files.set('_expo/routes.json', {\n contents: JSON.stringify(manifest, null, 2),\n targetDomain: 'server',\n });\n\n return files;\n}\n\nfunction warnPossibleInvalidExportType(appDir: string) {\n const apiRoutes = getApiRoutesForDirectory(appDir);\n if (apiRoutes.length) {\n // TODO: Allow API Routes for native-only.\n Log.warn(\n chalk.yellow`Skipping export for API routes because \\`web.output\\` is not \"server\". You may want to remove the routes: ${apiRoutes\n .map((v) => path.relative(appDir, v))\n .join(', ')}`\n );\n }\n}\n"],"names":["getFilesToExportFromServerAsync","exportFromServerAsync","getHtmlFiles","getPathVariations","debug","require","matchGroupName","name","match","projectRoot","manifest","renderAsync","exportServer","files","Map","Promise","all","includeGroupVariations","map","route","filePath","pathname","targetDomain","set","contents","data","routeId","e","logMetroErrorAsync","error","Error","modifyRouteNodeInRuntimeManifest","callback","iterateScreens","screens","Object","values","value","_route","makeRuntimeEntryPointsAbsolute","appDir","Array","isArray","entryPoints","entryPoint","startsWith","path","resolve","isAbsolute","resolveFrom","devServer","outputDir","baseUrl","includeSourceMaps","routerRoot","Log","log","learnMore","platform","isExporting","join","injectFaviconTag","getVirtualFaviconAssetsAsync","resources","serverManifest","getStaticResourcesAsync","getStaticRenderFunctionAsync","inspect","colors","depth","template","html","serializeHtmlWithAssets","artifacts","getFilesFromSerialAssets","assets","persistMetroAssetsAsync","outputDirectory","apiRoutes","exportApiRoutesAsync","server","warnPossibleInvalidExportType","htmlFiles","Set","traverseScreens","leaf","keys","length","endsWith","slice","stripGroupSegmentsFromPath","addOptionalGroups","add","newPath","variations","variation","uniqueBy","from","parts","split","partsWithGroups","part","filePathLocation","replace","array","key","seen","result","id","has","push","routePath","segments","generateVariations","current","head","rest","groups","group","trim","props","exportExpoRouterApiRoutesAsync","prerenderManifest","chalk","bold","size","JSON","stringify","getApiRoutesForDirectory","warn","yellow","v","relative"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IAqDsBA,+BAA+B,MAA/BA,+BAA+B;IA0E/BC,qBAAqB,MAArBA,qBAAqB;IAyF3BC,YAAY,MAAZA,YAAY;IA8GZC,iBAAiB,MAAjBA,iBAAiB;;;8DAtUf,OAAO;;;;;;;yBAEkB,4BAA4B;;;;;;;8DACtD,MAAM;;;;;;;8DACC,cAAc;;;;;;;yBACd,MAAM;;;;;;yBAEe,WAAW;oCAChB,sBAAsB;4BACL,cAAc;qBACnD,QAAQ;qCAMO,2CAA2C;wBACrC,8BAA8B;+BAC/B,qCAAqC;sBACnD,eAAe;;;;;;AAEzC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,kCAAkC,CAAC,AAAsB,AAAC;AA2BzF,6BAA6B,GAC7B,SAASC,cAAc,CAACC,IAAY,EAAsB;QACjDA,GAA4B;IAAnC,OAAOA,CAAAA,GAA4B,GAA5BA,IAAI,CAACC,KAAK,kBAAkB,SAAK,GAAjCD,KAAAA,CAAiC,GAAjCA,GAA4B,AAAE,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC;AAEM,eAAeP,+BAA+B,CACnDS,WAAmB,EACnB,EACEC,QAAQ,CAAA,EACRC,WAAW,CAAA,EACX,8DAA8D;AAC9D,kEAAkE;AAClE,aAAa;AACbC,YAAY,CAAA,EACZ,kBAAkB;AAClBC,KAAK,EAAG,IAAIC,GAAG,EAAE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|
1
|
-
{"version":3,"sources":["../../../src/export/saveAssets.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\nimport prettyBytes from 'pretty-bytes';\n\nimport { BundleAssetWithFileHashes } from './fork-bundleAsync';\nimport { Log } from '../log';\n\nexport type ManifestAsset = { fileHashes: string[]; files: string[]; hash: string };\n\nexport type Asset = ManifestAsset | BundleAssetWithFileHashes;\n\nexport type ExportAssetDescriptor = {\n contents: string | Buffer;\n originFilename?: string;\n /** An identifier for grouping together variations of the same asset. */\n assetId?: string;\n /** Expo Router route path for formatting the HTML output. */\n routeId?: string;\n /** A key for grouping together output files by server- or client-side. */\n targetDomain?: 'server' | 'client';\n};\n\nexport type ExportAssetMap = Map<string, ExportAssetDescriptor>;\n\nexport async function persistMetroFilesAsync(files: ExportAssetMap, outputDir: string) {\n if (!files.size) {\n return;\n }\n fs.mkdirSync(path.join(outputDir), { recursive: true });\n\n // Test fixtures:\n // Log.log(\n // JSON.stringify(\n // Object.fromEntries([...files.entries()].map(([k, v]) => [k, { ...v, contents: '' }]))\n // )\n // );\n\n const assetEntries: [string, ExportAssetDescriptor][] = [];\n const routeEntries: [string, ExportAssetDescriptor][] = [];\n const remainingEntries: [string, ExportAssetDescriptor][] = [];\n\n let hasServerOutput = false;\n for (const asset of files.entries()) {\n hasServerOutput = hasServerOutput || asset[1].targetDomain === 'server';\n if (asset[1].assetId) assetEntries.push(asset);\n else if (asset[1].routeId != null) routeEntries.push(asset);\n else remainingEntries.push(asset);\n }\n\n const groups = groupBy(assetEntries, ([, { assetId }]) => assetId!);\n\n const contentSize = (contents: string | Buffer) => {\n const length =\n typeof contents === 'string' ? Buffer.byteLength(contents, 'utf8') : contents.length;\n return length;\n };\n\n const sizeStr = (contents: string | Buffer) => {\n const length = contentSize(contents);\n const size = chalk.gray`(${prettyBytes(length)})`;\n return size;\n };\n\n if (routeEntries.length) {\n const plural = routeEntries.length === 1 ? '' : 's';\n\n Log.log('');\n Log.log(chalk.bold`Exporting ${routeEntries.length} static route${plural}:`);\n\n for (const [, assets] of routeEntries.sort((a, b) => a[0].length - b[0].length)) {\n const id = assets.routeId!;\n Log.log('/' + (id === '' ? chalk.gray(' (index)') : id), sizeStr(assets.contents));\n }\n }\n\n const assetGroups = [...groups.entries()].sort((a, b) => a[0].localeCompare(b[0])) as [\n string,\n [string, ExportAssetDescriptor][],\n ][];\n\n if (assetGroups.length) {\n const totalAssets = assetGroups.reduce((sum, [, assets]) => sum + assets.length, 0);\n const plural = totalAssets === 1 ? '' : 's';\n\n Log.log('');\n Log.log(chalk.bold`Exporting ${totalAssets} asset${plural}:`);\n\n for (const [assetId, assets] of assetGroups) {\n const averageContentSize =\n assets.reduce((sum, [, { contents }]) => sum + contentSize(contents), 0) / assets.length;\n Log.log(\n assetId,\n chalk.gray(\n `(${[\n assets.length > 1 ? `${assets.length} variations` : '',\n `${prettyBytes(averageContentSize)}`,\n ]\n .filter(Boolean)\n .join(' | ')})`\n )\n );\n }\n }\n\n const bundles: Map<string, [string, ExportAssetDescriptor][]> = new Map();\n const other: [string, ExportAssetDescriptor][] = [];\n\n remainingEntries.forEach(([filepath, asset]) => {\n if (!filepath.match(/_expo\\/static\\//)) {\n other.push([filepath, asset]);\n } else {\n const platform = filepath.match(/_expo\\/static\\/js\\/([^/]+)\\//)?.[1] ?? 'web';\n if (!bundles.has(platform)) bundles.set(platform, []);\n\n bundles.get(platform)!.push([filepath, asset]);\n }\n });\n\n [...bundles.entries()].forEach(([platform, assets]) => {\n Log.log('');\n const plural = assets.length === 1 ? '' : 's';\n Log.log(chalk.bold`Exporting ${assets.length} bundle${plural} for ${platform}:`);\n\n const allAssets = assets.sort((a, b) => a[0].localeCompare(b[0]));\n while (allAssets.length) {\n const [filePath, asset] = allAssets.shift()!;\n Log.log(filePath, sizeStr(asset.contents));\n if (filePath.match(/\\.(js|hbc)$/)) {\n // Get source map\n const sourceMapIndex = allAssets.findIndex(([fp]) => fp === filePath + '.map');\n if (sourceMapIndex !== -1) {\n const [sourceMapFilePath, sourceMapAsset] = allAssets.splice(sourceMapIndex, 1)[0];\n Log.log(chalk.gray(sourceMapFilePath), sizeStr(sourceMapAsset.contents));\n }\n }\n }\n });\n\n if (other.length) {\n Log.log('');\n const plural = other.length === 1 ? '' : 's';\n Log.log(chalk.bold`Exporting ${other.length} file${plural}:`);\n\n for (const [filePath, asset] of other.sort((a, b) => a[0].localeCompare(b[0]))) {\n Log.log(filePath, sizeStr(asset.contents));\n }\n }\n\n // Decouple logging from writing for better performance.\n\n await Promise.all(\n [...files.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(async ([file, { contents, targetDomain }]) => {\n // NOTE: Only use `targetDomain` if we have at least one server asset\n const domain = (hasServerOutput && targetDomain) || '';\n const outputPath = path.join(outputDir, domain, file);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.promises.writeFile(outputPath, contents);\n })\n );\n\n Log.log('');\n}\n\nfunction groupBy<T>(array: T[], key: (item: T) => string): Map<string, T[]> {\n const map = new Map<string, T[]>();\n array.forEach((item) => {\n const group = key(item);\n const list = map.get(group) ?? [];\n list.push(item);\n map.set(group, list);\n });\n return map;\n}\n\n// TODO: Move source map modification to the serializer\nexport function getFilesFromSerialAssets(\n resources: SerialAsset[],\n {\n includeSourceMaps,\n files = new Map(),\n platform,\n }: {\n includeSourceMaps: boolean;\n files?: ExportAssetMap;\n platform?: string;\n }\n) {\n resources.forEach((resource) => {\n files.set(resource.filename, {\n contents: resource.source,\n originFilename: resource.originFilename,\n targetDomain: platform === 'web' ? 'client' : undefined,\n });\n });\n\n return files;\n}\n"],"names":["persistMetroFilesAsync","getFilesFromSerialAssets","files","outputDir","size","fs","mkdirSync","path","join","recursive","assetEntries","routeEntries","remainingEntries","hasServerOutput","asset","entries","targetDomain","assetId","push","routeId","groups","groupBy","contentSize","contents","length","Buffer","byteLength","sizeStr","chalk","gray","prettyBytes","plural","Log","log","bold","assets","sort","a","b","id","assetGroups","localeCompare","totalAssets","reduce","sum","averageContentSize","filter","Boolean","bundles","Map","other","forEach","filepath","match","platform","has","set","get","allAssets","filePath","shift","sourceMapIndex","findIndex","fp","sourceMapFilePath","sourceMapAsset","splice","Promise","all","map","file","domain","outputPath","promises","mkdir","dirname","writeFile","array","key","item","group","list","resources","includeSourceMaps","resource","filename","source","originFilename","undefined"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IA0BsBA,sBAAsB,MAAtBA,sBAAsB;IAyJ5BC,wBAAwB,MAAxBA,wBAAwB;;;8DAlLtB,OAAO;;;;;;;8DACV,IAAI;;;;;;;8DACF,MAAM;;;;;;;8DACC,cAAc;;;;;;qBAGlB,QAAQ;;;;;;AAmBrB,eAAeD,sBAAsB,CAACE,KAAqB,EAAEC,SAAiB,EAAE;IACrF,IAAI,CAACD,KAAK,CAACE,IAAI,EAAE;QACf,OAAO;IACT,CAAC;IACDC,GAAE,EAAA,QAAA,CAACC,SAAS,CAACC,KAAI,EAAA,QAAA,CAACC,IAAI,CAACL,SAAS,CAAC,EAAE;QAAEM,SAAS,EAAE,IAAI;KAAE,CAAC,CAAC;IAExD,iBAAiB;IACjB,WAAW;IACX,oBAAoB;IACpB,4FAA4F;IAC5F,MAAM;IACN,KAAK;IAEL,MAAMC,YAAY,GAAsC,EAAE,AAAC;IAC3D,MAAMC,YAAY,GAAsC,EAAE,AAAC;IAC3D,MAAMC,gBAAgB,GAAsC,EAAE,AAAC;IAE/D,IAAIC,eAAe,GAAG,KAAK,AAAC;IAC5B,KAAK,MAAMC,KAAK,IAAIZ,KAAK,CAACa,OAAO,EAAE,CAAE;QACnCF,eAAe,GAAGA,eAAe,IAAIC,KAAK,CAAC,CAAC,CAAC,CAACE,YAAY,KAAK,QAAQ,CAAC;QACxE,IAAIF,KAAK,CAAC,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AC,CAAC,CAAC;IACH,OAAOZ,GAAG,CAAC;AACb,CAAC;AAGM,SAASpE,wBAAwB,CACtCiF,SAAwB,EACxB,EACEC,iBAAiB,CAAA,EACjBjF,KAAK,EAAG,IAAI+C,GAAG,EAAE,CAAA,EACjBK,QAAQ,CAAA,EAKT,EACD;IACA4B,SAAS,CAAC/B,OAAO,CAAC,CAACiC,QAAQ,GAAK;QAC9BlF,KAAK,CAACsD,GAAG,CAAC4B,QAAQ,CAACC,QAAQ,EAAE;YAC3B9D,QAAQ,EAAE6D,QAAQ,CAACE,MAAM;YACzBC,cAAc,EAAEH,QAAQ,CAACG,cAAc;YACvCvE,YAAY,EAAEsC,QAAQ,KAAK,KAAK,GAAG,QAAQ,GAAGkC,SAAS;SACxD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAOtF,KAAK,CAAC;AACf,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/export/saveAssets.ts"],"sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { SerialAsset } from '@expo/metro-config/build/serializer/serializerAssets';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport Metro from 'metro';\nimport path from 'path';\nimport prettyBytes from 'pretty-bytes';\n\nimport { Log } from '../log';\n\nexport type BundleOptions = {\n entryPoint: string;\n platform: 'android' | 'ios' | 'web';\n dev?: boolean;\n minify?: boolean;\n bytecode: boolean;\n sourceMapUrl?: string;\n sourcemaps?: boolean;\n};\n\nexport type BundleAssetWithFileHashes = Metro.AssetData & {\n fileHashes: string[]; // added by the hashAssets asset plugin\n};\n\nexport type BundleOutput = {\n artifacts: SerialAsset[];\n assets: readonly BundleAssetWithFileHashes[];\n};\n\nexport type ManifestAsset = { fileHashes: string[]; files: string[]; hash: string };\n\nexport type Asset = ManifestAsset | BundleAssetWithFileHashes;\n\nexport type ExportAssetDescriptor = {\n contents: string | Buffer;\n originFilename?: string;\n /** An identifier for grouping together variations of the same asset. */\n assetId?: string;\n /** Expo Router route path for formatting the HTML output. */\n routeId?: string;\n /** A key for grouping together output files by server- or client-side. */\n targetDomain?: 'server' | 'client';\n};\n\nexport type ExportAssetMap = Map<string, ExportAssetDescriptor>;\n\nexport async function persistMetroFilesAsync(files: ExportAssetMap, outputDir: string) {\n if (!files.size) {\n return;\n }\n fs.mkdirSync(path.join(outputDir), { recursive: true });\n\n // Test fixtures:\n // Log.log(\n // JSON.stringify(\n // Object.fromEntries([...files.entries()].map(([k, v]) => [k, { ...v, contents: '' }]))\n // )\n // );\n\n const assetEntries: [string, ExportAssetDescriptor][] = [];\n const routeEntries: [string, ExportAssetDescriptor][] = [];\n const remainingEntries: [string, ExportAssetDescriptor][] = [];\n\n let hasServerOutput = false;\n for (const asset of files.entries()) {\n hasServerOutput = hasServerOutput || asset[1].targetDomain === 'server';\n if (asset[1].assetId) assetEntries.push(asset);\n else if (asset[1].routeId != null) routeEntries.push(asset);\n else remainingEntries.push(asset);\n }\n\n const groups = groupBy(assetEntries, ([, { assetId }]) => assetId!);\n\n const contentSize = (contents: string | Buffer) => {\n const length =\n typeof contents === 'string' ? Buffer.byteLength(contents, 'utf8') : contents.length;\n return length;\n };\n\n const sizeStr = (contents: string | Buffer) => {\n const length = contentSize(contents);\n const size = chalk.gray`(${prettyBytes(length)})`;\n return size;\n };\n\n if (routeEntries.length) {\n const plural = routeEntries.length === 1 ? '' : 's';\n\n Log.log('');\n Log.log(chalk.bold`Exporting ${routeEntries.length} static route${plural}:`);\n\n for (const [, assets] of routeEntries.sort((a, b) => a[0].length - b[0].length)) {\n const id = assets.routeId!;\n Log.log('/' + (id === '' ? chalk.gray(' (index)') : id), sizeStr(assets.contents));\n }\n }\n\n const assetGroups = [...groups.entries()].sort((a, b) => a[0].localeCompare(b[0])) as [\n string,\n [string, ExportAssetDescriptor][],\n ][];\n\n if (assetGroups.length) {\n const totalAssets = assetGroups.reduce((sum, [, assets]) => sum + assets.length, 0);\n const plural = totalAssets === 1 ? '' : 's';\n\n Log.log('');\n Log.log(chalk.bold`Exporting ${totalAssets} asset${plural}:`);\n\n for (const [assetId, assets] of assetGroups) {\n const averageContentSize =\n assets.reduce((sum, [, { contents }]) => sum + contentSize(contents), 0) / assets.length;\n Log.log(\n assetId,\n chalk.gray(\n `(${[\n assets.length > 1 ? `${assets.length} variations` : '',\n `${prettyBytes(averageContentSize)}`,\n ]\n .filter(Boolean)\n .join(' | ')})`\n )\n );\n }\n }\n\n const bundles: Map<string, [string, ExportAssetDescriptor][]> = new Map();\n const other: [string, ExportAssetDescriptor][] = [];\n\n remainingEntries.forEach(([filepath, asset]) => {\n if (!filepath.match(/_expo\\/static\\//)) {\n other.push([filepath, asset]);\n } else {\n const platform = filepath.match(/_expo\\/static\\/js\\/([^/]+)\\//)?.[1] ?? 'web';\n if (!bundles.has(platform)) bundles.set(platform, []);\n\n bundles.get(platform)!.push([filepath, asset]);\n }\n });\n\n [...bundles.entries()].forEach(([platform, assets]) => {\n Log.log('');\n const plural = assets.length === 1 ? '' : 's';\n Log.log(chalk.bold`Exporting ${assets.length} bundle${plural} for ${platform}:`);\n\n const allAssets = assets.sort((a, b) => a[0].localeCompare(b[0]));\n while (allAssets.length) {\n const [filePath, asset] = allAssets.shift()!;\n Log.log(filePath, sizeStr(asset.contents));\n if (filePath.match(/\\.(js|hbc)$/)) {\n // Get source map\n const sourceMapIndex = allAssets.findIndex(([fp]) => fp === filePath + '.map');\n if (sourceMapIndex !== -1) {\n const [sourceMapFilePath, sourceMapAsset] = allAssets.splice(sourceMapIndex, 1)[0];\n Log.log(chalk.gray(sourceMapFilePath), sizeStr(sourceMapAsset.contents));\n }\n }\n }\n });\n\n if (other.length) {\n Log.log('');\n const plural = other.length === 1 ? '' : 's';\n Log.log(chalk.bold`Exporting ${other.length} file${plural}:`);\n\n for (const [filePath, asset] of other.sort((a, b) => a[0].localeCompare(b[0]))) {\n Log.log(filePath, sizeStr(asset.contents));\n }\n }\n\n // Decouple logging from writing for better performance.\n\n await Promise.all(\n [...files.entries()]\n .sort(([a], [b]) => a.localeCompare(b))\n .map(async ([file, { contents, targetDomain }]) => {\n // NOTE: Only use `targetDomain` if we have at least one server asset\n const domain = (hasServerOutput && targetDomain) || '';\n const outputPath = path.join(outputDir, domain, file);\n await fs.promises.mkdir(path.dirname(outputPath), { recursive: true });\n await fs.promises.writeFile(outputPath, contents);\n })\n );\n\n Log.log('');\n}\n\nfunction groupBy<T>(array: T[], key: (item: T) => string): Map<string, T[]> {\n const map = new Map<string, T[]>();\n array.forEach((item) => {\n const group = key(item);\n const list = map.get(group) ?? [];\n list.push(item);\n map.set(group, list);\n });\n return map;\n}\n\n// TODO: Move source map modification to the serializer\nexport function getFilesFromSerialAssets(\n resources: SerialAsset[],\n {\n includeSourceMaps,\n files = new Map(),\n platform,\n }: {\n includeSourceMaps: boolean;\n files?: ExportAssetMap;\n platform?: string;\n }\n) {\n resources.forEach((resource) => {\n files.set(resource.filename, {\n contents: resource.source,\n originFilename: resource.originFilename,\n targetDomain: platform === 'web' ? 'client' : undefined,\n });\n });\n\n return files;\n}\n"],"names":["persistMetroFilesAsync","getFilesFromSerialAssets","files","outputDir","size","fs","mkdirSync","path","join","recursive","assetEntries","routeEntries","remainingEntries","hasServerOutput","asset","entries","targetDomain","assetId","push","routeId","groups","groupBy","contentSize","contents","length","Buffer","byteLength","sizeStr","chalk","gray","prettyBytes","plural","Log","log","bold","assets","sort","a","b","id","assetGroups","localeCompare","totalAssets","reduce","sum","averageContentSize","filter","Boolean","bundles","Map","other","forEach","filepath","match","platform","has","set","get","allAssets","filePath","shift","sourceMapIndex","findIndex","fp","sourceMapFilePath","sourceMapAsset","splice","Promise","all","map","file","domain","outputPath","promises","mkdir","dirname","writeFile","array","key","item","group","list","resources","includeSourceMaps","resource","filename","source","originFilename","undefined"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IA6CsBA,sBAAsB,MAAtBA,sBAAsB;IAyJ5BC,wBAAwB,MA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GAAG,QAAQ,GAAGkC,SAAS;SACxD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAOtF,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -79,14 +79,7 @@ async function startBundlerAsync(projectRoot, { port , headless , scheme }) {
|
|
|
79
79
|
scheme
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
|
-
const devServerManager =
|
|
83
|
-
await devServerManager.startAsync([
|
|
84
|
-
{
|
|
85
|
-
// TODO: Allow swapping this value for another bundler.
|
|
86
|
-
type: "metro",
|
|
87
|
-
options
|
|
88
|
-
},
|
|
89
|
-
]);
|
|
82
|
+
const devServerManager = await _devServerManager.DevServerManager.startMetroAsync(projectRoot, options);
|
|
90
83
|
// Present the Terminal UI.
|
|
91
84
|
if (!headless && (0, _interactive.isInteractive)()) {
|
|
92
85
|
// Only read the config if we are going to use the results.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/run/startBundler.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { startInterfaceAsync } from '../start/interface/startInterface';\nimport { BundlerStartOptions } from '../start/server/BundlerDevServer';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { env } from '../utils/env';\nimport { isInteractive } from '../utils/interactive';\n\nexport async function startBundlerAsync(\n projectRoot: string,\n {\n port,\n headless,\n scheme,\n }: {\n port: number;\n headless?: boolean;\n scheme?: string;\n }\n): Promise<DevServerManager> {\n const options: BundlerStartOptions = {\n port,\n headless,\n devClient: true,\n minify: false,\n\n location: {\n scheme,\n },\n };\n\n const devServerManager =
|
|
1
|
+
{"version":3,"sources":["../../../src/run/startBundler.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport chalk from 'chalk';\n\nimport * as Log from '../log';\nimport { startInterfaceAsync } from '../start/interface/startInterface';\nimport { BundlerStartOptions } from '../start/server/BundlerDevServer';\nimport { DevServerManager } from '../start/server/DevServerManager';\nimport { env } from '../utils/env';\nimport { isInteractive } from '../utils/interactive';\n\nexport async function startBundlerAsync(\n projectRoot: string,\n {\n port,\n headless,\n scheme,\n }: {\n port: number;\n headless?: boolean;\n scheme?: string;\n }\n): Promise<DevServerManager> {\n const options: BundlerStartOptions = {\n port,\n headless,\n devClient: true,\n minify: false,\n\n location: {\n scheme,\n },\n };\n\n const devServerManager = await DevServerManager.startMetroAsync(projectRoot, options);\n\n // Present the Terminal UI.\n if (!headless && isInteractive()) {\n // Only read the config if we are going to use the results.\n const { exp } = getConfig(projectRoot, {\n // We don't need very many fields here, just use the lightest possible read.\n skipSDKVersionRequirement: true,\n skipPlugins: true,\n });\n await startInterfaceAsync(devServerManager, {\n platforms: exp.platforms ?? [],\n });\n } else {\n // Display the server location in CI...\n const url = devServerManager.getDefaultDevServer()?.getDevServerUrl();\n\n if (url) {\n if (env.__EXPO_E2E_TEST) {\n // Print the URL to stdout for tests\n console.info(`[__EXPO_E2E_TEST:server] ${JSON.stringify({ url })}`);\n }\n Log.log(chalk`Waiting on {underline ${url}}`);\n }\n }\n\n if (!options.headless) {\n await devServerManager.watchEnvironmentVariables();\n await devServerManager.bootstrapTypeScriptAsync();\n }\n\n return devServerManager;\n}\n"],"names":["startBundlerAsync","projectRoot","port","headless","scheme","options","devClient","minify","location","devServerManager","DevServerManager","startMetroAsync","isInteractive","exp","getConfig","skipSDKVersionRequirement","skipPlugins","startInterfaceAsync","platforms","url","getDefaultDevServer","getDevServerUrl","env","__EXPO_E2E_TEST","console","info","JSON","stringify","Log","log","chalk","watchEnvironmentVariables","bootstrapTypeScriptAsync"],"mappings":"AAAA;;;;+BAUsBA,mBAAiB;;aAAjBA,iBAAiB;;;yBAVb,cAAc;;;;;;;8DACtB,OAAO;;;;;;2DAEJ,QAAQ;gCACO,mCAAmC;kCAEtC,kCAAkC;qBAC/C,cAAc;6BACJ,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7C,eAAeA,iBAAiB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C,IAAAA,MAAK,EAAA,QAAA,CAAA,CAAC,sBAAsB,EAAEX,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,IAAI,CAACd,OAAO,CAACF,QAAQ,EAAE;QACrB,MAAMM,gBAAgB,CAACsB,yBAAyB,EAAE,CAAC;QACnD,MAAMtB,gBAAgB,CAACuB,wBAAwB,EAAE,CAAC;IACpD,CAAC;IAED,OAAOvB,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/platforms/DeviceManager.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as Log from '../../log';\n\n/** An abstract class for interacting with a native device. */\nexport abstract class DeviceManager<IDevice> {\n constructor(public device: IDevice) {}\n\n abstract get name(): string;\n\n abstract get identifier(): string;\n\n logOpeningUrl(url: string) {\n Log.log(chalk`\\u203A Opening {underline ${url}} on {bold ${this.name}}`);\n }\n\n abstract startAsync(): Promise<IDevice>;\n\n abstract getAppVersionAsync(\n applicationId: string,\n options?: { containerPath?: string }\n ): Promise<string | null>;\n\n abstract installAppAsync(binaryPath: string): Promise<void>;\n\n abstract uninstallAppAsync(applicationId: string): Promise<void>;\n\n abstract isAppInstalledAndIfSoReturnContainerPathForIOSAsync(\n applicationId: string\n ): Promise<boolean | string>;\n\n abstract openUrlAsync(url: string): Promise<void>;\n\n abstract activateWindowAsync(): Promise<void>;\n\n abstract ensureExpoGoAsync(sdkVersion: string): Promise<boolean>;\n}\n"],"names":["DeviceManager","constructor","device","logOpeningUrl","url","Log","log","chalk","name"],"mappings":"AAAA;;;;+BAKsBA,eAAa;;aAAbA,aAAa;;;8DALjB,OAAO;;;;;;2DAEJ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGzB,MAAeA,aAAa;IACjCC,YAAmBC,MAAe,CAAE;QAAjBA,cAAAA,MAAe,CAAA;IAAG;IAMrCC,aAAa,CAACC,GAAW,EAAE;QACzBC,IAAG,CAACC,GAAG,CAACC,IAAAA,MAAK,EAAA,QAAA,CAAA,CAAC,0BAA0B,EAAEH,GAAG,CAAC,WAAW,EAAE,IAAI,CAACI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E;
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/platforms/DeviceManager.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as Log from '../../log';\n\n/** An abstract class for interacting with a native device. */\nexport abstract class DeviceManager<IDevice> {\n constructor(public device: IDevice) {}\n\n abstract get name(): string;\n\n abstract get identifier(): string;\n\n logOpeningUrl(url: string) {\n Log.log(chalk`\\u203A Opening {underline ${url}} on {bold ${this.name}}`);\n }\n\n abstract startAsync(): Promise<IDevice>;\n\n abstract getAppVersionAsync(\n applicationId: string,\n options?: { containerPath?: string }\n ): Promise<string | null>;\n\n abstract installAppAsync(binaryPath: string): Promise<void>;\n\n abstract uninstallAppAsync(applicationId: string): Promise<void>;\n\n abstract isAppInstalledAndIfSoReturnContainerPathForIOSAsync(\n applicationId: string\n ): Promise<boolean | string>;\n\n abstract openUrlAsync(url: string, options?: { appId?: string }): Promise<void>;\n\n abstract activateWindowAsync(): Promise<void>;\n\n abstract ensureExpoGoAsync(sdkVersion: string): Promise<boolean>;\n\n abstract getExpoGoAppId(): string;\n}\n"],"names":["DeviceManager","constructor","device","logOpeningUrl","url","Log","log","chalk","name"],"mappings":"AAAA;;;;+BAKsBA,eAAa;;aAAbA,aAAa;;;8DALjB,OAAO;;;;;;2DAEJ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGzB,MAAeA,aAAa;IACjCC,YAAmBC,MAAe,CAAE;QAAjBA,cAAAA,MAAe,CAAA;IAAG;IAMrCC,aAAa,CAACC,GAAW,EAAE;QACzBC,IAAG,CAACC,GAAG,CAACC,IAAAA,MAAK,EAAA,QAAA,CAAA,CAAC,0BAA0B,EAAEH,GAAG,CAAC,WAAW,EAAE,IAAI,CAACI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E;CAwBD"}
|
|
@@ -85,7 +85,9 @@ class PlatformManager {
|
|
|
85
85
|
(0, _assert().default)(sdkVersion, "sdkVersion should be resolved by getConfig");
|
|
86
86
|
const installedExpo = await deviceManager.ensureExpoGoAsync(sdkVersion);
|
|
87
87
|
deviceManager.activateWindowAsync();
|
|
88
|
-
await deviceManager.openUrlAsync(url
|
|
88
|
+
await deviceManager.openUrlAsync(url, {
|
|
89
|
+
appId: deviceManager.getExpoGoAppId()
|
|
90
|
+
});
|
|
89
91
|
await (0, _telemetry.logEventAsync)("Open Url on Device", {
|
|
90
92
|
platform: this.props.platform,
|
|
91
93
|
installedExpo
|
|
@@ -102,6 +104,7 @@ class PlatformManager {
|
|
|
102
104
|
debug(`Opening project in custom runtime: ${url} -- %O`, props);
|
|
103
105
|
var _applicationId;
|
|
104
106
|
// TODO: It's unclear why we do application id validation when opening with a URL
|
|
107
|
+
// NOTE: But having it enables us to allow the deep link to directly open on iOS simulators without the modal.
|
|
105
108
|
const applicationId = (_applicationId = props.applicationId) != null ? _applicationId : await this._getAppIdResolver().getAppIdAsync();
|
|
106
109
|
const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);
|
|
107
110
|
if (!await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId)) {
|
|
@@ -117,7 +120,9 @@ class PlatformManager {
|
|
|
117
120
|
}
|
|
118
121
|
deviceManager.logOpeningUrl(url);
|
|
119
122
|
await deviceManager.activateWindowAsync();
|
|
120
|
-
await deviceManager.openUrlAsync(url
|
|
123
|
+
await deviceManager.openUrlAsync(url, {
|
|
124
|
+
appId: applicationId
|
|
125
|
+
});
|
|
121
126
|
return {
|
|
122
127
|
url
|
|
123
128
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/platforms/PlatformManager.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { AppIdResolver } from './AppIdResolver';\nimport { DeviceManager } from './DeviceManager';\nimport { Log } from '../../log';\nimport { CommandError, UnimplementedError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\nimport { logEventAsync } from '../../utils/telemetry';\n\nconst debug = require('debug')('expo:start:platforms:platformManager') as typeof console.log;\n\nexport interface BaseOpenInCustomProps {\n scheme?: string;\n applicationId?: string | null;\n}\n\nexport interface BaseResolveDeviceProps<IDevice> {\n /** Should prompt the user to select a device. */\n shouldPrompt?: boolean;\n /** The target device to use. */\n device?: IDevice;\n}\n\n/** An abstract class for launching a URL on a device. */\nexport class PlatformManager<\n IDevice,\n IOpenInCustomProps extends BaseOpenInCustomProps = BaseOpenInCustomProps,\n IResolveDeviceProps extends BaseResolveDeviceProps<IDevice> = BaseResolveDeviceProps<IDevice>,\n> {\n constructor(\n protected projectRoot: string,\n protected props: {\n platform: 'ios' | 'android';\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL. */\n getExpoGoUrl: () => string;\n /**\n * Get redirect URL for native disambiguation.\n * @returns a URL like `http://localhost:8081/_expo/loading`\n */\n getRedirectUrl: () => string | null;\n /** Dev Client */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n /** Resolve a device, this function should automatically handle opening the device and asserting any system validations. */\n resolveDeviceAsync: (\n resolver?: Partial<IResolveDeviceProps>\n ) => Promise<DeviceManager<IDevice>>;\n }\n ) {}\n\n /** Returns the project application identifier or asserts that one is not defined. Exposed for testing. */\n _getAppIdResolver(): AppIdResolver {\n throw new UnimplementedError();\n }\n\n /**\n * Get the URL for users intending to launch the project in Expo Go.\n * The CLI will check if the project has a custom dev client and if the redirect page feature is enabled.\n * If both are true, the CLI will return the redirect page URL.\n */\n protected async getExpoGoOrCustomRuntimeUrlAsync(\n deviceManager: DeviceManager<IDevice>\n ): Promise<string> {\n // Determine if the redirect page feature is enabled first since it's the cheapest to check.\n const redirectUrl = this.props.getRedirectUrl();\n if (redirectUrl) {\n // If the redirect page feature is enabled, check if the project has a resolvable native identifier.\n let applicationId;\n try {\n applicationId = await this._getAppIdResolver().getAppIdAsync();\n } catch {\n Log.warn(\n chalk`\\u203A Launching in Expo Go. If you want to use a ` +\n `development build, you need to create and install one first, or, if you already ` +\n chalk`have a build, add {bold ios.bundleIdentifier} and {bold android.package} to ` +\n `this project's app config.\\n${learnMore('https://docs.expo.dev/development/build/')}`\n );\n }\n if (applicationId) {\n debug(`Resolving launch URL: (appId: ${applicationId}, redirect URL: ${redirectUrl})`);\n // NOTE(EvanBacon): This adds considerable amount of time to the command, we should consider removing or memoizing it.\n // Finally determine if the target device has a custom dev client installed.\n if (\n await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId)\n ) {\n return redirectUrl;\n } else {\n // Log a warning if no development build is available on the device, but the\n // interstitial page would otherwise be opened.\n Log.warn(\n chalk`\\u203A The {bold expo-dev-client} package is installed, but a development build is not ` +\n chalk`installed on {bold ${deviceManager.name}}.\\nLaunching in Expo Go. If you want to use a ` +\n `development build, you need to create and install one first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n }\n }\n\n return this.props.getExpoGoUrl();\n }\n\n protected async openProjectInExpoGoAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n const url = await this.getExpoGoOrCustomRuntimeUrlAsync(deviceManager);\n\n deviceManager.logOpeningUrl(url);\n\n // TODO: Expensive, we should only do this once.\n const { exp } = getConfig(this.projectRoot);\n const sdkVersion = exp.sdkVersion;\n assert(sdkVersion, 'sdkVersion should be resolved by getConfig');\n const installedExpo = await deviceManager.ensureExpoGoAsync(sdkVersion);\n\n deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n await logEventAsync('Open Url on Device', {\n platform: this.props.platform,\n installedExpo,\n });\n\n return { url };\n }\n\n private async openProjectInCustomRuntimeAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {},\n props: Partial<IOpenInCustomProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open custom (${Object.entries(props)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ')})`\n );\n\n let url = this.props.getCustomRuntimeUrl({ scheme: props.scheme });\n debug(`Opening project in custom runtime: ${url} -- %O`, props);\n // TODO: It's unclear why we do application id validation when opening with a URL\n const applicationId = props.applicationId ?? (await this._getAppIdResolver().getAppIdAsync());\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n\n if (!(await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId))) {\n throw new CommandError(\n `No development build (${applicationId}) for this project is installed. ` +\n `Please make and install a development build on the device first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n // TODO: Rethink analytics\n await logEventAsync('Open Url on Device', {\n platform: this.props.platform,\n installedExpo: false,\n });\n\n if (!url) {\n url = this._resolveAlternativeLaunchUrl(applicationId, props);\n }\n\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return {\n url,\n };\n }\n\n /** Launch the project on a device given the input runtime. */\n async openAsync(\n options:\n | {\n runtime: 'expo' | 'web';\n }\n | {\n runtime: 'custom';\n props?: Partial<IOpenInCustomProps>;\n },\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open (runtime: ${options.runtime}, platform: ${this.props.platform}, device: %O, shouldPrompt: ${resolveSettings.shouldPrompt})`,\n resolveSettings.device\n );\n if (options.runtime === 'expo') {\n return this.openProjectInExpoGoAsync(resolveSettings);\n } else if (options.runtime === 'web') {\n return this.openWebProjectAsync(resolveSettings);\n } else if (options.runtime === 'custom') {\n return this.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n } else {\n throw new CommandError(`Invalid runtime target: ${options.runtime}`);\n }\n }\n\n /** Open the current web project (Webpack) in a device . */\n private async openWebProjectAsync(resolveSettings: Partial<IResolveDeviceProps> = {}): Promise<{\n url: string;\n }> {\n const url = this.props.getDevServerUrl();\n assert(url, 'Dev server is not running.');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return { url };\n }\n\n /** If the launch URL cannot be determined (`custom` runtimes) then an alternative string can be provided to open the device. Often a device ID or activity to launch. Exposed for testing. */\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props: Partial<IOpenInCustomProps> = {}\n ): string {\n throw new UnimplementedError();\n }\n}\n"],"names":["PlatformManager","debug","require","constructor","projectRoot","props","_getAppIdResolver","UnimplementedError","getExpoGoOrCustomRuntimeUrlAsync","deviceManager","redirectUrl","getRedirectUrl","applicationId","getAppIdAsync","Log","warn","chalk","learnMore","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","name","getExpoGoUrl","openProjectInExpoGoAsync","resolveSettings","resolveDeviceAsync","url","logOpeningUrl","exp","getConfig","sdkVersion","assert","installedExpo","ensureExpoGoAsync","activateWindowAsync","openUrlAsync","logEventAsync","platform","openProjectInCustomRuntimeAsync","Object","entries","map","k","v","join","getCustomRuntimeUrl","scheme","CommandError","_resolveAlternativeLaunchUrl","openAsync","options","runtime","shouldPrompt","device","openWebProjectAsync","getDevServerUrl"],"mappings":"AAAA;;;;+BA0BaA,iBAAe;;aAAfA,eAAe;;;yBA1BF,cAAc;;;;;;;8DACrB,QAAQ;;;;;;;8DACT,OAAO;;;;;;qBAIL,WAAW;wBACkB,oBAAoB;sBAC3C,kBAAkB;2BACd,uBAAuB;;;;;;AAErD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAetF,MAAMF,eAAe;IAK1BG,YACYC,WAAmB,EACnBC,KAiBT,CACD;QAnBUD,mBAAAA,W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ACD,eAAe,CAAC,AAAC;QAC3Eb,aAAa,CAACgB,aAAa,CAACD,GAAG,CAAC,CAAC;QACjC,MAAMf,aAAa,CAACuB,mBAAmB,EAAE,CAAC;QAC1C,MAAMvB,aAAa,CAACwB,YAAY,CAACT,GAAG,CAAC,CAAC;QAEtC,OAAO;YAAEA,GAAG;SAAE,CAAC;IACjB;IAEA,4LAA4L,GAC5LsB,4BAA4B,CAC1BlC,aAAqB,EACrBP,KAAkC,GAAG,EAAE,EAC/B;QACR,MAAM,IAAIE,OAAkB,mBAAA,EAAE,CAAC;IACjC;CACD"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/platforms/PlatformManager.ts"],"sourcesContent":["import { getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { AppIdResolver } from './AppIdResolver';\nimport { DeviceManager } from './DeviceManager';\nimport { Log } from '../../log';\nimport { CommandError, UnimplementedError } from '../../utils/errors';\nimport { learnMore } from '../../utils/link';\nimport { logEventAsync } from '../../utils/telemetry';\n\nconst debug = require('debug')('expo:start:platforms:platformManager') as typeof console.log;\n\nexport interface BaseOpenInCustomProps {\n scheme?: string;\n applicationId?: string | null;\n}\n\nexport interface BaseResolveDeviceProps<IDevice> {\n /** Should prompt the user to select a device. */\n shouldPrompt?: boolean;\n /** The target device to use. */\n device?: IDevice;\n}\n\n/** An abstract class for launching a URL on a device. */\nexport class PlatformManager<\n IDevice,\n IOpenInCustomProps extends BaseOpenInCustomProps = BaseOpenInCustomProps,\n IResolveDeviceProps extends BaseResolveDeviceProps<IDevice> = BaseResolveDeviceProps<IDevice>,\n> {\n constructor(\n protected projectRoot: string,\n protected props: {\n platform: 'ios' | 'android';\n /** Get the base URL for the dev server hosting this platform manager. */\n getDevServerUrl: () => string | null;\n /** Expo Go URL. */\n getExpoGoUrl: () => string;\n /**\n * Get redirect URL for native disambiguation.\n * @returns a URL like `http://localhost:8081/_expo/loading`\n */\n getRedirectUrl: () => string | null;\n /** Dev Client */\n getCustomRuntimeUrl: (props?: { scheme?: string }) => string | null;\n /** Resolve a device, this function should automatically handle opening the device and asserting any system validations. */\n resolveDeviceAsync: (\n resolver?: Partial<IResolveDeviceProps>\n ) => Promise<DeviceManager<IDevice>>;\n }\n ) {}\n\n /** Returns the project application identifier or asserts that one is not defined. Exposed for testing. */\n _getAppIdResolver(): AppIdResolver {\n throw new UnimplementedError();\n }\n\n /**\n * Get the URL for users intending to launch the project in Expo Go.\n * The CLI will check if the project has a custom dev client and if the redirect page feature is enabled.\n * If both are true, the CLI will return the redirect page URL.\n */\n protected async getExpoGoOrCustomRuntimeUrlAsync(\n deviceManager: DeviceManager<IDevice>\n ): Promise<string> {\n // Determine if the redirect page feature is enabled first since it's the cheapest to check.\n const redirectUrl = this.props.getRedirectUrl();\n if (redirectUrl) {\n // If the redirect page feature is enabled, check if the project has a resolvable native identifier.\n let applicationId;\n try {\n applicationId = await this._getAppIdResolver().getAppIdAsync();\n } catch {\n Log.warn(\n chalk`\\u203A Launching in Expo Go. If you want to use a ` +\n `development build, you need to create and install one first, or, if you already ` +\n chalk`have a build, add {bold ios.bundleIdentifier} and {bold android.package} to ` +\n `this project's app config.\\n${learnMore('https://docs.expo.dev/development/build/')}`\n );\n }\n if (applicationId) {\n debug(`Resolving launch URL: (appId: ${applicationId}, redirect URL: ${redirectUrl})`);\n // NOTE(EvanBacon): This adds considerable amount of time to the command, we should consider removing or memoizing it.\n // Finally determine if the target device has a custom dev client installed.\n if (\n await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId)\n ) {\n return redirectUrl;\n } else {\n // Log a warning if no development build is available on the device, but the\n // interstitial page would otherwise be opened.\n Log.warn(\n chalk`\\u203A The {bold expo-dev-client} package is installed, but a development build is not ` +\n chalk`installed on {bold ${deviceManager.name}}.\\nLaunching in Expo Go. If you want to use a ` +\n `development build, you need to create and install one first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n }\n }\n\n return this.props.getExpoGoUrl();\n }\n\n protected async openProjectInExpoGoAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n const url = await this.getExpoGoOrCustomRuntimeUrlAsync(deviceManager);\n\n deviceManager.logOpeningUrl(url);\n\n // TODO: Expensive, we should only do this once.\n const { exp } = getConfig(this.projectRoot);\n const sdkVersion = exp.sdkVersion;\n assert(sdkVersion, 'sdkVersion should be resolved by getConfig');\n const installedExpo = await deviceManager.ensureExpoGoAsync(sdkVersion);\n\n deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url, { appId: deviceManager.getExpoGoAppId() });\n\n await logEventAsync('Open Url on Device', {\n platform: this.props.platform,\n installedExpo,\n });\n\n return { url };\n }\n\n private async openProjectInCustomRuntimeAsync(\n resolveSettings: Partial<IResolveDeviceProps> = {},\n props: Partial<IOpenInCustomProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open custom (${Object.entries(props)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ')})`\n );\n\n let url = this.props.getCustomRuntimeUrl({ scheme: props.scheme });\n debug(`Opening project in custom runtime: ${url} -- %O`, props);\n // TODO: It's unclear why we do application id validation when opening with a URL\n // NOTE: But having it enables us to allow the deep link to directly open on iOS simulators without the modal.\n const applicationId = props.applicationId ?? (await this._getAppIdResolver().getAppIdAsync());\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n\n if (!(await deviceManager.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId))) {\n throw new CommandError(\n `No development build (${applicationId}) for this project is installed. ` +\n `Please make and install a development build on the device first.\\n${learnMore(\n 'https://docs.expo.dev/development/build/'\n )}`\n );\n }\n\n // TODO: Rethink analytics\n await logEventAsync('Open Url on Device', {\n platform: this.props.platform,\n installedExpo: false,\n });\n\n if (!url) {\n url = this._resolveAlternativeLaunchUrl(applicationId, props);\n }\n\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n\n await deviceManager.openUrlAsync(url, {\n appId: applicationId,\n });\n\n return {\n url,\n };\n }\n\n /** Launch the project on a device given the input runtime. */\n async openAsync(\n options:\n | {\n runtime: 'expo' | 'web';\n }\n | {\n runtime: 'custom';\n props?: Partial<IOpenInCustomProps>;\n },\n resolveSettings: Partial<IResolveDeviceProps> = {}\n ): Promise<{ url: string }> {\n debug(\n `open (runtime: ${options.runtime}, platform: ${this.props.platform}, device: %O, shouldPrompt: ${resolveSettings.shouldPrompt})`,\n resolveSettings.device\n );\n if (options.runtime === 'expo') {\n return this.openProjectInExpoGoAsync(resolveSettings);\n } else if (options.runtime === 'web') {\n return this.openWebProjectAsync(resolveSettings);\n } else if (options.runtime === 'custom') {\n return this.openProjectInCustomRuntimeAsync(resolveSettings, options.props);\n } else {\n throw new CommandError(`Invalid runtime target: ${options.runtime}`);\n }\n }\n\n /** Open the current web project (Webpack) in a device . */\n private async openWebProjectAsync(resolveSettings: Partial<IResolveDeviceProps> = {}): Promise<{\n url: string;\n }> {\n const url = this.props.getDevServerUrl();\n assert(url, 'Dev server is not running.');\n\n const deviceManager = await this.props.resolveDeviceAsync(resolveSettings);\n deviceManager.logOpeningUrl(url);\n await deviceManager.activateWindowAsync();\n await deviceManager.openUrlAsync(url);\n\n return { url };\n }\n\n /** If the launch URL cannot be determined (`custom` runtimes) then an alternative string can be provided to open the device. Often a device ID or activity to launch. Exposed for testing. */\n _resolveAlternativeLaunchUrl(\n applicationId: string,\n props: Partial<IOpenInCustomProps> = {}\n ): string {\n throw new UnimplementedError();\n }\n}\n"],"names":["PlatformManager","debug","require","constructor","projectRoot","props","_getAppIdResolver","UnimplementedError","getExpoGoOrCustomRuntimeUrlAsync","deviceManager","redirectUrl","getRedirectUrl","applicationId","getAppIdAsync","Log","warn","chalk","learnMore","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","name","getExpoGoUrl","openProjectInExpoGoAsync","resolveSettings","resolveDeviceAsync","url","logOpeningUrl","exp","getConfig","sdkVersion","assert","installedExpo","ensureExpoGoAsync","activateWindowAsync","openUrlAsync","appId","getExpoGoAppId","logEventAsync","platform","openProjectInCustomRuntimeAsync","Object","entries","map","k","v","join","getCustomRuntimeUrl","scheme","CommandError","_resolveAlternativeLaunchUrl","openAsync","options","runtime","shouldPrompt","device","openWebProjectAsync","getDevServerUrl"],"mappings":"AAAA;;;;+BA0BaA,iBAAe;;aAAfA,eAAe;;;yBA1BF,cAAc;;;;;;;8DACrB,QAAQ;;;;;;;8DACT,OAAO;;;;;;qBAIL,WAAW;wBACkB,oBAAoB;sBAC3C,kBAAkB;2BACd,uBAAuB;;;;;;AAErD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAetF,MAAMF,eAAe;IAK1BG,YACYC,WAAmB,EACnBC,KAiBT,CACD;QAnBUD,mBAAAA,WAAmB,CAAA;QACnBC,aAAAA,KAiBT,CAAA;IACA;IAEH,wGAAwG,GACxGC,iBAAiB,GAAkB;QACjC,MAAM,IAAIC,OAAkB,mBAAA,EAAE,CAAC;IACjC;IAEA;;;;GAIC,SACeC,gCAAgC,CAC9CC,aAAqC,EACpB;QACjB,4FAA4F;QAC5F,MAAMC,WAAW,GAAG,IAAI,CAACL,KAAK,CAACM,cAAc,EAAE,AAAC;QAChD,IAAID,WAAW,EAAE;YACf,oGAAoG;YACpG,IAAIE,aAAa,AAAC;YAClB,IAAI;gBACFA,aAAa,GAAG,MAAM,IAAI,CAACN,iBAAiB,EAAE,CAACO,aAAa,EAAE,CAAC;YACjE,EAAE,OAAM;gBACNC,IAAG,IAAA,CAACC,IAAI,CACNC,IAAAA,MAAK,EAAA,QAAA,CAAA,CAAC,kDAAkD,CAAC,GACvD,CAAC,gFAAgF,CAAC,GAClFA,IAAAA,MAAK,EAAA,QAAA,CAAA,CAAC,4EAA4E,CAAC,GACnF,CAAC,4BAA4B,EAAEC,IAAAA,KAAS,UAAA,EAAC,0CAA0C,CAAC,C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,OAAO,IAAI4B,OAAO,CAACC,OAAO,KAAK,KAAK,EAAE;YACpC,OAAO,IAAI,CAACG,mBAAmB,CAAChC,eAAe,CAAC,CAAC;QACnD,OAAO,IAAI4B,OAAO,CAACC,OAAO,KAAK,QAAQ,EAAE;YACvC,OAAO,IAAI,CAACb,+BAA+B,CAAChB,eAAe,EAAE4B,OAAO,CAAC7C,KAAK,CAAC,CAAC;QAC9E,OAAO;YACL,MAAM,IAAI0C,OAAY,aAAA,CAAC,CAAC,wBAAwB,EAAEG,OAAO,CAACC,OAAO,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC;IACH;IAEA,yDAAyD,SAC3CG,mBAAmB,CAAChC,eAA6C,GAAG,EAAE,EAEjF;QACD,MAAME,GAAG,GAAG,IAAI,CAACnB,KAAK,CAACkD,eAAe,EAAE,AAAC;QACzC1B,IAAAA,OAAM,EAAA,QAAA,EAACL,GAAG,EAAE,4BAA4B,CAAC,CAAC;QAE1C,MAAMf,aAAa,GAAG,MAAM,IAAI,CAACJ,KAAK,CAACkB,kBAAkB,CAACD,eAAe,CAAC,AAAC;QAC3Eb,aAAa,CAACgB,aAAa,CAACD,GAAG,CAAC,CAAC;QACjC,MAAMf,aAAa,CAACuB,mBAAmB,EAAE,CAAC;QAC1C,MAAMvB,aAAa,CAACwB,YAAY,CAACT,GAAG,CAAC,CAAC;QAEtC,OAAO;YAAEA,GAAG;SAAE,CAAC;IACjB;IAEA,4LAA4L,GAC5LwB,4BAA4B,CAC1BpC,aAAqB,EACrBP,KAAkC,GAAG,EAAE,EAC/B;QACR,MAAM,IAAIE,OAAkB,mBAAA,EAAE,CAAC;IACjC;CACD"}
|
|
@@ -206,6 +206,9 @@ class AndroidDeviceManager extends _deviceManager.DeviceManager {
|
|
|
206
206
|
// Bring the emulator window to the front on macos devices.
|
|
207
207
|
await (0, _activateWindow.activateWindowAsync)(this.device);
|
|
208
208
|
}
|
|
209
|
+
getExpoGoAppId() {
|
|
210
|
+
return EXPO_GO_APPLICATION_IDENTIFIER;
|
|
211
|
+
}
|
|
209
212
|
async ensureExpoGoAsync(sdkVersion) {
|
|
210
213
|
const installer = new _expoGoInstaller.ExpoGoInstaller("android", EXPO_GO_APPLICATION_IDENTIFIER, sdkVersion);
|
|
211
214
|
return installer.ensureAsync(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/platforms/android/AndroidDeviceManager.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport { activateWindowAsync } from './activateWindow';\nimport * as AndroidDebugBridge from './adb';\nimport { startDeviceAsync } from './emulator';\nimport { getDevicesAsync } from './getDevices';\nimport { promptForDeviceAsync } from './promptAndroidDevice';\nimport * as Log from '../../../log';\nimport { AbortCommandError, CommandError } from '../../../utils/errors';\nimport { validateUrl } from '../../../utils/url';\nimport { DeviceManager } from '../DeviceManager';\nimport { ExpoGoInstaller } from '../ExpoGoInstaller';\nimport { BaseResolveDeviceProps } from '../PlatformManager';\n\nconst EXPO_GO_APPLICATION_IDENTIFIER = 'host.exp.exponent';\n\nexport class AndroidDeviceManager extends DeviceManager<AndroidDebugBridge.Device> {\n static async resolveFromNameAsync(name: string): Promise<AndroidDeviceManager> {\n const devices = await getDevicesAsync();\n const device = devices.find((device) => device.name === name);\n\n if (!device) {\n throw new CommandError('Could not find device with name: ' + name);\n }\n return AndroidDeviceManager.resolveAsync({ device, shouldPrompt: false });\n }\n\n static async resolveAsync({\n device,\n shouldPrompt,\n }: BaseResolveDeviceProps<AndroidDebugBridge.Device> = {}): Promise<AndroidDeviceManager> {\n if (device) {\n const manager = new AndroidDeviceManager(device);\n if (!(await manager.attemptToStartAsync())) {\n throw new AbortCommandError();\n }\n return manager;\n }\n\n const devices = await getDevicesAsync();\n const _device = shouldPrompt ? await promptForDeviceAsync(devices) : devices[0];\n return AndroidDeviceManager.resolveAsync({ device: _device, shouldPrompt: false });\n }\n\n get name() {\n // TODO: Maybe strip `_` from the device name?\n return this.device.name;\n }\n\n get identifier(): string {\n return this.device.pid ?? 'unknown';\n }\n\n async getAppVersionAsync(applicationId: string): Promise<string | null> {\n const info = await AndroidDebugBridge.getPackageInfoAsync(this.device, {\n appId: applicationId,\n });\n\n const regex = /versionName=([0-9.]+)/;\n return regex.exec(info)?.[1] ?? null;\n }\n\n protected async attemptToStartAsync(): Promise<AndroidDebugBridge.Device | null> {\n // TODO: Add a light-weight method for checking since a device could disconnect.\n if (!(await AndroidDebugBridge.isDeviceBootedAsync(this.device))) {\n this.device = await startDeviceAsync(this.device);\n }\n\n if (this.device.isAuthorized === false) {\n AndroidDebugBridge.logUnauthorized(this.device);\n return null;\n }\n\n return this.device;\n }\n\n async startAsync(): Promise<AndroidDebugBridge.Device> {\n const device = await this.attemptToStartAsync();\n assert(device, `Failed to boot emulator.`);\n return this.device;\n }\n\n async installAppAsync(binaryPath: string) {\n await AndroidDebugBridge.installAsync(this.device, {\n filePath: binaryPath,\n });\n }\n\n async uninstallAppAsync(appId: string) {\n // we need to check if the app is installed, else we might bump into \"Failure [DELETE_FAILED_INTERNAL_ERROR]\"\n const isInstalled = await this.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(appId);\n if (!isInstalled) {\n return;\n }\n\n try {\n await AndroidDebugBridge.uninstallAsync(this.device, {\n appId,\n });\n } catch (e) {\n Log.error(\n `Could not uninstall app \"${appId}\" from your device, please uninstall it manually and try again.`\n );\n throw e;\n }\n }\n\n /**\n * @param launchActivity Activity to launch `[application identifier]/.[main activity name]`, ex: `com.bacon.app/.MainActivity`\n */\n async launchActivityAsync(launchActivity: string): Promise<string> {\n try {\n return await AndroidDebugBridge.launchActivityAsync(this.device, {\n launchActivity,\n });\n } catch (error: any) {\n let errorMessage = `Couldn't open Android app with activity \"${launchActivity}\" on device \"${this.name}\".`;\n if (error instanceof CommandError && error.code === 'APP_NOT_INSTALLED') {\n errorMessage += `\\nThe app might not be installed, try installing it with: ${chalk.bold(\n `npx expo run:android -d ${this.name}`\n )}`;\n }\n errorMessage += chalk.gray(`\\n${error.message}`);\n error.message = errorMessage;\n throw error;\n }\n }\n\n async isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId: string) {\n return await AndroidDebugBridge.isPackageInstalledAsync(this.device, applicationId);\n }\n\n async openUrlAsync(url: string) {\n // Non-compliant URLs will be treated as application identifiers.\n if (!validateUrl(url, { requireProtocol: true })) {\n await this.launchActivityAsync(url);\n return;\n }\n\n const parsed = new URL(url);\n\n if (parsed.protocol === 'exp:') {\n // NOTE(brentvatne): temporary workaround! launch Expo Go first, then\n // launch the project!\n // https://github.com/expo/expo/issues/7772\n // adb shell monkey -p host.exp.exponent -c android.intent.category.LAUNCHER 1\n // Note: this is not needed in Expo Development Client, it only applies to Expo Go\n await AndroidDebugBridge.openAppIdAsync(\n { pid: this.device.pid },\n { applicationId: EXPO_GO_APPLICATION_IDENTIFIER }\n );\n }\n\n await AndroidDebugBridge.openUrlAsync({ pid: this.device.pid }, { url });\n }\n\n async activateWindowAsync() {\n // Bring the emulator window to the front on macos devices.\n await activateWindowAsync(this.device);\n }\n\n async ensureExpoGoAsync(sdkVersion: string): Promise<boolean> {\n const installer = new ExpoGoInstaller('android', EXPO_GO_APPLICATION_IDENTIFIER, sdkVersion);\n return installer.ensureAsync(this);\n }\n}\n"],"names":["AndroidDeviceManager","EXPO_GO_APPLICATION_IDENTIFIER","DeviceManager","resolveFromNameAsync","name","devices","getDevicesAsync","device","find","CommandError","resolveAsync","shouldPrompt","manager","attemptToStartAsync","AbortCommandError","_device","promptForDeviceAsync","identifier","pid","getAppVersionAsync","applicationId","regex","info","AndroidDebugBridge","getPackageInfoAsync","appId","exec","isDeviceBootedAsync","startDeviceAsync","isAuthorized","logUnauthorized","startAsync","assert","installAppAsync","binaryPath","installAsync","filePath","uninstallAppAsync","isInstalled","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","uninstallAsync","e","Log","error","launchActivityAsync","launchActivity","errorMessage","code","chalk","bold","gray","message","isPackageInstalledAsync","openUrlAsync","url","validateUrl","requireProtocol","parsed","URL","protocol","openAppIdAsync","activateWindowAsync","ensureExpoGoAsync","sdkVersion","installer","ExpoGoInstaller","ensureAsync"],"mappings":"AAAA;;;;+BAiBaA,sBAAoB;;aAApBA,oBAAoB;;;8DAjBd,QAAQ;;;;;;;8DACT,OAAO;;;;;;gCAEW,kBAAkB;2DAClB,OAAO;0BACV,YAAY;4BACb,cAAc;qCACT,uBAAuB;2DACvC,cAAc;wBACa,uBAAuB;qBAC3C,oBAAoB;+BAClB,kBAAkB;iCAChB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGpD,MAAMC,8BAA8B,GAAG,mBAAmB,AAAC;AAEpD,MAAMD,oBAAoB,SAASE,cAAa,cAAA;iBACxCC,oBAAoB,CAACC,IAAY,EAAiC;QAC7E,MAAMC,OAAO,GAAG,MAAMC,IAAAA,WAAe,gBAAA,GAAE,AAAC;QACxC,MAAMC,MAAM,GAAGF,OAAO,CAACG,IAAI,CAAC,CAACD,MAAM,GAAKA,MAAM,CAACH,IAAI,KAAKA,IAAI,CAAC,AAAC;QAE9D,IAAI,CAACG,MAAM,EAAE;YACX,MAAM,IAAIE,OAAY,aAAA,CAAC,mCAAmC,GAAGL,IAAI,CAAC,CAAC;QACrE,CAAC;QACD,OAAOJ,oBAAoB,CAACU,YAAY,CAAC;YAAEH,MAAM;YAAEI,YAAY,EAAE,KAAK;SAAE,CAAC,CAAC;IAC5E;iBAEaD,YAAY,CAAC,EACxBH,MAAM,CAAA,EACNI,YAAY,CAAA,EACsC,GAAG,EAAE,EAAiC;QACxF,IAAIJ,MAAM,EAAE;YACV,MAAMK,OAAO,GAAG,IAAIZ,oBAAoB,CAACO,MAAM,CAAC,AAAC;YACjD,IAAI,CAAE,MAAMK,OAAO,CAACC,mBAAmB,EAAE,AAAC,EAAE;gBAC1C,MAAM,IAAIC,OAAiB,kBAAA,EAAE,CAAC;YAChC,CAAC;YACD,OAAOF,OAAO,CAAC;Q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D,CAAC;QACJ,CAAC;QAED,MAAMsB,IAAkB,CAAC8B,YAAY,CAAC;YAAEnC,GAAG,EAAE,IAAI,CAACX,MAAM,CAACW,GAAG;SAAE,EAAE;YAAEoC,GAAG;SAAE,CAAC,CAAC;IAC3E;UAEMO,mBAAmB,GAAG;QAC1B,2DAA2D;QAC3D,MAAMA,IAAAA,eAAmB,oBAAA,EAAC,IAAI,CAACtD,MAAM,CAAC,CAAC;IACzC;UAEMuD,iBAAiB,CAACC,UAAkB,EAAoB;QAC5D,MAAMC,SAAS,GAAG,IAAIC,gBAAe,gBAAA,CAAC,SAAS,EAAEhE,8BAA8B,EAAE8D,UAAU,CAAC,AAAC;QAC7F,OAAOC,SAAS,CAACE,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC;CACD"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/platforms/android/AndroidDeviceManager.ts"],"sourcesContent":["import assert from 'assert';\nimport chalk from 'chalk';\n\nimport { activateWindowAsync } from './activateWindow';\nimport * as AndroidDebugBridge from './adb';\nimport { startDeviceAsync } from './emulator';\nimport { getDevicesAsync } from './getDevices';\nimport { promptForDeviceAsync } from './promptAndroidDevice';\nimport * as Log from '../../../log';\nimport { AbortCommandError, CommandError } from '../../../utils/errors';\nimport { validateUrl } from '../../../utils/url';\nimport { DeviceManager } from '../DeviceManager';\nimport { ExpoGoInstaller } from '../ExpoGoInstaller';\nimport { BaseResolveDeviceProps } from '../PlatformManager';\n\nconst EXPO_GO_APPLICATION_IDENTIFIER = 'host.exp.exponent';\n\nexport class AndroidDeviceManager extends DeviceManager<AndroidDebugBridge.Device> {\n static async resolveFromNameAsync(name: string): Promise<AndroidDeviceManager> {\n const devices = await getDevicesAsync();\n const device = devices.find((device) => device.name === name);\n\n if (!device) {\n throw new CommandError('Could not find device with name: ' + name);\n }\n return AndroidDeviceManager.resolveAsync({ device, shouldPrompt: false });\n }\n\n static async resolveAsync({\n device,\n shouldPrompt,\n }: BaseResolveDeviceProps<AndroidDebugBridge.Device> = {}): Promise<AndroidDeviceManager> {\n if (device) {\n const manager = new AndroidDeviceManager(device);\n if (!(await manager.attemptToStartAsync())) {\n throw new AbortCommandError();\n }\n return manager;\n }\n\n const devices = await getDevicesAsync();\n const _device = shouldPrompt ? await promptForDeviceAsync(devices) : devices[0];\n return AndroidDeviceManager.resolveAsync({ device: _device, shouldPrompt: false });\n }\n\n get name() {\n // TODO: Maybe strip `_` from the device name?\n return this.device.name;\n }\n\n get identifier(): string {\n return this.device.pid ?? 'unknown';\n }\n\n async getAppVersionAsync(applicationId: string): Promise<string | null> {\n const info = await AndroidDebugBridge.getPackageInfoAsync(this.device, {\n appId: applicationId,\n });\n\n const regex = /versionName=([0-9.]+)/;\n return regex.exec(info)?.[1] ?? null;\n }\n\n protected async attemptToStartAsync(): Promise<AndroidDebugBridge.Device | null> {\n // TODO: Add a light-weight method for checking since a device could disconnect.\n if (!(await AndroidDebugBridge.isDeviceBootedAsync(this.device))) {\n this.device = await startDeviceAsync(this.device);\n }\n\n if (this.device.isAuthorized === false) {\n AndroidDebugBridge.logUnauthorized(this.device);\n return null;\n }\n\n return this.device;\n }\n\n async startAsync(): Promise<AndroidDebugBridge.Device> {\n const device = await this.attemptToStartAsync();\n assert(device, `Failed to boot emulator.`);\n return this.device;\n }\n\n async installAppAsync(binaryPath: string) {\n await AndroidDebugBridge.installAsync(this.device, {\n filePath: binaryPath,\n });\n }\n\n async uninstallAppAsync(appId: string) {\n // we need to check if the app is installed, else we might bump into \"Failure [DELETE_FAILED_INTERNAL_ERROR]\"\n const isInstalled = await this.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(appId);\n if (!isInstalled) {\n return;\n }\n\n try {\n await AndroidDebugBridge.uninstallAsync(this.device, {\n appId,\n });\n } catch (e) {\n Log.error(\n `Could not uninstall app \"${appId}\" from your device, please uninstall it manually and try again.`\n );\n throw e;\n }\n }\n\n /**\n * @param launchActivity Activity to launch `[application identifier]/.[main activity name]`, ex: `com.bacon.app/.MainActivity`\n */\n async launchActivityAsync(launchActivity: string): Promise<string> {\n try {\n return await AndroidDebugBridge.launchActivityAsync(this.device, {\n launchActivity,\n });\n } catch (error: any) {\n let errorMessage = `Couldn't open Android app with activity \"${launchActivity}\" on device \"${this.name}\".`;\n if (error instanceof CommandError && error.code === 'APP_NOT_INSTALLED') {\n errorMessage += `\\nThe app might not be installed, try installing it with: ${chalk.bold(\n `npx expo run:android -d ${this.name}`\n )}`;\n }\n errorMessage += chalk.gray(`\\n${error.message}`);\n error.message = errorMessage;\n throw error;\n }\n }\n\n async isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId: string) {\n return await AndroidDebugBridge.isPackageInstalledAsync(this.device, applicationId);\n }\n\n async openUrlAsync(url: string) {\n // Non-compliant URLs will be treated as application identifiers.\n if (!validateUrl(url, { requireProtocol: true })) {\n await this.launchActivityAsync(url);\n return;\n }\n\n const parsed = new URL(url);\n\n if (parsed.protocol === 'exp:') {\n // NOTE(brentvatne): temporary workaround! launch Expo Go first, then\n // launch the project!\n // https://github.com/expo/expo/issues/7772\n // adb shell monkey -p host.exp.exponent -c android.intent.category.LAUNCHER 1\n // Note: this is not needed in Expo Development Client, it only applies to Expo Go\n await AndroidDebugBridge.openAppIdAsync(\n { pid: this.device.pid },\n { applicationId: EXPO_GO_APPLICATION_IDENTIFIER }\n );\n }\n\n await AndroidDebugBridge.openUrlAsync({ pid: this.device.pid }, { url });\n }\n\n async activateWindowAsync() {\n // Bring the emulator window to the front on macos devices.\n await activateWindowAsync(this.device);\n }\n\n getExpoGoAppId(): string {\n return EXPO_GO_APPLICATION_IDENTIFIER;\n }\n\n async ensureExpoGoAsync(sdkVersion: string): Promise<boolean> {\n const installer = new ExpoGoInstaller('android', EXPO_GO_APPLICATION_IDENTIFIER, sdkVersion);\n return installer.ensureAsync(this);\n }\n}\n"],"names":["AndroidDeviceManager","EXPO_GO_APPLICATION_IDENTIFIER","DeviceManager","resolveFromNameAsync","name","devices","getDevicesAsync","device","find","CommandError","resolveAsync","shouldPrompt","manager","attemptToStartAsync","AbortCommandError","_device","promptForDeviceAsync","identifier","pid","getAppVersionAsync","applicationId","regex","info","AndroidDebugBridge","getPackageInfoAsync","appId","exec","isDeviceBootedAsync","startDeviceAsync","isAuthorized","logUnauthorized","startAsync","assert","installAppAsync","binaryPath","installAsync","filePath","uninstallAppAsync","isInstalled","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","uninstallAsync","e","Log","error","launchActivityAsync","launchActivity","errorMessage","code","chalk","bold","gray","message","isPackageInstalledAsync","openUrlAsync","url","validateUrl","requireProtocol","parsed","URL","protocol","openAppIdAsync","activateWindowAsync","getExpoGoAppId","ensureExpoGoAsync","sdkVersion","installer","ExpoGoInstaller","ensureAsync"],"mappings":"AAAA;;;;+BAiBaA,sBAAoB;;aAApBA,oBAAoB;;;8DAjBd,QAAQ;;;;;;;8DACT,OAAO;;;;;;gCAEW,kBAAkB;2DAClB,OAAO;0BACV,YAAY;4BACb,cAAc;qCACT,uBAAuB;2DACvC,cAAc;wBACa,uBAAuB;qBAC3C,oBAAoB;+BAClB,kBAAkB;iCAChB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGpD,MAAMC,8BAA8B,GAAG,mBAAmB,AAAC;AAEpD,MAAMD,oBAAoB,SAASE,cAAa,cAAA;iBACxCC,oBAAoB,CAACC,IAAY,EAAiC;QAC7E,MAAMC,OAAO,GAAG,MAAMC,IAAAA,WAAe,gBAAA,GAAE,AAAC;QACxC,MAAMC,MAAM,GAAGF,OAAO,CAACG,IAAI,CAAC,CAACD,MAAM,GAAKA,MAAM,CAACH,IAAI,KAAKA,IAAI,CAAC,AAAC;QAE9D,IAAI,CAACG,MAAM,EAAE;YACX,MAAM,IAAIE,OAAY,aAAA,CAAC,mCAAmC,GAAGL,IAAI,CAAC,CAAC;QACrE,CAAC;QACD,OAAOJ,oBAAoB,CAACU,YAAY,CAAC;YAAEH,MAAM;YAAEI,YAAY,EAAE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pC,OAAO;QACT,CAAC;QAED,MAAMG,MAAM,GAAG,IAAIC,GAAG,CAACJ,GAAG,CAAC,AAAC;QAE5B,IAAIG,MAAM,CAACE,QAAQ,KAAK,MAAM,EAAE;YAC9B,qEAAqE;YACrE,sBAAsB;YACtB,2CAA2C;YAC3C,8EAA8E;YAC9E,kFAAkF;YAClF,MAAMpC,IAAkB,CAACqC,cAAc,CACrC;gBAAE1C,GAAG,EAAE,IAAI,CAACX,MAAM,CAACW,GAAG;aAAE,EACxB;gBAAEE,aAAa,EAAEnB,8BAA8B;aAAE,CAClD,CAAC;QACJ,CAAC;QAED,MAAMsB,IAAkB,CAAC8B,YAAY,CAAC;YAAEnC,GAAG,EAAE,IAAI,CAACX,MAAM,CAACW,GAAG;SAAE,EAAE;YAAEoC,GAAG;SAAE,CAAC,CAAC;IAC3E;UAEMO,mBAAmB,GAAG;QAC1B,2DAA2D;QAC3D,MAAMA,IAAAA,eAAmB,oBAAA,EAAC,IAAI,CAACtD,MAAM,CAAC,CAAC;IACzC;IAEAuD,cAAc,GAAW;QACvB,OAAO7D,8BAA8B,CAAC;IACxC;UAEM8D,iBAAiB,CAACC,UAAkB,EAAoB;QAC5D,MAAMC,SAAS,GAAG,IAAIC,gBAAe,gBAAA,CAAC,SAAS,EAAEjE,8BAA8B,EAAE+D,UAAU,CAAC,AAAC;QAC7F,OAAOC,SAAS,CAACE,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC;CACD"}
|
|
@@ -237,7 +237,7 @@ class AppleDeviceManager extends _deviceManager.DeviceManager {
|
|
|
237
237
|
appId
|
|
238
238
|
})) != null ? ref : false;
|
|
239
239
|
}
|
|
240
|
-
async openUrlAsync(url) {
|
|
240
|
+
async openUrlAsync(url, options = {}) {
|
|
241
241
|
// Non-compliant URLs will be treated as application identifiers.
|
|
242
242
|
if (!(0, _url.validateUrl)(url, {
|
|
243
243
|
requireProtocol: true
|
|
@@ -246,7 +246,8 @@ class AppleDeviceManager extends _deviceManager.DeviceManager {
|
|
|
246
246
|
}
|
|
247
247
|
try {
|
|
248
248
|
await _simctl.openUrlAsync(this.device, {
|
|
249
|
-
url
|
|
249
|
+
url,
|
|
250
|
+
appId: options.appId
|
|
250
251
|
});
|
|
251
252
|
} catch (error) {
|
|
252
253
|
// 194 means the device does not conform to a given URL, in this case we'll assume that the desired app is not installed.
|
|
@@ -265,6 +266,9 @@ class AppleDeviceManager extends _deviceManager.DeviceManager {
|
|
|
265
266
|
// TODO: Focus the individual window
|
|
266
267
|
await _osascript().execAsync(`tell application "Simulator" to activate`);
|
|
267
268
|
}
|
|
269
|
+
getExpoGoAppId() {
|
|
270
|
+
return EXPO_GO_BUNDLE_IDENTIFIER;
|
|
271
|
+
}
|
|
268
272
|
async ensureExpoGoAsync(sdkVersion) {
|
|
269
273
|
const installer = new _expoGoInstaller.ExpoGoInstaller("ios", EXPO_GO_BUNDLE_IDENTIFIER, sdkVersion);
|
|
270
274
|
return installer.ensureAsync(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/platforms/ios/AppleDeviceManager.ts"],"sourcesContent":["import * as osascript from '@expo/osascript';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { assertSystemRequirementsAsync } from './assertSystemRequirements';\nimport { ensureSimulatorAppRunningAsync } from './ensureSimulatorAppRunning';\nimport {\n getBestBootedSimulatorAsync,\n getBestUnbootedSimulatorAsync,\n getSelectableSimulatorsAsync,\n} from './getBestSimulator';\nimport { promptAppleDeviceAsync } from './promptAppleDevice';\nimport * as SimControl from './simctl';\nimport { delayAsync, waitForActionAsync } from '../../../utils/delay';\nimport { CommandError } from '../../../utils/errors';\nimport { parsePlistAsync } from '../../../utils/plist';\nimport { validateUrl } from '../../../utils/url';\nimport { DeviceManager } from '../DeviceManager';\nimport { ExpoGoInstaller } from '../ExpoGoInstaller';\nimport { BaseResolveDeviceProps } from '../PlatformManager';\n\nconst debug = require('debug')('expo:start:platforms:ios:AppleDeviceManager') as typeof console.log;\n\nconst EXPO_GO_BUNDLE_IDENTIFIER = 'host.exp.Exponent';\n\n/**\n * Ensure a simulator is booted and the Simulator app is opened.\n * This is where any timeout related error handling should live.\n */\nexport async function ensureSimulatorOpenAsync(\n { udid, osType }: Partial<Pick<SimControl.Device, 'udid' | 'osType'>> = {},\n tryAgain: boolean = true\n): Promise<SimControl.Device> {\n // Use a default simulator if none was specified\n if (!udid) {\n // If a simulator is open, side step the entire booting sequence.\n const simulatorOpenedByApp = await getBestBootedSimulatorAsync({ osType });\n if (simulatorOpenedByApp) {\n return simulatorOpenedByApp;\n }\n\n // Otherwise, find the best possible simulator from user defaults and continue\n const bestUdid = await getBestUnbootedSimulatorAsync({ osType });\n if (!bestUdid) {\n throw new CommandError('No simulators found.');\n }\n udid = bestUdid;\n }\n\n const bootedDevice = await waitForActionAsync({\n action: () => {\n // Just for the type check.\n assert(udid);\n return SimControl.bootAsync({ udid });\n },\n });\n\n if (!bootedDevice) {\n // Give it a second chance, this might not be needed but it could potentially lead to a better UX on slower devices.\n if (tryAgain) {\n return await ensureSimulatorOpenAsync({ udid, osType }, false);\n }\n // TODO: We should eliminate all needs for a timeout error, it's bad UX to get an error about the simulator not starting while the user can clearly see it starting on their slow computer.\n throw new CommandError(\n 'SIMULATOR_TIMEOUT',\n `Simulator didn't boot fast enough. Try opening Simulator first, then running your app.`\n );\n }\n return bootedDevice;\n}\nexport class AppleDeviceManager extends DeviceManager<SimControl.Device> {\n static assertSystemRequirementsAsync = assertSystemRequirementsAsync;\n\n static async resolveAsync({\n device,\n shouldPrompt,\n }: BaseResolveDeviceProps<\n Partial<Pick<SimControl.Device, 'udid' | 'osType'>>\n > = {}): Promise<AppleDeviceManager> {\n if (shouldPrompt) {\n const devices = await getSelectableSimulatorsAsync(device);\n device = await promptAppleDeviceAsync(devices, device?.osType);\n }\n\n const booted = await ensureSimulatorOpenAsync(device);\n return new AppleDeviceManager(booted);\n }\n\n get name() {\n return this.device.name;\n }\n\n get identifier(): string {\n return this.device.udid;\n }\n\n async getAppVersionAsync(\n appId: string,\n { containerPath }: { containerPath?: string } = {}\n ): Promise<string | null> {\n return await SimControl.getInfoPlistValueAsync(this.device, {\n appId,\n key: 'CFBundleShortVersionString',\n containerPath,\n });\n }\n\n async startAsync(): Promise<SimControl.Device> {\n return ensureSimulatorOpenAsync({ osType: this.device.osType, udid: this.device.udid });\n }\n\n async launchApplicationIdAsync(appId: string) {\n try {\n const result = await SimControl.openAppIdAsync(this.device, {\n appId,\n });\n if (result.status === 0) {\n await this.activateWindowAsync();\n } else {\n throw new CommandError(result.stderr);\n }\n } catch (error: any) {\n let errorMessage = `Couldn't open iOS app with ID \"${appId}\" on device \"${this.name}\".`;\n if (error instanceof CommandError && error.code === 'APP_NOT_INSTALLED') {\n if (appId === EXPO_GO_BUNDLE_IDENTIFIER) {\n errorMessage = `Couldn't open Expo Go app on device \"${this.name}\". Please install.`;\n } else {\n errorMessage += `\\nThe app might not be installed, try installing it with: ${chalk.bold(\n `npx expo run:ios -d ${this.device.udid}`\n )}`;\n }\n }\n if (error.stderr) {\n errorMessage += chalk.gray(`\\n${error.stderr}`);\n } else if (error.message) {\n errorMessage += chalk.gray(`\\n${error.message}`);\n }\n throw new CommandError(errorMessage);\n }\n }\n\n async installAppAsync(filePath: string) {\n await SimControl.installAsync(this.device, {\n filePath,\n });\n\n await this.waitForAppInstalledAsync(await this.getApplicationIdFromBundle(filePath));\n }\n\n private async getApplicationIdFromBundle(filePath: string): Promise<string> {\n debug('getApplicationIdFromBundle:', filePath);\n const builtInfoPlistPath = path.join(filePath, 'Info.plist');\n if (fs.existsSync(builtInfoPlistPath)) {\n const { CFBundleIdentifier } = await parsePlistAsync(builtInfoPlistPath);\n debug('getApplicationIdFromBundle: using built Info.plist', CFBundleIdentifier);\n return CFBundleIdentifier;\n }\n debug('getApplicationIdFromBundle: no Info.plist found');\n return EXPO_GO_BUNDLE_IDENTIFIER;\n }\n\n private async waitForAppInstalledAsync(applicationId: string): Promise<boolean> {\n while (true) {\n if (await this.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId)) {\n return true;\n }\n await delayAsync(100);\n }\n }\n\n async uninstallAppAsync(appId: string) {\n await SimControl.uninstallAsync(this.device, {\n appId,\n });\n }\n\n async isAppInstalledAndIfSoReturnContainerPathForIOSAsync(appId: string) {\n return (\n (await SimControl.getContainerPathAsync(this.device, {\n appId,\n })) ?? false\n );\n }\n\n async openUrlAsync(url: string) {\n // Non-compliant URLs will be treated as application identifiers.\n if (!validateUrl(url, { requireProtocol: true })) {\n return await this.launchApplicationIdAsync(url);\n }\n\n try {\n await SimControl.openUrlAsync(this.device, { url });\n } catch (error: any) {\n // 194 means the device does not conform to a given URL, in this case we'll assume that the desired app is not installed.\n if (error.status === 194) {\n // An error was encountered processing the command (domain=NSOSStatusErrorDomain, code=-10814):\n // The operation couldn’t be completed. (OSStatus error -10814.)\n //\n // This can be thrown when no app conforms to the URI scheme that we attempted to open.\n throw new CommandError(\n 'APP_NOT_INSTALLED',\n `Device ${this.device.name} (${this.device.udid}) has no app to handle the URI: ${url}`\n );\n }\n throw error;\n }\n }\n\n async activateWindowAsync() {\n await ensureSimulatorAppRunningAsync(this.device);\n // TODO: Focus the individual window\n await osascript.execAsync(`tell application \"Simulator\" to activate`);\n }\n\n async ensureExpoGoAsync(sdkVersion: string): Promise<boolean> {\n const installer = new ExpoGoInstaller('ios', EXPO_GO_BUNDLE_IDENTIFIER, sdkVersion);\n return installer.ensureAsync(this);\n }\n}\n"],"names":["ensureSimulatorOpenAsync","AppleDeviceManager","debug","require","EXPO_GO_BUNDLE_IDENTIFIER","udid","osType","tryAgain","simulatorOpenedByApp","getBestBootedSimulatorAsync","bestUdid","getBestUnbootedSimulatorAsync","CommandError","bootedDevice","waitForActionAsync","action","assert","SimControl","bootAsync","DeviceManager","assertSystemRequirementsAsync","resolveAsync","device","shouldPrompt","devices","getSelectableSimulatorsAsync","promptAppleDeviceAsync","booted","name","identifier","getAppVersionAsync","appId","containerPath","getInfoPlistValueAsync","key","startAsync","launchApplicationIdAsync","result","openAppIdAsync","status","activateWindowAsync","stderr","error","errorMessage","code","chalk","bold","gray","message","installAppAsync","filePath","installAsync","waitForAppInstalledAsync","getApplicationIdFromBundle","builtInfoPlistPath","path","join","fs","existsSync","CFBundleIdentifier","parsePlistAsync","applicationId","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","delayAsync","uninstallAppAsync","uninstallAsync","getContainerPathAsync","openUrlAsync","url","validateUrl","requireProtocol","ensureSimulatorAppRunningAsync","osascript","execAsync","ensureExpoGoAsync","sdkVersion","installer","ExpoGoInstaller","ensureAsync"],"mappings":"AAAA;;;;;;;;;;;IA+BsBA,wBAAwB,MAAxBA,wBAAwB;IAyCjCC,kBAAkB,MAAlBA,kBAAkB;;;+DAxEJ,iBAAiB;;;;;;;8DACzB,QAAQ;;;;;;;8DACT,OAAO;;;;;;;8DACV,IAAI;;;;;;;8DACF,MAAM;;;;;;0CAEuB,4BAA4B;2CAC3B,6BAA6B;kCAKrE,oBAAoB;mCACY,qBAAqB;8DAChC,UAAU;uBACS,sBAAsB;wBACxC,uBAAuB;uBACpB,sBAAsB;qBAC1B,oBAAoB;+BAClB,kBAAkB;iCAChB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,6CAA6C,CAAC,AAAsB,AAAC;AAEpG,MAAMC,yBAAyB,GAAG,mBAAmB,AAAC;AAM/C,eAAeJ,wBAAwB,CAC5C,EAAEK,IAAI,CAAA,EAAEC,MAAM,CAAA,EAAuD,GAAG,EAAE,EAC1EC,QAAiB,GAAG,IAAI,EACI;IAC5B,gDAAgD;IAChD,IAAI,CAACF,IAAI,EAAE;QACT,iEAAiE;QACjE,MAAMG,oBAAoB,GAAG,MAAMC,IAAAA,iBAA2B,4BAAA,EAAC;YAAEH,MAAM;SAAE,CAAC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,OAAU,CAACkD,YAAY,CAAC,IAAI,CAAC7C,MAAM,EAAE;gBAAE8C,GAAG;aAAE,CAAC,CAAC;QACtD,EAAE,OAAO1B,KAAK,EAAO;YACnB,yHAAyH;YACzH,IAAIA,KAAK,CAACH,MAAM,KAAK,GAAG,EAAE;gBACxB,+FAA+F;gBAC/F,gEAAgE;gBAChE,EAAE;gBACF,uFAAuF;gBACvF,MAAM,IAAI3B,OAAY,aAAA,CACpB,mBAAmB,EACnB,CAAC,OAAO,EAAE,IAAI,CAACU,MAAM,CAACM,IAAI,CAAC,EAAE,EAAE,IAAI,CAACN,MAAM,CAACjB,IAAI,CAAC,gCAAgC,EAAE+D,GAAG,CAAC,CAAC,CACxF,CAAC;YACJ,CAAC;YACD,MAAM1B,KAAK,CAAC;QACd,CAAC;IACH;UAEMF,mBAAmB,GAAG;QAC1B,MAAM+B,IAAAA,0BAA8B,+BAAA,EAAC,IAAI,CAACjD,MAAM,CAAC,CAAC;QAClD,oCAAoC;QACpC,MAAMkD,UAAS,EAAA,CAACC,SAAS,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC;IACxE;UAEMC,iBAAiB,CAACC,UAAkB,EAAoB;QAC5D,MAAMC,SAAS,GAAG,IAAIC,gBAAe,gBAAA,CAAC,KAAK,EAAEzE,yBAAyB,EAAEuE,UAAU,CAAC,AAAC;QACpF,OAAOC,SAAS,CAACE,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC;CACD"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/platforms/ios/AppleDeviceManager.ts"],"sourcesContent":["import * as osascript from '@expo/osascript';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { assertSystemRequirementsAsync } from './assertSystemRequirements';\nimport { ensureSimulatorAppRunningAsync } from './ensureSimulatorAppRunning';\nimport {\n getBestBootedSimulatorAsync,\n getBestUnbootedSimulatorAsync,\n getSelectableSimulatorsAsync,\n} from './getBestSimulator';\nimport { promptAppleDeviceAsync } from './promptAppleDevice';\nimport * as SimControl from './simctl';\nimport { delayAsync, waitForActionAsync } from '../../../utils/delay';\nimport { CommandError } from '../../../utils/errors';\nimport { parsePlistAsync } from '../../../utils/plist';\nimport { validateUrl } from '../../../utils/url';\nimport { DeviceManager } from '../DeviceManager';\nimport { ExpoGoInstaller } from '../ExpoGoInstaller';\nimport { BaseResolveDeviceProps } from '../PlatformManager';\n\nconst debug = require('debug')('expo:start:platforms:ios:AppleDeviceManager') as typeof console.log;\n\nconst EXPO_GO_BUNDLE_IDENTIFIER = 'host.exp.Exponent';\n\n/**\n * Ensure a simulator is booted and the Simulator app is opened.\n * This is where any timeout related error handling should live.\n */\nexport async function ensureSimulatorOpenAsync(\n { udid, osType }: Partial<Pick<SimControl.Device, 'udid' | 'osType'>> = {},\n tryAgain: boolean = true\n): Promise<SimControl.Device> {\n // Use a default simulator if none was specified\n if (!udid) {\n // If a simulator is open, side step the entire booting sequence.\n const simulatorOpenedByApp = await getBestBootedSimulatorAsync({ osType });\n if (simulatorOpenedByApp) {\n return simulatorOpenedByApp;\n }\n\n // Otherwise, find the best possible simulator from user defaults and continue\n const bestUdid = await getBestUnbootedSimulatorAsync({ osType });\n if (!bestUdid) {\n throw new CommandError('No simulators found.');\n }\n udid = bestUdid;\n }\n\n const bootedDevice = await waitForActionAsync({\n action: () => {\n // Just for the type check.\n assert(udid);\n return SimControl.bootAsync({ udid });\n },\n });\n\n if (!bootedDevice) {\n // Give it a second chance, this might not be needed but it could potentially lead to a better UX on slower devices.\n if (tryAgain) {\n return await ensureSimulatorOpenAsync({ udid, osType }, false);\n }\n // TODO: We should eliminate all needs for a timeout error, it's bad UX to get an error about the simulator not starting while the user can clearly see it starting on their slow computer.\n throw new CommandError(\n 'SIMULATOR_TIMEOUT',\n `Simulator didn't boot fast enough. Try opening Simulator first, then running your app.`\n );\n }\n return bootedDevice;\n}\nexport class AppleDeviceManager extends DeviceManager<SimControl.Device> {\n static assertSystemRequirementsAsync = assertSystemRequirementsAsync;\n\n static async resolveAsync({\n device,\n shouldPrompt,\n }: BaseResolveDeviceProps<\n Partial<Pick<SimControl.Device, 'udid' | 'osType'>>\n > = {}): Promise<AppleDeviceManager> {\n if (shouldPrompt) {\n const devices = await getSelectableSimulatorsAsync(device);\n device = await promptAppleDeviceAsync(devices, device?.osType);\n }\n\n const booted = await ensureSimulatorOpenAsync(device);\n return new AppleDeviceManager(booted);\n }\n\n get name() {\n return this.device.name;\n }\n\n get identifier(): string {\n return this.device.udid;\n }\n\n async getAppVersionAsync(\n appId: string,\n { containerPath }: { containerPath?: string } = {}\n ): Promise<string | null> {\n return await SimControl.getInfoPlistValueAsync(this.device, {\n appId,\n key: 'CFBundleShortVersionString',\n containerPath,\n });\n }\n\n async startAsync(): Promise<SimControl.Device> {\n return ensureSimulatorOpenAsync({ osType: this.device.osType, udid: this.device.udid });\n }\n\n async launchApplicationIdAsync(appId: string) {\n try {\n const result = await SimControl.openAppIdAsync(this.device, {\n appId,\n });\n if (result.status === 0) {\n await this.activateWindowAsync();\n } else {\n throw new CommandError(result.stderr);\n }\n } catch (error: any) {\n let errorMessage = `Couldn't open iOS app with ID \"${appId}\" on device \"${this.name}\".`;\n if (error instanceof CommandError && error.code === 'APP_NOT_INSTALLED') {\n if (appId === EXPO_GO_BUNDLE_IDENTIFIER) {\n errorMessage = `Couldn't open Expo Go app on device \"${this.name}\". Please install.`;\n } else {\n errorMessage += `\\nThe app might not be installed, try installing it with: ${chalk.bold(\n `npx expo run:ios -d ${this.device.udid}`\n )}`;\n }\n }\n if (error.stderr) {\n errorMessage += chalk.gray(`\\n${error.stderr}`);\n } else if (error.message) {\n errorMessage += chalk.gray(`\\n${error.message}`);\n }\n throw new CommandError(errorMessage);\n }\n }\n\n async installAppAsync(filePath: string) {\n await SimControl.installAsync(this.device, {\n filePath,\n });\n\n await this.waitForAppInstalledAsync(await this.getApplicationIdFromBundle(filePath));\n }\n\n private async getApplicationIdFromBundle(filePath: string): Promise<string> {\n debug('getApplicationIdFromBundle:', filePath);\n const builtInfoPlistPath = path.join(filePath, 'Info.plist');\n if (fs.existsSync(builtInfoPlistPath)) {\n const { CFBundleIdentifier } = await parsePlistAsync(builtInfoPlistPath);\n debug('getApplicationIdFromBundle: using built Info.plist', CFBundleIdentifier);\n return CFBundleIdentifier;\n }\n debug('getApplicationIdFromBundle: no Info.plist found');\n return EXPO_GO_BUNDLE_IDENTIFIER;\n }\n\n private async waitForAppInstalledAsync(applicationId: string): Promise<boolean> {\n while (true) {\n if (await this.isAppInstalledAndIfSoReturnContainerPathForIOSAsync(applicationId)) {\n return true;\n }\n await delayAsync(100);\n }\n }\n\n async uninstallAppAsync(appId: string) {\n await SimControl.uninstallAsync(this.device, {\n appId,\n });\n }\n\n async isAppInstalledAndIfSoReturnContainerPathForIOSAsync(appId: string) {\n return (\n (await SimControl.getContainerPathAsync(this.device, {\n appId,\n })) ?? false\n );\n }\n\n async openUrlAsync(url: string, options: { appId?: string } = {}) {\n // Non-compliant URLs will be treated as application identifiers.\n if (!validateUrl(url, { requireProtocol: true })) {\n return await this.launchApplicationIdAsync(url);\n }\n\n try {\n await SimControl.openUrlAsync(this.device, { url, appId: options.appId });\n } catch (error: any) {\n // 194 means the device does not conform to a given URL, in this case we'll assume that the desired app is not installed.\n if (error.status === 194) {\n // An error was encountered processing the command (domain=NSOSStatusErrorDomain, code=-10814):\n // The operation couldn’t be completed. (OSStatus error -10814.)\n //\n // This can be thrown when no app conforms to the URI scheme that we attempted to open.\n throw new CommandError(\n 'APP_NOT_INSTALLED',\n `Device ${this.device.name} (${this.device.udid}) has no app to handle the URI: ${url}`\n );\n }\n throw error;\n }\n }\n\n async activateWindowAsync() {\n await ensureSimulatorAppRunningAsync(this.device);\n // TODO: Focus the individual window\n await osascript.execAsync(`tell application \"Simulator\" to activate`);\n }\n\n getExpoGoAppId(): string {\n return EXPO_GO_BUNDLE_IDENTIFIER;\n }\n\n async ensureExpoGoAsync(sdkVersion: string): Promise<boolean> {\n const installer = new ExpoGoInstaller('ios', EXPO_GO_BUNDLE_IDENTIFIER, sdkVersion);\n return installer.ensureAsync(this);\n }\n}\n"],"names":["ensureSimulatorOpenAsync","AppleDeviceManager","debug","require","EXPO_GO_BUNDLE_IDENTIFIER","udid","osType","tryAgain","simulatorOpenedByApp","getBestBootedSimulatorAsync","bestUdid","getBestUnbootedSimulatorAsync","CommandError","bootedDevice","waitForActionAsync","action","assert","SimControl","bootAsync","DeviceManager","assertSystemRequirementsAsync","resolveAsync","device","shouldPrompt","devices","getSelectableSimulatorsAsync","promptAppleDeviceAsync","booted","name","identifier","getAppVersionAsync","appId","containerPath","getInfoPlistValueAsync","key","startAsync","launchApplicationIdAsync","result","openAppIdAsync","status","activateWindowAsync","stderr","error","errorMessage","code","chalk","bold","gray","message","installAppAsync","filePath","installAsync","waitForAppInstalledAsync","getApplicationIdFromBundle","builtInfoPlistPath","path","join","fs","existsSync","CFBundleIdentifier","parsePlistAsync","applicationId","isAppInstalledAndIfSoReturnContainerPathForIOSAsync","delayAsync","uninstallAppAsync","uninstallAsync","getContainerPathAsync","openUrlAsync","url","options","validateUrl","requireProtocol","ensureSimulatorAppRunningAsync","osascript","execAsync","getExpoGoAppId","ensureExpoGoAsync","sdkVersion","installer","ExpoGoInstaller","ensureAsync"],"mappings":"AAAA;;;;;;;;;;;IA+BsBA,wBAAwB,MAAxBA,wBAAwB;IAyCjCC,kBAAkB,MAAlBA,kBAAkB;;;+DAxEJ,iBAAiB;;;;;;;8DACzB,QAAQ;;;;;;;8DACT,OAAO;;;;;;;8DACV,IAAI;;;;;;;8DACF,MAAM;;;;;;0CAEuB,4BAA4B;2CAC3B,6BAA6B;kCAKrE,oBAAoB;mCACY,qBAAqB;8DAChC,UAAU;uBACS,sBAAsB;wBACxC,uBAAuB;uBACpB,sBAAsB;qBAC1B,oBAAoB;+BAClB,kBAAkB;iCAChB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGpD,MAAMC,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