inital commit

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

View File

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

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "css", {
enumerable: true,
get: function() {
return css;
}
});
function css(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;
const str = // Convert template literal into a single line string
strings.slice(0, lastIndex).reduce((p, s, i)=>p + s + keys[i], '') + strings[lastIndex];
return str// Remove comments
.replace(/\/\*[\s\S]*?\*\//g, '')// Remove whitespace, tabs, and newlines
.replace(/\s+/g, ' ')// Remove spaces before and after semicolons, and spaces after commas
.replace(/\s*([:;,{}])\s*/g, '$1')// Remove extra semicolons
.replace(/;+}/g, '}')// Trim leading and trailing whitespaces
.trim();
}
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=css.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/utils/css.ts"],"sourcesContent":["export function css(\n strings: TemplateStringsArray,\n ...keys: readonly string[]\n): string {\n const lastIndex = strings.length - 1\n const str =\n // Convert template literal into a single line string\n strings.slice(0, lastIndex).reduce((p, s, i) => p + s + keys[i], '') +\n strings[lastIndex]\n\n return (\n str\n // Remove comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n // Remove whitespace, tabs, and newlines\n .replace(/\\s+/g, ' ')\n // Remove spaces before and after semicolons, and spaces after commas\n .replace(/\\s*([:;,{}])\\s*/g, '$1')\n // Remove extra semicolons\n .replace(/;+}/g, '}')\n // Trim leading and trailing whitespaces\n .trim()\n )\n}\n"],"names":["css","strings","keys","lastIndex","length","str","slice","reduce","p","s","i","replace","trim"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,IACdC,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,MAAMC,MACJ,qDAAqD;IACrDJ,QAAQK,KAAK,CAAC,GAAGH,WAAWI,MAAM,CAAC,CAACC,GAAGC,GAAGC,IAAMF,IAAIC,IAAIP,IAAI,CAACQ,EAAE,EAAE,MACjET,OAAO,CAACE,UAAU;IAEpB,OACEE,GACE,kBAAkB;KACjBM,OAAO,CAAC,qBAAqB,GAC9B,wCAAwC;KACvCA,OAAO,CAAC,QAAQ,IACjB,qEAAqE;KACpEA,OAAO,CAAC,oBAAoB,KAC7B,0BAA0B;KACzBA,OAAO,CAAC,QAAQ,IACjB,wCAAwC;KACvCC,IAAI;AAEX"}

View File

@@ -0,0 +1,5 @@
export declare function useIsDevRendering(): boolean;
export declare const devRenderIndicator: {
show: () => void;
hide: () => void;
};

View File

@@ -0,0 +1,58 @@
/*
* Singleton store to track whether the app is currently being rendered
* Used by the dev tools indicator to show render status
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
devRenderIndicator: null,
useIsDevRendering: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
devRenderIndicator: function() {
return devRenderIndicator;
},
useIsDevRendering: function() {
return useIsDevRendering;
}
});
const _react = require("react");
let isVisible = false;
let listeners = [];
const subscribe = (listener)=>{
listeners.push(listener);
return ()=>{
listeners = listeners.filter((l)=>l !== listener);
};
};
const getSnapshot = ()=>isVisible;
const show = ()=>{
isVisible = true;
listeners.forEach((listener)=>listener());
};
const hide = ()=>{
isVisible = false;
listeners.forEach((listener)=>listener());
};
function useIsDevRendering() {
return (0, _react.useSyncExternalStore)(subscribe, getSnapshot);
}
const devRenderIndicator = {
show,
hide
};
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=dev-render-indicator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/utils/dev-indicator/dev-render-indicator.tsx"],"sourcesContent":["/*\n * Singleton store to track whether the app is currently being rendered\n * Used by the dev tools indicator to show render status\n */\n\nimport { useSyncExternalStore } from 'react'\n\nlet isVisible = false\nlet listeners: Array<() => void> = []\n\nconst subscribe = (listener: () => void) => {\n listeners.push(listener)\n return () => {\n listeners = listeners.filter((l) => l !== listener)\n }\n}\n\nconst getSnapshot = () => isVisible\n\nconst show = () => {\n isVisible = true\n listeners.forEach((listener) => listener())\n}\n\nconst hide = () => {\n isVisible = false\n listeners.forEach((listener) => listener())\n}\n\nexport function useIsDevRendering() {\n return useSyncExternalStore(subscribe, getSnapshot)\n}\n\nexport const devRenderIndicator = {\n show,\n hide,\n}\n"],"names":["devRenderIndicator","useIsDevRendering","isVisible","listeners","subscribe","listener","push","filter","l","getSnapshot","show","forEach","hide","useSyncExternalStore"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;;;;;IA8BYA,kBAAkB;eAAlBA;;IAJGC,iBAAiB;eAAjBA;;;uBAxBqB;AAErC,IAAIC,YAAY;AAChB,IAAIC,YAA+B,EAAE;AAErC,MAAMC,YAAY,CAACC;IACjBF,UAAUG,IAAI,CAACD;IACf,OAAO;QACLF,YAAYA,UAAUI,MAAM,CAAC,CAACC,IAAMA,MAAMH;IAC5C;AACF;AAEA,MAAMI,cAAc,IAAMP;AAE1B,MAAMQ,OAAO;IACXR,YAAY;IACZC,UAAUQ,OAAO,CAAC,CAACN,WAAaA;AAClC;AAEA,MAAMO,OAAO;IACXV,YAAY;IACZC,UAAUQ,OAAO,CAAC,CAACN,WAAaA;AAClC;AAEO,SAASJ;IACd,OAAOY,IAAAA,2BAAoB,EAACT,WAAWK;AACzC;AAEO,MAAMT,qBAAqB;IAChCU;IACAE;AACF"}

View File

