main repo

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

View File

@@ -0,0 +1,4 @@
import { createAsyncLocalStorage } from "./async-local-storage";
export const actionAsyncStorage = createAsyncLocalStorage();
//# sourceMappingURL=action-async-storage.external.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/action-async-storage.external.ts"],"names":["createAsyncLocalStorage","actionAsyncStorage"],"mappings":"AACA,SAASA,uBAAuB,QAAQ,wBAAuB;AAS/D,OAAO,MAAMC,qBAAyCD,0BAAyB"}

View File

@@ -0,0 +1,64 @@
import { useEffect, useRef, useState } from "react";
import { createPortal } from "react-dom";
const ANNOUNCER_TYPE = "next-route-announcer";
const ANNOUNCER_ID = "__next-route-announcer__";
function getAnnouncerNode() {
var _existingAnnouncer_shadowRoot;
const existingAnnouncer = document.getElementsByName(ANNOUNCER_TYPE)[0];
if (existingAnnouncer == null ? void 0 : (_existingAnnouncer_shadowRoot = existingAnnouncer.shadowRoot) == null ? void 0 : _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;
}
}
export function AppRouterAnnouncer(param) {
let { tree } = param;
const [portalNode, setPortalNode] = useState(null);
useEffect(()=>{
const announcer = getAnnouncerNode();
setPortalNode(announcer);
return ()=>{
const container = document.getElementsByTagName(ANNOUNCER_TYPE)[0];
if (container == null ? void 0 : container.isConnected) {
document.body.removeChild(container);
}
};
}, []);
const [routeAnnouncement, setRouteAnnouncement] = useState("");
const previousTitle = useRef();
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__*/ createPortal(routeAnnouncement, portalNode) : null;
}
//# sourceMappingURL=app-router-announcer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/app-router-announcer.tsx"],"names":["useEffect","useRef","useState","createPortal","ANNOUNCER_TYPE","ANNOUNCER_ID","getAnnouncerNode","existingAnnouncer","document","getElementsByName","shadowRoot","childNodes","container","createElement","style","cssText","announcer","ariaLive","id","role","shadow","attachShadow","mode","appendChild","body","AppRouterAnnouncer","tree","portalNode","setPortalNode","getElementsByTagName","isConnected","removeChild","routeAnnouncement","setRouteAnnouncement","previousTitle","currentTitle","title","pageHeader","querySelector","innerText","textContent","current","undefined"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACnD,SAASC,YAAY,QAAQ,YAAW;AAGxC,MAAMC,iBAAiB;AACvB,MAAMC,eAAe;AAErB,SAASC;QAEHC;IADJ,MAAMA,oBAAoBC,SAASC,iBAAiB,CAACL,eAAe,CAAC,EAAE;IACvE,IAAIG,sCAAAA,gCAAAA,kBAAmBG,UAAU,qBAA7BH,8BAA+BI,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,SAAS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export const ACTION = "Next-Action";
export const NEXT_ROUTER_STATE_TREE = "Next-Router-State-Tree";
export const NEXT_ROUTER_PREFETCH = "Next-Router-Prefetch";
export const NEXT_URL = "Next-Url";
export const RSC_CONTENT_TYPE_HEADER = "text/x-component";
export const RSC_VARY_HEADER = RSC + ", " + NEXT_ROUTER_STATE_TREE + ", " + NEXT_ROUTER_PREFETCH + ", " + NEXT_URL;
export const FLIGHT_PARAMETERS = [
[
RSC
],
[
NEXT_ROUTER_STATE_TREE
],
[
NEXT_ROUTER_PREFETCH
]
];
export const NEXT_RSC_UNION_QUERY = "_rsc";
//# sourceMappingURL=app-router-headers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/app-router-headers.ts"],"names":["RSC","ACTION","NEXT_ROUTER_STATE_TREE","NEXT_ROUTER_PREFETCH","NEXT_URL","RSC_CONTENT_TYPE_HEADER","RSC_VARY_HEADER","FLIGHT_PARAMETERS","NEXT_RSC_UNION_QUERY"],"mappings":"AAAA,OAAO,MAAMA,MAAM,MAAc;AACjC,OAAO,MAAMC,SAAS,cAAsB;AAE5C,OAAO,MAAMC,yBAAyB,yBAAiC;AACvE,OAAO,MAAMC,uBAAuB,uBAA+B;AACnE,OAAO,MAAMC,WAAW,WAAmB;AAC3C,OAAO,MAAMC,0BAA0B,mBAA2B;AAClE,OAAO,MAAMC,kBACX,AAAGN,MAAI,OAAIE,yBAAuB,OAAIC,uBAAqB,OAAIC,SAAmB;AAEpF,OAAO,MAAMG,oBAAoB;IAC/B;QAACP;KAAI;IACL;QAACE;KAAuB;IACxB;QAACC;KAAqB;CACvB,CAAS;AAEV,OAAO,MAAMK,uBAAuB,OAAe"}

View File

@@ -0,0 +1,423 @@
"use client";
import React, { use, useEffect, useMemo, useCallback, startTransition, useInsertionEffect } from "react";
import { AppRouterContext, LayoutRouterContext, GlobalLayoutRouterContext, CacheStates } from "../../shared/lib/app-router-context.shared-runtime";
import { reducer } from "./router-reducer/router-reducer";
import { ACTION_FAST_REFRESH, ACTION_NAVIGATE, ACTION_PREFETCH, ACTION_REFRESH, ACTION_RESTORE, ACTION_SERVER_ACTION, ACTION_SERVER_PATCH, PrefetchKind } from "./router-reducer/router-reducer-types";
import { createHrefFromUrl } from "./router-reducer/create-href-from-url";
import { SearchParamsContext, PathnameContext } from "../../shared/lib/hooks-client-context.shared-runtime";
import { useReducerWithReduxDevtools } from "./use-reducer-with-devtools";
import { ErrorBoundary } from "./error-boundary";
import { createInitialRouterState } from "./router-reducer/create-initial-router-state";
import { isBot } from "../../shared/lib/router/utils/is-bot";
import { addBasePath } from "../add-base-path";
import { AppRouterAnnouncer } from "./app-router-announcer";
import { RedirectBoundary } from "./redirect-boundary";
import { findHeadInCache } from "./router-reducer/reducers/find-head-in-cache";
import { createInfinitePromise } from "./infinite-promise";
import { NEXT_RSC_UNION_QUERY } from "./app-router-headers";
import { removeBasePath } from "../remove-base-path";
import { hasBasePath } from "../has-base-path";
const isServer = typeof window === "undefined";
// Ensure the initialParallelRoutes are not combined because of double-rendering in the browser with Strict Mode.
let initialParallelRoutes = isServer ? null : new Map();
let globalServerActionDispatcher = null;
export function getServerActionDispatcher() {
return globalServerActionDispatcher;
}
let globalMutable = {
refresh: ()=>{}
};
export function urlToUrlWithoutFlightMarker(url) {
const urlWithoutFlightParameters = new URL(url, location.origin);
urlWithoutFlightParameters.searchParams.delete(NEXT_RSC_UNION_QUERY);
if (process.env.NODE_ENV === "production") {
if (process.env.__NEXT_CONFIG_OUTPUT === "export" && urlWithoutFlightParameters.pathname.endsWith(".txt")) {
const { pathname } = urlWithoutFlightParameters;
const length = pathname.endsWith("/index.txt") ? 10 : 4;
// Slice off `/index.txt` or `.txt` from the end of the pathname
urlWithoutFlightParameters.pathname = pathname.slice(0, -length);
}
}
return urlWithoutFlightParameters;
}
function isExternalURL(url) {
return url.origin !== window.location.origin;
}
function HistoryUpdater(param) {
let { tree, pushRef, canonicalUrl, sync } = param;
useInsertionEffect(()=>{
// 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.
const historyState = {
__NA: true,
tree
};
if (pushRef.pendingPush && 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);
}
sync();
}, [
tree,
pushRef,
canonicalUrl,
sync
]);
return null;
}
const createEmptyCacheNode = ()=>({
status: CacheStates.LAZY_INITIALIZED,
data: null,
subTreeData: null,
parallelRoutes: new Map()
});
function useServerActionDispatcher(dispatch) {
const serverActionDispatcher = useCallback((actionPayload)=>{
startTransition(()=>{
dispatch({
...actionPayload,
type: ACTION_SERVER_ACTION,
mutable: {
globalMutable
},
cache: createEmptyCacheNode()
});
});
}, [
dispatch
]);
globalServerActionDispatcher = serverActionDispatcher;
}
/**
* Server response that only patches the cache and tree.
*/ function useChangeByServerResponse(dispatch) {
return useCallback((previousTree, flightData, overrideCanonicalUrl)=>{
startTransition(()=>{
dispatch({
type: ACTION_SERVER_PATCH,
flightData,
previousTree,
overrideCanonicalUrl,
cache: createEmptyCacheNode(),
mutable: {
globalMutable
}
});
});
}, [
dispatch
]);
}
function useNavigate(dispatch) {
return useCallback((href, navigateType, forceOptimisticNavigation, shouldScroll)=>{
const url = new URL(addBasePath(href), location.href);
globalMutable.pendingNavigatePath = href;
return dispatch({
type: ACTION_NAVIGATE,
url,
isExternalUrl: isExternalURL(url),
locationSearch: location.search,
forceOptimisticNavigation,
shouldScroll: shouldScroll != null ? shouldScroll : true,
navigateType,
cache: createEmptyCacheNode(),
mutable: {
globalMutable
}
});
}, [
dispatch
]);
}
/**
* The global router that wraps the application components.
*/ function Router(param) {
let { buildId, initialHead, initialTree, initialCanonicalUrl, children, assetPrefix } = param;
const initialState = useMemo(()=>createInitialRouterState({
buildId,
children,
initialCanonicalUrl,
initialTree,
initialParallelRoutes,
isServer,
location: !isServer ? window.location : null,
initialHead
}), [
buildId,
children,
initialCanonicalUrl,
initialTree,
initialHead
]);
const [{ tree, cache, prefetchCache, pushRef, focusAndScrollRef, canonicalUrl, nextUrl }, dispatch, sync] = useReducerWithReduxDevtools(reducer, initialState);
useEffect(()=>{
// Ensure initialParallelRoutes is cleaned up from memory once it's used.
initialParallelRoutes = null;
}, []);
// Add memoized pathname/query for useSearchParams and usePathname.
const { searchParams, pathname } = 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: hasBasePath(url.pathname) ? removeBasePath(url.pathname) : url.pathname
};
}, [
canonicalUrl
]);
const changeByServerResponse = useChangeByServerResponse(dispatch);
const navigate = useNavigate(dispatch);
useServerActionDispatcher(dispatch);
/**
* The app router that is exposed through `useRouter`. It's only concerned with dispatching actions to the reducer, does not hold state.
*/ const appRouter = useMemo(()=>{
const routerInstance = {
back: ()=>window.history.back(),
forward: ()=>window.history.forward(),
prefetch: (href, options)=>{
// Don't prefetch for bots as they don't navigate.
// Don't prefetch during development (improves compilation performance)
if (isBot(window.navigator.userAgent) || process.env.NODE_ENV === "development") {
return;
}
const url = new URL(addBasePath(href), location.href);
// External urls can't be prefetched in the same way.
if (isExternalURL(url)) {
return;
}
startTransition(()=>{
var _options_kind;
dispatch({
type: ACTION_PREFETCH,
url,
kind: (_options_kind = options == null ? void 0 : options.kind) != null ? _options_kind : PrefetchKind.FULL
});
});
},
replace: (href, options)=>{
if (options === void 0) options = {};
startTransition(()=>{
var _options_scroll;
navigate(href, "replace", Boolean(options.forceOptimisticNavigation), (_options_scroll = options.scroll) != null ? _options_scroll : true);
});
},
push: (href, options)=>{
if (options === void 0) options = {};
startTransition(()=>{
var _options_scroll;
navigate(href, "push", Boolean(options.forceOptimisticNavigation), (_options_scroll = options.scroll) != null ? _options_scroll : true);
});
},
refresh: ()=>{
startTransition(()=>{
dispatch({
type: ACTION_REFRESH,
cache: createEmptyCacheNode(),
mutable: {
globalMutable
},
origin: window.location.origin
});
});
},
// @ts-ignore we don't want to expose this method at all
fastRefresh: ()=>{
if (process.env.NODE_ENV !== "development") {
throw new Error("fastRefresh can only be used in development mode. Please use refresh instead.");
} else {
startTransition(()=>{
dispatch({
type: ACTION_FAST_REFRESH,
cache: createEmptyCacheNode(),
mutable: {
globalMutable
},
origin: window.location.origin
});
});
}
}
};
return routerInstance;
}, [
dispatch,
navigate
]);
useEffect(()=>{
// Exists for debugging purposes. Don't use in application code.
if (window.next) {
window.next.router = appRouter;
}
}, [
appRouter
]);
useEffect(()=>{
globalMutable.refresh = appRouter.refresh;
}, [
appRouter.refresh
]);
if (process.env.NODE_ENV !== "production") {
// 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
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: appRouter,
cache,
prefetchCache,
tree
};
}, [
appRouter,
cache,
prefetchCache,
tree
]);
}
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) {
var _window_history_state;
if (!event.persisted || !((_window_history_state = window.history.state) == null ? void 0 : _window_history_state.tree)) return;
dispatch({
type: ACTION_RESTORE,
url: new URL(window.location.href),
tree: window.history.state.tree
});
}
window.addEventListener("pageshow", handlePageShow);
return ()=>{
window.removeEventListener("pageshow", handlePageShow);
};
}, [
dispatch
]);
// 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?)
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 location1 = window.location;
if (pushRef.pendingPush) {
location1.assign(canonicalUrl);
} else {
location1.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?
use(createInfinitePromise());
}
/**
* 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 = useCallback((param)=>{
let { state } = param;
if (!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 (!state.__NA) {
window.location.reload();
return;
}
// @ts-ignore useTransition exists
// 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
startTransition(()=>{
dispatch({
type: ACTION_RESTORE,
url: new URL(window.location.href),
tree: state.tree
});
});
}, [
dispatch
]);
// Register popstate event to call onPopstate.
useEffect(()=>{
window.addEventListener("popstate", onPopState);
return ()=>{
window.removeEventListener("popstate", onPopState);
};
}, [
onPopState
]);
const head = useMemo(()=>{
return findHeadInCache(cache, tree[1]);
}, [
cache,
tree
]);
let content = /*#__PURE__*/ React.createElement(RedirectBoundary, null, head, cache.subTreeData, /*#__PURE__*/ React.createElement(AppRouterAnnouncer, {
tree: tree
}));
if (process.env.NODE_ENV !== "production") {
if (typeof window !== "undefined") {
const DevRootNotFoundBoundary = require("./dev-root-not-found-boundary").DevRootNotFoundBoundary;
content = /*#__PURE__*/ React.createElement(DevRootNotFoundBoundary, null, content);
}
const HotReloader = require("./react-dev-overlay/hot-reloader-client").default;
content = /*#__PURE__*/ React.createElement(HotReloader, {
assetPrefix: assetPrefix
}, content);
}
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(HistoryUpdater, {
tree: tree,
pushRef: pushRef,
canonicalUrl: canonicalUrl,
sync: sync
}), /*#__PURE__*/ React.createElement(PathnameContext.Provider, {
value: pathname
}, /*#__PURE__*/ React.createElement(SearchParamsContext.Provider, {
value: searchParams
}, /*#__PURE__*/ React.createElement(GlobalLayoutRouterContext.Provider, {
value: {
buildId,
changeByServerResponse,
tree,
focusAndScrollRef,
nextUrl
}
}, /*#__PURE__*/ React.createElement(AppRouterContext.Provider, {
value: appRouter
}, /*#__PURE__*/ React.createElement(LayoutRouterContext.Provider, {
value: {
childNodes: cache.parallelRoutes,
tree: tree,
// Root node always has `url`
// Provided in AppTreeContext to ensure it can be overwritten in layout-router
url: canonicalUrl
}
}, content))))));
}
export default function AppRouter(props) {
const { globalErrorComponent, ...rest } = props;
return /*#__PURE__*/ React.createElement(ErrorBoundary, {
errorComponent: globalErrorComponent
}, /*#__PURE__*/ React.createElement(Router, rest));
}
//# sourceMappingURL=app-router.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,28 @@
const sharedAsyncLocalStorageNotAvailableError = new Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available");
class FakeAsyncLocalStorage {
disable() {
throw sharedAsyncLocalStorageNotAvailableError;
}
getStore() {
// This fake implementation of AsyncLocalStorage always returns `undefined`.
return undefined;
}
run() {
throw sharedAsyncLocalStorageNotAvailableError;
}
exit() {
throw sharedAsyncLocalStorageNotAvailableError;
}
enterWith() {
throw sharedAsyncLocalStorageNotAvailableError;
}
}
const maybeGlobalAsyncLocalStorage = globalThis.AsyncLocalStorage;
export function createAsyncLocalStorage() {
if (maybeGlobalAsyncLocalStorage) {
return new maybeGlobalAsyncLocalStorage();
}
return new FakeAsyncLocalStorage();
}
//# sourceMappingURL=async-local-storage.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/async-local-storage.ts"],"names":["sharedAsyncLocalStorageNotAvailableError","Error","FakeAsyncLocalStorage","disable","getStore","undefined","run","exit","enterWith","maybeGlobalAsyncLocalStorage","globalThis","AsyncLocalStorage","createAsyncLocalStorage"],"mappings":"AAEA,MAAMA,2CAA2C,IAAIC,MACnD;AAGF,MAAMC;IAGJC,UAAgB;QACd,MAAMH;IACR;IAEAI,WAA8B;QAC5B,4EAA4E;QAC5E,OAAOC;IACT;IAEAC,MAAY;QACV,MAAMN;IACR;IAEAO,OAAa;QACX,MAAMP;IACR;IAEAQ,YAAkB;QAChB,MAAMR;IACR;AACF;AAEA,MAAMS,+BAA+B,AAACC,WAAmBC,iBAAiB;AAE1E,OAAO,SAASC;IAGd,IAAIH,8BAA8B;QAChC,OAAO,IAAIA;IACb;IACA,OAAO,IAAIP;AACb"}

View File

@@ -0,0 +1,14 @@
import { suspense } from "../../shared/lib/lazy-dynamic/dynamic-no-ssr";
import { staticGenerationAsyncStorage } from "./static-generation-async-storage.external";
export function bailoutToClientRendering() {
const staticGenerationStore = staticGenerationAsyncStorage.getStore();
if (staticGenerationStore == null ? void 0 : staticGenerationStore.forceStatic) {
return true;
}
if (staticGenerationStore == null ? void 0 : staticGenerationStore.isStaticGeneration) {
suspense();
}
return false;
}
//# sourceMappingURL=bailout-to-client-rendering.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/bailout-to-client-rendering.ts"],"names":["suspense","staticGenerationAsyncStorage","bailoutToClientRendering","staticGenerationStore","getStore","forceStatic","isStaticGeneration"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,+CAA8C;AACvE,SAASC,4BAA4B,QAAQ,6CAA4C;AAEzF,OAAO,SAASC;IACd,MAAMC,wBAAwBF,6BAA6BG,QAAQ;IAEnE,IAAID,yCAAAA,sBAAuBE,WAAW,EAAE;QACtC,OAAO;IACT;IAEA,IAAIF,yCAAAA,sBAAuBG,kBAAkB,EAAE;QAC7CN;IACF;IAEA,OAAO;AACT"}

