Initial commit

This commit is contained in:
bilulib
2025-04-13 00:18:57 +02:00
parent cff009bb7c
commit d894249e61
18301 changed files with 2905442 additions and 3845 deletions

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,88 @@
/* globals __webpack_hash__ */ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _fouc = require("./fouc");
const _ondemandentriesclient = /*#__PURE__*/ _interop_require_default._(require("./on-demand-entries-client"));
const _websocket = require("../components/react-dev-overlay/pages/websocket");
const _hotreloadertypes = require("../../server/dev/hot-reloader-types");
const _shared = require("../components/react-dev-overlay/shared");
/// <reference types="webpack/module.d.ts" />
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';
}
// 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();
}
}
(0, _websocket.addMessageListener)((message)=>{
if (!('action' in message)) {
return;
}
try {
// actions which are not related to amp-dev
if (message.action === _hotreloadertypes.HMR_ACTIONS_SENT_TO_BROWSER.SERVER_ERROR || message.action === _hotreloadertypes.HMR_ACTIONS_SENT_TO_BROWSER.DEV_PAGES_MANIFEST_UPDATE) {
return;
}
if (message.action === _hotreloadertypes.HMR_ACTIONS_SENT_TO_BROWSER.SYNC || message.action === _hotreloadertypes.HMR_ACTIONS_SENT_TO_BROWSER.BUILT) {
if (!message.hash) {
return;
}
mostRecentHash = message.hash;
tryApplyUpdates();
} else if (message.action === _hotreloadertypes.HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE) {
window.location.reload();
}
} catch (err) {
(0, _shared.reportInvalidHmrMessage)(message, err);
}
});
(0, _websocket.connectHMR)({
assetPrefix,
path: '/_next/webpack-hmr'
});
(0, _fouc.displayContent)();
(0, _ondemandentriesclient.default)(data.page);
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=amp-dev.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
/** Integrates the generic dev build indicator with the App Router. */
export declare const initializeDevBuildIndicatorForAppRouter: () => void;

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "initializeDevBuildIndicatorForAppRouter", {
enumerable: true,
get: function() {
return initializeDevBuildIndicatorForAppRouter;
}
});
const _devbuildindicator = require("./internal/dev-build-indicator");
const initializeDevBuildIndicatorForAppRouter = ()=>{
if (!process.env.__NEXT_DEV_INDICATOR) {
return;
}
_devbuildindicator.devBuildIndicator.initialize();
};
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=initialize-for-app-router.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/dev/dev-build-indicator/initialize-for-app-router.ts"],"sourcesContent":["import { devBuildIndicator } from './internal/dev-build-indicator'\n\n/** Integrates the generic dev build indicator with the App Router. */\nexport const initializeDevBuildIndicatorForAppRouter = () => {\n if (!process.env.__NEXT_DEV_INDICATOR) {\n return\n }\n\n devBuildIndicator.initialize()\n}\n"],"names":["initializeDevBuildIndicatorForAppRouter","process","env","__NEXT_DEV_INDICATOR","devBuildIndicator","initialize"],"mappings":";;;;+BAGaA;;;eAAAA;;;mCAHqB;AAG3B,MAAMA,0CAA0C;IACrD,IAAI,CAACC,QAAQC,GAAG,CAACC,oBAAoB,EAAE;QACrC;IACF;IAEAC,oCAAiB,CAACC,UAAU;AAC9B"}

View File

@@ -0,0 +1,2 @@
/** Integrates the generic dev build indicator with the Pages Router. */
export declare const initializeDevBuildIndicatorForPageRouter: () => void;

