main repo

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

77
node_modules/next/dist/esm/client/dev/amp-dev.js generated vendored Normal file
View File

@@ -0,0 +1,77 @@
/* globals __webpack_hash__ */ import { displayContent } from "./fouc";
import initOnDemandEntries from "./on-demand-entries-client";
import { addMessageListener, connectHMR } from "./error-overlay/websocket";
import { HMR_ACTIONS_SENT_TO_BROWSER } from "../../server/dev/hot-reloader-types";
const data = JSON.parse(document.getElementById("__NEXT_DATA__").textContent);
window.__NEXT_DATA__ = data;
let { assetPrefix, page } = data;
assetPrefix = assetPrefix || "";
let mostRecentHash = null;
/* eslint-disable-next-line */ let curHash = __webpack_hash__;
const hotUpdatePath = assetPrefix + (assetPrefix.endsWith("/") ? "" : "/") + "_next/static/webpack/";
// Is there a newer version of this code available?
function isUpdateAvailable() {
// __webpack_hash__ is the hash of the current compilation.
// It's a global variable injected by Webpack.
/* eslint-disable-next-line */ return mostRecentHash !== __webpack_hash__;
}
// Webpack disallows updates in other states.
function canApplyUpdates() {
// @ts-expect-error TODO: module.hot exists but type needs to be added. Can't use `as any` here as webpack parses for `module.hot` calls.
return module.hot.status() === "idle";
}
// This function reads code updates on the fly and hard
// reloads the page when it has changed.
async function tryApplyUpdates() {
if (!isUpdateAvailable() || !canApplyUpdates()) {
return;
}
try {
const res = await fetch(typeof __webpack_runtime_id__ !== "undefined" ? "" + hotUpdatePath + curHash + "." + __webpack_runtime_id__ + ".hot-update.json" : "" + hotUpdatePath + curHash + ".hot-update.json");
const jsonData = await res.json();
const curPage = page === "/" ? "index" : page;
// webpack 5 uses an array instead
const pageUpdated = (Array.isArray(jsonData.c) ? jsonData.c : Object.keys(jsonData.c)).some((mod)=>{
return mod.indexOf("pages" + (curPage.startsWith("/") ? curPage : "/" + curPage)) !== -1 || mod.indexOf(("pages" + (curPage.startsWith("/") ? curPage : "/" + curPage)).replace(/\//g, "\\")) !== -1;
});
if (pageUpdated) {
window.location.reload();
} else {
curHash = mostRecentHash;
}
} catch (err) {
console.error("Error occurred checking for update", err);
window.location.reload();
}
}
addMessageListener((message)=>{
if (!("action" in message)) {
return;
}
try {
// actions which are not related to amp-dev
if (message.action === HMR_ACTIONS_SENT_TO_BROWSER.SERVER_ERROR || message.action === HMR_ACTIONS_SENT_TO_BROWSER.DEV_PAGES_MANIFEST_UPDATE) {
return;
}
if (message.action === HMR_ACTIONS_SENT_TO_BROWSER.SYNC || message.action === HMR_ACTIONS_SENT_TO_BROWSER.BUILT) {
if (!message.hash) {
return;
}
mostRecentHash = message.hash;
tryApplyUpdates();
} else if (message.action === HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE) {
window.location.reload();
}
} catch (err) {
var _err_stack;
console.warn("[HMR] Invalid message: " + message + "\n" + ((_err_stack = err == null ? void 0 : err.stack) != null ? _err_stack : ""));
}
});
connectHMR({
assetPrefix,
path: "/_next/webpack-hmr"
});
displayContent();
initOnDemandEntries(data.page);
//# sourceMappingURL=amp-dev.js.map

1
node_modules/next/dist/esm/client/dev/amp-dev.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/dev/amp-dev.ts"],"names":["displayContent","initOnDemandEntries","addMessageListener","connectHMR","HMR_ACTIONS_SENT_TO_BROWSER","data","JSON","parse","document","getElementById","textContent","window","__NEXT_DATA__","assetPrefix","page","mostRecentHash","curHash","__webpack_hash__","hotUpdatePath","endsWith","isUpdateAvailable","canApplyUpdates","module","hot","status","tryApplyUpdates","res","fetch","__webpack_runtime_id__","jsonData","json","curPage","pageUpdated","Array","isArray","c","Object","keys","some","mod","indexOf","startsWith","replace","location","reload","err","console","error","message","action","SERVER_ERROR","DEV_PAGES_MANIFEST_UPDATE","SYNC","BUILT","hash","RELOAD_PAGE","warn","stack","path"],"mappings":"AAAA,4BAA4B,GAC5B,SAASA,cAAc,QAAQ,SAAQ;AACvC,OAAOC,yBAAyB,6BAA4B;AAC5D,S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CAAA,AAAC,UAAOT,CAAAA,QAAQU,UAAU,CAAC,OAAOV,UAAU,AAAC,MAAGA,OAAQ,CAAE,EAAEW,OAAO,CACjE,OACA,WAEE,CAAC;QAEX;QAEA,IAAIV,aAAa;YACfrB,OAAOgC,QAAQ,CAACC,MAAM;QACxB,OAAO;YACL5B,UAAUD;QACZ;IACF,EAAE,OAAO8B,KAAK;QACZC,QAAQC,KAAK,CAAC,sCAAsCF;QACpDlC,OAAOgC,QAAQ,CAACC,MAAM;IACxB;AACF;AAEA1C,mBAAmB,CAAC8C;IAClB,IAAI,CAAE,CAAA,YAAYA,OAAM,GAAI;QAC1B;IACF;IAEA,IAAI;QACF,2CAA2C;QAC3C,IACEA,QAAQC,MAAM,KAAK7C,4BAA4B8C,YAAY,IAC3DF,QAAQC,MAAM,KAAK7C,4BAA4B+C,yBAAyB,EACxE;YACA;QACF;QACA,IACEH,QAAQC,MAAM,KAAK7C,4BAA4BgD,IAAI,IACnDJ,QAAQC,MAAM,KAAK7C,4BAA4BiD,KAAK,EACpD;YACA,IAAI,CAACL,QAAQM,IAAI,EAAE;gBACjB;YACF;YACAvC,iBAAiBiC,QAAQM,IAAI;YAC7B7B;QACF,OAAO,IAAIuB,QAAQC,MAAM,KAAK7C,4BAA4BmD,WAAW,EAAE;YACrE5C,OAAOgC,QAAQ,CAACC,MAAM;QACxB;IACF,EAAE,OAAOC,KAAU;YAE+BA;QADhDC,QAAQU,IAAI,CACV,4BAA4BR,UAAU,OAAQH,CAAAA,CAAAA,aAAAA,uBAAAA,IAAKY,KAAK,YAAVZ,aAAc,EAAC;IAEjE;AACF;AAEA1C,WAAW;IACTU;IACA6C,MAAM;AACR;AACA1D;AAEAC,oBAAoBI,KAAKS,IAAI"}

View File

@@ -0,0 +1,110 @@
/* eslint-disable @typescript-eslint/no-use-before-define */ import { HMR_ACTIONS_SENT_TO_BROWSER } from "../../server/dev/hot-reloader-types";
import { addMessageListener } from "./error-overlay/websocket";
export default function initializeBuildWatcher(toggleCallback, position) {
if (position === void 0) position = "bottom-right";
const shadowHost = document.createElement("div");
const [verticalProperty, horizontalProperty] = position.split("-");
shadowHost.id = "__next-build-watcher";
// Make sure container is fixed and on a high zIndex so it shows
shadowHost.style.position = "fixed";
// Ensure container's position to be top or bottom (default)
shadowHost.style[verticalProperty] = "10px";
// Ensure container's position to be left or right (default)
shadowHost.style[horizontalProperty] = "20px";
shadowHost.style.width = "0";
shadowHost.style.height = "0";
shadowHost.style.zIndex = "99999";
document.body.appendChild(shadowHost);
let shadowRoot;
let prefix = "";
if (shadowHost.attachShadow) {
shadowRoot = shadowHost.attachShadow({
mode: "open"
});
} else {
// If attachShadow is undefined then the browser does not support
// the Shadow DOM, we need to prefix all the names so there
// will be no conflicts
shadowRoot = shadowHost;
prefix = "__next-build-watcher-";
}
// Container
const container = createContainer(prefix);
shadowRoot.appendChild(container);
// CSS
const css = createCss(prefix, {
horizontalProperty,
verticalProperty
});
shadowRoot.appendChild(css);
// State
let isVisible = false;
let isBuilding = false;
let timeoutId = null;
// Handle events
addMessageListener((obj)=>{
try {
handleMessage(obj);
} catch (e) {}
});
function show() {
timeoutId && clearTimeout(timeoutId);
isVisible = true;
isBuilding = true;
updateContainer();
}
function hide() {
isBuilding = false;
// Wait for the fade out transition to complete
timeoutId = setTimeout(()=>{
isVisible = false;
updateContainer();
}, 100);
updateContainer();
}
function handleMessage(obj) {
if (!("action" in obj)) {
return;
}
// eslint-disable-next-line default-case
switch(obj.action){
case HMR_ACTIONS_SENT_TO_BROWSER.BUILDING:
show();
break;
case HMR_ACTIONS_SENT_TO_BROWSER.BUILT:
case HMR_ACTIONS_SENT_TO_BROWSER.SYNC:
hide();
break;
}
}
toggleCallback({
show,
hide
});
function updateContainer() {
if (isBuilding) {
container.classList.add("" + prefix + "building");
} else {
container.classList.remove("" + prefix + "building");
}
if (isVisible) {
container.classList.add("" + prefix + "visible");
} else {
container.classList.remove("" + prefix + "visible");
}
}
}
function createContainer(prefix) {
const container = document.createElement("div");
container.id = "" + prefix + "container";
container.innerHTML = '\n <div id="' + prefix + 'icon-wrapper">\n <svg viewBox="0 0 226 200">\n <defs>\n <linearGradient\n x1="114.720775%"\n y1="181.283245%"\n x2="39.5399306%"\n y2="100%"\n id="' + prefix + 'linear-gradient"\n >\n <stop stop-color="#000000" offset="0%" />\n <stop stop-color="#FFFFFF" offset="100%" />\n </linearGradient>\n </defs>\n <g id="' + prefix + 'icon-group" fill="none" stroke="url(#' + prefix + 'linear-gradient)" stroke-width="18">\n <path d="M113,5.08219117 L4.28393801,197.5 L221.716062,197.5 L113,5.08219117 Z" />\n </g>\n </svg>\n </div>\n ';
return container;
}
function createCss(prefix, param) {
let { horizontalProperty, verticalProperty } = param;
const css = document.createElement("style");
css.textContent = "\n #" + prefix + "container {\n position: absolute;\n " + verticalProperty + ": 10px;\n " + horizontalProperty + ": 30px;\n\n border-radius: 3px;\n background: #000;\n color: #fff;\n font: initial;\n cursor: initial;\n letter-spacing: initial;\n text-shadow: initial;\n text-transform: initial;\n visibility: initial;\n\n padding: 7px 10px 8px 10px;\n align-items: center;\n box-shadow: 0 11px 40px 0 rgba(0, 0, 0, 0.25), 0 2px 10px 0 rgba(0, 0, 0, 0.12);\n\n display: none;\n opacity: 0;\n transition: opacity 0.1s ease, " + verticalProperty + " 0.1s ease;\n animation: " + prefix + "fade-in 0.1s ease-in-out;\n }\n\n #" + prefix + "container." + prefix + "visible {\n display: flex;\n }\n\n #" + prefix + "container." + prefix + "building {\n " + verticalProperty + ": 20px;\n opacity: 1;\n }\n\n #" + prefix + "icon-wrapper {\n width: 16px;\n height: 16px;\n }\n\n #" + prefix + "icon-wrapper > svg {\n width: 100%;\n height: 100%;\n }\n\n #" + prefix + "icon-group {\n animation: " + prefix + "strokedash 1s ease-in-out both infinite;\n }\n\n @keyframes " + prefix + "fade-in {\n from {\n " + verticalProperty + ": 10px;\n opacity: 0;\n }\n to {\n " + verticalProperty + ": 20px;\n opacity: 1;\n }\n }\n\n @keyframes " + prefix + "strokedash {\n 0% {\n stroke-dasharray: 0 226;\n }\n 80%,\n 100% {\n stroke-dasharray: 659 226;\n }\n }\n ";
return css;
}
//# sourceMappingURL=dev-build-watcher.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/dev/dev-build-watcher.ts"],"names":["HMR_ACTIONS_SENT_TO_BROWSER","addMessageListener","initializeBuildWatcher","toggleCallback","position","shadowHost","document","createElement","verticalProperty","horizontalProperty","split","id","style","width","height","zIndex","body","appendChild","shadowRoot","prefix","attachShadow","mode","container","createContainer","css","createCss","isVisible","isBuilding","timeoutId","obj","handleMessage","show","clearTimeout","updateContainer","hide","setTimeout","action","BUILDING","BUILT","SYNC","classList","add","remove","innerHTML","textContent"],"mappings":"AAAA,0DAA0D,GAC1D,SACEA,2BAA2B,QAEtB,sCAAqC;AAC5C,SAASC,kBAAkB,QAAQ,4BAA2B;AAU9D,eAAe,SAASC,uBACtBC,cAAmD,EACnDC,QAAyB;IAAzBA,IAAAA,qBAAAA,WAAW;IAEX,MAAMC,aAAaC,SAASC,aAAa,CAAC;IAC1C,MAAM,CAACC,kBAAkBC,mBAAmB,GAAGL,SAASM,KAAK,CAAC;IAI9DL,WAAWM,EAAE,GAAG;IAChB,gEAAgE;IAChEN,WAAWO,KAAK,CAACR,QAAQ,GAAG;IAC5B,4DAA4D;IAC5DC,WAAWO,KAAK,CAACJ,iBAAiB,GAAG;IACrC,4DAA4D;IAC5DH,WAAWO,KAAK,CAACH,mBAAmB,GAAG;IACvCJ,WAAWO,KAAK,CAACC,KAAK,GAAG;IACzBR,WAAWO,KAAK,CAACE,MAAM,GAAG;IAC1BT,WAAWO,KAAK,CAACG,MAAM,GAAG;IAC1BT,SAASU,IAAI,CAACC,WAAW,CAACZ;IAE1B,IAAIa;IACJ,IAAIC,SAAS;IAEb,IAAId,WAAWe,YAAY,EAAE;QAC3BF,aAAab,WAAWe,YAAY,CAAC;YAAEC,MAAM;QAAO;IACtD,OAAO;QACL,iEAAiE;QACjE,2DAA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AAa,CAAC;IACzCe,UAAUX,EAAE,GAAG,AAAC,KAAEQ,SAAO;IACzBG,UAAUqB,SAAS,GAAG,AAAC,oBACVxB,SAAO,oOAQJA,SAAO,iNAMRA,SAAO,0CAAuCA,SAAO;IAOpE,OAAOG;AACT;AAEA,SAASG,UACPN,MAAc,EACd,KAG2D;IAH3D,IAAA,EACEV,kBAAkB,EAClBD,gBAAgB,EACyC,GAH3D;IAKA,MAAMgB,MAAMlB,SAASC,aAAa,CAAC;IACnCiB,IAAIoB,WAAW,GAAG,AAAC,YACdzB,SAAO,mDAENX,mBAAiB,oBACjBC,qBAAmB,weAkBYD,mBAAiB,mCACrCW,SAAO,8CAGnBA,SAAO,eAAYA,SAAO,oDAI1BA,SAAO,eAAYA,SAAO,uBACzBX,mBAAiB,+CAIlBW,SAAO,4EAKPA,SAAO,kFAKPA,SAAO,oCACKA,SAAO,uEAGTA,SAAO,sCAEdX,mBAAiB,gEAIjBA,mBAAiB,oEAKVW,SAAO;IAWtB,OAAOK;AACT"}

View File

@@ -0,0 +1,147 @@
/**
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.
*/ import stripAnsi from "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 stripAnsi(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 ? stripAnsi(message.moduleName) + "\n" : "") + (message.file ? stripAnsi(message.file) + "\n" : "") + body + (message.details && verbose ? "\n" + message.details : "") + (filteredModuleTrace && filteredModuleTrace.length ? (importTraceNote || "\n\nImport trace for requested module:") + filteredModuleTrace.map((trace)=>"\n" + trace.moduleName).join("") : "") + (message.stack && verbose ? "\n" + message.stack : "");
}
let lines = message.split("\n");
// Strip Webpack-added headers off errors/warnings
// https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
lines = lines.filter((line)=>!/Module [A-z ]+\(from/.test(line));
// Transform parsing error into syntax error
// TODO: move this to our ESLint formatter?
lines = lines.map((line)=>{
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
if (!parsingError) {
return line;
}
const [, errorLine, errorColumn, errorMessage] = parsingError;
return friendlySyntaxErrorLabel + " " + errorMessage + " (" + errorLine + ":" + errorColumn + ")";
});
message = lines.join("\n");
// Smoosh syntax errors (commonly found in CSS)
message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, "" + friendlySyntaxErrorLabel + " $3 ($1:$2)\n");
// Clean up export errors
message = message.replace(/^.*export '(.+?)' was not found in '(.+?)'.*$/gm, "Attempted import error: '$1' is not exported from '$2'.");
message = message.replace(/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, "Attempted import error: '$2' does not contain a default export (imported as '$1').");
message = message.replace(/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, "Attempted import error: '$1' is not exported from '$3' (imported as '$2').");
lines = message.split("\n");
// Remove leading newline
if (lines.length > 2 && lines[1].trim() === "") {
lines.splice(1, 1);
}
// Cleans up verbose "module not found" messages for files and packages.
if (lines[1] && lines[1].indexOf("Module not found: ") === 0) {
lines = [
lines[0],
lines[1].replace("Error: ", "").replace("Module not found: Cannot find file:", "Cannot find file:"),
...lines.slice(2)
];
}
// Add helpful message for users trying to use Sass for the first time
if (lines[1] && lines[1].match(/Cannot find module.+sass/)) {
// ./file.module.scss (<<loader info>>) => ./file.module.scss
const firstLine = lines[0].split("!");
lines[0] = firstLine[firstLine.length - 1];
lines[1] = "To use Next.js' built-in Sass support, you first need to install `sass`.\n";
lines[1] += "Run `npm i sass` or `yarn add sass` inside your workspace.\n";
lines[1] += "\nLearn more: https://nextjs.org/docs/messages/install-sass";
// dispose of unhelpful stack trace
lines = lines.slice(0, 2);
hadMissingSassError = true;
} else if (hadMissingSassError && message.match(/(sass-loader|resolve-url-loader: CSS error)/)) {
// dispose of unhelpful stack trace following missing sass module
lines = [];
}
if (!verbose) {
message = lines.join("\n");
// Internal stacks are generally useless so we strip them... with the
// exception of stacks containing `webpack:` because they're normally
// from user code generated by Webpack. For more information see
// https://github.com/facebook/create-react-app/pull/1050
message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, "") // at ... ...:x:y
;
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "") // at <anonymous>
;
message = message.replace(/File was processed with these loaders:\n(.+[\\/](next[\\/]dist[\\/].+|@next[\\/]react-refresh-utils[\\/]loader)\.js\n)*You may need an additional loader to handle the result of these loaders.\n/g, "");
lines = message.split("\n");
}
// Remove duplicated newlines
lines = lines.filter((line, index, arr)=>index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim());
// Reassemble the message
message = lines.join("\n");
return message.trim();
}
export default function formatWebpackMessages(json, verbose) {
const formattedErrors = json.errors.map((message)=>{
const isUnknownNextFontError = message.message.includes("An error occured 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;
}
//# sourceMappingURL=format-webpack-messages.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/dev/error-overlay/format-webpack-messages.ts"],"names":["stripAnsi","friendlySyntaxErrorLabel","WEBPACK_BREAKING_CHANGE_POLYFILLS","isLikelyASyntaxError","message","includes","hadMissingSassError","formatMessage","verbose","importTraceNote","filteredModuleTrace","moduleTrace","filter","trace","test","originName","body","breakingChangeIndex","indexOf","slice","moduleName","file","details","length","map","join","stack","lines","split","line","parsingError","exec","errorLine","errorColumn","errorMessage","replace","trim","splice","match","firstLine","index","arr","formatWebpackMessages","json","formattedErrors","errors","isUnknownNextFontError","formattedWarnings","warnings","reactServerComponentsError","i","error","unshift","result","some"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA,GACA,OAAOA,eAAe,gCAA+B;AACrD,qKAAqK;AACrK,0DAA0D;AAE1D,MAAMC,2BAA2B;AAEjC,MAAMC,oCACJ;AAEF,SAASC,qBAAqBC,OAAe;IAC3C,OAAOJ,UAAUI,SAASC,QAAQ,CAACJ;AACrC;AAEA,IAAIK,sBAAsB;AAE1B,oCAAoC;AACpC,SAASC,cACPH,OAAY,EACZI,OAAiB,EACjBC,eAAyB;IAEzB,8CAA8C;IAC9C,IAAI,OAAOL,YAAY,YAAYA,QAAQA,OAAO,EAAE;QAClD,MAAMM,sBACJN,QAAQO,WAAW,IACnBP,QAAQO,WAAW,CAACC,MAAM,CACxB,CAACC,QACC,CAAC,gEAAgEC,IAAI,CACnED,MAAME,UAAU;QAIxB,IAAIC,OAAOZ,QAAQA,OAAO;QAC1B,MAAMa,sBAAsBD,KAAKE,OAAO,CAAChB;QACzC,IAAIe,uBAAuB,GAAG;YAC5BD,OAAOA,KAAKG,KAAK,CAAC,GAAGF;QACvB;QAEAb,UACE,AAACA,CAAAA,QAAQgB,UAAU,GAAGpB,UAAUI,QAAQgB,UAAU,IAAI,OAAO,EAAC,IAC7DhB,CAAAA,QAAQiB,IAAI,GAAGrB,UAAUI,QAAQiB,IAAI,IAAI,OAAO,EAAC,IAClDL,OACCZ,CAAAA,QAAQkB,OAAO,IAAId,UAAU,OAAOJ,QAAQkB,OAAO,GAAG,EAAC,IACvDZ,CAAAA,uBAAuBA,oBAAoBa,MAAM,GAC9C,AAACd,CAAAA,mBAAmB,wCAAuC,IAC3DC,oBACGc,GAAG,CAAC,CAACX,QAAe,AAAC,OAAIA,MAAMO,UAAU,EACzCK,IAAI,CAAC,MACR,EAAC,IACJrB,CAAAA,QAAQsB,KAAK,IAAIlB,UAAU,OAAOJ,QAAQsB,KAAK,G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J,KAAKK,QAAQ,CAACxB,GAAG,CAAC,CAACpB;QAC3C,OAAOG,cAAcH,SAASI;IAChC;IAEA,sDAAsD;IACtD,IAAIyC,6BAA6B,CAAC;IAElC,IAAK,IAAIC,IAAI,GAAGA,IAAIN,gBAAgBrB,MAAM,EAAE2B,IAAK;QAC/C,MAAMC,QAAQP,eAAe,CAACM,EAAE;QAChC,IAAIC,MAAM9C,QAAQ,CAAC,+BAA+B;YAChD4C,6BAA6BC;YAC7B;QACF;IACF;IAEA,8DAA8D;IAC9D,IAAID,+BAA+B,CAAC,GAAG;QACrC,MAAME,QAAQP,gBAAgBP,MAAM,CAACY,4BAA4B;QACjEL,gBAAgBQ,OAAO,CAACD,KAAK,CAAC,EAAE;IAClC;IAEA,MAAME,SAAS;QACb,GAAGV,IAAI;QACPE,QAAQD;QACRI,UAAUD;IACZ;IACA,IAAI,CAACvC,WAAW6C,OAAOR,MAAM,CAACS,IAAI,CAACnD,uBAAuB;QACxD,kDAAkD;QAClDkD,OAAOR,MAAM,GAAGQ,OAAOR,MAAM,CAACjC,MAAM,CAACT;QACrCkD,OAAOL,QAAQ,GAAG,EAAE;IACtB;IACA,OAAOK;AACT"}

View File

@@ -0,0 +1,347 @@
// TODO: Remove use of `any` type. Fix no-use-before-define violations.
/* eslint-disable @typescript-eslint/no-use-before-define */ /**
* MIT License
*
* Copyright (c) 2013-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.
*/ // This file is a modified version of the Create React App HMR dev client that
// can be found here:
// https://github.com/facebook/create-react-app/blob/v3.4.1/packages/react-dev-utils/webpackHotDevClient.js
import { register, onBuildError, onBuildOk, onBeforeRefresh, onRefresh } from "next/dist/compiled/@next/react-dev-overlay/dist/client";
import stripAnsi from "next/dist/compiled/strip-ansi";
import { addMessageListener, sendMessage } from "./websocket";
import formatWebpackMessages from "./format-webpack-messages";
import { HMR_ACTIONS_SENT_TO_BROWSER } from "../../../server/dev/hot-reloader-types";
window.__nextDevClientId = Math.round(Math.random() * 100 + Date.now());
let hadRuntimeError = false;
let customHmrEventHandler;
let MODE = "webpack";
export default function connect(mode) {
MODE = mode;
register();
addMessageListener((payload)=>{
if (!("action" in payload)) {
return;
}
try {
processMessage(payload);
} catch (err) {
var _err_stack;
console.warn("[HMR] Invalid message: " + payload + "\n" + ((_err_stack = err == null ? void 0 : err.stack) != null ? _err_stack : ""));
}
});
return {
subscribeToHmrEvent (handler) {
customHmrEventHandler = handler;
},
onUnrecoverableError () {
hadRuntimeError = true;
}
};
}
// Remember some state related to hot module replacement.
var isFirstCompilation = true;
var mostRecentCompilationHash = null;
var hasCompileErrors = false;
function clearOutdatedErrors() {
// Clean up outdated compile errors, if any.
if (typeof console !== "undefined" && typeof console.clear === "function") {
if (hasCompileErrors) {
console.clear();
}
}
}
// Successful compilation.
function handleSuccess() {
clearOutdatedErrors();
if (MODE === "webpack") {
const isHotUpdate = !isFirstCompilation || window.__NEXT_DATA__.page !== "/_error" && isUpdateAvailable();
isFirstCompilation = false;
hasCompileErrors = false;
// Attempt to apply hot updates or reload.
if (isHotUpdate) {
tryApplyUpdates(onBeforeFastRefresh, onFastRefresh);
}
}
}
// Compilation with warnings (e.g. ESLint).
function handleWarnings(warnings) {
clearOutdatedErrors();
const isHotUpdate = !isFirstCompilation;
isFirstCompilation = false;
hasCompileErrors = false;
function printWarnings() {
// Print warnings to the console.
const formatted = formatWebpackMessages({
warnings: warnings,
errors: []
});
if (typeof console !== "undefined" && typeof console.warn === "function") {
var _formatted_warnings;
for(let i = 0; i < ((_formatted_warnings = formatted.warnings) == null ? void 0 : _formatted_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(formatted.warnings[i]));
}
}
}
printWarnings();
// Attempt to apply hot updates or reload.
if (isHotUpdate) {
tryApplyUpdates(onBeforeFastRefresh, onFastRefresh);
}
}
// Compilation with errors (e.g. syntax error or missing modules).
function handleErrors(errors) {
clearOutdatedErrors();
isFirstCompilation = false;
hasCompileErrors = true;
// "Massage" webpack messages.
var formatted = formatWebpackMessages({
errors: errors,
warnings: []
});
// Only show the first error.
onBuildError(formatted.errors[0]);
// Also log them to the console.
if (typeof console !== "undefined" && typeof console.error === "function") {
for(var 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;
}
}
}
let startLatency = undefined;
function onBeforeFastRefresh(updatedModules) {
if (updatedModules.length > 0) {
// Only trigger a pending state if we have updates to apply
// (cf. onFastRefresh)
onBeforeRefresh();
}
}
function onFastRefresh(updatedModules) {
onBuildOk();
if (updatedModules.length > 0) {
// Only complete a pending state if we applied updates
// (cf. onBeforeFastRefresh)
onRefresh();
}
if (startLatency) {
const endLatency = Date.now();
const latency = endLatency - startLatency;
console.log("[Fast Refresh] done in " + latency + "ms");
sendMessage(JSON.stringify({
event: "client-hmr-latency",
id: window.__nextDevClientId,
startTime: startLatency,
endTime: endLatency,
page: window.location.pathname,
updatedModules,
// Whether the page (tab) was hidden at the time the event occurred.
// This can impact the accuracy of the event's timing.
isPageHidden: document.visibilityState === "hidden"
}));
if (self.__NEXT_HMR_LATENCY_CB) {
self.__NEXT_HMR_LATENCY_CB(latency);
}
}
}
// There is a newer version of the code available.
function handleAvailableHash(hash) {
// Update last known compilation hash.
mostRecentCompilationHash = hash;
}
// Handle messages from the server.
function processMessage(obj) {
if (!("action" in obj)) {
return;
}
switch(obj.action){
case HMR_ACTIONS_SENT_TO_BROWSER.BUILDING:
{
startLatency = Date.now();
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;
const hasErrors = Boolean(errors && errors.length);
if (hasErrors) {
sendMessage(JSON.stringify({
event: "client-error",
errorCount: errors.length,
clientId: window.__nextDevClientId
}));
return handleErrors(errors);
}
const hasWarnings = Boolean(warnings && warnings.length);
if (hasWarnings) {
sendMessage(JSON.stringify({
event: "client-warning",
warningCount: warnings.length,
clientId: window.__nextDevClientId
}));
return handleWarnings(warnings);
}
sendMessage(JSON.stringify({
event: "client-success",
clientId: window.__nextDevClientId
}));
return handleSuccess();
}
case HMR_ACTIONS_SENT_TO_BROWSER.SERVER_COMPONENT_CHANGES:
{
window.location.reload();
return;
}
case HMR_ACTIONS_SENT_TO_BROWSER.SERVER_ERROR:
{
const { errorJSON } = obj;
if (errorJSON) {
const { message, stack } = JSON.parse(errorJSON);
const error = new Error(message);
error.stack = stack;
handleErrors([
error
]);
}
return;
}
default:
{
if (customHmrEventHandler) {
customHmrEventHandler(obj);
break;
}
break;
}
}
}
// Is there a newer version of this code available?
function isUpdateAvailable() {
/* 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() {
// @ts-expect-error TODO: module.hot exists but type needs to be added. Can't use `as any` here as webpack parses for `module.hot` calls.
return module.hot.status() === "idle";
}
function afterApplyUpdates(fn) {
if (canApplyUpdates()) {
fn();
} else {
function handler(status) {
if (status === "idle") {
// @ts-expect-error TODO: module.hot exists but type needs to be added. Can't use `as any` here as webpack parses for `module.hot` calls.
module.hot.removeStatusHandler(handler);
fn();
}
}
// @ts-expect-error TODO: module.hot exists but type needs to be added. Can't use `as any` here as webpack parses for `module.hot` calls.
module.hot.addStatusHandler(handler);
}
}
// Attempt to update code on the fly, fall back to a hard reload.
function tryApplyUpdates(onBeforeHotUpdate, onHotUpdateSuccess) {
// @ts-expect-error TODO: module.hot exists but type needs to be added. Can't use `as any` here as webpack parses for `module.hot` calls.
if (!module.hot) {
// HotModuleReplacementPlugin is not in Webpack configuration.
console.error("HotModuleReplacementPlugin is not in Webpack configuration.");
// window.location.reload();
return;
}
if (!isUpdateAvailable() || !canApplyUpdates()) {
onBuildOk();
return;
}
function handleApplyUpdates(err, updatedModules) {
if (err || hadRuntimeError || !updatedModules) {
if (err) {
console.warn("[Fast Refresh] performing full reload\n\n" + "Fast Refresh will perform a full reload when you edit a file that's imported by modules outside of the React rendering tree.\n" + "You might have a file which exports a React component but also exports a value that is imported by a non-React component file.\n" + "Consider migrating the non-React component export to a separate file and importing it into both files.\n\n" + "It is also possible the parent component of the component you edited is a class component, which disables Fast Refresh.\n" + "Fast Refresh requires at least one parent function component in your React tree.");
} else if (hadRuntimeError) {
console.warn("[Fast Refresh] performing full reload because your application had an unrecoverable error");
}
performFullReload(err);
return;
}
if (typeof onHotUpdateSuccess === "function") {
// Maybe we want to do something.
onHotUpdateSuccess(updatedModules);
}
if (isUpdateAvailable()) {
// While we were updating, there was a new update! Do it again.
// However, this time, don't trigger a pending refresh state.
tryApplyUpdates(updatedModules.length > 0 ? undefined : onBeforeHotUpdate, updatedModules.length > 0 ? onBuildOk : onHotUpdateSuccess);
} else {
onBuildOk();
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
// @ts-expect-error TODO: module.hot exists but type needs to be added. Can't use `as any` here as webpack parses for `module.hot` calls.
module.hot.check(/* autoApply */ false).then((updatedModules)=>{
if (!updatedModules) {
return null;
}
if (typeof onBeforeHotUpdate === "function") {
onBeforeHotUpdate(updatedModules);
}
// @ts-expect-error TODO: module.hot exists but type needs to be added. Can't use `as any` here as webpack parses for `module.hot` calls.
return module.hot.apply();
}).then((updatedModules)=>{
handleApplyUpdates(null, updatedModules);
}, (err)=>{
handleApplyUpdates(err, null);
});
}
function performFullReload(err) {
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: !!hadRuntimeError
}));
window.location.reload();
}
//# sourceMappingURL=hot-dev-client.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,53 @@
let source;
const eventCallbacks = [];
function getSocketProtocol(assetPrefix) {
let protocol = location.protocol;
try {
// assetPrefix is a url
protocol = new URL(assetPrefix).protocol;
} catch (e) {}
return protocol === "http:" ? "ws" : "wss";
}
export function addMessageListener(callback) {
eventCallbacks.push(callback);
}
export function sendMessage(data) {
if (!source || source.readyState !== source.OPEN) return;
return source.send(data);
}
export function connectHMR(options) {
function init() {
if (source) source.close();
function handleOnline() {
window.console.log("[HMR] connected");
}
function handleMessage(event) {
// Coerce into HMR_ACTION_TYPES as that is the format.
const msg = JSON.parse(event.data);
for (const eventCallback of eventCallbacks){
eventCallback(msg);
}
}
function handleDisconnect() {
source.onerror = null;
source.onclose = null;
source.close();
init();
}
const { hostname, port } = location;
const protocol = getSocketProtocol(options.assetPrefix || "");
const assetPrefix = options.assetPrefix.replace(/^\/+/, "");
let url = protocol + "://" + hostname + ":" + port + (assetPrefix ? "/" + assetPrefix : "");
if (assetPrefix.startsWith("http")) {
url = protocol + "://" + assetPrefix.split("://")[1];
}
source = new window.WebSocket("" + url + options.path);
source.onopen = handleOnline;
source.onerror = handleDisconnect;
source.onclose = handleDisconnect;
source.onmessage = handleMessage;
}
init();
}
//# sourceMappingURL=websocket.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/dev/error-overlay/websocket.ts"],"names":["source","eventCallbacks","getSocketProtocol","assetPrefix","protocol","location","URL","addMessageListener","callback","push","sendMessage","data","readyState","OPEN","send","connectHMR","options","init","close","handleOnline","window","console","log","handleMessage","event","msg","JSON","parse","eventCallback","handleDisconnect","onerror","onclose","hostname","port","replace","url","startsWith","split","WebSocket","path","onopen","onmessage"],"mappings":"AAEA,IAAIA;AAIJ,MAAMC,iBAAwC,EAAE;AAEhD,SAASC,kBAAkBC,WAAmB;IAC5C,IAAIC,WAAWC,SAASD,QAAQ;IAEhC,IAAI;QACF,uBAAuB;QACvBA,WAAW,IAAIE,IAAIH,aAAaC,QAAQ;IAC1C,EAAE,UAAM,CAAC;IAET,OAAOA,aAAa,UAAU,OAAO;AACvC;AAEA,OAAO,SAASG,mBAAmBC,QAAwB;IACzDP,eAAeQ,IAAI,CAACD;AACtB;AAEA,OAAO,SAASE,YAAYC,IAAY;IACtC,IAAI,CAACX,UAAUA,OAAOY,UAAU,KAAKZ,OAAOa,IAAI,EAAE;IAClD,OAAOb,OAAOc,IAAI,CAACH;AACrB;AAEA,OAAO,SAASI,WAAWC,OAA8C;IACvE,SAASC;QACP,IAAIjB,QAAQA,OAAOkB,KAAK;QAExB,SAASC;YACPC,OAAOC,OAAO,CAACC,GAAG,CAAC;QACrB;QAEA,SAASC,cAAcC,KAA2B;YAChD,sDAAsD;YACtD,MAAMC,MAAwBC,KAAKC,KAAK,CAACH,MAAMb,IAAI;YACnD,KAAK,MAAMiB,iBAAiB3B,eAAgB;gBAC1C2B,cAAcH;YAChB;QACF;QAEA,SAASI;YACP7B,OAAO8B,OAAO,GAAG;YACjB9B,OAAO+B,OAAO,GAAG;YACjB/B,OAAOkB,KAAK;YACZD;QACF;QAEA,MAAM,EAAEe,QAAQ,EAAEC,IAAI,EAAE,GAAG5B;QAC3B,MAAMD,WAAWF,kBAAkBc,QAAQb,WAAW,IAAI;QAC1D,MAAMA,cAAca,QAAQb,WAAW,CAAC+B,OAAO,CAAC,QAAQ;QAExD,IAAIC,MAAM,AAAG/B,WAAS,QAAK4B,WAAS,MAAGC,OACrC9B,CAAAA,cAAc,AAAC,MAAGA,cAAgB,EAAC;QAGrC,IAAIA,YAAYiC,UAAU,CAAC,SAAS;YAClCD,MAAM,AAAG/B,WAAS,QAAKD,YAAYkC,KAAK,CAAC,MAAM,CAAC,EAAE;QACpD;QAEArC,SAAS,IAAIoB,OAAOkB,SAAS,CAAC,AAAC,KAAEH,MAAMnB,QAAQuB,IAAI;QACnDvC,OAAOwC,MAAM,GAAGrB;QAChBnB,OAAO8B,OAAO,GAAGD;QACjB7B,OAAO+B,OAAO,GAAGF;QACjB7B,OAAOyC,SAAS,GAAGlB;IACrB;IAEAN;AACF"}