@@ -0,0 +1 @@
export declare const useSyncDevRenderIndicatorInternal: () => import("react").TransitionStartFunction;

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useSyncDevRenderIndicatorInternal", {
enumerable: true,
get: function() {
return useSyncDevRenderIndicatorInternal;
}
});
const _react = require("react");
const _devrenderindicator = require("./dev-render-indicator");
const useSyncDevRenderIndicatorInternal = ()=>{
const [isPending, startTransition] = (0, _react.useTransition)();
(0, _react.useEffect)(()=>{
if (isPending) {
_devrenderindicator.devRenderIndicator.show();
} else {
_devrenderindicator.devRenderIndicator.hide();
}
}, [
isPending
]);
return startTransition;
};
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-sync-dev-render-indicator-internal.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/utils/dev-indicator/use-sync-dev-render-indicator-internal.tsx"],"sourcesContent":["import { useEffect, useTransition } from 'react'\nimport { devRenderIndicator } from './dev-render-indicator'\n\nexport const useSyncDevRenderIndicatorInternal = () => {\n const [isPending, startTransition] = useTransition()\n\n useEffect(() => {\n if (isPending) {\n devRenderIndicator.show()\n } else {\n devRenderIndicator.hide()\n }\n }, [isPending])\n\n return startTransition\n}\n"],"names":["useSyncDevRenderIndicatorInternal","isPending","startTransition","useTransition","useEffect","devRenderIndicator","show","hide"],"mappings":";;;;+BAGaA;;;eAAAA;;;uBAH4B;oCACN;AAE5B,MAAMA,oCAAoC;IAC/C,MAAM,CAACC,WAAWC,gBAAgB,GAAGC,IAAAA,oBAAa;IAElDC,IAAAA,gBAAS,EAAC;QACR,IAAIH,WAAW;YACbI,sCAAkB,CAACC,IAAI;QACzB,OAAO;YACLD,sCAAkB,CAACE,IAAI;QACzB;IACF,GAAG;QAACN;KAAU;IAEd,OAAOC;AACT"}

View File

