Initial boiler plate project

This commit is contained in:
2024-09-24 03:52:46 +00:00
parent 6120b2d6c3
commit 154b93e267
10034 changed files with 2079352 additions and 2 deletions

View File

@ -0,0 +1 @@
export default function formatWebpackMessages(json: any, verbose?: boolean): any;

View File

@ -0,0 +1,164 @@
/**
MIT License
Copyright (c) 2015-present, Facebook, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return formatWebpackMessages;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _stripansi = /*#__PURE__*/ _interop_require_default._(require("next/dist/compiled/strip-ansi"));
// This file is based on https://github.com/facebook/create-react-app/blob/7b1a32be6ec9f99a6c9a3c66813f3ac09c4736b9/packages/react-dev-utils/formatWebpackMessages.js
// It's been edited to remove chalk and CRA-specific logic
const friendlySyntaxErrorLabel = "Syntax error:";
const WEBPACK_BREAKING_CHANGE_POLYFILLS = "\n\nBREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.";
function isLikelyASyntaxError(message) {
return (0, _stripansi.default)(message).includes(friendlySyntaxErrorLabel);
}
let hadMissingSassError = false;
// Cleans up webpack error messages.
function formatMessage(message, verbose, importTraceNote) {
// TODO: Replace this once webpack 5 is stable
if (typeof message === "object" && message.message) {
const filteredModuleTrace = message.moduleTrace && message.moduleTrace.filter((trace)=>!/next-(middleware|client-pages|route|edge-function)-loader\.js/.test(trace.originName));
let body = message.message;
const breakingChangeIndex = body.indexOf(WEBPACK_BREAKING_CHANGE_POLYFILLS);
if (breakingChangeIndex >= 0) {
body = body.slice(0, breakingChangeIndex);
}
message = (message.moduleName ? (0, _stripansi.default)(message.moduleName) + "\n" : "") + (message.file ? (0, _stripansi.default)(message.file) + "\n" : "") + body + (message.details && verbose ? "\n" + message.details : "") + (filteredModuleTrace && filteredModuleTrace.length ? (importTraceNote || "\n\nImport trace for requested module:") + filteredModuleTrace.map((trace)=>"\n" + trace.moduleName).join("") : "") + (message.stack && verbose ? "\n" + message.stack : "");
}
let lines = message.split("\n");
// Strip Webpack-added headers off errors/warnings
// https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
lines = lines.filter((line)=>!/Module [A-z ]+\(from/.test(line));
// Transform parsing error into syntax error
// TODO: move this to our ESLint formatter?
lines = lines.map((line)=>{
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
if (!parsingError) {
return line;
}
const [, errorLine, errorColumn, errorMessage] = parsingError;
return friendlySyntaxErrorLabel + " " + errorMessage + " (" + errorLine + ":" + errorColumn + ")";
});
message = lines.join("\n");
// Smoosh syntax errors (commonly found in CSS)
message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, "" + friendlySyntaxErrorLabel + " $3 ($1:$2)\n");
// Clean up export errors
message = message.replace(/^.*export '(.+?)' was not found in '(.+?)'.*$/gm, "Attempted import error: '$1' is not exported from '$2'.");
message = message.replace(/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, "Attempted import error: '$2' does not contain a default export (imported as '$1').");
message = message.replace(/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, "Attempted import error: '$1' is not exported from '$3' (imported as '$2').");
lines = message.split("\n");
// Remove leading newline
if (lines.length > 2 && lines[1].trim() === "") {
lines.splice(1, 1);
}
// Cleans up verbose "module not found" messages for files and packages.
if (lines[1] && lines[1].indexOf("Module not found: ") === 0) {
lines = [
lines[0],
lines[1].replace("Error: ", "").replace("Module not found: Cannot find file:", "Cannot find file:"),
...lines.slice(2)
];
}
// Add helpful message for users trying to use Sass for the first time
if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
// ./file.module.scss (<<loader info>>) => ./file.module.scss
const firstLine = lines[0].split("!");
lines[0] = firstLine[firstLine.length - 1];
lines[1] = "To use Next.js' built-in Sass support, you first need to install `sass`.\n";
lines[1] += "Run `npm i sass` or `yarn add sass` inside your workspace.\n";
lines[1] += "\nLearn more: https://nextjs.org/docs/messages/install-sass";
// dispose of unhelpful stack trace
lines = lines.slice(0, 2);
hadMissingSassError = true;
} else if (hadMissingSassError && message.match(/(sass-loader|resolve-url-loader: CSS error)/)) {
// dispose of unhelpful stack trace following missing sass module
lines = [];
}
if (!verbose) {
message = lines.join("\n");
// Internal stacks are generally useless so we strip them... with the
// exception of stacks containing `webpack:` because they're normally
// from user code generated by Webpack. For more information see
// https://github.com/facebook/create-react-app/pull/1050
message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, "") // at ... ...:x:y
;
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "") // at <anonymous>
;
message = message.replace(/File was processed with these loaders:\n(.+[\\/](next[\\/]dist[\\/].+|@next[\\/]react-refresh-utils[\\/]loader)\.js\n)*You may need an additional loader to handle the result of these loaders.\n/g, "");
lines = message.split("\n");
}
// Remove duplicated newlines
lines = lines.filter((line, index, arr)=>index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim());
// Reassemble the message
message = lines.join("\n");
return message.trim();
}
function formatWebpackMessages(json, verbose) {
const formattedErrors = json.errors.map((message)=>{
const isUnknownNextFontError = message.message.includes("An error occurred in `next/font`.");
return formatMessage(message, isUnknownNextFontError || verbose);
});
const formattedWarnings = json.warnings.map((message)=>{
return formatMessage(message, verbose);
});
// Reorder errors to put the most relevant ones first.
let reactServerComponentsError = -1;
for(let i = 0; i < formattedErrors.length; i++){
const error = formattedErrors[i];
if (error.includes("ReactServerComponentsError")) {
reactServerComponentsError = i;
break;
}
}
// Move the reactServerComponentsError to the top if it exists
if (reactServerComponentsError !== -1) {
const error = formattedErrors.splice(reactServerComponentsError, 1);
formattedErrors.unshift(error[0]);
}
const result = {
...json,
errors: formattedErrors,
warnings: formattedWarnings
};
if (!verbose && result.errors.some(isLikelyASyntaxError)) {
// If there are any syntax errors, show just them.
result.errors = result.errors.filter(isLikelyASyntaxError);
result.warnings = [];
}
return result;
}
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=format-webpack-messages.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/format-webpack-messages.ts"],"names":["formatWebpackMessages","friendlySyntaxErrorLabel","WEBPACK_BREAKING_CHANGE_POLYFILLS","isLikelyASyntaxError","message","stripAnsi","includes","hadMissingSassError","formatMessage","verbose","importTraceNote","filteredModuleTrace","moduleTrace","filter","trace","test","originName","body","breakingChangeIndex","indexOf","slice","moduleName","file","details","length","map","join","stack","lines","split","line","parsingError","exec","errorLine","errorColumn","errorMessage","replace","trim","splice","match","firstLine","index","arr","json","formattedErrors","errors","isUnknownNextFontError","formattedWarnings","warnings","reactServerComponentsError","i","error","unshift","result","some"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;+BAiKA;;;eAAwBA;;;;oEAhKF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,IAAK,IAAIC,IAAI,GAAGA,IAAIN,gBAAgBpB,MAAM,EAAE0B,IAAK;QAC/C,MAAMC,QAAQP,eAAe,CAACM,EAAE;QAChC,IAAIC,MAAM7C,QAAQ,CAAC,+BAA+B;YAChD2C,6BAA6BC;YAC7B;QACF;IACF;IAEA,8DAA8D;IAC9D,IAAID,+BAA+B,CAAC,GAAG;QACrC,MAAME,QAAQP,gBAAgBN,MAAM,CAACW,4BAA4B;QACjEL,gBAAgBQ,OAAO,CAACD,KAAK,CAAC,EAAE;IAClC;IAEA,MAAME,SAAS;QACb,GAAGV,IAAI;QACPE,QAAQD;QACRI,UAAUD;IACZ;IACA,IAAI,CAACtC,WAAW4C,OAAOR,MAAM,CAACS,IAAI,CAACnD,uBAAuB;QACxD,kDAAkD;QAClDkD,OAAOR,MAAM,GAAGQ,OAAOR,MAAM,CAAChC,MAAM,CAACV;QACrCkD,OAAOL,QAAQ,GAAG,EAAE;IACtB;IACA,OAAOK;AACT"}