View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "initializeDevBuildIndicatorForPageRouter", {
enumerable: true,
get: function() {
return initializeDevBuildIndicatorForPageRouter;
}
});
const _websocket = require("../../components/react-dev-overlay/pages/websocket");
const _devbuildindicator = require("./internal/dev-build-indicator");
const _handledevbuildindicatorhmrevents = require("./internal/handle-dev-build-indicator-hmr-events");
const initializeDevBuildIndicatorForPageRouter = ()=>{
if (!process.env.__NEXT_DEV_INDICATOR) {
return;
}
_devbuildindicator.devBuildIndicator.initialize();
// Add message listener specifically for Pages Router to handle lifecycle events
// related to dev builds (building, built, sync)
(0, _websocket.addMessageListener)(_handledevbuildindicatorhmrevents.handleDevBuildIndicatorHmrEvents);
};
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=initialize-for-page-router.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/dev/dev-build-indicator/initialize-for-page-router.ts"],"sourcesContent":["import { addMessageListener } from '../../components/react-dev-overlay/pages/websocket'\nimport { devBuildIndicator } from './internal/dev-build-indicator'\nimport { handleDevBuildIndicatorHmrEvents } from './internal/handle-dev-build-indicator-hmr-events'\n\n/** Integrates the generic dev build indicator with the Pages Router. */\nexport const initializeDevBuildIndicatorForPageRouter = () => {\n if (!process.env.__NEXT_DEV_INDICATOR) {\n return\n }\n\n devBuildIndicator.initialize()\n\n // Add message listener specifically for Pages Router to handle lifecycle events\n // related to dev builds (building, built, sync)\n addMessageListener(handleDevBuildIndicatorHmrEvents)\n}\n"],"names":["initializeDevBuildIndicatorForPageRouter","process","env","__NEXT_DEV_INDICATOR","devBuildIndicator","initialize","addMessageListener","handleDevBuildIndicatorHmrEvents"],"mappings":";;;;+BAKaA;;;eAAAA;;;2BALsB;mCACD;kDACe;AAG1C,MAAMA,2CAA2C;IACtD,IAAI,CAACC,QAAQC,GAAG,CAACC,oBAAoB,EAAE;QACrC;IACF;IAEAC,oCAAiB,CAACC,UAAU;IAE5B,gFAAgF;IAChF,gDAAgD;IAChDC,IAAAA,6BAAkB,EAACC,kEAAgC;AACrD"}

View File

@@ -0,0 +1,9 @@
import { initialize } from './initialize';
export declare const devBuildIndicator: {
/** Shows build indicator when Next.js is compiling. Requires initialize() first. */
show: () => void;
/** Hides build indicator when Next.js finishes compiling. Requires initialize() first. */
hide: () => void;
/** Sets up the build indicator UI component. Call this before using show/hide. */
initialize: typeof initialize;
};

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "devBuildIndicator", {
enumerable: true,
get: function() {
return devBuildIndicator;
}
});
const _initialize = require("./initialize");
const NOOP = ()=>{};
const devBuildIndicator = {
/** Shows build indicator when Next.js is compiling. Requires initialize() first. */ show: NOOP,
/** Hides build indicator when Next.js finishes compiling. Requires initialize() first. */ hide: NOOP,
/** Sets up the build indicator UI component. Call this before using show/hide. */ initialize: _initialize.initialize
};
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=dev-build-indicator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/dev/dev-build-indicator/internal/dev-build-indicator.ts"],"sourcesContent":["import { initialize } from './initialize'\n\nconst NOOP = () => {}\n\nexport const devBuildIndicator = {\n /** Shows build indicator when Next.js is compiling. Requires initialize() first. */\n show: NOOP,\n /** Hides build indicator when Next.js finishes compiling. Requires initialize() first. */\n hide: NOOP,\n /** Sets up the build indicator UI component. Call this before using show/hide. */\n initialize,\n}\n"],"names":["devBuildIndicator","NOOP","show","hide","initialize"],"mappings":";;;;+BAIaA;;;eAAAA;;;4BAJc;AAE3B,MAAMC,OAAO,KAAO;AAEb,MAAMD,oBAAoB;IAC/B,kFAAkF,GAClFE,MAAMD;IACN,wFAAwF,GACxFE,MAAMF;IACN,gFAAgF,GAChFG,YAAAA,sBAAU;AACZ"}

View File

@@ -0,0 +1,6 @@
import { type HMR_ACTION_TYPES } from '../../../../server/dev/hot-reloader-types';
/**
* Handles HMR events to control the dev build indicator visibility.
* Shows indicator when building and hides it when build completes or syncs.
*/
export declare const handleDevBuildIndicatorHmrEvents: (obj: HMR_ACTION_TYPES) => void;

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "handleDevBuildIndicatorHmrEvents", {
enumerable: true,
get: function() {
return handleDevBuildIndicatorHmrEvents;
}
});
const _hotreloadertypes = require("../../../../server/dev/hot-reloader-types");
const _devbuildindicator = require("./dev-build-indicator");
const handleDevBuildIndicatorHmrEvents = (obj)=>{
try {
if (!('action' in obj)) {
return;
}
// eslint-disable-next-line default-case
switch(obj.action){
case _hotreloadertypes.HMR_ACTIONS_SENT_TO_BROWSER.BUILDING:
_devbuildindicator.devBuildIndicator.show();
break;
case _hotreloadertypes.HMR_ACTIONS_SENT_TO_BROWSER.BUILT:
case _hotreloadertypes.HMR_ACTIONS_SENT_TO_BROWSER.SYNC:
_devbuildindicator.devBuildIndicator.hide();
break;
}
} catch (e) {}
};
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=handle-dev-build-indicator-hmr-events.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/dev/dev-build-indicator/internal/handle-dev-build-indicator-hmr-events.ts"],"sourcesContent":["import {\n HMR_ACTIONS_SENT_TO_BROWSER,\n type HMR_ACTION_TYPES,\n} from '../../../../server/dev/hot-reloader-types'\nimport { devBuildIndicator } from './dev-build-indicator'\n\n/**\n * Handles HMR events to control the dev build indicator visibility.\n * Shows indicator when building and hides it when build completes or syncs.\n */\nexport const handleDevBuildIndicatorHmrEvents = (obj: HMR_ACTION_TYPES) => {\n try {\n if (!('action' in obj)) {\n return\n }\n\n // eslint-disable-next-line default-case\n switch (obj.action) {\n case HMR_ACTIONS_SENT_TO_BROWSER.BUILDING:\n devBuildIndicator.show()\n break\n case HMR_ACTIONS_SENT_TO_BROWSER.BUILT:\n case HMR_ACTIONS_SENT_TO_BROWSER.SYNC:\n devBuildIndicator.hide()\n break\n }\n } catch {}\n}\n"],"names":["handleDevBuildIndicatorHmrEvents","obj","action","HMR_ACTIONS_SENT_TO_BROWSER","BUILDING","devBuildIndicator","show","BUILT","SYNC","hide"],"mappings":";;;;+BAUaA;;;eAAAA;;;kCAPN;mCAC2B;AAM3B,MAAMA,mCAAmC,CAACC;IAC/C,IAAI;QACF,IAAI,CAAE,CAAA,YAAYA,GAAE,GAAI;YACtB;QACF;QAEA,wCAAwC;QACxC,OAAQA,IAAIC,MAAM;YAChB,KAAKC,6CAA2B,CAACC,QAAQ;gBACvCC,oCAAiB,CAACC,IAAI;gBACtB;YACF,KAAKH,6CAA2B,CAACI,KAAK;YACtC,KAAKJ,6CAA2B,CAACK,IAAI;gBACnCH,oCAAiB,CAACI,IAAI;gBACtB;QACJ;IACF,EAAE,UAAM,CAAC;AACX"}

View File

@@ -0,0 +1,2 @@
export declare function useIsDevBuilding(): boolean;
export declare function initialize(): void;

View File

@@ -0,0 +1,57 @@
/*
* Singleton store to track whether the app is currently being built
* Used by the dev tools indicator of the new overlay to show build status
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
initialize: null,
useIsDevBuilding: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
initialize: function() {
return initialize;
},
useIsDevBuilding: function() {
return useIsDevBuilding;
}
});
const _devbuildindicator = require("./dev-build-indicator");
const _react = require("react");
let isVisible = false;
let listeners = [];
const subscribe = (listener)=>{
listeners.push(listener);
return ()=>{
listeners = listeners.filter((l)=>l !== listener);
};
};
const getSnapshot = ()=>isVisible;
function useIsDevBuilding() {
return (0, _react.useSyncExternalStore)(subscribe, getSnapshot);
}
function initialize() {
_devbuildindicator.devBuildIndicator.show = ()=>{
isVisible = true;
listeners.forEach((listener)=>listener());
};
_devbuildindicator.devBuildIndicator.hide = ()=>{
isVisible = false;
listeners.forEach((listener)=>listener());
};
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=initialize.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/dev/dev-build-indicator/internal/initialize.ts"],"sourcesContent":["/*\n * Singleton store to track whether the app is currently being built\n * Used by the dev tools indicator of the new overlay to show build status\n */\n\nimport { devBuildIndicator } from './dev-build-indicator'\nimport { useSyncExternalStore } from 'react'\n\nlet isVisible = false\nlet listeners: Array<() => void> = []\n\nconst subscribe = (listener: () => void) => {\n listeners.push(listener)\n return () => {\n listeners = listeners.filter((l) => l !== listener)\n }\n}\n\nconst getSnapshot = () => isVisible\n\nexport function useIsDevBuilding() {\n return useSyncExternalStore(subscribe, getSnapshot)\n}\n\nexport function initialize() {\n devBuildIndicator.show = () => {\n isVisible = true\n listeners.forEach((listener) => listener())\n }\n\n devBuildIndicator.hide = () => {\n isVisible = false\n listeners.forEach((listener) => listener())\n }\n}\n"],"names":["initialize","useIsDevBuilding","isVisible","listeners","subscribe","listener","push","filter","l","getSnapshot","useSyncExternalStore","devBuildIndicator","show","forEach","hide"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;;;;;IAqBeA,UAAU;eAAVA;;IAJAC,gBAAgB;eAAhBA;;;mCAfkB;uBACG;AAErC,IAAIC,YAAY;AAChB,IAAIC,YAA+B,EAAE;AAErC,MAAMC,YAAY,CAACC;IACjBF,UAAUG,IAAI,CAACD;IACf,OAAO;QACLF,YAAYA,UAAUI,MAAM,CAAC,CAACC,IAAMA,MAAMH;IAC5C;AACF;AAEA,MAAMI,cAAc,IAAMP;AAEnB,SAASD;IACd,OAAOS,IAAAA,2BAAoB,EAACN,WAAWK;AACzC;AAEO,SAAST;IACdW,oCAAiB,CAACC,IAAI,GAAG;QACvBV,YAAY;QACZC,UAAUU,OAAO,CAAC,CAACR,WAAaA;IAClC;IAEAM,oCAAiB,CAACG,IAAI,GAAG;QACvBZ,YAAY;QACZC,UAAUU,OAAO,CAAC,CAACR,WAAaA;IAClC;AACF"}

View File

@@ -0,0 +1 @@
export { addMessageListener } from '../../components/react-dev-overlay/pages/websocket';

View File

@@ -0,0 +1,22 @@
// next-contentlayer is relying on this internal path
// https://github.com/contentlayerdev/contentlayer/blob/2f491c540e1d3667577f57fa368b150bff427aaf/packages/next-contentlayer/src/hooks/useLiveReload.ts#L1
// Drop this file if https://github.com/contentlayerdev/contentlayer/pull/649 is merged/released
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "addMessageListener", {
enumerable: true,
get: function() {
return _websocket.addMessageListener;
}
});
const _websocket = require("../../components/react-dev-overlay/pages/websocket");
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=websocket.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/dev/error-overlay/websocket.ts"],"sourcesContent":["// next-contentlayer is relying on this internal path\n// https://github.com/contentlayerdev/contentlayer/blob/2f491c540e1d3667577f57fa368b150bff427aaf/packages/next-contentlayer/src/hooks/useLiveReload.ts#L1\n// Drop this file if https://github.com/contentlayerdev/contentlayer/pull/649 is merged/released\nexport { addMessageListener } from '../../components/react-dev-overlay/pages/websocket'\n"],"names":["addMessageListener"],"mappings":"AAAA,qDAAqD;AACrD,yJAAyJ;AACzJ,gGAAgG;;;;;+BACvFA;;;eAAAA,6BAAkB;;;2BAAQ"}

View File

@@ -0,0 +1 @@
export declare function displayContent(): Promise<void>;

View File

@@ -0,0 +1,42 @@
// 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
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "displayContent", {
enumerable: true,
get: function() {
return displayContent;
}
});
const safeCallbackQueue = (callback)=>{
if (window.requestAnimationFrame && window.self === window.top) {
window.requestAnimationFrame(callback);
} else {
window.setTimeout(callback);
}
};
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();
});
});
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=fouc.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/dev/fouc.ts"],"sourcesContent":["// This wrapper function is used to safely select the best available function\n// to schedule removal of the no-FOUC styles workaround. requestAnimationFrame\n// is the ideal choice, but when used in iframes, there are no guarantees that\n// the callback will actually be called, which could stall the promise returned\n// from displayContent.\n//\n// See: https://www.vector-logic.com/blog/posts/on-request-animation-frame-and-embedded-iframes\nconst safeCallbackQueue = (callback: () => void) => {\n if (window.requestAnimationFrame && window.self === window.top) {\n window.requestAnimationFrame(callback)\n } else {\n window.setTimeout(callback)\n }\n}\n\n// This function is used to remove Next.js' no-FOUC styles workaround for using\n// `style-loader` in development. It must be called before hydration, or else\n// rendering won't have the correct computed values in effects.\nexport function displayContent(): Promise<void> {\n return new Promise((resolve) => {\n safeCallbackQueue(function () {\n for (\n var x = document.querySelectorAll('[data-next-hide-fouc]'),\n i = x.length;\n i--;\n\n ) {\n x[i].parentNode!.removeChild(x[i])\n }\n resolve()\n })\n })\n}\n"],"names":["displayContent","safeCallbackQueue","callback","window","requestAnimationFrame","self","top","setTimeout","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;;;;;+BAY/EA;;;eAAAA;;;AAXhB,MAAMC,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;AAKO,SAASF;IACd,OAAO,IAAIQ,QAAQ,CAACC;QAClBR,kBAAkB;YAChB,IACE,IAAIS,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,8 @@
declare const _default: () => {
subscribeToHmrEvent(handler: any): void;
onUnrecoverableError(): void;
addTurbopackMessageListener(cb: (msg: import("../../server/dev/hot-reloader-types").TurbopackMsgToBrowser) => void): void;
sendTurbopackMessage(msg: string): void;
handleUpdateError(err: unknown): void;
};
export default _default;

View File

@@ -0,0 +1,98 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _default;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _hotreloaderclient = /*#__PURE__*/ _interop_require_default._(require("../components/react-dev-overlay/pages/hot-reloader-client"));
const _websocket = require("../components/react-dev-overlay/pages/websocket");
let reloading = false;
const _default = ()=>{
const devClient = (0, _hotreloaderclient.default)();
devClient.subscribeToHmrEvent((obj)=>{
var _window_next;
if (reloading) return;
// Retrieve the router if it's available
const router = (_window_next = window.next) == null ? void 0 : _window_next.router;
// Determine if we're on an error page or the router is not initialized
const isOnErrorPage = !router || router.pathname === '/404' || router.pathname === '/_error';
switch(obj.action){
case 'reloadPage':
{
(0, _websocket.sendMessage)(JSON.stringify({
event: 'client-reload-page',
clientId: window.__nextDevClientId
}));
reloading = true;
return window.location.reload();
}
case 'removedPage':
{
const [page] = obj.data;
// Check if the removed page is the current page
const isCurrentPage = page === (router == null ? void 0 : router.pathname);
// We enter here if the removed page is currently being viewed
// or if we happen to be on an error page.
if (isCurrentPage || isOnErrorPage) {
(0, _websocket.sendMessage)(JSON.stringify({
event: 'client-removed-page',
clientId: window.__nextDevClientId,
page
}));
return window.location.reload();
}
return;
}
case 'addedPage':
{
var _router_components;
const [page] = obj.data;
// Check if the added page is the current page
const isCurrentPage = page === (router == null ? void 0 : router.pathname);
// Check if the page component is not yet loaded
const isPageNotLoaded = typeof (router == null ? void 0 : (_router_components = router.components) == null ? void 0 : _router_components[page]) === 'undefined';
// We enter this block if the newly added page is the one currently being viewed
// but hasn't been loaded yet, or if we're on an error page.
if (isCurrentPage && isPageNotLoaded || isOnErrorPage) {
(0, _websocket.sendMessage)(JSON.stringify({
event: 'client-added-page',
clientId: window.__nextDevClientId,
page
}));
return window.location.reload();
}
return;
}
case 'serverError':
case 'devPagesManifestUpdate':
case 'isrManifest':
case 'building':
case 'finishBuilding':
{
return;
}
default:
{
throw Object.defineProperty(new Error('Unexpected action ' + obj.action), "__NEXT_ERROR_CODE", {
value: "E59",
enumerable: false,
configurable: true
});
}
}
});
return devClient;
};
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=hot-middleware-client.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/dev/hot-middleware-client.ts"],"sourcesContent":["import type {\n NextRouter,\n PrivateRouteInfo,\n} from '../../shared/lib/router/router'\nimport connect from '../components/react-dev-overlay/pages/hot-reloader-client'\nimport { sendMessage } from '../components/react-dev-overlay/pages/websocket'\n\n// Define a local type for the window.next object\ninterface NextWindow {\n next?: {\n router?: NextRouter & {\n components: { [pathname: string]: PrivateRouteInfo }\n }\n }\n __nextDevClientId?: string\n location: Location\n}\n\ndeclare const window: NextWindow\n\nlet reloading = false\n\nexport default () => {\n const devClient = connect()\n\n devClient.subscribeToHmrEvent((obj: any) => {\n if (reloading) return\n\n // Retrieve the router if it's available\n const router = window.next?.router\n\n // Determine if we're on an error page or the router is not initialized\n const isOnErrorPage =\n !router || router.pathname === '/404' || router.pathname === '/_error'\n\n switch (obj.action) {\n case 'reloadPage': {\n sendMessage(\n JSON.stringify({\n event: 'client-reload-page',\n clientId: window.__nextDevClientId,\n })\n )\n reloading = true\n return window.location.reload()\n }\n case 'removedPage': {\n const [page] = obj.data\n\n // Check if the removed page is the current page\n const isCurrentPage = page === router?.pathname\n\n // We enter here if the removed page is currently being viewed\n // or if we happen to be on an error page.\n if (isCurrentPage || isOnErrorPage) {\n sendMessage(\n JSON.stringify({\n event: 'client-removed-page',\n clientId: window.__nextDevClientId,\n page,\n })\n )\n return window.location.reload()\n }\n return\n }\n case 'addedPage': {\n const [page] = obj.data\n\n // Check if the added page is the current page\n const isCurrentPage = page === router?.pathname\n\n // Check if the page component is not yet loaded\n const isPageNotLoaded =\n typeof router?.components?.[page] === 'undefined'\n\n // We enter this block if the newly added page is the one currently being viewed\n // but hasn't been loaded yet, or if we're on an error page.\n if ((isCurrentPage && isPageNotLoaded) || isOnErrorPage) {\n sendMessage(\n JSON.stringify({\n event: 'client-added-page',\n clientId: window.__nextDevClientId,\n page,\n })\n )\n return window.location.reload()\n }\n return\n }\n case 'serverError':\n case 'devPagesManifestUpdate':\n case 'isrManifest':\n case 'building':\n case 'finishBuilding': {\n return\n }\n default: {\n throw new Error('Unexpected action ' + obj.action)\n }\n }\n })\n\n return devClient\n}\n"],"names":["reloading","devClient","connect","subscribeToHmrEvent","obj","window","router","next","isOnErrorPage","pathname","action","sendMessage","JSON","stringify","event","clientId","__nextDevClientId","location","reload","page","data","isCurrentPage","isPageNotLoaded","components","Error"],"mappings":";;;;+BAsBA;;;eAAA;;;;4EAlBoB;2BACQ;AAe5B,IAAIA,YAAY;MAEhB,WAAe;IACb,MAAMC,YAAYC,IAAAA,0BAAO;IAEzBD,UAAUE,mBAAmB,CAAC,CAACC;YAIdC;QAHf,IAAIL,WAAW;QAEf,wCAAwC;QACxC,MAAMM,UAASD,eAAAA,OAAOE,IAAI,qBAAXF,aAAaC,MAAM;QAElC,uEAAuE;QACvE,MAAME,gBACJ,CAACF,UAAUA,OAAOG,QAAQ,KAAK,UAAUH,OAAOG,QAAQ,KAAK;QAE/D,OAAQL,IAAIM,MAAM;YAChB,KAAK;gBAAc;oBACjBC,IAAAA,sBAAW,EACTC,KAAKC,SAAS,CAAC;wBACbC,OAAO;wBACPC,UAAUV,OAAOW,iBAAiB;oBACpC;oBAEFhB,YAAY;oBACZ,OAAOK,OAAOY,QAAQ,CAACC,MAAM;gBAC/B;YACA,KAAK;gBAAe;oBAClB,MAAM,CAACC,KAAK,GAAGf,IAAIgB,IAAI;oBAEvB,gDAAgD;oBAChD,MAAMC,gBAAgBF,UAASb,0BAAAA,OAAQG,QAAQ;oBAE/C,8DAA8D;oBAC9D,0CAA0C;oBAC1C,IAAIY,iBAAiBb,eAAe;wBAClCG,IAAAA,sBAAW,EACTC,KAAKC,SAAS,CAAC;4BACbC,OAAO;4BACPC,UAAUV,OAAOW,iBAAiB;4BAClCG;wBACF;wBAEF,OAAOd,OAAOY,QAAQ,CAACC,MAAM;oBAC/B;oBACA;gBACF;YACA,KAAK;gBAAa;wBAQPZ;oBAPT,MAAM,CAACa,KAAK,GAAGf,IAAIgB,IAAI;oBAEvB,8CAA8C;oBAC9C,MAAMC,gBAAgBF,UAASb,0BAAAA,OAAQG,QAAQ;oBAE/C,gDAAgD;oBAChD,MAAMa,kBACJ,QAAOhB,2BAAAA,qBAAAA,OAAQiB,UAAU,qBAAlBjB,kBAAoB,CAACa,KAAK,MAAK;oBAExC,gFAAgF;oBAChF,4DAA4D;oBAC5D,IAAI,AAACE,iBAAiBC,mBAAoBd,eAAe;wBACvDG,IAAAA,sBAAW,EACTC,KAAKC,SAAS,CAAC;4BACbC,OAAO;4BACPC,UAAUV,OAAOW,iBAAiB;4BAClCG;wBACF;wBAEF,OAAOd,OAAOY,QAAQ,CAACC,MAAM;oBAC/B;oBACA;gBACF;YACA,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;YACL,KAAK;gBAAkB;oBACrB;gBACF;YACA;gBAAS;oBACP,MAAM,qBAA4C,CAA5C,IAAIM,MAAM,uBAAuBpB,IAAIM,MAAM,GAA3C,qBAAA;+BAAA;oCAAA;sCAAA;oBAA2C;gBACnD;QACF;IACF;IAEA,OAAOT;AACT"}

