Unverified Commit 81b554f3 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Rename todos (#38560)

Renames todos to split them / make it easier to find what has to be done for the new router.


## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
parent 62eb16b6
......@@ -510,7 +510,7 @@ export function finalizeEntrypoint({
name !== CLIENT_STATIC_FILES_RUNTIME_AMP &&
name !== CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH
) {
// TODO: this is a temporary fix. @shuding is going to change the handling of server components
// TODO-APP: this is a temporary fix. @shuding is going to change the handling of server components
if (appDir && entry.import.includes('flight')) {
return {
dependOn: CLIENT_STATIC_FILES_RUNTIME_MAIN_ROOT,
......
import { hydrate, version } from './app-index'
// TODO: implement FOUC guard
// TODO-APP: implement FOUC guard
// TODO: hydration warning
// TODO-APP: hydration warning
window.next = {
version,
......@@ -11,4 +11,4 @@ window.next = {
hydrate()
// TODO: build indicator
// TODO-APP: build indicator
......@@ -49,7 +49,7 @@ function ErrorOverlay({
}
}
// TODO: move this back into AppRouter
// TODO-APP: move this back into AppRouter
let initialParallelRoutes: CacheNode['parallelRoutes'] =
typeof window === 'undefined' ? null! : new Map()
......@@ -136,7 +136,7 @@ export default function AppRouter({
}
const routerInstance: AppRouterInstance = {
// TODO: implement prefetching of loading / flight
// TODO-APP: implement prefetching of loading / flight
prefetch: (_href) => Promise.resolve(),
replace: (href) => {
// @ts-ignore startTransition exists
......@@ -168,7 +168,7 @@ export default function AppRouter({
dispatch({
type: 'reload',
payload: {
// TODO: revisit if this needs to be passed.
// TODO-APP: revisit if this needs to be passed.
url: new URL(window.location.href),
cache: {
data: null,
......@@ -211,11 +211,11 @@ export default function AppRouter({
const onPopState = React.useCallback(({ state }: PopStateEvent) => {
if (!state) {
// TODO: this case only happens when pushState/replaceState was called outside of Next.js. It should probably reload the page in this case.
// 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
}
// TODO: this case happens when pushState/replaceState was called outside of Next.js or when the history entry was pushed by the old router.
// TODO-APP: this case happens when pushState/replaceState was called outside of Next.js or when the history entry was pushed by the old router.
// It reloads the page in this case but we might have to revisit this as the old router ignores it.
if (!state.__NA) {
window.location.reload()
......@@ -223,7 +223,7 @@ export default function AppRouter({
}
// @ts-ignore useTransition exists
// TODO: Ideally the back button should not use startTransition as it should apply the updates synchronously
// 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({
......
......@@ -21,12 +21,12 @@ export function useSearchParam(key: string) {
return params[key]
}
// TODO: Move the other router context over to this one
// TODO-APP: Move the other router context over to this one
export function useRouter() {
return useContext(AppRouterContext)
}
// TODO: 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.
// 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)
// }
......@@ -35,7 +35,7 @@ export function usePathname() {
return useContext(PathnameContext)
}
// TODO: define what should be provided through context.
// TODO-APP: define what should be provided through context.
// export function useLayoutSegments() {
// return useContext(LayoutSegmentsContext)
// }
......
......@@ -3,7 +3,7 @@ import {
useContext,
useEffect,
useRef,
// @ts-expect-error TODO: startTransition exists
// @ts-expect-error TODO-APP: startTransition exists
startTransition,
} from 'react'
import { FullAppTreeContext } from '../../shared/lib/app-router-context'
......@@ -31,7 +31,7 @@ function getSocketProtocol(assetPrefix: string): string {
// const TIMEOUT = 5000
// TODO: add actual type
// TODO-APP: add actual type
type PongEvent = any
let mostRecentCompilationHash: any = null
......@@ -305,7 +305,7 @@ function processMessage(
}
return
}
// TODO: make server component change more granular
// TODO-APP: make server component change more granular
case 'serverComponentChanges': {
sendMessage(
JSON.stringify({
......@@ -375,7 +375,7 @@ function processMessage(
// Page exists now, reload
location.reload()
} else {
// TODO: fix this
// TODO-APP: fix this
// Page doesn't exist
// if (
// self.__NEXT_DATA__.page === Router.pathname &&
......@@ -442,12 +442,12 @@ export default function HotReload({ assetPrefix }: { assetPrefix: string }) {
}, [assetPrefix])
useEffect(() => {
// Taken from on-demand-entries-client.js
// TODO: check 404 case
// TODO-APP: check 404 case
const interval = setInterval(() => {
sendMessage(
JSON.stringify({
event: 'ping',
// TODO: fix case for dynamic parameters, this will be resolved wrong currently.
// TODO-APP: fix case for dynamic parameters, this will be resolved wrong currently.
tree,
appDirRoute: true,
})
......@@ -459,7 +459,7 @@ export default function HotReload({ assetPrefix }: { assetPrefix: string }) {
const handler = (event: MessageEvent<PongEvent>) => {
if (
event.data.indexOf('action') === -1 &&
// TODO: clean this up for consistency
// TODO-APP: clean this up for consistency
event.data.indexOf('pong') === -1
) {
return
......
......@@ -123,7 +123,7 @@ export function InnerLayoutRouter({
return treeToRecreate
}
// TODO: remove ''
// TODO-APP: remove ''
const refetchTree = walkAddRefetch(['', ...segmentPath], fullTree)
const data = fetchServerResponse(new URL(url, location.origin), refetchTree)
......@@ -148,7 +148,7 @@ export function InnerLayoutRouter({
}
if (childNode.data) {
// TODO: error case
// TODO-APP: error case
const flightData = childNode.data.readRoot()
// Handle case when navigating to page in `pages` from `app`
......@@ -165,7 +165,7 @@ export function InnerLayoutRouter({
if (pathMatches(flightDataPath, segmentPath)) {
childNode.data = null
// Last item is the subtreeData
// TODO: routerTreePatch needs to be applied to the tree, handle it in render?
// TODO-APP: routerTreePatch needs to be applied to the tree, handle it in render?
const [, /* routerTreePatch */ subTreeData] = flightDataPath.slice(-2)
childNode.subTreeData = subTreeData
childNode.parallelRoutes = new Map()
......@@ -182,7 +182,7 @@ export function InnerLayoutRouter({
setTimeout(() => {
// @ts-ignore startTransition exists
React.startTransition(() => {
// TODO: handle redirect
// TODO-APP: handle redirect
changeByServerResponse(fullTree, flightData)
})
})
......@@ -191,7 +191,7 @@ export function InnerLayoutRouter({
}
}
// TODO: double check users can't return null in a component that will kick in here
// TODO-APP: double check users can't return null in a component that will kick in here
if (!childNode.subTreeData) {
throw createInfinitePromise()
}
......@@ -201,7 +201,7 @@ export function InnerLayoutRouter({
value={{
tree: tree[1][parallelRouterKey],
childNodes: childNode.parallelRoutes,
// TODO: overriding of url for parallel routes
// TODO-APP: overriding of url for parallel routes
url: url,
}}
>
......
......@@ -12,7 +12,7 @@ const fillCacheWithNewSubTreeData = (
existingCache: CacheNode,
flightDataPath: FlightDataPath
) => {
// TODO: handle case of / (root of the tree) refetch
// TODO-APP: handle case of / (root of the tree) refetch
const isLastEntry = flightDataPath.length <= 4
const [parallelRouteKey, segment] = flightDataPath
......@@ -224,7 +224,7 @@ const walkTreeWithFlightDataPath = (
const [currentSegment, parallelRouteKey] = flightSegmentPath
// Tree path returned from the server should always match up with the current tree in the browser
// TODO: verify
// TODO-APP: verify
if (!matchSegment(currentSegment, segment)) {
throw new Error('SEGMENT MISMATCH')
}
......@@ -315,7 +315,7 @@ export function reducer(
const href = url.pathname + url.search + url.hash
const segments = pathname.split('/')
// TODO: figure out something better for index pages
// TODO-APP: figure out something better for index pages
segments.push('')
// In case of soft push data fetching happens in layout-router if a segment is missing
......@@ -352,7 +352,7 @@ export function reducer(
}
}
// TODO: flag on the tree of which part of the tree for if there is a loading boundary
// TODO-APP: flag on the tree of which part of the tree for if there is a loading boundary
const isOptimistic = false
if (isOptimistic) {
......@@ -367,7 +367,7 @@ export function reducer(
)
// Fill in the cache with blank that holds the `data` field.
// TODO: segments.slice(1) strips '', we can get rid of '' altogether.
// TODO-APP: segments.slice(1) strips '', we can get rid of '' altogether.
const res = fillCacheWithDataProperty(
cache,
state.cache,
......@@ -406,13 +406,13 @@ export function reducer(
cache.data = null
// TODO: ensure flightDataPath does not have "" as first item
// TODO-APP: ensure flightDataPath does not have "" as first item
const flightDataPath = flightData[0]
const [treePatch] = flightDataPath.slice(-2)
const treePath = flightDataPath.slice(0, -3)
const newTree = walkTreeWithFlightDataPath(
// TODO: remove ''
// TODO-APP: remove ''
['', ...treePath],
state.tree,
treePatch
......@@ -438,7 +438,7 @@ export function reducer(
if (action.type === 'server-patch') {
const { flightData, previousTree, cache } = action.payload
if (JSON.stringify(previousTree) !== JSON.stringify(state.tree)) {
// TODO: Handle tree mismatch
// TODO-APP: Handle tree mismatch
console.log('TREE MISMATCH')
return {
canonicalUrl: state.canonicalUrl,
......@@ -458,7 +458,7 @@ export function reducer(
}
}
// TODO: flightData could hold multiple paths
// TODO-APP: flightData could hold multiple paths
const flightDataPath = flightData[0]
// Slices off the last segment (which is at -3) as it doesn't exist in the tree yet
......@@ -466,7 +466,7 @@ export function reducer(
const [treePatch] = flightDataPath.slice(-2)
const newTree = walkTreeWithFlightDataPath(
// TODO: remove ''
// TODO-APP: remove ''
['', ...treePath],
state.tree,
treePatch
......@@ -526,18 +526,18 @@ export function reducer(
cache.data = null
// TODO: ensure flightDataPath does not have "" as first item
// TODO-APP: ensure flightDataPath does not have "" as first item
const flightDataPath = flightData[0]
if (flightDataPath.length !== 2) {
// TODO: handle this case better
// TODO-APP: handle this case better
console.log('RELOAD FAILED')
return state
}
const [treePatch, subTreeData] = flightDataPath.slice(-2)
const newTree = walkTreeWithFlightDataPath(
// TODO: remove ''
// TODO-APP: remove ''
[''],
state.tree,
treePatch
......
......@@ -46,7 +46,7 @@ type InternalLinkProps = {
onClick?: (e: any) => void
}
// TODO: Include the full set of Anchor props
// TODO-APP: Include the full set of Anchor props
// adding this to the publicly exported type currently breaks existing apps
export type LinkProps = InternalLinkProps
type LinkPropsRequired = RequiredKeys<LinkProps>
......@@ -292,7 +292,7 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkPropsReal>(
: []
let router = React.useContext(RouterContext)
// TODO: type error. Remove `as any`
// TODO-APP: type error. Remove `as any`
const appRouter = React.useContext(AppRouterContext) as any
if (appRouter) {
router = appRouter
......
import React from 'react'
export type LayoutProps = {
children: any
}
export default function AppLayout({ children }: LayoutProps) {
return (
<html>
<head>
{/* TODO: Remove <title> */}
<title>Test</title>
</head>
<body>{children}</body>
</html>
)
}
......@@ -385,9 +385,9 @@ export async function renderToHTML(
)
}
// TODO: verify the tree is valid
// TODO: verify query param is single value (not an array)
// TODO: verify tree can't grow out of control
// TODO-APP: verify the tree is valid
// TODO-APP: verify query param is single value (not an array)
// TODO-APP: verify tree can't grow out of control
const providedFlightRouterState: FlightRouterState = isFlight
? query.__flight_router_state_tree__
? JSON.parse(query.__flight_router_state_tree__ as string)
......@@ -406,7 +406,7 @@ export async function renderToHTML(
| null
const headers = req.headers
// @ts-expect-error TODO: fix type of req
// @ts-expect-error TODO-APP: fix type of req
const cookies = req.cookies
const tree: LoaderTree = ComponentMod.tree
......@@ -421,7 +421,7 @@ export async function renderToHTML(
)
const isPreview = previewData !== false
const serverContexts: Array<[string, any]> = [
['WORKAROUND', null], // TODO: First value has a bug currently where the value is not set on the second request
['WORKAROUND', null], // TODO-APP: First value has a bug currently where the value is not set on the second request
['HeadersContext', headers],
['CookiesContext', cookies],
['PreviewDataContext', previewData],
......@@ -442,7 +442,7 @@ export async function renderToHTML(
treeValue: string
type: DynamicParamTypesShort
} | null => {
// TODO: use correct matching for dynamic routes to get segment param
// TODO-APP: use correct matching for dynamic routes to get segment param
const segmentParam = getSegmentParam(segment)
if (!segmentParam) {
return null
......@@ -517,7 +517,7 @@ export async function renderToHTML(
layoutOrPageMod && !layoutOrPageMod.hasOwnProperty('__next_rsc__')
// Only server components can have getServerSideProps / getStaticProps
// TODO: friendly error with correct stacktrace. Potentially this can be part of the compiler instead.
// TODO-APP: friendly error with correct stacktrace. Potentially this can be part of the compiler instead.
if (isClientComponentModule) {
if (layoutOrPageMod.getServerSideProps) {
throw new Error(
......@@ -602,7 +602,7 @@ export async function renderToHTML(
let fetcher: (() => Promise<any>) | null = null
type GetServerSidePropsContext = {
// TODO: has to be serializable
// TODO-APP: has to be serializable
headers: IncomingHttpHeaders
cookies: NextApiRequestCookies
layoutSegments: FlightSegmentPath
......@@ -616,9 +616,9 @@ export async function renderToHTML(
pathname: string
}
// TODO: pass a shared cache from previous getStaticProps/getServerSideProps calls?
// TODO-APP: pass a shared cache from previous getStaticProps/getServerSideProps calls?
if (layoutOrPageMod.getServerSideProps) {
// TODO: recommendation for i18n
// TODO-APP: recommendation for i18n
// locales: (renderOpts as any).locales, // always the same
// locale: (renderOpts as any).locale, // /nl/something -> nl
// defaultLocale: (renderOpts as any).defaultLocale, // changes based on domain
......@@ -628,7 +628,7 @@ export async function renderToHTML(
headers,
cookies,
layoutSegments: segmentPath,
// TODO: Currently query holds params and pathname is not the actual pathname, it holds the dynamic parameter
// TODO-APP: Currently query holds params and pathname is not the actual pathname, it holds the dynamic parameter
...(isPage ? { query, pathname } : {}),
...(pageIsDynamic ? { params: currentParams } : undefined),
...(isPreview
......@@ -640,11 +640,11 @@ export async function renderToHTML(
layoutOrPageMod.getServerSideProps(getServerSidePropsContext)
)
}
// TODO: implement layout specific caching for getStaticProps
// TODO-APP: implement layout specific caching for getStaticProps
if (layoutOrPageMod.getStaticProps) {
const getStaticPropsContext = {
layoutSegments: segmentPath,
// TODO: change this to be URLSearchParams instead?
// TODO-APP: change this to be URLSearchParams instead?
...(isPage ? { pathname } : {}),
...(pageIsDynamic ? { params: currentParams } : undefined),
...(isPreview
......@@ -686,7 +686,7 @@ export async function renderToHTML(
<Component
{...props}
{...parallelRouteComponents}
// TODO: params and query have to be blocked parallel route names. Might have to add a reserved name list.
// TODO-APP: params and query have to be blocked parallel route names. Might have to add a reserved name list.
// Params are always the current params that apply to the layout
// If you have a `/dashboard/[team]/layout.js` it will provide `team` as a param but not anything further down.
params={currentParams}
......@@ -699,7 +699,7 @@ export async function renderToHTML(
}
if (isFlight) {
// TODO: throw on invalid flightRouterState
// TODO-APP: throw on invalid flightRouterState
const walkTreeWithFlightRouterState = (
treeToFilter: LoaderTree,
parentParams: { [key: string]: string | string[] },
......@@ -770,7 +770,7 @@ export async function renderToHTML(
serverComponentManifest
)
const flightData: FlightData = [
// TODO: change walk to output without ''
// TODO-APP: change walk to output without ''
walkTreeWithFlightRouterState(tree, {}, providedFlightRouterState).slice(
1
),
......@@ -785,10 +785,10 @@ export async function renderToHTML(
const search = stringifyQuery(query)
// TODO: validate req.url as it gets passed to render.
// TODO-APP: validate req.url as it gets passed to render.
const initialCanonicalUrl = req.url!
// TODO: change tree to accommodate this
// TODO-APP: change tree to accommodate this
// /blog/[...slug]/page.js -> /blog/hello-world/b/c/d -> ['children', 'blog', 'children', ['slug', 'hello-world/b/c/d']]
// /blog/[slug] /blog/hello-world -> ['children', 'blog', 'children', ['slug', 'hello-world']]
const initialTree = createFlightRouterStateFromLoaderTree(tree)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment