feat(blog): add file-based blog with dynamic slugs, MDX content and layout shell

- Introduced blog routing using Next.js App Router
- Implemented dynamic [slug] pages for blog posts
- Added MDX-based content loading via lib/posts
- Integrated shared TopBar layout with navigation
- Established clear content, lib and component separation
This commit is contained in:
PascalSchattenburg
2026-01-22 14:14:15 +01:00
parent b717952234
commit d147843c76
10412 changed files with 2475583 additions and 0 deletions

View File

@@ -0,0 +1 @@
export declare function addBasePath(path: string, required?: boolean): string;

View File

@@ -0,0 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "addBasePath", {
enumerable: true,
get: function() {
return addBasePath;
}
});
const _addpathprefix = require("../shared/lib/router/utils/add-path-prefix");
const _normalizetrailingslash = require("./normalize-trailing-slash");
const basePath = process.env.__NEXT_ROUTER_BASEPATH || '';
function addBasePath(path, required) {
return (0, _normalizetrailingslash.normalizePathTrailingSlash)(process.env.__NEXT_MANUAL_CLIENT_BASE_PATH && !required ? path : (0, _addpathprefix.addPathPrefix)(path, basePath));
}
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=add-base-path.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/add-base-path.ts"],"sourcesContent":["import { addPathPrefix } from '../shared/lib/router/utils/add-path-prefix'\nimport { normalizePathTrailingSlash } from './normalize-trailing-slash'\n\nconst basePath = (process.env.__NEXT_ROUTER_BASEPATH as string) || ''\n\nexport function addBasePath(path: string, required?: boolean): string {\n return normalizePathTrailingSlash(\n process.env.__NEXT_MANUAL_CLIENT_BASE_PATH && !required\n ? path\n : addPathPrefix(path, basePath)\n )\n}\n"],"names":["addBasePath","basePath","process","env","__NEXT_ROUTER_BASEPATH","path","required","normalizePathTrailingSlash","__NEXT_MANUAL_CLIENT_BASE_PATH","addPathPrefix"],"mappings":";;;;+BAKgBA;;;eAAAA;;;+BALc;wCACa;AAE3C,MAAMC,WAAW,AAACC,QAAQC,GAAG,CAACC,sBAAsB,IAAe;AAE5D,SAASJ,YAAYK,IAAY,EAAEC,QAAkB;IAC1D,OAAOC,IAAAA,kDAA0B,EAC/BL,QAAQC,GAAG,CAACK,8BAA8B,IAAI,CAACF,WAC3CD,OACAI,IAAAA,4BAAa,EAACJ,MAAMJ;AAE5B","ignoreList":[0]}

View File

@@ -0,0 +1,2 @@
import type { addLocale as Fn } from '../shared/lib/router/utils/add-locale';
export declare const addLocale: typeof Fn;

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "addLocale", {
enumerable: true,
get: function() {
return addLocale;
}
});
const _normalizetrailingslash = require("./normalize-trailing-slash");
const addLocale = (path, ...args)=>{
if (process.env.__NEXT_I18N_SUPPORT) {
return (0, _normalizetrailingslash.normalizePathTrailingSlash)(require('../shared/lib/router/utils/add-locale').addLocale(path, ...args));
}
return path;
};
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=add-locale.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/add-locale.ts"],"sourcesContent":["import type { addLocale as Fn } from '../shared/lib/router/utils/add-locale'\nimport { normalizePathTrailingSlash } from './normalize-trailing-slash'\n\nexport const addLocale: typeof Fn = (path, ...args) => {\n if (process.env.__NEXT_I18N_SUPPORT) {\n return normalizePathTrailingSlash(\n (\n require('../shared/lib/router/utils/add-locale') as typeof import('../shared/lib/router/utils/add-locale')\n ).addLocale(path, ...args)\n )\n }\n return path\n}\n"],"names":["addLocale","path","args","process","env","__NEXT_I18N_SUPPORT","normalizePathTrailingSlash","require"],"mappings":";;;;+BAGaA;;;eAAAA;;;wCAF8B;AAEpC,MAAMA,YAAuB,CAACC,MAAM,GAAGC;IAC5C,IAAIC,QAAQC,GAAG,CAACC,mBAAmB,EAAE;QACnC,OAAOC,IAAAA,kDAA0B,EAC/B,AACEC,QAAQ,yCACRP,SAAS,CAACC,SAASC;IAEzB;IACA,OAAOD;AACT","ignoreList":[0]}

View File

@@ -0,0 +1,7 @@
/**
* Before starting the Next.js runtime and requiring any module, we need to make
* sure the following scripts are executed in the correct order:
* - Polyfills
* - next/script with `beforeInteractive` strategy
*/
export declare function appBootstrap(hydrate: (assetPrefix: string) => void): void;

View File

@@ -0,0 +1,76 @@
/**
* Before starting the Next.js runtime and requiring any module, we need to make
* sure the following scripts are executed in the correct order:
* - Polyfills
* - next/script with `beforeInteractive` strategy
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "appBootstrap", {
enumerable: true,
get: function() {
return appBootstrap;
}
});
const _assetprefix = require("./asset-prefix");
const _setattributesfromprops = require("./set-attributes-from-props");
const version = "16.1.4";
window.next = {
version,
appDir: true
};
function loadScriptsInSequence(scripts, hydrate) {
if (!scripts || !scripts.length) {
return hydrate();
}
return scripts.reduce((promise, [src, props])=>{
return promise.then(()=>{
return new Promise((resolve, reject)=>{
const el = document.createElement('script');
if (props) {
(0, _setattributesfromprops.setAttributesFromProps)(el, props);
}
if (src) {
el.src = src;
el.onload = ()=>resolve();
el.onerror = reject;
} else if (props) {
el.innerHTML = props.children;
setTimeout(resolve);
}
document.head.appendChild(el);
});
});
}, Promise.resolve()).catch((err)=>{
console.error(err);
// Still try to hydrate even if there's an error.
}).then(()=>{
hydrate();
});
}
function appBootstrap(hydrate) {
const assetPrefix = (0, _assetprefix.getAssetPrefix)();
loadScriptsInSequence(self.__next_s, ()=>{
// If the static shell is being debugged, skip hydration if the
// `__nextppronly` query is present. This is only enabled when the
// environment variable `__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING` is
// set to `1`. Otherwise the following is optimized out.
if (process.env.__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING === '1') {
const search = new URLSearchParams(window.location.search);
if (search.get('__nextppronly') === 'fallback' || search.get('__nextppronly') === '1') {
console.warn(`Skipping hydration due to __nextppronly=${search.get('__nextppronly')}`);
return;
}
}
hydrate(assetPrefix);
});
}
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=app-bootstrap.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/app-bootstrap.ts"],"sourcesContent":["/**\n * Before starting the Next.js runtime and requiring any module, we need to make\n * sure the following scripts are executed in the correct order:\n * - Polyfills\n * - next/script with `beforeInteractive` strategy\n */\n\nimport { getAssetPrefix } from './asset-prefix'\nimport { setAttributesFromProps } from './set-attributes-from-props'\n\nconst version = process.env.__NEXT_VERSION\n\nwindow.next = {\n version,\n appDir: true,\n}\n\nfunction loadScriptsInSequence(\n scripts: [src: string, props: { [prop: string]: any }][],\n hydrate: () => void\n) {\n if (!scripts || !scripts.length) {\n return hydrate()\n }\n\n return scripts\n .reduce((promise, [src, props]) => {\n return promise.then(() => {\n return new Promise<void>((resolve, reject) => {\n const el = document.createElement('script')\n\n if (props) {\n setAttributesFromProps(el, props)\n }\n\n if (src) {\n el.src = src\n el.onload = () => resolve()\n el.onerror = reject\n } else if (props) {\n el.innerHTML = props.children\n setTimeout(resolve)\n }\n\n document.head.appendChild(el)\n })\n })\n }, Promise.resolve())\n .catch((err: Error) => {\n console.error(err)\n // Still try to hydrate even if there's an error.\n })\n .then(() => {\n hydrate()\n })\n}\n\nexport function appBootstrap(hydrate: (assetPrefix: string) => void) {\n const assetPrefix = getAssetPrefix()\n\n loadScriptsInSequence((self as any).__next_s, () => {\n // If the static shell is being debugged, skip hydration if the\n // `__nextppronly` query is present. This is only enabled when the\n // environment variable `__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING` is\n // set to `1`. Otherwise the following is optimized out.\n if (process.env.__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING === '1') {\n const search = new URLSearchParams(window.location.search)\n if (\n search.get('__nextppronly') === 'fallback' ||\n search.get('__nextppronly') === '1'\n ) {\n console.warn(\n `Skipping hydration due to __nextppronly=${search.get('__nextppronly')}`\n )\n return\n }\n }\n\n hydrate(assetPrefix)\n })\n}\n"],"names":["appBootstrap","version","process","env","__NEXT_VERSION","window","next","appDir","loadScriptsInSequence","scripts","hydrate","length","reduce","promise","src","props","then","Promise","resolve","reject","el","document","createElement","setAttributesFromProps","onload","onerror","innerHTML","children","setTimeout","head","appendChild","catch","err","console","error","assetPrefix","getAssetPrefix","self","__next_s","__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING","search","URLSearchParams","location","get","warn"],"mappings":"AAAA;;;;;CAKC;;;;+BAoDeA;;;eAAAA;;;6BAlDe;wCACQ;AAEvC,MAAMC,UAAUC,QAAQC,GAAG,CAACC,cAAc;AAE1CC,OAAOC,IAAI,GAAG;IACZL;IACAM,QAAQ;AACV;AAEA,SAASC,sBACPC,OAAwD,EACxDC,OAAmB;IAEnB,IAAI,CAACD,WAAW,CAACA,QAAQE,MAAM,EAAE;QAC/B,OAAOD;IACT;IAEA,OAAOD,QACJG,MAAM,CAAC,CAACC,SAAS,CAACC,KAAKC,MAAM;QAC5B,OAAOF,QAAQG,IAAI,CAAC;YAClB,OAAO,IAAIC,QAAc,CAACC,SAASC;gBACjC,MAAMC,KAAKC,SAASC,aAAa,CAAC;gBAElC,IAAIP,OAAO;oBACTQ,IAAAA,8CAAsB,EAACH,IAAIL;gBAC7B;gBAEA,IAAID,KAAK;oBACPM,GAAGN,GAAG,GAAGA;oBACTM,GAAGI,MAAM,GAAG,IAAMN;oBAClBE,GAAGK,OAAO,GAAGN;gBACf,OAAO,IAAIJ,OAAO;oBAChBK,GAAGM,SAAS,GAAGX,MAAMY,QAAQ;oBAC7BC,WAAWV;gBACb;gBAEAG,SAASQ,IAAI,CAACC,WAAW,CAACV;YAC5B;QACF;IACF,GAAGH,QAAQC,OAAO,IACjBa,KAAK,CAAC,CAACC;QACNC,QAAQC,KAAK,CAACF;IACd,iDAAiD;IACnD,GACChB,IAAI,CAAC;QACJN;IACF;AACJ;AAEO,SAASV,aAAaU,OAAsC;IACjE,MAAMyB,cAAcC,IAAAA,2BAAc;IAElC5B,sBAAsB,AAAC6B,KAAaC,QAAQ,EAAE;QAC5C,+DAA+D;QAC/D,kEAAkE;QAClE,uEAAuE;QACvE,wDAAwD;QACxD,IAAIpC,QAAQC,GAAG,CAACoC,0CAA0C,KAAK,KAAK;YAClE,MAAMC,SAAS,IAAIC,gBAAgBpC,OAAOqC,QAAQ,CAACF,MAAM;YACzD,IACEA,OAAOG,GAAG,CAAC,qBAAqB,cAChCH,OAAOG,GAAG,CAAC,qBAAqB,KAChC;gBACAV,QAAQW,IAAI,CACV,CAAC,wCAAwC,EAAEJ,OAAOG,GAAG,CAAC,kBAAkB;gBAE1E;YACF;QACF;QAEAjC,QAAQyB;IACV;AACF","ignoreList":[0]}

View File

@@ -0,0 +1,2 @@
export declare function setAppBuildId(buildId: string): void;
export declare function getAppBuildId(): string;

View File

@@ -0,0 +1,49 @@
// This gets assigned as a side-effect during app initialization. Because it
// represents the build used to create the JS bundle, it should never change
// after being set, so we store it in a global variable.
//
// When performing RSC requests, if the incoming data has a different build ID,
// we perform an MPA navigation/refresh to load the updated build and ensure
// that the client and server in sync.
// Starts as an empty string. In practice, because setAppBuildId is called
// during initialization before hydration starts, this will always get
// reassigned to the actual build ID before it's ever needed by a navigation.
// If for some reasons it didn't, due to a bug or race condition, then on
// navigation the build comparision would fail and trigger an MPA navigation.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getAppBuildId: null,
setAppBuildId: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getAppBuildId: function() {
return getAppBuildId;
},
setAppBuildId: function() {
return setAppBuildId;
}
});
let globalBuildId = '';
function setAppBuildId(buildId) {
globalBuildId = buildId;
}
function getAppBuildId() {
return globalBuildId;
}
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=app-build-id.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/app-build-id.ts"],"sourcesContent":["// This gets assigned as a side-effect during app initialization. Because it\n// represents the build used to create the JS bundle, it should never change\n// after being set, so we store it in a global variable.\n//\n// When performing RSC requests, if the incoming data has a different build ID,\n// we perform an MPA navigation/refresh to load the updated build and ensure\n// that the client and server in sync.\n\n// Starts as an empty string. In practice, because setAppBuildId is called\n// during initialization before hydration starts, this will always get\n// reassigned to the actual build ID before it's ever needed by a navigation.\n// If for some reasons it didn't, due to a bug or race condition, then on\n// navigation the build comparision would fail and trigger an MPA navigation.\nlet globalBuildId: string = ''\n\nexport function setAppBuildId(buildId: string) {\n globalBuildId = buildId\n}\n\nexport function getAppBuildId(): string {\n return globalBuildId\n}\n"],"names":["getAppBuildId","setAppBuildId","globalBuildId","buildId"],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,wDAAwD;AACxD,EAAE;AACF,+EAA+E;AAC/E,4EAA4E;AAC5E,sCAAsC;AAEtC,0EAA0E;AAC1E,sEAAsE;AACtE,6EAA6E;AAC7E,yEAAyE;AACzE,6EAA6E;;;;;;;;;;;;;;;;IAO7DA,aAAa;eAAbA;;IAJAC,aAAa;eAAbA;;;AAFhB,IAAIC,gBAAwB;AAErB,SAASD,cAAcE,OAAe;IAC3CD,gBAAgBC;AAClB;AAEO,SAASH;IACd,OAAOE;AACT","ignoreList":[0]}

View File

@@ -0,0 +1 @@
export declare function callServer(actionId: string, actionArgs: any[]): Promise<unknown>;

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "callServer", {
enumerable: true,
get: function() {
return callServer;
}
});
const _react = require("react");
const _routerreducertypes = require("./components/router-reducer/router-reducer-types");
const _useactionqueue = require("./components/use-action-queue");
async function callServer(actionId, actionArgs) {
return new Promise((resolve, reject)=>{
(0, _react.startTransition)(()=>{
(0, _useactionqueue.dispatchAppRouterAction)({
type: _routerreducertypes.ACTION_SERVER_ACTION,
actionId,
actionArgs,
resolve,
reject
});
});
});
}
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=app-call-server.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/app-call-server.ts"],"sourcesContent":["import { startTransition } from 'react'\nimport { ACTION_SERVER_ACTION } from './components/router-reducer/router-reducer-types'\nimport { dispatchAppRouterAction } from './components/use-action-queue'\n\nexport async function callServer(actionId: string, actionArgs: any[]) {\n return new Promise((resolve, reject) => {\n startTransition(() => {\n dispatchAppRouterAction({\n type: ACTION_SERVER_ACTION,\n actionId,\n actionArgs,\n resolve,\n reject,\n })\n })\n })\n}\n"],"names":["callServer","actionId","actionArgs","Promise","resolve","reject","startTransition","dispatchAppRouterAction","type","ACTION_SERVER_ACTION"],"mappings":";;;;+BAIsBA;;;eAAAA;;;uBAJU;oCACK;gCACG;AAEjC,eAAeA,WAAWC,QAAgB,EAAEC,UAAiB;IAClE,OAAO,IAAIC,QAAQ,CAACC,SAASC;QAC3BC,IAAAA,sBAAe,EAAC;YACdC,IAAAA,uCAAuB,EAAC;gBACtBC,MAAMC,wCAAoB;gBAC1BR;gBACAC;gBACAE;gBACAC;YACF;QACF;IACF;AACF","ignoreList":[0]}

View File

@@ -0,0 +1,3 @@
import { type FormProps } from '../form-shared';
export type { FormProps };
export default function Form({ replace, scroll, prefetch: prefetchProp, ref: externalRef, ...props }: FormProps): import("react/jsx-runtime").JSX.Element;

View File

