create project

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

View File

@@ -0,0 +1,13 @@
import { addPathPrefix } from '../shared/lib/router/utils/add-path-prefix';
import { normalizePathTrailingSlash } from './normalize-trailing-slash';
const basePath = process.env.__NEXT_ROUTER_BASEPATH || '';
export function addBasePath(path, required) {
if (process.env.__NEXT_MANUAL_CLIENT_BASE_PATH) {
if (!required) {
return path;
}
}
return normalizePathTrailingSlash(addPathPrefix(path, basePath));
}
//# sourceMappingURL=add-base-path.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../client/add-base-path.ts"],"names":["addPathPrefix","normalizePathTrailingSlash","basePath","process","env","__NEXT_ROUTER_BASEPATH","addBasePath","path","required","__NEXT_MANUAL_CLIENT_BASE_PATH"],"mappings":"AAAA,SAASA,aAAa,QAAQ,4CAA4C,CAAA;AAC1E,SAASC,0BAA0B,QAAQ,4BAA4B,CAAA;AAEvE,MAAMC,QAAQ,GAAG,AAACC,OAAO,CAACC,GAAG,CAACC,sBAAsB,IAAe,EAAE;AAErE,OAAO,SAASC,WAAW,CAACC,IAAY,EAAEC,QAAkB,EAAU;IACpE,IAAIL,OAAO,CAACC,GAAG,CAACK,8BAA8B,EAAE;QAC9C,IAAI,CAACD,QAAQ,EAAE;YACb,OAAOD,IAAI,CAAA;SACZ;KACF;IAED,OAAON,0BAA0B,CAACD,aAAa,CAACO,IAAI,EAAEL,QAAQ,CAAC,CAAC,CAAA;CACjE"}

View File

@@ -0,0 +1,9 @@
import { normalizePathTrailingSlash } from './normalize-trailing-slash';
export const addLocale = (path, ...args)=>{
if (process.env.__NEXT_I18N_SUPPORT) {
return normalizePathTrailingSlash(require('../shared/lib/router/utils/add-locale').addLocale(path, ...args));
}
return path;
};
//# sourceMappingURL=add-locale.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../client/add-locale.ts"],"names":["normalizePathTrailingSlash","addLocale","path","args","process","env","__NEXT_I18N_SUPPORT","require"],"mappings":"AACA,SAASA,0BAA0B,QAAQ,4BAA4B,CAAA;AAEvE,OAAO,MAAMC,SAAS,GAAc,CAACC,IAAI,EAAKC,GAAAA,IAAI,GAAK;IACrD,IAAIC,OAAO,CAACC,GAAG,CAACC,mBAAmB,EAAE;QACnC,OAAON,0BAA0B,CAC/BO,OAAO,CAAC,uCAAuC,CAAC,CAACN,SAAS,CAACC,IAAI,KAAKC,IAAI,CAAC,CAC1E,CAAA;KACF;IACD,OAAOD,IAAI,CAAA;CACZ,CAAA"}

View File

@@ -0,0 +1,51 @@
/**
* Before starting the Next.js runtime and requiring any module, we need to make
* sure the following scripts are executed in the correct order:
* - Polyfills
* - next/script with `beforeInteractive` strategy
*/ const version = "13.1.1";
window.next = {
version,
appDir: true
};
function loadScriptsInSequence(scripts, hydrate) {
if (!scripts || !scripts.length) {
return hydrate();
}
return scripts.reduce((promise, [src, props])=>{
return promise.then(()=>{
return new Promise((resolve, reject)=>{
const el = document.createElement('script');
if (props) {
for(const key in props){
if (key !== 'children') {
el.setAttribute(key, props[key]);
}
}
}
if (src) {
el.src = src;
el.onload = resolve;
el.onerror = reject;
} else if (props) {
el.innerHTML = props.children;
setTimeout(resolve);
}
document.head.appendChild(el);
});
});
}, Promise.resolve()).then(()=>{
hydrate();
}).catch((err)=>{
console.error(err);
// Still try to hydrate even if there's an error.
hydrate();
});
}
export function appBootstrap(callback) {
loadScriptsInSequence(self.__next_s, ()=>{
callback();
});
}
//# sourceMappingURL=app-bootstrap.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../client/app-bootstrap.js"],"names":["version","process","env","__NEXT_VERSION","window","next","appDir","loadScriptsInSequence","scripts","hydrate","length","reduce","promise","src","props","then","Promise","resolve","reject","el","document","createElement","key","setAttribute","onload","onerror","innerHTML","children","setTimeout","head","appendChild","catch","err","console","error","appBootstrap","callback","self","__next_s"],"mappings":"AAAA;;;;;GAKG,CAEH,MAAMA,OAAO,GAA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,OAAO,CAACC,KAAK,CAACF,GAAG,CAAC;QAClB,iDAAiD;QACjDvB,OAAO,EAAE;KACV,CAAC,CAAA;CACL;AAED,OAAO,SAAS0B,YAAY,CAACC,QAAQ,EAAE;IACrC7B,qBAAqB,CAAC8B,IAAI,CAACC,QAAQ,EAAE,IAAM;QACzCF,QAAQ,EAAE;KACX,CAAC;CACH"}

View File

@@ -0,0 +1,189 @@
/* global location */ import '../build/polyfills/polyfill-module';
// @ts-ignore react-dom/client exists when using React 18
import ReactDOMClient from 'react-dom/client';
import React, { use } from 'react';
import { createFromReadableStream } from 'next/dist/compiled/react-server-dom-webpack/client';
import { HeadManagerContext } from '../shared/lib/head-manager-context';
import { GlobalLayoutRouterContext } from '../shared/lib/app-router-context';
import onRecoverableError from './on-recoverable-error';
// eslint-disable-next-line no-undef
const getChunkScriptFilename = __webpack_require__.u;
const chunkFilenameMap = {};
// eslint-disable-next-line no-undef
__webpack_require__.u = (chunkId)=>{
return chunkFilenameMap[chunkId] || getChunkScriptFilename(chunkId);
};
// Ignore the module ID transform in client.
// eslint-disable-next-line no-undef
// @ts-expect-error TODO: fix type
self.__next_require__ = process.env.NODE_ENV !== 'production' ? (id)=>{
const mod = __webpack_require__(id);
if (typeof mod === 'object') {
// Return a proxy to flight client to make sure it's always getting
// the latest module, instead of being cached.
return new Proxy(mod, {
get (_target, prop) {
return __webpack_require__(id)[prop];
}
});
}
return mod;
} : __webpack_require__;
self.__next_chunk_load__ = (chunk)=>{
if (!chunk) return Promise.resolve();
const [chunkId, chunkFileName] = chunk.split(':');
chunkFilenameMap[chunkId] = `static/chunks/${chunkFileName}.js`;
// @ts-ignore
// eslint-disable-next-line no-undef
return __webpack_chunk_load__(chunkId);
};
const appElement = document;
const getCacheKey = ()=>{
const { pathname , search } = location;
return pathname + search;
};
const encoder = new TextEncoder();
let initialServerDataBuffer = undefined;
let initialServerDataWriter = undefined;
let initialServerDataLoaded = false;
let initialServerDataFlushed = false;
function nextServerDataCallback(seg) {
if (seg[0] === 0) {
initialServerDataBuffer = [];
} else {
if (!initialServerDataBuffer) throw new Error('Unexpected server data: missing bootstrap script.');
if (initialServerDataWriter) {
initialServerDataWriter.enqueue(encoder.encode(seg[1]));
} else {
initialServerDataBuffer.push(seg[1]);
}
}
}
// There might be race conditions between `nextServerDataRegisterWriter` and
// `DOMContentLoaded`. The former will be called when React starts to hydrate
// the root, the latter will be called when the DOM is fully loaded.
// For streaming, the former is called first due to partial hydration.
// For non-streaming, the latter can be called first.
// Hence, we use two variables `initialServerDataLoaded` and
// `initialServerDataFlushed` to make sure the writer will be closed and
// `initialServerDataBuffer` will be cleared in the right time.
function nextServerDataRegisterWriter(ctr) {
if (initialServerDataBuffer) {
initialServerDataBuffer.forEach((val)=>{
ctr.enqueue(encoder.encode(val));
});
if (initialServerDataLoaded && !initialServerDataFlushed) {
ctr.close();
initialServerDataFlushed = true;
initialServerDataBuffer = undefined;
}
}
initialServerDataWriter = ctr;
}
// When `DOMContentLoaded`, we can close all pending writers to finish hydration.
const DOMContentLoaded = function() {
if (initialServerDataWriter && !initialServerDataFlushed) {
initialServerDataWriter.close();
initialServerDataFlushed = true;
initialServerDataBuffer = undefined;
}
initialServerDataLoaded = true;
};
// It's possible that the DOM is already loaded.
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', DOMContentLoaded, false);
} else {
DOMContentLoaded();
}
const nextServerDataLoadingGlobal = self.__next_f = self.__next_f || [];
nextServerDataLoadingGlobal.forEach(nextServerDataCallback);
nextServerDataLoadingGlobal.push = nextServerDataCallback;
function createResponseCache() {
return new Map();
}
const rscCache = createResponseCache();
function useInitialServerResponse(cacheKey) {
const response = rscCache.get(cacheKey);
if (response) return response;
const readable = new ReadableStream({
start (controller) {
nextServerDataRegisterWriter(controller);
}
});
const newResponse = createFromReadableStream(readable);
rscCache.set(cacheKey, newResponse);
return newResponse;
}
function ServerRoot({ cacheKey }) {
React.useEffect(()=>{
rscCache.delete(cacheKey);
});
const response = useInitialServerResponse(cacheKey);
const root = use(response);
return root;
}
const StrictModeIfEnabled = process.env.__NEXT_STRICT_MODE_APP ? React.StrictMode : React.Fragment;
function Root({ children }) {
React.useEffect(()=>{
if (process.env.__NEXT_ANALYTICS_ID) {
require('./performance-relayer-app')();
}
}, []);
if (process.env.__NEXT_TEST_MODE) {
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(()=>{
window.__NEXT_HYDRATED = true;
if (window.__NEXT_HYDRATED_CB) {
window.__NEXT_HYDRATED_CB();
}
}, []);
}
return children;
}
function RSCComponent(props) {
const cacheKey = getCacheKey();
return /*#__PURE__*/ React.createElement(ServerRoot, Object.assign({}, props, {
cacheKey: cacheKey
}));
}
export function hydrate() {
if (process.env.NODE_ENV !== 'production') {
const rootLayoutMissingTagsError = self.__next_root_layout_missing_tags_error;
const HotReload = require('./components/react-dev-overlay/hot-reloader-client').default;
// Don't try to hydrate if root layout is missing required tags, render error instead
if (rootLayoutMissingTagsError) {
const reactRootElement = document.createElement('div');
document.body.appendChild(reactRootElement);
const reactRoot = ReactDOMClient.createRoot(reactRootElement, {
onRecoverableError
});
reactRoot.render(/*#__PURE__*/ React.createElement(GlobalLayoutRouterContext.Provider, {
value: {
tree: rootLayoutMissingTagsError.tree,
changeByServerResponse: ()=>{},
focusAndScrollRef: {
apply: false
}
}
}, /*#__PURE__*/ React.createElement(HotReload, {
assetPrefix: rootLayoutMissingTagsError.assetPrefix
})));
return;
}
}
const reactEl = /*#__PURE__*/ React.createElement(StrictModeIfEnabled, null, /*#__PURE__*/ React.createElement(HeadManagerContext.Provider, {
value: {
appDir: true
}
}, /*#__PURE__*/ React.createElement(Root, null, /*#__PURE__*/ React.createElement(RSCComponent, null))));
const options = {
onRecoverableError
};
const isError = document.documentElement.id === '__next_error__';
const reactRoot = isError ? ReactDOMClient.createRoot(appElement, options) : React.startTransition(()=>ReactDOMClient.hydrateRoot(appElement, reactEl, options));
if (isError) {
reactRoot.render(reactEl);
}
}
//# sourceMappingURL=app-index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
// TODO-APP: hydration warning
import { appBootstrap } from './app-bootstrap';
appBootstrap(()=>{
const { hydrate } = require('./app-index');
hydrate();
}) // TODO-APP: build indicator
;
//# sourceMappingURL=app-next-dev.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../client/app-next-dev.js"],"names":["appBootstrap","hydrate","require"],"mappings":"AAAA,8BAA8B;AAE9B,SAASA,YAAY,QAAQ,iBAAiB,CAAA;AAE9CA,YAAY,CAAC,IAAM;IACjB,MAAM,EAAEC,OAAO,CAAA,EAAE,GAAGC,OAAO,CAAC,aAAa,CAAC;IAC1CD,OAAO,EAAE;CACV,CAAC,CAEF,4BAA4B"}

View File

@@ -0,0 +1,10 @@
import { appBootstrap } from './app-bootstrap';
appBootstrap(()=>{
// Include app-router and layout-router in the main chunk
require('next/dist/client/components/app-router');
require('next/dist/client/components/layout-router');
const { hydrate } = require('./app-index');
hydrate();
});
//# sourceMappingURL=app-next.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../client/app-next.js"],"names":["appBootstrap","require","hydrate"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB,CAAA;AAE9CA,YAAY,CAAC,IAAM;IACjB,yDAAyD;IACzDC,OAAO,CAAC,wCAAwC,CAAC;IACjDA,OAAO,CAAC,2CAA2C,CAAC;IACpD,MAAM,EAAEC,OAAO,CAAA,EAAE,GAAGD,OAAO,CAAC,aAAa,CAAC;IAC1CC,OAAO,EAAE;CACV,CAAC"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/compat/router.ts"],"names":["useContext","RouterContext","useRouter"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO,CAAA;AAClC,SAASC,aAAa,QAAQ,iCAAiC,CAAA;AAG/D;;;;;;;;;GASG,CACH,OAAO,SAASC,SAAS,GAAsB;IAC7C,OAAOF,UAAU,CAACC,aAAa,CAAC,CAAA;CACjC"}

View File

@@ -0,0 +1,18 @@
export const RSC = 'RSC';
export const NEXT_ROUTER_STATE_TREE = 'Next-Router-State-Tree';
export const NEXT_ROUTER_PREFETCH = 'Next-Router-Prefetch';
export const FETCH_CACHE_HEADER = 'x-vercel-sc-headers';
export const RSC_VARY_HEADER = `${RSC}, ${NEXT_ROUTER_STATE_TREE}, ${NEXT_ROUTER_PREFETCH}`;
export const FLIGHT_PARAMETERS = [
[
RSC
],
[
NEXT_ROUTER_STATE_TREE
],
[
NEXT_ROUTER_PREFETCH
],
];
//# sourceMappingURL=app-router-headers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/components/app-router-headers.ts"],"names":["RSC","NEXT_ROUTER_STATE_TREE","NEXT_ROUTER_PREFETCH","FETCH_CACHE_HEADER","RSC_VARY_HEADER","FLIGHT_PARAMETERS"],"mappings":"AAAA,OAAO,MAAMA,GAAG,GAAG,KAAK,AAAS,CAAA;AACjC,OAAO,MAAMC,sBAAsB,GAAG,wBAAwB,AAAS,CAAA;AACvE,OAAO,MAAMC,oBAAoB,GAAG,sBAAsB,AAAS,CAAA;AACnE,OAAO,MAAMC,kBAAkB,GAAG,qBAAqB,AAAS,CAAA;AAChE,OAAO,MAAMC,eAAe,GAC1B,CAAC,EAAEJ,GAAG,CAAC,EAAE,EAAEC,sBAAsB,CAAC,EAAE,EAAEC,oBAAoB,CAAC,CAAC,AAAS,CAAA;AAEvE,OAAO,MAAMG,iBAAiB,GAAG;IAC/B;QAACL,GAAG;KAAC;IACL;QAACC,sBAAsB;KAAC;IACxB;QAACC,oBAAoB;KAAC;CACvB,AAAS,CAAA"}

View File

@@ -0,0 +1,341 @@
"use client";
import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
import _object_without_properties_loose from "@swc/helpers/src/_object_without_properties_loose.mjs";
import React, { useEffect, useMemo, useCallback } from 'react';
import { createFromFetch } from 'next/dist/compiled/react-server-dom-webpack/client';
import { AppRouterContext, LayoutRouterContext, GlobalLayoutRouterContext, CacheStates } from '../../shared/lib/app-router-context';
import { ACTION_NAVIGATE, ACTION_PREFETCH, ACTION_REFRESH, ACTION_RESTORE, ACTION_SERVER_PATCH, createHrefFromUrl, reducer } from './reducer';
import { SearchParamsContext, // ParamsContext,
PathnameContext } from '../../shared/lib/hooks-client-context';
import { useReducerWithReduxDevtools } from './use-reducer-with-devtools';
import { ErrorBoundary } from './error-boundary';
import { NEXT_ROUTER_PREFETCH, NEXT_ROUTER_STATE_TREE, RSC } from './app-router-headers';
function urlToUrlWithoutFlightMarker(url) {
const urlWithoutFlightParameters = new URL(url, location.origin);
// TODO-APP: handle .rsc for static export case
return urlWithoutFlightParameters;
}
const HotReloader = process.env.NODE_ENV === 'production' ? null : require('./react-dev-overlay/hot-reloader-client').default;
/**
* Fetch the flight data for the provided url. Takes in the current router state to decide what to render server-side.
*/ export function fetchServerResponse(url, flightRouterState, prefetch) {
return _fetchServerResponse.apply(this, arguments);
}
function _fetchServerResponse() {
_fetchServerResponse = _async_to_generator(function*(url, flightRouterState, prefetch) {
const headers = {
// Enable flight response
[RSC]: '1',
// Provide the current router state
[NEXT_ROUTER_STATE_TREE]: JSON.stringify(flightRouterState)
};
if (prefetch) {
// Enable prefetch response
headers[NEXT_ROUTER_PREFETCH] = '1';
}
const res = yield fetch(url.toString(), {
headers
});
const canonicalUrl = res.redirected ? urlToUrlWithoutFlightMarker(res.url) : undefined;
const isFlightResponse = res.headers.get('content-type') === 'application/octet-stream';
// If fetch returns something different than flight response handle it like a mpa navigation
if (!isFlightResponse) {
return [
res.url,
undefined
];
}
// Handle the `fetch` readable stream that can be unwrapped by `React.use`.
const flightData = yield createFromFetch(Promise.resolve(res));
return [
flightData,
canonicalUrl
];
});
return _fetchServerResponse.apply(this, arguments);
}
// Ensure the initialParallelRoutes are not combined because of double-rendering in the browser with Strict Mode.
let initialParallelRoutes = typeof window === 'undefined' ? null : new Map();
const prefetched = new Set();
function findHeadInCache(cache, parallelRoutes) {
const isLastItem = Object.keys(parallelRoutes).length === 0;
if (isLastItem) {
return cache.head;
}
for(const key in parallelRoutes){
const [segment, childParallelRoutes] = parallelRoutes[key];
const childSegmentMap = cache.parallelRoutes.get(key);
if (!childSegmentMap) {
continue;
}
const cacheKey = Array.isArray(segment) ? segment[1] : segment;
const cacheNode = childSegmentMap.get(cacheKey);
if (!cacheNode) {
continue;
}
const item = findHeadInCache(cacheNode, childParallelRoutes);
if (item) {
return item;
}
}
return undefined;
}
/**
* The global router that wraps the application components.
*/ function Router({ initialHead , initialTree , initialCanonicalUrl , children , assetPrefix }) {
const initialState = useMemo(()=>{
return {
tree: initialTree,
cache: {
status: CacheStates.READY,
data: null,
subTreeData: children,
parallelRoutes: typeof window === 'undefined' ? new Map() : initialParallelRoutes
},
prefetchCache: new Map(),
pushRef: {
pendingPush: false,
mpaNavigation: false
},
focusAndScrollRef: {
apply: false
},
canonicalUrl: // location.href is read as the initial value for canonicalUrl in the browser
// This is safe to do as canonicalUrl can't be rendered, it's only used to control the history updates in the useEffect further down in this file.
typeof window !== 'undefined' ? createHrefFromUrl(window.location) : initialCanonicalUrl
};
}, [
children,
initialCanonicalUrl,
initialTree
]);
const [{ tree , cache , prefetchCache , pushRef , focusAndScrollRef , canonicalUrl }, dispatch, sync, ] = useReducerWithReduxDevtools(reducer, initialState);
const head = useMemo(()=>{
return findHeadInCache(cache, tree[1]);
}, [
cache,
tree
]);
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: url.pathname
};
}, [
canonicalUrl
]);
/**
* Server response that only patches the cache and tree.
*/ const changeByServerResponse = useCallback((previousTree, flightData, overrideCanonicalUrl)=>{
dispatch({
type: ACTION_SERVER_PATCH,
flightData,
previousTree,
overrideCanonicalUrl,
cache: {
status: CacheStates.LAZY_INITIALIZED,
data: null,
subTreeData: null,
parallelRoutes: new Map()
},
mutable: {}
});
}, [
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 navigate = (href, navigateType, forceOptimisticNavigation)=>{
return dispatch({
type: ACTION_NAVIGATE,
url: new URL(href, location.origin),
forceOptimisticNavigation,
navigateType,
cache: {
status: CacheStates.LAZY_INITIALIZED,
data: null,
subTreeData: null,
parallelRoutes: new Map()
},
mutable: {}
});
};
const routerInstance = {
back: ()=>window.history.back(),
forward: ()=>window.history.forward(),
prefetch: _async_to_generator(function*(href) {
// If prefetch has already been triggered, don't trigger it again.
if (prefetched.has(href)) {
return;
}
prefetched.add(href);
const url = new URL(href, location.origin);
try {
var ref;
const routerTree = ((ref = window.history.state) == null ? void 0 : ref.tree) || initialTree;
const serverResponse = yield fetchServerResponse(url, // initialTree is used when history.state.tree is missing because the history state is set in `useEffect` below, it being missing means this is the hydration case.
routerTree, true);
// @ts-ignore startTransition exists
React.startTransition(()=>{
dispatch({
type: ACTION_PREFETCH,
url,
tree: routerTree,
serverResponse
});
});
} catch (err) {
console.error('PREFETCH ERROR', err);
}
}),
replace: (href, options = {})=>{
// @ts-ignore startTransition exists
React.startTransition(()=>{
navigate(href, 'replace', Boolean(options.forceOptimisticNavigation));
});
},
push: (href, options = {})=>{
// @ts-ignore startTransition exists
React.startTransition(()=>{
navigate(href, 'push', Boolean(options.forceOptimisticNavigation));
});
},
refresh: ()=>{
// @ts-ignore startTransition exists
React.startTransition(()=>{
dispatch({
type: ACTION_REFRESH,
cache: {
status: CacheStates.LAZY_INITIALIZED,
data: null,
subTreeData: null,
parallelRoutes: new Map()
},
mutable: {}
});
});
}
};
return routerInstance;
}, [
dispatch,
initialTree
]);
useEffect(()=>{
// When mpaNavigation flag is set do a hard navigation to the new url.
if (pushRef.mpaNavigation) {
window.location.href = canonicalUrl;
return;
}
// 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
]);
// Add `window.nd` for debugging purposes.
// This is not meant for use in applications as concurrent rendering will affect the cache/tree/router.
if (typeof window !== 'undefined') {
// @ts-ignore this is for debugging
window.nd = {
router: appRouter,
cache,
prefetchCache,
tree
};
}
/**
* 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(({ state })=>{
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
React.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 content = /*#__PURE__*/ React.createElement(React.Fragment, null, head || initialHead, cache.subTreeData);
return /*#__PURE__*/ React.createElement(PathnameContext.Provider, {
value: pathname
}, /*#__PURE__*/ React.createElement(SearchParamsContext.Provider, {
value: searchParams
}, /*#__PURE__*/ React.createElement(GlobalLayoutRouterContext.Provider, {
value: {
changeByServerResponse,
tree,
focusAndScrollRef
}
}, /*#__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
}
}, HotReloader ? /*#__PURE__*/ React.createElement(HotReloader, {
assetPrefix: assetPrefix
}, content) : content)))));
}
export default function AppRouter(props) {
const { globalErrorComponent } = props, rest = _object_without_properties_loose(props, [
"globalErrorComponent"
]);
return /*#__PURE__*/ React.createElement(ErrorBoundary, {
errorComponent: globalErrorComponent
}, /*#__PURE__*/ React.createElement(Router, Object.assign({}, rest)));
};
//# sourceMappingURL=app-router.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
import { suspense } from '../../shared/lib/dynamic-no-ssr';
import { staticGenerationAsyncStorage } from './static-generation-async-storage';
export function bailoutToClientRendering() {
const staticGenerationStore = staticGenerationAsyncStorage && 'getStore' in staticGenerationAsyncStorage ? staticGenerationAsyncStorage == null ? void 0 : staticGenerationAsyncStorage.getStore() : staticGenerationAsyncStorage;
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":["../../../client/components/bailout-to-client-rendering.ts"],"names":["suspense","staticGenerationAsyncStorage","bailoutToClientRendering","staticGenerationStore","getStore","forceStatic","isStaticGeneration"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,iCAAiC,CAAA;AAC1D,SAASC,4BAA4B,QAAQ,mCAAmC,CAAA;AAEhF,OAAO,SAASC,wBAAwB,GAAoB;IAC1D,MAAMC,qBAAqB,GACzBF,4BAA4B,IAAI,UAAU,IAAIA,4BAA4B,GACtEA,4BAA4B,QAAU,GAAtCA,KAAAA,CAAsC,GAAtCA,4BAA4B,CAAEG,QAAQ,EAAE,GACxCH,4BAA4B;IAElC,IAAIE,qBAAqB,QAAa,GAAlCA,KAAAA,CAAkC,GAAlCA,qBAAqB,CAAEE,WAAW,EAAE;QACtC,OAAO,IAAI,CAAA;KACZ;IAED,IAAIF,qBAAqB,QAAoB,GAAzCA,KAAAA,CAAyC,GAAzCA,qBAAqB,CAAEG,kBAAkB,EAAE;QAC7CN,QAAQ,EAAE;KACX;IAED,OAAO,KAAK,CAAA;CACb"}

View File

