inital commit

This commit is contained in:
2026-01-01 15:25:19 +05:30
commit f0ae49465a
36361 changed files with 4894111 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import type { ServerResponse, IncomingMessage } from 'http';
import type { Telemetry } from '../../../../telemetry/storage';
export declare function getNextErrorFeedbackMiddleware(telemetry: Telemetry): (req: IncomingMessage, res: ServerResponse, next: () => void) => Promise<void>;

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getNextErrorFeedbackMiddleware", {
enumerable: true,
get: function() {
return getNextErrorFeedbackMiddleware;
}
});
const _errorfeedback = require("../../../../telemetry/events/error-feedback");
const _middlewareresponse = require("./middleware-response");
function getNextErrorFeedbackMiddleware(telemetry) {
return async function(req, res, next) {
const { pathname, searchParams } = new URL("http://n" + req.url);
if (pathname !== '/__nextjs_error_feedback') {
return next();
}
try {
const errorCode = searchParams.get('errorCode');
const wasHelpful = searchParams.get('wasHelpful');
if (!errorCode || !wasHelpful) {
return _middlewareresponse.middlewareResponse.badRequest(res);
}
await telemetry.record((0, _errorfeedback.eventErrorFeedback)({
errorCode,
wasHelpful: wasHelpful === 'true'
}));
return _middlewareresponse.middlewareResponse.noContent(res);
} catch (error) {
return _middlewareresponse.middlewareResponse.internalServerError(res);
}
};
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=get-next-error-feedback-middleware.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/get-next-error-feedback-middleware.ts"],"sourcesContent":["import { eventErrorFeedback } from '../../../../telemetry/events/error-feedback'\nimport { middlewareResponse } from './middleware-response'\nimport type { ServerResponse, IncomingMessage } from 'http'\nimport type { Telemetry } from '../../../../telemetry/storage'\n\n// Handles HTTP requests to /__nextjs_error_feedback endpoint for collecting user feedback on error messages\nexport function getNextErrorFeedbackMiddleware(telemetry: Telemetry) {\n return async function (\n req: IncomingMessage,\n res: ServerResponse,\n next: () => void\n ): Promise<void> {\n const { pathname, searchParams } = new URL(`http://n${req.url}`)\n\n if (pathname !== '/__nextjs_error_feedback') {\n return next()\n }\n\n try {\n const errorCode = searchParams.get('errorCode')\n const wasHelpful = searchParams.get('wasHelpful')\n\n if (!errorCode || !wasHelpful) {\n return middlewareResponse.badRequest(res)\n }\n\n await telemetry.record(\n eventErrorFeedback({\n errorCode,\n wasHelpful: wasHelpful === 'true',\n })\n )\n\n return middlewareResponse.noContent(res)\n } catch (error) {\n return middlewareResponse.internalServerError(res)\n }\n }\n}\n"],"names":["getNextErrorFeedbackMiddleware","telemetry","req","res","next","pathname","searchParams","URL","url","errorCode","get","wasHelpful","middlewareResponse","badRequest","record","eventErrorFeedback","noContent","error","internalServerError"],"mappings":";;;;+BAMgBA;;;eAAAA;;;+BANmB;oCACA;AAK5B,SAASA,+BAA+BC,SAAoB;IACjE,OAAO,eACLC,GAAoB,EACpBC,GAAmB,EACnBC,IAAgB;QAEhB,MAAM,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAG,IAAIC,IAAI,AAAC,aAAUL,IAAIM,GAAG;QAE7D,IAAIH,aAAa,4BAA4B;YAC3C,OAAOD;QACT;QAEA,IAAI;YACF,MAAMK,YAAYH,aAAaI,GAAG,CAAC;YACnC,MAAMC,aAAaL,aAAaI,GAAG,CAAC;YAEpC,IAAI,CAACD,aAAa,CAACE,YAAY;gBAC7B,OAAOC,sCAAkB,CAACC,UAAU,CAACV;YACvC;YAEA,MAAMF,UAAUa,MAAM,CACpBC,IAAAA,iCAAkB,EAAC;gBACjBN;gBACAE,YAAYA,eAAe;YAC7B;YAGF,OAAOC,sCAAkB,CAACI,SAAS,CAACb;QACtC,EAAE,OAAOc,OAAO;YACd,OAAOL,sCAAkB,CAACM,mBAAmB,CAACf;QAChD;IACF;AACF"}

View File

@@ -0,0 +1,10 @@
import type { ServerResponse } from 'http';
export declare const middlewareResponse: {
noContent(res: ServerResponse): void;
badRequest(res: ServerResponse): void;
notFound(res: ServerResponse): void;
methodNotAllowed(res: ServerResponse): void;
internalServerError(res: ServerResponse, error?: unknown): void;
json(res: ServerResponse, data: any): void;
jsonString(res: ServerResponse, data: string): void;
};

View File

@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "middlewareResponse", {
enumerable: true,
get: function() {
return middlewareResponse;
}
});
const _util = require("util");
const middlewareResponse = {
noContent (res) {
res.statusCode = 204;
res.end('No Content');
},
badRequest (res) {
res.statusCode = 400;
res.end('Bad Request');
},
notFound (res) {
res.statusCode = 404;
res.end('Not Found');
},
methodNotAllowed (res) {
res.statusCode = 405;
res.end('Method Not Allowed');
},
internalServerError (res, error) {
res.statusCode = 500;
res.setHeader('Content-Type', 'text/plain');
res.end(error !== undefined ? (0, _util.inspect)(error, {
colors: false
}) : 'Internal Server Error');
},
json (res, data) {
res.setHeader('Content-Type', 'application/json').end(Buffer.from(JSON.stringify(data)));
},
jsonString (res, data) {
res.setHeader('Content-Type', 'application/json').end(Buffer.from(data));
}
};
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=middleware-response.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/middleware-response.ts"],"sourcesContent":["import type { ServerResponse } from 'http'\nimport { inspect } from 'util'\n\nexport const middlewareResponse = {\n noContent(res: ServerResponse) {\n res.statusCode = 204\n res.end('No Content')\n },\n badRequest(res: ServerResponse) {\n res.statusCode = 400\n res.end('Bad Request')\n },\n notFound(res: ServerResponse) {\n res.statusCode = 404\n res.end('Not Found')\n },\n methodNotAllowed(res: ServerResponse) {\n res.statusCode = 405\n res.end('Method Not Allowed')\n },\n internalServerError(res: ServerResponse, error?: unknown) {\n res.statusCode = 500\n res.setHeader('Content-Type', 'text/plain')\n res.end(\n error !== undefined\n ? inspect(error, { colors: false })\n : 'Internal Server Error'\n )\n },\n json(res: ServerResponse, data: any) {\n res\n .setHeader('Content-Type', 'application/json')\n .end(Buffer.from(JSON.stringify(data)))\n },\n jsonString(res: ServerResponse, data: string) {\n res.setHeader('Content-Type', 'application/json').end(Buffer.from(data))\n },\n}\n"],"names":["middlewareResponse","noContent","res","statusCode","end","badRequest","notFound","methodNotAllowed","internalServerError","error","setHeader","undefined","inspect","colors","json","data","Buffer","from","JSON","stringify","jsonString"],"mappings":";;;;+BAGaA;;;eAAAA;;;sBAFW;AAEjB,MAAMA,qBAAqB;IAChCC,WAAUC,GAAmB;QAC3BA,IAAIC,UAAU,GAAG;QACjBD,IAAIE,GAAG,CAAC;IACV;IACAC,YAAWH,GAAmB;QAC5BA,IAAIC,UAAU,GAAG;QACjBD,IAAIE,GAAG,CAAC;IACV;IACAE,UAASJ,GAAmB;QAC1BA,IAAIC,UAAU,GAAG;QACjBD,IAAIE,GAAG,CAAC;IACV;IACAG,kBAAiBL,GAAmB;QAClCA,IAAIC,UAAU,GAAG;QACjBD,IAAIE,GAAG,CAAC;IACV;IACAI,qBAAoBN,GAAmB,EAAEO,KAAe;QACtDP,IAAIC,UAAU,GAAG;QACjBD,IAAIQ,SAAS,CAAC,gBAAgB;QAC9BR,IAAIE,GAAG,CACLK,UAAUE,YACNC,IAAAA,aAAO,EAACH,OAAO;YAAEI,QAAQ;QAAM,KAC/B;IAER;IACAC,MAAKZ,GAAmB,EAAEa,IAAS;QACjCb,IACGQ,SAAS,CAAC,gBAAgB,oBAC1BN,GAAG,CAACY,OAAOC,IAAI,CAACC,KAAKC,SAAS,CAACJ;IACpC;IACAK,YAAWlB,GAAmB,EAAEa,IAAY;QAC1Cb,IAAIQ,SAAS,CAAC,gBAAgB,oBAAoBN,GAAG,CAACY,OAAOC,IAAI,CAACF;IACpE;AACF"}