View File

@@ -0,0 +1,11 @@
import React from "react";
export function clientHookInServerComponentError(hookName) {
if (process.env.NODE_ENV !== "production") {
// If useState is undefined we're in a server component
if (!React.useState) {
throw new Error("" + hookName + ' only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/react-client-hook-in-server-component');
}
}
}
//# sourceMappingURL=client-hook-in-server-component-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/client-hook-in-server-component-error.ts"],"names":["React","clientHookInServerComponentError","hookName","process","env","NODE_ENV","useState","Error"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AAEzB,OAAO,SAASC,iCACdC,QAAgB;IAEhB,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,uDAAuD;QACvD,IAAI,CAACL,MAAMM,QAAQ,EAAE;YACnB,MAAM,IAAIC,MACR,AAAC,KAAEL,WAAS;QAEhB;IACF;AACF"}

View File

@@ -0,0 +1,7 @@
import React from "react";
export default function DefaultLayout(param) {
let { children } = param;
return /*#__PURE__*/ React.createElement("html", null, /*#__PURE__*/ React.createElement("body", null, children));
}
//# sourceMappingURL=default-layout.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/default-layout.tsx"],"names":["React","DefaultLayout","children","html","body"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AAEzB,eAAe,SAASC,cAAc,KAIrC;IAJqC,IAAA,EACpCC,QAAQ,EAGT,GAJqC;IAKpC,qBACE,oBAACC,4BACC,oBAACC,cAAMF;AAGb"}

View File

@@ -0,0 +1,19 @@
"use client";
import React from "react";
import { NotFoundBoundary } from "./not-found-boundary";
export function bailOnNotFound() {
throw new Error("notFound() is not allowed to use in root layout");
}
function NotAllowedRootNotFoundError() {
bailOnNotFound();
return null;
}
export function DevRootNotFoundBoundary(param) {
let { children } = param;
return /*#__PURE__*/ React.createElement(NotFoundBoundary, {
notFound: /*#__PURE__*/ React.createElement(NotAllowedRootNotFoundError, null)
}, children);
}
//# sourceMappingURL=dev-root-not-found-boundary.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/dev-root-not-found-boundary.tsx"],"names":["React","NotFoundBoundary","bailOnNotFound","Error","NotAllowedRootNotFoundError","DevRootNotFoundBoundary","children","notFound"],"mappings":"AAAA;AAEA,OAAOA,WAAW,QAAO;AACzB,SAASC,gBAAgB,QAAQ,uBAAsB;AAEvD,OAAO,SAASC;IACd,MAAM,IAAIC,MAAM;AAClB;AAEA,SAASC;IACPF;IACA,OAAO;AACT;AAEA,OAAO,SAASG,wBAAwB,KAIvC;IAJuC,IAAA,EACtCC,QAAQ,EAGT,GAJuC;IAKtC,qBACE,oBAACL;QAAiBM,wBAAU,oBAACH;OAC1BE;AAGP"}

View File

@@ -0,0 +1,23 @@
import { staticGenerationBailout } from "./static-generation-bailout";
export class DraftMode {
get isEnabled() {
return this._provider.isEnabled;
}
enable() {
if (staticGenerationBailout("draftMode().enable()")) {
return;
}
return this._provider.enable();
}
disable() {
if (staticGenerationBailout("draftMode().disable()")) {
return;
}
return this._provider.disable();
}
constructor(provider){
this._provider = provider;
}
}
//# sourceMappingURL=draft-mode.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/draft-mode.ts"],"names":["staticGenerationBailout","DraftMode","isEnabled","_provider","enable","disable","constructor","provider"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ,8BAA6B;AAErE,OAAO,MAAMC;IASX,IAAIC,YAAY;QACd,OAAO,IAAI,CAACC,SAAS,CAACD,SAAS;IACjC;IACOE,SAAS;QACd,IAAIJ,wBAAwB,yBAAyB;YACnD;QACF;QACA,OAAO,IAAI,CAACG,SAAS,CAACC,MAAM;IAC9B;IACOC,UAAU;QACf,IAAIL,wBAAwB,0BAA0B;YACpD;QACF;QACA,OAAO,IAAI,CAACG,SAAS,CAACE,OAAO;IAC/B;IAjBAC,YAAYC,QAA2B,CAAE;QACvC,IAAI,CAACJ,SAAS,GAAGI;IACnB;AAgBF"}

View File

@@ -0,0 +1,103 @@
"use client";
import React from "react";
import { usePathname } from "./navigation";
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"
}
};
export class ErrorBoundaryHandler extends React.Component {
static getDerivedStateFromError(error) {
return {
error
};
}
static getDerivedStateFromProps(props, state) {
/**
* Handles reset of the error boundary when a navigation happens.
* Ensures the error boundary does not stay enabled when navigating to a new page.
* Approach of setState in render is safe as it checks the previous pathname and then overrides
* it as outlined in https://react.dev/reference/react/useState#storing-information-from-previous-renders
*/ if (props.pathname !== state.previousPathname && state.error) {
return {
error: null,
previousPathname: props.pathname
};
}
return {
error: state.error,
previousPathname: props.pathname
};
}
render() {
if (this.state.error) {
return /*#__PURE__*/ React.createElement(React.Fragment, null, this.props.errorStyles, /*#__PURE__*/ React.createElement(this.props.errorComponent, {
error: this.state.error,
reset: this.reset
}));
}
return this.props.children;
}
constructor(props){
super(props);
this.reset = ()=>{
this.setState({
error: null
});
};
this.state = {
error: null,
previousPathname: this.props.pathname
};
}
}
export function GlobalError(param) {
let { error } = param;
const digest = error == null ? void 0 : error.digest;
return /*#__PURE__*/ React.createElement("html", {
id: "__next_error__"
}, /*#__PURE__*/ React.createElement("head", null), /*#__PURE__*/ React.createElement("body", null, /*#__PURE__*/ React.createElement("div", {
style: styles.error
}, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("h2", {
style: styles.text
}, "Application error: a " + (digest ? "server" : "client") + "-side exception has occurred (see the " + (digest ? "server logs" : "browser console") + " for more information)."), digest ? /*#__PURE__*/ React.createElement("p", {
style: styles.text
}, "Digest: " + digest) : null))));
}
// Exported so that the import signature in the loaders can be identical to user
// supplied custom global error signatures.
export default GlobalError;
/**
* Handles errors through `getDerivedStateFromError`.
* Renders the provided error component and provides a way to `reset` the error boundary state.
*/ /**
* Renders error boundary with the provided "errorComponent" property as the fallback.
* If no "errorComponent" property is provided it renders the children without an error boundary.
*/ export function ErrorBoundary(param) {
let { errorComponent, errorStyles, children } = param;
const pathname = usePathname();
if (errorComponent) {
return /*#__PURE__*/ React.createElement(ErrorBoundaryHandler, {
pathname: pathname,
errorComponent: errorComponent,
errorStyles: errorStyles
}, children);
}
return /*#__PURE__*/ React.createElement(React.Fragment, null, children);
}
//# sourceMappingURL=error-boundary.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/error-boundary.tsx"],"names":["React","usePathname","styles","error","fontFamily","height","textAlign","display","flexDirection","alignItems","justifyContent","text","fontSize","fontWeight","lineHeight","margin","ErrorBoundaryHandler","Component","getDerivedStateFromError","getDerivedStateFromProps","props","state","pathname","previousPathname","render","errorStyles","this","errorComponent","reset","children","constructor","setState","GlobalError","digest","html","id","head","body","div","style","h2","p","ErrorBoundary"],"mappings":"AAAA;AAEA,OAAOA,WAAW,QAAO;AACzB,SAASC,WAAW,QAAQ,eAAc;AAE1C,MAAMC,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;AAsBA,OAAO,MAAMC,6BAA6BhB,MAAMiB,SAAS;IASvD,OAAOC,yBAAyBf,KAAY,EAAE;QAC5C,OAAO;YAAEA;QAAM;IACjB;IAEA,OAAOgB,yBACLC,KAAgC,EAChCC,KAAgC,EACE;QAClC;;;;;KAKC,GACD,IAAID,MAAME,QAAQ,KAAKD,MAAME,gBAAgB,IAAIF,MAAMlB,KAAK,EAAE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,OAAO,SAASU,cAAc,KAIuB;IAJvB,IAAA,EAC5Bf,cAAc,EACdF,WAAW,EACXI,QAAQ,EAC2C,GAJvB;IAK5B,MAAMP,WAAWrB;IACjB,IAAI0B,gBAAgB;QAClB,qBACE,oBAACX;YACCM,UAAUA;YACVK,gBAAgBA;YAChBF,aAAaA;WAEZI;IAGP;IAEA,qBAAO,0CAAGA;AACZ"}

View File

@@ -0,0 +1,9 @@
import { isRedirectError } from "./redirect";
export function getRedirectStatusCodeFromError(error) {
if (!isRedirectError(error)) {
throw new Error("Not a redirect error");
}
return error.digest.split(";", 4)[3] === "true" ? 308 : 307;
}
//# sourceMappingURL=get-redirect-status-code-from-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/get-redirect-status-code-from-error.ts"],"names":["isRedirectError","getRedirectStatusCodeFromError","error","Error","digest","split"],"mappings":"AAAA,SAA6BA,eAAe,QAAQ,aAAY;AAEhE,OAAO,SAASC,+BACdC,KAAuB;IAEvB,IAAI,CAACF,gBAAgBE,QAAQ;QAC3B,MAAM,IAAIC,MAAM;IAClB;IAEA,OAAOD,MAAME,MAAM,CAACC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,SAAS,MAAM;AAC1D"}

View File

@@ -0,0 +1,46 @@
import { RequestCookiesAdapter } from "../../server/web/spec-extension/adapters/request-cookies";
import { HeadersAdapter } from "../../server/web/spec-extension/adapters/headers";
import { RequestCookies } from "../../server/web/spec-extension/cookies";
import { requestAsyncStorage } from "./request-async-storage.external";
import { actionAsyncStorage } from "./action-async-storage.external";
import { staticGenerationBailout } from "./static-generation-bailout";
import { DraftMode } from "./draft-mode";
export function headers() {
if (staticGenerationBailout("headers", {
link: "https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering"
})) {
return HeadersAdapter.seal(new Headers({}));
}
const requestStore = requestAsyncStorage.getStore();
if (!requestStore) {
throw new Error("Invariant: headers() expects to have requestAsyncStorage, none available.");
}
return requestStore.headers;
}
export function cookies() {
if (staticGenerationBailout("cookies", {
link: "https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering"
})) {
return RequestCookiesAdapter.seal(new RequestCookies(new Headers({})));
}
const requestStore = requestAsyncStorage.getStore();
if (!requestStore) {
throw new Error("Invariant: cookies() expects to have requestAsyncStorage, none available.");
}
const asyncActionStore = actionAsyncStorage.getStore();
if (asyncActionStore && (asyncActionStore.isAction || asyncActionStore.isAppRoute)) {
// We can't conditionally return different types here based on the context.
// To avoid confusion, we always return the readonly type here.
return requestStore.mutableCookies;
}
return requestStore.cookies;
}
export function draftMode() {
const requestStore = requestAsyncStorage.getStore();
if (!requestStore) {
throw new Error("Invariant: draftMode() expects to have requestAsyncStorage, none available.");
}
return new DraftMode(requestStore.draftMode);
}
//# sourceMappingURL=headers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/headers.ts"],"names":["RequestCookiesAdapter","HeadersAdapter","RequestCookies","requestAsyncStorage","actionAsyncStorage","staticGenerationBailout","DraftMode","headers","link","seal","Headers","requestStore","getStore","Error","cookies","asyncActionStore","isAction","isAppRoute","mutableCookies","draftMode"],"mappings":"AAAA,SAEEA,qBAAqB,QAChB,2DAA0D;AACjE,SAASC,cAAc,QAAQ,mDAAkD;AACjF,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,mBAAmB,QAAQ,mCAAkC;AACtE,SAASC,kBAAkB,QAAQ,kCAAiC;AACpE,SAASC,uBAAuB,QAAQ,8BAA6B;AACrE,SAASC,SAAS,QAAQ,eAAc;AAExC,OAAO,SAASC;IACd,IACEF,wBAAwB,WAAW;QACjCG,MAAM;IACR,IACA;QACA,OAAOP,eAAeQ,IAAI,CAAC,IAAIC,QAAQ,CAAC;IAC1C;IACA,MAAMC,eAAeR,oBAAoBS,QAAQ;IACjD,IAAI,CAACD,cAAc;QACjB,MAAM,IAAIE,MACP;IAEL;IAEA,OAAOF,aAAaJ,OAAO;AAC7B;AAEA,OAAO,SAASO;IACd,IACET,wBAAwB,WAAW;QACjCG,MAAM;IACR,IACA;QACA,OAAOR,sBAAsBS,IAAI,CAAC,IAAIP,eAAe,IAAIQ,QAAQ,CAAC;IACpE;IAEA,MAAMC,eAAeR,oBAAoBS,QAAQ;IACjD,IAAI,CAACD,cAAc;QACjB,MAAM,IAAIE,MACP;IAEL;IAEA,MAAME,mBAAmBX,mBAAmBQ,QAAQ;IACpD,IACEG,oBACCA,CAAAA,iBAAiBC,QAAQ,IAAID,iBAAiBE,UAAU,AAAD,GACxD;QACA,2EAA2E;QAC3E,+DAA+D;QAC/D,OAAON,aAAaO,cAAc;IACpC;IAEA,OAAOP,aAAaG,OAAO;AAC7B;AAEA,OAAO,SAASK;IACd,MAAMR,eAAeR,oBAAoBS,QAAQ;IACjD,IAAI,CAACD,cAAc;QACjB,MAAM,IAAIE,MACP;IAEL;IACA,OAAO,IAAIP,UAAUK,aAAaQ,SAAS;AAC7C"}

View File

@@ -0,0 +1,9 @@
export const DYNAMIC_ERROR_CODE = "DYNAMIC_SERVER_USAGE";
export class DynamicServerError extends Error {
constructor(type){
super("Dynamic server usage: " + type);
this.digest = DYNAMIC_ERROR_CODE;
}
}
//# sourceMappingURL=hooks-server-context.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/hooks-server-context.ts"],"names":["DYNAMIC_ERROR_CODE","DynamicServerError","Error","constructor","type","digest"],"mappings":"AAAA,OAAO,MAAMA,qBAAqB,uBAAsB;AAExD,OAAO,MAAMC,2BAA2BC;IAGtCC,YAAYC,IAAY,CAAE;QACxB,KAAK,CAAC,AAAC,2BAAwBA;aAHjCC,SAAoCL;IAIpC;AACF"}

View File

@@ -0,0 +1,20 @@
/**
* Used to cache in createInfinitePromise
*/ let infinitePromise;
/**
* Create a Promise that does not resolve. This is used to suspend when data is not available yet.
*/ export function createInfinitePromise() {
if (!infinitePromise) {
// Only create the Promise once
infinitePromise = new Promise(()=>{
// This is used to debug when the rendering is never updated.
// setTimeout(() => {
// infinitePromise = new Error('Infinite promise')
// resolve()
// }, 5000)
});
}
return infinitePromise;
}
//# sourceMappingURL=infinite-promise.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/infinite-promise.ts"],"names":["infinitePromise","createInfinitePromise","Promise"],"mappings":"AAAA;;CAEC,GACD,IAAIA;AAEJ;;CAEC,GACD,OAAO,SAASC;IACd,IAAI,CAACD,iBAAiB;QACpB,+BAA+B;QAC/BA,kBAAkB,IAAIE,QAAQ;QAC5B,6DAA6D;QAC7D,qBAAqB;QACrB,oDAAoD;QACpD,cAAc;QACd,WAAW;QACb;IACF;IAEA,OAAOF;AACT"}

View File

@@ -0,0 +1,7 @@
import { isNotFoundError } from "./not-found";
import { isRedirectError } from "./redirect";
export function isNextRouterError(error) {
return error && error.digest && (isRedirectError(error) || isNotFoundError(error));
}
//# sourceMappingURL=is-next-router-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/is-next-router-error.ts"],"names":["isNotFoundError","isRedirectError","isNextRouterError","error","digest"],"mappings":"AAAA,SAASA,eAAe,QAAQ,cAAa;AAC7C,SAASC,eAAe,QAAQ,aAAY;AAE5C,OAAO,SAASC,kBAAkBC,KAAU;IAC1C,OACEA,SAASA,MAAMC,MAAM,IAAKH,CAAAA,gBAAgBE,UAAUH,gBAAgBG,MAAK;AAE7E"}

View File