View File

@ -0,0 +1 @@
export declare function getSocketUrl(assetPrefix: string | undefined): string;

View File

@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getSocketUrl", {
enumerable: true,
get: function() {
return getSocketUrl;
}
});
const _normalizedassetprefix = require("../../../../../shared/lib/normalized-asset-prefix");
function getSocketProtocol(assetPrefix) {
let protocol = window.location.protocol;
try {
// assetPrefix is a url
protocol = new URL(assetPrefix).protocol;
} catch (e) {}
return protocol === "http:" ? "ws:" : "wss:";
}
function getSocketUrl(assetPrefix) {
const prefix = (0, _normalizedassetprefix.normalizedAssetPrefix)(assetPrefix);
const protocol = getSocketProtocol(assetPrefix || "");
if (URL.canParse(prefix)) {
// since normalized asset prefix is ensured to be a URL format,
// we can safely replace the protocol
return prefix.replace(/^http/, "ws");
}
const { hostname, port } = window.location;
return protocol + "//" + hostname + (port ? ":" + port : "") + prefix;
}
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-socket-url.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/get-socket-url.ts"],"names":["getSocketUrl","getSocketProtocol","assetPrefix","protocol","window","location","URL","prefix","normalizedAssetPrefix","canParse","replace","hostname","port"],"mappings":";;;;+BAagBA;;;eAAAA;;;uCAbsB;AAEtC,SAASC,kBAAkBC,WAAmB;IAC5C,IAAIC,WAAWC,OAAOC,QAAQ,CAACF,QAAQ;IAEvC,IAAI;QACF,uBAAuB;QACvBA,WAAW,IAAIG,IAAIJ,aAAaC,QAAQ;IAC1C,EAAE,UAAM,CAAC;IAET,OAAOA,aAAa,UAAU,QAAQ;AACxC;AAEO,SAASH,aAAaE,WAA+B;IAC1D,MAAMK,SAASC,IAAAA,4CAAqB,EAACN;IACrC,MAAMC,WAAWF,kBAAkBC,eAAe;IAElD,IAAII,IAAIG,QAAQ,CAACF,SAAS;QACxB,+DAA+D;QAC/D,qCAAqC;QACrC,OAAOA,OAAOG,OAAO,CAAC,SAAS;IACjC;IAEA,MAAM,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGR,OAAOC,QAAQ;IAC1C,OAAO,AAAGF,WAAS,OAAIQ,WAAWC,CAAAA,OAAO,AAAC,MAAGA,OAAS,EAAC,IAAIL;AAC7D"}

View File

@ -0,0 +1,11 @@
import type { SupportedErrorEvent } from '../container/Errors';
import type { OriginalStackFrame } from './stack-frame';
import type { ComponentStackFrame } from './parse-component-stack';
export type ReadyRuntimeError = {
id: number;
runtime: true;
error: Error;
frames: OriginalStackFrame[];
componentStackFrames?: ComponentStackFrame[];
};
export declare function getErrorByType(ev: SupportedErrorEvent, isAppDir: boolean): Promise<ReadyRuntimeError>;

View File

@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getErrorByType", {
enumerable: true,
get: function() {
return getErrorByType;
}
});
const _shared = require("../../shared");
const _stackframe = require("./stack-frame");
const _errorsource = require("../../../../../shared/lib/error-source");
async function getErrorByType(ev, isAppDir) {
const { id, event } = ev;
switch(event.type){
case _shared.ACTION_UNHANDLED_ERROR:
case _shared.ACTION_UNHANDLED_REJECTION:
{
const readyRuntimeError = {
id,
runtime: true,
error: event.reason,
frames: await (0, _stackframe.getOriginalStackFrames)(event.frames, (0, _errorsource.getErrorSource)(event.reason), isAppDir, event.reason.toString())
};
if (event.type === _shared.ACTION_UNHANDLED_ERROR) {
readyRuntimeError.componentStackFrames = event.componentStackFrames;
}
return readyRuntimeError;
}
default:
{
break;
}
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _ = event;
throw new Error("type system invariant violation");
}
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=getErrorByType.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/getErrorByType.ts"],"names":["getErrorByType","ev","isAppDir","id","event","type","ACTION_UNHANDLED_ERROR","ACTION_UNHANDLED_REJECTION","readyRuntimeError","runtime","error","reason","frames","getOriginalStackFrames","getErrorSource","toString","componentStackFrames","_","Error"],"mappings":";;;;+BAkBsBA;;;eAAAA;;;wBAff;4BAEgC;6BAGR;AAUxB,eAAeA,eACpBC,EAAuB,EACvBC,QAAiB;IAEjB,MAAM,EAAEC,EAAE,EAAEC,KAAK,EAAE,GAAGH;IACtB,OAAQG,MAAMC,IAAI;QAChB,KAAKC,8BAAsB;QAC3B,KAAKC,kCAA0B;YAAE;gBAC/B,MAAMC,oBAAuC;oBAC3CL;oBACAM,SAAS;oBACTC,OAAON,MAAMO,MAAM;oBACnBC,QAAQ,MAAMC,IAAAA,kCAAsB,EAClCT,MAAMQ,MAAM,EACZE,IAAAA,2BAAc,EAACV,MAAMO,MAAM,GAC3BT,UACAE,MAAMO,MAAM,CAACI,QAAQ;gBAEzB;gBACA,IAAIX,MAAMC,IAAI,KAAKC,8BAAsB,EAAE;oBACzCE,kBAAkBQ,oBAAoB,GAAGZ,MAAMY,oBAAoB;gBACrE;gBACA,OAAOR;YACT;QACA;YAAS;gBACP;YACF;IACF;IACA,6DAA6D;IAC7D,MAAMS,IAAWb;IACjB,MAAM,IAAIc,MAAM;AAClB"}

View File

@ -0,0 +1 @@
export declare function getRawSourceMap(fileContents: string): unknown | null;

View File

@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getRawSourceMap", {
enumerable: true,
get: function() {
return getRawSourceMap;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _datauritobuffer = /*#__PURE__*/ _interop_require_default._(require("next/dist/compiled/data-uri-to-buffer"));
const _getSourceMapUrl = require("./getSourceMapUrl");
function getRawSourceMap(fileContents) {
const sourceUrl = (0, _getSourceMapUrl.getSourceMapUrl)(fileContents);
if (!(sourceUrl == null ? void 0 : sourceUrl.startsWith("data:"))) {
return null;
}
let buffer;
try {
buffer = (0, _datauritobuffer.default)(sourceUrl);
} catch (err) {
console.error("Failed to parse source map URL:", err);
return null;
}
if (buffer.type !== "application/json") {
console.error("Unknown source map type: " + buffer.typeFull + ".");
return null;
}
try {
return JSON.parse(buffer.toString());
} catch (e) {
console.error("Failed to parse source map.");
return null;
}
}
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=getRawSourceMap.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/getRawSourceMap.ts"],"names":["getRawSourceMap","fileContents","sourceUrl","getSourceMapUrl","startsWith","buffer","dataUriToBuffer","err","console","error","type","typeFull","JSON","parse","toString"],"mappings":";;;;+BAGgBA;;;eAAAA;;;;0EAHY;iCACI;AAEzB,SAASA,gBAAgBC,YAAoB;IAClD,MAAMC,YAAYC,IAAAA,gCAAe,EAACF;IAClC,IAAI,EAACC,6BAAAA,UAAWE,UAAU,CAAC,WAAU;QACnC,OAAO;IACT;IAEA,IAAIC;IACJ,IAAI;QACFA,SAASC,IAAAA,wBAAe,EAACJ;IAC3B,EAAE,OAAOK,KAAK;QACZC,QAAQC,KAAK,CAAC,mCAAmCF;QACjD,OAAO;IACT;IAEA,IAAIF,OAAOK,IAAI,KAAK,oBAAoB;QACtCF,QAAQC,KAAK,CAAC,AAAC,8BAA2BJ,OAAOM,QAAQ,GAAC;QAC1D,OAAO;IACT;IAEA,IAAI;QACF,OAAOC,KAAKC,KAAK,CAACR,OAAOS,QAAQ;IACnC,EAAE,UAAM;QACNN,QAAQC,KAAK,CAAC;QACd,OAAO;IACT;AACF"}

View File

@ -0,0 +1 @@
export declare function getSourceMapUrl(fileContents: string): string | null;

View File

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getSourceMapUrl", {
enumerable: true,
get: function() {
return getSourceMapUrl;
}
});
function getSourceMapUrl(fileContents) {
const regex = /\/\/[#@] ?sourceMappingURL=([^\s'"]+)\s*$/gm;
let match = null;
for(;;){
let next = regex.exec(fileContents);
if (next == null) {
break;
}
match = next;
}
if (!(match && match[1])) {
return null;
}
return match[1].toString();
}
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=getSourceMapUrl.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/getSourceMapUrl.ts"],"names":["getSourceMapUrl","fileContents","regex","match","next","exec","toString"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,gBAAgBC,YAAoB;IAClD,MAAMC,QAAQ;IACd,IAAIC,QAAQ;IACZ,OAAS;QACP,IAAIC,OAAOF,MAAMG,IAAI,CAACJ;QACtB,IAAIG,QAAQ,MAAM;YAChB;QACF;QACAD,QAAQC;IACV;IACA,IAAI,CAAED,CAAAA,SAASA,KAAK,CAAC,EAAE,AAAD,GAAI;QACxB,OAAO;IACT;IACA,OAAOA,KAAK,CAAC,EAAE,CAACG,QAAQ;AAC1B"}