@@ -0,0 +1,83 @@
"use client";
import React from 'react';
const styles = {
error: {
fontFamily: '-apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", "Fira Sans", Avenir, "Helvetica Neue", "Lucida Grande", sans-serif',
height: '100vh',
textAlign: 'center',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center'
},
desc: {
display: 'inline-block',
textAlign: 'left',
lineHeight: '49px',
height: '49px',
verticalAlign: 'middle'
},
text: {
fontSize: '14px',
fontWeight: 'normal',
lineHeight: '49px',
margin: 0,
padding: 0
}
};
export class ErrorBoundaryHandler extends React.Component {
static getDerivedStateFromError(error) {
return {
error
};
}
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
};
}
}
export default function GlobalError({ error }) {
return /*#__PURE__*/ React.createElement("html", null, /*#__PURE__*/ React.createElement("head", null), /*#__PURE__*/ React.createElement("body", null, /*#__PURE__*/ React.createElement("div", {
style: styles.error
}, /*#__PURE__*/ React.createElement("div", {
style: styles.desc
}, /*#__PURE__*/ React.createElement("h2", {
style: styles.text
}, "Application error: a client-side exception has occurred (see the browser console for more information)."), (error == null ? void 0 : error.digest) && /*#__PURE__*/ React.createElement("p", {
style: styles.text
}, `Digest: ${error.digest}`)))));
};
/**
* 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({ errorComponent , errorStyles , children }) {
if (errorComponent) {
return /*#__PURE__*/ React.createElement(ErrorBoundaryHandler, {
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":["../../../client/components/error-boundary.tsx"],"names":["React","styles","error","fontFamily","height","textAlign","display","flexDirection","alignItems","justifyContent","desc","lineHeight","verticalAlign","text","fontSize","fontWeight","margin","padding","ErrorBoundaryHandler","Component","getDerivedStateFromError","render","state","props","errorStyles","this","errorComponent","reset","children","constructor","setState","GlobalError","html","head","body","div","style","h2","digest","p","ErrorBoundary"],"mappings":"AAEA,OAAOA,KAAK,MAAM,OAAO,CAAA;AAFzB,YAAY;AAIZ,MAAMC,MAAM,GAAG;IACbC,KAAK,EAAE;QACLC,UAAU,EACR,2HAA2H;QAC7HC,MAAM,EAAE,OAAO;QACfC,SAAS,EAAE,QAAQ;QACnBC,OAAO,EAAE,MAAM;QACfC,aAAa,EAAE,QAAQ;QACvBC,UAAU,EAAE,QAAQ;QACpBC,cAAc,EAAE,QAAQ;KACzB;IACDC,IAAI,EAAE;QACJJ,OAAO,EAAE,cAAc;QACvBD,SAAS,EAAE,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;qBACrB,oBAAC2B,IAAE;QAACD,KAAK,EAAEnC,MAAM,CAACY,IAAI;OAAE,yGAGxB,CAAK,EACJX,CAAAA,KAAK,QAAQ,GAAbA,KAAAA,CAAa,GAAbA,KAAK,CAAEoC,MAAM,CAAA,kBACZ,oBAACC,GAAC;QAACH,KAAK,EAAEnC,MAAM,CAACY,IAAI;OAAG,CAAC,QAAQ,EAAEX,KAAK,CAACoC,MAAM,CAAC,CAAC,CAAK,AACvD,CACG,CACF,CACD,CACF,CACR;CACF,CAAA;AAED;;;GAGG,CAEH;;;GAGG,CACH,OAAO,SAASE,aAAa,CAAC,EAC5Bd,cAAc,CAAA,EACdF,WAAW,CAAA,EACXI,QAAQ,CAAA,EAC2C,EAAe;IAClE,IAAIF,cAAc,EAAE;QAClB,qBACE,oBAACR,oBAAoB;YACnBQ,cAAc,EAAEA,cAAc;YAC9BF,WAAW,EAAEA,WAAW;WAEvBI,QAAQ,CACY,CACxB;KACF;IAED,qBAAO,0CAAGA,QAAQ,CAAI,CAAA;CACvB"}

View File

@@ -0,0 +1,66 @@
import React from 'react';
const styles = {
error: {
fontFamily: '-apple-system, BlinkMacSystemFont, Roboto, "Segoe UI", "Fira Sans", Avenir, "Helvetica Neue", "Lucida Grande", sans-serif',
height: '100vh',
textAlign: 'center',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center'
},
desc: {
display: 'inline-block',
textAlign: 'left',
lineHeight: '49px',
height: '49px',
verticalAlign: 'middle'
},
h1: {
display: 'inline-block',
margin: 0,
marginRight: '20px',
padding: '0 23px 0 0',
fontSize: '24px',
fontWeight: 500,
verticalAlign: 'top',
lineHeight: '49px'
},
h2: {
fontSize: '14px',
fontWeight: 'normal',
lineHeight: '49px',
margin: 0,
padding: 0
}
};
export function NotFound() {
return /*#__PURE__*/ React.createElement("div", {
style: styles.error
}, /*#__PURE__*/ React.createElement("head", null, /*#__PURE__*/ React.createElement("title", null, "404: This page could not be found.")), /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("style", {
dangerouslySetInnerHTML: {
__html: `
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);
}
}
`
}
}), /*#__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=error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/components/error.tsx"],"names":["React","styles","error","fontFamily","height","textAlign","display","flexDirection","alignItems","justifyContent","desc","lineHeight","verticalAlign","h1","margin","marginRight","padding","fontSize","fontWeight","h2","NotFound","div","style","head","title","dangerouslySetInnerHTML","__html","className"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAMC,MAAM,GAAyC;IACnDC,KAAK,EAAE;QACLC,UAAU,EACR,2HAA2H;QAC7HC,MAAM,EAAE,OAAO;QACfC,SAAS,EAAE,QAAQ;QACnBC,OAAO,EAAE,MAAM;QACfC,aAAa,EAAE,QAAQ;QACvBC,UAAU,EAAE,QAAQ;QACpBC,cAAc,EAAE,QAAQ;KACzB;IAEDC,IAAI,EAAE;QACJJ,OAAO,EAAE,cAAc;QACvBD,SAAS,EAAE,MAAM;QACjBM,UAAU,EAAE,MAAM;QAClBP,MAAM,EAAE,MAAM;QACdQ,aAAa,EAAE,QAAQ;KACxB;IAEDC,EAAE,EAAE;QACFP,OAAO,EAAE,cAAc;QACvBQ,MAAM,EAAE,CAAC;QACTC,WAAW,EAAE,MAAM;QACnBC,OAAO,EAAE,YAAY;QACrBC,QAAQ,EAAE,MAAM;QAChBC,UAAU,EAAE,GAAG;QACfN,aAAa,EAAE,KAAK;QACpBD,UAAU,EAAE,MAAM;KACnB;IAEDQ,EAAE,EAAE;QACFF,QAAQ,EAAE,MAAM;QAChBC,UAAU,EAAE,QAAQ;QACpBP,UAAU,EAAE,MAAM;QAClBG,MAAM,EAAE,CAAC;QACTE,OAAO,EAAE,CAAC;KACX;CACF;AAED,OAAO,SAASI,QAAQ,GAAG;IACzB,qBACE,oBAACC,KAAG;QAACC,KAAK,EAAErB,MAAM,CAACC,KAAK;qBACtB,oBAACqB,MAAI,sBACH,oBAACC,OAAK,QAAC,oCAAkC,CAAQ,CAC5C,gBACP,oBAACH,KAAG,sBACF,oBAACC,OAAK;QACJG,uBAAuB,EAAE;YACvBC,MAAM,EAAE,CAAC;;;;;;;;;;;;UAYX,CAAC;SACA;MACD,gBACF,oBAACb,IAAE;QAACc,SAAS,EAAC,eAAe;QAACL,KAAK,EAAErB,MAAM,CAACY,EAAE;OAAE,KAEhD,CAAK,gBACL,oBAACQ,KAAG;QAACC,KAAK,EAAErB,MAAM,CAACS,IAAI;qBACrB,oBAACS,IAAE;QAACG,KAAK,EAAErB,MAAM,CAACkB,EAAE;OAAE,+BAA6B,CAAK,CACpD,CACF,CACF,CACP;CACF"}

View File

@@ -0,0 +1,11 @@
import React from 'react';
export function DefaultHead() {
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("meta", {
charSet: "utf-8"
}), /*#__PURE__*/ React.createElement("meta", {
name: "viewport",
content: "width=device-width, initial-scale=1"
}));
}
//# sourceMappingURL=head.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/components/head.tsx"],"names":["React","DefaultHead","meta","charSet","name","content"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,SAASC,WAAW,GAAG;IAC5B,qBACE,wDACE,oBAACC,MAAI;QAACC,OAAO,EAAC,OAAO;MAAG,gBACxB,oBAACD,MAAI;QAACE,IAAI,EAAC,UAAU;QAACC,OAAO,EAAC,qCAAqC;MAAG,CACrE,CACJ;CACF"}

View File

@@ -0,0 +1,23 @@
import { RequestCookies } from '../../server/web/spec-extension/cookies';
import { requestAsyncStorage } from './request-async-storage';
import { staticGenerationBailout } from './static-generation-bailout';
export function headers() {
if (staticGenerationBailout('headers')) {
return new Headers({});
}
const requestStore = requestAsyncStorage && 'getStore' in requestAsyncStorage ? requestAsyncStorage.getStore() : requestAsyncStorage;
return requestStore.headers;
}
export function previewData() {
const requestStore = requestAsyncStorage && 'getStore' in requestAsyncStorage ? requestAsyncStorage.getStore() : requestAsyncStorage;
return requestStore.previewData;
}
export function cookies() {
if (staticGenerationBailout('cookies')) {
return new RequestCookies(new Headers({}));
}
const requestStore = requestAsyncStorage && 'getStore' in requestAsyncStorage ? requestAsyncStorage.getStore() : requestAsyncStorage;
return requestStore.cookies;
}
//# sourceMappingURL=headers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/components/headers.ts"],"names":["RequestCookies","requestAsyncStorage","staticGenerationBailout","headers","Headers","requestStore","getStore","previewData","cookies"],"mappings":"AAAA,SAASA,cAAc,QAAQ,yCAAyC,CAAA;AACxE,SAASC,mBAAmB,QAAQ,yBAAyB,CAAA;AAC7D,SAASC,uBAAuB,QAAQ,6BAA6B,CAAA;AAErE,OAAO,SAASC,OAAO,GAAG;IACxB,IAAID,uBAAuB,CAAC,SAAS,CAAC,EAAE;QACtC,OAAO,IAAIE,OAAO,CAAC,EAAE,CAAC,CAAA;KACvB;IAED,MAAMC,YAAY,GAChBJ,mBAAmB,IAAI,UAAU,IAAIA,mBAAmB,GACpDA,mBAAmB,CAACK,QAAQ,EAAE,GAC9BL,mBAAmB;IAEzB,OAAOI,YAAY,CAACF,OAAO,CAAA;CAC5B;AAED,OAAO,SAASI,WAAW,GAAG;IAC5B,MAAMF,YAAY,GAChBJ,mBAAmB,IAAI,UAAU,IAAIA,mBAAmB,GACpDA,mBAAmB,CAACK,QAAQ,EAAE,GAC9BL,mBAAmB;IACzB,OAAOI,YAAY,CAACE,WAAW,CAAA;CAChC;AAED,OAAO,SAASC,OAAO,GAAG;IACxB,IAAIN,uBAAuB,CAAC,SAAS,CAAC,EAAE;QACtC,OAAO,IAAIF,cAAc,CAAC,IAAII,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;KAC3C;IACD,MAAMC,YAAY,GAChBJ,mBAAmB,IAAI,UAAU,IAAIA,mBAAmB,GACpDA,mBAAmB,CAACK,QAAQ,EAAE,GAC9BL,mBAAmB;IAEzB,OAAOI,YAAY,CAACG,OAAO,CAAA;CAC5B"}

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":["../../../client/components/hooks-server-context.ts"],"names":["DYNAMIC_ERROR_CODE","DynamicServerError","Error","constructor","type","digest"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAAG,sBAAsB,CAAA;AAExD,OAAO,MAAMC,kBAAkB,SAASC,KAAK;IAG3CC,YAAYC,IAAY,CAAE;QACxB,KAAK,CAAC,CAAC,sBAAsB,EAAEA,IAAI,CAAC,CAAC,CAAC;QAHxCC,KAAAA,MAAM,GAA8BL,kBAAkB,CAAA;KAIrD;CACF"}

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":["../../../client/components/infinite-promise.ts"],"names":["infinitePromise","createInfinitePromise","Promise"],"mappings":"AAAA;;GAEG,CACH,IAAIA,eAAe,AAAe;AAElC;;GAEG,CACH,OAAO,SAASC,qBAAqB,GAAG;IACtC,IAAI,CAACD,eAAe,EAAE;QACpB,+BAA+B;QAC/BA,eAAe,GAAG,IAAIE,OAAO,CAAC,IAAmB;QAC/C,6DAA6D;QAC7D,qBAAqB;QACrB,oDAAoD;QACpD,cAAc;QACd,WAAW;SACZ,CAAC;KACH;IAED,OAAOF,eAAe,CAAA;CACvB"}

View File

@@ -0,0 +1,363 @@
"use client";
import _extends from "@swc/helpers/src/_extends.mjs";
import React, { useContext, useEffect, use } from 'react';
import ReactDOM from 'react-dom';
import { CacheStates, LayoutRouterContext, GlobalLayoutRouterContext, TemplateContext } from '../../shared/lib/app-router-context';
import { fetchServerResponse } from './app-router';
import { createInfinitePromise } from './infinite-promise';
import { ErrorBoundary } from './error-boundary';
import { matchSegment } from './match-segments';
import { useRouter } from './navigation';
/**
* 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],
_extends({}, treeToRecreate[1], {
[parallelRouteKey]: [
subTree[0],
subTree[1],
subTree[2],
'refetch',
]
}),
];
}
return [
treeToRecreate[0],
_extends({}, 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 = (...messages)=>{
// 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);
}
/**
* Check if the top of the HTMLElement is in the viewport.
*/ function topOfElementInViewport(element) {
const rect = element.getBoundingClientRect();
return rect.top >= 0;
}
class ScrollAndFocusHandler extends React.Component {
componentDidMount() {
// Handle scroll and focus, it's only applied once in the first useEffect that triggers that changed.
const { focusAndScrollRef } = this.props;
const domNode = findDOMNode(this);
if (focusAndScrollRef.apply && domNode instanceof HTMLElement) {
// State is mutated to ensure that the focus and scroll is applied only once.
focusAndScrollRef.apply = false;
// Set focus on the element
domNode.focus();
// Only scroll into viewport when the layout is not visible currently.
if (!topOfElementInViewport(domNode)) {
const htmlElement = document.documentElement;
const existing = htmlElement.style.scrollBehavior;
htmlElement.style.scrollBehavior = 'auto';
// In Chrome-based browsers we need to force reflow before calling `scrollTo`.
// Otherwise it will not pickup the change in scrollBehavior
// More info here: https://github.com/vercel/next.js/issues/40719#issuecomment-1336248042
htmlElement.getClientRects();
domNode.scrollIntoView();
htmlElement.style.scrollBehavior = existing;
}
}
}
render() {
return this.props.children;
}
}
/**
* InnerLayoutRouter handles rendering the provided segment based on the cache.
*/ export function InnerLayoutRouter({ parallelRouterKey , url , childNodes , childProp , segmentPath , tree , // TODO-APP: implement `<Offscreen>` when available.
// isActive,
path , rootLayoutIncluded }) {
const context = useContext(GlobalLayoutRouterContext);
if (!context) {
throw new Error('invariant global layout router not mounted');
}
const { changeByServerResponse , tree: fullTree , focusAndScrollRef } = context;
// Read segment path from the parallel router cache node.
let childNode = childNodes.get(path);
// 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 && childNode.status === CacheStates.LAZY_INITIALIZED) {
// @ts-expect-error TODO-APP: handle changing of the type
childNode.status = CacheStates.READY;
// @ts-expect-error TODO-APP: handle changing of the type
childNode.subTreeData = childProp.current;
// Mutates the prop in order to clean up the memory associated with the subTreeData as it is now part of the cache.
childProp.current = null;
} else {
// 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.
childNodes.set(path, {
status: CacheStates.READY,
data: null,
subTreeData: childProp.current,
parallelRoutes: new Map()
});
// Mutates the prop in order to clean up the memory associated with the subTreeData as it is now part of the cache.
childProp.current = null;
// In the above case childNode was set on childNodes, so we have to get it from the cacheNodes again.
childNode = childNodes.get(path);
}
}
// 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);
/**
* Flight data fetch kicked off during render and put into the cache.
*/ childNodes.set(path, {
status: CacheStates.DATA_FETCH,
data: fetchServerResponse(new URL(url, location.origin), refetchTree),
subTreeData: null,
head: childNode && childNode.status === CacheStates.LAZY_INITIALIZED ? childNode.head : undefined,
parallelRoutes: childNode && childNode.status === CacheStates.LAZY_INITIALIZED ? childNode.parallelRoutes : new Map()
});
// In the above case childNode was set on childNodes, so we have to get it from the cacheNodes again.
childNode = childNodes.get(path);
}
// 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);
// Handle case when navigating to page in `pages` from `app`
if (typeof flightData === 'string') {
window.location.href = url;
return null;
}
// 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(()=>{
// @ts-ignore startTransition exists
React.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 rootLayoutIncluded ? /*#__PURE__*/ React.createElement(ScrollAndFocusHandler, {
focusAndScrollRef: focusAndScrollRef
}, subtree) : 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({ children , loading , loadingStyles , hasLoading }) {
if (hasLoading) {
return /*#__PURE__*/ React.createElement(React.Suspense, {
fallback: /*#__PURE__*/ React.createElement(React.Fragment, null, loadingStyles, loading)
}, children);
}
return /*#__PURE__*/ React.createElement(React.Fragment, null, children);
}
function HandleRedirect({ redirect }) {
const router = useRouter();
useEffect(()=>{
router.replace(redirect, {});
}, [
redirect,
router
]);
return null;
}
class RedirectErrorBoundary extends React.Component {
static getDerivedStateFromError(error) {
var ref;
if (error == null ? void 0 : (ref = error.digest) == null ? void 0 : ref.startsWith('NEXT_REDIRECT')) {
const url = error.digest.split(';')[1];
return {
redirect: url
};
}
// Re-throw if error is not for redirect
throw error;
}
render() {
const redirect = this.state.redirect;
if (redirect !== null) {
return /*#__PURE__*/ React.createElement(HandleRedirect, {
redirect: redirect
});
}
return this.props.children;
}
constructor(props){
super(props);
this.state = {
redirect: null
};
}
}
function RedirectBoundary({ children }) {
const router = useRouter();
return /*#__PURE__*/ React.createElement(RedirectErrorBoundary, {
router: router
}, children);
}
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;
}
render() {
if (this.state.notFoundTriggered) {
return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("meta", {
name: "robots",
content: "noindex"
}), this.props.notFoundStyles, this.props.notFound);
}
return this.props.children;
}
constructor(props){
super(props);
this.state = {
notFoundTriggered: false
};
}
}
function NotFoundBoundary({ notFound , notFoundStyles , children }) {
return notFound ? /*#__PURE__*/ React.createElement(NotFoundErrorBoundary, {
notFound: notFound,
notFoundStyles: notFoundStyles
}, children) : /*#__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({ parallelRouterKey , segmentPath , childProp , error , errorStyles , templateStyles , loading , loadingStyles , hasLoading , template , notFound , notFoundStyles , rootLayoutIncluded }) {
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) {
childNodes.set(parallelRouterKey, new Map());
childNodesForParallelRouter = childNodes.get(parallelRouterKey);
}
// 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 = Array.isArray(childProp.segment) ? childProp.segment[1] : 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 currentChildSegment = Array.isArray(treeSegment) ? treeSegment[1] : 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 = [
currentChildSegment
];
return /*#__PURE__*/ React.createElement(React.Fragment, null, preservedSegments.map((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: preservedSegment,
value: /*#__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: childPropSegment === preservedSegment ? childProp : null,
segmentPath: segmentPath,
path: preservedSegment,
isActive: currentChildSegment === preservedSegment,
rootLayoutIncluded: rootLayoutIncluded
})))))
}, /*#__PURE__*/ React.createElement(React.Fragment, null, templateStyles, template)));
}));
};
//# sourceMappingURL=layout-router.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
export const matchSegment = (existingSegment, segment)=>{
// Common case: segment is just a string
if (typeof existingSegment === 'string' && typeof segment === 'string') {
return existingSegment === segment;
}
// Dynamic parameter case: segment is an array with param/value. Both param and value are compared.
if (Array.isArray(existingSegment) && Array.isArray(segment)) {
return existingSegment[0] === segment[0] && existingSegment[1] === segment[1];
}
return false;
};
//# sourceMappingURL=match-segments.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/components/match-segments.ts"],"names":["matchSegment","existingSegment","segment","Array","isArray"],"mappings":"AAEA,OAAO,MAAMA,YAAY,GAAG,CAC1BC,eAAwB,EACxBC,OAAgB,GACJ;IACZ,wCAAwC;IACxC,IAAI,OAAOD,eAAe,KAAK,QAAQ,IAAI,OAAOC,OAAO,KAAK,QAAQ,EAAE;QACtE,OAAOD,eAAe,KAAKC,OAAO,CAAA;KACnC;IAED,mGAAmG;IACnG,IAAIC,KAAK,CAACC,OAAO,CAACH,eAAe,CAAC,IAAIE,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,EAAE;QAC5D,OACED,eAAe,CAAC,CAAC,CAAC,KAAKC,OAAO,CAAC,CAAC,CAAC,IAAID,eAAe,CAAC,CAAC,CAAC,KAAKC,OAAO,CAAC,CAAC,CAAC,CACvE;KACF;IAED,OAAO,KAAK,CAAA;CACb,CAAA"}

View File

@@ -0,0 +1,121 @@
// useLayoutSegments() // Only the segments for the current place. ['children', 'dashboard', 'children', 'integrations'] -> /dashboard/integrations (/dashboard/layout.js would get ['children', 'dashboard', 'children', 'integrations'])
import { useContext, useMemo } from 'react';
import { AppRouterContext, LayoutRouterContext } from '../../shared/lib/app-router-context';
import { SearchParamsContext, // ParamsContext,
PathnameContext } from '../../shared/lib/hooks-client-context';
import { bailoutToClientRendering } from './bailout-to-client-rendering';
const INTERNAL_URLSEARCHPARAMS_INSTANCE = Symbol('internal for urlsearchparams readonly');
function readonlyURLSearchParamsError() {
return new Error('ReadonlyURLSearchParams cannot be modified');
}
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){
// Since `new Headers` uses `this.append()` to fill the headers object ReadonlyHeaders can't extend from Headers directly as it would throw.
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);
}
}
/**
* 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/en-US/docs/Web/API/URLSearchParams
*/ export function useSearchParams() {
const searchParams = useContext(SearchParamsContext);
const readonlySearchParams = useMemo(()=>{
return new ReadonlyURLSearchParams(searchParams || new URLSearchParams());
}, [
searchParams
]);
if (bailoutToClientRendering()) {
// TODO-APP: handle dynamic = 'force-static' here and on the client
return readonlySearchParams;
}
if (!searchParams) {
throw new Error('invariant expected search params to be mounted');
}
return readonlySearchParams;
}
/**
* Get the current pathname. For example usePathname() on /dashboard?foo=bar would return "/dashboard"
*/ export function usePathname() {
return useContext(PathnameContext);
}
// TODO-APP: getting all params when client-side navigating is non-trivial as it does not have route matchers so this might have to be a server context instead.
// export function useParams() {
// return useContext(ParamsContext)
// }
// TODO-APP: define what should be provided through context.
// export function useLayoutSegments() {
// return useContext(LayoutSegmentsContext)
// }
export { ServerInsertedHTMLContext, useServerInsertedHTML } from '../../shared/lib/server-inserted-html';
/**
* Get the router methods. For example router.push('/dashboard')
*/ export function useRouter() {
const router = useContext(AppRouterContext);
if (router === null) {
throw new Error('invariant expected app router to be mounted');
}
return router;
}
// TODO-APP: handle parallel routes
function getSelectedLayoutSegmentPath(tree, parallelRouteKey, first = true, 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 _children;
node = (_children = parallelRoutes.children) != null ? _children : Object.values(parallelRoutes)[0];
}
if (!node) return segmentPath;
const segment = node[0];
const segmentValue = Array.isArray(segment) ? segment[1] : segment;
if (!segmentValue) 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 = 'children') {
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 = 'children') {
const selectedLayoutSegments = useSelectedLayoutSegments(parallelRouteKey);
if (selectedLayoutSegments.length === 0) {
return null;
}
return selectedLayoutSegments[0];
}
export { redirect } from './redirect';
export { notFound } from './not-found';
//# sourceMappingURL=navigation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/components/navigation.ts"],"names":["useContext","useMemo","AppRouterContext","LayoutRouterContext","SearchParamsContext","PathnameContext","bailoutToClientRendering","INTERNAL_URLSEARCHPARAMS_INSTANCE","Symbol","readonlyURLSearchParamsError","Error","ReadonlyURLSearchParams","iterator","append","delete","set","sort","constructor","urlSearchParams","entries","bind","forEach","get","getAll","has","keys","values","toString","useSearchParams","searchParams","readonlySearchParams","URLSearchParams","usePathname","ServerInsertedHTMLContext","useServerInsertedHTML","useRouter","router","getSelectedLayoutSegmentPath","tree","parallelRouteKey","first","segmentPath","node","parallelRoutes","children","Object","segment","segmentValue","Array","isArray","push","useSelectedLayoutSegments","useSelectedLayoutSegment","selectedLayoutSegments","length","redirect","notFound"],"mappings":"AAAA,0OAA0O;AAE1O,SAASA,UAAU,EAAEC,OAAO,QAAQ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IAAIc,sBAAsB,CAACC,MAAM,KAAK,CAAC,EAAE;QACvC,OAAO,IAAI,CAAA;KACZ;IAED,OAAOD,sBAAsB,CAAC,CAAC,CAAC,CAAA;CACjC;AAED,SAASE,QAAQ,QAAQ,YAAY,CAAA;AACrC,SAASC,QAAQ,QAAQ,aAAa,CAAA"}

View File

@@ -0,0 +1,5 @@
export default function NoopHead() {
return null;
};
//# sourceMappingURL=noop-head.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/components/noop-head.tsx"],"names":["NoopHead"],"mappings":"AAAA,eAAe,SAASA,QAAQ,GAAG;IACjC,OAAO,IAAI,CAAA;CACZ,CAAA"}

View File

@@ -0,0 +1,9 @@
export const NOT_FOUND_ERROR_CODE = 'NEXT_NOT_FOUND';
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;
}
//# sourceMappingURL=not-found.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../client/components/not-found.ts"],"names":["NOT_FOUND_ERROR_CODE","notFound","error","Error","digest"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG,gBAAgB,CAAA;AAEpD,OAAO,SAASC,QAAQ,GAAU;IAChC,4CAA4C;IAC5C,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAACH,oBAAoB,CAAC,AAC5C;IAAA,AAACE,KAAK,CAASE,MAAM,GAAGJ,oBAAoB;IAC7C,MAAME,KAAK,CAAA;CACZ"}

