@expo/cli 0.18.18 → 0.18.19
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 +41 -110
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +1 -0
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +92 -130
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportHermes.js +0 -15
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +48 -3
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +284 -0
- package/build/src/export/fork-bundleAsync.js.map +1 -0
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/run/startBundler.js +8 -1
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +2 -9
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +1 -13
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +123 -9
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +102 -391
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +9 -0
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +12 -19
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +2 -49
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +20 -28
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +9 -8
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +3 -6
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +3 -11
- 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/telemetry/getContext.js +1 -1
- package/package.json +3 -3
- package/build/src/start/server/metro/metroPrivateServer.js +0 -26
- package/build/src/start/server/metro/metroPrivateServer.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/BundlerDevServer.ts"],"sourcesContent":["import assert from 'assert';\nimport resolveFrom from 'resolve-from';\n\nimport { AsyncNgrok } from './AsyncNgrok';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { openBrowserAsync } from '../../utils/open';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\n\nexport type MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\n addListener?(event: string, listener: (...args: any[]) => void): unknown;\n};\n\nexport type DevServerInstance = {\n /** Bundler dev server instance. */\n server: ServerLike;\n /** Dev server URL location properties. */\n location: {\n url: string;\n port: number;\n protocol: 'http' | 'https';\n host?: string;\n };\n /** Additional middleware that's attached to the `server`. */\n middleware: any;\n /** Message socket for communicating with the runtime. */\n messageSocket: MessageSocket;\n};\n\nexport interface BundlerStartOptions {\n /** Should the dev server use `https` protocol. */\n https?: boolean;\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Is dev client enabled. */\n devClient?: boolean;\n /** Should run dev servers with clean caches. */\n resetDevServer?: boolean;\n /** Code signing private key path (defaults to same directory as certificate) */\n privateKeyPath?: string;\n\n /** Max amount of workers (threads) to use with Metro bundler, defaults to undefined for max workers. */\n maxWorkers?: number;\n /** Port to start the dev server on. */\n port?: number;\n\n /** Should start a headless dev server e.g. mock representation to approximate info from a server running in a different process. */\n headless?: boolean;\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n\n /** Will the bundler be used for exporting. NOTE: This is an odd option to pass to the dev server. */\n isExporting?: boolean;\n\n // Webpack options\n /** Should modify and create PWA icons. */\n isImageEditingEnabled?: boolean;\n\n location: CreateURLOptions;\n}\n\nconst PLATFORM_MANAGERS = {\n simulator: () =>\n require('../platforms/ios/ApplePlatformManager')\n .ApplePlatformManager as typeof import('../platforms/ios/ApplePlatformManager').ApplePlatformManager,\n emulator: () =>\n require('../platforms/android/AndroidPlatformManager')\n .AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Ngrok instance for managing tunnel connections. */\n protected ngrok: AsyncNgrok | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n private notifier: FileNotifier | null = null;\n protected readonly devToolsPluginManager: DevToolsPluginManager;\n public isDevClient: boolean;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n /** Advanced options */\n options?: {\n /**\n * The instance of DevToolsPluginManager\n * @default new DevToolsPluginManager(projectRoot)\n */\n devToolsPluginManager?: DevToolsPluginManager;\n // TODO: Replace with custom scheme maybe...\n isDevClient?: boolean;\n }\n ) {\n this.devToolsPluginManager =\n options?.devToolsPluginManager ?? new DevToolsPluginManager(projectRoot);\n this.isDevClient = options?.isDevClient ?? false;\n }\n\n protected setInstance(instance: DevServerInstance) {\n this.instance = instance;\n }\n\n /** Get the manifest middleware function. */\n protected async getManifestMiddlewareAsync(\n options: Pick<BundlerStartOptions, 'minify' | 'mode' | 'privateKeyPath'> = {}\n ) {\n const Middleware = require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware;\n\n const urlCreator = this.getUrlCreator();\n const middleware = new Middleware(this.projectRoot, {\n constructUrl: urlCreator.constructUrl.bind(urlCreator),\n mode: options.mode,\n minify: options.minify,\n isNativeWebpack: this.name === 'webpack' && this.isTargetingNative(),\n privateKeyPath: options.privateKeyPath,\n });\n return middleware;\n }\n\n /** Start the dev server using settings defined in the start command. */\n public async startAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n await this.stopAsync();\n\n let instance: DevServerInstance;\n if (options.headless) {\n instance = await this.startHeadlessAsync(options);\n } else {\n instance = await this.startImplementationAsync(options);\n }\n\n this.setInstance(instance);\n await this.postStartAsync(options);\n return instance;\n }\n\n protected abstract startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance>;\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n return false;\n }\n\n public abstract startTypeScriptServices(): Promise<void>;\n\n public async watchEnvironmentVariables(): Promise<void> {\n // noop -- We've only implemented this functionality in Metro.\n }\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: () => {\n this.instance = null;\n },\n addListener() {},\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n /**\n * Runs after the `startAsync` function, performing any additional common operations.\n * You can assume the dev server is started by the time this function is called.\n */\n protected async postStartAsync(options: BundlerStartOptions) {\n if (\n options.location.hostType === 'tunnel' &&\n !env.EXPO_OFFLINE &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n }\n await this.startDevSessionAsync();\n\n if (!options.isExporting) {\n this.watchConfig();\n }\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n this.notifier?.stopObserving();\n this.notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n this.notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[ngrok] connect to port: ' + port);\n this.ngrok = new AsyncNgrok(this.projectRoot, port);\n await this.ngrok.startAsync();\n return this.ngrok;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n this.devSession?.stopNotifying?.();\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' }),\n () => {\n // TODO: This appears to be happening consistently after an hour.\n // We should investigate why this is happening and fix it on our servers.\n // Log.error(\n // chalk.red(\n // '\\nAn unexpected error occurred while updating the Dev Session API. This project will not appear in the \"Development servers\" section of the Expo Go app until this process has been restarted.'\n // )\n // );\n // Log.exception(error);\n this.devSession?.closeAsync().catch((error) => {\n debug('[dev-session] error closing: ' + error.message);\n });\n }\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop file watching.\n this.notifier?.stopObserving();\n\n // Stop the dev session timer and tell Expo API to remove dev session.\n await this.devSession?.closeAsync();\n\n // Stop ngrok if running.\n await this.ngrok?.stopAsync().catch((e) => {\n Log.error(`Error stopping ngrok:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n // Check if server is even running.\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n if ('code' in error && error.code === 'ERR_SERVER_NOT_RUNNING') {\n resolve();\n } else {\n reject(error);\n }\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n public getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl()\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n return location.url ?? null;\n }\n\n /** Get the base URL for JS inspector */\n public getJsInspectorBaseUrl(): string {\n if (this.name !== 'metro') {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the JS inspector base url - bundler[${this.name}]`\n );\n }\n return this.getUrlCreator().constructUrl({ scheme: 'http' });\n }\n\n /** Get the tunnel URL from ngrok. */\n public getTunnelUrl(): string | null {\n return this.ngrok?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const serverUrl = this.getDevServerUrl({ hostType: 'localhost' });\n // Allow opening the tunnel URL when using Metro web.\n const url = this.name === 'metro' ? this.getTunnelUrl() ?? serverUrl : serverUrl;\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<BaseOpenInCustomProps> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(): string {\n return this.getUrlCreator().constructUrl({ scheme: 'exp' });\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected isRedirectPageEnabled(): boolean {\n return (\n !env.EXPO_NO_REDIRECT_PAGE &&\n // if user passed --dev-client flag, skip interstitial page\n !this.isDevClient &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-client')\n );\n }\n\n /** Get the redirect URL when redirecting is enabled. */\n public getRedirectUrl(platform: keyof typeof PLATFORM_MANAGERS | null = null): string | null {\n if (!this.isRedirectPageEnabled()) {\n debug('Redirect page is disabled');\n return null;\n }\n\n return (\n this.getUrlCreator().constructLoadingUrl(\n {},\n platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null\n ) ?? null\n );\n }\n\n public getReactDevToolsUrl(): string {\n return new URL(\n '_expo/react-devtools',\n this.getUrlCreator().constructUrl({ scheme: 'http' })\n ).toString();\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this),\n getRedirectUrl: this.getRedirectUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["BundlerDevServer","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","constructor","projectRoot","platformBundlers","options","ngrok","devSession","instance","platformManagers","urlCreator","notifier","devToolsPluginManager","DevToolsPluginManager","isDevClient","setInstance","getManifestMiddlewareAsync","Middleware","ExpoGoManifestHandlerMiddleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","waitForTypeScriptAsync","watchEnvironmentVariables","port","CommandError","server","close","addListener","location","host","url","protocol","messageSocket","broadcast","hostType","env","EXPO_OFFLINE","_startTunnelAsync","startDevSessionAsync","isExporting","watchConfig","stopObserving","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncNgrok","stopNotifying","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","closeAsync","catch","error","message","runtime","isTargetingWeb","web","broadcastMessage","method","params","e","Log","exception","resolveWithTimeout","Promise","resolve","reject","code","timeout","errorMessage","assert","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getJsInspectorBaseUrl","getActiveUrl","openPlatformAsync","launchTarget","resolver","serverUrl","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","getExpoGoUrl","isRedirectPageEnabled","EXPO_NO_REDIRECT_PAGE","resolveFrom","silent","getRedirectUrl","platform","constructLoadingUrl","getReactDevToolsUrl","URL","toString","Manager","getCustomRuntimeUrl"],"mappings":"AAAA;;;;+BA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ts"],"sourcesContent":["import assert from 'assert';\nimport resolveFrom from 'resolve-from';\n\nimport { AsyncNgrok } from './AsyncNgrok';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { DevelopmentSession } from './DevelopmentSession';\nimport { CreateURLOptions, UrlCreator } from './UrlCreator';\nimport { PlatformBundlers } from './platformBundlers';\nimport * as Log from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { resolveWithTimeout } from '../../utils/delay';\nimport { env } from '../../utils/env';\nimport { CommandError } from '../../utils/errors';\nimport { openBrowserAsync } from '../../utils/open';\nimport {\n BaseOpenInCustomProps,\n BaseResolveDeviceProps,\n PlatformManager,\n} from '../platforms/PlatformManager';\n\nconst debug = require('debug')('expo:start:server:devServer') as typeof console.log;\n\nexport type MessageSocket = {\n broadcast: (method: string, params?: Record<string, any> | undefined) => void;\n};\n\nexport type ServerLike = {\n close(callback?: (err?: Error) => void): void;\n addListener?(event: string, listener: (...args: any[]) => void): unknown;\n};\n\nexport type DevServerInstance = {\n /** Bundler dev server instance. */\n server: ServerLike;\n /** Dev server URL location properties. */\n location: {\n url: string;\n port: number;\n protocol: 'http' | 'https';\n host?: string;\n };\n /** Additional middleware that's attached to the `server`. */\n middleware: any;\n /** Message socket for communicating with the runtime. */\n messageSocket: MessageSocket;\n};\n\nexport interface BundlerStartOptions {\n /** Should the dev server use `https` protocol. */\n https?: boolean;\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Is dev client enabled. */\n devClient?: boolean;\n /** Should run dev servers with clean caches. */\n resetDevServer?: boolean;\n /** Code signing private key path (defaults to same directory as certificate) */\n privateKeyPath?: string;\n\n /** Max amount of workers (threads) to use with Metro bundler, defaults to undefined for max workers. */\n maxWorkers?: number;\n /** Port to start the dev server on. */\n port?: number;\n\n /** Should start a headless dev server e.g. mock representation to approximate info from a server running in a different process. */\n headless?: boolean;\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n\n /** Will the bundler be used for exporting. NOTE: This is an odd option to pass to the dev server. */\n isExporting?: boolean;\n\n // Webpack options\n /** Should modify and create PWA icons. */\n isImageEditingEnabled?: boolean;\n\n location: CreateURLOptions;\n}\n\nconst PLATFORM_MANAGERS = {\n simulator: () =>\n require('../platforms/ios/ApplePlatformManager')\n .ApplePlatformManager as typeof import('../platforms/ios/ApplePlatformManager').ApplePlatformManager,\n emulator: () =>\n require('../platforms/android/AndroidPlatformManager')\n .AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,\n};\n\nexport abstract class BundlerDevServer {\n /** Name of the bundler. */\n abstract get name(): string;\n\n /** Ngrok instance for managing tunnel connections. */\n protected ngrok: AsyncNgrok | null = null;\n /** Interfaces with the Expo 'Development Session' API. */\n protected devSession: DevelopmentSession | null = null;\n /** Http server and related info. */\n protected instance: DevServerInstance | null = null;\n /** Native platform interfaces for opening projects. */\n private platformManagers: Record<string, PlatformManager<any>> = {};\n /** Manages the creation of dev server URLs. */\n protected urlCreator?: UrlCreator | null = null;\n\n private notifier: FileNotifier | null = null;\n protected readonly devToolsPluginManager: DevToolsPluginManager;\n public isDevClient: boolean;\n\n constructor(\n /** Project root folder. */\n public projectRoot: string,\n /** A mapping of bundlers to platforms. */\n public platformBundlers: PlatformBundlers,\n /** Advanced options */\n options?: {\n /**\n * The instance of DevToolsPluginManager\n * @default new DevToolsPluginManager(projectRoot)\n */\n devToolsPluginManager?: DevToolsPluginManager;\n // TODO: Replace with custom scheme maybe...\n isDevClient?: boolean;\n }\n ) {\n this.devToolsPluginManager =\n options?.devToolsPluginManager ?? new DevToolsPluginManager(projectRoot);\n this.isDevClient = options?.isDevClient ?? false;\n }\n\n protected setInstance(instance: DevServerInstance) {\n this.instance = instance;\n }\n\n /** Get the manifest middleware function. */\n protected async getManifestMiddlewareAsync(\n options: Pick<BundlerStartOptions, 'minify' | 'mode' | 'privateKeyPath'> = {}\n ) {\n const Middleware = require('./middleware/ExpoGoManifestHandlerMiddleware')\n .ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware;\n\n const urlCreator = this.getUrlCreator();\n const middleware = new Middleware(this.projectRoot, {\n constructUrl: urlCreator.constructUrl.bind(urlCreator),\n mode: options.mode,\n minify: options.minify,\n isNativeWebpack: this.name === 'webpack' && this.isTargetingNative(),\n privateKeyPath: options.privateKeyPath,\n });\n return middleware;\n }\n\n /** Start the dev server using settings defined in the start command. */\n public async startAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n await this.stopAsync();\n\n let instance: DevServerInstance;\n if (options.headless) {\n instance = await this.startHeadlessAsync(options);\n } else {\n instance = await this.startImplementationAsync(options);\n }\n\n this.setInstance(instance);\n await this.postStartAsync(options);\n return instance;\n }\n\n protected abstract startImplementationAsync(\n options: BundlerStartOptions\n ): Promise<DevServerInstance>;\n\n public async waitForTypeScriptAsync(): Promise<boolean> {\n return false;\n }\n\n public abstract startTypeScriptServices(): Promise<void>;\n\n public async watchEnvironmentVariables(): Promise<void> {\n // noop -- We've only implemented this functionality in Metro.\n }\n\n /**\n * Creates a mock server representation that can be used to estimate URLs for a server started in another process.\n * This is used for the run commands where you can reuse the server from a previous run.\n */\n private async startHeadlessAsync(options: BundlerStartOptions): Promise<DevServerInstance> {\n if (!options.port)\n throw new CommandError('HEADLESS_SERVER', 'headless dev server requires a port option');\n this.urlCreator = this.getUrlCreator(options);\n\n return {\n // Create a mock server\n server: {\n close: () => {\n this.instance = null;\n },\n addListener() {},\n },\n location: {\n // The port is the main thing we want to send back.\n port: options.port,\n // localhost isn't always correct.\n host: 'localhost',\n // http is the only supported protocol on native.\n url: `http://localhost:${options.port}`,\n protocol: 'http',\n },\n middleware: {},\n messageSocket: {\n broadcast: () => {\n throw new CommandError('HEADLESS_SERVER', 'Cannot broadcast messages to headless server');\n },\n },\n };\n }\n\n /**\n * Runs after the `startAsync` function, performing any additional common operations.\n * You can assume the dev server is started by the time this function is called.\n */\n protected async postStartAsync(options: BundlerStartOptions) {\n if (\n options.location.hostType === 'tunnel' &&\n !env.EXPO_OFFLINE &&\n // This is a hack to prevent using tunnel on web since we block it upstream for some reason.\n this.isTargetingNative()\n ) {\n await this._startTunnelAsync();\n }\n await this.startDevSessionAsync();\n\n this.watchConfig();\n }\n\n protected abstract getConfigModuleIds(): string[];\n\n protected watchConfig() {\n this.notifier?.stopObserving();\n this.notifier = new FileNotifier(this.projectRoot, this.getConfigModuleIds());\n this.notifier.startObserving();\n }\n\n /** Create ngrok instance and start the tunnel server. Exposed for testing. */\n public async _startTunnelAsync(): Promise<AsyncNgrok | null> {\n const port = this.getInstance()?.location.port;\n if (!port) return null;\n debug('[ngrok] connect to port: ' + port);\n this.ngrok = new AsyncNgrok(this.projectRoot, port);\n await this.ngrok.startAsync();\n return this.ngrok;\n }\n\n protected async startDevSessionAsync() {\n // This is used to make Expo Go open the project in either Expo Go, or the web browser.\n // Must come after ngrok (`startTunnelAsync`) setup.\n this.devSession?.stopNotifying?.();\n this.devSession = new DevelopmentSession(\n this.projectRoot,\n // This URL will be used on external devices so the computer IP won't be relevant.\n this.isTargetingNative()\n ? this.getNativeRuntimeUrl()\n : this.getDevServerUrl({ hostType: 'localhost' }),\n () => {\n // TODO: This appears to be happening consistently after an hour.\n // We should investigate why this is happening and fix it on our servers.\n // Log.error(\n // chalk.red(\n // '\\nAn unexpected error occurred while updating the Dev Session API. This project will not appear in the \"Development servers\" section of the Expo Go app until this process has been restarted.'\n // )\n // );\n // Log.exception(error);\n this.devSession?.closeAsync().catch((error) => {\n debug('[dev-session] error closing: ' + error.message);\n });\n }\n );\n\n await this.devSession.startAsync({\n runtime: this.isTargetingNative() ? 'native' : 'web',\n });\n }\n\n public isTargetingNative() {\n // Temporary hack while we implement multi-bundler dev server proxy.\n return true;\n }\n\n public isTargetingWeb() {\n return this.platformBundlers.web === this.name;\n }\n\n /**\n * Sends a message over web sockets to any connected device,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params\n */\n public broadcastMessage(\n method: 'reload' | 'devMenu' | 'sendDevCommand',\n params?: Record<string, any>\n ) {\n this.getInstance()?.messageSocket.broadcast(method, params);\n }\n\n /** Get the running dev server instance. */\n public getInstance() {\n return this.instance;\n }\n\n /** Stop the running dev server instance. */\n async stopAsync() {\n // Stop file watching.\n this.notifier?.stopObserving();\n\n // Stop the dev session timer and tell Expo API to remove dev session.\n await this.devSession?.closeAsync();\n\n // Stop ngrok if running.\n await this.ngrok?.stopAsync().catch((e) => {\n Log.error(`Error stopping ngrok:`);\n Log.exception(e);\n });\n\n return resolveWithTimeout(\n () =>\n new Promise<void>((resolve, reject) => {\n // Close the server.\n debug(`Stopping dev server (bundler: ${this.name})`);\n\n if (this.instance?.server) {\n this.instance.server.close((error) => {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n } else {\n debug(`Stopped dev server (bundler: ${this.name})`);\n this.instance = null;\n resolve();\n }\n }),\n {\n // NOTE(Bacon): Metro dev server doesn't seem to be closing in time.\n timeout: 1000,\n errorMessage: `Timeout waiting for '${this.name}' dev server to close`,\n }\n );\n }\n\n public getUrlCreator(options: Partial<Pick<BundlerStartOptions, 'port' | 'location'>> = {}) {\n if (!this.urlCreator) {\n assert(options?.port, 'Dev server instance not found');\n this.urlCreator = new UrlCreator(options.location, {\n port: options.port,\n getTunnelUrl: this.getTunnelUrl.bind(this),\n });\n }\n return this.urlCreator;\n }\n\n public getNativeRuntimeUrl(opts: Partial<CreateURLOptions> = {}) {\n return this.isDevClient\n ? this.getUrlCreator().constructDevClientUrl(opts) ?? this.getDevServerUrl()\n : this.getUrlCreator().constructUrl({ ...opts, scheme: 'exp' });\n }\n\n /** Get the URL for the running instance of the dev server. */\n public getDevServerUrl(options: { hostType?: 'localhost' } = {}): string | null {\n const instance = this.getInstance();\n if (!instance?.location) {\n return null;\n }\n const { location } = instance;\n if (options.hostType === 'localhost') {\n return `${location.protocol}://localhost:${location.port}`;\n }\n return location.url ?? null;\n }\n\n /** Get the base URL for JS inspector */\n public getJsInspectorBaseUrl(): string {\n if (this.name !== 'metro') {\n throw new CommandError(\n 'DEV_SERVER',\n `Cannot get the JS inspector base url - bundler[${this.name}]`\n );\n }\n return this.getUrlCreator().constructUrl({ scheme: 'http' });\n }\n\n /** Get the tunnel URL from ngrok. */\n public getTunnelUrl(): string | null {\n return this.ngrok?.getActiveUrl() ?? null;\n }\n\n /** Open the dev server in a runtime. */\n public async openPlatformAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS | 'desktop',\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n if (launchTarget === 'desktop') {\n const serverUrl = this.getDevServerUrl({ hostType: 'localhost' });\n // Allow opening the tunnel URL when using Metro web.\n const url = this.name === 'metro' ? this.getTunnelUrl() ?? serverUrl : serverUrl;\n await openBrowserAsync(url!);\n return { url };\n }\n\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime }, resolver);\n }\n\n /** Open the dev server in a runtime. */\n public async openCustomRuntimeAsync(\n launchTarget: keyof typeof PLATFORM_MANAGERS,\n launchProps: Partial<BaseOpenInCustomProps> = {},\n resolver: BaseResolveDeviceProps<any> = {}\n ) {\n const runtime = this.isTargetingNative() ? (this.isDevClient ? 'custom' : 'expo') : 'web';\n if (runtime !== 'custom') {\n throw new CommandError(\n `dev server cannot open custom runtimes either because it does not target native platforms or because it is not targeting dev clients. (target: ${runtime})`\n );\n }\n\n const manager = await this.getPlatformManagerAsync(launchTarget);\n return manager.openAsync({ runtime: 'custom', props: launchProps }, resolver);\n }\n\n /** Get the URL for opening in Expo Go. */\n protected getExpoGoUrl(): string {\n return this.getUrlCreator().constructUrl({ scheme: 'exp' });\n }\n\n /** Should use the interstitial page for selecting which runtime to use. */\n protected isRedirectPageEnabled(): boolean {\n return (\n !env.EXPO_NO_REDIRECT_PAGE &&\n // if user passed --dev-client flag, skip interstitial page\n !this.isDevClient &&\n // Checks if dev client is installed.\n !!resolveFrom.silent(this.projectRoot, 'expo-dev-client')\n );\n }\n\n /** Get the redirect URL when redirecting is enabled. */\n public getRedirectUrl(platform: keyof typeof PLATFORM_MANAGERS | null = null): string | null {\n if (!this.isRedirectPageEnabled()) {\n debug('Redirect page is disabled');\n return null;\n }\n\n return (\n this.getUrlCreator().constructLoadingUrl(\n {},\n platform === 'emulator' ? 'android' : platform === 'simulator' ? 'ios' : null\n ) ?? null\n );\n }\n\n public getReactDevToolsUrl(): string {\n return new URL(\n '_expo/react-devtools',\n this.getUrlCreator().constructUrl({ scheme: 'http' })\n ).toString();\n }\n\n protected async getPlatformManagerAsync(platform: keyof typeof PLATFORM_MANAGERS) {\n if (!this.platformManagers[platform]) {\n const Manager = PLATFORM_MANAGERS[platform]();\n const port = this.getInstance()?.location.port;\n if (!port || !this.urlCreator) {\n throw new CommandError(\n 'DEV_SERVER',\n 'Cannot interact with native platforms until dev server has started'\n );\n }\n debug(`Creating platform manager (platform: ${platform}, port: ${port})`);\n this.platformManagers[platform] = new Manager(this.projectRoot, port, {\n getCustomRuntimeUrl: this.urlCreator.constructDevClientUrl.bind(this.urlCreator),\n getExpoGoUrl: this.getExpoGoUrl.bind(this),\n getRedirectUrl: this.getRedirectUrl.bind(this, platform),\n getDevServerUrl: this.getDevServerUrl.bind(this, { hostType: 'localhost' }),\n });\n }\n return this.platformManagers[platform];\n }\n}\n"],"names":["BundlerDevServer","debug","require","PLATFORM_MANAGERS","simulator","ApplePlatformManager","emulator","AndroidPlatformManager","constructor","projectRoot","platformBundlers","options","ngrok","devSession","instance","platformManagers","urlCreator","notifier","devToolsPluginManager","DevToolsPluginManager","isDevClient","setInstance","getManifestMiddlewareAsync","Middleware","ExpoGoManifestHandlerMiddleware","getUrlCreator","middleware","constructUrl","bind","mode","minify","isNativeWebpack","name","isTargetingNative","privateKeyPath","startAsync","stopAsync","headless","startHeadlessAsync","startImplementationAsync","postStartAsync","waitForTypeScriptAsync","watchEnvironmentVariables","port","CommandError","server","close","addListener","location","host","url","protocol","messageSocket","broadcast","hostType","env","EXPO_OFFLINE","_startTunnelAsync","startDevSessionAsync","watchConfig","stopObserving","FileNotifier","getConfigModuleIds","startObserving","getInstance","AsyncNgrok","stopNotifying","DevelopmentSession","getNativeRuntimeUrl","getDevServerUrl","closeAsync","catch","error","message","runtime","isTargetingWeb","web","broadcastMessage","method","params","e","Log","exception","resolveWithTimeout","Promise","resolve","reject","timeout","errorMessage","assert","UrlCreator","getTunnelUrl","opts","constructDevClientUrl","scheme","getJsInspectorBaseUrl","getActiveUrl","openPlatformAsync","launchTarget","resolver","serverUrl","openBrowserAsync","manager","getPlatformManagerAsync","openAsync","openCustomRuntimeAsync","launchProps","props","getExpoGoUrl","isRedirectPageEnabled","EXPO_NO_REDIRECT_PAGE","resolveFrom","silent","getRedirectUrl","platform","constructLoadingUrl","getReactDevToolsUrl","URL","toString","Manager","getCustomRuntimeUrl"],"mappings":"AAAA;;;;+BAwFsBA,kBAAgB;;aAAhBA,gBAAgB;;;8DAxFnB,QAAQ;;;;;;;8DACH,cAAc;;;;;;4BAEX,cAAc;4EACP,yBAAyB;oCACxB,sBAAsB;4BACZ,cAAc;2DAEtC,WAAW;8BACH,0BAA0B;uBACpB,mBAAmB;qBAClC,iBAAiB;wBACR,oBAAoB;sBAChB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOnD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,6BAA6B,CAAC,AAAsB,AAAC;AA2DpF,MAAMC,iBAAiB,GAAG;IACxBC,SAAS,EAAE,IACTF,OAAO,CAAC,uCAAuC,CAAC,CAC7CG,oBAAoB,AAA+E;IACxGC,QAAQ,EAAE,IACRJ,OAAO,CAAC,6CAA6C,CAAC,CACnDK,sBAAsB,AAAuF;CACnH,A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BAAqB,CAACjE,IAAI,CAAC,IAAI,CAACZ,UAAU,CAAC;gBAChF4F,YAAY,EAAE,IAAI,CAACA,YAAY,CAAChF,IAAI,CAAC,IAAI,CAAC;gBAC1CqF,cAAc,EAAE,IAAI,CAACA,cAAc,CAACrF,IAAI,CAAC,IAAI,EAAEsF,QAAQ,CAAC;gBACxD7C,eAAe,EAAE,IAAI,CAACA,eAAe,CAACzC,IAAI,CAAC,IAAI,EAAE;oBAAE0B,QAAQ,EAAE,WAAW;iBAAE,CAAC;aAC5E,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAACvC,gBAAgB,CAACmG,QAAQ,CAAC,CAAC;IACzC;CACD"}
|
|
@@ -89,24 +89,12 @@ const BUNDLERS = {
|
|
|
89
89
|
metro: ()=>require("./metro/MetroBundlerDevServer").MetroBundlerDevServer
|
|
90
90
|
};
|
|
91
91
|
class DevServerManager {
|
|
92
|
-
static async startMetroAsync(projectRoot, startOptions) {
|
|
93
|
-
const devServerManager = new DevServerManager(projectRoot, startOptions);
|
|
94
|
-
await devServerManager.startAsync([
|
|
95
|
-
{
|
|
96
|
-
type: "metro",
|
|
97
|
-
options: startOptions
|
|
98
|
-
},
|
|
99
|
-
]);
|
|
100
|
-
return devServerManager;
|
|
101
|
-
}
|
|
102
92
|
constructor(projectRoot, options){
|
|
103
93
|
this.projectRoot = projectRoot;
|
|
104
94
|
this.options = options;
|
|
105
95
|
this.projectPrerequisites = [];
|
|
106
96
|
this.notifier = null;
|
|
107
|
-
|
|
108
|
-
this.notifier = this.watchBabelConfig();
|
|
109
|
-
}
|
|
97
|
+
this.notifier = this.watchBabelConfig();
|
|
110
98
|
this.devtoolsPluginManager = new _devToolsPluginManager.default(projectRoot);
|
|
111
99
|
}
|
|
112
100
|
watchBabelConfig() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { getPlatformBundlers } from './platformBundlers';\nimport { Log } from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { env } from '../../utils/env';\nimport { logEventAsync } from '../../utils/telemetry';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport { TypeScriptProjectPrerequisite } from '../doctor/typescript/TypeScriptProjectPrerequisite';\nimport { printItem } from '../interface/commandsTable';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { resolveSchemeAsync } from '../resolveOptions';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst devServers: BundlerDevServer[] = [];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n static async startMetroAsync(projectRoot: string, startOptions: BundlerStartOptions) {\n const devServerManager = new DevServerManager(projectRoot, startOptions);\n\n await devServerManager.startAsync([\n {\n type: 'metro',\n options: startOptions,\n },\n ]);\n return devServerManager;\n }\n\n private projectPrerequisites: ProjectPrerequisite<any, void>[] = [];\n public readonly devtoolsPluginManager: DevToolsPluginManager;\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n if (!options.isExporting) {\n this.notifier = this.watchBabelConfig();\n }\n this.devtoolsPluginManager = new DevToolsPluginManager(projectRoot);\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite<any, any>) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n return await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(this.projectRoot, exp).web;\n debug(`Starting ${bundler} dev server for web`);\n return this.startAsync([\n {\n type: bundler,\n options: this.options,\n },\n ]);\n }\n\n /** Switch between Expo Go and Expo Dev Clients. */\n async toggleRuntimeMode(isUsingDevClient: boolean = !this.options.devClient): Promise<boolean> {\n const nextMode = isUsingDevClient ? '--dev-client' : '--go';\n Log.log(printItem(chalk`Switching to {bold ${nextMode}}`));\n\n const nextScheme = await resolveSchemeAsync(this.projectRoot, {\n devClient: isUsingDevClient,\n // NOTE: The custom `--scheme` argument is lost from this point on.\n });\n\n this.options.location.scheme = nextScheme;\n this.options.devClient = isUsingDevClient;\n for (const devServer of devServers) {\n devServer.isDevClient = isUsingDevClient;\n const urlCreator = devServer.getUrlCreator();\n urlCreator.defaults ??= {};\n urlCreator.defaults.scheme = nextScheme;\n }\n\n debug(`New runtime options (runtime: ${nextMode}):`, this.options);\n return true;\n }\n\n /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n\n await logEventAsync('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\n\n const platformBundlers = getPlatformBundlers(this.projectRoot, exp);\n\n // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(this.projectRoot, platformBundlers, {\n devToolsPluginManager: this.devtoolsPluginManager,\n isDevClient: !!options?.devClient,\n });\n await server.startAsync(options ?? this.options);\n devServers.push(server);\n }\n\n return exp;\n }\n\n async bootstrapTypeScriptAsync() {\n const typescriptPrerequisite = await this.ensureProjectPrerequisiteAsync(\n TypeScriptProjectPrerequisite\n );\n\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n return;\n }\n\n // Optionally, wait for the user to add TypeScript during the\n // development cycle.\n const server = devServers.find((server) => server.name === 'metro');\n if (!server) {\n return;\n }\n\n // The dev server shouldn't wait for the typescript services\n if (!typescriptPrerequisite) {\n server.waitForTypeScriptAsync().then(async (success) => {\n if (success) {\n server.startTypeScriptServices();\n }\n });\n } else {\n server.startTypeScriptServices();\n }\n }\n\n async watchEnvironmentVariables() {\n await devServers.find((server) => server.name === 'metro')?.watchEnvironmentVariables();\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n this.notifier?.stopObserving(),\n // Stop all dev servers\n ...devServers.map((server) => server.stopAsync()),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n ]);\n }\n}\n"],"names":["DevServerManager","urlCreator","debug","require","devServers","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","startMetroAsync","projectRoot","startOptions","devServerManager","startAsync","type","options","constructor","projectPrerequisites","notifier","isExporting","watchBabelConfig","devtoolsPluginManager","DevToolsPluginManager","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","toggleRuntimeMode","isUsingDevClient","devClient","nextMode","Log","log","printItem","nextScheme","resolveSchemeAsync","scheme","devServer","isDevClient","getUrlCreator","defaults","logEventAsync","sdkVersion","platformBundlers","BundlerDevServerClass","devToolsPluginManager","bootstrapTypeScriptAsync","typescriptPrerequisite","TypeScriptProjectPrerequisite","env","EXPO_NO_TYPESCRIPT_SETUP","name","waitForTypeScriptAsync","then","success","startTypeScriptServices","watchEnvironmentVariables","stopAsync","Promise","allSettled","stopObserving","map","AndroidDebugBridge","getServer"],"mappings":"AAAA;;;;+BAoCaA,kBAAgB;;aAAhBA,gBAAgB;;;yBApCS,cAAc;;;;;;;8DACjC,QAAQ;;;;;;;8DACT,OAAO;;;;;;4EAGS,yBAAyB;kCACvB,oBAAoB;qBACpC,WAAW;8BACF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AC2B,IAAI,CAAC,CAACO,MAAM,GAAKA,MAAM,CAAC4C,IAAI,KAAK,OAAO,CAAC,AAAC;QACpE,IAAI,CAAC5C,MAAM,EAAE;YACX,OAAO;QACT,CAAC;QAED,4DAA4D;QAC5D,IAAI,CAACwC,sBAAsB,EAAE;YAC3BxC,MAAM,CAAC6C,sBAAsB,EAAE,CAACC,IAAI,CAAC,OAAOC,OAAO,GAAK;gBACtD,IAAIA,OAAO,EAAE;oBACX/C,MAAM,CAACgD,uBAAuB,EAAE,CAAC;gBACnC,CAAC;YACH,CAAC,CAAC,CAAC;QACL,OAAO;YACLhD,MAAM,CAACgD,uBAAuB,EAAE,CAAC;QACnC,CAAC;IACH;UAEMC,yBAAyB,GAAG;YAC1BnF,GAAoD;QAA1D,OAAMA,CAAAA,GAAoD,GAApDA,UAAU,CAAC2B,IAAI,CAAC,CAACO,MAAM,GAAKA,MAAM,CAAC4C,IAAI,KAAK,OAAO,CAAC,SAA2B,GAA/E9E,KAAAA,CAA+E,GAA/EA,GAAoD,CAAEmF,yBAAyB,EAAE,CAAA,CAAC;IAC1F;IAEA,oCAAoC,SAC9BC,SAAS,GAAkB;YAE7B,GAAa;QADf,MAAMC,OAAO,CAACC,UAAU,CAAC;YACvB,CAAA,GAAa,GAAb,IAAI,CAACvE,QAAQ,SAAe,GAA5B,KAAA,CAA4B,GAA5B,GAAa,CAAEwE,aAAa,EAAE;YAC9B,uBAAuB;eACpBvF,UAAU,CAACwF,GAAG,CAAC,CAACtD,MAAM,GAAKA,MAAM,CAACkD,SAAS,EAAE,CAAC;YACjD,WAAW;YACXK,IAAkB,CAACC,SAAS,EAAE,CAACN,SAAS,EAAE;SAC3C,CAAC,CAAC;IACL;CACD"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/DevServerManager.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\n\nimport { BundlerDevServer, BundlerStartOptions } from './BundlerDevServer';\nimport DevToolsPluginManager from './DevToolsPluginManager';\nimport { getPlatformBundlers } from './platformBundlers';\nimport { Log } from '../../log';\nimport { FileNotifier } from '../../utils/FileNotifier';\nimport { env } from '../../utils/env';\nimport { logEventAsync } from '../../utils/telemetry';\nimport { ProjectPrerequisite } from '../doctor/Prerequisite';\nimport { TypeScriptProjectPrerequisite } from '../doctor/typescript/TypeScriptProjectPrerequisite';\nimport { printItem } from '../interface/commandsTable';\nimport * as AndroidDebugBridge from '../platforms/android/adb';\nimport { resolveSchemeAsync } from '../resolveOptions';\n\nconst debug = require('debug')('expo:start:server:devServerManager') as typeof console.log;\n\nexport type MultiBundlerStartOptions = {\n type: keyof typeof BUNDLERS;\n options?: BundlerStartOptions;\n}[];\n\nconst devServers: BundlerDevServer[] = [];\n\nconst BUNDLERS = {\n webpack: () =>\n require('./webpack/WebpackBundlerDevServer')\n .WebpackBundlerDevServer as typeof import('./webpack/WebpackBundlerDevServer').WebpackBundlerDevServer,\n metro: () =>\n require('./metro/MetroBundlerDevServer')\n .MetroBundlerDevServer as typeof import('./metro/MetroBundlerDevServer').MetroBundlerDevServer,\n};\n\n/** Manages interacting with multiple dev servers. */\nexport class DevServerManager {\n private projectPrerequisites: ProjectPrerequisite<any, void>[] = [];\n public readonly devtoolsPluginManager: DevToolsPluginManager;\n\n private notifier: FileNotifier | null = null;\n\n constructor(\n public projectRoot: string,\n /** Keep track of the original CLI options for bundlers that are started interactively. */\n public options: BundlerStartOptions\n ) {\n this.notifier = this.watchBabelConfig();\n this.devtoolsPluginManager = new DevToolsPluginManager(projectRoot);\n }\n\n private watchBabelConfig() {\n const notifier = new FileNotifier(\n this.projectRoot,\n [\n './babel.config.js',\n './babel.config.json',\n './.babelrc.json',\n './.babelrc',\n './.babelrc.js',\n ],\n {\n additionalWarning: chalk` You may need to clear the bundler cache with the {bold --clear} flag for your changes to take effect.`,\n }\n );\n\n notifier.startObserving();\n\n return notifier;\n }\n\n /** Lazily load and assert a project-level prerequisite. */\n async ensureProjectPrerequisiteAsync(PrerequisiteClass: typeof ProjectPrerequisite<any, any>) {\n let prerequisite = this.projectPrerequisites.find(\n (prerequisite) => prerequisite instanceof PrerequisiteClass\n );\n if (!prerequisite) {\n prerequisite = new PrerequisiteClass(this.projectRoot);\n this.projectPrerequisites.push(prerequisite);\n }\n return await prerequisite.assertAsync();\n }\n\n /**\n * Sends a message over web sockets to all connected devices,\n * does nothing when the dev server is not running.\n *\n * @param method name of the command. In RN projects `reload`, and `devMenu` are available. In Expo Go, `sendDevCommand` is available.\n * @param params extra event info to send over the socket.\n */\n broadcastMessage(method: 'reload' | 'devMenu' | 'sendDevCommand', params?: Record<string, any>) {\n devServers.forEach((server) => {\n server.broadcastMessage(method, params);\n });\n }\n\n /** Get the port for the dev server (either Webpack or Metro) that is hosting code for React Native runtimes. */\n getNativeDevServerPort() {\n const server = devServers.find((server) => server.isTargetingNative());\n return server?.getInstance()?.location.port ?? null;\n }\n\n /** Get the first server that targets web. */\n getWebDevServer() {\n const server = devServers.find((server) => server.isTargetingWeb());\n return server ?? null;\n }\n\n getDefaultDevServer(): BundlerDevServer {\n // Return the first native dev server otherwise return the first dev server.\n const server = devServers.find((server) => server.isTargetingNative());\n const defaultServer = server ?? devServers[0];\n assert(defaultServer, 'No dev servers are running');\n return defaultServer;\n }\n\n async ensureWebDevServerRunningAsync() {\n const [server] = devServers.filter((server) => server.isTargetingWeb());\n if (server) {\n return;\n }\n const { exp } = getConfig(this.projectRoot, {\n skipPlugins: true,\n skipSDKVersionRequirement: true,\n });\n const bundler = getPlatformBundlers(this.projectRoot, exp).web;\n debug(`Starting ${bundler} dev server for web`);\n return this.startAsync([\n {\n type: bundler,\n options: this.options,\n },\n ]);\n }\n\n /** Switch between Expo Go and Expo Dev Clients. */\n async toggleRuntimeMode(isUsingDevClient: boolean = !this.options.devClient): Promise<boolean> {\n const nextMode = isUsingDevClient ? '--dev-client' : '--go';\n Log.log(printItem(chalk`Switching to {bold ${nextMode}}`));\n\n const nextScheme = await resolveSchemeAsync(this.projectRoot, {\n devClient: isUsingDevClient,\n // NOTE: The custom `--scheme` argument is lost from this point on.\n });\n\n this.options.location.scheme = nextScheme;\n this.options.devClient = isUsingDevClient;\n for (const devServer of devServers) {\n devServer.isDevClient = isUsingDevClient;\n const urlCreator = devServer.getUrlCreator();\n urlCreator.defaults ??= {};\n urlCreator.defaults.scheme = nextScheme;\n }\n\n debug(`New runtime options (runtime: ${nextMode}):`, this.options);\n return true;\n }\n\n /** Start all dev servers. */\n async startAsync(startOptions: MultiBundlerStartOptions): Promise<ExpoConfig> {\n const { exp } = getConfig(this.projectRoot, { skipSDKVersionRequirement: true });\n\n await logEventAsync('Start Project', {\n sdkVersion: exp.sdkVersion ?? null,\n });\n\n const platformBundlers = getPlatformBundlers(this.projectRoot, exp);\n\n // Start all dev servers...\n for (const { type, options } of startOptions) {\n const BundlerDevServerClass = await BUNDLERS[type]();\n const server = new BundlerDevServerClass(this.projectRoot, platformBundlers, {\n devToolsPluginManager: this.devtoolsPluginManager,\n isDevClient: !!options?.devClient,\n });\n await server.startAsync(options ?? this.options);\n devServers.push(server);\n }\n\n return exp;\n }\n\n async bootstrapTypeScriptAsync() {\n const typescriptPrerequisite = await this.ensureProjectPrerequisiteAsync(\n TypeScriptProjectPrerequisite\n );\n\n if (env.EXPO_NO_TYPESCRIPT_SETUP) {\n return;\n }\n\n // Optionally, wait for the user to add TypeScript during the\n // development cycle.\n const server = devServers.find((server) => server.name === 'metro');\n if (!server) {\n return;\n }\n\n // The dev server shouldn't wait for the typescript services\n if (!typescriptPrerequisite) {\n server.waitForTypeScriptAsync().then(async (success) => {\n if (success) {\n server.startTypeScriptServices();\n }\n });\n } else {\n server.startTypeScriptServices();\n }\n }\n\n async watchEnvironmentVariables() {\n await devServers.find((server) => server.name === 'metro')?.watchEnvironmentVariables();\n }\n\n /** Stop all servers including ADB. */\n async stopAsync(): Promise<void> {\n await Promise.allSettled([\n this.notifier?.stopObserving(),\n // Stop all dev servers\n ...devServers.map((server) => server.stopAsync()),\n // Stop ADB\n AndroidDebugBridge.getServer().stopAsync(),\n ]);\n }\n}\n"],"names":["DevServerManager","urlCreator","debug","require","devServers","BUNDLERS","webpack","WebpackBundlerDevServer","metro","MetroBundlerDevServer","constructor","projectRoot","options","projectPrerequisites","notifier","watchBabelConfig","devtoolsPluginManager","DevToolsPluginManager","FileNotifier","additionalWarning","chalk","startObserving","ensureProjectPrerequisiteAsync","PrerequisiteClass","prerequisite","find","push","assertAsync","broadcastMessage","method","params","forEach","server","getNativeDevServerPort","isTargetingNative","getInstance","location","port","getWebDevServer","isTargetingWeb","getDefaultDevServer","defaultServer","assert","ensureWebDevServerRunningAsync","filter","exp","getConfig","skipPlugins","skipSDKVersionRequirement","bundler","getPlatformBundlers","web","startAsync","type","toggleRuntimeMode","isUsingDevClient","devClient","nextMode","Log","log","printItem","nextScheme","resolveSchemeAsync","scheme","devServer","isDevClient","getUrlCreator","defaults","startOptions","logEventAsync","sdkVersion","platformBundlers","BundlerDevServerClass","devToolsPluginManager","bootstrapTypeScriptAsync","typescriptPrerequisite","TypeScriptProjectPrerequisite","env","EXPO_NO_TYPESCRIPT_SETUP","name","waitForTypeScriptAsync","then","success","startTypeScriptServices","watchEnvironmentVariables","stopAsync","Promise","allSettled","stopObserving","map","AndroidDebugBridge","getServer"],"mappings":"AAAA;;;;+BAoCaA,kBAAgB;;aAAhBA,gBAAgB;;;yBApCS,cAAc;;;;;;;8DACjC,QAAQ;;;;;;;8DACT,OAAO;;;;;;4EAGS,yBAAyB;kCACvB,oBAAoB;qBACpC,WAAW;8BACF,0BAA0B;qBACnC,iBAAiB;2BACP,uBAAuB;+CAEP,oDAAoD;+BACxE,4BAA4B;2DAClB,0BAA0B;gCAC3B,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAuIhDC,WAAU;AArIhB,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,oCAAoC,CAAC,AAAsB,AAAC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/E3E,KAAAA,CAA+E,GAA/EA,GAAoD,CAAEgF,yBAAyB,EAAE,CAAA,CAAC;IAC1F;IAEA,oCAAoC,SAC9BC,SAAS,GAAkB;YAE7B,GAAa;QADf,MAAMC,OAAO,CAACC,UAAU,CAAC;YACvB,CAAA,GAAa,GAAb,IAAI,CAACzE,QAAQ,SAAe,GAA5B,KAAA,CAA4B,GAA5B,GAAa,CAAE0E,aAAa,EAAE;YAC9B,uBAAuB;eACpBpF,UAAU,CAACqF,GAAG,CAAC,CAACzD,MAAM,GAAKA,MAAM,CAACqD,SAAS,EAAE,CAAC;YACjD,WAAW;YACXK,IAAkB,CAACC,SAAS,EAAE,CAACN,SAAS,EAAE;SAC3C,CAAC,CAAC;IACL;CACD"}
|
|
@@ -14,9 +14,10 @@ function _export(target, all) {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
_export(exports, {
|
|
17
|
-
cachedSourceMaps: ()=>cachedSourceMaps,
|
|
18
17
|
createMetroEndpointAsync: ()=>createMetroEndpointAsync,
|
|
19
|
-
|
|
18
|
+
requireFileContentsWithMetro: ()=>requireFileContentsWithMetro,
|
|
19
|
+
getStaticRenderFunctionsForEntry: ()=>getStaticRenderFunctionsForEntry,
|
|
20
|
+
evalMetro: ()=>evalMetro,
|
|
20
21
|
evalMetroNoHandling: ()=>evalMetroNoHandling
|
|
21
22
|
});
|
|
22
23
|
function _fs() {
|
|
@@ -26,6 +27,13 @@ function _fs() {
|
|
|
26
27
|
};
|
|
27
28
|
return data;
|
|
28
29
|
}
|
|
30
|
+
function _nodeFetch() {
|
|
31
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("node-fetch"));
|
|
32
|
+
_nodeFetch = function() {
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
29
37
|
function _path() {
|
|
30
38
|
const data = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
31
39
|
_path = function() {
|
|
@@ -40,18 +48,34 @@ function _requireFromString() {
|
|
|
40
48
|
};
|
|
41
49
|
return data;
|
|
42
50
|
}
|
|
51
|
+
function _resolveFrom() {
|
|
52
|
+
const data = /*#__PURE__*/ _interopRequireDefault(require("resolve-from"));
|
|
53
|
+
_resolveFrom = function() {
|
|
54
|
+
return data;
|
|
55
|
+
};
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
43
58
|
const _metroErrorInterface = require("./metro/metroErrorInterface");
|
|
44
59
|
const _manifestMiddleware = require("./middleware/ManifestMiddleware");
|
|
45
60
|
const _metroOptions = require("./middleware/metroOptions");
|
|
46
61
|
const _serverLogLikeMetro = require("./serverLogLikeMetro");
|
|
62
|
+
const _ansi = require("../../utils/ansi");
|
|
47
63
|
const _delay = require("../../utils/delay");
|
|
48
64
|
const _errors = require("../../utils/errors");
|
|
65
|
+
const _fn = require("../../utils/fn");
|
|
49
66
|
const _profile = require("../../utils/profile");
|
|
50
67
|
function _interopRequireDefault(obj) {
|
|
51
68
|
return obj && obj.__esModule ? obj : {
|
|
52
69
|
default: obj
|
|
53
70
|
};
|
|
54
71
|
}
|
|
72
|
+
class MetroNodeError extends Error {
|
|
73
|
+
constructor(message, rawObject){
|
|
74
|
+
super(message);
|
|
75
|
+
this.rawObject = rawObject;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const debug = require("debug")("expo:start:server:node-renderer");
|
|
55
79
|
const cachedSourceMaps = new Map();
|
|
56
80
|
// Support unhandled rejections
|
|
57
81
|
// Detect if running in Bun
|
|
@@ -66,6 +90,44 @@ if (!process.isBun) {
|
|
|
66
90
|
}
|
|
67
91
|
});
|
|
68
92
|
}
|
|
93
|
+
function wrapBundle(str) {
|
|
94
|
+
// Skip the metro runtime so debugging is a bit easier.
|
|
95
|
+
// Replace the __r() call with an export statement.
|
|
96
|
+
// Use gm to apply to the last require line. This is needed when the bundle has side-effects.
|
|
97
|
+
return str.replace(/^(__r\(.*\);)$/gm, "module.exports = $1");
|
|
98
|
+
}
|
|
99
|
+
// TODO(EvanBacon): Group all the code together and version.
|
|
100
|
+
const getRenderModuleId = (projectRoot, entry = "expo-router/node/render.js")=>{
|
|
101
|
+
const moduleId = _resolveFrom().default.silent(projectRoot, entry);
|
|
102
|
+
if (!moduleId) {
|
|
103
|
+
throw new Error(`A version of expo-router with Node.js support is not installed in the project.`);
|
|
104
|
+
}
|
|
105
|
+
return moduleId;
|
|
106
|
+
};
|
|
107
|
+
const moveStaticRenderFunction = (0, _fn.memoize)(async (projectRoot, requiredModuleId)=>{
|
|
108
|
+
// Copy the file into the project to ensure it works in monorepos.
|
|
109
|
+
// This means the file cannot have any relative imports.
|
|
110
|
+
const tempDir = _path().default.join(projectRoot, ".expo/static");
|
|
111
|
+
await _fs().default.promises.mkdir(tempDir, {
|
|
112
|
+
recursive: true
|
|
113
|
+
});
|
|
114
|
+
const moduleId = _path().default.join(tempDir, "render.js");
|
|
115
|
+
await _fs().default.promises.writeFile(moduleId, await _fs().default.promises.readFile(requiredModuleId, "utf8"));
|
|
116
|
+
// Sleep to give watchman time to register the file.
|
|
117
|
+
await (0, _delay.delayAsync)(50);
|
|
118
|
+
return moduleId;
|
|
119
|
+
});
|
|
120
|
+
/** @returns the js file contents required to generate the static generation function. */ async function getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, props, entry) {
|
|
121
|
+
const root = (0, _manifestMiddleware.getMetroServerRoot)(projectRoot);
|
|
122
|
+
const requiredModuleId = getRenderModuleId(root, entry);
|
|
123
|
+
let moduleId = requiredModuleId;
|
|
124
|
+
// Cannot be accessed using Metro's server API, we need to move the file
|
|
125
|
+
// into the project root and try again.
|
|
126
|
+
if (_path().default.relative(root, moduleId).startsWith("..")) {
|
|
127
|
+
moduleId = await moveStaticRenderFunction(projectRoot, requiredModuleId);
|
|
128
|
+
}
|
|
129
|
+
return requireFileContentsWithMetro(root, devServerUrl, moduleId, props);
|
|
130
|
+
}
|
|
69
131
|
async function ensureFileInRootDirectory(projectRoot, otherFile) {
|
|
70
132
|
// Cannot be accessed using Metro's server API, we need to move the file
|
|
71
133
|
// into the project root and try again.
|
|
@@ -106,14 +168,48 @@ async function createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFileP
|
|
|
106
168
|
}
|
|
107
169
|
return url;
|
|
108
170
|
}
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
171
|
+
async function requireFileContentsWithMetro(projectRoot, devServerUrl, absoluteFilePath, props) {
|
|
172
|
+
const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);
|
|
173
|
+
return await metroFetchAsync(projectRoot, url);
|
|
174
|
+
}
|
|
175
|
+
async function metroFetchAsync(projectRoot, url) {
|
|
176
|
+
debug("Fetching from Metro:", url);
|
|
177
|
+
// TODO: Skip the dev server and use the Metro instance directly for better results, faster.
|
|
178
|
+
const res = await (0, _nodeFetch().default)(url);
|
|
179
|
+
// TODO: Improve error handling
|
|
180
|
+
if (res.status === 500) {
|
|
181
|
+
const text = await res.text();
|
|
182
|
+
if (text.startsWith('{"originModulePath"') || text.startsWith('{"type":"TransformError"') || text.startsWith('{"type":"InternalError"')) {
|
|
183
|
+
const errorObject = JSON.parse(text);
|
|
184
|
+
var ref;
|
|
185
|
+
throw new MetroNodeError((ref = (0, _ansi.stripAnsi)(errorObject.message)) != null ? ref : errorObject.message, errorObject);
|
|
186
|
+
}
|
|
187
|
+
throw new Error(`[${res.status}]: ${res.statusText}\n${text}`);
|
|
116
188
|
}
|
|
189
|
+
if (!res.ok) {
|
|
190
|
+
throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);
|
|
191
|
+
}
|
|
192
|
+
const content = await res.text();
|
|
193
|
+
const map = await (0, _nodeFetch().default)(url.replace(".bundle?", ".map?")).then((r)=>r.json());
|
|
194
|
+
cachedSourceMaps.set(url, {
|
|
195
|
+
url: projectRoot,
|
|
196
|
+
map
|
|
197
|
+
});
|
|
198
|
+
return {
|
|
199
|
+
src: wrapBundle(content),
|
|
200
|
+
filename: url,
|
|
201
|
+
map
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
async function getStaticRenderFunctionsForEntry(projectRoot, devServerUrl, options, entry) {
|
|
205
|
+
const { src: scriptContents , filename } = await getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, options, entry);
|
|
206
|
+
return {
|
|
207
|
+
filename,
|
|
208
|
+
fn: await evalMetroAndWrapFunctions(projectRoot, scriptContents, filename)
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function evalMetroAndWrapFunctions(projectRoot, script, filename) {
|
|
212
|
+
const contents = evalMetro(projectRoot, script, filename);
|
|
117
213
|
// wrap each function with a try/catch that uses Metro's error formatter
|
|
118
214
|
return Object.keys(contents).reduce((acc, key)=>{
|
|
119
215
|
const fn = contents[key];
|
|
@@ -136,6 +232,24 @@ function evalMetroAndWrapFunctions(projectRoot, script, filename) {
|
|
|
136
232
|
return acc;
|
|
137
233
|
}, {});
|
|
138
234
|
}
|
|
235
|
+
function evalMetro(projectRoot, src, filename) {
|
|
236
|
+
try {
|
|
237
|
+
return evalMetroNoHandling(projectRoot, src, filename);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
// Format any errors that were thrown in the global scope of the evaluation.
|
|
240
|
+
if (error instanceof Error) {
|
|
241
|
+
(0, _metroErrorInterface.logMetroErrorAsync)({
|
|
242
|
+
projectRoot,
|
|
243
|
+
error
|
|
244
|
+
}).catch((internalError)=>{
|
|
245
|
+
debug("Failed to log metro error:", internalError);
|
|
246
|
+
throw error;
|
|
247
|
+
});
|
|
248
|
+
} else {
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
139
253
|
function evalMetroNoHandling(projectRoot, src, filename) {
|
|
140
254
|
(0, _serverLogLikeMetro.augmentLogs)(projectRoot);
|
|
141
255
|
return (0, _profile.profile)(_requireFromString().default, "eval-metro-bundle")(src, filename);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/getStaticRenderFunctions.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 fs from 'fs';\nimport path from 'path';\nimport requireString from 'require-from-string';\n\nimport { logMetroError } from './metro/metroErrorInterface';\nimport { getMetroServerRoot } from './middleware/ManifestMiddleware';\nimport { createBundleUrlPath, ExpoMetroOptions } from './middleware/metroOptions';\nimport { augmentLogs } from './serverLogLikeMetro';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { profile } from '../../utils/profile';\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nexport const cachedSourceMaps: Map<string, { url: string; map: string }> = new Map();\n\n// Support unhandled rejections\n// Detect if running in Bun\n\n// @ts-expect-error: This is a global variable that is set by Bun.\nif (!process.isBun) {\n require('source-map-support').install({\n retrieveSourceMap(source: string) {\n if (cachedSourceMaps.has(source)) {\n return cachedSourceMaps.get(source);\n }\n return null;\n },\n });\n}\n\nasync function ensureFileInRootDirectory(projectRoot: string, otherFile: string) {\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (!path.relative(projectRoot, otherFile).startsWith('..' + path.sep)) {\n return otherFile;\n }\n\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static-tmp');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, path.basename(otherFile));\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(otherFile, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n}\n\nexport async function createMetroEndpointAsync(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);\n const serverPath = path.relative(root, safeOtherFile).replace(/\\.[jt]sx?$/, '');\n\n const urlFragment = createBundleUrlPath({\n mainModuleName: serverPath,\n lazy: false,\n asyncRoutes: false,\n inlineSourceMap: false,\n engine: 'hermes',\n minify: false,\n bytecode: false,\n ...props,\n });\n\n let url: string;\n if (devServerUrl) {\n url = new URL(urlFragment.replace(/^\\//, ''), devServerUrl).toString();\n } else {\n url = '/' + urlFragment.replace(/^\\/+/, '');\n }\n return url;\n}\n\nexport function evalMetroAndWrapFunctions<T = Record<string, any>>(\n projectRoot: string,\n script: string,\n filename: string\n): T {\n // TODO: Add back stack trace logic that hides traces from metro-runtime and other internal modules.\n const contents = evalMetroNoHandling(projectRoot, script, filename);\n\n if (!contents) {\n // This can happen if ErrorUtils isn't working correctly on web and failing to throw an error when a module throws.\n // This is unexpected behavior and should not be pretty formatted, therefore we're avoiding CommandError.\n throw new Error(\n '[Expo SSR] Module returned undefined, this could be due to a misconfiguration in Metro error handling'\n );\n }\n // wrap each function with a try/catch that uses Metro's error formatter\n return Object.keys(contents).reduce((acc, key) => {\n const fn = contents[key];\n if (typeof fn !== 'function') {\n return { ...acc, [key]: fn };\n }\n\n acc[key] = async function (...props: any[]) {\n try {\n return await fn.apply(this, props);\n } catch (error: any) {\n await logMetroError(projectRoot, { error });\n throw new SilentError(error);\n }\n };\n return acc;\n }, {} as any);\n}\n\nexport function evalMetroNoHandling(projectRoot: string, src: string, filename: string) {\n augmentLogs(projectRoot);\n\n return profile(requireString, 'eval-metro-bundle')(src, filename);\n}\n"],"names":["cachedSourceMaps","createMetroEndpointAsync","evalMetroAndWrapFunctions","evalMetroNoHandling","Map","process","isBun","require","install","retrieveSourceMap","source","has","get","ensureFileInRootDirectory","projectRoot","otherFile","path","relative","startsWith","sep","tempDir","join","fs","promises","mkdir","recursive","moduleId","basename","writeFile","readFile","delayAsync","devServerUrl","absoluteFilePath","props","root","getMetroServerRoot","safeOtherFile","serverPath","replace","urlFragment","createBundleUrlPath","mainModuleName","lazy","asyncRoutes","inlineSourceMap","engine","minify","bytecode","url","URL","toString","script","filename","contents","Error","Object","keys","reduce","acc","key","fn","apply","error","logMetroError","SilentError","src","augmentLogs","profile","requireString"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IAeaA,gBAAgB,MAAhBA,gBAAgB;IAmCPC,wBAAwB,MAAxBA,wBAAwB;IA8B9BC,yBAAyB,MAAzBA,yBAAyB;IAkCzBC,mBAAmB,MAAnBA,mBAAmB;;;8DAlHpB,IAAI;;;;;;;8DACF,MAAM;;;;;;;8DACG,qBAAqB;;;;;;qCAEjB,6BAA6B;oCACxB,iCAAiC;8BACd,2BAA2B;oCACrD,sBAAsB;uBACvB,mBAAmB;wBAClB,oBAAoB;yBACxB,qBAAqB;;;;;;AAKtC,MAAMH,gBAAgB,GAA8C,IAAII,GAAG,EAAE,AAAC;AAErF,+BAA+B;AAC/B,2BAA2B;AAE3B,kEAAkE;AAClE,IAAI,CAACC,OAAO,CAACC,KAAK,EAAE;IAClBC,OAAO,CAAC,oBAAoB,CAAC,CAACC,OAAO,CAAC;QACpCC,iBAAiB,EAACC,MAAc,EAAE;YAChC,IAAIV,gBAAgB,CAACW,GAAG,CAACD,MAAM,CAAC,EAAE;gBAChC,OAAOV,gBAAgB,CAACY,GAAG,CAACF,MAAM,CAAC,CAAC;YACtC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,eAAeG,yBAAyB,CAACC,WAAmB,EAAEC,SAAiB,EAAE;IAC/E,wEAAwE;IACxE,uCAAuC;IACvC,IAAI,CAACC,KAAI,EAAA,QAAA,CAACC,QAAQ,CAACH,WAAW,EAAEC,SAAS,CAAC,CAACG,UAAU,CAAC,IAAI,GAAGF,KAAI,EAAA,QAAA,CAACG,GAAG,CAAC,EAAE;QACtE,OAAOJ,S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MAAMC,IAAAA,oBAAa,cAAA,EAACjD,WAAW,EAAE;oBAAEgD,KAAK;iBAAE,CAAC,CAAC;gBAC5C,MAAM,IAAIE,OAAW,YAAA,CAACF,KAAK,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,CAAC;QACF,OAAOJ,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAQ,CAAC;AAChB,CAAC;AAEM,SAASvD,mBAAmB,CAACW,WAAmB,EAAEmD,GAAW,EAAEb,QAAgB,EAAE;IACtFc,IAAAA,mBAAW,YAAA,EAACpD,WAAW,CAAC,CAAC;IAEzB,OAAOqD,IAAAA,QAAO,QAAA,EAACC,kBAAa,EAAA,QAAA,EAAE,mBAAmB,CAAC,CAACH,GAAG,EAAEb,QAAQ,CAAC,CAAC;AACpE,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/getStaticRenderFunctions.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 fs from 'fs';\nimport fetch from 'node-fetch';\nimport path from 'path';\nimport requireString from 'require-from-string';\nimport resolveFrom from 'resolve-from';\n\nimport { logMetroError, logMetroErrorAsync } from './metro/metroErrorInterface';\nimport { getMetroServerRoot } from './middleware/ManifestMiddleware';\nimport { createBundleUrlPath, ExpoMetroOptions } from './middleware/metroOptions';\nimport { augmentLogs } from './serverLogLikeMetro';\nimport { stripAnsi } from '../../utils/ansi';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { memoize } from '../../utils/fn';\nimport { profile } from '../../utils/profile';\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\nclass MetroNodeError extends Error {\n constructor(\n message: string,\n public rawObject: any\n ) {\n super(message);\n }\n}\n\nconst debug = require('debug')('expo:start:server:node-renderer') as typeof console.log;\n\nconst cachedSourceMaps: Map<string, { url: string; map: string }> = new Map();\n\n// Support unhandled rejections\n// Detect if running in Bun\n\n// @ts-expect-error: This is a global variable that is set by Bun.\nif (!process.isBun) {\n require('source-map-support').install({\n retrieveSourceMap(source: string) {\n if (cachedSourceMaps.has(source)) {\n return cachedSourceMaps.get(source);\n }\n return null;\n },\n });\n}\n\nfunction wrapBundle(str: string) {\n // Skip the metro runtime so debugging is a bit easier.\n // Replace the __r() call with an export statement.\n // Use gm to apply to the last require line. This is needed when the bundle has side-effects.\n return str.replace(/^(__r\\(.*\\);)$/gm, 'module.exports = $1');\n}\n\n// TODO(EvanBacon): Group all the code together and version.\nconst getRenderModuleId = (\n projectRoot: string,\n entry: string = 'expo-router/node/render.js'\n): string => {\n const moduleId = resolveFrom.silent(projectRoot, entry);\n if (!moduleId) {\n throw new Error(\n `A version of expo-router with Node.js support is not installed in the project.`\n );\n }\n\n return moduleId;\n};\n\nconst moveStaticRenderFunction = memoize(async (projectRoot: string, requiredModuleId: string) => {\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, 'render.js');\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(requiredModuleId, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n});\n\n/** @returns the js file contents required to generate the static generation function. */\nasync function getStaticRenderFunctionsContentAsync(\n projectRoot: string,\n devServerUrl: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>,\n entry?: string\n): Promise<{ src: string; filename: string }> {\n const root = getMetroServerRoot(projectRoot);\n const requiredModuleId = getRenderModuleId(root, entry);\n let moduleId = requiredModuleId;\n\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (path.relative(root, moduleId).startsWith('..')) {\n moduleId = await moveStaticRenderFunction(projectRoot, requiredModuleId);\n }\n\n return requireFileContentsWithMetro(root, devServerUrl, moduleId, props);\n}\n\nasync function ensureFileInRootDirectory(projectRoot: string, otherFile: string) {\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (!path.relative(projectRoot, otherFile).startsWith('..' + path.sep)) {\n return otherFile;\n }\n\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static-tmp');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, path.basename(otherFile));\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(otherFile, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n}\n\nexport async function createMetroEndpointAsync(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);\n const serverPath = path.relative(root, safeOtherFile).replace(/\\.[jt]sx?$/, '');\n\n const urlFragment = createBundleUrlPath({\n mainModuleName: serverPath,\n lazy: false,\n asyncRoutes: false,\n inlineSourceMap: false,\n engine: 'hermes',\n minify: false,\n bytecode: false,\n ...props,\n });\n\n let url: string;\n if (devServerUrl) {\n url = new URL(urlFragment.replace(/^\\//, ''), devServerUrl).toString();\n } else {\n url = '/' + urlFragment.replace(/^\\/+/, '');\n }\n return url;\n}\n\nexport async function requireFileContentsWithMetro(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>\n): Promise<{ src: string; filename: string }> {\n const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);\n return await metroFetchAsync(projectRoot, url);\n}\n\nasync function metroFetchAsync(\n projectRoot: string,\n url: string\n): Promise<{ src: string; filename: string; map?: any }> {\n debug('Fetching from Metro:', url);\n // TODO: Skip the dev server and use the Metro instance directly for better results, faster.\n const res = await fetch(url);\n\n // TODO: Improve error handling\n if (res.status === 500) {\n const text = await res.text();\n if (\n text.startsWith('{\"originModulePath\"') ||\n text.startsWith('{\"type\":\"TransformError\"') ||\n text.startsWith('{\"type\":\"InternalError\"')\n ) {\n const errorObject = JSON.parse(text);\n\n throw new MetroNodeError(stripAnsi(errorObject.message) ?? errorObject.message, errorObject);\n }\n throw new Error(`[${res.status}]: ${res.statusText}\\n${text}`);\n }\n\n if (!res.ok) {\n throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);\n }\n\n const content = await res.text();\n\n const map = await fetch(url.replace('.bundle?', '.map?')).then((r) => r.json());\n cachedSourceMaps.set(url, { url: projectRoot, map });\n\n return {\n src: wrapBundle(content),\n filename: url,\n map,\n };\n}\n\nexport async function getStaticRenderFunctionsForEntry<T = any>(\n projectRoot: string,\n devServerUrl: string,\n options: PickPartial<ExpoMetroOptions, 'mainModuleName' | 'bytecode'>,\n entry: string\n) {\n const { src: scriptContents, filename } = await getStaticRenderFunctionsContentAsync(\n projectRoot,\n devServerUrl,\n options,\n entry\n );\n\n return {\n filename,\n fn: await evalMetroAndWrapFunctions<T>(projectRoot, scriptContents, filename),\n };\n}\n\nfunction evalMetroAndWrapFunctions<T = Record<string, any>>(\n projectRoot: string,\n script: string,\n filename: string\n): Promise<T> {\n const contents = evalMetro(projectRoot, script, filename);\n // wrap each function with a try/catch that uses Metro's error formatter\n return Object.keys(contents).reduce((acc, key) => {\n const fn = contents[key];\n if (typeof fn !== 'function') {\n return { ...acc, [key]: fn };\n }\n\n acc[key] = async function (...props: any[]) {\n try {\n return await fn.apply(this, props);\n } catch (error: any) {\n await logMetroError(projectRoot, { error });\n throw new SilentError(error);\n }\n };\n return acc;\n }, {} as any);\n}\n\nexport function evalMetro(projectRoot: string, src: string, filename: string) {\n try {\n return evalMetroNoHandling(projectRoot, src, filename);\n } catch (error: any) {\n // Format any errors that were thrown in the global scope of the evaluation.\n if (error instanceof Error) {\n logMetroErrorAsync({ projectRoot, error }).catch((internalError) => {\n debug('Failed to log metro error:', internalError);\n throw error;\n });\n } else {\n throw error;\n }\n }\n}\n\nexport function evalMetroNoHandling(projectRoot: string, src: string, filename: string) {\n augmentLogs(projectRoot);\n\n return profile(requireString, 'eval-metro-bundle')(src, filename);\n}\n"],"names":["createMetroEndpointAsync","requireFileContentsWithMetro","getStaticRenderFunctionsForEntry","evalMetro","evalMetroNoHandling","MetroNodeError","Error","constructor","message","rawObject","debug","require","cachedSourceMaps","Map","process","isBun","install","retrieveSourceMap","source","has","get","wrapBundle","str","replace","getRenderModuleId","projectRoot","entry","moduleId","resolveFrom","silent","moveStaticRenderFunction","memoize","requiredModuleId","tempDir","path","join","fs","promises","mkdir","recursive","writeFile","readFile","delayAsync","getStaticRenderFunctionsContentAsync","devServerUrl","props","root","getMetroServerRoot","relative","startsWith","ensureFileInRootDirectory","otherFile","sep","basename","absoluteFilePath","safeOtherFile","serverPath","urlFragment","createBundleUrlPath","mainModuleName","lazy","asyncRoutes","inlineSourceMap","engine","minify","bytecode","url","URL","toString","metroFetchAsync","res","fetch","status","text","errorObject","JSON","parse","stripAnsi","statusText","ok","content","map","then","r","json","set","src","filename","options","scriptContents","fn","evalMetroAndWrapFunctions","script","contents","Object","keys","reduce","acc","key","apply","error","logMetroError","SilentError","logMetroErrorAsync","catch","internalError","augmentLogs","profile","requireString"],"mappings":"AAAA;;;;;CAKC,GACD;;;;;;;;;;;IAuHsBA,wBAAwB,MAAxBA,wBAAwB;IA8BxBC,4BAA4B,MAA5BA,4BAA4B;IAiD5BC,gCAAgC,MAAhCA,gCAAgC;IA4CtCC,SAAS,MAATA,SAAS;IAgBTC,mBAAmB,MAAnBA,mBAAmB;;;8DAlQpB,IAAI;;;;;;;8DACD,YAAY;;;;;;;8DACb,MAAM;;;;;;;8DACG,qBAAqB;;;;;;;8DACvB,cAAc;;;;;;qCAEY,6BAA6B;oCAC5C,iCAAiC;8BACd,2BAA2B;oCACrD,sBAA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