View File

@@ -0,0 +1,4 @@
import type { IncomingMessage, ServerResponse } from 'http';
import type { Project } from '../../../../build/swc/types';
export declare function getOverlayMiddleware(project: Project, projectPath: string): (req: IncomingMessage, res: ServerResponse, next: () => void) => Promise<void>;
export declare function getSourceMapMiddleware(project: Project): (req: IncomingMessage, res: ServerResponse, next: () => void) => Promise<void>;

View File

@@ -0,0 +1,391 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getOverlayMiddleware: null,
getSourceMapMiddleware: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getOverlayMiddleware: function() {
return getOverlayMiddleware;
},
getSourceMapMiddleware: function() {
return getSourceMapMiddleware;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _shared = require("./shared");
const _middlewareresponse = require("./middleware-response");
const _promises = /*#__PURE__*/ _interop_require_wildcard._(require("fs/promises"));
const _path = /*#__PURE__*/ _interop_require_default._(require("path"));
const _url = /*#__PURE__*/ _interop_require_default._(require("url"));
const _launcheditor = require("../utils/launch-editor");
const _sourcemap08 = require("next/dist/compiled/source-map08");
const _getsourcemapfromfile = require("../utils/get-source-map-from-file");
const _nodemodule = require("node:module");
const _nodeurl = require("node:url");
const _nodeutil = require("node:util");
function shouldIgnorePath(modulePath) {
return modulePath.includes('node_modules') || // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo
modulePath.includes('next/dist') || modulePath.startsWith('node:');
}
const currentSourcesByFile = new Map();
async function batchedTraceSource(project, frame) {
const file = frame.file ? decodeURIComponent(frame.file) : undefined;
if (!file) return;
// For node internals they cannot traced the actual source code with project.traceSource,
// we need an early return to indicate it's ignored to avoid the unknown scheme error from `project.traceSource`.
if (file.startsWith('node:')) {
var _frame_line, _frame_column, _frame_methodName;
return {
frame: {
file,
lineNumber: (_frame_line = frame.line) != null ? _frame_line : 0,
column: (_frame_column = frame.column) != null ? _frame_column : 0,
methodName: (_frame_methodName = frame.methodName) != null ? _frame_methodName : '<unknown>',
ignored: true,
arguments: []
},
source: null
};
}
const currentDirectoryFileUrl = (0, _nodeurl.pathToFileURL)(process.cwd()).href;
const sourceFrame = await project.traceSource(frame, currentDirectoryFileUrl);
if (!sourceFrame) {
var _frame_line1, _frame_column1, _frame_methodName1;
return {
frame: {
file,
lineNumber: (_frame_line1 = frame.line) != null ? _frame_line1 : 0,
column: (_frame_column1 = frame.column) != null ? _frame_column1 : 0,
methodName: (_frame_methodName1 = frame.methodName) != null ? _frame_methodName1 : '<unknown>',
ignored: shouldIgnorePath(file),
arguments: []
},
source: null
};
}
let source = null;
const originalFile = sourceFrame.originalFile;
// Don't look up source for node_modules or internals. These can often be large bundled files.
const ignored = shouldIgnorePath(originalFile != null ? originalFile : sourceFrame.file) || // isInternal means resource starts with turbopack:///[turbopack]
!!sourceFrame.isInternal;
if (originalFile && !ignored) {
let sourcePromise = currentSourcesByFile.get(originalFile);
if (!sourcePromise) {
sourcePromise = project.getSourceForAsset(originalFile);
currentSourcesByFile.set(originalFile, sourcePromise);
setTimeout(()=>{
// Cache file reads for 100ms, as frames will often reference the same
// files and can be large.
currentSourcesByFile.delete(originalFile);
}, 100);
}
source = await sourcePromise;
}
var _sourceFrame_line, _sourceFrame_column, // We ignore the sourcemapped name since it won't be the correct name.
// The callsite will point to the column of the variable name instead of the
// name of the enclosing function.
// TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.
_frame_methodName2;
// TODO: get ignoredList from turbopack source map
const ignorableFrame = {
file: sourceFrame.file,
lineNumber: (_sourceFrame_line = sourceFrame.line) != null ? _sourceFrame_line : 0,
column: (_sourceFrame_column = sourceFrame.column) != null ? _sourceFrame_column : 0,
methodName: (_frame_methodName2 = frame.methodName) != null ? _frame_methodName2 : '<unknown>',
ignored,
arguments: []
};
return {
frame: ignorableFrame,
source
};
}
function parseFile(fileParam) {
if (!fileParam) {
return undefined;
}
// rsc://React/Server/file://<filename>?42 => file://<filename>
return fileParam.replace(/^rsc:\/\/React\/[^/]+\//, '').replace(/\?\d+$/, '');
}
function createStackFrames(body) {
const { frames, isServer } = body;
return frames.map((frame)=>{
const file = parseFile(frame.file);
if (!file) {
return undefined;
}
var _frame_methodName, _frame_lineNumber, _frame_column;
return {
file,
methodName: (_frame_methodName = frame.methodName) != null ? _frame_methodName : '<unknown>',
line: (_frame_lineNumber = frame.lineNumber) != null ? _frame_lineNumber : 0,
column: (_frame_column = frame.column) != null ? _frame_column : 0,
isServer
};
}).filter((f)=>f !== undefined);
}
function createStackFrame(searchParams) {
const file = parseFile(searchParams.get('file'));
if (!file) {
return undefined;
}
var _searchParams_get, _searchParams_get1, _searchParams_get2;
return {
file,
methodName: (_searchParams_get = searchParams.get('methodName')) != null ? _searchParams_get : '<unknown>',
line: parseInt((_searchParams_get1 = searchParams.get('lineNumber')) != null ? _searchParams_get1 : '0', 10) || 0,
column: parseInt((_searchParams_get2 = searchParams.get('column')) != null ? _searchParams_get2 : '0', 10) || 0,
isServer: searchParams.get('isServer') === 'true'
};
}
/**
* Finds the sourcemap payload applicable to a given frame.
* Equal to the input unless an Index Source Map is used.
*/ function findApplicableSourceMapPayload(frame, payload) {
if ('sections' in payload) {
var _frame_line;
const frameLine = (_frame_line = frame.line) != null ? _frame_line : 0;
var _frame_column;
const frameColumn = (_frame_column = frame.column) != null ? _frame_column : 0;
// Sections must not overlap and must be sorted: https://tc39.es/source-map/#section-object
// Therefore the last section that has an offset less than or equal to the frame is the applicable one.
// TODO(veil): Binary search
let section = payload.sections[0];
for(let i = 0; i < payload.sections.length && payload.sections[i].offset.line <= frameLine && payload.sections[i].offset.column <= frameColumn; i++){
section = payload.sections[i];
}
return section === undefined ? undefined : section.map;
} else {
return payload;
}
}
/**
* @returns 1-based lines and 0-based columns
*/ async function nativeTraceSource(frame) {
const sourceURL = decodeURIComponent(frame.file);
let sourceMapPayload;
try {
var _findSourceMap;
sourceMapPayload = (_findSourceMap = (0, _nodemodule.findSourceMap)(sourceURL)) == null ? void 0 : _findSourceMap.payload;
} catch (cause) {
throw Object.defineProperty(new Error("" + sourceURL + ": Invalid source map. Only conformant source maps can be used to find the original code.", {
cause
}), "__NEXT_ERROR_CODE", {
value: "E635",
enumerable: false,
configurable: true
});
}
if (sourceMapPayload !== undefined) {
let consumer;
try {
consumer = await new _sourcemap08.SourceMapConsumer(sourceMapPayload);
} catch (cause) {
throw Object.defineProperty(new Error("" + sourceURL + ": Invalid source map. Only conformant source maps can be used to find the original code.", {
cause
}), "__NEXT_ERROR_CODE", {
value: "E635",
enumerable: false,
configurable: true
});
}
let traced;
try {
var _frame_line, _frame_column;
const originalPosition = consumer.originalPositionFor({
line: (_frame_line = frame.line) != null ? _frame_line : 1,
// 0-based columns out requires 0-based columns in.
column: ((_frame_column = frame.column) != null ? _frame_column : 1) - 1
});
if (originalPosition.source === null) {
traced = null;
} else {
var _consumer_sourceContentFor;
const sourceContent = (_consumer_sourceContentFor = consumer.sourceContentFor(originalPosition.source, /* returnNullOnMissing */ true)) != null ? _consumer_sourceContentFor : null;
traced = {
originalPosition,
sourceContent
};
}
} finally{
consumer.destroy();
}
if (traced !== null) {
var // We ignore the sourcemapped name since it won't be the correct name.
// The callsite will point to the column of the variable name instead of the
// name of the enclosing function.
// TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.
_frame_methodName_replace, _frame_methodName;
const { originalPosition, sourceContent } = traced;
const applicableSourceMap = findApplicableSourceMapPayload(frame, sourceMapPayload);
// TODO(veil): Upstream a method to sourcemap consumer that immediately says if a frame is ignored or not.
let ignored = false;
if (applicableSourceMap === undefined) {
console.error('No applicable source map found in sections for frame', frame);
} else {
var _applicableSourceMap_ignoreList;
// TODO: O(n^2). Consider moving `ignoreList` into a Set
const sourceIndex = applicableSourceMap.sources.indexOf(originalPosition.source);
var _applicableSourceMap_ignoreList_includes;
ignored = (_applicableSourceMap_ignoreList_includes = (_applicableSourceMap_ignoreList = applicableSourceMap.ignoreList) == null ? void 0 : _applicableSourceMap_ignoreList.includes(sourceIndex)) != null ? _applicableSourceMap_ignoreList_includes : // When sourcemap is not available, fallback to checking `frame.file`.
// e.g. In pages router, nextjs server code is not bundled into the page.
shouldIgnorePath(frame.file);
}
var _originalPosition_column, _originalPosition_line;
const originalStackFrame = {
methodName: ((_frame_methodName = frame.methodName) == null ? void 0 : (_frame_methodName_replace = _frame_methodName.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')) == null ? void 0 : _frame_methodName_replace.replace('__webpack_exports__.', '')) || '<unknown>',
column: ((_originalPosition_column = originalPosition.column) != null ? _originalPosition_column : 0) + 1,
file: originalPosition.source,
lineNumber: (_originalPosition_line = originalPosition.line) != null ? _originalPosition_line : 0,
// TODO: c&p from async createOriginalStackFrame but why not frame.arguments?
arguments: [],
ignored
};
return {
frame: originalStackFrame,
source: sourceContent
};
}
}
return undefined;
}
async function createOriginalStackFrame(project, projectPath, frame) {
var _ref;
const traced = (_ref = await nativeTraceSource(frame)) != null ? _ref : // TODO(veil): When would the bundler know more than native?
// If it's faster, try the bundler first and fall back to native later.
await batchedTraceSource(project, frame);
if (!traced) {
return null;
}
let normalizedStackFrameLocation = traced.frame.file;
if (normalizedStackFrameLocation !== null && normalizedStackFrameLocation.startsWith('file://')) {
normalizedStackFrameLocation = _path.default.relative(projectPath, _url.default.fileURLToPath(normalizedStackFrameLocation));
}
return {
originalStackFrame: {
arguments: traced.frame.arguments,
column: traced.frame.column,
file: normalizedStackFrameLocation,
ignored: traced.frame.ignored,
lineNumber: traced.frame.lineNumber,
methodName: traced.frame.methodName
},
originalCodeFrame: (0, _shared.getOriginalCodeFrame)(traced.frame, traced.source)
};
}
function getOverlayMiddleware(project, projectPath) {
return async function(req, res, next) {
const { pathname, searchParams } = new URL(req.url, 'http://n');
if (pathname === '/__nextjs_original-stack-frames') {
if (req.method !== 'POST') {
return _middlewareresponse.middlewareResponse.badRequest(res);
}
const body = await new Promise((resolve, reject)=>{
let data = '';
req.on('data', (chunk)=>{
data += chunk;
});
req.on('end', ()=>resolve(data));
req.on('error', reject);
});
const request = JSON.parse(body);
const stackFrames = createStackFrames(request);
const result = await Promise.all(stackFrames.map(async (frame)=>{
try {
const stackFrame = await createOriginalStackFrame(project, projectPath, frame);
if (stackFrame === null) {
return {
status: 'rejected',
reason: 'Failed to create original stack frame'
};
}
return {
status: 'fulfilled',
value: stackFrame
};
} catch (error) {
return {
status: 'rejected',
reason: (0, _nodeutil.inspect)(error, {
colors: false
})
};
}
}));
return _middlewareresponse.middlewareResponse.json(res, result);
} else if (pathname === '/__nextjs_launch-editor') {
const frame = createStackFrame(searchParams);
if (!frame) return _middlewareresponse.middlewareResponse.badRequest(res);
const fileExists = await _promises.default.access(frame.file, _promises.constants.F_OK).then(()=>true, ()=>false);
if (!fileExists) return _middlewareresponse.middlewareResponse.notFound(res);
try {
var _frame_line, _frame_column;
(0, _launcheditor.launchEditor)(frame.file, (_frame_line = frame.line) != null ? _frame_line : 1, (_frame_column = frame.column) != null ? _frame_column : 1);
} catch (err) {
console.log('Failed to launch editor:', err);
return _middlewareresponse.middlewareResponse.internalServerError(res);
}
return _middlewareresponse.middlewareResponse.noContent(res);
}
return next();
};
}
function getSourceMapMiddleware(project) {
return async function(req, res, next) {
const { pathname, searchParams } = new URL(req.url, 'http://n');
if (pathname !== '/__nextjs_source-map') {
return next();
}
let filename = searchParams.get('filename');
if (!filename) {
return _middlewareresponse.middlewareResponse.badRequest(res);
}
// TODO(veil): Always try the native version first.
// Externals could also be files that aren't bundled via Webpack.
if (filename.startsWith('webpack://') || filename.startsWith('webpack-internal:///')) {
const sourceMap = (0, _nodemodule.findSourceMap)(filename);
if (sourceMap) {
return _middlewareresponse.middlewareResponse.json(res, sourceMap.payload);
}
return _middlewareresponse.middlewareResponse.noContent(res);
}
try {
// Turbopack chunk filenames might be URL-encoded.
filename = decodeURI(filename);
if (_path.default.isAbsolute(filename)) {
filename = _url.default.pathToFileURL(filename).href;
}
const sourceMapString = await project.getSourceMap(filename);
if (sourceMapString) {
return _middlewareresponse.middlewareResponse.jsonString(res, sourceMapString);
}
if (filename.startsWith('file:')) {
const sourceMap = await (0, _getsourcemapfromfile.getSourceMapFromFile)(filename);
if (sourceMap) {
return _middlewareresponse.middlewareResponse.json(res, sourceMap);
}
}
} catch (error) {
console.error('Failed to get source map:', error);
}
_middlewareresponse.middlewareResponse.noContent(res);
};
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=middleware-turbopack.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,49 @@
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser';
import { getSourceMapFromFile } from '../utils/get-source-map-from-file';
import { type OriginalStackFrameResponse } from './shared';
export { getServerError } from '../utils/node-stack-frames';
export { parseStack } from '../utils/parse-stack';
export { getSourceMapFromFile };
import type { IncomingMessage, ServerResponse } from 'http';
import type webpack from 'webpack';
import type { RawSourceMap } from 'next/dist/compiled/source-map08';
type IgnoredSources = Array<{
url: string;
ignored: boolean;
}>;
export interface IgnorableStackFrame extends StackFrame {
ignored: boolean;
}
type Source = {
type: 'file';
sourceMap: RawSourceMap;
ignoredSources: IgnoredSources;
moduleURL: string;
} | {
type: 'bundle';
sourceMap: RawSourceMap;
ignoredSources: IgnoredSources;
compilation: webpack.Compilation;
moduleId: string;
moduleURL: string;
};
export declare function getIgnoredSources(sourceMap: RawSourceMap & {
ignoreList?: number[];
}): IgnoredSources;
export declare function createOriginalStackFrame({ source, rootDirectory, frame, errorMessage, }: {
source: Source;
rootDirectory: string;
frame: StackFrame;
errorMessage?: string;
}): Promise<OriginalStackFrameResponse | null>;
export declare function getOverlayMiddleware(options: {
rootDirectory: string;
clientStats: () => webpack.Stats | null;
serverStats: () => webpack.Stats | null;
edgeServerStats: () => webpack.Stats | null;
}): (req: IncomingMessage, res: ServerResponse, next: () => void) => Promise<void>;
export declare function getSourceMapMiddleware(options: {
clientStats: () => webpack.Stats | null;
serverStats: () => webpack.Stats | null;
edgeServerStats: () => webpack.Stats | null;
}): (req: IncomingMessage, res: ServerResponse, next: () => void) => Promise<void>;

View File

@@ -0,0 +1,488 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
createOriginalStackFrame: null,
getIgnoredSources: null,
getOverlayMiddleware: null,
getServerError: null,
getSourceMapFromFile: null,
getSourceMapMiddleware: null,
parseStack: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
createOriginalStackFrame: function() {
return createOriginalStackFrame;
},
getIgnoredSources: function() {
return getIgnoredSources;
},
getOverlayMiddleware: function() {
return getOverlayMiddleware;
},
getServerError: function() {
return _nodestackframes.getServerError;
},
getSourceMapFromFile: function() {
return _getsourcemapfromfile.getSourceMapFromFile;
},
getSourceMapMiddleware: function() {
return getSourceMapMiddleware;
},
parseStack: function() {
return _parsestack.parseStack;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _fs = require("fs");
const _module = require("module");
const _path = /*#__PURE__*/ _interop_require_default._(require("path"));
const _url = require("url");
const _sourcemap08 = require("next/dist/compiled/source-map08");
const _getsourcemapfromfile = require("../utils/get-source-map-from-file");
const _launcheditor = require("../utils/launch-editor");
const _shared = require("./shared");
const _middlewareresponse = require("./middleware-response");
const _nodestackframes = require("../utils/node-stack-frames");
const _parsestack = require("../utils/parse-stack");
const _webpackmodulepath = require("../utils/webpack-module-path");
const _util = require("util");
function shouldIgnoreSource(sourceURL) {
return sourceURL.includes('node_modules') || // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo
sourceURL.includes('next/dist') || sourceURL.startsWith('node:');
}
function getModuleById(id, compilation) {
const { chunkGraph, modules } = compilation;
return [
...modules
].find((module1)=>chunkGraph.getModuleId(module1) === id);
}
function findModuleNotFoundFromError(errorMessage) {
var _errorMessage_match;
return errorMessage == null ? void 0 : (_errorMessage_match = errorMessage.match(/'([^']+)' module/)) == null ? void 0 : _errorMessage_match[1];
}
function getSourcePath(source) {
if (source.startsWith('file://')) {
return (0, _url.fileURLToPath)(source);
}
return source.replace(/^(webpack:\/\/\/|webpack:\/\/|webpack:\/\/_N_E\/)/, '');
}
/**
* @returns 1-based lines and 0-based columns
*/ async function findOriginalSourcePositionAndContent(sourceMap, position) {
let consumer;
try {
consumer = await new _sourcemap08.SourceMapConsumer(sourceMap);
} catch (cause) {
throw Object.defineProperty(new Error("" + sourceMap.file + ": Invalid source map. Only conformant source maps can be used to find the original code.", {
cause
}), "__NEXT_ERROR_CODE", {
value: "E635",
enumerable: false,
configurable: true
});
}
try {
var _position_lineNumber, _position_column;
const sourcePosition = consumer.originalPositionFor({
line: (_position_lineNumber = position.lineNumber) != null ? _position_lineNumber : 1,
// 0-based columns out requires 0-based columns in.
column: ((_position_column = position.column) != null ? _position_column : 1) - 1
});
if (!sourcePosition.source) {
return null;
}
var _consumer_sourceContentFor;
const sourceContent = (_consumer_sourceContentFor = consumer.sourceContentFor(sourcePosition.source, /* returnNullOnMissing */ true)) != null ? _consumer_sourceContentFor : null;
return {
sourcePosition,
sourceContent
};
} finally{
consumer.destroy();
}
}
function getIgnoredSources(sourceMap) {
var _sourceMap_ignoreList;
const ignoreList = new Set((_sourceMap_ignoreList = sourceMap.ignoreList) != null ? _sourceMap_ignoreList : []);
var _sourceMap_sources;
const moduleFilenames = (_sourceMap_sources = sourceMap == null ? void 0 : sourceMap.sources) != null ? _sourceMap_sources : [];
for(let index = 0; index < moduleFilenames.length; index++){
// bundlerFilePath case: webpack://./app/page.tsx
const webpackSourceURL = moduleFilenames[index];
// Format the path to the normal file path
const formattedFilePath = (0, _webpackmodulepath.formatFrameSourceFile)(webpackSourceURL);
if (shouldIgnoreSource(formattedFilePath)) {
ignoreList.add(index);
}
}
const ignoredSources = sourceMap.sources.map((source, index)=>{
var _sourceMap_sourcesContent;
var _sourceMap_sourcesContent_index;
return {
url: source,
ignored: ignoreList.has(sourceMap.sources.indexOf(source)),
content: (_sourceMap_sourcesContent_index = (_sourceMap_sourcesContent = sourceMap.sourcesContent) == null ? void 0 : _sourceMap_sourcesContent[index]) != null ? _sourceMap_sourcesContent_index : null
};
});
return ignoredSources;
}
function isIgnoredSource(source, sourcePosition) {
if (sourcePosition.source == null) {
return true;
}
for (const ignoredSource of source.ignoredSources){
if (ignoredSource.ignored && ignoredSource.url === sourcePosition.source) {
return true;
}
}
return false;
}
function findOriginalSourcePositionAndContentFromCompilation(moduleId, importedModule, compilation) {
var _module_buildInfo_importLocByPath, _module_buildInfo;
const module1 = getModuleById(moduleId, compilation);
var _module_buildInfo_importLocByPath_get;
return (_module_buildInfo_importLocByPath_get = module1 == null ? void 0 : (_module_buildInfo = module1.buildInfo) == null ? void 0 : (_module_buildInfo_importLocByPath = _module_buildInfo.importLocByPath) == null ? void 0 : _module_buildInfo_importLocByPath.get(importedModule)) != null ? _module_buildInfo_importLocByPath_get : null;
}
async function createOriginalStackFrame(param) {
let { source, rootDirectory, frame, errorMessage } = param;
var // We ignore the sourcemapped name since it won't be the correct name.
// The callsite will point to the column of the variable name instead of the
// name of the enclosing function.
// TODO(NDX-531): Spy on prepareStackTrace to get the enclosing line number for method name mapping.
// default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export
// Resolve it back to `default` for the method name if the source position didn't have the method.
_frame_methodName_replace, _frame_methodName;
const moduleNotFound = findModuleNotFoundFromError(errorMessage);
const result = await (()=>{
if (moduleNotFound) {
if (source.type === 'file') {
return undefined;
}
return findOriginalSourcePositionAndContentFromCompilation(source.moduleId, moduleNotFound, source.compilation);
}
return findOriginalSourcePositionAndContent(source.sourceMap, frame);
})();
if (!result) {
return null;
}
const { sourcePosition, sourceContent } = result;
if (!sourcePosition.source) {
return null;
}
const ignored = isIgnoredSource(source, sourcePosition) || // If the source file is externals, should be excluded even it's not ignored source.
// e.g. webpack://next/dist/.. needs to be ignored
shouldIgnoreSource(source.moduleURL);
const sourcePath = getSourcePath(// When sourcePosition.source is the loader path the modulePath is generally better.
(sourcePosition.source.includes('|') ? source.moduleURL : sourcePosition.source) || source.moduleURL);
const filePath = _path.default.resolve(rootDirectory, sourcePath);
const resolvedFilePath = _path.default.relative(rootDirectory, filePath);
var _sourcePosition_column;
const traced = {
file: resolvedFilePath,
lineNumber: sourcePosition.line,
column: ((_sourcePosition_column = sourcePosition.column) != null ? _sourcePosition_column : 0) + 1,
methodName: (_frame_methodName = frame.methodName) == null ? void 0 : (_frame_methodName_replace = _frame_methodName.replace('__WEBPACK_DEFAULT_EXPORT__', 'default')) == null ? void 0 : _frame_methodName_replace.replace('__webpack_exports__.', ''),
arguments: [],
ignored
};
return {
originalStackFrame: traced,
originalCodeFrame: (0, _shared.getOriginalCodeFrame)(traced, sourceContent)
};
}
async function getSourceMapFromCompilation(id, compilation) {
try {
const module1 = getModuleById(id, compilation);
if (!module1) {
return undefined;
}
// @ts-expect-error The types for `CodeGenerationResults.get` require a
// runtime to be passed as second argument, but apparently it also works
// without it.
const codeGenerationResult = compilation.codeGenerationResults.get(module1);
const source = codeGenerationResult == null ? void 0 : codeGenerationResult.sources.get('javascript');
var _source_map;
return (_source_map = source == null ? void 0 : source.map()) != null ? _source_map : undefined;
} catch (err) {
console.error('Failed to lookup module by ID ("' + id + '"):', err);
return undefined;
}
}
async function getSource(sourceURL, options) {
const { getCompilations } = options;
// Rspack is now using file:// URLs for source maps. Remove the rsc prefix to produce the file:/// url.
sourceURL = sourceURL.replace(/(.*)\/(?=file:\/\/)/, '');
let nativeSourceMap;
try {
nativeSourceMap = (0, _module.findSourceMap)(sourceURL);
} catch (cause) {
throw Object.defineProperty(new Error("" + sourceURL + ": Invalid source map. Only conformant source maps can be used to find the original code.", {
cause
}), "__NEXT_ERROR_CODE", {
value: "E635",
enumerable: false,
configurable: true
});
}
if (nativeSourceMap !== undefined) {
const sourceMapPayload = nativeSourceMap.payload;
return {
type: 'file',
sourceMap: sourceMapPayload,
ignoredSources: getIgnoredSources(sourceMapPayload),
moduleURL: sourceURL
};
}
if (_path.default.isAbsolute(sourceURL)) {
sourceURL = (0, _url.pathToFileURL)(sourceURL).href;
}
if (sourceURL.startsWith('file:')) {
const sourceMap = await (0, _getsourcemapfromfile.getSourceMapFromFile)(sourceURL);
return sourceMap ? {
type: 'file',
sourceMap,
ignoredSources: getIgnoredSources(sourceMap),
moduleURL: sourceURL
} : undefined;
}
// webpack-internal:///./src/hello.tsx => ./src/hello.tsx
// rsc://React/Server/webpack-internal:///(rsc)/./src/hello.tsx?42 => (rsc)/./src/hello.tsx
// webpack://_N_E/./src/hello.tsx => ./src/hello.tsx
const moduleId = sourceURL.replace(/^(rsc:\/\/React\/[^/]+\/)?(webpack-internal:\/\/\/|webpack:\/\/(_N_E\/)?)/, '').replace(/\?\d+$/, '');
// (rsc)/./src/hello.tsx => ./src/hello.tsx
const moduleURL = moduleId.replace(/^(\(.*\)\/?)/, '');
for (const compilation of getCompilations()){
const sourceMap = await getSourceMapFromCompilation(moduleId, compilation);
if (sourceMap) {
const ignoredSources = getIgnoredSources(sourceMap);
return {
type: 'bundle',
sourceMap,
compilation,
moduleId,
moduleURL,
ignoredSources
};
}
}
return undefined;
}
function getOriginalStackFrames(param) {
let { isServer, isEdgeServer, isAppDirectory, frames, clientStats, serverStats, edgeServerStats, rootDirectory } = param;
return Promise.all(frames.map((frame)=>getOriginalStackFrame({
isServer,
isEdgeServer,
isAppDirectory,
frame,
clientStats,
serverStats,
edgeServerStats,
rootDirectory
}).then((value)=>{
return {
status: 'fulfilled',
value
};
}, (reason)=>{
return {
status: 'rejected',
reason: (0, _util.inspect)(reason, {
colors: false
})
};
})));
}
async function getOriginalStackFrame(param) {
let { isServer, isEdgeServer, isAppDirectory, frame, clientStats, serverStats, edgeServerStats, rootDirectory } = param;
var _frame_file;
const filename = (_frame_file = frame.file) != null ? _frame_file : '';
const source = await getSource(filename, {
getCompilations: ()=>{
const compilations = [];
// Try Client Compilation first. In `pages` we leverage
// `isClientError` to check. In `app` it depends on if it's a server
// / client component and when the code throws. E.g. during HTML
// rendering it's the server/edge compilation.
if (!isEdgeServer && !isServer || isAppDirectory) {
var _clientStats;
const compilation = (_clientStats = clientStats()) == null ? void 0 : _clientStats.compilation;
if (compilation) {
compilations.push(compilation);
}
}
// Try Server Compilation. In `pages` this could be something
// imported in getServerSideProps/getStaticProps as the code for
// those is tree-shaken. In `app` this finds server components and
// code that was imported from a server component. It also covers
// when client component code throws during HTML rendering.
if (isServer || isAppDirectory) {
var _serverStats;
const compilation = (_serverStats = serverStats()) == null ? void 0 : _serverStats.compilation;
if (compilation) {
compilations.push(compilation);
}
}
// Try Edge Server Compilation. Both cases are the same as Server
// Compilation, main difference is that it covers `runtime: 'edge'`
// pages/app routes.
if (isEdgeServer || isAppDirectory) {
var _edgeServerStats;
const compilation = (_edgeServerStats = edgeServerStats()) == null ? void 0 : _edgeServerStats.compilation;
if (compilation) {
compilations.push(compilation);
}
}
return compilations;
}
});
let defaultNormalizedStackFrameLocation = frame.file;
if (defaultNormalizedStackFrameLocation !== null && defaultNormalizedStackFrameLocation.startsWith('file://')) {
defaultNormalizedStackFrameLocation = _path.default.relative(rootDirectory, (0, _url.fileURLToPath)(defaultNormalizedStackFrameLocation));
}
var _frame_column;
// This stack frame is used for the one that couldn't locate the source or source mapped frame
const defaultStackFrame = {
file: defaultNormalizedStackFrameLocation,
lineNumber: frame.lineNumber,
column: (_frame_column = frame.column) != null ? _frame_column : 1,
methodName: frame.methodName,
ignored: shouldIgnoreSource(filename),
arguments: []
};
if (!source) {
// return original stack frame with no source map
return {
originalStackFrame: defaultStackFrame,
originalCodeFrame: null
};
}
const originalStackFrameResponse = await createOriginalStackFrame({
frame,
source,
rootDirectory
});
if (!originalStackFrameResponse) {
return {
originalStackFrame: defaultStackFrame,
originalCodeFrame: null
};
}
return originalStackFrameResponse;
}
function getOverlayMiddleware(options) {
const { rootDirectory, clientStats, serverStats, edgeServerStats } = options;
return async function(req, res, next) {
const { pathname, searchParams } = new URL("http://n" + req.url);
if (pathname === '/__nextjs_original-stack-frames') {
if (req.method !== 'POST') {
return _middlewareresponse.middlewareResponse.badRequest(res);
}
const body = await new Promise((resolve, reject)=>{
let data = '';
req.on('data', (chunk)=>{
data += chunk;
});
req.on('end', ()=>resolve(data));
req.on('error', reject);
});
try {
const { frames, isServer, isEdgeServer, isAppDirectory } = JSON.parse(body);
return _middlewareresponse.middlewareResponse.json(res, await getOriginalStackFrames({
isServer,
isEdgeServer,
isAppDirectory,
frames: frames.map((frame)=>{
var _frame_lineNumber, _frame_column;
return {
...frame,
lineNumber: (_frame_lineNumber = frame.lineNumber) != null ? _frame_lineNumber : 0,
column: (_frame_column = frame.column) != null ? _frame_column : 0
};
}),
clientStats,
serverStats,
edgeServerStats,
rootDirectory
}));
} catch (err) {
return _middlewareresponse.middlewareResponse.badRequest(res);
}
} else if (pathname === '/__nextjs_launch-editor') {
var _searchParams_get, _searchParams_get1;
const frame = {
file: searchParams.get('file'),
methodName: searchParams.get('methodName'),
lineNumber: parseInt((_searchParams_get = searchParams.get('lineNumber')) != null ? _searchParams_get : '0', 10) || 0,
column: parseInt((_searchParams_get1 = searchParams.get('column')) != null ? _searchParams_get1 : '0', 10) || 0,
arguments: searchParams.getAll('arguments').filter(Boolean)
};
if (!frame.file) return _middlewareresponse.middlewareResponse.badRequest(res);
// frame files may start with their webpack layer, like (middleware)/middleware.js
const filePath = _path.default.resolve(rootDirectory, frame.file.replace(/^\([^)]+\)\//, ''));
const fileExists = await _fs.promises.access(filePath, _fs.constants.F_OK).then(()=>true, ()=>false);
if (!fileExists) return _middlewareresponse.middlewareResponse.notFound(res);
try {
var _frame_column;
(0, _launcheditor.launchEditor)(filePath, frame.lineNumber, (_frame_column = frame.column) != null ? _frame_column : 1);
} catch (err) {
console.log('Failed to launch editor:', err);
return _middlewareresponse.middlewareResponse.internalServerError(res);
}
return _middlewareresponse.middlewareResponse.noContent(res);
}
return next();
};
}
function getSourceMapMiddleware(options) {
const { clientStats, serverStats, edgeServerStats } = options;
return async function(req, res, next) {
const { pathname, searchParams } = new URL("http://n" + req.url);
if (pathname !== '/__nextjs_source-map') {
return next();
}
const filename = searchParams.get('filename');
if (!filename) {
return _middlewareresponse.middlewareResponse.badRequest(res);
}
let source;
try {
source = await getSource(filename, {
getCompilations: ()=>{
const compilations = [];
for (const stats of [
clientStats(),
serverStats(),
edgeServerStats()
]){
if (stats == null ? void 0 : stats.compilation) {
compilations.push(stats.compilation);
}
}
return compilations;
}
});
} catch (error) {
return _middlewareresponse.middlewareResponse.internalServerError(res, error);
}
if (!source) {
return _middlewareresponse.middlewareResponse.noContent(res);
}
return _middlewareresponse.middlewareResponse.json(res, source.sourceMap);
};
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=middleware-webpack.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
import type { StackFrame } from 'stacktrace-parser';
export interface OriginalStackFramesRequest {
frames: StackFrame[];
isServer: boolean;
isEdgeServer: boolean;
isAppDirectory: boolean;
}
export type OriginalStackFramesResponse = OriginalStackFrameResponseResult[];
export type OriginalStackFrameResponseResult = PromiseSettledResult<OriginalStackFrameResponse>;
export interface OriginalStackFrameResponse {
originalStackFrame?: (StackFrame & {
ignored: boolean;
}) | null;
originalCodeFrame?: string | null;
}
/**
* It looks up the code frame of the traced source.
* @note It ignores Next.js/React internals, as these can often be huge bundled files.
*/
export declare function getOriginalCodeFrame(frame: StackFrame, source: string | null, colors?: boolean): string | null;

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getOriginalCodeFrame", {
enumerable: true,
get: function() {
return getOriginalCodeFrame;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _codeframe = require("next/dist/compiled/babel/code-frame");
const _isinternal = /*#__PURE__*/ _interop_require_default._(require("../../../../shared/lib/is-internal"));
function getOriginalCodeFrame(frame, source, colors) {
if (colors === void 0) colors = process.stdout.isTTY;
if (!source || (0, _isinternal.default)(frame.file)) {
return null;
}
var _frame_lineNumber, _frame_column;
return (0, _codeframe.codeFrameColumns)(source, {
start: {
// 1-based, but -1 means start line without highlighting
line: (_frame_lineNumber = frame.lineNumber) != null ? _frame_lineNumber : -1,
// 1-based, but 0 means whole line without column highlighting
column: (_frame_column = frame.column) != null ? _frame_column : 0
}
}, {
forceColor: colors
});
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=shared.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/shared.ts"],"sourcesContent":["import type { StackFrame } from 'stacktrace-parser'\nimport { codeFrameColumns } from 'next/dist/compiled/babel/code-frame'\nimport isInternal from '../../../../shared/lib/is-internal'\n\nexport interface OriginalStackFramesRequest {\n frames: StackFrame[]\n isServer: boolean\n isEdgeServer: boolean\n isAppDirectory: boolean\n}\n\nexport type OriginalStackFramesResponse = OriginalStackFrameResponseResult[]\n\nexport type OriginalStackFrameResponseResult =\n PromiseSettledResult<OriginalStackFrameResponse>\n\nexport interface OriginalStackFrameResponse {\n originalStackFrame?: (StackFrame & { ignored: boolean }) | null\n originalCodeFrame?: string | null\n}\n\n/**\n * It looks up the code frame of the traced source.\n * @note It ignores Next.js/React internals, as these can often be huge bundled files.\n */\nexport function getOriginalCodeFrame(\n frame: StackFrame,\n source: string | null,\n colors: boolean = process.stdout.isTTY\n): string | null {\n if (!source || isInternal(frame.file)) {\n return null\n }\n\n return codeFrameColumns(\n source,\n {\n start: {\n // 1-based, but -1 means start line without highlighting\n line: frame.lineNumber ?? -1,\n // 1-based, but 0 means whole line without column highlighting\n column: frame.column ?? 0,\n },\n },\n { forceColor: colors }\n )\n}\n"],"names":["getOriginalCodeFrame","frame","source","colors","process","stdout","isTTY","isInternal","file","codeFrameColumns","start","line","lineNumber","column","forceColor"],"mappings":";;;;+BAyBgBA;;;eAAAA;;;;2BAxBiB;qEACV;AAuBhB,SAASA,qBACdC,KAAiB,EACjBC,MAAqB,EACrBC,MAAsC;IAAtCA,IAAAA,mBAAAA,SAAkBC,QAAQC,MAAM,CAACC,KAAK;IAEtC,IAAI,CAACJ,UAAUK,IAAAA,mBAAU,EAACN,MAAMO,IAAI,GAAG;QACrC,OAAO;IACT;QAOYP,mBAEEA;IAPd,OAAOQ,IAAAA,2BAAgB,EACrBP,QACA;QACEQ,OAAO;YACL,wDAAwD;YACxDC,MAAMV,CAAAA,oBAAAA,MAAMW,UAAU,YAAhBX,oBAAoB,CAAC;YAC3B,8DAA8D;YAC9DY,QAAQZ,CAAAA,gBAAAA,MAAMY,MAAM,YAAZZ,gBAAgB;QAC1B;IACF,GACA;QAAEa,YAAYX;IAAO;AAEzB"}