View File

@ -0,0 +1,28 @@
import type { SourcePackage } from '../../server/shared';
import type { OriginalStackFrame } from './stack-frame';
export type StackFramesGroup = {
framework?: SourcePackage | null;
stackFrames: OriginalStackFrame[];
};
/**
* Group sequences of stack frames by framework.
*
* Given the following stack frames:
* Error
* user code
* user code
* react
* react
* next
* next
* react
* react
*
* The grouped stack frames would be:
* > user code
* > react
* > next
* > react
*
*/
export declare function groupStackFramesByFramework(stackFrames: OriginalStackFrame[]): StackFramesGroup[];

View File

@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "groupStackFramesByFramework", {
enumerable: true,
get: function() {
return groupStackFramesByFramework;
}
});
function groupStackFramesByFramework(stackFrames) {
const stackFramesGroupedByFramework = [];
for (const stackFrame of stackFrames){
const currentGroup = stackFramesGroupedByFramework[stackFramesGroupedByFramework.length - 1];
const framework = stackFrame.sourcePackage;
if (currentGroup && currentGroup.framework === framework) {
currentGroup.stackFrames.push(stackFrame);
} else {
stackFramesGroupedByFramework.push({
framework: framework,
stackFrames: [
stackFrame
]
});
}
}
return stackFramesGroupedByFramework;
}
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=group-stack-frames-by-framework.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/group-stack-frames-by-framework.ts"],"names":["groupStackFramesByFramework","stackFrames","stackFramesGroupedByFramework","stackFrame","currentGroup","length","framework","sourcePackage","push"],"mappings":";;;;+BA6BgBA;;;eAAAA;;;AAAT,SAASA,4BACdC,WAAiC;IAEjC,MAAMC,gCAAoD,EAAE;IAE5D,KAAK,MAAMC,cAAcF,YAAa;QACpC,MAAMG,eACJF,6BAA6B,CAACA,8BAA8BG,MAAM,GAAG,EAAE;QACzE,MAAMC,YAAYH,WAAWI,aAAa;QAE1C,IAAIH,gBAAgBA,aAAaE,SAAS,KAAKA,WAAW;YACxDF,aAAaH,WAAW,CAACO,IAAI,CAACL;QAChC,OAAO;YACLD,8BAA8BM,IAAI,CAAC;gBACjCF,WAAWA;gBACXL,aAAa;oBAACE;iBAAW;YAC3B;QACF;IACF;IAEA,OAAOD;AACT"}

View File

@ -0,0 +1,17 @@
export type HydrationErrorState = {
warning?: [string, string, string];
componentStack?: string;
serverContent?: string;
clientContent?: string;
};
type NullableText = string | null | undefined;
export declare const getHydrationWarningType: (msg: NullableText) => 'tag' | 'text' | 'text-in-tag';
export declare const hydrationErrorState: HydrationErrorState;
/**
* Patch console.error to capture hydration errors.
* If any of the knownHydrationWarnings are logged, store the message and component stack.
* When the hydration runtime error is thrown, the message and component stack are added to the error.
* This results in a more helpful error message in the error overlay.
*/
export declare function patchConsoleError(): void;
export {};

View File

@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getHydrationWarningType: null,
hydrationErrorState: null,
patchConsoleError: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getHydrationWarningType: function() {
return getHydrationWarningType;
},
hydrationErrorState: function() {
return hydrationErrorState;
},
patchConsoleError: function() {
return patchConsoleError;
}
});
const getHydrationWarningType = (msg)=>{
if (isHtmlTagsWarning(msg)) return "tag";
if (isTextInTagsMismatchWarning(msg)) return "text-in-tag";
return "text";
};
const isHtmlTagsWarning = (msg)=>Boolean(msg && htmlTagsWarnings.has(msg));
const isTextMismatchWarning = (msg)=>textMismatchWarning === msg;
const isTextInTagsMismatchWarning = (msg)=>Boolean(msg && textAndTagsMismatchWarnings.has(msg));
const isKnownHydrationWarning = (msg)=>isHtmlTagsWarning(msg) || isTextInTagsMismatchWarning(msg) || isTextMismatchWarning(msg);
const hydrationErrorState = {};
// https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference
const htmlTagsWarnings = new Set([
'Warning: Cannot render a sync or defer <script> outside the main document without knowing its order. Try adding async="" or moving it into the root <head> tag.%s',
"Warning: In HTML, %s cannot be a child of <%s>.%s\nThis will cause a hydration error.%s",
"Warning: In HTML, %s cannot be a descendant of <%s>.\nThis will cause a hydration error.%s",
"Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will cause a hydration error.",
"Warning: In HTML, whitespace text nodes cannot be a child of <%s>. Make sure you don't have any extra whitespace between tags on each line of your source code.\nThis will cause a hydration error.",
"Warning: Expected server HTML to contain a matching <%s> in <%s>.%s",
"Warning: Did not expect server HTML to contain a <%s> in <%s>.%s"
]);
const textAndTagsMismatchWarnings = new Set([
'Warning: Expected server HTML to contain a matching text node for "%s" in <%s>.%s',
'Warning: Did not expect server HTML to contain the text node "%s" in <%s>.%s'
]);
const textMismatchWarning = 'Warning: Text content did not match. Server: "%s" Client: "%s"%s';
function patchConsoleError() {
const prev = console.error;
console.error = function(msg, serverContent, clientContent, componentStack) {
if (isKnownHydrationWarning(msg)) {
hydrationErrorState.warning = [
// remove the last %s from the message
msg,
serverContent,
clientContent
];
hydrationErrorState.componentStack = componentStack;
hydrationErrorState.serverContent = serverContent;
hydrationErrorState.clientContent = clientContent;
}
// @ts-expect-error argument is defined
prev.apply(console, arguments);
};
}
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=hydration-error-info.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/hydration-error-info.ts"],"names":["getHydrationWarningType","hydrationErrorState","patchConsoleError","msg","isHtmlTagsWarning","isTextInTagsMismatchWarning","Boolean","htmlTagsWarnings","has","isTextMismatchWarning","textMismatchWarning","textAndTagsMismatchWarnings","isKnownHydrationWarning","Set","prev","console","error","serverContent","clientContent","componentStack","warning","apply","arguments"],"mappings":";;;;;;;;;;;;;;;;IAUaA,uBAAuB;eAAvBA;;IAoBAC,mBAAmB;eAAnBA;;IAyBGC,iBAAiB;eAAjBA;;;AA7CT,MAAMF,0BAA0B,CACrCG;IAEA,IAAIC,kBAAkBD,MAAM,OAAO;IACnC,IAAIE,4BAA4BF,MAAM,OAAO;IAC7C,OAAO;AACT;AAEA,MAAMC,oBAAoB,CAACD,MACzBG,QAAQH,OAAOI,iBAAiBC,GAAG,CAACL;AAEtC,MAAMM,wBAAwB,CAACN,MAAsBO,wBAAwBP;AAC7E,MAAME,8BAA8B,CAACF,MACnCG,QAAQH,OAAOQ,4BAA4BH,GAAG,CAACL;AAEjD,MAAMS,0BAA0B,CAACT,MAC/BC,kBAAkBD,QAClBE,4BAA4BF,QAC5BM,sBAAsBN;AAEjB,MAAMF,sBAA2C,CAAC;AAEzD,iIAAiI;AACjI,MAAMM,mBAAmB,IAAIM,IAAI;IAC/B;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AACD,MAAMF,8BAA8B,IAAIE,IAAI;IAC1C;IACA;CACD;AACD,MAAMH,sBACJ;AAQK,SAASR;IACd,MAAMY,OAAOC,QAAQC,KAAK;IAC1BD,QAAQC,KAAK,GAAG,SAAUb,GAAG,EAAEc,aAAa,EAAEC,aAAa,EAAEC,cAAc;QACzE,IAAIP,wBAAwBT,MAAM;YAChCF,oBAAoBmB,OAAO,GAAG;gBAC5B,sCAAsC;gBACtCjB;gBACAc;gBACAC;aACD;YACDjB,oBAAoBkB,cAAc,GAAGA;YACrClB,oBAAoBgB,aAAa,GAAGA;YACpChB,oBAAoBiB,aAAa,GAAGA;QACtC;QAEA,uCAAuC;QACvCJ,KAAKO,KAAK,CAACN,SAASO;IACtB;AACF"}

View File

@ -0,0 +1,2 @@
declare function launchEditor(fileName: string, lineNumber: number, colNumber: number): void;
export { launchEditor };

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser';
import { type ErrorSourceType } from '../../../../../shared/lib/error-source';
export declare function getFilesystemFrame(frame: StackFrame): StackFrame;
export declare function getServerError(error: Error, type: ErrorSourceType): Error;

View File

@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getFilesystemFrame: null,
getServerError: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getFilesystemFrame: function() {
return getFilesystemFrame;
},
getServerError: function() {
return getServerError;
}
});
const _stacktraceparser = require("next/dist/compiled/stacktrace-parser");
const _errorsource = require("../../../../../shared/lib/error-source");
function getFilesystemFrame(frame) {
const f = {
...frame
};
if (typeof f.file === "string") {
if (// Posix:
f.file.startsWith("/") || // Win32:
/^[a-z]:\\/i.test(f.file) || // Win32 UNC:
f.file.startsWith("\\\\")) {
f.file = "file://" + f.file;
}
}
return f;
}
function getServerError(error, type) {
let n;
try {
throw new Error(error.message);
} catch (e) {
n = e;
}
n.name = error.name;
try {
n.stack = n.toString() + "\n" + (0, _stacktraceparser.parse)(error.stack).map(getFilesystemFrame).map((f)=>{
let str = " at " + f.methodName;
if (f.file) {
let loc = f.file;
if (f.lineNumber) {
loc += ":" + f.lineNumber;
if (f.column) {
loc += ":" + f.column;
}
}
str += " (" + loc + ")";
}
return str;
}).join("\n");
} catch (e) {
n.stack = error.stack;
}
(0, _errorsource.decorateServerError)(n, type);
return n;
}
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=nodeStackFrames.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/nodeStackFrames.ts"],"names":["getFilesystemFrame","getServerError","frame","f","file","startsWith","test","error","type","n","Error","message","e","name","stack","toString","parse","map","str","methodName","loc","lineNumber","column","join","decorateServerError"],"mappings":";;;;;;;;;;;;;;;IAOgBA,kBAAkB;eAAlBA;;IAmBAC,cAAc;eAAdA;;;kCA1BM;6BAKf;AAEA,SAASD,mBAAmBE,KAAiB;IAClD,MAAMC,IAAgB;QAAE,GAAGD,KAAK;IAAC;IAEjC,IAAI,OAAOC,EAAEC,IAAI,KAAK,UAAU;QAC9B,IACE,SAAS;QACTD,EAAEC,IAAI,CAACC,UAAU,CAAC,QAClB,SAAS;QACT,aAAaC,IAAI,CAACH,EAAEC,IAAI,KACxB,aAAa;QACbD,EAAEC,IAAI,CAACC,UAAU,CAAC,SAClB;YACAF,EAAEC,IAAI,GAAG,AAAC,YAASD,EAAEC,IAAI;QAC3B;IACF;IAEA,OAAOD;AACT;AAEO,SAASF,eAAeM,KAAY,EAAEC,IAAqB;IAChE,IAAIC;IACJ,IAAI;QACF,MAAM,IAAIC,MAAMH,MAAMI,OAAO;IAC/B,EAAE,OAAOC,GAAG;QACVH,IAAIG;IACN;IAEAH,EAAEI,IAAI,GAAGN,MAAMM,IAAI;IACnB,IAAI;QACFJ,EAAEK,KAAK,GAAG,AAAGL,EAAEM,QAAQ,KAAG,OAAIC,IAAAA,uBAAK,EAACT,MAAMO,KAAK,EAC5CG,GAAG,CAACjB,oBACJiB,GAAG,CAAC,CAACd;YACJ,IAAIe,MAAM,AAAC,YAASf,EAAEgB,UAAU;YAChC,IAAIhB,EAAEC,IAAI,EAAE;gBACV,IAAIgB,MAAMjB,EAAEC,IAAI;gBAChB,IAAID,EAAEkB,UAAU,EAAE;oBAChBD,OAAO,AAAC,MAAGjB,EAAEkB,UAAU;oBACvB,IAAIlB,EAAEmB,MAAM,EAAE;wBACZF,OAAO,AAAC,MAAGjB,EAAEmB,MAAM;oBACrB;gBACF;gBACAJ,OAAO,AAAC,OAAIE,MAAI;YAClB;YACA,OAAOF;QACT,GACCK,IAAI,CAAC;IACV,EAAE,UAAM;QACNd,EAAEK,KAAK,GAAGP,MAAMO,KAAK;IACvB;IAEAU,IAAAA,gCAAmB,EAACf,GAAGD;IACvB,OAAOC;AACT"}

View File

@ -0,0 +1 @@
export declare function noop(strings: TemplateStringsArray, ...keys: readonly string[]): string;

View File

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "noop", {
enumerable: true,
get: function() {
return noop;
}
});
function noop(strings) {
for(var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
keys[_key - 1] = arguments[_key];
}
const lastIndex = strings.length - 1;
return strings.slice(0, lastIndex).reduce((p, s, i)=>p + s + keys[i], "") + strings[lastIndex];
}
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=noop-template.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/noop-template.ts"],"names":["noop","strings","keys","lastIndex","length","slice","reduce","p","s","i"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,KACdC,OAA6B;IAC7B,IAAA,IAAA,OAAA,UAAA,QAAA,AAAGC,OAAH,UAAA,OAAA,IAAA,OAAA,QAAA,OAAA,GAAA,OAAA,MAAA;QAAGA,KAAH,OAAA,KAAA,SAAA,CAAA,KAA0B;;IAE1B,MAAMC,YAAYF,QAAQG,MAAM,GAAG;IACnC,OACEH,QAAQI,KAAK,CAAC,GAAGF,WAAWG,MAAM,CAAC,CAACC,GAAGC,GAAGC,IAAMF,IAAIC,IAAIN,IAAI,CAACO,EAAE,EAAE,MACjER,OAAO,CAACE,UAAU;AAEtB"}

View File

@ -0,0 +1,8 @@
export type ComponentStackFrame = {
canOpenInEditor: boolean;
component: string;
file?: string;
lineNumber?: number;
column?: number;
};
export declare function parseComponentStack(componentStack: string): ComponentStackFrame[];

View File