@@ -0,0 +1,158 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return Form;
}
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _addbasepath = require("../add-base-path");
const _usemergedref = require("../use-merged-ref");
const _approutercontextsharedruntime = require("../../shared/lib/app-router-context.shared-runtime");
const _formshared = require("../form-shared");
const _links = require("../components/links");
const _types = require("../components/segment-cache/types");
function Form({ replace, scroll, prefetch: prefetchProp, ref: externalRef, ...props }) {
const router = (0, _react.useContext)(_approutercontextsharedruntime.AppRouterContext);
const actionProp = props.action;
const isNavigatingForm = typeof actionProp === 'string';
// Validate `action`
if (process.env.NODE_ENV === 'development') {
if (isNavigatingForm) {
(0, _formshared.checkFormActionUrl)(actionProp, 'action');
}
}
// Validate `prefetch`
if (process.env.NODE_ENV === 'development') {
if (!(prefetchProp === undefined || prefetchProp === false || prefetchProp === null)) {
console.error('The `prefetch` prop of <Form> must be `false` or `null`');
}
if (prefetchProp !== undefined && !isNavigatingForm) {
console.error('Passing `prefetch` to a <Form> whose `action` is a function has no effect.');
}
}
// TODO(runtime-ppr): allow runtime prefetches in Form
const prefetch = prefetchProp === false || prefetchProp === null ? prefetchProp : null;
// Validate `scroll` and `replace`
if (process.env.NODE_ENV === 'development') {
if (!isNavigatingForm && (replace !== undefined || scroll !== undefined)) {
console.error('Passing `replace` or `scroll` to a <Form> whose `action` is a function has no effect.\n' + 'See the relevant docs to learn how to control this behavior for navigations triggered from actions:\n' + ' `redirect()` - https://nextjs.org/docs/app/api-reference/functions/redirect#parameters\n' + ' `router.replace()` - https://nextjs.org/docs/app/api-reference/functions/use-router#userouter\n');
}
}
// Clean up any unsupported form props (and warn if present)
for (const key of _formshared.DISALLOWED_FORM_PROPS){
if (key in props) {
if (process.env.NODE_ENV === 'development') {
console.error(`<Form> does not support changing \`${key}\`. ` + (isNavigatingForm ? `If you'd like to use it to perform a mutation, consider making \`action\` a function instead.\n` + `Learn more: https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations` : ''));
}
delete props[key];
}
}
const isPrefetchEnabled = // if we don't have an action path, we can't prefetch anything.
!!router && isNavigatingForm && prefetch === null;
const observeFormVisibilityOnMount = (0, _react.useCallback)((element)=>{
if (isPrefetchEnabled && router !== null) {
(0, _links.mountFormInstance)(element, actionProp, router, // We default to PPR. We'll discover whether or not the route supports it with the initial prefetch.
_types.FetchStrategy.PPR);
}
return ()=>{
(0, _links.unmountPrefetchableInstance)(element);
};
}, [
isPrefetchEnabled,
actionProp,
router
]);
const mergedRef = (0, _usemergedref.useMergedRef)(observeFormVisibilityOnMount, externalRef ?? null);
if (!isNavigatingForm) {
return /*#__PURE__*/ (0, _jsxruntime.jsx)("form", {
...props,
ref: mergedRef
});
}
const actionHref = (0, _addbasepath.addBasePath)(actionProp);
return /*#__PURE__*/ (0, _jsxruntime.jsx)("form", {
...props,
ref: mergedRef,
action: actionHref,
onSubmit: (event)=>onFormSubmit(event, {
router,
actionHref,
replace,
scroll,
onSubmit: props.onSubmit
})
});
}
function onFormSubmit(event, { actionHref, onSubmit, replace, scroll, router }) {
if (typeof onSubmit === 'function') {
onSubmit(event);
// if the user called event.preventDefault(), do nothing.
// (this matches what Link does for `onClick`)
if (event.defaultPrevented) {
return;
}
}
if (!router) {
// Form was somehow used outside of the router (but not in pages, the implementation is forked!).
// We can't perform a soft navigation, so let the native submit handling do its thing.
return;
}
const formElement = event.currentTarget;
const submitter = event.nativeEvent.submitter;
let action = actionHref;
if (submitter) {
if (process.env.NODE_ENV === 'development') {
// the way server actions are encoded (e.g. `formMethod="post")
// causes some unnecessary dev-mode warnings from `hasUnsupportedSubmitterAttributes`.
// we'd bail out anyway, but we just do it silently.
if (hasReactServerActionAttributes(submitter)) {
return;
}
}
if ((0, _formshared.hasUnsupportedSubmitterAttributes)(submitter)) {
return;
}
// client actions have `formAction="javascript:..."`. We obviously can't prefetch/navigate to that.
if ((0, _formshared.hasReactClientActionAttributes)(submitter)) {
return;
}
// If the submitter specified an alternate formAction,
// use that URL instead -- this is what a native form would do.
// NOTE: `submitter.formAction` is unreliable, because it will give us `location.href` if it *wasn't* set
// NOTE: this should not have `basePath` added, because we can't add it before hydration
const submitterFormAction = submitter.getAttribute('formAction');
if (submitterFormAction !== null) {
if (process.env.NODE_ENV === 'development') {
(0, _formshared.checkFormActionUrl)(submitterFormAction, 'formAction');
}
action = submitterFormAction;
}
}
const targetUrl = (0, _formshared.createFormSubmitDestinationUrl)(action, formElement);
// Finally, no more reasons for bailing out.
event.preventDefault();
const method = replace ? 'replace' : 'push';
const targetHref = targetUrl.href;
router[method](targetHref, {
scroll
});
}
function hasReactServerActionAttributes(submitter) {
// https://github.com/facebook/react/blob/942eb80381b96f8410eab1bef1c539bed1ab0eb1/packages/react-client/src/ReactFlightReplyClient.js#L931-L934
const name = submitter.getAttribute('name');
return name && (name.startsWith('$ACTION_ID_') || name.startsWith('$ACTION_REF_'));
}
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=form.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,192 @@
import React from 'react';
import type { UrlObject } from 'url';
type Url = string | UrlObject;
type OnNavigateEventHandler = (event: {
preventDefault: () => void;
}) => void;
type InternalLinkProps = {
/**
* **Required**. The path or URL to navigate to. It can also be an object (similar to `URL`).
*
* @example
* ```tsx
* // Navigate to /dashboard:
* <Link href="/dashboard">Dashboard</Link>
*
* // Navigate to /about?name=test:
* <Link href={{ pathname: '/about', query: { name: 'test' } }}>
* About
* </Link>
* ```
*
* @remarks
* - For external URLs, use a fully qualified URL such as `https://...`.
* - In the App Router, dynamic routes must not include bracketed segments in `href`.
*/
href: Url;
/**
* @deprecated v10.0.0: `href` props pointing to a dynamic route are
* automatically resolved and no longer require the `as` prop.
*/
as?: Url;
/**
* Replace the current `history` state instead of adding a new URL into the stack.
*
* @defaultValue `false`
*
* @example
* ```tsx
* <Link href="/about" replace>
* About (replaces the history state)
* </Link>
* ```
*/
replace?: boolean;
/**
* Whether to override the default scroll behavior. If `true`, Next.js attempts to maintain
* the scroll position if the newly navigated page is still visible. If not, it scrolls to the top.
*
* If `false`, Next.js will not modify the scroll behavior at all.
*
* @defaultValue `true`
*
* @example
* ```tsx
* <Link href="/dashboard" scroll={false}>
* No auto scroll
* </Link>
* ```
*/
scroll?: boolean;
/**
* Update the path of the current page without rerunning data fetching methods
* like `getStaticProps`, `getServerSideProps`, or `getInitialProps`.
*
* @remarks
* `shallow` only applies to the Pages Router. For the App Router, see the
* [following documentation](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#using-the-native-history-api).
*
* @defaultValue `false`
*
* @example
* ```tsx
* <Link href="/blog" shallow>
* Shallow navigation
* </Link>
* ```
*/
shallow?: boolean;
/**
* Forces `Link` to pass its `href` to the child component. Useful if the child is a custom
* component that wraps an `<a>` tag, or if you're using certain styling libraries.
*
* @defaultValue `false`
*
* @example
* ```tsx
* <Link href="/dashboard" passHref legacyBehavior>
* <MyStyledAnchor>Dashboard</MyStyledAnchor>
* </Link>
* ```
*/
passHref?: boolean;
/**
* Prefetch the page in the background.
* Any `<Link />` that is in the viewport (initially or through scroll) will be prefetched.
* Prefetch can be disabled by passing `prefetch={false}`.
*
* @remarks
* Prefetching is only enabled in production.
*
* - In the **App Router**:
* - `"auto"`, `null`, `undefined` (default): Prefetch behavior depends on static vs dynamic routes:
* - Static routes: fully prefetched
* - Dynamic routes: partial prefetch to the nearest segment with a `loading.js`
* - `true`: Always prefetch the full route and data.
* - `false`: Disable prefetching on both viewport and hover.
* - In the **Pages Router**:
* - `true` (default): Prefetches the route and data in the background on viewport or hover.
* - `false`: Prefetch only on hover, not on viewport.
*
* @defaultValue `true` (Pages Router) or `null` (App Router)
*
* @example
* ```tsx
* <Link href="/dashboard" prefetch={false}>
* Dashboard
* </Link>
* ```
*/
prefetch?: boolean | 'auto' | null;
/**
* (unstable) Switch to a full prefetch on hover. Effectively the same as
* updating the prefetch prop to `true` in a mouse event.
*/
unstable_dynamicOnHover?: boolean;
/**
* The active locale is automatically prepended in the Pages Router. `locale` allows for providing
* a different locale, or can be set to `false` to opt out of automatic locale behavior.
*
* @remarks
* Note: locale only applies in the Pages Router and is ignored in the App Router.
*
* @example
* ```tsx
* // Use the 'fr' locale:
* <Link href="/about" locale="fr">
* About (French)
* </Link>
*
* // Disable locale prefix:
* <Link href="/about" locale={false}>
* About (no locale prefix)
* </Link>
* ```
*/
locale?: string | false;
/**
* Enable legacy link behavior.
*
* @deprecated This will be removed in a future version
* @defaultValue `false`
* @see https://github.com/vercel/next.js/commit/489e65ed98544e69b0afd7e0cfc3f9f6c2b803b7
*/
legacyBehavior?: boolean;
/**
* Optional event handler for when the mouse pointer is moved onto the `<Link>`.
*/
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
/**
* Optional event handler for when the `<Link>` is touched.
*/
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
/**
* Optional event handler for when the `<Link>` is clicked.
*/
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
/**
* Optional event handler for when the `<Link>` is navigated.
*/
onNavigate?: OnNavigateEventHandler;
};
export type LinkProps<RouteInferType = any> = InternalLinkProps;
/**
* A React component that extends the HTML `<a>` element to provide
* [prefetching](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#2-prefetching)
* and client-side navigation. This is the primary way to navigate between routes in Next.js.
*
* @remarks
* - Prefetching is only enabled in production.
*
* @see https://nextjs.org/docs/app/api-reference/components/link
*/
export default function LinkComponent(props: LinkProps & {
children: React.ReactNode;
ref: React.Ref<HTMLAnchorElement>;
}): import("react/jsx-runtime").JSX.Element;
export declare const useLinkStatus: () => {
pending: boolean;
} | {
pending: boolean;
};
export {};

View File

@@ -0,0 +1,406 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
default: null,
useLinkStatus: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
/**
* A React component that extends the HTML `<a>` element to provide
* [prefetching](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#2-prefetching)
* and client-side navigation. This is the primary way to navigate between routes in Next.js.
*
* @remarks
* - Prefetching is only enabled in production.
*
* @see https://nextjs.org/docs/app/api-reference/components/link
*/ default: function() {
return LinkComponent;
},
useLinkStatus: function() {
return useLinkStatus;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _jsxruntime = require("react/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _formaturl = require("../../shared/lib/router/utils/format-url");
const _approutercontextsharedruntime = require("../../shared/lib/app-router-context.shared-runtime");
const _usemergedref = require("../use-merged-ref");
const _utils = require("../../shared/lib/utils");
const _addbasepath = require("../add-base-path");
const _warnonce = require("../../shared/lib/utils/warn-once");
const _links = require("../components/links");
const _islocalurl = require("../../shared/lib/router/utils/is-local-url");
const _types = require("../components/segment-cache/types");
const _erroronce = require("../../shared/lib/utils/error-once");
function isModifiedEvent(event) {
const eventTarget = event.currentTarget;
const target = eventTarget.getAttribute('target');
return target && target !== '_self' || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || // triggers resource download
event.nativeEvent && event.nativeEvent.which === 2;
}
function linkClicked(e, href, as, linkInstanceRef, replace, scroll, onNavigate) {
if (typeof window !== 'undefined') {
const { nodeName } = e.currentTarget;
// anchors inside an svg have a lowercase nodeName
const isAnchorNodeName = nodeName.toUpperCase() === 'A';
if (isAnchorNodeName && isModifiedEvent(e) || e.currentTarget.hasAttribute('download')) {
// ignore click for browsers default behavior
return;
}
if (!(0, _islocalurl.isLocalURL)(href)) {
if (replace) {
// browser default behavior does not replace the history state
// so we need to do it manually
e.preventDefault();
location.replace(href);
}
// ignore click for browsers default behavior
return;
}
e.preventDefault();
if (onNavigate) {
let isDefaultPrevented = false;
onNavigate({
preventDefault: ()=>{
isDefaultPrevented = true;
}
});
if (isDefaultPrevented) {
return;
}
}
const { dispatchNavigateAction } = require('../components/app-router-instance');
_react.default.startTransition(()=>{
dispatchNavigateAction(as || href, replace ? 'replace' : 'push', scroll ?? true, linkInstanceRef.current);
});
}
}
function formatStringOrUrl(urlObjOrString) {
if (typeof urlObjOrString === 'string') {
return urlObjOrString;
}
return (0, _formaturl.formatUrl)(urlObjOrString);
}
function LinkComponent(props) {
const [linkStatus, setOptimisticLinkStatus] = (0, _react.useOptimistic)(_links.IDLE_LINK_STATUS);
let children;
const linkInstanceRef = (0, _react.useRef)(null);
const { href: hrefProp, as: asProp, children: childrenProp, prefetch: prefetchProp = null, passHref, replace, shallow, scroll, onClick, onMouseEnter: onMouseEnterProp, onTouchStart: onTouchStartProp, legacyBehavior = false, onNavigate, ref: forwardedRef, unstable_dynamicOnHover, ...restProps } = props;
children = childrenProp;
if (legacyBehavior && (typeof children === 'string' || typeof children === 'number')) {
children = /*#__PURE__*/ (0, _jsxruntime.jsx)("a", {
children: children
});
}
const router = _react.default.useContext(_approutercontextsharedruntime.AppRouterContext);
const prefetchEnabled = prefetchProp !== false;
const fetchStrategy = prefetchProp !== false ? getFetchStrategyFromPrefetchProp(prefetchProp) : _types.FetchStrategy.PPR;
if (process.env.NODE_ENV !== 'production') {
function createPropError(args) {
return Object.defineProperty(new Error(`Failed prop type: The prop \`${args.key}\` expects a ${args.expected} in \`<Link>\`, but got \`${args.actual}\` instead.` + (typeof window !== 'undefined' ? "\nOpen your browser's console to view the Component stack trace." : '')), "__NEXT_ERROR_CODE", {
value: "E319",
enumerable: false,
configurable: true
});
}
// TypeScript trick for type-guarding:
const requiredPropsGuard = {
href: true
};
const requiredProps = Object.keys(requiredPropsGuard);
requiredProps.forEach((key)=>{
if (key === 'href') {
if (props[key] == null || typeof props[key] !== 'string' && typeof props[key] !== 'object') {
throw createPropError({
key,
expected: '`string` or `object`',
actual: props[key] === null ? 'null' : typeof props[key]
});
}
} else {
// TypeScript trick for type-guarding:
const _ = key;
}
});
// TypeScript trick for type-guarding:
const optionalPropsGuard = {
as: true,
replace: true,
scroll: true,
shallow: true,
passHref: true,
prefetch: true,
unstable_dynamicOnHover: true,
onClick: true,
onMouseEnter: true,
onTouchStart: true,
legacyBehavior: true,
onNavigate: true
};
const optionalProps = Object.keys(optionalPropsGuard);
optionalProps.forEach((key)=>{
const valType = typeof props[key];
if (key === 'as') {
if (props[key] && valType !== 'string' && valType !== 'object') {
throw createPropError({
key,
expected: '`string` or `object`',
actual: valType
});
}
} else if (key === 'onClick' || key === 'onMouseEnter' || key === 'onTouchStart' || key === 'onNavigate') {
if (props[key] && valType !== 'function') {
throw createPropError({
key,
expected: '`function`',
actual: valType
});
}
} else if (key === 'replace' || key === 'scroll' || key === 'shallow' || key === 'passHref' || key === 'legacyBehavior' || key === 'unstable_dynamicOnHover') {
if (props[key] != null && valType !== 'boolean') {
throw createPropError({
key,
expected: '`boolean`',
actual: valType
});
}
} else if (key === 'prefetch') {
if (props[key] != null && valType !== 'boolean' && props[key] !== 'auto') {
throw createPropError({
key,
expected: '`boolean | "auto"`',
actual: valType
});
}
} else {
// TypeScript trick for type-guarding:
const _ = key;
}
});
}
if (process.env.NODE_ENV !== 'production') {
if (props.locale) {
(0, _warnonce.warnOnce)('The `locale` prop is not supported in `next/link` while using the `app` router. Read more about app router internalization: https://nextjs.org/docs/app/building-your-application/routing/internationalization');
}
if (!asProp) {
let href;
if (typeof hrefProp === 'string') {
href = hrefProp;
} else if (typeof hrefProp === 'object' && typeof hrefProp.pathname === 'string') {
href = hrefProp.pathname;
}
if (href) {
const hasDynamicSegment = href.split('/').some((segment)=>segment.startsWith('[') && segment.endsWith(']'));
if (hasDynamicSegment) {
throw Object.defineProperty(new Error(`Dynamic href \`${href}\` found in <Link> while using the \`/app\` router, this is not supported. Read more: https://nextjs.org/docs/messages/app-dir-dynamic-href`), "__NEXT_ERROR_CODE", {
value: "E267",
enumerable: false,
configurable: true
});
}
}
}
}
const { href, as } = _react.default.useMemo(()=>{
const resolvedHref = formatStringOrUrl(hrefProp);
return {
href: resolvedHref,
as: asProp ? formatStringOrUrl(asProp) : resolvedHref
};
}, [
hrefProp,
asProp
]);
// This will return the first child, if multiple are provided it will throw an error
let child;
if (legacyBehavior) {
if (children?.$$typeof === Symbol.for('react.lazy')) {
throw Object.defineProperty(new Error(`\`<Link legacyBehavior>\` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's \`<a>\` tag.`), "__NEXT_ERROR_CODE", {
value: "E863",
enumerable: false,
configurable: true
});
}
if (process.env.NODE_ENV === 'development') {
if (onClick) {
console.warn(`"onClick" was passed to <Link> with \`href\` of \`${hrefProp}\` but "legacyBehavior" was set. The legacy behavior requires onClick be set on the child of next/link`);
}
if (onMouseEnterProp) {
console.warn(`"onMouseEnter" was passed to <Link> with \`href\` of \`${hrefProp}\` but "legacyBehavior" was set. The legacy behavior requires onMouseEnter be set on the child of next/link`);
}
try {
child = _react.default.Children.only(children);
} catch (err) {
if (!children) {
throw Object.defineProperty(new Error(`No children were passed to <Link> with \`href\` of \`${hrefProp}\` but one child is required https://nextjs.org/docs/messages/link-no-children`), "__NEXT_ERROR_CODE", {
value: "E320",
enumerable: false,
configurable: true
});
}
throw Object.defineProperty(new Error(`Multiple children were passed to <Link> with \`href\` of \`${hrefProp}\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children` + (typeof window !== 'undefined' ? " \nOpen your browser's console to view the Component stack trace." : '')), "__NEXT_ERROR_CODE", {
value: "E266",
enumerable: false,
configurable: true
});
}
} else {
child = _react.default.Children.only(children);
}
} else {
if (process.env.NODE_ENV === 'development') {
if (children?.type === 'a') {
throw Object.defineProperty(new Error('Invalid <Link> with <a> child. Please remove <a> or use <Link legacyBehavior>.\nLearn more: https://nextjs.org/docs/messages/invalid-new-link-with-extra-anchor'), "__NEXT_ERROR_CODE", {
value: "E209",
enumerable: false,
configurable: true
});
}
}
}
const childRef = legacyBehavior ? child && typeof child === 'object' && child.ref : forwardedRef;
// Use a callback ref to attach an IntersectionObserver to the anchor tag on
// mount. In the future we will also use this to keep track of all the
// currently mounted <Link> instances, e.g. so we can re-prefetch them after
// a revalidation or refresh.
const observeLinkVisibilityOnMount = _react.default.useCallback((element)=>{
if (router !== null) {
linkInstanceRef.current = (0, _links.mountLinkInstance)(element, href, router, fetchStrategy, prefetchEnabled, setOptimisticLinkStatus);
}
return ()=>{
if (linkInstanceRef.current) {
(0, _links.unmountLinkForCurrentNavigation)(linkInstanceRef.current);
linkInstanceRef.current = null;
}
(0, _links.unmountPrefetchableInstance)(element);
};
}, [
prefetchEnabled,
href,
router,
fetchStrategy,
setOptimisticLinkStatus
]);
const mergedRef = (0, _usemergedref.useMergedRef)(observeLinkVisibilityOnMount, childRef);
const childProps = {
ref: mergedRef,
onClick (e) {
if (process.env.NODE_ENV !== 'production') {
if (!e) {
throw Object.defineProperty(new Error(`Component rendered inside next/link has to pass click event to "onClick" prop.`), "__NEXT_ERROR_CODE", {
value: "E312",
enumerable: false,
configurable: true
});
}
}
if (!legacyBehavior && typeof onClick === 'function') {
onClick(e);
}
if (legacyBehavior && child.props && typeof child.props.onClick === 'function') {
child.props.onClick(e);
}
if (!router) {
return;
}
if (e.defaultPrevented) {
return;
}
linkClicked(e, href, as, linkInstanceRef, replace, scroll, onNavigate);
},
onMouseEnter (e) {
if (!legacyBehavior && typeof onMouseEnterProp === 'function') {
onMouseEnterProp(e);
}
if (legacyBehavior && child.props && typeof child.props.onMouseEnter === 'function') {
child.props.onMouseEnter(e);
}
if (!router) {
return;
}
if (!prefetchEnabled || process.env.NODE_ENV === 'development') {
return;
}
const upgradeToDynamicPrefetch = unstable_dynamicOnHover === true;
(0, _links.onNavigationIntent)(e.currentTarget, upgradeToDynamicPrefetch);
},
onTouchStart: process.env.__NEXT_LINK_NO_TOUCH_START ? undefined : function onTouchStart(e) {
if (!legacyBehavior && typeof onTouchStartProp === 'function') {
onTouchStartProp(e);
}
if (legacyBehavior && child.props && typeof child.props.onTouchStart === 'function') {
child.props.onTouchStart(e);
}
if (!router) {
return;
}
if (!prefetchEnabled) {
return;
}
const upgradeToDynamicPrefetch = unstable_dynamicOnHover === true;
(0, _links.onNavigationIntent)(e.currentTarget, upgradeToDynamicPrefetch);
}
};
// If the url is absolute, we can bypass the logic to prepend the basePath.
if ((0, _utils.isAbsoluteUrl)(as)) {
childProps.href = as;
} else if (!legacyBehavior || passHref || child.type === 'a' && !('href' in child.props)) {
childProps.href = (0, _addbasepath.addBasePath)(as);
}
let link;
if (legacyBehavior) {
if (process.env.NODE_ENV === 'development') {
(0, _erroronce.errorOnce)('`legacyBehavior` is deprecated and will be removed in a future ' + 'release. A codemod is available to upgrade your components:\n\n' + 'npx @next/codemod@latest new-link .\n\n' + 'Learn more: https://nextjs.org/docs/app/building-your-application/upgrading/codemods#remove-a-tags-from-link-components');
}
link = /*#__PURE__*/ _react.default.cloneElement(child, childProps);
} else {
link = /*#__PURE__*/ (0, _jsxruntime.jsx)("a", {
...restProps,
...childProps,
children: children
});
}
return /*#__PURE__*/ (0, _jsxruntime.jsx)(LinkStatusContext.Provider, {
value: linkStatus,
children: link
});
}
const LinkStatusContext = /*#__PURE__*/ (0, _react.createContext)(_links.IDLE_LINK_STATUS);
const useLinkStatus = ()=>{
return (0, _react.useContext)(LinkStatusContext);
};
function getFetchStrategyFromPrefetchProp(prefetchProp) {
if (process.env.__NEXT_CACHE_COMPONENTS) {
if (prefetchProp === true) {
return _types.FetchStrategy.Full;
}
// `null` or `"auto"`: this is the default "auto" mode, where we will prefetch partially if the link is in the viewport.
// This will also include invalid prop values that don't match the types specified here.
// (although those should've been filtered out by prop validation in dev)
prefetchProp;
return _types.FetchStrategy.PPR;
} else {
return prefetchProp === null || prefetchProp === 'auto' ? _types.FetchStrategy.PPR : // To preserve backwards-compatibility, anything other than `false`, `null`, or `"auto"` results in a full prefetch.
// (although invalid values should've been filtered out by prop validation in dev)
_types.FetchStrategy.Full;
}
}
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=link.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
import type { ComponentProps } from 'react';
import ClientLinkComponent, { type LinkProps, useLinkStatus } from './link';
export default function LinkComponent(props: ComponentProps<typeof ClientLinkComponent>): import("react/jsx-runtime").JSX.Element;
export { type LinkProps, useLinkStatus };

View File

@@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
default: null,
useLinkStatus: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
default: function() {
return LinkComponent;
},
useLinkStatus: function() {
return _link.useLinkStatus;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _jsxruntime = require("react/jsx-runtime");
const _link = /*#__PURE__*/ _interop_require_wildcard._(require("./link"));
function LinkComponent(props) {
const isLegacyBehavior = props.legacyBehavior;
const childIsHostComponent = typeof props.children === 'string' || typeof props.children === 'number' || typeof props.children?.type === 'string';
const childIsClientComponent = props.children?.type?.$$typeof === Symbol.for('react.client.reference');
if (isLegacyBehavior && !childIsHostComponent && !childIsClientComponent) {
if (props.children?.type?.$$typeof === Symbol.for('react.lazy')) {
console.error(`Using a Lazy Component as a direct child of \`<Link legacyBehavior>\` from a Server Component is not supported. If you need legacyBehavior, wrap your Lazy Component in a Client Component that renders the Link's \`<a>\` tag.`);
} else {
console.error(`Using a Server Component as a direct child of \`<Link legacyBehavior>\` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's \`<a>\` tag.`);
}
}
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_link.default, {
...props
});
}
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=link.react-server.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/app-dir/link.react-server.tsx"],"sourcesContent":["import type { ComponentProps } from 'react'\nimport ClientLinkComponent, { type LinkProps, useLinkStatus } from './link'\n\nexport default function LinkComponent(\n props: ComponentProps<typeof ClientLinkComponent>\n) {\n const isLegacyBehavior = props.legacyBehavior\n const childIsHostComponent =\n typeof props.children === 'string' ||\n typeof props.children === 'number' ||\n typeof (props.children as any)?.type === 'string'\n const childIsClientComponent =\n (props.children as any)?.type?.$$typeof ===\n Symbol.for('react.client.reference')\n\n if (isLegacyBehavior && !childIsHostComponent && !childIsClientComponent) {\n if ((props.children as any)?.type?.$$typeof === Symbol.for('react.lazy')) {\n console.error(\n `Using a Lazy Component as a direct child of \\`<Link legacyBehavior>\\` from a Server Component is not supported. If you need legacyBehavior, wrap your Lazy Component in a Client Component that renders the Link's \\`<a>\\` tag.`\n )\n } else {\n console.error(\n `Using a Server Component as a direct child of \\`<Link legacyBehavior>\\` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's \\`<a>\\` tag.`\n )\n }\n }\n\n return <ClientLinkComponent {...props} />\n}\n\nexport { type LinkProps, useLinkStatus }\n"],"names":["LinkComponent","useLinkStatus","props","isLegacyBehavior","legacyBehavior","childIsHostComponent","children","type","childIsClientComponent","$$typeof","Symbol","for","console","error","ClientLinkComponent"],"mappings":";;;;;;;;;;;;;;;IAGA,OAyBC;eAzBuBA;;IA2BCC,aAAa;eAAbA,mBAAa;;;;;gEA7B6B;AAEpD,SAASD,cACtBE,KAAiD;IAEjD,MAAMC,mBAAmBD,MAAME,cAAc;IAC7C,MAAMC,uBACJ,OAAOH,MAAMI,QAAQ,KAAK,YAC1B,OAAOJ,MAAMI,QAAQ,KAAK,YAC1B,OAAQJ,MAAMI,QAAQ,EAAUC,SAAS;IAC3C,MAAMC,yBACJ,AAACN,MAAMI,QAAQ,EAAUC,MAAME,aAC/BC,OAAOC,GAAG,CAAC;IAEb,IAAIR,oBAAoB,CAACE,wBAAwB,CAACG,wBAAwB;QACxE,IAAI,AAACN,MAAMI,QAAQ,EAAUC,MAAME,aAAaC,OAAOC,GAAG,CAAC,eAAe;YACxEC,QAAQC,KAAK,CACX,CAAC,+NAA+N,CAAC;QAErO,OAAO;YACLD,QAAQC,KAAK,CACX,CAAC,2MAA2M,CAAC;QAEjN;IACF;IAEA,qBAAO,qBAACC,aAAmB;QAAE,GAAGZ,KAAK;;AACvC","ignoreList":[0]}

View File

@@ -0,0 +1 @@
export declare const findSourceMapURL: ((filename: string) => string | null) | undefined;

View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "findSourceMapURL", {
enumerable: true,
get: function() {
return findSourceMapURL;
}
});
const basePath = process.env.__NEXT_ROUTER_BASEPATH || '';
const pathname = `${basePath}/__nextjs_source-map`;
const findSourceMapURL = process.env.NODE_ENV === 'development' ? function findSourceMapURL(filename) {
if (filename === '') {
return null;
}
if (filename.startsWith(document.location.origin) && filename.includes('/_next/static')) {
// This is a request for a client chunk. This can only happen when
// using Turbopack. In this case, since we control how those source
// maps are generated, we can safely assume that the sourceMappingURL
// is relative to the filename, with an added `.map` extension. The
// browser can just request this file, and it gets served through the
// normal dev server, without the need to route this through
// the `/__nextjs_source-map` dev middleware.
return `${filename}.map`;
}
const url = new URL(pathname, document.location.origin);
url.searchParams.set('filename', filename);
return url.href;
} : undefined;
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=app-find-source-map-url.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/app-find-source-map-url.ts"],"sourcesContent":["const basePath = process.env.__NEXT_ROUTER_BASEPATH || ''\nconst pathname = `${basePath}/__nextjs_source-map`\n\nexport const findSourceMapURL =\n process.env.NODE_ENV === 'development'\n ? function findSourceMapURL(filename: string): string | null {\n if (filename === '') {\n return null\n }\n\n if (\n filename.startsWith(document.location.origin) &&\n filename.includes('/_next/static')\n ) {\n // This is a request for a client chunk. This can only happen when\n // using Turbopack. In this case, since we control how those source\n // maps are generated, we can safely assume that the sourceMappingURL\n // is relative to the filename, with an added `.map` extension. The\n // browser can just request this file, and it gets served through the\n // normal dev server, without the need to route this through\n // the `/__nextjs_source-map` dev middleware.\n return `${filename}.map`\n }\n\n const url = new URL(pathname, document.location.origin)\n url.searchParams.set('filename', filename)\n\n return url.href\n }\n : undefined\n"],"names":["findSourceMapURL","basePath","process","env","__NEXT_ROUTER_BASEPATH","pathname","NODE_ENV","filename","startsWith","document","location","origin","includes","url","URL","searchParams","set","href","undefined"],"mappings":";;;;+BAGaA;;;eAAAA;;;AAHb,MAAMC,WAAWC,QAAQC,GAAG,CAACC,sBAAsB,IAAI;AACvD,MAAMC,WAAW,GAAGJ,SAAS,oBAAoB,CAAC;AAE3C,MAAMD,mBACXE,QAAQC,GAAG,CAACG,QAAQ,KAAK,gBACrB,SAASN,iBAAiBO,QAAgB;IACxC,IAAIA,aAAa,IAAI;QACnB,OAAO;IACT;IAEA,IACEA,SAASC,UAAU,CAACC,SAASC,QAAQ,CAACC,MAAM,KAC5CJ,SAASK,QAAQ,CAAC,kBAClB;QACA,kEAAkE;QAClE,mEAAmE;QACnE,qEAAqE;QACrE,mEAAmE;QACnE,qEAAqE;QACrE,4DAA4D;QAC5D,6CAA6C;QAC7C,OAAO,GAAGL,SAAS,IAAI,CAAC;IAC1B;IAEA,MAAMM,MAAM,IAAIC,IAAIT,UAAUI,SAASC,QAAQ,CAACC,MAAM;IACtDE,IAAIE,YAAY,CAACC,GAAG,CAAC,YAAYT;IAEjC,OAAOM,IAAII,IAAI;AACjB,IACAC","ignoreList":[0]}

View File

@@ -0,0 +1 @@
import '../build/polyfills/polyfill-module';

View File

@@ -0,0 +1,18 @@
// imports polyfill from `@next/polyfill-module` after build.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
require("../build/polyfills/polyfill-module");
// Only setup devtools in development
if (process.env.NODE_ENV !== 'production') {
require('../next-devtools/userspace/app/app-dev-overlay-setup');
}
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=app-globals.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/app-globals.ts"],"sourcesContent":["// imports polyfill from `@next/polyfill-module` after build.\nimport '../build/polyfills/polyfill-module'\n\n// Only setup devtools in development\nif (process.env.NODE_ENV !== 'production') {\n require('../next-devtools/userspace/app/app-dev-overlay-setup') as typeof import('../next-devtools/userspace/app/app-dev-overlay-setup')\n}\n"],"names":["process","env","NODE_ENV","require"],"mappings":"AAAA,6DAA6D;;;;;QACtD;AAEP,qCAAqC;AACrC,IAAIA,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACzCC,QAAQ;AACV","ignoreList":[0]}

View File

@@ -0,0 +1,19 @@
import './app-globals';
type FlightSegment = [isBootStrap: 0] | [isNotBootstrap: 1, responsePartial: string] | [isFormState: 2, formState: any] | [isBinary: 3, responseBase64Partial: string];
type NextFlight = Omit<Array<FlightSegment>, 'push'> & {
push: (seg: FlightSegment) => void;
};
declare global {
interface Window {
/**
* request ID, dev-only
*/
__next_r?: string;
__next_f: NextFlight;
}
}
export type ClientInstrumentationHooks = {
onRouterTransitionStart?: (url: string, navigationType: 'push' | 'replace' | 'traverse') => void;
};
export declare function hydrate(instrumentationHooks: ClientInstrumentationHooks | null, assetPrefix: string): Promise<void>;
export {};

View File

@@ -0,0 +1,269 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "hydrate", {
enumerable: true,
get: function() {
return hydrate;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _jsxruntime = require("react/jsx-runtime");
require("./app-globals");
const _client = /*#__PURE__*/ _interop_require_default._(require("react-dom/client"));
const _react = /*#__PURE__*/ _interop_require_default._(require("react"));
const _client1 = require("react-server-dom-webpack/client");
const _headmanagercontextsharedruntime = require("../shared/lib/head-manager-context.shared-runtime");
const _onrecoverableerror = require("./react-client-callbacks/on-recoverable-error");
const _errorboundarycallbacks = require("./react-client-callbacks/error-boundary-callbacks");
const _appcallserver = require("./app-call-server");
const _appfindsourcemapurl = require("./app-find-source-map-url");
const _approuterinstance = require("./components/app-router-instance");
const _approuter = /*#__PURE__*/ _interop_require_default._(require("./components/app-router"));
const _createinitialrouterstate = require("./components/router-reducer/create-initial-router-state");
const _approutercontextsharedruntime = require("../shared/lib/app-router-context.shared-runtime");
const _appbuildid = require("./app-build-id");
const _flightdatahelpers = require("./flight-data-helpers");
/// <reference types="react-dom/experimental" />
const createFromReadableStream = _client1.createFromReadableStream;
const createFromFetch = _client1.createFromFetch;
const appElement = document;
const encoder = new TextEncoder();
let initialServerDataBuffer = undefined;
let initialServerDataWriter = undefined;
let initialServerDataLoaded = false;
let initialServerDataFlushed = false;
let initialFormStateData = null;
function nextServerDataCallback(seg) {
if (seg[0] === 0) {
initialServerDataBuffer = [];
} else if (seg[0] === 1) {
if (!initialServerDataBuffer) throw Object.defineProperty(new Error('Unexpected server data: missing bootstrap script.'), "__NEXT_ERROR_CODE", {
value: "E18",
enumerable: false,
configurable: true
});
if (initialServerDataWriter) {
initialServerDataWriter.enqueue(encoder.encode(seg[1]));
} else {
initialServerDataBuffer.push(seg[1]);
}
} else if (seg[0] === 2) {
initialFormStateData = seg[1];
} else if (seg[0] === 3) {
if (!initialServerDataBuffer) throw Object.defineProperty(new Error('Unexpected server data: missing bootstrap script.'), "__NEXT_ERROR_CODE", {
value: "E18",
enumerable: false,
configurable: true
});
// Decode the base64 string back to binary data.
const binaryString = atob(seg[1]);
const decodedChunk = new Uint8Array(binaryString.length);
for(var i = 0; i < binaryString.length; i++){
decodedChunk[i] = binaryString.charCodeAt(i);
}
if (initialServerDataWriter) {
initialServerDataWriter.enqueue(decodedChunk);
} else {
initialServerDataBuffer.push(decodedChunk);
}
}
}
function isStreamErrorOrUnfinished(ctr) {
// If `desiredSize` is null, it means the stream is closed or errored. If it is lower than 0, the stream is still unfinished.
return ctr.desiredSize === null || ctr.desiredSize < 0;
}
// There might be race conditions between `nextServerDataRegisterWriter` and
// `DOMContentLoaded`. The former will be called when React starts to hydrate
// the root, the latter will be called when the DOM is fully loaded.
// For streaming, the former is called first due to partial hydration.
// For non-streaming, the latter can be called first.
// Hence, we use two variables `initialServerDataLoaded` and
// `initialServerDataFlushed` to make sure the writer will be closed and
// `initialServerDataBuffer` will be cleared in the right time.
function nextServerDataRegisterWriter(ctr) {
if (initialServerDataBuffer) {
initialServerDataBuffer.forEach((val)=>{
ctr.enqueue(typeof val === 'string' ? encoder.encode(val) : val);
});
if (initialServerDataLoaded && !initialServerDataFlushed) {
if (isStreamErrorOrUnfinished(ctr)) {
ctr.error(Object.defineProperty(new Error('The connection to the page was unexpectedly closed, possibly due to the stop button being clicked, loss of Wi-Fi, or an unstable internet connection.'), "__NEXT_ERROR_CODE", {
value: "E117",
enumerable: false,
configurable: true
}));
} else {
ctr.close();
}
initialServerDataFlushed = true;
initialServerDataBuffer = undefined;
}
}
initialServerDataWriter = ctr;
}
// When `DOMContentLoaded`, we can close all pending writers to finish hydration.
const DOMContentLoaded = function() {
if (initialServerDataWriter && !initialServerDataFlushed) {
initialServerDataWriter.close();
initialServerDataFlushed = true;
initialServerDataBuffer = undefined;
}
initialServerDataLoaded = true;
};
// It's possible that the DOM is already loaded.
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', DOMContentLoaded, false);
} else {
// Delayed in marco task to ensure it's executed later than hydration
setTimeout(DOMContentLoaded);
}
const nextServerDataLoadingGlobal = self.__next_f = self.__next_f || [];
// Consume all buffered chunks and clear the global data array right after to release memory.
// Otherwise it will be retained indefinitely.
nextServerDataLoadingGlobal.forEach(nextServerDataCallback);
nextServerDataLoadingGlobal.length = 0;
// Patch its push method so subsequent chunks are handled (but not actually pushed to the array).
nextServerDataLoadingGlobal.push = nextServerDataCallback;
const readable = new ReadableStream({
start (controller) {
nextServerDataRegisterWriter(controller);
}
});
if (process.env.NODE_ENV !== 'production') {
// @ts-expect-error
readable.name = 'hydration';
}
let debugChannel;
if (process.env.NODE_ENV !== 'production' && process.env.__NEXT_REACT_DEBUG_CHANNEL && typeof window !== 'undefined') {
const { createDebugChannel } = require('./dev/debug-channel');
debugChannel = createDebugChannel(undefined);
}
const clientResumeFetch = // @ts-expect-error
window.__NEXT_CLIENT_RESUME;
let initialServerResponse;
if (clientResumeFetch) {
initialServerResponse = Promise.resolve(createFromFetch(clientResumeFetch, {
callServer: _appcallserver.callServer,
findSourceMapURL: _appfindsourcemapurl.findSourceMapURL,
debugChannel
})).then(async (fallbackInitialRSCPayload)=>(0, _flightdatahelpers.createInitialRSCPayloadFromFallbackPrerender)(await clientResumeFetch, fallbackInitialRSCPayload));
} else {
initialServerResponse = createFromReadableStream(readable, {
callServer: _appcallserver.callServer,
findSourceMapURL: _appfindsourcemapurl.findSourceMapURL,
debugChannel,
startTime: 0
});
}
function ServerRoot({ initialRSCPayload, actionQueue, webSocket, staticIndicatorState }) {
const router = /*#__PURE__*/ (0, _jsxruntime.jsx)(_approuter.default, {
actionQueue: actionQueue,
globalErrorState: initialRSCPayload.G,
webSocket: webSocket,
staticIndicatorState: staticIndicatorState
});
if (process.env.NODE_ENV === 'development' && initialRSCPayload.m) {
// We provide missing slot information in a context provider only during development
// as we log some additional information about the missing slots in the console.
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_approutercontextsharedruntime.MissingSlotContext, {
value: initialRSCPayload.m,
children: router
});
}
return router;
}
const StrictModeIfEnabled = process.env.__NEXT_STRICT_MODE_APP ? _react.default.StrictMode : _react.default.Fragment;
function Root({ children }) {
if (process.env.__NEXT_TEST_MODE) {
// eslint-disable-next-line react-hooks/rules-of-hooks
_react.default.useEffect(()=>{
window.__NEXT_HYDRATED = true;
window.__NEXT_HYDRATED_AT = performance.now();
window.__NEXT_HYDRATED_CB?.();
}, []);
}
return children;
}
const enableTransitionIndicator = process.env.__NEXT_TRANSITION_INDICATOR;
function noDefaultTransitionIndicator() {
return ()=>{};
}
const reactRootOptions = {
onDefaultTransitionIndicator: enableTransitionIndicator ? undefined : noDefaultTransitionIndicator,
onRecoverableError: _onrecoverableerror.onRecoverableError,
onCaughtError: _errorboundarycallbacks.onCaughtError,
onUncaughtError: _errorboundarycallbacks.onUncaughtError
};
async function hydrate(instrumentationHooks, assetPrefix) {
let staticIndicatorState;
let webSocket;
if (process.env.NODE_ENV !== 'production') {
const { createWebSocket } = require('./dev/hot-reloader/app/web-socket');
staticIndicatorState = {
pathname: null,
appIsrManifest: null
};
webSocket = createWebSocket(assetPrefix, staticIndicatorState);
}
const initialRSCPayload = await initialServerResponse;
// setAppBuildId should be called only once, during JS initialization
// and before any components have hydrated.
(0, _appbuildid.setAppBuildId)(initialRSCPayload.b);
const initialTimestamp = Date.now();
const actionQueue = (0, _approuterinstance.createMutableActionQueue)((0, _createinitialrouterstate.createInitialRouterState)({
navigatedAt: initialTimestamp,
initialFlightData: initialRSCPayload.f,
initialCanonicalUrlParts: initialRSCPayload.c,
initialRenderedSearch: initialRSCPayload.q,
location: window.location
}), instrumentationHooks);
const reactEl = /*#__PURE__*/ (0, _jsxruntime.jsx)(StrictModeIfEnabled, {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_headmanagercontextsharedruntime.HeadManagerContext.Provider, {
value: {
appDir: true
},
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Root, {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(ServerRoot, {
initialRSCPayload: initialRSCPayload,
actionQueue: actionQueue,
webSocket: webSocket,
staticIndicatorState: staticIndicatorState
})
})
})
});
if (document.documentElement.id === '__next_error__') {
let element = reactEl;
// Server rendering failed, fall back to client-side rendering
if (process.env.NODE_ENV !== 'production') {
const { RootLevelDevOverlayElement } = require('../next-devtools/userspace/app/client-entry');
// Note this won't cause hydration mismatch because we are doing CSR w/o hydration
element = /*#__PURE__*/ (0, _jsxruntime.jsx)(RootLevelDevOverlayElement, {
children: element
});
}
_client.default.createRoot(appElement, reactRootOptions).render(element);
} else {
_react.default.startTransition(()=>{
_client.default.hydrateRoot(appElement, reactEl, {
...reactRootOptions,
formState: initialFormStateData
});
});
}
// TODO-APP: Remove this logic when Float has GC built-in in development.
if (process.env.NODE_ENV !== 'production') {
const { linkGc } = require('./app-link-gc');
linkGc();
}
}
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=app-index.js.map

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "linkGc", {
enumerable: true,
get: function() {
return linkGc;
}
});
function linkGc() {
// TODO-APP: Remove this logic when Float has GC built-in in development.
if (process.env.NODE_ENV !== 'production') {
const callback = (mutationList)=>{
for (const mutation of mutationList){
if (mutation.type === 'childList') {
for (const node of mutation.addedNodes){
if ('tagName' in node && node.tagName === 'LINK') {
const link = node;
if (link.dataset.precedence?.startsWith('next')) {
const href = link.getAttribute('href');
if (href) {
const [resource, version] = href.split('?v=', 2);
if (version) {
const currentOrigin = window.location.origin;
const allLinks = [
...document.querySelectorAll('link[href^="' + resource + '"]'),
// It's possible that the resource is a full URL or only pathname,
// so we need to remove the alternative href as well.
...document.querySelectorAll('link[href^="' + (resource.startsWith(currentOrigin) ? resource.slice(currentOrigin.length) : currentOrigin + resource) + '"]')
];
for (const otherLink of allLinks){
if (otherLink.dataset.precedence?.startsWith('next')) {
const otherHref = otherLink.getAttribute('href');
if (otherHref) {
const [, otherVersion] = otherHref.split('?v=', 2);
if (!otherVersion || +otherVersion < +version) {
// Delay the removal of the stylesheet to avoid FOUC
// caused by `@font-face` rules, as they seem to be
// a couple of ticks delayed between the old and new
// styles being swapped even if the font is cached.
setTimeout(()=>{
otherLink.remove();
}, 5);
const preloadLink = document.querySelector(`link[rel="preload"][as="style"][href="${otherHref}"]`);
if (preloadLink) {
preloadLink.remove();
}
}
}
}
}
}
}
}
}
}
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
observer.observe(document.head, {
childList: true
});
}
}
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=app-link-gc.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
import './app-webpack';

View File

@@ -0,0 +1,29 @@
// TODO-APP: hydration warning
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
require("./app-webpack");
const _nextdevtools = require("next/dist/compiled/next-devtools");
const _appbootstrap = require("./app-bootstrap");
const _stitchederror = require("../next-devtools/userspace/app/errors/stitched-error");
const _onrecoverableerror = require("./react-client-callbacks/on-recoverable-error");
// eslint-disable-next-line @next/internal/typechecked-require
const instrumentationHooks = require('../lib/require-instrumentation-client');
(0, _appbootstrap.appBootstrap)((assetPrefix)=>{
const { hydrate } = require('./app-index');
try {
hydrate(instrumentationHooks, assetPrefix);
} finally{
const enableCacheIndicator = process.env.__NEXT_CACHE_COMPONENTS;
(0, _nextdevtools.renderAppDevOverlay)(_stitchederror.getOwnerStack, _onrecoverableerror.isRecoverableError, enableCacheIndicator);
}
});
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=app-next-dev.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/app-next-dev.ts"],"sourcesContent":["// TODO-APP: hydration warning\n\nimport './app-webpack'\n\nimport { renderAppDevOverlay } from 'next/dist/compiled/next-devtools'\nimport { appBootstrap } from './app-bootstrap'\nimport { getOwnerStack } from '../next-devtools/userspace/app/errors/stitched-error'\nimport { isRecoverableError } from './react-client-callbacks/on-recoverable-error'\n\n// eslint-disable-next-line @next/internal/typechecked-require\nconst instrumentationHooks = require('../lib/require-instrumentation-client')\n\nappBootstrap((assetPrefix) => {\n const { hydrate } = require('./app-index') as typeof import('./app-index')\n try {\n hydrate(instrumentationHooks, assetPrefix)\n } finally {\n const enableCacheIndicator = process.env.__NEXT_CACHE_COMPONENTS\n renderAppDevOverlay(getOwnerStack, isRecoverableError, enableCacheIndicator)\n }\n})\n"],"names":["instrumentationHooks","require","appBootstrap","assetPrefix","hydrate","enableCacheIndicator","process","env","__NEXT_CACHE_COMPONENTS","renderAppDevOverlay","getOwnerStack","isRecoverableError"],"mappings":"AAAA,8BAA8B;;;;;QAEvB;8BAE6B;8BACP;+BACC;oCACK;AAEnC,8DAA8D;AAC9D,MAAMA,uBAAuBC,QAAQ;AAErCC,IAAAA,0BAAY,EAAC,CAACC;IACZ,MAAM,EAAEC,OAAO,EAAE,GAAGH,QAAQ;IAC5B,IAAI;QACFG,QAAQJ,sBAAsBG;IAChC,SAAU;QACR,MAAME,uBAAuBC,QAAQC,GAAG,CAACC,uBAAuB;QAChEC,IAAAA,iCAAmB,EAACC,4BAAa,EAAEC,sCAAkB,EAAEN;IACzD;AACF","ignoreList":[0]}

View File

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

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _appbootstrap = require("./app-bootstrap");
const _onrecoverableerror = require("./react-client-callbacks/on-recoverable-error");
window.next.turbopack = true;
self.__webpack_hash__ = '';
// eslint-disable-next-line @next/internal/typechecked-require
const instrumentationHooks = require('../lib/require-instrumentation-client');
(0, _appbootstrap.appBootstrap)((assetPrefix)=>{
const { hydrate } = require('./app-index');
try {
hydrate(instrumentationHooks, assetPrefix);
} finally{
if (process.env.NODE_ENV !== 'production') {
const enableCacheIndicator = process.env.__NEXT_CACHE_COMPONENTS;
const { getOwnerStack } = require('../next-devtools/userspace/app/errors/stitched-error');
const { renderAppDevOverlay } = require('next/dist/compiled/next-devtools');
renderAppDevOverlay(getOwnerStack, _onrecoverableerror.isRecoverableError, enableCacheIndicator);
}
}
});
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=app-next-turbopack.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/app-next-turbopack.ts"],"sourcesContent":["import { appBootstrap } from './app-bootstrap'\nimport { isRecoverableError } from './react-client-callbacks/on-recoverable-error'\n\nwindow.next.turbopack = true\n;(self as any).__webpack_hash__ = ''\n\n// eslint-disable-next-line @next/internal/typechecked-require\nconst instrumentationHooks = require('../lib/require-instrumentation-client')\n\nappBootstrap((assetPrefix) => {\n const { hydrate } = require('./app-index') as typeof import('./app-index')\n try {\n hydrate(instrumentationHooks, assetPrefix)\n } finally {\n if (process.env.NODE_ENV !== 'production') {\n const enableCacheIndicator = process.env.__NEXT_CACHE_COMPONENTS\n const { getOwnerStack } =\n require('../next-devtools/userspace/app/errors/stitched-error') as typeof import('../next-devtools/userspace/app/errors/stitched-error')\n const { renderAppDevOverlay } =\n require('next/dist/compiled/next-devtools') as typeof import('next/dist/compiled/next-devtools')\n renderAppDevOverlay(\n getOwnerStack,\n isRecoverableError,\n enableCacheIndicator\n )\n }\n }\n})\n"],"names":["window","next","turbopack","self","__webpack_hash__","instrumentationHooks","require","appBootstrap","assetPrefix","hydrate","process","env","NODE_ENV","enableCacheIndicator","__NEXT_CACHE_COMPONENTS","getOwnerStack","renderAppDevOverlay","isRecoverableError"],"mappings":";;;;8BAA6B;oCACM;AAEnCA,OAAOC,IAAI,CAACC,SAAS,GAAG;AACtBC,KAAaC,gBAAgB,GAAG;AAElC,8DAA8D;AAC9D,MAAMC,uBAAuBC,QAAQ;AAErCC,IAAAA,0BAAY,EAAC,CAACC;IACZ,MAAM,EAAEC,OAAO,EAAE,GAAGH,QAAQ;IAC5B,IAAI;QACFG,QAAQJ,sBAAsBG;IAChC,SAAU;QACR,IAAIE,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC,MAAMC,uBAAuBH,QAAQC,GAAG,CAACG,uBAAuB;YAChE,MAAM,EAAEC,aAAa,EAAE,GACrBT,QAAQ;YACV,MAAM,EAAEU,mBAAmB,EAAE,GAC3BV,QAAQ;YACVU,oBACED,eACAE,sCAAkB,EAClBJ;QAEJ;IACF;AACF","ignoreList":[0]}

View File

@@ -0,0 +1 @@
import './app-webpack';

View File

@@ -0,0 +1,27 @@
// This import must go first because it needs to patch webpack chunk loading
// before React patches chunk loading.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
require("./app-webpack");
const _appbootstrap = require("./app-bootstrap");
const instrumentationHooks = // eslint-disable-next-line @next/internal/typechecked-require -- not a module
require('../lib/require-instrumentation-client');
(0, _appbootstrap.appBootstrap)((assetPrefix)=>{
const { hydrate } = require('./app-index');
// Include app-router and layout-router in the main chunk
// eslint-disable-next-line @next/internal/typechecked-require -- Why not relative imports?
require('next/dist/client/components/app-router');
// eslint-disable-next-line @next/internal/typechecked-require -- Why not relative imports?
require('next/dist/client/components/layout-router');
hydrate(instrumentationHooks, assetPrefix);
});
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=app-next.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/app-next.ts"],"sourcesContent":["// This import must go first because it needs to patch webpack chunk loading\n// before React patches chunk loading.\nimport './app-webpack'\nimport { appBootstrap } from './app-bootstrap'\n\nconst instrumentationHooks =\n // eslint-disable-next-line @next/internal/typechecked-require -- not a module\n require('../lib/require-instrumentation-client')\n\nappBootstrap((assetPrefix) => {\n const { hydrate } = require('./app-index') as typeof import('./app-index')\n // Include app-router and layout-router in the main chunk\n // eslint-disable-next-line @next/internal/typechecked-require -- Why not relative imports?\n require('next/dist/client/components/app-router')\n // eslint-disable-next-line @next/internal/typechecked-require -- Why not relative imports?\n require('next/dist/client/components/layout-router')\n hydrate(instrumentationHooks, assetPrefix)\n})\n"],"names":["instrumentationHooks","require","appBootstrap","assetPrefix","hydrate"],"mappings":"AAAA,4EAA4E;AAC5E,sCAAsC;;;;;QAC/B;8BACsB;AAE7B,MAAMA,uBACJ,8EAA8E;AAC9EC,QAAQ;AAEVC,IAAAA,0BAAY,EAAC,CAACC;IACZ,MAAM,EAAEC,OAAO,EAAE,GAAGH,QAAQ;IAC5B,yDAAyD;IACzD,2FAA2F;IAC3FA,QAAQ;IACR,2FAA2F;IAC3FA,QAAQ;IACRG,QAAQJ,sBAAsBG;AAChC","ignoreList":[0]}

View File

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

View File

@@ -0,0 +1,38 @@
// Override chunk URL mapping in the webpack runtime
// https://github.com/webpack/webpack/blob/2738eebc7880835d88c727d364ad37f3ec557593/lib/RuntimeGlobals.js#L204
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const _deploymentid = require("../shared/lib/deployment-id");
const _encodeuripath = require("../shared/lib/encode-uri-path");
// If we have a deployment ID, we need to append it to the webpack chunk names
// I am keeping the process check explicit so this can be statically optimized
if (process.env.NEXT_DEPLOYMENT_ID) {
const suffix = (0, _deploymentid.getDeploymentIdQueryOrEmptyString)();
const getChunkScriptFilename = __webpack_require__.u;
__webpack_require__.u = (...args)=>// We encode the chunk filename because our static server matches against and encoded
// filename path.
(0, _encodeuripath.encodeURIPath)(getChunkScriptFilename(...args)) + suffix;
const getChunkCssFilename = __webpack_require__.k;
__webpack_require__.k = (...args)=>getChunkCssFilename(...args) + suffix;
const getMiniCssFilename = __webpack_require__.miniCssF;
__webpack_require__.miniCssF = (...args)=>getMiniCssFilename(...args) + suffix;
} else {
const getChunkScriptFilename = __webpack_require__.u;
__webpack_require__.u = (...args)=>// We encode the chunk filename because our static server matches against and encoded
// filename path.
(0, _encodeuripath.encodeURIPath)(getChunkScriptFilename(...args));
// We don't need to override __webpack_require__.k because we don't modify
// the css chunk name when not using deployment id suffixes
// WE don't need to override __webpack_require__.miniCssF because we don't modify
// the mini css chunk name when not using deployment id suffixes
}
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=app-webpack.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/app-webpack.ts"],"sourcesContent":["// Override chunk URL mapping in the webpack runtime\n// https://github.com/webpack/webpack/blob/2738eebc7880835d88c727d364ad37f3ec557593/lib/RuntimeGlobals.js#L204\n\nimport { getDeploymentIdQueryOrEmptyString } from '../shared/lib/deployment-id'\nimport { encodeURIPath } from '../shared/lib/encode-uri-path'\n\ndeclare const __webpack_require__: any\n\n// If we have a deployment ID, we need to append it to the webpack chunk names\n// I am keeping the process check explicit so this can be statically optimized\nif (process.env.NEXT_DEPLOYMENT_ID) {\n const suffix = getDeploymentIdQueryOrEmptyString()\n const getChunkScriptFilename = __webpack_require__.u\n __webpack_require__.u = (...args: any[]) =>\n // We encode the chunk filename because our static server matches against and encoded\n // filename path.\n encodeURIPath(getChunkScriptFilename(...args)) + suffix\n\n const getChunkCssFilename = __webpack_require__.k\n __webpack_require__.k = (...args: any[]) =>\n getChunkCssFilename(...args) + suffix\n\n const getMiniCssFilename = __webpack_require__.miniCssF\n __webpack_require__.miniCssF = (...args: any[]) =>\n getMiniCssFilename(...args) + suffix\n} else {\n const getChunkScriptFilename = __webpack_require__.u\n __webpack_require__.u = (...args: any[]) =>\n // We encode the chunk filename because our static server matches against and encoded\n // filename path.\n encodeURIPath(getChunkScriptFilename(...args))\n\n // We don't need to override __webpack_require__.k because we don't modify\n // the css chunk name when not using deployment id suffixes\n\n // WE don't need to override __webpack_require__.miniCssF because we don't modify\n // the mini css chunk name when not using deployment id suffixes\n}\n\nexport {}\n"],"names":["process","env","NEXT_DEPLOYMENT_ID","suffix","getDeploymentIdQueryOrEmptyString","getChunkScriptFilename","__webpack_require__","u","args","encodeURIPath","getChunkCssFilename","k","getMiniCssFilename","miniCssF"],"mappings":"AAAA,oDAAoD;AACpD,8GAA8G;;;;;8BAE5D;+BACpB;AAI9B,8EAA8E;AAC9E,8EAA8E;AAC9E,IAAIA,QAAQC,GAAG,CAACC,kBAAkB,EAAE;IAClC,MAAMC,SAASC,IAAAA,+CAAiC;IAChD,MAAMC,yBAAyBC,oBAAoBC,CAAC;IACpDD,oBAAoBC,CAAC,GAAG,CAAC,GAAGC,OAC1B,qFAAqF;QACrF,iBAAiB;QACjBC,IAAAA,4BAAa,EAACJ,0BAA0BG,SAASL;IAEnD,MAAMO,sBAAsBJ,oBAAoBK,CAAC;IACjDL,oBAAoBK,CAAC,GAAG,CAAC,GAAGH,OAC1BE,uBAAuBF,QAAQL;IAEjC,MAAMS,qBAAqBN,oBAAoBO,QAAQ;IACvDP,oBAAoBO,QAAQ,GAAG,CAAC,GAAGL,OACjCI,sBAAsBJ,QAAQL;AAClC,OAAO;IACL,MAAME,yBAAyBC,oBAAoBC,CAAC;IACpDD,oBAAoBC,CAAC,GAAG,CAAC,GAAGC,OAC1B,qFAAqF;QACrF,iBAAiB;QACjBC,IAAAA,4BAAa,EAACJ,0BAA0BG;AAE1C,0EAA0E;AAC1E,2DAA2D;AAE3D,iFAAiF;AACjF,gEAAgE;AAClE","ignoreList":[0]}

View File

@@ -0,0 +1 @@
export declare function getAssetPrefix(): string;

View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "getAssetPrefix", {
enumerable: true,
get: function() {
return getAssetPrefix;
}
});
const _invarianterror = require("../shared/lib/invariant-error");
function getAssetPrefix() {
const currentScript = document.currentScript;
if (!(currentScript instanceof HTMLScriptElement)) {
throw Object.defineProperty(new _invarianterror.InvariantError(`Expected document.currentScript to be a <script> element. Received ${currentScript} instead.`), "__NEXT_ERROR_CODE", {
value: "E783",
enumerable: false,
configurable: true
});
}
const { pathname } = new URL(currentScript.src);
const nextIndex = pathname.indexOf('/_next/');
if (nextIndex === -1) {
throw Object.defineProperty(new _invarianterror.InvariantError(`Expected document.currentScript src to contain '/_next/'. Received ${currentScript.src} instead.`), "__NEXT_ERROR_CODE", {
value: "E784",
enumerable: false,
configurable: true
});
}
return pathname.slice(0, nextIndex);
}
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=asset-prefix.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/asset-prefix.ts"],"sourcesContent":["import { InvariantError } from '../shared/lib/invariant-error'\n\nexport function getAssetPrefix() {\n const currentScript = document.currentScript\n\n if (!(currentScript instanceof HTMLScriptElement)) {\n throw new InvariantError(\n `Expected document.currentScript to be a <script> element. Received ${currentScript} instead.`\n )\n }\n\n const { pathname } = new URL(currentScript.src)\n const nextIndex = pathname.indexOf('/_next/')\n\n if (nextIndex === -1) {\n throw new InvariantError(\n `Expected document.currentScript src to contain '/_next/'. Received ${currentScript.src} instead.`\n )\n }\n\n return pathname.slice(0, nextIndex)\n}\n"],"names":["getAssetPrefix","currentScript","document","HTMLScriptElement","InvariantError","pathname","URL","src","nextIndex","indexOf","slice"],"mappings":";;;;+BAEgBA;;;eAAAA;;;gCAFe;AAExB,SAASA;IACd,MAAMC,gBAAgBC,SAASD,aAAa;IAE5C,IAAI,CAAEA,CAAAA,yBAAyBE,iBAAgB,GAAI;QACjD,MAAM,qBAEL,CAFK,IAAIC,8BAAc,CACtB,CAAC,mEAAmE,EAAEH,cAAc,SAAS,CAAC,GAD1F,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF;IAEA,MAAM,EAAEI,QAAQ,EAAE,GAAG,IAAIC,IAAIL,cAAcM,GAAG;IAC9C,MAAMC,YAAYH,SAASI,OAAO,CAAC;IAEnC,IAAID,cAAc,CAAC,GAAG;QACpB,MAAM,qBAEL,CAFK,IAAIJ,8BAAc,CACtB,CAAC,mEAAmE,EAAEH,cAAcM,GAAG,CAAC,SAAS,CAAC,GAD9F,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF;IAEA,OAAOF,SAASK,KAAK,CAAC,GAAGF;AAC3B","ignoreList":[0]}

View File

@@ -0,0 +1,8 @@
/**
* Function to correctly assign location to URL
*
* The method will add basePath, and will also correctly add location (including if it is a relative path)
* @param location Location that should be added to the url
* @param url Base URL to which the location should be assigned
*/
export declare function assignLocation(location: string, url: URL): URL;

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "assignLocation", {
enumerable: true,
get: function() {
return assignLocation;
}
});
const _addbasepath = require("./add-base-path");
function assignLocation(location, url) {
if (location.startsWith('.')) {
const urlBase = url.origin + url.pathname;
return new URL(// In order for a relative path to be added to the current url correctly, the current url must end with a slash
// new URL('./relative', 'https://example.com/subdir').href -> 'https://example.com/relative'
// new URL('./relative', 'https://example.com/subdir/').href -> 'https://example.com/subdir/relative'
(urlBase.endsWith('/') ? urlBase : urlBase + '/') + location);
}
return new URL((0, _addbasepath.addBasePath)(location), url.href);
}
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=assign-location.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../src/client/assign-location.ts"],"sourcesContent":["import { addBasePath } from './add-base-path'\n\n/**\n * Function to correctly assign location to URL\n *\n * The method will add basePath, and will also correctly add location (including if it is a relative path)\n * @param location Location that should be added to the url\n * @param url Base URL to which the location should be assigned\n */\nexport function assignLocation(location: string, url: URL): URL {\n if (location.startsWith('.')) {\n const urlBase = url.origin + url.pathname\n return new URL(\n // In order for a relative path to be added to the current url correctly, the current url must end with a slash\n // new URL('./relative', 'https://example.com/subdir').href -> 'https://example.com/relative'\n // new URL('./relative', 'https://example.com/subdir/').href -> 'https://example.com/subdir/relative'\n (urlBase.endsWith('/') ? urlBase : urlBase + '/') + location\n )\n }\n\n return new URL(addBasePath(location), url.href)\n}\n"],"names":["assignLocation","location","url","startsWith","urlBase","origin","pathname","URL","endsWith","addBasePath","href"],"mappings":";;;;+BASgBA;;;eAAAA;;;6BATY;AASrB,SAASA,eAAeC,QAAgB,EAAEC,GAAQ;IACvD,IAAID,SAASE,UAAU,CAAC,MAAM;QAC5B,MAAMC,UAAUF,IAAIG,MAAM,GAAGH,IAAII,QAAQ;QACzC,OAAO,IAAIC,IAIT,AAHA,+GAA+G;QAC/G,6FAA6F;QAC7F,qGAAqG;QACpGH,CAAAA,QAAQI,QAAQ,CAAC,OAAOJ,UAAUA,UAAU,GAAE,IAAKH;IAExD;IAEA,OAAO,IAAIM,IAAIE,IAAAA,wBAAW,EAACR,WAAWC,IAAIQ,IAAI;AAChD","ignoreList":[0]}

View File

@@ -0,0 +1,12 @@
import type { NextRouter } from '../router';
/**
* useRouter from `next/compat/router` is designed to assist developers
* migrating from `pages/` to `app/`. Unlike `next/router`, this hook does not
* throw when the `NextRouter` is not mounted, and instead returns `null`. The
* more concrete return type here lets developers use this hook within
* components that could be shared between both `app/` and `pages/` and handle
* to the case where the router is not mounted.
*
* @returns The `NextRouter` instance if it's available, otherwise `null`.
*/
export declare function useRouter(): NextRouter | null;

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useRouter", {
enumerable: true,
get: function() {
return useRouter;
}
});
const _react = require("react");
const _routercontextsharedruntime = require("../../shared/lib/router-context.shared-runtime");
function useRouter() {
return (0, _react.useContext)(_routercontextsharedruntime.RouterContext);
}
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=router.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/compat/router.ts"],"sourcesContent":["import { useContext } from 'react'\nimport { RouterContext } from '../../shared/lib/router-context.shared-runtime'\nimport type { NextRouter } from '../router'\n\n/**\n * useRouter from `next/compat/router` is designed to assist developers\n * migrating from `pages/` to `app/`. Unlike `next/router`, this hook does not\n * throw when the `NextRouter` is not mounted, and instead returns `null`. The\n * more concrete return type here lets developers use this hook within\n * components that could be shared between both `app/` and `pages/` and handle\n * to the case where the router is not mounted.\n *\n * @returns The `NextRouter` instance if it's available, otherwise `null`.\n */\nexport function useRouter(): NextRouter | null {\n return useContext(RouterContext)\n}\n"],"names":["useRouter","useContext","RouterContext"],"mappings":";;;;+BAcgBA;;;eAAAA;;;uBAdW;4CACG;AAavB,SAASA;IACd,OAAOC,IAAAA,iBAAU,EAACC,yCAAa;AACjC","ignoreList":[0]}

View File

@@ -0,0 +1,4 @@
import type { FlightRouterState } from '../../shared/lib/app-router-types';
export declare function AppRouterAnnouncer({ tree }: {
tree: FlightRouterState;
}): import("react").ReactPortal | null;

View File

@@ -0,0 +1,78 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "AppRouterAnnouncer", {
enumerable: true,
get: function() {
return AppRouterAnnouncer;
}
});
const _react = require("react");
const _reactdom = require("react-dom");
const ANNOUNCER_TYPE = 'next-route-announcer';
const ANNOUNCER_ID = '__next-route-announcer__';
function getAnnouncerNode() {
const existingAnnouncer = document.getElementsByName(ANNOUNCER_TYPE)[0];
if (existingAnnouncer?.shadowRoot?.childNodes[0]) {
return existingAnnouncer.shadowRoot.childNodes[0];
} else {
const container = document.createElement(ANNOUNCER_TYPE);
container.style.cssText = 'position:absolute';
const announcer = document.createElement('div');
announcer.ariaLive = 'assertive';
announcer.id = ANNOUNCER_ID;
announcer.role = 'alert';
announcer.style.cssText = 'position:absolute;border:0;height:1px;margin:-1px;padding:0;width:1px;clip:rect(0 0 0 0);overflow:hidden;white-space:nowrap;word-wrap:normal';
// Use shadow DOM here to avoid any potential CSS bleed
const shadow = container.attachShadow({
mode: 'open'
});
shadow.appendChild(announcer);
document.body.appendChild(container);
return announcer;
}
}
function AppRouterAnnouncer({ tree }) {
const [portalNode, setPortalNode] = (0, _react.useState)(null);
(0, _react.useEffect)(()=>{
const announcer = getAnnouncerNode();
setPortalNode(announcer);
return ()=>{
const container = document.getElementsByTagName(ANNOUNCER_TYPE)[0];
if (container?.isConnected) {
document.body.removeChild(container);
}
};
}, []);
const [routeAnnouncement, setRouteAnnouncement] = (0, _react.useState)('');
const previousTitle = (0, _react.useRef)(undefined);
(0, _react.useEffect)(()=>{
let currentTitle = '';
if (document.title) {
currentTitle = document.title;
} else {
const pageHeader = document.querySelector('h1');
if (pageHeader) {
currentTitle = pageHeader.innerText || pageHeader.textContent || '';
}
}
// Only announce the title change, but not for the first load because screen
// readers do that automatically.
if (previousTitle.current !== undefined && previousTitle.current !== currentTitle) {
setRouteAnnouncement(currentTitle);
}
previousTitle.current = currentTitle;
}, [
tree
]);
return portalNode ? /*#__PURE__*/ (0, _reactdom.createPortal)(routeAnnouncement, portalNode) : null;
}
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=app-router-announcer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/app-router-announcer.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\nimport type { FlightRouterState } from '../../shared/lib/app-router-types'\n\nconst ANNOUNCER_TYPE = 'next-route-announcer'\nconst ANNOUNCER_ID = '__next-route-announcer__'\n\nfunction getAnnouncerNode() {\n const existingAnnouncer = document.getElementsByName(ANNOUNCER_TYPE)[0]\n if (existingAnnouncer?.shadowRoot?.childNodes[0]) {\n return existingAnnouncer.shadowRoot.childNodes[0] as HTMLElement\n } else {\n const container = document.createElement(ANNOUNCER_TYPE)\n container.style.cssText = 'position:absolute'\n const announcer = document.createElement('div')\n announcer.ariaLive = 'assertive'\n announcer.id = ANNOUNCER_ID\n announcer.role = 'alert'\n announcer.style.cssText =\n 'position:absolute;border:0;height:1px;margin:-1px;padding:0;width:1px;clip:rect(0 0 0 0);overflow:hidden;white-space:nowrap;word-wrap:normal'\n\n // Use shadow DOM here to avoid any potential CSS bleed\n const shadow = container.attachShadow({ mode: 'open' })\n shadow.appendChild(announcer)\n document.body.appendChild(container)\n return announcer\n }\n}\n\nexport function AppRouterAnnouncer({ tree }: { tree: FlightRouterState }) {\n const [portalNode, setPortalNode] = useState<HTMLElement | null>(null)\n\n useEffect(() => {\n const announcer = getAnnouncerNode()\n setPortalNode(announcer)\n return () => {\n const container = document.getElementsByTagName(ANNOUNCER_TYPE)[0]\n if (container?.isConnected) {\n document.body.removeChild(container)\n }\n }\n }, [])\n\n const [routeAnnouncement, setRouteAnnouncement] = useState('')\n const previousTitle = useRef<string | undefined>(undefined)\n\n useEffect(() => {\n let currentTitle = ''\n if (document.title) {\n currentTitle = document.title\n } else {\n const pageHeader = document.querySelector('h1')\n if (pageHeader) {\n currentTitle = pageHeader.innerText || pageHeader.textContent || ''\n }\n }\n\n // Only announce the title change, but not for the first load because screen\n // readers do that automatically.\n if (\n previousTitle.current !== undefined &&\n previousTitle.current !== currentTitle\n ) {\n setRouteAnnouncement(currentTitle)\n }\n previousTitle.current = currentTitle\n }, [tree])\n\n return portalNode ? createPortal(routeAnnouncement, portalNode) : null\n}\n"],"names":["AppRouterAnnouncer","ANNOUNCER_TYPE","ANNOUNCER_ID","getAnnouncerNode","existingAnnouncer","document","getElementsByName","shadowRoot","childNodes","container","createElement","style","cssText","announcer","ariaLive","id","role","shadow","attachShadow","mode","appendChild","body","tree","portalNode","setPortalNode","useState","useEffect","getElementsByTagName","isConnected","removeChild","routeAnnouncement","setRouteAnnouncement","previousTitle","useRef","undefined","currentTitle","title","pageHeader","querySelector","innerText","textContent","current","createPortal"],"mappings":";;;;+BA6BgBA;;;eAAAA;;;uBA7B4B;0BACf;AAG7B,MAAMC,iBAAiB;AACvB,MAAMC,eAAe;AAErB,SAASC;IACP,MAAMC,oBAAoBC,SAASC,iBAAiB,CAACL,eAAe,CAAC,EAAE;IACvE,IAAIG,mBAAmBG,YAAYC,UAAU,CAAC,EAAE,EAAE;QAChD,OAAOJ,kBAAkBG,UAAU,CAACC,UAAU,CAAC,EAAE;IACnD,OAAO;QACL,MAAMC,YAAYJ,SAASK,aAAa,CAACT;QACzCQ,UAAUE,KAAK,CAACC,OAAO,GAAG;QAC1B,MAAMC,YAAYR,SAASK,aAAa,CAAC;QACzCG,UAAUC,QAAQ,GAAG;QACrBD,UAAUE,EAAE,GAAGb;QACfW,UAAUG,IAAI,GAAG;QACjBH,UAAUF,KAAK,CAACC,OAAO,GACrB;QAEF,uDAAuD;QACvD,MAAMK,SAASR,UAAUS,YAAY,CAAC;YAAEC,MAAM;QAAO;QACrDF,OAAOG,WAAW,CAACP;QACnBR,SAASgB,IAAI,CAACD,WAAW,CAACX;QAC1B,OAAOI;IACT;AACF;AAEO,SAASb,mBAAmB,EAAEsB,IAAI,EAA+B;IACtE,MAAM,CAACC,YAAYC,cAAc,GAAGC,IAAAA,eAAQ,EAAqB;IAEjEC,IAAAA,gBAAS,EAAC;QACR,MAAMb,YAAYV;QAClBqB,cAAcX;QACd,OAAO;YACL,MAAMJ,YAAYJ,SAASsB,oBAAoB,CAAC1B,eAAe,CAAC,EAAE;YAClE,IAAIQ,WAAWmB,aAAa;gBAC1BvB,SAASgB,IAAI,CAACQ,WAAW,CAACpB;YAC5B;QACF;IACF,GAAG,EAAE;IAEL,MAAM,CAACqB,mBAAmBC,qBAAqB,GAAGN,IAAAA,eAAQ,EAAC;IAC3D,MAAMO,gBAAgBC,IAAAA,aAAM,EAAqBC;IAEjDR,IAAAA,gBAAS,EAAC;QACR,IAAIS,eAAe;QACnB,IAAI9B,SAAS+B,KAAK,EAAE;YAClBD,eAAe9B,SAAS+B,KAAK;QAC/B,OAAO;YACL,MAAMC,aAAahC,SAASiC,aAAa,CAAC;YAC1C,IAAID,YAAY;gBACdF,eAAeE,WAAWE,SAAS,IAAIF,WAAWG,WAAW,IAAI;YACnE;QACF;QAEA,4EAA4E;QAC5E,iCAAiC;QACjC,IACER,cAAcS,OAAO,KAAKP,aAC1BF,cAAcS,OAAO,KAAKN,cAC1B;YACAJ,qBAAqBI;QACvB;QACAH,cAAcS,OAAO,GAAGN;IAC1B,GAAG;QAACb;KAAK;IAET,OAAOC,2BAAamB,IAAAA,sBAAY,EAACZ,mBAAmBP,cAAc;AACpE","ignoreList":[0]}

View File

@@ -0,0 +1,20 @@
export declare const RSC_HEADER: "rsc";
export declare const ACTION_HEADER: "next-action";
export declare const NEXT_ROUTER_STATE_TREE_HEADER: "next-router-state-tree";
export declare const NEXT_ROUTER_PREFETCH_HEADER: "next-router-prefetch";
export declare const NEXT_ROUTER_SEGMENT_PREFETCH_HEADER: "next-router-segment-prefetch";
export declare const NEXT_HMR_REFRESH_HEADER: "next-hmr-refresh";
export declare const NEXT_HMR_REFRESH_HASH_COOKIE: "__next_hmr_refresh_hash__";
export declare const NEXT_URL: "next-url";
export declare const RSC_CONTENT_TYPE_HEADER: "text/x-component";
export declare const FLIGHT_HEADERS: readonly ["rsc", "next-router-state-tree", "next-router-prefetch", "next-hmr-refresh", "next-router-segment-prefetch"];
export declare const NEXT_RSC_UNION_QUERY: "_rsc";
export declare const NEXT_ROUTER_STALE_TIME_HEADER: "x-nextjs-stale-time";
export declare const NEXT_DID_POSTPONE_HEADER: "x-nextjs-postponed";
export declare const NEXT_REWRITTEN_PATH_HEADER: "x-nextjs-rewritten-path";
export declare const NEXT_REWRITTEN_QUERY_HEADER: "x-nextjs-rewritten-query";
export declare const NEXT_IS_PRERENDER_HEADER: "x-nextjs-prerender";
export declare const NEXT_ACTION_NOT_FOUND_HEADER: "x-nextjs-action-not-found";
export declare const NEXT_REQUEST_ID_HEADER: "x-nextjs-request-id";
export declare const NEXT_HTML_REQUEST_ID_HEADER: "x-nextjs-html-request-id";
export declare const NEXT_ACTION_REVALIDATED_HEADER: "x-action-revalidated";

View File

@@ -0,0 +1,128 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
ACTION_HEADER: null,
FLIGHT_HEADERS: null,
NEXT_ACTION_NOT_FOUND_HEADER: null,
NEXT_ACTION_REVALIDATED_HEADER: null,
NEXT_DID_POSTPONE_HEADER: null,
NEXT_HMR_REFRESH_HASH_COOKIE: null,
NEXT_HMR_REFRESH_HEADER: null,
NEXT_HTML_REQUEST_ID_HEADER: null,
NEXT_IS_PRERENDER_HEADER: null,
NEXT_REQUEST_ID_HEADER: null,
NEXT_REWRITTEN_PATH_HEADER: null,
NEXT_REWRITTEN_QUERY_HEADER: null,
NEXT_ROUTER_PREFETCH_HEADER: null,
NEXT_ROUTER_SEGMENT_PREFETCH_HEADER: null,
NEXT_ROUTER_STALE_TIME_HEADER: null,
NEXT_ROUTER_STATE_TREE_HEADER: null,
NEXT_RSC_UNION_QUERY: null,
NEXT_URL: null,
RSC_CONTENT_TYPE_HEADER: null,
RSC_HEADER: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
ACTION_HEADER: function() {
return ACTION_HEADER;
},
FLIGHT_HEADERS: function() {
return FLIGHT_HEADERS;
},
NEXT_ACTION_NOT_FOUND_HEADER: function() {
return NEXT_ACTION_NOT_FOUND_HEADER;
},
NEXT_ACTION_REVALIDATED_HEADER: function() {
return NEXT_ACTION_REVALIDATED_HEADER;
},
NEXT_DID_POSTPONE_HEADER: function() {
return NEXT_DID_POSTPONE_HEADER;
},
NEXT_HMR_REFRESH_HASH_COOKIE: function() {
return NEXT_HMR_REFRESH_HASH_COOKIE;
},
NEXT_HMR_REFRESH_HEADER: function() {
return NEXT_HMR_REFRESH_HEADER;
},
NEXT_HTML_REQUEST_ID_HEADER: function() {
return NEXT_HTML_REQUEST_ID_HEADER;
},
NEXT_IS_PRERENDER_HEADER: function() {
return NEXT_IS_PRERENDER_HEADER;
},
NEXT_REQUEST_ID_HEADER: function() {
return NEXT_REQUEST_ID_HEADER;
},
NEXT_REWRITTEN_PATH_HEADER: function() {
return NEXT_REWRITTEN_PATH_HEADER;
},
NEXT_REWRITTEN_QUERY_HEADER: function() {
return NEXT_REWRITTEN_QUERY_HEADER;
},
NEXT_ROUTER_PREFETCH_HEADER: function() {
return NEXT_ROUTER_PREFETCH_HEADER;
},
NEXT_ROUTER_SEGMENT_PREFETCH_HEADER: function() {
return NEXT_ROUTER_SEGMENT_PREFETCH_HEADER;
},
NEXT_ROUTER_STALE_TIME_HEADER: function() {
return NEXT_ROUTER_STALE_TIME_HEADER;
},
NEXT_ROUTER_STATE_TREE_HEADER: function() {
return NEXT_ROUTER_STATE_TREE_HEADER;
},
NEXT_RSC_UNION_QUERY: function() {
return NEXT_RSC_UNION_QUERY;
},
NEXT_URL: function() {
return NEXT_URL;
},
RSC_CONTENT_TYPE_HEADER: function() {
return RSC_CONTENT_TYPE_HEADER;
},
RSC_HEADER: function() {
return RSC_HEADER;
}
});
const RSC_HEADER = 'rsc';
const ACTION_HEADER = 'next-action';
const NEXT_ROUTER_STATE_TREE_HEADER = 'next-router-state-tree';
const NEXT_ROUTER_PREFETCH_HEADER = 'next-router-prefetch';
const NEXT_ROUTER_SEGMENT_PREFETCH_HEADER = 'next-router-segment-prefetch';
const NEXT_HMR_REFRESH_HEADER = 'next-hmr-refresh';
const NEXT_HMR_REFRESH_HASH_COOKIE = '__next_hmr_refresh_hash__';
const NEXT_URL = 'next-url';
const RSC_CONTENT_TYPE_HEADER = 'text/x-component';
const FLIGHT_HEADERS = [
RSC_HEADER,
NEXT_ROUTER_STATE_TREE_HEADER,
NEXT_ROUTER_PREFETCH_HEADER,
NEXT_HMR_REFRESH_HEADER,
NEXT_ROUTER_SEGMENT_PREFETCH_HEADER
];
const NEXT_RSC_UNION_QUERY = '_rsc';
const NEXT_ROUTER_STALE_TIME_HEADER = 'x-nextjs-stale-time';
const NEXT_DID_POSTPONE_HEADER = 'x-nextjs-postponed';
const NEXT_REWRITTEN_PATH_HEADER = 'x-nextjs-rewritten-path';
const NEXT_REWRITTEN_QUERY_HEADER = 'x-nextjs-rewritten-query';
const NEXT_IS_PRERENDER_HEADER = 'x-nextjs-prerender';
const NEXT_ACTION_NOT_FOUND_HEADER = 'x-nextjs-action-not-found';
const NEXT_REQUEST_ID_HEADER = 'x-nextjs-request-id';
const NEXT_HTML_REQUEST_ID_HEADER = 'x-nextjs-html-request-id';
const NEXT_ACTION_REVALIDATED_HEADER = 'x-action-revalidated';
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=app-router-headers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/app-router-headers.ts"],"sourcesContent":["export const RSC_HEADER = 'rsc' as const\nexport const ACTION_HEADER = 'next-action' as const\n// TODO: Instead of sending the full router state, we only need to send the\n// segment path. Saves bytes. Then we could also use this field for segment\n// prefetches, which also need to specify a particular segment.\nexport const NEXT_ROUTER_STATE_TREE_HEADER = 'next-router-state-tree' as const\nexport const NEXT_ROUTER_PREFETCH_HEADER = 'next-router-prefetch' as const\n// This contains the path to the segment being prefetched.\n// TODO: If we change next-router-state-tree to be a segment path, we can use\n// that instead. Then next-router-prefetch and next-router-segment-prefetch can\n// be merged into a single enum.\nexport const NEXT_ROUTER_SEGMENT_PREFETCH_HEADER =\n 'next-router-segment-prefetch' as const\nexport const NEXT_HMR_REFRESH_HEADER = 'next-hmr-refresh' as const\nexport const NEXT_HMR_REFRESH_HASH_COOKIE = '__next_hmr_refresh_hash__' as const\nexport const NEXT_URL = 'next-url' as const\nexport const RSC_CONTENT_TYPE_HEADER = 'text/x-component' as const\n\nexport const FLIGHT_HEADERS = [\n RSC_HEADER,\n NEXT_ROUTER_STATE_TREE_HEADER,\n NEXT_ROUTER_PREFETCH_HEADER,\n NEXT_HMR_REFRESH_HEADER,\n NEXT_ROUTER_SEGMENT_PREFETCH_HEADER,\n] as const\n\nexport const NEXT_RSC_UNION_QUERY = '_rsc' as const\n\nexport const NEXT_ROUTER_STALE_TIME_HEADER = 'x-nextjs-stale-time' as const\nexport const NEXT_DID_POSTPONE_HEADER = 'x-nextjs-postponed' as const\nexport const NEXT_REWRITTEN_PATH_HEADER = 'x-nextjs-rewritten-path' as const\nexport const NEXT_REWRITTEN_QUERY_HEADER = 'x-nextjs-rewritten-query' as const\nexport const NEXT_IS_PRERENDER_HEADER = 'x-nextjs-prerender' as const\nexport const NEXT_ACTION_NOT_FOUND_HEADER = 'x-nextjs-action-not-found' as const\nexport const NEXT_REQUEST_ID_HEADER = 'x-nextjs-request-id' as const\nexport const NEXT_HTML_REQUEST_ID_HEADER = 'x-nextjs-html-request-id' as const\n\n// TODO: Should this include nextjs in the name, like the others?\nexport const NEXT_ACTION_REVALIDATED_HEADER = 'x-action-revalidated' as const\n"],"names":["ACTION_HEADER","FLIGHT_HEADERS","NEXT_ACTION_NOT_FOUND_HEADER","NEXT_ACTION_REVALIDATED_HEADER","NEXT_DID_POSTPONE_HEADER","NEXT_HMR_REFRESH_HASH_COOKIE","NEXT_HMR_REFRESH_HEADER","NEXT_HTML_REQUEST_ID_HEADER","NEXT_IS_PRERENDER_HEADER","NEXT_REQUEST_ID_HEADER","NEXT_REWRITTEN_PATH_HEADER","NEXT_REWRITTEN_QUERY_HEADER","NEXT_ROUTER_PREFETCH_HEADER","NEXT_ROUTER_SEGMENT_PREFETCH_HEADER","NEXT_ROUTER_STALE_TIME_HEADER","NEXT_ROUTER_STATE_TREE_HEADER","NEXT_RSC_UNION_QUERY","NEXT_URL","RSC_CONTENT_TYPE_HEADER","RSC_HEADER"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACaA,aAAa;eAAbA;;IAiBAC,cAAc;eAAdA;;IAeAC,4BAA4B;eAA5BA;;IAKAC,8BAA8B;eAA9BA;;IATAC,wBAAwB;eAAxBA;;IAfAC,4BAA4B;eAA5BA;;IADAC,uBAAuB;eAAvBA;;IAsBAC,2BAA2B;eAA3BA;;IAHAC,wBAAwB;eAAxBA;;IAEAC,sBAAsB;eAAtBA;;IAJAC,0BAA0B;eAA1BA;;IACAC,2BAA2B;eAA3BA;;IAzBAC,2BAA2B;eAA3BA;;IAKAC,mCAAmC;eAAnCA;;IAiBAC,6BAA6B;eAA7BA;;IAvBAC,6BAA6B;eAA7BA;;IAqBAC,oBAAoB;eAApBA;;IAXAC,QAAQ;eAARA;;IACAC,uBAAuB;eAAvBA;;IAhBAC,UAAU;eAAVA;;;AAAN,MAAMA,aAAa;AACnB,MAAMnB,gBAAgB;AAItB,MAAMe,gCAAgC;AACtC,MAAMH,8BAA8B;AAKpC,MAAMC,sCACX;AACK,MAAMP,0BAA0B;AAChC,MAAMD,+BAA+B;AACrC,MAAMY,WAAW;AACjB,MAAMC,0BAA0B;AAEhC,MAAMjB,iBAAiB;IAC5BkB;IACAJ;IACAH;IACAN;IACAO;CACD;AAEM,MAAMG,uBAAuB;AAE7B,MAAMF,gCAAgC;AACtC,MAAMV,2BAA2B;AACjC,MAAMM,6BAA6B;AACnC,MAAMC,8BAA8B;AACpC,MAAMH,2BAA2B;AACjC,MAAMN,+BAA+B;AACrC,MAAMO,yBAAyB;AAC/B,MAAMF,8BAA8B;AAGpC,MAAMJ,iCAAiC","ignoreList":[0]}

View File

@@ -0,0 +1,36 @@
import { type AppRouterState, type ReducerActions, type ReducerState, type NavigateAction, type AppHistoryState } from './router-reducer/router-reducer-types';
import type { AppRouterInstance } from '../../shared/lib/app-router-context.shared-runtime';
import { type LinkInstance } from './links';
import type { ClientInstrumentationHooks } from '../app-index';
import type { GlobalErrorComponent } from './builtin/global-error';
export type DispatchStatePromise = React.Dispatch<ReducerState>;
export type AppRouterActionQueue = {
state: AppRouterState;
dispatch: (payload: ReducerActions, setState: DispatchStatePromise) => void;
action: (state: AppRouterState, action: ReducerActions) => ReducerState;
onRouterTransitionStart: ((url: string, type: 'push' | 'replace' | 'traverse') => void) | null;
pending: ActionQueueNode | null;
needsRefresh?: boolean;
last: ActionQueueNode | null;
};
export type GlobalErrorState = [
GlobalError: GlobalErrorComponent,
styles: React.ReactNode
];
export type ActionQueueNode = {
payload: ReducerActions;
next: ActionQueueNode | null;
resolve: (value: ReducerState) => void;
reject: (err: Error) => void;
discarded?: boolean;
};
export declare function createMutableActionQueue(initialState: AppRouterState, instrumentationHooks: ClientInstrumentationHooks | null): AppRouterActionQueue;
export declare function getCurrentAppRouterState(): AppRouterState | null;
export declare function dispatchNavigateAction(href: string, navigateType: NavigateAction['navigateType'], shouldScroll: boolean, linkInstanceRef: LinkInstance | null): void;
export declare function dispatchTraverseAction(href: string, historyState: AppHistoryState | undefined): void;
/**
* The app router that is exposed through `useRouter`. These are public API
* methods. Internal Next.js code should call the lower level methods directly
* (although there's lots of existing code that doesn't do that).
*/
export declare const publicAppRouterInstance: AppRouterInstance;

View File

@@ -0,0 +1,319 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
createMutableActionQueue: null,
dispatchNavigateAction: null,
dispatchTraverseAction: null,
getCurrentAppRouterState: null,
publicAppRouterInstance: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
createMutableActionQueue: function() {
return createMutableActionQueue;
},
dispatchNavigateAction: function() {
return dispatchNavigateAction;
},
dispatchTraverseAction: function() {
return dispatchTraverseAction;
},
getCurrentAppRouterState: function() {
return getCurrentAppRouterState;
},
publicAppRouterInstance: function() {
return publicAppRouterInstance;
}
});
const _routerreducertypes = require("./router-reducer/router-reducer-types");
const _routerreducer = require("./router-reducer/router-reducer");
const _react = require("react");
const _isthenable = require("../../shared/lib/is-thenable");
const _types = require("./segment-cache/types");
const _prefetch = require("./segment-cache/prefetch");
const _useactionqueue = require("./use-action-queue");
const _addbasepath = require("../add-base-path");
const _approuterutils = require("./app-router-utils");
const _links = require("./links");
function runRemainingActions(actionQueue, setState) {
if (actionQueue.pending !== null) {
actionQueue.pending = actionQueue.pending.next;
if (actionQueue.pending !== null) {
runAction({
actionQueue,
action: actionQueue.pending,
setState
});
}
} else {
// Check for refresh when pending is already null
// This handles the case where a discarded server action completes
// after the navigation has already finished and the queue is empty
if (actionQueue.needsRefresh) {
actionQueue.needsRefresh = false;
actionQueue.dispatch({
type: _routerreducertypes.ACTION_REFRESH
}, setState);
}
}
}
async function runAction({ actionQueue, action, setState }) {
const prevState = actionQueue.state;
actionQueue.pending = action;
const payload = action.payload;
const actionResult = actionQueue.action(prevState, payload);
function handleResult(nextState) {
// if we discarded this action, the state should also be discarded
if (action.discarded) {
// Check if the discarded server action revalidated data
if (action.payload.type === _routerreducertypes.ACTION_SERVER_ACTION && action.payload.didRevalidate) {
// The server action was discarded but it revalidated data,
// mark that we need to refresh after all actions complete
actionQueue.needsRefresh = true;
}
// Still need to run remaining actions even for discarded actions
// to potentially trigger the refresh
runRemainingActions(actionQueue, setState);
return;
}
actionQueue.state = nextState;
runRemainingActions(actionQueue, setState);
action.resolve(nextState);
}
// if the action is a promise, set up a callback to resolve it
if ((0, _isthenable.isThenable)(actionResult)) {
actionResult.then(handleResult, (err)=>{
runRemainingActions(actionQueue, setState);
action.reject(err);
});
} else {
handleResult(actionResult);
}
}
function dispatchAction(actionQueue, payload, setState) {
let resolvers = {
resolve: setState,
reject: ()=>{}
};
// most of the action types are async with the exception of restore
// it's important that restore is handled quickly since it's fired on the popstate event
// and we don't want to add any delay on a back/forward nav
// this only creates a promise for the async actions
if (payload.type !== _routerreducertypes.ACTION_RESTORE) {
// Create the promise and assign the resolvers to the object.
const deferredPromise = new Promise((resolve, reject)=>{
resolvers = {
resolve,
reject
};
});
(0, _react.startTransition)(()=>{
// we immediately notify React of the pending promise -- the resolver is attached to the action node
// and will be called when the associated action promise resolves
setState(deferredPromise);
});
}
const newAction = {
payload,
next: null,
resolve: resolvers.resolve,
reject: resolvers.reject
};
// Check if the queue is empty
if (actionQueue.pending === null) {
// The queue is empty, so add the action and start it immediately
// Mark this action as the last in the queue
actionQueue.last = newAction;
runAction({
actionQueue,
action: newAction,
setState
});
} else if (payload.type === _routerreducertypes.ACTION_NAVIGATE || payload.type === _routerreducertypes.ACTION_RESTORE) {
// Navigations (including back/forward) take priority over any pending actions.
// Mark the pending action as discarded (so the state is never applied) and start the navigation action immediately.
actionQueue.pending.discarded = true;
// The rest of the current queue should still execute after this navigation.
// (Note that it can't contain any earlier navigations, because we always put those into `actionQueue.pending` by calling `runAction`)
newAction.next = actionQueue.pending.next;
runAction({
actionQueue,
action: newAction,
setState
});
} else {
// The queue is not empty, so add the action to the end of the queue
// It will be started by runRemainingActions after the previous action finishes
if (actionQueue.last !== null) {
actionQueue.last.next = newAction;
}
actionQueue.last = newAction;
}
}
let globalActionQueue = null;
function createMutableActionQueue(initialState, instrumentationHooks) {
const actionQueue = {
state: initialState,
dispatch: (payload, setState)=>dispatchAction(actionQueue, payload, setState),
action: async (state, action)=>{
const result = (0, _routerreducer.reducer)(state, action);
return result;
},
pending: null,
last: null,
onRouterTransitionStart: instrumentationHooks !== null && typeof instrumentationHooks.onRouterTransitionStart === 'function' ? instrumentationHooks.onRouterTransitionStart : null
};
if (typeof window !== 'undefined') {
// The action queue is lazily created on hydration, but after that point
// it doesn't change. So we can store it in a global rather than pass
// it around everywhere via props/context.
if (globalActionQueue !== null) {
throw Object.defineProperty(new Error('Internal Next.js Error: createMutableActionQueue was called more ' + 'than once'), "__NEXT_ERROR_CODE", {
value: "E624",
enumerable: false,
configurable: true
});
}
globalActionQueue = actionQueue;
}
return actionQueue;
}
function getCurrentAppRouterState() {
return globalActionQueue !== null ? globalActionQueue.state : null;
}
function getAppRouterActionQueue() {
if (globalActionQueue === null) {
throw Object.defineProperty(new Error('Internal Next.js error: Router action dispatched before initialization.'), "__NEXT_ERROR_CODE", {
value: "E668",
enumerable: false,
configurable: true
});
}
return globalActionQueue;
}
function getProfilingHookForOnNavigationStart() {
if (globalActionQueue !== null) {
return globalActionQueue.onRouterTransitionStart;
}
return null;
}
function dispatchNavigateAction(href, navigateType, shouldScroll, linkInstanceRef) {
// TODO: This stuff could just go into the reducer. Leaving as-is for now
// since we're about to rewrite all the router reducer stuff anyway.
const url = new URL((0, _addbasepath.addBasePath)(href), location.href);
if (process.env.__NEXT_APP_NAV_FAIL_HANDLING) {
window.next.__pendingUrl = url;
}
(0, _links.setLinkForCurrentNavigation)(linkInstanceRef);
const onRouterTransitionStart = getProfilingHookForOnNavigationStart();
if (onRouterTransitionStart !== null) {
onRouterTransitionStart(href, navigateType);
}
(0, _useactionqueue.dispatchAppRouterAction)({
type: _routerreducertypes.ACTION_NAVIGATE,
url,
isExternalUrl: (0, _approuterutils.isExternalURL)(url),
locationSearch: location.search,
shouldScroll,
navigateType
});
}
function dispatchTraverseAction(href, historyState) {
const onRouterTransitionStart = getProfilingHookForOnNavigationStart();
if (onRouterTransitionStart !== null) {
onRouterTransitionStart(href, 'traverse');
}
(0, _useactionqueue.dispatchAppRouterAction)({
type: _routerreducertypes.ACTION_RESTORE,
url: new URL(href),
historyState
});
}
const publicAppRouterInstance = {
back: ()=>window.history.back(),
forward: ()=>window.history.forward(),
prefetch: // Unlike the old implementation, the Segment Cache doesn't store its
// data in the router reducer state; it writes into a global mutable
// cache. So we don't need to dispatch an action.
(href, options)=>{
const actionQueue = getAppRouterActionQueue();
const prefetchKind = options?.kind ?? _routerreducertypes.PrefetchKind.AUTO;
// We don't currently offer a way to issue a runtime prefetch via `router.prefetch()`.
// This will be possible when we update its API to not take a PrefetchKind.
let fetchStrategy;
switch(prefetchKind){
case _routerreducertypes.PrefetchKind.AUTO:
{
// We default to PPR. We'll discover whether or not the route supports it with the initial prefetch.
fetchStrategy = _types.FetchStrategy.PPR;
break;
}
case _routerreducertypes.PrefetchKind.FULL:
{
fetchStrategy = _types.FetchStrategy.Full;
break;
}
default:
{
prefetchKind;
// Despite typescript thinking that this can't happen,
// we might get an unexpected value from user code.
// We don't know what they want, but we know they want a prefetch,
// so use the default.
fetchStrategy = _types.FetchStrategy.PPR;
}
}
(0, _prefetch.prefetch)(href, actionQueue.state.nextUrl, actionQueue.state.tree, fetchStrategy, options?.onInvalidate ?? null);
},
replace: (href, options)=>{
(0, _react.startTransition)(()=>{
dispatchNavigateAction(href, 'replace', options?.scroll ?? true, null);
});
},
push: (href, options)=>{
(0, _react.startTransition)(()=>{
dispatchNavigateAction(href, 'push', options?.scroll ?? true, null);
});
},
refresh: ()=>{
(0, _react.startTransition)(()=>{
(0, _useactionqueue.dispatchAppRouterAction)({
type: _routerreducertypes.ACTION_REFRESH
});
});
},
hmrRefresh: ()=>{
if (process.env.NODE_ENV !== 'development') {
throw Object.defineProperty(new Error('hmrRefresh can only be used in development mode. Please use refresh instead.'), "__NEXT_ERROR_CODE", {
value: "E485",
enumerable: false,
configurable: true
});
} else {
(0, _react.startTransition)(()=>{
(0, _useactionqueue.dispatchAppRouterAction)({
type: _routerreducertypes.ACTION_HMR_REFRESH
});
});
}
}
};
// Exists for debugging purposes. Don't use in application code.
if (typeof window !== 'undefined' && window.next) {
window.next.router = publicAppRouterInstance;
}
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=app-router-instance.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
export declare function isExternalURL(url: URL): boolean;
/**
* Given a link href, constructs the URL that should be prefetched. Returns null
* in cases where prefetching should be disabled, like external URLs, or
* during development.
* @param href The href passed to <Link>, router.prefetch(), or similar
* @returns A URL object to prefetch, or null if prefetching should be disabled
*/
export declare function createPrefetchURL(href: string): URL | null;

