create project

This commit is contained in:
ismailsosic
2022-12-27 12:05:56 +01:00
parent 2a33a2d3de
commit cd2143287c
16035 changed files with 2489703 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
/* globals __webpack_hash__ */ import { displayContent } from './fouc';
import initOnDemandEntries from './on-demand-entries-client';
import { addMessageListener, connectHMR } from './error-overlay/websocket';
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() {
return module.hot.status() === 'idle';
}
function tryApplyUpdates() {
return _tryApplyUpdates.apply(this, arguments);
}
function _tryApplyUpdates() {
_tryApplyUpdates = // This function reads code updates on the fly and hard
// reloads the page when it has changed.
_async_to_generator(function*() {
if (!isUpdateAvailable() || !canApplyUpdates()) {
return;
}
try {
const res = yield fetch(typeof __webpack_runtime_id__ !== 'undefined' ? `${hotUpdatePath}${curHash}.${__webpack_runtime_id__}.hot-update.json` : `${hotUpdatePath}${curHash}.hot-update.json`);
const jsonData = yield 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) {
document.location.reload(true);
} else {
curHash = mostRecentHash;
}
} catch (err) {
console.error('Error occurred checking for update', err);
document.location.reload(true);
}
});
return _tryApplyUpdates.apply(this, arguments);
}
addMessageListener((event)=>{
if (event.data === '\uD83D\uDC93') {
return;
}
try {
const message = JSON.parse(event.data);
if (message.action === 'sync' || message.action === 'built') {
if (!message.hash) {
return;
}
mostRecentHash = message.hash;
tryApplyUpdates();
} else if (message.action === 'reloadPage') {
document.location.reload(true);
}
} catch (ex) {
console.warn('Invalid HMR message: ' + event.data + '\n' + ex);
}
});
connectHMR({
assetPrefix,
path: '/_next/webpack-hmr'
});
displayContent();
initOnDemandEntries(data.page);
//# sourceMappingURL=amp-dev.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/dev/amp-dev.js"],"names":["displayContent","initOnDemandEntries","addMessageListener","connectHMR","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","event","message","action","hash","ex","warn","path"],"mappings":"AACA;AADA,8BAA8B,CAC9B,SAASA,cAAc,QAAQ,QAAQ,CAAA;AACvC,OAAOC,mBAAmB,MAAM,4BAA4B,CAAA;AAC5D,SAASC,kBAAkB,EAAEC,UAAU,QAAQ,2BAA2B,CAAA;AAE1E,MAAMC,IAAI,GAAGC,IAAI,CAACC,KAAK,CAACC,QAAQ,CAACC,cAAc,CAAC,eAAe,CAAC,CAACC,WAAW,CAAC;AAC7EC,MAAM,CAACC,aAAa,GAAGP,IAAI;AAE3B,IAAI,EAAEQ,WAAW,CAAA,EAAEC,IAAI,CAAA,EAAE,GAAGT,IAAI;AAChCQ,WAAW,GAAGA,WAAW,IAAI,EAAE;AAC/B,IAAIE,cAAc,GAAG,IAAI;AACzB,8BAA8B,CAC9B,IAAIC,OAAO,GAA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E,EAAE;QACXN,OAAO,CAACO,IAAI,CAAC,uBAAuB,GAAGL,KAAK,CAAC3C,IAAI,GAAG,IAAI,GAAG+C,EAAE,CAAC;KAC/D;CACF,CAAC;AAEFhD,UAAU,CAAC;IACTS,WAAW;IACXyC,IAAI,EAAE,oBAAoB;CAC3B,CAAC;AACFrD,cAAc,EAAE;AAEhBC,mBAAmB,CAACG,IAAI,CAACS,IAAI,CAAC"}

View File

@@ -0,0 +1,191 @@
import { addMessageListener } from './error-overlay/websocket';
export default function initializeBuildWatcher(toggleCallback, 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((event)=>{
// This is the heartbeat event
if (event.data === '\uD83D\uDC93') {
return;
}
try {
handleMessage(event);
} catch (e) {}
});
function handleMessage(event) {
const obj = typeof event === 'string' ? {
action: event
} : JSON.parse(event.data);
// eslint-disable-next-line default-case
switch(obj.action){
case 'building':
timeoutId && clearTimeout(timeoutId);
isVisible = true;
isBuilding = true;
updateContainer();
break;
case 'built':
case 'sync':
isBuilding = false;
// Wait for the fade out transition to complete
timeoutId = setTimeout(()=>{
isVisible = false;
updateContainer();
}, 100);
updateContainer();
break;
}
}
toggleCallback(handleMessage);
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 = `
<div id="${prefix}icon-wrapper">
<svg viewBox="0 0 226 200">
<defs>
<linearGradient
x1="114.720775%"
y1="181.283245%"
x2="39.5399306%"
y2="100%"
id="${prefix}linear-gradient"
>
<stop stop-color="#000000" offset="0%" />
<stop stop-color="#FFFFFF" offset="100%" />
</linearGradient>
</defs>
<g id="${prefix}icon-group" fill="none" stroke="url(#${prefix}linear-gradient)" stroke-width="18">
<path d="M113,5.08219117 L4.28393801,197.5 L221.716062,197.5 L113,5.08219117 Z" />
</g>
</svg>
</div>
`;
return container;
}
function createCss(prefix, { horizontalProperty , verticalProperty }) {
const css = document.createElement('style');
css.textContent = `
#${prefix}container {
position: absolute;
${verticalProperty}: 10px;
${horizontalProperty}: 30px;
border-radius: 3px;
background: #000;
color: #fff;
font: initial;
cursor: initial;
letter-spacing: initial;
text-shadow: initial;
text-transform: initial;
visibility: initial;
padding: 7px 10px 8px 10px;
align-items: center;
box-shadow: 0 11px 40px 0 rgba(0, 0, 0, 0.25), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
display: none;
opacity: 0;
transition: opacity 0.1s ease, ${verticalProperty} 0.1s ease;
animation: ${prefix}fade-in 0.1s ease-in-out;
}
#${prefix}container.${prefix}visible {
display: flex;
}
#${prefix}container.${prefix}building {
${verticalProperty}: 20px;
opacity: 1;
}
#${prefix}icon-wrapper {
width: 16px;
height: 16px;
}
#${prefix}icon-wrapper > svg {
width: 100%;
height: 100%;
}
#${prefix}icon-group {
animation: ${prefix}strokedash 1s ease-in-out both infinite;
}
@keyframes ${prefix}fade-in {
from {
${verticalProperty}: 10px;
opacity: 0;
}
to {
${verticalProperty}: 20px;
opacity: 1;
}
}
@keyframes ${prefix}strokedash {
0% {
stroke-dasharray: 0 226;
}
80%,
100% {
stroke-dasharray: 659 226;
}
}
`;
return css;
}
//# sourceMappingURL=dev-build-watcher.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/dev/dev-build-watcher.js"],"names":["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","event","data","handleMessage","obj","action","JSON","parse","clearTimeout","updateContainer","setTimeout","classList","add","remove","innerHTML","textContent"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,2BAA2B,CAAA;AAE9D,eAAe,SAASC,sBAAsB,CAC5CC,cAAc,EACdC,QAAQ,GAAG,cAAc,EACzB;IACA,MAAMC,UAAU,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;IAChD,MAAM,CAACC,gBAAgB,EAAEC,kBAAkB,CAAC,GAAGL,QAAQ,CAACM,KAAK,CAAC,GAAG,CAAC;IAClEL,UAAU,CAACM,EAAE,GAAG,sBAAsB;IACtC,gEAAgE;IAChEN,UAAU,CAACO,KAAK,CAACR,QAAQ,GAAG,OAAO;IACnC,4DAA4D;IAC5DC,UAAU,CAACO,KAAK,CAACJ,gBAAgB,CAAC,GAAG,MAAM;IAC3C,4DAA4D;IAC5DH,UAAU,CAACO,KAAK,CAACH,kBAAkB,CAAC,GAAG,MAAM;IAC7CJ,UAAU,CAACO,KAAK,CAACC,KAAK,GAAG,CAAC;IAC1BR,UAAU,CAACO,KAAK,CAACE,MAAM,GAAG,CAAC;IAC3BT,UAAU,CAACO,KAAK,CAACG,MAAM,GAAG,KAAK;IAC/BT,QAAQ,CAACU,IAAI,CAACC,WAAW,CAACZ,UAAU,CAAC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AAE;IACnE,MAAMgB,GAAG,GAAGlB,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;IAC3CiB,GAAG,CAACmB,WAAW,GAAG,CAAC;KAChB,EAAExB,MAAM,CAAC;;MAER,EAAEX,gBAAgB,CAAC;MACnB,EAAEC,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;qCAkBU,EAAED,gBAAgB,CAAC;iBACvC,EAAEW,MAAM,CAAC;;;KAGrB,EAAEA,MAAM,CAAC,UAAU,EAAEA,MAAM,CAAC;;;;KAI5B,EAAEA,MAAM,CAAC,UAAU,EAAEA,MAAM,CAAC;MAC3B,EAAEX,gBAAgB,CAAC;;;;KAIpB,EAAEW,MAAM,CAAC;;;;;KAKT,EAAEA,MAAM,CAAC;;;;;KAKT,EAAEA,MAAM,CAAC;iBACG,EAAEA,MAAM,CAAC;;;eAGX,EAAEA,MAAM,CAAC;;QAEhB,EAAEX,gBAAgB,CAAC;;;;QAInB,EAAEA,gBAAgB,CAAC;;;;;eAKZ,EAAEW,MAAM,CAAC;;;;;;;;;EAStB,CAAC;IAED,OAAOK,GAAG,CAAA;CACX"}

View File

@@ -0,0 +1 @@
export default function formatWebpackMessages(json: any, verbose?: boolean): any

View File

@@ -0,0 +1,133 @@
import _extends from "@swc/helpers/src/_extends.mjs";
/**
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).indexOf(friendlySyntaxErrorLabel) !== -1;
}
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|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 && verbose ? (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>
;
lines = message.split('\n');
}
// Remove duplicated newlines
lines = lines.filter((line, index, arr)=>index === 0 || line.trim() !== '' || line.trim() !== arr[index - 1].trim());
// Reassemble the message
message = lines.join('\n');
return message.trim();
}
function formatWebpackMessages(json, verbose) {
const formattedErrors = json.errors.map(function(message) {
const isUnknownNextFontError = message.message.includes('An error occured in `@next/font`.');
return formatMessage(message, isUnknownNextFontError || verbose);
});
const formattedWarnings = json.warnings.map(function(message) {
return formatMessage(message, verbose);
});
const result = _extends({}, 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;
}
module.exports = formatWebpackMessages;
//# sourceMappingURL=format-webpack-messages.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,321 @@
/**
* 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';
// This alternative WebpackDevServer combines the functionality of:
// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js
// https://github.com/webpack/webpack/blob/webpack-1/hot/dev-server.js
// It only supports their simplest configuration (hot updates on same server).
// It makes some opinionated choices on top, like adding a syntax error overlay
// that looks similar to our console output. The error overlay is inspired by:
// https://github.com/glenjamin/webpack-hot-middleware
window.__nextDevClientId = Math.round(Math.random() * 100 + Date.now());
let hadRuntimeError = false;
let customHmrEventHandler;
export default function connect() {
register();
addMessageListener((event)=>{
if (event.data.indexOf('action') === -1) return;
try {
processMessage(event);
} catch (ex) {
console.warn('Invalid HMR message: ' + event.data + '\n', ex);
}
});
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();
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 ref;
for(let i = 0; i < ((ref = formatted.warnings) == null ? void 0 : ref.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(hasUpdates) {
if (hasUpdates) {
// Only trigger a pending state if we have updates to apply
// (cf. onFastRefresh)
onBeforeRefresh();
}
}
function onFastRefresh(hasUpdates) {
onBuildOk();
if (hasUpdates) {
// 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
}));
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(e) {
const obj = JSON.parse(e.data);
switch(obj.action){
case 'building':
{
startLatency = Date.now();
console.log('[Fast Refresh] rebuilding');
break;
}
case 'built':
case '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 'serverComponentChanges':
{
// Server component changes don't apply to `pages`.
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() {
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);
}
}
// Attempt to update code on the fly, fall back to a hard reload.
function tryApplyUpdates(onBeforeHotUpdate, onHotUpdateSuccess) {
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;
}
const hasUpdates = Boolean(updatedModules.length);
if (typeof onHotUpdateSuccess === 'function') {
// Maybe we want to do something.
onHotUpdateSuccess(hasUpdates);
}
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(hasUpdates ? undefined : onBeforeHotUpdate, hasUpdates ? 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
module.hot.check(/* autoApply */ false).then((updatedModules)=>{
if (!updatedModules) {
return null;
}
if (typeof onBeforeHotUpdate === 'function') {
const hasUpdates = Boolean(updatedModules.length);
onBeforeHotUpdate(hasUpdates);
}
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,61 @@
let source;
const eventCallbacks = [];
let lastActivity = Date.now();
function getSocketProtocol(assetPrefix) {
let protocol = location.protocol;
try {
// assetPrefix is a url
protocol = new URL(assetPrefix).protocol;
} catch (_) {}
return protocol === 'http:' ? 'ws' : 'wss';
}
export function addMessageListener(cb) {
eventCallbacks.push(cb);
}
export function sendMessage(data) {
if (!source || source.readyState !== source.OPEN) return;
return source.send(data);
}
export function connectHMR(options) {
if (!options.timeout) {
options.timeout = 5 * 1000;
}
function init() {
if (source) source.close();
function handleOnline() {
if (options.log) console.log('[HMR] connected');
lastActivity = Date.now();
}
function handleMessage(event) {
lastActivity = Date.now();
eventCallbacks.forEach((cb)=>{
cb(event);
});
}
let timer;
function handleDisconnect() {
clearInterval(timer);
source.close();
setTimeout(init, options.timeout);
}
timer = setInterval(function() {
if (Date.now() - lastActivity > options.timeout) {
handleDisconnect();
}
}, options.timeout / 2);
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.onmessage = handleMessage;
}
init();
}
//# sourceMappingURL=websocket.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../client/dev/error-overlay/websocket.ts"],"names":["source","eventCallbacks","lastActivity","Date","now","getSocketProtocol","assetPrefix","protocol","location","URL","_","addMessageListener","cb","push","sendMessage","data","readyState","OPEN","send","connectHMR","options","timeout","init","close","handleOnline","log","console","handleMessage","event","forEach","timer","handleDisconnect","clearInterval","setTimeout","setInterval","hostname","port","replace","url","startsWith","split","window","WebSocket","path","onopen","onerror","onmessage"],"mappings":"AAAA,I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AS,GAAGnB,aAAa;KACjC;IAEDL,IAAI,EAAE;CACP"}

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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../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,iBAAiB,GAAG,CAACC,QAAoB,GAAK;IAClD,IAAIC,MAAM,CAACC,qBAAqB,IAAID,MAAM,CAACE,IAAI,KAAKF,MAAM,CAACG,GAAG,EAAE;QAC9DH,MAAM,CAACC,qBAAqB,CAACF,QAAQ,CAAC;KACvC,MAAM;QACLC,MAAM,CAACI,UAAU,CAACL,QAAQ,CAAC;KAC5B;CACF;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,+DAA+D;AAC/D,OAAO,SAASM,cAAc,GAAkB;IAC9C,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,GAAK;QAC9BT,iBAAiB,CAAC,WAAY;YAC5B,IACE,IAAIU,CAAC,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,uBAAuB,CAAC,EACxDC,CAAC,GAAGH,CAAC,CAACI,MAAM,EACdD,CAAC,EAAE,EAEH;gBACAH,CAAC,CAACG,CAAC,CAAC,CAACE,UAAU,CAAEC,WAAW,CAACN,CAAC,CAACG,CAAC,CAAC,CAAC;aACnC;YACDJ,OAAO,EAAE;SACV,CAAC;KACH,CAAC,CAAA;CACH"}

View File

@@ -0,0 +1,61 @@
import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
import Router from 'next/router';
import { addMessageListener, sendMessage } from './error-overlay/websocket';
export default _async_to_generator(function*(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);
});
}
addMessageListener((event)=>{
if (event.data.indexOf('{') === -1) return;
try {
const payload = JSON.parse(event.data);
// don't attempt fetching the page if we're already showing
// the dev overlay as this can cause the error to be triggered
// repeatedly
if (payload.event === 'pong' && payload.invalid && !self.__NEXT_DATA__.err) {
// Payload can be invalid even if the page does exist.
// So, we check if it can be created.
fetch(location.href, {
credentials: 'same-origin'
}).then((pageRes)=>{
if (pageRes.status === 200) {
// Page exists now, reload
location.reload();
} else {
// Page doesn't exist
if (self.__NEXT_DATA__.page === Router.pathname && Router.pathname !== '/_error') {
// We are still on the page,
// reload to show 404 error page
location.reload();
}
}
});
}
} catch (err) {
console.error('on-demand-entries failed to parse response', err);
}
});
});
//# sourceMappingURL=on-demand-entries-client.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/dev/on-demand-entries-client.js"],"names":["Router","addMessageListener","sendMessage","page","setInterval","JSON","stringify","event","ready","notFoundSrcPage","self","__NEXT_DATA__","pathname","data","indexOf","payload","parse","invalid","err","fetch","location","href","credentials","then","pageRes","status","reload","console","error"],"mappings":"AAAA;AAAA,OAAOA,MAAM,MAAM,aAAa,CAAA;AAChC,SAASC,kBAAkB,EAAEC,WAAW,QAAQ,2BAA2B,CAAA;AAE3E,eAAe,oBAAA,UAAOC,IAAI,EAAK;IAC7B,IAAIA,IAAI,EAAE;QACR,wDAAwD;QACxD,sDAAsD;QACtDC,WAAW,CAAC,IAAM;YAChBF,WAAW,CAACG,IAAI,CAACC,SAAS,CAAC;gBAAEC,KAAK,EAAE,MAAM;gBAAEJ,IAAI;aAAE,CAAC,CAAC;SACrD,EAAE,IAAI,CAAC;KACT,MAAM;QACLH,MAAM,CAACQ,KAAK,CAAC,IAAM;YACjBJ,WAAW,CAAC,IAAM;gBAChB,iEAAiE;gBACjE,gEAAgE;gBAChE,+DAA+D;gBAC/D,MAAMK,eAAe,GAAGC,IAAI,CAACC,aAAa,CAACF,eAAe;gBAC1D,MAAMG,QAAQ,GACZ,CAACZ,MAAM,CAACY,QAAQ,KAAK,MAAM,IAAIZ,MAAM,CAACY,QAAQ,KAAK,SAAS,CAAC,IAC7DH,eAAe,GACXA,eAAe,GACfT,MAAM,CAACY,QAAQ;gBAErBV,WAAW,CAACG,IAAI,CAACC,SAAS,CAAC;oBAAEC,KAAK,EAAE,MAAM;oBAAEJ,IAAI,EAAES,QAAQ;iBAAE,CAAC,CAAC;aAC/D,EAAE,IAAI,CAAC;SACT,CAAC;KACH;IAEDX,kBAAkB,CAAC,CAACM,KAAK,GAAK;QAC5B,IAAIA,KAAK,CAACM,IAAI,CAACC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,OAAM;QAC1C,IAAI;YACF,MAAMC,OAAO,GAAGV,IAAI,CAACW,KAAK,CAACT,KAAK,CAACM,IAAI,CAAC;YACtC,2DAA2D;YAC3D,8DAA8D;YAC9D,aAAa;YACb,IACEE,OAAO,CAACR,KAAK,KAAK,MAAM,IACxBQ,OAAO,CAACE,OAAO,IACf,CAACP,IAAI,CAACC,aAAa,CAACO,GAAG,EACvB;gBACA,sDAAsD;gBACtD,qCAAqC;gBACrCC,KAAK,CAACC,QAAQ,CAACC,IAAI,EAAE;oBACnBC,WAAW,EAAE,aAAa;iBAC3B,CAAC,CAACC,IAAI,CAAC,CAACC,OAAO,GAAK;oBACnB,IAAIA,OAAO,CAACC,MAAM,KAAK,GAAG,EAAE;wBAC1B,0BAA0B;wBAC1BL,QAAQ,CAACM,MAAM,EAAE;qBAClB,MAAM;wBACL,qBAAqB;wBACrB,IACEhB,IAAI,CAACC,aAAa,CAACR,IAAI,KAAKH,MAAM,CAACY,QAAQ,IAC3CZ,MAAM,CAACY,QAAQ,KAAK,SAAS,EAC7B;4BACA,4BAA4B;4BAC5B,gCAAgC;4BAChCQ,QAAQ,CAACM,MAAM,EAAE;yBAClB;qBACF;iBACF,CAAC;aACH;SACF,CAAC,OAAOR,GAAG,EAAE;YACZS,OAAO,CAACC,KAAK,CAAC,4CAA4C,EAAEV,GAAG,CAAC;SACjE;KACF,CAAC;CACH,CAAA,CAAA"}

View File

@@ -0,0 +1,42 @@
import connect from './error-overlay/hot-dev-client';
import { sendMessage } from './error-overlay/websocket';
export default (()=>{
const devClient = connect();
devClient.subscribeToHmrEvent((obj)=>{
if (obj.action === 'reloadPage') {
sendMessage(JSON.stringify({
event: 'client-reload-page',
clientId: window.__nextDevClientId
}));
return window.location.reload();
}
if (obj.action === 'removedPage') {
const [page] = obj.data;
if (page === window.next.router.pathname) {
sendMessage(JSON.stringify({
event: 'client-removed-page',
clientId: window.__nextDevClientId,
page
}));
return window.location.reload();
}
return;
}
if (obj.action === 'addedPage') {
const [page] = obj.data;
if (page === window.next.router.pathname && typeof window.next.router.components[page] === 'undefined') {
sendMessage(JSON.stringify({
event: 'client-added-page',
clientId: window.__nextDevClientId,
page
}));
return window.location.reload();
}
return;
}
throw new Error('Unexpected action ' + obj.action);
});
return devClient;
});
//# sourceMappingURL=webpack-hot-middleware-client.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/dev/webpack-hot-middleware-client.js"],"names":["connect","sendMessage","devClient","subscribeToHmrEvent","obj","action","JSON","stringify","event","clientId","window","__nextDevClientId","location","reload","page","data","next","router","pathname","components","Error"],"mappings":"AAAA,OAAOA,OAAO,MAAM,gCAAgC,CAAA;AACpD,SAASC,WAAW,QAAQ,2BAA2B,CAAA;AAEvD,eAAe,CAAA,IAAM;IACnB,MAAMC,SAAS,GAAGF,OAAO,EAAE;IAE3BE,SAAS,CAACC,mBAAmB,CAAC,CAACC,GAAG,GAAK;QACrC,IAAIA,GAAG,CAACC,MAAM,KAAK,YAAY,EAAE;YAC/BJ,WAAW,CACTK,IAAI,CAACC,SAAS,CAAC;gBACbC,KAAK,EAAE,oBAAoB;gBAC3BC,QAAQ,EAAEC,MAAM,CAACC,iBAAiB;aACnC,CAAC,CACH;YACD,OAAOD,MAAM,CAACE,QAAQ,CAACC,MAAM,EAAE,CAAA;SAChC;QACD,IAAIT,GAAG,CAACC,MAAM,KAAK,aAAa,EAAE;YAChC,MAAM,CAACS,IAAI,CAAC,GAAGV,GAAG,CAACW,IAAI;YACvB,IAAID,IAAI,KAAKJ,MAAM,CAACM,IAAI,CAACC,MAAM,CAACC,QAAQ,EAAE;gBACxCjB,WAAW,CACTK,IAAI,CAACC,SAAS,CAAC;oBACbC,KAAK,EAAE,qBAAqB;oBAC5BC,QAAQ,EAAEC,MAAM,CAACC,iBAAiB;oBAClCG,IAAI;iBACL,CAAC,CACH;gBACD,OAAOJ,MAAM,CAACE,QAAQ,CAACC,MAAM,EAAE,CAAA;aAChC;YACD,OAAM;SACP;QACD,IAAIT,GAAG,CAACC,MAAM,KAAK,W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