main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getSocketUrl", {
enumerable: true,
get: function() {
return getSocketUrl;
}
});
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 { hostname, port } = window.location;
const protocol = getSocketProtocol(assetPrefix);
const normalizedAssetPrefix = assetPrefix.replace(/^\/+/, "");
let url = protocol + "://" + hostname + ":" + port + (normalizedAssetPrefix ? "/" + normalizedAssetPrefix : "");
if (normalizedAssetPrefix.startsWith("http")) {
url = protocol + "://" + normalizedAssetPrefix.split("://")[1];
}
return url;
}
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","hostname","port","normalizedAssetPrefix","replace","url","startsWith","split"],"mappings":";;;;+BAWgBA;;;eAAAA;;;AAXhB,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,OAAO;AACvC;AAEO,SAASH,aAAaE,WAAmB;IAC9C,MAAM,EAAEK,QAAQ,EAAEC,IAAI,EAAE,GAAGJ,OAAOC,QAAQ;IAC1C,MAAMF,WAAWF,kBAAkBC;IACnC,MAAMO,wBAAwBP,YAAYQ,OAAO,CAAC,QAAQ;IAE1D,IAAIC,MAAM,AAAGR,WAAS,QAAKI,WAAS,MAAGC,OACrCC,CAAAA,wBAAwB,AAAC,MAAGA,wBAA0B,EAAC;IAGzD,IAAIA,sBAAsBG,UAAU,CAAC,SAAS;QAC5CD,MAAM,AAAGR,WAAS,QAAKM,sBAAsBI,KAAK,CAAC,MAAM,CAAC,EAAE;IAC9D;IAEA,OAAOF;AACT"}

View File