@ -0,0 +1,98 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "parseComponentStack", {
enumerable: true,
get: function() {
return parseComponentStack;
}
});
var LocationType;
(function(LocationType) {
LocationType["FILE"] = "file";
LocationType["WEBPACK_INTERNAL"] = "webpack-internal";
LocationType["HTTP"] = "http";
LocationType["PROTOCOL_RELATIVE"] = "protocol-relative";
LocationType["UNKNOWN"] = "unknown";
})(LocationType || (LocationType = {}));
/**
* Get the type of frame line based on the location
*/ function getLocationType(location) {
if (location.startsWith("file://")) {
return "file";
}
if (location.startsWith("webpack-internal://")) {
return "webpack-internal";
}
if (location.startsWith("http://") || location.startsWith("https://")) {
return "http";
}
if (location.startsWith("//")) {
return "protocol-relative";
}
return "unknown";
}
function parseStackFrameLocation(location) {
const locationType = getLocationType(location);
const modulePath = location == null ? void 0 : location.replace(/^(webpack-internal:\/\/\/|file:\/\/)(\(.*\)\/)?/, "");
var _modulePath_match;
const [, file, lineNumber, column] = (_modulePath_match = modulePath == null ? void 0 : modulePath.match(/^(.+):(\d+):(\d+)/)) != null ? _modulePath_match : [];
switch(locationType){
case "file":
case "webpack-internal":
return {
canOpenInEditor: true,
file,
lineNumber: lineNumber ? Number(lineNumber) : undefined,
column: column ? Number(column) : undefined
};
// When the location is a URL we only show the file
// TODO: Resolve http(s) URLs through sourcemaps
case "http":
case "protocol-relative":
case "unknown":
default:
{
return {
canOpenInEditor: false
};
}
}
}
function parseComponentStack(componentStack) {
const componentStackFrames = [];
for (const line of componentStack.trim().split("\n")){
// Get component and file from the component stack line
const match = /at ([^ ]+)( \((.*)\))?/.exec(line);
if (match == null ? void 0 : match[1]) {
const component = match[1];
const location = match[3];
if (!location) {
componentStackFrames.push({
canOpenInEditor: false,
component
});
continue;
}
// Stop parsing the component stack if we reach a Next.js component
if (location == null ? void 0 : location.includes("next/dist")) {
break;
}
const frameLocation = parseStackFrameLocation(location);
componentStackFrames.push({
component,
...frameLocation
});
}
}
return componentStackFrames;
}
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=parse-component-stack.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/parse-component-stack.ts"],"names":["parseComponentStack","LocationType","getLocationType","location","startsWith","parseStackFrameLocation","locationType","modulePath","replace","file","lineNumber","column","match","canOpenInEditor","Number","undefined","componentStack","componentStackFrames","line","trim","split","exec","component","push","includes","frameLocation"],"mappings":";;;;+BAqEgBA;;;eAAAA;;;;UA7DXC;;;;;;GAAAA,iBAAAA;AAQL;;CAEC,GACD,SAASC,gBAAgBC,QAAgB;IACvC,IAAIA,SAASC,UAAU,CAAC,YAAY;QAClC;IACF;IACA,IAAID,SAASC,UAAU,CAAC,wBAAwB;QAC9C;IACF;IACA,IAAID,SAASC,UAAU,CAAC,cAAcD,SAASC,UAAU,CAAC,aAAa;QACrE;IACF;IACA,IAAID,SAASC,UAAU,CAAC,OAAO;QAC7B;IACF;IACA;AACF;AAEA,SAASC,wBACPF,QAAgB;IAEhB,MAAMG,eAAeJ,gBAAgBC;IAErC,MAAMI,aAAaJ,4BAAAA,SAAUK,OAAO,CAClC,mDACA;QAGAD;IADF,MAAM,GAAGE,MAAMC,YAAYC,OAAO,GAChCJ,CAAAA,oBAAAA,8BAAAA,WAAYK,KAAK,CAAC,gCAAlBL,oBAA0C,EAAE;IAE9C,OAAQD;QACN;QACA;YACE,OAAO;gBACLO,iBAAiB;gBACjBJ;gBACAC,YAAYA,aAAaI,OAAOJ,cAAcK;gBAC9CJ,QAAQA,SAASG,OAAOH,UAAUI;YACpC;QACF,mDAAmD;QACnD,gDAAgD;QAChD;QACA;QACA;QACA;YAAS;gBACP,OAAO;oBACLF,iBAAiB;gBACnB;YACF;IACF;AACF;AAEO,SAASb,oBACdgB,cAAsB;IAEtB,MAAMC,uBAA8C,EAAE;IACtD,KAAK,MAAMC,QAAQF,eAAeG,IAAI,GAAGC,KAAK,CAAC,MAAO;QACpD,uDAAuD;QACvD,MAAMR,QAAQ,yBAAyBS,IAAI,CAACH;QAC5C,IAAIN,yBAAAA,KAAO,CAAC,EAAE,EAAE;YACd,MAAMU,YAAYV,KAAK,CAAC,EAAE;YAC1B,MAAMT,WAAWS,KAAK,CAAC,EAAE;YAEzB,IAAI,CAACT,UAAU;gBACbc,qBAAqBM,IAAI,CAAC;oBACxBV,iBAAiB;oBACjBS;gBACF;gBACA;YACF;YAEA,mEAAmE;YACnE,IAAInB,4BAAAA,SAAUqB,QAAQ,CAAC,cAAc;gBACnC;YACF;YAEA,MAAMC,gBAAgBpB,wBAAwBF;YAC9Cc,qBAAqBM,IAAI,CAAC;gBACxBD;gBACA,GAAGG,aAAa;YAClB;QACF;IACF;IAEA,OAAOR;AACT"}

View File

@ -0,0 +1,2 @@
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser';
export declare function parseStack(stack: string): StackFrame[];

View File

@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "parseStack", {
enumerable: true,
get: function() {
return parseStack;
}
});
const _stacktraceparser = require("next/dist/compiled/stacktrace-parser");
const regexNextStatic = /\/_next(\/static\/.+)/;
function parseStack(stack) {
const frames = (0, _stacktraceparser.parse)(stack);
return frames.map((frame)=>{
try {
const url = new URL(frame.file);
const res = regexNextStatic.exec(url.pathname);
if (res) {
var _process_env___NEXT_DIST_DIR_replace, _process_env___NEXT_DIST_DIR;
const distDir = (_process_env___NEXT_DIST_DIR = process.env.__NEXT_DIST_DIR) == null ? void 0 : (_process_env___NEXT_DIST_DIR_replace = _process_env___NEXT_DIST_DIR.replace(/\\/g, "/")) == null ? void 0 : _process_env___NEXT_DIST_DIR_replace.replace(/\/$/, "");
if (distDir) {
frame.file = "file://" + distDir.concat(res.pop()) + url.search;
}
}
} catch (e) {}
return frame;
});
}
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=parseStack.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/parseStack.ts"],"names":["parseStack","regexNextStatic","stack","frames","parse","map","frame","url","URL","file","res","exec","pathname","process","distDir","env","__NEXT_DIST_DIR","replace","concat","pop","search"],"mappings":";;;;+BAKgBA;;;eAAAA;;;kCALM;AAGtB,MAAMC,kBAAkB;AAEjB,SAASD,WAAWE,KAAa;IACtC,MAAMC,SAASC,IAAAA,uBAAK,EAACF;IACrB,OAAOC,OAAOE,GAAG,CAAC,CAACC;QACjB,IAAI;YACF,MAAMC,MAAM,IAAIC,IAAIF,MAAMG,IAAI;YAC9B,MAAMC,MAAMT,gBAAgBU,IAAI,CAACJ,IAAIK,QAAQ;YAC7C,IAAIF,KAAK;oBACSG,sCAAAA;gBAAhB,MAAMC,WAAUD,+BAAAA,QAAQE,GAAG,CAACC,eAAe,sBAA3BH,uCAAAA,6BACZI,OAAO,CAAC,OAAO,yBADHJ,qCAEZI,OAAO,CAAC,OAAO;gBACnB,IAAIH,SAAS;oBACXR,MAAMG,IAAI,GAAG,YAAYK,QAAQI,MAAM,CAACR,IAAIS,GAAG,MAAOZ,IAAIa,MAAM;gBAClE;YACF;QACF,EAAE,UAAM,CAAC;QACT,OAAOd;IACT;AACF"}