@@ -0,0 +1,406 @@
"use client";
import React, { useContext, use, startTransition, Suspense } from "react";
import ReactDOM from "react-dom";
import { CacheStates, LayoutRouterContext, GlobalLayoutRouterContext, TemplateContext } from "../../shared/lib/app-router-context.shared-runtime";
import { fetchServerResponse } from "./router-reducer/fetch-server-response";
import { createInfinitePromise } from "./infinite-promise";
import { ErrorBoundary } from "./error-boundary";
import { matchSegment } from "./match-segments";
import { handleSmoothScroll } from "../../shared/lib/router/utils/handle-smooth-scroll";
import { RedirectBoundary } from "./redirect-boundary";
import { NotFoundBoundary } from "./not-found-boundary";
import { getSegmentValue } from "./router-reducer/reducers/get-segment-value";
import { createRouterCacheKey } from "./router-reducer/create-router-cache-key";
/**
* Add refetch marker to router state at the point of the current layout segment.
* This ensures the response returned is not further down than the current layout segment.
*/ function walkAddRefetch(segmentPathToWalk, treeToRecreate) {
if (segmentPathToWalk) {
const [segment, parallelRouteKey] = segmentPathToWalk;
const isLast = segmentPathToWalk.length === 2;
if (matchSegment(treeToRecreate[0], segment)) {
if (treeToRecreate[1].hasOwnProperty(parallelRouteKey)) {
if (isLast) {
const subTree = walkAddRefetch(undefined, treeToRecreate[1][parallelRouteKey]);
return [
treeToRecreate[0],
{
...treeToRecreate[1],
[parallelRouteKey]: [
subTree[0],
subTree[1],
subTree[2],
"refetch"
]
}
];
}
return [
treeToRecreate[0],
{
...treeToRecreate[1],
[parallelRouteKey]: walkAddRefetch(segmentPathToWalk.slice(2), treeToRecreate[1][parallelRouteKey])
}
];
}
}
}
return treeToRecreate;
}
// TODO-APP: Replace with new React API for finding dom nodes without a `ref` when available
/**
* Wraps ReactDOM.findDOMNode with additional logic to hide React Strict Mode warning
*/ function findDOMNode(instance) {
// Tree-shake for server bundle
if (typeof window === "undefined") return null;
// Only apply strict mode warning when not in production
if (process.env.NODE_ENV !== "production") {
const originalConsoleError = console.error;
try {
console.error = function() {
for(var _len = arguments.length, messages = new Array(_len), _key = 0; _key < _len; _key++){
messages[_key] = arguments[_key];
}
// Ignore strict mode warning for the findDomNode call below
if (!messages[0].includes("Warning: %s is deprecated in StrictMode.")) {
originalConsoleError(...messages);
}
};
return ReactDOM.findDOMNode(instance);
} finally{
console.error = originalConsoleError;
}
}
return ReactDOM.findDOMNode(instance);
}
const rectProperties = [
"bottom",
"height",
"left",
"right",
"top",
"width",
"x",
"y"
];
/**
* Check if a HTMLElement is hidden or fixed/sticky position
*/ function shouldSkipElement(element) {
// we ignore fixed or sticky positioned elements since they'll likely pass the "in-viewport" check
// and will result in a situation we bail on scroll because of something like a fixed nav,
// even though the actual page content is offscreen
if ([
"sticky",
"fixed"
].includes(getComputedStyle(element).position)) {
if (process.env.NODE_ENV === "development") {
console.warn("Skipping auto-scroll behavior due to `position: sticky` or `position: fixed` on element:", element);
}
return true;
}
// Uses `getBoundingClientRect` to check if the element is hidden instead of `offsetParent`
// because `offsetParent` doesn't consider document/body
const rect = element.getBoundingClientRect();
return rectProperties.every((item)=>rect[item] === 0);
}
/**
* Check if the top corner of the HTMLElement is in the viewport.
*/ function topOfElementInViewport(element, viewportHeight) {
const rect = element.getBoundingClientRect();
return rect.top >= 0 && rect.top <= viewportHeight;
}
/**
* Find the DOM node for a hash fragment.
* If `top` the page has to scroll to the top of the page. This mirrors the browser's behavior.
* If the hash fragment is an id, the page has to scroll to the element with that id.
* If the hash fragment is a name, the page has to scroll to the first element with that name.
*/ function getHashFragmentDomNode(hashFragment) {
// If the hash fragment is `top` the page has to scroll to the top of the page.
if (hashFragment === "top") {
return document.body;
}
var _document_getElementById;
// If the hash fragment is an id, the page has to scroll to the element with that id.
return (_document_getElementById = document.getElementById(hashFragment)) != null ? _document_getElementById : // If the hash fragment is a name, the page has to scroll to the first element with that name.
document.getElementsByName(hashFragment)[0];
}
class InnerScrollAndFocusHandler extends React.Component {
componentDidMount() {
this.handlePotentialScroll();
}
componentDidUpdate() {
// Because this property is overwritten in handlePotentialScroll it's fine to always run it when true as it'll be set to false for subsequent renders.
if (this.props.focusAndScrollRef.apply) {
this.handlePotentialScroll();
}
}
render() {
return this.props.children;
}
constructor(...args){
super(...args);
this.handlePotentialScroll = ()=>{
// Handle scroll and focus, it's only applied once in the first useEffect that triggers that changed.
const { focusAndScrollRef, segmentPath } = this.props;
if (focusAndScrollRef.apply) {
// segmentPaths is an array of segment paths that should be scrolled to
// if the current segment path is not in the array, the scroll is not applied
// unless the array is empty, in which case the scroll is always applied
if (focusAndScrollRef.segmentPaths.length !== 0 && !focusAndScrollRef.segmentPaths.some((scrollRefSegmentPath)=>segmentPath.every((segment, index)=>matchSegment(segment, scrollRefSegmentPath[index])))) {
return;
}
let domNode = null;
const hashFragment = focusAndScrollRef.hashFragment;
if (hashFragment) {
domNode = getHashFragmentDomNode(hashFragment);
}
// `findDOMNode` is tricky because it returns just the first child if the component is a fragment.
// This already caused a bug where the first child was a <link/> in head.
if (!domNode) {
domNode = findDOMNode(this);
}
// If there is no DOM node this layout-router level is skipped. It'll be handled higher-up in the tree.
if (!(domNode instanceof Element)) {
return;
}
// Verify if the element is a HTMLElement and if we want to consider it for scroll behavior.
// If the element is skipped, try to select the next sibling and try again.
while(!(domNode instanceof HTMLElement) || shouldSkipElement(domNode)){
// No siblings found that match the criteria are found, so handle scroll higher up in the tree instead.
if (domNode.nextElementSibling === null) {
return;
}
domNode = domNode.nextElementSibling;
}
// State is mutated to ensure that the focus and scroll is applied only once.
focusAndScrollRef.apply = false;
focusAndScrollRef.hashFragment = null;
focusAndScrollRef.segmentPaths = [];
handleSmoothScroll(()=>{
// In case of hash scroll, we only need to scroll the element into view
if (hashFragment) {
domNode.scrollIntoView();
return;
}
// Store the current viewport height because reading `clientHeight` causes a reflow,
// and it won't change during this function.
const htmlElement = document.documentElement;
const viewportHeight = htmlElement.clientHeight;
// If the element's top edge is already in the viewport, exit early.
if (topOfElementInViewport(domNode, viewportHeight)) {
return;
}
// Otherwise, try scrolling go the top of the document to be backward compatible with pages
// scrollIntoView() called on `<html/>` element scrolls horizontally on chrome and firefox (that shouldn't happen)
// We could use it to scroll horizontally following RTL but that also seems to be broken - it will always scroll left
// scrollLeft = 0 also seems to ignore RTL and manually checking for RTL is too much hassle so we will scroll just vertically
htmlElement.scrollTop = 0;
// Scroll to domNode if domNode is not in viewport when scrolled to top of document
if (!topOfElementInViewport(domNode, viewportHeight)) {
domNode.scrollIntoView();
}
}, {
// We will force layout by querying domNode position
dontForceLayout: true,
onlyHashChange: focusAndScrollRef.onlyHashChange
});
// Mutate after scrolling so that it can be read by `handleSmoothScroll`
focusAndScrollRef.onlyHashChange = false;
// Set focus on the element
domNode.focus();
}
};
}
}
function ScrollAndFocusHandler(param) {
let { segmentPath, children } = param;
const context = useContext(GlobalLayoutRouterContext);
if (!context) {
throw new Error("invariant global layout router not mounted");
}
return /*#__PURE__*/ React.createElement(InnerScrollAndFocusHandler, {
segmentPath: segmentPath,
focusAndScrollRef: context.focusAndScrollRef
}, children);
}
/**
* InnerLayoutRouter handles rendering the provided segment based on the cache.
*/ function InnerLayoutRouter(param) {
let { parallelRouterKey, url, childNodes, childProp, segmentPath, tree, // TODO-APP: implement `<Offscreen>` when available.
// isActive,
cacheKey } = param;
const context = useContext(GlobalLayoutRouterContext);
if (!context) {
throw new Error("invariant global layout router not mounted");
}
const { buildId, changeByServerResponse, tree: fullTree } = context;
// Read segment path from the parallel router cache node.
let childNode = childNodes.get(cacheKey);
// If childProp is available this means it's the Flight / SSR case.
if (childProp && // TODO-APP: verify if this can be null based on user code
childProp.current !== null) {
if (!childNode) {
// Add the segment's subTreeData to the cache.
// This writes to the cache when there is no item in the cache yet. It never *overwrites* existing cache items which is why it's safe in concurrent mode.
childNode = {
status: CacheStates.READY,
data: null,
subTreeData: childProp.current,
parallelRoutes: new Map()
};
childNodes.set(cacheKey, childNode);
} else {
if (childNode.status === CacheStates.LAZY_INITIALIZED) {
// @ts-expect-error we're changing it's type!
childNode.status = CacheStates.READY;
// @ts-expect-error
childNode.subTreeData = childProp.current;
}
}
}
// When childNode is not available during rendering client-side we need to fetch it from the server.
if (!childNode || childNode.status === CacheStates.LAZY_INITIALIZED) {
/**
* Router state with refetch marker added
*/ // TODO-APP: remove ''
const refetchTree = walkAddRefetch([
"",
...segmentPath
], fullTree);
childNode = {
status: CacheStates.DATA_FETCH,
data: fetchServerResponse(new URL(url, location.origin), refetchTree, context.nextUrl, buildId),
subTreeData: null,
head: childNode && childNode.status === CacheStates.LAZY_INITIALIZED ? childNode.head : undefined,
parallelRoutes: childNode && childNode.status === CacheStates.LAZY_INITIALIZED ? childNode.parallelRoutes : new Map()
};
/**
* Flight data fetch kicked off during render and put into the cache.
*/ childNodes.set(cacheKey, childNode);
}
// This case should never happen so it throws an error. It indicates there's a bug in the Next.js.
if (!childNode) {
throw new Error("Child node should always exist");
}
// This case should never happen so it throws an error. It indicates there's a bug in the Next.js.
if (childNode.subTreeData && childNode.data) {
throw new Error("Child node should not have both subTreeData and data");
}
// If cache node has a data request we have to unwrap response by `use` and update the cache.
if (childNode.data) {
/**
* Flight response data
*/ // When the data has not resolved yet `use` will suspend here.
const [flightData, overrideCanonicalUrl] = use(childNode.data);
// segmentPath from the server does not match the layout's segmentPath
childNode.data = null;
// setTimeout is used to start a new transition during render, this is an intentional hack around React.
setTimeout(()=>{
startTransition(()=>{
changeByServerResponse(fullTree, flightData, overrideCanonicalUrl);
});
});
// Suspend infinitely as `changeByServerResponse` will cause a different part of the tree to be rendered.
use(createInfinitePromise());
}
// If cache node has no subTreeData and no data request we have to infinitely suspend as the data will likely flow in from another place.
// TODO-APP: double check users can't return null in a component that will kick in here.
if (!childNode.subTreeData) {
use(createInfinitePromise());
}
const subtree = // The layout router context narrows down tree and childNodes at each level.
/*#__PURE__*/ React.createElement(LayoutRouterContext.Provider, {
value: {
tree: tree[1][parallelRouterKey],
childNodes: childNode.parallelRoutes,
// TODO-APP: overriding of url for parallel routes
url: url
}
}, childNode.subTreeData);
// Ensure root layout is not wrapped in a div as the root layout renders `<html>`
return subtree;
}
/**
* Renders suspense boundary with the provided "loading" property as the fallback.
* If no loading property is provided it renders the children without a suspense boundary.
*/ function LoadingBoundary(param) {
let { children, loading, loadingStyles, hasLoading } = param;
if (hasLoading) {
return /*#__PURE__*/ React.createElement(Suspense, {
fallback: /*#__PURE__*/ React.createElement(React.Fragment, null, loadingStyles, loading)
}, children);
}
return /*#__PURE__*/ React.createElement(React.Fragment, null, children);
}
/**
* OuterLayoutRouter handles the current segment as well as <Offscreen> rendering of other segments.
* It can be rendered next to each other with a different `parallelRouterKey`, allowing for Parallel routes.
*/ export default function OuterLayoutRouter(param) {
let { parallelRouterKey, segmentPath, childProp, error, errorStyles, templateStyles, loading, loadingStyles, hasLoading, template, notFound, notFoundStyles, styles } = param;
const context = useContext(LayoutRouterContext);
if (!context) {
throw new Error("invariant expected layout router to be mounted");
}
const { childNodes, tree, url } = context;
// Get the current parallelRouter cache node
let childNodesForParallelRouter = childNodes.get(parallelRouterKey);
// If the parallel router cache node does not exist yet, create it.
// This writes to the cache when there is no item in the cache yet. It never *overwrites* existing cache items which is why it's safe in concurrent mode.
if (!childNodesForParallelRouter) {
childNodesForParallelRouter = new Map();
childNodes.set(parallelRouterKey, childNodesForParallelRouter);
}
// Get the active segment in the tree
// The reason arrays are used in the data format is that these are transferred from the server to the browser so it's optimized to save bytes.
const treeSegment = tree[1][parallelRouterKey][0];
const childPropSegment = childProp.segment;
// If segment is an array it's a dynamic route and we want to read the dynamic route value as the segment to get from the cache.
const currentChildSegmentValue = getSegmentValue(treeSegment);
/**
* Decides which segments to keep rendering, all segments that are not active will be wrapped in `<Offscreen>`.
*/ // TODO-APP: Add handling of `<Offscreen>` when it's available.
const preservedSegments = [
treeSegment
];
return /*#__PURE__*/ React.createElement(React.Fragment, null, styles, preservedSegments.map((preservedSegment)=>{
const isChildPropSegment = matchSegment(preservedSegment, childPropSegment);
const preservedSegmentValue = getSegmentValue(preservedSegment);
const cacheKey = createRouterCacheKey(preservedSegment);
return(/*
- Error boundary
- Only renders error boundary if error component is provided.
- Rendered for each segment to ensure they have their own error state.
- Loading boundary
- Only renders suspense boundary if loading components is provided.
- Rendered for each segment to ensure they have their own loading state.
- Passed to the router during rendering to ensure it can be immediately rendered when suspending on a Flight fetch.
*/ /*#__PURE__*/ React.createElement(TemplateContext.Provider, {
key: createRouterCacheKey(preservedSegment, true),
value: /*#__PURE__*/ React.createElement(ScrollAndFocusHandler, {
segmentPath: segmentPath
}, /*#__PURE__*/ React.createElement(ErrorBoundary, {
errorComponent: error,
errorStyles: errorStyles
}, /*#__PURE__*/ React.createElement(LoadingBoundary, {
hasLoading: hasLoading,
loading: loading,
loadingStyles: loadingStyles
}, /*#__PURE__*/ React.createElement(NotFoundBoundary, {
notFound: notFound,
notFoundStyles: notFoundStyles
}, /*#__PURE__*/ React.createElement(RedirectBoundary, null, /*#__PURE__*/ React.createElement(InnerLayoutRouter, {
parallelRouterKey: parallelRouterKey,
url: url,
tree: tree,
childNodes: childNodesForParallelRouter,
childProp: isChildPropSegment ? childProp : null,
segmentPath: segmentPath,
cacheKey: cacheKey,
isActive: currentChildSegmentValue === preservedSegmentValue
}))))))
}, templateStyles, template));
}));
}
//# sourceMappingURL=layout-router.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,26 @@
import { getSegmentParam } from "../../server/app-render/get-segment-param";
export const matchSegment = (existingSegment, segment)=>{
// segment is either Array or string
if (typeof existingSegment === "string") {
if (typeof segment === "string") {
// Common case: segment is just a string
return existingSegment === segment;
}
return false;
}
if (typeof segment === "string") {
return false;
}
return existingSegment[0] === segment[0] && existingSegment[1] === segment[1];
};
/*
* This function is used to determine if an existing segment can be overridden by the incoming segment.
*/ export const canSegmentBeOverridden = (existingSegment, segment)=>{
var _getSegmentParam;
if (Array.isArray(existingSegment) || !Array.isArray(segment)) {
return false;
}
return ((_getSegmentParam = getSegmentParam(existingSegment)) == null ? void 0 : _getSegmentParam.param) === segment[0];
};
//# sourceMappingURL=match-segments.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/match-segments.ts"],"names":["getSegmentParam","matchSegment","existingSegment","segment","canSegmentBeOverridden","Array","isArray","param"],"mappings":"AAAA,SAASA,eAAe,QAAQ,4CAA2C;AAG3E,OAAO,MAAMC,eAAe,CAC1BC,iBACAC;IAEA,oCAAoC;IACpC,IAAI,OAAOD,oBAAoB,UAAU;QACvC,IAAI,OAAOC,YAAY,UAAU;YAC/B,wCAAwC;YACxC,OAAOD,oBAAoBC;QAC7B;QACA,OAAO;IACT;IAEA,IAAI,OAAOA,YAAY,UAAU;QAC/B,OAAO;IACT;IACA,OAAOD,eAAe,CAAC,EAAE,KAAKC,OAAO,CAAC,EAAE,IAAID,eAAe,CAAC,EAAE,KAAKC,OAAO,CAAC,EAAE;AAC/E,EAAC;AAED;;CAEC,GACD,OAAO,MAAMC,yBAAyB,CACpCF,iBACAC;QAMOH;IAJP,IAAIK,MAAMC,OAAO,CAACJ,oBAAoB,CAACG,MAAMC,OAAO,CAACH,UAAU;QAC7D,OAAO;IACT;IAEA,OAAOH,EAAAA,mBAAAA,gBAAgBE,qCAAhBF,iBAAkCO,KAAK,MAAKJ,OAAO,CAAC,EAAE;AAC/D,EAAC"}

View File

@@ -0,0 +1,169 @@
import { useContext, useMemo } from "react";
import { AppRouterContext, GlobalLayoutRouterContext, LayoutRouterContext } from "../../shared/lib/app-router-context.shared-runtime";
import { SearchParamsContext, PathnameContext, PathParamsContext } from "../../shared/lib/hooks-client-context.shared-runtime";
import { clientHookInServerComponentError } from "./client-hook-in-server-component-error";
import { getSegmentValue } from "./router-reducer/reducers/get-segment-value";
const INTERNAL_URLSEARCHPARAMS_INSTANCE = Symbol("internal for urlsearchparams readonly");
function readonlyURLSearchParamsError() {
return new Error("ReadonlyURLSearchParams cannot be modified");
}
export class ReadonlyURLSearchParams {
[Symbol.iterator]() {
return this[INTERNAL_URLSEARCHPARAMS_INSTANCE][Symbol.iterator]();
}
append() {
throw readonlyURLSearchParamsError();
}
delete() {
throw readonlyURLSearchParamsError();
}
set() {
throw readonlyURLSearchParamsError();
}
sort() {
throw readonlyURLSearchParamsError();
}
constructor(urlSearchParams){
this[INTERNAL_URLSEARCHPARAMS_INSTANCE] = urlSearchParams;
this.entries = urlSearchParams.entries.bind(urlSearchParams);
this.forEach = urlSearchParams.forEach.bind(urlSearchParams);
this.get = urlSearchParams.get.bind(urlSearchParams);
this.getAll = urlSearchParams.getAll.bind(urlSearchParams);
this.has = urlSearchParams.has.bind(urlSearchParams);
this.keys = urlSearchParams.keys.bind(urlSearchParams);
this.values = urlSearchParams.values.bind(urlSearchParams);
this.toString = urlSearchParams.toString.bind(urlSearchParams);
this.size = urlSearchParams.size;
}
}
/**
* Get a read-only URLSearchParams object. For example searchParams.get('foo') would return 'bar' when ?foo=bar
* Learn more about URLSearchParams here: https://developer.mozilla.org/docs/Web/API/URLSearchParams
*/ export function useSearchParams() {
clientHookInServerComponentError("useSearchParams");
const searchParams = useContext(SearchParamsContext);
// In the case where this is `null`, the compat types added in
// `next-env.d.ts` will add a new overload that changes the return type to
// include `null`.
const readonlySearchParams = useMemo(()=>{
if (!searchParams) {
// When the router is not ready in pages, we won't have the search params
// available.
return null;
}
return new ReadonlyURLSearchParams(searchParams);
}, [
searchParams
]);
if (typeof window === "undefined") {
// AsyncLocalStorage should not be included in the client bundle.
const { bailoutToClientRendering } = require("./bailout-to-client-rendering");
if (bailoutToClientRendering()) {
// TODO-APP: handle dynamic = 'force-static' here and on the client
return readonlySearchParams;
}
}
return readonlySearchParams;
}
/**
* Get the current pathname. For example usePathname() on /dashboard?foo=bar would return "/dashboard"
*/ export function usePathname() {
clientHookInServerComponentError("usePathname");
// In the case where this is `null`, the compat types added in `next-env.d.ts`
// will add a new overload that changes the return type to include `null`.
return useContext(PathnameContext);
}
export { ServerInsertedHTMLContext, useServerInsertedHTML } from "../../shared/lib/server-inserted-html.shared-runtime";
/**
* Get the router methods. For example router.push('/dashboard')
*/ export function useRouter() {
clientHookInServerComponentError("useRouter");
const router = useContext(AppRouterContext);
if (router === null) {
throw new Error("invariant expected app router to be mounted");
}
return router;
}
// this function performs a depth-first search of the tree to find the selected
// params
function getSelectedParams(tree, params) {
if (params === void 0) params = {};
const parallelRoutes = tree[1];
for (const parallelRoute of Object.values(parallelRoutes)){
const segment = parallelRoute[0];
const isDynamicParameter = Array.isArray(segment);
const segmentValue = isDynamicParameter ? segment[1] : segment;
if (!segmentValue || segmentValue.startsWith("__PAGE__")) continue;
// Ensure catchAll and optional catchall are turned into an array
const isCatchAll = isDynamicParameter && (segment[2] === "c" || segment[2] === "oc");
if (isCatchAll) {
params[segment[0]] = segment[1].split("/");
} else if (isDynamicParameter) {
params[segment[0]] = segment[1];
}
params = getSelectedParams(parallelRoute, params);
}
return params;
}
/**
* Get the current parameters. For example useParams() on /dashboard/[team]
* where pathname is /dashboard/nextjs would return { team: 'nextjs' }
*/ export function useParams() {
clientHookInServerComponentError("useParams");
const globalLayoutRouter = useContext(GlobalLayoutRouterContext);
const pathParams = useContext(PathParamsContext);
// When it's under app router
if (globalLayoutRouter) {
return getSelectedParams(globalLayoutRouter.tree);
}
// When it's under client side pages router
return pathParams;
}
// TODO-APP: handle parallel routes
/**
* Get the canonical parameters from the current level to the leaf node.
*/ function getSelectedLayoutSegmentPath(tree, parallelRouteKey, first, segmentPath) {
if (first === void 0) first = true;
if (segmentPath === void 0) segmentPath = [];
let node;
if (first) {
// Use the provided parallel route key on the first parallel route
node = tree[1][parallelRouteKey];
} else {
// After first parallel route prefer children, if there's no children pick the first parallel route.
const parallelRoutes = tree[1];
var _parallelRoutes_children;
node = (_parallelRoutes_children = parallelRoutes.children) != null ? _parallelRoutes_children : Object.values(parallelRoutes)[0];
}
if (!node) return segmentPath;
const segment = node[0];
const segmentValue = getSegmentValue(segment);
if (!segmentValue || segmentValue.startsWith("__PAGE__")) return segmentPath;
segmentPath.push(segmentValue);
return getSelectedLayoutSegmentPath(node, parallelRouteKey, false, segmentPath);
}
// TODO-APP: Expand description when the docs are written for it.
/**
* Get the canonical segment path from the current level to the leaf node.
*/ export function useSelectedLayoutSegments(parallelRouteKey) {
if (parallelRouteKey === void 0) parallelRouteKey = "children";
clientHookInServerComponentError("useSelectedLayoutSegments");
const { tree } = useContext(LayoutRouterContext);
return getSelectedLayoutSegmentPath(tree, parallelRouteKey);
}
// TODO-APP: Expand description when the docs are written for it.
/**
* Get the segment below the current level
*/ export function useSelectedLayoutSegment(parallelRouteKey) {
if (parallelRouteKey === void 0) parallelRouteKey = "children";
clientHookInServerComponentError("useSelectedLayoutSegment");
const selectedLayoutSegments = useSelectedLayoutSegments(parallelRouteKey);
if (selectedLayoutSegments.length === 0) {
return null;
}
return selectedLayoutSegments[0];
}
export { redirect, permanentRedirect, RedirectType } from "./redirect";
export { notFound } from "./not-found";
//# sourceMappingURL=navigation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/navigation.ts"],"names":["useContext","useMemo","AppRouterContext","GlobalLayoutRouterContext","LayoutRouterContext","SearchParamsContext","PathnameContext","PathParamsContext","clientHookInServerComponentError","getSegmentValue","INTERNAL_URLSEARCHPARAMS_INSTANCE","Symbol","readonlyURLSearchParamsError","Error","ReadonlyURLSearchParams","iterator","append","delete","set","sort","constructor","urlSearchParams","entries","bind","forEach","get","getAll","has","keys","values","toString","size","useSearchParams","searchParams","readonlySearchParams","window","bailoutToClientRendering","require","usePathname","ServerInsertedHTMLContext","useServerInsertedHTML","useRouter","router","getSelectedParams","tree","params","parallelRoutes","parallelRoute","Object","segment","isDynamicParameter","Array","isArray","segmentValue","startsWith","isCatchAll","split","useParams","globalLayoutRouter","pathParams","getSelectedLayoutSegmentPath","parallelRouteKey","first","segmentPath","node","children","push","useSelectedLayoutSegments","useSelectedLayoutSegment","selectedLayoutSegments","length","redirect","permanentRedirect","RedirectType","notFound"],"mappings":"AAAA,SAASA,UAAU,EAAEC,OAAO,QAAQ,QAAO;AAE3C,SACEC,gBAAgB,EAChBC,yBAAyB,EACzBC,mBAAmB,QACd,qDAAoD;AAC3D,SACEC,mBAAmB,EACnBC,eAAe,EACfC,iBAAiB,QACZ,uDAAsD;AAC7D,SAASC,gCAAgC,QAAQ,0CAAyC;AAC1F,SAASC,eAAe,QAAQ,8CAA6C;AAE7E,MAAMC,oCAAoCC,OACxC;AAGF,SAASC;IACP,OAAO,IAAIC,MAAM;AACnB;AAEA,OAAO,MAAMC;IA0BX,CAACH,OAAOI,QAAQ,CAAC,GAAG;QAClB,OAAO,IAAI,CAACL,kCAAkC,CAACC,OAAOI,QAAQ,CAAC;IACjE;IAEAC,SAAS;QACP,MAAMJ;IACR;IACAK,SAAS;QACP,MAAML;IACR;IACAM,MAAM;QACJ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 +1,5 @@
export default function NoopHead() {
return null;
}
//# sourceMappingURL=noop-head.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/noop-head.tsx"],"names":["NoopHead"],"mappings":"AAAA,eAAe,SAASA;IACtB,OAAO;AACT"}

View File

@@ -0,0 +1,63 @@
"use client";
import React from "react";
import { usePathname } from "./navigation";
class NotFoundErrorBoundary extends React.Component {
static getDerivedStateFromError(error) {
if ((error == null ? void 0 : error.digest) === "NEXT_NOT_FOUND") {
return {
notFoundTriggered: true
};
}
// Re-throw if error is not for 404
throw error;
}
static getDerivedStateFromProps(props, state) {
/**
* Handles reset of the error boundary when a navigation happens.
* Ensures the error boundary does not stay enabled when navigating to a new page.
* Approach of setState in render is safe as it checks the previous pathname and then overrides
* it as outlined in https://react.dev/reference/react/useState#storing-information-from-previous-renders
*/ if (props.pathname !== state.previousPathname && state.notFoundTriggered) {
return {
notFoundTriggered: false,
previousPathname: props.pathname
};
}
return {
notFoundTriggered: state.notFoundTriggered,
previousPathname: props.pathname
};
}
render() {
if (this.state.notFoundTriggered) {
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("meta", {
name: "robots",
content: "noindex"
}), process.env.NODE_ENV === "development" && /*#__PURE__*/ React.createElement("meta", {
name: "next-error",
content: "not-found"
}), this.props.notFoundStyles, this.props.notFound);
}
return this.props.children;
}
constructor(props){
super(props);
this.state = {
notFoundTriggered: !!props.asNotFound,
previousPathname: props.pathname
};
}
}
export function NotFoundBoundary(param) {
let { notFound, notFoundStyles, asNotFound, children } = param;
const pathname = usePathname();
return notFound ? /*#__PURE__*/ React.createElement(NotFoundErrorBoundary, {
pathname: pathname,
notFound: notFound,
notFoundStyles: notFoundStyles,
asNotFound: asNotFound
}, children) : /*#__PURE__*/ React.createElement(React.Fragment, null, children);
}
//# sourceMappingURL=not-found-boundary.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/not-found-boundary.tsx"],"names":["React","usePathname","NotFoundErrorBoundary","Component","getDerivedStateFromError","error","digest","notFoundTriggered","getDerivedStateFromProps","props","state","pathname","previousPathname","render","meta","name","content","process","env","NODE_ENV","notFoundStyles","notFound","children","constructor","asNotFound","NotFoundBoundary"],"mappings":"AAAA;AAEA,OAAOA,WAAW,QAAO;AACzB,SAASC,WAAW,QAAQ,eAAc;AAkB1C,MAAMC,8BAA8BF,MAAMG,SAAS;IAYjD,OAAOC,yBAAyBC,KAAU,EAAE;QAC1C,IAAIA,CAAAA,yBAAAA,MAAOC,MAAM,MAAK,kBAAkB;YACtC,OAAO;gBAAEC,mBAAmB;YAAK;QACnC;QACA,mCAAmC;QACnC,MAAMF;IACR;IAEA,OAAOG,yBACLC,KAAiC,EACjCC,KAAiC,EACE;QACnC;;;;;KAKC,GACD,IAAID,MAAME,QAAQ,KAAKD,MAAME,gBAAgB,IAAIF,MAAMH,iBAAiB,EAAE;YACxE,OAAO;gBACLA,mBAAmB;gBACnBK,kBAAkBH,MAAME,QAAQ;YAClC;QACF;QACA,OAAO;YACLJ,mBAAmBG,MAAMH,iBAAiB;YAC1CK,kBAAkBH,MAAME,QAAQ;QAClC;IACF;IAEAE,SAAS;QACP,IAAI,IAAI,CAACH,KAAK,CAACH,iBAAiB,EAAE;YAChC,qBACE,wDACE,oBAACO;gBAAKC,MAAK;gBAASC,SAAQ;gBAC3BC,QAAQC,GAAG,CAACC,QAAQ,KAAK,+BACxB,oBAACL;gBAAKC,MAAK;gBAAaC,SAAQ;gBAEjC,IAAI,CAACP,KAAK,CAACW,cAAc,EACzB,IAAI,CAACX,KAAK,CAACY,QAAQ;QAG1B;QAEA,OAAO,IAAI,CAACZ,KAAK,CAACa,QAAQ;IAC5B;IArDAC,YAAYd,KAAiC,CAAE;QAC7C,KAAK,CAACA;QACN,IAAI,CAACC,KAAK,GAAG;YACXH,mBAAmB,CAAC,CAACE,MAAMe,UAAU;YACrCZ,kBAAkBH,MAAME,QAAQ;QAClC;IACF;AAgDF;AAEA,OAAO,SAASc,iBAAiB,KAKT;IALS,IAAA,EAC/BJ,QAAQ,EACRD,cAAc,EACdI,UAAU,EACVF,QAAQ,EACc,GALS;IAM/B,MAAMX,WAAWV;IACjB,OAAOoB,yBACL,oBAACnB;QACCS,UAAUA;QACVU,UAAUA;QACVD,gBAAgBA;QAChBI,YAAYA;OAEXF,0BAGH,0CAAGA;AAEP"}

View File

@@ -0,0 +1,61 @@
import React from "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: {
display: "inline-block"
},
h1: {
display: "inline-block",
margin: "0 20px 0 0",
padding: "0 23px 0 0",
fontSize: 24,
fontWeight: 500,
verticalAlign: "top",
lineHeight: "49px"
},
h2: {
fontSize: 14,
fontWeight: 400,
lineHeight: "49px",
margin: 0
}
};
export default function NotFound() {
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("title", null, "404: This page could not be found."), /*#__PURE__*/ React.createElement("div", {
style: styles.error
}, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("style", {
dangerouslySetInnerHTML: {
/* Minified CSS 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);
}
}
*/ __html: "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)}}"
}
}), /*#__PURE__*/ React.createElement("h1", {
className: "next-error-h1",
style: styles.h1
}, "404"), /*#__PURE__*/ React.createElement("div", {
style: styles.desc
}, /*#__PURE__*/ React.createElement("h2", {
style: styles.h2
}, "This page could not be found.")))));
}
//# sourceMappingURL=not-found-error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/not-found-error.tsx"],"names":["React","styles","error","fontFamily","height","textAlign","display","flexDirection","alignItems","justifyContent","desc","h1","margin","padding","fontSize","fontWeight","verticalAlign","lineHeight","h2","NotFound","title","div","style","dangerouslySetInnerHTML","__html","className"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AAEzB,MAAMC,SAA8C;IAClDC,OAAO;QACL,0FAA0F;QAC1FC,YACE;QACFC,QAAQ;QACRC,WAAW;QACXC,SAAS;QACTC,eAAe;QACfC,YAAY;QACZC,gBAAgB;IAClB;IAEAC,MAAM;QACJJ,SAAS;IACX;IAEAK,IAAI;QACFL,SAAS;QACTM,QAAQ;QACRC,SAAS;QACTC,UAAU;QACVC,YAAY;QACZC,eAAe;QACfC,YAAY;IACd;IAEAC,IAAI;QACFJ,UAAU;QACVC,YAAY;QACZE,YAAY;QACZL,QAAQ;IACV;AACF;AAEA,eAAe,SAASO;IACtB,qBACE,wDAEE,oBAACC,eAAM,qDAEP,oBAACC;QAAIC,OAAOrB,OAAOC,KAAK;qBACtB,oBAACmB,2BACC,oBAACC;QACCC,yBAAyB;YACvB;;;;;;;;;;;;cAYA,GACAC,QAAS;QACX;sBAEF,oBAACb;QAAGc,WAAU;QAAgBH,OAAOrB,OAAOU,EAAE;OAAE,sBAGhD,oBAACU;QAAIC,OAAOrB,OAAOS,IAAI;qBACrB,oBAACQ;QAAGI,OAAOrB,OAAOiB,EAAE;OAAE;AAMlC"}

View File

@@ -0,0 +1,21 @@
const NOT_FOUND_ERROR_CODE = "NEXT_NOT_FOUND";
/**
* When used in a React server component, this will set the status code to 404.
* When used in a custom app route it will just send a 404 status.
*/ export function notFound() {
// eslint-disable-next-line no-throw-literal
const error = new Error(NOT_FOUND_ERROR_CODE);
error.digest = NOT_FOUND_ERROR_CODE;
throw error;
}
/**
* Checks an error to determine if it's an error generated by the `notFound()`
* helper.
*
* @param error the error that may reference a not found error
* @returns true if the error is a not found error
*/ export function isNotFoundError(error) {
return (error == null ? void 0 : error.digest) === NOT_FOUND_ERROR_CODE;
}
//# sourceMappingURL=not-found.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/not-found.ts"],"names":["NOT_FOUND_ERROR_CODE","notFound","error","Error","digest","isNotFoundError"],"mappings":"AAAA,MAAMA,uBAAuB;AAI7B;;;CAGC,GACD,OAAO,SAASC;IACd,4CAA4C;IAC5C,MAAMC,QAAQ,IAAIC,MAAMH;IACtBE,MAAwBE,MAAM,GAAGJ;IACnC,MAAME;AACR;AAEA;;;;;;CAMC,GACD,OAAO,SAASG,gBAAgBH,KAAU;IACxC,OAAOA,CAAAA,yBAAAA,MAAOE,MAAM,MAAKJ;AAC3B"}

View File

@@ -0,0 +1,6 @@
import { notFound } from "./not-found";
export default function NoopParallelRouteDefault() {
notFound();
}
//# sourceMappingURL=parallel-route-default.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/parallel-route-default.tsx"],"names":["notFound","NoopParallelRouteDefault"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAa;AAEtC,eAAe,SAASC;IACtBD;AACF"}

View File

@@ -0,0 +1,75 @@
/*
This is a simple promise queue that allows you to limit the number of concurrent promises
that are running at any given time. It's used to limit the number of concurrent
prefetch requests that are being made to the server but could be used for other
things as well.
*/ import { _ as _class_private_field_loose_base } from "@swc/helpers/_/_class_private_field_loose_base";
import { _ as _class_private_field_loose_key } from "@swc/helpers/_/_class_private_field_loose_key";
var _maxConcurrency = /*#__PURE__*/ _class_private_field_loose_key("_maxConcurrency"), _runningCount = /*#__PURE__*/ _class_private_field_loose_key("_runningCount"), _queue = /*#__PURE__*/ _class_private_field_loose_key("_queue"), _processNext = /*#__PURE__*/ _class_private_field_loose_key("_processNext");
export class PromiseQueue {
enqueue(promiseFn) {
let taskResolve;
let taskReject;
const taskPromise = new Promise((resolve, reject)=>{
taskResolve = resolve;
taskReject = reject;
});
const task = async ()=>{
try {
_class_private_field_loose_base(this, _runningCount)[_runningCount]++;
const result = await promiseFn();
taskResolve(result);
} catch (error) {
taskReject(error);
} finally{
_class_private_field_loose_base(this, _runningCount)[_runningCount]--;
_class_private_field_loose_base(this, _processNext)[_processNext]();
}
};
const enqueueResult = {
promiseFn: taskPromise,
task
};
// wonder if we should take a LIFO approach here
_class_private_field_loose_base(this, _queue)[_queue].push(enqueueResult);
_class_private_field_loose_base(this, _processNext)[_processNext]();
return taskPromise;
}
bump(promiseFn) {
const index = _class_private_field_loose_base(this, _queue)[_queue].findIndex((item)=>item.promiseFn === promiseFn);
if (index > -1) {
const bumpedItem = _class_private_field_loose_base(this, _queue)[_queue].splice(index, 1)[0];
_class_private_field_loose_base(this, _queue)[_queue].unshift(bumpedItem);
_class_private_field_loose_base(this, _processNext)[_processNext](true);
}
}
constructor(maxConcurrency = 5){
Object.defineProperty(this, _processNext, {
value: processNext
});
Object.defineProperty(this, _maxConcurrency, {
writable: true,
value: void 0
});
Object.defineProperty(this, _runningCount, {
writable: true,
value: void 0
});
Object.defineProperty(this, _queue, {
writable: true,
value: void 0
});
_class_private_field_loose_base(this, _maxConcurrency)[_maxConcurrency] = maxConcurrency;
_class_private_field_loose_base(this, _runningCount)[_runningCount] = 0;
_class_private_field_loose_base(this, _queue)[_queue] = [];
}
}
function processNext(forced) {
if (forced === void 0) forced = false;
if ((_class_private_field_loose_base(this, _runningCount)[_runningCount] < _class_private_field_loose_base(this, _maxConcurrency)[_maxConcurrency] || forced) && _class_private_field_loose_base(this, _queue)[_queue].length > 0) {
var _class_private_field_loose_base__queue_shift;
(_class_private_field_loose_base__queue_shift = _class_private_field_loose_base(this, _queue)[_queue].shift()) == null ? void 0 : _class_private_field_loose_base__queue_shift.task();
}
}
//# sourceMappingURL=promise-queue.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/client/components/promise-queue.ts"],"names":["PromiseQueue","enqueue","promiseFn","taskResolve","taskReject","taskPromise","Promise","resolve","reject","task","runningCount","result","error","processNext","enqueueResult","queue","push","bump","index","findIndex","item","bumpedItem","splice","unshift","constructor","maxConcurrency","forced","length","shift"],"mappings":"AAAA;;;;;AAKA;;IAEE,mFACA,+EACA,iEAgDA;AAnDF,OAAO,MAAMA;IAWXC,QAAWC,SAA2B,EAAc;QAClD,IAAIC;QACJ,IAAIC;QAEJ,MAAMC,cAAc,IAAIC,QAAQ,CAACC,SAASC;YACxCL,cAAcI;YACdH,aAAaI;QACf;QAEA,MAAMC,OAAO;YACX,IAAI;gBACF,gCAAA,IAAI,EAAEC,eAAAA;gBACN,MAAMC,SAAS,MAAMT;gBACrBC,YAAYQ;YACd,EAAE,OAAOC,OAAO;gBACdR,WAAWQ;YACb,SAAU;gBACR,gCAAA,IAAI,EAAEF,eAAAA;gBACN,gCAAA,IAAI,EAAEG,cAAAA;YACR;QACF;QAEA,MAAMC,gBAAgB;YAAEZ,WAAWG;YAAaI;QAAK;QACrD,gDAAgD;QAChD,gCAAA,IAAI,EAAEM,QAAAA,QAAMC,IAAI,CAACF;QACjB,gCAAA,IAAI,EAAED,cAAAA;QAEN,OAAOR;IACT;IAEAY,KAAKf,SAAuB,EAAE;QAC5B,MAAMgB,QAAQ,gCAAA,IAAI,EAAEH,QAAAA,QAAMI,SAAS,CAAC,CAACC,OAASA,KAAKlB,SAAS,KAAKA;QAEjE,IAAIgB,QAAQ,CAAC,GAAG;YACd,MAAMG,aAAa,gCAAA,IAAI,EAAEN,QAAAA,QAAMO,MAAM,CAACJ,OAAO,EAAE,CAAC,EAAE;YAClD,gCAAA,IAAI,EAAEH,QAAAA,QAAMQ,OAAO,CAACF;YACpB,gCAAA,IAAI,EAAER,cAAAA,cAAY;QACpB;IACF;IA5CAW,YAAYC,iBAAiB,CAAC,CAAE;QA8ChC,4BAAA;mBAAA;;QAlDA,4BAAA;;mBAAA,KAAA;;QACA,4BAAA;;mBAAA,KAAA;;QACA,4BAAA;;mBAAA,KAAA;;QAGE,gCAAA,IAAI,EAAEA,iBAAAA,mBAAiBA;QACvB,gCAAA,IAAI,EAAEf,eAAAA,iBAAe;QACrB,gCAAA,IAAI,EAAEK,QAAAA,UAAQ,EAAE;IAClB;AAkDF;AARE,SAAA,YAAaW,MAAc;IAAdA,IAAAA,mBAAAA,SAAS;IACpB,IACE,AAAC,CAAA,gCAAA,IAAI,EAAEhB,eAAAA,iBAAe,gCAAA,IAAI,EAAEe,iBAAAA,oBAAkBC,MAAK,KACnD,gCAAA,IAAI,EAAEX,QAAAA,QAAMY,MAAM,GAAG,GACrB;YACA;SAAA,+CAAA,gCAAA,IAAI,EAAEZ,QAAAA,QAAMa,KAAK,uBAAjB,6CAAqBnB,IAAI;IAC3B;AACF"}

View File

@@ -0,0 +1,385 @@
import React, { useCallback, useEffect, useReducer, useMemo, startTransition } from "react";
import stripAnsi from "next/dist/compiled/strip-ansi";
import formatWebpackMessages from "../../dev/error-overlay/format-webpack-messages";
import { useRouter } from "../navigation";
import { ACTION_VERSION_INFO, INITIAL_OVERLAY_STATE, errorOverlayReducer } from "./internal/error-overlay-reducer";
import { ACTION_BUILD_OK, ACTION_BUILD_ERROR, ACTION_BEFORE_REFRESH, ACTION_REFRESH, ACTION_UNHANDLED_ERROR, ACTION_UNHANDLED_REJECTION } from "./internal/error-overlay-reducer";
import { parseStack } from "./internal/helpers/parseStack";
import ReactDevOverlay from "./internal/ReactDevOverlay";
import { RuntimeErrorHandler, useErrorHandler } from "./internal/helpers/use-error-handler";
import { useSendMessage, useTurbopack, useWebsocket, useWebsocketPing } from "./internal/helpers/use-websocket";
import { parseComponentStack } from "./internal/helpers/parse-component-stack";
import { HMR_ACTIONS_SENT_TO_BROWSER } from "../../../server/dev/hot-reloader-types";
let mostRecentCompilationHash = null;
let __nextDevClientId = Math.round(Math.random() * 100 + Date.now());
function onBeforeFastRefresh(dispatcher, hasUpdates) {
if (hasUpdates) {
dispatcher.onBeforeRefresh();
}
}
function onFastRefresh(dispatcher, hasUpdates) {
dispatcher.onBuildOk();
if (hasUpdates) {
dispatcher.onRefresh();
}
}
// There is a newer version of the code available.
function handleAvailableHash(hash) {
// Update last known compilation hash.
mostRecentCompilationHash = hash;
}
// Is there a newer version of this code available?
function isUpdateAvailable() {
/* globals __webpack_hash__ */ // __webpack_hash__ is the hash of the current compilation.
// It's a global variable injected by Webpack.
return mostRecentCompilationHash !== __webpack_hash__;
}
// Webpack disallows updates in other states.
function canApplyUpdates() {
// @ts-expect-error module.hot exists
return module.hot.status() === "idle";
}
function afterApplyUpdates(fn) {
if (canApplyUpdates()) {
fn();
} else {
function handler(status) {
if (status === "idle") {
// @ts-expect-error module.hot exists
module.hot.removeStatusHandler(handler);
fn();
}
}
// @ts-expect-error module.hot exists
module.hot.addStatusHandler(handler);
}
}
function performFullReload(err, sendMessage) {
const stackTrace = err && (err.stack && err.stack.split("\n").slice(0, 5).join("\n") || err.message || err + "");
sendMessage(JSON.stringify({
event: "client-full-reload",
stackTrace,
hadRuntimeError: !!RuntimeErrorHandler.hadRuntimeError
}));
window.location.reload();
}
// Attempt to update code on the fly, fall back to a hard reload.
function tryApplyUpdates(onBeforeUpdate, onHotUpdateSuccess, sendMessage, dispatcher) {
if (!isUpdateAvailable() || !canApplyUpdates()) {
dispatcher.onBuildOk();
return;
}
function handleApplyUpdates(err, updatedModules) {
if (err || RuntimeErrorHandler.hadRuntimeError || !updatedModules) {
if (err) {
console.warn("[Fast Refresh] performing full reload\n\n" + "Fast Refresh will perform a full reload when you edit a file that's imported by modules outside of the React rendering tree.\n" + "You might have a file which exports a React component but also exports a value that is imported by a non-React component file.\n" + "Consider migrating the non-React component export to a separate file and importing it into both files.\n\n" + "It is also possible the parent component of the component you edited is a class component, which disables Fast Refresh.\n" + "Fast Refresh requires at least one parent function component in your React tree.");
} else if (RuntimeErrorHandler.hadRuntimeError) {
console.warn("[Fast Refresh] performing full reload because your application had an unrecoverable error");
}
performFullReload(err, sendMessage);
return;
}
const hasUpdates = Boolean(updatedModules.length);
if (typeof onHotUpdateSuccess === "function") {
// Maybe we want to do something.
onHotUpdateSuccess(hasUpdates);
}
if (isUpdateAvailable()) {
// While we were updating, there was a new update! Do it again.
tryApplyUpdates(hasUpdates ? ()=>{} : onBeforeUpdate, hasUpdates ? ()=>dispatcher.onBuildOk() : onHotUpdateSuccess, sendMessage, dispatcher);
} else {
dispatcher.onBuildOk();
if (process.env.__NEXT_TEST_MODE) {
afterApplyUpdates(()=>{
if (self.__NEXT_HMR_CB) {
self.__NEXT_HMR_CB();
self.__NEXT_HMR_CB = null;
}
});
}
}
}
// https://webpack.js.org/api/hot-module-replacement/#check
// @ts-expect-error module.hot exists
module.hot.check(/* autoApply */ false).then((updatedModules)=>{
if (!updatedModules) {
return null;
}
if (typeof onBeforeUpdate === "function") {
const hasUpdates = Boolean(updatedModules.length);
onBeforeUpdate(hasUpdates);
}
// https://webpack.js.org/api/hot-module-replacement/#apply
// @ts-expect-error module.hot exists
return module.hot.apply();
}).then((updatedModules)=>{
handleApplyUpdates(null, updatedModules);
}, (err)=>{
handleApplyUpdates(err, null);
});
}
function processMessage(obj, sendMessage, router, dispatcher) {
if (!("action" in obj)) {
return;
}
function handleErrors(errors) {
// "Massage" webpack messages.
const formatted = formatWebpackMessages({
errors: errors,
warnings: []
});
// Only show the first error.
dispatcher.onBuildError(formatted.errors[0]);
// Also log them to the console.
for(let i = 0; i < formatted.errors.length; i++){
console.error(stripAnsi(formatted.errors[i]));
}
// Do not attempt to reload now.
// We will reload on next success instead.
if (process.env.__NEXT_TEST_MODE) {
if (self.__NEXT_HMR_CB) {
self.__NEXT_HMR_CB(formatted.errors[0]);
self.__NEXT_HMR_CB = null;
}
}
}
switch(obj.action){
case HMR_ACTIONS_SENT_TO_BROWSER.BUILDING:
{
console.log("[Fast Refresh] rebuilding");
break;
}
case HMR_ACTIONS_SENT_TO_BROWSER.BUILT:
case HMR_ACTIONS_SENT_TO_BROWSER.SYNC:
{
if (obj.hash) {
handleAvailableHash(obj.hash);
}
const { errors, warnings } = obj;
// Is undefined when it's a 'built' event
if ("versionInfo" in obj) {
dispatcher.onVersionInfo(obj.versionInfo);
}
const hasErrors = Boolean(errors && errors.length);
// Compilation with errors (e.g. syntax error or missing modules).
if (hasErrors) {
sendMessage(JSON.stringify({
event: "client-error",
errorCount: errors.length,
clientId: __nextDevClientId
}));
handleErrors(errors);
return;
}
const hasWarnings = Boolean(warnings && warnings.length);
if (hasWarnings) {
sendMessage(JSON.stringify({
event: "client-warning",
warningCount: warnings.length,
clientId: __nextDevClientId
}));
// Compilation with warnings (e.g. ESLint).
const isHotUpdate = obj.action !== HMR_ACTIONS_SENT_TO_BROWSER.SYNC;
// Print warnings to the console.
const formattedMessages = formatWebpackMessages({
warnings: warnings,
errors: []
});
for(let i = 0; i < formattedMessages.warnings.length; i++){
if (i === 5) {
console.warn("There were more warnings in other files.\n" + "You can find a complete log in the terminal.");
break;
}
console.warn(stripAnsi(formattedMessages.warnings[i]));
}
// Attempt to apply hot updates or reload.
if (isHotUpdate) {
tryApplyUpdates(function onBeforeHotUpdate(hasUpdates) {
onBeforeFastRefresh(dispatcher, hasUpdates);
}, function onSuccessfulHotUpdate(hasUpdates) {
// Only dismiss it when we're sure it's a hot update.
// Otherwise it would flicker right before the reload.
onFastRefresh(dispatcher, hasUpdates);
}, sendMessage, dispatcher);
}
return;
}
sendMessage(JSON.stringify({
event: "client-success",
clientId: __nextDevClientId
}));
const isHotUpdate = obj.action !== HMR_ACTIONS_SENT_TO_BROWSER.SYNC && (!window.__NEXT_DATA__ || window.__NEXT_DATA__.page !== "/_error") && isUpdateAvailable();
// Attempt to apply hot updates or reload.
if (isHotUpdate) {
tryApplyUpdates(function onBeforeHotUpdate(hasUpdates) {
onBeforeFastRefresh(dispatcher, hasUpdates);
}, function onSuccessfulHotUpdate(hasUpdates) {
// Only dismiss it when we're sure it's a hot update.
// Otherwise it would flicker right before the reload.
onFastRefresh(dispatcher, hasUpdates);
}, sendMessage, dispatcher);
}
return;
}
// TODO-APP: make server component change more granular
case HMR_ACTIONS_SENT_TO_BROWSER.SERVER_COMPONENT_CHANGES:
{
sendMessage(JSON.stringify({
event: "server-component-reload-page",
clientId: __nextDevClientId
}));
if (RuntimeErrorHandler.hadRuntimeError) {
return window.location.reload();
}
startTransition(()=>{
// @ts-ignore it exists, it's just hidden
router.fastRefresh();
dispatcher.onRefresh();
});
if (process.env.__NEXT_TEST_MODE) {
if (self.__NEXT_HMR_CB) {
self.__NEXT_HMR_CB();
self.__NEXT_HMR_CB = null;
}
}
return;
}
case HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE:
{
sendMessage(JSON.stringify({
event: "client-reload-page",
clientId: __nextDevClientId
}));
return window.location.reload();
}
case HMR_ACTIONS_SENT_TO_BROWSER.REMOVED_PAGE:
{
// TODO-APP: potentially only refresh if the currently viewed page was removed.
// @ts-ignore it exists, it's just hidden
router.fastRefresh();
return;
}
case HMR_ACTIONS_SENT_TO_BROWSER.ADDED_PAGE:
{
// TODO-APP: potentially only refresh if the currently viewed page was added.
// @ts-ignore it exists, it's just hidden
router.fastRefresh();
return;
}
case HMR_ACTIONS_SENT_TO_BROWSER.SERVER_ERROR:
{
const { errorJSON } = obj;
if (errorJSON) {
const { message, stack } = JSON.parse(errorJSON);
const error = new Error(message);
error.stack = stack;
handleErrors([
error
]);
}
return;
}
case HMR_ACTIONS_SENT_TO_BROWSER.DEV_PAGES_MANIFEST_UPDATE:
{
return;
}
default:
{
throw new Error("Unexpected action " + JSON.stringify(obj));
}
}
}
export default function HotReload(param) {
let { assetPrefix, children } = param;
const [state, dispatch] = useReducer(errorOverlayReducer, INITIAL_OVERLAY_STATE);
const dispatcher = useMemo(()=>{
return {
onBuildOk () {
dispatch({
type: ACTION_BUILD_OK
});
},
onBuildError (message) {
dispatch({
type: ACTION_BUILD_ERROR,
message
});
},
onBeforeRefresh () {
dispatch({
type: ACTION_BEFORE_REFRESH
});
},
onRefresh () {
dispatch({
type: ACTION_REFRESH
});
},
onVersionInfo (versionInfo) {
dispatch({
type: ACTION_VERSION_INFO,
versionInfo
});
}
};
}, [
dispatch
]);
const handleOnUnhandledError = useCallback((error)=>{
// Component stack is added to the error in use-error-handler in case there was a hydration errror
const componentStack = error._componentStack;
dispatch({
type: ACTION_UNHANDLED_ERROR,
reason: error,
frames: parseStack(error.stack),
componentStackFrames: componentStack && parseComponentStack(componentStack)
});
}, []);
const handleOnUnhandledRejection = useCallback((reason)=>{
dispatch({
type: ACTION_UNHANDLED_REJECTION,
reason: reason,
frames: parseStack(reason.stack)
});
}, []);
const handleOnReactError = useCallback(()=>{
RuntimeErrorHandler.hadRuntimeError = true;
}, []);
useErrorHandler(handleOnUnhandledError, handleOnUnhandledRejection);
const webSocketRef = useWebsocket(assetPrefix);
useWebsocketPing(webSocketRef);
const sendMessage = useSendMessage(webSocketRef);
const processTurbopackMessage = useTurbopack(sendMessage);
const router = useRouter();
useEffect(()=>{
const handler = (event)=>{
try {
const obj = JSON.parse(event.data);
const handledByTurbopack = processTurbopackMessage == null ? void 0 : processTurbopackMessage(obj);
if (!handledByTurbopack) {
processMessage(obj, sendMessage, router, dispatcher);
}
} catch (err) {
var _err_stack;
console.warn("[HMR] Invalid message: " + event.data + "\n" + ((_err_stack = err == null ? void 0 : err.stack) != null ? _err_stack : ""));
}
};
const websocket = webSocketRef.current;
if (websocket) {
websocket.addEventListener("message", handler);
}
return ()=>websocket && websocket.removeEventListener("message", handler);
}, [
sendMessage,
router,
webSocketRef,
dispatcher,
processTurbopackMessage
]);
return /*#__PURE__*/ React.createElement(ReactDevOverlay, {
onReactError: handleOnReactError,
state: state
}, children);
}
//# sourceMappingURL=hot-reloader-client.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,63 @@
import * as React from "react";
import { ACTION_UNHANDLED_ERROR } from "./error-overlay-reducer";
import { ShadowPortal } from "./components/ShadowPortal";
import { BuildError } from "./container/BuildError";
import { Errors } from "./container/Errors";
import { RootLayoutError } from "./container/RootLayoutError";
import { parseStack } from "./helpers/parseStack";
import { Base } from "./styles/Base";
import { ComponentStyles } from "./styles/ComponentStyles";
import { CssReset } from "./styles/CssReset";
class ReactDevOverlay extends React.PureComponent {
static getDerivedStateFromError(error) {
const e = error;
const event = {
type: ACTION_UNHANDLED_ERROR,
reason: error,
frames: parseStack(e.stack)
};
const errorEvent = {
id: 0,
event
};
return {
reactError: errorEvent
};
}
componentDidCatch(componentErr) {
this.props.onReactError(componentErr);
}
render() {
const { state, children } = this.props;
const { reactError } = this.state;
const hasBuildError = state.buildError != null;
const hasRuntimeErrors = Boolean(state.errors.length);
const rootLayoutMissingTagsError = state.rootLayoutMissingTagsError;
const isMounted = hasBuildError || hasRuntimeErrors || reactError || rootLayoutMissingTagsError;
return /*#__PURE__*/ React.createElement(React.Fragment, null, reactError ? /*#__PURE__*/ React.createElement("html", null, /*#__PURE__*/ React.createElement("head", null), /*#__PURE__*/ React.createElement("body", null)) : children, isMounted ? /*#__PURE__*/ React.createElement(ShadowPortal, null, /*#__PURE__*/ React.createElement(CssReset, null), /*#__PURE__*/ React.createElement(Base, null), /*#__PURE__*/ React.createElement(ComponentStyles, null), rootLayoutMissingTagsError ? /*#__PURE__*/ React.createElement(RootLayoutError, {
missingTags: rootLayoutMissingTagsError.missingTags
}) : hasBuildError ? /*#__PURE__*/ React.createElement(BuildError, {
message: state.buildError,
versionInfo: state.versionInfo
}) : reactError ? /*#__PURE__*/ React.createElement(Errors, {
versionInfo: state.versionInfo,
initialDisplayState: "fullscreen",
errors: [
reactError
]
}) : hasRuntimeErrors ? /*#__PURE__*/ React.createElement(Errors, {
initialDisplayState: "minimized",
errors: state.errors,
versionInfo: state.versionInfo
}) : undefined) : undefined);
}
constructor(...args){
super(...args);
this.state = {
reactError: null
};
}
}
export default ReactDevOverlay;
//# sourceMappingURL=ReactDevOverlay.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/client/components/react-dev-overlay/internal/ReactDevOverlay.tsx"],"names":["React","ACTION_UNHANDLED_ERROR","ShadowPortal","BuildError","Errors","RootLayoutError","parseStack","Base","ComponentStyles","CssReset","ReactDevOverlay","PureComponent","getDerivedStateFromError","error","e","event","type","reason","frames","stack","errorEvent","id","reactError","componentDidCatch","componentErr","props","onReactError","render","state","children","hasBuildError","buildError","hasRuntimeErrors","Boolean","errors","length","rootLayoutMissingTagsError","isMounted","html","head","body","missingTags","message","versionInfo","initialDisplayState","undefined"],"mappings":"AAAA,YAAYA,WAAW,QAAO;AAC9B,SACEC,sBAAsB,QAGjB,0BAAyB;AAEhC,SAASC,YAAY,QAAQ,4BAA2B;AACxD,SAASC,UAAU,QAAQ,yBAAwB;AACnD,SAASC,MAAM,QAA6B,qBAAoB;AAChE,SAASC,eAAe,QAAQ,8BAA6B;AAC7D,SAASC,UAAU,QAAQ,uBAAsB;AACjD,SAASC,IAAI,QAAQ,gBAAe;AACpC,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,QAAQ,QAAQ,oBAAmB;AAK5C,MAAMC,wBAAwBV,MAAMW,aAAa;IAU/C,OAAOC,yBAAyBC,KAAY,EAAwB;QAClE,MAAMC,IAAID;QACV,MAAME,QAA8B;YAClCC,MAAMf;YACNgB,QAAQJ;YACRK,QAAQZ,WAAWQ,EAAEK,KAAK;QAC5B;QACA,MAAMC,aAAkC;YACtCC,IAAI;YACJN;QACF;QACA,OAAO;YAAEO,YAAYF;QAAW;IAClC;IAEAG,kBAAkBC,YAAmB,EAAE;QACrC,IAAI,CAACC,KAAK,CAACC,YAAY,CAACF;IAC1B;IAEAG,SAAS;QACP,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAACJ,KAAK;QACtC,MAAM,EAAEH,UAAU,EAAE,GAAG,IAAI,CAACM,KAAK;QAEjC,MAAME,gBAAgBF,MAAMG,UAAU,IAAI;QAC1C,MAAMC,mBAAmBC,QAAQL,MAAMM,MAAM,CAACC,MAAM;QACpD,MAAMC,6BAA6BR,MAAMQ,0BAA0B;QACnE,MAAMC,YACJP,iBACAE,oBACAV,cACAc;QAEF,qBACE,0CACGd,2BACC,oBAACgB,4BACC,oBAACC,6BACD,oBAACC,iBAGHX,UAEDQ,0BACC,oBAACnC,kCACC,oBAACO,+BACD,oBAACF,2BACD,oBAACC,wBAEA4B,2CACC,oBAAC/B;YACCoC,aAAaL,2BAA2BK,WAAW;aAEnDX,8BACF,oBAAC3B;YACCuC,SAASd,MAAMG,UAAU;YACzBY,aAAaf,MAAMe,WAAW;aAE9BrB,2BACF,oBAAClB;YACCuC,aAAaf,MAAMe,WAAW;YAC9BC,qBAAoB;YACpBV,QAAQ;gBAACZ;aAAW;aAEpBU,iCACF,oBAAC5B;YACCwC,qBAAoB;YACpBV,QAAQN,MAAMM,MAAM;YACpBS,aAAaf,MAAMe,WAAW;aAE9BE,aAEJA;IAGV;;;aA3EAjB,QAAQ;YAAEN,YAAY;QAAK;;AA4E7B;AAEA,eAAeZ,gBAAe"}

View File

@@ -0,0 +1,72 @@
import Anser from "next/dist/compiled/anser";
import * as React from "react";
import stripAnsi from "next/dist/compiled/strip-ansi";
import { getFrameSource } from "../../helpers/stack-frame";
import { useOpenInEditor } from "../../helpers/use-open-in-editor";
export const CodeFrame = function CodeFrame(param) {
let { stackFrame, codeFrame } = param;
// Strip leading spaces out of the code frame:
const formattedFrame = React.useMemo(()=>{
const lines = codeFrame.split(/\r?\n/g);
const prefixLength = lines.map((line)=>/^>? +\d+ +\| [ ]+/.exec(stripAnsi(line)) === null ? null : /^>? +\d+ +\| ( *)/.exec(stripAnsi(line))).filter(Boolean).map((v)=>v.pop()).reduce((c, n)=>isNaN(c) ? n.length : Math.min(c, n.length), NaN);
if (prefixLength > 1) {
const p = " ".repeat(prefixLength);
return lines.map((line, a)=>~(a = line.indexOf("|")) ? line.substring(0, a) + line.substring(a).replace(p, "") : line).join("\n");
}
return lines.join("\n");
}, [
codeFrame
]);
const decoded = React.useMemo(()=>{
return Anser.ansiToJson(formattedFrame, {
json: true,
use_classes: true,
remove_empty: true
});
}, [
formattedFrame
]);
const open = useOpenInEditor({
file: stackFrame.file,
lineNumber: stackFrame.lineNumber,
column: stackFrame.column
});
// TODO: make the caret absolute
return /*#__PURE__*/ React.createElement("div", {
"data-nextjs-codeframe": true
}, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("p", {
role: "link",
onClick: open,
tabIndex: 1,
title: "Click to open in your editor"
}, /*#__PURE__*/ React.createElement("span", null, getFrameSource(stackFrame), " @ ", stackFrame.methodName), /*#__PURE__*/ React.createElement("svg", {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round"
}, /*#__PURE__*/ React.createElement("path", {
d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
}), /*#__PURE__*/ React.createElement("polyline", {
points: "15 3 21 3 21 9"
}), /*#__PURE__*/ React.createElement("line", {
x1: "10",
y1: "14",
x2: "21",
y2: "3"
})))), /*#__PURE__*/ React.createElement("pre", null, decoded.map((entry, index)=>/*#__PURE__*/ React.createElement("span", {
key: "frame-" + index,
style: {
color: entry.fg ? "var(--color-" + entry.fg + ")" : undefined,
...entry.decoration === "bold" ? {
fontWeight: 800
} : entry.decoration === "italic" ? {
fontStyle: "italic"
} : undefined
}
}, entry.content))));
};
//# sourceMappingURL=CodeFrame.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/CodeFrame/CodeFrame.tsx"],"names":["Anser","React","stripAnsi","getFrameSource","useOpenInEditor","CodeFrame","stackFrame","codeFrame","formattedFrame","useMemo","lines","split","prefixLength","map","line","exec","filter","Boolean","v","pop","reduce","c","n","isNaN","length","Math","min","NaN","p","repeat","a","indexOf","substring","replace","join","decoded","ansiToJson","json","use_classes","remove_empty","open","file","lineNumber","column","div","data-nextjs-codeframe","role","onClick","tabIndex","title","span","methodName","svg","xmlns","viewBox","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","path","d","polyline","points","x1","y1","x2","y2","pre","entry","index","key","style","color","fg","undefined","decoration","fontWeight","fontStyle","content"],"mappings":"AAAA,OAAOA,WAAW,2BAA0B;AAC5C,YAAYC,WAAW,QAAO;AAE9B,OAAOC,eAAe,gCAA+B;AACrD,SAASC,cAAc,QAAQ,4BAA2B;AAC1D,SAASC,eAAe,QAAQ,mCAAkC;AAIlE,OAAO,MAAMC,YAAsC,SAASA,UAAU,KAGrE;IAHqE,IAAA,EACpEC,UAAU,EACVC,SAAS,EACV,GAHqE;IAIpE,8CAA8C;IAC9C,MAAMC,iBAAiBP,MAAMQ,OAAO,CAAS;QAC3C,MAAMC,QAAQH,UAAUI,KAAK,CAAC;QAC9B,MAAMC,eAAeF,MAClBG,GAAG,CAAC,CAACC,OACJ,oBAAoBC,IAAI,CAACb,UAAUY,WAAW,OAC1C,OACA,oBAAoBC,IAAI,CAACb,UAAUY,QAExCE,MAAM,CAACC,SACPJ,GAAG,CAAC,CAACK,IAAMA,EAAGC,GAAG,IACjBC,MAAM,CAAC,CAACC,GAAGC,IAAOC,MAAMF,KAAKC,EAAEE,MAAM,GAAGC,KAAKC,GAAG,CAACL,GAAGC,EAAEE,MAAM,GAAIG;QAEnE,IAAIf,eAAe,GAAG;YACpB,MAAMgB,IAAI,IAAIC,MAAM,CAACjB;YACrB,OAAOF,MACJG,GAAG,CAAC,CAACC,MAAMgB,IACV,CAAEA,CAAAA,IAAIhB,KAAKiB,OAAO,CAAC,IAAG,IAClBjB,KAAKkB,SAAS,CAAC,GAAGF,KAAKhB,KAAKkB,SAAS,CAACF,GAAGG,OAAO,CAACL,GAAG,MACpDd,MAELoB,IAAI,CAAC;QACV;QACA,OAAOxB,MAAMwB,IAAI,CAAC;IACpB,GAAG;QAAC3B;KAAU;IAEd,MAAM4B,UAAUlC,MAAMQ,OAAO,CAAC;QAC5B,OAAOT,MAAMoC,UAAU,CAAC5B,gBAAgB;YACtC6B,MAAM;YACNC,aAAa;YACbC,cAAc;QAChB;IACF,GAAG;QAAC/B;KAAe;IAEnB,MAAMgC,OAAOpC,gBAAgB;QAC3BqC,MAAMnC,WAAWmC,IAAI;QACrBC,YAAYpC,WAAWoC,UAAU;QACjCC,QAAQrC,WAAWqC,MAAM;IAC3B;IAEA,gCAAgC;IAChC,qBACE,oBAACC;QAAIC,yBAAAA;qBACH,oBAACD,2BACC,oBAAChB;QACCkB,MAAK;QACLC,SAASP;QACTQ,UAAU;QACVC,OAAM;qBAEN,oBAACC,cACE/C,eAAeG,aAAY,OAAIA,WAAW6C,UAAU,iBAEvD,oBAACC;QACCC,OAAM;QACNC,SAAQ;QACRC,MAAK;QACLC,QAAO;QACPC,aAAY;QACZC,eAAc;QACdC,gBAAe;qBAEf,oBAACC;QAAKC,GAAE;sBACR,oBAACC;QAASC,QAAO;sBACjB,oBAACjD;QAAKkD,IAAG;QAAKC,IAAG;QAAKC,IAAG;QAAKC,IAAG;yBAIvC,oBAACC,aACEjC,QAAQtB,GAAG,CAAC,CAACwD,OAAOC,sBACnB,oBAACpB;YACCqB,KAAK,AAAC,WAAQD;YACdE,OAAO;gBACLC,OAAOJ,MAAMK,EAAE,GAAG,AAAC,iBAAcL,MAAMK,EAAE,GAAC,MAAKC;gBAC/C,GAAIN,MAAMO,UAAU,KAAK,SACrB;oBAAEC,YAAY;gBAAI,IAClBR,MAAMO,UAAU,KAAK,WACrB;oBAAEE,WAAW;gBAAS,IACtBH,SAAS;YACf;WAECN,MAAMU,OAAO;AAM1B,EAAC"}

View File

@@ -0,0 +1,3 @@
export { CodeFrame } from "./CodeFrame";
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/CodeFrame/index.tsx"],"names":["CodeFrame"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAa"}

View File

@@ -0,0 +1,15 @@
import { _ as _tagged_template_literal_loose } from "@swc/helpers/_/_tagged_template_literal_loose";
function _templateObject() {
const data = _tagged_template_literal_loose([
"\n [data-nextjs-codeframe] {\n overflow: auto;\n border-radius: var(--size-gap-half);\n background-color: var(--color-ansi-bg);\n color: var(--color-ansi-fg);\n }\n [data-nextjs-codeframe]::selection,\n [data-nextjs-codeframe] *::selection {\n background-color: var(--color-ansi-selection);\n }\n [data-nextjs-codeframe] * {\n color: inherit;\n background-color: transparent;\n font-family: var(--font-stack-monospace);\n }\n\n [data-nextjs-codeframe] > * {\n margin: 0;\n padding: calc(var(--size-gap) + var(--size-gap-half))\n calc(var(--size-gap-double) + var(--size-gap-half));\n }\n [data-nextjs-codeframe] > div {\n display: inline-block;\n width: auto;\n min-width: 100%;\n border-bottom: 1px solid var(--color-ansi-bright-black);\n }\n [data-nextjs-codeframe] > div > p {\n display: flex;\n align-items: center;\n justify-content: space-between;\n cursor: pointer;\n margin: 0;\n }\n [data-nextjs-codeframe] > div > p:hover {\n text-decoration: underline dotted;\n }\n [data-nextjs-codeframe] div > p > svg {\n width: auto;\n height: 1em;\n margin-left: 8px;\n }\n [data-nextjs-codeframe] div > pre {\n overflow: hidden;\n display: inline-block;\n }\n"
]);
_templateObject = function() {
return data;
};
return data;
}
import { noop as css } from "../../helpers/noop-template";
const styles = css(_templateObject());
export { styles };
//# sourceMappingURL=styles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/CodeFrame/styles.tsx"],"names":["noop","css","styles"],"mappings":";;;;;;;;;;AAAA,SAASA,QAAQC,GAAG,QAAQ,8BAA6B;AAEzD,MAAMC,SAASD;AAiDf,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,62 @@
import * as React from "react";
import { useOnClickOutside } from "../../hooks/use-on-click-outside";
const Dialog = function Dialog(param) {
let { children, type, onClose, ...props } = param;
const [dialog, setDialog] = React.useState(null);
const [role, setRole] = React.useState(typeof document !== "undefined" && document.hasFocus() ? "dialog" : undefined);
const onDialog = React.useCallback((node)=>{
setDialog(node);
}, []);
useOnClickOutside(dialog, onClose);
// Make HTMLElements with `role=link` accessible to be triggered by the
// keyboard, i.e. [Enter].
React.useEffect(()=>{
if (dialog == null) {
return;
}
const root = dialog.getRootNode();
// Always true, but we do this for TypeScript:
if (!(root instanceof ShadowRoot)) {
return;
}
const shadowRoot = root;
function handler(e) {
const el = shadowRoot.activeElement;
if (e.key === "Enter" && el instanceof HTMLElement && el.getAttribute("role") === "link") {
e.preventDefault();
e.stopPropagation();
el.click();
}
}
function handleFocus() {
// safari will force itself as the active application when a background page triggers any sort of autofocus
// this is a workaround to only set the dialog role if the document has focus
setRole(document.hasFocus() ? "dialog" : undefined);
}
shadowRoot.addEventListener("keydown", handler);
window.addEventListener("focus", handleFocus);
window.addEventListener("blur", handleFocus);
return ()=>{
shadowRoot.removeEventListener("keydown", handler);
window.removeEventListener("focus", handleFocus);
window.removeEventListener("blur", handleFocus);
};
}, [
dialog
]);
return /*#__PURE__*/ React.createElement("div", {
ref: onDialog,
"data-nextjs-dialog": true,
tabIndex: -1,
role: role,
"aria-labelledby": props["aria-labelledby"],
"aria-describedby": props["aria-describedby"],
"aria-modal": "true"
}, /*#__PURE__*/ React.createElement("div", {
"data-nextjs-dialog-banner": true,
className: "banner-" + type
}), children);
};
export { Dialog };
//# sourceMappingURL=Dialog.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Dialog/Dialog.tsx"],"names":["React","useOnClickOutside","Dialog","children","type","onClose","props","dialog","setDialog","useState","role","setRole","document","hasFocus","undefined","onDialog","useCallback","node","useEffect","root","getRootNode","ShadowRoot","shadowRoot","handler","e","el","activeElement","key","HTMLElement","getAttribute","preventDefault","stopPropagation","click","handleFocus","addEventListener","window","removeEventListener","div","ref","data-nextjs-dialog","tabIndex","aria-labelledby","aria-describedby","aria-modal","data-nextjs-dialog-banner","className"],"mappings":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1B;KAAO;IAEX,qBACE,oBAAC8B;QACCC,KAAKvB;QACLwB,sBAAAA;QACAC,UAAU,CAAC;QACX9B,MAAMA;QACN+B,mBAAiBnC,KAAK,CAAC,kBAAkB;QACzCoC,oBAAkBpC,KAAK,CAAC,mBAAmB;QAC3CqC,cAAW;qBAEX,oBAACN;QAAIO,6BAAAA;QAA0BC,WAAW,AAAC,YAASzC;QACnDD;AAGP;AAEA,SAASD,MAAM,GAAE"}

View File

@@ -0,0 +1,11 @@
import * as React from "react";
const DialogBody = function DialogBody(param) {
let { children, className } = param;
return /*#__PURE__*/ React.createElement("div", {
"data-nextjs-dialog-body": true,
className: className
}, children);
};
export { DialogBody };
//# sourceMappingURL=DialogBody.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Dialog/DialogBody.tsx"],"names":["React","DialogBody","children","className","div","data-nextjs-dialog-body"],"mappings":"AAAA,YAAYA,WAAW,QAAO;AAO9B,MAAMC,aAAwC,SAASA,WAAW,KAGjE;IAHiE,IAAA,EAChEC,QAAQ,EACRC,SAAS,EACV,GAHiE;IAIhE,qBACE,oBAACC;QAAIC,2BAAAA;QAAwBF,WAAWA;OACrCD;AAGP;AAEA,SAASD,UAAU,GAAE"}

View File

@@ -0,0 +1,11 @@
import * as React from "react";
const DialogContent = function DialogContent(param) {
let { children, className } = param;
return /*#__PURE__*/ React.createElement("div", {
"data-nextjs-dialog-content": true,
className: className
}, children);
};
export { DialogContent };
//# sourceMappingURL=DialogContent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Dialog/DialogContent.tsx"],"names":["React","DialogContent","children","className","div","data-nextjs-dialog-content"],"mappings":"AAAA,YAAYA,WAAW,QAAO;AAO9B,MAAMC,gBAA8C,SAASA,cAAc,KAG1E;IAH0E,IAAA,EACzEC,QAAQ,EACRC,SAAS,EACV,GAH0E;IAIzE,qBACE,oBAACC;QAAIC,8BAAAA;QAA2BF,WAAWA;OACxCD;AAGP;AAEA,SAASD,aAAa,GAAE"}

View File

@@ -0,0 +1,11 @@
import * as React from "react";
const DialogHeader = function DialogHeader(param) {
let { children, className } = param;
return /*#__PURE__*/ React.createElement("div", {
"data-nextjs-dialog-header": true,
className: className
}, children);
};
export { DialogHeader };
//# sourceMappingURL=DialogHeader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Dialog/DialogHeader.tsx"],"names":["React","DialogHeader","children","className","div","data-nextjs-dialog-header"],"mappings":"AAAA,YAAYA,WAAW,QAAO;AAO9B,MAAMC,eAA4C,SAASA,aAAa,KAGvE;IAHuE,IAAA,EACtEC,QAAQ,EACRC,SAAS,EACV,GAHuE;IAItE,qBACE,oBAACC;QAAIC,6BAAAA;QAA0BF,WAAWA;OACvCD;AAGP;AAEA,SAASD,YAAY,GAAE"}

View File

@@ -0,0 +1,7 @@
export { Dialog } from "./Dialog";
export { DialogBody } from "./DialogBody";
export { DialogContent } from "./DialogContent";
export { DialogHeader } from "./DialogHeader";
export { styles } from "./styles";
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Dialog/index.ts"],"names":["Dialog","DialogBody","DialogContent","DialogHeader","styles"],"mappings":"AAAA,SAASA,MAAM,QAAQ,WAAU;AACjC,SAASC,UAAU,QAAQ,eAAc;AACzC,SAASC,aAAa,QAAQ,kBAAiB;AAC/C,SAASC,YAAY,QAAQ,iBAAgB;AAC7C,SAASC,MAAM,QAAQ,WAAU"}

View File

@@ -0,0 +1,15 @@
import { _ as _tagged_template_literal_loose } from "@swc/helpers/_/_tagged_template_literal_loose";
function _templateObject() {
const data = _tagged_template_literal_loose([
"\n [data-nextjs-dialog] {\n display: flex;\n flex-direction: column;\n width: 100%;\n margin-right: auto;\n margin-left: auto;\n outline: none;\n background: white;\n border-radius: var(--size-gap);\n box-shadow: 0 var(--size-gap-half) var(--size-gap-double)\n rgba(0, 0, 0, 0.25);\n max-height: calc(100% - 56px);\n overflow-y: hidden;\n }\n\n @media (max-height: 812px) {\n [data-nextjs-dialog-overlay] {\n max-height: calc(100% - 15px);\n }\n }\n\n @media (min-width: 576px) {\n [data-nextjs-dialog] {\n max-width: 540px;\n box-shadow: 0 var(--size-gap) var(--size-gap-quad) rgba(0, 0, 0, 0.25);\n }\n }\n\n @media (min-width: 768px) {\n [data-nextjs-dialog] {\n max-width: 720px;\n }\n }\n\n @media (min-width: 992px) {\n [data-nextjs-dialog] {\n max-width: 960px;\n }\n }\n\n [data-nextjs-dialog-banner] {\n position: relative;\n }\n [data-nextjs-dialog-banner].banner-warning {\n border-color: var(--color-ansi-yellow);\n }\n [data-nextjs-dialog-banner].banner-error {\n border-color: var(--color-ansi-red);\n }\n\n [data-nextjs-dialog-banner]::after {\n z-index: 2;\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n width: 100%;\n /* banner width: */\n border-top-width: var(--size-gap-half);\n border-bottom-width: 0;\n border-top-style: solid;\n border-bottom-style: solid;\n border-top-color: inherit;\n border-bottom-color: transparent;\n }\n\n [data-nextjs-dialog-content] {\n overflow-y: auto;\n border: none;\n margin: 0;\n /* calc(padding + banner width offset) */\n padding: calc(var(--size-gap-double) + var(--size-gap-half))\n var(--size-gap-double);\n height: 100%;\n display: flex;\n flex-direction: column;\n }\n [data-nextjs-dialog-content] > [data-nextjs-dialog-header] {\n flex-shrink: 0;\n margin-bottom: var(--size-gap-double);\n }\n [data-nextjs-dialog-content] > [data-nextjs-dialog-body] {\n position: relative;\n flex: 1 1 auto;\n }\n"
]);
_templateObject = function() {
return data;
};
return data;
}
import { noop as css } from "../../helpers/noop-template";
const styles = css(_templateObject());
export { styles };
//# sourceMappingURL=styles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Dialog/styles.ts"],"names":["noop","css","styles"],"mappings":";;;;;;;;;;AAAA,SAASA,QAAQC,GAAG,QAAQ,8BAA6B;AAEzD,MAAMC,SAASD;AAwFf,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,135 @@
import * as React from "react";
import { CloseIcon } from "../../icons/CloseIcon";
const LeftRightDialogHeader = function LeftRightDialogHeader(param) {
let { children, className, previous, next, close } = param;
const buttonLeft = React.useRef(null);
const buttonRight = React.useRef(null);
const buttonClose = React.useRef(null);
const [nav, setNav] = React.useState(null);
const onNav = React.useCallback((el)=>{
setNav(el);
}, []);
React.useEffect(()=>{
if (nav == null) {
return;
}
const root = nav.getRootNode();
const d = self.document;
function handler(e) {
if (e.key === "ArrowLeft") {
e.stopPropagation();
if (buttonLeft.current) {
buttonLeft.current.focus();
}
previous && previous();
} else if (e.key === "ArrowRight") {
e.stopPropagation();
if (buttonRight.current) {
buttonRight.current.focus();
}
next && next();
} else if (e.key === "Escape") {
e.stopPropagation();
if (root instanceof ShadowRoot) {
const a = root.activeElement;
if (a && a !== buttonClose.current && a instanceof HTMLElement) {
a.blur();
return;
}
}
if (close) {
close();
}
}
}
root.addEventListener("keydown", handler);
if (root !== d) {
d.addEventListener("keydown", handler);
}
return function() {
root.removeEventListener("keydown", handler);
if (root !== d) {
d.removeEventListener("keydown", handler);
}
};
}, [
close,
nav,
next,
previous
]);
// Unlock focus for browsers like Firefox, that break all user focus if the
// currently focused item becomes disabled.
React.useEffect(()=>{
if (nav == null) {
return;
}
const root = nav.getRootNode();
// Always true, but we do this for TypeScript:
if (root instanceof ShadowRoot) {
const a = root.activeElement;
if (previous == null) {
if (buttonLeft.current && a === buttonLeft.current) {
buttonLeft.current.blur();
}
} else if (next == null) {
if (buttonRight.current && a === buttonRight.current) {
buttonRight.current.blur();
}
}
}
}, [
nav,
next,
previous
]);
return /*#__PURE__*/ React.createElement("div", {
"data-nextjs-dialog-left-right": true,
className: className
}, /*#__PURE__*/ React.createElement("nav", {
ref: onNav
}, /*#__PURE__*/ React.createElement("button", {
ref: buttonLeft,
type: "button",
disabled: previous == null ? true : undefined,
"aria-disabled": previous == null ? true : undefined,
onClick: previous != null ? previous : undefined
}, /*#__PURE__*/ React.createElement("svg", {
viewBox: "0 0 14 14",
fill: "none",
xmlns: "http://www.w3.org/2000/svg"
}, /*#__PURE__*/ React.createElement("title", null, "previous"), /*#__PURE__*/ React.createElement("path", {
d: "M6.99996 1.16666L1.16663 6.99999L6.99996 12.8333M12.8333 6.99999H1.99996H12.8333Z",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round"
}))), /*#__PURE__*/ React.createElement("button", {
ref: buttonRight,
type: "button",
disabled: next == null ? true : undefined,
"aria-disabled": next == null ? true : undefined,
onClick: next != null ? next : undefined
}, /*#__PURE__*/ React.createElement("svg", {
viewBox: "0 0 14 14",
fill: "none",
xmlns: "http://www.w3.org/2000/svg"
}, /*#__PURE__*/ React.createElement("title", null, "next"), /*#__PURE__*/ React.createElement("path", {
d: "M6.99996 1.16666L12.8333 6.99999L6.99996 12.8333M1.16663 6.99999H12H1.16663Z",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round"
}))), "\xa0", children), close ? /*#__PURE__*/ React.createElement("button", {
"data-nextjs-errors-dialog-left-right-close-button": true,
ref: buttonClose,
type: "button",
onClick: close,
"aria-label": "Close"
}, /*#__PURE__*/ React.createElement("span", {
"aria-hidden": "true"
}, /*#__PURE__*/ React.createElement(CloseIcon, null))) : null);
};
export { LeftRightDialogHeader };
//# sourceMappingURL=LeftRightDialogHeader.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/LeftRightDialogHeader/LeftRightDialogHeader.tsx"],"names":["React","CloseIcon","LeftRightDialogHeader","children","className","previous","next","close","buttonLeft","useRef","buttonRight","buttonClose","nav","setNav","useState","onNav","useCallback","el","useEffect","root","getRootNode","d","self","document","handler","e","key","stopPropagation","current","focus","ShadowRoot","a","activeElement","HTMLElement","blur","addEventListener","removeEventListener","div","data-nextjs-dialog-left-right","ref","button","type","disabled","undefined","aria-disabled","onClick","svg","viewBox","fill","xmlns","title","path","stroke","strokeWidth","strokeLinecap","strokeLinejoin","data-nextjs-errors-dialog-left-right-close-button","aria-label","span","aria-hidden"],"mappings":"AAAA,YAAYA,WAAW,QAAO;AAC9B,SAASC,SAAS,QAAQ,wBAAuB;AAUjD,MAAMC,wBACJ,SAASA,sBAAsB,KAM9B;IAN8B,IAAA,EAC7BC,QAAQ,EACRC,SAAS,EACTC,QAAQ,EACRC,IAAI,EACJC,KAAK,EACN,GAN8B;IAO7B,MAAMC,aAAaR,MAAMS,MAAM,CAA2B;IAC1D,MAAMC,cAAcV,MAAMS,MAAM,CAA2B;IAC3D,MAAME,cAAcX,MAAMS,MAAM,CAA2B;IAE3D,MAAM,CAACG,KAAKC,OAAO,GAAGb,MAAMc,QAAQ,CAAqB;IACzD,MAAMC,QAAQf,MAAMgB,WAAW,CAAC,CAACC;QAC/BJ,OAAOI;IACT,GAAG,EAAE;IAELjB,MAAMkB,SAAS,CAAC;QACd,IAAIN,OAAO,MAAM;YACf;QACF;QAEA,MAAMO,OAAOP,IAAIQ,WAAW;QAC5B,MAAMC,IAAIC,KAAKC,QAAQ;QAEvB,SAASC,QAAQC,CAAgB;YAC/B,IAAIA,EAAEC,GAAG,KAAK,aAAa;gBACzBD,EAAEE,eAAe;gBACjB,IAAInB,WAAWoB,OAAO,EAAE;oBACtBpB,WAAWoB,OAAO,CAACC,KAAK;gBAC1B;gBACAxB,YAAYA;YACd,OAAO,IAAIoB,EAAEC,GAAG,KAAK,cAAc;gBACjCD,EAAEE,eAAe;gBACjB,IAAIjB,YAAYkB,OAAO,EAAE;oBACvBlB,YAAYkB,OAAO,CAACC,KAAK;gBAC3B;gBACAvB,QAAQA;YACV,OAAO,IAAImB,EAAEC,GAAG,KAAK,UAAU;gBAC7BD,EAAEE,eAAe;gBACjB,IAAIR,gBAAgBW,YAAY;oBAC9B,MAAMC,IAA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QACRC,MAAK;QACLC,OAAM;qBAEN,oBAACC,eAAM,2BACP,oBAACC;QACC9B,GAAE;QACF+B,QAAO;QACPC,aAAY;QACZC,eAAc;QACdC,gBAAe;wBAIrB,oBAACf;QACCD,KAAK7B;QACL+B,MAAK;QACLC,UAAUpC,QAAQ,OAAO,OAAOqC;QAChCC,iBAAetC,QAAQ,OAAO,OAAOqC;QACrCE,SAASvC,eAAAA,OAAQqC;qBAEjB,oBAACG;QACCC,SAAQ;QACRC,MAAK;QACLC,OAAM;qBAEN,oBAACC,eAAM,uBACP,oBAACC;QACC9B,GAAE;QACF+B,QAAO;QACPC,aAAY;QACZC,eAAc;QACdC,gBAAe;UAGZ,QAERpD,WAEFI,sBACC,oBAACiC;QACCgB,qDAAAA;QACAjB,KAAK5B;QACL8B,MAAK;QACLI,SAAStC;QACTkD,cAAW;qBAEX,oBAACC;QAAKC,eAAY;qBAChB,oBAAC1D,qBAGH;AAGV;AAEF,SAASC,qBAAqB,GAAE"}

View File

@@ -0,0 +1,4 @@
export { LeftRightDialogHeader } from "./LeftRightDialogHeader";
export { styles } from "./styles";
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/LeftRightDialogHeader/index.ts"],"names":["LeftRightDialogHeader","styles"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,0BAAyB;AAC/D,SAASC,MAAM,QAAQ,WAAU"}

View File

@@ -0,0 +1,15 @@
import { _ as _tagged_template_literal_loose } from "@swc/helpers/_/_tagged_template_literal_loose";
function _templateObject() {
const data = _tagged_template_literal_loose([
"\n [data-nextjs-dialog-left-right] {\n display: flex;\n flex-direction: row;\n align-content: center;\n align-items: center;\n justify-content: space-between;\n }\n [data-nextjs-dialog-left-right] > nav {\n flex: 1;\n display: flex;\n align-items: center;\n margin-right: var(--size-gap);\n }\n [data-nextjs-dialog-left-right] > nav > button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n\n width: calc(var(--size-gap-double) + var(--size-gap));\n height: calc(var(--size-gap-double) + var(--size-gap));\n font-size: 0;\n border: none;\n background-color: rgba(255, 85, 85, 0.1);\n color: var(--color-ansi-red);\n cursor: pointer;\n transition: background-color 0.25s ease;\n }\n [data-nextjs-dialog-left-right] > nav > button > svg {\n width: auto;\n height: calc(var(--size-gap) + var(--size-gap-half));\n }\n [data-nextjs-dialog-left-right] > nav > button:hover {\n background-color: rgba(255, 85, 85, 0.2);\n }\n [data-nextjs-dialog-left-right] > nav > button:disabled {\n background-color: rgba(255, 85, 85, 0.1);\n color: rgba(255, 85, 85, 0.4);\n cursor: not-allowed;\n }\n\n [data-nextjs-dialog-left-right] > nav > button:first-of-type {\n border-radius: var(--size-gap-half) 0 0 var(--size-gap-half);\n margin-right: 1px;\n }\n [data-nextjs-dialog-left-right] > nav > button:last-of-type {\n border-radius: 0 var(--size-gap-half) var(--size-gap-half) 0;\n }\n\n [data-nextjs-dialog-left-right] > button:last-of-type {\n border: 0;\n padding: 0;\n\n background-color: transparent;\n appearance: none;\n\n opacity: 0.4;\n transition: opacity 0.25s ease;\n }\n [data-nextjs-dialog-left-right] > button:last-of-type:hover {\n opacity: 0.7;\n }\n"
]);
_templateObject = function() {
return data;
};
return data;
}
import { noop as css } from "../../helpers/noop-template";
const styles = css(_templateObject());
export { styles };
//# sourceMappingURL=styles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/LeftRightDialogHeader/styles.ts"],"names":["noop","css","styles"],"mappings":";;;;;;;;;;AAAA,SAASA,QAAQC,GAAG,QAAQ,8BAA6B;AAEzD,MAAMC,SAASD;AAgEf,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,41 @@
// @ts-ignore
import allyTrap from "./maintain--tab-focus";
import * as React from "react";
import { lock, unlock } from "./body-locker";
const Overlay = function Overlay(param) {
let { className, children, fixed } = param;
React.useEffect(()=>{
lock();
return ()=>{
unlock();
};
}, []);
const [overlay, setOverlay] = React.useState(null);
const onOverlay = React.useCallback((el)=>{
setOverlay(el);
}, []);
React.useEffect(()=>{
if (overlay == null) {
return;
}
const handle2 = allyTrap({
context: overlay
});
return ()=>{
handle2.disengage();
};
}, [
overlay
]);
return /*#__PURE__*/ React.createElement("div", {
"data-nextjs-dialog-overlay": true,
className: className,
ref: onOverlay
}, /*#__PURE__*/ React.createElement("div", {
"data-nextjs-dialog-backdrop": true,
"data-nextjs-dialog-backdrop-fixed": fixed ? true : undefined
}), children);
};
export { Overlay };
//# sourceMappingURL=Overlay.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Overlay/Overlay.tsx"],"names":["allyTrap","React","lock","unlock","Overlay","className","children","fixed","useEffect","overlay","setOverlay","useState","onOverlay","useCallback","el","handle2","context","disengage","div","data-nextjs-dialog-overlay","ref","data-nextjs-dialog-backdrop","data-nextjs-dialog-backdrop-fixed","undefined"],"mappings":"AAAA,aAAa;AACb,OAAOA,cAAc,wBAAuB;AAC5C,YAAYC,WAAW,QAAO;AAC9B,SAASC,IAAI,EAAEC,MAAM,QAAQ,gBAAe;AAQ5C,MAAMC,UAAkC,SAASA,QAAQ,KAIxD;IAJwD,IAAA,EACvDC,SAAS,EACTC,QAAQ,EACRC,KAAK,EACN,GAJwD;IAKvDN,MAAMO,SAAS,CAAC;QACdN;QACA,OAAO;YACLC;QACF;IACF,GAAG,EAAE;IAEL,MAAM,CAACM,SAASC,WAAW,GAAGT,MAAMU,QAAQ,CAAwB;IACpE,MAAMC,YAAYX,MAAMY,WAAW,CAAC,CAACC;QACnCJ,WAAWI;IACb,GAAG,EAAE;IAELb,MAAMO,SAAS,CAAC;QACd,IAAIC,WAAW,MAAM;YACnB;QACF;QAEA,MAAMM,UAAUf,SAAS;YAAEgB,SAASP;QAAQ;QAC5C,OAAO;YACLM,QAAQE,SAAS;QACnB;IACF,GAAG;QAACR;KAAQ;IAEZ,qBACE,oBAACS;QAAIC,8BAAAA;QAA2Bd,WAAWA;QAAWe,KAAKR;qBACzD,oBAACM;QACCG,+BAAAA;QACAC,qCAAmCf,QAAQ,OAAOgB;QAEnDjB;AAGP;AAEA,SAASF,OAAO,GAAE"}

View File

@@ -0,0 +1,34 @@
let previousBodyPaddingRight;
let previousBodyOverflowSetting;
let activeLocks = 0;
export function lock() {
setTimeout(()=>{
if (activeLocks++ > 0) {
return;
}
const scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
if (scrollBarGap > 0) {
previousBodyPaddingRight = document.body.style.paddingRight;
document.body.style.paddingRight = "" + scrollBarGap + "px";
}
previousBodyOverflowSetting = document.body.style.overflow;
document.body.style.overflow = "hidden";
});
}
export function unlock() {
setTimeout(()=>{
if (activeLocks === 0 || --activeLocks !== 0) {
return;
}
if (previousBodyPaddingRight !== undefined) {
document.body.style.paddingRight = previousBodyPaddingRight;
previousBodyPaddingRight = undefined;
}
if (previousBodyOverflowSetting !== undefined) {
document.body.style.overflow = previousBodyOverflowSetting;
previousBodyOverflowSetting = undefined;
}
});
}
//# sourceMappingURL=body-locker.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Overlay/body-locker.ts"],"names":["previousBodyPaddingRight","previousBodyOverflowSetting","activeLocks","lock","setTimeout","scrollBarGap","window","innerWidth","document","documentElement","clientWidth","body","style","paddingRight","overflow","unlock","undefined"],"mappings":"AAAA,IAAIA;AACJ,IAAIC;AAEJ,IAAIC,cAAc;AAElB,OAAO,SAASC;IACdC,WAAW;QACT,IAAIF,gBAAgB,GAAG;YACrB;QACF;QAEA,MAAMG,eACJC,OAAOC,UAAU,GAAGC,SAASC,eAAe,CAACC,WAAW;QAE1D,IAAIL,eAAe,GAAG;YACpBL,2BAA2BQ,SAASG,IAAI,CAACC,KAAK,CAACC,YAAY;YAC3DL,SAASG,IAAI,CAACC,KAAK,CAACC,YAAY,GAAG,AAAC,KAAER,eAAa;QACrD;QAEAJ,8BAA8BO,SAASG,IAAI,CAACC,KAAK,CAACE,QAAQ;QAC1DN,SAASG,IAAI,CAACC,KAAK,CAACE,QAAQ,GAAG;IACjC;AACF;AAEA,OAAO,SAASC;IACdX,WAAW;QACT,IAAIF,gBAAgB,KAAK,EAAEA,gBAAgB,GAAG;YAC5C;QACF;QAEA,IAAIF,6BAA6BgB,WAAW;YAC1CR,SAASG,IAAI,CAACC,KAAK,CAACC,YAAY,GAAGb;YACnCA,2BAA2BgB;QAC7B;QAEA,IAAIf,gCAAgCe,WAAW;YAC7CR,SAASG,IAAI,CAACC,KAAK,CAACE,QAAQ,GAAGb;YAC/BA,8BAA8Be;QAChC;IACF;AACF"}

View File

@@ -0,0 +1,3 @@
export { Overlay } from "./Overlay";
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Overlay/index.tsx"],"names":["Overlay"],"mappings":"AAAA,SAASA,OAAO,QAAQ,YAAW"}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
import { _ as _tagged_template_literal_loose } from "@swc/helpers/_/_tagged_template_literal_loose";
function _templateObject() {
const data = _tagged_template_literal_loose([
"\n [data-nextjs-dialog-overlay] {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n overflow: auto;\n z-index: 9000;\n\n display: flex;\n align-content: center;\n align-items: center;\n flex-direction: column;\n padding: 10vh 15px 0;\n }\n\n @media (max-height: 812px) {\n [data-nextjs-dialog-overlay] {\n padding: 15px 15px 0;\n }\n }\n\n [data-nextjs-dialog-backdrop] {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(17, 17, 17, 0.2);\n pointer-events: all;\n z-index: -1;\n }\n\n [data-nextjs-dialog-backdrop-fixed] {\n cursor: not-allowed;\n -webkit-backdrop-filter: blur(8px);\n backdrop-filter: blur(8px);\n }\n"
]);
_templateObject = function() {
return data;
};
return data;
}
import { noop as css } from "../../helpers/noop-template";
const styles = css(_templateObject());
export { styles };
//# sourceMappingURL=styles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Overlay/styles.tsx"],"names":["noop","css","styles"],"mappings":";;;;;;;;;;AAAA,SAASA,QAAQC,GAAG,QAAQ,8BAA6B;AAEzD,MAAMC,SAASD;AAyCf,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,25 @@
import * as React from "react";
import { createPortal } from "react-dom";
export function ShadowPortal(param) {
let { children } = param;
let portalNode = React.useRef(null);
let shadowNode = React.useRef(null);
let [, forceUpdate] = React.useState();
React.useLayoutEffect(()=>{
const ownerDocument = document;
portalNode.current = ownerDocument.createElement("nextjs-portal");
shadowNode.current = portalNode.current.attachShadow({
mode: "open"
});
ownerDocument.body.appendChild(portalNode.current);
forceUpdate({});
return ()=>{
if (portalNode.current && portalNode.current.ownerDocument) {
portalNode.current.ownerDocument.body.removeChild(portalNode.current);
}
};
}, []);
return shadowNode.current ? /*#__PURE__*/ createPortal(children, shadowNode.current) : null;
}
//# sourceMappingURL=ShadowPortal.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../src/client/components/react-dev-overlay/internal/components/ShadowPortal.tsx"],"names":["React","createPortal","ShadowPortal","children","portalNode","useRef","shadowNode","forceUpdate","useState","useLayoutEffect","ownerDocument","document","current","createElement","attachShadow","mode","body","appendChild","removeChild"],"mappings":"AAAA,YAAYA,WAAW,QAAO;AAC9B,SAASC,YAAY,QAAQ,YAAW;AAExC,OAAO,SAASC,aAAa,KAA2C;IAA3C,IAAA,EAAEC,QAAQ,EAAiC,GAA3C;IAC3B,IAAIC,aAAaJ,MAAMK,MAAM,CAAqB;IAClD,IAAIC,aAAaN,MAAMK,MAAM,CAAoB;IACjD,IAAI,GAAGE,YAAY,GAAGP,MAAMQ,QAAQ;IAEpCR,MAAMS,eAAe,CAAC;QACpB,MAAMC,gBAAgBC;QACtBP,WAAWQ,OAAO,GAAGF,cAAcG,aAAa,CAAC;QACjDP,WAAWM,OAAO,GAAGR,WAAWQ,OAAO,CAACE,YAAY,CAAC;YAAEC,MAAM;QAAO;QACpEL,cAAcM,IAAI,CAACC,WAAW,CAACb,WAAWQ,OAAO;QACjDL,YAAY,CAAC;QACb,OAAO;YACL,IAAIH,WAAWQ,OAAO,IAAIR,WAAWQ,OAAO,CAACF,aAAa,EAAE;gBAC1DN,WAAWQ,OAAO,CAACF,aAAa,CAACM,IAAI,CAACE,WAAW,CAACd,WAAWQ,OAAO;YACtE;QACF;IACF,GAAG,EAAE;IAEL,OAAON,WAAWM,OAAO,iBACrBX,aAAaE,UAAUG,WAAWM,OAAO,IACzC;AACN"}

View File

@@ -0,0 +1,39 @@
import React from "react";
import { useOpenInEditor } from "../../helpers/use-open-in-editor";
export function EditorLink(param) {
let { file, isSourceFile, location } = param;
var _location_line, _location_column;
const open = useOpenInEditor({
file,
lineNumber: (_location_line = location == null ? void 0 : location.line) != null ? _location_line : 1,
column: (_location_column = location == null ? void 0 : location.column) != null ? _location_column : 0
});
return /*#__PURE__*/ React.createElement("div", {
"data-with-open-in-editor-link": true,
"data-with-open-in-editor-link-source-file": isSourceFile ? true : undefined,
"data-with-open-in-editor-link-import-trace": isSourceFile ? undefined : true,
tabIndex: 10,
role: "link",
onClick: open,
title: "Click to open in your editor"
}, file, location ? " (" + location.line + ":" + location.column + ")" : null, /*#__PURE__*/ React.createElement("svg", {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round"
}, /*#__PURE__*/ React.createElement("path", {
d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
}), /*#__PURE__*/ React.createElement("polyline", {
points: "15 3 21 3 21 9"
}), /*#__PURE__*/ React.createElement("line", {
x1: "10",
y1: "14",
x2: "21",
y2: "3"
})));
}
//# sourceMappingURL=EditorLink.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Terminal/EditorLink.tsx"],"names":["React","useOpenInEditor","EditorLink","file","isSourceFile","location","open","lineNumber","line","column","div","data-with-open-in-editor-link","data-with-open-in-editor-link-source-file","undefined","data-with-open-in-editor-link-import-trace","tabIndex","role","onClick","title","svg","xmlns","viewBox","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","path","d","polyline","points","x1","y1","x2","y2"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AACzB,SAASC,eAAe,QAAQ,mCAAkC;AAUlE,OAAO,SAASC,WAAW,KAAiD;IAAjD,IAAA,EAAEC,IAAI,EAAEC,YAAY,EAAEC,QAAQ,EAAmB,GAAjD;QAGXA,gBACJA;IAHV,MAAMC,OAAOL,gBAAgB;QAC3BE;QACAI,YAAYF,CAAAA,iBAAAA,4BAAAA,SAAUG,IAAI,YAAdH,iBAAkB;QAC9BI,QAAQJ,CAAAA,mBAAAA,4BAAAA,SAAUI,MAAM,YAAhBJ,mBAAoB;IAC9B;IAEA,qBACE,oBAACK;QACCC,iCAAAA;QACAC,6CACER,eAAe,OAAOS;QAExBC,8CACEV,eAAeS,YAAY;QAE7BE,UAAU;QACVC,MAAM;QACNC,SAASX;QACTY,OAAO;OAENf,MACAE,WAAW,AAAC,OAAIA,SAASG,IAAI,GAAC,MAAGH,SAASI,MAAM,GAAC,MAAK,oBACvD,oBAACU;QACCC,OAAM;QACNC,SAAQ;QACRC,MAAK;QACLC,QAAO;QACPC,aAAY;QACZC,eAAc;QACdC,gBAAe;qBAEf,oBAACC;QAAKC,GAAE;sBACR,oBAACC;QAASC,QAAO;sBACjB,oBAACtB;QAAKuB,IAAG;QAAKC,IAAG;QAAKC,IAAG;QAAKC,IAAG;;AAIzC"}

View File

@@ -0,0 +1,82 @@
import Anser from "next/dist/compiled/anser";
import * as React from "react";
import { HotlinkedText } from "../hot-linked-text";
import { EditorLink } from "./EditorLink";
function getFile(lines) {
const contentFileName = lines.shift();
if (!contentFileName) return null;
const [fileName, line, column] = contentFileName.split(":");
const parsedLine = Number(line);
const parsedColumn = Number(column);
const hasLocation = !Number.isNaN(parsedLine) && !Number.isNaN(parsedColumn);
return {
fileName: hasLocation ? fileName : contentFileName,
location: hasLocation ? {
line: parsedLine,
column: parsedColumn
} : undefined
};
}
function getImportTraceFiles(lines) {
if (lines.some((line)=>/ReactServerComponentsError:/.test(line)) || lines.some((line)=>/Import trace for requested module:/.test(line))) {
// Grab the lines at the end containing the files
const files = [];
while(/.+\..+/.test(lines[lines.length - 1]) && !lines[lines.length - 1].includes(":")){
const file = lines.pop().trim();
files.unshift(file);
}
return files;
}
return [];
}
function getEditorLinks(content) {
const lines = content.split("\n");
const file = getFile(lines);
const importTraceFiles = getImportTraceFiles(lines);
return {
file,
source: lines.join("\n"),
importTraceFiles
};
}
export const Terminal = function Terminal(param) {
let { content } = param;
const { file, source, importTraceFiles } = React.useMemo(()=>getEditorLinks(content), [
content
]);
const decoded = React.useMemo(()=>{
return Anser.ansiToJson(source, {
json: true,
use_classes: true,
remove_empty: true
});
}, [
source
]);
return /*#__PURE__*/ React.createElement("div", {
"data-nextjs-terminal": true
}, file && /*#__PURE__*/ React.createElement(EditorLink, {
isSourceFile: true,
key: file.fileName,
file: file.fileName,
location: file.location
}), /*#__PURE__*/ React.createElement("pre", null, decoded.map((entry, index)=>/*#__PURE__*/ React.createElement("span", {
key: "terminal-entry-" + index,
style: {
color: entry.fg ? "var(--color-" + entry.fg + ")" : undefined,
...entry.decoration === "bold" ? {
fontWeight: 800
} : entry.decoration === "italic" ? {
fontStyle: "italic"
} : undefined
}
}, /*#__PURE__*/ React.createElement(HotlinkedText, {
text: entry.content
}))), importTraceFiles.map((importTraceFile)=>/*#__PURE__*/ React.createElement(EditorLink, {
isSourceFile: false,
key: importTraceFile,
file: importTraceFile
}))));
};
//# sourceMappingURL=Terminal.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Terminal/Terminal.tsx"],"names":["Anser","React","HotlinkedText","EditorLink","getFile","lines","contentFileName","shift","fileName","line","column","split","parsedLine","Number","parsedColumn","hasLocation","isNaN","location","undefined","getImportTraceFiles","some","test","files","length","includes","file","pop","trim","unshift","getEditorLinks","content","importTraceFiles","source","join","Terminal","useMemo","decoded","ansiToJson","json","use_classes","remove_empty","div","data-nextjs-terminal","isSourceFile","key","pre","map","entry","index","span","style","color","fg","decoration","fontWeight","fontStyle","text","importTraceFile"],"mappings":"AAAA,OAAOA,WAAW,2BAA0B;AAC5C,YAAYC,WAAW,QAAO;AAC9B,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,UAAU,QAAQ,eAAc;AAIzC,SAASC,QAAQC,KAAe;IAC9B,MAAMC,kBAAkBD,MAAME,KAAK;IACnC,IAAI,CAACD,iBAAiB,OAAO;IAC7B,MAAM,CAACE,UAAUC,MAAMC,OAAO,GAAGJ,gBAAgBK,KAAK,CAAC;IAEvD,MAAMC,aAAaC,OAAOJ;IAC1B,MAAMK,eAAeD,OAAOH;IAC5B,MAAMK,cAAc,CAACF,OAAOG,KAAK,CAACJ,eAAe,CAACC,OAAOG,KAAK,CAACF;IAE/D,OAAO;QACLN,UAAUO,cAAcP,WAAWF;QACnCW,UAAUF,cACN;YACEN,MAAMG;YACNF,QAAQI;QACV,IACAI;IACN;AACF;AAEA,SAASC,oBAAoBd,KAAe;IAC1C,IACEA,MAAMe,IAAI,CAAC,CAACX,OAAS,8BAA8BY,IAAI,CAACZ,UACxDJ,MAAMe,IAAI,CAAC,CAACX,OAAS,qCAAqCY,IAAI,CAACZ,QAC/D;QACA,iDAAiD;QACjD,MAAMa,QAAQ,EAAE;QAChB,MACE,SAASD,IAAI,CAAChB,KAAK,CAACA,MAAMkB,MAAM,GAAG,EAAE,KACrC,CAAClB,KAAK,CAACA,MAAMkB,MAAM,GAAG,EAAE,CAACC,QAAQ,CAAC,KAClC;YACA,MAA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AAiBe,GAAG,CAAC,CAACW,gCACrB,oBAACtD;YACCwC,cAAc;YACdC,KAAKa;YACLhC,MAAMgC;;AAMlB,EAAC"}

View File

@@ -0,0 +1,3 @@
export { Terminal } from "./Terminal";
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Terminal/index.tsx"],"names":["Terminal"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,aAAY"}

View File

@@ -0,0 +1,15 @@
import { _ as _tagged_template_literal_loose } from "@swc/helpers/_/_tagged_template_literal_loose";
function _templateObject() {
const data = _tagged_template_literal_loose([
"\n [data-nextjs-terminal] {\n border-radius: var(--size-gap-half);\n background-color: var(--color-ansi-bg);\n color: var(--color-ansi-fg);\n }\n [data-nextjs-terminal]::selection,\n [data-nextjs-terminal] *::selection {\n background-color: var(--color-ansi-selection);\n }\n [data-nextjs-terminal] * {\n color: inherit;\n background-color: transparent;\n font-family: var(--font-stack-monospace);\n }\n [data-nextjs-terminal] > * {\n margin: 0;\n padding: calc(var(--size-gap) + var(--size-gap-half))\n calc(var(--size-gap-double) + var(--size-gap-half));\n }\n\n [data-nextjs-terminal] pre {\n white-space: pre-wrap;\n word-break: break-word;\n }\n\n [data-with-open-in-editor-link] svg {\n width: auto;\n height: var(--size-font-small);\n margin-left: var(--size-gap);\n }\n [data-with-open-in-editor-link] {\n cursor: pointer;\n }\n [data-with-open-in-editor-link]:hover {\n text-decoration: underline dotted;\n }\n [data-with-open-in-editor-link-source-file] {\n border-bottom: 1px solid var(--color-ansi-bright-black);\n display: flex;\n align-items: center;\n justify-content: space-between;\n }\n [data-with-open-in-editor-link-import-trace] {\n margin-left: var(--size-gap-double);\n }\n [data-nextjs-terminal] a {\n color: inherit;\n }\n"
]);
_templateObject = function() {
return data;
};
return data;
}
import { noop as css } from "../../helpers/noop-template";
const styles = css(_templateObject());
export { styles };
//# sourceMappingURL=styles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Terminal/styles.tsx"],"names":["noop","css","styles"],"mappings":";;;;;;;;;;AAAA,SAASA,QAAQC,GAAG,QAAQ,8BAA6B;AAEzD,MAAMC,SAASD;AAmDf,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,13 @@
import * as React from "react";
export const Toast = function Toast(param) {
let { onClick, children, className } = param;
return /*#__PURE__*/ React.createElement("div", {
"data-nextjs-toast": true,
onClick: onClick,
className: className
}, /*#__PURE__*/ React.createElement("div", {
"data-nextjs-toast-wrapper": true
}, children));
};
//# sourceMappingURL=Toast.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../src/client/components/react-dev-overlay/internal/components/Toast/Toast.tsx"],"names":["React","Toast","onClick","children","className","div","data-nextjs-toast","data-nextjs-toast-wrapper"],"mappings":"AAAA,YAAYA,WAAW,QAAO;AAQ9B,OAAO,MAAMC,QAA8B,SAASA,MAAM,KAIzD;IAJyD,IAAA,EACxDC,OAAO,EACPC,QAAQ,EACRC,SAAS,EACV,GAJyD;IAKxD,qBACE,oBAACC;QAAIC,qBAAAA;QAAkBJ,SAASA;QAASE,WAAWA;qBAClD,oBAACC;QAAIE,6BAAAA;OAA2BJ;AAGtC,EAAC"}

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