29
node_modules/next/dist/esm/client/dev/fouc.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
// This wrapper function is used to safely select the best available function
// to schedule removal of the no-FOUC styles workaround. requestAnimationFrame
// is the ideal choice, but when used in iframes, there are no guarantees that
// the callback will actually be called, which could stall the promise returned
// from displayContent.
//
// See: https://www.vector-logic.com/blog/posts/on-request-animation-frame-and-embedded-iframes
const safeCallbackQueue = (callback)=>{
if (window.requestAnimationFrame && window.self === window.top) {
window.requestAnimationFrame(callback);
} else {
window.setTimeout(callback);
}
};
// This function is used to remove Next.js' no-FOUC styles workaround for using
// `style-loader` in development. It must be called before hydration, or else
// rendering won't have the correct computed values in effects.
export function displayContent() {
return new Promise((resolve)=>{
safeCallbackQueue(function() {
for(var x = document.querySelectorAll("[data-next-hide-fouc]"), i = x.length; i--;){
x[i].parentNode.removeChild(x[i]);
}
resolve();
});
});
}
//# sourceMappingURL=fouc.js.map

1
node_modules/next/dist/esm/client/dev/fouc.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/dev/fouc.ts"],"names":["safeCallbackQueue","callback","window","requestAnimationFrame","self","top","setTimeout","displayContent","Promise","resolve","x","document","querySelectorAll","i","length","parentNode","removeChild"],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,uBAAuB;AACvB,EAAE;AACF,+FAA+F;AAC/F,MAAMA,oBAAoB,CAACC;IACzB,IAAIC,OAAOC,qBAAqB,IAAID,OAAOE,IAAI,KAAKF,OAAOG,GAAG,EAAE;QAC9DH,OAAOC,qBAAqB,CAACF;IAC/B,OAAO;QACLC,OAAOI,UAAU,CAACL;IACpB;AACF;AAEA,+EAA+E;AAC/E,6EAA6E;AAC7E,+DAA+D;AAC/D,OAAO,SAASM;IACd,OAAO,IAAIC,QAAQ,CAACC;QAClBT,kBAAkB;YAChB,IACE,IAAIU,IAAIC,SAASC,gBAAgB,CAAC,0BAChCC,IAAIH,EAAEI,MAAM,EACdD,KAEA;gBACAH,CAAC,CAACG,EAAE,CAACE,UAAU,CAAEC,WAAW,CAACN,CAAC,CAACG,EAAE;YACnC;YACAJ;QACF;IACF;AACF"}

View File

@@ -0,0 +1,58 @@
import connect from "./error-overlay/hot-dev-client";
import { sendMessage } from "./error-overlay/websocket";
export default ((mode)=>{
const devClient = connect(mode);
devClient.subscribeToHmrEvent((obj)=>{
// if we're on an error/404 page, we can't reliably tell if the newly added/removed page
// matches the current path. In that case, assume any added/removed entries should trigger a reload of the current page
const isOnErrorPage = window.next.router.pathname === "/404" || window.next.router.pathname === "/_error";
switch(obj.action){
case "reloadPage":
{
sendMessage(JSON.stringify({
event: "client-reload-page",
clientId: window.__nextDevClientId
}));
return window.location.reload();
}
case "removedPage":
{
const [page] = obj.data;
if (page === window.next.router.pathname || isOnErrorPage) {
sendMessage(JSON.stringify({
event: "client-removed-page",
clientId: window.__nextDevClientId,
page
}));
return window.location.reload();
}
return;
}
case "addedPage":
{
const [page] = obj.data;
if (page === window.next.router.pathname && typeof window.next.router.components[page] === "undefined" || isOnErrorPage) {
sendMessage(JSON.stringify({
event: "client-added-page",
clientId: window.__nextDevClientId,
page
}));
return window.location.reload();
}
return;
}
case "serverError":
case "devPagesManifestUpdate":
{
return;
}
default:
{
throw new Error("Unexpected action " + obj.action);
}
}
});
return devClient;
});
//# sourceMappingURL=hot-middleware-client.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/dev/hot-middleware-client.ts"],"names":["connect","sendMessage","mode","devClient","subscribeToHmrEvent","obj","isOnErrorPage","window","next","router","pathname","action","JSON","stringify","event","clientId","__nextDevClientId","location","reload","page","data","components","Error"],"mappings":"AAAA,OAAOA,aAAa,iCAAgC;AACpD,SAASC,WAAW,QAAQ,4BAA2B;AAEvD,eAAe,CAAA,CAACC;IACd,MAAMC,YAAYH,QAAQE;IAE1BC,UAAUC,mBAAmB,CAAC,CAACC;QAC7B,wFAAwF;QACxF,uHAAuH;QACvH,MAAMC,gBACJC,OAAOC,IAAI,CAACC,MAAM,CAACC,QAAQ,KAAK,UAChCH,OAAOC,IAAI,CAACC,MAAM,CAACC,QAAQ,KAAK;QAElC,OAAQL,IAAIM,MAAM;YAChB,KAAK;gBAAc;oBACjBV,YACEW,KAAKC,SAAS,CAAC;wBACbC,OAAO;wBACPC,UAAUR,OAAOS,iBAAiB;oBACpC;oBAEF,OAAOT,OAAOU,QAAQ,CAACC,MAAM;gBAC/B;YACA,KAAK;gBAAe;oBAClB,MAAM,CAACC,KAAK,GAAGd,IAAIe,IAAI;oBACvB,IAAID,SAASZ,OAAOC,IAAI,CAACC,MAAM,CAACC,QAAQ,IAAIJ,eAAe;wBACzDL,YACEW,KAAKC,SAAS,CAAC;4BACbC,OAAO;4BACPC,UAAUR,OAAOS,iBAAiB;4BAClCG;wBACF;wBAEF,OAAOZ,OAAOU,QAAQ,CAACC,MAAM;oBAC/B;oBACA;gBACF;YACA,KAAK;gBAAa;oBAChB,MAAM,CAACC,KAAK,GAAGd,IAAIe,IAAI;oBACvB,IACE,AAACD,SAASZ,OAAOC,IAAI,CAACC,MAAM,CAACC,QAAQ,IACnC,OAAOH,OAAOC,IAAI,CAACC,MAAM,CAACY,UAAU,CAACF,KAAK,KAAK,eACjDb,eACA;wBACAL,YACEW,KAAKC,SAAS,CAAC;4BACbC,OAAO;4BACPC,UAAUR,OAAOS,iBAAiB;4BAClCG;wBACF;wBAEF,OAAOZ,OAAOU,QAAQ,CAACC,MAAM;oBAC/B;oBACA;gBACF;YACA,KAAK;YACL,KAAK;gBAA0B;oBAC7B;gBACF;YACA;gBAAS;oBACP,MAAM,IAAII,MAAM,uBAAuBjB,IAAIM,MAAM;gBACnD;QACF;IACF;IAEA,OAAOR;AACT,CAAA,EAAC"}

View File

@@ -0,0 +1,5 @@
// The Turbopack HMR client can't be properly omitted at the moment (WEB-1589),
// so instead we remap its import to this file in webpack builds.
export function connect() {}
//# sourceMappingURL=noop-turbopack-hmr.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/dev/noop-turbopack-hmr.ts"],"names":["connect"],"mappings":"AAAA,+EAA+E;AAC/E,iEAAiE;AACjE,OAAO,SAASA,WAAW"}

View File

@@ -0,0 +1,30 @@
import Router from "../router";
import { sendMessage } from "./error-overlay/websocket";
export default (async (page)=>{
if (page) {
// in AMP the router isn't initialized on the client and
// client-transitions don't occur so ping initial page
setInterval(()=>{
sendMessage(JSON.stringify({
event: "ping",
page
}));
}, 2500);
} else {
Router.ready(()=>{
setInterval(()=>{
// when notFound: true is returned we should use the notFoundPage
// as the Router.pathname will point to the 404 page but we want
// to ping the source page that returned notFound: true instead
const notFoundSrcPage = self.__NEXT_DATA__.notFoundSrcPage;
const pathname = (Router.pathname === "/404" || Router.pathname === "/_error") && notFoundSrcPage ? notFoundSrcPage : Router.pathname;
sendMessage(JSON.stringify({
event: "ping",
page: pathname
}));
}, 2500);
});
}
});
//# sourceMappingURL=on-demand-entries-client.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/dev/on-demand-entries-client.ts"],"names":["Router","sendMessage","page","setInterval","JSON","stringify","event","ready","notFoundSrcPage","self","__NEXT_DATA__","pathname"],"mappings":"AAAA,OAAOA,YAAY,YAAW;AAC9B,SAASC,WAAW,QAAQ,4BAA2B;AAEvD,eAAe,CAAA,OAAOC;IACpB,IAAIA,MAAM;QACR,wDAAwD;QACxD,sDAAsD;QACtDC,YAAY;YACVF,YAAYG,KAAKC,SAAS,CAAC;gBAAEC,OAAO;gBAAQJ;YAAK;QACnD,GAAG;IACL,OAAO;QACLF,OAAOO,KAAK,CAAC;YACXJ,YAAY;gBACV,iEAAiE;gBACjE,gEAAgE;gBAChE,+DAA+D;gBAC/D,MAAMK,kBAAkBC,KAAKC,aAAa,CAACF,eAAe;gBAC1D,MAAMG,WACJ,AAACX,CAAAA,OAAOW,QAAQ,KAAK,UAAUX,OAAOW,QAAQ,KAAK,SAAQ,KAC3DH,kBACIA,kBACAR,OAAOW,QAAQ;gBAErBV,YAAYG,KAAKC,SAAS,CAAC;oBAAEC,OAAO;oBAAQJ,MAAMS;gBAAS;YAC7D,GAAG;QACL;IACF;AACF,CAAA,EAAC"}