@expo/cli 1.0.0-canary-20250722-599a28f → 54.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/bin/cli +1 -1
- package/build/metro-require/require.js +24 -13
- package/build/src/api/getExpoSchema.js +8 -7
- package/build/src/api/getExpoSchema.js.map +1 -1
- package/build/src/expoUpdatesExports.js +28 -0
- package/build/src/expoUpdatesExports.js.map +1 -0
- package/build/src/export/embed/exportEmbedAsync.js +26 -25
- package/build/src/export/embed/exportEmbedAsync.js.map +1 -1
- package/build/src/export/embed/resolveOptions.js +1 -1
- package/build/src/export/embed/resolveOptions.js.map +1 -1
- package/build/src/export/exportApp.js +7 -4
- package/build/src/export/exportApp.js.map +1 -1
- package/build/src/export/exportAssets.js +20 -4
- package/build/src/export/exportAssets.js.map +1 -1
- package/build/src/export/exportAsync.js +2 -2
- package/build/src/export/exportAsync.js.map +1 -1
- package/build/src/export/exportHermes.js +34 -9
- package/build/src/export/exportHermes.js.map +1 -1
- package/build/src/export/exportStaticAsync.js +23 -2
- package/build/src/export/exportStaticAsync.js.map +1 -1
- package/build/src/export/index.js +1 -0
- package/build/src/export/index.js.map +1 -1
- package/build/src/export/metroAssetLocalPath.js.map +1 -1
- package/build/src/export/persistMetroAssets.js.map +1 -1
- package/build/src/export/resolveOptions.js +1 -0
- package/build/src/export/resolveOptions.js.map +1 -1
- package/build/src/export/saveAssets.js +12 -0
- package/build/src/export/saveAssets.js.map +1 -1
- package/build/src/install/checkPackages.js +9 -1
- package/build/src/install/checkPackages.js.map +1 -1
- package/build/src/lint/lintAsync.js +2 -0
- package/build/src/lint/lintAsync.js.map +1 -1
- package/build/src/prebuild/prebuildAsync.js +18 -0
- package/build/src/prebuild/prebuildAsync.js.map +1 -1
- package/build/src/prebuild/resolveLocalTemplate.js +42 -0
- package/build/src/prebuild/resolveLocalTemplate.js.map +1 -0
- package/build/src/prebuild/resolveTemplate.js +17 -7
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/prebuild/updateFromTemplate.js +1 -0
- package/build/src/prebuild/updateFromTemplate.js.map +1 -1
- package/build/src/prebuild/updatePackageJson.js +5 -3
- package/build/src/prebuild/updatePackageJson.js.map +1 -1
- package/build/src/run/android/resolveOptions.js +2 -2
- package/build/src/run/android/resolveOptions.js.map +1 -1
- package/build/src/run/ios/options/resolveOptions.js +2 -2
- package/build/src/run/ios/options/resolveOptions.js.map +1 -1
- package/build/src/run/ios/runIosAsync.js +3 -0
- package/build/src/run/ios/runIosAsync.js.map +1 -1
- package/build/src/serve/serveAsync.js +5 -2
- package/build/src/serve/serveAsync.js.map +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js +1 -1
- package/build/src/start/platforms/ExpoGoInstaller.js.map +1 -1
- package/build/src/start/server/DevToolsPluginManager.js +7 -35
- package/build/src/start/server/DevToolsPluginManager.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +88 -56
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/MetroTerminalReporter.js +66 -25
- package/build/src/start/server/metro/MetroTerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/TerminalReporter.js +6 -6
- package/build/src/start/server/metro/TerminalReporter.js.map +1 -1
- package/build/src/start/server/metro/createExpoAutolinkingResolver.js +121 -0
- package/build/src/start/server/metro/createExpoAutolinkingResolver.js.map +1 -0
- package/build/src/start/server/metro/createExpoFallbackResolver.js +1 -0
- package/build/src/start/server/metro/createExpoFallbackResolver.js.map +1 -1
- package/build/src/start/server/metro/createExpoMetroResolver.js.map +1 -1
- package/build/src/start/server/metro/createJResolver.js.map +1 -1
- package/build/src/start/server/metro/createServerComponentsMiddleware.js +4 -4
- package/build/src/start/server/metro/createServerComponentsMiddleware.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +54 -8
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/debugging/attachAtlas.js +2 -0
- package/build/src/start/server/metro/debugging/attachAtlas.js.map +1 -1
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js +1 -1
- package/build/src/start/server/metro/dev-server/createMetroMiddleware.js.map +1 -1
- package/build/src/start/server/metro/fetchRouterManifest.js +1 -0
- package/build/src/start/server/metro/fetchRouterManifest.js.map +1 -1
- package/build/src/start/server/metro/formatFileCandidates.js.map +1 -1
- package/build/src/start/server/metro/getCssModulesFromBundler.js +10 -9
- package/build/src/start/server/metro/getCssModulesFromBundler.js.map +1 -1
- package/build/src/start/server/metro/instantiateMetro.js +44 -40
- package/build/src/start/server/metro/instantiateMetro.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +79 -12
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/metro/metroVirtualModules.js.map +1 -1
- package/build/src/start/server/metro/metroWatchTypeScriptFiles.js.map +1 -1
- package/build/src/start/server/metro/router.js +75 -0
- package/build/src/start/server/metro/router.js.map +1 -1
- package/build/src/start/server/metro/runServer-fork.js +19 -19
- package/build/src/start/server/metro/runServer-fork.js.map +1 -1
- package/build/src/start/server/metro/serializeHtml.js +45 -5
- package/build/src/start/server/metro/serializeHtml.js.map +1 -1
- package/build/src/start/server/metro/waitForMetroToObserveTypeScriptFile.js.map +1 -1
- package/build/src/start/server/metro/withMetroErrorReportingResolver.js +267 -0
- package/build/src/start/server/metro/withMetroErrorReportingResolver.js.map +1 -0
- package/build/src/start/server/metro/withMetroMultiPlatform.js +58 -82
- package/build/src/start/server/metro/withMetroMultiPlatform.js.map +1 -1
- package/build/src/start/server/metro/withMetroResolvers.js +2 -219
- package/build/src/start/server/metro/withMetroResolvers.js.map +1 -1
- package/build/src/start/server/metro/withMetroSupervisingTransformWorker.js +63 -0
- package/build/src/start/server/metro/withMetroSupervisingTransformWorker.js.map +1 -0
- package/build/src/start/server/middleware/createBuiltinAPIRequestHandler.js +1 -1
- package/build/src/start/server/middleware/createBuiltinAPIRequestHandler.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +7 -2
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/start/server/middleware/resolvePlatform.js +3 -0
- package/build/src/start/server/middleware/resolvePlatform.js.map +1 -1
- package/build/src/start/server/serverLogLikeMetro.js +13 -11
- package/build/src/start/server/serverLogLikeMetro.js.map +1 -1
- package/build/src/start/server/type-generation/routes.js.map +1 -1
- package/build/src/start/server/type-generation/startTypescriptTypeGeneration.js.map +1 -1
- package/build/src/types.d.ts +2 -0
- package/build/src/utils/build-cache-providers/index.js.map +1 -1
- package/build/src/utils/dir.js +7 -0
- package/build/src/utils/dir.js.map +1 -1
- package/build/src/utils/env.js +9 -4
- package/build/src/utils/env.js.map +1 -1
- package/build/src/utils/errors.js +1 -1
- package/build/src/utils/errors.js.map +1 -1
- package/build/src/utils/git.js +2 -2
- package/build/src/utils/git.js.map +1 -1
- package/build/src/utils/telemetry/clients/FetchClient.js +1 -1
- package/build/src/utils/telemetry/utils/context.js +1 -1
- package/build/src/utils/tsconfig/resolveWithTsConfigPaths.js.map +1 -1
- package/internal/unstable-expo-updates-exports.d.ts +31 -0
- package/internal/unstable-expo-updates-exports.js +3 -0
- package/package.json +33 -17
- package/static/template/[...rsc]+api.ts +1 -1
- package/build/src/start/server/metro/createExpoStickyResolver.js +0 -137
- package/build/src/start/server/metro/createExpoStickyResolver.js.map +0 -1
- package/build/src/start/server/metro/metroPrivateServer.js +0 -28
- package/build/src/start/server/metro/metroPrivateServer.js.map +0 -1
- package/build/src/utils/jsonSchemaDeref.js +0 -150
- package/build/src/utils/jsonSchemaDeref.js.map +0 -1
|
@@ -17,12 +17,21 @@ _export(exports, {
|
|
|
17
17
|
IS_METRO_BUNDLE_ERROR_SYMBOL: function() {
|
|
18
18
|
return IS_METRO_BUNDLE_ERROR_SYMBOL;
|
|
19
19
|
},
|
|
20
|
+
attachImportStackToRootMessage: function() {
|
|
21
|
+
return attachImportStackToRootMessage;
|
|
22
|
+
},
|
|
23
|
+
dropStackIfContainsCodeFrame: function() {
|
|
24
|
+
return dropStackIfContainsCodeFrame;
|
|
25
|
+
},
|
|
20
26
|
getErrorOverlayHtmlAsync: function() {
|
|
21
27
|
return getErrorOverlayHtmlAsync;
|
|
22
28
|
},
|
|
23
29
|
getStackAsFormattedLog: function() {
|
|
24
30
|
return getStackAsFormattedLog;
|
|
25
31
|
},
|
|
32
|
+
likelyContainsCodeFrame: function() {
|
|
33
|
+
return likelyContainsCodeFrame;
|
|
34
|
+
},
|
|
26
35
|
logMetroError: function() {
|
|
27
36
|
return logMetroError;
|
|
28
37
|
},
|
|
@@ -31,6 +40,9 @@ _export(exports, {
|
|
|
31
40
|
},
|
|
32
41
|
logMetroErrorWithStack: function() {
|
|
33
42
|
return logMetroErrorWithStack;
|
|
43
|
+
},
|
|
44
|
+
nearestImportStack: function() {
|
|
45
|
+
return nearestImportStack;
|
|
34
46
|
}
|
|
35
47
|
});
|
|
36
48
|
function _paths() {
|
|
@@ -47,6 +59,13 @@ function _chalk() {
|
|
|
47
59
|
};
|
|
48
60
|
return data;
|
|
49
61
|
}
|
|
62
|
+
function _nodeutil() {
|
|
63
|
+
const data = require("node:util");
|
|
64
|
+
_nodeutil = function() {
|
|
65
|
+
return data;
|
|
66
|
+
};
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
50
69
|
function _path() {
|
|
51
70
|
const data = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
52
71
|
_path = function() {
|
|
@@ -87,6 +106,7 @@ function _interop_require_default(obj) {
|
|
|
87
106
|
default: obj
|
|
88
107
|
};
|
|
89
108
|
}
|
|
109
|
+
const isDebug = require('debug').enabled('expo:start:server:metro');
|
|
90
110
|
function fill(width) {
|
|
91
111
|
return Array(width).join(' ');
|
|
92
112
|
}
|
|
@@ -114,16 +134,24 @@ async function logMetroErrorWithStack(projectRoot, { stack, codeFrame, error })
|
|
|
114
134
|
codeFrame,
|
|
115
135
|
error,
|
|
116
136
|
showCollapsedFrames: true
|
|
117
|
-
}));
|
|
137
|
+
}).stack);
|
|
118
138
|
}
|
|
119
139
|
function getStackAsFormattedLog(projectRoot, { stack, codeFrame, error, showCollapsedFrames = _env.env.EXPO_DEBUG }) {
|
|
120
140
|
const logs = [];
|
|
121
|
-
|
|
122
|
-
if (
|
|
141
|
+
const containsCodeFrame = likelyContainsCodeFrame(error == null ? void 0 : error.message);
|
|
142
|
+
if (containsCodeFrame) {
|
|
143
|
+
// Some transformation errors will have a code frame embedded in the error message
|
|
144
|
+
// from Babel and we should not duplicate it as message is already printed before this call.
|
|
145
|
+
} else if (codeFrame) {
|
|
123
146
|
var _codeFrame_location;
|
|
124
147
|
const maxWarningLineLength = Math.max(800, process.stdout.columns);
|
|
125
148
|
const lineText = codeFrame.content;
|
|
126
|
-
const
|
|
149
|
+
const lines = codeFrame.content.split('\n');
|
|
150
|
+
// ---- index.tsx ------------------------------------------------------
|
|
151
|
+
// 32 | This is example code which will be under the title.
|
|
152
|
+
const title = _path().default.basename(codeFrame.fileName);
|
|
153
|
+
logs.push(_chalk().default.bold`Code: ${title}`);
|
|
154
|
+
const isPreviewTooLong = lines.some((line)=>line.length > maxWarningLineLength);
|
|
127
155
|
const column = (_codeFrame_location = codeFrame.location) == null ? void 0 : _codeFrame_location.column;
|
|
128
156
|
// When the preview is too long, we skip reading the file and attempting to apply
|
|
129
157
|
// code coloring, this is because it can get very slow.
|
|
@@ -158,19 +186,18 @@ function getStackAsFormattedLog(projectRoot, { stack, codeFrame, error, showColl
|
|
|
158
186
|
// If the column property could be found, then use that to fix the cursor location which is often broken in regex.
|
|
159
187
|
cursorLine = (column == null ? '' : fill(column) + _chalk().default.reset('^')).slice(minBounds);
|
|
160
188
|
logs.push(formattedPath, '', previewLine, cursorLine, _chalk().default.dim('(error truncated)'));
|
|
161
|
-
hasCodeFramePresented = true;
|
|
162
189
|
}
|
|
163
190
|
} else {
|
|
164
191
|
logs.push(codeFrame.content);
|
|
165
|
-
hasCodeFramePresented = true;
|
|
166
192
|
}
|
|
167
193
|
}
|
|
194
|
+
let isFallback = false;
|
|
168
195
|
if (stack == null ? void 0 : stack.length) {
|
|
169
196
|
const stackProps = stack.map((frame)=>{
|
|
170
197
|
return {
|
|
171
198
|
title: frame.methodName,
|
|
172
199
|
subtitle: (0, _formatProjectFilePath.getStackFormattedLocation)(projectRoot, frame),
|
|
173
|
-
collapse: frame.collapse
|
|
200
|
+
collapse: frame.collapse || isInternalBytecode(frame)
|
|
174
201
|
};
|
|
175
202
|
});
|
|
176
203
|
const stackLines = [];
|
|
@@ -191,22 +218,23 @@ function getStackAsFormattedLog(projectRoot, { stack, codeFrame, error, showColl
|
|
|
191
218
|
backupStackLines.push(lineItem);
|
|
192
219
|
}
|
|
193
220
|
});
|
|
194
|
-
if (hasCodeFramePresented) {
|
|
195
|
-
logs.push('');
|
|
196
|
-
}
|
|
197
221
|
logs.push(_chalk().default.bold`Call Stack`);
|
|
198
222
|
if (!backupStackLines.length) {
|
|
199
223
|
logs.push(_chalk().default.gray(' No stack trace available.'));
|
|
200
224
|
} else {
|
|
225
|
+
isFallback = stackLines.length === 0;
|
|
201
226
|
// If there are not stack lines then it means the error likely happened in the node modules, in this case we should fallback to showing all the
|
|
202
227
|
// the stacks to give the user whatever help we can.
|
|
203
228
|
const displayStack = stackLines.length ? stackLines : backupStackLines;
|
|
204
229
|
logs.push(displayStack.join('\n'));
|
|
205
230
|
}
|
|
206
|
-
} else if (error) {
|
|
231
|
+
} else if (error && error.stack) {
|
|
207
232
|
logs.push(_chalk().default.gray(` ${error.stack}`));
|
|
208
233
|
}
|
|
209
|
-
return
|
|
234
|
+
return {
|
|
235
|
+
isFallback,
|
|
236
|
+
stack: logs.join('\n')
|
|
237
|
+
};
|
|
210
238
|
}
|
|
211
239
|
const IS_METRO_BUNDLE_ERROR_SYMBOL = Symbol('_isMetroBundleError');
|
|
212
240
|
const HAS_LOGGED_SYMBOL = Symbol('_hasLoggedInCLI');
|
|
@@ -363,5 +391,44 @@ function canParse(url) {
|
|
|
363
391
|
return false;
|
|
364
392
|
}
|
|
365
393
|
}
|
|
394
|
+
function dropStackIfContainsCodeFrame(err) {
|
|
395
|
+
if (!(err instanceof Error)) return;
|
|
396
|
+
if (likelyContainsCodeFrame(err.message)) {
|
|
397
|
+
// If the error message contains a code frame, we should drop the stack to avoid cluttering the output.
|
|
398
|
+
delete err.stack;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
function likelyContainsCodeFrame(message) {
|
|
402
|
+
if (!message) return false;
|
|
403
|
+
const clean = (0, _nodeutil().stripVTControlCharacters)(message);
|
|
404
|
+
if (!clean) return false;
|
|
405
|
+
return /^\s*\d+\s+\|/m.test(clean);
|
|
406
|
+
}
|
|
407
|
+
const attachImportStackToRootMessage = (err)=>{
|
|
408
|
+
if (!(err instanceof Error)) return;
|
|
409
|
+
// Space out build failures.
|
|
410
|
+
const nearestImportStackValue = nearestImportStack(err);
|
|
411
|
+
if (nearestImportStackValue) {
|
|
412
|
+
err.message += '\n\n' + nearestImportStackValue;
|
|
413
|
+
if (!isDebug) {
|
|
414
|
+
// When not debugging remove the stack to avoid cluttering the output and confusing users,
|
|
415
|
+
// the import stack is the guide to fixing the error.
|
|
416
|
+
delete err.stack;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
const nearestImportStack = (err, root = err)=>{
|
|
421
|
+
if (!(err instanceof Error) || !(root instanceof Error)) return undefined;
|
|
422
|
+
if ('_expoImportStack' in err && typeof err._expoImportStack === 'string') {
|
|
423
|
+
// Space out build failures.
|
|
424
|
+
return err._expoImportStack;
|
|
425
|
+
} else {
|
|
426
|
+
return nearestImportStack(err.cause, root);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
function isInternalBytecode(frame) {
|
|
430
|
+
var _frame_file;
|
|
431
|
+
return ((_frame_file = frame.file) == null ? void 0 : _frame_file.includes('InternalBytecode.js')) ?? false;
|
|
432
|
+
}
|
|
366
433
|
|
|
367
434
|
//# sourceMappingURL=metroErrorInterface.js.map
|
|
@@ -1 +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 { getMetroServerRoot } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { parse, StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { LogBoxLog } from './log-box/LogBoxLog';\nimport type { CodeFrame, StackFrame as MetroStackFrame } from './log-box/LogBoxSymbolication';\nimport { getStackFormattedLocation } from './log-box/formatProjectFilePath';\nimport { Log } from '../../../log';\nimport { stripAnsi } from '../../../utils/ansi';\nimport { env } from '../../../utils/env';\nimport { CommandError, SilentError } from '../../../utils/errors';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n\nfunction fill(width: number): string {\n return Array(width).join(' ');\n}\n\nfunction formatPaths(config: { filePath: string | null; line?: number; col?: number }) {\n const filePath = chalk.reset(config.filePath);\n return (\n chalk.dim('(') +\n filePath +\n chalk.dim(`:${[config.line, config.col].filter(Boolean).join(':')})`)\n );\n}\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 if (error instanceof SilentError) {\n return;\n }\n\n // process.stdout.write('\\u001b[0m'); // Reset attributes\n // process.stdout.write('\\u001bc'); // Reset the terminal\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (error instanceof CommandError) {\n return;\n }\n\n Log.log(\n getStackAsFormattedLog(projectRoot, { stack, codeFrame, error, showCollapsedFrames: true })\n );\n}\n\nexport function getStackAsFormattedLog(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n showCollapsedFrames = env.EXPO_DEBUG,\n }: {\n stack: MetroStackFrame[];\n codeFrame?: CodeFrame;\n error?: Error;\n showCollapsedFrames?: boolean;\n }\n): string {\n const logs: string[] = [];\n let hasCodeFramePresented = false;\n if (codeFrame) {\n const maxWarningLineLength = Math.max(800, process.stdout.columns);\n\n const lineText = codeFrame.content;\n const isPreviewTooLong = codeFrame.content\n .split('\\n')\n .some((line) => line.length > maxWarningLineLength);\n const column = codeFrame.location?.column;\n // When the preview is too long, we skip reading the file and attempting to apply\n // code coloring, this is because it can get very slow.\n if (isPreviewTooLong) {\n let previewLine = '';\n let cursorLine = '';\n\n const formattedPath = formatPaths({\n filePath: codeFrame.fileName,\n line: codeFrame.location?.row,\n col: codeFrame.location?.column,\n });\n // Create a curtailed preview line like:\n // `...transition:'fade'},k._updatePropsStack=function(){clearImmediate(k._updateImmediate),k._updateImmediate...`\n // If there is no text preview or column number, we can't do anything.\n if (lineText && column != null) {\n const rangeWindow = Math.round(\n Math.max(codeFrame.fileName?.length ?? 0, Math.max(80, process.stdout.columns)) / 2\n );\n let minBounds = Math.max(0, column - rangeWindow);\n const maxBounds = Math.min(minBounds + rangeWindow * 2, lineText.length);\n previewLine = lineText.slice(minBounds, maxBounds);\n\n // If we splice content off the start, then we should append `...`.\n // This is unlikely to happen since we limit the activation size.\n if (minBounds > 0) {\n // Adjust the min bounds so the cursor is aligned after we add the \"...\"\n minBounds -= 3;\n previewLine = chalk.dim('...') + previewLine;\n }\n if (maxBounds < lineText.length) {\n previewLine += chalk.dim('...');\n }\n\n // If the column property could be found, then use that to fix the cursor location which is often broken in regex.\n cursorLine = (column == null ? '' : fill(column) + chalk.reset('^')).slice(minBounds);\n\n logs.push(formattedPath, '', previewLine, cursorLine, chalk.dim('(error truncated)'));\n hasCodeFramePresented = true;\n }\n } else {\n logs.push(codeFrame.content);\n hasCodeFramePresented = true;\n }\n }\n\n if (stack?.length) {\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 const stackLines: string[] = [];\n const backupStackLines: string[] = [];\n\n stackProps.forEach((frame) => {\n const shouldShow = !frame.collapse || showCollapsedFrames;\n\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n // Never show the internal module system.\n const isMetroRuntime =\n /\\/metro-runtime\\/src\\/polyfills\\/require\\.js/.test(frame.subtitle) ||\n /\\/metro-require\\/require\\.js/.test(frame.subtitle);\n if (!isMetroRuntime) {\n if (shouldShow) {\n stackLines.push(lineItem);\n }\n backupStackLines.push(lineItem);\n }\n });\n\n if (hasCodeFramePresented) {\n logs.push('');\n }\n logs.push(chalk.bold`Call Stack`);\n\n if (!backupStackLines.length) {\n logs.push(chalk.gray(' No stack trace available.'));\n } else {\n // If there are not stack lines then it means the error likely happened in the node modules, in this case we should fallback to showing all the\n // the stacks to give the user whatever help we can.\n const displayStack = stackLines.length ? stackLines : backupStackLines;\n logs.push(displayStack.join('\\n'));\n }\n } else if (error) {\n logs.push(chalk.gray(` ${error.stack}`));\n }\n return logs.join('\\n');\n}\n\nexport const IS_METRO_BUNDLE_ERROR_SYMBOL = Symbol('_isMetroBundleError');\nconst HAS_LOGGED_SYMBOL = Symbol('_hasLoggedInCLI');\n\nexport async function logMetroError(\n projectRoot: string,\n {\n error,\n }: {\n error: Error & {\n [HAS_LOGGED_SYMBOL]?: boolean;\n };\n }\n) {\n if (error instanceof SilentError || error[HAS_LOGGED_SYMBOL]) {\n return;\n }\n error[HAS_LOGGED_SYMBOL] = true;\n\n const stack = parseErrorStack(projectRoot, 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\nfunction isTransformError(\n error: any\n): error is { type: 'TransformError'; filename: string; lineNumber: number; column: number } {\n return error.type === 'TransformError';\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nfunction logFromError({ error, projectRoot }: { error: Error; projectRoot: string }) {\n // Remap direct Metro Node.js errors to a format that will appear more client-friendly in the logbox UI.\n let stack: MetroStackFrame[] | undefined;\n if (isTransformError(error) && error.filename) {\n // Syntax errors in static rendering.\n stack = [\n {\n file: path.join(projectRoot, error.filename),\n methodName: '<unknown>',\n arguments: [],\n // TODO: Import stack\n lineNumber: error.lineNumber,\n column: error.column,\n },\n ];\n } else if ('originModulePath' in error && typeof error.originModulePath === 'string') {\n // TODO: Use import stack here when the error is resolution based.\n stack = [\n {\n file: error.originModulePath,\n methodName: '<unknown>',\n arguments: [],\n // TODO: Import stack\n lineNumber: 0,\n column: 0,\n },\n ];\n } else {\n stack = parseErrorStack(projectRoot, error.stack);\n }\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 routerRoot,\n}: {\n error: Error;\n projectRoot: string;\n routerRoot: 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 if ('message' in log && 'content' in log.message && typeof log.message.content === 'string') {\n log.message.content = stripAnsi(log.message.content)!;\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 mode: 'development',\n platform: 'web',\n minify: false,\n optimize: false,\n usedExports: false,\n baseUrl: '',\n routerRoot,\n isExporting: false,\n reactCompiler: false,\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n\nfunction parseErrorStack(\n projectRoot: string,\n stack?: string\n): (StackFrame & { collapse?: boolean })[] {\n if (stack == null) {\n return [];\n }\n if (Array.isArray(stack)) {\n return stack;\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n\n return parse(stack)\n .map((frame) => {\n // frame.file will mostly look like `http://localhost:8081/index.bundle?platform=web&dev=true&hot=false`\n\n if (frame.file) {\n // SSR will sometimes have absolute paths followed by `.bundle?...`, we need to try and make them relative paths and append a dev server URL.\n if (frame.file.startsWith('/') && frame.file.includes('bundle?') && !canParse(frame.file)) {\n // Malformed stack file from SSR. Attempt to repair.\n frame.file = 'https://localhost:8081/' + path.relative(serverRoot, frame.file);\n }\n }\n\n return {\n ...frame,\n column: frame.column != null ? frame.column - 1 : null,\n };\n })\n .filter((frame) => frame.file && !frame.file.includes('node_modules'));\n}\n\nfunction canParse(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n"],"names":["IS_METRO_BUNDLE_ERROR_SYMBOL","getErrorOverlayHtmlAsync","getStackAsFormattedLog","logMetroError","logMetroErrorAsync","logMetroErrorWithStack","fill","width","Array","join","formatPaths","config","filePath","chalk","reset","dim","line","col","filter","Boolean","projectRoot","stack","codeFrame","error","SilentError","Log","log","red","message","CommandError","showCollapsedFrames","env","EXPO_DEBUG","logs","hasCodeFramePresented","maxWarningLineLength","Math","max","process","stdout","columns","lineText","content","isPreviewTooLong","split","some","length","column","location","previewLine","cursorLine","formattedPath","fileName","row","rangeWindow","round","minBounds","maxBounds","min","slice","push","stackProps","map","frame","title","methodName","subtitle","getStackFormattedLocation","collapse","stackLines","backupStackLines","forEach","shouldShow","position","terminalLink","isSupported","lineItem","gray","isMetroRuntime","test","bold","displayStack","Symbol","HAS_LOGGED_SYMBOL","parseErrorStack","LogBoxLog","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","isTransformError","type","logFromError","filename","file","path","arguments","lineNumber","originModulePath","routerRoot","stripAnsi","logBoxContext","selectedLogIndex","isDisabled","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","resolveFrom","mode","platform","minify","optimize","usedExports","baseUrl","isExporting","reactCompiler","htmlWithJs","replace","isArray","serverRoot","getMetroServerRoot","parse","startsWith","includes","canParse","relative","url","URL"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IAyLYA,4BAA4B;eAA5BA;;IAgHSC,wBAAwB;eAAxBA;;IA3ONC,sBAAsB;eAAtBA;;IA8HMC,aAAa;eAAbA;;IA0FAC,kBAAkB;eAAlBA;;IAxPAC,sBAAsB;eAAtBA;;;;yBA7Ba;;;;;;;gEACjB;;;;;;;gEACD;;;;;;;gEACO;;;;;;;yBACU;;;;;;;gEACT;;;;;;2BAEC;uCAEgB;qBACtB;sBACM;qBACN;wBACsB;0CACD;;;;;;AAEzC,SAASC,KAAKC,KAAa;IACzB,OAAOC,MAAMD,OAAOE,IAAI,CAAC;AAC3B;AAEA,SAASC,YAAYC,MAAgE;IACnF,MAAMC,WAAWC,gBAAK,CAACC,KAAK,CA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7I,IAAIpC,MAAMoC,IAAI,CAAC8B,UAAU,CAAC,QAAQlE,MAAMoC,IAAI,CAAC+B,QAAQ,CAAC,cAAc,CAACC,SAASpE,MAAMoC,IAAI,GAAG;gBACzF,oDAAoD;gBACpDpC,MAAMoC,IAAI,GAAG,4BAA4BC,eAAI,CAACgC,QAAQ,CAACN,YAAY/D,MAAMoC,IAAI;YAC/E;QACF;QAEA,OAAO;YACL,GAAGpC,KAAK;YACRhB,QAAQgB,MAAMhB,MAAM,IAAI,OAAOgB,MAAMhB,MAAM,GAAG,IAAI;QACpD;IACF,GACC7B,MAAM,CAAC,CAAC6C,QAAUA,MAAMoC,IAAI,IAAI,CAACpC,MAAMoC,IAAI,CAAC+B,QAAQ,CAAC;AAC1D;AAEA,SAASC,SAASE,GAAW;IAC3B,IAAI;QACF,kCAAkC;QAClC,IAAIC,IAAID;QACR,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
|
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 { getMetroServerRoot } from '@expo/config/paths';\nimport chalk from 'chalk';\nimport { stripVTControlCharacters } from 'node:util';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\nimport { parse, StackFrame } from 'stacktrace-parser';\nimport terminalLink from 'terminal-link';\n\nimport { LogBoxLog } from './log-box/LogBoxLog';\nimport type { CodeFrame, StackFrame as MetroStackFrame } from './log-box/LogBoxSymbolication';\nimport { getStackFormattedLocation } from './log-box/formatProjectFilePath';\nimport { Log } from '../../../log';\nimport { stripAnsi } from '../../../utils/ansi';\nimport { env } from '../../../utils/env';\nimport { CommandError, SilentError } from '../../../utils/errors';\nimport { createMetroEndpointAsync } from '../getStaticRenderFunctions';\n\nconst isDebug = require('debug').enabled('expo:start:server:metro');\n\nfunction fill(width: number): string {\n return Array(width).join(' ');\n}\n\nfunction formatPaths(config: { filePath: string | null; line?: number; col?: number }) {\n const filePath = chalk.reset(config.filePath);\n return (\n chalk.dim('(') +\n filePath +\n chalk.dim(`:${[config.line, config.col].filter(Boolean).join(':')})`)\n );\n}\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 if (error instanceof SilentError) {\n return;\n }\n\n // process.stdout.write('\\u001b[0m'); // Reset attributes\n // process.stdout.write('\\u001bc'); // Reset the terminal\n\n Log.log();\n Log.log(chalk.red('Metro error: ') + error.message);\n Log.log();\n\n if (error instanceof CommandError) {\n return;\n }\n\n Log.log(\n getStackAsFormattedLog(projectRoot, { stack, codeFrame, error, showCollapsedFrames: true })\n .stack\n );\n}\n\nexport function getStackAsFormattedLog(\n projectRoot: string,\n {\n stack,\n codeFrame,\n error,\n showCollapsedFrames = env.EXPO_DEBUG,\n }: {\n stack: MetroStackFrame[];\n codeFrame?: CodeFrame;\n error?: Error;\n showCollapsedFrames?: boolean;\n }\n): {\n isFallback: boolean;\n stack: string;\n} {\n const logs: string[] = [];\n const containsCodeFrame = likelyContainsCodeFrame(error?.message);\n\n if (containsCodeFrame) {\n // Some transformation errors will have a code frame embedded in the error message\n // from Babel and we should not duplicate it as message is already printed before this call.\n } else if (codeFrame) {\n const maxWarningLineLength = Math.max(800, process.stdout.columns);\n\n const lineText = codeFrame.content;\n const lines = codeFrame.content.split('\\n');\n\n // ---- index.tsx ------------------------------------------------------\n // 32 | This is example code which will be under the title.\n const title = path.basename(codeFrame.fileName);\n logs.push(chalk.bold`Code: ${title}`);\n\n const isPreviewTooLong = lines.some((line) => line.length > maxWarningLineLength);\n const column = codeFrame.location?.column;\n // When the preview is too long, we skip reading the file and attempting to apply\n // code coloring, this is because it can get very slow.\n if (isPreviewTooLong) {\n let previewLine = '';\n let cursorLine = '';\n\n const formattedPath = formatPaths({\n filePath: codeFrame.fileName,\n line: codeFrame.location?.row,\n col: codeFrame.location?.column,\n });\n // Create a curtailed preview line like:\n // `...transition:'fade'},k._updatePropsStack=function(){clearImmediate(k._updateImmediate),k._updateImmediate...`\n // If there is no text preview or column number, we can't do anything.\n if (lineText && column != null) {\n const rangeWindow = Math.round(\n Math.max(codeFrame.fileName?.length ?? 0, Math.max(80, process.stdout.columns)) / 2\n );\n let minBounds = Math.max(0, column - rangeWindow);\n const maxBounds = Math.min(minBounds + rangeWindow * 2, lineText.length);\n previewLine = lineText.slice(minBounds, maxBounds);\n\n // If we splice content off the start, then we should append `...`.\n // This is unlikely to happen since we limit the activation size.\n if (minBounds > 0) {\n // Adjust the min bounds so the cursor is aligned after we add the \"...\"\n minBounds -= 3;\n previewLine = chalk.dim('...') + previewLine;\n }\n if (maxBounds < lineText.length) {\n previewLine += chalk.dim('...');\n }\n\n // If the column property could be found, then use that to fix the cursor location which is often broken in regex.\n cursorLine = (column == null ? '' : fill(column) + chalk.reset('^')).slice(minBounds);\n\n logs.push(formattedPath, '', previewLine, cursorLine, chalk.dim('(error truncated)'));\n }\n } else {\n logs.push(codeFrame.content);\n }\n }\n\n let isFallback = false;\n if (stack?.length) {\n const stackProps = stack.map((frame) => {\n return {\n title: frame.methodName,\n subtitle: getStackFormattedLocation(projectRoot, frame),\n collapse: frame.collapse || isInternalBytecode(frame),\n };\n });\n\n const stackLines: string[] = [];\n const backupStackLines: string[] = [];\n\n stackProps.forEach((frame) => {\n const shouldShow = !frame.collapse || showCollapsedFrames;\n\n const position = terminalLink.isSupported\n ? terminalLink(frame.subtitle, frame.subtitle)\n : frame.subtitle;\n let lineItem = chalk.gray(` ${frame.title} (${position})`);\n\n if (frame.collapse) {\n lineItem = chalk.dim(lineItem);\n }\n // Never show the internal module system.\n const isMetroRuntime =\n /\\/metro-runtime\\/src\\/polyfills\\/require\\.js/.test(frame.subtitle) ||\n /\\/metro-require\\/require\\.js/.test(frame.subtitle);\n if (!isMetroRuntime) {\n if (shouldShow) {\n stackLines.push(lineItem);\n }\n backupStackLines.push(lineItem);\n }\n });\n\n logs.push(chalk.bold`Call Stack`);\n\n if (!backupStackLines.length) {\n logs.push(chalk.gray(' No stack trace available.'));\n } else {\n isFallback = stackLines.length === 0;\n // If there are not stack lines then it means the error likely happened in the node modules, in this case we should fallback to showing all the\n // the stacks to give the user whatever help we can.\n const displayStack = stackLines.length ? stackLines : backupStackLines;\n logs.push(displayStack.join('\\n'));\n }\n } else if (error && error.stack) {\n logs.push(chalk.gray(` ${error.stack}`));\n }\n\n return {\n isFallback,\n stack: logs.join('\\n'),\n };\n}\n\nexport const IS_METRO_BUNDLE_ERROR_SYMBOL = Symbol('_isMetroBundleError');\nconst HAS_LOGGED_SYMBOL = Symbol('_hasLoggedInCLI');\n\nexport async function logMetroError(\n projectRoot: string,\n {\n error,\n }: {\n error: Error & {\n [HAS_LOGGED_SYMBOL]?: boolean;\n };\n }\n) {\n if (error instanceof SilentError || error[HAS_LOGGED_SYMBOL]) {\n return;\n }\n error[HAS_LOGGED_SYMBOL] = true;\n\n const stack = parseErrorStack(projectRoot, 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\nfunction isTransformError(\n error: any\n): error is { type: 'TransformError'; filename: string; lineNumber: number; column: number } {\n return error.type === 'TransformError';\n}\n\n/** @returns the html required to render the static metro error as an SPA. */\nfunction logFromError({ error, projectRoot }: { error: Error; projectRoot: string }) {\n // Remap direct Metro Node.js errors to a format that will appear more client-friendly in the logbox UI.\n let stack: MetroStackFrame[] | undefined;\n if (isTransformError(error) && error.filename) {\n // Syntax errors in static rendering.\n stack = [\n {\n file: path.join(projectRoot, error.filename),\n methodName: '<unknown>',\n arguments: [],\n // TODO: Import stack\n lineNumber: error.lineNumber,\n column: error.column,\n },\n ];\n } else if ('originModulePath' in error && typeof error.originModulePath === 'string') {\n // TODO: Use import stack here when the error is resolution based.\n stack = [\n {\n file: error.originModulePath,\n methodName: '<unknown>',\n arguments: [],\n // TODO: Import stack\n lineNumber: 0,\n column: 0,\n },\n ];\n } else {\n stack = parseErrorStack(projectRoot, error.stack);\n }\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 routerRoot,\n}: {\n error: Error;\n projectRoot: string;\n routerRoot: 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 if ('message' in log && 'content' in log.message && typeof log.message.content === 'string') {\n log.message.content = stripAnsi(log.message.content)!;\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 mode: 'development',\n platform: 'web',\n minify: false,\n optimize: false,\n usedExports: false,\n baseUrl: '',\n routerRoot,\n isExporting: false,\n reactCompiler: false,\n }\n );\n\n const htmlWithJs = html.replace('</body>', `<script src=${errorOverlayEntry}></script></body>`);\n return htmlWithJs;\n}\n\nfunction parseErrorStack(\n projectRoot: string,\n stack?: string\n): (StackFrame & { collapse?: boolean })[] {\n if (stack == null) {\n return [];\n }\n if (Array.isArray(stack)) {\n return stack;\n }\n\n const serverRoot = getMetroServerRoot(projectRoot);\n\n return parse(stack)\n .map((frame) => {\n // frame.file will mostly look like `http://localhost:8081/index.bundle?platform=web&dev=true&hot=false`\n\n if (frame.file) {\n // SSR will sometimes have absolute paths followed by `.bundle?...`, we need to try and make them relative paths and append a dev server URL.\n if (frame.file.startsWith('/') && frame.file.includes('bundle?') && !canParse(frame.file)) {\n // Malformed stack file from SSR. Attempt to repair.\n frame.file = 'https://localhost:8081/' + path.relative(serverRoot, frame.file);\n }\n }\n\n return {\n ...frame,\n column: frame.column != null ? frame.column - 1 : null,\n };\n })\n .filter((frame) => frame.file && !frame.file.includes('node_modules'));\n}\n\nfunction canParse(url: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function dropStackIfContainsCodeFrame(err: unknown) {\n if (!(err instanceof Error)) return;\n\n if (likelyContainsCodeFrame(err.message)) {\n // If the error message contains a code frame, we should drop the stack to avoid cluttering the output.\n delete err.stack;\n }\n}\n\n/**\n * Tests given string on presence of ` [num] |` at the start of any line.\n * Returns `false` for undefined or empty strings.\n */\nexport function likelyContainsCodeFrame(message: string | undefined): boolean {\n if (!message) return false;\n\n const clean = stripVTControlCharacters(message);\n if (!clean) return false;\n\n return /^\\s*\\d+\\s+\\|/m.test(clean);\n}\n\n/**\n * Walks thru the error cause chain and attaches the import stack to the root error message.\n * Removes the error stack for import and syntax errors.\n */\nexport const attachImportStackToRootMessage = (err: unknown) => {\n if (!(err instanceof Error)) return;\n\n // Space out build failures.\n const nearestImportStackValue = nearestImportStack(err);\n if (nearestImportStackValue) {\n err.message += '\\n\\n' + nearestImportStackValue;\n\n if (!isDebug) {\n // When not debugging remove the stack to avoid cluttering the output and confusing users,\n // the import stack is the guide to fixing the error.\n delete err.stack;\n }\n }\n};\n\n/**\n * Walks thru the error cause chain and returns the nearest import stack.\n * If the import stack is not found, it returns `undefined`.\n */\nexport const nearestImportStack = (err: unknown, root: unknown = err): string | undefined => {\n if (!(err instanceof Error) || !(root instanceof Error)) return undefined;\n\n if ('_expoImportStack' in err && typeof err._expoImportStack === 'string') {\n // Space out build failures.\n return err._expoImportStack;\n } else {\n return nearestImportStack(err.cause, root);\n }\n};\n\nfunction isInternalBytecode(frame: StackFrame): boolean {\n return frame.file?.includes('InternalBytecode.js') ?? false;\n}\n"],"names":["IS_METRO_BUNDLE_ERROR_SYMBOL","attachImportStackToRootMessage","dropStackIfContainsCodeFrame","getErrorOverlayHtmlAsync","getStackAsFormattedLog","likelyContainsCodeFrame","logMetroError","logMetroErrorAsync","logMetroErrorWithStack","nearestImportStack","isDebug","require","enabled","fill","width","Array","join","formatPaths","config","filePath","chalk","reset","dim","line","col","filter","Boolean","projectRoot","stack","codeFrame","error","SilentError","Log","log","red","message","CommandError","showCollapsedFrames","env","EXPO_DEBUG","logs","containsCodeFrame","maxWarningLineLength","Math","max","process","stdout","columns","lineText","content","lines","split","title","path","basename","fileName","push","bold","isPreviewTooLong","some","length","column","location","previewLine","cursorLine","formattedPath","row","rangeWindow","round","minBounds","maxBounds","min","slice","isFallback","stackProps","map","frame","methodName","subtitle","getStackFormattedLocation","collapse","isInternalBytecode","stackLines","backupStackLines","forEach","shouldShow","position","terminalLink","isSupported","lineItem","gray","isMetroRuntime","test","displayStack","Symbol","HAS_LOGGED_SYMBOL","parseErrorStack","LogBoxLog","level","substitutions","isComponentError","category","componentStack","Promise","res","symbolicate","symbolicated","isTransformError","type","logFromError","filename","file","arguments","lineNumber","originModulePath","routerRoot","stripAnsi","logBoxContext","selectedLogIndex","isDisabled","html","JSON","stringify","errorOverlayEntry","createMetroEndpointAsync","resolveFrom","mode","platform","minify","optimize","usedExports","baseUrl","isExporting","reactCompiler","htmlWithJs","replace","isArray","serverRoot","getMetroServerRoot","parse","startsWith","includes","canParse","relative","url","URL","err","Error","clean","stripVTControlCharacters","nearestImportStackValue","root","undefined","_expoImportStack","cause"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;IA0MYA,4BAA4B;eAA5BA;;IA2OAC,8BAA8B;eAA9BA;;IA1BGC,4BAA4B;eAA5BA;;IAjGMC,wBAAwB;eAAxBA;;IAxPNC,sBAAsB;eAAtBA;;IAsWAC,uBAAuB;eAAvBA;;IA3NMC,aAAa;eAAbA;;IA0FAC,kBAAkB;eAAlBA;;IAtQAC,sBAAsB;eAAtBA;;IAwaTC,kBAAkB;eAAlBA;;;;yBAxcsB;;;;;;;gEACjB;;;;;;;yBACuB;;;;;;;gEACxB;;;;;;;gEACO;;;;;;;yBACU;;;;;;;gEACT;;;;;;2BAEC;uCAEgB;qBACtB;sBACM;qBACN;wBACsB;0CACD;;;;;;AAEzC,MAAMC,UAAUC,QAAQ,SAASC,OAAO,CAAC;AAEzC,SAASC,KAAKC,KAAa;IACzB,OAAOC,MAAMD,OAAOE,IAAI,CAAC;AAC3B;AAEA,SAASC,YAAYC,MAAgE;IACnF,MAAMC,WAAWC,gBAAK,CAACC,KAAK,CAACH,OAAOC,QAAQ;IAC5C,OACEC,gBAAK,CAACE,GAAG,CAAC,OACVH,WACAC,gBAAK,CAACE,GAAG,CAAC,CAAC,CAAC,EAAE;QAACJ,OAAOK,IAAI;QAAEL,OAAOM,GAAG;KAAC,CAACC,MAAM,CAACC,SAASV,IAAI,CAAC,KAAK,CAAC,CAAC;AAExE;AAEO,eAAeR,uBACpBmB,WAAmB,EACnB,EACEC,KAAK,EACLC,SAAS,EACTC,KAAK,EAKN;IAED,IAAIA,iBAAiBC,mBAAW,EAAE;QAChC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AACF;AAMO,MAAMnB,qBAAqB,CAACyI,KAAcK,OAAgBL,GAAG;IAClE,IAAI,CAAEA,CAAAA,eAAeC,KAAI,KAAM,CAAEI,CAAAA,gBAAgBJ,KAAI,GAAI,OAAOK;IAEhE,IAAI,sBAAsBN,OAAO,OAAOA,IAAIO,gBAAgB,KAAK,UAAU;QACzE,4BAA4B;QAC5B,OAAOP,IAAIO,gBAAgB;IAC7B,OAAO;QACL,OAAOhJ,mBAAmByI,IAAIQ,KAAK,EAAEH;IACvC;AACF;AAEA,SAAStE,mBAAmBL,KAAiB;QACpCA;IAAP,OAAOA,EAAAA,cAAAA,MAAMmC,IAAI,qBAAVnC,YAAYiE,QAAQ,CAAC,2BAA0B;AACxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/metroVirtualModules.ts"],"sourcesContent":["/**\n * Copyright © 2024 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 Bundler from 'metro/
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/metroVirtualModules.ts"],"sourcesContent":["/**\n * Copyright © 2024 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 type Bundler from '@expo/metro/metro/Bundler';\nimport type DependencyGraph from '@expo/metro/metro/node-haste/DependencyGraph';\nimport type { FileSystem } from '@expo/metro/metro-file-map';\n\ntype ExpoPatchedFileSystem = Omit<FileSystem, 'getSha1'> & {\n getSha1: FileSystem['getSha1'] & { __patched?: boolean };\n expoVirtualModules?: Map<string, Buffer>;\n};\n\ntype ActualDependencyGraph = DependencyGraph & {\n _fileSystem: ExpoPatchedFileSystem;\n};\n\ntype ActualBundler = Bundler & {\n _depGraph: ActualDependencyGraph;\n};\n\ntype ExpoPatchedBundler = Bundler & {\n setVirtualModule: (id: string, contents: string) => void;\n hasVirtualModule: (id: string) => boolean;\n};\n\nfunction assertBundlerHasPrivateMembers(bundler: Bundler): asserts bundler is ActualBundler {\n if (!('_depGraph' in bundler)) {\n throw new Error(\n 'Expected bundler to have member: _depGraph. Upstream metro may have removed this property.'\n );\n }\n\n assertDepGraphHasPrivateMembers(bundler._depGraph);\n}\n\nfunction assertDepGraphHasPrivateMembers(\n depGraph: unknown\n): asserts depGraph is ActualDependencyGraph {\n if (!depGraph || typeof depGraph !== 'object' || !('_fileSystem' in depGraph)) {\n throw new Error(\n 'Expected bundler._depGraph to have member: _fileSystem. Upstream metro may have removed this property.'\n );\n }\n}\n\nfunction ensureMetroBundlerPatchedWithSetVirtualModule(\n bundler: Bundler & {\n setVirtualModule?: (id: string, contents: string) => void;\n hasVirtualModule?: (id: string) => boolean;\n }\n): ExpoPatchedBundler {\n if (!bundler.setVirtualModule) {\n bundler.setVirtualModule = function (this: Bundler, id: string, contents: string) {\n assertBundlerHasPrivateMembers(this);\n const fs = ensureFileSystemPatched(this._depGraph._fileSystem);\n fs.expoVirtualModules!.set(ensureStartsWithNullByte(id), Buffer.from(contents));\n };\n bundler.hasVirtualModule = function (this: Bundler, id: string) {\n assertBundlerHasPrivateMembers(this);\n const fs = ensureFileSystemPatched(this._depGraph._fileSystem);\n return fs.expoVirtualModules!.has(ensureStartsWithNullByte(id));\n };\n }\n\n return bundler as ExpoPatchedBundler;\n}\n\nfunction ensureStartsWithNullByte(id: string): string {\n // Because you'll likely need to return the path somewhere, we should just assert with a useful error message instead of\n // attempting to mutate the value behind the scenes. This ensures correctness in the resolution.\n if (!id.startsWith('\\0')) {\n throw new Error(`Virtual modules in Expo CLI must start with with null byte (\\\\0), got: ${id}`);\n }\n return id;\n}\n\nexport function getMetroBundlerWithVirtualModules(\n bundler: Bundler & {\n transformFile: Bundler['transformFile'] & { __patched?: boolean };\n }\n): ExpoPatchedBundler {\n if (!bundler.transformFile.__patched) {\n const originalTransformFile = bundler.transformFile.bind(bundler);\n\n bundler.transformFile = async function (\n filePath: string,\n transformOptions: any,\n /** Optionally provide the file contents, this can be used to provide virtual contents for a file. */\n fileBuffer?: Buffer\n ) {\n // file buffer will be defined for virtual modules in Metro, e.g. context modules.\n if (!fileBuffer) {\n if (filePath.startsWith('\\0')) {\n const graph = await this.getDependencyGraph();\n\n assertDepGraphHasPrivateMembers(graph);\n\n if (graph._fileSystem.expoVirtualModules) {\n fileBuffer = graph._fileSystem.expoVirtualModules.get(filePath);\n }\n\n if (!fileBuffer) {\n throw new Error(`Virtual module \"${filePath}\" not found.`);\n }\n }\n }\n return originalTransformFile(filePath, transformOptions, fileBuffer);\n };\n\n bundler.transformFile.__patched = true;\n }\n\n return ensureMetroBundlerPatchedWithSetVirtualModule(bundler);\n}\n\nfunction ensureFileSystemPatched(fs: ExpoPatchedFileSystem): ExpoPatchedFileSystem {\n if (!fs.getSha1.__patched) {\n const original_getSha1 = fs.getSha1.bind(fs);\n fs.getSha1 = (filename: string) => {\n // Rollup virtual module format.\n if (filename.startsWith('\\0')) {\n return filename;\n }\n\n return original_getSha1(filename);\n };\n fs.getSha1.__patched = true;\n }\n\n // TODO: Connect virtual modules to a specific context so they don't cross-bundles.\n if (!fs.expoVirtualModules) {\n fs.expoVirtualModules = new Map<string, Buffer>();\n }\n\n return fs;\n}\n"],"names":["getMetroBundlerWithVirtualModules","assertBundlerHasPrivateMembers","bundler","Error","assertDepGraphHasPrivateMembers","_depGraph","depGraph","ensureMetroBundlerPatchedWithSetVirtualModule","setVirtualModule","id","contents","fs","ensureFileSystemPatched","_fileSystem","expoVirtualModules","set","ensureStartsWithNullByte","Buffer","from","hasVirtualModule","has","startsWith","transformFile","__patched","originalTransformFile","bind","filePath","transformOptions","fileBuffer","graph","getDependencyGraph","get","getSha1","original_getSha1","filename","Map"],"mappings":"AAAA;;;;;CAKC;;;;+BA0EeA;;;eAAAA;;;AAnDhB,SAASC,+BAA+BC,OAAgB;IACtD,IAAI,CAAE,CAAA,eAAeA,OAAM,GAAI;QAC7B,MAAM,IAAIC,MACR;IAEJ;IAEAC,gCAAgCF,QAAQG,S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,WAAW,CAACC,kBAAkB,EAAE;wBACxCc,aAAaC,MAAMhB,WAAW,CAACC,kBAAkB,CAACiB,GAAG,CAACL;oBACxD;oBAEA,IAAI,CAACE,YAAY;wBACf,MAAM,IAAIzB,MAAM,CAAC,gBAAgB,EAAEuB,SAAS,YAAY,CAAC;oBAC3D;gBACF;YACF;YACA,OAAOF,sBAAsBE,UAAUC,kBAAkBC;QAC3D;QAEA1B,QAAQoB,aAAa,CAACC,SAAS,GAAG;IACpC;IAEA,OAAOhB,8CAA8CL;AACvD;AAEA,SAASU,wBAAwBD,EAAyB;IACxD,IAAI,CAACA,GAAGqB,OAAO,CAACT,SAAS,EAAE;QACzB,MAAMU,mBAAmBtB,GAAGqB,OAAO,CAACP,IAAI,CAACd;QACzCA,GAAGqB,OAAO,GAAG,CAACE;YACZ,gCAAgC;YAChC,IAAIA,SAASb,UAAU,CAAC,OAAO;gBAC7B,OAAOa;YACT;YAEA,OAAOD,iBAAiBC;QAC1B;QACAvB,GAAGqB,OAAO,CAACT,SAAS,GAAG;IACzB;IAEA,mFAAmF;IACnF,IAAI,CAACZ,GAAGG,kBAAkB,EAAE;QAC1BH,GAAGG,kBAAkB,GAAG,IAAIqB;IAC9B;IAEA,OAAOxB;AACT"}
|
|
@@ -1 +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')(\n 'expo:start:server:metro:metroWatchTypeScriptFiles'\n) as typeof console.log;\n\nexport interface MetroWatchTypeScriptFilesOptions {\n projectRoot: string;\n metro:
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/metroWatchTypeScriptFiles.ts"],"sourcesContent":["import type MetroServer from '@expo/metro/metro/Server';\nimport path from 'path';\n\nimport type { ServerLike } from '../BundlerDevServer';\n\nconst debug = require('debug')(\n 'expo:start:server:metro:metroWatchTypeScriptFiles'\n) as typeof console.log;\n\nexport interface MetroWatchTypeScriptFilesOptions {\n projectRoot: string;\n metro: MetroServer;\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":";;;;+BAmCgBA;;;eAAAA;;;;gEAlCC;;;;;;;;;;;AAIjB,MAAMC,QAAQC,QAAQ,SACpB;AA6BK,SAASF,0BAA0B,EACxCG,KAAK,EACLC,MAAM,EACNC,WAAW,EACXC,QAAQ,EACRC,WAAW,KAAK,EAChBC,WAAW,KAAK,EAChBC,aAAa;IAAC;IAAO;IAAU;CAAS,EACP;IACjC,MAAMC,UAAUP,MAAMQ,UAAU,GAAGA,UAAU,GAAGC,UAAU;IAE1D,MAAMC,eAAeC,eAAI,CAACC,IAAI,CAACV,aAAa;IAE5C,MAAMW,WAAW,CAAC,EAAEC,WAAW,EAAiC;QAC9D,KAAK,MAAMC,SAASD,YAAa;gBAG7BC;YAFF,IACET,WAAWU,QAAQ,CAACD,MAAME,IAAI,KAC9BF,EAAAA,kBAAAA,MAAMG,QAAQ,qBAAdH,gBAAgBE,IAAI,MAAK,OACzB,yGAAyG;YACzG,CAAC,eAAeE,IAAI,CAACJ,MAAMK,QAAQ,KACnC,2BAA2B;YAC3B,CAAC,WAAWD,IAAI,CAACJ,MAAMK,QAAQ,GAC/B;gBACA,MAAM,EAAEA,QAAQ,EAAE,GAAGL;gBACrB,iBAAiB;gBACjB,IACE,+EAA+E;gBAC/E,UAAUI,IAAI,CAACC,aACf,gEAAgE;gBAC/DhB,YAAYgB,aAAaV,cAC1B;oBACAZ,MAAM,qDAAqDsB;oBAC3DjB,SAASY;oBAET,IAAIV,UAAU;wBACZ;oBACF;gBACF;YACF;QACF;IACF;IAEAP,MAAM;IACNS,QAAQc,WAAW,CAAC,UAAUR;IAC9BN,QAAQc,WAAW,CAAC,OAAOR;IAE3B,MAAMS,MAAM;QACVf,QAAQgB,cAAc,CAAC,UAAUV;QACjCN,QAAQgB,cAAc,CAAC,OAAOV;IAChC;IAEAZ,OAAOoB,WAAW,oBAAlBpB,OAAOoB,WAAW,MAAlBpB,QAAqB,SAASqB;IAC9B,OAAOA;AACT"}
|
|
@@ -15,6 +15,9 @@ _export(exports, {
|
|
|
15
15
|
getAppRouterRelativeEntryPath: function() {
|
|
16
16
|
return getAppRouterRelativeEntryPath;
|
|
17
17
|
},
|
|
18
|
+
getMiddlewareForDirectory: function() {
|
|
19
|
+
return getMiddlewareForDirectory;
|
|
20
|
+
},
|
|
18
21
|
getRoutePaths: function() {
|
|
19
22
|
return getRoutePaths;
|
|
20
23
|
},
|
|
@@ -27,9 +30,18 @@ _export(exports, {
|
|
|
27
30
|
hasWarnedAboutApiRoutes: function() {
|
|
28
31
|
return hasWarnedAboutApiRoutes;
|
|
29
32
|
},
|
|
33
|
+
hasWarnedAboutMiddleware: function() {
|
|
34
|
+
return hasWarnedAboutMiddleware;
|
|
35
|
+
},
|
|
30
36
|
isApiRouteConvention: function() {
|
|
31
37
|
return isApiRouteConvention;
|
|
32
38
|
},
|
|
39
|
+
warnInvalidMiddlewareMatcherSettings: function() {
|
|
40
|
+
return warnInvalidMiddlewareMatcherSettings;
|
|
41
|
+
},
|
|
42
|
+
warnInvalidMiddlewareOutput: function() {
|
|
43
|
+
return warnInvalidMiddlewareOutput;
|
|
44
|
+
},
|
|
33
45
|
warnInvalidWebOutput: function() {
|
|
34
46
|
return warnInvalidWebOutput;
|
|
35
47
|
}
|
|
@@ -120,6 +132,22 @@ function getApiRoutesForDirectory(cwd) {
|
|
|
120
132
|
dot: true
|
|
121
133
|
});
|
|
122
134
|
}
|
|
135
|
+
function getMiddlewareForDirectory(cwd) {
|
|
136
|
+
const files = (0, _glob().sync)('+middleware.@(ts|tsx|js|jsx)', {
|
|
137
|
+
cwd,
|
|
138
|
+
absolute: true,
|
|
139
|
+
dot: true
|
|
140
|
+
});
|
|
141
|
+
if (files.length === 0) return null;
|
|
142
|
+
if (files.length > 1) {
|
|
143
|
+
// In development, throw an error if there are multiple root-level middleware files
|
|
144
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
145
|
+
const relativePaths = files.map((f)=>'./' + _path().default.relative(cwd, f)).sort();
|
|
146
|
+
throw new Error(`Only one middleware file is allowed. Keep one of the conflicting files: ${relativePaths.map((p)=>`"${p}"`).join(' or ')}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return files[0];
|
|
150
|
+
}
|
|
123
151
|
function getRoutePaths(cwd) {
|
|
124
152
|
return (0, _glob().sync)('**/*.@(ts|tsx|js|jsx)', {
|
|
125
153
|
cwd,
|
|
@@ -130,14 +158,61 @@ function normalizePaths(p) {
|
|
|
130
158
|
return p.replace(/\\/g, '/');
|
|
131
159
|
}
|
|
132
160
|
let hasWarnedAboutApiRouteOutput = false;
|
|
161
|
+
let hasWarnedAboutMiddlewareOutput = false;
|
|
133
162
|
function hasWarnedAboutApiRoutes() {
|
|
134
163
|
return hasWarnedAboutApiRouteOutput;
|
|
135
164
|
}
|
|
165
|
+
function hasWarnedAboutMiddleware() {
|
|
166
|
+
return hasWarnedAboutMiddlewareOutput;
|
|
167
|
+
}
|
|
136
168
|
function warnInvalidWebOutput() {
|
|
137
169
|
if (!hasWarnedAboutApiRouteOutput) {
|
|
138
170
|
_log.Log.warn(_chalk().default.yellow`Using API routes requires the {bold web.output} to be set to {bold "server"} in the project {bold app.json}. ${(0, _link.learnMore)('https://docs.expo.dev/router/reference/api-routes/')}`);
|
|
139
171
|
}
|
|
140
172
|
hasWarnedAboutApiRouteOutput = true;
|
|
141
173
|
}
|
|
174
|
+
function warnInvalidMiddlewareOutput() {
|
|
175
|
+
if (!hasWarnedAboutMiddlewareOutput) {
|
|
176
|
+
_log.Log.warn(_chalk().default.yellow`Using middleware requires the {bold web.output} to be set to {bold "server"} in the project {bold app.json}. ${(0, _link.learnMore)('https://docs.expo.dev/router/reference/api-routes/')}`);
|
|
177
|
+
}
|
|
178
|
+
hasWarnedAboutMiddlewareOutput = true;
|
|
179
|
+
}
|
|
180
|
+
function warnInvalidMiddlewareMatcherSettings(matcher) {
|
|
181
|
+
const validMethods = [
|
|
182
|
+
'GET',
|
|
183
|
+
'POST',
|
|
184
|
+
'PUT',
|
|
185
|
+
'PATCH',
|
|
186
|
+
'DELETE',
|
|
187
|
+
'OPTIONS',
|
|
188
|
+
'HEAD'
|
|
189
|
+
];
|
|
190
|
+
// Ensure methods are valid HTTP methods
|
|
191
|
+
if (matcher.methods) {
|
|
192
|
+
if (!Array.isArray(matcher.methods)) {
|
|
193
|
+
_log.Log.error(_chalk().default.red`Middleware matcher methods must be an array of valid HTTP methods. Supported methods are: ${validMethods.join(', ')}`);
|
|
194
|
+
} else {
|
|
195
|
+
for (const method of matcher.methods){
|
|
196
|
+
if (!validMethods.includes(method)) {
|
|
197
|
+
_log.Log.error(_chalk().default.red`Invalid middleware HTTP method: ${method}. Supported methods are: ${validMethods.join(', ')}`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// Ensure patterns are either a string or RegExp
|
|
203
|
+
if (matcher.patterns) {
|
|
204
|
+
const patterns = Array.isArray(matcher.patterns) ? matcher.patterns : [
|
|
205
|
+
matcher.patterns
|
|
206
|
+
];
|
|
207
|
+
for (const pattern of patterns){
|
|
208
|
+
if (typeof pattern !== 'string' && !(pattern instanceof RegExp)) {
|
|
209
|
+
_log.Log.error(_chalk().default.red`Middleware matcher patterns must be strings or regular expressions. Received: ${String(pattern)}`);
|
|
210
|
+
}
|
|
211
|
+
if (typeof pattern === 'string' && !pattern.startsWith('/')) {
|
|
212
|
+
_log.Log.error(_chalk().default.red`String patterns in middleware matcher must start with '/'. Received: ${pattern}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
142
217
|
|
|
143
218
|
//# sourceMappingURL=router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/start/server/metro/router.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport chalk from 'chalk';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { Log } from '../../../log';\nimport { directoryExistsSync } from '../../../utils/dir';\nimport { toPosixPath } from '../../../utils/filePath';\nimport { learnMore } from '../../../utils/link';\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('expo-router entry', 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 getRouterDirectoryModuleIdWithManifest(\n projectRoot: string,\n exp: ExpoConfig\n): string {\n return toPosixPath(exp.extra?.router?.root ?? getRouterDirectory(projectRoot));\n}\n\nlet hasWarnedAboutSrcDir = false;\nconst logSrcDir = () => {\n if (hasWarnedAboutSrcDir) return;\n hasWarnedAboutSrcDir = true;\n Log.log(chalk.gray('Using src/app as the root directory for Expo Router.'));\n};\n\nexport function getRouterDirectory(projectRoot: string): string {\n // more specific directories first\n if (directoryExistsSync(path.join(projectRoot, 'src', 'app'))) {\n logSrcDir();\n return path.join('src', 'app');\n }\n\n debug('Using app as the root directory for Expo Router.');\n return 'app';\n}\n\nexport function isApiRouteConvention(name: string): boolean {\n return /\\+api\\.[tj]sx?$/.test(name);\n}\n\nexport function getApiRoutesForDirectory(cwd: string) {\n return globSync('**/*+api.@(ts|tsx|js|jsx)', {\n cwd,\n absolute: true,\n dot: true,\n });\n}\n\n// Used to emulate a context module, but way faster. TODO: May need to adjust the extensions to stay in sync with Metro.\nexport function getRoutePaths(cwd: string) {\n return globSync('**/*.@(ts|tsx|js|jsx)', {\n cwd,\n dot: true,\n }).map((p) => './' + normalizePaths(p));\n}\n\nfunction normalizePaths(p: string) {\n return p.replace(/\\\\/g, '/');\n}\n\nlet hasWarnedAboutApiRouteOutput = false;\n\nexport function hasWarnedAboutApiRoutes() {\n return hasWarnedAboutApiRouteOutput;\n}\n\nexport function warnInvalidWebOutput() {\n if (!hasWarnedAboutApiRouteOutput) {\n Log.warn(\n chalk.yellow`Using API routes requires the {bold web.output} to be set to {bold \"server\"} in the project {bold app.json}. ${learnMore(\n 'https://docs.expo.dev/router/reference/api-routes/'\n )}`\n );\n }\n\n hasWarnedAboutApiRouteOutput = true;\n}\n"],"names":["getApiRoutesForDirectory","getAppRouterRelativeEntryPath","getRoutePaths","getRouterDirectory","getRouterDirectoryModuleIdWithManifest","hasWarnedAboutApiRoutes","isApiRouteConvention","warnInvalidWebOutput","debug","require","projectRoot","routerDirectory","routerEntry","resolveFrom","silent","getFallbackEntryRoot","undefined","appFolder","path","join","appRoot","relative","dirname","expoRoot","exp","toPosixPath","extra","router","root","hasWarnedAboutSrcDir","logSrcDir","Log","log","chalk","gray","directoryExistsSync","name","test","cwd","globSync","absolute","dot","map","p","normalizePaths","replace","hasWarnedAboutApiRouteOutput","warn","yellow","learnMore"],"mappings":";;;;;;;;;;;IAwEgBA,wBAAwB;eAAxBA;;IAvDAC,6BAA6B;eAA7BA;;IAgEAC,aAAa;eAAbA;;IAxBAC,kBAAkB;eAAlBA;;IAdAC,sCAAsC;eAAtCA;;IAmDAC,uBAAuB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AAIyB,IAAAA,wBAAmB,EAACjB,eAAI,CAACC,IAAI,CAACT,aAAa,OAAO,SAAS;QAC7DoB;QACA,OAAOZ,eAAI,CAACC,IAAI,CAAC,OAAO;IAC1B;IAEAX,MAAM;IACN,OAAO;AACT;AAEO,SAASF,qBAAqB8B,IAAY;IAC/C,OAAO,kBAAkBC,IAAI,CAACD;AAChC;AAEO,SAASpC,yBAAyBsC,GAAW;IAClD,OAAOC,IAAAA,YAAQ,EAAC,6BAA6B;QAC3CD;QACAE,UAAU;QACVC,KAAK;IACP;AACF;AAGO,SAASvC,cAAcoC,GAAW;IACvC,OAAOC,IAAAA,YAAQ,EAAC,yBAAyB;QACvCD;QACAG,KAAK;IACP,GAAGC,GAAG,CAAC,CAACC,IAAM,OAAOC,eAAeD;AACtC;AAEA,SAASC,eAAeD,CAAS;IAC/B,OAAOA,EAAEE,OAAO,CAAC,OAAO;AAC1B;AAEA,IAAIC,+BAA+B;AAE5B,SAASzC;IACd,OAAOyC;AACT;AAEO,SAASvC;IACd,IAAI,CAACuC,8BAA8B;QACjCf,QAAG,CAACgB,IAAI,CACNd,gBAAK,CAACe,MAAM,CAAC,6GAA6G,EAAEC,IAAAA,eAAS,EACnI,sDACA,CAAC;IAEP;IAEAH,+BAA+B;AACjC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/start/server/metro/router.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport type { MiddlewareMatcher } from '@expo/server/build/types';\nimport chalk from 'chalk';\nimport { sync as globSync } from 'glob';\nimport path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { Log } from '../../../log';\nimport { directoryExistsSync } from '../../../utils/dir';\nimport { toPosixPath } from '../../../utils/filePath';\nimport { learnMore } from '../../../utils/link';\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('expo-router entry', 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 getRouterDirectoryModuleIdWithManifest(\n projectRoot: string,\n exp: ExpoConfig\n): string {\n return toPosixPath(exp.extra?.router?.root ?? getRouterDirectory(projectRoot));\n}\n\nlet hasWarnedAboutSrcDir = false;\nconst logSrcDir = () => {\n if (hasWarnedAboutSrcDir) return;\n hasWarnedAboutSrcDir = true;\n Log.log(chalk.gray('Using src/app as the root directory for Expo Router.'));\n};\n\nexport function getRouterDirectory(projectRoot: string): string {\n // more specific directories first\n if (directoryExistsSync(path.join(projectRoot, 'src', 'app'))) {\n logSrcDir();\n return path.join('src', 'app');\n }\n\n debug('Using app as the root directory for Expo Router.');\n return 'app';\n}\n\nexport function isApiRouteConvention(name: string): boolean {\n return /\\+api\\.[tj]sx?$/.test(name);\n}\n\nexport function getApiRoutesForDirectory(cwd: string) {\n return globSync('**/*+api.@(ts|tsx|js|jsx)', {\n cwd,\n absolute: true,\n dot: true,\n });\n}\n\n/**\n * Gets the +middleware file for a given directory. In\n * @param cwd\n */\nexport function getMiddlewareForDirectory(cwd: string): string | null {\n const files = globSync('+middleware.@(ts|tsx|js|jsx)', {\n cwd,\n absolute: true,\n dot: true,\n });\n\n if (files.length === 0) return null;\n\n if (files.length > 1) {\n // In development, throw an error if there are multiple root-level middleware files\n if (process.env.NODE_ENV !== 'production') {\n const relativePaths = files.map((f) => './' + path.relative(cwd, f)).sort();\n throw new Error(\n `Only one middleware file is allowed. Keep one of the conflicting files: ${relativePaths.map((p) => `\"${p}\"`).join(' or ')}`\n );\n }\n }\n\n return files[0];\n}\n\n// Used to emulate a context module, but way faster. TODO: May need to adjust the extensions to stay in sync with Metro.\nexport function getRoutePaths(cwd: string) {\n return globSync('**/*.@(ts|tsx|js|jsx)', {\n cwd,\n dot: true,\n }).map((p) => './' + normalizePaths(p));\n}\n\nfunction normalizePaths(p: string) {\n return p.replace(/\\\\/g, '/');\n}\n\nlet hasWarnedAboutApiRouteOutput = false;\nlet hasWarnedAboutMiddlewareOutput = false;\n\nexport function hasWarnedAboutApiRoutes() {\n return hasWarnedAboutApiRouteOutput;\n}\n\nexport function hasWarnedAboutMiddleware() {\n return hasWarnedAboutMiddlewareOutput;\n}\n\nexport function warnInvalidWebOutput() {\n if (!hasWarnedAboutApiRouteOutput) {\n Log.warn(\n chalk.yellow`Using API routes requires the {bold web.output} to be set to {bold \"server\"} in the project {bold app.json}. ${learnMore(\n 'https://docs.expo.dev/router/reference/api-routes/'\n )}`\n );\n }\n\n hasWarnedAboutApiRouteOutput = true;\n}\n\nexport function warnInvalidMiddlewareOutput() {\n if (!hasWarnedAboutMiddlewareOutput) {\n Log.warn(\n chalk.yellow`Using middleware requires the {bold web.output} to be set to {bold \"server\"} in the project {bold app.json}. ${learnMore(\n 'https://docs.expo.dev/router/reference/api-routes/'\n )}`\n );\n }\n\n hasWarnedAboutMiddlewareOutput = true;\n}\n\nexport function warnInvalidMiddlewareMatcherSettings(matcher: MiddlewareMatcher) {\n const validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD'];\n\n // Ensure methods are valid HTTP methods\n if (matcher.methods) {\n if (!Array.isArray(matcher.methods)) {\n Log.error(\n chalk.red`Middleware matcher methods must be an array of valid HTTP methods. Supported methods are: ${validMethods.join(', ')}`\n );\n } else {\n for (const method of matcher.methods) {\n if (!validMethods.includes(method)) {\n Log.error(\n chalk.red`Invalid middleware HTTP method: ${method}. Supported methods are: ${validMethods.join(', ')}`\n );\n }\n }\n }\n }\n\n // Ensure patterns are either a string or RegExp\n if (matcher.patterns) {\n const patterns = Array.isArray(matcher.patterns) ? matcher.patterns : [matcher.patterns];\n for (const pattern of patterns) {\n if (typeof pattern !== 'string' && !(pattern instanceof RegExp)) {\n Log.error(\n chalk.red`Middleware matcher patterns must be strings or regular expressions. Received: ${String(\n pattern\n )}`\n );\n }\n\n if (typeof pattern === 'string' && !pattern.startsWith('/')) {\n Log.error(\n chalk.red`String patterns in middleware matcher must start with '/'. Received: ${pattern}`\n );\n }\n }\n }\n}\n"],"names":["getApiRoutesForDirectory","getAppRouterRelativeEntryPath","getMiddlewareForDirectory","getRoutePaths","getRouterDirectory","getRouterDirectoryModuleIdWithManifest","hasWarnedAboutApiRoutes","hasWarnedAboutMiddleware","isApiRouteConvention","warnInvalidMiddlewareMatcherSettings","warnInvalidMiddlewareOutput","warnInvalidWebOutput","debug","require","projectRoot","routerDirectory","routerEntry","resolveFrom","silent","getFallbackEntryRoot","undefined","appFolder","path","join","appRoot","relative","dirname","expoRoot","exp","toPosixPath","extra","router","root","hasWarnedAboutSrcDir","logSrcDir","Log","log","chalk","gray","directoryExistsSync","name","test","cwd","globSync","absolute","dot","files","length","process","env","NODE_ENV","relativePaths","map","f","sort","Error","p","normalizePaths","replace","hasWarnedAboutApiRouteOutput","hasWarnedAboutMiddlewareOutput","warn","yellow","learnMore","matcher","validMethods","methods","Array","isArray","error","red","method","includes","patterns","pattern","RegExp","String","startsWith"],"mappings":";;;;;;;;;;;IAyEgBA,wBAAwB;eAAxBA;;IAvDAC,6BAA6B;eAA7BA;;IAmEAC,yBAAyB;eAAzBA;;IAuBAC,aAAa;eAAbA;;IAlDAC,kBA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KAAK,MAAMC,WAAWD,SAAU;YAC9B,IAAI,OAAOC,YAAY,YAAY,CAAEA,CAAAA,mBAAmBC,MAAK,GAAI;gBAC/DxC,QAAG,CAACkC,KAAK,CACPhC,gBAAK,CAACiC,GAAG,CAAC,8EAA8E,EAAEM,OACxFF,SACA,CAAC;YAEP;YAEA,IAAI,OAAOA,YAAY,YAAY,CAACA,QAAQG,UAAU,CAAC,MAAM;gBAC3D1C,QAAG,CAACkC,KAAK,CACPhC,gBAAK,CAACiC,GAAG,CAAC,qEAAqE,EAAEI,QAAQ,CAAC;YAE9F;QACF;IACF;AACF"}
|
|
@@ -13,44 +13,44 @@ Object.defineProperty(exports, "runServer", {
|
|
|
13
13
|
return runServer;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
function
|
|
17
|
-
const data =
|
|
18
|
-
|
|
16
|
+
function _metro() {
|
|
17
|
+
const data = require("@expo/metro/metro");
|
|
18
|
+
_metro = function() {
|
|
19
19
|
return data;
|
|
20
20
|
};
|
|
21
21
|
return data;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const data = /*#__PURE__*/ _interop_require_default(require("
|
|
25
|
-
|
|
23
|
+
function _HmrServer() {
|
|
24
|
+
const data = /*#__PURE__*/ _interop_require_default(require("@expo/metro/metro/HmrServer"));
|
|
25
|
+
_HmrServer = function() {
|
|
26
26
|
return data;
|
|
27
27
|
};
|
|
28
28
|
return data;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
const data = /*#__PURE__*/ _interop_require_default(require("
|
|
32
|
-
|
|
30
|
+
function _createWebsocketServer() {
|
|
31
|
+
const data = /*#__PURE__*/ _interop_require_default(require("@expo/metro/metro/lib/createWebsocketServer"));
|
|
32
|
+
_createWebsocketServer = function() {
|
|
33
33
|
return data;
|
|
34
34
|
};
|
|
35
35
|
return data;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
const data = /*#__PURE__*/ _interop_require_default(require("
|
|
39
|
-
|
|
37
|
+
function _assert() {
|
|
38
|
+
const data = /*#__PURE__*/ _interop_require_default(require("assert"));
|
|
39
|
+
_assert = function() {
|
|
40
40
|
return data;
|
|
41
41
|
};
|
|
42
42
|
return data;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const data = /*#__PURE__*/ _interop_require_default(require("
|
|
46
|
-
|
|
44
|
+
function _http() {
|
|
45
|
+
const data = /*#__PURE__*/ _interop_require_default(require("http"));
|
|
46
|
+
_http = function() {
|
|
47
47
|
return data;
|
|
48
48
|
};
|
|
49
49
|
return data;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
const data = /*#__PURE__*/ _interop_require_default(require("
|
|
53
|
-
|
|
51
|
+
function _https() {
|
|
52
|
+
const data = /*#__PURE__*/ _interop_require_default(require("https"));
|
|
53
|
+
_https = function() {
|
|
54
54
|
return data;
|
|
55
55
|
};
|
|
56
56
|
return data;
|
|
@@ -80,7 +80,7 @@ const runServer = async (metroBundler, config, { hasReducedPerformance = false,
|
|
|
80
80
|
// "Metro's https development server.",
|
|
81
81
|
// );
|
|
82
82
|
// }
|
|
83
|
-
const { middleware, end, metroServer } = await _metro().
|
|
83
|
+
const { middleware, end, metroServer } = await (0, _metro().createConnectMiddleware)(config, {
|
|
84
84
|
hasReducedPerformance,
|
|
85
85
|
waitForBundler,
|
|
86
86
|
watch
|