View File

@@ -0,0 +1,62 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
createPrefetchURL: null,
isExternalURL: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
createPrefetchURL: function() {
return createPrefetchURL;
},
isExternalURL: function() {
return isExternalURL;
}
});
const _isbot = require("../../shared/lib/router/utils/is-bot");
const _addbasepath = require("../add-base-path");
function isExternalURL(url) {
return url.origin !== window.location.origin;
}
function createPrefetchURL(href) {
// Don't prefetch for bots as they don't navigate.
if ((0, _isbot.isBot)(window.navigator.userAgent)) {
return null;
}
let url;
try {
url = new URL((0, _addbasepath.addBasePath)(href), window.location.href);
} catch (_) {
// TODO: Does this need to throw or can we just console.error instead? Does
// anyone rely on this throwing? (Seems unlikely.)
throw Object.defineProperty(new Error(`Cannot prefetch '${href}' because it cannot be converted to a URL.`), "__NEXT_ERROR_CODE", {
value: "E234",
enumerable: false,
configurable: true
});
}
// Don't prefetch during development (improves compilation performance)
if (process.env.NODE_ENV === 'development') {
return null;
}
// External urls can't be prefetched in the same way.
if (isExternalURL(url)) {
return null;
}
return url;
}
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=app-router-utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/app-router-utils.ts"],"sourcesContent":["import { isBot } from '../../shared/lib/router/utils/is-bot'\nimport { addBasePath } from '../add-base-path'\n\nexport function isExternalURL(url: URL) {\n return url.origin !== window.location.origin\n}\n\n/**\n * Given a link href, constructs the URL that should be prefetched. Returns null\n * in cases where prefetching should be disabled, like external URLs, or\n * during development.\n * @param href The href passed to <Link>, router.prefetch(), or similar\n * @returns A URL object to prefetch, or null if prefetching should be disabled\n */\nexport function createPrefetchURL(href: string): URL | null {\n // Don't prefetch for bots as they don't navigate.\n if (isBot(window.navigator.userAgent)) {\n return null\n }\n\n let url: URL\n try {\n url = new URL(addBasePath(href), window.location.href)\n } catch (_) {\n // TODO: Does this need to throw or can we just console.error instead? Does\n // anyone rely on this throwing? (Seems unlikely.)\n throw new Error(\n `Cannot prefetch '${href}' because it cannot be converted to a URL.`\n )\n }\n\n // Don't prefetch during development (improves compilation performance)\n if (process.env.NODE_ENV === 'development') {\n return null\n }\n\n // External urls can't be prefetched in the same way.\n if (isExternalURL(url)) {\n return null\n }\n\n return url\n}\n"],"names":["createPrefetchURL","isExternalURL","url","origin","window","location","href","isBot","navigator","userAgent","URL","addBasePath","_","Error","process","env","NODE_ENV"],"mappings":";;;;;;;;;;;;;;;IAcgBA,iBAAiB;eAAjBA;;IAXAC,aAAa;eAAbA;;;uBAHM;6BACM;AAErB,SAASA,cAAcC,GAAQ;IACpC,OAAOA,IAAIC,MAAM,KAAKC,OAAOC,QAAQ,CAACF,MAAM;AAC9C;AASO,SAASH,kBAAkBM,IAAY;IAC5C,kDAAkD;IAClD,IAAIC,IAAAA,YAAK,EAACH,OAAOI,SAAS,CAACC,SAAS,GAAG;QACrC,OAAO;IACT;IAEA,IAAIP;IACJ,IAAI;QACFA,MAAM,IAAIQ,IAAIC,IAAAA,wBAAW,EAACL,OAAOF,OAAOC,QAAQ,CAACC,IAAI;IACvD,EAAE,OAAOM,GAAG;QACV,2EAA2E;QAC3E,kDAAkD;QAClD,MAAM,qBAEL,CAFK,IAAIC,MACR,CAAC,iBAAiB,EAAEP,KAAK,0CAA0C,CAAC,GADhE,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF;IAEA,uEAAuE;IACvE,IAAIQ,QAAQC,GAAG,CAACC,QAAQ,KAAK,eAAe;QAC1C,OAAO;IACT;IAEA,qDAAqD;IACrD,IAAIf,cAAcC,MAAM;QACtB,OAAO;IACT;IAEA,OAAOA;AACT","ignoreList":[0]}

View File

@@ -0,0 +1,8 @@
import { type AppRouterActionQueue, type GlobalErrorState } from './app-router-instance';
import type { StaticIndicatorState } from '../dev/hot-reloader/app/hot-reloader-app';
export default function AppRouter({ actionQueue, globalErrorState, webSocket, staticIndicatorState, }: {
actionQueue: AppRouterActionQueue;
globalErrorState: GlobalErrorState;
webSocket?: WebSocket;
staticIndicatorState?: StaticIndicatorState;
}): import("react/jsx-runtime").JSX.Element;

View File

@@ -0,0 +1,495 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return AppRouter;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _jsxruntime = require("react/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _approutercontextsharedruntime = require("../../shared/lib/app-router-context.shared-runtime");
const _routerreducertypes = require("./router-reducer/router-reducer-types");
const _createhreffromurl = require("./router-reducer/create-href-from-url");
const _hooksclientcontextsharedruntime = require("../../shared/lib/hooks-client-context.shared-runtime");
const _useactionqueue = require("./use-action-queue");
const _approuterannouncer = require("./app-router-announcer");
const _redirectboundary = require("./redirect-boundary");
const _findheadincache = require("./router-reducer/reducers/find-head-in-cache");
const _unresolvedthenable = require("./unresolved-thenable");
const _removebasepath = require("../remove-base-path");
const _hasbasepath = require("../has-base-path");
const _computechangedpath = require("./router-reducer/compute-changed-path");
const _navfailurehandler = require("./nav-failure-handler");
const _approuterinstance = require("./app-router-instance");
const _redirect = require("./redirect");
const _redirecterror = require("./redirect-error");
const _links = require("./links");
const _rooterrorboundary = /*#__PURE__*/ _interop_require_default._(require("./errors/root-error-boundary"));
const _globalerror = /*#__PURE__*/ _interop_require_default._(require("./builtin/global-error"));
const _boundarycomponents = require("../../lib/framework/boundary-components");
const _deploymentid = require("../../shared/lib/deployment-id");
const globalMutable = {};
function HistoryUpdater({ appRouterState }) {
(0, _react.useInsertionEffect)(()=>{
if (process.env.__NEXT_APP_NAV_FAIL_HANDLING) {
// clear pending URL as navigation is no longer
// in flight
window.next.__pendingUrl = undefined;
}
const { tree, pushRef, canonicalUrl, renderedSearch } = appRouterState;
const appHistoryState = {
tree,
renderedSearch
};
// TODO: Use Navigation API if available
const historyState = {
...pushRef.preserveCustomHistoryState ? window.history.state : {},
// Identifier is shortened intentionally.
// __NA is used to identify if the history entry can be handled by the app-router.
// __N is used to identify if the history entry can be handled by the old router.
__NA: true,
__PRIVATE_NEXTJS_INTERNALS_TREE: appHistoryState
};
if (pushRef.pendingPush && // Skip pushing an additional history entry if the canonicalUrl is the same as the current url.
// This mirrors the browser behavior for normal navigation.
(0, _createhreffromurl.createHrefFromUrl)(new URL(window.location.href)) !== canonicalUrl) {
// This intentionally mutates React state, pushRef is overwritten to ensure additional push/replace calls do not trigger an additional history entry.
pushRef.pendingPush = false;
window.history.pushState(historyState, '', canonicalUrl);
} else {
window.history.replaceState(historyState, '', canonicalUrl);
}
}, [
appRouterState
]);
(0, _react.useEffect)(()=>{
// The Next-Url and the base tree may affect the result of a prefetch
// task. Re-prefetch all visible links with the updated values. In most
// cases, this will not result in any new network requests, only if
// the prefetch result actually varies on one of these inputs.
(0, _links.pingVisibleLinks)(appRouterState.nextUrl, appRouterState.tree);
}, [
appRouterState.nextUrl,
appRouterState.tree
]);
return null;
}
function copyNextJsInternalHistoryState(data) {
if (data == null) data = {};
const currentState = window.history.state;
const __NA = currentState?.__NA;
if (__NA) {
data.__NA = __NA;
}
const __PRIVATE_NEXTJS_INTERNALS_TREE = currentState?.__PRIVATE_NEXTJS_INTERNALS_TREE;
if (__PRIVATE_NEXTJS_INTERNALS_TREE) {
data.__PRIVATE_NEXTJS_INTERNALS_TREE = __PRIVATE_NEXTJS_INTERNALS_TREE;
}
return data;
}
function Head({ headCacheNode }) {
// If this segment has a `prefetchHead`, it's the statically prefetched data.
// We should use that on initial render instead of `head`. Then we'll switch
// to `head` when the dynamic response streams in.
const head = headCacheNode !== null ? headCacheNode.head : null;
const prefetchHead = headCacheNode !== null ? headCacheNode.prefetchHead : null;
// If no prefetch data is available, then we go straight to rendering `head`.
const resolvedPrefetchRsc = prefetchHead !== null ? prefetchHead : head;
// We use `useDeferredValue` to handle switching between the prefetched and
// final values. The second argument is returned on initial render, then it
// re-renders with the first argument.
return (0, _react.useDeferredValue)(head, resolvedPrefetchRsc);
}
/**
* The global router that wraps the application components.
*/ function Router({ actionQueue, globalError, webSocket, staticIndicatorState }) {
const state = (0, _useactionqueue.useActionQueue)(actionQueue);
const { canonicalUrl } = state;
// Add memoized pathname/query for useSearchParams and usePathname.
const { searchParams, pathname } = (0, _react.useMemo)(()=>{
const url = new URL(canonicalUrl, typeof window === 'undefined' ? 'http://n' : window.location.href);
return {
// This is turned into a readonly class in `useSearchParams`
searchParams: url.searchParams,
pathname: (0, _hasbasepath.hasBasePath)(url.pathname) ? (0, _removebasepath.removeBasePath)(url.pathname) : url.pathname
};
}, [
canonicalUrl
]);
if (process.env.NODE_ENV !== 'production') {
const { cache, tree } = state;
// This hook is in a conditional but that is ok because `process.env.NODE_ENV` never changes
// eslint-disable-next-line react-hooks/rules-of-hooks
(0, _react.useEffect)(()=>{
// Add `window.nd` for debugging purposes.
// This is not meant for use in applications as concurrent rendering will affect the cache/tree/router.
// @ts-ignore this is for debugging
window.nd = {
router: _approuterinstance.publicAppRouterInstance,
cache,
tree
};
}, [
cache,
tree
]);
}
(0, _react.useEffect)(()=>{
// If the app is restored from bfcache, it's possible that
// pushRef.mpaNavigation is true, which would mean that any re-render of this component
// would trigger the mpa navigation logic again from the lines below.
// This will restore the router to the initial state in the event that the app is restored from bfcache.
function handlePageShow(event) {
if (!event.persisted || !window.history.state?.__PRIVATE_NEXTJS_INTERNALS_TREE) {
return;
}
// Clear the pendingMpaPath value so that a subsequent MPA navigation to the same URL can be triggered.
// This is necessary because if the browser restored from bfcache, the pendingMpaPath would still be set to the value
// of the last MPA navigation.
globalMutable.pendingMpaPath = undefined;
(0, _useactionqueue.dispatchAppRouterAction)({
type: _routerreducertypes.ACTION_RESTORE,
url: new URL(window.location.href),
historyState: window.history.state.__PRIVATE_NEXTJS_INTERNALS_TREE
});
}
window.addEventListener('pageshow', handlePageShow);
return ()=>{
window.removeEventListener('pageshow', handlePageShow);
};
}, []);
(0, _react.useEffect)(()=>{
// Ensure that any redirect errors that bubble up outside of the RedirectBoundary
// are caught and handled by the router.
function handleUnhandledRedirect(event) {
const error = 'reason' in event ? event.reason : event.error;
if ((0, _redirecterror.isRedirectError)(error)) {
event.preventDefault();
const url = (0, _redirect.getURLFromRedirectError)(error);
const redirectType = (0, _redirect.getRedirectTypeFromError)(error);
// TODO: This should access the router methods directly, rather than
// go through the public interface.
if (redirectType === _redirecterror.RedirectType.push) {
_approuterinstance.publicAppRouterInstance.push(url, {});
} else {
_approuterinstance.publicAppRouterInstance.replace(url, {});
}
}
}
window.addEventListener('error', handleUnhandledRedirect);
window.addEventListener('unhandledrejection', handleUnhandledRedirect);
return ()=>{
window.removeEventListener('error', handleUnhandledRedirect);
window.removeEventListener('unhandledrejection', handleUnhandledRedirect);
};
}, []);
// When mpaNavigation flag is set do a hard navigation to the new url.
// Infinitely suspend because we don't actually want to rerender any child
// components with the new URL and any entangled state updates shouldn't
// commit either (eg: useTransition isPending should stay true until the page
// unloads).
//
// This is a side effect in render. Don't try this at home, kids. It's
// probably safe because we know this is a singleton component and it's never
// in <Offscreen>. At least I hope so. (It will run twice in dev strict mode,
// but that's... fine?)
const { pushRef } = state;
if (pushRef.mpaNavigation) {
// if there's a re-render, we don't want to trigger another redirect if one is already in flight to the same URL
if (globalMutable.pendingMpaPath !== canonicalUrl) {
const location = window.location;
if (pushRef.pendingPush) {
location.assign(canonicalUrl);
} else {
location.replace(canonicalUrl);
}
globalMutable.pendingMpaPath = canonicalUrl;
}
// TODO-APP: Should we listen to navigateerror here to catch failed
// navigations somehow? And should we call window.stop() if a SPA navigation
// should interrupt an MPA one?
// NOTE: This is intentionally using `throw` instead of `use` because we're
// inside an externally mutable condition (pushRef.mpaNavigation), which
// violates the rules of hooks.
throw _unresolvedthenable.unresolvedThenable;
}
(0, _react.useEffect)(()=>{
const originalPushState = window.history.pushState.bind(window.history);
const originalReplaceState = window.history.replaceState.bind(window.history);
// Ensure the canonical URL in the Next.js Router is updated when the URL is changed so that `usePathname` and `useSearchParams` hold the pushed values.
const applyUrlFromHistoryPushReplace = (url)=>{
const href = window.location.href;
const appHistoryState = window.history.state?.__PRIVATE_NEXTJS_INTERNALS_TREE;
(0, _react.startTransition)(()=>{
(0, _useactionqueue.dispatchAppRouterAction)({
type: _routerreducertypes.ACTION_RESTORE,
url: new URL(url ?? href, href),
historyState: appHistoryState
});
});
};
/**
* Patch pushState to ensure external changes to the history are reflected in the Next.js Router.
* Ensures Next.js internal history state is copied to the new history entry.
* Ensures usePathname and useSearchParams hold the newly provided url.
*/ window.history.pushState = function pushState(data, _unused, url) {
// TODO: Warn when Navigation API is available (navigation.navigate() should be used)
// Avoid a loop when Next.js internals trigger pushState/replaceState
if (data?.__NA || data?._N) {
return originalPushState(data, _unused, url);
}
data = copyNextJsInternalHistoryState(data);
if (url) {
applyUrlFromHistoryPushReplace(url);
}
return originalPushState(data, _unused, url);
};
/**
* Patch replaceState to ensure external changes to the history are reflected in the Next.js Router.
* Ensures Next.js internal history state is copied to the new history entry.
* Ensures usePathname and useSearchParams hold the newly provided url.
*/ window.history.replaceState = function replaceState(data, _unused, url) {
// TODO: Warn when Navigation API is available (navigation.navigate() should be used)
// Avoid a loop when Next.js internals trigger pushState/replaceState
if (data?.__NA || data?._N) {
return originalReplaceState(data, _unused, url);
}
data = copyNextJsInternalHistoryState(data);
if (url) {
applyUrlFromHistoryPushReplace(url);
}
return originalReplaceState(data, _unused, url);
};
/**
* Handle popstate event, this is used to handle back/forward in the browser.
* By default dispatches ACTION_RESTORE, however if the history entry was not pushed/replaced by app-router it will reload the page.
* That case can happen when the old router injected the history entry.
*/ const onPopState = (event)=>{
if (!event.state) {
// TODO-APP: this case only happens when pushState/replaceState was called outside of Next.js. It should probably reload the page in this case.
return;
}
// This case happens when the history entry was pushed by the `pages` router.
if (!event.state.__NA) {
window.location.reload();
return;
}
// TODO-APP: Ideally the back button should not use startTransition as it should apply the updates synchronously
// Without startTransition works if the cache is there for this path
(0, _react.startTransition)(()=>{
(0, _approuterinstance.dispatchTraverseAction)(window.location.href, event.state.__PRIVATE_NEXTJS_INTERNALS_TREE);
});
};
// Register popstate event to call onPopstate.
window.addEventListener('popstate', onPopState);
return ()=>{
window.history.pushState = originalPushState;
window.history.replaceState = originalReplaceState;
window.removeEventListener('popstate', onPopState);
};
}, []);
const { cache, tree, nextUrl, focusAndScrollRef, previousNextUrl } = state;
const matchingHead = (0, _react.useMemo)(()=>{
return (0, _findheadincache.findHeadInCache)(cache, tree[1]);
}, [
cache,
tree
]);
// Add memoized pathParams for useParams.
const pathParams = (0, _react.useMemo)(()=>{
return (0, _computechangedpath.getSelectedParams)(tree);
}, [
tree
]);
// Create instrumented promises for navigation hooks (dev-only)
// These are specially instrumented promises to show in the Suspense DevTools
// Promises are cached outside of render to survive suspense retries.
let instrumentedNavigationPromises = null;
if (process.env.NODE_ENV !== 'production') {
const { createRootNavigationPromises } = require('./navigation-devtools');
instrumentedNavigationPromises = createRootNavigationPromises(tree, pathname, searchParams, pathParams);
}
const layoutRouterContext = (0, _react.useMemo)(()=>{
return {
parentTree: tree,
parentCacheNode: cache,
parentSegmentPath: null,
parentParams: {},
// This is the <Activity> "name" that shows up in the Suspense DevTools.
// It represents the root of the app.
debugNameContext: '/',
// Root node always has `url`
// Provided in AppTreeContext to ensure it can be overwritten in layout-router
url: canonicalUrl,
// Root segment is always active
isActive: true
};
}, [
tree,
cache,
canonicalUrl
]);
const globalLayoutRouterContext = (0, _react.useMemo)(()=>{
return {
tree,
focusAndScrollRef,
nextUrl,
previousNextUrl
};
}, [
tree,
focusAndScrollRef,
nextUrl,
previousNextUrl
]);
let head;
if (matchingHead !== null) {
// The head is wrapped in an extra component so we can use
// `useDeferredValue` to swap between the prefetched and final versions of
// the head. (This is what LayoutRouter does for segment data, too.)
//
// The `key` is used to remount the component whenever the head moves to
// a different segment.
const [headCacheNode, headKey, headKeyWithoutSearchParams] = matchingHead;
head = /*#__PURE__*/ (0, _jsxruntime.jsx)(Head, {
headCacheNode: headCacheNode
}, // Necessary for PPR: omit search params from the key to match prerendered keys
typeof window === 'undefined' ? headKeyWithoutSearchParams : headKey);
} else {
head = null;
}
let content = /*#__PURE__*/ (0, _jsxruntime.jsxs)(_redirectboundary.RedirectBoundary, {
children: [
head,
/*#__PURE__*/ (0, _jsxruntime.jsx)(_boundarycomponents.RootLayoutBoundary, {
children: cache.rsc
}),
/*#__PURE__*/ (0, _jsxruntime.jsx)(_approuterannouncer.AppRouterAnnouncer, {
tree: tree
})
]
});
if (process.env.NODE_ENV !== 'production') {
// In development, we apply few error boundaries and hot-reloader:
// - DevRootHTTPAccessFallbackBoundary: avoid using navigation API like notFound() in root layout
// - HotReloader:
// - hot-reload the app when the code changes
// - render dev overlay
// - catch runtime errors and display global-error when necessary
if (typeof window !== 'undefined') {
const { DevRootHTTPAccessFallbackBoundary } = require('./dev-root-http-access-fallback-boundary');
content = /*#__PURE__*/ (0, _jsxruntime.jsx)(DevRootHTTPAccessFallbackBoundary, {
children: content
});
}
const HotReloader = require('../dev/hot-reloader/app/hot-reloader-app').default;
content = /*#__PURE__*/ (0, _jsxruntime.jsx)(HotReloader, {
globalError: globalError,
webSocket: webSocket,
staticIndicatorState: staticIndicatorState,
children: content
});
} else {
content = /*#__PURE__*/ (0, _jsxruntime.jsx)(_rooterrorboundary.default, {
errorComponent: globalError[0],
errorStyles: globalError[1],
children: content
});
}
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)(HistoryUpdater, {
appRouterState: state
}),
/*#__PURE__*/ (0, _jsxruntime.jsx)(RuntimeStyles, {}),
/*#__PURE__*/ (0, _jsxruntime.jsx)(_hooksclientcontextsharedruntime.NavigationPromisesContext.Provider, {
value: instrumentedNavigationPromises,
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_hooksclientcontextsharedruntime.PathParamsContext.Provider, {
value: pathParams,
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_hooksclientcontextsharedruntime.PathnameContext.Provider, {
value: pathname,
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_hooksclientcontextsharedruntime.SearchParamsContext.Provider, {
value: searchParams,
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_approutercontextsharedruntime.GlobalLayoutRouterContext.Provider, {
value: globalLayoutRouterContext,
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_approutercontextsharedruntime.AppRouterContext.Provider, {
value: _approuterinstance.publicAppRouterInstance,
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_approutercontextsharedruntime.LayoutRouterContext.Provider, {
value: layoutRouterContext,
children: content
})
})
})
})
})
})
})
]
});
}
function AppRouter({ actionQueue, globalErrorState, webSocket, staticIndicatorState }) {
(0, _navfailurehandler.useNavFailureHandler)();
const router = /*#__PURE__*/ (0, _jsxruntime.jsx)(Router, {
actionQueue: actionQueue,
globalError: globalErrorState,
webSocket: webSocket,
staticIndicatorState: staticIndicatorState
});
// At the very top level, use the default GlobalError component as the final fallback.
// When the app router itself fails, which means the framework itself fails, we show the default error.
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_rooterrorboundary.default, {
errorComponent: _globalerror.default,
children: router
});
}
const runtimeStyles = new Set();
let runtimeStyleChanged = new Set();
globalThis._N_E_STYLE_LOAD = function(href) {
let len = runtimeStyles.size;
runtimeStyles.add(href);
if (runtimeStyles.size !== len) {
runtimeStyleChanged.forEach((cb)=>cb());
}
// TODO figure out how to get a promise here
// But maybe it's not necessary as react would block rendering until it's loaded
return Promise.resolve();
};
function RuntimeStyles() {
const [, forceUpdate] = _react.default.useState(0);
const renderedStylesSize = runtimeStyles.size;
(0, _react.useEffect)(()=>{
const changed = ()=>forceUpdate((c)=>c + 1);
runtimeStyleChanged.add(changed);
if (renderedStylesSize !== runtimeStyles.size) {
changed();
}
return ()=>{
runtimeStyleChanged.delete(changed);
};
}, [
renderedStylesSize,
forceUpdate
]);
const dplId = (0, _deploymentid.getDeploymentIdQueryOrEmptyString)();
return [
...runtimeStyles
].map((href, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)("link", {
rel: "stylesheet",
href: `${href}${dplId}`,
// @ts-ignore
precedence: "next"
}, i));
}
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=app-router.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,27 @@
import type { FlightRouterState } from '../../shared/lib/app-router-types';
export type RouterBFCacheEntry = {
tree: FlightRouterState;
stateKey: string;
next: RouterBFCacheEntry | null;
};
/**
* Keeps track of the most recent N trees (FlightRouterStates) that were active
* at a certain segment level. E.g. for a segment "/a/b/[param]", this hook
* tracks the last N param values that the router rendered for N.
*
* The result of this hook precisely determines the number and order of
* trees that are rendered in parallel at their segment level.
*
* The purpose of this cache is to we can preserve the React and DOM state of
* some number of inactive trees, by rendering them in an <Activity> boundary.
* That means it would not make sense for the the lifetime of the cache to be
* any longer than the lifetime of the React tree; e.g. if the hook were
* unmounted, then the React tree would be, too. So, we use React state to
* manage it.
*
* Note that we don't store the RSC data for the cache entries in this hook —
* the data for inactive segments is stored in the parent CacheNode, which
* *does* have a longer lifetime than the React tree. This hook only determines
* which of those trees should have their *state* preserved, by <Activity>.
*/
export declare function useRouterBFCache(activeTree: FlightRouterState, activeStateKey: string): RouterBFCacheEntry;

View File

@@ -0,0 +1,90 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "useRouterBFCache", {
enumerable: true,
get: function() {
return useRouterBFCache;
}
});
const _react = require("react");
// When the flag is disabled, only track the currently active tree
const MAX_BF_CACHE_ENTRIES = process.env.__NEXT_CACHE_COMPONENTS ? 3 : 1;
function useRouterBFCache(activeTree, activeStateKey) {
// The currently active entry. The entries form a linked list, sorted in
// order of most recently active. This allows us to reuse parts of the list
// without cloning, unless there's a reordering or removal.
// TODO: Once we start tracking back/forward history at each route level,
// we should use the history order instead. In other words, when traversing
// to an existing entry as a result of a popstate event, we should maintain
// the existing order instead of moving it to the front of the list. I think
// an initial implementation of this could be to pass an incrementing id
// to history.pushState/replaceState, then use that here for ordering.
const [prevActiveEntry, setPrevActiveEntry] = (0, _react.useState)(()=>{
const initialEntry = {
tree: activeTree,
stateKey: activeStateKey,
next: null
};
return initialEntry;
});
if (prevActiveEntry.tree === activeTree) {
// Fast path. The active tree hasn't changed, so we can reuse the
// existing state.
return prevActiveEntry;
}
// The route tree changed. Note that this doesn't mean that the tree changed
// *at this level* — the change may be due to a child route. Either way, we
// need to either add or update the router tree in the bfcache.
//
// The rest of the code looks more complicated than it actually is because we
// can't mutate the state in place; we have to copy-on-write.
// Create a new entry for the active cache key. This is the head of the new
// linked list.
const newActiveEntry = {
tree: activeTree,
stateKey: activeStateKey,
next: null
};
// We need to append the old list onto the new list. If the head of the new
// list was already present in the cache, then we'll need to clone everything
// that came before it. Then we can reuse the rest.
let n = 1;
let oldEntry = prevActiveEntry;
let clonedEntry = newActiveEntry;
while(oldEntry !== null && n < MAX_BF_CACHE_ENTRIES){
if (oldEntry.stateKey === activeStateKey) {
// Fast path. This entry in the old list that corresponds to the key that
// is now active. We've already placed a clone of this entry at the front
// of the new list. We can reuse the rest of the old list without cloning.
// NOTE: We don't need to worry about eviction in this case because we
// haven't increased the size of the cache, and we assume the max size
// is constant across renders. If we were to change it to a dynamic limit,
// then the implementation would need to account for that.
clonedEntry.next = oldEntry.next;
break;
} else {
// Clone the entry and append it to the list.
n++;
const entry = {
tree: oldEntry.tree,
stateKey: oldEntry.stateKey,
next: null
};
clonedEntry.next = entry;
clonedEntry = entry;
}
oldEntry = oldEntry.next;
}
setPrevActiveEntry(newActiveEntry);
return newActiveEntry;
}
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=bfcache.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
declare function AppError(): import("react/jsx-runtime").JSX.Element;
export default AppError;

View File

@@ -0,0 +1,107 @@
"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 _jsxruntime = require("react/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_default._(require("react"));
const styles = {
error: {
// https://github.com/sindresorhus/modern-normalize/blob/main/modern-normalize.css#L38-L52
fontFamily: 'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',
height: '100vh',
textAlign: 'center',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center'
},
desc: {
lineHeight: '48px'
},
h1: {
display: 'inline-block',
margin: '0 20px 0 0',
paddingRight: 23,
fontSize: 24,
fontWeight: 500,
verticalAlign: 'top'
},
h2: {
fontSize: 14,
fontWeight: 400,
lineHeight: '28px'
},
wrap: {
display: 'inline-block'
}
};
/* CSS minified from
body { margin: 0; color: #000; background: #fff; }
.next-error-h1 {
border-right: 1px solid rgba(0, 0, 0, .3);
}
@media (prefers-color-scheme: dark) {
body { color: #fff; background: #000; }
.next-error-h1 {
border-right: 1px solid rgba(255, 255, 255, .3);
}
}
*/ const themeCss = `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}
@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`;
function AppError() {
const errorMessage = 'Internal Server Error.';
const title = `500: ${errorMessage}`;
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("html", {
id: "__next_error__",
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)("head", {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("title", {
children: title
})
}),
/*#__PURE__*/ (0, _jsxruntime.jsx)("body", {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
style: styles.error,
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
style: styles.desc,
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)("style", {
dangerouslySetInnerHTML: {
__html: themeCss
}
}),
/*#__PURE__*/ (0, _jsxruntime.jsx)("h1", {
className: "next-error-h1",
style: styles.h1,
children: "500"
}),
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
style: styles.wrap,
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("h2", {
style: styles.h2,
children: errorMessage
})
})
]
})
})
})
]
});
}
const _default = AppError;
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=app-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/builtin/app-error.tsx"],"sourcesContent":["import React from 'react'\n\nconst styles: Record<string, React.CSSProperties> = {\n error: {\n // https://github.com/sindresorhus/modern-normalize/blob/main/modern-normalize.css#L38-L52\n fontFamily:\n 'system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"',\n height: '100vh',\n textAlign: 'center',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n },\n desc: {\n lineHeight: '48px',\n },\n h1: {\n display: 'inline-block',\n margin: '0 20px 0 0',\n paddingRight: 23,\n fontSize: 24,\n fontWeight: 500,\n verticalAlign: 'top',\n },\n h2: {\n fontSize: 14,\n fontWeight: 400,\n lineHeight: '28px',\n },\n wrap: {\n display: 'inline-block',\n },\n} as const\n\n/* CSS minified from\nbody { margin: 0; color: #000; background: #fff; }\n.next-error-h1 {\n border-right: 1px solid rgba(0, 0, 0, .3);\n}\n@media (prefers-color-scheme: dark) {\n body { color: #fff; background: #000; }\n .next-error-h1 {\n border-right: 1px solid rgba(255, 255, 255, .3);\n }\n}\n*/\nconst themeCss = `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}\n@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`\n\nfunction AppError() {\n const errorMessage = 'Internal Server Error.'\n const title = `500: ${errorMessage}`\n return (\n <html id=\"__next_error__\">\n <head>\n <title>{title}</title>\n </head>\n <body>\n <div style={styles.error}>\n <div style={styles.desc}>\n <style\n dangerouslySetInnerHTML={{\n __html: themeCss,\n }}\n />\n <h1 className=\"next-error-h1\" style={styles.h1}>\n 500\n </h1>\n <div style={styles.wrap}>\n <h2 style={styles.h2}>{errorMessage}</h2>\n </div>\n </div>\n </div>\n </body>\n </html>\n )\n}\n\nexport default AppError\n"],"names":["styles","error","fontFamily","height","textAlign","display","flexDirection","alignItems","justifyContent","desc","lineHeight","h1","margin","paddingRight","fontSize","fontWeight","verticalAlign","h2","wrap","themeCss","AppError","errorMessage","title","html","id","head","body","div","style","dangerouslySetInnerHTML","__html","className"],"mappings":";;;;+BA+EA;;;eAAA;;;;;gEA/EkB;AAElB,MAAMA,SAA8C;IAClDC,OAAO;QACL,0FAA0F;QAC1FC,YACE;QACFC,QAAQ;QACRC,WAAW;QACXC,SAAS;QACTC,eAAe;QACfC,YAAY;QACZC,gBAAgB;IAClB;IACAC,MAAM;QACJC,YAAY;IACd;IACAC,IAAI;QACFN,SAAS;QACTO,QAAQ;QACRC,cAAc;QACdC,UAAU;QACVC,YAAY;QACZC,eAAe;IACjB;IACAC,IAAI;QACFH,UAAU;QACVC,YAAY;QACZL,YAAY;IACd;IACAQ,MAAM;QACJb,SAAS;IACX;AACF;AAEA;;;;;;;;;;;AAWA,GACA,MAAMc,WAAW,CAAC;+HAC6G,CAAC;AAEhI,SAASC;IACP,MAAMC,eAAe;IACrB,MAAMC,QAAQ,CAAC,KAAK,EAAED,cAAc;IACpC,qBACE,sBAACE;QAAKC,IAAG;;0BACP,qBAACC;0BACC,cAAA,qBAACH;8BAAOA;;;0BAEV,qBAACI;0BACC,cAAA,qBAACC;oBAAIC,OAAO5B,OAAOC,KAAK;8BACtB,cAAA,sBAAC0B;wBAAIC,OAAO5B,OAAOS,IAAI;;0CACrB,qBAACmB;gCACCC,yBAAyB;oCACvBC,QAAQX;gCACV;;0CAEF,qBAACR;gCAAGoB,WAAU;gCAAgBH,OAAO5B,OAAOW,EAAE;0CAAE;;0CAGhD,qBAACgB;gCAAIC,OAAO5B,OAAOkB,IAAI;0CACrB,cAAA,qBAACD;oCAAGW,OAAO5B,OAAOiB,EAAE;8CAAGI;;;;;;;;;AAOrC;MAEA,WAAeD","ignoreList":[0]}

View File

@@ -0,0 +1,2 @@
export declare const PARALLEL_ROUTE_DEFAULT_NULL_PATH = "next/dist/client/components/builtin/default-null.js";
export default function ParallelRouteDefaultNull(): null;

View File

@@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
PARALLEL_ROUTE_DEFAULT_NULL_PATH: null,
default: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
PARALLEL_ROUTE_DEFAULT_NULL_PATH: function() {
return PARALLEL_ROUTE_DEFAULT_NULL_PATH;
},
default: function() {
return ParallelRouteDefaultNull;
}
});
const PARALLEL_ROUTE_DEFAULT_NULL_PATH = 'next/dist/client/components/builtin/default-null.js';
function ParallelRouteDefaultNull() {
return null;
}
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=default-null.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/builtin/default-null.tsx"],"sourcesContent":["export const PARALLEL_ROUTE_DEFAULT_NULL_PATH =\n 'next/dist/client/components/builtin/default-null.js'\n\nexport default function ParallelRouteDefaultNull() {\n return null\n}\n"],"names":["PARALLEL_ROUTE_DEFAULT_NULL_PATH","ParallelRouteDefaultNull"],"mappings":";;;;;;;;;;;;;;;IAAaA,gCAAgC;eAAhCA;;IAGb,OAEC;eAFuBC;;;AAHjB,MAAMD,mCACX;AAEa,SAASC;IACtB,OAAO;AACT","ignoreList":[0]}

