@expo/cli 0.13.2 → 0.15.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 +30 -27
- package/build/bin/cli.map +1 -1
- package/build/src/api/getVersions.js.map +1 -1
- package/build/src/api/rest/cache/response.js.map +1 -1
- package/build/src/api/rest/client.js +2 -2
- package/build/src/api/rest/client.js.map +1 -1
- package/build/src/config/configAsync.js +1 -1
- package/build/src/config/configAsync.js.map +1 -1
- package/build/src/config/index.js +2 -2
- package/build/src/config/index.js.map +1 -1
- package/build/src/customize/generate.js +1 -1
- package/build/src/customize/generate.js.map +1 -1
- package/build/src/customize/typescript.js +6 -4
- package/build/src/customize/typescript.js.map +1 -1
- package/build/src/export/createMetadataJson.js +3 -2
- package/build/src/export/createMetadataJson.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +44 -17
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/index.js +4 -4
- package/build/src/export/embed/index.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +3 -3
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +74 -83
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +81 -21
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportHermes.js +24 -14
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +109 -58
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/favicon.js +2 -2
- package/build/src/export/favicon.js.map +1 -1
- package/build/src/export/fork-bundleAsync.js +56 -23
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/index.js +11 -9
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/metroAssetLocalPath.js +101 -0
- package/build/src/export/metroAssetLocalPath.js.map +1 -0
- package/build/src/export/persistMetroAssets.js +94 -21
- package/build/src/export/persistMetroAssets.js.map +1 -1
- package/build/src/export/resolveOptions.js +1 -1
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +9 -48
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/export/web/exportWebAsync.js +1 -1
- package/build/src/export/web/exportWebAsync.js.map +1 -1
- package/build/src/export/web/index.js +2 -2
- package/build/src/export/web/index.js.map +1 -1
- package/build/src/export/writeContents.js +6 -3
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/install/applyPlugins.js +52 -0
- package/build/src/install/applyPlugins.js.map +1 -0
- package/build/src/install/checkPackages.js +2 -2
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/fixPackages.js +84 -0
- package/build/src/install/fixPackages.js.map +1 -0
- package/build/src/install/installAsync.js +32 -61
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/install/installExpoPackage.js +79 -0
- package/build/src/install/installExpoPackage.js.map +1 -0
- package/build/src/login/index.js +1 -1
- package/build/src/login/index.js.map +1 -1
- package/build/src/logout/index.js +1 -1
- package/build/src/logout/index.js.map +1 -1
- package/build/src/prebuild/clearNativeFolder.js +1 -1
- package/build/src/prebuild/clearNativeFolder.js.map +1 -1
- package/build/src/prebuild/configureProjectAsync.js +3 -3
- package/build/src/prebuild/configureProjectAsync.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +21 -30
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/index.js +3 -3
- package/build/src/prebuild/index.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +39 -17
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveOptions.js +2 -2
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +6 -6
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +49 -36
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/prebuild/validateTemplatePlatforms.js +2 -2
- package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -1
- package/build/src/register/index.js +1 -1
- package/build/src/register/index.js.map +1 -1
- package/build/src/run/android/index.js +2 -2
- package/build/src/run/android/index.js.map +1 -1
- package/build/src/run/ios/appleDevice/AppleDevice.js +35 -2
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
- package/build/src/run/ios/index.js +2 -2
- package/build/src/run/ios/index.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +12 -4
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +20 -3
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/index.js +3 -3
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +30 -11
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +14 -10
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +6 -1
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/DevToolsPluginManager.js +63 -0
- package/build/src/start/server/DevToolsPluginManager.js.map +1 -0
- package/build/src/start/server/getStaticRenderFunctions.js +21 -20
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +67 -64
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/bundleApiRoutes.js +4 -19
- package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
- package/build/src/start/server/metro/createExpoMetroResolver.js +187 -0
- package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -0
- package/build/src/start/server/metro/createJResolver.js +149 -0
- package/build/src/start/server/metro/createJResolver.js.map +1 -0
- package/build/src/start/server/metro/createServerRouteMiddleware.js +13 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/externals.js +25 -3
- package/build/src/start/server/metro/externals.js.map +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
- package/build/src/start/server/metro/formatFileCandidates.js +72 -0
- package/build/src/start/server/metro/formatFileCandidates.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/device.js +3 -1
- package/build/src/start/server/metro/inspector-proxy/device.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js +3 -4
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeDebuggerGetPossibleBreakpoints.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js +24 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/VscodeRuntimeCallFunctionOn.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/utils.js +11 -0
- package/build/src/start/server/metro/inspector-proxy/handlers/utils.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/index.js +10 -7
- package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +37 -16
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +3 -2
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/router.js +6 -3
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +19 -10
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/serializeHtml.js +43 -0
- package/build/src/start/server/metro/serializeHtml.js.map +1 -0
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +1 -2
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
- package/build/src/start/server/metro/withMetroMultiPlatform.js +268 -191
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/metro/withMetroResolvers.js +114 -40
- package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js +61 -0
- package/build/src/start/server/middleware/DevToolsPluginMiddleware.js.map +1 -0
- package/build/src/start/server/middleware/ExpoMiddleware.js +2 -2
- package/build/src/start/server/middleware/ExpoMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +45 -68
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js +1 -1
- package/build/src/start/server/middleware/inspector/JsInspector.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowser.js +30 -26
- package/build/src/start/server/middleware/inspector/LaunchBrowser.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js +7 -7
- package/build/src/start/server/middleware/inspector/LaunchBrowser.types.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js +5 -2
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplLinux.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js +3 -2
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplMacOS.js.map +1 -1
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js +8 -7
- package/build/src/start/server/middleware/inspector/LaunchBrowserImplWindows.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +123 -0
- package/build/src/start/server/middleware/metroOptions.js.map +1 -0
- package/build/src/start/server/middleware/resolveAssets.js.map +1 -1
- package/build/src/start/server/type-generation/__typetests__/fixtures/basic.js.map +1 -1
- package/build/src/start/server/type-generation/expo-env.js +1 -1
- package/build/src/start/server/type-generation/expo-env.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js +1 -0
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/utils/analytics/getMetroDebugProperties.js +1 -2
- package/build/src/utils/analytics/getMetroDebugProperties.js.map +1 -1
- package/build/src/utils/analytics/getMetroProperties.js +1 -2
- package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/args.js +4 -2
- package/build/src/utils/args.js.map +1 -1
- package/build/src/utils/cocoapods.js +2 -1
- package/build/src/utils/cocoapods.js.map +1 -1
- package/build/src/utils/dir.js +18 -8
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/env.js +6 -0
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/getOrPromptApplicationId.js +2 -4
- package/build/src/utils/getOrPromptApplicationId.js.map +1 -1
- package/build/src/utils/prompts.js +1 -28
- package/build/src/utils/prompts.js.map +1 -1
- package/build/src/whoami/index.js +1 -1
- package/build/src/whoami/index.js.map +1 -1
- package/package.json +16 -16
- package/static/shims/react-native-web/dist/cjs/exports/AppRegistry/AppContainer.js +13 -0
- package/static/shims/react-native-web/dist/cjs/exports/BackHandler/index.js +10 -0
- package/static/shims/react-native-web/dist/exports/AppRegistry/AppContainer.js +12 -0
- package/static/shims/react-native-web/dist/exports/BackHandler/index.js +7 -0
- package/build/src/export/createBundles.js +0 -37
- package/build/src/export/createBundles.js.map +0 -1
- package/build/src/start/server/metro/resolveFromProject.js +0 -90
- package/build/src/start/server/metro/resolveFromProject.js.map +0 -1
- package/build/src/start/server/middleware/resolveEntryPoint.js +0 -42
- package/build/src/start/server/middleware/resolveEntryPoint.js.map +0 -1
|
@@ -6,20 +6,20 @@ exports.getWorkspaceRoot = getWorkspaceRoot;
|
|
|
6
6
|
exports.getEntryWithServerRoot = getEntryWithServerRoot;
|
|
7
7
|
exports.getMetroServerRoot = getMetroServerRoot;
|
|
8
8
|
exports.resolveMainModuleName = resolveMainModuleName;
|
|
9
|
-
exports.shouldEnableAsyncImports = shouldEnableAsyncImports;
|
|
10
|
-
exports.createBundleUrlPath = createBundleUrlPath;
|
|
11
9
|
exports.DEVELOPER_TOOL = void 0;
|
|
12
10
|
var _config = require("@expo/config");
|
|
11
|
+
var _paths = require("@expo/config/paths");
|
|
13
12
|
var _findYarnWorkspaceRoot = _interopRequireDefault(require("find-yarn-workspace-root"));
|
|
14
13
|
var _path = _interopRequireDefault(require("path"));
|
|
15
|
-
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
16
14
|
var _url = require("url");
|
|
17
15
|
var _expoMiddleware = require("./ExpoMiddleware");
|
|
16
|
+
var _metroOptions = require("./metroOptions");
|
|
18
17
|
var _resolveAssets = require("./resolveAssets");
|
|
19
|
-
var _resolveEntryPoint = require("./resolveEntryPoint");
|
|
20
18
|
var _resolvePlatform = require("./resolvePlatform");
|
|
19
|
+
var _exportHermes = require("../../../export/exportHermes");
|
|
21
20
|
var Log = _interopRequireWildcard(require("../../../log"));
|
|
22
21
|
var _env = require("../../../utils/env");
|
|
22
|
+
var _errors = require("../../../utils/errors");
|
|
23
23
|
var _url1 = require("../../../utils/url");
|
|
24
24
|
var ProjectDevices = _interopRequireWildcard(require("../../project/devices"));
|
|
25
25
|
var _platformBundlers = require("../platformBundlers");
|
|
@@ -61,8 +61,17 @@ function getWorkspaceRoot(projectRoot) {
|
|
|
61
61
|
throw error;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const supportedPlatforms = [
|
|
65
|
+
"ios",
|
|
66
|
+
"android",
|
|
67
|
+
"web",
|
|
68
|
+
"none"
|
|
69
|
+
];
|
|
70
|
+
function getEntryWithServerRoot(projectRoot, props) {
|
|
71
|
+
if (!supportedPlatforms.includes(props.platform)) {
|
|
72
|
+
throw new _errors.CommandError(`Failed to resolve the project's entry file: The platform "${props.platform}" is not supported.`);
|
|
73
|
+
}
|
|
74
|
+
return _path.default.relative(getMetroServerRoot(projectRoot), (0, _paths).resolveEntryPoint(projectRoot, props));
|
|
66
75
|
}
|
|
67
76
|
function getMetroServerRoot(projectRoot) {
|
|
68
77
|
if (_env.env.EXPO_USE_METRO_WORKSPACE_ROOT) {
|
|
@@ -71,46 +80,11 @@ function getMetroServerRoot(projectRoot) {
|
|
|
71
80
|
}
|
|
72
81
|
return projectRoot;
|
|
73
82
|
}
|
|
74
|
-
function resolveMainModuleName(projectRoot,
|
|
75
|
-
const entryPoint = getEntryWithServerRoot(projectRoot,
|
|
83
|
+
function resolveMainModuleName(projectRoot, props) {
|
|
84
|
+
const entryPoint = getEntryWithServerRoot(projectRoot, props);
|
|
76
85
|
debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);
|
|
77
86
|
return (0, _url1).stripExtension(entryPoint, "js");
|
|
78
87
|
}
|
|
79
|
-
function shouldEnableAsyncImports(projectRoot) {
|
|
80
|
-
if (_env.env.EXPO_NO_METRO_LAZY) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
// `@expo/metro-runtime` includes support for the fetch + eval runtime code required
|
|
84
|
-
// to support async imports. If it's not installed, we can't support async imports.
|
|
85
|
-
// If it is installed, the user MUST import it somewhere in their project.
|
|
86
|
-
// Expo Router automatically pulls this in, so we can check for it.
|
|
87
|
-
return _resolveFrom.default.silent(projectRoot, "@expo/metro-runtime") != null;
|
|
88
|
-
}
|
|
89
|
-
function createBundleUrlPath({ platform , mainModuleName , mode , minify =mode === "production" , environment , serializerOutput , serializerIncludeMaps , lazy }) {
|
|
90
|
-
const queryParams = new URLSearchParams({
|
|
91
|
-
platform: encodeURIComponent(platform),
|
|
92
|
-
dev: String(mode !== "production"),
|
|
93
|
-
// TODO: Is this still needed?
|
|
94
|
-
hot: String(false)
|
|
95
|
-
});
|
|
96
|
-
if (lazy) {
|
|
97
|
-
queryParams.append("lazy", String(lazy));
|
|
98
|
-
}
|
|
99
|
-
if (minify) {
|
|
100
|
-
queryParams.append("minify", String(minify));
|
|
101
|
-
}
|
|
102
|
-
if (environment) {
|
|
103
|
-
queryParams.append("resolver.environment", environment);
|
|
104
|
-
queryParams.append("transform.environment", environment);
|
|
105
|
-
}
|
|
106
|
-
if (serializerOutput) {
|
|
107
|
-
queryParams.append("serializer.output", serializerOutput);
|
|
108
|
-
}
|
|
109
|
-
if (serializerIncludeMaps) {
|
|
110
|
-
queryParams.append("serializer.map", String(serializerIncludeMaps));
|
|
111
|
-
}
|
|
112
|
-
return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;
|
|
113
|
-
}
|
|
114
88
|
const DEVELOPER_TOOL = "expo-cli";
|
|
115
89
|
exports.DEVELOPER_TOOL = DEVELOPER_TOOL;
|
|
116
90
|
class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
@@ -130,7 +104,11 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
130
104
|
// Read the config
|
|
131
105
|
const projectConfig = (0, _config).getConfig(this.projectRoot);
|
|
132
106
|
// Read from headers
|
|
133
|
-
const mainModuleName = this.resolveMainModuleName(
|
|
107
|
+
const mainModuleName = this.resolveMainModuleName({
|
|
108
|
+
pkg: projectConfig.pkg,
|
|
109
|
+
platform
|
|
110
|
+
});
|
|
111
|
+
const isHermesEnabled = (0, _exportHermes).isEnableHermesManaged(projectConfig.exp, platform);
|
|
134
112
|
// Create the manifest and set fields within it
|
|
135
113
|
const expoGoConfig = this.getExpoGoConfig({
|
|
136
114
|
mainModuleName,
|
|
@@ -143,7 +121,9 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
143
121
|
const bundleUrl = this._getBundleUrl({
|
|
144
122
|
platform,
|
|
145
123
|
mainModuleName,
|
|
146
|
-
hostname
|
|
124
|
+
hostname,
|
|
125
|
+
engine: isHermesEnabled ? "hermes" : undefined,
|
|
126
|
+
baseUrl: (0, _metroOptions).getBaseUrlFromExpoConfig(projectConfig.exp)
|
|
147
127
|
});
|
|
148
128
|
// Resolve all assets and set them on the manifest as URLs
|
|
149
129
|
await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);
|
|
@@ -154,8 +134,8 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
154
134
|
exp: projectConfig.exp
|
|
155
135
|
};
|
|
156
136
|
}
|
|
157
|
-
/** Get the main entry module ID (file) relative to the project root. */ resolveMainModuleName(
|
|
158
|
-
let entryPoint = getEntryWithServerRoot(this.projectRoot,
|
|
137
|
+
/** Get the main entry module ID (file) relative to the project root. */ resolveMainModuleName(props) {
|
|
138
|
+
let entryPoint = getEntryWithServerRoot(this.projectRoot, props);
|
|
159
139
|
debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);
|
|
160
140
|
// NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native
|
|
161
141
|
// in the future (TODO) we should move this logic into a Webpack plugin and use
|
|
@@ -176,14 +156,16 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
176
156
|
);
|
|
177
157
|
}
|
|
178
158
|
}
|
|
179
|
-
/** Create the bundle URL (points to the single JS entry file). Exposed for testing. */ _getBundleUrl({ platform , mainModuleName , hostname }) {
|
|
159
|
+
/** Create the bundle URL (points to the single JS entry file). Exposed for testing. */ _getBundleUrl({ platform , mainModuleName , hostname , engine , baseUrl }) {
|
|
180
160
|
var _mode;
|
|
181
|
-
const path = createBundleUrlPath({
|
|
161
|
+
const path = (0, _metroOptions).createBundleUrlPath({
|
|
182
162
|
mode: (_mode = this.options.mode) != null ? _mode : "development",
|
|
183
163
|
minify: this.options.minify,
|
|
184
164
|
platform,
|
|
185
165
|
mainModuleName,
|
|
186
|
-
lazy: shouldEnableAsyncImports(this.projectRoot)
|
|
166
|
+
lazy: (0, _metroOptions).shouldEnableAsyncImports(this.projectRoot),
|
|
167
|
+
engine,
|
|
168
|
+
baseUrl
|
|
187
169
|
});
|
|
188
170
|
return this.options.constructUrl({
|
|
189
171
|
scheme: "http",
|
|
@@ -191,21 +173,6 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
191
173
|
hostname
|
|
192
174
|
}) + path;
|
|
193
175
|
}
|
|
194
|
-
_getBundleUrlPath({ platform , mainModuleName }) {
|
|
195
|
-
const queryParams = new URLSearchParams({
|
|
196
|
-
platform: encodeURIComponent(platform),
|
|
197
|
-
dev: String(this.options.mode !== "production"),
|
|
198
|
-
// TODO: Is this still needed?
|
|
199
|
-
hot: String(false)
|
|
200
|
-
});
|
|
201
|
-
if (shouldEnableAsyncImports(this.projectRoot)) {
|
|
202
|
-
queryParams.append("lazy", String(true));
|
|
203
|
-
}
|
|
204
|
-
if (this.options.minify) {
|
|
205
|
-
queryParams.append("minify", String(this.options.minify));
|
|
206
|
-
}
|
|
207
|
-
return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;
|
|
208
|
-
}
|
|
209
176
|
getExpoGoConfig({ mainModuleName , hostname }) {
|
|
210
177
|
return {
|
|
211
178
|
// localhost:8081
|
|
@@ -249,10 +216,20 @@ class ManifestMiddleware extends _expoMiddleware.ExpoMiddleware {
|
|
|
249
216
|
getWebBundleUrl() {
|
|
250
217
|
const platform = "web";
|
|
251
218
|
// Read from headers
|
|
252
|
-
const mainModuleName = this.resolveMainModuleName(
|
|
253
|
-
|
|
219
|
+
const mainModuleName = this.resolveMainModuleName({
|
|
220
|
+
pkg: this.initialProjectConfig.pkg,
|
|
221
|
+
platform
|
|
222
|
+
});
|
|
223
|
+
var _mode;
|
|
224
|
+
return (0, _metroOptions).createBundleUrlPath({
|
|
254
225
|
platform,
|
|
255
|
-
mainModuleName
|
|
226
|
+
mainModuleName,
|
|
227
|
+
minify: this.options.minify,
|
|
228
|
+
lazy: (0, _metroOptions).shouldEnableAsyncImports(this.projectRoot),
|
|
229
|
+
mode: (_mode = this.options.mode) != null ? _mode : "development",
|
|
230
|
+
// Hermes doesn't support more modern JS features than most, if not all, modern browser.
|
|
231
|
+
engine: "hermes",
|
|
232
|
+
baseUrl: (0, _metroOptions).getBaseUrlFromExpoConfig(this.initialProjectConfig.exp)
|
|
256
233
|
});
|
|
257
234
|
}
|
|
258
235
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import { ExpoConfig, ExpoGoConfig, getConfig, ProjectConfig } from '@expo/config';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { resolve } from 'url';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { resolveAbsoluteEntryPoint } from './resolveEntryPoint';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\n\nconst debug = require('debug')('expo:start:server:middleware:manifest') as typeof console.log;\n\n/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */\nexport function getWorkspaceRoot(projectRoot: string): string | null {\n try {\n return findWorkspaceRoot(projectRoot);\n } catch (error: any) {\n if (error.message.includes('Unexpected end of JSON input')) {\n return null;\n }\n throw error;\n }\n}\n\nexport function getEntryWithServerRoot(\n projectRoot: string,\n projectConfig: ProjectConfig,\n platform: string\n) {\n return path.relative(\n getMetroServerRoot(projectRoot),\n resolveAbsoluteEntryPoint(projectRoot, platform, projectConfig)\n );\n}\n\nexport function getMetroServerRoot(projectRoot: string) {\n if (env.EXPO_USE_METRO_WORKSPACE_ROOT) {\n return getWorkspaceRoot(projectRoot) ?? projectRoot;\n }\n\n return projectRoot;\n}\n\n/** Get the main entry module ID (file) relative to the project root. */\nexport function resolveMainModuleName(\n projectRoot: string,\n projectConfig: ProjectConfig,\n platform: string\n): string {\n const entryPoint = getEntryWithServerRoot(projectRoot, projectConfig, platform);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);\n\n return stripExtension(entryPoint, 'js');\n}\n\nexport function shouldEnableAsyncImports(projectRoot: string): boolean {\n if (env.EXPO_NO_METRO_LAZY) {\n return false;\n }\n\n // `@expo/metro-runtime` includes support for the fetch + eval runtime code required\n // to support async imports. If it's not installed, we can't support async imports.\n // If it is installed, the user MUST import it somewhere in their project.\n // Expo Router automatically pulls this in, so we can check for it.\n return resolveFrom.silent(projectRoot, '@expo/metro-runtime') != null;\n}\n\nexport function createBundleUrlPath({\n platform,\n mainModuleName,\n mode,\n minify = mode === 'production',\n environment,\n serializerOutput,\n serializerIncludeMaps,\n lazy,\n}: {\n platform: string;\n mainModuleName: string;\n mode: string;\n minify?: boolean;\n environment?: string;\n serializerOutput?: 'static';\n serializerIncludeMaps?: boolean;\n lazy?: boolean;\n}): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n });\n\n if (lazy) {\n queryParams.append('lazy', String(lazy));\n }\n\n if (minify) {\n queryParams.append('minify', String(minify));\n }\n if (environment) {\n queryParams.append('resolver.environment', environment);\n queryParams.append('transform.environment', environment);\n }\n if (serializerOutput) {\n queryParams.append('serializer.output', serializerOutput);\n }\n if (serializerIncludeMaps) {\n queryParams.append('serializer.map', String(serializerIncludeMaps));\n }\n\n return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n}\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo,\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n\n constructor(\n protected projectRoot: string,\n protected options: ManifestMiddlewareOptions\n ) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n }: Pick<TManifestRequestInfo, 'hostname' | 'platform'>): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(projectConfig, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(projectConfig: ProjectConfig, platform: string): string {\n let entryPoint = getEntryWithServerRoot(this.projectRoot, projectConfig, platform);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);\n\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n }): string {\n const path = createBundleUrlPath({\n mode: this.options.mode ?? 'development',\n minify: this.options.minify,\n platform,\n mainModuleName,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n });\n\n return (\n this.options.constructUrl({\n scheme: 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n public _getBundleUrlPath({\n platform,\n mainModuleName,\n }: {\n platform: string;\n mainModuleName: string;\n }): string {\n const queryParams = new URLSearchParams({\n platform: encodeURIComponent(platform),\n dev: String(this.options.mode !== 'production'),\n // TODO: Is this still needed?\n hot: String(false),\n });\n if (shouldEnableAsyncImports(this.projectRoot)) {\n queryParams.append('lazy', String(true));\n }\n\n if (this.options.minify) {\n queryParams.append('minify', String(this.options.minify));\n }\n\n return `/${encodeURI(mainModuleName)}.bundle?${queryParams.toString()}`;\n }\n\n /** Log telemetry. */\n protected abstract trackManifest(version?: string): void;\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:8081\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=8081 open -a flipper.app`\n // Where 8081 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n public getWebBundleUrl() {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName(this.initialProjectConfig, platform);\n return this._getBundleUrlPath({\n platform,\n mainModuleName,\n });\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n // Read from headers\n const bundleUrl = this.getWebBundleUrl();\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n await createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n })\n );\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse, next: ServerNext) {\n // Read the config\n const bundlers = getPlatformBundlers(this.initialProjectConfig.exp);\n if (bundlers.web === 'metro') {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n if (['static', 'server'].includes(this.initialProjectConfig.exp.web?.output ?? '')) {\n // Skip the spa-styled index.html when static generation is enabled.\n next();\n return true;\n } else {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res, next)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, version, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n\n // Log analytics\n this.trackManifest(version ?? null);\n }\n}\n"],"names":["getWorkspaceRoot","getEntryWithServerRoot","getMetroServerRoot","resolveMainModuleName","shouldEnableAsyncImports","createBundleUrlPath","Log","ProjectDevices","debug","require","projectRoot","findWorkspaceRoot","error","message","includes","projectConfig","platform","path","relative","resolveAbsoluteEntryPoint","env","EXPO_USE_METRO_WORKSPACE_ROOT","entryPoint","stripExtension","EXPO_NO_METRO_LAZY","resolveFrom","silent","mainModuleName","mode","minify","environment","serializerOutput","serializerIncludeMaps","lazy","queryParams","URLSearchParams","encodeURIComponent","dev","String","hot","append","encodeURI","toString","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","_resolveProjectSettingsAsync","hostname","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","mutateManifestWithAssetsAsync","exp","isNativeWebpack","saveDevicesAsync","req","deviceIds","headers","catch","e","exception","_getBundleUrlPath","debuggerHost","developer","tool","packagerOpts","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","getWebBundleUrl","handleWebRequestAsync","res","setHeader","end","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","next","bundlers","getPlatformBundlers","web","parsePlatformHeader","output","handleRequestAsync","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","trackManifest"],"mappings":"AAAA;;;;QAsBgBA,gBAAgB,GAAhBA,gBAAgB;QAWhBC,sBAAsB,GAAtBA,sBAAsB;QAWtBC,kBAAkB,GAAlBA,kBAAkB;QASlBC,qBAAqB,GAArBA,qBAAqB;QAYrBC,wBAAwB,GAAxBA,wBAAwB;QAYxBC,mBAAmB,GAAnBA,mBAAmB;;AA7EgC,IAAA,OAAc,WAAd,cAAc,CAAA;AACnD,IAAA,sBAA0B,kCAA1B,0BAA0B,EAAA;AACvC,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AACd,IAAA,IAAK,WAAL,KAAK,CAAA;AAEE,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AACgB,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AACxC,IAAA,kBAAqB,WAArB,qBAAqB,CAAA;AACV,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AAE5DC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACK,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACT,IAAA,KAAoB,WAApB,oBAAoB,CAAA;AACvCC,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AAEU,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACH,IAAA,YAAgB,WAAhB,gBAAgB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C,WAAW,CAAC,IAAIpC,OAAO,CAAE;YAC/CkB,GAAG,CAACC,SAAS,CAACgB,UAAU,EAAEC,WAAW,CAAC,CAAC;SACxC;QACDlB,GAAG,CAACE,GAAG,CAACY,IAAI,CAAC,CAAC;QAEd,gBAAgB;QAChB,IAAI,CAACK,aAAa,CAACJ,OAAO,WAAPA,OAAO,GAAI,IAAI,CAAC,CAAC;KACrC;CACF;QAhRqBtD,kBAAkB,GAAlBA,kBAAkB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/middleware/ManifestMiddleware.ts"],"sourcesContent":["import {\n ExpoConfig,\n ExpoGoConfig,\n getConfig,\n PackageJSONConfig,\n ProjectConfig,\n} from '@expo/config';\nimport { resolveEntryPoint } from '@expo/config/paths';\nimport findWorkspaceRoot from 'find-yarn-workspace-root';\nimport path from 'path';\nimport { resolve } from 'url';\n\nimport { ExpoMiddleware } from './ExpoMiddleware';\nimport {\n shouldEnableAsyncImports,\n createBundleUrlPath,\n getBaseUrlFromExpoConfig,\n} from './metroOptions';\nimport { resolveGoogleServicesFile, resolveManifestAssets } from './resolveAssets';\nimport { parsePlatformHeader, RuntimePlatform } from './resolvePlatform';\nimport { ServerHeaders, ServerNext, ServerRequest, ServerResponse } from './server.types';\nimport { isEnableHermesManaged } from '../../../export/exportHermes';\nimport * as Log from '../../../log';\nimport { env } from '../../../utils/env';\nimport { CommandError } from '../../../utils/errors';\nimport { stripExtension } from '../../../utils/url';\nimport * as ProjectDevices from '../../project/devices';\nimport { UrlCreator } from '../UrlCreator';\nimport { getPlatformBundlers } from '../platformBundlers';\nimport { createTemplateHtmlFromExpoConfigAsync } from '../webTemplate';\n\nconst debug = require('debug')('expo:start:server:middleware:manifest') as typeof console.log;\n\n/** Wraps `findWorkspaceRoot` and guards against having an empty `package.json` file in an upper directory. */\nexport function getWorkspaceRoot(projectRoot: string): string | null {\n try {\n return findWorkspaceRoot(projectRoot);\n } catch (error: any) {\n if (error.message.includes('Unexpected end of JSON input')) {\n return null;\n }\n throw error;\n }\n}\n\nconst supportedPlatforms = ['ios', 'android', 'web', 'none'];\n\nexport function getEntryWithServerRoot(\n projectRoot: string,\n props: { platform: string; pkg?: PackageJSONConfig }\n) {\n if (!supportedPlatforms.includes(props.platform)) {\n throw new CommandError(\n `Failed to resolve the project's entry file: The platform \"${props.platform}\" is not supported.`\n );\n }\n return path.relative(getMetroServerRoot(projectRoot), resolveEntryPoint(projectRoot, props));\n}\n\nexport function getMetroServerRoot(projectRoot: string) {\n if (env.EXPO_USE_METRO_WORKSPACE_ROOT) {\n return getWorkspaceRoot(projectRoot) ?? projectRoot;\n }\n\n return projectRoot;\n}\n\n/** Get the main entry module ID (file) relative to the project root. */\nexport function resolveMainModuleName(\n projectRoot: string,\n props: { platform: string; pkg?: PackageJSONConfig }\n): string {\n const entryPoint = getEntryWithServerRoot(projectRoot, props);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${projectRoot})`);\n\n return stripExtension(entryPoint, 'js');\n}\n\n/** Info about the computer hosting the dev server. */\nexport interface HostInfo {\n host: string;\n server: 'expo';\n serverVersion: string;\n serverDriver: string | null;\n serverOS: NodeJS.Platform;\n serverOSVersion: string;\n}\n\n/** Parsed values from the supported request headers. */\nexport interface ManifestRequestInfo {\n /** Platform to serve. */\n platform: RuntimePlatform;\n /** Requested host name. */\n hostname?: string | null;\n}\n\n/** Project related info. */\nexport type ResponseProjectSettings = {\n expoGoConfig: ExpoGoConfig;\n hostUri: string;\n bundleUrl: string;\n exp: ExpoConfig;\n};\n\nexport const DEVELOPER_TOOL = 'expo-cli';\n\nexport type ManifestMiddlewareOptions = {\n /** Should start the dev servers in development mode (minify). */\n mode?: 'development' | 'production';\n /** Should instruct the bundler to create minified bundles. */\n minify?: boolean;\n constructUrl: UrlCreator['constructUrl'];\n isNativeWebpack?: boolean;\n privateKeyPath?: string;\n};\n\n/** Base middleware creator for serving the Expo manifest (like the index.html but for native runtimes). */\nexport abstract class ManifestMiddleware<\n TManifestRequestInfo extends ManifestRequestInfo,\n> extends ExpoMiddleware {\n private initialProjectConfig: ProjectConfig;\n\n constructor(\n protected projectRoot: string,\n protected options: ManifestMiddlewareOptions\n ) {\n super(\n projectRoot,\n /**\n * Only support `/`, `/manifest`, `/index.exp` for the manifest middleware.\n */\n ['/', '/manifest', '/index.exp']\n );\n this.initialProjectConfig = getConfig(projectRoot);\n }\n\n /** Exposed for testing. */\n public async _resolveProjectSettingsAsync({\n platform,\n hostname,\n }: Pick<TManifestRequestInfo, 'hostname' | 'platform'>): Promise<ResponseProjectSettings> {\n // Read the config\n const projectConfig = getConfig(this.projectRoot);\n\n // Read from headers\n const mainModuleName = this.resolveMainModuleName({\n pkg: projectConfig.pkg,\n platform,\n });\n\n const isHermesEnabled = isEnableHermesManaged(projectConfig.exp, platform);\n\n // Create the manifest and set fields within it\n const expoGoConfig = this.getExpoGoConfig({\n mainModuleName,\n hostname,\n });\n\n const hostUri = this.options.constructUrl({ scheme: '', hostname });\n\n const bundleUrl = this._getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n engine: isHermesEnabled ? 'hermes' : undefined,\n baseUrl: getBaseUrlFromExpoConfig(projectConfig.exp),\n });\n\n // Resolve all assets and set them on the manifest as URLs\n await this.mutateManifestWithAssetsAsync(projectConfig.exp, bundleUrl);\n\n return {\n expoGoConfig,\n hostUri,\n bundleUrl,\n exp: projectConfig.exp,\n };\n }\n\n /** Get the main entry module ID (file) relative to the project root. */\n private resolveMainModuleName(props: { pkg: PackageJSONConfig; platform: string }): string {\n let entryPoint = getEntryWithServerRoot(this.projectRoot, props);\n\n debug(`Resolved entry point: ${entryPoint} (project root: ${this.projectRoot})`);\n\n // NOTE(Bacon): Webpack is currently hardcoded to index.bundle on native\n // in the future (TODO) we should move this logic into a Webpack plugin and use\n // a generated file name like we do on web.\n // const server = getDefaultDevServer();\n // // TODO: Move this into BundlerDevServer and read this info from self.\n // const isNativeWebpack = server instanceof WebpackBundlerDevServer && server.isTargetingNative();\n if (this.options.isNativeWebpack) {\n entryPoint = 'index.js';\n }\n\n return stripExtension(entryPoint, 'js');\n }\n\n /** Parse request headers into options. */\n public abstract getParsedHeaders(req: ServerRequest): TManifestRequestInfo;\n\n /** Store device IDs that were sent in the request headers. */\n private async saveDevicesAsync(req: ServerRequest) {\n const deviceIds = req.headers?.['expo-dev-client-id'];\n if (deviceIds) {\n await ProjectDevices.saveDevicesAsync(this.projectRoot, deviceIds).catch((e) =>\n Log.exception(e)\n );\n }\n }\n\n /** Create the bundle URL (points to the single JS entry file). Exposed for testing. */\n public _getBundleUrl({\n platform,\n mainModuleName,\n hostname,\n engine,\n baseUrl,\n }: {\n platform: string;\n hostname?: string | null;\n mainModuleName: string;\n engine?: 'hermes';\n baseUrl?: string;\n }): string {\n const path = createBundleUrlPath({\n mode: this.options.mode ?? 'development',\n minify: this.options.minify,\n platform,\n mainModuleName,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n engine,\n baseUrl,\n });\n\n return (\n this.options.constructUrl({\n scheme: 'http',\n // hostType: this.options.location.hostType,\n hostname,\n }) + path\n );\n }\n\n /** Log telemetry. */\n protected abstract trackManifest(version?: string): void;\n\n /** Get the manifest response to return to the runtime. This file contains info regarding where the assets can be loaded from. Exposed for testing. */\n public abstract _getManifestResponseAsync(options: TManifestRequestInfo): Promise<{\n body: string;\n version: string;\n headers: ServerHeaders;\n }>;\n\n private getExpoGoConfig({\n mainModuleName,\n hostname,\n }: {\n mainModuleName: string;\n hostname?: string | null;\n }): ExpoGoConfig {\n return {\n // localhost:8081\n debuggerHost: this.options.constructUrl({ scheme: '', hostname }),\n // Required for Expo Go to function.\n developer: {\n tool: DEVELOPER_TOOL,\n projectRoot: this.projectRoot,\n },\n packagerOpts: {\n // Required for dev client.\n dev: this.options.mode !== 'production',\n },\n // Indicates the name of the main bundle.\n mainModuleName,\n // Add this string to make Flipper register React Native / Metro as \"running\".\n // Can be tested by running:\n // `METRO_SERVER_PORT=8081 open -a flipper.app`\n // Where 8081 is the port where the Expo project is being hosted.\n __flipperHack: 'React Native packager is running',\n };\n }\n\n /** Resolve all assets and set them on the manifest as URLs */\n private async mutateManifestWithAssetsAsync(manifest: ExpoConfig, bundleUrl: string) {\n await resolveManifestAssets(this.projectRoot, {\n manifest,\n resolver: async (path) => {\n if (this.options.isNativeWebpack) {\n // When using our custom dev server, just do assets normally\n // without the `assets/` subpath redirect.\n return resolve(bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0], path);\n }\n return bundleUrl!.match(/^https?:\\/\\/.*?\\//)![0] + 'assets/' + path;\n },\n });\n // The server normally inserts this but if we're offline we'll do it here\n await resolveGoogleServicesFile(this.projectRoot, manifest);\n }\n\n public getWebBundleUrl() {\n const platform = 'web';\n // Read from headers\n const mainModuleName = this.resolveMainModuleName({\n pkg: this.initialProjectConfig.pkg,\n platform,\n });\n\n return createBundleUrlPath({\n platform,\n mainModuleName,\n minify: this.options.minify,\n lazy: shouldEnableAsyncImports(this.projectRoot),\n mode: this.options.mode ?? 'development',\n // Hermes doesn't support more modern JS features than most, if not all, modern browser.\n engine: 'hermes',\n baseUrl: getBaseUrlFromExpoConfig(this.initialProjectConfig.exp),\n });\n }\n\n /**\n * Web platforms should create an index.html response using the same script resolution as native.\n *\n * Instead of adding a `bundleUrl` to a `manifest.json` (native) we'll add a `<script src=\"\">`\n * to an `index.html`, this enables the web platform to load JavaScript from the server.\n */\n private async handleWebRequestAsync(req: ServerRequest, res: ServerResponse) {\n // Read from headers\n const bundleUrl = this.getWebBundleUrl();\n\n res.setHeader('Content-Type', 'text/html');\n\n res.end(\n await createTemplateHtmlFromExpoConfigAsync(this.projectRoot, {\n exp: this.initialProjectConfig.exp,\n scripts: [bundleUrl],\n })\n );\n }\n\n /** Exposed for testing. */\n async checkBrowserRequestAsync(req: ServerRequest, res: ServerResponse, next: ServerNext) {\n // Read the config\n const bundlers = getPlatformBundlers(this.initialProjectConfig.exp);\n if (bundlers.web === 'metro') {\n // NOTE(EvanBacon): This effectively disables the safety check we do on custom runtimes to ensure\n // the `expo-platform` header is included. When `web.bundler=web`, if the user has non-standard Expo\n // code loading then they'll get a web bundle without a clear assertion of platform support.\n const platform = parsePlatformHeader(req);\n // On web, serve the public folder\n if (!platform || platform === 'web') {\n if (['static', 'server'].includes(this.initialProjectConfig.exp.web?.output ?? '')) {\n // Skip the spa-styled index.html when static generation is enabled.\n next();\n return true;\n } else {\n await this.handleWebRequestAsync(req, res);\n return true;\n }\n }\n }\n return false;\n }\n\n async handleRequestAsync(\n req: ServerRequest,\n res: ServerResponse,\n next: ServerNext\n ): Promise<void> {\n // First check for standard JavaScript runtimes (aka legacy browsers like Chrome).\n if (await this.checkBrowserRequestAsync(req, res, next)) {\n return;\n }\n\n // Save device IDs for dev client.\n await this.saveDevicesAsync(req);\n\n // Read from headers\n const options = this.getParsedHeaders(req);\n const { body, version, headers } = await this._getManifestResponseAsync(options);\n for (const [headerName, headerValue] of headers) {\n res.setHeader(headerName, headerValue);\n }\n res.end(body);\n\n // Log analytics\n this.trackManifest(version ?? null);\n }\n}\n"],"names":["getWorkspaceRoot","getEntryWithServerRoot","getMetroServerRoot","resolveMainModuleName","Log","ProjectDevices","debug","require","projectRoot","findWorkspaceRoot","error","message","includes","supportedPlatforms","props","platform","CommandError","path","relative","resolveEntryPoint","env","EXPO_USE_METRO_WORKSPACE_ROOT","entryPoint","stripExtension","DEVELOPER_TOOL","ManifestMiddleware","ExpoMiddleware","constructor","options","initialProjectConfig","getConfig","_resolveProjectSettingsAsync","hostname","projectConfig","mainModuleName","pkg","isHermesEnabled","isEnableHermesManaged","exp","expoGoConfig","getExpoGoConfig","hostUri","constructUrl","scheme","bundleUrl","_getBundleUrl","engine","undefined","baseUrl","getBaseUrlFromExpoConfig","mutateManifestWithAssetsAsync","isNativeWebpack","saveDevicesAsync","req","deviceIds","headers","catch","e","exception","createBundleUrlPath","mode","minify","lazy","shouldEnableAsyncImports","debuggerHost","developer","tool","packagerOpts","dev","__flipperHack","manifest","resolveManifestAssets","resolver","resolve","match","resolveGoogleServicesFile","getWebBundleUrl","handleWebRequestAsync","res","setHeader","end","createTemplateHtmlFromExpoConfigAsync","scripts","checkBrowserRequestAsync","next","bundlers","getPlatformBundlers","web","parsePlatformHeader","output","handleRequestAsync","getParsedHeaders","body","version","_getManifestResponseAsync","headerName","headerValue","trackManifest"],"mappings":"AAAA;;;;QAkCgBA,gBAAgB,GAAhBA,gBAAgB;QAahBC,sBAAsB,GAAtBA,sBAAsB;QAYtBC,kBAAkB,GAAlBA,kBAAkB;QASlBC,qBAAqB,GAArBA,qBAAqB;;AA9D9B,IAAA,OAAc,WAAd,cAAc,CAAA;AACa,IAAA,MAAoB,WAApB,oBAAoB,CAAA;AACxB,IAAA,sBAA0B,kCAA1B,0BAA0B,EAAA;AACvC,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,IAAK,WAAL,KAAK,CAAA;AAEE,IAAA,eAAkB,WAAlB,kBAAkB,CAAA;AAK1C,IAAA,aAAgB,WAAhB,gBAAgB,CAAA;AAC0C,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AAC7B,IAAA,gBAAmB,WAAnB,mBAAmB,CAAA;AAElC,IAAA,aAA8B,WAA9B,8BAA8B,CAAA;AACxDC,IAAAA,GAAG,mCAAM,cAAc,EAApB;AACK,IAAA,IAAoB,WAApB,oBAAoB,CAAA;AACX,IAAA,OAAuB,WAAvB,uBAAuB,CAAA;AACrB,IAAA,KAAoB,WAApB,oBAAoB,CAAA;AACvCC,IAAAA,cAAc,mCAAM,uBAAuB,EAA7B;AAEU,IAAA,iBAAqB,WAArB,qBAAqB,CAAA;AACH,IAAA,YAAgB,WAAhB,gBAAgB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtE,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,uCAAuC,CAAC,AAAsB,AAAC;AAGvF,SAASP,gBAAgB,CAACQ,WAAmB,EAAiB;IACnE,IAAI;QACF,OAAOC,CAAAA,GAAAA,sBAAiB,AA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ACDlB,GAAG,CAACE,GAAG,CAACY,IAAI,CAAC,CAAC;QAEd,gBAAgB;QAChB,IAAI,CAACK,aAAa,CAACJ,OAAO,WAAPA,OAAO,GAAI,IAAI,CAAC,CAAC;KACrC;CACF;QA/QqBpE,kBAAkB,GAAlBA,kBAAkB"}
|
|
@@ -26,7 +26,7 @@ async function openJsInspector(app) {
|
|
|
26
26
|
const ws = app.webSocketDebuggerUrl.replace(/^ws:\/\//, "");
|
|
27
27
|
const url = `${urlBase}?panel=console&ws=${encodeURIComponent(ws)}`;
|
|
28
28
|
await closeJsInspector();
|
|
29
|
-
openingBrowserInstance = await (0, _launchBrowser).
|
|
29
|
+
openingBrowserInstance = await (0, _launchBrowser).launchInspectorBrowserAsync(url);
|
|
30
30
|
}
|
|
31
31
|
async function closeJsInspector() {
|
|
32
32
|
await (openingBrowserInstance == null ? void 0 : openingBrowserInstance.close());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/JsInspector.ts"],"sourcesContent":["import fetch from 'node-fetch';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/JsInspector.ts"],"sourcesContent":["import fetch from 'node-fetch';\n\nimport { launchInspectorBrowserAsync, type LaunchBrowserInstance } from './LaunchBrowser';\nexport interface MetroInspectorProxyApp {\n description: string;\n devtoolsFrontendUrl: string;\n faviconUrl: string;\n id: string;\n title: string;\n type: 'node';\n vm: 'Hermes' | \"don't use\";\n webSocketDebuggerUrl: string;\n}\n\nlet openingBrowserInstance: LaunchBrowserInstance | null = null;\n\nexport async function openJsInspector(app: MetroInspectorProxyApp) {\n // To update devtoolsFrontendRev, find the full commit hash in the url:\n // https://chromium.googlesource.com/chromium/src.git/+log/refs/tags/{CHROME_VERSION}/chrome/VERSION\n //\n // 1. Replace {CHROME_VERSION} with the target chrome version\n // 2. Click the first log item in the webpage\n // 3. The full commit hash is the desired revision\n const devtoolsFrontendRev = 'd9568d04d7dd79269c5a655d7ada69650c5a8336'; // Chrome 100.0.4896.75\n\n const urlBase = `https://chrome-devtools-frontend.appspot.com/serve_rev/@${devtoolsFrontendRev}/devtools_app.html`;\n const ws = app.webSocketDebuggerUrl.replace(/^ws:\\/\\//, '');\n const url = `${urlBase}?panel=console&ws=${encodeURIComponent(ws)}`;\n await closeJsInspector();\n openingBrowserInstance = await launchInspectorBrowserAsync(url);\n}\n\nexport async function closeJsInspector() {\n await openingBrowserInstance?.close();\n openingBrowserInstance = null;\n}\n\nexport async function queryInspectorAppAsync(\n metroServerOrigin: string,\n appId: string\n): Promise<MetroInspectorProxyApp | null> {\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n return apps.find((app) => app.description === appId) ?? null;\n}\n\nexport async function queryAllInspectorAppsAsync(\n metroServerOrigin: string\n): Promise<MetroInspectorProxyApp[]> {\n const resp = await fetch(`${metroServerOrigin}/json/list`);\n const apps: MetroInspectorProxyApp[] = transformApps(await resp.json());\n // Only use targets with better reloading support\n return apps.filter((app) => app.title === 'React Native Experimental (Improved Chrome Reloads)');\n}\n\n// The description of `React Native Experimental (Improved Chrome Reloads)` target is `don't use` from metro.\n// This function tries to transform the unmeaningful description to appId\nfunction transformApps(apps: MetroInspectorProxyApp[]): MetroInspectorProxyApp[] {\n const deviceIdToAppId: Record<string, string> = {};\n\n for (const app of apps) {\n if (app.description !== \"don't use\") {\n const deviceId = app.id.split('-')[0];\n const appId = app.description;\n deviceIdToAppId[deviceId] = appId;\n }\n }\n\n return apps.map((app) => {\n if (app.description === \"don't use\") {\n const deviceId = app.id.split('-')[0];\n app.description = deviceIdToAppId[deviceId] ?? app.description;\n }\n return app;\n });\n}\n"],"names":["openJsInspector","closeJsInspector","queryInspectorAppAsync","queryAllInspectorAppsAsync","openingBrowserInstance","app","devtoolsFrontendRev","urlBase","ws","webSocketDebuggerUrl","replace","url","encodeURIComponent","launchInspectorBrowserAsync","close","metroServerOrigin","appId","apps","find","description","resp","fetch","transformApps","json","filter","title","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Ae,CAACC,QAAQ,CAAC,YAAzBD,SAAyB,GAAIrB,GAAG,CAACc,WAAW,CAAC;SAChE;QACD,OAAOd,GAAG,CAAC;KACZ,CAAC,CAAC;CACJ"}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.
|
|
5
|
+
exports.createLaunchBrowser = createLaunchBrowser;
|
|
6
|
+
exports.findSupportedBrowserTypeAsync = findSupportedBrowserTypeAsync;
|
|
7
|
+
exports.launchInspectorBrowserAsync = launchInspectorBrowserAsync;
|
|
6
8
|
var _os = _interopRequireDefault(require("os"));
|
|
7
9
|
var _launchBrowserTypes = require("./LaunchBrowser.types");
|
|
8
10
|
var _launchBrowserImplLinux = _interopRequireDefault(require("./LaunchBrowserImplLinux"));
|
|
@@ -14,9 +16,32 @@ function _interopRequireDefault(obj) {
|
|
|
14
16
|
};
|
|
15
17
|
}
|
|
16
18
|
const IS_WSL = require("is-wsl") && !require("is-docker")();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
function createLaunchBrowser() {
|
|
20
|
+
let launchBrowser;
|
|
21
|
+
if (_os.default.platform() === "darwin") {
|
|
22
|
+
launchBrowser = new _launchBrowserImplMacOS.default();
|
|
23
|
+
} else if (_os.default.platform() === "win32" || IS_WSL) {
|
|
24
|
+
launchBrowser = new _launchBrowserImplWindows.default();
|
|
25
|
+
} else if (_os.default.platform() === "linux") {
|
|
26
|
+
launchBrowser = new _launchBrowserImplLinux.default();
|
|
27
|
+
} else {
|
|
28
|
+
throw new Error("[createLaunchBrowser] Unsupported host platform");
|
|
29
|
+
}
|
|
30
|
+
return launchBrowser;
|
|
31
|
+
}
|
|
32
|
+
async function findSupportedBrowserTypeAsync(launchBrowser) {
|
|
33
|
+
const supportedBrowsers = Object.values(_launchBrowserTypes.LaunchBrowserTypesEnum);
|
|
34
|
+
for (const browserType of supportedBrowsers){
|
|
35
|
+
if (await launchBrowser.isSupportedBrowser(browserType)) {
|
|
36
|
+
return browserType;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`[findSupportedBrowserTypeAsync] Unable to find a browser on the host to open the inspector. Supported browsers: ${supportedBrowsers.join(", ")}`);
|
|
40
|
+
}
|
|
41
|
+
async function launchInspectorBrowserAsync(url, browser, browserType) {
|
|
42
|
+
const launchBrowser = browser != null ? browser : createLaunchBrowser();
|
|
43
|
+
const launchBrowserType = browserType != null ? browserType : await findSupportedBrowserTypeAsync(launchBrowser);
|
|
44
|
+
const tempBrowserDir = await launchBrowser.createTempBrowserDir("expo-inspector");
|
|
20
45
|
// For dev-client connecting metro in LAN, the request to fetch sourcemaps may be blocked by Chromium
|
|
21
46
|
// with insecure-content (https page send xhr for http resource).
|
|
22
47
|
// Adding `--allow-running-insecure-content` to overcome this limitation
|
|
@@ -30,28 +55,7 @@ async function launchBrowserAsync(url) {
|
|
|
30
55
|
"--no-first-run",
|
|
31
56
|
"--no-default-browser-check",
|
|
32
57
|
];
|
|
33
|
-
|
|
34
|
-
_launchBrowserTypes.LaunchBrowserTypes.CHROME,
|
|
35
|
-
_launchBrowserTypes.LaunchBrowserTypes.EDGE
|
|
36
|
-
]){
|
|
37
|
-
const isSupported = await browser.isSupportedBrowser(browserType);
|
|
38
|
-
if (isSupported) {
|
|
39
|
-
return browser.launchAsync(browserType, launchArgs);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
throw new Error("[LaunchBrowser] Unable to find a browser on the host to open the inspector. Supported browsers: Google Chrome, Microsoft Edge");
|
|
43
|
-
}
|
|
44
|
-
function createBrowser() {
|
|
45
|
-
if (_os.default.platform() === "darwin") {
|
|
46
|
-
return new _launchBrowserImplMacOS.default();
|
|
47
|
-
}
|
|
48
|
-
if (_os.default.platform() === "win32" || IS_WSL) {
|
|
49
|
-
return new _launchBrowserImplWindows.default();
|
|
50
|
-
}
|
|
51
|
-
if (_os.default.platform() === "linux") {
|
|
52
|
-
return new _launchBrowserImplLinux.default();
|
|
53
|
-
}
|
|
54
|
-
throw new Error("[LaunchBrowser] Unsupported host platform");
|
|
58
|
+
return launchBrowser.launchAsync(launchBrowserType, launchArgs);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
//# sourceMappingURL=LaunchBrowser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/LaunchBrowser.ts"],"sourcesContent":["import os from 'os';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/LaunchBrowser.ts"],"sourcesContent":["import os from 'os';\n\nimport {\n LaunchBrowserTypesEnum,\n type LaunchBrowser,\n type LaunchBrowserInstance,\n type LaunchBrowserTypes,\n} from './LaunchBrowser.types';\nimport LaunchBrowserImplLinux from './LaunchBrowserImplLinux';\nimport LaunchBrowserImplMacOS from './LaunchBrowserImplMacOS';\nimport LaunchBrowserImplWindows from './LaunchBrowserImplWindows';\n\nexport type { LaunchBrowserInstance };\n\nconst IS_WSL = require('is-wsl') && !require('is-docker')();\n\n/**\n * A factory to create a LaunchBrowser instance based on the host platform\n */\nexport function createLaunchBrowser(): LaunchBrowser {\n let launchBrowser: LaunchBrowser;\n if (os.platform() === 'darwin') {\n launchBrowser = new LaunchBrowserImplMacOS();\n } else if (os.platform() === 'win32' || IS_WSL) {\n launchBrowser = new LaunchBrowserImplWindows();\n } else if (os.platform() === 'linux') {\n launchBrowser = new LaunchBrowserImplLinux();\n } else {\n throw new Error('[createLaunchBrowser] Unsupported host platform');\n }\n return launchBrowser;\n}\n\n/**\n * Find a supported browser type on the host\n */\nexport async function findSupportedBrowserTypeAsync(\n launchBrowser: LaunchBrowser\n): Promise<LaunchBrowserTypes> {\n const supportedBrowsers = Object.values(LaunchBrowserTypesEnum);\n for (const browserType of supportedBrowsers) {\n if (await launchBrowser.isSupportedBrowser(browserType)) {\n return browserType;\n }\n }\n\n throw new Error(\n `[findSupportedBrowserTypeAsync] Unable to find a browser on the host to open the inspector. Supported browsers: ${supportedBrowsers.join(\n ', '\n )}`\n );\n}\n\n/**\n * Launch a browser for inspector\n */\nexport async function launchInspectorBrowserAsync(\n url: string,\n browser?: LaunchBrowser,\n browserType?: LaunchBrowserTypes\n): Promise<LaunchBrowserInstance> {\n const launchBrowser = browser ?? createLaunchBrowser();\n const launchBrowserType = browserType ?? (await findSupportedBrowserTypeAsync(launchBrowser));\n\n const tempBrowserDir = await launchBrowser.createTempBrowserDir('expo-inspector');\n\n // For dev-client connecting metro in LAN, the request to fetch sourcemaps may be blocked by Chromium\n // with insecure-content (https page send xhr for http resource).\n // Adding `--allow-running-insecure-content` to overcome this limitation\n // without users manually allow insecure-content in site settings.\n // However, if there is existing chromium browser process, the argument will not take effect.\n // We also pass a `--user-data-dir=` as temporary profile and force chromium to create new browser process.\n const launchArgs = [\n `--app=${url}`,\n '--allow-running-insecure-content',\n `--user-data-dir=${tempBrowserDir}`,\n '--no-first-run',\n '--no-default-browser-check',\n ];\n\n return launchBrowser.launchAsync(launchBrowserType, launchArgs);\n}\n"],"names":["createLaunchBrowser","findSupportedBrowserTypeAsync","launchInspectorBrowserAsync","IS_WSL","require","launchBrowser","os","platform","LaunchBrowserImplMacOS","LaunchBrowserImplWindows","LaunchBrowserImplLinux","Error","supportedBrowsers","Object","values","LaunchBrowserTypesEnum","browserType","isSupportedBrowser","join","url","browser","launchBrowserType","tempBrowserDir","createTempBrowserDir","launchArgs","launchAsync"],"mappings":"AAAA;;;;QAmBgBA,mBAAmB,GAAnBA,mBAAmB;QAiBbC,6BAA6B,GAA7BA,6BAA6B;QAoB7BC,2BAA2B,GAA3BA,2BAA2B;AAxDlC,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAOZ,IAAA,mBAAuB,WAAvB,uBAAuB,CAAA;AACK,IAAA,uBAA0B,kCAA1B,0BAA0B,EAAA;AAC1B,IAAA,uBAA0B,kCAA1B,0BAA0B,EAAA;AACxB,IAAA,yBA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AGL,WAAW,WAAXA,WAAW,GAAK,MAAMf,6BAA6B,CAACI,aAAa,CAAC,AAAC,AAAC;IAE9F,MAAMiB,cAAc,GAAG,MAAMjB,aAAa,CAACkB,oBAAoB,CAAC,gBAAgB,CAAC,AAAC;IAElF,qGAAqG;IACrG,iEAAiE;IACjE,wEAAwE;IACxE,kEAAkE;IAClE,6FAA6F;IAC7F,2GAA2G;IAC3G,MAAMC,UAAU,GAAG;QACjB,CAAC,MAAM,EAAEL,GAAG,CAAC,CAAC;QACd,kCAAkC;QAClC,CAAC,gBAAgB,EAAEG,cAAc,CAAC,CAAC;QACnC,gBAAgB;QAChB,4BAA4B;KAC7B,AAAC;IAEF,OAAOjB,aAAa,CAACoB,WAAW,CAACJ,iBAAiB,EAAEG,UAAU,CAAC,CAAC;CACjE"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
exports.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
exports.LaunchBrowserTypesEnum = void 0;
|
|
6
|
+
const LaunchBrowserTypesEnum = {
|
|
7
|
+
CHROME: "Google Chrome",
|
|
8
|
+
EDGE: "Microsoft Edge",
|
|
9
|
+
BRAVE: "Brave"
|
|
10
|
+
};
|
|
11
|
+
exports.LaunchBrowserTypesEnum = LaunchBrowserTypesEnum;
|
|
12
12
|
|
|
13
13
|
//# sourceMappingURL=LaunchBrowser.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/LaunchBrowser.types.ts"],"sourcesContent":["export interface LaunchBrowserInstance {\n close: () => Promise<void>;\n}\n\n/**\n * Supported browser types\n */\nexport
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/LaunchBrowser.types.ts"],"sourcesContent":["export interface LaunchBrowserInstance {\n close: () => Promise<void>;\n}\n\n/**\n * Supported browser types enum\n */\nexport const LaunchBrowserTypesEnum = {\n CHROME: 'Google Chrome',\n EDGE: 'Microsoft Edge',\n BRAVE: 'Brave',\n} as const;\n\n/**\n * Supported browser types\n */\nexport type LaunchBrowserTypes =\n (typeof LaunchBrowserTypesEnum)[keyof typeof LaunchBrowserTypesEnum];\n\n/**\n * A browser launcher\n */\nexport interface LaunchBrowser {\n /**\n * Return whether the given `browserType` is supported\n */\n isSupportedBrowser: (browserType: LaunchBrowserTypes) => Promise<boolean>;\n\n /**\n * Create temp directory for browser profile\n *\n * @param baseDirName The base directory name for the created directory\n */\n createTempBrowserDir: (baseDirName: string) => Promise<string>;\n\n /**\n * Launch the browser\n */\n launchAsync: (browserType: LaunchBrowserTypes, args: string[]) => Promise<LaunchBrowserInstance>;\n\n /**\n * Close current browser instance\n */\n close: () => Promise<void>;\n}\n"],"names":["LaunchBrowserTypesEnum","CHROME","EDGE","BRAVE"],"mappings":"AAAA;;;;;AAOO,MAAMA,sBAAsB,GAAG;IACpCC,MAAM,EAAE,eAAe;IACvBC,IAAI,EAAE,gBAAgB;IACtBC,KAAK,EAAE,OAAO;CACf,AAAS,AAAC;QAJEH,sBAAsB,GAAtBA,sBAAsB"}
|
|
@@ -9,14 +9,17 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
9
9
|
var _launchBrowserTypes = require("./LaunchBrowser.types");
|
|
10
10
|
class LaunchBrowserImplLinux {
|
|
11
11
|
MAP = {
|
|
12
|
-
[_launchBrowserTypes.
|
|
12
|
+
[_launchBrowserTypes.LaunchBrowserTypesEnum.CHROME]: [
|
|
13
13
|
"google-chrome",
|
|
14
14
|
"google-chrome-stable",
|
|
15
15
|
"chromium"
|
|
16
16
|
],
|
|
17
|
-
[_launchBrowserTypes.
|
|
17
|
+
[_launchBrowserTypes.LaunchBrowserTypesEnum.EDGE]: [
|
|
18
18
|
"microsoft-edge",
|
|
19
19
|
"microsoft-edge-dev"
|
|
20
|
+
],
|
|
21
|
+
[_launchBrowserTypes.LaunchBrowserTypesEnum.BRAVE]: [
|
|
22
|
+
"brave"
|
|
20
23
|
]
|
|
21
24
|
};
|
|
22
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/LaunchBrowserImplLinux.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { type ChildProcess } from 'child_process';\nimport open from 'open';\nimport path from 'path';\n\nimport {\n LaunchBrowserTypes,\n type
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/LaunchBrowserImplLinux.ts"],"sourcesContent":["import spawnAsync from '@expo/spawn-async';\nimport { type ChildProcess } from 'child_process';\nimport open from 'open';\nimport path from 'path';\n\nimport {\n LaunchBrowserTypes,\n type LaunchBrowser,\n type LaunchBrowserInstance,\n LaunchBrowserTypesEnum,\n} from './LaunchBrowser.types';\n\n/**\n * Browser implementation for Linux\n */\nexport default class LaunchBrowserImplLinux implements LaunchBrowser, LaunchBrowserInstance {\n private _appId: string | undefined;\n private _process: ChildProcess | undefined;\n\n MAP = {\n [LaunchBrowserTypesEnum.CHROME]: ['google-chrome', 'google-chrome-stable', 'chromium'],\n [LaunchBrowserTypesEnum.EDGE]: ['microsoft-edge', 'microsoft-edge-dev'],\n [LaunchBrowserTypesEnum.BRAVE]: ['brave'],\n };\n\n /**\n * On Linux, the supported appId is an array, this function finds the available appId and caches it\n */\n private async getAppId(browserType: LaunchBrowserTypes): Promise<string> {\n if (this._appId == null || !this.MAP[browserType].includes(this._appId)) {\n for (const appId of this.MAP[browserType]) {\n try {\n const { status } = await spawnAsync('which', [appId], { stdio: 'ignore' });\n if (status === 0) {\n this._appId = appId;\n break;\n }\n } catch {}\n }\n }\n\n if (this._appId == null) {\n throw new Error(\n `Unable to find supported browser - tried[${this.MAP[browserType].join(', ')}]`\n );\n }\n\n return this._appId;\n }\n\n async isSupportedBrowser(browserType: LaunchBrowserTypes): Promise<boolean> {\n let result = false;\n try {\n await this.getAppId(browserType);\n result = true;\n } catch {\n result = false;\n }\n return result;\n }\n\n async createTempBrowserDir(baseDirName: string) {\n return path.join(require('temp-dir'), baseDirName);\n }\n\n async launchAsync(\n browserType: LaunchBrowserTypes,\n args: string[]\n ): Promise<LaunchBrowserInstance> {\n const appId = await this.getAppId(browserType);\n this._process = await open.openApp(appId, { arguments: args });\n return this;\n }\n\n async close(): Promise<void> {\n this._process?.kill();\n this._process = undefined;\n this._appId = undefined;\n }\n}\n"],"names":["LaunchBrowserImplLinux","MAP","LaunchBrowserTypesEnum","CHROME","EDGE","BRAVE","getAppId","browserType","_appId","includes","appId","status","spawnAsync","stdio","Error","join","isSupportedBrowser","result","createTempBrowserDir","baseDirName","path","require","launchAsync","args","_process","open","openApp","arguments","close","kill","undefined"],"mappings":"AAAA;;;;;AAAuB,IAAA,WAAmB,kCAAnB,mBAAmB,EAAA;AAEzB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACN,IAAA,KAAM,kCAAN,MAAM,EAAA;AAOhB,IAAA,mBAAuB,WAAvB,uBAAuB,CAAA;AAKf,MAAMA,sBAAsB;IAIzCC,GAAG,GAAG;QACJ,CAACC,mBAAsB,uBAAA,CAACC,MAAM,CAAC,EAAE;YAAC,eAAe;YAAE,sBAAsB;YAAE,UAAU;SAAC;QACtF,CAACD,mBAAsB,uBAAA,CAACE,IAAI,CAAC,EAAE;YAAC,gBAAgB;YAAE,oBAAoB;SAAC;QACvE,CAACF,mBAAsB,uBAAA,CAACG,KAAK,CAAC,EAAE;YAAC,OAAO;SAAC;KAC1C,CAAC;IAEF;;KAEG,CACH,MAAcC,QAAQ,CAACC,WAA+B,EAAmB;QACvE,IAAI,IAAI,CAACC,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAACP,GAAG,CAACM,WAAW,CAAC,CAACE,QAAQ,CAAC,IAAI,CAACD,MAAM,CAAC,EAAE;YACvE,KAAK,MAAME,KAAK,IAAI,IAAI,CAACT,GAAG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,IAAI;SAAE,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;KACb;IAED,MAAMK,KAAK,GAAkB;YAC3B,GAAa;QAAb,CAAA,GAAa,GAAb,IAAI,CAACJ,QAAQ,SAAM,GAAnB,KAAA,CAAmB,GAAnB,GAAa,CAAEK,IAAI,EAAE,AA3EzB,CA2E0B;QACtB,IAAI,CAACL,QAAQ,GAAGM,SAAS,CAAC;QAC1B,IAAI,CAACtB,MAAM,GAAGsB,SAAS,CAAC;KACzB;CACF;kBAhEoB9B,sBAAsB"}
|
|
@@ -10,8 +10,9 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
10
10
|
var _launchBrowserTypes = require("./LaunchBrowser.types");
|
|
11
11
|
class LaunchBrowserImplMacOS {
|
|
12
12
|
MAP = {
|
|
13
|
-
[_launchBrowserTypes.
|
|
14
|
-
[_launchBrowserTypes.
|
|
13
|
+
[_launchBrowserTypes.LaunchBrowserTypesEnum.CHROME]: "google chrome",
|
|
14
|
+
[_launchBrowserTypes.LaunchBrowserTypesEnum.EDGE]: "microsoft edge",
|
|
15
|
+
[_launchBrowserTypes.LaunchBrowserTypesEnum.BRAVE]: "brave browser"
|
|
15
16
|
};
|
|
16
17
|
async isSupportedBrowser(browserType) {
|
|
17
18
|
let result = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/LaunchBrowserImplMacOS.ts"],"sourcesContent":["import * as osascript from '@expo/osascript';\nimport { spawn, type ChildProcess } from 'child_process';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\nimport {\n LaunchBrowserTypes,\n type
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/start/server/middleware/inspector/LaunchBrowserImplMacOS.ts"],"sourcesContent":["import * as osascript from '@expo/osascript';\nimport { spawn, type ChildProcess } from 'child_process';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\n\nimport {\n LaunchBrowserTypes,\n type LaunchBrowser,\n type LaunchBrowserInstance,\n LaunchBrowserTypesEnum,\n} from './LaunchBrowser.types';\n\n/**\n * Browser implementation for macOS\n */\nexport default class LaunchBrowserImplMacOS implements LaunchBrowser, LaunchBrowserInstance {\n private _process: ChildProcess | undefined;\n\n MAP = {\n [LaunchBrowserTypesEnum.CHROME]: 'google chrome',\n [LaunchBrowserTypesEnum.EDGE]: 'microsoft edge',\n [LaunchBrowserTypesEnum.BRAVE]: 'brave browser',\n };\n\n async isSupportedBrowser(browserType: LaunchBrowserTypes): Promise<boolean> {\n let result = false;\n try {\n await osascript.execAsync(`id of application \"${this.MAP[browserType]}\"`);\n result = true;\n } catch {\n result = false;\n }\n return result;\n }\n\n async createTempBrowserDir(baseDirName: string) {\n return path.join(require('temp-dir'), baseDirName);\n }\n\n async launchAsync(\n browserType: LaunchBrowserTypes,\n args: string[]\n ): Promise<LaunchBrowserInstance> {\n const appDirectory = await osascript.execAsync(\n `POSIX path of (path to application \"${this.MAP[browserType]}\")`\n );\n const appPath = globSync('Contents/MacOS/*', { cwd: appDirectory.trim(), absolute: true })?.[0];\n if (!appPath) {\n throw new Error(`Cannot find application path from ${appDirectory}Contents/MacOS`);\n }\n this._process = spawn(appPath, args, { stdio: 'ignore' });\n\n return this;\n }\n\n async close(): Promise<void> {\n this._process?.kill();\n this._process = undefined;\n }\n}\n"],"names":["osascript","LaunchBrowserImplMacOS","MAP","LaunchBrowserTypesEnum","CHROME","EDGE","BRAVE","isSupportedBrowser","browserType","result","execAsync","createTempBrowserDir","baseDirName","path","join","require","launchAsync","args","globSync","appDirectory","appPath","cwd","trim","absolute","Error","_process","spawn","stdio","close","kill","undefined"],"mappings":"AAAA;;;;;AAAYA,IAAAA,SAAS,mCAAM,iBAAiB,EAAvB;AACoB,IAAA,aAAe,WAAf,eAAe,CAAA;AACvB,IAAA,KAAM,WAAN,MAAM,CAAA;AACtB,IAAA,KAAM,kCAAN,MAAM,EAAA;AAOhB,IAAA,mBAAuB,WAAvB,uBAAuB,CAAA;AAKf,MAAMC,sBAA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