View File

@ -0,0 +1,3 @@
export declare const RuntimeErrorHandler: {
hadRuntimeError: boolean;
};

View File

@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "RuntimeErrorHandler", {
enumerable: true,
get: function() {
return RuntimeErrorHandler;
}
});
const RuntimeErrorHandler = {
hadRuntimeError: false
};
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=runtime-error-handler.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/runtime-error-handler.ts"],"names":["RuntimeErrorHandler","hadRuntimeError"],"mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA,sBAAsB;IACjCC,iBAAiB;AACnB"}

View File

@ -0,0 +1,11 @@
import type { StackFrame } from 'next/dist/compiled/stacktrace-parser';
import type { OriginalStackFrameResponse } from '../../server/shared';
export interface OriginalStackFrame extends OriginalStackFrameResponse {
error: boolean;
reason: string | null;
external: boolean;
expanded: boolean;
sourceStackFrame: StackFrame;
}
export declare function getOriginalStackFrames(frames: StackFrame[], type: 'server' | 'edge-server' | null, isAppDir: boolean, errorMessage: string): Promise<OriginalStackFrame[]>;
export declare function getFrameSource(frame: StackFrame): string;

View File

@ -0,0 +1,145 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getFrameSource: null,
getOriginalStackFrames: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getFrameSource: function() {
return getFrameSource;
},
getOriginalStackFrames: function() {
return getOriginalStackFrames;
}
});
function getOriginalStackFrame(source, type, isAppDir, errorMessage) {
var _source_file, _source_file1;
async function _getOriginalStackFrame() {
var /* collapsed */ _source_file, _body_originalStackFrame_file, _body_originalStackFrame, _body_originalStackFrame_file1, _body_originalStackFrame1;
const params = new URLSearchParams();
params.append("isServer", String(type === "server"));
params.append("isEdgeServer", String(type === "edge-server"));
params.append("isAppDirectory", String(isAppDir));
params.append("errorMessage", errorMessage);
for(const key in source){
var _source_key;
params.append(key, ((_source_key = source[key]) != null ? _source_key : "").toString());
}
const controller = new AbortController();
const tm = setTimeout(()=>controller.abort(), 3000);
const res = await self.fetch((process.env.__NEXT_ROUTER_BASEPATH || "") + "/__nextjs_original-stack-frame?" + params.toString(), {
signal: controller.signal
}).finally(()=>{
clearTimeout(tm);
});
if (!res.ok || res.status === 204) {
return Promise.reject(new Error(await res.text()));
}
const body = await res.json();
var _ref;
return {
error: false,
reason: null,
external: false,
expanded: !Boolean((_ref = ((_source_file = source.file) == null ? void 0 : _source_file.includes("node_modules")) || ((_body_originalStackFrame = body.originalStackFrame) == null ? void 0 : (_body_originalStackFrame_file = _body_originalStackFrame.file) == null ? void 0 : _body_originalStackFrame_file.includes("node_modules")) || ((_body_originalStackFrame1 = body.originalStackFrame) == null ? void 0 : (_body_originalStackFrame_file1 = _body_originalStackFrame1.file) == null ? void 0 : _body_originalStackFrame_file1.startsWith("[turbopack]/"))) != null ? _ref : true),
sourceStackFrame: source,
originalStackFrame: body.originalStackFrame,
originalCodeFrame: body.originalCodeFrame || null,
sourcePackage: body.sourcePackage
};
}
if (source.file === "<anonymous>" || ((_source_file = source.file) == null ? void 0 : _source_file.match(/^node:/)) || ((_source_file1 = source.file) == null ? void 0 : _source_file1.match(/https?:\/\//))) {
return Promise.resolve({
error: false,
reason: null,
external: true,
expanded: false,
sourceStackFrame: source,
originalStackFrame: null,
originalCodeFrame: null,
sourcePackage: null
});
}
return _getOriginalStackFrame().catch((err)=>{
var _err_message, _ref;
return {
error: true,
reason: (_ref = (_err_message = err == null ? void 0 : err.message) != null ? _err_message : err == null ? void 0 : err.toString()) != null ? _ref : "Unknown Error",
external: false,
expanded: false,
sourceStackFrame: source,
originalStackFrame: null,
originalCodeFrame: null,
sourcePackage: null
};
});
}
function getOriginalStackFrames(frames, type, isAppDir, errorMessage) {
return Promise.all(frames.map((frame)=>getOriginalStackFrame(frame, type, isAppDir, errorMessage)));
}
const webpackRegExes = [
/^webpack-internal:\/\/\/(\.)?(\((\w+)\))?/,
/^(webpack:\/\/\/(\.)?|webpack:\/\/(_N_E\/)?)(\((\w+)\))?/
];
function isWebpackBundled(file) {
return webpackRegExes.some((regEx)=>regEx.test(file));
}
/**
* Format the webpack internal id to original file path
* webpack-internal:///./src/hello.tsx => ./src/hello.tsx
* webpack://_N_E/./src/hello.tsx => ./src/hello.tsx
* webpack://./src/hello.tsx => ./src/hello.tsx
* webpack:///./src/hello.tsx => ./src/hello.tsx
*/ function formatFrameSourceFile(file) {
for (const regex of webpackRegExes)file = file.replace(regex, "");
return file;
}
function getFrameSource(frame) {
if (!frame.file) return "";
let str = "";
try {
var _globalThis_location;
const u = new URL(frame.file);
// Strip the origin for same-origin scripts.
if (((_globalThis_location = globalThis.location) == null ? void 0 : _globalThis_location.origin) !== u.origin) {
// URLs can be valid without an `origin`, so long as they have a
// `protocol`. However, `origin` is preferred.
if (u.origin === "null") {
str += u.protocol;
} else {
str += u.origin;
}
}
// Strip query string information as it's typically too verbose to be
// meaningful.
str += u.pathname;
str += " ";
str = formatFrameSourceFile(str);
} catch (e) {
str += formatFrameSourceFile(frame.file || "(unknown)") + " ";
}
if (!isWebpackBundled(frame.file) && frame.lineNumber != null) {
if (frame.column != null) {
str += "(" + frame.lineNumber + ":" + frame.column + ") ";
} else {
str += "(" + frame.lineNumber + ") ";
}
}
return str.slice(0, -1);
}
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=stack-frame.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/stack-frame.ts"],"names":["getFrameSource","getOriginalStackFrames","getOriginalStackFrame","source","type","isAppDir","errorMessage","_getOriginalStackFrame","body","params","URLSearchParams","append","String","key","toString","controller","AbortController","tm","setTimeout","abort","res","self","fetch","process","env","__NEXT_ROUTER_BASEPATH","signal","finally","clearTimeout","ok","status","Promise","reject","Error","text","json","error","reason","external","expanded","Boolean","file","includes","originalStackFrame","startsWith","sourceStackFrame","originalCodeFrame","sourcePackage","match","resolve","catch","err","message","frames","all","map","frame","webpackRegExes","isWebpackBundled","some","regEx","test","formatFrameSourceFile","regex","replace","str","globalThis","u","URL","location","origin","protocol","pathname","lineNumber","column","slice"],"mappings":";;;;;;;;;;;;;;;IA6HgBA,cAAc;eAAdA;;IAlCAC,sBAAsB;eAAtBA;;;AAhFhB,SAASC,sBACPC,MAAkB,EAClBC,IAAqC,EACrCC,QAAiB,EACjBC,YAAoB;QAiDlBH,cACAA;IAhDF,eAAeI;YAgCT,aAAa,GACZJ,cACCK,+BAAAA,0BACAA,gCAAAA;QAlCN,MAAMC,SAAS,IAAIC;QACnBD,OAAOE,MAAM,CAAC,YAAYC,OAAOR,SAAS;QAC1CK,OAAOE,MAAM,CAAC,gBAAgBC,OAAOR,SAAS;QAC9CK,OAAOE,MAAM,CAAC,kBAAkBC,OAAOP;QACvCI,OAAOE,MAAM,CAAC,gBAAgBL;QAC9B,IAAK,MAAMO,OAAOV,OAAQ;gBACJ;YAApBM,OAAOE,MAAM,CAACE,KAAK,AAAC,CAAA,CAAA,cAAA,AAACV,MAAc,CAACU,IAAI,YAApB,cAAwB,EAAC,EAAGC,QAAQ;QAC1D;QAEA,MAAMC,aAAa,I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AM;YACjB;QACF;QAEA,qEAAqE;QACrE,cAAc;QACdL,OAAOE,EAAEK,QAAQ;QACjBP,OAAO;QACPA,MAAMH,sBAAsBG;IAC9B,EAAE,UAAM;QACNA,OAAOH,sBAAsBN,MAAMf,IAAI,IAAI,eAAe;IAC5D;IAEA,IAAI,CAACiB,iBAAiBF,MAAMf,IAAI,KAAKe,MAAMiB,UAAU,IAAI,MAAM;QAC7D,IAAIjB,MAAMkB,MAAM,IAAI,MAAM;YACxBT,OAAO,AAAC,MAAGT,MAAMiB,UAAU,GAAC,MAAGjB,MAAMkB,MAAM,GAAC;QAC9C,OAAO;YACLT,OAAO,AAAC,MAAGT,MAAMiB,UAAU,GAAC;QAC9B;IACF;IACA,OAAOR,IAAIU,KAAK,CAAC,GAAG,CAAC;AACvB"}

View File

@ -0,0 +1,2 @@
export type ErrorHandler = (error: Error) => void;
export declare function useErrorHandler(handleOnUnhandledError: ErrorHandler, handleOnUnhandledRejection: ErrorHandler): void;

View File

@ -0,0 +1,103 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useErrorHandler", {
enumerable: true,
get: function() {
return useErrorHandler;
}
});
const _react = require("react");
const _hydrationerrorinfo = require("./hydration-error-info");
const _isnextroutererror = require("../../../is-next-router-error");
const _ishydrationerror = require("../../../is-hydration-error");
if (typeof window !== "undefined") {
try {
// Increase the number of stack frames on the client
Error.stackTraceLimit = 50;
} catch (e) {}
}
let hasHydrationError = false;
const errorQueue = [];
const rejectionQueue = [];
const errorHandlers = [];
const rejectionHandlers = [];
if (typeof window !== "undefined") {
// These event handlers must be added outside of the hook because there is no
// guarantee that the hook will be alive in a mounted component in time to
// when the errors occur.
window.addEventListener("error", (ev)=>{
if ((0, _isnextroutererror.isNextRouterError)(ev.error)) {
ev.preventDefault();
return;
}
const error = ev == null ? void 0 : ev.error;
if (!error || !(error instanceof Error) || typeof error.stack !== "string") {
// A non-error was thrown, we don't have anything to show. :-(
return;
}
const isCausedByHydrationFailure = (0, _ishydrationerror.isHydrationError)(error);
if ((0, _ishydrationerror.isHydrationError)(error) && !error.message.includes("https://nextjs.org/docs/messages/react-hydration-error")) {
// If there's any extra information in the error message to display,
// append it to the error message details property
if (_hydrationerrorinfo.hydrationErrorState.warning) {
error.details = {
...error.details,
// It contains the warning, component stack, server and client tag names
..._hydrationerrorinfo.hydrationErrorState
};
}
error.message += "\nSee more info here: https://nextjs.org/docs/messages/react-hydration-error";
}
const e = error;
// Only queue one hydration every time
if (isCausedByHydrationFailure) {
if (!hasHydrationError) {
errorQueue.push(e);
}
hasHydrationError = true;
}
for (const handler of errorHandlers){
handler(e);
}
});
window.addEventListener("unhandledrejection", (ev)=>{
const reason = ev == null ? void 0 : ev.reason;
if (!reason || !(reason instanceof Error) || typeof reason.stack !== "string") {
// A non-error was thrown, we don't have anything to show. :-(
return;
}
const e = reason;
rejectionQueue.push(e);
for (const handler of rejectionHandlers){
handler(e);
}
});
}
function useErrorHandler(handleOnUnhandledError, handleOnUnhandledRejection) {
(0, _react.useEffect)(()=>{
// Handle queued errors.
errorQueue.forEach(handleOnUnhandledError);
rejectionQueue.forEach(handleOnUnhandledRejection);
// Listen to new errors.
errorHandlers.push(handleOnUnhandledError);
rejectionHandlers.push(handleOnUnhandledRejection);
return ()=>{
// Remove listeners.
errorHandlers.splice(errorHandlers.indexOf(handleOnUnhandledError), 1);
rejectionHandlers.splice(rejectionHandlers.indexOf(handleOnUnhandledRejection), 1);
};
}, [
handleOnUnhandledError,
handleOnUnhandledRejection
]);
}
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=use-error-handler.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/use-error-handler.ts"],"names":["useErrorHandler","window","Error","stackTraceLimit","hasHydrationError","errorQueue","rejectionQueue","errorHandlers","rejectionHandlers","addEventListener","ev","isNextRouterError","error","preventDefault","stack","isCausedByHydrationFailure","isHydrationError","message","includes","hydrationErrorState","warning","details","e","push","handler","reason","handleOnUnhandledError","handleOnUnhandledRejection","useEffect","forEach","splice","indexOf"],"mappings":";;;;+BAgGgBA;;;eAAAA;;;uBAhGU;oCACU;mCACF;kCACD;AAIjC,IAAI,OAAOC,WAAW,aAAa;IACjC,IAAI;QACF,oDAAoD;QACpDC,MAAMC,eAAe,GAAG;IAC1B,EAAE,UAAM,CAAC;AACX;AAEA,IAAIC,oBAAoB;AACxB,MAAMC,aAA2B,EAAE;AACnC,MAAMC,iBAA+B,EAAE;AACvC,MAAMC,gBAAqC,EAAE;AAC7C,MAAMC,oBAAyC,EAAE;AAEjD,IAAI,OAAOP,WAAW,aAAa;IACjC,6EAA6E;IAC7E,0EAA0E;IAC1E,yBAAyB;IACzBA,OAAOQ,gBAAgB,CAAC,SAAS,CAACC;QAChC,IAAIC,IAAAA,oCAAiB,EAACD,GAAGE,KAAK,GAAG;YAC/BF,GAAGG,cAAc;YACjB;QACF;QAEA,MAAMD,QAAQF,sBAAAA,GAAIE,KAAK;QACvB,IACE,CAACA,SACD,CAAEA,CAAAA,iBAAiBV,KAAI,KACvB,OAAOU,MAAME,KAAK,KAAK,UACvB;YACA,8DAA8D;YAC9D;QACF;QAEA,MAAMC,6BAA6BC,IAAAA,kCAAgB,EAACJ;QACpD,IACEI,IAAAA,kCAAgB,EAACJ,UACjB,CAACA,MAAMK,OAAO,CAACC,QAAQ,CACrB,2DAEF;YACA,oEAAoE;YACpE,kDAAkD;YAClD,IAAIC,uCAAmB,CAACC,OAAO,EAAE;gBAG7BR,MAAcS,OAAO,GAAG;oBACxB,GAAG,AAACT,MAAcS,OAAO;oBACzB,wEAAwE;oBACxE,GAAGF,uCAAmB;gBACxB;YACF;YACAP,MAAMK,OAAO,IACX;QACJ;QAEA,MAAMK,IAAIV;QACV,sCAAsC;QACtC,IAAIG,4BAA4B;YAC9B,IAAI,CAACX,mBAAmB;gBACtBC,WAAWkB,IAAI,CAACD;YAClB;YACAlB,oBAAoB;QACtB;QACA,KAAK,MAAMoB,WAAWjB,cAAe;YACnCiB,QAAQF;QACV;IACF;IACArB,OAAOQ,gBAAgB,CACrB,sBACA,CAACC;QACC,MAAMe,SAASf,sBAAAA,GAAIe,MAAM;QACzB,IACE,CAACA,UACD,CAAEA,CAAAA,kBAAkBvB,KAAI,KACxB,OAAOuB,OAAOX,KAAK,KAAK,UACxB;YACA,8DAA8D;YAC9D;QACF;QAEA,MAAMQ,IAAIG;QACVnB,eAAeiB,IAAI,CAACD;QACpB,KAAK,MAAME,WAAWhB,kBAAmB;YACvCgB,QAAQF;QACV;IACF;AAEJ;AAEO,SAAStB,gBACd0B,sBAAoC,EACpCC,0BAAwC;IAExCC,IAAAA,gBAAS,EAAC;QACR,wBAAwB;QACxBvB,WAAWwB,OAAO,CAACH;QACnBpB,eAAeuB,OAAO,CAACF;QAEvB,wBAAwB;QACxBpB,cAAcgB,IAAI,CAACG;QACnBlB,kBAAkBe,IAAI,CAACI;QAEvB,OAAO;YACL,oBAAoB;YACpBpB,cAAcuB,MAAM,CAACvB,cAAcwB,OAAO,CAACL,yBAAyB;YACpElB,kBAAkBsB,MAAM,CACtBtB,kBAAkBuB,OAAO,CAACJ,6BAC1B;QAEJ;IACF,GAAG;QAACD;QAAwBC;KAA2B;AACzD"}