View File

@@ -0,0 +1,2 @@
export declare const PARALLEL_ROUTE_DEFAULT_PATH = "next/dist/client/components/builtin/default.js";
export default function ParallelRouteDefault(): void;

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
PARALLEL_ROUTE_DEFAULT_PATH: null,
default: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
PARALLEL_ROUTE_DEFAULT_PATH: function() {
return PARALLEL_ROUTE_DEFAULT_PATH;
},
default: function() {
return ParallelRouteDefault;
}
});
const _notfound = require("../not-found");
const PARALLEL_ROUTE_DEFAULT_PATH = 'next/dist/client/components/builtin/default.js';
function ParallelRouteDefault() {
(0, _notfound.notFound)();
}
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=default.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/builtin/default.tsx"],"sourcesContent":["import { notFound } from '../not-found'\n\nexport const PARALLEL_ROUTE_DEFAULT_PATH =\n 'next/dist/client/components/builtin/default.js'\n\nexport default function ParallelRouteDefault() {\n notFound()\n}\n"],"names":["PARALLEL_ROUTE_DEFAULT_PATH","ParallelRouteDefault","notFound"],"mappings":";;;;;;;;;;;;;;;IAEaA,2BAA2B;eAA3BA;;IAGb,OAEC;eAFuBC;;;0BALC;AAElB,MAAMD,8BACX;AAEa,SAASC;IACtBC,IAAAA,kBAAQ;AACV","ignoreList":[0]}

