Initial boiler plate project
This commit is contained in:
11
node_modules/next/dist/client/components/react-dev-overlay/server/middleware-turbopack.d.ts
generated
vendored
Normal file
11
node_modules/next/dist/client/components/react-dev-overlay/server/middleware-turbopack.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/// <reference types="node" />
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import { type OriginalStackFrameResponse } from './shared';
|
||||
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser';
|
||||
import type { Project, TurbopackStackFrame } from '../../../../build/swc';
|
||||
export declare function batchedTraceSource(project: Project, frame: TurbopackStackFrame): Promise<{
|
||||
frame: StackFrame;
|
||||
source: string | null;
|
||||
} | undefined>;
|
||||
export declare function createOriginalStackFrame(project: Project, frame: TurbopackStackFrame): Promise<OriginalStackFrameResponse | null>;
|
||||
export declare function getOverlayMiddleware(project: Project): (req: IncomingMessage, res: ServerResponse) => Promise<void | ServerResponse<IncomingMessage>>;
|
||||
124
node_modules/next/dist/client/components/react-dev-overlay/server/middleware-turbopack.js
generated
vendored
Normal file
124
node_modules/next/dist/client/components/react-dev-overlay/server/middleware-turbopack.js
generated
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
batchedTraceSource: null,
|
||||
createOriginalStackFrame: null,
|
||||
getOverlayMiddleware: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
batchedTraceSource: function() {
|
||||
return batchedTraceSource;
|
||||
},
|
||||
createOriginalStackFrame: function() {
|
||||
return createOriginalStackFrame;
|
||||
},
|
||||
getOverlayMiddleware: function() {
|
||||
return getOverlayMiddleware;
|
||||
}
|
||||
});
|
||||
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
||||
const _shared = require("./shared");
|
||||
const _promises = /*#__PURE__*/ _interop_require_wildcard._(require("fs/promises"));
|
||||
const _launchEditor = require("../internal/helpers/launchEditor");
|
||||
const currentSourcesByFile = new Map();
|
||||
async function batchedTraceSource(project, frame) {
|
||||
const file = frame.file ? decodeURIComponent(frame.file) : undefined;
|
||||
if (!file) return;
|
||||
const sourceFrame = await project.traceSource(frame);
|
||||
if (!sourceFrame) return;
|
||||
let source = null;
|
||||
// Don't look up source for node_modules or internals. These can often be large bundled files.
|
||||
if (sourceFrame.file && !(sourceFrame.file.includes("node_modules") || sourceFrame.isInternal)) {
|
||||
let sourcePromise = currentSourcesByFile.get(sourceFrame.file);
|
||||
if (!sourcePromise) {
|
||||
sourcePromise = project.getSourceForAsset(sourceFrame.file);
|
||||
currentSourcesByFile.set(sourceFrame.file, sourcePromise);
|
||||
setTimeout(()=>{
|
||||
// Cache file reads for 100ms, as frames will often reference the same
|
||||
// files and can be large.
|
||||
currentSourcesByFile.delete(sourceFrame.file);
|
||||
}, 100);
|
||||
}
|
||||
source = await sourcePromise;
|
||||
}
|
||||
var _sourceFrame_line, _sourceFrame_column, _sourceFrame_methodName, _ref;
|
||||
return {
|
||||
frame: {
|
||||
file: sourceFrame.file,
|
||||
lineNumber: (_sourceFrame_line = sourceFrame.line) != null ? _sourceFrame_line : 0,
|
||||
column: (_sourceFrame_column = sourceFrame.column) != null ? _sourceFrame_column : 0,
|
||||
methodName: (_ref = (_sourceFrame_methodName = sourceFrame.methodName) != null ? _sourceFrame_methodName : frame.methodName) != null ? _ref : "<unknown>",
|
||||
arguments: []
|
||||
},
|
||||
source
|
||||
};
|
||||
}
|
||||
async function createOriginalStackFrame(project, frame) {
|
||||
const traced = await batchedTraceSource(project, frame);
|
||||
if (!traced) {
|
||||
const sourcePackage = (0, _shared.findSourcePackage)(frame);
|
||||
if (sourcePackage) return {
|
||||
sourcePackage
|
||||
};
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
originalStackFrame: traced.frame,
|
||||
originalCodeFrame: (0, _shared.getOriginalCodeFrame)(traced.frame, traced.source),
|
||||
sourcePackage: (0, _shared.findSourcePackage)(traced.frame)
|
||||
};
|
||||
}
|
||||
function getOverlayMiddleware(project) {
|
||||
return async function(req, res) {
|
||||
const { pathname, searchParams } = new URL(req.url, "http://n");
|
||||
var _searchParams_get, _searchParams_get1, _searchParams_get2;
|
||||
const frame = {
|
||||
file: searchParams.get("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"
|
||||
};
|
||||
if (pathname === "/__nextjs_original-stack-frame") {
|
||||
let originalStackFrame;
|
||||
try {
|
||||
originalStackFrame = await createOriginalStackFrame(project, frame);
|
||||
} catch (e) {
|
||||
return (0, _shared.internalServerError)(res, e.message);
|
||||
}
|
||||
if (!originalStackFrame) {
|
||||
res.statusCode = 404;
|
||||
return res.end("Unable to resolve sourcemap");
|
||||
}
|
||||
return (0, _shared.json)(res, originalStackFrame);
|
||||
} else if (pathname === "/__nextjs_launch-editor") {
|
||||
if (!frame.file) return (0, _shared.badRequest)(res);
|
||||
const fileExists = await _promises.default.access(frame.file, _promises.constants.F_OK).then(()=>true, ()=>false);
|
||||
if (!fileExists) return (0, _shared.noContent)(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 (0, _shared.internalServerError)(res);
|
||||
}
|
||||
(0, _shared.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
|
||||
1
node_modules/next/dist/client/components/react-dev-overlay/server/middleware-turbopack.js.map
generated
vendored
Normal file
1
node_modules/next/dist/client/components/react-dev-overlay/server/middleware-turbopack.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/middleware-turbopack.ts"],"names":["batchedTraceSource","createOriginalStackFrame","getOverlayMiddleware","currentSourcesByFile","Map","project","frame","file","decodeURIComponent","undefined","sourceFrame","traceSource","source","includes","isInternal","sourcePromise","get","getSourceForAsset","set","setTimeout","delete","lineNumber","line","column","methodName","arguments","traced","sourcePackage","findSourcePackage","originalStackFrame","originalCodeFrame","getOriginalCodeFrame","req","res","pathname","searchParams","URL","url","parseInt","isServer","e","internalServerError","message","statusCode","end","json","badRequest","fileExists","fs","access","FS","F_OK","then","noContent","launchEditor","err","console","log"],"mappings":";;;;;;;;;;;;;;;;IAiBsBA,kBAAkB;eAAlBA;;IA0CAC,wBAAwB;eAAxBA;;IAkBNC,oBAAoB;eAApBA;;;;wBApET;oEAE6B;8BACP;AAI7B,MAAMC,uBAA4D,IAAIC;AAC/D,eAAeJ,mBACpBK,OAAgB,EAChBC,KAA0B;IAE1B,MAAMC,OAAOD,MAAMC,IAAI,GAAGC,mBAAmBF,MAAMC,IAAI,IAAIE;IAC3D,IAAI,CAACF,MAAM;IAEX,MAAMG,cAAc,MAAML,QAAQM,WAAW,CAACL;IAC9C,IAAI,CAACI,aAAa;IAElB,IAAIE,SAAS;IACb,8FAA8F;IAC9F,IACEF,YAAYH,IAAI,IAChB,CAAEG,CAAAA,YAAYH,IAAI,CAACM,QAAQ,CAAC,mBAAmBH,YAAYI,UAAU,AAAD,GACpE;QAC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4BF;gBACxC,OAAOd,IAAAA,2BAAmB,EAACR;YAC7B;YAEAoB,IAAAA,iBAAS,EAACpB;QACZ;IACF;AACF"}
|
||||
25
node_modules/next/dist/client/components/react-dev-overlay/server/middleware.d.ts
generated
vendored
Normal file
25
node_modules/next/dist/client/components/react-dev-overlay/server/middleware.d.ts
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser';
|
||||
import { type OriginalStackFrameResponse } from './shared';
|
||||
export { getServerError } from '../internal/helpers/nodeStackFrames';
|
||||
export { parseStack } from '../internal/helpers/parseStack';
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import type webpack from 'webpack';
|
||||
type Source = {
|
||||
map: () => any;
|
||||
} | null;
|
||||
export declare function createOriginalStackFrame({ source, moduleId, modulePath, rootDirectory, frame, errorMessage, compilation, }: {
|
||||
source: any;
|
||||
moduleId?: string;
|
||||
modulePath?: string;
|
||||
rootDirectory: string;
|
||||
frame: StackFrame;
|
||||
errorMessage?: string;
|
||||
compilation?: webpack.Compilation;
|
||||
}): Promise<OriginalStackFrameResponse | null>;
|
||||
export declare function getSourceById(isFile: boolean, id: string, compilation?: webpack.Compilation): Promise<Source>;
|
||||
export declare function getOverlayMiddleware(options: {
|
||||
rootDirectory: string;
|
||||
stats(): webpack.Stats | null;
|
||||
serverStats(): webpack.Stats | null;
|
||||
edgeServerStats(): webpack.Stats | null;
|
||||
}): (req: IncomingMessage, res: ServerResponse, next: Function) => Promise<any>;
|
||||
263
node_modules/next/dist/client/components/react-dev-overlay/server/middleware.js
generated
vendored
Normal file
263
node_modules/next/dist/client/components/react-dev-overlay/server/middleware.js
generated
vendored
Normal file
@ -0,0 +1,263 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
createOriginalStackFrame: null,
|
||||
getOverlayMiddleware: null,
|
||||
getServerError: null,
|
||||
getSourceById: 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;
|
||||
},
|
||||
getOverlayMiddleware: function() {
|
||||
return getOverlayMiddleware;
|
||||
},
|
||||
getServerError: function() {
|
||||
return _nodeStackFrames.getServerError;
|
||||
},
|
||||
getSourceById: function() {
|
||||
return getSourceById;
|
||||
},
|
||||
parseStack: function() {
|
||||
return _parseStack.parseStack;
|
||||
}
|
||||
});
|
||||
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
||||
const _fs = require("fs");
|
||||
const _path = /*#__PURE__*/ _interop_require_default._(require("path"));
|
||||
const _sourcemap08 = require("next/dist/compiled/source-map08");
|
||||
const _getRawSourceMap = require("../internal/helpers/getRawSourceMap");
|
||||
const _launchEditor = require("../internal/helpers/launchEditor");
|
||||
const _shared = require("./shared");
|
||||
const _nodeStackFrames = require("../internal/helpers/nodeStackFrames");
|
||||
const _parseStack = require("../internal/helpers/parseStack");
|
||||
function getModuleId(compilation, module1) {
|
||||
return compilation.chunkGraph.getModuleId(module1);
|
||||
}
|
||||
function getModuleById(id, compilation) {
|
||||
return [
|
||||
...compilation.modules
|
||||
].find((searchModule)=>getModuleId(compilation, searchModule) === id);
|
||||
}
|
||||
function findModuleNotFoundFromError(errorMessage) {
|
||||
var _errorMessage_match;
|
||||
return errorMessage == null ? void 0 : (_errorMessage_match = errorMessage.match(/'([^']+)' module/)) == null ? void 0 : _errorMessage_match[1];
|
||||
}
|
||||
function getModuleSource(compilation, module1) {
|
||||
var _compilation_codeGenerationResults_get;
|
||||
if (!module1) return null;
|
||||
var _compilation_codeGenerationResults_get_sources_get;
|
||||
return (_compilation_codeGenerationResults_get_sources_get = (_compilation_codeGenerationResults_get = compilation.codeGenerationResults.get(module1)) == null ? void 0 : _compilation_codeGenerationResults_get.sources.get("javascript")) != null ? _compilation_codeGenerationResults_get_sources_get : null;
|
||||
}
|
||||
function getSourcePath(source) {
|
||||
return source.replace(/^(webpack:\/\/\/|webpack:\/\/|webpack:\/\/_N_E\/)/, "");
|
||||
}
|
||||
async function findOriginalSourcePositionAndContent(webpackSource, position) {
|
||||
const consumer = await new _sourcemap08.SourceMapConsumer(webpackSource.map());
|
||||
try {
|
||||
var _position_column;
|
||||
const sourcePosition = consumer.originalPositionFor({
|
||||
line: position.line,
|
||||
column: (_position_column = position.column) != null ? _position_column : 0
|
||||
});
|
||||
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 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, moduleId, modulePath, rootDirectory, frame, errorMessage, compilation } = param;
|
||||
var // 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 { lineNumber, column } = frame;
|
||||
const moduleNotFound = findModuleNotFoundFromError(errorMessage);
|
||||
const result = await (async ()=>{
|
||||
if (moduleNotFound) {
|
||||
if (!compilation) return null;
|
||||
return findOriginalSourcePositionAndContentFromCompilation(moduleId, moduleNotFound, compilation);
|
||||
}
|
||||
// This returns 1-based lines and 0-based columns
|
||||
return await findOriginalSourcePositionAndContent(source, {
|
||||
line: lineNumber != null ? lineNumber : 1,
|
||||
column
|
||||
});
|
||||
})();
|
||||
if (!(result == null ? void 0 : result.sourcePosition.source)) return null;
|
||||
const { sourcePosition, sourceContent } = result;
|
||||
const filePath = _path.default.resolve(rootDirectory, getSourcePath(// When sourcePosition.source is the loader path the modulePath is generally better.
|
||||
(sourcePosition.source.includes("|") ? modulePath : sourcePosition.source) || modulePath));
|
||||
var _sourcePosition_column;
|
||||
const traced = {
|
||||
file: sourceContent ? _path.default.relative(rootDirectory, filePath) : sourcePosition.source,
|
||||
lineNumber: sourcePosition.line,
|
||||
column: ((_sourcePosition_column = sourcePosition.column) != null ? _sourcePosition_column : 0) + 1,
|
||||
methodName: sourcePosition.name || ((_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: []
|
||||
};
|
||||
return {
|
||||
originalStackFrame: traced,
|
||||
originalCodeFrame: (0, _shared.getOriginalCodeFrame)(traced, sourceContent),
|
||||
sourcePackage: (0, _shared.findSourcePackage)(traced)
|
||||
};
|
||||
}
|
||||
async function getSourceById(isFile, id, compilation) {
|
||||
if (isFile) {
|
||||
const fileContent = await _fs.promises.readFile(id, "utf-8").catch(()=>null);
|
||||
if (fileContent == null) {
|
||||
return null;
|
||||
}
|
||||
const map = (0, _getRawSourceMap.getRawSourceMap)(fileContent);
|
||||
if (map == null) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
map () {
|
||||
return map;
|
||||
}
|
||||
};
|
||||
}
|
||||
try {
|
||||
if (!compilation) {
|
||||
return null;
|
||||
}
|
||||
const module1 = getModuleById(id, compilation);
|
||||
const moduleSource = getModuleSource(compilation, module1);
|
||||
return moduleSource;
|
||||
} catch (err) {
|
||||
console.error('Failed to lookup module by ID ("' + id + '"):', err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function getOverlayMiddleware(options) {
|
||||
return async function(req, res, next) {
|
||||
const { pathname, searchParams } = new URL("http://n" + req.url);
|
||||
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)
|
||||
};
|
||||
const isServer = searchParams.get("isServer") === "true";
|
||||
const isEdgeServer = searchParams.get("isEdgeServer") === "true";
|
||||
const isAppDirectory = searchParams.get("isAppDirectory") === "true";
|
||||
if (pathname === "/__nextjs_original-stack-frame") {
|
||||
const isClient = !isServer && !isEdgeServer;
|
||||
let sourcePackage = (0, _shared.findSourcePackage)(frame);
|
||||
if (!(/^(webpack-internal:\/\/\/|(file|webpack):\/\/)/.test(frame.file) && frame.lineNumber)) {
|
||||
if (sourcePackage) return (0, _shared.json)(res, {
|
||||
sourcePackage
|
||||
});
|
||||
return (0, _shared.badRequest)(res);
|
||||
}
|
||||
const moduleId = frame.file.replace(/^(webpack-internal:\/\/\/|file:\/\/|webpack:\/\/(_N_E\/)?)/, "");
|
||||
const modulePath = frame.file.replace(/^(webpack-internal:\/\/\/|file:\/\/|webpack:\/\/(_N_E\/)?)(\(.*\)\/?)/, "");
|
||||
let source = null;
|
||||
let compilation;
|
||||
const isFile = frame.file.startsWith("file:");
|
||||
try {
|
||||
if (isClient || isAppDirectory) {
|
||||
var _options_stats;
|
||||
compilation = (_options_stats = options.stats()) == null ? void 0 : _options_stats.compilation;
|
||||
// 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.
|
||||
source = await getSourceById(isFile, moduleId, 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) && source === null) {
|
||||
var _options_serverStats;
|
||||
compilation = (_options_serverStats = options.serverStats()) == null ? void 0 : _options_serverStats.compilation;
|
||||
source = await getSourceById(isFile, moduleId, 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) && source === null) {
|
||||
var _options_edgeServerStats;
|
||||
compilation = (_options_edgeServerStats = options.edgeServerStats()) == null ? void 0 : _options_edgeServerStats.compilation;
|
||||
source = await getSourceById(isFile, moduleId, compilation);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log("Failed to get source map:", err);
|
||||
return (0, _shared.internalServerError)(res);
|
||||
}
|
||||
if (!source) {
|
||||
if (sourcePackage) return (0, _shared.json)(res, {
|
||||
sourcePackage
|
||||
});
|
||||
return (0, _shared.noContent)(res);
|
||||
}
|
||||
try {
|
||||
const originalStackFrameResponse = await createOriginalStackFrame({
|
||||
frame,
|
||||
source,
|
||||
moduleId,
|
||||
modulePath,
|
||||
rootDirectory: options.rootDirectory,
|
||||
compilation
|
||||
});
|
||||
if (originalStackFrameResponse === null) {
|
||||
if (sourcePackage) return (0, _shared.json)(res, {
|
||||
sourcePackage
|
||||
});
|
||||
return (0, _shared.noContent)(res);
|
||||
}
|
||||
return (0, _shared.json)(res, originalStackFrameResponse);
|
||||
} catch (err) {
|
||||
console.log("Failed to parse source map:", err);
|
||||
return (0, _shared.internalServerError)(res);
|
||||
}
|
||||
} else if (pathname === "/__nextjs_launch-editor") {
|
||||
if (!frame.file) return (0, _shared.badRequest)(res);
|
||||
// frame files may start with their webpack layer, like (middleware)/middleware.js
|
||||
const filePath = _path.default.resolve(options.rootDirectory, frame.file.replace(/^\([^)]+\)\//, ""));
|
||||
const fileExists = await _fs.promises.access(filePath, _fs.constants.F_OK).then(()=>true, ()=>false);
|
||||
if (!fileExists) return (0, _shared.noContent)(res);
|
||||
try {
|
||||
var _frame_column;
|
||||
await (0, _launchEditor.launchEditor)(filePath, frame.lineNumber, (_frame_column = frame.column) != null ? _frame_column : 1);
|
||||
} catch (err) {
|
||||
console.log("Failed to launch editor:", err);
|
||||
return (0, _shared.internalServerError)(res);
|
||||
}
|
||||
return (0, _shared.noContent)(res);
|
||||
}
|
||||
return next();
|
||||
};
|
||||
}
|
||||
|
||||
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.js.map
|
||||
1
node_modules/next/dist/client/components/react-dev-overlay/server/middleware.js.map
generated
vendored
Normal file
1
node_modules/next/dist/client/components/react-dev-overlay/server/middleware.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
24
node_modules/next/dist/client/components/react-dev-overlay/server/shared.d.ts
generated
vendored
Normal file
24
node_modules/next/dist/client/components/react-dev-overlay/server/shared.d.ts
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
/// <reference types="node" />
|
||||
import type { StackFrame } from 'stacktrace-parser';
|
||||
import type { ServerResponse } from 'http';
|
||||
export type SourcePackage = 'react' | 'next';
|
||||
export interface OriginalStackFrameResponse {
|
||||
originalStackFrame?: StackFrame | null;
|
||||
originalCodeFrame?: string | null;
|
||||
/** We use this to group frames in the error overlay */
|
||||
sourcePackage?: SourcePackage | null;
|
||||
}
|
||||
/** Given a frame, it parses which package it belongs to. */
|
||||
export declare function findSourcePackage({ file, methodName, }: Partial<{
|
||||
file: string | null;
|
||||
methodName: string | null;
|
||||
}>): SourcePackage | undefined;
|
||||
/**
|
||||
* It looks up the code frame of the traced source.
|
||||
* @note It ignores node_modules or Next.js/React internals, as these can often be huge budnled files.
|
||||
*/
|
||||
export declare function getOriginalCodeFrame(frame: StackFrame, source: string | null): string | null | undefined;
|
||||
export declare function noContent(res: ServerResponse): void;
|
||||
export declare function badRequest(res: ServerResponse): void;
|
||||
export declare function internalServerError(res: ServerResponse, e?: any): void;
|
||||
export declare function json(res: ServerResponse, data: any): void;
|
||||
103
node_modules/next/dist/client/components/react-dev-overlay/server/shared.js
generated
vendored
Normal file
103
node_modules/next/dist/client/components/react-dev-overlay/server/shared.js
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
badRequest: null,
|
||||
findSourcePackage: null,
|
||||
getOriginalCodeFrame: null,
|
||||
internalServerError: null,
|
||||
json: null,
|
||||
noContent: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
badRequest: function() {
|
||||
return badRequest;
|
||||
},
|
||||
findSourcePackage: function() {
|
||||
return findSourcePackage;
|
||||
},
|
||||
getOriginalCodeFrame: function() {
|
||||
return getOriginalCodeFrame;
|
||||
},
|
||||
internalServerError: function() {
|
||||
return internalServerError;
|
||||
},
|
||||
json: function() {
|
||||
return json;
|
||||
},
|
||||
noContent: function() {
|
||||
return noContent;
|
||||
}
|
||||
});
|
||||
const _codeframe = require("next/dist/compiled/babel/code-frame");
|
||||
/** React that's compiled with `next`. Used by App Router. */ const reactVendoredRe = /[\\/]next[\\/]dist[\\/]compiled[\\/](react|react-dom|react-server-dom-(webpack|turbopack)|scheduler)[\\/]/;
|
||||
/** React the user installed. Used by Pages Router, or user imports in App Router. */ const reactNodeModulesRe = /node_modules[\\/](react|react-dom|scheduler)[\\/]/;
|
||||
const nextInternalsRe = /(node_modules[\\/]next[\\/]|[\\/].next[\\/]static[\\/]chunks[\\/]webpack\.js$|(edge-runtime-webpack|webpack-runtime)\.js$)/;
|
||||
const nextMethodRe = /(^__webpack_.*|node_modules[\\/]next[\\/])/;
|
||||
function isInternal(file) {
|
||||
if (!file) return false;
|
||||
return nextInternalsRe.test(file) || reactVendoredRe.test(file) || reactNodeModulesRe.test(file);
|
||||
}
|
||||
function findSourcePackage(param) {
|
||||
let { file, methodName } = param;
|
||||
if (file) {
|
||||
// matching React first since vendored would match under `next` too
|
||||
if (reactVendoredRe.test(file) || reactNodeModulesRe.test(file)) {
|
||||
return "react";
|
||||
} else if (nextInternalsRe.test(file)) {
|
||||
return "next";
|
||||
}
|
||||
}
|
||||
if (methodName) {
|
||||
if (nextMethodRe.test(methodName)) {
|
||||
return "next";
|
||||
}
|
||||
}
|
||||
}
|
||||
function getOriginalCodeFrame(frame, source) {
|
||||
var _frame_file;
|
||||
if (!source || ((_frame_file = frame.file) == null ? void 0 : _frame_file.includes("node_modules")) || isInternal(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: true
|
||||
});
|
||||
}
|
||||
function noContent(res) {
|
||||
res.statusCode = 204;
|
||||
res.end("No Content");
|
||||
}
|
||||
function badRequest(res) {
|
||||
res.statusCode = 400;
|
||||
res.end("Bad Request");
|
||||
}
|
||||
function internalServerError(res, e) {
|
||||
res.statusCode = 500;
|
||||
res.end(e != null ? e : "Internal Server Error");
|
||||
}
|
||||
function json(res, data) {
|
||||
res.setHeader("Content-Type", "application/json").end(Buffer.from(JSON.stringify(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=shared.js.map
|
||||
1
node_modules/next/dist/client/components/react-dev-overlay/server/shared.js.map
generated
vendored
Normal file
1
node_modules/next/dist/client/components/react-dev-overlay/server/shared.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/server/shared.ts"],"names":["badRequest","findSourcePackage","getOriginalCodeFrame","internalServerError","json","noContent","reactVendoredRe","reactNodeModulesRe","nextInternalsRe","nextMethodRe","isInternal","file","test","methodName","frame","source","includes","codeFrameColumns","start","line","lineNumber","column","forceColor","res","statusCode","end","e","data","setHeader","Buffer","from","JSON","stringify"],"mappings":";;;;;;;;;;;;;;;;;;;IA6FgBA,UAAU;eAAVA;;IAzDAC,iBAAiB;eAAjBA;;IA0BAC,oBAAoB;eAApBA;;IAoCAC,mBAAmB;eAAnBA;;IAKAC,IAAI;eAAJA;;IAfAC,SAAS;eAATA;;;2BAtFiB;AAWjC,2DAA2D,GAC3D,MAAMC,kBACJ;AAEF,mFAAmF,GACnF,MAAMC,qBAAqB;AAE3B,MAAMC,kBACJ;AAEF,MAAMC,eAAe;AAErB,SAASC,WAAWC,IAAmB;IACrC,IAAI,CAACA,MAAM,OAAO;IAElB,OACEH,gBAAgBI,IAAI,CAACD,SACrBL,gBAAgBM,IAAI,CAACD,SACrBJ,mBAAmBK,IAAI,CAACD;AAE5B;AAGO,SAASV,kBAAkB,KAG4B;IAH5B,IAAA,EAChCU,IAA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