Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
68
node_modules/next/dist/esm/client/components/errors/attach-hydration-error-state.js
generated
vendored
Normal file
68
node_modules/next/dist/esm/client/components/errors/attach-hydration-error-state.js
generated
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import { getDefaultHydrationErrorMessage, isHydrationError, testReactHydrationWarning } from '../is-hydration-error';
|
||||
import { hydrationErrorState, getReactHydrationDiffSegments } from './hydration-error-info';
|
||||
export function attachHydrationErrorState(error) {
|
||||
let parsedHydrationErrorState = {};
|
||||
const isHydrationWarning = testReactHydrationWarning(error.message);
|
||||
const isHydrationRuntimeError = isHydrationError(error);
|
||||
// If it's not hydration warnings or errors, skip
|
||||
if (!(isHydrationRuntimeError || isHydrationWarning)) {
|
||||
return;
|
||||
}
|
||||
const reactHydrationDiffSegments = getReactHydrationDiffSegments(error.message);
|
||||
// If the reactHydrationDiffSegments exists
|
||||
// and the diff (reactHydrationDiffSegments[1]) exists
|
||||
// e.g. the hydration diff log error.
|
||||
if (reactHydrationDiffSegments) {
|
||||
const diff = reactHydrationDiffSegments[1];
|
||||
parsedHydrationErrorState = {
|
||||
...error.details,
|
||||
...hydrationErrorState,
|
||||
// If diff is present in error, we don't need to pick up the console logged warning.
|
||||
// - if hydration error has diff, and is not hydration diff log, then it's a normal hydration error.
|
||||
// - if hydration error no diff, then leverage the one from the hydration diff log.
|
||||
warning: (diff && !isHydrationWarning ? null : hydrationErrorState.warning) || [
|
||||
getDefaultHydrationErrorMessage(),
|
||||
'',
|
||||
''
|
||||
],
|
||||
// When it's hydration diff log, do not show notes section.
|
||||
// This condition is only for the 1st squashed error.
|
||||
notes: isHydrationWarning ? '' : reactHydrationDiffSegments[0],
|
||||
reactOutputComponentDiff: diff
|
||||
};
|
||||
// Cache the `reactOutputComponentDiff` into hydrationErrorState.
|
||||
// This is only required for now when we still squashed the hydration diff log into hydration error.
|
||||
// Once the all error is logged to dev overlay in order, this will go away.
|
||||
if (!hydrationErrorState.reactOutputComponentDiff && diff) {
|
||||
hydrationErrorState.reactOutputComponentDiff = diff;
|
||||
}
|
||||
// If it's hydration runtime error that doesn't contain the diff, combine the diff from the cached hydration diff.
|
||||
if (!diff && isHydrationRuntimeError && hydrationErrorState.reactOutputComponentDiff) {
|
||||
parsedHydrationErrorState.reactOutputComponentDiff = hydrationErrorState.reactOutputComponentDiff;
|
||||
}
|
||||
} else {
|
||||
// Normal runtime error, where it doesn't contain the hydration diff.
|
||||
// If there's any extra information in the error message to display,
|
||||
// append it to the error message details property
|
||||
if (hydrationErrorState.warning) {
|
||||
// The patched console.error found hydration errors logged by React
|
||||
// Append the logged warning to the error message
|
||||
parsedHydrationErrorState = {
|
||||
...error.details,
|
||||
// It contains the warning, component stack, server and client tag names
|
||||
...hydrationErrorState
|
||||
};
|
||||
}
|
||||
// Consume the cached hydration diff.
|
||||
// This is only required for now when we still squashed the hydration diff log into hydration error.
|
||||
// Once the all error is logged to dev overlay in order, this will go away.
|
||||
if (hydrationErrorState.reactOutputComponentDiff) {
|
||||
parsedHydrationErrorState.reactOutputComponentDiff = hydrationErrorState.reactOutputComponentDiff;
|
||||
}
|
||||
}
|
||||
// If it's a hydration error, store the hydration error state into the error object
|
||||
;
|
||||
error.details = parsedHydrationErrorState;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=attach-hydration-error-state.js.map
|
||||
1
node_modules/next/dist/esm/client/components/errors/attach-hydration-error-state.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/errors/attach-hydration-error-state.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
24
node_modules/next/dist/esm/client/components/errors/console-error.js
generated
vendored
Normal file
24
node_modules/next/dist/esm/client/components/errors/console-error.js
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// To distinguish from React error.digest, we use a different symbol here to determine if the error is from console.error or unhandled promise rejection.
|
||||
const digestSym = Symbol.for('next.console.error.digest');
|
||||
const consoleTypeSym = Symbol.for('next.console.error.type');
|
||||
export function createConsoleError(message, environmentName) {
|
||||
const error = typeof message === 'string' ? Object.defineProperty(new Error(message), "__NEXT_ERROR_CODE", {
|
||||
value: "E394",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
}) : message;
|
||||
error[digestSym] = 'NEXT_CONSOLE_ERROR';
|
||||
error[consoleTypeSym] = typeof message === 'string' ? 'string' : 'error';
|
||||
if (environmentName && !error.environmentName) {
|
||||
error.environmentName = environmentName;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
export const isConsoleError = (error)=>{
|
||||
return error && error[digestSym] === 'NEXT_CONSOLE_ERROR';
|
||||
};
|
||||
export const getConsoleErrorType = (error)=>{
|
||||
return error[consoleTypeSym];
|
||||
};
|
||||
|
||||
//# sourceMappingURL=console-error.js.map
|
||||
1
node_modules/next/dist/esm/client/components/errors/console-error.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/errors/console-error.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../../../src/client/components/errors/console-error.ts"],"sourcesContent":["// To distinguish from React error.digest, we use a different symbol here to determine if the error is from console.error or unhandled promise rejection.\nconst digestSym = Symbol.for('next.console.error.digest')\nconst consoleTypeSym = Symbol.for('next.console.error.type')\n\n// Represent non Error shape unhandled promise rejections or console.error errors.\n// Those errors will be captured and displayed in Error Overlay.\nexport type ConsoleError = Error & {\n [digestSym]: 'NEXT_CONSOLE_ERROR'\n [consoleTypeSym]: 'string' | 'error'\n environmentName: string\n}\n\nexport function createConsoleError(\n message: string | Error,\n environmentName?: string | null\n): ConsoleError {\n const error = (\n typeof message === 'string' ? new Error(message) : message\n ) as ConsoleError\n error[digestSym] = 'NEXT_CONSOLE_ERROR'\n error[consoleTypeSym] = typeof message === 'string' ? 'string' : 'error'\n\n if (environmentName && !error.environmentName) {\n error.environmentName = environmentName\n }\n\n return error\n}\n\nexport const isConsoleError = (error: any): error is ConsoleError => {\n return error && error[digestSym] === 'NEXT_CONSOLE_ERROR'\n}\n\nexport const getConsoleErrorType = (error: ConsoleError) => {\n return error[consoleTypeSym]\n}\n"],"names":["digestSym","Symbol","for","consoleTypeSym","createConsoleError","message","environmentName","error","Error","isConsoleError","getConsoleErrorType"],"mappings":"AAAA,yJAAyJ;AACzJ,MAAMA,YAAYC,OAAOC,GAAG,CAAC;AAC7B,MAAMC,iBAAiBF,OAAOC,GAAG,CAAC;AAUlC,OAAO,SAASE,mBACdC,OAAuB,EACvBC,eAA+B;IAE/B,MAAMC,QACJ,OAAOF,YAAY,WAAW,qBAAkB,CAAlB,IAAIG,MAAMH,UAAV,qBAAA;eAAA;oBAAA;sBAAA;IAAiB,KAAIA;IAErDE,KAAK,CAACP,UAAU,GAAG;IACnBO,KAAK,CAACJ,eAAe,GAAG,OAAOE,YAAY,WAAW,WAAW;IAEjE,IAAIC,mBAAmB,CAACC,MAAMD,eAAe,EAAE;QAC7CC,MAAMD,eAAe,GAAGA;IAC1B;IAEA,OAAOC;AACT;AAEA,OAAO,MAAME,iBAAiB,CAACF;IAC7B,OAAOA,SAASA,KAAK,CAACP,UAAU,KAAK;AACvC,EAAC;AAED,OAAO,MAAMU,sBAAsB,CAACH;IAClC,OAAOA,KAAK,CAACJ,eAAe;AAC9B,EAAC"}
|
||||
11
node_modules/next/dist/esm/client/components/errors/enqueue-client-error.js
generated
vendored
Normal file
11
node_modules/next/dist/esm/client/components/errors/enqueue-client-error.js
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// Dedupe the two consecutive errors: If the previous one is same as current one, ignore the current one.
|
||||
export function enqueueConsecutiveDedupedError(queue, error) {
|
||||
const previousError = queue[queue.length - 1];
|
||||
// Compare the error stack to dedupe the consecutive errors
|
||||
if (previousError && previousError.stack === error.stack) {
|
||||
return;
|
||||
}
|
||||
queue.push(error);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=enqueue-client-error.js.map
|
||||
1
node_modules/next/dist/esm/client/components/errors/enqueue-client-error.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/errors/enqueue-client-error.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../../../src/client/components/errors/enqueue-client-error.ts"],"sourcesContent":["// Dedupe the two consecutive errors: If the previous one is same as current one, ignore the current one.\nexport function enqueueConsecutiveDedupedError(\n queue: Array<Error>,\n error: Error\n) {\n const previousError = queue[queue.length - 1]\n // Compare the error stack to dedupe the consecutive errors\n if (previousError && previousError.stack === error.stack) {\n return\n }\n queue.push(error)\n}\n"],"names":["enqueueConsecutiveDedupedError","queue","error","previousError","length","stack","push"],"mappings":"AAAA,yGAAyG;AACzG,OAAO,SAASA,+BACdC,KAAmB,EACnBC,KAAY;IAEZ,MAAMC,gBAAgBF,KAAK,CAACA,MAAMG,MAAM,GAAG,EAAE;IAC7C,2DAA2D;IAC3D,IAAID,iBAAiBA,cAAcE,KAAK,KAAKH,MAAMG,KAAK,EAAE;QACxD;IACF;IACAJ,MAAMK,IAAI,CAACJ;AACb"}
|
||||
140
node_modules/next/dist/esm/client/components/errors/hydration-error-info.js
generated
vendored
Normal file
140
node_modules/next/dist/esm/client/components/errors/hydration-error-info.js
generated
vendored
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
import { getHydrationErrorStackInfo, testReactHydrationWarning } from '../is-hydration-error';
|
||||
export const hydrationErrorState = {};
|
||||
// https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference
|
||||
const htmlTagsWarnings = new Set([
|
||||
'Warning: In HTML, %s cannot be a child of <%s>.%s\nThis will cause a hydration error.%s',
|
||||
'Warning: In HTML, %s cannot be a descendant of <%s>.\nThis will cause a hydration error.%s',
|
||||
'Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will cause a hydration error.',
|
||||
"Warning: In HTML, whitespace text nodes cannot be a child of <%s>. Make sure you don't have any extra whitespace between tags on each line of your source code.\nThis will cause a hydration error.",
|
||||
'Warning: Expected server HTML to contain a matching <%s> in <%s>.%s',
|
||||
'Warning: Did not expect server HTML to contain a <%s> in <%s>.%s'
|
||||
]);
|
||||
const textAndTagsMismatchWarnings = new Set([
|
||||
'Warning: Expected server HTML to contain a matching text node for "%s" in <%s>.%s',
|
||||
'Warning: Did not expect server HTML to contain the text node "%s" in <%s>.%s'
|
||||
]);
|
||||
export const getHydrationWarningType = (message)=>{
|
||||
if (typeof message !== 'string') {
|
||||
// TODO: Doesn't make sense to treat no message as a hydration error message.
|
||||
// We should bail out somewhere earlier.
|
||||
return 'text';
|
||||
}
|
||||
const normalizedMessage = message.startsWith('Warning: ') ? message : "Warning: " + message;
|
||||
if (isHtmlTagsWarning(normalizedMessage)) return 'tag';
|
||||
if (isTextInTagsMismatchWarning(normalizedMessage)) return 'text-in-tag';
|
||||
return 'text';
|
||||
};
|
||||
const isHtmlTagsWarning = (message)=>htmlTagsWarnings.has(message);
|
||||
const isTextInTagsMismatchWarning = (msg)=>textAndTagsMismatchWarnings.has(msg);
|
||||
export const getReactHydrationDiffSegments = (msg)=>{
|
||||
if (msg) {
|
||||
const { message, diff } = getHydrationErrorStackInfo(msg);
|
||||
if (message) return [
|
||||
message,
|
||||
diff
|
||||
];
|
||||
}
|
||||
return 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 function storeHydrationErrorStateFromConsoleArgs() {
|
||||
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
let [msg, firstContent, secondContent, ...rest] = args;
|
||||
if (testReactHydrationWarning(msg)) {
|
||||
// Some hydration warnings has 4 arguments, some has 3, fallback to the last argument
|
||||
// when the 3rd argument is not the component stack but an empty string
|
||||
const isReact18 = msg.startsWith('Warning: ');
|
||||
// For some warnings, there's only 1 argument for template.
|
||||
// The second argument is the diff or component stack.
|
||||
if (args.length === 3) {
|
||||
secondContent = '';
|
||||
}
|
||||
const warning = [
|
||||
// remove the last %s from the message
|
||||
msg,
|
||||
firstContent,
|
||||
secondContent
|
||||
];
|
||||
const lastArg = (rest[rest.length - 1] || '').trim();
|
||||
if (!isReact18) {
|
||||
hydrationErrorState.reactOutputComponentDiff = lastArg;
|
||||
} else {
|
||||
hydrationErrorState.reactOutputComponentDiff = generateHydrationDiffReact18(msg, firstContent, secondContent, lastArg);
|
||||
}
|
||||
hydrationErrorState.warning = warning;
|
||||
hydrationErrorState.serverContent = firstContent;
|
||||
hydrationErrorState.clientContent = secondContent;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Some hydration errors in React 18 does not have the diff in the error message.
|
||||
* Instead it has the error stack trace which is component stack that we can leverage.
|
||||
* Will parse the diff from the error stack trace
|
||||
* e.g.
|
||||
* Warning: Expected server HTML to contain a matching <div> in <p>.
|
||||
* at div
|
||||
* at p
|
||||
* at div
|
||||
* at div
|
||||
* at Page
|
||||
* output:
|
||||
* <Page>
|
||||
* <div>
|
||||
* <p>
|
||||
* > <div>
|
||||
*
|
||||
*/ function generateHydrationDiffReact18(message, firstContent, secondContent, lastArg) {
|
||||
const componentStack = lastArg;
|
||||
let firstIndex = -1;
|
||||
let secondIndex = -1;
|
||||
const hydrationWarningType = getHydrationWarningType(message);
|
||||
// at div\n at Foo\n at Bar (....)\n -> [div, Foo]
|
||||
const components = componentStack.split('\n')// .reverse()
|
||||
.map((line, index)=>{
|
||||
// `<space>at <component> (<location>)` -> `at <component> (<location>)`
|
||||
line = line.trim();
|
||||
// extract `<space>at <component>` to `<<component>>`
|
||||
// e.g. ` at Foo` -> `<Foo>`
|
||||
const [, component, location] = /at (\w+)( \((.*)\))?/.exec(line) || [];
|
||||
// If there's no location then it's user-land stack frame
|
||||
if (!location) {
|
||||
if (component === firstContent && firstIndex === -1) {
|
||||
firstIndex = index;
|
||||
} else if (component === secondContent && secondIndex === -1) {
|
||||
secondIndex = index;
|
||||
}
|
||||
}
|
||||
return location ? '' : component;
|
||||
}).filter(Boolean).reverse();
|
||||
let diff = '';
|
||||
for(let i = 0; i < components.length; i++){
|
||||
const component = components[i];
|
||||
const matchFirstContent = hydrationWarningType === 'tag' && i === components.length - firstIndex - 1;
|
||||
const matchSecondContent = hydrationWarningType === 'tag' && i === components.length - secondIndex - 1;
|
||||
if (matchFirstContent || matchSecondContent) {
|
||||
const spaces = ' '.repeat(Math.max(i * 2 - 2, 0) + 2);
|
||||
diff += "> " + spaces + "<" + component + ">\n";
|
||||
} else {
|
||||
const spaces = ' '.repeat(i * 2 + 2);
|
||||
diff += spaces + "<" + component + ">\n";
|
||||
}
|
||||
}
|
||||
if (hydrationWarningType === 'text') {
|
||||
const spaces = ' '.repeat(components.length * 2);
|
||||
diff += "+ " + spaces + '"' + firstContent + '"\n';
|
||||
diff += "- " + spaces + '"' + secondContent + '"\n';
|
||||
} else if (hydrationWarningType === 'text-in-tag') {
|
||||
const spaces = ' '.repeat(components.length * 2);
|
||||
diff += "> " + spaces + "<" + secondContent + ">\n";
|
||||
diff += "> " + spaces + '"' + firstContent + '"\n';
|
||||
}
|
||||
return diff;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=hydration-error-info.js.map
|
||||
1
node_modules/next/dist/esm/client/components/errors/hydration-error-info.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/errors/hydration-error-info.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/next/dist/esm/client/components/errors/runtime-error-handler.js
generated
vendored
Normal file
5
node_modules/next/dist/esm/client/components/errors/runtime-error-handler.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
export const RuntimeErrorHandler = {
|
||||
hadRuntimeError: false
|
||||
};
|
||||
|
||||
//# sourceMappingURL=runtime-error-handler.js.map
|
||||
1
node_modules/next/dist/esm/client/components/errors/runtime-error-handler.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/errors/runtime-error-handler.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../../../src/client/components/errors/runtime-error-handler.ts"],"sourcesContent":["export const RuntimeErrorHandler = {\n hadRuntimeError: false,\n}\n"],"names":["RuntimeErrorHandler","hadRuntimeError"],"mappings":"AAAA,OAAO,MAAMA,sBAAsB;IACjCC,iBAAiB;AACnB,EAAC"}
|
||||
43
node_modules/next/dist/esm/client/components/errors/stitched-error.js
generated
vendored
Normal file
43
node_modules/next/dist/esm/client/components/errors/stitched-error.js
generated
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import React from 'react';
|
||||
import isError from '../../../lib/is-error';
|
||||
import { copyNextErrorCode } from '../../../lib/error-telemetry-utils';
|
||||
const REACT_ERROR_STACK_BOTTOM_FRAME = 'react-stack-bottom-frame';
|
||||
const REACT_ERROR_STACK_BOTTOM_FRAME_REGEX = new RegExp("(at " + REACT_ERROR_STACK_BOTTOM_FRAME + " )|(" + REACT_ERROR_STACK_BOTTOM_FRAME + "\\@)");
|
||||
export function getReactStitchedError(err) {
|
||||
const isErrorInstance = isError(err);
|
||||
const originStack = isErrorInstance ? err.stack || '' : '';
|
||||
const originMessage = isErrorInstance ? err.message : '';
|
||||
const stackLines = originStack.split('\n');
|
||||
const indexOfSplit = stackLines.findIndex((line)=>REACT_ERROR_STACK_BOTTOM_FRAME_REGEX.test(line));
|
||||
const isOriginalReactError = indexOfSplit >= 0 // has the react-stack-bottom-frame
|
||||
;
|
||||
let newStack = isOriginalReactError ? stackLines.slice(0, indexOfSplit).join('\n') : originStack;
|
||||
const newError = Object.defineProperty(new Error(originMessage), "__NEXT_ERROR_CODE", {
|
||||
value: "E394",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
// Copy all enumerable properties, e.g. digest
|
||||
Object.assign(newError, err);
|
||||
copyNextErrorCode(err, newError);
|
||||
newError.stack = newStack;
|
||||
// Avoid duplicate overriding stack frames
|
||||
appendOwnerStack(newError);
|
||||
return newError;
|
||||
}
|
||||
function appendOwnerStack(error) {
|
||||
if (!React.captureOwnerStack) {
|
||||
return;
|
||||
}
|
||||
let stack = error.stack || '';
|
||||
// This module is only bundled in development mode so this is safe.
|
||||
const ownerStack = React.captureOwnerStack();
|
||||
// Avoid duplicate overriding stack frames
|
||||
if (ownerStack && stack.endsWith(ownerStack) === false) {
|
||||
stack += ownerStack;
|
||||
// Override stack
|
||||
error.stack = stack;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=stitched-error.js.map
|
||||
1
node_modules/next/dist/esm/client/components/errors/stitched-error.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/errors/stitched-error.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../../../src/client/components/errors/stitched-error.ts"],"sourcesContent":["import React from 'react'\nimport isError from '../../../lib/is-error'\nimport { copyNextErrorCode } from '../../../lib/error-telemetry-utils'\n\nconst REACT_ERROR_STACK_BOTTOM_FRAME = 'react-stack-bottom-frame'\nconst REACT_ERROR_STACK_BOTTOM_FRAME_REGEX = new RegExp(\n `(at ${REACT_ERROR_STACK_BOTTOM_FRAME} )|(${REACT_ERROR_STACK_BOTTOM_FRAME}\\\\@)`\n)\n\nexport function getReactStitchedError<T = unknown>(err: T): Error | T {\n const isErrorInstance = isError(err)\n const originStack = isErrorInstance ? err.stack || '' : ''\n const originMessage = isErrorInstance ? err.message : ''\n const stackLines = originStack.split('\\n')\n const indexOfSplit = stackLines.findIndex((line) =>\n REACT_ERROR_STACK_BOTTOM_FRAME_REGEX.test(line)\n )\n const isOriginalReactError = indexOfSplit >= 0 // has the react-stack-bottom-frame\n let newStack = isOriginalReactError\n ? stackLines.slice(0, indexOfSplit).join('\\n')\n : originStack\n\n const newError = new Error(originMessage)\n // Copy all enumerable properties, e.g. digest\n Object.assign(newError, err)\n copyNextErrorCode(err, newError)\n newError.stack = newStack\n\n // Avoid duplicate overriding stack frames\n appendOwnerStack(newError)\n\n return newError\n}\n\nfunction appendOwnerStack(error: Error) {\n if (!React.captureOwnerStack) {\n return\n }\n let stack = error.stack || ''\n // This module is only bundled in development mode so this is safe.\n const ownerStack = React.captureOwnerStack()\n // Avoid duplicate overriding stack frames\n if (ownerStack && stack.endsWith(ownerStack) === false) {\n stack += ownerStack\n // Override stack\n error.stack = stack\n }\n}\n"],"names":["React","isError","copyNextErrorCode","REACT_ERROR_STACK_BOTTOM_FRAME","REACT_ERROR_STACK_BOTTOM_FRAME_REGEX","RegExp","getReactStitchedError","err","isErrorInstance","originStack","stack","originMessage","message","stackLines","split","indexOfSplit","findIndex","line","test","isOriginalReactError","newStack","slice","join","newError","Error","Object","assign","appendOwnerStack","error","captureOwnerStack","ownerStack","endsWith"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AACzB,OAAOC,aAAa,wBAAuB;AAC3C,SAASC,iBAAiB,QAAQ,qCAAoC;AAEtE,MAAMC,iCAAiC;AACvC,MAAMC,uCAAuC,IAAIC,OAC/C,AAAC,SAAMF,iCAA+B,SAAMA,iCAA+B;AAG7E,OAAO,SAASG,sBAAmCC,GAAM;IACvD,MAAMC,kBAAkBP,QAAQM;IAChC,MAAME,cAAcD,kBAAkBD,IAAIG,KAAK,IAAI,KAAK;IACxD,MAAMC,gBAAgBH,kBAAkBD,IAAIK,OAAO,GAAG;IACtD,MAAMC,aAAaJ,YAAYK,KAAK,CAAC;IACrC,MAAMC,eAAeF,WAAWG,SAAS,CAAC,CAACC,OACzCb,qCAAqCc,IAAI,CAACD;IAE5C,MAAME,uBAAuBJ,gBAAgB,EAAE,mCAAmC;;IAClF,IAAIK,WAAWD,uBACXN,WAAWQ,KAAK,CAAC,GAAGN,cAAcO,IAAI,CAAC,QACvCb;IAEJ,MAAMc,WAAW,qBAAwB,CAAxB,IAAIC,MAAMb,gBAAV,qBAAA;eAAA;oBAAA;sBAAA;IAAuB;IACxC,8CAA8C;IAC9Cc,OAAOC,MAAM,CAACH,UAAUhB;IACxBL,kBAAkBK,KAAKgB;IACvBA,SAASb,KAAK,GAAGU;IAEjB,0CAA0C;IAC1CO,iBAAiBJ;IAEjB,OAAOA;AACT;AAEA,SAASI,iBAAiBC,KAAY;IACpC,IAAI,CAAC5B,MAAM6B,iBAAiB,EAAE;QAC5B;IACF;IACA,IAAInB,QAAQkB,MAAMlB,KAAK,IAAI;IAC3B,mEAAmE;IACnE,MAAMoB,aAAa9B,MAAM6B,iBAAiB;IAC1C,0CAA0C;IAC1C,IAAIC,cAAcpB,MAAMqB,QAAQ,CAACD,gBAAgB,OAAO;QACtDpB,SAASoB;QACT,iBAAiB;QACjBF,MAAMlB,KAAK,GAAGA;IAChB;AACF"}
|
||||
121
node_modules/next/dist/esm/client/components/errors/use-error-handler.js
generated
vendored
Normal file
121
node_modules/next/dist/esm/client/components/errors/use-error-handler.js
generated
vendored
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
import { useEffect } from 'react';
|
||||
import { attachHydrationErrorState } from './attach-hydration-error-state';
|
||||
import { isNextRouterError } from '../is-next-router-error';
|
||||
import { storeHydrationErrorStateFromConsoleArgs } from './hydration-error-info';
|
||||
import { formatConsoleArgs, parseConsoleArgs } from '../../lib/console';
|
||||
import isError from '../../../lib/is-error';
|
||||
import { createConsoleError } from './console-error';
|
||||
import { enqueueConsecutiveDedupedError } from './enqueue-client-error';
|
||||
import { getReactStitchedError } from '../errors/stitched-error';
|
||||
const queueMicroTask = globalThis.queueMicrotask || ((cb)=>Promise.resolve().then(cb));
|
||||
const errorQueue = [];
|
||||
const errorHandlers = [];
|
||||
const rejectionQueue = [];
|
||||
const rejectionHandlers = [];
|
||||
export function handleConsoleError(originError, consoleErrorArgs) {
|
||||
let error;
|
||||
const { environmentName } = parseConsoleArgs(consoleErrorArgs);
|
||||
if (isError(originError)) {
|
||||
error = createConsoleError(originError, environmentName);
|
||||
} else {
|
||||
error = createConsoleError(formatConsoleArgs(consoleErrorArgs), environmentName);
|
||||
}
|
||||
error = getReactStitchedError(error);
|
||||
storeHydrationErrorStateFromConsoleArgs(...consoleErrorArgs);
|
||||
attachHydrationErrorState(error);
|
||||
enqueueConsecutiveDedupedError(errorQueue, error);
|
||||
for (const handler of errorHandlers){
|
||||
// Delayed the error being passed to React Dev Overlay,
|
||||
// avoid the state being synchronously updated in the component.
|
||||
queueMicroTask(()=>{
|
||||
handler(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
export function handleClientError(originError) {
|
||||
let error;
|
||||
if (isError(originError)) {
|
||||
error = originError;
|
||||
} else {
|
||||
// If it's not an error, format the args into an error
|
||||
const formattedErrorMessage = originError + '';
|
||||
error = Object.defineProperty(new Error(formattedErrorMessage), "__NEXT_ERROR_CODE", {
|
||||
value: "E394",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
error = getReactStitchedError(error);
|
||||
attachHydrationErrorState(error);
|
||||
enqueueConsecutiveDedupedError(errorQueue, error);
|
||||
for (const handler of errorHandlers){
|
||||
// Delayed the error being passed to React Dev Overlay,
|
||||
// avoid the state being synchronously updated in the component.
|
||||
queueMicroTask(()=>{
|
||||
handler(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
export function useErrorHandler(handleOnUnhandledError, handleOnUnhandledRejection) {
|
||||
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);
|
||||
// Reset error queues.
|
||||
errorQueue.splice(0, errorQueue.length);
|
||||
rejectionQueue.splice(0, rejectionQueue.length);
|
||||
};
|
||||
}, [
|
||||
handleOnUnhandledError,
|
||||
handleOnUnhandledRejection
|
||||
]);
|
||||
}
|
||||
function onUnhandledError(event) {
|
||||
if (isNextRouterError(event.error)) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
// When there's an error property present, we log the error to error overlay.
|
||||
// Otherwise we don't do anything as it's not logging in the console either.
|
||||
if (event.error) {
|
||||
handleClientError(event.error);
|
||||
}
|
||||
}
|
||||
function onUnhandledRejection(ev) {
|
||||
const reason = ev == null ? void 0 : ev.reason;
|
||||
if (isNextRouterError(reason)) {
|
||||
ev.preventDefault();
|
||||
return;
|
||||
}
|
||||
let error = reason;
|
||||
if (error && !isError(error)) {
|
||||
error = Object.defineProperty(new Error(error + ''), "__NEXT_ERROR_CODE", {
|
||||
value: "E394",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
rejectionQueue.push(error);
|
||||
for (const handler of rejectionHandlers){
|
||||
handler(error);
|
||||
}
|
||||
}
|
||||
export function handleGlobalErrors() {
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
// Increase the number of stack frames on the client
|
||||
Error.stackTraceLimit = 50;
|
||||
} catch (e) {}
|
||||
window.addEventListener('error', onUnhandledError);
|
||||
window.addEventListener('unhandledrejection', onUnhandledRejection);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=use-error-handler.js.map
|
||||
1
node_modules/next/dist/esm/client/components/errors/use-error-handler.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/errors/use-error-handler.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue