@expo/cli 0.18.19 → 0.18.21
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 +133 -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 +5 -49
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/favicon.js +5 -4
- package/build/src/export/favicon.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/server/BundlerDevServer.js +10 -3
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +19 -4
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevelopmentSession.js +21 -11
- package/build/src/start/server/DevelopmentSession.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 +469 -177
- 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 +44 -37
- 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 +44 -21
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +9 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +7 -4
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +16 -4
- 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/export/fork-bundleAsync.js +0 -284
- package/build/src/export/fork-bundleAsync.js.map +0 -1
|
@@ -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 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;AAO3F,MAAMC,UAAU,GAAuB,EAAE,AAAC;AAE1C,MAAMC,QAAQ,GAAG;IACfC,OAAO,EAAE,IACPH,OAAO,CAAC,mCAAmC,CAAC,CACzCI,uBAAuB,AAA8E;IAC1GC,KAAK,EAAE,IACLL,OAAO,CAAC,+BAA+B,CAAC,CACrCM,qBAAqB,AAAwE;CACnG,AAAC;AAGK,MAAMT,gBAAgB;IAM3BU,YACSC,WAAmB,EAEnBC,OAA4B,CACnC;QAHOD,mBAAAA,WAAmB,CAAA;QAEnBC,eAAAA,OAA4B,CAAA;aAR7BC,oBAAoB,GAAqC,EAAE;aAG3DC,QAAQ,GAAwB,IAAI;QAO1C,IAAI,CAACA,QAAQ,GAAG,IAAI,CAACC,gBAAgB,EAAE,CAAC;QACxC,IAAI,CAACC,qBAAqB,GAAG,IAAIC,sBAAqB,QAAA,CAACN,WAAW,C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AChC,OAAO;QACT,CAAC;QAED,6DAA6D;QAC7D,qBAAqB;QACrB,MAAM9C,MAAM,GAAG5B,UAAU,CAACqB,IAAI,CAAC,CAACO,MAAM,GAAKA,MAAM,CAAC+C,IAAI,KAAK,OAAO,CAAC,AAAC;QACpE,IAAI,CAAC/C,MAAM,EAAE;YACX,OAAO;QACT,CAAC;QAED,4DAA4D;QAC5D,IAAI,CAAC2C,sBAAsB,EAAE;YAC3B3C,MAAM,CAACgD,sBAAsB,EAAE,CAACC,IAAI,CAAC,OAAOC,OAAO,GAAK;gBACtD,IAAIA,OAAO,EAAE;oBACXlD,MAAM,CAACmD,uBAAuB,EAAE,CAAC;gBACnC,CAAC;YACH,CAAC,CAAC,CAAC;QACL,OAAO;YACLnD,MAAM,CAACmD,uBAAuB,EAAE,CAAC;QACnC,CAAC;IACH;UAEMC,yBAAyB,GAAG;YAC1BhF,GAAoD;QAA1D,OAAMA,CAAAA,GAAoD,GAApDA,UAAU,CAACqB,IAAI,CAAC,CAACO,MAAM,GAAKA,MAAM,CAAC+C,IAAI,KAAK,OAAO,CAAC,SAA2B,GAA/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"}
|
|
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 ADB\n AndroidDebugBridge.getServer().stopAsync(),\n // Stop all dev servers\n ...devServers.map((server) =>\n server.stopAsync().catch((error) => {\n Log.error(`Failed to stop dev server (bundler: ${server.name})`);\n Log.exception(error);\n })\n ),\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","AndroidDebugBridge","getServer","map","catch","error","exception"],"mappings":"AAAA;;;;+BAoCaA,kBAAgB;;aAAhBA,gBAAgB;;;yBApCS,cAAc;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AAC4C,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;oBACjEpB,IAAG,IAAA,CAACmC,SAAS,CAACD,KAAK,CAAC,CAAC;gBACvB,CAAC,CAAC,CACH;SACF,CAAC,CAAC;IACL;CACD"}
|
|
@@ -79,8 +79,8 @@ class DevelopmentSession {
|
|
|
79
79
|
* @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.
|
|
80
80
|
*/ async startAsync({ exp =(0, _config().getConfig)(this.projectRoot).exp , runtime }) {
|
|
81
81
|
try {
|
|
82
|
-
if (_env.env.EXPO_OFFLINE) {
|
|
83
|
-
debug("This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.");
|
|
82
|
+
if (_env.env.CI || _env.env.EXPO_OFFLINE) {
|
|
83
|
+
debug(_env.env.CI ? "This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in CI." : "This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.");
|
|
84
84
|
this.stopNotifying();
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
@@ -120,17 +120,27 @@ class DevelopmentSession {
|
|
|
120
120
|
}
|
|
121
121
|
this.timeout = null;
|
|
122
122
|
}
|
|
123
|
-
async closeAsync() {
|
|
123
|
+
/** Try to close any pending development sessions, but always resolve */ async closeAsync() {
|
|
124
124
|
this.stopNotifying();
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return;
|
|
125
|
+
if (_env.env.CI || _env.env.EXPO_OFFLINE) {
|
|
126
|
+
return false;
|
|
128
127
|
}
|
|
129
|
-
|
|
130
|
-
await (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
128
|
+
try {
|
|
129
|
+
const deviceIds = await this.getDeviceInstallationIdsAsync();
|
|
130
|
+
if (!await isAuthenticatedAsync() && !(deviceIds == null ? void 0 : deviceIds.length)) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (this.url) {
|
|
134
|
+
await (0, _updateDevelopmentSession.closeDevelopmentSessionAsync)({
|
|
135
|
+
url: this.url,
|
|
136
|
+
deviceIds
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
} catch (error) {
|
|
141
|
+
debug(`Error closing development session API: ${error}`);
|
|
142
|
+
this.onError(error);
|
|
143
|
+
return false;
|
|
134
144
|
}
|
|
135
145
|
}
|
|
136
146
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport { env } from '../../utils/env';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nconst UPDATE_FREQUENCY = 20 * 1000; // 20 seconds\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n protected timeout: NodeJS.Timeout | null = null;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null,\n /** Catch any errors that may occur during the `startAsync` method. */\n private onError: (error: Error) => void\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * This method starts an interval that will continue to ping the servers until we stop it.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n try {\n if (env.EXPO_OFFLINE) {\n debug(\n 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.'\n );\n this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n // debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n }\n\n this.stopNotifying();\n\n this.timeout = setTimeout(() => this.startAsync({ exp, runtime }), UPDATE_FREQUENCY);\n } catch (error: any) {\n debug(`Error updating development session API: ${error}`);\n this.stopNotifying();\n this.onError(error);\n }\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Stop notifying the Expo servers that the development session is running. */\n public stopNotifying() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = null;\n }\n\n public async closeAsync(): Promise<
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/DevelopmentSession.ts"],"sourcesContent":["import { ExpoConfig, getConfig } from '@expo/config';\n\nimport {\n closeDevelopmentSessionAsync,\n updateDevelopmentSessionAsync,\n} from '../../api/updateDevelopmentSession';\nimport { getUserAsync } from '../../api/user/user';\nimport { env } from '../../utils/env';\nimport * as ProjectDevices from '../project/devices';\n\nconst debug = require('debug')('expo:start:server:developmentSession') as typeof console.log;\n\nconst UPDATE_FREQUENCY = 20 * 1000; // 20 seconds\n\nasync function isAuthenticatedAsync(): Promise<boolean> {\n return !!(await getUserAsync().catch(() => null));\n}\n\nexport class DevelopmentSession {\n protected timeout: NodeJS.Timeout | null = null;\n\n constructor(\n /** Project root directory. */\n private projectRoot: string,\n /** Development Server URL. */\n public url: string | null,\n /** Catch any errors that may occur during the `startAsync` method. */\n private onError: (error: Error) => void\n ) {}\n\n /**\n * Notify the Expo servers that a project is running, this enables the Expo Go app\n * and Dev Clients to offer a \"recently in development\" section for quick access.\n *\n * This method starts an interval that will continue to ping the servers until we stop it.\n *\n * @param projectRoot Project root folder, used for retrieving device installation IDs.\n * @param props.exp Partial Expo config with values that will be used in the Expo Go app.\n * @param props.runtime which runtime the app should be opened in. `native` for dev clients, `web` for web browsers.\n */\n public async startAsync({\n exp = getConfig(this.projectRoot).exp,\n runtime,\n }: {\n exp?: Pick<ExpoConfig, 'name' | 'description' | 'slug' | 'primaryColor'>;\n runtime: 'native' | 'web';\n }): Promise<void> {\n try {\n if (env.CI || env.EXPO_OFFLINE) {\n debug(\n env.CI\n ? 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in CI.'\n : 'This project will not be suggested in Expo Go or Dev Clients because Expo CLI is running in offline-mode.'\n );\n this.stopNotifying();\n return;\n }\n\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n debug(\n 'Development session will not ping because the user is not authenticated and there are no devices.'\n );\n this.stopNotifying();\n return;\n }\n\n if (this.url) {\n // debug(`Development session ping (runtime: ${runtime}, url: ${this.url})`);\n\n await updateDevelopmentSessionAsync({\n url: this.url,\n runtime,\n exp,\n deviceIds,\n });\n }\n\n this.stopNotifying();\n\n this.timeout = setTimeout(() => this.startAsync({ exp, runtime }), UPDATE_FREQUENCY);\n } catch (error: any) {\n debug(`Error updating development session API: ${error}`);\n this.stopNotifying();\n this.onError(error);\n }\n }\n\n /** Get all recent devices for the project. */\n private async getDeviceInstallationIdsAsync(): Promise<string[]> {\n const { devices } = await ProjectDevices.getDevicesInfoAsync(this.projectRoot);\n return devices.map(({ installationId }) => installationId);\n }\n\n /** Stop notifying the Expo servers that the development session is running. */\n public stopNotifying() {\n if (this.timeout) {\n clearTimeout(this.timeout);\n }\n this.timeout = null;\n }\n\n /** Try to close any pending development sessions, but always resolve */\n public async closeAsync(): Promise<boolean> {\n this.stopNotifying();\n\n if (env.CI || env.EXPO_OFFLINE) {\n return false;\n }\n\n try {\n const deviceIds = await this.getDeviceInstallationIdsAsync();\n\n if (!(await isAuthenticatedAsync()) && !deviceIds?.length) {\n return false;\n }\n\n if (this.url) {\n await closeDevelopmentSessionAsync({\n url: this.url,\n deviceIds,\n });\n }\n\n return true;\n } catch (error: any) {\n debug(`Error closing development session API: ${error}`);\n this.onError(error);\n return false;\n }\n }\n}\n"],"names":["DevelopmentSession","debug","require","UPDATE_FREQUENCY","isAuthenticatedAsync","getUserAsync","catch","constructor","projectRoot","url","onError","timeout","startAsync","exp","getConfig","runtime","env","CI","EXPO_OFFLINE","stopNotifying","deviceIds","getDeviceInstallationIdsAsync","length","updateDevelopmentSessionAsync","setTimeout","error","devices","ProjectDevices","getDevicesInfoAsync","map","installationId","clearTimeout","closeAsync","closeDevelopmentSessionAsync"],"mappings":"AAAA;;;;+BAkBaA,oBAAkB;;aAAlBA,kBAAkB;;;yBAlBO,cAAc;;;;;;0CAK7C,oCAAoC;sBACd,qBAAqB;qBAC9B,iBAAiB;+DACL,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,sCAAsC,CAAC,AAAsB,AAAC;AAE7F,MAAMC,gBAAgB,GAAG,EAAE,GAAG,IAAI,AAAC,EAAC,aAAa;AAEjD,eAAeC,oBAAoB,GAAqB;IACtD,OAAO,CAAC,CAAE,MAAMC,IAAAA,KAAY,aAAA,GAAE,CAACC,KAAK,CAAC,IAAM,IAAI,CAAC,AAAC,CAAC;AACpD,CAAC;AAEM,MAAMN,kBAAkB;IAG7BO,YAEUC,WAAmB,EAEpBC,GAAkB,EAEjBC,OAA+B,CACvC;QALQF,mBAAAA,WAAmB,CAAA;QAEpBC,WAAAA,GAAkB,CAAA;QAEjBC,eAAAA,OAA+B,CAAA;aAR/BC,OAAO,GA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,CAAC;YACzD,IAAI,CAACf,OAAO,CAACe,KAAK,CAAC,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC;IACH;CACD"}
|
|
@@ -14,10 +14,9 @@ function _export(target, all) {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
_export(exports, {
|
|
17
|
+
cachedSourceMaps: ()=>cachedSourceMaps,
|
|
17
18
|
createMetroEndpointAsync: ()=>createMetroEndpointAsync,
|
|
18
|
-
|
|
19
|
-
getStaticRenderFunctionsForEntry: ()=>getStaticRenderFunctionsForEntry,
|
|
20
|
-
evalMetro: ()=>evalMetro,
|
|
19
|
+
evalMetroAndWrapFunctions: ()=>evalMetroAndWrapFunctions,
|
|
21
20
|
evalMetroNoHandling: ()=>evalMetroNoHandling
|
|
22
21
|
});
|
|
23
22
|
function _fs() {
|
|
@@ -27,13 +26,6 @@ function _fs() {
|
|
|
27
26
|
};
|
|
28
27
|
return data;
|
|
29
28
|
}
|
|
30
|
-
function _nodeFetch() {
|
|
31
|
-
const data = /*#__PURE__*/ _interopRequireDefault(require("node-fetch"));
|
|
32
|
-
_nodeFetch = function() {
|
|
33
|
-
return data;
|
|
34
|
-
};
|
|
35
|
-
return data;
|
|
36
|
-
}
|
|
37
29
|
function _path() {
|
|
38
30
|
const data = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
39
31
|
_path = function() {
|
|
@@ -48,34 +40,18 @@ function _requireFromString() {
|
|
|
48
40
|
};
|
|
49
41
|
return data;
|
|
50
42
|
}
|
|
51
|
-
function _resolveFrom() {
|
|
52
|
-
const data = /*#__PURE__*/ _interopRequireDefault(require("resolve-from"));
|
|
53
|
-
_resolveFrom = function() {
|
|
54
|
-
return data;
|
|
55
|
-
};
|
|
56
|
-
return data;
|
|
57
|
-
}
|
|
58
43
|
const _metroErrorInterface = require("./metro/metroErrorInterface");
|
|
59
44
|
const _manifestMiddleware = require("./middleware/ManifestMiddleware");
|
|
60
45
|
const _metroOptions = require("./middleware/metroOptions");
|
|
61
46
|
const _serverLogLikeMetro = require("./serverLogLikeMetro");
|
|
62
|
-
const _ansi = require("../../utils/ansi");
|
|
63
47
|
const _delay = require("../../utils/delay");
|
|
64
48
|
const _errors = require("../../utils/errors");
|
|
65
|
-
const _fn = require("../../utils/fn");
|
|
66
49
|
const _profile = require("../../utils/profile");
|
|
67
50
|
function _interopRequireDefault(obj) {
|
|
68
51
|
return obj && obj.__esModule ? obj : {
|
|
69
52
|
default: obj
|
|
70
53
|
};
|
|
71
54
|
}
|
|
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");
|
|
79
55
|
const cachedSourceMaps = new Map();
|
|
80
56
|
// Support unhandled rejections
|
|
81
57
|
// Detect if running in Bun
|
|
@@ -90,44 +66,6 @@ if (!process.isBun) {
|
|
|
90
66
|
}
|
|
91
67
|
});
|
|
92
68
|
}
|
|
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
|
-
}
|
|
131
69
|
async function ensureFileInRootDirectory(projectRoot, otherFile) {
|
|
132
70
|
// Cannot be accessed using Metro's server API, we need to move the file
|
|
133
71
|
// into the project root and try again.
|
|
@@ -168,48 +106,14 @@ async function createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFileP
|
|
|
168
106
|
}
|
|
169
107
|
return url;
|
|
170
108
|
}
|
|
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}`);
|
|
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
109
|
function evalMetroAndWrapFunctions(projectRoot, script, filename) {
|
|
212
|
-
|
|
110
|
+
// TODO: Add back stack trace logic that hides traces from metro-runtime and other internal modules.
|
|
111
|
+
const contents = evalMetroNoHandling(projectRoot, script, filename);
|
|
112
|
+
if (!contents) {
|
|
113
|
+
// This can happen if ErrorUtils isn't working correctly on web and failing to throw an error when a module throws.
|
|
114
|
+
// This is unexpected behavior and should not be pretty formatted, therefore we're avoiding CommandError.
|
|
115
|
+
throw new Error("[Expo SSR] Module returned undefined, this could be due to a misconfiguration in Metro error handling");
|
|
116
|
+
}
|
|
213
117
|
// wrap each function with a try/catch that uses Metro's error formatter
|
|
214
118
|
return Object.keys(contents).reduce((acc, key)=>{
|
|
215
119
|
const fn = contents[key];
|
|
@@ -232,24 +136,6 @@ function evalMetroAndWrapFunctions(projectRoot, script, filename) {
|
|
|
232
136
|
return acc;
|
|
233
137
|
}, {});
|
|
234
138
|
}
|
|
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
|
-
}
|
|
253
139
|
function evalMetroNoHandling(projectRoot, src, filename) {
|
|
254
140
|
(0, _serverLogLikeMetro.augmentLogs)(projectRoot);
|
|
255
141
|
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 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,sBAAsB;sBACxB,kBAAkB;uBACjB,mBAAmB;wBAClB,oBAAoB;oBACxB,gBAAgB;yBAChB,qBAAqB;;;;;;AAK7C,MAAMC,cAAc,SAASC,KAAK;IAChCC,YACEC,OAAe,EACRC,SAAc,CACrB;QACA,KAAK,CAACD,OAAO,CAAC,CAAC;QAFRC,iBAAAA,SAAc,CAAA;IAGvB;CACD;AAED,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAExF,MAAMC,gBAAgB,GAA8C,IAAIC,GAAG,EAAE,AAAC;AAE9E,+BAA+B;AAC/B,2BAA2B;AAE3B,kEAAkE;AAClE,IAAI,CAACC,OAAO,CAACC,KAAK,EAAE;IAClBJ,OAAO,CAAC,oBAAoB,CAAC,CAACK,OAAO,CAAC;QACpCC,iBAAiB,EAACC,MAAc,EAAE;YAChC,IAAIN,gBAAgB,CAACO,GAAG,CAACD,MAAM,CAAC,EAAE;gBAChC,OAAON,gBAAgB,CAACQ,GAAG,CAACF,MAAM,CAAC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Aa,GAAK;gBAClE/F,KAAK,CAAC,4BAA4B,EAAE+F,aAAa,CAAC,CAAC;gBACnD,MAAML,KAAK,CAAC;YACd,CAAC,CAAC,CAAC;QACL,OAAO;YACL,MAAMA,KAAK,CAAC;QACd,CAAC;IACH,CAAC;AACH,CAAC;AAEM,SAAShG,mBAAmB,CAACqB,WAAmB,EAAE6D,GAAW,EAAEC,QAAgB,EAAE;IACtFmB,IAAAA,mBAAW,YAAA,EAACjF,WAAW,CAAC,CAAC;IAEzB,OAAOkF,IAAAA,QAAO,QAAA,EAACC,kBAAa,EAAA,QAAA,EAAE,mBAAmB,CAAC,CAACtB,GAAG,EAAEC,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 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,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