View File

@@ -0,0 +1 @@
export declare function connect(): void;

View File

@@ -0,0 +1,21 @@
// 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.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "connect", {
enumerable: true,
get: function() {
return connect;
}
});
function connect() {}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=noop-turbopack-hmr.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/dev/noop-turbopack-hmr.ts"],"sourcesContent":["// The Turbopack HMR client can't be properly omitted at the moment (WEB-1589),\n// so instead we remap its import to this file in webpack builds.\nexport function connect() {}\n"],"names":["connect"],"mappings":"AAAA,+EAA+E;AAC/E,iEAAiE;;;;;+BACjDA;;;eAAAA;;;AAAT,SAASA,WAAW"}

View File

@@ -0,0 +1,2 @@
declare const _default: (page?: string) => Promise<void>;
export default _default;

View File

@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _default;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _router = /*#__PURE__*/ _interop_require_default._(require("../router"));
const _websocket = require("../components/react-dev-overlay/pages/websocket");
const _default = async (page)=>{
// Never send pings when using Turbopack as it's not used.
// Pings were originally used to keep track of active routes in on-demand-entries with webpack.
if (process.env.TURBOPACK) {
return;
}
if (page) {
// in AMP the router isn't initialized on the client and
// client-transitions don't occur so ping initial page
setInterval(()=>{
(0, _websocket.sendMessage)(JSON.stringify({
event: 'ping',
page
}));
}, 2500);
} else {
_router.default.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.default.pathname === '/404' || _router.default.pathname === '/_error') && notFoundSrcPage ? notFoundSrcPage : _router.default.pathname;
(0, _websocket.sendMessage)(JSON.stringify({
event: 'ping',
page: pathname
}));
}, 2500);
});
}
};
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=on-demand-entries-client.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/dev/on-demand-entries-client.ts"],"sourcesContent":["import Router from '../router'\nimport { sendMessage } from '../components/react-dev-overlay/pages/websocket'\n\nexport default async (page?: string) => {\n // Never send pings when using Turbopack as it's not used.\n // Pings were originally used to keep track of active routes in on-demand-entries with webpack.\n if (process.env.TURBOPACK) {\n return\n }\n if (page) {\n // in AMP the router isn't initialized on the client and\n // client-transitions don't occur so ping initial page\n setInterval(() => {\n sendMessage(JSON.stringify({ event: 'ping', page }))\n }, 2500)\n } else {\n Router.ready(() => {\n setInterval(() => {\n // when notFound: true is returned we should use the notFoundPage\n // as the Router.pathname will point to the 404 page but we want\n // to ping the source page that returned notFound: true instead\n const notFoundSrcPage = self.__NEXT_DATA__.notFoundSrcPage\n const pathname =\n (Router.pathname === '/404' || Router.pathname === '/_error') &&\n notFoundSrcPage\n ? notFoundSrcPage\n : Router.pathname\n\n sendMessage(JSON.stringify({ event: 'ping', page: pathname }))\n }, 2500)\n })\n }\n}\n"],"names":["page","process","env","TURBOPACK","setInterval","sendMessage","JSON","stringify","event","Router","ready","notFoundSrcPage","self","__NEXT_DATA__","pathname"],"mappings":";;;;+BAGA;;;eAAA;;;;iEAHmB;2BACS;MAE5B,WAAe,OAAOA;IACpB,0DAA0D;IAC1D,+FAA+F;IAC/F,IAAIC,QAAQC,GAAG,CAACC,SAAS,EAAE;QACzB;IACF;IACA,IAAIH,MAAM;QACR,wDAAwD;QACxD,sDAAsD;QACtDI,YAAY;YACVC,IAAAA,sBAAW,EAACC,KAAKC,SAAS,CAAC;gBAAEC,OAAO;gBAAQR;YAAK;QACnD,GAAG;IACL,OAAO;QACLS,eAAM,CAACC,KAAK,CAAC;YACXN,YAAY;gBACV,iEAAiE;gBACjE,gEAAgE;gBAChE,+DAA+D;gBAC/D,MAAMO,kBAAkBC,KAAKC,aAAa,CAACF,eAAe;gBAC1D,MAAMG,WACJ,AAACL,CAAAA,eAAM,CAACK,QAAQ,KAAK,UAAUL,eAAM,CAACK,QAAQ,KAAK,SAAQ,KAC3DH,kBACIA,kBACAF,eAAM,CAACK,QAAQ;gBAErBT,IAAAA,sBAAW,EAACC,KAAKC,SAAS,CAAC;oBAAEC,OAAO;oBAAQR,MAAMc;gBAAS;YAC7D,GAAG;QACL;IACF;AACF"}