View File

@ -0,0 +1,5 @@
export declare function useOpenInEditor({ file, lineNumber, column, }?: {
file?: string | null;
lineNumber?: number | null;
column?: number | null;
}): () => void;

View File

@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useOpenInEditor", {
enumerable: true,
get: function() {
return useOpenInEditor;
}
});
const _react = require("react");
function useOpenInEditor(param) {
let { file, lineNumber, column } = param === void 0 ? {} : param;
const openInEditor = (0, _react.useCallback)(()=>{
if (file == null || lineNumber == null || column == null) return;
const params = new URLSearchParams();
params.append("file", file);
params.append("lineNumber", String(lineNumber));
params.append("column", String(column));
self.fetch((process.env.__NEXT_ROUTER_BASEPATH || "") + "/__nextjs_launch-editor?" + params.toString()).then(()=>{}, ()=>{
console.error("There was an issue opening this code in your editor.");
});
}, [
file,
lineNumber,
column
]);
return openInEditor;
}
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=use-open-in-editor.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/use-open-in-editor.ts"],"names":["useOpenInEditor","file","lineNumber","column","openInEditor","useCallback","params","URLSearchParams","append","String","self","fetch","process","env","__NEXT_ROUTER_BASEPATH","toString","then","console","error"],"mappings":";;;;+BAEgBA;;;eAAAA;;;uBAFY;AAErB,SAASA,gBAAgB;IAAA,IAAA,EAC9BC,IAAI,EACJC,UAAU,EACVC,MAAM,EAKP,GAR+B,mBAQ5B,CAAC,IAR2B;IAS9B,MAAMC,eAAeC,IAAAA,kBAAW,EAAC;QAC/B,IAAIJ,QAAQ,QAAQC,cAAc,QAAQC,UAAU,MAAM;QAE1D,MAAMG,SAAS,IAAIC;QACnBD,OAAOE,MAAM,CAAC,QAAQP;QACtBK,OAAOE,MAAM,CAAC,cAAcC,OAAOP;QACnCI,OAAOE,MAAM,CAAC,UAAUC,OAAON;QAE/BO,KACGC,KAAK,CACJ,AACEC,CAAAA,QAAQC,GAAG,CAACC,sBAAsB,IAAI,EAAC,IACxC,6BAA0BR,OAAOS,QAAQ,IAE3CC,IAAI,CACH,KAAO,GACP;YACEC,QAAQC,KAAK,CAAC;QAChB;IAEN,GAAG;QAACjB;QAAMC;QAAYC;KAAO;IAE7B,OAAOC;AACT"}

View File

@ -0,0 +1,6 @@
/// <reference types="react" />
import type { TurbopackMsgToBrowser } from '../../../../../server/dev/hot-reloader-types';
export declare function useWebsocket(assetPrefix: string): import("react").MutableRefObject<WebSocket | undefined>;
export declare function useSendMessage(webSocketRef: ReturnType<typeof useWebsocket>): (data: string) => void;
export declare function useTurbopack(sendMessage: ReturnType<typeof useSendMessage>, onUpdateError: (err: unknown) => void): (msg: TurbopackMsgToBrowser) => void;
export declare function useWebsocketPing(websocketRef: ReturnType<typeof useWebsocket>): void;

View File

@ -0,0 +1,129 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
useSendMessage: null,
useTurbopack: null,
useWebsocket: null,
useWebsocketPing: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
useSendMessage: function() {
return useSendMessage;
},
useTurbopack: function() {
return useTurbopack;
},
useWebsocket: function() {
return useWebsocket;
},
useWebsocketPing: function() {
return useWebsocketPing;
}
});
const _react = require("react");
const _approutercontextsharedruntime = require("../../../../../shared/lib/app-router-context.shared-runtime");
const _getsocketurl = require("./get-socket-url");
function useWebsocket(assetPrefix) {
const webSocketRef = (0, _react.useRef)();
(0, _react.useEffect)(()=>{
if (webSocketRef.current) {
return;
}
const url = (0, _getsocketurl.getSocketUrl)(assetPrefix);
webSocketRef.current = new window.WebSocket("" + url + "/_next/webpack-hmr");
}, [
assetPrefix
]);
return webSocketRef;
}
function useSendMessage(webSocketRef) {
const sendMessage = (0, _react.useCallback)((data)=>{
const socket = webSocketRef.current;
if (!socket || socket.readyState !== socket.OPEN) {
return;
}
return socket.send(data);
}, [
webSocketRef
]);
return sendMessage;
}
function useTurbopack(sendMessage, onUpdateError) {
const turbopackState = (0, _react.useRef)({
init: false,
// Until the dynamic import resolves, queue any turbopack messages which will be replayed.
queue: [],
callback: undefined
});
const processTurbopackMessage = (0, _react.useCallback)((msg)=>{
const { callback, queue } = turbopackState.current;
if (callback) {
callback(msg);
} else {
queue.push(msg);
}
}, []);
(0, _react.useEffect)(()=>{
const { current: initCurrent } = turbopackState;
// TODO(WEB-1589): only install if `process.turbopack` set.
if (initCurrent.init) {
return;
}
initCurrent.init = true;
import(// @ts-expect-error requires "moduleResolution": "node16" in tsconfig.json and not .ts extension
"@vercel/turbopack-ecmascript-runtime/dev/client/hmr-client.ts").then((param)=>{
let { connect } = param;
const { current } = turbopackState;
connect({
addMessageListener (cb) {
current.callback = cb;
// Replay all Turbopack messages before we were able to establish the HMR client.
for (const msg of current.queue){
cb(msg);
}
current.queue = undefined;
},
sendMessage,
onUpdateError
});
});
}, [
sendMessage,
onUpdateError
]);
return processTurbopackMessage;
}
function useWebsocketPing(websocketRef) {
const sendMessage = useSendMessage(websocketRef);
const { tree } = (0, _react.useContext)(_approutercontextsharedruntime.GlobalLayoutRouterContext);
(0, _react.useEffect)(()=>{
// Taken from on-demand-entries-client.js
const interval = setInterval(()=>{
sendMessage(JSON.stringify({
event: "ping",
tree,
appDirRoute: true
}));
}, 2500);
return ()=>clearInterval(interval);
}, [
tree,
sendMessage
]);
}
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=use-websocket.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/helpers/use-websocket.ts"],"names":["useSendMessage","useTurbopack","useWebsocket","useWebsocketPing","assetPrefix","webSocketRef","useRef","useEffect","current","url","getSocketUrl","window","WebSocket","sendMessage","useCallback","data","socket","readyState","OPEN","send","onUpdateError","turbopackState","init","queue","callback","undefined","processTurbopackMessage","msg","push","initCurrent","then","connect","addMessageListener","cb","websocketRef","tree","useContext","GlobalLayoutRouterContext","interval","setInterval","JSON","stringify","event","appDirRoute","clearInterval"],"mappings":";;;;;;;;;;;;;;;;;IAqBgBA,cAAc;eAAdA;;IAcAC,YAAY;eAAZA;;IA9BAC,YAAY;eAAZA;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