@@ -0,0 +1,6 @@
/**
* Returns a transition function that can be used to wrap router actions.
* This allows us to tap into the transition state of the router as an
* approximation of React render time.
*/
export declare const useSyncDevRenderIndicator: () => (fn: () => void) => void;

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useSyncDevRenderIndicator", {
enumerable: true,
get: function() {
return useSyncDevRenderIndicator;
}
});
const NOOP = (fn)=>fn();
const useSyncDevRenderIndicator = ()=>{
let syncDevRenderIndicator = NOOP;
if (process.env.NODE_ENV === 'development') {
const { useSyncDevRenderIndicatorInternal } = require('./use-sync-dev-render-indicator-internal');
// eslint-disable-next-line react-hooks/rules-of-hooks
syncDevRenderIndicator = useSyncDevRenderIndicatorInternal();
}
return syncDevRenderIndicator;
};
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-sync-dev-render-indicator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/utils/dev-indicator/use-sync-dev-render-indicator.tsx"],"sourcesContent":["const NOOP = (fn: () => void) => fn()\n\n/**\n * Returns a transition function that can be used to wrap router actions.\n * This allows us to tap into the transition state of the router as an\n * approximation of React render time.\n */\nexport const useSyncDevRenderIndicator = () => {\n let syncDevRenderIndicator = NOOP\n\n if (process.env.NODE_ENV === 'development') {\n const { useSyncDevRenderIndicatorInternal } =\n require('./use-sync-dev-render-indicator-internal') as typeof import('./use-sync-dev-render-indicator-internal')\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n syncDevRenderIndicator = useSyncDevRenderIndicatorInternal()\n }\n\n return syncDevRenderIndicator\n}\n"],"names":["useSyncDevRenderIndicator","NOOP","fn","syncDevRenderIndicator","process","env","NODE_ENV","useSyncDevRenderIndicatorInternal","require"],"mappings":";;;;+BAOaA;;;eAAAA;;;AAPb,MAAMC,OAAO,CAACC,KAAmBA;AAO1B,MAAMF,4BAA4B;IACvC,IAAIG,yBAAyBF;IAE7B,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,MAAM,EAAEC,iCAAiC,EAAE,GACzCC,QAAQ;QAEV,sDAAsD;QACtDL,yBAAyBI;IAC3B;IAEA,OAAOJ;AACT"}

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].startsWith('Module not found: ')) {
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

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -0,0 +1,111 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getErrorByType: null,
useFrames: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getErrorByType: function() {
return getErrorByType;
},
useFrames: function() {
return useFrames;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _shared = require("../shared");
const _stackframe = require("./stack-frame");
const _errorsource = require("../../../../shared/lib/error-source");
const _react = /*#__PURE__*/ _interop_require_default._(require("react"));
const useFrames = (error)=>{
if ('use' in _react.default) {
const frames = error.frames;
if (typeof frames !== 'function') {
throw Object.defineProperty(new Error('Invariant: frames must be a function when the React version has React.use. This is a bug in Next.js.'), "__NEXT_ERROR_CODE", {
value: "E636",
enumerable: false,
configurable: true
});
}
return _react.default.use(frames());
} else {
if (!Array.isArray(error.frames)) {
throw Object.defineProperty(new Error('Invariant: frames must be an array when the React version does not have React.use. This is a bug in Next.js.'), "__NEXT_ERROR_CODE", {
value: "E637",
enumerable: false,
configurable: true
});
}
return error.frames;
}
};
async function getErrorByType(ev, isAppDir) {
const { id, event } = ev;
switch(event.type){
case _shared.ACTION_UNHANDLED_ERROR:
case _shared.ACTION_UNHANDLED_REJECTION:
{
const baseError = {
id,
runtime: true,
error: event.reason
};
if ('use' in _react.default) {
const readyRuntimeError = {
...baseError,
// createMemoizedPromise dedups calls to getOriginalStackFrames
frames: createMemoizedPromise(async ()=>{
return await (0, _stackframe.getOriginalStackFrames)(event.frames, (0, _errorsource.getErrorSource)(event.reason), isAppDir);
})
};
if (event.type === _shared.ACTION_UNHANDLED_ERROR) {
readyRuntimeError.componentStackFrames = event.componentStackFrames;
}
return readyRuntimeError;
} else {
const readyRuntimeError = {
...baseError,
// createMemoizedPromise dedups calls to getOriginalStackFrames
frames: await (0, _stackframe.getOriginalStackFrames)(event.frames, (0, _errorsource.getErrorSource)(event.reason), isAppDir)
};
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 Object.defineProperty(new Error('type system invariant violation'), "__NEXT_ERROR_CODE", {
value: "E335",
enumerable: false,
configurable: true
});
}
function createMemoizedPromise(promiseFactory) {
const cachedPromise = promiseFactory();
return function() {
return cachedPromise;
};
}
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-error-by-type.js.map

File diff suppressed because one or more lines are too long

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/utils/get-socket-url.ts"],"sourcesContent":["import { normalizedAssetPrefix } from '../../../../shared/lib/normalized-asset-prefix'\n\nfunction getSocketProtocol(assetPrefix: string): string {\n let protocol = window.location.protocol\n\n try {\n // assetPrefix is a url\n protocol = new URL(assetPrefix).protocol\n } catch {}\n\n return protocol === 'http:' ? 'ws:' : 'wss:'\n}\n\nexport function getSocketUrl(assetPrefix: string | undefined): string {\n const prefix = normalizedAssetPrefix(assetPrefix)\n const protocol = getSocketProtocol(assetPrefix || '')\n\n if (URL.canParse(prefix)) {\n // since normalized asset prefix is ensured to be a URL format,\n // we can safely replace the protocol\n return prefix.replace(/^http/, 'ws')\n }\n\n const { hostname, port } = window.location\n return `${protocol}//${hostname}${port ? `:${port}` : ''}${prefix}`\n}\n"],"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,2 @@
import type { RawSourceMap } from 'next/dist/compiled/source-map08';
export declare function getSourceMapFromFile(filename: string): Promise<RawSourceMap | undefined>;

View File

@@ -0,0 +1,88 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getSourceMapFromFile", {
enumerable: true,
get: function() {
return getSourceMapFromFile;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _promises = /*#__PURE__*/ _interop_require_default._(require("fs/promises"));
const _path = /*#__PURE__*/ _interop_require_default._(require("path"));
const _url = /*#__PURE__*/ _interop_require_default._(require("url"));
const _datauritobuffer = /*#__PURE__*/ _interop_require_default._(require("next/dist/compiled/data-uri-to-buffer"));
const _getsourcemapurl = require("./get-source-map-url");
async function getSourceMapFromFile(filename) {
filename = filename.startsWith('file://') ? _url.default.fileURLToPath(filename) : filename;
let fileContents;
try {
fileContents = await _promises.default.readFile(filename, 'utf-8');
} catch (error) {
throw Object.defineProperty(new Error("Failed to read file contents of " + filename + ".", {
cause: error
}), "__NEXT_ERROR_CODE", {
value: "E466",
enumerable: false,
configurable: true
});
}
const sourceUrl = (0, _getsourcemapurl.getSourceMapUrl)(fileContents);
if (!sourceUrl) {
return undefined;
}
if (sourceUrl.startsWith('data:')) {
let buffer;
try {
buffer = (0, _datauritobuffer.default)(sourceUrl);
} catch (error) {
throw Object.defineProperty(new Error("Failed to parse source map URL for " + filename + ".", {
cause: error
}), "__NEXT_ERROR_CODE", {
value: "E199",
enumerable: false,
configurable: true
});
}
if (buffer.type !== 'application/json') {
throw Object.defineProperty(new Error("Unknown source map type for " + filename + ": " + buffer.typeFull + "."), "__NEXT_ERROR_CODE", {
value: "E113",
enumerable: false,
configurable: true
});
}
try {
return JSON.parse(buffer.toString());
} catch (error) {
throw Object.defineProperty(new Error("Failed to parse source map for " + filename + ".", {
cause: error
}), "__NEXT_ERROR_CODE", {
value: "E318",
enumerable: false,
configurable: true
});
}
}
const sourceMapFilename = _path.default.resolve(_path.default.dirname(filename), decodeURIComponent(sourceUrl));
try {
const sourceMapContents = await _promises.default.readFile(sourceMapFilename, 'utf-8');
return JSON.parse(sourceMapContents.toString());
} catch (error) {
throw Object.defineProperty(new Error("Failed to parse source map " + sourceMapFilename + ".", {
cause: error
}), "__NEXT_ERROR_CODE", {
value: "E220",
enumerable: false,
configurable: true
});
}
}
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-source-map-from-file.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/utils/get-source-map-from-file.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\nimport url from 'url'\nimport type { RawSourceMap } from 'next/dist/compiled/source-map08'\nimport dataUriToBuffer from 'next/dist/compiled/data-uri-to-buffer'\nimport { getSourceMapUrl } from './get-source-map-url'\n\nexport async function getSourceMapFromFile(\n filename: string\n): Promise<RawSourceMap | undefined> {\n filename = filename.startsWith('file://')\n ? url.fileURLToPath(filename)\n : filename\n\n let fileContents: string\n\n try {\n fileContents = await fs.readFile(filename, 'utf-8')\n } catch (error) {\n throw new Error(`Failed to read file contents of ${filename}.`, {\n cause: error,\n })\n }\n\n const sourceUrl = getSourceMapUrl(fileContents)\n\n if (!sourceUrl) {\n return undefined\n }\n\n if (sourceUrl.startsWith('data:')) {\n let buffer: dataUriToBuffer.MimeBuffer\n\n try {\n buffer = dataUriToBuffer(sourceUrl)\n } catch (error) {\n throw new Error(`Failed to parse source map URL for ${filename}.`, {\n cause: error,\n })\n }\n\n if (buffer.type !== 'application/json') {\n throw new Error(\n `Unknown source map type for ${filename}: ${buffer.typeFull}.`\n )\n }\n\n try {\n return JSON.parse(buffer.toString())\n } catch (error) {\n throw new Error(`Failed to parse source map for ${filename}.`, {\n cause: error,\n })\n }\n }\n\n const sourceMapFilename = path.resolve(\n path.dirname(filename),\n decodeURIComponent(sourceUrl)\n )\n\n try {\n const sourceMapContents = await fs.readFile(sourceMapFilename, 'utf-8')\n\n return JSON.parse(sourceMapContents.toString())\n } catch (error) {\n throw new Error(`Failed to parse source map ${sourceMapFilename}.`, {\n cause: error,\n })\n }\n}\n"],"names":["getSourceMapFromFile","filename","startsWith","url","fileURLToPath","fileContents","fs","readFile","error","Error","cause","sourceUrl","getSourceMapUrl","undefined","buffer","dataUriToBuffer","type","typeFull","JSON","parse","toString","sourceMapFilename","path","resolve","dirname","decodeURIComponent","sourceMapContents"],"mappings":";;;;+BAOsBA;;;eAAAA;;;;mEAPP;+DACE;8DACD;0EAEY;iCACI;AAEzB,eAAeA,qBACpBC,QAAgB;IAEhBA,WAAWA,SAASC,UAAU,CAAC,aAC3BC,YAAG,CAACC,aAAa,CAACH,YAClBA;IAEJ,IAAII;IAEJ,IAAI;QACFA,eAAe,MAAMC,iBAAE,CAACC,QAAQ,CAACN,UAAU;IAC7C,EAAE,OAAOO,OAAO;QACd,MAAM,qBAEJ,CAFI,IAAIC,MAAM,AAAC,qCAAkCR,WAAS,KAAI;YAC9DS,OAAOF;QACT,IAFM,qBAAA;mBAAA;wBAAA;0BAAA;QAEL;IACH;IAEA,MAAMG,YAAYC,IAAAA,gCAAe,EAACP;IAElC,IAAI,CAACM,WAAW;QACd,OAAOE;IACT;IAEA,IAAIF,UAAUT,UAAU,CAAC,UAAU;QACjC,IAAIY;QAEJ,IAAI;YACFA,SAASC,IAAAA,wBAAe,EAACJ;QAC3B,EAAE,OAAOH,OAAO;YACd,MAAM,qBAEJ,CAFI,IAAIC,MAAM,AAAC,wCAAqCR,WAAS,KAAI;gBACjES,OAAOF;YACT,IAFM,qBAAA;uBAAA;4BAAA;8BAAA;YAEL;QACH;QAEA,IAAIM,OAAOE,IAAI,KAAK,oBAAoB;YACtC,MAAM,qBAEL,CAFK,IAAIP,MACR,AAAC,iCAA8BR,WAAS,OAAIa,OAAOG,QAAQ,GAAC,MADxD,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;QACF;QAEA,IAAI;YACF,OAAOC,KAAKC,KAAK,CAACL,OAAOM,QAAQ;QACnC,EAAE,OAAOZ,OAAO;YACd,MAAM,qBAEJ,CAFI,IAAIC,MAAM,AAAC,oCAAiCR,WAAS,KAAI;gBAC7DS,OAAOF;YACT,IAFM,qBAAA;uBAAA;4BAAA;8BAAA;YAEL;QACH;IACF;IAEA,MAAMa,oBAAoBC,aAAI,CAACC,OAAO,CACpCD,aAAI,CAACE,OAAO,CAACvB,WACbwB,mBAAmBd;IAGrB,IAAI;QACF,MAAMe,oBAAoB,MAAMpB,iBAAE,CAACC,QAAQ,CAACc,mBAAmB;QAE/D,OAAOH,KAAKC,KAAK,CAACO,kBAAkBN,QAAQ;IAC9C,EAAE,OAAOZ,OAAO;QACd,MAAM,qBAEJ,CAFI,IAAIC,MAAM,AAAC,gCAA6BY,oBAAkB,KAAI;YAClEX,OAAOF;QACT,IAFM,qBAAA;mBAAA;wBAAA;0BAAA;QAEL;IACH;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=get-source-map-url.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/utils/get-source-map-url.ts"],"sourcesContent":["export function getSourceMapUrl(fileContents: string): string | null {\n const regex = /\\/\\/[#@] ?sourceMappingURL=([^\\s'\"]+)\\s*$/gm\n let match = null\n for (;;) {\n let next = regex.exec(fileContents)\n if (next == null) {\n break\n }\n match = next\n }\n if (!(match && match[1])) {\n return null\n }\n return match[1].toString()\n}\n"],"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,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,90 @@
"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) {
if (error.name === 'TurbopackInternalError') {
// If this is an internal Turbopack error we shouldn't show internal details
// to the user. These are written to a log file instead.
const turbopackInternalError = Object.defineProperty(new Error('An unexpected Turbopack error occurred. Please see the output of `next dev` for more details.'), "__NEXT_ERROR_CODE", {
value: "E167",
enumerable: false,
configurable: true
});
(0, _errorsource.decorateServerError)(turbopackInternalError, type);
return turbopackInternalError;
}
let n;
try {
throw Object.defineProperty(new Error(error.message), "__NEXT_ERROR_CODE", {
value: "E394",
enumerable: false,
configurable: true
});
} 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=node-stack-frames.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/utils/node-stack-frames.ts"],"sourcesContent":["import { parse } from 'next/dist/compiled/stacktrace-parser'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport {\n decorateServerError,\n type ErrorSourceType,\n} from '../../../../shared/lib/error-source'\n\nexport function getFilesystemFrame(frame: StackFrame): StackFrame {\n const f: StackFrame = { ...frame }\n\n if (typeof f.file === 'string') {\n if (\n // Posix:\n f.file.startsWith('/') ||\n // Win32:\n /^[a-z]:\\\\/i.test(f.file) ||\n // Win32 UNC:\n f.file.startsWith('\\\\\\\\')\n ) {\n f.file = `file://${f.file}`\n }\n }\n\n return f\n}\n\nexport function getServerError(error: Error, type: ErrorSourceType): Error {\n if (error.name === 'TurbopackInternalError') {\n // If this is an internal Turbopack error we shouldn't show internal details\n // to the user. These are written to a log file instead.\n const turbopackInternalError = new Error(\n 'An unexpected Turbopack error occurred. Please see the output of `next dev` for more details.'\n )\n decorateServerError(turbopackInternalError, type)\n return turbopackInternalError\n }\n\n let n: Error\n try {\n throw new Error(error.message)\n } catch (e) {\n n = e as Error\n }\n\n n.name = error.name\n try {\n n.stack = `${n.toString()}\\n${parse(error.stack!)\n .map(getFilesystemFrame)\n .map((f) => {\n let str = ` at ${f.methodName}`\n if (f.file) {\n let loc = f.file\n if (f.lineNumber) {\n loc += `:${f.lineNumber}`\n if (f.column) {\n loc += `:${f.column}`\n }\n }\n str += ` (${loc})`\n }\n return str\n })\n .join('\\n')}`\n } catch {\n n.stack = error.stack\n }\n\n decorateServerError(n, type)\n return n\n}\n"],"names":["getFilesystemFrame","getServerError","frame","f","file","startsWith","test","error","type","name","turbopackInternalError","Error","decorateServerError","n","message","e","stack","toString","parse","map","str","methodName","loc","lineNumber","column","join"],"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,IAAID,MAAME,IAAI,KAAK,0BAA0B;QAC3C,4EAA4E;QAC5E,wDAAwD;QACxD,MAAMC,yBAAyB,qBAE9B,CAF8B,IAAIC,MACjC,kGAD6B,qBAAA;mBAAA;wBAAA;0BAAA;QAE/B;QACAC,IAAAA,gCAAmB,EAACF,wBAAwBF;QAC5C,OAAOE;IACT;IAEA,IAAIG;IACJ,IAAI;QACF,MAAM,qBAAwB,CAAxB,IAAIF,MAAMJ,MAAMO,OAAO,GAAvB,qBAAA;mBAAA;wBAAA;0BAAA;QAAuB;IAC/B,EAAE,OAAOC,GAAG;QACVF,IAAIE;IACN;IAEAF,EAAEJ,IAAI,GAAGF,MAAME,IAAI;IACnB,IAAI;QACFI,EAAEG,KAAK,GAAG,AAAGH,EAAEI,QAAQ,KAAG,OAAIC,IAAAA,uBAAK,EAACX,MAAMS,KAAK,EAC5CG,GAAG,CAACnB,oBACJmB,GAAG,CAAC,CAAChB;YACJ,IAAIiB,MAAM,AAAC,YAASjB,EAAEkB,UAAU;YAChC,IAAIlB,EAAEC,IAAI,EAAE;gBACV,IAAIkB,MAAMnB,EAAEC,IAAI;gBAChB,IAAID,EAAEoB,UAAU,EAAE;oBAChBD,OAAO,AAAC,MAAGnB,EAAEoB,UAAU;oBACvB,IAAIpB,EAAEqB,MAAM,EAAE;wBACZF,OAAO,AAAC,MAAGnB,EAAEqB,MAAM;oBACrB;gBACF;gBACAJ,OAAO,AAAC,OAAIE,MAAI;YAClB;YACA,OAAOF;QACT,GACCK,IAAI,CAAC;IACV,EAAE,UAAM;QACNZ,EAAEG,KAAK,GAAGT,MAAMS,KAAK;IACvB;IAEAJ,IAAAA,gCAAmB,EAACC,GAAGL;IACvB,OAAOK;AACT"}

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,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "parseComponentStack", {
enumerable: true,
get: function() {
return parseComponentStack;
}
});
var LocationType = /*#__PURE__*/ function(LocationType) {
LocationType["FILE"] = "file";
LocationType["WEBPACK_INTERNAL"] = "webpack-internal";
LocationType["HTTP"] = "http";
LocationType["PROTOCOL_RELATIVE"] = "protocol-relative";
LocationType["UNKNOWN"] = "unknown";
return LocationType;
}(LocationType || {});
/**
* Get the type of frame line based on the location
*/ function getLocationType(location) {
if (location.startsWith('file://')) {
return "file";
}
if (location.includes('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')){
// TODO: support safari stack trace
// 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/utils/parse-component-stack.ts"],"sourcesContent":["export type ComponentStackFrame = {\n canOpenInEditor: boolean\n component: string\n file?: string\n lineNumber?: number\n column?: number\n}\n\nenum LocationType {\n FILE = 'file',\n WEBPACK_INTERNAL = 'webpack-internal',\n HTTP = 'http',\n PROTOCOL_RELATIVE = 'protocol-relative',\n UNKNOWN = 'unknown',\n}\n\n/**\n * Get the type of frame line based on the location\n */\nfunction getLocationType(location: string): LocationType {\n if (location.startsWith('file://')) {\n return LocationType.FILE\n }\n if (location.includes('webpack-internal://')) {\n return LocationType.WEBPACK_INTERNAL\n }\n if (location.startsWith('http://') || location.startsWith('https://')) {\n return LocationType.HTTP\n }\n if (location.startsWith('//')) {\n return LocationType.PROTOCOL_RELATIVE\n }\n return LocationType.UNKNOWN\n}\n\nfunction parseStackFrameLocation(\n location: string\n): Omit<ComponentStackFrame, 'component'> {\n const locationType = getLocationType(location)\n\n const modulePath = location?.replace(\n /^(webpack-internal:\\/\\/\\/|file:\\/\\/)(\\(.*\\)\\/)?/,\n ''\n )\n const [, file, lineNumber, column] =\n modulePath?.match(/^(.+):(\\d+):(\\d+)/) ?? []\n\n switch (locationType) {\n case LocationType.FILE:\n case LocationType.WEBPACK_INTERNAL:\n return {\n canOpenInEditor: true,\n file,\n lineNumber: lineNumber ? Number(lineNumber) : undefined,\n column: column ? Number(column) : undefined,\n }\n // When the location is a URL we only show the file\n // TODO: Resolve http(s) URLs through sourcemaps\n case LocationType.HTTP:\n case LocationType.PROTOCOL_RELATIVE:\n case LocationType.UNKNOWN:\n default: {\n return {\n canOpenInEditor: false,\n }\n }\n }\n}\n\nexport function parseComponentStack(\n componentStack: string\n): ComponentStackFrame[] {\n const componentStackFrames: ComponentStackFrame[] = []\n for (const line of componentStack.trim().split('\\n')) {\n // TODO: support safari stack trace\n // Get component and file from the component stack line\n const match = /at ([^ ]+)( \\((.*)\\))?/.exec(line)\n if (match?.[1]) {\n const component = match[1]\n const location = match[3]\n\n if (!location) {\n componentStackFrames.push({\n canOpenInEditor: false,\n component,\n })\n continue\n }\n\n // Stop parsing the component stack if we reach a Next.js component\n if (location?.includes('next/dist')) {\n break\n }\n\n const frameLocation = parseStackFrameLocation(location)\n componentStackFrames.push({\n component,\n ...frameLocation,\n })\n }\n }\n\n return componentStackFrames\n}\n"],"names":["parseComponentStack","LocationType","getLocationType","location","startsWith","includes","parseStackFrameLocation","locationType","modulePath","replace","file","lineNumber","column","match","canOpenInEditor","Number","undefined","componentStack","componentStackFrames","line","trim","split","exec","component","push","frameLocation"],"mappings":";;;;+BAqEgBA;;;eAAAA;;;AA7DhB,IAAA,AAAKC,sCAAAA;;;;;;WAAAA;EAAAA;AAQL;;CAEC,GACD,SAASC,gBAAgBC,QAAgB;IACvC,IAAIA,SAASC,UAAU,CAAC,YAAY;QAClC;IACF;IACA,IAAID,SAASE,QAAQ,CAAC,wBAAwB;QAC5C;IACF;IACA,IAAIF,SAASC,UAAU,CAAC,cAAcD,SAASC,UAAU,CAAC,aAAa;QACrE;IACF;IACA,IAAID,SAASC,UAAU,CAAC,OAAO;QAC7B;IACF;IACA;AACF;AAEA,SAASE,wBACPH,QAAgB;IAEhB,MAAMI,eAAeL,gBAAgBC;IAErC,MAAMK,aAAaL,4BAAAA,SAAUM,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,SAASd,oBACdiB,cAAsB;IAEtB,MAAMC,uBAA8C,EAAE;IACtD,KAAK,MAAMC,QAAQF,eAAeG,IAAI,GAAGC,KAAK,CAAC,MAAO;QACpD,mCAAmC;QACnC,uDAAuD;QACvD,MAAMR,QAAQ,yBAAyBS,IAAI,CAACH;QAC5C,IAAIN,yBAAAA,KAAO,CAAC,EAAE,EAAE;YACd,MAAMU,YAAYV,KAAK,CAAC,EAAE;YAC1B,MAAMV,WAAWU,KAAK,CAAC,EAAE;YAEzB,IAAI,CAACV,UAAU;gBACbe,qBAAqBM,IAAI,CAAC;oBACxBV,iBAAiB;oBACjBS;gBACF;gBACA;YACF;YAEA,mEAAmE;YACnE,IAAIpB,4BAAAA,SAAUE,QAAQ,CAAC,cAAc;gBACnC;YACF;YAEA,MAAMoB,gBAAgBnB,wBAAwBH;YAC9Ce,qBAAqBM,IAAI,CAAC;gBACxBD;gBACA,GAAGE,aAAa;YAClB;QACF;IACF;IAEA,OAAOP;AACT"}

View File

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

View File

@@ -0,0 +1,54 @@
"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 _ishydrationerror = require("../../is-hydration-error");
const regexNextStatic = /\/_next(\/static\/.+)/;
function parseStack(stack) {
if (!stack) return [];
const messageAndStack = stack.replace(/^Error: /, '');
if ((0, _ishydrationerror.isReactHydrationErrorMessage)(messageAndStack)) {
const { stack: parsedStack } = (0, _ishydrationerror.getHydrationErrorStackInfo)(messageAndStack);
if (parsedStack) {
stack = parsedStack;
}
}
// throw away eval information that stacktrace-parser doesn't support
// adapted from https://github.com/stacktracejs/error-stack-parser/blob/9f33c224b5d7b607755eb277f9d51fcdb7287e24/error-stack-parser.js#L59C33-L59C62
stack = stack.split('\n').map((line)=>{
if (line.includes('(eval ')) {
line = line.replace(/eval code/g, 'eval').replace(/\(eval at [^()]* \(/, '(file://').replace(/\),.*$/g, ')');
}
return line;
}).join('\n');
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=parse-stack.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/utils/parse-stack.ts"],"sourcesContent":["import { parse } from 'next/dist/compiled/stacktrace-parser'\nimport type { StackFrame } from 'next/dist/compiled/stacktrace-parser'\nimport {\n getHydrationErrorStackInfo,\n isReactHydrationErrorMessage,\n} from '../../is-hydration-error'\n\nconst regexNextStatic = /\\/_next(\\/static\\/.+)/\n\nexport function parseStack(stack: string | undefined): StackFrame[] {\n if (!stack) return []\n const messageAndStack = stack.replace(/^Error: /, '')\n if (isReactHydrationErrorMessage(messageAndStack)) {\n const { stack: parsedStack } = getHydrationErrorStackInfo(messageAndStack)\n if (parsedStack) {\n stack = parsedStack\n }\n }\n\n // throw away eval information that stacktrace-parser doesn't support\n // adapted from https://github.com/stacktracejs/error-stack-parser/blob/9f33c224b5d7b607755eb277f9d51fcdb7287e24/error-stack-parser.js#L59C33-L59C62\n stack = stack\n .split('\\n')\n .map((line) => {\n if (line.includes('(eval ')) {\n line = line\n .replace(/eval code/g, 'eval')\n .replace(/\\(eval at [^()]* \\(/, '(file://')\n .replace(/\\),.*$/g, ')')\n }\n\n return line\n })\n .join('\\n')\n\n const frames = parse(stack)\n return frames.map((frame) => {\n try {\n const url = new URL(frame.file!)\n const res = regexNextStatic.exec(url.pathname)\n if (res) {\n const distDir = process.env.__NEXT_DIST_DIR\n ?.replace(/\\\\/g, '/')\n ?.replace(/\\/$/, '')\n if (distDir) {\n frame.file = 'file://' + distDir.concat(res.pop()!) + url.search\n }\n }\n } catch {}\n return frame\n })\n}\n"],"names":["parseStack","regexNextStatic","stack","messageAndStack","replace","isReactHydrationErrorMessage","parsedStack","getHydrationErrorStackInfo","split","map","line","includes","join","frames","parse","frame","url","URL","file","res","exec","pathname","process","distDir","env","__NEXT_DIST_DIR","concat","pop","search"],"mappings":";;;;+BASgBA;;;eAAAA;;;kCATM;kCAKf;AAEP,MAAMC,kBAAkB;AAEjB,SAASD,WAAWE,KAAyB;IAClD,IAAI,CAACA,OAAO,OAAO,EAAE;IACrB,MAAMC,kBAAkBD,MAAME,OAAO,CAAC,YAAY;IAClD,IAAIC,IAAAA,8CAA4B,EAACF,kBAAkB;QACjD,MAAM,EAAED,OAAOI,WAAW,EAAE,GAAGC,IAAAA,4CAA0B,EAACJ;QAC1D,IAAIG,aAAa;YACfJ,QAAQI;QACV;IACF;IAEA,qEAAqE;IACrE,oJAAoJ;IACpJJ,QAAQA,MACLM,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC;QACJ,IAAIA,KAAKC,QAAQ,CAAC,WAAW;YAC3BD,OAAOA,KACJN,OAAO,CAAC,cAAc,QACtBA,OAAO,CAAC,uBAAuB,YAC/BA,OAAO,CAAC,WAAW;QACxB;QAEA,OAAOM;IACT,GACCE,IAAI,CAAC;IAER,MAAMC,SAASC,IAAAA,uBAAK,EAACZ;IACrB,OAAOW,OAAOJ,GAAG,CAAC,CAACM;QACjB,IAAI;YACF,MAAMC,MAAM,IAAIC,IAAIF,MAAMG,IAAI;YAC9B,MAAMC,MAAMlB,gBAAgBmB,IAAI,CAACJ,IAAIK,QAAQ;YAC7C,IAAIF,KAAK;oBACSG,sCAAAA;gBAAhB,MAAMC,WAAUD,+BAAAA,QAAQE,GAAG,CAACC,eAAe,sBAA3BH,uCAAAA,6BACZlB,OAAO,CAAC,OAAO,yBADHkB,qCAEZlB,OAAO,CAAC,OAAO;gBACnB,IAAImB,SAAS;oBACXR,MAAMG,IAAI,GAAG,YAAYK,QAAQG,MAAM,CAACP,IAAIQ,GAAG,MAAOX,IAAIY,MAAM;gBAClE;YACF;QACF,EAAE,UAAM,CAAC;QACT,OAAOb;IACT;AACF"}

View File

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

View File

@@ -0,0 +1,152 @@
"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;
}
});
const _webpackmodulepath = require("./webpack-module-path");
function getOriginalStackFrame(source, response) {
var _source_file;
async function _getOriginalStackFrame() {
var _body_originalStackFrame;
if (response.status === 'rejected') {
throw Object.defineProperty(new Error(response.reason), "__NEXT_ERROR_CODE", {
value: "E394",
enumerable: false,
configurable: true
});
}
const body = response.value;
return {
error: false,
reason: null,
external: false,
sourceStackFrame: source,
originalStackFrame: body.originalStackFrame,
originalCodeFrame: body.originalCodeFrame || null,
ignored: ((_body_originalStackFrame = body.originalStackFrame) == null ? void 0 : _body_originalStackFrame.ignored) || false
};
}
// TODO: merge this section into ignoredList handling
if (source.file === 'file://' || ((_source_file = source.file) == null ? void 0 : _source_file.match(/https?:\/\//))) {
return Promise.resolve({
error: false,
reason: null,
external: true,
sourceStackFrame: source,
originalStackFrame: null,
originalCodeFrame: null,
ignored: true
});
}
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,
sourceStackFrame: source,
originalStackFrame: null,
originalCodeFrame: null,
ignored: false
};
});
}
async function getOriginalStackFrames(frames, type, isAppDir) {
const req = {
frames,
isServer: type === 'server',
isEdgeServer: type === 'edge-server',
isAppDirectory: isAppDir
};
let res = undefined;
let reason = undefined;
try {
res = await fetch('/__nextjs_original-stack-frames', {
method: 'POST',
body: JSON.stringify(req)
});
} catch (e) {
reason = e + '';
}
// When fails to fetch the original stack frames, we reject here to be
// caught at `_getOriginalStackFrame()` and return the stack frames so
// that the error overlay can render.
if (res && res.ok && res.status !== 204) {
const data = await res.json();
return Promise.all(frames.map((frame, index)=>getOriginalStackFrame(frame, data[index])));
} else {
if (res) {
reason = await res.text();
}
}
return Promise.all(frames.map((frame)=>getOriginalStackFrame(frame, {
status: 'rejected',
reason: "Failed to fetch the original stack frames " + (reason ? ": " + reason : '')
})));
}
function getFrameSource(frame) {
if (!frame.file) return '';
const isWebpackFrame = (0, _webpackmodulepath.isWebpackInternalResource)(frame.file);
let str = '';
// Skip URL parsing for webpack internal file paths.
if (isWebpackFrame) {
str = (0, _webpackmodulepath.formatFrameSourceFile)(frame.file);
} else {
try {
var _globalThis_location;
const u = new URL(frame.file);
let parsedPath = '';
// 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') {
parsedPath += u.protocol;
} else {
parsedPath += u.origin;
}
}
// Strip query string information as it's typically too verbose to be
// meaningful.
parsedPath += u.pathname;
str = (0, _webpackmodulepath.formatFrameSourceFile)(parsedPath);
} catch (e) {
str = (0, _webpackmodulepath.formatFrameSourceFile)(frame.file);
}
}
if (!(0, _webpackmodulepath.isWebpackInternalResource)(frame.file) && frame.lineNumber != null) {
if (str) {
if (frame.column != null) {
str += " (" + frame.lineNumber + ":" + frame.column + ")";
} else {
str += " (" + frame.lineNumber + ")";
}
}
}
return str;
}
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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
import type { TurbopackMsgToBrowser } from '../../../../server/dev/hot-reloader-types';
export declare function useWebsocket(assetPrefix: string): import("react").RefObject<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,134 @@
"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)(undefined);
(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/browser/dev/hmr-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)(()=>{
// Never send pings when using Turbopack as it's not used.
// Pings were originally used to keep track of active routes in on-demand-entries with webpack.
if (process.env.TURBOPACK) {
return;
}
// 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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
export declare function isWebpackInternalResource(file: string): boolean;
/**
* 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
*/
export declare function formatFrameSourceFile(file: string): string;

View File

@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
formatFrameSourceFile: null,
isWebpackInternalResource: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
formatFrameSourceFile: function() {
return formatFrameSourceFile;
},
isWebpackInternalResource: function() {
return isWebpackInternalResource;
}
});
const replacementRegExes = [
/^webpack-internal:\/\/\/(\([\w-]+\)\/)?/,
/^(webpack:\/\/\/|webpack:\/\/(_N_E\/)?)(\([\w-]+\)\/)?/
];
function isWebpackInternalResource(file) {
for (const regex of replacementRegExes){
if (regex.test(file)) return true;
file = file.replace(regex, '');
}
return false;
}
function formatFrameSourceFile(file) {
for (const regex of replacementRegExes){
file = file.replace(regex, '');
}
return file;
}
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=webpack-module-path.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/utils/webpack-module-path.ts"],"sourcesContent":["const replacementRegExes = [\n /^webpack-internal:\\/\\/\\/(\\([\\w-]+\\)\\/)?/,\n /^(webpack:\\/\\/\\/|webpack:\\/\\/(_N_E\\/)?)(\\([\\w-]+\\)\\/)?/,\n]\n\nexport function isWebpackInternalResource(file: string) {\n for (const regex of replacementRegExes) {\n if (regex.test(file)) return true\n\n file = file.replace(regex, '')\n }\n\n return false\n}\n\n/**\n * Format the webpack internal id to original file path\n *\n * webpack-internal:///./src/hello.tsx => ./src/hello.tsx\n * webpack://_N_E/./src/hello.tsx => ./src/hello.tsx\n * webpack://./src/hello.tsx => ./src/hello.tsx\n * webpack:///./src/hello.tsx => ./src/hello.tsx\n */\nexport function formatFrameSourceFile(file: string) {\n for (const regex of replacementRegExes) {\n file = file.replace(regex, '')\n }\n\n return file\n}\n"],"names":["formatFrameSourceFile","isWebpackInternalResource","replacementRegExes","file","regex","test","replace"],"mappings":";;;;;;;;;;;;;;;IAuBgBA,qBAAqB;eAArBA;;IAlBAC,yBAAyB;eAAzBA;;;AALhB,MAAMC,qBAAqB;IACzB;IACA;CACD;AAEM,SAASD,0BAA0BE,IAAY;IACpD,KAAK,MAAMC,SAASF,mBAAoB;QACtC,IAAIE,MAAMC,IAAI,CAACF,OAAO,OAAO;QAE7BA,OAAOA,KAAKG,OAAO,CAACF,OAAO;IAC7B;IAEA,OAAO;AACT;AAUO,SAASJ,sBAAsBG,IAAY;IAChD,KAAK,MAAMC,SAASF,mBAAoB;QACtCC,OAAOA,KAAKG,OAAO,CAACF,OAAO;IAC7B;IAEA,OAAOD;AACT"}