View File

@@ -0,0 +1,361 @@
import React, { useCallback, useEffect, useReducer, useMemo, // @ts-expect-error TODO-APP: startTransition exists
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 { 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, useWebsocket, useWebsocketPing } from './internal/helpers/use-websocket';
let mostRecentCompilationHash = null;
let __nextDevClientId = Math.round(Math.random() * 100 + Date.now());
// let startLatency = undefined
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.
// @ts-expect-error __webpack_hash__ exists
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(e, sendMessage, router, dispatcher) {
const obj = JSON.parse(e.data);
switch(obj.action){
case 'building':
{
console.log('[Fast Refresh] rebuilding');
break;
}
case 'built':
case 'sync':
{
if (obj.hash) {
handleAvailableHash(obj.hash);
}
const { errors , warnings } = obj;
const hasErrors = Boolean(errors && errors.length);
// Compilation with errors (e.g. syntax error or missing modules).
if (hasErrors) {
sendMessage(JSON.stringify({
event: 'client-error',
errorCount: errors.length,
clientId: __nextDevClientId
}));
// "Massage" webpack messages.
var 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;
}
}
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 !== '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 !== '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 'serverComponentChanges':
{
sendMessage(JSON.stringify({
event: 'server-component-reload-page',
clientId: __nextDevClientId
}));
if (RuntimeErrorHandler.hadRuntimeError) {
return window.location.reload();
}
startTransition(()=>{
router.refresh();
dispatcher.onRefresh();
});
if (process.env.__NEXT_TEST_MODE) {
if (self.__NEXT_HMR_CB) {
self.__NEXT_HMR_CB();
self.__NEXT_HMR_CB = null;
}
}
return;
}
case 'reloadPage':
{
sendMessage(JSON.stringify({
event: 'client-reload-page',
clientId: __nextDevClientId
}));
return window.location.reload();
}
case 'removedPage':
{
// TODO-APP: potentially only refresh if the currently viewed page was removed.
router.refresh();
return;
}
case 'addedPage':
{
// TODO-APP: potentially only refresh if the currently viewed page was added.
router.refresh();
return;
}
case 'pong':
{
const { invalid } = obj;
if (invalid) {
// Payload can be invalid even if the page does exist.
// So, we check if it can be created.
router.refresh();
}
return;
}
default:
{
throw new Error('Unexpected action ' + obj.action);
}
}
}
export default function HotReload({ assetPrefix , children }) {
const [state, dispatch] = useReducer(errorOverlayReducer, {
nextId: 1,
buildError: null,
errors: [],
refreshState: {
type: 'idle'
}
});
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
});
}
};
}, [
dispatch
]);
const handleOnUnhandledError = useCallback((error)=>{
dispatch({
type: ACTION_UNHANDLED_ERROR,
reason: error,
frames: parseStack(error.stack)
});
}, []);
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 router = useRouter();
useEffect(()=>{
const handler = (event)=>{
if (event.data.indexOf('action') === -1 && // TODO-APP: clean this up for consistency
event.data.indexOf('pong') === -1) {
return;
}
try {
processMessage(event, sendMessage, router, dispatcher);
} catch (ex) {
console.warn('Invalid HMR message: ' + event.data + '\n', ex);
}
};
const websocket = webSocketRef.current;
if (websocket) {
websocket.addEventListener('message', handler);
}
return ()=>websocket && websocket.removeEventListener('message', handler);
}, [
sendMessage,
router,
webSocketRef,
dispatcher
]);
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,60 @@
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 { Base } from './styles/Base';
import { ComponentStyles } from './styles/ComponentStyles';
import { CssReset } from './styles/CssReset';
import { parseStack } from './helpers/parseStack';
import { RootLayoutError } from './container/RootLayoutError';
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
}) : reactError ? /*#__PURE__*/ React.createElement(Errors, {
initialDisplayState: "fullscreen",
errors: [
reactError
]
}) : hasRuntimeErrors ? /*#__PURE__*/ React.createElement(Errors, {
initialDisplayState: "minimized",
errors: state.errors
}) : 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":["../../../../../client/components/react-dev-overlay/internal/ReactDevOverlay.tsx"],"names":["React","ACTION_UNHANDLED_ERROR","ShadowPortal","BuildError","Errors","Base","ComponentStyles","CssReset","parseStack","RootLayoutError","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","initialDisplayState","undefined"],"mappings":"AAAA,YAAYA,KAAK,MAAM,OAAO,CAAA;AAC9B,SACEC,sBAAsB,QAGjB,yBAAyB,CAAA;AAEhC,SAASC,YAAY,QAAQ,2BAA2B,CAAA;AACxD,SAASC,UAAU,QAAQ,wBAAwB,CAAA;AACnD,SAASC,MAAM,QAA6B,oBAAoB,CAAA;AAChE,SAASC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ACR,oBAACnC,YAAY,sBACX,oBAACK,QAAQ,OAAG,gBACZ,oBAACF,IAAI,OAAG,gBACR,oBAACC,eAAe,OAAG,EAElB8B,0BAA0B,iBACzB,oBAAC3B,eAAe;YACdgC,WAAW,EAAEL,0BAA0B,CAACK,WAAW;UACnD,GACAX,aAAa,iBACf,oBAAC3B,UAAU;YAACuC,OAAO,EAAEd,KAAK,CAACG,UAAU;UAAK,GACxCT,UAAU,iBACZ,oBAAClB,MAAM;YAACuC,mBAAmB,EAAC,YAAY;YAACT,MAAM,EAAE;gBAACZ,UAAU;aAAC;UAAI,GAC/DU,gBAAgB,iBAClB,oBAAC5B,MAAM;YAACuC,mBAAmB,EAAC,WAAW;YAACT,MAAM,EAAEN,KAAK,CAACM,MAAM;UAAI,GAC9DU,SAAS,CACA,GACbA,SAAS,CACZ,CACJ;KACF;;;QAhEDhB,KAAAA,KAAK,GAAG;YAAEN,UAAU,EAAE,IAAI;SAAE,CAAA;;CAiE7B;AAED,eAAeZ,eAAe,CAAA"}

View File

@@ -0,0 +1,77 @@
import _extends from "@swc/helpers/src/_extends.mjs";
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';
export const CodeFrame = function CodeFrame({ stackFrame , codeFrame , }) {
// 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 = React.useCallback(()=>{
const params = new URLSearchParams();
for(const key in stackFrame){
var _key;
params.append(key, ((_key = stackFrame[key]) != null ? _key : '').toString());
}
self.fetch(`${process.env.__NEXT_ROUTER_BASEPATH || ''}/__nextjs_launch-editor?${params.toString()}`).then(()=>{}, ()=>{
console.error('There was an issue opening this code in your editor.');
});
}, [
stackFrame
]);
// 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: _extends({
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":["../../../../../../../client/components/react-dev-overlay/internal/components/CodeFrame/CodeFrame.tsx"],"names":["Anser","React","stripAnsi","getFrameSource","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","useCallback","params","URLSearchParams","key","append","toString","self","fetch","process","env","__NEXT_ROUTER_BASEPATH","then","console","error","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","style","color","fg","undefined","decoration","fontWeight","fontStyle","content"],"mappings":"AAAA;AAAA,OAAOA,KAAK,MAAM,0BAA0B,CAAA;AAC5C,YAAYC,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAOC,SAAS,MAAM,+BAA+B,CAAA;AACrD,SAASC,cAAc,QAAQ,2BAA2B,CAAA;AAI1D,OAAO,MAAMC,SAAS,GAA6B,SAASA,SAAS,CAAC,EACpEC,UAAU,CAAA,EACVC,SAAS,CAAA,IACV,EAAE;IACD,8CAA8C;IAC9C,MAAMC,cAAc,GAAGN,KAAK,CAACO,OAAO,CAAS,IAAM;QACjD,MAAMC,KAAK,GAAGH,SAAS,CAACI,KAAK,UAAU;QACvC,MAAMC,YAAY,GAAGF,KAAK,CACvBG,GAAG,CAAC,CAACC,IAAI,GACR,oBAAoBC,IAAI,CAACZ,SAAS,CAACW,IAAI,CAAC,CAAC,KAAK,IAAI,GAC9C,IAAI,GACJ,oBAAoBC,IAAI,CAACZ,SAAS,CAACW,IAAI,CAAC,CAAC,CAC9C,CACAE,MAAM,CAACC,OAAO,CAAC,CACfJ,GAAG,CAAC,CAACK,CAAC,GAAKA,CAAC,CAAEC,GAAG,EAAE,AAAC,CAAC,CACrBC,MAAM,CAAC,CAACC,CAAC,EAAEC,CAAC,GAAMC,KAAK,CAACF,CAAC,CAAC,GAAGC,CAAC,CAACE,MAAM,GAAGC,IAAI,CAACC,GAAG,CAACL,CAAC,EAAEC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J,KAAK,CAACI,EAAE,CAAC,CAAC,CAAC,GAAGC,SAAS;eACpDL,KAAK,CAACM,UAAU,KAAK,MAAM,GAC3B;gBAAEC,UAAU,EAAE,GAAG;aAAE,GACnBP,KAAK,CAACM,UAAU,KAAK,QAAQ,GAC7B;gBAAEE,SAAS,EAAE,QAAQ;aAAE,GACvBH,SAAS,CACd;WAEAL,KAAK,CAACS,OAAO,CACT,AACR,CAAC,CACE,CACF,CACP;CACF,CAAA"}

View File

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

