Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
59
node_modules/next/dist/esm/client/components/react-dev-overlay/app/app-dev-overlay-error-boundary.js
generated
vendored
Normal file
59
node_modules/next/dist/esm/client/components/react-dev-overlay/app/app-dev-overlay-error-boundary.js
generated
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
import { PureComponent } from 'react';
|
||||
import { RuntimeErrorHandler } from '../../errors/runtime-error-handler';
|
||||
import { ErrorBoundary, GlobalError as DefaultGlobalError } from '../../error-boundary';
|
||||
function ErroredHtml(param) {
|
||||
let { globalError: [GlobalError, globalErrorStyles], error } = param;
|
||||
if (!error) {
|
||||
return /*#__PURE__*/ _jsxs("html", {
|
||||
children: [
|
||||
/*#__PURE__*/ _jsx("head", {}),
|
||||
/*#__PURE__*/ _jsx("body", {})
|
||||
]
|
||||
});
|
||||
}
|
||||
return /*#__PURE__*/ _jsxs(ErrorBoundary, {
|
||||
errorComponent: DefaultGlobalError,
|
||||
children: [
|
||||
globalErrorStyles,
|
||||
/*#__PURE__*/ _jsx(GlobalError, {
|
||||
error: error
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
export class AppDevOverlayErrorBoundary extends PureComponent {
|
||||
static getDerivedStateFromError(error) {
|
||||
if (!error.stack) {
|
||||
return {
|
||||
isReactError: false,
|
||||
reactError: null
|
||||
};
|
||||
}
|
||||
RuntimeErrorHandler.hadRuntimeError = true;
|
||||
return {
|
||||
isReactError: true,
|
||||
reactError: error
|
||||
};
|
||||
}
|
||||
componentDidCatch() {
|
||||
this.props.onError(this.state.isReactError);
|
||||
}
|
||||
render() {
|
||||
const { children, globalError } = this.props;
|
||||
const { isReactError, reactError } = this.state;
|
||||
const fallback = /*#__PURE__*/ _jsx(ErroredHtml, {
|
||||
globalError: globalError,
|
||||
error: reactError
|
||||
});
|
||||
return isReactError ? fallback : children;
|
||||
}
|
||||
constructor(...args){
|
||||
super(...args), this.state = {
|
||||
isReactError: false,
|
||||
reactError: null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=app-dev-overlay-error-boundary.js.map
|
||||
1
node_modules/next/dist/esm/client/components/react-dev-overlay/app/app-dev-overlay-error-boundary.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/react-dev-overlay/app/app-dev-overlay-error-boundary.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/app/app-dev-overlay-error-boundary.tsx"],"sourcesContent":["import { PureComponent } from 'react'\nimport { RuntimeErrorHandler } from '../../errors/runtime-error-handler'\nimport {\n ErrorBoundary,\n type GlobalErrorComponent,\n GlobalError as DefaultGlobalError,\n} from '../../error-boundary'\n\ntype AppDevOverlayErrorBoundaryProps = {\n children: React.ReactNode\n globalError: [GlobalErrorComponent, React.ReactNode]\n onError: (value: boolean) => void\n}\n\ntype AppDevOverlayErrorBoundaryState = {\n isReactError: boolean\n reactError: unknown\n}\n\nfunction ErroredHtml({\n globalError: [GlobalError, globalErrorStyles],\n error,\n}: {\n globalError: [GlobalErrorComponent, React.ReactNode]\n error: unknown\n}) {\n if (!error) {\n return (\n <html>\n <head />\n <body />\n </html>\n )\n }\n return (\n <ErrorBoundary errorComponent={DefaultGlobalError}>\n {globalErrorStyles}\n <GlobalError error={error} />\n </ErrorBoundary>\n )\n}\n\nexport class AppDevOverlayErrorBoundary extends PureComponent<\n AppDevOverlayErrorBoundaryProps,\n AppDevOverlayErrorBoundaryState\n> {\n state = { isReactError: false, reactError: null }\n\n static getDerivedStateFromError(error: Error) {\n if (!error.stack) {\n return { isReactError: false, reactError: null }\n }\n\n RuntimeErrorHandler.hadRuntimeError = true\n\n return {\n isReactError: true,\n reactError: error,\n }\n }\n\n componentDidCatch() {\n this.props.onError(this.state.isReactError)\n }\n\n render() {\n const { children, globalError } = this.props\n const { isReactError, reactError } = this.state\n\n const fallback = (\n <ErroredHtml globalError={globalError} error={reactError} />\n )\n\n return isReactError ? fallback : children\n }\n}\n"],"names":["PureComponent","RuntimeErrorHandler","ErrorBoundary","GlobalError","DefaultGlobalError","ErroredHtml","globalError","globalErrorStyles","error","html","head","body","errorComponent","AppDevOverlayErrorBoundary","getDerivedStateFromError","stack","isReactError","reactError","hadRuntimeError","componentDidCatch","props","onError","state","render","children","fallback"],"mappings":";AAAA,SAASA,aAAa,QAAQ,QAAO;AACrC,SAASC,mBAAmB,QAAQ,qCAAoC;AACxE,SACEC,aAAa,EAEbC,eAAeC,kBAAkB,QAC5B,uBAAsB;AAa7B,SAASC,YAAY,KAMpB;IANoB,IAAA,EACnBC,aAAa,CAACH,aAAaI,kBAAkB,EAC7CC,KAAK,EAIN,GANoB;IAOnB,IAAI,CAACA,OAAO;QACV,qBACE,MAACC;;8BACC,KAACC;8BACD,KAACC;;;IAGP;IACA,qBACE,MAACT;QAAcU,gBAAgBR;;YAC5BG;0BACD,KAACJ;gBAAYK,OAAOA;;;;AAG1B;AAEA,OAAO,MAAMK,mCAAmCb;IAM9C,OAAOc,yBAAyBN,KAAY,EAAE;QAC5C,IAAI,CAACA,MAAMO,KAAK,EAAE;YAChB,OAAO;gBAAEC,cAAc;gBAAOC,YAAY;YAAK;QACjD;QAEAhB,oBAAoBiB,eAAe,GAAG;QAEtC,OAAO;YACLF,cAAc;YACdC,YAAYT;QACd;IACF;IAEAW,oBAAoB;QAClB,IAAI,CAACC,KAAK,CAACC,OAAO,CAAC,IAAI,CAACC,KAAK,CAACN,YAAY;IAC5C;IAEAO,SAAS;QACP,MAAM,EAAEC,QAAQ,EAAElB,WAAW,EAAE,GAAG,IAAI,CAACc,KAAK;QAC5C,MAAM,EAAEJ,YAAY,EAAEC,UAAU,EAAE,GAAG,IAAI,CAACK,KAAK;QAE/C,MAAMG,yBACJ,KAACpB;YAAYC,aAAaA;YAAaE,OAAOS;;QAGhD,OAAOD,eAAeS,WAAWD;IACnC;;QAhCK,qBAILF,QAAQ;YAAEN,cAAc;YAAOC,YAAY;QAAK;;AA6BlD"}
|
||||
95
node_modules/next/dist/esm/client/components/react-dev-overlay/app/app-dev-overlay.js
generated
vendored
Normal file
95
node_modules/next/dist/esm/client/components/react-dev-overlay/app/app-dev-overlay.js
generated
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { AppDevOverlayErrorBoundary } from './app-dev-overlay-error-boundary';
|
||||
import { FontStyles } from '../font/font-styles';
|
||||
import { DevOverlay } from '../ui/dev-overlay';
|
||||
import { handleClientError } from '../../errors/use-error-handler';
|
||||
import { isNextRouterError } from '../../is-next-router-error';
|
||||
import { MISSING_ROOT_TAGS_ERROR } from '../../../../shared/lib/errors/constants';
|
||||
function readSsrError() {
|
||||
if (typeof document === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
const ssrErrorTemplateTag = document.querySelector('template[data-next-error-message]');
|
||||
if (ssrErrorTemplateTag) {
|
||||
const message = ssrErrorTemplateTag.getAttribute('data-next-error-message');
|
||||
const stack = ssrErrorTemplateTag.getAttribute('data-next-error-stack');
|
||||
const digest = ssrErrorTemplateTag.getAttribute('data-next-error-digest');
|
||||
const error = Object.defineProperty(new Error(message), "__NEXT_ERROR_CODE", {
|
||||
value: "E394",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
if (digest) {
|
||||
;
|
||||
error.digest = digest;
|
||||
}
|
||||
// Skip Next.js SSR'd internal errors that which will be handled by the error boundaries.
|
||||
if (isNextRouterError(error)) {
|
||||
return null;
|
||||
}
|
||||
error.stack = stack || '';
|
||||
return error;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Needs to be in the same error boundary as the shell.
|
||||
// If it commits, we know we recovered from an SSR error.
|
||||
// If it doesn't commit, we errored again and React will take care of error reporting.
|
||||
function ReplaySsrOnlyErrors(param) {
|
||||
let { onBlockingError } = param;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// Need to read during render. The attributes will be gone after commit.
|
||||
const ssrError = readSsrError();
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
useEffect(()=>{
|
||||
if (ssrError !== null) {
|
||||
// TODO(veil): Produces wrong Owner Stack
|
||||
// TODO(veil): Mark as recoverable error
|
||||
// TODO(veil): console.error
|
||||
handleClientError(ssrError);
|
||||
// If it's missing root tags, we can't recover, make it blocking.
|
||||
if (ssrError.digest === MISSING_ROOT_TAGS_ERROR) {
|
||||
onBlockingError();
|
||||
}
|
||||
}
|
||||
}, [
|
||||
ssrError,
|
||||
onBlockingError
|
||||
]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
export function AppDevOverlay(param) {
|
||||
let { state, globalError, children } = param;
|
||||
const [isErrorOverlayOpen, setIsErrorOverlayOpen] = useState(false);
|
||||
const openOverlay = useCallback(()=>{
|
||||
setIsErrorOverlayOpen(true);
|
||||
}, []);
|
||||
return /*#__PURE__*/ _jsxs(_Fragment, {
|
||||
children: [
|
||||
/*#__PURE__*/ _jsxs(AppDevOverlayErrorBoundary, {
|
||||
globalError: globalError,
|
||||
onError: setIsErrorOverlayOpen,
|
||||
children: [
|
||||
/*#__PURE__*/ _jsx(ReplaySsrOnlyErrors, {
|
||||
onBlockingError: openOverlay
|
||||
}),
|
||||
children
|
||||
]
|
||||
}),
|
||||
/*#__PURE__*/ _jsxs(_Fragment, {
|
||||
children: [
|
||||
/*#__PURE__*/ _jsx(FontStyles, {}),
|
||||
/*#__PURE__*/ _jsx(DevOverlay, {
|
||||
state: state,
|
||||
isErrorOverlayOpen: isErrorOverlayOpen,
|
||||
setIsErrorOverlayOpen: setIsErrorOverlayOpen
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=app-dev-overlay.js.map
|
||||
1
node_modules/next/dist/esm/client/components/react-dev-overlay/app/app-dev-overlay.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/react-dev-overlay/app/app-dev-overlay.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
37
node_modules/next/dist/esm/client/components/react-dev-overlay/app/client-entry.js
generated
vendored
Normal file
37
node_modules/next/dist/esm/client/components/react-dev-overlay/app/client-entry.js
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import React from 'react';
|
||||
import { getSocketUrl } from '../utils/get-socket-url';
|
||||
import { HMR_ACTIONS_SENT_TO_BROWSER } from '../../../../server/dev/hot-reloader-types';
|
||||
import GlobalError from '../../error-boundary';
|
||||
import { AppDevOverlayErrorBoundary } from './app-dev-overlay-error-boundary';
|
||||
const noop = ()=>{};
|
||||
// if an error is thrown while rendering an RSC stream, this will catch it in dev
|
||||
// and show the error overlay
|
||||
export function createRootLevelDevOverlayElement(reactEl) {
|
||||
const socketUrl = getSocketUrl(process.env.__NEXT_ASSET_PREFIX || '');
|
||||
const socket = new window.WebSocket("" + socketUrl + "/_next/webpack-hmr");
|
||||
// add minimal "hot reload" support for RSC errors
|
||||
const handler = (event)=>{
|
||||
let obj;
|
||||
try {
|
||||
obj = JSON.parse(event.data);
|
||||
} catch (e) {}
|
||||
if (!obj || !('action' in obj)) {
|
||||
return;
|
||||
}
|
||||
if (obj.action === HMR_ACTIONS_SENT_TO_BROWSER.SERVER_COMPONENT_CHANGES) {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
socket.addEventListener('message', handler);
|
||||
return /*#__PURE__*/ _jsx(AppDevOverlayErrorBoundary, {
|
||||
globalError: [
|
||||
GlobalError,
|
||||
null
|
||||
],
|
||||
onError: noop,
|
||||
children: reactEl
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=client-entry.js.map
|
||||
1
node_modules/next/dist/esm/client/components/react-dev-overlay/app/client-entry.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/react-dev-overlay/app/client-entry.js.map
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/app/client-entry.tsx"],"sourcesContent":["import React from 'react'\nimport { getSocketUrl } from '../utils/get-socket-url'\nimport { HMR_ACTIONS_SENT_TO_BROWSER } from '../../../../server/dev/hot-reloader-types'\nimport GlobalError from '../../error-boundary'\nimport { AppDevOverlayErrorBoundary } from './app-dev-overlay-error-boundary'\n\nconst noop = () => {}\n\n// if an error is thrown while rendering an RSC stream, this will catch it in dev\n// and show the error overlay\nexport function createRootLevelDevOverlayElement(reactEl: React.ReactElement) {\n const socketUrl = getSocketUrl(process.env.__NEXT_ASSET_PREFIX || '')\n const socket = new window.WebSocket(`${socketUrl}/_next/webpack-hmr`)\n\n // add minimal \"hot reload\" support for RSC errors\n const handler = (event: MessageEvent) => {\n let obj\n try {\n obj = JSON.parse(event.data)\n } catch {}\n\n if (!obj || !('action' in obj)) {\n return\n }\n\n if (obj.action === HMR_ACTIONS_SENT_TO_BROWSER.SERVER_COMPONENT_CHANGES) {\n window.location.reload()\n }\n }\n\n socket.addEventListener('message', handler)\n\n return (\n <AppDevOverlayErrorBoundary\n globalError={[GlobalError, null]}\n onError={noop}\n >\n {reactEl}\n </AppDevOverlayErrorBoundary>\n )\n}\n"],"names":["React","getSocketUrl","HMR_ACTIONS_SENT_TO_BROWSER","GlobalError","AppDevOverlayErrorBoundary","noop","createRootLevelDevOverlayElement","reactEl","socketUrl","process","env","__NEXT_ASSET_PREFIX","socket","window","WebSocket","handler","event","obj","JSON","parse","data","action","SERVER_COMPONENT_CHANGES","location","reload","addEventListener","globalError","onError"],"mappings":";AAAA,OAAOA,WAAW,QAAO;AACzB,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,2BAA2B,QAAQ,4CAA2C;AACvF,OAAOC,iBAAiB,uBAAsB;AAC9C,SAASC,0BAA0B,QAAQ,mCAAkC;AAE7E,MAAMC,OAAO,KAAO;AAEpB,iFAAiF;AACjF,6BAA6B;AAC7B,OAAO,SAASC,iCAAiCC,OAA2B;IAC1E,MAAMC,YAAYP,aAAaQ,QAAQC,GAAG,CAACC,mBAAmB,IAAI;IAClE,MAAMC,SAAS,IAAIC,OAAOC,SAAS,CAAC,AAAC,KAAEN,YAAU;IAEjD,kDAAkD;IAClD,MAAMO,UAAU,CAACC;QACf,IAAIC;QACJ,IAAI;YACFA,MAAMC,KAAKC,KAAK,CAACH,MAAMI,IAAI;QAC7B,EAAE,UAAM,CAAC;QAET,IAAI,CAACH,OAAO,CAAE,CAAA,YAAYA,GAAE,GAAI;YAC9B;QACF;QAEA,IAAIA,IAAII,MAAM,KAAKnB,4BAA4BoB,wBAAwB,EAAE;YACvET,OAAOU,QAAQ,CAACC,MAAM;QACxB;IACF;IAEAZ,OAAOa,gBAAgB,CAAC,WAAWV;IAEnC,qBACE,KAACX;QACCsB,aAAa;YAACvB;YAAa;SAAK;QAChCwB,SAAStB;kBAERE;;AAGP"}
|
||||
506
node_modules/next/dist/esm/client/components/react-dev-overlay/app/hot-reloader-client.js
generated
vendored
Normal file
506
node_modules/next/dist/esm/client/components/react-dev-overlay/app/hot-reloader-client.js
generated
vendored
Normal file
|
|
@ -0,0 +1,506 @@
|
|||
/// <reference types="webpack/module.d.ts" />
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import { useCallback, useEffect, startTransition, useMemo, useRef } from 'react';
|
||||
import stripAnsi from 'next/dist/compiled/strip-ansi';
|
||||
import formatWebpackMessages from '../utils/format-webpack-messages';
|
||||
import { useRouter } from '../../navigation';
|
||||
import { ACTION_BEFORE_REFRESH, ACTION_BUILD_ERROR, ACTION_BUILD_OK, ACTION_DEBUG_INFO, ACTION_DEV_INDICATOR, ACTION_REFRESH, ACTION_STATIC_INDICATOR, ACTION_UNHANDLED_ERROR, ACTION_UNHANDLED_REJECTION, ACTION_VERSION_INFO, REACT_REFRESH_FULL_RELOAD, reportInvalidHmrMessage, useErrorOverlayReducer } from '../shared';
|
||||
import { parseStack } from '../utils/parse-stack';
|
||||
import { AppDevOverlay } from './app-dev-overlay';
|
||||
import { useErrorHandler } from '../../errors/use-error-handler';
|
||||
import { RuntimeErrorHandler } from '../../errors/runtime-error-handler';
|
||||
import { useSendMessage, useTurbopack, useWebsocket, useWebsocketPing } from '../utils/use-websocket';
|
||||
import { parseComponentStack } from '../utils/parse-component-stack';
|
||||
import { HMR_ACTIONS_SENT_TO_BROWSER } from '../../../../server/dev/hot-reloader-types';
|
||||
import { REACT_REFRESH_FULL_RELOAD_FROM_ERROR } from '../shared';
|
||||
import { useUntrackedPathname } from '../../navigation-untracked';
|
||||
import { getReactStitchedError } from '../../errors/stitched-error';
|
||||
import { handleDevBuildIndicatorHmrEvents } from '../../../dev/dev-build-indicator/internal/handle-dev-build-indicator-hmr-events';
|
||||
import reportHmrLatency from '../utils/report-hmr-latency';
|
||||
import { TurbopackHmr } from '../utils/turbopack-hot-reloader-common';
|
||||
import { NEXT_HMR_REFRESH_HASH_COOKIE } from '../../app-router-headers';
|
||||
let mostRecentCompilationHash = null;
|
||||
let __nextDevClientId = Math.round(Math.random() * 100 + Date.now());
|
||||
let reloading = false;
|
||||
let webpackStartMsSinceEpoch = null;
|
||||
const turbopackHmr = process.env.TURBOPACK ? new TurbopackHmr() : null;
|
||||
let pendingHotUpdateWebpack = Promise.resolve();
|
||||
let resolvePendingHotUpdateWebpack = ()=>{};
|
||||
function setPendingHotUpdateWebpack() {
|
||||
pendingHotUpdateWebpack = new Promise((resolve)=>{
|
||||
resolvePendingHotUpdateWebpack = ()=>{
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
}
|
||||
export function waitForWebpackRuntimeHotUpdate() {
|
||||
return pendingHotUpdateWebpack;
|
||||
}
|
||||
// There is a newer version of the code available.
|
||||
function handleAvailableHash(hash) {
|
||||
// Update last known compilation hash.
|
||||
mostRecentCompilationHash = hash;
|
||||
}
|
||||
/**
|
||||
* Is there a newer version of this code available?
|
||||
* For webpack: Check if the hash changed compared to __webpack_hash__
|
||||
* For Turbopack: Always true because it doesn't have __webpack_hash__
|
||||
*/ function isUpdateAvailable() {
|
||||
if (process.env.TURBOPACK) {
|
||||
return true;
|
||||
}
|
||||
/* globals __webpack_hash__ */ // __webpack_hash__ is the hash of the current compilation.
|
||||
// It's a global variable injected by Webpack.
|
||||
return mostRecentCompilationHash !== __webpack_hash__;
|
||||
}
|
||||
// Webpack disallows updates in other states.
|
||||
function canApplyUpdates() {
|
||||
return module.hot.status() === 'idle';
|
||||
}
|
||||
function afterApplyUpdates(fn) {
|
||||
if (canApplyUpdates()) {
|
||||
fn();
|
||||
} else {
|
||||
function handler(status) {
|
||||
if (status === 'idle') {
|
||||
module.hot.removeStatusHandler(handler);
|
||||
fn();
|
||||
}
|
||||
}
|
||||
module.hot.addStatusHandler(handler);
|
||||
}
|
||||
}
|
||||
function performFullReload(err, sendMessage) {
|
||||
const stackTrace = err && (err.stack && err.stack.split('\n').slice(0, 5).join('\n') || err.message || err + '');
|
||||
sendMessage(JSON.stringify({
|
||||
event: 'client-full-reload',
|
||||
stackTrace,
|
||||
hadRuntimeError: !!RuntimeErrorHandler.hadRuntimeError,
|
||||
dependencyChain: err ? err.dependencyChain : undefined
|
||||
}));
|
||||
if (reloading) return;
|
||||
reloading = true;
|
||||
window.location.reload();
|
||||
}
|
||||
// Attempt to update code on the fly, fall back to a hard reload.
|
||||
function tryApplyUpdatesWebpack(sendMessage, dispatcher) {
|
||||
if (!isUpdateAvailable() || !canApplyUpdates()) {
|
||||
resolvePendingHotUpdateWebpack();
|
||||
dispatcher.onBuildOk();
|
||||
reportHmrLatency(sendMessage, [], webpackStartMsSinceEpoch, Date.now());
|
||||
return;
|
||||
}
|
||||
function handleApplyUpdates(err, updatedModules) {
|
||||
if (err || RuntimeErrorHandler.hadRuntimeError || updatedModules == null) {
|
||||
if (err) {
|
||||
console.warn(REACT_REFRESH_FULL_RELOAD);
|
||||
} else if (RuntimeErrorHandler.hadRuntimeError) {
|
||||
console.warn(REACT_REFRESH_FULL_RELOAD_FROM_ERROR);
|
||||
}
|
||||
performFullReload(err, sendMessage);
|
||||
return;
|
||||
}
|
||||
dispatcher.onBuildOk();
|
||||
if (isUpdateAvailable()) {
|
||||
// While we were updating, there was a new update! Do it again.
|
||||
tryApplyUpdatesWebpack(sendMessage, dispatcher);
|
||||
return;
|
||||
}
|
||||
dispatcher.onRefresh();
|
||||
resolvePendingHotUpdateWebpack();
|
||||
reportHmrLatency(sendMessage, updatedModules, webpackStartMsSinceEpoch, Date.now());
|
||||
if (process.env.__NEXT_TEST_MODE) {
|
||||
afterApplyUpdates(()=>{
|
||||
if (self.__NEXT_HMR_CB) {
|
||||
self.__NEXT_HMR_CB();
|
||||
self.__NEXT_HMR_CB = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// https://webpack.js.org/api/hot-module-replacement/#check
|
||||
module.hot.check(/* autoApply */ false).then((updatedModules)=>{
|
||||
if (updatedModules == null) {
|
||||
return null;
|
||||
}
|
||||
// We should always handle an update, even if updatedModules is empty (but
|
||||
// non-null) for any reason. That's what webpack would normally do:
|
||||
// https://github.com/webpack/webpack/blob/3aa6b6bc3a64/lib/hmr/HotModuleReplacement.runtime.js#L296-L298
|
||||
dispatcher.onBeforeRefresh();
|
||||
// https://webpack.js.org/api/hot-module-replacement/#apply
|
||||
return module.hot.apply();
|
||||
}).then((updatedModules)=>{
|
||||
handleApplyUpdates(null, updatedModules);
|
||||
}, (err)=>{
|
||||
handleApplyUpdates(err, null);
|
||||
});
|
||||
}
|
||||
/** Handles messages from the server for the App Router. */ function processMessage(obj, sendMessage, processTurbopackMessage, router, dispatcher, appIsrManifestRef, pathnameRef) {
|
||||
if (!('action' in obj)) {
|
||||
return;
|
||||
}
|
||||
function handleErrors(errors) {
|
||||
// "Massage" webpack messages.
|
||||
const formatted = formatWebpackMessages({
|
||||
errors: errors,
|
||||
warnings: []
|
||||
});
|
||||
// Only show the first error.
|
||||
dispatcher.onBuildError(formatted.errors[0]);
|
||||
// Also log them to the console.
|
||||
for(let i = 0; i < formatted.errors.length; i++){
|
||||
console.error(stripAnsi(formatted.errors[i]));
|
||||
}
|
||||
// Do not attempt to reload now.
|
||||
// We will reload on next success instead.
|
||||
if (process.env.__NEXT_TEST_MODE) {
|
||||
if (self.__NEXT_HMR_CB) {
|
||||
self.__NEXT_HMR_CB(formatted.errors[0]);
|
||||
self.__NEXT_HMR_CB = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
function handleHotUpdate() {
|
||||
if (process.env.TURBOPACK) {
|
||||
const hmrUpdate = turbopackHmr.onBuilt();
|
||||
if (hmrUpdate != null) {
|
||||
reportHmrLatency(sendMessage, [
|
||||
...hmrUpdate.updatedModules
|
||||
], hmrUpdate.startMsSinceEpoch, hmrUpdate.endMsSinceEpoch, // suppress the `client-hmr-latency` event if the update was a no-op:
|
||||
hmrUpdate.hasUpdates);
|
||||
}
|
||||
dispatcher.onBuildOk();
|
||||
} else {
|
||||
tryApplyUpdatesWebpack(sendMessage, dispatcher);
|
||||
}
|
||||
}
|
||||
switch(obj.action){
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.ISR_MANIFEST:
|
||||
{
|
||||
if (process.env.__NEXT_DEV_INDICATOR) {
|
||||
if (appIsrManifestRef) {
|
||||
appIsrManifestRef.current = obj.data;
|
||||
// handle initial status on receiving manifest
|
||||
// navigation is handled in useEffect for pathname changes
|
||||
// as we'll receive the updated manifest before usePathname
|
||||
// triggers for new value
|
||||
if (pathnameRef.current in obj.data) {
|
||||
dispatcher.onStaticIndicator(true);
|
||||
} else {
|
||||
dispatcher.onStaticIndicator(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.BUILDING:
|
||||
{
|
||||
if (process.env.TURBOPACK) {
|
||||
turbopackHmr.onBuilding();
|
||||
} else {
|
||||
webpackStartMsSinceEpoch = Date.now();
|
||||
setPendingHotUpdateWebpack();
|
||||
console.log('[Fast Refresh] rebuilding');
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.BUILT:
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.SYNC:
|
||||
{
|
||||
if (obj.hash) {
|
||||
handleAvailableHash(obj.hash);
|
||||
}
|
||||
const { errors, warnings } = obj;
|
||||
// Is undefined when it's a 'built' event
|
||||
if ('versionInfo' in obj) dispatcher.onVersionInfo(obj.versionInfo);
|
||||
if ('debug' in obj && obj.debug) dispatcher.onDebugInfo(obj.debug);
|
||||
if ('devIndicator' in obj) dispatcher.onDevIndicator(obj.devIndicator);
|
||||
const hasErrors = Boolean(errors && errors.length);
|
||||
// Compilation with errors (e.g. syntax error or missing modules).
|
||||
if (hasErrors) {
|
||||
sendMessage(JSON.stringify({
|
||||
event: 'client-error',
|
||||
errorCount: errors.length,
|
||||
clientId: __nextDevClientId
|
||||
}));
|
||||
handleErrors(errors);
|
||||
return;
|
||||
}
|
||||
const hasWarnings = Boolean(warnings && warnings.length);
|
||||
if (hasWarnings) {
|
||||
sendMessage(JSON.stringify({
|
||||
event: 'client-warning',
|
||||
warningCount: warnings.length,
|
||||
clientId: __nextDevClientId
|
||||
}));
|
||||
// Print warnings to the console.
|
||||
const formattedMessages = formatWebpackMessages({
|
||||
warnings: warnings,
|
||||
errors: []
|
||||
});
|
||||
for(let i = 0; i < formattedMessages.warnings.length; i++){
|
||||
if (i === 5) {
|
||||
console.warn('There were more warnings in other files.\n' + 'You can find a complete log in the terminal.');
|
||||
break;
|
||||
}
|
||||
console.warn(stripAnsi(formattedMessages.warnings[i]));
|
||||
}
|
||||
// No early return here as we need to apply modules in the same way between warnings only and compiles without warnings
|
||||
}
|
||||
sendMessage(JSON.stringify({
|
||||
event: 'client-success',
|
||||
clientId: __nextDevClientId
|
||||
}));
|
||||
if (obj.action === HMR_ACTIONS_SENT_TO_BROWSER.BUILT) {
|
||||
handleHotUpdate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_CONNECTED:
|
||||
{
|
||||
processTurbopackMessage({
|
||||
type: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_CONNECTED,
|
||||
data: {
|
||||
sessionId: obj.data.sessionId
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_MESSAGE:
|
||||
{
|
||||
turbopackHmr.onTurbopackMessage(obj);
|
||||
dispatcher.onBeforeRefresh();
|
||||
processTurbopackMessage({
|
||||
type: HMR_ACTIONS_SENT_TO_BROWSER.TURBOPACK_MESSAGE,
|
||||
data: obj.data
|
||||
});
|
||||
if (RuntimeErrorHandler.hadRuntimeError) {
|
||||
console.warn(REACT_REFRESH_FULL_RELOAD_FROM_ERROR);
|
||||
performFullReload(null, sendMessage);
|
||||
}
|
||||
dispatcher.onRefresh();
|
||||
break;
|
||||
}
|
||||
// TODO-APP: make server component change more granular
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.SERVER_COMPONENT_CHANGES:
|
||||
{
|
||||
turbopackHmr == null ? void 0 : turbopackHmr.onServerComponentChanges();
|
||||
sendMessage(JSON.stringify({
|
||||
event: 'server-component-reload-page',
|
||||
clientId: __nextDevClientId,
|
||||
hash: obj.hash
|
||||
}));
|
||||
// Store the latest hash in a session cookie so that it's sent back to the
|
||||
// server with any subsequent requests.
|
||||
document.cookie = NEXT_HMR_REFRESH_HASH_COOKIE + "=" + obj.hash;
|
||||
if (RuntimeErrorHandler.hadRuntimeError) {
|
||||
if (reloading) return;
|
||||
reloading = true;
|
||||
return window.location.reload();
|
||||
}
|
||||
startTransition(()=>{
|
||||
router.hmrRefresh();
|
||||
dispatcher.onRefresh();
|
||||
});
|
||||
if (process.env.__NEXT_TEST_MODE) {
|
||||
if (self.__NEXT_HMR_CB) {
|
||||
self.__NEXT_HMR_CB();
|
||||
self.__NEXT_HMR_CB = null;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE:
|
||||
{
|
||||
turbopackHmr == null ? void 0 : turbopackHmr.onReloadPage();
|
||||
sendMessage(JSON.stringify({
|
||||
event: 'client-reload-page',
|
||||
clientId: __nextDevClientId
|
||||
}));
|
||||
if (reloading) return;
|
||||
reloading = true;
|
||||
return window.location.reload();
|
||||
}
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.ADDED_PAGE:
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.REMOVED_PAGE:
|
||||
{
|
||||
turbopackHmr == null ? void 0 : turbopackHmr.onPageAddRemove();
|
||||
// TODO-APP: potentially only refresh if the currently viewed page was added/removed.
|
||||
return router.hmrRefresh();
|
||||
}
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.SERVER_ERROR:
|
||||
{
|
||||
const { errorJSON } = obj;
|
||||
if (errorJSON) {
|
||||
const { message, stack } = JSON.parse(errorJSON);
|
||||
const error = Object.defineProperty(new Error(message), "__NEXT_ERROR_CODE", {
|
||||
value: "E394",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
error.stack = stack;
|
||||
handleErrors([
|
||||
error
|
||||
]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case HMR_ACTIONS_SENT_TO_BROWSER.DEV_PAGES_MANIFEST_UPDATE:
|
||||
{
|
||||
return;
|
||||
}
|
||||
default:
|
||||
{}
|
||||
}
|
||||
}
|
||||
export default function HotReload(param) {
|
||||
let { assetPrefix, children, globalError } = param;
|
||||
const [state, dispatch] = useErrorOverlayReducer('app');
|
||||
const dispatcher = useMemo(()=>{
|
||||
return {
|
||||
onBuildOk () {
|
||||
dispatch({
|
||||
type: ACTION_BUILD_OK
|
||||
});
|
||||
},
|
||||
onBuildError (message) {
|
||||
dispatch({
|
||||
type: ACTION_BUILD_ERROR,
|
||||
message
|
||||
});
|
||||
},
|
||||
onBeforeRefresh () {
|
||||
dispatch({
|
||||
type: ACTION_BEFORE_REFRESH
|
||||
});
|
||||
},
|
||||
onRefresh () {
|
||||
dispatch({
|
||||
type: ACTION_REFRESH
|
||||
});
|
||||
},
|
||||
onVersionInfo (versionInfo) {
|
||||
dispatch({
|
||||
type: ACTION_VERSION_INFO,
|
||||
versionInfo
|
||||
});
|
||||
},
|
||||
onStaticIndicator (status) {
|
||||
dispatch({
|
||||
type: ACTION_STATIC_INDICATOR,
|
||||
staticIndicator: status
|
||||
});
|
||||
},
|
||||
onDebugInfo (debugInfo) {
|
||||
dispatch({
|
||||
type: ACTION_DEBUG_INFO,
|
||||
debugInfo
|
||||
});
|
||||
},
|
||||
onDevIndicator (devIndicator) {
|
||||
dispatch({
|
||||
type: ACTION_DEV_INDICATOR,
|
||||
devIndicator
|
||||
});
|
||||
}
|
||||
};
|
||||
}, [
|
||||
dispatch
|
||||
]);
|
||||
const handleOnUnhandledError = useCallback((error)=>{
|
||||
// Component stack is added to the error in use-error-handler in case there was a hydration error
|
||||
const componentStackTrace = error._componentStack;
|
||||
dispatch({
|
||||
type: ACTION_UNHANDLED_ERROR,
|
||||
reason: error,
|
||||
frames: parseStack(error.stack || ''),
|
||||
componentStackFrames: typeof componentStackTrace === 'string' ? parseComponentStack(componentStackTrace) : undefined
|
||||
});
|
||||
}, [
|
||||
dispatch
|
||||
]);
|
||||
const handleOnUnhandledRejection = useCallback((reason)=>{
|
||||
const stitchedError = getReactStitchedError(reason);
|
||||
dispatch({
|
||||
type: ACTION_UNHANDLED_REJECTION,
|
||||
reason: stitchedError,
|
||||
frames: parseStack(stitchedError.stack || '')
|
||||
});
|
||||
}, [
|
||||
dispatch
|
||||
]);
|
||||
useErrorHandler(handleOnUnhandledError, handleOnUnhandledRejection);
|
||||
const webSocketRef = useWebsocket(assetPrefix);
|
||||
useWebsocketPing(webSocketRef);
|
||||
const sendMessage = useSendMessage(webSocketRef);
|
||||
const processTurbopackMessage = useTurbopack(sendMessage, (err)=>performFullReload(err, sendMessage));
|
||||
const router = useRouter();
|
||||
// We don't want access of the pathname for the dev tools to trigger a dynamic
|
||||
// access (as the dev overlay will never be present in production).
|
||||
const pathname = useUntrackedPathname();
|
||||
const appIsrManifestRef = useRef({});
|
||||
const pathnameRef = useRef(pathname);
|
||||
if (process.env.__NEXT_DEV_INDICATOR) {
|
||||
// this conditional is only for dead-code elimination which
|
||||
// isn't a runtime conditional only build-time so ignore hooks rule
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
useEffect(()=>{
|
||||
pathnameRef.current = pathname;
|
||||
const appIsrManifest = appIsrManifestRef.current;
|
||||
if (appIsrManifest) {
|
||||
if (pathname && pathname in appIsrManifest) {
|
||||
try {
|
||||
dispatcher.onStaticIndicator(true);
|
||||
} catch (reason) {
|
||||
let message = '';
|
||||
if (reason instanceof DOMException) {
|
||||
var _reason_stack;
|
||||
// Most likely a SecurityError, because of an unavailable localStorage
|
||||
message = (_reason_stack = reason.stack) != null ? _reason_stack : reason.message;
|
||||
} else if (reason instanceof Error) {
|
||||
var _reason_stack1;
|
||||
message = 'Error: ' + reason.message + '\n' + ((_reason_stack1 = reason.stack) != null ? _reason_stack1 : '');
|
||||
} else {
|
||||
message = 'Unexpected Exception: ' + reason;
|
||||
}
|
||||
console.warn('[HMR] ' + message);
|
||||
}
|
||||
} else {
|
||||
dispatcher.onStaticIndicator(false);
|
||||
}
|
||||
}
|
||||
}, [
|
||||
pathname,
|
||||
dispatcher
|
||||
]);
|
||||
}
|
||||
useEffect(()=>{
|
||||
const websocket = webSocketRef.current;
|
||||
if (!websocket) return;
|
||||
const handler = (event)=>{
|
||||
try {
|
||||
const obj = JSON.parse(event.data);
|
||||
handleDevBuildIndicatorHmrEvents(obj);
|
||||
processMessage(obj, sendMessage, processTurbopackMessage, router, dispatcher, appIsrManifestRef, pathnameRef);
|
||||
} catch (err) {
|
||||
reportInvalidHmrMessage(event, err);
|
||||
}
|
||||
};
|
||||
websocket.addEventListener('message', handler);
|
||||
return ()=>websocket.removeEventListener('message', handler);
|
||||
}, [
|
||||
sendMessage,
|
||||
router,
|
||||
webSocketRef,
|
||||
dispatcher,
|
||||
processTurbopackMessage,
|
||||
appIsrManifestRef
|
||||
]);
|
||||
return /*#__PURE__*/ _jsx(AppDevOverlay, {
|
||||
state: state,
|
||||
globalError: globalError,
|
||||
children: children
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=hot-reloader-client.js.map
|
||||
1
node_modules/next/dist/esm/client/components/react-dev-overlay/app/hot-reloader-client.js.map
generated
vendored
Normal file
1
node_modules/next/dist/esm/client/components/react-dev-overlay/app/hot-reloader-client.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