@@ -0,0 +1,11 @@
import { SupportedErrorEvent } from '../container/Errors';
import { OriginalStackFrame } from './stack-frame';
import { ComponentStackFrame } from './parse-component-stack';
export type ReadyRuntimeError = {
id: number;
runtime: true;
error: Error;
frames: OriginalStackFrame[];
componentStackFrames?: ComponentStackFrame[];
};
export declare function getErrorByType(ev: SupportedErrorEvent): 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 _erroroverlayreducer = require("../error-overlay-reducer");
const _nodeStackFrames = require("./nodeStackFrames");
const _stackframe = require("./stack-frame");
async function getErrorByType(ev) {
const { id, event } = ev;
switch(event.type){
case _erroroverlayreducer.ACTION_UNHANDLED_ERROR:
case _erroroverlayreducer.ACTION_UNHANDLED_REJECTION:
{
const readyRuntimeError = {
id,
runtime: true,
error: event.reason,
frames: await (0, _stackframe.getOriginalStackFrames)(event.frames, (0, _nodeStackFrames.getErrorSource)(event.reason), event.reason.toString())
};
if (event.type === _erroroverlayreducer.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","id","event","type","ACTION_UNHANDLED_ERROR","ACTION_UNHANDLED_REJECTION","readyRuntimeError","runtime","error","reason","frames","getOriginalStackFrames","getErrorSource","toString","componentStackFrames","_","Error"],"mappings":";;;;+BAiBsBA;;;eAAAA;;;qCAdf;iCAEwB;4BAC4B;AAWpD,eAAeA,eACpBC,EAAuB;IAEvB,MAAM,EAAEC,EAAE,EAAEC,KAAK,EAAE,GAAGF;IACtB,OAAQE,MAAMC,IAAI;QAChB,KAAKC,2CAAsB;QAC3B,KAAKC,+CAA0B;YAAE;gBAC/B,MAAMC,oBAAuC;oBAC3CL;oBACAM,SAAS;oBACTC,OAAON,MAAMO,MAAM;oBACnBC,QAAQ,MAAMC,IAAAA,kCAAsB,EAClCT,MAAMQ,MAAM,EACZE,IAAAA,+BAAc,EAACV,MAAMO,MAAM,GAC3BP,MAAMO,MAAM,CAACI,QAAQ;gBAEzB;gBACA,IAAIX,MAAMC,IAAI,KAAKC,2CAAsB,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,2 @@
import type { RawSourceMap } from 'source-map';
export declare function getRawSourceMap(fileContents: string): RawSourceMap | null;

View File

@@ -0,0 +1,45 @@
"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 {
// @ts-expect-error TODO-APP: fix type.
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":";;;;+BAMgBA;;;eAAAA;;;;0EAJT;iCAEyB;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;QACF,uCAAuC;QACvCA,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,27 @@
import type { OriginalStackFrame } from './stack-frame';
export type StackFramesGroup = {
framework?: 'next' | 'react';
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,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "groupStackFramesByFramework", {
enumerable: true,
get: function() {
return groupStackFramesByFramework;
}
});
/**
* Get the origin framework of the stack frame by package name.
*/ function getFramework(sourcePackage) {
if (!sourcePackage) return undefined;
if (/^(react|react-dom|react-is|react-refresh|react-server-dom-webpack|scheduler)$/.test(sourcePackage)) {
return "react";
} else if (sourcePackage === "next") {
return "next";
}
return undefined;
}
function groupStackFramesByFramework(stackFrames) {
const stackFramesGroupedByFramework = [];
for (const stackFrame of stackFrames){
const currentGroup = stackFramesGroupedByFramework[stackFramesGroupedByFramework.length - 1];
const framework = getFramework(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","getFramework","sourcePackage","undefined","test","stackFrames","stackFramesGroupedByFramework","stackFrame","currentGroup","length","framework","push"],"mappings":";;;;+BAiDgBA;;;eAAAA;;;AA1ChB;;CAEC,GACD,SAASC,aACPC,aAAiC;IAEjC,IAAI,CAACA,eAAe,OAAOC;IAE3B,IACE,gFAAgFC,IAAI,CAClFF,gBAEF;QACA,OAAO;IACT,OAAO,IAAIA,kBAAkB,QAAQ;QACnC,OAAO;IACT;IAEA,OAAOC;AACT;AAuBO,SAASH,4BACdK,WAAiC;IAEjC,MAAMC,gCAAoD,EAAE;IAE5D,KAAK,MAAMC,cAAcF,YAAa;QACpC,MAAMG,eACJF,6BAA6B,CAACA,8BAA8BG,MAAM,GAAG,EAAE;QACzE,MAAMC,YAAYT,aAAaM,WAAWL,aAAa;QAEvD,IAAIM,gBAAgBA,aAAaE,SAAS,KAAKA,WAAW;YACxDF,aAAaH,WAAW,CAACM,IAAI,CAACJ;QAChC,OAAO;YACLD,8BAA8BK,IAAI,CAAC;gBACjCD,WAAWA;gBACXL,aAAa;oBAACE;iBAAW;YAC3B;QACF;IACF;IAEA,OAAOD;AACT"}

View File

@@ -0,0 +1,9 @@
export declare let hydrationErrorWarning: string | undefined;
export declare let hydrationErrorComponentStack: string | undefined;
/**
* 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;

View File

@@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
hydrationErrorWarning: null,
hydrationErrorComponentStack: null,
patchConsoleError: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
hydrationErrorWarning: function() {
return hydrationErrorWarning;
},
hydrationErrorComponentStack: function() {
return hydrationErrorComponentStack;
},
patchConsoleError: function() {
return patchConsoleError;
}
});
let hydrationErrorWarning;
let hydrationErrorComponentStack;
// https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference
const knownHydrationWarnings = new Set([
'Warning: Text content did not match. Server: "%s" Client: "%s"%s',
"Warning: Expected server HTML to contain a matching <%s> in <%s>.%s",
'Warning: Expected server HTML to contain a matching text node for "%s" in <%s>.%s',
"Warning: Did not expect server HTML to contain a <%s> in <%s>.%s",
'Warning: Did not expect server HTML to contain the text node "%s" in <%s>.%s'
]);
function patchConsoleError() {
const prev = console.error;
console.error = function(msg, serverContent, clientContent, componentStack) {
if (knownHydrationWarnings.has(msg)) {
hydrationErrorWarning = msg.replace("%s", serverContent).replace("%s", clientContent).replace("%s", "");
hydrationErrorComponentStack = componentStack;
}
// @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":["hydrationErrorWarning","hydrationErrorComponentStack","patchConsoleError","knownHydrationWarnings","Set","prev","console","error","msg","serverContent","clientContent","componentStack","has","replace","apply","arguments"],"mappings":";;;;;;;;;;;;;;;;IAAWA,qBAAqB;eAArBA;;IACAC,4BAA4B;eAA5BA;;IAiBKC,iBAAiB;eAAjBA;;;AAlBT,IAAIF;AACJ,IAAIC;AAEX,iIAAiI;AACjI,MAAME,yBAAyB,IAAIC,IAAI;IACrC;IACA;IACA;IACA;IACA;CACD;AAQM,SAASF;IACd,MAAMG,OAAOC,QAAQC,KAAK;IAC1BD,QAAQC,KAAK,GAAG,SAAUC,GAAG,EAAEC,aAAa,EAAEC,aAAa,EAAEC,cAAc;QACzE,IAAIR,uBAAuBS,GAAG,CAACJ,MAAM;YACnCR,wBAAwBQ,IACrBK,OAAO,CAAC,MAAMJ,eACdI,OAAO,CAAC,MAAMH,eACdG,OAAO,CAAC,MAAM;YACjBZ,+BAA+BU;QACjC;QAEA,uCAAuC;QACvCN,KAAKS,KAAK,CAACR,SAASS;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,7 @@
import { StackFrame } from 'next/dist/compiled/stacktrace-parser';
export declare function getFilesystemFrame(frame: StackFrame): StackFrame;
export declare function getErrorSource(error: Error): 'server' | 'edge-server' | null;
type ErrorType = 'edge-server' | 'server';
export declare function decorateServerError(error: Error, type: ErrorType): void;
export declare function getServerError(error: Error, type: ErrorType): Error;
export {};

View File

@@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getFilesystemFrame: null,
getErrorSource: null,
decorateServerError: 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;
},
getErrorSource: function() {
return getErrorSource;
},
decorateServerError: function() {
return decorateServerError;
},
getServerError: function() {
return getServerError;
}
});
const _stacktraceparser = require("next/dist/compiled/stacktrace-parser");
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;
}
const symbolError = Symbol("NextjsError");
function getErrorSource(error) {
return error[symbolError] || null;
}
function decorateServerError(error, type) {
Object.defineProperty(error, symbolError, {
writable: false,
enumerable: false,
configurable: false,
value: type
});
}
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;
}
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","getErrorSource","decorateServerError","getServerError","frame","f","file","startsWith","test","symbolError","Symbol","error","type","Object","defineProperty","writable","enumerable","configurable","value","n","Error","message","e","name","stack","toString","parse","map","str","methodName","loc","lineNumber","column","join"],"mappings":";;;;;;;;;;;;;;;;;IAEgBA,kBAAkB;eAAlBA;;IAqBAC,cAAc;eAAdA;;IAMAC,mBAAmB;eAAnBA;;IASAC,cAAc;eAAdA;;;kCAtCkB;AAE3B,SAASH,mBAAmBI,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;AAEA,MAAMI,cAAcC,OAAO;AAEpB,SAAST,eAAeU,KAAY;IACzC,OAAO,AAACA,KAAa,CAACF,YAAY,IAAI;AACxC;AAIO,SAASP,oBAAoBS,KAAY,EAAEC,IAAe;IAC/DC,OAAOC,cAAc,CAACH,OAAOF,aAAa;QACxCM,UAAU;QACVC,YAAY;QACZC,cAAc;QACdC,OAAON;IACT;AACF;AAEO,SAAST,eAAeQ,KAAY,EAAEC,IAAe;IAC1D,IAAIO;IACJ,IAAI;QACF,MAAM,IAAIC,MAAMT,MAAMU,OAAO;IAC/B,EAAE,OAAOC,GAAG;QACVH,IAAIG;IACN;IAEAH,EAAEI,IAAI,GAAGZ,MAAMY,IAAI;IACnB,IAAI;QACFJ,EAAEK,KAAK,GAAG,AAAGL,EAAEM,QAAQ,KAAG,OAAIC,IAAAA,uBAAK,EAACf,MAAMa,KAAK,EAC5CG,GAAG,CAAC3B,oBACJ2B,GAAG,CAAC,CAACtB;YACJ,IAAIuB,MAAM,AAAC,YAASvB,EAAEwB,UAAU;YAChC,IAAIxB,EAAEC,IAAI,EAAE;gBACV,IAAIwB,MAAMzB,EAAEC,IAAI;gBAChB,IAAID,EAAE0B,UAAU,EAAE;oBAChBD,OAAO,AAAC,MAAGzB,EAAE0B,UAAU;oBACvB,IAAI1B,EAAE2B,MAAM,EAAE;wBACZF,OAAO,AAAC,MAAGzB,EAAE2B,MAAM;oBACrB;gBACF;gBACAJ,OAAO,AAAC,OAAIE,MAAI;YAClB;YACA,OAAOF;QACT,GACCK,IAAI,CAAC;IACV,EAAE,UAAM;QACNd,EAAEK,KAAK,GAAGb,MAAMa,KAAK;IACvB;IAEAtB,oBAAoBiB,GAAGP;IACvB,OAAOO;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,OAAA;QAAGA,KAAH,OAAA,KAAA,SAAA,CAAA,KAA0B;IAAD;IAEzB,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,7 @@
export type ComponentStackFrame = {
component: string;
file?: string;
lineNumber?: number;
column?: number;
};
export declare function parseComponentStack(componentStack: string): ComponentStackFrame[];

View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "parseComponentStack", {
enumerable: true,
get: function() {
return parseComponentStack;
}
});
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 webpackFile = match[3];
// Stop parsing the component stack if we reach a Next.js component
if (webpackFile == null ? void 0 : webpackFile.includes("next/dist")) {
break;
}
const modulePath = webpackFile == null ? void 0 : webpackFile.replace(/^(webpack-internal:\/\/\/|file:\/\/)(\(.*\)\/)?/, "");
var _modulePath_split;
const [file, lineNumber, column] = (_modulePath_split = modulePath == null ? void 0 : modulePath.split(":")) != null ? _modulePath_split : [];
componentStackFrames.push({
component,
file,
lineNumber: lineNumber ? Number(lineNumber) : undefined,
column: column ? Number(column) : undefined
});
}
}
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","componentStack","componentStackFrames","line","trim","split","match","exec","component","webpackFile","includes","modulePath","replace","file","lineNumber","column","push","Number","undefined"],"mappings":";;;;+BAOgBA;;;eAAAA;;;AAAT,SAASA,oBACdC,cAAsB;IAEtB,MAAMC,uBAA8C,EAAE;IAEtD,KAAK,MAAMC,QAAQF,eAAeG,IAAI,GAAGC,KAAK,CAAC,MAAO;QACpD,uDAAuD;QACvD,MAAMC,QAAQ,yBAAyBC,IAAI,CAACJ;QAC5C,IAAIG,yBAAAA,KAAO,CAAC,EAAE,EAAE;YACd,MAAME,YAAYF,KAAK,CAAC,EAAE;YAC1B,MAAMG,cAAcH,KAAK,CAAC,EAAE;YAE5B,mEAAmE;YACnE,IAAIG,+BAAAA,YAAaC,QAAQ,CAAC,cAAc;gBACtC;YACF;YAEA,MAAMC,aAAaF,+BAAAA,YAAaG,OAAO,CACrC,mDACA;gBAEiCD;YAAnC,MAAM,CAACE,MAAMC,YAAYC,OAAO,GAAGJ,CAAAA,oBAAAA,8BAAAA,WAAYN,KAAK,CAAC,gBAAlBM,oBAA0B,EAAE;YAE/DT,qBAAqBc,IAAI,CAAC;gBACxBR;gBACAK;gBACAC,YAAYA,aAAaG,OAAOH,cAAcI;gBAC9CH,QAAQA,SAASE,OAAOF,UAAUG;YACpC;QACF;IACF;IAEA,OAAOhB;AACT"}

View File

@@ -0,0 +1,2 @@
import { 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\/.+)/g;
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());
}
}
} 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"],"mappings":";;;;+BAIgBA;;;eAAAA;;;kCAJkB;AAElC,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;gBACjD;YACF;QACF,EAAE,UAAM,CAAC;QACT,OAAOb;IACT;AACF"}

View File

@@ -0,0 +1,32 @@
import { StackFrame } from 'next/dist/compiled/stacktrace-parser';
export type OriginalStackFrame = {
error: true;
reason: string;
external: false;
expanded: false;
sourceStackFrame: StackFrame;
originalStackFrame: null;
originalCodeFrame: null;
sourcePackage?: string;
} | {
error: false;
reason: null;
external: false;
expanded: boolean;
sourceStackFrame: StackFrame;
originalStackFrame: StackFrame;
originalCodeFrame: string | null;
sourcePackage?: string;
} | {
error: false;
reason: null;
external: true;
expanded: false;
sourceStackFrame: StackFrame;
originalStackFrame: null;
originalCodeFrame: null;
sourcePackage?: string;
};
export declare function getOriginalStackFrame(source: StackFrame, type: 'server' | 'edge-server' | null, errorMessage: string): Promise<OriginalStackFrame>;
export declare function getOriginalStackFrames(frames: StackFrame[], type: 'server' | 'edge-server' | null, errorMessage: string): Promise<OriginalStackFrame[]>;
export declare function getFrameSource(frame: StackFrame): string;

View File

@@ -0,0 +1,126 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getOriginalStackFrame: null,
getOriginalStackFrames: null,
getFrameSource: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getOriginalStackFrame: function() {
return getOriginalStackFrame;
},
getOriginalStackFrames: function() {
return getOriginalStackFrames;
},
getFrameSource: function() {
return getFrameSource;
}
});
function getOriginalStackFrame(source, type, errorMessage) {
var _source_file, _source_file1;
async function _getOriginalStackFrame() {
var /* collapsed */ _source_file, _body_originalStackFrame_file, _body_originalStackFrame;
const params = new URLSearchParams();
params.append("isServer", String(type === "server"));
params.append("isEdgeServer", String(type === "edge-server"));
params.append("isAppDirectory", "true");
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"))) != null ? _ref : true),
sourceStackFrame: source,
originalStackFrame: body.originalStackFrame,
originalCodeFrame: body.originalCodeFrame || null,
sourcePackage: body.sourcePackage
};
}
if (!(((_source_file = source.file) == null ? void 0 : _source_file.startsWith("webpack-internal:")) || ((_source_file1 = source.file) == null ? void 0 : _source_file1.startsWith("file:")))) {
return Promise.resolve({
error: false,
reason: null,
external: true,
expanded: false,
sourceStackFrame: source,
originalStackFrame: null,
originalCodeFrame: null
});
}
var _err_message, _ref;
return _getOriginalStackFrame().catch((err)=>({
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
}));
}
function getOriginalStackFrames(frames, type, errorMessage) {
return Promise.all(frames.map((frame)=>getOriginalStackFrame(frame, type, errorMessage)));
}
function getFrameSource(frame) {
let str = "";
try {
var _globalThis_location;
const u = new URL(frame.file);
// Strip the origin for same-origin scripts.
if (typeof globalThis !== "undefined" && ((_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 += " ";
} catch (e) {
str += (frame.file || "(unknown)") + " ";
}
if (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":["getOriginalStackFrame","getOriginalStackFrames","getFrameSource","source","type","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","sourceStackFrame","originalCodeFrame","sourcePackage","startsWith","resolve","err","catch","message","frames","all","map","frame","str","globalThis","u","URL","location","origin","protocol","pathname","lineNumber","column","slice"],"mappings":";;;;;;;;;;;;;;;;IAmCgBA,qBAAqB;eAArBA;;IA+EAC,sBAAsB;eAAtBA;;IAUAC,cAAc;eAAdA;;;AAzFT,SAASF,sBACdG,MAAkB,EAClBC,IAAqC,EACrCC,YAAoB;QAkDhBF,cACAA;IAjDJ,eAAeG;YAkCT,aAAa,GACZH,cACCI,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BP,OAAO;IACT,EAAE,UAAM;QACNA,OAAO,AAACD,CAAAA,MAAMd,IAAI,IAAI,WAAU,IAAK;IACvC;IAEA,IAAIc,MAAMS,UAAU,IAAI,MAAM;QAC5B,IAAIT,MAAMU,MAAM,IAAI,MAAM;YACxBT,OAAO,AAAC,MAAGD,MAAMS,UAAU,GAAC,MAAGT,MAAMU,MAAM,GAAC;QAC9C,OAAO;YACLT,OAAO,AAAC,MAAGD,MAAMS,UAAU,GAAC;QAC9B;IACF;IACA,OAAOR,IAAIU,KAAK,CAAC,GAAG,CAAC;AACvB"}

View File

@@ -0,0 +1,5 @@
export type ErrorHandler = (error: Error) => void;
export declare const RuntimeErrorHandler: {
hadRuntimeError: boolean;
};
export declare function useErrorHandler(handleOnUnhandledError: ErrorHandler, handleOnUnhandledRejection: ErrorHandler): void;

View File

@@ -0,0 +1,111 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
RuntimeErrorHandler: null,
useErrorHandler: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
RuntimeErrorHandler: function() {
return RuntimeErrorHandler;
},
useErrorHandler: function() {
return useErrorHandler;
}
});
const _react = require("react");
const _hydrationerrorinfo = require("./hydration-error-info");
const _isnextroutererror = require("../../../is-next-router-error");
const RuntimeErrorHandler = {
hadRuntimeError: false
};
function isHydrationError(error) {
return error.message.match(/(hydration|content does not match|did not match)/i) != null;
}
if (typeof window !== "undefined") {
try {
// Increase the number of stack frames on the client
Error.stackTraceLimit = 50;
} catch (e) {}
}
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;
}
if (isHydrationError(error) && !error.message.includes("https://nextjs.org/docs/messages/react-hydration-error")) {
if (_hydrationerrorinfo.hydrationErrorWarning) {
// The patched console.error found hydration errors logged by React
// Append the logged warning to the error message
error.message += "\n\n" + _hydrationerrorinfo.hydrationErrorWarning;
}
if (_hydrationerrorinfo.hydrationErrorComponentStack) {
error._componentStack = _hydrationerrorinfo.hydrationErrorComponentStack;
}
error.message += "\n\nSee more info here: https://nextjs.org/docs/messages/react-hydration-error";
}
const e = error;
errorQueue.push(e);
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":["RuntimeErrorHandler","useErrorHandler","hadRuntimeError","isHydrationError","error","message","match","window","Error","stackTraceLimit","errorQueue","rejectionQueue","errorHandlers","rejectionHandlers","addEventListener","ev","isNextRouterError","preventDefault","stack","includes","hydrationErrorWarning","hydrationErrorComponentStack","_componentStack","e","push","handler","reason","handleOnUnhandledError","handleOnUnhandledRejection","useEffect","forEach","splice","indexOf"],"mappings":";;;;;;;;;;;;;;;IASaA,mBAAmB;eAAnBA;;IA0FGC,eAAe;eAAfA;;;uBAnGU;oCAInB;mCAC2B;AAI3B,MAAMD,sBAAsB;IACjCE,iBAAiB;AACnB;AAEA,SAASC,iBAAiBC,KAAY;IACpC,OACEA,MAAMC,OAAO,CAACC,KAAK,CAAC,wDACpB;AAEJ;AAEA,IAAI,OAAOC,WAAW,aAAa;IACjC,IAAI;QACF,oDAAoD;QACpDC,MAAMC,eAAe,GAAG;IAC1B,EAAE,UAAM,CAAC;AACX;AAEA,MAAMC,aAA2B,EAAE;AACnC,MAAMC,iBAA+B,EAAE;AACvC,MAAMC,gBAAqC,EAAE;AAC7C,MAAMC,oBAAyC,EAAE;AAEjD,IAAI,OAAON,WAAW,aAAa;IACjC,6EAA6E;IAC7E,0EAA0E;IAC1E,yBAAyB;IACzBA,OAAOO,gBAAgB,CAAC,SAAS,CAACC;QAChC,IAAIC,IAAAA,oCAAiB,EAACD,GAAGX,KAAK,GAAG;YAC/BW,GAAGE,cAAc;YACjB;QACF;QAEA,MAAMb,QAAQW,sBAAAA,GAAIX,KAAK;QACvB,IACE,CAACA,SACD,CAAEA,CAAAA,iBAAiBI,KAAI,KACvB,OAAOJ,MAAMc,KAAK,KAAK,UACvB;YACA,8DAA8D;YAC9D;QACF;QAEA,IACEf,iBAAiBC,UACjB,CAACA,MAAMC,OAAO,CAACc,QAAQ,CACrB,2DAEF;YACA,IAAIC,yCAAqB,EAAE;gBACzB,mEAAmE;gBACnE,iDAAiD;gBACjDhB,MAAMC,OAAO,IAAI,SAASe,yCAAqB;YACjD;YACA,IAAIC,gDAA4B,EAAE;gBAE9BjB,MAAckB,eAAe,GAAGD,gDAA4B;YAChE;YACAjB,MAAMC,OAAO,IACX;QACJ;QAEA,MAAMkB,IAAInB;QACVM,WAAWc,IAAI,CAACD;QAChB,KAAK,MAAME,WAAWb,cAAe;YACnCa,QAAQF;QACV;IACF;IACAhB,OAAOO,gBAAgB,CACrB,sBACA,CAACC;QACC,MAAMW,SAASX,sBAAAA,GAAIW,MAAM;QACzB,IACE,CAACA,UACD,CAAEA,CAAAA,kBAAkBlB,KAAI,KACxB,OAAOkB,OAAOR,KAAK,KAAK,UACxB;YACA,8DAA8D;YAC9D;QACF;QAEA,MAAMK,IAAIG;QACVf,eAAea,IAAI,CAACD;QACpB,KAAK,MAAME,WAAWZ,kBAAmB;YACvCY,QAAQF;QACV;IACF;AAEJ;AAEO,SAAStB,gBACd0B,sBAAoC,EACpCC,0BAAwC;IAExCC,IAAAA,gBAAS,EAAC;QACR,wBAAwB;QACxBnB,WAAWoB,OAAO,CAACH;QACnBhB,eAAemB,OAAO,CAACF;QAEvB,wBAAwB;QACxBhB,cAAcY,IAAI,CAACG;QACnBd,kBAAkBW,IAAI,CAACI;QAEvB,OAAO;YACL,oBAAoB;YACpBhB,cAAcmB,MAAM,CAACnB,cAAcoB,OAAO,CAACL,yBAAyB;YACpEd,kBAAkBkB,MAAM,CACtBlB,kBAAkBmB,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 { HMR_ACTION_TYPES } 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>): (msg: HMR_ACTION_TYPES) => boolean;
export declare function useWebsocketPing(websocketRef: ReturnType<typeof useWebsocket>): void;

View File

@@ -0,0 +1,132 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
useWebsocket: null,
useSendMessage: null,
useTurbopack: null,
useWebsocketPing: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
useWebsocket: function() {
return useWebsocket;
},
useSendMessage: function() {
return useSendMessage;
},
useTurbopack: function() {
return useTurbopack;
},
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) {
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)=>{
var _msg_type;
if ("type" in msg && ((_msg_type = msg.type) == null ? void 0 : _msg_type.startsWith("turbopack-"))) {
const { callback, queue } = turbopackState.current;
if (callback) {
callback(msg);
} else {
queue.push(msg);
}
return true;
}
return false;
}, []);
(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
});
});
}, [
sendMessage
]);
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":["useWebsocket","useSendMessage","useTurbopack","useWebsocketPing","assetPrefix","webSocketRef","useRef","useEffect","current","url","getSocketUrl","window","WebSocket","sendMessage","useCallback","data","socket","readyState","OPEN","send","turbopackState","init","queue","callback","undefined","processTurbopackMessage","msg","type","startsWith","push","initCurrent","then","connect","addMessageListener","cb","websocketRef","tree","useContext","GlobalLayoutRouterContext","interval","setInterval","JSON","stringify","event","appDirRoute","clearInterval"],"mappings":";;;;;;;;;;;;;;;;;IASgBA,YAAY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