View File

@@ -0,0 +1 @@
export default function Empty(): null;

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return Empty;
}
});
function Empty() {
return null;
}
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=empty-stub.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/builtin/empty-stub.tsx"],"sourcesContent":["export default function Empty() {\n return null\n}\n"],"names":["Empty"],"mappings":";;;;+BAAA;;;eAAwBA;;;AAAT,SAASA;IACtB,OAAO;AACT","ignoreList":[0]}

View File

@@ -0,0 +1 @@
export default function Forbidden(): import("react/jsx-runtime").JSX.Element;

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return Forbidden;
}
});
const _jsxruntime = require("react/jsx-runtime");
const _errorfallback = require("../http-access-fallback/error-fallback");
function Forbidden() {
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_errorfallback.HTTPAccessErrorFallback, {
status: 403,
message: "This page could not be accessed."
});
}
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=forbidden.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/builtin/forbidden.tsx"],"sourcesContent":["import { HTTPAccessErrorFallback } from '../http-access-fallback/error-fallback'\n\nexport default function Forbidden() {\n return (\n <HTTPAccessErrorFallback\n status={403}\n message=\"This page could not be accessed.\"\n />\n )\n}\n"],"names":["Forbidden","HTTPAccessErrorFallback","status","message"],"mappings":";;;;+BAEA;;;eAAwBA;;;;+BAFgB;AAEzB,SAASA;IACtB,qBACE,qBAACC,sCAAuB;QACtBC,QAAQ;QACRC,SAAQ;;AAGd","ignoreList":[0]}

View File

@@ -0,0 +1,7 @@
export type GlobalErrorComponent = React.ComponentType<{
error: any;
}>;
declare function DefaultGlobalError({ error }: {
error: any;
}): import("react/jsx-runtime").JSX.Element;
export default DefaultGlobalError;

View File

@@ -0,0 +1,82 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, // Exported so that the import signature in the loaders can be identical to user
// supplied custom global error signatures.
"default", {
enumerable: true,
get: function() {
return _default;
}
});
const _jsxruntime = require("react/jsx-runtime");
const _handleisrerror = require("../handle-isr-error");
const styles = {
error: {
// https://github.com/sindresorhus/modern-normalize/blob/main/modern-normalize.css#L38-L52
fontFamily: 'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',
height: '100vh',
textAlign: 'center',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center'
},
text: {
fontSize: '14px',
fontWeight: 400,
lineHeight: '28px',
margin: '0 8px'
}
};
function DefaultGlobalError({ error }) {
const digest = error?.digest;
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("html", {
id: "__next_error__",
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)("head", {}),
/*#__PURE__*/ (0, _jsxruntime.jsxs)("body", {
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)(_handleisrerror.HandleISRError, {
error: error
}),
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
style: styles.error,
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
children: [
/*#__PURE__*/ (0, _jsxruntime.jsxs)("h2", {
style: styles.text,
children: [
"Application error: a ",
digest ? 'server' : 'client',
"-side exception has occurred while loading ",
window.location.hostname,
" (see the",
' ',
digest ? 'server logs' : 'browser console',
" for more information)."
]
}),
digest ? /*#__PURE__*/ (0, _jsxruntime.jsx)("p", {
style: styles.text,
children: `Digest: ${digest}`
}) : null
]
})
})
]
})
]
});
}
const _default = DefaultGlobalError;
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=global-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/builtin/global-error.tsx"],"sourcesContent":["'use client'\n\nimport { HandleISRError } from '../handle-isr-error'\n\nconst styles = {\n error: {\n // https://github.com/sindresorhus/modern-normalize/blob/main/modern-normalize.css#L38-L52\n fontFamily:\n 'system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"',\n height: '100vh',\n textAlign: 'center',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n },\n text: {\n fontSize: '14px',\n fontWeight: 400,\n lineHeight: '28px',\n margin: '0 8px',\n },\n} as const\n\nexport type GlobalErrorComponent = React.ComponentType<{\n error: any\n}>\nfunction DefaultGlobalError({ error }: { error: any }) {\n const digest: string | undefined = error?.digest\n return (\n <html id=\"__next_error__\">\n <head></head>\n <body>\n <HandleISRError error={error} />\n <div style={styles.error}>\n <div>\n <h2 style={styles.text}>\n Application error: a {digest ? 'server' : 'client'}-side exception\n has occurred while loading {window.location.hostname} (see the{' '}\n {digest ? 'server logs' : 'browser console'} for more\n information).\n </h2>\n {digest ? <p style={styles.text}>{`Digest: ${digest}`}</p> : null}\n </div>\n </div>\n </body>\n </html>\n )\n}\n\n// Exported so that the import signature in the loaders can be identical to user\n// supplied custom global error signatures.\nexport default DefaultGlobalError\n"],"names":["styles","error","fontFamily","height","textAlign","display","flexDirection","alignItems","justifyContent","text","fontSize","fontWeight","lineHeight","margin","DefaultGlobalError","digest","html","id","head","body","HandleISRError","div","style","h2","window","location","hostname","p"],"mappings":"AAAA;;;;;+BAkDA,gFAAgF;AAChF,2CAA2C;AAC3C;;;eAAA;;;;gCAlD+B;AAE/B,MAAMA,SAAS;IACbC,OAAO;QACL,0FAA0F;QAC1FC,YACE;QACFC,QAAQ;QACRC,WAAW;QACXC,SAAS;QACTC,eAAe;QACfC,YAAY;QACZC,gBAAgB;IAClB;IACAC,MAAM;QACJC,UAAU;QACVC,YAAY;QACZC,YAAY;QACZC,QAAQ;IACV;AACF;AAKA,SAASC,mBAAmB,EAAEb,KAAK,EAAkB;IACnD,MAAMc,SAA6Bd,OAAOc;IAC1C,qBACE,sBAACC;QAAKC,IAAG;;0BACP,qBAACC;0BACD,sBAACC;;kCACC,qBAACC,8BAAc;wBAACnB,OAAOA;;kCACvB,qBAACoB;wBAAIC,OAAOtB,OAAOC,KAAK;kCACtB,cAAA,sBAACoB;;8CACC,sBAACE;oCAAGD,OAAOtB,OAAOS,IAAI;;wCAAE;wCACAM,SAAS,WAAW;wCAAS;wCACvBS,OAAOC,QAAQ,CAACC,QAAQ;wCAAC;wCAAU;wCAC9DX,SAAS,gBAAgB;wCAAkB;;;gCAG7CA,uBAAS,qBAACY;oCAAEL,OAAOtB,OAAOS,IAAI;8CAAG,CAAC,QAAQ,EAAEM,QAAQ;qCAAQ;;;;;;;;AAMzE;MAIA,WAAeD","ignoreList":[0]}

View File

@@ -0,0 +1,2 @@
declare function GlobalNotFound(): import("react/jsx-runtime").JSX.Element;
export default GlobalNotFound;

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return _default;
}
});
const _jsxruntime = require("react/jsx-runtime");
const _errorfallback = require("../http-access-fallback/error-fallback");
function GlobalNotFound() {
return /*#__PURE__*/ (0, _jsxruntime.jsx)("html", {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("body", {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_errorfallback.HTTPAccessErrorFallback, {
status: 404,
message: 'This page could not be found.'
})
})
});
}
const _default = GlobalNotFound;
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=global-not-found.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/builtin/global-not-found.tsx"],"sourcesContent":["import { HTTPAccessErrorFallback } from '../http-access-fallback/error-fallback'\n\nfunction GlobalNotFound() {\n return (\n <html>\n <body>\n <HTTPAccessErrorFallback\n status={404}\n message={'This page could not be found.'}\n />\n </body>\n </html>\n )\n}\n\nexport default GlobalNotFound\n"],"names":["GlobalNotFound","html","body","HTTPAccessErrorFallback","status","message"],"mappings":";;;;+BAeA;;;eAAA;;;;+BAfwC;AAExC,SAASA;IACP,qBACE,qBAACC;kBACC,cAAA,qBAACC;sBACC,cAAA,qBAACC,sCAAuB;gBACtBC,QAAQ;gBACRC,SAAS;;;;AAKnB;MAEA,WAAeL","ignoreList":[0]}

View File

@@ -0,0 +1,4 @@
import React from 'react';
export default function DefaultLayout({ children, }: {
children: React.ReactNode;
}): import("react/jsx-runtime").JSX.Element;

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function() {
return DefaultLayout;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _jsxruntime = require("react/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_default._(require("react"));
function DefaultLayout({ children }) {
return /*#__PURE__*/ (0, _jsxruntime.jsx)("html", {
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("body", {
children: children
})
});
}
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=layout.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/builtin/layout.tsx"],"sourcesContent":["import React from 'react'\n\nexport default function DefaultLayout({\n children,\n}: {\n children: React.ReactNode\n}) {\n return (\n <html>\n <body>{children}</body>\n </html>\n )\n}\n"],"names":["DefaultLayout","children","html","body"],"mappings":";;;;+BAEA;;;eAAwBA;;;;;gEAFN;AAEH,SAASA,cAAc,EACpCC,QAAQ,EAGT;IACC,qBACE,qBAACC;kBACC,cAAA,qBAACC;sBAAMF;;;AAGb","ignoreList":[0]}

View File

@@ -0,0 +1 @@
export default function NotFound(): import("react/jsx-runtime").JSX.Element;

Some files were not shown because too many files have changed in this diff Show More