View File

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

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../client/components/react-dev-overlay/internal/components/CodeFrame/styles.tsx"],"names":["noop","css","styles"],"mappings":"AAAA,SAASA,IAAI,IAAIC,GAAG,QAAQ,6BAA6B,CAAA;AAEzD,MAAMC,MAAM,GAAGD,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CnB,CAAC;AAED,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,55 @@
import _object_without_properties_loose from "@swc/helpers/src/_object_without_properties_loose.mjs";
import * as React from 'react';
import { useOnClickOutside } from '../../hooks/use-on-click-outside';
const Dialog = function Dialog(_param) {
var { children , type , onClose } = _param, props = _object_without_properties_loose(_param, [
"children",
"type",
"onClose"
]);
const [dialog, setDialog] = React.useState(null);
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();
}
}
shadowRoot.addEventListener('keydown', handler);
return ()=>shadowRoot.removeEventListener('keydown', handler);
}, [
dialog
]);
return /*#__PURE__*/ React.createElement("div", {
ref: onDialog,
"data-nextjs-dialog": true,
tabIndex: -1,
role: "dialog",
"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":["../../../../../../../client/components/react-dev-overlay/internal/components/Dialog/Dialog.tsx"],"names":["React","useOnClickOutside","Dialog","children","type","onClose","props","dialog","setDialog","useState","onDialog","useCallback","node","useEffect","root","getRootNode","ShadowRoot","shadowRoot","handler","e","el","activeElement","key","HTMLElement","getAttribute","preventDefault","stopPropagation","click","addEventListener","removeEventListener","div","ref","data-nextjs-dialog","tabIndex","role","aria-labelledby","aria-describedby","aria-modal","data-nextjs-dialog-banner","className"],"mappings":"AAAA;AAAA,YAAYA,KAAK,MAAM,OAAO,CAAA;AAC9B,SAASC,iBAAiB,QAAQ,kCAAkC,CAAA;AASpE,MAAMC,MAAM,GAA0B,SAASA,MAAM,CAAC,MAKrD,EAAE;QALmD,EACpDC,QAAQ,CAAA,EACRC,IAAI,CAAA,EACJC,OAAO,CAAA,EAER,GALqD,MAKrD,EADIC,KAAK,oCAJ4C,MAKrD;QAJCH,UAAQ;QACRC,MAAI;QACJC,SAAO;;IAGP,MAAM,CAACE,MAAM,EAAEC,SAAS,CAAC,GAAGR,KAAK,CAACS,QAAQ,CAAwB,IAAI,CAAC;IACvE,MAAMC,QAAQ,GAAGV,KAAK,CAACW,WAAW,CAAC,CAACC,IAAI,GAAK;QAC3CJ,SAAS,CAACI,IAAI,CAAC;KAChB,EAAE,EAAE,CAAC;IACNX,iBAAiB,CAACM,MAAM,EAAEF,OAAO,CAAC;IAElC,uEAAuE;IACvE,0BAA0B;IAC1BL,KAAK,CAACa,SAAS,CAAC,IAAM;QACpB,IAAIN,MAAM,IAAI,IAAI,EAAE;YAClB,OAAM;SACP;QAED,MAAMO,IAAI,GAAGP,MAAM,CAACQ,WAAW,EAAE;QACjC,8CAA8C;QAC9C,IAAI,CAAC,CAACD,IAAI,YAAYE,UAAU,CAAC,EAAE;YACjC,OAAM;SACP;QACD,MAAMC,UAAU,GAAGH,IAAI;QACvB,SAASI,OAAO,CAACC,CAAgB,EAAE;YACjC,MAAMC,EAAE,GAAGH,UAAU,CAACI,aAAa;YACnC,IACEF,CAAC,CAACG,GAAG,KAAK,OAAO,IACjBF,EAAE,YAAYG,WAAW,IACzBH,EAAE,CAACI,YAAY,CAAC,MAAM,CAAC,KAAK,MAAM,EAClC;gBACAL,CAAC,CAACM,cAAc,EAAE;gBAClBN,CAAC,CAACO,eAAe,EAAE;gBAEnBN,EAAE,CAACO,KAAK,EAAE;aACX;SACF;QAEDV,UAAU,CAACW,gBAAgB,CAAC,SAAS,EAAEV,OAAO,CAAkB;QAChE,OAAO,IACLD,UAAU,CAACY,mBAAmB,CAAC,SAAS,EAAEX,OAAO,CAAkB,CAAA;KACtE,EAAE;QAACX,MAAM;KAAC,CAAC;IAEZ,qBACE,oBAACuB,KAAG;QACFC,GAAG,EAAErB,QAAQ;QACbsB,oBAAkB,EAAlBA,IAAkB;QAClBC,QAAQ,EAAE,CAAC,CAAC;QACZC,IAAI,EAAC,QAAQ;QACbC,iBAAe,EAAE7B,KAAK,CAAC,iBAAiB,CAAC;QACzC8B,kBAAgB,EAAE9B,KAAK,CAAC,kBAAkB,CAAC;QAC3C+B,YAAU,EAAC,MAAM;qBAEjB,oBAACP,KAAG;QAACQ,2BAAyB,EAAzBA,IAAyB;QAACC,SAAS,EAAE,CAAC,OAAO,EAAEnC,IAAI,CAAC,CAAC;MAAI,EAC7DD,QAAQ,CACL,CACP;CACF;AAED,SAASD,MAAM,GAAE"}

View File

@@ -0,0 +1,10 @@
import * as React from 'react';
const DialogBody = function DialogBody({ children , className , }) {
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":["../../../../../../../client/components/react-dev-overlay/internal/components/Dialog/DialogBody.tsx"],"names":["React","DialogBody","children","className","div","data-nextjs-dialog-body"],"mappings":"AAAA,YAAYA,KAAK,MAAM,OAAO,CAAA;AAM9B,MAAMC,UAAU,GAA8B,SAASA,UAAU,CAAC,EAChEC,QAAQ,CAAA,EACRC,SAAS,CAAA,IACV,EAAE;IACD,qBACE,oBAACC,KAAG;QAACC,yBAAuB,EAAvBA,IAAuB;QAACF,SAAS,EAAEA,SAAS;OAC9CD,QAAQ,CACL,CACP;CACF;AAED,SAASD,UAAU,GAAE"}

View File

@@ -0,0 +1,10 @@
import * as React from 'react';
const DialogContent = function DialogContent({ children , className , }) {
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":["../../../../../../../client/components/react-dev-overlay/internal/components/Dialog/DialogContent.tsx"],"names":["React","DialogContent","children","className","div","data-nextjs-dialog-content"],"mappings":"AAAA,YAAYA,KAAK,MAAM,OAAO,CAAA;AAM9B,MAAMC,aAAa,GAAiC,SAASA,aAAa,CAAC,EACzEC,QAAQ,CAAA,EACRC,SAAS,CAAA,IACV,EAAE;IACD,qBACE,oBAACC,KAAG;QAACC,4BAA0B,EAA1BA,IAA0B;QAACF,SAAS,EAAEA,SAAS;OACjDD,QAAQ,CACL,CACP;CACF;AAED,SAASD,aAAa,GAAE"}

View File

@@ -0,0 +1,10 @@
import * as React from 'react';
const DialogHeader = function DialogHeader({ children , className , }) {
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":["../../../../../../../client/components/react-dev-overlay/internal/components/Dialog/DialogHeader.tsx"],"names":["React","DialogHeader","children","className","div","data-nextjs-dialog-header"],"mappings":"AAAA,YAAYA,KAAK,MAAM,OAAO,CAAA;AAM9B,MAAMC,YAAY,GAAgC,SAASA,YAAY,CAAC,EACtEC,QAAQ,CAAA,EACRC,SAAS,CAAA,IACV,EAAE;IACD,qBACE,oBAACC,KAAG;QAACC,2BAAyB,EAAzBA,IAAyB;QAACF,SAAS,EAAEA,SAAS;OAChDD,QAAQ,CACL,CACP;CACF;AAED,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":["../../../../../../../client/components/react-dev-overlay/internal/components/Dialog/index.ts"],"names":["Dialog","DialogBody","DialogContent","DialogHeader","styles"],"mappings":"AAAA,SAASA,MAAM,QAAQ,UAAU,CAAA;AACjC,SAASC,UAAU,QAAQ,cAAc,CAAA;AACzC,SAASC,aAAa,QAAQ,iBAAiB,CAAA;AAC/C,SAASC,YAAY,QAAQ,gBAAgB,CAAA;AAC7C,SAASC,MAAM,QAAQ,UAAU,CAAA"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../client/components/react-dev-overlay/internal/components/Dialog/styles.ts"],"names":["noop","css","styles"],"mappings":"AAAA,SAASA,IAAI,IAAIC,GAAG,QAAQ,6BAA6B,CAAA;AAEzD,MAAMC,MAAM,GAAGD,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFnB,CAAC;AAED,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,134 @@
import * as React from 'react';
import { CloseIcon } from '../../icons/CloseIcon';
const LeftRightDialogHeader = function LeftRightDialogHeader({ children , className , previous , next , close , }) {
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("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("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":["../../../../../../../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","path","stroke","strokeWidth","strokeLinecap","strokeLinejoin","data-nextjs-errors-dialog-left-right-close-button","aria-label","span","aria-hidden"],"mappings":"AAAA,YAAYA,KAAK,MAAM,OAAO,CAAA;AAC9B,SAASC,SAAS,QAAQ,uBAAuB,CAAA;AASjD,MAAMC,qBAAqB,GACzB,SAASA,qBAAqB,CAAC,EAC7BC,QAAQ,CAAA,EACRC,SAAS,CAAA,EACTC,QAAQ,CAAA,EACRC,IAAI,CAAA,EACJC,KAAK,CAAA,IACN,EAAE;IACD,MAAMC,UAAU,GAAGR,KAAK,CAACS,MAAM,CAA2B,IAAI,CAAC;IAC/D,MAAMC,WAAW,GAAGV,KAAK,CAACS,MAAM,CAA2B,IAAI,CAAC;IAChE,MAAME,WAAW,GAAGX,KAAK,CAACS,MAAM,CAA2B,IAAI,CAAC;IAEhE,MAAM,CAACG,GAAG,EAAEC,MAAM,CAAC,GAAGb,KAAK,CAACc,QAAQ,CAAqB,IAAI,CAAC;IAC9D,MAAMC,KAAK,GAAGf,KAAK,CAACgB,WAAW,C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M;qBACtB,oBAACzD,SAAS,OAAG,CACR,CACA,GACP,IAAI,CACJ,CACP;CACF;AAEH,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":["../../../../../../../client/components/react-dev-overlay/internal/components/LeftRightDialogHeader/index.ts"],"names":["LeftRightDialogHeader","styles"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,yBAAyB,CAAA;AAC/D,SAASC,MAAM,QAAQ,UAAU,CAAA"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../client/components/react-dev-overlay/internal/components/LeftRightDialogHeader/styles.ts"],"names":["noop","css","styles"],"mappings":"AAAA,SAASA,IAAI,IAAIC,GAAG,QAAQ,6BAA6B,CAAA;AAEzD,MAAMC,MAAM,GAAGD,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDnB,CAAC;AAED,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,40 @@
// @ts-ignore
import allyTrap from './maintain--tab-focus';
import * as React from 'react';
import { lock, unlock } from './body-locker';
const Overlay = function Overlay({ className , children , fixed , }) {
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":["../../../../../../../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,QAAQ,MAAM,uBAAuB,CAAA;AAC5C,YAAYC,KAAK,MAAM,OAAO,CAAA;AAC9B,SAASC,IAAI,EAAEC,MAAM,QAAQ,eAAe,CAAA;AAI5C,MAAMC,OAAO,GAA2B,SAASA,OAAO,CAAC,EACvDC,SAAS,CAAA,EACTC,QAAQ,CAAA,EACRC,KAAK,CAAA,IACN,EAAE;IACDN,KAAK,CAACO,SAAS,CAAC,IAAM;QACpBN,IAAI,EAAE;QACN,OAAO,IAAM;YACXC,MAAM,EAAE;SACT,CAAA;KACF,EAAE,EAAE,CAAC;IAEN,MAAM,CAACM,OAAO,EAAEC,UAAU,CAAC,GAAGT,KAAK,CAACU,QAAQ,CAAwB,IAAI,CAAC;IACzE,MAAMC,SAAS,GAAGX,KAAK,CAACY,WAAW,CAAC,CAACC,EAAkB,GAAK;QAC1DJ,UAAU,CAACI,EAAE,CAAC;KACf,EAAE,EAAE,CAAC;IAENb,KAAK,CAACO,SAAS,CAAC,IAAM;QACpB,IAAIC,OAAO,IAAI,IAAI,EAAE;YACnB,OAAM;SACP;QAED,MAAMM,OAAO,GAAGf,QAAQ,CAAC;YAAEgB,OAAO,EAAEP,OAAO;SAAE,CAAC;QAC9C,OAAO,IAAM;YACXM,OAAO,CAACE,SAAS,EAAE;SACpB,CAAA;KACF,EAAE;QAACR,OAAO;KAAC,CAAC;IAEb,qBACE,oBAACS,KAAG;QAACC,4BAA0B,EAA1BA,IAA0B;QAACd,SAAS,EAAEA,SAAS;QAAEe,GAAG,EAAER,SAAS;qBAClE,oBAACM,KAAG;QACFG,6BAA2B,EAA3BA,IAA2B;QAC3BC,mCAAiC,EAAEf,KAAK,GAAG,IAAI,GAAGgB,SAAS;MAC3D,EACDjB,QAAQ,CACL,CACP;CACF;AAED,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":["../../../../../../../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,wBAAwB,AAAoB;AAChD,IAAIC,2BAA2B,AAAoB;AAEnD,IAAIC,WAAW,GAAG,CAAC;AAEnB,OAAO,SAASC,IAAI,GAAG;IACrBC,UAAU,CAAC,IAAM;QACf,IAAIF,WAAW,EAAE,GAAG,CAAC,EAAE;YACrB,OAAM;SACP;QAED,MAAMG,YAAY,GAChBC,MAAM,CAACC,UAAU,GAAGC,QAAQ,CAACC,eAAe,CAACC,WAAW;QAE1D,IAAIL,YAAY,GAAG,CAAC,EAAE;YACpBL,wBAAwB,GAAGQ,QAAQ,CAACG,IAAI,CAACC,KAAK,CAACC,YAAY;YAC3DL,QAAQ,CAACG,IAAI,CAACC,KAAK,CAACC,YAAY,GAAG,CAAC,EAAER,YAAY,CAAC,EAAE,CAAC;SACvD;QAEDJ,2BAA2B,GAAGO,QAAQ,CAACG,IAAI,CAACC,KAAK,CAACE,QAAQ;QAC1DN,QAAQ,CAACG,IAAI,CAACC,KAAK,CAACE,QAAQ,GAAG,QAAQ;KACxC,CAAC;CACH;AAED,OAAO,SAASC,MAAM,GAAG;IACvBX,UAAU,CAAC,IAAM;QACf,IAAIF,WAAW,KAAK,CAAC,IAAI,EAAEA,WAAW,KAAK,CAAC,EAAE;YAC5C,OAAM;SACP;QAED,IAAIF,wBAAwB,KAAKgB,SAAS,EAAE;YAC1CR,QAAQ,CAACG,IAAI,CAACC,KAAK,CAACC,YAAY,GAAGb,wBAAwB;YAC3DA,wBAAwB,GAAGgB,SAAS;SACrC;QAED,IAAIf,2BAA2B,KAAKe,SAAS,EAAE;YAC7CR,QAAQ,CAACG,IAAI,CAACC,KAAK,CAACE,QAAQ,GAAGb,2BAA2B;YAC1DA,2BAA2B,GAAGe,SAAS;SACxC;KACF,CAAC;CACH"}

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../client/components/react-dev-overlay/internal/components/Overlay/styles.tsx"],"names":["noop","css","styles"],"mappings":"AAAA,SAASA,IAAI,IAAIC,GAAG,QAAQ,6BAA6B,CAAA;AAEzD,MAAMC,MAAM,GAAGD,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCnB,CAAC;AAED,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,24 @@
import * as React from 'react';
import { createPortal } from 'react-dom';
export function ShadowPortal({ children }) {
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":["../../../../../../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,KAAK,MAAM,OAAO,CAAA;AAC9B,SAASC,YAAY,QAAQ,WAAW,CAAA;AAExC,OAAO,SAASC,YAAY,CAAC,EAAEC,QAAQ,CAAA,EAAiC,EAAE;IACxE,IAAIC,UAAU,GAAGJ,KAAK,CAACK,MAAM,CAAqB,IAAI,CAAC;IACvD,IAAIC,UAAU,GAAGN,KAAK,CAACK,MAAM,CAAoB,IAAI,CAAC;IACtD,IAAI,GAAGE,WAAW,CAAC,GAAGP,KAAK,CAACQ,QAAQ,EAAkB;IAEtDR,KAAK,CAACS,eAAe,CAAC,IAAM;QAC1B,MAAMC,aAAa,GAAGC,QAAQ;QAC9BP,UAAU,CAACQ,OAAO,GAAGF,aAAa,CAACG,aAAa,CAAC,eAAe,CAAC;QACjEP,UAAU,CAACM,OAAO,GAAGR,UAAU,CAACQ,OAAO,CAACE,YAAY,CAAC;YAAEC,IAAI,EAAE,MAAM;SAAE,CAAC;QACtEL,aAAa,CAACM,IAAI,CAACC,WAAW,CAACb,UAAU,CAACQ,OAAO,CAAC;QAClDL,WAAW,CAAC,EAAE,CAAC;QACf,OAAO,IAAM;YACX,IAAIH,UAAU,CAACQ,OAAO,IAAIR,UAAU,CAACQ,OAAO,CAACF,aAAa,EAAE;gBAC1DN,UAAU,CAACQ,OAAO,CAACF,aAAa,CAACM,IAAI,CAACE,WAAW,CAACd,UAAU,CAACQ,OAAO,CAAC;aACtE;SACF,CAAA;KACF,EAAE,EAAE,CAAC;IAEN,OAAON,UAAU,CAACM,OAAO,iBACrBX,YAAY,CAACE,QAAQ,EAAEG,UAAU,CAACM,OAAO,CAAQ,GACjD,IAAI,CAAA;CACT"}

View File

@@ -0,0 +1,28 @@
import _extends from "@swc/helpers/src/_extends.mjs";
import Anser from 'next/dist/compiled/anser';
import * as React from 'react';
export const Terminal = function Terminal({ content , }) {
const decoded = React.useMemo(()=>{
return Anser.ansiToJson(content, {
json: true,
use_classes: true,
remove_empty: true
});
}, [
content
]);
return /*#__PURE__*/ React.createElement("div", {
"data-nextjs-terminal": true
}, /*#__PURE__*/ React.createElement("pre", null, decoded.map((entry, index)=>/*#__PURE__*/ React.createElement("span", {
key: `terminal-entry-${index}`,
style: _extends({
color: entry.fg ? `var(--color-${entry.fg})` : undefined
}, entry.decoration === 'bold' ? {
fontWeight: 800
} : entry.decoration === 'italic' ? {
fontStyle: 'italic'
} : undefined)
}, entry.content))));
};
//# sourceMappingURL=Terminal.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../client/components/react-dev-overlay/internal/components/Terminal/Terminal.tsx"],"names":["Anser","React","Terminal","content","decoded","useMemo","ansiToJson","json","use_classes","remove_empty","div","data-nextjs-terminal","pre","map","entry","index","span","key","style","color","fg","undefined","decoration","fontWeight","fontStyle"],"mappings":"AAAA;AAAA,OAAOA,KAAK,MAAM,0BAA0B,CAAA;AAC5C,YAAYC,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,MAAMC,QAAQ,GAA4B,SAASA,QAAQ,CAAC,EACjEC,OAAO,CAAA,IACR,EAAE;IACD,MAAMC,OAAO,GAAGH,KAAK,CAACI,OAAO,CAAC,IAAM;QAClC,OAAOL,KAAK,CAACM,UAAU,CAACH,OAAO,EAAE;YAC/BI,IAAI,EAAE,IAAI;YACVC,WAAW,EAAE,IAAI;YACjBC,YAAY,EAAE,IAAI;SACnB,CAAC,CAAA;KACH,EAAE;QAACN,OAAO;KAAC,CAAC;IAEb,qBACE,oBAACO,KAAG;QAACC,sBAAoB,EAApBA,IAAoB;qBACvB,oBAACC,KAAG,QACDR,OAAO,CAACS,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,iBACxB,oBAACC,MAAI;YACHC,GAAG,EAAE,CAAC,eAAe,EAAEF,KAAK,CAAC,CAAC;YAC9BG,KAAK,EAAE;gBACLC,KAAK,EAAEL,KAAK,CAACM,EAAE,GAAG,CAAC,YAAY,EAAEN,KAAK,CAACM,EAAE,CAAC,CAAC,CAAC,GAAGC,SAAS;eACpDP,KAAK,CAACQ,UAAU,KAAK,MAAM,GAC3B;gBAAEC,UAAU,EAAE,GAAG;aAAE,GACnBT,KAAK,CAACQ,UAAU,KAAK,QAAQ,GAC7B;gBAAEE,SAAS,EAAE,QAAQ;aAAE,GACvBH,SAAS,CACd;WAEAP,KAAK,CAACX,OAAO,CACT,AACR,CAAC,CACE,CACF,CACP;CACF,CAAA"}

View File

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

View File

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

View File

@@ -0,0 +1,30 @@
import { noop as css } from '../../helpers/noop-template';
const styles = css`
[data-nextjs-terminal] {
border-radius: var(--size-gap-half);
background-color: var(--color-ansi-bg);
color: var(--color-ansi-fg);
}
[data-nextjs-terminal]::selection,
[data-nextjs-terminal] *::selection {
background-color: var(--color-ansi-selection);
}
[data-nextjs-terminal] * {
color: inherit;
background-color: transparent;
font-family: var(--font-stack-monospace);
}
[data-nextjs-terminal] > * {
margin: 0;
padding: calc(var(--size-gap) + var(--size-gap-half))
calc(var(--size-gap-double) + var(--size-gap-half));
}
[data-nextjs-terminal] pre {
white-space: pre-wrap;
word-break: break-word;
}
`;
export { styles };
//# sourceMappingURL=styles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../client/components/react-dev-overlay/internal/components/Terminal/styles.tsx"],"names":["noop","css","styles"],"mappings":"AAAA,SAASA,IAAI,IAAIC,GAAG,QAAQ,6BAA6B,CAAA;AAEzD,MAAMC,MAAM,GAAGD,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBnB,CAAC;AAED,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,12 @@
import * as React from 'react';
export const Toast = function Toast({ onClick , children , className , }) {
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":["../../../../../../../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,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,MAAMC,KAAK,GAAyB,SAASA,KAAK,CAAC,EACxDC,OAAO,CAAA,EACPC,QAAQ,CAAA,EACRC,SAAS,CAAA,IACV,EAAE;IACD,qBACE,oBAACC,KAAG;QAACC,mBAAiB,EAAjBA,IAAiB;QAACJ,OAAO,EAAEA,OAAO;QAAEE,SAAS,EAAEA,SAAS;qBAC3D,oBAACC,KAAG;QAACE,2BAAyB,EAAzBA,IAAyB;OAAEJ,QAAQ,CAAO,CAC3C,CACP;CACF,CAAA"}

View File

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

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../client/components/react-dev-overlay/internal/components/Toast/index.tsx"],"names":["styles","Toast"],"mappings":"AAAA,SAASA,MAAM,QAAQ,UAAU,CAAA;AACjC,SAASC,KAAK,QAAQ,SAAS,CAAA"}

View File

@@ -0,0 +1,30 @@
import { noop as css } from '../../helpers/noop-template';
const styles = css`
[data-nextjs-toast] {
position: fixed;
bottom: var(--size-gap-double);
left: var(--size-gap-double);
max-width: 420px;
z-index: 9000;
}
@media (max-width: 440px) {
[data-nextjs-toast] {
max-width: 90vw;
left: 5vw;
}
}
[data-nextjs-toast-wrapper] {
padding: 16px;
border-radius: var(--size-gap-half);
font-weight: 500;
color: var(--color-ansi-bright-white);
background-color: var(--color-ansi-red);
box-shadow: 0px var(--size-gap-double) var(--size-gap-quad)
rgba(0, 0, 0, 0.25);
}
`;
export { styles };
//# sourceMappingURL=styles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../../client/components/react-dev-overlay/internal/components/Toast/styles.ts"],"names":["noop","css","styles"],"mappings":"AAAA,SAASA,IAAI,IAAIC,GAAG,QAAQ,6BAA6B,CAAA;AAEzD,MAAMC,MAAM,GAAGD,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;AAyBnB,CAAC;AAED,SAASC,MAAM,GAAE"}

View File

@@ -0,0 +1,46 @@
import * as React from 'react';
import { Dialog, DialogBody, DialogContent, DialogHeader } from '../components/Dialog';
import { Overlay } from '../components/Overlay';
import { Terminal } from '../components/Terminal';
import { noop as css } from '../helpers/noop-template';
export const BuildError = function BuildError({ message , }) {
const noop = React.useCallback(()=>{}, []);
return /*#__PURE__*/ React.createElement(Overlay, {
fixed: true
}, /*#__PURE__*/ React.createElement(Dialog, {
type: "error",
"aria-labelledby": "nextjs__container_build_error_label",
"aria-describedby": "nextjs__container_build_error_desc",
onClose: noop
}, /*#__PURE__*/ React.createElement(DialogContent, null, /*#__PURE__*/ React.createElement(DialogHeader, {
className: "nextjs-container-build-error-header"
}, /*#__PURE__*/ React.createElement("h4", {
id: "nextjs__container_build_error_label"
}, "Failed to compile")), /*#__PURE__*/ React.createElement(DialogBody, {
className: "nextjs-container-build-error-body"
}, /*#__PURE__*/ React.createElement(Terminal, {
content: message
}), /*#__PURE__*/ React.createElement("footer", null, /*#__PURE__*/ React.createElement("p", {
id: "nextjs__container_build_error_desc"
}, /*#__PURE__*/ React.createElement("small", null, "This error occurred during the build process and can only be dismissed by fixing the error.")))))));
};
export const styles = css`
.nextjs-container-build-error-header > h4 {
line-height: 1.5;
margin: 0;
padding: 0;
}
.nextjs-container-build-error-body footer {
margin-top: var(--size-gap);
}
.nextjs-container-build-error-body footer p {
margin: 0;
}
.nextjs-container-build-error-body small {
color: #757575;
}
`;
//# sourceMappingURL=BuildError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../client/components/react-dev-overlay/internal/container/BuildError.tsx"],"names":["React","Dialog","DialogBody","DialogContent","DialogHeader","Overlay","Terminal","noop","css","BuildError","message","useCallback","fixed","type","aria-labelledby","aria-describedby","onClose","className","h4","id","content","footer","p","small","styles"],"mappings":"AAAA,YAAYA,KAAK,MAAM,OAAO,CAAA;AAC9B,SACEC,MAAM,EACNC,UAAU,EACVC,aAAa,EACbC,YAAY,QACP,sBAAsB,CAAA;AAC7B,SAASC,OAAO,QAAQ,uBAAuB,CAAA;AAC/C,SAASC,QAAQ,QAAQ,wBAAwB,CAAA;AACjD,SAASC,IAAI,IAAIC,GAAG,QAAQ,0BAA0B,CAAA;AAItD,OAAO,MAAMC,UAAU,GAA8B,SAASA,UAAU,CAAC,EACvEC,OAAO,CAAA,IACR,EAAE;IACD,MAAMH,IAAI,GAAGP,KAAK,CAACW,WAAW,CAAC,IAAM,EAAE,EAAE,EAAE,CAAC;IAC5C,qBACE,oBAACN,OAAO;QAACO,KAAK,EAALA,IAAK;qBACZ,oBAACX,MAAM;QACLY,IAAI,EAAC,OAAO;QACZC,iBAAe,EAAC,qCAAqC;QACrDC,kBAAgB,EAAC,oCAAoC;QACrDC,OAAO,EAAET,IAAI;qBAEb,oBAACJ,aAAa,sBACZ,oBAACC,YAAY;QAACa,SAAS,EAAC,qCAAqC;qBAC3D,oBAACC,IAAE;QAACC,EAAE,EAAC,qCAAqC;OAAC,mBAAiB,CAAK,CACtD,gBACf,oBAACjB,UAAU;QAACe,SAAS,EAAC,mCAAmC;qBACvD,oBAACX,QAAQ;QAACc,OAAO,EAAEV,OAAO;MAAI,gBAC9B,oBAACW,QAAM,sBACL,oBAACC,GAAC;QAACH,EAAE,EAAC,oCAAoC;qBACxC,oBAACI,OAAK,QAAC,6FAGP,CAAQ,CACN,CACG,CACE,CACC,CACT,CACD,CACX;CACF,CAAA;AAED,OAAO,MAAMC,MAAM,GAAGhB,GAAG,CAAC;;;;;;;;;;;;;;;;;AAiB1B,CAAC,CAAA"}

View File

@@ -0,0 +1,297 @@
import _extends from "@swc/helpers/src/_extends.mjs";
import * as React from 'react';
import { ACTION_UNHANDLED_ERROR, ACTION_UNHANDLED_REJECTION } from '../error-overlay-reducer';
import { Dialog, DialogBody, DialogContent, DialogHeader } from '../components/Dialog';
import { LeftRightDialogHeader } from '../components/LeftRightDialogHeader';
import { Overlay } from '../components/Overlay';
import { Toast } from '../components/Toast';
import { getErrorByType } from '../helpers/getErrorByType';
import { getErrorSource } from '../helpers/nodeStackFrames';
import { noop as css } from '../helpers/noop-template';
import { CloseIcon } from '../icons/CloseIcon';
import { RuntimeError } from './RuntimeError';
function getErrorSignature(ev) {
const { event } = ev;
switch(event.type){
case ACTION_UNHANDLED_ERROR:
case ACTION_UNHANDLED_REJECTION:
{
return `${event.reason.name}::${event.reason.message}::${event.reason.stack}`;
}
default:
{}
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _ = event;
return '';
}
const HotlinkedText = function HotlinkedText(props) {
const { text } = props;
const linkRegex = /https?:\/\/[^\s/$.?#].[^\s"]*/i;
return /*#__PURE__*/ React.createElement(React.Fragment, null, linkRegex.test(text) ? text.split(' ').map((word, index, array)=>{
if (linkRegex.test(word)) {
return /*#__PURE__*/ React.createElement(React.Fragment, {
key: `link-${index}`
}, /*#__PURE__*/ React.createElement("a", {
href: word
}, word), index === array.length - 1 ? '' : ' ');
}
return index === array.length - 1 ? /*#__PURE__*/ React.createElement(React.Fragment, {
key: `text-${index}`
}, word) : /*#__PURE__*/ React.createElement(React.Fragment, {
key: `text-${index}`
}, word, " ");
}) : text);
};
export const Errors = function Errors({ errors , initialDisplayState , }) {
const [lookups, setLookups] = React.useState({});
const [readyErrors, nextError] = React.useMemo(()=>{
let ready = [];
let next = null;
// Ensure errors are displayed in the order they occurred in:
for(let idx = 0; idx < errors.length; ++idx){
const e = errors[idx];
const { id } = e;
if (id in lookups) {
ready.push(lookups[id]);
continue;
}
// Check for duplicate errors
if (idx > 0) {
const prev = errors[idx - 1];
if (getErrorSignature(prev) === getErrorSignature(e)) {
continue;
}
}
next = e;
break;
}
return [
ready,
next
];
}, [
errors,
lookups
]);
const isLoading = React.useMemo(()=>{
return readyErrors.length < 1 && Boolean(errors.length);
}, [
errors.length,
readyErrors.length
]);
React.useEffect(()=>{
if (nextError == null) {
return;
}
let mounted = true;
getErrorByType(nextError).then((resolved)=>{
// We don't care if the desired error changed while we were resolving,
// thus we're not tracking it using a ref. Once the work has been done,
// we'll store it.
if (mounted) {
setLookups((m)=>_extends({}, m, {
[resolved.id]: resolved
}));
}
}, ()=>{
// TODO: handle this, though an edge case
});
return ()=>{
mounted = false;
};
}, [
nextError
]);
const [displayState, setDisplayState] = React.useState(initialDisplayState);
const [activeIdx, setActiveIndex] = React.useState(0);
const previous = React.useCallback((e)=>{
e == null ? void 0 : e.preventDefault();
setActiveIndex((v)=>Math.max(0, v - 1));
}, []);
const next1 = React.useCallback((e)=>{
e == null ? void 0 : e.preventDefault();
setActiveIndex((v)=>Math.max(0, Math.min(readyErrors.length - 1, v + 1)));
}, [
readyErrors.length
]);
var _activeIdx;
const activeError = React.useMemo(()=>(_activeIdx = readyErrors[activeIdx]) != null ? _activeIdx : null, [
activeIdx,
readyErrors
]);
// Reset component state when there are no errors to be displayed.
// This should never happen, but lets handle it.
React.useEffect(()=>{
if (errors.length < 1) {
setLookups({});
setDisplayState('hidden');
setActiveIndex(0);
}
}, [
errors.length
]);
const minimize = React.useCallback((e)=>{
e == null ? void 0 : e.preventDefault();
setDisplayState('minimized');
}, []);
const hide = React.useCallback((e)=>{
e == null ? void 0 : e.preventDefault();
setDisplayState('hidden');
}, []);
const fullscreen = React.useCallback((e)=>{
e == null ? void 0 : e.preventDefault();
setDisplayState('fullscreen');
}, []);
// This component shouldn't be rendered with no errors, but if it is, let's
// handle it gracefully by rendering nothing.
if (errors.length < 1 || activeError == null) {
return null;
}
if (isLoading) {
// TODO: better loading state
return /*#__PURE__*/ React.createElement(Overlay, null);
}
if (displayState === 'hidden') {
return null;
}
if (displayState === 'minimized') {
return /*#__PURE__*/ React.createElement(Toast, {
className: "nextjs-toast-errors-parent",
onClick: fullscreen
}, /*#__PURE__*/ React.createElement("div", {
className: "nextjs-toast-errors"
}, /*#__PURE__*/ React.createElement("svg", {
xmlns: "http://www.w3.org/2000/svg",
width: "24",
height: "24",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
strokeWidth: "2",
strokeLinecap: "round",
strokeLinejoin: "round"
}, /*#__PURE__*/ React.createElement("circle", {
cx: "12",
cy: "12",
r: "10"
}), /*#__PURE__*/ React.createElement("line", {
x1: "12",
y1: "8",
x2: "12",
y2: "12"
}), /*#__PURE__*/ React.createElement("line", {
x1: "12",
y1: "16",
x2: "12.01",
y2: "16"
})), /*#__PURE__*/ React.createElement("span", null, readyErrors.length, " error", readyErrors.length > 1 ? 's' : ''), /*#__PURE__*/ React.createElement("button", {
"data-nextjs-toast-errors-hide-button": true,
className: "nextjs-toast-errors-hide-button",
type: "button",
onClick: (e)=>{
e.stopPropagation();
hide();
},
"aria-label": "Hide Errors"
}, /*#__PURE__*/ React.createElement(CloseIcon, null))));
}
const isServerError = [
'server',
'edge-server'
].includes(getErrorSource(activeError.error) || '');
return /*#__PURE__*/ React.createElement(Overlay, null, /*#__PURE__*/ React.createElement(Dialog, {
type: "error",
"aria-labelledby": "nextjs__container_errors_label",
"aria-describedby": "nextjs__container_errors_desc",
onClose: isServerError ? undefined : minimize
}, /*#__PURE__*/ React.createElement(DialogContent, null, /*#__PURE__*/ React.createElement(DialogHeader, {
className: "nextjs-container-errors-header"
}, /*#__PURE__*/ React.createElement(LeftRightDialogHeader, {
previous: activeIdx > 0 ? previous : null,
next: activeIdx < readyErrors.length - 1 ? next1 : null,
close: isServerError ? undefined : minimize
}, /*#__PURE__*/ React.createElement("small", null, /*#__PURE__*/ React.createElement("span", null, activeIdx + 1), " of", ' ', /*#__PURE__*/ React.createElement("span", null, readyErrors.length), " unhandled error", readyErrors.length < 2 ? '' : 's')), /*#__PURE__*/ React.createElement("h1", {
id: "nextjs__container_errors_label"
}, isServerError ? 'Server Error' : 'Unhandled Runtime Error'), /*#__PURE__*/ React.createElement("p", {
id: "nextjs__container_errors_desc"
}, activeError.error.name, ":", ' ', /*#__PURE__*/ React.createElement(HotlinkedText, {
text: activeError.error.message
})), isServerError ? /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement("small", null, "This error happened while generating the page. Any console logs will be displayed in the terminal window.")) : undefined), /*#__PURE__*/ React.createElement(DialogBody, {
className: "nextjs-container-errors-body"
}, /*#__PURE__*/ React.createElement(RuntimeError, {
key: activeError.id.toString(),
error: activeError
})))));
};
export const styles = css`
.nextjs-container-errors-header > h1 {
font-size: var(--size-font-big);
line-height: var(--size-font-bigger);
font-weight: bold;
margin: 0;
margin-top: calc(var(--size-gap-double) + var(--size-gap-half));
}
.nextjs-container-errors-header small {
font-size: var(--size-font-small);
color: var(--color-accents-1);
margin-left: var(--size-gap-double);
}
.nextjs-container-errors-header small > span {
font-family: var(--font-stack-monospace);
}
.nextjs-container-errors-header > p {
font-family: var(--font-stack-monospace);
font-size: var(--size-font-small);
line-height: var(--size-font-big);
font-weight: bold;
margin: 0;
margin-top: var(--size-gap-half);
color: var(--color-ansi-red);
white-space: pre-wrap;
}
.nextjs-container-errors-header > div > small {
margin: 0;
margin-top: var(--size-gap-half);
}
.nextjs-container-errors-header > p > a {
color: var(--color-ansi-red);
}
.nextjs-container-errors-body > h5:not(:first-child) {
margin-top: calc(var(--size-gap-double) + var(--size-gap));
}
.nextjs-container-errors-body > h5 {
margin-bottom: var(--size-gap);
}
.nextjs-toast-errors-parent {
cursor: pointer;
transition: transform 0.2s ease;
}
.nextjs-toast-errors-parent:hover {
transform: scale(1.1);
}
.nextjs-toast-errors {
display: flex;
align-items: center;
justify-content: flex-start;
}
.nextjs-toast-errors > svg {
margin-right: var(--size-gap);
}
.nextjs-toast-errors-hide-button {
margin-left: var(--size-gap-triple);
border: none;
background: none;
color: var(--color-ansi-bright-white);
padding: 0;
transition: opacity 0.25s ease;
opacity: 0.7;
}
.nextjs-toast-errors-hide-button:hover {
opacity: 1;
}
`;
//# sourceMappingURL=Errors.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,47 @@
import React from 'react';
import { Dialog, DialogBody, DialogContent, DialogHeader } from '../components/Dialog';
import { Overlay } from '../components/Overlay';
import { Terminal } from '../components/Terminal';
import { noop as css } from '../helpers/noop-template';
export const RootLayoutError = function BuildError({ missingTags }) {
const message = 'Please make sure to include the following tags in your root layout: <html>, <body>.\n\n' + `Missing required root layout tag${missingTags.length === 1 ? '' : 's'}: ` + missingTags.join(', ');
const noop = React.useCallback(()=>{}, []);
return /*#__PURE__*/ React.createElement(Overlay, {
fixed: true
}, /*#__PURE__*/ React.createElement(Dialog, {
type: "error",
"aria-labelledby": "nextjs__container_root_layout_error_label",
"aria-describedby": "nextjs__container_root_layout_error_desc",
onClose: noop
}, /*#__PURE__*/ React.createElement(DialogContent, null, /*#__PURE__*/ React.createElement(DialogHeader, {
className: "nextjs-container-root-layout-error-header"
}, /*#__PURE__*/ React.createElement("h4", {
id: "nextjs__container_root_layout_error_label"
}, "Missing required tags")), /*#__PURE__*/ React.createElement(DialogBody, {
className: "nextjs-container-root-layout-error-body"
}, /*#__PURE__*/ React.createElement(Terminal, {
content: message
}), /*#__PURE__*/ React.createElement("footer", null, /*#__PURE__*/ React.createElement("p", {
id: "nextjs__container_root_layout_error_desc"
}, /*#__PURE__*/ React.createElement("small", null, "This error and can only be dismissed by providing all required tags.")))))));
};
export const styles = css`
.nextjs-container-root-layout-error-header > h4 {
line-height: 1.5;
margin: 0;
padding: 0;
}
.nextjs-container-root-layout-error-body footer {
margin-top: var(--size-gap);
}
.nextjs-container-root-layout-error-body footer p {
margin: 0;
}
.nextjs-container-root-layout-error-body small {
color: #757575;
}
`;
//# sourceMappingURL=RootLayoutError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../../client/components/react-dev-overlay/internal/container/RootLayoutError.tsx"],"names":["React","Dialog","DialogBody","DialogContent","DialogHeader","Overlay","Terminal","noop","css","RootLayoutError","BuildError","missingTags","message","length","join","useCallback","fixed","type","aria-labelledby","aria-describedby","onClose","className","h4","id","content","footer","p","small","styles"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO,CAAA;AACzB,SACEC,MAAM,EACNC,UAAU,EACVC,aAAa,EACbC,YAAY,QACP,sBAAsB,CAAA;AAC7B,SAASC,OAAO,QAAQ,uBAAuB,CAAA;AAC/C,SAASC,QAAQ,QAAQ,wBAAwB,CAAA;AACjD,SAASC,IAAI,IAAIC,GAAG,QAAQ,0BAA0B,CAAA;AAItD,OAAO,MAAMC,eAAe,GAC1B,SAASC,UAAU,CAAC,EAAEC,WAAW,CAAA,EAAE,EAAE;IACnC,MAAMC,OAAO,GACX,yFAAyF,GACzF,CAAC,gCAAgC,EAC/BD,WAAW,CAACE,MAAM,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,CACpC,EAAE,CAAC,GACJF,WAAW,CAACG,IAAI,CAAC,IAAI,CAAC;IAExB,MAAMP,IAAI,GAAGP,KAAK,CAACe,WAAW,CAAC,IAAM,EAAE,EAAE,EAAE,CAAC;IAC5C,qBACE,oBAACV,OAAO;QAACW,KAAK,EAALA,IAAK;qBACZ,oBAACf,MAAM;QACLgB,IAAI,EAAC,OAAO;QACZC,iBAAe,EAAC,2CAA2C;QAC3DC,kBAAgB,EAAC,0CAA0C;QAC3DC,OAAO,EAAEb,IAAI;qBAEb,oBAACJ,aAAa,sBACZ,oBAACC,YAAY;QAACiB,SAAS,EAAC,2CAA2C;qBACjE,oBAACC,IAAE;QAACC,EAAE,EAAC,2CAA2C;OAAC,uBAEnD,CAAK,CACQ,gBACf,oBAACrB,UAAU;QAACmB,SAAS,EAAC,yCAAyC;qBAC7D,oBAACf,QAAQ;QAACkB,OAAO,EAAEZ,OAAO;MAAI,gBAC9B,oBAACa,QAAM,sBACL,oBAACC,GAAC;QAACH,EAAE,EAAC,0CAA0C;qBAC9C,oBAACI,OAAK,QAAC,sEAGP,CAAQ,CACN,CACG,CACE,CACC,CACT,CACD,CACX;CACF,CAAA;AAEH,OAAO,MAAMC,MAAM,GAAGpB,GAAG,CAAC;;;;;;;;;;;;;;;;;AAiB1B,CAAC,CAAA"}

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