@expo/cli 0.7.3 → 0.9.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/README.md +1 -1
- package/build/bin/cli +17 -3
- package/build/bin/cli.map +1 -1
- package/build/src/api/getExpoGoIntermediateCertificate.js +0 -2
- package/build/src/api/getExpoGoIntermediateCertificate.js.map +1 -1
- package/build/src/api/getProjectDevelopmentCertificate.js +0 -2
- package/build/src/api/getProjectDevelopmentCertificate.js.map +1 -1
- package/build/src/api/graphql/queries/AppQuery.js +39 -0
- package/build/src/api/graphql/queries/AppQuery.js.map +1 -0
- package/build/src/api/graphql/queries/UserQuery.js +10 -3
- package/build/src/api/graphql/queries/UserQuery.js.map +1 -1
- package/build/src/api/graphql/types/App.js +23 -0
- package/build/src/api/graphql/types/App.js.map +1 -0
- package/build/src/api/signManifest.js +0 -12
- package/build/src/api/signManifest.js.map +1 -1
- package/build/src/api/user/UserSettings.js.map +1 -1
- package/build/src/api/user/user.js.map +1 -1
- package/build/src/config/configAsync.js +3 -0
- package/build/src/config/configAsync.js.map +1 -1
- package/build/src/customize/customizeAsync.js +3 -0
- package/build/src/customize/customizeAsync.js.map +1 -1
- package/build/src/export/createBundles.js +8 -3
- package/build/src/export/createBundles.js.map +1 -1
- package/build/src/export/embed/exportEmbedAsync.js +23 -0
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -0
- package/build/src/export/embed/index.js +117 -0
- package/build/src/export/embed/index.js.map +1 -0
- package/build/src/export/embed/resolveOptions.js +63 -0
- package/build/src/export/embed/resolveOptions.js.map +1 -0
- package/build/src/export/exportApp.js +58 -31
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +17 -0
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportAsync.js +3 -0
- package/build/src/export/exportAsync.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +179 -0
- package/build/src/export/exportStaticAsync.js.map +1 -0
- package/build/src/export/fork-bundleAsync.js +15 -43
- package/build/src/export/fork-bundleAsync.js.map +1 -1
- package/build/src/export/html.js +21 -0
- package/build/src/export/html.js.map +1 -0
- package/build/src/export/index.js +5 -1
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/printBundleSizes.js +2 -2
- package/build/src/export/printBundleSizes.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/web/exportWebAsync.js +3 -0
- package/build/src/export/web/exportWebAsync.js.map +1 -1
- package/build/src/export/writeContents.js +5 -2
- package/build/src/export/writeContents.js.map +1 -1
- package/build/src/graphql/generated.js +462 -0
- package/build/src/graphql/generated.js.map +1 -0
- package/build/src/install/checkPackages.js +6 -0
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/install/installAsync.js +18 -1
- package/build/src/install/installAsync.js.map +1 -1
- package/build/src/prebuild/clearNativeFolder.js +6 -1
- package/build/src/prebuild/clearNativeFolder.js.map +1 -1
- package/build/src/prebuild/copyTemplateFiles.js +3 -33
- package/build/src/prebuild/copyTemplateFiles.js.map +1 -1
- package/build/src/prebuild/ensureConfigAsync.js +1 -12
- package/build/src/prebuild/ensureConfigAsync.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +7 -2
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveOptions.js +7 -8
- package/build/src/prebuild/resolveOptions.js.map +1 -1
- package/build/src/prebuild/resolveTemplate.js +5 -0
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +6 -8
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +33 -47
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/prebuild/validateTemplatePlatforms.js +48 -0
- package/build/src/prebuild/validateTemplatePlatforms.js.map +1 -0
- package/build/src/run/android/runAndroidAsync.js +4 -0
- package/build/src/run/android/runAndroidAsync.js.map +1 -1
- package/build/src/run/ios/appleDevice/AppleDevice.js +25 -19
- package/build/src/run/ios/appleDevice/AppleDevice.js.map +1 -1
- package/build/src/run/ios/appleDevice/client/InstallationProxyClient.js.map +1 -1
- package/build/src/run/ios/options/resolveNativeScheme.js +13 -4
- package/build/src/run/ios/options/resolveNativeScheme.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/run/startBundler.js +4 -0
- package/build/src/run/startBundler.js.map +1 -1
- package/build/src/start/doctor/Prerequisite.js.map +1 -1
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js +12 -6
- package/build/src/start/doctor/dependencies/ensureDependenciesAsync.js.map +1 -1
- package/build/src/start/doctor/dependencies/getVersionedPackages.js +13 -2
- package/build/src/start/doctor/dependencies/getVersionedPackages.js.map +1 -1
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js +12 -4
- package/build/src/start/doctor/dependencies/validateDependenciesVersions.js.map +1 -1
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js +31 -5
- package/build/src/start/doctor/typescript/TypeScriptProjectPrerequisite.js.map +1 -1
- package/build/src/start/doctor/typescript/updateTSConfig.js +6 -0
- package/build/src/start/doctor/typescript/updateTSConfig.js.map +1 -1
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js +1 -0
- package/build/src/start/doctor/web/WebSupportProjectPrerequisite.js.map +1 -1
- package/build/src/start/index.js +3 -1
- package/build/src/start/index.js.map +1 -1
- package/build/src/start/platforms/android/adb.js +1 -1
- package/build/src/start/platforms/android/adb.js.map +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js +1 -1
- package/build/src/start/platforms/ios/AppleDeviceManager.js.map +1 -1
- package/build/src/start/server/BundlerDevServer.js +16 -2
- package/build/src/start/server/BundlerDevServer.js.map +1 -1
- package/build/src/start/server/DevServerManager.js +33 -2
- package/build/src/start/server/DevServerManager.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +167 -0
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -0
- package/build/src/start/server/metro/MetroBundlerDevServer.js +262 -3
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +2 -34
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/externals.js +72 -0
- package/build/src/start/server/metro/externals.js.map +1 -0
- package/build/src/start/server/metro/getCssModulesFromBundler.js +77 -0
- package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -0
- package/build/src/start/server/metro/inspector-proxy/index.js +2 -2
- package/build/src/start/server/metro/inspector-proxy/index.js.map +1 -1
- package/build/src/start/server/metro/inspector-proxy/proxy.js +1 -3
- package/build/src/start/server/metro/inspector-proxy/proxy.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +47 -48
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +137 -0
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -0
- package/build/src/start/server/metro/metroWatchTypeScriptFiles.js +51 -0
- package/build/src/start/server/metro/metroWatchTypeScriptFiles.js.map +1 -0
- package/build/src/start/server/metro/resolveFromProject.js +26 -3
- package/build/src/start/server/metro/resolveFromProject.js.map +1 -1
- package/build/src/start/server/metro/router.js +15 -2
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +107 -0
- package/build/src/start/server/metro/runServer-fork.js.map +1 -0
- package/build/src/start/server/metro/symbolicate.js +6 -0
- package/build/src/start/server/metro/symbolicate.js.map +1 -0
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js +70 -0
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js +188 -45
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js +8 -1
- package/build/src/start/server/middleware/ClassicManifestMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/CreateFileMiddleware.js +6 -3
- package/build/src/start/server/middleware/CreateFileMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js +113 -47
- package/build/src/start/server/middleware/ExpoGoManifestHandlerMiddleware.js.map +1 -1
- package/build/src/start/server/middleware/ManifestMiddleware.js +59 -20
- package/build/src/start/server/middleware/ManifestMiddleware.js.map +1 -1
- package/build/src/start/server/type-generation/expo-env.js +27 -0
- package/build/src/start/server/type-generation/expo-env.js.map +1 -0
- package/build/src/start/server/type-generation/index.js +57 -0
- package/build/src/start/server/type-generation/index.js.map +1 -0
- package/build/src/start/server/type-generation/routes.js +291 -0
- package/build/src/start/server/type-generation/routes.js.map +1 -0
- package/build/src/start/server/type-generation/tsconfig.js +89 -0
- package/build/src/start/server/type-generation/tsconfig.js.map +1 -0
- package/build/src/start/server/webTemplate.js +20 -4
- package/build/src/start/server/webTemplate.js.map +1 -1
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js +4 -6
- package/build/src/start/server/webpack/WebpackBundlerDevServer.js.map +1 -1
- package/build/src/start/startAsync.js +30 -8
- package/build/src/start/startAsync.js.map +1 -1
- package/build/src/utils/FileNotifier.js +11 -4
- package/build/src/utils/FileNotifier.js.map +1 -1
- package/build/src/utils/analytics/getMetroProperties.js +1 -1
- package/build/src/utils/analytics/getMetroProperties.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/codesigning.js +31 -7
- package/build/src/utils/codesigning.js.map +1 -1
- package/build/src/utils/dir.js +16 -6
- 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/mergeGitIgnorePaths.js +42 -0
- package/build/src/utils/mergeGitIgnorePaths.js.map +1 -1
- package/build/src/utils/nodeEnv.js +11 -0
- package/build/src/utils/nodeEnv.js.map +1 -0
- package/build/src/utils/resolveArgs.js +43 -0
- package/build/src/utils/resolveArgs.js.map +1 -1
- package/build/src/utils/strings.js +24 -0
- package/build/src/utils/strings.js.map +1 -0
- package/build/src/utils/template.js +21 -0
- package/build/src/utils/template.js.map +1 -0
- package/build/src/utils/tsconfig/evaluateTsConfig.js +61 -0
- package/build/src/utils/tsconfig/evaluateTsConfig.js.map +1 -0
- package/build/src/utils/tsconfig/loadTsConfigPaths.js +69 -0
- package/build/src/utils/tsconfig/loadTsConfigPaths.js.map +1 -0
- package/build/src/utils/tsconfig/matchTsConfigPathAlias.js +88 -0
- package/build/src/utils/tsconfig/matchTsConfigPathAlias.js.map +1 -0
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js +41 -0
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -0
- package/package.json +16 -10
- package/static/template/metro.config.js +4 -1
- package/build/src/api/getProject.js +0 -19
- package/build/src/api/getProject.js.map +0 -1
- package/build/src/api/graphql/generated.js +0 -113
- package/build/src/api/graphql/generated.js.map +0 -1
- package/build/src/prebuild/writeMetroConfig.js +0 -89
- package/build/src/prebuild/writeMetroConfig.js.map +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.logMetroErrorWithStack = logMetroErrorWithStack;
|
|
6
|
+
exports.logMetroError = logMetroError;
|
|
7
|
+
exports.logFromError = logFromError;
|
|
8
|
+
exports.logMetroErrorAsync = logMetroErrorAsync;
|
|
9
|
+
exports.getErrorOverlayHtmlAsync = getErrorOverlayHtmlAsync;
|
|
10
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
|
+
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
12
|
+
var _terminalLink = _interopRequireDefault(require("terminal-link"));
|
|
13
|
+
var _log = require("../../../log");
|
|
14
|
+
var _getStaticRenderFunctions = require("../getStaticRenderFunctions");
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async function logMetroErrorWithStack(projectRoot, { stack , codeFrame , error }) {
|
|
21
|
+
const { getStackFormattedLocation } = require((0, _resolveFrom).default(projectRoot, "@expo/metro-runtime/symbolicate"));
|
|
22
|
+
_log.Log.log();
|
|
23
|
+
_log.Log.log(_chalk.default.red("Metro error: ") + error.message);
|
|
24
|
+
_log.Log.log();
|
|
25
|
+
if (codeFrame) {
|
|
26
|
+
_log.Log.log(codeFrame.content);
|
|
27
|
+
}
|
|
28
|
+
if (stack == null ? void 0 : stack.length) {
|
|
29
|
+
_log.Log.log();
|
|
30
|
+
_log.Log.log(_chalk.default.bold`Call Stack`);
|
|
31
|
+
const stackProps = stack.map((frame)=>{
|
|
32
|
+
return {
|
|
33
|
+
title: frame.methodName,
|
|
34
|
+
subtitle: getStackFormattedLocation(projectRoot, frame),
|
|
35
|
+
collapse: frame.collapse
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
stackProps.forEach((frame)=>{
|
|
39
|
+
const position = _terminalLink.default.isSupported ? (0, _terminalLink).default(frame.subtitle, frame.subtitle) : frame.subtitle;
|
|
40
|
+
let lineItem = _chalk.default.gray(` ${frame.title} (${position})`);
|
|
41
|
+
if (frame.collapse) {
|
|
42
|
+
lineItem = _chalk.default.dim(lineItem);
|
|
43
|
+
}
|
|
44
|
+
_log.Log.log(lineItem);
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
_log.Log.log(_chalk.default.gray(` ${error.stack}`));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function logMetroError(projectRoot, { error }) {
|
|
51
|
+
var ref, ref1;
|
|
52
|
+
const { LogBoxLog , parseErrorStack } = require((0, _resolveFrom).default(projectRoot, "@expo/metro-runtime/symbolicate"));
|
|
53
|
+
const stack = parseErrorStack(error.stack);
|
|
54
|
+
const log = new LogBoxLog({
|
|
55
|
+
level: "static",
|
|
56
|
+
message: {
|
|
57
|
+
content: error.message,
|
|
58
|
+
substitutions: []
|
|
59
|
+
},
|
|
60
|
+
isComponentError: false,
|
|
61
|
+
stack,
|
|
62
|
+
category: "static",
|
|
63
|
+
componentStack: []
|
|
64
|
+
});
|
|
65
|
+
await new Promise((res)=>log.symbolicate("stack", res)
|
|
66
|
+
);
|
|
67
|
+
var ref2;
|
|
68
|
+
logMetroErrorWithStack(projectRoot, {
|
|
69
|
+
stack: (ref2 = (ref = log.symbolicated) == null ? void 0 : (ref1 = ref.stack) == null ? void 0 : ref1.stack) != null ? ref2 : [],
|
|
70
|
+
codeFrame: log.codeFrame,
|
|
71
|
+
error
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function logFromError({ error , projectRoot }) {
|
|
75
|
+
const { LogBoxLog , parseErrorStack } = require((0, _resolveFrom).default(projectRoot, "@expo/metro-runtime/symbolicate"));
|
|
76
|
+
const stack = parseErrorStack(error.stack);
|
|
77
|
+
return new LogBoxLog({
|
|
78
|
+
level: "static",
|
|
79
|
+
message: {
|
|
80
|
+
content: error.message,
|
|
81
|
+
substitutions: []
|
|
82
|
+
},
|
|
83
|
+
isComponentError: false,
|
|
84
|
+
stack,
|
|
85
|
+
category: "static",
|
|
86
|
+
componentStack: []
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async function logMetroErrorAsync({ error , projectRoot }) {
|
|
90
|
+
var ref, ref3;
|
|
91
|
+
const log = logFromError({
|
|
92
|
+
projectRoot,
|
|
93
|
+
error
|
|
94
|
+
});
|
|
95
|
+
await new Promise((res)=>log.symbolicate("stack", res)
|
|
96
|
+
);
|
|
97
|
+
var ref4;
|
|
98
|
+
logMetroErrorWithStack(projectRoot, {
|
|
99
|
+
stack: (ref4 = (ref = log.symbolicated) == null ? void 0 : (ref3 = ref.stack) == null ? void 0 : ref3.stack) != null ? ref4 : [],
|
|
100
|
+
codeFrame: log.codeFrame,
|
|
101
|
+
error
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async function getErrorOverlayHtmlAsync({ error , projectRoot }) {
|
|
105
|
+
var ref, ref5;
|
|
106
|
+
const log = logFromError({
|
|
107
|
+
projectRoot,
|
|
108
|
+
error
|
|
109
|
+
});
|
|
110
|
+
await new Promise((res)=>log.symbolicate("stack", res)
|
|
111
|
+
);
|
|
112
|
+
var ref6;
|
|
113
|
+
logMetroErrorWithStack(projectRoot, {
|
|
114
|
+
stack: (ref6 = (ref = log.symbolicated) == null ? void 0 : (ref5 = ref.stack) == null ? void 0 : ref5.stack) != null ? ref6 : [],
|
|
115
|
+
codeFrame: log.codeFrame,
|
|
116
|
+
error
|
|
117
|
+
});
|
|
118
|
+
const logBoxContext = {
|
|
119
|
+
selectedLogIndex: 0,
|
|
120
|
+
isDisabled: false,
|
|
121
|
+
logs: [
|
|
122
|
+
log
|
|
123
|
+
]
|
|
124
|
+
};
|
|
125
|
+
const html = `<html><head><style>#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}</style></head><body><div id="root"></div><script id="_expo-static-error" type="application/json">${JSON.stringify(logBoxContext)}</script></body></html>`;
|
|
126
|
+
const errorOverlayEntry = await (0, _getStaticRenderFunctions).createMetroEndpointAsync(projectRoot, // Keep the URL relative
|
|
127
|
+
"", (0, _resolveFrom).default(projectRoot, "expo-router/_error"), {
|
|
128
|
+
dev: true,
|
|
129
|
+
platform: "web",
|
|
130
|
+
minify: false,
|
|
131
|
+
environment: "node"
|
|
132
|
+
});
|
|
133
|
+
const htmlWithJs = html.replace("</body>", `<script src=${errorOverlayEntry}></script></body>`);
|
|
134
|
+
return htmlWithJs;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=metroErrorInterface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/metroErrorInterface.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport chalk from 'chalk';\nimport resolveFrom from 'resolve-from';\nimport { StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { Log } from '../../../log';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n// import type { CodeFrame, MetroStackFrame } from '@expo/metro-runtime/symbolicate';\n\ntype CodeFrame = {\n content: string;\n location?: {\n row: number;\n column: number;\n [key: string]: any;\n };\n fileName: string;\n};\n\ntype MetroStackFrame = StackFrame & { collapse?: boolean };\n\nexport async function logMetroErrorWithStack(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n }: {\n stack: MetroStackFrame[];\n codeFrame: CodeFrame;\n error: Error;\n }\n) {\n const { getStackFormattedLocation } = require(resolveFrom(\n projectRoot,\n '@expo/metro-runtime/symbolicate'\n ));\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (codeFrame) {\n Log.log(codeFrame.content);\n }\n\n if (stack?.length) {\n Log.log();\n Log.log(chalk.bold`Call Stack`);\n\n const stackProps = stack.map((frame) => {\n return {\n title: frame.methodName,\n subtitle: getStackFormattedLocation(projectRoot, frame),\n collapse: frame.collapse,\n };\n });\n\n stackProps.forEach((frame) => {\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n Log.log(lineItem);\n });\n } else {\n Log.log(chalk.gray(` ${error.stack}`));\n }\n}\n\nexport async function logMetroError(projectRoot: string, { error }: { error: Error }) {\n const { LogBoxLog, parseErrorStack } = require(resolveFrom(\n projectRoot,\n '@expo/metro-runtime/symbolicate'\n ));\n\n const stack = parseErrorStack(error.stack);\n\n const log = new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n\n await new Promise((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport function logFromError({ error, projectRoot }: { error: Error; projectRoot: string }): {\n symbolicated: any;\n symbolicate: (type: string, callback: () => void) => void;\n codeFrame: CodeFrame;\n} {\n const { LogBoxLog, parseErrorStack } = require(resolveFrom(\n projectRoot,\n '@expo/metro-runtime/symbolicate'\n ));\n\n const stack = parseErrorStack(error.stack);\n\n return new LogBoxLog({\n level: 'static',\n message: {\n content: error.message,\n substitutions: [],\n },\n isComponentError: false,\n stack,\n category: 'static',\n componentStack: [],\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function logMetroErrorAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nexport async function getErrorOverlayHtmlAsync({\n error,\n projectRoot,\n}: {\n error: Error;\n projectRoot: string;\n}) {\n const log = logFromError({ projectRoot, error });\n\n await new Promise<void>((res) => log.symbolicate('stack', res));\n\n logMetroErrorWithStack(projectRoot, {\n stack: log.symbolicated?.stack?.stack ?? [],\n codeFrame: log.codeFrame,\n error,\n });\n\n const logBoxContext = {\n selectedLogIndex: 0,\n isDisabled: false,\n logs: [log],\n };\n const html = `<html><head><style>#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}</style></head><body><div id=\"root\"></div><script id=\"_expo-static-error\" type=\"application/json\">${JSON.stringify(\n logBoxContext\n )}</script></body></html>`;\n\n const errorOverlayEntry = await createMetroEndpointAsync(\n projectRoot,\n // Keep the URL relative\n '',\n resolveFrom(projectRoot, 'expo-router/_error'),\n {\n dev: true,\n platform: 'web',\n minify: false,\n environment: 'node',\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n"],"names":["logMetroErrorWithStack","logMetroError","logFromError","logMetroErrorAsync","getErrorOverlayHtmlAsync","projectRoot","stack","codeFrame","error","getStackFormattedLocation","require","resolveFrom","Log","log","chalk","red","message","content","length","bold","stackProps","map","frame","title","methodName","subtitle","collapse","forEach","position","terminalLink","isSupported","lineItem","gray","dim","LogBoxLog","parseErrorStack","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","logBoxContext","selectedLogIndex","isDisabled","logs","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","dev","platform","minify","environment","htmlWithJs","replace"],"mappings":"AAMA;;;;QAqBsBA,sBAAsB,GAAtBA,sBAAsB;QAoDtBC,aAAa,GAAbA,aAAa;QA8BnBC,YAAY,GAAZA,YAAY;QA0BNC,kBAAkB,GAAlBA,kBAAkB;QAmBlBC,wBAAwB,GAAxBA,wBAAwB;AApJ5B,IAAA,MAAO,kCAAP,OAAO,EAAA;AACD,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEb,IAAA,aAAe,kCAAf,eAAe,EAAA;AAEpB,IAAA,IAAc,WAAd,cAAc,CAAA;AACO,IAAA,yBAA6B,WAA7B,6BAA6B,CAAA;;;;;;AAe/D,eAAeJ,sBAAsB,CAC1CK,WAAmB,EACnB,EACEC,KAAK,CAAA,EACLC,SAAS,CAAA,EACTC,KAAK,CAAA,EAKN,EACD;IACA,MAAM,EAAEC,yBAAyB,CAAA,EAAE,GAAGC,OAAO,CAACC,CAAAA,GAAAA,YAAW,AAGxD,CAAA,QAHwD,CACvDN,WAAW,EACX,iCAAiC,CAClC,CAAC,AAAC;IAEHO,IAAG,IAAA,CAACC,GAAG,EAAE,CAAC;IACVD,IAAG,IAAA,CAACC,GAAG,CAACC,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C,WAAW,EAAE,MAAM;KACpB,CACF,AAAC;IAEF,MAAMC,UAAU,GAAGT,IAAI,CAACU,OAAO,CAAC,SAAS,EAAE,CAAC,YAAY,EAAEP,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,AAAC;IAChG,OAAOM,UAAU,CAAC;CACnB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.metroWatchTypeScriptFiles = metroWatchTypeScriptFiles;
|
|
6
|
+
var _path = _interopRequireDefault(require("path"));
|
|
7
|
+
function _interopRequireDefault(obj) {
|
|
8
|
+
return obj && obj.__esModule ? obj : {
|
|
9
|
+
default: obj
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const debug = require("debug")("expo:start:server:metro:waitForTypescript");
|
|
13
|
+
function metroWatchTypeScriptFiles({ metro , server , projectRoot , callback , tsconfig =false , throttle =false , eventTypes =[
|
|
14
|
+
"add",
|
|
15
|
+
"change",
|
|
16
|
+
"delete"
|
|
17
|
+
] }) {
|
|
18
|
+
const watcher = metro.getBundler().getBundler().getWatcher();
|
|
19
|
+
const tsconfigPath = _path.default.join(projectRoot, "tsconfig.json");
|
|
20
|
+
const listener = ({ eventsQueue })=>{
|
|
21
|
+
for (const event of eventsQueue){
|
|
22
|
+
var ref;
|
|
23
|
+
if (eventTypes.includes(event.type) && ((ref = event.metadata) == null ? void 0 : ref.type) !== "d" && // We need to ignore node_modules because Metro will add all of the files in node_modules to the watcher.
|
|
24
|
+
!/node_modules/.test(event.filePath) && // Ignore declaration files
|
|
25
|
+
!/\.d\.ts$/.test(event.filePath)) {
|
|
26
|
+
const { filePath } = event;
|
|
27
|
+
// Is TypeScript?
|
|
28
|
+
if (// If the user adds a TypeScript file to the observable files in their project.
|
|
29
|
+
/\.tsx?$/.test(filePath) || // Or if the user adds a tsconfig.json file to the project root.
|
|
30
|
+
(tsconfig && filePath === tsconfigPath)) {
|
|
31
|
+
debug("Detected TypeScript file changed in the project: ", filePath);
|
|
32
|
+
callback(event);
|
|
33
|
+
if (throttle) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
debug("Waiting for TypeScript files to be added to the project...");
|
|
41
|
+
watcher.addListener("change", listener);
|
|
42
|
+
watcher.addListener("add", listener);
|
|
43
|
+
const off = ()=>{
|
|
44
|
+
watcher.removeListener("change", listener);
|
|
45
|
+
watcher.removeListener("add", listener);
|
|
46
|
+
};
|
|
47
|
+
server.addListener == null ? void 0 : server.addListener("close", off);
|
|
48
|
+
return off;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=metroWatchTypeScriptFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/metroWatchTypeScriptFiles.ts"],"sourcesContent":["import path from 'path';\n\nimport type { ServerLike } from '../BundlerDevServer';\n\nconst debug = require('debug')('expo:start:server:metro:waitForTypescript') as typeof console.log;\n\nexport interface MetroWatchTypeScriptFilesOptions {\n projectRoot: string;\n metro: import('metro').Server;\n server: ServerLike;\n /* Include tsconfig.json in the watcher */\n tsconfig?: boolean;\n callback: (event: WatchEvent) => void;\n /* Array of eventTypes to watch. Defaults to all events */\n eventTypes?: string[];\n /* Throlle the callback. When true and a group of events are recieved, callback it will only be called with the\n * first event */\n throttle?: boolean;\n}\n\ninterface WatchEvent {\n filePath: string;\n metadata?: {\n type: 'f' | 'd' | 'l'; // Regular file / Directory / Symlink\n } | null;\n type: string;\n}\n\n/**\n * Use the native file watcher / Metro ruleset to detect if a\n * TypeScript file is added to the project during development.\n */\nexport function metroWatchTypeScriptFiles({\n metro,\n server,\n projectRoot,\n callback,\n tsconfig = false,\n throttle = false,\n eventTypes = ['add', 'change', 'delete'],\n}: MetroWatchTypeScriptFilesOptions): () => void {\n const watcher = metro.getBundler().getBundler().getWatcher();\n\n const tsconfigPath = path.join(projectRoot, 'tsconfig.json');\n\n const listener = ({ eventsQueue }: { eventsQueue: WatchEvent[] }) => {\n for (const event of eventsQueue) {\n if (\n eventTypes.includes(event.type) &&\n event.metadata?.type !== 'd' &&\n // We need to ignore node_modules because Metro will add all of the files in node_modules to the watcher.\n !/node_modules/.test(event.filePath) &&\n // Ignore declaration files\n !/\\.d\\.ts$/.test(event.filePath)\n ) {\n const { filePath } = event;\n // Is TypeScript?\n if (\n // If the user adds a TypeScript file to the observable files in their project.\n /\\.tsx?$/.test(filePath) ||\n // Or if the user adds a tsconfig.json file to the project root.\n (tsconfig && filePath === tsconfigPath)\n ) {\n debug('Detected TypeScript file changed in the project: ', filePath);\n callback(event);\n\n if (throttle) {\n return;\n }\n }\n }\n }\n };\n\n debug('Waiting for TypeScript files to be added to the project...');\n watcher.addListener('change', listener);\n watcher.addListener('add', listener);\n\n const off = () => {\n watcher.removeListener('change', listener);\n watcher.removeListener('add', listener);\n };\n\n server.addListener?.('close', off);\n return off;\n}\n"],"names":["metroWatchTypeScriptFiles","debug","require","metro","server","projectRoot","callback","tsconfig","throttle","eventTypes","watcher","getBundler","getWatcher","tsconfigPath","path","join","listener","eventsQueue","event","includes","type","metadata","test","filePath","addListener","off","removeListener"],"mappings":"AAAA;;;;QAgCgBA,yBAAyB,GAAzBA,yBAAyB;AAhCxB,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAIvB,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,2CAA2C,CAAC,AAAsB,AAAC;AA4B3F,SAASF,yBAAyB,CAAC,EACxCG,KAAK,CAAA,EACLC,MAAM,CAAA,EACNC,WAAW,CAAA,EACXC,QAAQ,CAAA,EACRC,QAAQ,EAAG,KAAK,CAAA,EAChBC,QAAQ,EAAG,KAAK,CAAA,EAChBC,UAAU,EAAG;IAAC,KAAK;IAAE,QAAQ;IAAE,QAAQ;CAAC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AAG,GAAG,IAAM;QAChBf,OAAO,CAACgB,cAAc,CAAC,QAAQ,EAAEV,QAAQ,CAAC,CAAC;QAC3CN,OAAO,CAACgB,cAAc,CAAC,KAAK,EAAEV,QAAQ,CAAC,CAAC;KACzC,AAAC;IAEFZ,MAAM,CAACoB,WAAW,QAAgB,GAAlCpB,KAAAA,CAAkC,GAAlCA,MAAM,CAACoB,WAAW,CAAG,OAAO,EAAEC,GAAG,CAAC,AAnFpC,CAmFqC;IACnC,OAAOA,GAAG,CAAC;CACZ"}
|
|
@@ -3,11 +3,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
exports.importMetroFromProject = importMetroFromProject;
|
|
6
|
-
exports.
|
|
6
|
+
exports.importMetroCreateWebsocketServerFromProject = importMetroCreateWebsocketServerFromProject;
|
|
7
|
+
exports.importMetroHmrServerFromProject = importMetroHmrServerFromProject;
|
|
8
|
+
exports.importExpoMetroConfig = importExpoMetroConfig;
|
|
9
|
+
exports.importFromProjectOrFallback = importFromProjectOrFallback;
|
|
7
10
|
exports.importMetroResolverFromProject = importMetroResolverFromProject;
|
|
8
11
|
exports.importMetroInspectorProxyFromProject = importMetroInspectorProxyFromProject;
|
|
9
12
|
exports.importMetroInspectorDeviceFromProject = importMetroInspectorDeviceFromProject;
|
|
10
13
|
exports.importCliSaveAssetsFromProject = importCliSaveAssetsFromProject;
|
|
14
|
+
exports.importCliBuildBundleWithConfigFromProject = importCliBuildBundleWithConfigFromProject;
|
|
11
15
|
exports.resolveMetroVersionFromProject = resolveMetroVersionFromProject;
|
|
12
16
|
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
13
17
|
function _interopRequireDefault(obj) {
|
|
@@ -15,6 +19,7 @@ function _interopRequireDefault(obj) {
|
|
|
15
19
|
default: obj
|
|
16
20
|
};
|
|
17
21
|
}
|
|
22
|
+
const debug = require("debug")("expo:metro:import");
|
|
18
23
|
// These resolvers enable us to test the CLI in older projects.
|
|
19
24
|
// We may be able to get rid of this in the future.
|
|
20
25
|
// TODO: Maybe combine with AsyncResolver?
|
|
@@ -36,8 +41,23 @@ function importFromProject(projectRoot, moduleId) {
|
|
|
36
41
|
function importMetroFromProject(projectRoot) {
|
|
37
42
|
return importFromProject(projectRoot, "metro");
|
|
38
43
|
}
|
|
39
|
-
function
|
|
40
|
-
return importFromProject(projectRoot, "
|
|
44
|
+
function importMetroCreateWebsocketServerFromProject(projectRoot) {
|
|
45
|
+
return importFromProject(projectRoot, "metro/src/lib/createWebsocketServer");
|
|
46
|
+
}
|
|
47
|
+
function importMetroHmrServerFromProject(projectRoot) {
|
|
48
|
+
return importFromProject(projectRoot, "metro/src/HmrServer");
|
|
49
|
+
}
|
|
50
|
+
function importExpoMetroConfig(projectRoot) {
|
|
51
|
+
return importFromProjectOrFallback(projectRoot, "@expo/metro-config");
|
|
52
|
+
}
|
|
53
|
+
function importFromProjectOrFallback(projectRoot, moduleId) {
|
|
54
|
+
const resolvedPath = _resolveFrom.default.silent(projectRoot, moduleId);
|
|
55
|
+
if (!resolvedPath) {
|
|
56
|
+
debug(`requiring "${moduleId}" relative to the CLI`);
|
|
57
|
+
return require(require.resolve(moduleId));
|
|
58
|
+
}
|
|
59
|
+
debug(`requiring "${moduleId}" from the project:`, resolvedPath);
|
|
60
|
+
return require(resolvedPath);
|
|
41
61
|
}
|
|
42
62
|
function importMetroResolverFromProject(projectRoot) {
|
|
43
63
|
return importFromProject(projectRoot, "metro-resolver");
|
|
@@ -51,6 +71,9 @@ function importMetroInspectorDeviceFromProject(projectRoot) {
|
|
|
51
71
|
function importCliSaveAssetsFromProject(projectRoot) {
|
|
52
72
|
return importFromProject(projectRoot, "@react-native-community/cli-plugin-metro/build/commands/bundle/saveAssets").default;
|
|
53
73
|
}
|
|
74
|
+
function importCliBuildBundleWithConfigFromProject(projectRoot) {
|
|
75
|
+
return importFromProject(projectRoot, "@react-native-community/cli-plugin-metro/build/commands/bundle/buildBundle").buildBundleWithConfig;
|
|
76
|
+
}
|
|
54
77
|
function resolveMetroVersionFromProject(projectRoot) {
|
|
55
78
|
return importFromProject(projectRoot, "metro/package.json").version;
|
|
56
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/resolveFromProject.ts"],"sourcesContent":["import resolveFrom from 'resolve-from';\n\n// These resolvers enable us to test the CLI in older projects.\n// We may be able to get rid of this in the future.\n// TODO: Maybe combine with AsyncResolver?\nclass MetroImportError extends Error {\n constructor(projectRoot: string, moduleId: string) {\n super(\n `Missing package \"${moduleId}\" in the project at: ${projectRoot}\\n` +\n 'This usually means \"react-native\" is not installed. ' +\n 'Please verify that dependencies in package.json include \"react-native\" ' +\n 'and run `yarn` or `npm install`.'\n );\n }\n}\n\nfunction resolveFromProject(projectRoot: string, moduleId: string) {\n const resolvedPath = resolveFrom.silent(projectRoot, moduleId);\n if (!resolvedPath) {\n throw new MetroImportError(projectRoot, moduleId);\n }\n return resolvedPath;\n}\n\nfunction importFromProject(projectRoot: string, moduleId: string) {\n return require(resolveFromProject(projectRoot, moduleId));\n}\n\n/** Import `metro` from the project. */\nexport function importMetroFromProject(projectRoot: string): typeof import('metro') {\n return importFromProject(projectRoot, 'metro');\n}\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/resolveFromProject.ts"],"sourcesContent":["import resolveFrom from 'resolve-from';\n\nconst debug = require('debug')('expo:metro:import');\n\n// These resolvers enable us to test the CLI in older projects.\n// We may be able to get rid of this in the future.\n// TODO: Maybe combine with AsyncResolver?\nclass MetroImportError extends Error {\n constructor(projectRoot: string, moduleId: string) {\n super(\n `Missing package \"${moduleId}\" in the project at: ${projectRoot}\\n` +\n 'This usually means \"react-native\" is not installed. ' +\n 'Please verify that dependencies in package.json include \"react-native\" ' +\n 'and run `yarn` or `npm install`.'\n );\n }\n}\n\nfunction resolveFromProject(projectRoot: string, moduleId: string) {\n const resolvedPath = resolveFrom.silent(projectRoot, moduleId);\n if (!resolvedPath) {\n throw new MetroImportError(projectRoot, moduleId);\n }\n return resolvedPath;\n}\n\nfunction importFromProject(projectRoot: string, moduleId: string) {\n return require(resolveFromProject(projectRoot, moduleId));\n}\n\n/** Import `metro` from the project. */\nexport function importMetroFromProject(projectRoot: string): typeof import('metro') {\n return importFromProject(projectRoot, 'metro');\n}\nexport function importMetroCreateWebsocketServerFromProject(\n projectRoot: string\n): typeof import('metro/src/lib/createWebsocketServer').createWebsocketServer {\n return importFromProject(projectRoot, 'metro/src/lib/createWebsocketServer');\n}\nexport function importMetroHmrServerFromProject(\n projectRoot: string\n): typeof import('metro/src/HmrServer').MetroHmrServer {\n return importFromProject(projectRoot, 'metro/src/HmrServer');\n}\n\nexport function importExpoMetroConfig(projectRoot: string) {\n return importFromProjectOrFallback<typeof import('@expo/metro-config')>(\n projectRoot,\n '@expo/metro-config'\n );\n}\n\n/**\n * Attempt to use the local version of a module or fallback on the CLI version.\n * This should only ever happen when testing Expo CLI in development.\n */\nexport function importFromProjectOrFallback<TModule>(\n projectRoot: string,\n moduleId: string\n): TModule {\n const resolvedPath = resolveFrom.silent(projectRoot, moduleId);\n if (!resolvedPath) {\n debug(`requiring \"${moduleId}\" relative to the CLI`);\n return require(require.resolve(moduleId));\n }\n debug(`requiring \"${moduleId}\" from the project:`, resolvedPath);\n return require(resolvedPath);\n}\n\n/** Import `metro-resolver` from the project. */\nexport function importMetroResolverFromProject(\n projectRoot: string\n): typeof import('metro-resolver') {\n return importFromProject(projectRoot, 'metro-resolver');\n}\n\n/** Import `metro-inspector-proxy` from the project. */\nexport function importMetroInspectorProxyFromProject(\n projectRoot: string\n): typeof import('metro-inspector-proxy') {\n return importFromProject(projectRoot, 'metro-inspector-proxy');\n}\n\n/** Import `metro-inspector-proxy/src/Device` from the project. */\nexport function importMetroInspectorDeviceFromProject(\n projectRoot: string\n): typeof import('metro-inspector-proxy/src/Device') {\n return importFromProject(projectRoot, 'metro-inspector-proxy/src/Device');\n}\n\n/**\n * Import the internal `saveAssets()` function from `react-native` for the purpose\n * of saving production assets as-is instead of converting them to a hash.\n */\nexport function importCliSaveAssetsFromProject(\n projectRoot: string\n): typeof import('@react-native-community/cli-plugin-metro/build/commands/bundle/saveAssets').default {\n return importFromProject(\n projectRoot,\n '@react-native-community/cli-plugin-metro/build/commands/bundle/saveAssets'\n ).default;\n}\n\nexport function importCliBuildBundleWithConfigFromProject(\n projectRoot: string\n): typeof import('@react-native-community/cli-plugin-metro/build/commands/bundle/buildBundle').buildBundleWithConfig {\n return importFromProject(\n projectRoot,\n '@react-native-community/cli-plugin-metro/build/commands/bundle/buildBundle'\n ).buildBundleWithConfig;\n}\n\n/** Resolve the installed Metro version from project */\nexport function resolveMetroVersionFromProject(projectRoot: string): string {\n return importFromProject(projectRoot, 'metro/package.json').version;\n}\n"],"names":["importMetroFromProject","importMetroCreateWebsocketServerFromProject","importMetroHmrServerFromProject","importExpoMetroConfig","importFromProjectOrFallback","importMetroResolverFromProject","importMetroInspectorProxyFromProject","importMetroInspectorDeviceFromProject","importCliSaveAssetsFromProject","importCliBuildBundleWithConfigFromProject","resolveMetroVersionFromProject","debug","require","MetroImportError","Error","constructor","projectRoot","moduleId","resolveFromProject","resolvedPath","resolveFrom","silent","importFromProject","resolve","default","buildBundleWithConfig","version"],"mappings":"AAAA;;;;QA+BgBA,sBAAsB,GAAtBA,sBAAsB;QAGtBC,2CAA2C,GAA3CA,2CAA2C;QAK3CC,+BAA+B,GAA/BA,+BAA+B;QAM/BC,qBAAqB,GAArBA,qBAAqB;QAWrBC,2BAA2B,GAA3BA,2BAA2B;QAc3BC,8BAA8B,GAA9BA,8BAA8B;QAO9BC,oCAAoC,GAApCA,oCAAoC;QAOpCC,qCAAqC,GAArCA,qCAAqC;QAUrCC,8BAA8B,GAA9BA,8BAA8B;QAS9BC,yCAAyC,GAAzCA,yCAAyC;QAUzCC,8BAA8B,GAA9BA,8BAA8B;AAjHtB,IAAA,YAAc,kCAAd,cAAc,EAAA;;;;;;A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outerRelativeEntryPath = getAppRouterRelativeEntryPath;
|
|
6
|
+
exports.getRouterDirectory = getRouterDirectory;
|
|
7
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
6
8
|
var _path = _interopRequireDefault(require("path"));
|
|
7
9
|
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
10
|
+
var _log = require("../../../log");
|
|
11
|
+
var _dir = require("../../../utils/dir");
|
|
8
12
|
function _interopRequireDefault(obj) {
|
|
9
13
|
return obj && obj.__esModule ? obj : {
|
|
10
14
|
default: obj
|
|
11
15
|
};
|
|
12
16
|
}
|
|
13
17
|
const debug = require("debug")("expo:start:server:metro:router");
|
|
14
|
-
function getAppRouterRelativeEntryPath(projectRoot) {
|
|
18
|
+
function getAppRouterRelativeEntryPath(projectRoot, routerDirectory = getRouterDirectory(projectRoot)) {
|
|
15
19
|
var ref;
|
|
16
20
|
// Auto pick App entry
|
|
17
21
|
const routerEntry = (ref = _resolveFrom.default.silent(projectRoot, "expo-router/entry")) != null ? ref : getFallbackEntryRoot(projectRoot);
|
|
@@ -19,7 +23,7 @@ function getAppRouterRelativeEntryPath(projectRoot) {
|
|
|
19
23
|
return undefined;
|
|
20
24
|
}
|
|
21
25
|
// It doesn't matter if the app folder exists.
|
|
22
|
-
const appFolder = _path.default.join(projectRoot,
|
|
26
|
+
const appFolder = _path.default.join(projectRoot, routerDirectory);
|
|
23
27
|
const appRoot = _path.default.relative(_path.default.dirname(routerEntry), appFolder);
|
|
24
28
|
debug("routerEntry", routerEntry, appFolder, appRoot);
|
|
25
29
|
return appRoot;
|
|
@@ -31,5 +35,14 @@ function getAppRouterRelativeEntryPath(projectRoot) {
|
|
|
31
35
|
}
|
|
32
36
|
return _path.default.join(projectRoot, "node_modules/expo-router/entry");
|
|
33
37
|
}
|
|
38
|
+
function getRouterDirectory(projectRoot) {
|
|
39
|
+
// more specific directories first
|
|
40
|
+
if ((0, _dir).directoryExistsSync(_path.default.join(projectRoot, "src/app"))) {
|
|
41
|
+
_log.Log.log(_chalk.default.gray("Using src/app as the root directory for Expo Router."));
|
|
42
|
+
return "src/app";
|
|
43
|
+
}
|
|
44
|
+
_log.Log.debug("Using app as the root directory for Expo Router.");
|
|
45
|
+
return "app";
|
|
46
|
+
}
|
|
34
47
|
|
|
35
48
|
//# sourceMappingURL=router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/router.ts"],"sourcesContent":["import path from 'path';\nimport resolveFrom from 'resolve-from';\n\nconst debug = require('debug')('expo:start:server:metro:router') as typeof console.log;\n\n/**\n * Get the relative path for requiring the `/app` folder relative to the `expo-router/entry` file.\n * This mechanism does require the server to restart after the `expo-router` package is installed.\n */\nexport function getAppRouterRelativeEntryPath(projectRoot: string): string | undefined {\n // Auto pick App entry\n const routerEntry =\n resolveFrom.silent(projectRoot, 'expo-router/entry') ?? getFallbackEntryRoot(projectRoot);\n if (!routerEntry) {\n return undefined;\n }\n // It doesn't matter if the app folder exists.\n const appFolder = path.join(projectRoot,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/router.ts"],"sourcesContent":["import chalk from 'chalk';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { Log } from '../../../log';\nimport { directoryExistsSync } from '../../../utils/dir';\n\nconst debug = require('debug')('expo:start:server:metro:router') as typeof console.log;\n\n/**\n * Get the relative path for requiring the `/app` folder relative to the `expo-router/entry` file.\n * This mechanism does require the server to restart after the `expo-router` package is installed.\n */\nexport function getAppRouterRelativeEntryPath(\n projectRoot: string,\n routerDirectory: string = getRouterDirectory(projectRoot)\n): string | undefined {\n // Auto pick App entry\n const routerEntry =\n resolveFrom.silent(projectRoot, 'expo-router/entry') ?? getFallbackEntryRoot(projectRoot);\n if (!routerEntry) {\n return undefined;\n }\n // It doesn't matter if the app folder exists.\n const appFolder = path.join(projectRoot, routerDirectory);\n const appRoot = path.relative(path.dirname(routerEntry), appFolder);\n debug('routerEntry', routerEntry, appFolder, appRoot);\n return appRoot;\n}\n\n/** If the `expo-router` package is not installed, then use the `expo` package to determine where the node modules are relative to the project. */\nfunction getFallbackEntryRoot(projectRoot: string): string {\n const expoRoot = resolveFrom.silent(projectRoot, 'expo/package.json');\n if (expoRoot) {\n return path.join(path.dirname(path.dirname(expoRoot)), 'expo-router/entry');\n }\n return path.join(projectRoot, 'node_modules/expo-router/entry');\n}\n\nexport function getRouterDirectory(projectRoot: string): string {\n // more specific directories first\n if (directoryExistsSync(path.join(projectRoot, 'src/app'))) {\n Log.log(chalk.gray('Using src/app as the root directory for Expo Router.'));\n return 'src/app';\n }\n\n Log.debug('Using app as the root directory for Expo Router.');\n return 'app';\n}\n"],"names":["getAppRouterRelativeEntryPath","getRouterDirectory","debug","require","projectRoot","routerDirectory","resolveFrom","routerEntry","silent","getFallbackEntryRoot","undefined","appFolder","path","join","appRoot","relative","dirname","expoRoot","directoryExistsSync","Log","log","chalk","gray"],"mappings":"AAAA;;;;QAagBA,6BAA6B,GAA7BA,6BAA6B;QA0B7BC,kBAAkB,GAAlBA,kBAAkB;AAvChB,IAAA,MAAO,kCAAP,OAAO,EAAA;AACR,IAAA,KAAM,kCAAN,MAAM,EAAA;AACC,IAAA,YAAc,kCAAd,cAAc,EAAA;AAElB,IAAA,IAAc,WAAd,cAAc,CAAA;AACE,IAAA,IAAoB,WAApB,oBAAoB,CAAA;;;;;;AAExD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,gCAAgC,CAAC,AAAsB,AAAC;AAMhF,SAASH,6BAA6B,CAC3CI,WAAmB,EACnBC,eAAuB,GAAGJ,kBAAkB,CAACG,WAAW,CAAC,EACrC;QAGlBE,GAAoD;IAFtD,sBAAsB;IACtB,MAAMC,WAAW,GACfD,CAAAA,GAAoD,GAApDA,YAAW,QAAA,CAACE,MAAM,CAACJ,WAAW,EAAE,mBAAmB,CAAC,YAApDE,GAAoD,GAAIG,oBAAoB,CAACL,WAAW,CAAC,AAAC;IAC5F,IAA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
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.runServer = void 0;
|
|
6
|
+
var _http = _interopRequireDefault(require("http"));
|
|
7
|
+
var _https = _interopRequireDefault(require("https"));
|
|
8
|
+
var _url = require("url");
|
|
9
|
+
var _env = require("../../../utils/env");
|
|
10
|
+
var _inspectorProxy = require("./inspector-proxy");
|
|
11
|
+
var _resolveFromProject = require("./resolveFromProject");
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const runServer = async (metroBundler, config, { hasReducedPerformance =false , host , onError , onReady , secureServerOptions , waitForBundler =false , websocketEndpoints ={} , watch })=>{
|
|
18
|
+
const projectRoot = metroBundler.projectRoot;
|
|
19
|
+
const Metro = (0, _resolveFromProject).importMetroFromProject(projectRoot);
|
|
20
|
+
const createWebsocketServer = (0, _resolveFromProject).importMetroCreateWebsocketServerFromProject(projectRoot);
|
|
21
|
+
const { InspectorProxy } = (0, _resolveFromProject).importMetroInspectorProxyFromProject(projectRoot);
|
|
22
|
+
const MetroHmrServer = (0, _resolveFromProject).importMetroHmrServerFromProject(projectRoot);
|
|
23
|
+
// await earlyPortCheck(host, config.server.port);
|
|
24
|
+
// if (secure != null || secureCert != null || secureKey != null) {
|
|
25
|
+
// // eslint-disable-next-line no-console
|
|
26
|
+
// console.warn(
|
|
27
|
+
// chalk.inverse.yellow.bold(' DEPRECATED '),
|
|
28
|
+
// 'The `secure`, `secureCert`, and `secureKey` options are now deprecated. ' +
|
|
29
|
+
// 'Please use the `secureServerOptions` object instead to pass options to ' +
|
|
30
|
+
// "Metro's https development server.",
|
|
31
|
+
// );
|
|
32
|
+
// }
|
|
33
|
+
// Lazy require
|
|
34
|
+
const connect = require("connect");
|
|
35
|
+
const serverApp = connect();
|
|
36
|
+
const { middleware , end , metroServer } = await Metro.createConnectMiddleware(config, {
|
|
37
|
+
hasReducedPerformance,
|
|
38
|
+
waitForBundler,
|
|
39
|
+
watch
|
|
40
|
+
});
|
|
41
|
+
serverApp.use(middleware);
|
|
42
|
+
let inspectorProxy = null;
|
|
43
|
+
if (config.server.runInspectorProxy && _env.env.EXPO_USE_CUSTOM_INSPECTOR_PROXY) {
|
|
44
|
+
inspectorProxy = (0, _inspectorProxy).createInspectorProxy(metroBundler, config.projectRoot);
|
|
45
|
+
} else if (config.server.runInspectorProxy) {
|
|
46
|
+
inspectorProxy = new InspectorProxy(config.projectRoot);
|
|
47
|
+
}
|
|
48
|
+
let httpServer;
|
|
49
|
+
if (secureServerOptions != null) {
|
|
50
|
+
httpServer = _https.default.createServer(secureServerOptions, serverApp);
|
|
51
|
+
} else {
|
|
52
|
+
httpServer = _http.default.createServer(serverApp);
|
|
53
|
+
}
|
|
54
|
+
return new Promise((resolve, reject)=>{
|
|
55
|
+
httpServer.on("error", (error)=>{
|
|
56
|
+
if (onError) {
|
|
57
|
+
onError(error);
|
|
58
|
+
}
|
|
59
|
+
reject(error);
|
|
60
|
+
end();
|
|
61
|
+
});
|
|
62
|
+
httpServer.listen(config.server.port, host, ()=>{
|
|
63
|
+
if (onReady) {
|
|
64
|
+
onReady(httpServer);
|
|
65
|
+
}
|
|
66
|
+
Object.assign(websocketEndpoints, {
|
|
67
|
+
...inspectorProxy ? {
|
|
68
|
+
...inspectorProxy.createWebSocketListeners(httpServer)
|
|
69
|
+
} : {},
|
|
70
|
+
"/hot": createWebsocketServer({
|
|
71
|
+
websocketServer: new MetroHmrServer(metroServer.getBundler(), metroServer.getCreateModuleId(), config)
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
httpServer.on("upgrade", (request, socket, head)=>{
|
|
75
|
+
const { pathname } = (0, _url).parse(request.url);
|
|
76
|
+
if (pathname != null && websocketEndpoints[pathname]) {
|
|
77
|
+
websocketEndpoints[pathname].handleUpgrade(request, socket, head, (ws)=>{
|
|
78
|
+
websocketEndpoints[pathname].emit("connection", ws, request);
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
socket.destroy();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
if (inspectorProxy) {
|
|
85
|
+
// TODO(hypuk): Refactor inspectorProxy.processRequest into separate request handlers
|
|
86
|
+
// so that we could provide routes (/json/list and /json/version) here.
|
|
87
|
+
// Currently this causes Metro to give warning about T31407894.
|
|
88
|
+
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
89
|
+
serverApp.use(inspectorProxy.processRequest.bind(inspectorProxy));
|
|
90
|
+
}
|
|
91
|
+
resolve({
|
|
92
|
+
server: httpServer,
|
|
93
|
+
metro: metroServer
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
// Disable any kind of automatic timeout behavior for incoming
|
|
97
|
+
// requests in case it takes the packager more than the default
|
|
98
|
+
// timeout of 120 seconds to respond to a request.
|
|
99
|
+
httpServer.timeout = 0;
|
|
100
|
+
httpServer.on("close", ()=>{
|
|
101
|
+
end();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
exports.runServer = runServer;
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=runServer-fork.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/runServer-fork.ts"],"sourcesContent":["// Copyright © 2023 650 Industries.\n// Copyright (c) Meta Platforms, Inc. and affiliates.\n//\n// Forks https://github.com/facebook/metro/blob/b80d9a0f638ee9fb82ff69cd3c8d9f4309ca1da2/packages/metro/src/index.flow.js#L57\n// and adds the ability to access the bundler instance.\nimport http from 'http';\nimport https from 'https';\nimport { RunServerOptions, Server } from 'metro';\nimport { ConfigT } from 'metro-config';\nimport { InspectorProxy } from 'metro-inspector-proxy';\nimport { parse } from 'url';\n\nimport { env } from '../../../utils/env';\nimport { MetroBundlerDevServer } from './MetroBundlerDevServer';\nimport { createInspectorProxy, ExpoInspectorProxy } from './inspector-proxy';\nimport {\n importMetroCreateWebsocketServerFromProject,\n importMetroFromProject,\n importMetroHmrServerFromProject,\n importMetroInspectorProxyFromProject,\n} from './resolveFromProject';\n\nexport const runServer = async (\n metroBundler: MetroBundlerDevServer,\n config: ConfigT,\n {\n hasReducedPerformance = false,\n host,\n onError,\n onReady,\n secureServerOptions,\n waitForBundler = false,\n websocketEndpoints = {},\n watch,\n }: RunServerOptions\n): Promise<{ server: http.Server | https.Server; metro: Server }> => {\n const projectRoot = metroBundler.projectRoot;\n\n const Metro = importMetroFromProject(projectRoot);\n\n const createWebsocketServer = importMetroCreateWebsocketServerFromProject(projectRoot);\n\n const { InspectorProxy } = importMetroInspectorProxyFromProject(projectRoot);\n\n const MetroHmrServer = importMetroHmrServerFromProject(projectRoot);\n\n // await earlyPortCheck(host, config.server.port);\n\n // if (secure != null || secureCert != null || secureKey != null) {\n // // eslint-disable-next-line no-console\n // console.warn(\n // chalk.inverse.yellow.bold(' DEPRECATED '),\n // 'The `secure`, `secureCert`, and `secureKey` options are now deprecated. ' +\n // 'Please use the `secureServerOptions` object instead to pass options to ' +\n // \"Metro's https development server.\",\n // );\n // }\n // Lazy require\n const connect = require('connect');\n\n const serverApp = connect();\n\n const { middleware, end, metroServer } = await Metro.createConnectMiddleware(config, {\n hasReducedPerformance,\n waitForBundler,\n watch,\n });\n\n serverApp.use(middleware);\n\n let inspectorProxy: InspectorProxy | ExpoInspectorProxy | null = null;\n if (config.server.runInspectorProxy && env.EXPO_USE_CUSTOM_INSPECTOR_PROXY) {\n inspectorProxy = createInspectorProxy(metroBundler, config.projectRoot);\n } else if (config.server.runInspectorProxy) {\n inspectorProxy = new InspectorProxy(config.projectRoot);\n }\n\n let httpServer: http.Server | https.Server;\n\n if (secureServerOptions != null) {\n httpServer = https.createServer(secureServerOptions, serverApp);\n } else {\n httpServer = http.createServer(serverApp);\n }\n return new Promise<{ server: http.Server | https.Server; metro: Server }>((resolve, reject) => {\n httpServer.on('error', (error) => {\n if (onError) {\n onError(error);\n }\n reject(error);\n end();\n });\n\n httpServer.listen(config.server.port, host, () => {\n if (onReady) {\n onReady(httpServer);\n }\n\n Object.assign(websocketEndpoints, {\n ...(inspectorProxy ? { ...inspectorProxy.createWebSocketListeners(httpServer) } : {}),\n '/hot': createWebsocketServer({\n websocketServer: new MetroHmrServer(\n metroServer.getBundler(),\n metroServer.getCreateModuleId(),\n config\n ),\n }),\n });\n\n httpServer.on('upgrade', (request, socket, head) => {\n const { pathname } = parse(request.url!);\n if (pathname != null && websocketEndpoints[pathname]) {\n websocketEndpoints[pathname].handleUpgrade(request, socket, head, (ws) => {\n websocketEndpoints[pathname].emit('connection', ws, request);\n });\n } else {\n socket.destroy();\n }\n });\n\n if (inspectorProxy) {\n // TODO(hypuk): Refactor inspectorProxy.processRequest into separate request handlers\n // so that we could provide routes (/json/list and /json/version) here.\n // Currently this causes Metro to give warning about T31407894.\n // $FlowFixMe[method-unbinding] added when improving typing for this parameters\n serverApp.use(inspectorProxy.processRequest.bind(inspectorProxy));\n }\n\n resolve({ server: httpServer, metro: metroServer });\n });\n\n // Disable any kind of automatic timeout behavior for incoming\n // requests in case it takes the packager more than the default\n // timeout of 120 seconds to respond to a request.\n httpServer.timeout = 0;\n\n httpServer.on('close', () => {\n end();\n });\n });\n};\n"],"names":["runServer","metroBundler","config","hasReducedPerformance","host","onError","onReady","secureServerOptions","waitForBundler","websocketEndpoints","watch","projectRoot","Metro","importMetroFromProject","createWebsocketServer","importMetroCreateWebsocketServerFromProject","InspectorProxy","importMetroInspectorProxyFromProject","MetroHmrServer","importMetroHmrServerFromProject","connect","require","serverApp","middleware","end","metroServer","createConnectMiddleware","use","inspectorProxy","server","runInspectorProxy","env","EXPO_USE_CUSTOM_INSPECTOR_PROXY","createInspectorProxy","httpServer","https","createServer","http","Promise","resolve","reject","on","error","listen","port","Object","assign","createWebSocketListeners","websocketServer","getBundler","getCreateModuleId","request","socket","head","pathname","parse","url","handleUpgrade","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YAEDW,OAAO,CAAC;gBAAEV,MAAM,EAAEK,UAAU;gBAAE6B,KAAK,EAAEtC,WAAW;aAAE,CAAC,CAAC;SACrD,CAAC,CAAC;QAEH,8DAA8D;QAC9D,+DAA+D;QAC/D,kDAAkD;QAClDS,UAAU,CAAC8B,OAAO,GAAG,CAAC,CAAC;QAEvB9B,UAAU,CAACO,EAAE,CAAC,OAAO,EAAE,IAAM;YAC3BjB,GAAG,EAAE,CAAC;SACP,CAAC,CAAC;KACJ,CAAC,CAAC;CACJ,AAAC;QAtHWxB,SAAS,GAATA,SAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/symbolicate.ts"],"sourcesContent":["import { StackFrame } from 'stacktrace-parser';\n\nexport type CodeFrame = {\n content: string;\n location?: {\n row: number;\n column: number;\n [key: string]: any;\n };\n fileName: string;\n};\n\nexport type MetroStackFrame = StackFrame & { collapse?: boolean };\nexport type Stack = StackFrame[];\n"],"names":[],"mappings":"AAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
exports.waitForMetroToObserveTypeScriptFile = waitForMetroToObserveTypeScriptFile;
|
|
6
|
+
exports.observeFileChanges = observeFileChanges;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
function _interopRequireDefault(obj) {
|
|
9
|
+
return obj && obj.__esModule ? obj : {
|
|
10
|
+
default: obj
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const debug = require("debug")("expo:start:server:metro:waitForTypescript");
|
|
14
|
+
function waitForMetroToObserveTypeScriptFile(projectRoot, runner, callback) {
|
|
15
|
+
const watcher = runner.metro.getBundler().getBundler().getWatcher();
|
|
16
|
+
const tsconfigPath = _path.default.join(projectRoot, "tsconfig.json");
|
|
17
|
+
const listener = ({ eventsQueue })=>{
|
|
18
|
+
for (const event of eventsQueue){
|
|
19
|
+
var ref;
|
|
20
|
+
if (event.type === "add" && ((ref = event.metadata) == null ? void 0 : ref.type) !== "d" && // We need to ignore node_modules because Metro will add all of the files in node_modules to the watcher.
|
|
21
|
+
!/node_modules/.test(event.filePath)) {
|
|
22
|
+
const { filePath } = event;
|
|
23
|
+
// Is TypeScript?
|
|
24
|
+
if (// If the user adds a TypeScript file to the observable files in their project.
|
|
25
|
+
/\.tsx?$/.test(filePath) || // Or if the user adds a tsconfig.json file to the project root.
|
|
26
|
+
filePath === tsconfigPath) {
|
|
27
|
+
debug("Detected TypeScript file added to the project: ", filePath);
|
|
28
|
+
callback();
|
|
29
|
+
off();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
debug("Waiting for TypeScript files to be added to the project...");
|
|
36
|
+
watcher.addListener("change", listener);
|
|
37
|
+
const off = ()=>{
|
|
38
|
+
watcher.removeListener("change", listener);
|
|
39
|
+
};
|
|
40
|
+
runner.server.addListener == null ? void 0 : runner.server.addListener("close", off);
|
|
41
|
+
return off;
|
|
42
|
+
}
|
|
43
|
+
function observeFileChanges(runner, files, callback) {
|
|
44
|
+
const watcher = runner.metro.getBundler().getBundler().getWatcher();
|
|
45
|
+
const listener = ({ eventsQueue })=>{
|
|
46
|
+
for (const event of eventsQueue){
|
|
47
|
+
var // event.type === 'add' &&
|
|
48
|
+
ref;
|
|
49
|
+
if (((ref = event.metadata) == null ? void 0 : ref.type) !== "d" && // We need to ignore node_modules because Metro will add all of the files in node_modules to the watcher.
|
|
50
|
+
!/node_modules/.test(event.filePath)) {
|
|
51
|
+
const { filePath } = event;
|
|
52
|
+
// Is TypeScript?
|
|
53
|
+
if (files.includes(filePath)) {
|
|
54
|
+
debug("Observed change:", filePath);
|
|
55
|
+
callback();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
debug("Watching file changes:", files);
|
|
62
|
+
watcher.addListener("change", listener);
|
|
63
|
+
const off = ()=>{
|
|
64
|
+
watcher.removeListener("change", listener);
|
|
65
|
+
};
|
|
66
|
+
runner.server.addListener == null ? void 0 : runner.server.addListener("close", off);
|
|
67
|
+
return off;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=waitForMetroToObserveTypeScriptFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/waitForMetroToObserveTypeScriptFile.ts"],"sourcesContent":["import path from 'path';\n\nimport type { ServerLike } from '../BundlerDevServer';\n\nconst debug = require('debug')('expo:start:server:metro:waitForTypescript') as typeof console.log;\n\n/**\n * Use the native file watcher / Metro ruleset to detect if a\n * TypeScript file is added to the project during development.\n */\nexport function waitForMetroToObserveTypeScriptFile(\n projectRoot: string,\n runner: {\n metro: import('metro').Server;\n server: ServerLike;\n },\n callback: () => Promise<void>\n): () => void {\n const watcher = runner.metro.getBundler().getBundler().getWatcher();\n\n const tsconfigPath = path.join(projectRoot, 'tsconfig.json');\n\n const listener = ({\n eventsQueue,\n }: {\n eventsQueue: {\n filePath: string;\n metadata?: {\n type: 'f' | 'd' | 'l'; // Regular file / Directory / Symlink\n } | null;\n type: string;\n }[];\n }) => {\n for (const event of eventsQueue) {\n if (\n event.type === 'add' &&\n event.metadata?.type !== 'd' &&\n // We need to ignore node_modules because Metro will add all of the files in node_modules to the watcher.\n !/node_modules/.test(event.filePath)\n ) {\n const { filePath } = event;\n // Is TypeScript?\n if (\n // If the user adds a TypeScript file to the observable files in their project.\n /\\.tsx?$/.test(filePath) ||\n // Or if the user adds a tsconfig.json file to the project root.\n filePath === tsconfigPath\n ) {\n debug('Detected TypeScript file added to the project: ', filePath);\n callback();\n off();\n return;\n }\n }\n }\n };\n\n debug('Waiting for TypeScript files to be added to the project...');\n watcher.addListener('change', listener);\n\n const off = () => {\n watcher.removeListener('change', listener);\n };\n\n runner.server.addListener?.('close', off);\n return off;\n}\n\nexport function observeFileChanges(\n runner: {\n metro: import('metro').Server;\n server: ServerLike;\n },\n files: string[],\n callback: () => void | Promise<void>\n): () => void {\n const watcher = runner.metro.getBundler().getBundler().getWatcher();\n\n const listener = ({\n eventsQueue,\n }: {\n eventsQueue: {\n filePath: string;\n metadata?: {\n type: 'f' | 'd' | 'l'; // Regular file / Directory / Symlink\n } | null;\n type: string;\n }[];\n }) => {\n for (const event of eventsQueue) {\n if (\n // event.type === 'add' &&\n event.metadata?.type !== 'd' &&\n // We need to ignore node_modules because Metro will add all of the files in node_modules to the watcher.\n !/node_modules/.test(event.filePath)\n ) {\n const { filePath } = event;\n // Is TypeScript?\n if (files.includes(filePath)) {\n debug('Observed change:', filePath);\n callback();\n return;\n }\n }\n }\n };\n\n debug('Watching file changes:', files);\n watcher.addListener('change', listener);\n\n const off = () => {\n watcher.removeListener('change', listener);\n };\n\n runner.server.addListener?.('close', off);\n return off;\n}\n"],"names":["waitForMetroToObserveTypeScriptFile","observeFileChanges","debug","require","projectRoot","runner","callback","watcher","metro","getBundler","getWatcher","tsconfigPath","path","join","listener","eventsQueue","event","type","metadata","test","filePath","off","addListener","removeListener","server","files","includes"],"mappings":"AAAA;;;;QAUgBA,mCAAmC,GAAnCA,mCAAmC;QA0DnCC,kBAAkB,GAAlBA,kBAAkB;AApEjB,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;AAIvB,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,2CAA2C,CAAC,AAAsB,AAAC;AAM3F,SAASH,mCAAmC,CACjDI,WAAmB,EACnBC,MAGC,EACDC,QAA6B,EACjB;IACZ,MAAMC,OAAO,GAAGF,MAAM,CAACG,KAAK,CAACC,UAAU,EAAE,CAACA,UAAU,EAAE,CAACC,UAAU,EAAE,AAAC;IAEpE,MAAMC,YAAY,GAAGC,KAAI,QAAA,CAACC,IAAI,CAACT,WAAW,EAAE,eAAe,CAAC,AAAC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