@expo/cli 1.0.0-canary-20250722-599a28f → 54.0.0
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/metro-require/require.js +24 -13
- package/build/src/api/getExpoSchema.js +8 -7
- package/build/src/api/getExpoSchema.js.map +1 -1
- package/build/src/expoUpdatesExports.js +28 -0
- package/build/src/expoUpdatesExports.js.map +1 -0
- package/build/src/export/embed/exportEmbedAsync.js +26 -25
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +1 -1
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +7 -4
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +20 -4
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportAsync.js +2 -2
- package/build/src/export/exportAsync.js.map +1 -1
- package/build/src/export/exportHermes.js +34 -9
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +23 -2
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/index.js +1 -0
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/metroAssetLocalPath.js.map +1 -1
- package/build/src/export/persistMetroAssets.js.map +1 -1
- package/build/src/export/resolveOptions.js +1 -0
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +12 -0
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/install/checkPackages.js +9 -1
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/lint/lintAsync.js +2 -0
- package/build/src/lint/lintAsync.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +18 -0
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveLocalTemplate.js +42 -0
- package/build/src/prebuild/resolveLocalTemplate.js.map +1 -0
- package/build/src/prebuild/resolveTemplate.js +17 -7
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +1 -0
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +5 -3
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/android/resolveOptions.js +2 -2
- package/build/src/run/android/resolveOptions.js.map +1 -1
- package/build/src/run/ios/options/resolveOptions.js +2 -2
- package/build/src/run/ios/options/resolveOptions.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +3 -0
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/serve/serveAsync.js +5 -2
- package/build/src/serve/serveAsync.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/server/DevToolsPluginManager.js +7 -35
- package/build/src/start/server/DevToolsPluginManager.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +88 -56
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +66 -25
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.js +6 -6
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/createExpoAutolinkingResolver.js +121 -0
- package/build/src/start/server/metro/createExpoAutolinkingResolver.js.map +1 -0
- package/build/src/start/server/metro/createExpoFallbackResolver.js +1 -0
- package/build/src/start/server/metro/createExpoFallbackResolver.js.map +1 -1
- package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
- package/build/src/start/server/metro/createJResolver.js.map +1 -1
- package/build/src/start/server/metro/createServerComponentsMiddleware.js +4 -4
- package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +54 -8
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/debugging/attachAtlas.js +2 -0
- package/build/src/start/server/metro/debugging/attachAtlas.js.map +1 -1
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +1 -1
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js +1 -0
- package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
- package/build/src/start/server/metro/formatFileCandidates.js.map +1 -1
- package/build/src/start/server/metro/getCssModulesFromBundler.js +10 -9
- package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +44 -40
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +79 -12
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/metroVirtualModules.js.map +1 -1
- package/build/src/start/server/metro/metroWatchTypeScriptFiles.js.map +1 -1
- package/build/src/start/server/metro/router.js +75 -0
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +19 -19
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/serializeHtml.js +45 -5
- package/build/src/start/server/metro/serializeHtml.js.map +1 -1
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
- package/build/src/start/server/metro/withMetroErrorReportingResolver.js +267 -0
- package/build/src/start/server/metro/withMetroErrorReportingResolver.js.map +1 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js +58 -82
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/metro/withMetroResolvers.js +2 -219
- package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
- package/build/src/start/server/metro/withMetroSupervisingTransformWorker.js +63 -0
- package/build/src/start/server/metro/withMetroSupervisingTransformWorker.js.map +1 -0
- package/build/src/start/server/middleware/createBuiltinAPIRequestHandler.js +1 -1
- package/build/src/start/server/middleware/createBuiltinAPIRequestHandler.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +7 -2
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/resolvePlatform.js +3 -0
- package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
- package/build/src/start/server/serverLogLikeMetro.js +13 -11
- package/build/src/start/server/serverLogLikeMetro.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
- package/build/src/types.d.ts +2 -0
- package/build/src/utils/build-cache-providers/index.js.map +1 -1
- package/build/src/utils/dir.js +7 -0
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/env.js +9 -4
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/errors.js +1 -1
- package/build/src/utils/errors.js.map +1 -1
- package/build/src/utils/git.js +2 -2
- package/build/src/utils/git.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -1
- package/internal/unstable-expo-updates-exports.d.ts +31 -0
- package/internal/unstable-expo-updates-exports.js +3 -0
- package/package.json +33 -17
- package/static/template/[...rsc]+api.ts +1 -1
- package/build/src/start/server/metro/createExpoStickyResolver.js +0 -137
- package/build/src/start/server/metro/createExpoStickyResolver.js.map +0 -1
- package/build/src/start/server/metro/metroPrivateServer.js +0 -28
- package/build/src/start/server/metro/metroPrivateServer.js.map +0 -1
- package/build/src/utils/jsonSchemaDeref.js +0 -150
- package/build/src/utils/jsonSchemaDeref.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/errors.ts"],"sourcesContent":["import { AssertionError } from 'assert';\nimport chalk from 'chalk';\nimport { execSync } from 'child_process';\n\nimport { exit, exception, warn } from '../log';\n\nconst ERROR_PREFIX = 'Error: ';\n\n/**\n * General error, formatted as a message in red text when caught by expo-cli (no stack trace is printed). Should be used in favor of `log.error()` in most cases.\n */\nexport class CommandError extends Error {\n name = 'CommandError';\n readonly isCommandError = true;\n\n constructor(\n public code: string,\n message: string = ''\n ) {\n super('');\n // If e.toString() was called to get `message` we don't want it to look\n // like \"Error: Error:\".\n if (message.startsWith(ERROR_PREFIX)) {\n message = message.substring(ERROR_PREFIX.length);\n }\n\n this.message = message || code;\n }\n}\n\nexport class AbortCommandError extends CommandError {\n constructor() {\n super('ABORTED', 'Interactive prompt was cancelled.');\n }\n}\n\n/**\n * Used to end a CLI process without printing a stack trace in the Expo CLI. Should be used in favor of `process.exit`.\n */\nexport class SilentError extends CommandError {\n constructor(messageOrError?: string | Error) {\n const message =\n (typeof messageOrError === 'string' ? messageOrError : messageOrError?.message) ??\n 'This error should fail silently in the CLI';\n super('SILENT', message);\n if (typeof messageOrError !== 'string') {\n // forward the props of the incoming error for tests or processes outside of expo-cli that use expo cli internals.\n this.stack = messageOrError?.stack ?? this.stack;\n this.name = messageOrError?.name ?? this.name;\n }\n }\n}\n\nexport function logCmdError(error: any): never {\n if (!(error instanceof Error)) {\n throw error;\n }\n if (error instanceof AbortCommandError || error instanceof SilentError) {\n // Do nothing, this is used for prompts or other cases that were custom logged.\n process.exit(
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/errors.ts"],"sourcesContent":["import { AssertionError } from 'assert';\nimport chalk from 'chalk';\nimport { execSync } from 'child_process';\n\nimport { exit, exception, warn } from '../log';\n\nconst ERROR_PREFIX = 'Error: ';\n\n/**\n * General error, formatted as a message in red text when caught by expo-cli (no stack trace is printed). Should be used in favor of `log.error()` in most cases.\n */\nexport class CommandError extends Error {\n name = 'CommandError';\n readonly isCommandError = true;\n\n constructor(\n public code: string,\n message: string = ''\n ) {\n super('');\n // If e.toString() was called to get `message` we don't want it to look\n // like \"Error: Error:\".\n if (message.startsWith(ERROR_PREFIX)) {\n message = message.substring(ERROR_PREFIX.length);\n }\n\n this.message = message || code;\n }\n}\n\nexport class AbortCommandError extends CommandError {\n constructor() {\n super('ABORTED', 'Interactive prompt was cancelled.');\n }\n}\n\n/**\n * Used to end a CLI process without printing a stack trace in the Expo CLI. Should be used in favor of `process.exit`.\n */\nexport class SilentError extends CommandError {\n constructor(messageOrError?: string | Error) {\n const message =\n (typeof messageOrError === 'string' ? messageOrError : messageOrError?.message) ??\n 'This error should fail silently in the CLI';\n super('SILENT', message);\n if (typeof messageOrError !== 'string') {\n // forward the props of the incoming error for tests or processes outside of expo-cli that use expo cli internals.\n this.stack = messageOrError?.stack ?? this.stack;\n this.name = messageOrError?.name ?? this.name;\n }\n }\n}\n\nexport function logCmdError(error: any): never {\n if (!(error instanceof Error)) {\n throw error;\n }\n if (error instanceof AbortCommandError || error instanceof SilentError) {\n // Do nothing, this is used for prompts or other cases that were custom logged.\n process.exit(1);\n } else if (\n error instanceof CommandError ||\n error instanceof AssertionError ||\n error.name === 'ApiV2Error' ||\n error.name === 'ConfigError'\n ) {\n // Print the stack trace in debug mode only.\n exit(error);\n }\n\n const errorDetails = error.stack ? '\\n' + chalk.gray(error.stack) : '';\n\n exit(chalk.red(error.toString()) + errorDetails);\n}\n\n/** This should never be thrown in production. */\nexport class UnimplementedError extends Error {\n constructor() {\n super('Unimplemented');\n this.name = 'UnimplementedError';\n }\n}\n\n/**\n * Add additional information when EMFILE errors are encountered.\n * These errors originate from Metro's FSEventsWatcher due to `fsevents` going over MacOS system limit.\n * Unfortunately, these limits in macOS are relatively low compared to an average React Native project.\n *\n * @see https://github.com/expo/expo/issues/29083\n * @see https://github.com/facebook/metro/issues/834\n * @see https://github.com/fsevents/fsevents/issues/42#issuecomment-62632234\n */\nfunction handleTooManyOpenFileErrors(error: any) {\n // Only enable special logging when running on macOS and are running into the `EMFILE` error\n if ('code' in error && error.code === 'EMFILE' && process.platform === 'darwin') {\n try {\n // Try to recover watchman, if it's not installed this will throw\n execSync('watchman shutdown-server', { stdio: 'ignore' });\n // NOTE(cedric): this both starts the watchman server and resets all watchers\n execSync('watchman watch-del-all', { stdio: 'ignore' });\n\n warn(\n 'Watchman is installed but was likely not enabled when starting Metro, try starting your project again.\\nIf this problem persists, follow the troubleshooting guide of Watchman: https://facebook.github.io/watchman/docs/troubleshooting'\n );\n } catch {\n warn(\n `Your macOS system limit does not allow enough watchers for Metro, install Watchman instead. Learn more: https://facebook.github.io/watchman/docs/install`\n );\n }\n\n exception(error);\n process.exit(1);\n }\n\n throw error;\n}\n\nprocess.on('uncaughtException', handleTooManyOpenFileErrors);\n"],"names":["AbortCommandError","CommandError","SilentError","UnimplementedError","logCmdError","ERROR_PREFIX","Error","constructor","code","message","name","isCommandError","startsWith","substring","length","messageOrError","stack","error","process","exit","AssertionError","errorDetails","chalk","gray","red","toString","handleTooManyOpenFileErrors","platform","execSync","stdio","warn","exception","on"],"mappings":";;;;;;;;;;;IA8BaA,iBAAiB;eAAjBA;;IAnBAC,YAAY;eAAZA;;IA4BAC,WAAW;eAAXA;;IAqCAC,kBAAkB;eAAlBA;;IAvBGC,WAAW;eAAXA;;;;yBArDe;;;;;;;gEACb;;;;;;;yBACO;;;;;;qBAEa;;;;;;AAEtC,MAAMC,eAAe;AAKd,MAAMJ,qBAAqBK;IAIhCC,YACE,AAAOC,IAAY,EACnBC,UAAkB,EAAE,CACpB;QACA,KAAK,CAAC,UAHCD,OAAAA,WAJTE,OAAO,qBACEC,iBAAiB;QAOxB,uEAAuE;QACvE,wBAAwB;QACxB,IAAIF,QAAQG,UAAU,CAACP,eAAe;YACpCI,UAAUA,QAAQI,SAAS,CAACR,aAAaS,MAAM;QACjD;QAEA,IAAI,CAACL,OAAO,GAAGA,WAAWD;IAC5B;AACF;AAEO,MAAMR,0BAA0BC;IACrCM,aAAc;QACZ,KAAK,CAAC,WAAW;IACnB;AACF;AAKO,MAAML,oBAAoBD;IAC/BM,YAAYQ,cAA+B,CAAE;QAC3C,MAAMN,UACJ,AAAC,CAAA,OAAOM,mBAAmB,WAAWA,iBAAiBA,kCAAAA,eAAgBN,OAAO,AAAD,KAC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AA,SAAI,EACF,CAAC,wJAAwJ,CAAC;QAE9J;QAEAC,IAAAA,cAAS,EAACd;QACVC,QAAQC,IAAI,CAAC;IACf;IAEA,MAAMF;AACR;AAEAC,QAAQc,EAAE,CAAC,qBAAqBN"}
|
package/build/src/utils/git.js
CHANGED
|
@@ -94,7 +94,7 @@ async function maybeBailOnGitStatusAsync() {
|
|
|
94
94
|
}
|
|
95
95
|
_log.log();
|
|
96
96
|
const answer = await (0, _prompts.confirmAsync)({
|
|
97
|
-
message: `Continue with
|
|
97
|
+
message: `Continue with uncommitted changes?`
|
|
98
98
|
});
|
|
99
99
|
if (!answer) {
|
|
100
100
|
return true;
|
|
@@ -118,7 +118,7 @@ async function validateGitStatusAsync() {
|
|
|
118
118
|
if (workingTreeStatus === 'clean') {
|
|
119
119
|
return true;
|
|
120
120
|
} else if (workingTreeStatus === 'dirty') {
|
|
121
|
-
logWarning('Git branch has
|
|
121
|
+
logWarning('Git branch has uncommitted file changes', `It's recommended to commit all changes before proceeding in case you want to revert generated changes.`);
|
|
122
122
|
} else {
|
|
123
123
|
logWarning('No git repo found in current directory', `Use git to track file changes before running commands that modify project files.`);
|
|
124
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/git.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\n\nimport { env } from './env';\nimport { isInteractive } from './interactive';\nimport { confirmAsync } from './prompts';\nimport * as Log from '../log';\n\nexport async function maybeBailOnGitStatusAsync(): Promise<boolean> {\n if (env.EXPO_NO_GIT_STATUS) {\n Log.warn(\n 'Git status is dirty but the command will continue because EXPO_NO_GIT_STATUS is enabled...'\n );\n return false;\n }\n const isGitStatusClean = await validateGitStatusAsync();\n\n // Give people a chance to bail out if git working tree is dirty\n if (!isGitStatusClean) {\n if (!isInteractive()) {\n Log.warn(\n `Git status is dirty but the command will continue because the terminal is not interactive.`\n );\n return false;\n }\n\n Log.log();\n const answer = await confirmAsync({\n message: `Continue with
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/git.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport chalk from 'chalk';\n\nimport { env } from './env';\nimport { isInteractive } from './interactive';\nimport { confirmAsync } from './prompts';\nimport * as Log from '../log';\n\nexport async function maybeBailOnGitStatusAsync(): Promise<boolean> {\n if (env.EXPO_NO_GIT_STATUS) {\n Log.warn(\n 'Git status is dirty but the command will continue because EXPO_NO_GIT_STATUS is enabled...'\n );\n return false;\n }\n const isGitStatusClean = await validateGitStatusAsync();\n\n // Give people a chance to bail out if git working tree is dirty\n if (!isGitStatusClean) {\n if (!isInteractive()) {\n Log.warn(\n `Git status is dirty but the command will continue because the terminal is not interactive.`\n );\n return false;\n }\n\n Log.log();\n const answer = await confirmAsync({\n message: `Continue with uncommitted changes?`,\n });\n\n if (!answer) {\n return true;\n }\n\n Log.log();\n }\n return false;\n}\n\nexport async function validateGitStatusAsync(): Promise<boolean> {\n let workingTreeStatus = 'unknown';\n try {\n const result = await spawnAsync('git', ['status', '--porcelain']);\n workingTreeStatus = result.stdout === '' ? 'clean' : 'dirty';\n } catch {\n // Maybe git is not installed?\n // Maybe this project is not using git?\n }\n\n if (workingTreeStatus === 'clean') {\n return true;\n } else if (workingTreeStatus === 'dirty') {\n logWarning(\n 'Git branch has uncommitted file changes',\n `It's recommended to commit all changes before proceeding in case you want to revert generated changes.`\n );\n } else {\n logWarning(\n 'No git repo found in current directory',\n `Use git to track file changes before running commands that modify project files.`\n );\n }\n\n return false;\n}\n\nfunction logWarning(warning: string, hint: string) {\n Log.warn(chalk.bold`! ` + warning);\n Log.log(chalk.gray`\\u203A ` + chalk.gray(hint));\n}\n"],"names":["maybeBailOnGitStatusAsync","validateGitStatusAsync","env","EXPO_NO_GIT_STATUS","Log","warn","isGitStatusClean","isInteractive","log","answer","confirmAsync","message","workingTreeStatus","result","spawnAsync","stdout","logWarning","warning","hint","chalk","bold","gray"],"mappings":";;;;;;;;;;;IAQs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}
|
|
@@ -33,7 +33,7 @@ class FetchClient {
|
|
|
33
33
|
this.headers = {
|
|
34
34
|
accept: 'application/json',
|
|
35
35
|
'content-type': 'application/json',
|
|
36
|
-
'user-agent': `expo-cli/${"
|
|
36
|
+
'user-agent': `expo-cli/${"54.0.0"}`,
|
|
37
37
|
authorization: 'Basic ' + _nodebuffer().Buffer.from(`${target}:`).toString('base64')
|
|
38
38
|
};
|
|
39
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utils/tsconfig/resolveWithTsConfigPaths.ts"],"sourcesContent":["import { Resolution } from 'metro-resolver';\nimport path from 'path';\n\nimport { matchTsConfigPathAlias } from './matchTsConfigPathAlias';\n\ntype Paths = { [match: string]: string[] };\n\nconst debug = require('debug')('expo:metro:tsconfig-paths') as typeof console.log;\n\nconst isAbsolute = process.platform === 'win32' ? path.win32.isAbsolute : path.posix.isAbsolute;\n\nexport function resolveWithTsConfigPaths(\n config: { paths: Paths; baseUrl: string; hasBaseUrl: boolean },\n request: {\n /** Import request */\n moduleName: string;\n /** Originating file path */\n originModulePath: string;\n },\n resolve: (moduleName: string) => Resolution | null\n): Resolution | null {\n const aliases = Object.keys(config.paths);\n\n if (\n // If no aliases are added bail out\n (!aliases.length && !config.hasBaseUrl) ||\n // Library authors cannot utilize this feature in userspace.\n /node_modules/.test(request.originModulePath) ||\n // Absolute paths are not supported\n isAbsolute(request.moduleName) ||\n // Relative paths are not supported\n /^\\.\\.?($|[\\\\/])/.test(request.moduleName)\n ) {\n return null;\n }\n\n const matched = matchTsConfigPathAlias(aliases, request.moduleName);\n if (matched) {\n for (const alias of config.paths[matched.text]) {\n const nextModuleName = matched.star ? alias.replace('*', matched.star) : alias;\n\n if (/\\.d\\.ts$/.test(nextModuleName)) continue;\n\n const possibleResult = path.join(config.baseUrl, nextModuleName);\n\n const result = resolve(possibleResult);\n if (result) {\n debug(`${request.moduleName} -> ${possibleResult}`);\n return result;\n }\n }\n } else {\n // Only resolve against baseUrl if no `paths` groups were matched.\n // Base URL is resolved after paths, and before node_modules.\n if (config.hasBaseUrl) {\n const possibleResult = path.join(config.baseUrl, request.moduleName);\n const result = resolve(possibleResult);\n if (result) {\n debug(`baseUrl: ${request.moduleName} -> ${possibleResult}`);\n return result;\n }\n }\n }\n\n return null;\n}\n"],"names":["resolveWithTsConfigPaths","debug","require","isAbsolute","process","platform","path","win32","posix","config","request","resolve","aliases","Object","keys","paths","length","hasBaseUrl","test","originModulePath","moduleName","matched","matchTsConfigPathAlias","alias","text","nextModuleName","star","replace","possibleResult","join","baseUrl","result"],"mappings":";;;;+BAWgBA;;;eAAAA;;;;gEAVC;;;;;;wCAEsB;;;;;;AAIvC,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,aAAaC,QAAQC,QAAQ,KAAK,UAAUC,eAAI,CAACC,KAAK,CAACJ,UAAU,GAAGG,eAAI,CAACE,KAAK,CAACL,UAAU;AAExF,SAASH,yBACdS,MAA8D,EAC9DC,OAKC,EACDC,OAAkD;IAElD,MAAMC,UAAUC,OAAOC,IAAI,CAACL,OAAOM,KAAK;IAExC,IAEE,AADA,mCAAmC;IAClC,CAACH,QAAQI,MAAM,IAAI,CAACP,OAAOQ,UAAU,IACtC,4DAA4D;IAC5D,eAAeC,IAAI,CAACR,QAAQS,gBAAgB,KAC5C,mCAAmC;IACnChB,WAAWO,QAAQU,UAAU,KAC7B,mCAAmC;IACnC,kBAAkBF,IAAI,CAACR,QAAQU,UAAU,GACzC;QACA,OAAO;IACT;IAEA,MAAMC,UAAUC,IAAAA,8CAAsB,EAACV,SAASF,QAAQU,UAAU;IAClE,IAAIC,SAAS;QACX,KAAK,MAAME,SAASd,OAAOM,KAAK,CAACM,QAAQG,IAAI,CAAC,CAAE;YAC9C,MAAMC,iBAAiBJ,QAAQK,IAAI,GAAGH,MAAMI,OAAO,CAAC,KAAKN,QAAQK,IAAI,IAAIH;YAEzE,IAAI,WAAWL,IAAI,CAACO,iBAAiB;YAErC,MAAMG,iBAAiBtB,eAAI,CAACuB,IAAI,CAACpB,OAAOqB,OAAO,EAAEL;YAEjD,MAAMM,SAASpB,QAAQiB;YACvB,IAAIG,QAAQ;gBACV9B,MAAM,GAAGS,QAAQU,UAAU,CAAC,IAAI,EAAEQ,gBAAgB;gBAClD,OAAOG;YACT;QACF;IACF,OAAO;QACL,kEAAkE;QAClE,6DAA6D;QAC7D,IAAItB,OAAOQ,UAAU,EAAE;YACrB,MAAMW,iBAAiBtB,eAAI,CAACuB,IAAI,CAACpB,OAAOqB,OAAO,EAAEpB,QAAQU,UAAU;YACnE,MAAMW,SAASpB,QAAQiB;YACvB,IAAIG,QAAQ;gBACV9B,MAAM,CAAC,SAAS,EAAES,QAAQU,UAAU,CAAC,IAAI,EAAEQ,gBAAgB;gBAC3D,OAAOG;YACT;QACF;IACF;IAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/utils/tsconfig/resolveWithTsConfigPaths.ts"],"sourcesContent":["import type { Resolution } from '@expo/metro/metro-resolver';\nimport path from 'path';\n\nimport { matchTsConfigPathAlias } from './matchTsConfigPathAlias';\n\ntype Paths = { [match: string]: string[] };\n\nconst debug = require('debug')('expo:metro:tsconfig-paths') as typeof console.log;\n\nconst isAbsolute = process.platform === 'win32' ? path.win32.isAbsolute : path.posix.isAbsolute;\n\nexport function resolveWithTsConfigPaths(\n config: { paths: Paths; baseUrl: string; hasBaseUrl: boolean },\n request: {\n /** Import request */\n moduleName: string;\n /** Originating file path */\n originModulePath: string;\n },\n resolve: (moduleName: string) => Resolution | null\n): Resolution | null {\n const aliases = Object.keys(config.paths);\n\n if (\n // If no aliases are added bail out\n (!aliases.length && !config.hasBaseUrl) ||\n // Library authors cannot utilize this feature in userspace.\n /node_modules/.test(request.originModulePath) ||\n // Absolute paths are not supported\n isAbsolute(request.moduleName) ||\n // Relative paths are not supported\n /^\\.\\.?($|[\\\\/])/.test(request.moduleName)\n ) {\n return null;\n }\n\n const matched = matchTsConfigPathAlias(aliases, request.moduleName);\n if (matched) {\n for (const alias of config.paths[matched.text]) {\n const nextModuleName = matched.star ? alias.replace('*', matched.star) : alias;\n\n if (/\\.d\\.ts$/.test(nextModuleName)) continue;\n\n const possibleResult = path.join(config.baseUrl, nextModuleName);\n\n const result = resolve(possibleResult);\n if (result) {\n debug(`${request.moduleName} -> ${possibleResult}`);\n return result;\n }\n }\n } else {\n // Only resolve against baseUrl if no `paths` groups were matched.\n // Base URL is resolved after paths, and before node_modules.\n if (config.hasBaseUrl) {\n const possibleResult = path.join(config.baseUrl, request.moduleName);\n const result = resolve(possibleResult);\n if (result) {\n debug(`baseUrl: ${request.moduleName} -> ${possibleResult}`);\n return result;\n }\n }\n }\n\n return null;\n}\n"],"names":["resolveWithTsConfigPaths","debug","require","isAbsolute","process","platform","path","win32","posix","config","request","resolve","aliases","Object","keys","paths","length","hasBaseUrl","test","originModulePath","moduleName","matched","matchTsConfigPathAlias","alias","text","nextModuleName","star","replace","possibleResult","join","baseUrl","result"],"mappings":";;;;+BAWgBA;;;eAAAA;;;;gEAVC;;;;;;wCAEsB;;;;;;AAIvC,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,aAAaC,QAAQC,QAAQ,KAAK,UAAUC,eAAI,CAACC,KAAK,CAACJ,UAAU,GAAGG,eAAI,CAACE,KAAK,CAACL,UAAU;AAExF,SAASH,yBACdS,MAA8D,EAC9DC,OAKC,EACDC,OAAkD;IAElD,MAAMC,UAAUC,OAAOC,IAAI,CAACL,OAAOM,KAAK;IAExC,IAEE,AADA,mCAAmC;IAClC,CAACH,QAAQI,MAAM,IAAI,CAACP,OAAOQ,UAAU,IACtC,4DAA4D;IAC5D,eAAeC,IAAI,CAACR,QAAQS,gBAAgB,KAC5C,mCAAmC;IACnChB,WAAWO,QAAQU,UAAU,KAC7B,mCAAmC;IACnC,kBAAkBF,IAAI,CAACR,QAAQU,UAAU,GACzC;QACA,OAAO;IACT;IAEA,MAAMC,UAAUC,IAAAA,8CAAsB,EAACV,SAASF,QAAQU,UAAU;IAClE,IAAIC,SAAS;QACX,KAAK,MAAME,SAASd,OAAOM,KAAK,CAACM,QAAQG,IAAI,CAAC,CAAE;YAC9C,MAAMC,iBAAiBJ,QAAQK,IAAI,GAAGH,MAAMI,OAAO,CAAC,KAAKN,QAAQK,IAAI,IAAIH;YAEzE,IAAI,WAAWL,IAAI,CAACO,iBAAiB;YAErC,MAAMG,iBAAiBtB,eAAI,CAACuB,IAAI,CAACpB,OAAOqB,OAAO,EAAEL;YAEjD,MAAMM,SAASpB,QAAQiB;YACvB,IAAIG,QAAQ;gBACV9B,MAAM,GAAGS,QAAQU,UAAU,CAAC,IAAI,EAAEQ,gBAAgB;gBAClD,OAAOG;YACT;QACF;IACF,OAAO;QACL,kEAAkE;QAClE,6DAA6D;QAC7D,IAAItB,OAAOQ,UAAU,EAAE;YACrB,MAAMW,iBAAiBtB,eAAI,CAACuB,IAAI,CAACpB,OAAOqB,OAAO,EAAEpB,QAAQU,UAAU;YACnE,MAAMW,SAASpB,QAAQiB;YACvB,IAAIG,QAAQ;gBACV9B,MAAM,CAAC,SAAS,EAAES,QAAQU,UAAU,CAAC,IAAI,EAAEQ,gBAAgB;gBAC3D,OAAOG;YACT;QACF;IACF;IAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// WARN: Internal re-export, don't rely on this to be a public API or use it outside of `expo/expo`'s monorepo
|
|
2
|
+
// NOTE for Expo Maintainers: Do not add to this file. We want to remove this
|
|
3
|
+
|
|
4
|
+
import type { HashedAssetData } from '@expo/metro-config/build/transform-worker/getAssets';
|
|
5
|
+
import type { BundleOptions } from '@expo/metro/metro/shared/types.flow';
|
|
6
|
+
import type Server from '@expo/metro/metro/Server';
|
|
7
|
+
|
|
8
|
+
export const drawableFileTypes: Set<string>;
|
|
9
|
+
|
|
10
|
+
export function createMetroServerAndBundleRequestAsync(
|
|
11
|
+
projectRoot: string,
|
|
12
|
+
options: {
|
|
13
|
+
maxWorkers?: number;
|
|
14
|
+
config?: string;
|
|
15
|
+
platform: string;
|
|
16
|
+
sourcemapOutput?: string;
|
|
17
|
+
sourcemapUseAbsolutePath: boolean;
|
|
18
|
+
entryFile: string;
|
|
19
|
+
minify?: boolean;
|
|
20
|
+
dev: boolean;
|
|
21
|
+
resetCache: boolean;
|
|
22
|
+
unstableTransformProfile?: string;
|
|
23
|
+
}
|
|
24
|
+
): Promise<{ server: Server; bundleRequest: BundleOptions }>;
|
|
25
|
+
|
|
26
|
+
export function exportEmbedAssetsAsync(
|
|
27
|
+
server: Server,
|
|
28
|
+
bundleRequest: BundleOptions,
|
|
29
|
+
projectRoot: string,
|
|
30
|
+
options: { platform: string },
|
|
31
|
+
): Promise<HashedAssetData[]>;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "54.0.0",
|
|
4
4
|
"description": "The Expo CLI",
|
|
5
5
|
"main": "build/bin/cli",
|
|
6
6
|
"bin": {
|
|
7
7
|
"expo-internal": "build/bin/cli"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
+
"internal",
|
|
10
11
|
"static",
|
|
11
12
|
"build"
|
|
12
13
|
],
|
|
@@ -40,23 +41,25 @@
|
|
|
40
41
|
"homepage": "https://github.com/expo/expo/tree/main/packages/@expo/cli",
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@0no-co/graphql.web": "^1.0.8",
|
|
43
|
-
"@babel/runtime": "^7.20.0",
|
|
44
44
|
"@expo/code-signing-certificates": "^0.0.5",
|
|
45
|
-
"@expo/config": "
|
|
46
|
-
"@expo/config-plugins": "
|
|
45
|
+
"@expo/config": "~12.0.7",
|
|
46
|
+
"@expo/config-plugins": "~54.0.0",
|
|
47
47
|
"@expo/devcert": "^1.1.2",
|
|
48
|
-
"@expo/env": "
|
|
49
|
-
"@expo/image-utils": "0.
|
|
50
|
-
"@expo/json-file": "
|
|
51
|
-
"@expo/metro
|
|
52
|
-
"@expo/
|
|
53
|
-
"@expo/
|
|
54
|
-
"@expo/
|
|
55
|
-
"@expo/
|
|
48
|
+
"@expo/env": "~2.0.6",
|
|
49
|
+
"@expo/image-utils": "^0.8.6",
|
|
50
|
+
"@expo/json-file": "^10.0.6",
|
|
51
|
+
"@expo/metro": "~0.1.1",
|
|
52
|
+
"@expo/metro-config": "~54.0.0",
|
|
53
|
+
"@expo/osascript": "^2.3.6",
|
|
54
|
+
"@expo/package-manager": "^1.9.6",
|
|
55
|
+
"@expo/plist": "^0.4.6",
|
|
56
|
+
"@expo/prebuild-config": "^54.0.0",
|
|
57
|
+
"@expo/schema-utils": "^0.1.6",
|
|
58
|
+
"@expo/server": "^0.7.3",
|
|
56
59
|
"@expo/spawn-async": "^1.7.2",
|
|
57
60
|
"@expo/ws-tunnel": "^1.0.1",
|
|
58
61
|
"@expo/xcpretty": "^4.3.0",
|
|
59
|
-
"@react-native/dev-middleware": "0.
|
|
62
|
+
"@react-native/dev-middleware": "0.81.4",
|
|
60
63
|
"@urql/core": "^5.0.6",
|
|
61
64
|
"@urql/exchange-retry": "^1.3.0",
|
|
62
65
|
"accepts": "^1.3.8",
|
|
@@ -73,8 +76,8 @@
|
|
|
73
76
|
"freeport-async": "^2.0.0",
|
|
74
77
|
"getenv": "^2.0.0",
|
|
75
78
|
"glob": "^10.4.2",
|
|
76
|
-
"minimatch": "^9.0.0",
|
|
77
79
|
"lan-network": "^0.1.6",
|
|
80
|
+
"minimatch": "^9.0.0",
|
|
78
81
|
"node-forge": "^1.3.1",
|
|
79
82
|
"npm-package-arg": "^11.0.0",
|
|
80
83
|
"ora": "^3.4.0",
|
|
@@ -106,10 +109,22 @@
|
|
|
106
109
|
"./taskfile-swc.js"
|
|
107
110
|
]
|
|
108
111
|
},
|
|
112
|
+
"peerDependencies": {
|
|
113
|
+
"expo": "*",
|
|
114
|
+
"expo-router": "*",
|
|
115
|
+
"react-native": "*"
|
|
116
|
+
},
|
|
117
|
+
"peerDependenciesMeta": {
|
|
118
|
+
"expo-router": {
|
|
119
|
+
"optional": true
|
|
120
|
+
},
|
|
121
|
+
"react-native": {
|
|
122
|
+
"optional": true
|
|
123
|
+
}
|
|
124
|
+
},
|
|
109
125
|
"devDependencies": {
|
|
110
126
|
"@expo/multipart-body-parser": "^1.0.0",
|
|
111
127
|
"@expo/ngrok": "4.1.3",
|
|
112
|
-
"@expo/server": "0.6.4-canary-20250722-599a28f",
|
|
113
128
|
"@graphql-codegen/cli": "^2.16.3",
|
|
114
129
|
"@graphql-codegen/typescript": "^2.8.7",
|
|
115
130
|
"@graphql-codegen/typescript-operations": "^2.5.12",
|
|
@@ -139,7 +154,7 @@
|
|
|
139
154
|
"@types/ws": "^8.5.4",
|
|
140
155
|
"devtools-protocol": "^0.0.1113120",
|
|
141
156
|
"expo-atlas": "^0.4.1",
|
|
142
|
-
"expo-module-scripts": "
|
|
157
|
+
"expo-module-scripts": "^5.0.7",
|
|
143
158
|
"find-process": "^1.4.7",
|
|
144
159
|
"jest-runner-tsd": "^6.0.0",
|
|
145
160
|
"klaw-sync": "^6.0.0",
|
|
@@ -151,5 +166,6 @@
|
|
|
151
166
|
"taskr": "^1.1.0",
|
|
152
167
|
"tree-kill": "^1.2.2",
|
|
153
168
|
"tsd": "^0.28.1"
|
|
154
|
-
}
|
|
169
|
+
},
|
|
170
|
+
"gitHead": "87186d10c8239c6469e055417e67bd4d0ed63efb"
|
|
155
171
|
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
_dependenciesToRegex: function() {
|
|
13
|
-
return _dependenciesToRegex;
|
|
14
|
-
},
|
|
15
|
-
createStickyModuleResolver: function() {
|
|
16
|
-
return createStickyModuleResolver;
|
|
17
|
-
},
|
|
18
|
-
createStickyModuleResolverInput: function() {
|
|
19
|
-
return createStickyModuleResolverInput;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const debug = require('debug')('expo:start:server:metro:sticky-resolver');
|
|
23
|
-
const AUTOLINKING_PLATFORMS = [
|
|
24
|
-
'android',
|
|
25
|
-
'ios',
|
|
26
|
-
'web'
|
|
27
|
-
];
|
|
28
|
-
const escapeDependencyName = (dependency)=>dependency.replace(/[*.?()[\]]/g, (x)=>`\\${x}`);
|
|
29
|
-
const _dependenciesToRegex = (dependencies)=>new RegExp(`^(${dependencies.map(escapeDependencyName).join('|')})($|/.*)`);
|
|
30
|
-
/** Creates a function to load a dependency of the `expo` package */ const createExpoDependencyLoader = (request)=>{
|
|
31
|
-
let mod;
|
|
32
|
-
return ()=>{
|
|
33
|
-
if (!mod) {
|
|
34
|
-
const expoPath = require.resolve('expo/package.json');
|
|
35
|
-
const autolinkingPath = require.resolve(request, {
|
|
36
|
-
paths: [
|
|
37
|
-
expoPath
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
|
-
return mod = require(autolinkingPath);
|
|
41
|
-
}
|
|
42
|
-
return mod;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
const getAutolinkingModule = createExpoDependencyLoader('expo-modules-autolinking/exports');
|
|
46
|
-
const getReactNativeConfigModule = createExpoDependencyLoader('expo-modules-autolinking/build/reactNativeConfig');
|
|
47
|
-
const getAutolinkingOptions = async (projectRoot, platform)=>{
|
|
48
|
-
const autolinking = getAutolinkingModule();
|
|
49
|
-
return await autolinking.mergeLinkingOptionsAsync({
|
|
50
|
-
searchPaths: [],
|
|
51
|
-
projectRoot,
|
|
52
|
-
platform: platform === 'ios' ? 'apple' : platform,
|
|
53
|
-
onlyProjectDeps: true,
|
|
54
|
-
silent: true
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const getAutolinkingResolutions = async (opts)=>{
|
|
58
|
-
const autolinking = getAutolinkingModule();
|
|
59
|
-
const resolvedModules = await autolinking.findModulesAsync(opts);
|
|
60
|
-
return Object.fromEntries(Object.entries(resolvedModules).map(([key, entry])=>[
|
|
61
|
-
key,
|
|
62
|
-
entry.path
|
|
63
|
-
]));
|
|
64
|
-
};
|
|
65
|
-
const getReactNativeConfigResolutions = async (opts)=>{
|
|
66
|
-
const reactNativeConfigModule = getReactNativeConfigModule();
|
|
67
|
-
const configResult = await reactNativeConfigModule.createReactNativeConfigAsync({
|
|
68
|
-
...opts,
|
|
69
|
-
// NOTE(@kitten): web will use ios here. This is desired since this function only accepts android|ios.
|
|
70
|
-
// However, we'd still like to sticky resolve dependencies for web
|
|
71
|
-
platform: opts.platform === 'android' ? 'android' : 'ios',
|
|
72
|
-
// TODO(@kitten): Unclear if this should be populated or directly relates to sticky resolution
|
|
73
|
-
transitiveLinkingDependencies: []
|
|
74
|
-
});
|
|
75
|
-
return Object.fromEntries(Object.entries(configResult.dependencies).map(([key, entry])=>[
|
|
76
|
-
key,
|
|
77
|
-
entry.root
|
|
78
|
-
]));
|
|
79
|
-
};
|
|
80
|
-
const getPlatformModuleDescription = async (projectRoot, platform)=>{
|
|
81
|
-
const searchOptions = await getAutolinkingOptions(projectRoot, platform);
|
|
82
|
-
const autolinkingResolutions$ = getAutolinkingResolutions(searchOptions);
|
|
83
|
-
const reactNativeConfigResolutions$ = getReactNativeConfigResolutions(searchOptions);
|
|
84
|
-
const resolvedModulePaths = {
|
|
85
|
-
...await reactNativeConfigResolutions$,
|
|
86
|
-
...await autolinkingResolutions$
|
|
87
|
-
};
|
|
88
|
-
const resolvedModuleNames = Object.keys(resolvedModulePaths);
|
|
89
|
-
debug(`Sticky resolution for ${platform} registered ${resolvedModuleNames.length} resolutions:`, resolvedModuleNames);
|
|
90
|
-
return {
|
|
91
|
-
platform,
|
|
92
|
-
moduleTestRe: _dependenciesToRegex(resolvedModuleNames),
|
|
93
|
-
resolvedModulePaths
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
async function createStickyModuleResolverInput({ platforms, projectRoot }) {
|
|
97
|
-
return Object.fromEntries(await Promise.all(platforms.filter((platform)=>AUTOLINKING_PLATFORMS.includes(platform)).map(async (platform)=>{
|
|
98
|
-
const platformModuleDescription = await getPlatformModuleDescription(projectRoot, platform);
|
|
99
|
-
return [
|
|
100
|
-
platformModuleDescription.platform,
|
|
101
|
-
platformModuleDescription
|
|
102
|
-
];
|
|
103
|
-
})));
|
|
104
|
-
}
|
|
105
|
-
function createStickyModuleResolver(input, { getStrictResolver }) {
|
|
106
|
-
if (!input) {
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
|
-
const fileSpecifierRe = /^[\\/]|^\.\.?(?:$|[\\/])/i;
|
|
110
|
-
const isAutolinkingPlatform = (platform)=>!!platform && input[platform] != null;
|
|
111
|
-
return function requestStickyModule(immutableContext, moduleName, platform) {
|
|
112
|
-
if (!isAutolinkingPlatform(platform)) {
|
|
113
|
-
return null;
|
|
114
|
-
} else if (fileSpecifierRe.test(moduleName)) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
const moduleDescription = input[platform];
|
|
118
|
-
const moduleMatch = moduleDescription.moduleTestRe.exec(moduleName);
|
|
119
|
-
if (moduleMatch) {
|
|
120
|
-
const resolvedModulePath = moduleDescription.resolvedModulePaths[moduleMatch[1]] || moduleName;
|
|
121
|
-
// We instead resolve as if it was a dependency from within the module (self-require/import)
|
|
122
|
-
const context = {
|
|
123
|
-
...immutableContext,
|
|
124
|
-
nodeModulesPaths: [
|
|
125
|
-
resolvedModulePath
|
|
126
|
-
],
|
|
127
|
-
originModulePath: resolvedModulePath
|
|
128
|
-
};
|
|
129
|
-
const res = getStrictResolver(context, platform)(moduleName);
|
|
130
|
-
debug(`Sticky resolution for ${platform}: ${moduleName} -> ${resolvedModulePath}`);
|
|
131
|
-
return res;
|
|
132
|
-
}
|
|
133
|
-
return null;
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
//# sourceMappingURL=createExpoStickyResolver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/createExpoStickyResolver.ts"],"sourcesContent":["import type { SearchOptions as AutolinkingSearchOptions } from 'expo-modules-autolinking/exports';\nimport type { ResolutionContext } from 'metro-resolver';\n\nimport type { StrictResolverFactory } from './withMetroMultiPlatform';\nimport type { ExpoCustomMetroResolver } from './withMetroResolvers';\n\nconst debug = require('debug')('expo:start:server:metro:sticky-resolver') as typeof console.log;\n\nconst AUTOLINKING_PLATFORMS = ['android', 'ios', 'web'] as const;\ntype AutolinkingPlatform = (typeof AUTOLINKING_PLATFORMS)[number];\n\nconst escapeDependencyName = (dependency: string) =>\n dependency.replace(/[*.?()[\\]]/g, (x) => `\\\\${x}`);\n\n/** Converts a list of module names to a regex that may either match bare module names or sub-modules of modules */\nexport const _dependenciesToRegex = (dependencies: string[]) =>\n new RegExp(`^(${dependencies.map(escapeDependencyName).join('|')})($|/.*)`);\n\n/** Creates a function to load a dependency of the `expo` package */\nconst createExpoDependencyLoader = <T>(request: string) => {\n let mod: T | undefined;\n return (): T => {\n if (!mod) {\n const expoPath = require.resolve('expo/package.json');\n const autolinkingPath = require.resolve(request, {\n paths: [expoPath],\n });\n return (mod = require(autolinkingPath));\n }\n return mod;\n };\n};\n\nconst getAutolinkingModule = createExpoDependencyLoader<\n typeof import('expo-modules-autolinking/exports')\n>('expo-modules-autolinking/exports');\n\nconst getReactNativeConfigModule = createExpoDependencyLoader<\n typeof import('expo-modules-autolinking/build/reactNativeConfig')\n>('expo-modules-autolinking/build/reactNativeConfig');\n\nconst getAutolinkingOptions = async (\n projectRoot: string,\n platform: AutolinkingPlatform\n): Promise<AutolinkingSearchOptions> => {\n const autolinking = getAutolinkingModule();\n return await autolinking.mergeLinkingOptionsAsync({\n searchPaths: [],\n projectRoot,\n platform: platform === 'ios' ? 'apple' : platform,\n onlyProjectDeps: true,\n silent: true,\n });\n};\n\nconst getAutolinkingResolutions = async (\n opts: AutolinkingSearchOptions\n): Promise<Record<string, string>> => {\n const autolinking = getAutolinkingModule();\n const resolvedModules = await autolinking.findModulesAsync(opts);\n return Object.fromEntries(\n Object.entries(resolvedModules).map(([key, entry]) => [key, entry.path])\n );\n};\n\nconst getReactNativeConfigResolutions = async (\n opts: AutolinkingSearchOptions\n): Promise<Record<string, string>> => {\n const reactNativeConfigModule = getReactNativeConfigModule();\n const configResult = await reactNativeConfigModule.createReactNativeConfigAsync({\n ...opts,\n // NOTE(@kitten): web will use ios here. This is desired since this function only accepts android|ios.\n // However, we'd still like to sticky resolve dependencies for web\n platform: opts.platform === 'android' ? 'android' : 'ios',\n // TODO(@kitten): Unclear if this should be populated or directly relates to sticky resolution\n transitiveLinkingDependencies: [],\n });\n return Object.fromEntries(\n Object.entries(configResult.dependencies).map(([key, entry]) => [key, entry.root])\n );\n};\n\ninterface PlatformModuleDescription {\n platform: AutolinkingPlatform;\n moduleTestRe: RegExp;\n resolvedModulePaths: Record<string, string>;\n}\n\nconst getPlatformModuleDescription = async (\n projectRoot: string,\n platform: AutolinkingPlatform\n): Promise<PlatformModuleDescription> => {\n const searchOptions = await getAutolinkingOptions(projectRoot, platform);\n const autolinkingResolutions$ = getAutolinkingResolutions(searchOptions);\n const reactNativeConfigResolutions$ = getReactNativeConfigResolutions(searchOptions);\n const resolvedModulePaths = {\n ...(await reactNativeConfigResolutions$),\n ...(await autolinkingResolutions$),\n };\n const resolvedModuleNames = Object.keys(resolvedModulePaths);\n debug(\n `Sticky resolution for ${platform} registered ${resolvedModuleNames.length} resolutions:`,\n resolvedModuleNames\n );\n return {\n platform,\n moduleTestRe: _dependenciesToRegex(resolvedModuleNames),\n resolvedModulePaths,\n };\n};\n\nexport type StickyModuleResolverInput = {\n [platform in AutolinkingPlatform]?: PlatformModuleDescription;\n};\n\nexport async function createStickyModuleResolverInput({\n platforms,\n projectRoot,\n}: {\n projectRoot: string;\n platforms: string[];\n}): Promise<StickyModuleResolverInput> {\n return Object.fromEntries(\n await Promise.all(\n platforms\n .filter((platform): platform is AutolinkingPlatform =>\n AUTOLINKING_PLATFORMS.includes(platform as any)\n )\n .map(async (platform) => {\n const platformModuleDescription = await getPlatformModuleDescription(\n projectRoot,\n platform\n );\n return [platformModuleDescription.platform, platformModuleDescription] as const;\n })\n )\n ) as StickyModuleResolverInput;\n}\n\nexport function createStickyModuleResolver(\n input: StickyModuleResolverInput | undefined,\n { getStrictResolver }: { getStrictResolver: StrictResolverFactory }\n): ExpoCustomMetroResolver | undefined {\n if (!input) {\n return undefined;\n }\n\n const fileSpecifierRe = /^[\\\\/]|^\\.\\.?(?:$|[\\\\/])/i;\n const isAutolinkingPlatform = (platform: string | null): platform is AutolinkingPlatform =>\n !!platform && (input as any)[platform] != null;\n\n return function requestStickyModule(immutableContext, moduleName, platform) {\n if (!isAutolinkingPlatform(platform)) {\n return null;\n } else if (fileSpecifierRe.test(moduleName)) {\n return null;\n }\n\n const moduleDescription = input[platform]!;\n const moduleMatch = moduleDescription.moduleTestRe.exec(moduleName);\n if (moduleMatch) {\n const resolvedModulePath =\n moduleDescription.resolvedModulePaths[moduleMatch[1]] || moduleName;\n // We instead resolve as if it was a dependency from within the module (self-require/import)\n const context: ResolutionContext = {\n ...immutableContext,\n nodeModulesPaths: [resolvedModulePath],\n originModulePath: resolvedModulePath,\n };\n const res = getStrictResolver(context, platform)(moduleName);\n debug(`Sticky resolution for ${platform}: ${moduleName} -> ${resolvedModulePath}`);\n return res;\n }\n\n return null;\n };\n}\n"],"names":["_dependenciesToRegex","createStickyModuleResolver","createStickyModuleResolverInput","debug","require","AUTOLINKING_PLATFORMS","escapeDependencyName","dependency","replace","x","dependencies","RegExp","map","join","createExpoDependencyLoader","request","mod","expoPath","resolve","autolinkingPath","paths","getAutolinkingModule","getReactNativeConfigModule","getAutolinkingOptions","projectRoot","platform","autolinking","mergeLinkingOptionsAsync","searchPaths","onlyProjectDeps","silent","getAutolinkingResolutions","opts","resolvedModules","findModulesAsync","Object","fromEntries","entries","key","entry","path","getReactNativeConfigResolutions","reactNativeConfigModule","configResult","createReactNativeConfigAsync","transitiveLinkingDependencies","root","getPlatformModuleDescription","searchOptions","autolinkingResolutions$","reactNativeConfigResolutions$","resolvedModulePaths","resolvedModuleNames","keys","length","moduleTestRe","platforms","Promise","all","filter","includes","platformModuleDescription","input","getStrictResolver","undefined","fileSpecifierRe","isAutolinkingPlatform","requestStickyModule","immutableContext","moduleName","test","moduleDescription","moduleMatch","exec","resolvedModulePath","context","nodeModulesPaths","originModulePath","res"],"mappings":";;;;;;;;;;;IAeaA,oBAAoB;eAApBA;;IA4HGC,0BAA0B;eAA1BA;;IAxBMC,+BAA+B;eAA/BA;;;AA7GtB,MAAMC,QAAQC,QAAQ,SAAS;AAE/B,MAAMC,wBAAwB;IAAC;IAAW;IAAO;CAAM;AAGvD,MAAMC,uBAAuB,CAACC,aAC5BA,WAAWC,OAAO,CAAC,eAAe,CAACC,IAAM,CAAC,EAAE,EAAEA,GAAG;AAG5C,MAAMT,uBAAuB,CAACU,eACnC,IAAIC,OAAO,CAAC,EAAE,EAAED,aAAaE,GAAG,CAACN,sBAAsBO,IAAI,CAAC,KAAK,QAAQ,CAAC;AAE5E,kEAAkE,GAClE,MAAMC,6BAA6B,CAAIC;IACrC,IAAIC;IACJ,OAAO;QACL,IAAI,CAACA,KAAK;YACR,MAAMC,WAAWb,QAAQc,OAAO,CAAC;YACjC,MAAMC,kBAAkBf,QAAQc,OAAO,CAACH,SAAS;gBAC/CK,OAAO;oBAACH;iBAAS;YACnB;YACA,OAAQD,MAAMZ,QAAQe;QACxB;QACA,OAAOH;IACT;AACF;AAEA,MAAMK,uBAAuBP,2BAE3B;AAEF,MAAMQ,6BAA6BR,2BAEjC;AAEF,MAAMS,wBAAwB,OAC5BC,aACAC;IAEA,MAAMC,cAAcL;IACpB,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|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "assertMetroPrivateServer", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return assertMetroPrivateServer;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
function _nodeassert() {
|
|
12
|
-
const data = /*#__PURE__*/ _interop_require_default(require("node:assert"));
|
|
13
|
-
_nodeassert = function() {
|
|
14
|
-
return data;
|
|
15
|
-
};
|
|
16
|
-
return data;
|
|
17
|
-
}
|
|
18
|
-
function _interop_require_default(obj) {
|
|
19
|
-
return obj && obj.__esModule ? obj : {
|
|
20
|
-
default: obj
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function assertMetroPrivateServer(metro) {
|
|
24
|
-
(0, _nodeassert().default)(metro, 'Metro server undefined.');
|
|
25
|
-
(0, _nodeassert().default)('_config' in metro && '_bundler' in metro, 'Metro server is missing expected properties (_config, _bundler). This could be due to a version mismatch or change in the Metro API.');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=metroPrivateServer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/metroPrivateServer.ts"],"sourcesContent":["import { TransformInputOptions } from 'metro';\nimport type Metro from 'metro';\nimport { ConfigT } from 'metro-config';\nimport assert from 'node:assert';\n\nexport type MetroPrivateServer = import('metro').Server & {\n _bundler: import('metro/src/IncrementalBundler').default;\n _config: ConfigT;\n _createModuleId: (path: string, context?: { environment?: string; platform: string }) => number;\n _isEnded: boolean;\n _nextBundleBuildNumber: number;\n _platforms: Set<string>;\n _reporter: import('metro/src/lib/reporting').Reporter;\n _serverOptions: import('metro').ServerOptions | void;\n\n getNewBuildNumber(): number;\n _getSortedModules(\n graph: import('metro/src/IncrementalBundler').OutputGraph\n ): import('metro/src/DeltaBundler/types').Module[];\n\n _resolveRelativePath(\n filePath: string,\n {\n relativeTo,\n resolverOptions,\n transformOptions,\n }: {\n relativeTo: 'project' | 'server';\n resolverOptions: import('metro/src/shared/types').ResolverInputOptions;\n transformOptions: TransformInputOptions;\n }\n ): Promise<string>;\n\n _shouldAddModuleToIgnoreList(module: import('metro/src/DeltaBundler/types').Module<any>): boolean;\n};\n\nexport function assertMetroPrivateServer(metro: Metro.Server): asserts metro is MetroPrivateServer {\n assert(metro, 'Metro server undefined.');\n assert(\n '_config' in metro && '_bundler' in metro,\n 'Metro server is missing expected properties (_config, _bundler). This could be due to a version mismatch or change in the Metro API.'\n );\n}\n"],"names":["assertMetroPrivateServer","metro","assert"],"mappings":";;;;+BAoCgBA;;;eAAAA;;;;gEAjCG;;;;;;;;;;;AAiCZ,SAASA,yBAAyBC,KAAmB;IAC1DC,IAAAA,qBAAM,EAACD,OAAO;IACdC,IAAAA,qBAAM,EACJ,aAAaD,SAAS,cAAcA,OACpC;AAEJ"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "jsonSchemaDeref", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return jsonSchemaDeref;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
/** Return JSON schema ref if input is of `NodeRef` type */ const getRef = (node)=>node != null && typeof node === 'object' && '$ref' in node && typeof node.$ref === 'string' ? node.$ref : undefined;
|
|
12
|
-
/** Parse a JSON schema ref into a path array, or return undefined */ const parseRefMaybe = (ref)=>{
|
|
13
|
-
if (ref[0] !== '#') {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
const props = [];
|
|
17
|
-
let startIndex = 1;
|
|
18
|
-
let index = 1;
|
|
19
|
-
let char;
|
|
20
|
-
while(index < ref.length){
|
|
21
|
-
while((char = ref.charCodeAt(index++)) && char !== 47 /*'/'*/ );
|
|
22
|
-
const prop = ref.slice(startIndex, index - 1);
|
|
23
|
-
startIndex = index;
|
|
24
|
-
if (prop) props.push(prop);
|
|
25
|
-
}
|
|
26
|
-
return props.length ? props : undefined;
|
|
27
|
-
};
|
|
28
|
-
const NOT_FOUND_SYMBOL = Symbol();
|
|
29
|
-
/** Get value at given JSON schema path or return `NOT_FOUND_SYMBOL` */ const getValueAtPath = (input, ref)=>{
|
|
30
|
-
let node = input;
|
|
31
|
-
for(let index = 0; index < ref.length; index++){
|
|
32
|
-
const part = ref[index];
|
|
33
|
-
if (node != null && typeof node === 'object' && part in node) {
|
|
34
|
-
node = node[part];
|
|
35
|
-
} else {
|
|
36
|
-
node = NOT_FOUND_SYMBOL;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return node;
|
|
41
|
-
};
|
|
42
|
-
/** Find all JSON schema refs recursively and add them to `refs` Map */ const findRefsRec = (node, refs, path)=>{
|
|
43
|
-
if (node == null || typeof node !== 'object') {} else if (Array.isArray(node)) {
|
|
44
|
-
for(let index = 0, l = node.length; index < l; index++){
|
|
45
|
-
const value = node[index];
|
|
46
|
-
const ref = getRef(value);
|
|
47
|
-
if (ref) {
|
|
48
|
-
const targetRef = parseRefMaybe(ref);
|
|
49
|
-
if (targetRef) refs.set([
|
|
50
|
-
...path,
|
|
51
|
-
index
|
|
52
|
-
], targetRef);
|
|
53
|
-
} else if (value != null && typeof value === 'object') {
|
|
54
|
-
path.push(index);
|
|
55
|
-
findRefsRec(value, refs, path);
|
|
56
|
-
path.pop();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
} else {
|
|
60
|
-
const record = node;
|
|
61
|
-
for(const key in record){
|
|
62
|
-
const value = record[key];
|
|
63
|
-
const ref = getRef(value);
|
|
64
|
-
if (ref) {
|
|
65
|
-
const targetRef = parseRefMaybe(ref);
|
|
66
|
-
if (targetRef) refs.set([
|
|
67
|
-
...path,
|
|
68
|
-
key
|
|
69
|
-
], targetRef);
|
|
70
|
-
} else if (value != null && typeof value === 'object') {
|
|
71
|
-
path.push(key);
|
|
72
|
-
findRefsRec(value, refs, path);
|
|
73
|
-
path.pop();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
/** Detect whether target (where we set the source value) is a nested path inside the source path */ const isSelfReferencingRefEntry = (target, source)=>{
|
|
79
|
-
for(let index = 0; index < source.length; index++){
|
|
80
|
-
if (source[index] !== target[index]) return false;
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
};
|
|
84
|
-
/** Return sorted refs entries. Longest target paths will be returned first */ const getSortedRefEntries = (refs)=>{
|
|
85
|
-
const entries = [
|
|
86
|
-
...refs.entries()
|
|
87
|
-
].sort((a, b)=>b[1].length - a[1].length);
|
|
88
|
-
// Filter out self-referenceing paths. If we set nested targets to source values, we'd
|
|
89
|
-
// create unserializable circular references
|
|
90
|
-
return entries.filter((entry)=>!isSelfReferencingRefEntry(entry[0], entry[1]));
|
|
91
|
-
};
|
|
92
|
-
function jsonSchemaDeref(input) {
|
|
93
|
-
// Find all JSON schema refs paths
|
|
94
|
-
const refs = new Map();
|
|
95
|
-
findRefsRec(input, refs, []);
|
|
96
|
-
// Shallow copy output
|
|
97
|
-
const output = {
|
|
98
|
-
...input
|
|
99
|
-
};
|
|
100
|
-
// Process all ref entries with deepest targets first
|
|
101
|
-
nextRef: for (const [target, source] of getSortedRefEntries(refs)){
|
|
102
|
-
let inputNode = input;
|
|
103
|
-
let outputNode = output;
|
|
104
|
-
let targetIndex = 0;
|
|
105
|
-
// For each path part on the target, traverse the output and clone the input
|
|
106
|
-
// to not pollute it
|
|
107
|
-
for(; targetIndex < target.length - 1; targetIndex++){
|
|
108
|
-
const part = target[targetIndex];
|
|
109
|
-
if (inputNode == null || typeof inputNode !== 'object' || !(part in inputNode)) {
|
|
110
|
-
break;
|
|
111
|
-
} else if (outputNode[part] === inputNode[part]) {
|
|
112
|
-
// Copy the input on the output if references are equal
|
|
113
|
-
outputNode[part] = Array.isArray(inputNode[part]) ? [
|
|
114
|
-
...inputNode[part]
|
|
115
|
-
] : {
|
|
116
|
-
...inputNode[part]
|
|
117
|
-
};
|
|
118
|
-
inputNode = inputNode[part];
|
|
119
|
-
outputNode = outputNode[part];
|
|
120
|
-
} else {
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// For each remaining part on the target, continue traversing the output
|
|
125
|
-
for(; targetIndex < target.length - 1; targetIndex++){
|
|
126
|
-
const part = target[targetIndex];
|
|
127
|
-
if (outputNode == null || typeof outputNode !== 'object' || !(part in outputNode)) {
|
|
128
|
-
continue nextRef;
|
|
129
|
-
} else {
|
|
130
|
-
outputNode = outputNode[part];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// Get value from output
|
|
134
|
-
let sourceValue = getValueAtPath(output, source);
|
|
135
|
-
if (sourceValue === NOT_FOUND_SYMBOL) {
|
|
136
|
-
// If no value was found, try to get a value from the input instead
|
|
137
|
-
sourceValue = getValueAtPath(input, source);
|
|
138
|
-
// Otherwise, skip this ref
|
|
139
|
-
if (sourceValue === NOT_FOUND_SYMBOL) continue;
|
|
140
|
-
}
|
|
141
|
-
// Set the source value on the target path
|
|
142
|
-
// The for-loops prior have made sure that the output has already been deeply
|
|
143
|
-
// cloned and traversed for the entire path
|
|
144
|
-
outputNode[target[target.length - 1]] = sourceValue;
|
|
145
|
-
}
|
|
146
|
-
// Return the output with resolved refs
|
|
147
|
-
return output;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
//# sourceMappingURL=jsonSchemaDeref.js.map
|