@openuiai/next 15.6.0-bun.27 → 15.6.0-bun.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/next +1 -1
- package/dist/build/index.js +3 -3
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack/plugins/next-types-plugin/index.js +22 -20
- package/dist/build/webpack/plugins/next-types-plugin/index.js.map +1 -1
- package/dist/build/webpack-config.js +2 -2
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/esm/build/index.js +3 -3
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/webpack/plugins/next-types-plugin/index.js +22 -20
- package/dist/esm/build/webpack/plugins/next-types-plugin/index.js.map +1 -1
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/router-utils/typegen.js +16 -14
- package/dist/esm/server/lib/router-utils/typegen.js.map +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/shared/lib/canary-only.js +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/router-utils/typegen.js +16 -14
- package/dist/server/lib/router-utils/typegen.js.map +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/shared/lib/canary-only.js +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/build/webpack/plugins/next-types-plugin/index.ts"],"sourcesContent":["import type { Rewrite, Redirect } from '../../../../lib/load-custom-routes'\n\nimport fs from 'fs/promises'\nimport { webpack, sources } from 'next/dist/compiled/webpack/webpack'\nimport path from 'path'\n\nimport { WEBPACK_LAYERS } from '../../../../lib/constants'\nimport { denormalizePagePath } from '../../../../shared/lib/page-path/denormalize-page-path'\nimport { ensureLeadingSlash } from '../../../../shared/lib/page-path/ensure-leading-slash'\nimport { normalizePathSep } from '../../../../shared/lib/page-path/normalize-path-sep'\nimport { HTTP_METHODS } from '../../../../server/web/http'\nimport { isDynamicRoute } from '../../../../shared/lib/router/utils'\nimport { normalizeAppPath } from '../../../../shared/lib/router/utils/app-paths'\nimport { getPageFromPath } from '../../../entries'\nimport type { PageExtensions } from '../../../page-extensions-type'\nimport { getProxiedPluginState } from '../../../build-context'\nimport type { CacheLife } from '../../../../server/use-cache/cache-life'\n\nconst PLUGIN_NAME = 'NextTypesPlugin'\n\ntype Rewrites = {\n fallback: Rewrite[]\n afterFiles: Rewrite[]\n beforeFiles: Rewrite[]\n}\n\ninterface Options {\n dir: string\n distDir: string\n appDir: string\n dev: boolean\n isEdgeServer: boolean\n pageExtensions: PageExtensions\n cacheLifeConfig: undefined | { [profile: string]: CacheLife }\n originalRewrites: Rewrites | undefined\n originalRedirects: Redirect[] | undefined\n}\n\nfunction createTypeGuardFile(\n fullPath: string,\n relativePath: string,\n options: {\n type: 'layout' | 'page' | 'route'\n slots?: string[]\n }\n) {\n return `// File: ${fullPath}\nimport * as entry from '${relativePath}.js'\n${\n options.type === 'route'\n ? `import type { NextRequest } from 'next/server.js'`\n : `import type { ResolvingMetadata, ResolvingViewport } from 'next/dist/lib/metadata/types/metadata-interface.js'`\n}\n\ntype TEntry = typeof import('${relativePath}.js')\n\ntype SegmentParams<T extends Object = any> = T extends Record<string, any>\n ? { [K in keyof T]: T[K] extends string ? string | string[] | undefined : never }\n : T\n\n// Check that the entry is a valid entry\ncheckFields<Diff<{\n ${\n options.type === 'route'\n ? HTTP_METHODS.map((method) => `${method}?: Function`).join('\\n ')\n : 'default: Function'\n }\n config?: {}\n generateStaticParams?: Function\n unstable_prefetch?: 'unstable_static' | 'unstable_runtime'\n revalidate?: RevalidateRange<TEntry> | false\n dynamic?: 'auto' | 'force-dynamic' | 'error' | 'force-static'\n dynamicParams?: boolean\n fetchCache?: 'auto' | 'force-no-store' | 'only-no-store' | 'default-no-store' | 'default-cache' | 'only-cache' | 'force-cache'\n preferredRegion?: 'auto' | 'global' | 'home' | string | string[]\n runtime?: 'nodejs' | 'experimental-edge' | 'edge'\n maxDuration?: number\n ${\n options.type === 'route'\n ? ''\n : `\n metadata?: any\n generateMetadata?: Function\n viewport?: any\n generateViewport?: Function\n experimental_ppr?: boolean\n `\n }\n}, TEntry, ''>>()\n\n${options.type === 'route' ? `type RouteContext = { params: Promise<SegmentParams> }` : ''}\n${\n options.type === 'route'\n ? HTTP_METHODS.map(\n (method) => `// Check the prop type of the entry function\nif ('${method}' in entry) {\n checkFields<\n Diff<\n ParamCheck<Request | NextRequest>,\n {\n __tag__: '${method}'\n __param_position__: 'first'\n __param_type__: FirstArg<MaybeField<TEntry, '${method}'>>\n },\n '${method}'\n >\n >()\n checkFields<\n Diff<\n ParamCheck<RouteContext>,\n {\n __tag__: '${method}'\n __param_position__: 'second'\n __param_type__: SecondArg<MaybeField<TEntry, '${method}'>>\n },\n '${method}'\n >\n >()\n ${\n ''\n // Adding void to support never return type without explicit return:\n // e.g. notFound() will interrupt the execution but the handler return type is inferred as void.\n // x-ref: https://github.com/microsoft/TypeScript/issues/16608#issuecomment-309327984\n }\n checkFields<\n Diff<\n {\n __tag__: '${method}',\n __return_type__: Response | void | never | Promise<Response | void | never>\n },\n {\n __tag__: '${method}',\n __return_type__: ReturnType<MaybeField<TEntry, '${method}'>>\n },\n '${method}'\n >\n >()\n}\n`\n ).join('')\n : `// Check the prop type of the entry function\ncheckFields<Diff<${\n options.type === 'page' ? 'PageProps' : 'LayoutProps'\n }, FirstArg<TEntry['default']>, 'default'>>()\n\n// Check the arguments and return type of the generateMetadata function\nif ('generateMetadata' in entry) {\n checkFields<Diff<${\n options.type === 'page' ? 'PageProps' : 'LayoutProps'\n }, FirstArg<MaybeField<TEntry, 'generateMetadata'>>, 'generateMetadata'>>()\n checkFields<Diff<ResolvingMetadata, SecondArg<MaybeField<TEntry, 'generateMetadata'>>, 'generateMetadata'>>()\n}\n\n// Check the arguments and return type of the generateViewport function\nif ('generateViewport' in entry) {\n checkFields<Diff<${\n options.type === 'page' ? 'PageProps' : 'LayoutProps'\n }, FirstArg<MaybeField<TEntry, 'generateViewport'>>, 'generateViewport'>>()\n checkFields<Diff<ResolvingViewport, SecondArg<MaybeField<TEntry, 'generateViewport'>>, 'generateViewport'>>()\n}\n`\n}\n// Check the arguments and return type of the generateStaticParams function\nif ('generateStaticParams' in entry) {\n checkFields<Diff<{ params: SegmentParams }, FirstArg<MaybeField<TEntry, 'generateStaticParams'>>, 'generateStaticParams'>>()\n checkFields<Diff<{ __tag__: 'generateStaticParams', __return_type__: any[] | Promise<any[]> }, { __tag__: 'generateStaticParams', __return_type__: ReturnType<MaybeField<TEntry, 'generateStaticParams'>> }>>()\n}\n\nexport interface PageProps {\n params?: Promise<SegmentParams>\n searchParams?: Promise<any>\n}\nexport interface LayoutProps {\n children?: React.ReactNode\n${\n options.slots\n ? options.slots.map((slot) => ` ${slot}: React.ReactNode`).join('\\n')\n : ''\n}\n params?: Promise<SegmentParams>\n}\n\n// =============\n// Utility types\ntype RevalidateRange<T> = T extends { revalidate: any } ? NonNegative<T['revalidate']> : never\n\n// If T is unknown or any, it will be an empty {} type. Otherwise, it will be the same as Omit<T, keyof Base>.\ntype OmitWithTag<T, K extends keyof any, _M> = Omit<T, K>\ntype Diff<Base, T extends Base, Message extends string = ''> = 0 extends (1 & T) ? {} : OmitWithTag<T, keyof Base, Message>\n\ntype FirstArg<T extends Function> = T extends (...args: [infer T, any]) => any ? unknown extends T ? any : T : never\ntype SecondArg<T extends Function> = T extends (...args: [any, infer T]) => any ? unknown extends T ? any : T : never\ntype MaybeField<T, K extends string> = T extends { [k in K]: infer G } ? G extends Function ? G : never : never\n\n${\n options.type === 'route'\n ? `type ParamCheck<T> = {\n __tag__: string\n __param_position__: string\n __param_type__: T\n}`\n : ''\n}\n\nfunction checkFields<_ extends { [k in keyof any]: never }>() {}\n\n// https://github.com/sindresorhus/type-fest\ntype Numeric = number | bigint\ntype Zero = 0 | 0n\ntype Negative<T extends Numeric> = T extends Zero ? never : \\`\\${T}\\` extends \\`-\\${string}\\` ? T : never\ntype NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : '__invalid_negative_number__'\n`\n}\n\nasync function collectNamedSlots(layoutPath: string) {\n const layoutDir = path.dirname(layoutPath)\n const items = await fs.readdir(layoutDir, { withFileTypes: true })\n const slots = []\n for (const item of items) {\n if (\n item.isDirectory() &&\n item.name.startsWith('@') &&\n // `@children slots are matched to the children prop, and should not be handled separately for type-checking\n item.name !== '@children'\n ) {\n slots.push(item.name.slice(1))\n }\n }\n return slots\n}\n\n// By exposing the static route types separately as string literals,\n// editors can provide autocompletion for them. However it's currently not\n// possible to provide the same experience for dynamic routes.\n\nconst pluginState = getProxiedPluginState({\n collectedRootParams: {} as Record<string, string[]>,\n routeTypes: {\n edge: {\n static: [],\n dynamic: [],\n },\n node: {\n static: [],\n dynamic: [],\n },\n extra: {\n static: [],\n dynamic: [],\n },\n } as Record<\n 'edge' | 'node' | 'extra',\n Record<'static' | 'dynamic', string[]>\n >,\n})\n\nfunction formatRouteToRouteType(route: string) {\n const isDynamic = isDynamicRoute(route)\n if (isDynamic) {\n route = route\n .split('/')\n .map((part) => {\n if (part.startsWith('[') && part.endsWith(']')) {\n if (part.startsWith('[...')) {\n // /[...slug]\n return `\\${CatchAllSlug<T>}`\n } else if (part.startsWith('[[...') && part.endsWith(']]')) {\n // /[[...slug]]\n return `\\${OptionalCatchAllSlug<T>}`\n }\n // /[slug]\n return `\\${SafeSlug<T>}`\n }\n return part\n })\n .join('/')\n }\n\n return {\n isDynamic,\n routeType: route,\n }\n}\n\nfunction formatTimespan(seconds: number): string {\n if (seconds > 0) {\n if (seconds === 18748800) {\n return '1 month'\n }\n if (seconds === 18144000) {\n return '1 month'\n }\n if (seconds === 604800) {\n return '1 week'\n }\n if (seconds === 86400) {\n return '1 day'\n }\n if (seconds === 3600) {\n return '1 hour'\n }\n if (seconds === 60) {\n return '1 minute'\n }\n if (seconds % 18748800 === 0) {\n return seconds / 18748800 + ' months'\n }\n if (seconds % 18144000 === 0) {\n return seconds / 18144000 + ' months'\n }\n if (seconds % 604800 === 0) {\n return seconds / 604800 + ' weeks'\n }\n if (seconds % 86400 === 0) {\n return seconds / 86400 + ' days'\n }\n if (seconds % 3600 === 0) {\n return seconds / 3600 + ' hours'\n }\n if (seconds % 60 === 0) {\n return seconds / 60 + ' minutes'\n }\n }\n return seconds + ' seconds'\n}\n\nfunction formatTimespanWithSeconds(seconds: undefined | number): string {\n if (seconds === undefined) {\n return 'default'\n }\n if (seconds >= 0xfffffffe) {\n return 'never'\n }\n const text = seconds + ' seconds'\n const descriptive = formatTimespan(seconds)\n if (descriptive === text) {\n return text\n }\n return text + ' (' + descriptive + ')'\n}\n\nfunction getRootParamsFromLayouts(layouts: Record<string, string[]>) {\n // Sort layouts by depth (descending)\n const sortedLayouts = Object.entries(layouts).sort(\n (a, b) => b[0].split('/').length - a[0].split('/').length\n )\n\n if (!sortedLayouts.length) {\n return []\n }\n\n // we assume the shorted layout path is the root layout\n let rootLayout = sortedLayouts[sortedLayouts.length - 1][0]\n\n let rootParams = new Set<string>()\n let isMultipleRootLayouts = false\n\n for (const [layoutPath, params] of sortedLayouts) {\n const allSegmentsAreDynamic = layoutPath\n .split('/')\n .slice(1, -1)\n // match dynamic params but not catch-all or optional catch-all\n .every((segment) => /^\\[[^[.\\]]+\\]$/.test(segment))\n\n if (allSegmentsAreDynamic) {\n if (isSubpath(rootLayout, layoutPath)) {\n // Current path is a subpath of the root layout, update root\n rootLayout = layoutPath\n rootParams = new Set(params)\n } else {\n // Found another potential root layout\n isMultipleRootLayouts = true\n // Add any new params\n for (const param of params) {\n rootParams.add(param)\n }\n }\n }\n }\n\n // Create result array\n const result = Array.from(rootParams).map((param) => ({\n param,\n optional: isMultipleRootLayouts,\n }))\n\n return result\n}\n\nfunction isSubpath(parentLayoutPath: string, potentialChildLayoutPath: string) {\n // we strip off the `layout` part of the path as those will always conflict with being a subpath\n const parentSegments = parentLayoutPath.split('/').slice(1, -1)\n const childSegments = potentialChildLayoutPath.split('/').slice(1, -1)\n\n // child segments should be shorter or equal to parent segments to be a subpath\n if (childSegments.length > parentSegments.length || !childSegments.length)\n return false\n\n // Verify all segment values are equal\n return childSegments.every(\n (childSegment, index) => childSegment === parentSegments[index]\n )\n}\n\nfunction createServerDefinitions(\n rootParams: { param: string; optional: boolean }[]\n) {\n return `\n declare module 'next/server' {\n\n import type { AsyncLocalStorage as NodeAsyncLocalStorage } from 'async_hooks'\n declare global {\n var AsyncLocalStorage: typeof NodeAsyncLocalStorage\n }\n export { NextFetchEvent } from 'next/dist/server/web/spec-extension/fetch-event'\n export { NextRequest } from 'next/dist/server/web/spec-extension/request'\n export { NextResponse } from 'next/dist/server/web/spec-extension/response'\n export { NextMiddleware, MiddlewareConfig } from 'next/dist/server/web/types'\n export { userAgentFromString } from 'next/dist/server/web/spec-extension/user-agent'\n export { userAgent } from 'next/dist/server/web/spec-extension/user-agent'\n export { URLPattern } from 'next/dist/compiled/@edge-runtime/primitives/url'\n export { ImageResponse } from 'next/dist/server/web/spec-extension/image-response'\n export type { ImageResponseOptions } from 'next/dist/compiled/@vercel/og/types'\n export { after } from 'next/dist/server/after'\n export { connection } from 'next/dist/server/request/connection'\n export type { UnsafeUnwrappedSearchParams } from 'next/dist/server/request/search-params'\n export type { UnsafeUnwrappedParams } from 'next/dist/server/request/params'\n export function unstable_rootParams(): Promise<{ ${rootParams\n .map(\n ({ param, optional }) =>\n // ensure params with dashes are valid keys\n `${param.includes('-') ? `'${param}'` : param}${optional ? '?' : ''}: string`\n )\n .join(', ')} }>\n }\n `\n}\n\nfunction createCustomCacheLifeDefinitions(cacheLife: {\n [profile: string]: CacheLife\n}) {\n let overloads = ''\n\n const profileNames = Object.keys(cacheLife)\n for (let i = 0; i < profileNames.length; i++) {\n const profileName = profileNames[i]\n const profile = cacheLife[profileName]\n if (typeof profile !== 'object' || profile === null) {\n continue\n }\n\n let description = ''\n\n if (profile.stale === undefined) {\n description += `\n * This cache may be stale on clients for the default stale time of the scope before checking with the server.`\n } else if (profile.stale >= 0xfffffffe) {\n description += `\n * This cache may be stale on clients indefinitely before checking with the server.`\n } else {\n description += `\n * This cache may be stale on clients for ${formatTimespan(profile.stale)} before checking with the server.`\n }\n if (\n profile.revalidate !== undefined &&\n profile.expire !== undefined &&\n profile.revalidate >= profile.expire\n ) {\n description += `\n * This cache will expire after ${formatTimespan(profile.expire)}. The next request will recompute it.`\n } else {\n if (profile.revalidate === undefined) {\n description += `\n * It will inherit the default revalidate time of its scope since it does not define its own.`\n } else if (profile.revalidate >= 0xfffffffe) {\n // Nothing to mention.\n } else {\n description += `\n * If the server receives a new request after ${formatTimespan(profile.revalidate)}, start revalidating new values in the background.`\n }\n if (profile.expire === undefined) {\n description += `\n * It will inherit the default expiration time of its scope since it does not define its own.`\n } else if (profile.expire >= 0xfffffffe) {\n description += `\n * It lives for the maximum age of the server cache. If this entry has no traffic for a while, it may serve an old value the next request.`\n } else {\n description += `\n * If this entry has no traffic for ${formatTimespan(profile.expire)} it will expire. The next request will recompute it.`\n }\n }\n\n overloads += `\n /**\n * Cache this \\`\"use cache\"\\` for a timespan defined by the \\`${JSON.stringify(profileName)}\\` profile.\n * \\`\\`\\`\n * stale: ${formatTimespanWithSeconds(profile.stale)}\n * revalidate: ${formatTimespanWithSeconds(profile.revalidate)}\n * expire: ${formatTimespanWithSeconds(profile.expire)}\n * \\`\\`\\`\n * ${description}\n */\n export function unstable_cacheLife(profile: ${JSON.stringify(profileName)}): void\n `\n }\n\n overloads += `\n /**\n * Cache this \\`\"use cache\"\\` using a custom timespan.\n * \\`\\`\\`\n * stale: ... // seconds\n * revalidate: ... // seconds\n * expire: ... // seconds\n * \\`\\`\\`\n *\n * This is similar to Cache-Control: max-age=\\`stale\\`,s-max-age=\\`revalidate\\`,stale-while-revalidate=\\`expire-revalidate\\`\n *\n * If a value is left out, the lowest of other cacheLife() calls or the default, is used instead.\n */\n export function unstable_cacheLife(profile: {\n /**\n * This cache may be stale on clients for ... seconds before checking with the server.\n */\n stale?: number,\n /**\n * If the server receives a new request after ... seconds, start revalidating new values in the background.\n */\n revalidate?: number,\n /**\n * If this entry has no traffic for ... seconds it will expire. The next request will recompute it.\n */\n expire?: number\n }): void\n `\n\n // Redefine the cacheLife() accepted arguments.\n return `// Type definitions for Next.js cacheLife configs\n\ndeclare module 'next/cache' {\n export { unstable_cache } from 'next/dist/server/web/spec-extension/unstable-cache'\n export {\n revalidateTag,\n revalidatePath,\n unstable_expireTag,\n unstable_expirePath,\n } from 'next/dist/server/web/spec-extension/revalidate'\n export { unstable_noStore } from 'next/dist/server/web/spec-extension/unstable-no-store'\n\n ${overloads}\n\n export { cacheTag as unstable_cacheTag } from 'next/dist/server/use-cache/cache-tag'\n}\n`\n}\n\nconst appTypesBasePath = path.join('types', 'app')\n\nexport class NextTypesPlugin {\n dir: string\n distDir: string\n appDir: string\n dev: boolean\n isEdgeServer: boolean\n pageExtensions: string[]\n pagesDir: string\n cacheLifeConfig: undefined | { [profile: string]: CacheLife }\n distDirAbsolutePath: string\n\n constructor(options: Options) {\n this.dir = options.dir\n this.distDir = options.distDir\n this.appDir = options.appDir\n this.dev = options.dev\n this.isEdgeServer = options.isEdgeServer\n this.pageExtensions = options.pageExtensions\n this.pagesDir = path.join(this.appDir, '..', 'pages')\n this.cacheLifeConfig = options.cacheLifeConfig\n this.distDirAbsolutePath = path.join(this.dir, this.distDir)\n }\n\n getRelativePathFromAppTypesDir(moduleRelativePathToAppDir: string) {\n const moduleAbsolutePath = path.join(\n this.appDir,\n moduleRelativePathToAppDir\n )\n\n const moduleInAppTypesAbsolutePath = path.join(\n this.distDirAbsolutePath,\n appTypesBasePath,\n moduleRelativePathToAppDir\n )\n\n return path.relative(\n moduleInAppTypesAbsolutePath + '/..',\n moduleAbsolutePath\n )\n }\n\n collectPage(filePath: string) {\n const isApp = filePath.startsWith(this.appDir + path.sep)\n const isPages = !isApp && filePath.startsWith(this.pagesDir + path.sep)\n\n if (!isApp && !isPages) {\n return\n }\n\n // Filter out non-page and non-route files in app dir\n if (isApp && !/[/\\\\](?:page|route)\\.[^.]+$/.test(filePath)) {\n return\n }\n\n // Filter out non-page files in pages dir\n if (\n isPages &&\n /[/\\\\](?:_app|_document|_error|404|500)\\.[^.]+$/.test(filePath)\n ) {\n return\n }\n\n let route = (isApp ? normalizeAppPath : denormalizePagePath)(\n ensureLeadingSlash(\n getPageFromPath(\n path.relative(isApp ? this.appDir : this.pagesDir, filePath),\n this.pageExtensions\n )\n )\n )\n\n const { isDynamic, routeType } = formatRouteToRouteType(route)\n\n pluginState.routeTypes[this.isEdgeServer ? 'edge' : 'node'][\n isDynamic ? 'dynamic' : 'static'\n ].push(routeType)\n }\n\n apply(compiler: webpack.Compiler) {\n // From asset root to dist root\n const assetDirRelative = this.dev\n ? '..'\n : this.isEdgeServer\n ? '..'\n : '../..'\n\n const handleModule = async (\n mod: webpack.NormalModule,\n compilation: webpack.Compilation\n ) => {\n if (!mod.resource) return\n\n const pageExtensionsRegex = new RegExp(\n `\\\\.(${this.pageExtensions.join('|')})$`\n )\n\n if (!pageExtensionsRegex.test(mod.resource)) return\n\n if (!mod.resource.startsWith(this.appDir + path.sep)) {\n if (!this.dev) {\n if (mod.resource.startsWith(this.pagesDir + path.sep)) {\n this.collectPage(mod.resource)\n }\n }\n return\n }\n if (mod.layer !== WEBPACK_LAYERS.reactServerComponents) return\n\n // skip for /app/_private dir convention\n // matches <app-dir>/**/_*\n const IS_PRIVATE = /(?:\\/[^/]+)*\\/_.*$/.test(\n mod.resource.replace(this.appDir, '')\n )\n if (IS_PRIVATE) return\n\n const IS_LAYOUT = /[/\\\\]layout\\.[^./\\\\]+$/.test(mod.resource)\n const IS_PAGE = !IS_LAYOUT && /[/\\\\]page\\.[^.]+$/.test(mod.resource)\n const IS_ROUTE = !IS_PAGE && /[/\\\\]route\\.[^.]+$/.test(mod.resource)\n const IS_IMPORTABLE = /\\.(js|jsx|ts|tsx|mjs|cjs)$/.test(mod.resource)\n const relativePathToApp = path.relative(this.appDir, mod.resource)\n\n if (!this.dev) {\n if (IS_PAGE || IS_ROUTE) {\n this.collectPage(mod.resource)\n }\n }\n\n const typePath = path.join(\n appTypesBasePath,\n relativePathToApp.replace(pageExtensionsRegex, '.ts')\n )\n const relativeImportPath = normalizePathSep(\n path\n .join(this.getRelativePathFromAppTypesDir(relativePathToApp))\n .replace(pageExtensionsRegex, '')\n )\n\n const assetPath = path.join(assetDirRelative, typePath)\n\n // Typescript won’t allow relative-importing (for example) a .mdx file using the .js extension\n // so for now we only generate “type guard files” for files that typescript can transform\n if (!IS_IMPORTABLE) return\n\n if (IS_LAYOUT) {\n const rootLayoutPath = normalizeAppPath(\n ensureLeadingSlash(\n getPageFromPath(\n path.relative(this.appDir, mod.resource),\n this.pageExtensions\n )\n )\n )\n\n const foundParams = Array.from(\n rootLayoutPath.matchAll(/\\[(.*?)\\]/g),\n (match) => match[1]\n )\n\n pluginState.collectedRootParams[rootLayoutPath] = foundParams\n\n const slots = await collectNamedSlots(mod.resource)\n compilation.emitAsset(\n assetPath,\n new sources.RawSource(\n createTypeGuardFile(mod.resource, relativeImportPath, {\n type: 'layout',\n slots,\n })\n ) as unknown as webpack.sources.RawSource\n )\n } else if (IS_PAGE) {\n compilation.emitAsset(\n assetPath,\n new sources.RawSource(\n createTypeGuardFile(mod.resource, relativeImportPath, {\n type: 'page',\n })\n ) as unknown as webpack.sources.RawSource\n )\n } else if (IS_ROUTE) {\n compilation.emitAsset(\n assetPath,\n new sources.RawSource(\n createTypeGuardFile(mod.resource, relativeImportPath, {\n type: 'route',\n })\n ) as unknown as webpack.sources.RawSource\n )\n }\n }\n\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {\n compilation.hooks.processAssets.tapAsync(\n {\n name: PLUGIN_NAME,\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH,\n },\n async (_, callback) => {\n const promises: Promise<any>[] = []\n\n // Clear routes\n if (this.isEdgeServer) {\n pluginState.routeTypes.edge.dynamic = []\n pluginState.routeTypes.edge.static = []\n } else {\n pluginState.routeTypes.node.dynamic = []\n pluginState.routeTypes.node.static = []\n }\n\n compilation.chunkGroups.forEach((chunkGroup) => {\n chunkGroup.chunks.forEach((chunk) => {\n if (!chunk.name) return\n\n // Here we only track page and route chunks.\n if (\n !chunk.name.startsWith('pages/') &&\n !(\n chunk.name.startsWith('app/') &&\n (chunk.name.endsWith('/page') ||\n chunk.name.endsWith('/route'))\n )\n ) {\n return\n }\n\n const chunkModules =\n compilation.chunkGraph.getChunkModulesIterable(\n chunk\n ) as Iterable<webpack.NormalModule>\n for (const mod of chunkModules) {\n promises.push(handleModule(mod, compilation))\n\n // If this is a concatenation, register each child to the parent ID.\n const anyModule = mod as unknown as {\n modules: webpack.NormalModule[]\n }\n if (anyModule.modules) {\n anyModule.modules.forEach((concatenatedMod) => {\n promises.push(handleModule(concatenatedMod, compilation))\n })\n }\n }\n })\n })\n\n await Promise.all(promises)\n\n const rootParams = getRootParamsFromLayouts(\n pluginState.collectedRootParams\n )\n // If we discovered rootParams, we'll override the `next/server` types\n // since we're able to determine the root params at build time.\n if (rootParams.length > 0) {\n const serverTypesPath = path.join(\n assetDirRelative,\n 'types/server.d.ts'\n )\n\n compilation.emitAsset(\n serverTypesPath,\n new sources.RawSource(\n createServerDefinitions(rootParams)\n ) as unknown as webpack.sources.RawSource\n )\n }\n\n // Support `\"moduleResolution\": \"Node16\" | \"NodeNext\"` with `\"type\": \"module\"`\n\n const packageJsonAssetPath = path.join(\n assetDirRelative,\n 'types/package.json'\n )\n\n compilation.emitAsset(\n packageJsonAssetPath,\n new sources.RawSource(\n '{\"type\": \"module\"}'\n ) as unknown as webpack.sources.RawSource\n )\n\n if (this.cacheLifeConfig) {\n const cacheLifeAssetPath = path.join(\n assetDirRelative,\n 'types/cache-life.d.ts'\n )\n\n compilation.emitAsset(\n cacheLifeAssetPath,\n new sources.RawSource(\n createCustomCacheLifeDefinitions(this.cacheLifeConfig)\n ) as unknown as webpack.sources.RawSource\n )\n }\n\n callback()\n }\n )\n })\n }\n}\n"],"names":["fs","webpack","sources","path","WEBPACK_LAYERS","denormalizePagePath","ensureLeadingSlash","normalizePathSep","HTTP_METHODS","isDynamicRoute","normalizeAppPath","getPageFromPath","getProxiedPluginState","PLUGIN_NAME","createTypeGuardFile","fullPath","relativePath","options","type","map","method","join","slots","slot","collectNamedSlots","layoutPath","layoutDir","dirname","items","readdir","withFileTypes","item","isDirectory","name","startsWith","push","slice","pluginState","collectedRootParams","routeTypes","edge","static","dynamic","node","extra","formatRouteToRouteType","route","isDynamic","split","part","endsWith","routeType","formatTimespan","seconds","formatTimespanWithSeconds","undefined","text","descriptive","getRootParamsFromLayouts","layouts","sortedLayouts","Object","entries","sort","a","b","length","rootLayout","rootParams","Set","isMultipleRootLayouts","params","allSegmentsAreDynamic","every","segment","test","isSubpath","param","add","result","Array","from","optional","parentLayoutPath","potentialChildLayoutPath","parentSegments","childSegments","childSegment","index","createServerDefinitions","includes","createCustomCacheLifeDefinitions","cacheLife","overloads","profileNames","keys","i","profileName","profile","description","stale","revalidate","expire","JSON","stringify","appTypesBasePath","NextTypesPlugin","constructor","dir","distDir","appDir","dev","isEdgeServer","pageExtensions","pagesDir","cacheLifeConfig","distDirAbsolutePath","getRelativePathFromAppTypesDir","moduleRelativePathToAppDir","moduleAbsolutePath","moduleInAppTypesAbsolutePath","relative","collectPage","filePath","isApp","sep","isPages","apply","compiler","assetDirRelative","handleModule","mod","compilation","resource","pageExtensionsRegex","RegExp","layer","reactServerComponents","IS_PRIVATE","replace","IS_LAYOUT","IS_PAGE","IS_ROUTE","IS_IMPORTABLE","relativePathToApp","typePath","relativeImportPath","assetPath","rootLayoutPath","foundParams","matchAll","match","emitAsset","RawSource","hooks","tap","processAssets","tapAsync","stage","Compilation","PROCESS_ASSETS_STAGE_OPTIMIZE_HASH","_","callback","promises","chunkGroups","forEach","chunkGroup","chunks","chunk","chunkModules","chunkGraph","getChunkModulesIterable","anyModule","modules","concatenatedMod","Promise","all","serverTypesPath","packageJsonAssetPath","cacheLifeAssetPath"],"mappings":"AAEA,OAAOA,QAAQ,cAAa;AAC5B,SAASC,OAAO,EAAEC,OAAO,QAAQ,qCAAoC;AACrE,OAAOC,UAAU,OAAM;AAEvB,SAASC,cAAc,QAAQ,4BAA2B;AAC1D,SAASC,mBAAmB,QAAQ,yDAAwD;AAC5F,SAASC,kBAAkB,QAAQ,wDAAuD;AAC1F,SAASC,gBAAgB,QAAQ,sDAAqD;AACtF,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,cAAc,QAAQ,sCAAqC;AACpE,SAASC,gBAAgB,QAAQ,gDAA+C;AAChF,SAASC,eAAe,QAAQ,mBAAkB;AAElD,SAASC,qBAAqB,QAAQ,yBAAwB;AAG9D,MAAMC,cAAc;AAoBpB,SAASC,oBACPC,QAAgB,EAChBC,YAAoB,EACpBC,OAGC;IAED,OAAO,CAAC,SAAS,EAAEF,SAAS;wBACN,EAAEC,aAAa;AACvC,EACEC,QAAQC,IAAI,KAAK,UACb,CAAC,iDAAiD,CAAC,GACnD,CAAC,8GAA8G,CAAC,CACrH;;6BAE4B,EAAEF,aAAa;;;;;;;;EAQ1C,EACEC,QAAQC,IAAI,KAAK,UACbV,aAAaW,GAAG,CAAC,CAACC,SAAW,GAAGA,OAAO,WAAW,CAAC,EAAEC,IAAI,CAAC,UAC1D,oBACL;;;;;;;;;;;EAWD,EACEJ,QAAQC,IAAI,KAAK,UACb,KACA,CAAC;;;;;;EAMP,CAAC,CACA;;;AAGH,EAAED,QAAQC,IAAI,KAAK,UAAU,CAAC,sDAAsD,CAAC,GAA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,IAAI,CACpC4G,kBACA;gBAGFG,YAAYoB,SAAS,CACnB0B,sBACA,IAAIhL,QAAQuJ,SAAS,CACnB;gBAIJ,IAAI,IAAI,CAACtC,eAAe,EAAE;oBACxB,MAAMgE,qBAAqBhL,KAAKkB,IAAI,CAClC4G,kBACA;oBAGFG,YAAYoB,SAAS,CACnB2B,oBACA,IAAIjL,QAAQuJ,SAAS,CACnB9D,iCAAiC,IAAI,CAACwB,eAAe;gBAG3D;gBAEA+C;YACF;QAEJ;IACF;AACF","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/build/webpack/plugins/next-types-plugin/index.ts"],"sourcesContent":["import type { Rewrite, Redirect } from '../../../../lib/load-custom-routes'\n\nimport fs from 'fs/promises'\nimport { webpack, sources } from 'next/dist/compiled/webpack/webpack'\nimport path from 'path'\n\nimport { WEBPACK_LAYERS } from '../../../../lib/constants'\n\n// Read package name dynamically to support forked packages\nconst PKG_NAME = require('../../../../../package.json').name\nimport { denormalizePagePath } from '../../../../shared/lib/page-path/denormalize-page-path'\nimport { ensureLeadingSlash } from '../../../../shared/lib/page-path/ensure-leading-slash'\nimport { normalizePathSep } from '../../../../shared/lib/page-path/normalize-path-sep'\nimport { HTTP_METHODS } from '../../../../server/web/http'\nimport { isDynamicRoute } from '../../../../shared/lib/router/utils'\nimport { normalizeAppPath } from '../../../../shared/lib/router/utils/app-paths'\nimport { getPageFromPath } from '../../../entries'\nimport type { PageExtensions } from '../../../page-extensions-type'\nimport { getProxiedPluginState } from '../../../build-context'\nimport type { CacheLife } from '../../../../server/use-cache/cache-life'\n\nconst PLUGIN_NAME = 'NextTypesPlugin'\n\ntype Rewrites = {\n fallback: Rewrite[]\n afterFiles: Rewrite[]\n beforeFiles: Rewrite[]\n}\n\ninterface Options {\n dir: string\n distDir: string\n appDir: string\n dev: boolean\n isEdgeServer: boolean\n pageExtensions: PageExtensions\n cacheLifeConfig: undefined | { [profile: string]: CacheLife }\n originalRewrites: Rewrites | undefined\n originalRedirects: Redirect[] | undefined\n}\n\nfunction createTypeGuardFile(\n fullPath: string,\n relativePath: string,\n options: {\n type: 'layout' | 'page' | 'route'\n slots?: string[]\n }\n) {\n return `// File: ${fullPath}\nimport * as entry from '${relativePath}.js'\n${\n options.type === 'route'\n ? `import type { NextRequest } from '${PKG_NAME}/server.js'`\n : `import type { ResolvingMetadata, ResolvingViewport } from '${PKG_NAME}/dist/lib/metadata/types/metadata-interface.js'`\n}\n\ntype TEntry = typeof import('${relativePath}.js')\n\ntype SegmentParams<T extends Object = any> = T extends Record<string, any>\n ? { [K in keyof T]: T[K] extends string ? string | string[] | undefined : never }\n : T\n\n// Check that the entry is a valid entry\ncheckFields<Diff<{\n ${\n options.type === 'route'\n ? HTTP_METHODS.map((method) => `${method}?: Function`).join('\\n ')\n : 'default: Function'\n }\n config?: {}\n generateStaticParams?: Function\n unstable_prefetch?: 'unstable_static' | 'unstable_runtime'\n revalidate?: RevalidateRange<TEntry> | false\n dynamic?: 'auto' | 'force-dynamic' | 'error' | 'force-static'\n dynamicParams?: boolean\n fetchCache?: 'auto' | 'force-no-store' | 'only-no-store' | 'default-no-store' | 'default-cache' | 'only-cache' | 'force-cache'\n preferredRegion?: 'auto' | 'global' | 'home' | string | string[]\n runtime?: 'nodejs' | 'experimental-edge' | 'edge'\n maxDuration?: number\n ${\n options.type === 'route'\n ? ''\n : `\n metadata?: any\n generateMetadata?: Function\n viewport?: any\n generateViewport?: Function\n experimental_ppr?: boolean\n `\n }\n}, TEntry, ''>>()\n\n${options.type === 'route' ? `type RouteContext = { params: Promise<SegmentParams> }` : ''}\n${\n options.type === 'route'\n ? HTTP_METHODS.map(\n (method) => `// Check the prop type of the entry function\nif ('${method}' in entry) {\n checkFields<\n Diff<\n ParamCheck<Request | NextRequest>,\n {\n __tag__: '${method}'\n __param_position__: 'first'\n __param_type__: FirstArg<MaybeField<TEntry, '${method}'>>\n },\n '${method}'\n >\n >()\n checkFields<\n Diff<\n ParamCheck<RouteContext>,\n {\n __tag__: '${method}'\n __param_position__: 'second'\n __param_type__: SecondArg<MaybeField<TEntry, '${method}'>>\n },\n '${method}'\n >\n >()\n ${\n ''\n // Adding void to support never return type without explicit return:\n // e.g. notFound() will interrupt the execution but the handler return type is inferred as void.\n // x-ref: https://github.com/microsoft/TypeScript/issues/16608#issuecomment-309327984\n }\n checkFields<\n Diff<\n {\n __tag__: '${method}',\n __return_type__: Response | void | never | Promise<Response | void | never>\n },\n {\n __tag__: '${method}',\n __return_type__: ReturnType<MaybeField<TEntry, '${method}'>>\n },\n '${method}'\n >\n >()\n}\n`\n ).join('')\n : `// Check the prop type of the entry function\ncheckFields<Diff<${\n options.type === 'page' ? 'PageProps' : 'LayoutProps'\n }, FirstArg<TEntry['default']>, 'default'>>()\n\n// Check the arguments and return type of the generateMetadata function\nif ('generateMetadata' in entry) {\n checkFields<Diff<${\n options.type === 'page' ? 'PageProps' : 'LayoutProps'\n }, FirstArg<MaybeField<TEntry, 'generateMetadata'>>, 'generateMetadata'>>()\n checkFields<Diff<ResolvingMetadata, SecondArg<MaybeField<TEntry, 'generateMetadata'>>, 'generateMetadata'>>()\n}\n\n// Check the arguments and return type of the generateViewport function\nif ('generateViewport' in entry) {\n checkFields<Diff<${\n options.type === 'page' ? 'PageProps' : 'LayoutProps'\n }, FirstArg<MaybeField<TEntry, 'generateViewport'>>, 'generateViewport'>>()\n checkFields<Diff<ResolvingViewport, SecondArg<MaybeField<TEntry, 'generateViewport'>>, 'generateViewport'>>()\n}\n`\n}\n// Check the arguments and return type of the generateStaticParams function\nif ('generateStaticParams' in entry) {\n checkFields<Diff<{ params: SegmentParams }, FirstArg<MaybeField<TEntry, 'generateStaticParams'>>, 'generateStaticParams'>>()\n checkFields<Diff<{ __tag__: 'generateStaticParams', __return_type__: any[] | Promise<any[]> }, { __tag__: 'generateStaticParams', __return_type__: ReturnType<MaybeField<TEntry, 'generateStaticParams'>> }>>()\n}\n\nexport interface PageProps {\n params?: Promise<SegmentParams>\n searchParams?: Promise<any>\n}\nexport interface LayoutProps {\n children?: React.ReactNode\n${\n options.slots\n ? options.slots.map((slot) => ` ${slot}: React.ReactNode`).join('\\n')\n : ''\n}\n params?: Promise<SegmentParams>\n}\n\n// =============\n// Utility types\ntype RevalidateRange<T> = T extends { revalidate: any } ? NonNegative<T['revalidate']> : never\n\n// If T is unknown or any, it will be an empty {} type. Otherwise, it will be the same as Omit<T, keyof Base>.\ntype OmitWithTag<T, K extends keyof any, _M> = Omit<T, K>\ntype Diff<Base, T extends Base, Message extends string = ''> = 0 extends (1 & T) ? {} : OmitWithTag<T, keyof Base, Message>\n\ntype FirstArg<T extends Function> = T extends (...args: [infer T, any]) => any ? unknown extends T ? any : T : never\ntype SecondArg<T extends Function> = T extends (...args: [any, infer T]) => any ? unknown extends T ? any : T : never\ntype MaybeField<T, K extends string> = T extends { [k in K]: infer G } ? G extends Function ? G : never : never\n\n${\n options.type === 'route'\n ? `type ParamCheck<T> = {\n __tag__: string\n __param_position__: string\n __param_type__: T\n}`\n : ''\n}\n\nfunction checkFields<_ extends { [k in keyof any]: never }>() {}\n\n// https://github.com/sindresorhus/type-fest\ntype Numeric = number | bigint\ntype Zero = 0 | 0n\ntype Negative<T extends Numeric> = T extends Zero ? never : \\`\\${T}\\` extends \\`-\\${string}\\` ? T : never\ntype NonNegative<T extends Numeric> = T extends Zero ? T : Negative<T> extends never ? T : '__invalid_negative_number__'\n`\n}\n\nasync function collectNamedSlots(layoutPath: string) {\n const layoutDir = path.dirname(layoutPath)\n const items = await fs.readdir(layoutDir, { withFileTypes: true })\n const slots = []\n for (const item of items) {\n if (\n item.isDirectory() &&\n item.name.startsWith('@') &&\n // `@children slots are matched to the children prop, and should not be handled separately for type-checking\n item.name !== '@children'\n ) {\n slots.push(item.name.slice(1))\n }\n }\n return slots\n}\n\n// By exposing the static route types separately as string literals,\n// editors can provide autocompletion for them. However it's currently not\n// possible to provide the same experience for dynamic routes.\n\nconst pluginState = getProxiedPluginState({\n collectedRootParams: {} as Record<string, string[]>,\n routeTypes: {\n edge: {\n static: [],\n dynamic: [],\n },\n node: {\n static: [],\n dynamic: [],\n },\n extra: {\n static: [],\n dynamic: [],\n },\n } as Record<\n 'edge' | 'node' | 'extra',\n Record<'static' | 'dynamic', string[]>\n >,\n})\n\nfunction formatRouteToRouteType(route: string) {\n const isDynamic = isDynamicRoute(route)\n if (isDynamic) {\n route = route\n .split('/')\n .map((part) => {\n if (part.startsWith('[') && part.endsWith(']')) {\n if (part.startsWith('[...')) {\n // /[...slug]\n return `\\${CatchAllSlug<T>}`\n } else if (part.startsWith('[[...') && part.endsWith(']]')) {\n // /[[...slug]]\n return `\\${OptionalCatchAllSlug<T>}`\n }\n // /[slug]\n return `\\${SafeSlug<T>}`\n }\n return part\n })\n .join('/')\n }\n\n return {\n isDynamic,\n routeType: route,\n }\n}\n\nfunction formatTimespan(seconds: number): string {\n if (seconds > 0) {\n if (seconds === 18748800) {\n return '1 month'\n }\n if (seconds === 18144000) {\n return '1 month'\n }\n if (seconds === 604800) {\n return '1 week'\n }\n if (seconds === 86400) {\n return '1 day'\n }\n if (seconds === 3600) {\n return '1 hour'\n }\n if (seconds === 60) {\n return '1 minute'\n }\n if (seconds % 18748800 === 0) {\n return seconds / 18748800 + ' months'\n }\n if (seconds % 18144000 === 0) {\n return seconds / 18144000 + ' months'\n }\n if (seconds % 604800 === 0) {\n return seconds / 604800 + ' weeks'\n }\n if (seconds % 86400 === 0) {\n return seconds / 86400 + ' days'\n }\n if (seconds % 3600 === 0) {\n return seconds / 3600 + ' hours'\n }\n if (seconds % 60 === 0) {\n return seconds / 60 + ' minutes'\n }\n }\n return seconds + ' seconds'\n}\n\nfunction formatTimespanWithSeconds(seconds: undefined | number): string {\n if (seconds === undefined) {\n return 'default'\n }\n if (seconds >= 0xfffffffe) {\n return 'never'\n }\n const text = seconds + ' seconds'\n const descriptive = formatTimespan(seconds)\n if (descriptive === text) {\n return text\n }\n return text + ' (' + descriptive + ')'\n}\n\nfunction getRootParamsFromLayouts(layouts: Record<string, string[]>) {\n // Sort layouts by depth (descending)\n const sortedLayouts = Object.entries(layouts).sort(\n (a, b) => b[0].split('/').length - a[0].split('/').length\n )\n\n if (!sortedLayouts.length) {\n return []\n }\n\n // we assume the shorted layout path is the root layout\n let rootLayout = sortedLayouts[sortedLayouts.length - 1][0]\n\n let rootParams = new Set<string>()\n let isMultipleRootLayouts = false\n\n for (const [layoutPath, params] of sortedLayouts) {\n const allSegmentsAreDynamic = layoutPath\n .split('/')\n .slice(1, -1)\n // match dynamic params but not catch-all or optional catch-all\n .every((segment) => /^\\[[^[.\\]]+\\]$/.test(segment))\n\n if (allSegmentsAreDynamic) {\n if (isSubpath(rootLayout, layoutPath)) {\n // Current path is a subpath of the root layout, update root\n rootLayout = layoutPath\n rootParams = new Set(params)\n } else {\n // Found another potential root layout\n isMultipleRootLayouts = true\n // Add any new params\n for (const param of params) {\n rootParams.add(param)\n }\n }\n }\n }\n\n // Create result array\n const result = Array.from(rootParams).map((param) => ({\n param,\n optional: isMultipleRootLayouts,\n }))\n\n return result\n}\n\nfunction isSubpath(parentLayoutPath: string, potentialChildLayoutPath: string) {\n // we strip off the `layout` part of the path as those will always conflict with being a subpath\n const parentSegments = parentLayoutPath.split('/').slice(1, -1)\n const childSegments = potentialChildLayoutPath.split('/').slice(1, -1)\n\n // child segments should be shorter or equal to parent segments to be a subpath\n if (childSegments.length > parentSegments.length || !childSegments.length)\n return false\n\n // Verify all segment values are equal\n return childSegments.every(\n (childSegment, index) => childSegment === parentSegments[index]\n )\n}\n\nfunction createServerDefinitions(\n rootParams: { param: string; optional: boolean }[]\n) {\n return `\n declare module '${PKG_NAME}/server' {\n\n import type { AsyncLocalStorage as NodeAsyncLocalStorage } from 'async_hooks'\n declare global {\n var AsyncLocalStorage: typeof NodeAsyncLocalStorage\n }\n export { NextFetchEvent } from '${PKG_NAME}/dist/server/web/spec-extension/fetch-event'\n export { NextRequest } from '${PKG_NAME}/dist/server/web/spec-extension/request'\n export { NextResponse } from '${PKG_NAME}/dist/server/web/spec-extension/response'\n export { NextMiddleware, MiddlewareConfig } from '${PKG_NAME}/dist/server/web/types'\n export { userAgentFromString } from '${PKG_NAME}/dist/server/web/spec-extension/user-agent'\n export { userAgent } from '${PKG_NAME}/dist/server/web/spec-extension/user-agent'\n export { URLPattern } from '${PKG_NAME}/dist/compiled/@edge-runtime/primitives/url'\n export { ImageResponse } from '${PKG_NAME}/dist/server/web/spec-extension/image-response'\n export type { ImageResponseOptions } from '${PKG_NAME}/dist/compiled/@vercel/og/types'\n export { after } from '${PKG_NAME}/dist/server/after'\n export { connection } from '${PKG_NAME}/dist/server/request/connection'\n export type { UnsafeUnwrappedSearchParams } from '${PKG_NAME}/dist/server/request/search-params'\n export type { UnsafeUnwrappedParams } from '${PKG_NAME}/dist/server/request/params'\n export function unstable_rootParams(): Promise<{ ${rootParams\n .map(\n ({ param, optional }) =>\n // ensure params with dashes are valid keys\n `${param.includes('-') ? `'${param}'` : param}${optional ? '?' : ''}: string`\n )\n .join(', ')} }>\n }\n `\n}\n\nfunction createCustomCacheLifeDefinitions(cacheLife: {\n [profile: string]: CacheLife\n}) {\n let overloads = ''\n\n const profileNames = Object.keys(cacheLife)\n for (let i = 0; i < profileNames.length; i++) {\n const profileName = profileNames[i]\n const profile = cacheLife[profileName]\n if (typeof profile !== 'object' || profile === null) {\n continue\n }\n\n let description = ''\n\n if (profile.stale === undefined) {\n description += `\n * This cache may be stale on clients for the default stale time of the scope before checking with the server.`\n } else if (profile.stale >= 0xfffffffe) {\n description += `\n * This cache may be stale on clients indefinitely before checking with the server.`\n } else {\n description += `\n * This cache may be stale on clients for ${formatTimespan(profile.stale)} before checking with the server.`\n }\n if (\n profile.revalidate !== undefined &&\n profile.expire !== undefined &&\n profile.revalidate >= profile.expire\n ) {\n description += `\n * This cache will expire after ${formatTimespan(profile.expire)}. The next request will recompute it.`\n } else {\n if (profile.revalidate === undefined) {\n description += `\n * It will inherit the default revalidate time of its scope since it does not define its own.`\n } else if (profile.revalidate >= 0xfffffffe) {\n // Nothing to mention.\n } else {\n description += `\n * If the server receives a new request after ${formatTimespan(profile.revalidate)}, start revalidating new values in the background.`\n }\n if (profile.expire === undefined) {\n description += `\n * It will inherit the default expiration time of its scope since it does not define its own.`\n } else if (profile.expire >= 0xfffffffe) {\n description += `\n * It lives for the maximum age of the server cache. If this entry has no traffic for a while, it may serve an old value the next request.`\n } else {\n description += `\n * If this entry has no traffic for ${formatTimespan(profile.expire)} it will expire. The next request will recompute it.`\n }\n }\n\n overloads += `\n /**\n * Cache this \\`\"use cache\"\\` for a timespan defined by the \\`${JSON.stringify(profileName)}\\` profile.\n * \\`\\`\\`\n * stale: ${formatTimespanWithSeconds(profile.stale)}\n * revalidate: ${formatTimespanWithSeconds(profile.revalidate)}\n * expire: ${formatTimespanWithSeconds(profile.expire)}\n * \\`\\`\\`\n * ${description}\n */\n export function unstable_cacheLife(profile: ${JSON.stringify(profileName)}): void\n `\n }\n\n overloads += `\n /**\n * Cache this \\`\"use cache\"\\` using a custom timespan.\n * \\`\\`\\`\n * stale: ... // seconds\n * revalidate: ... // seconds\n * expire: ... // seconds\n * \\`\\`\\`\n *\n * This is similar to Cache-Control: max-age=\\`stale\\`,s-max-age=\\`revalidate\\`,stale-while-revalidate=\\`expire-revalidate\\`\n *\n * If a value is left out, the lowest of other cacheLife() calls or the default, is used instead.\n */\n export function unstable_cacheLife(profile: {\n /**\n * This cache may be stale on clients for ... seconds before checking with the server.\n */\n stale?: number,\n /**\n * If the server receives a new request after ... seconds, start revalidating new values in the background.\n */\n revalidate?: number,\n /**\n * If this entry has no traffic for ... seconds it will expire. The next request will recompute it.\n */\n expire?: number\n }): void\n `\n\n // Redefine the cacheLife() accepted arguments.\n return `// Type definitions for Next.js cacheLife configs\n\ndeclare module '${PKG_NAME}/cache' {\n export { unstable_cache } from '${PKG_NAME}/dist/server/web/spec-extension/unstable-cache'\n export {\n revalidateTag,\n revalidatePath,\n unstable_expireTag,\n unstable_expirePath,\n } from '${PKG_NAME}/dist/server/web/spec-extension/revalidate'\n export { unstable_noStore } from '${PKG_NAME}/dist/server/web/spec-extension/unstable-no-store'\n\n ${overloads}\n\n export { cacheTag as unstable_cacheTag } from '${PKG_NAME}/dist/server/use-cache/cache-tag'\n}\n`\n}\n\nconst appTypesBasePath = path.join('types', 'app')\n\nexport class NextTypesPlugin {\n dir: string\n distDir: string\n appDir: string\n dev: boolean\n isEdgeServer: boolean\n pageExtensions: string[]\n pagesDir: string\n cacheLifeConfig: undefined | { [profile: string]: CacheLife }\n distDirAbsolutePath: string\n\n constructor(options: Options) {\n this.dir = options.dir\n this.distDir = options.distDir\n this.appDir = options.appDir\n this.dev = options.dev\n this.isEdgeServer = options.isEdgeServer\n this.pageExtensions = options.pageExtensions\n this.pagesDir = path.join(this.appDir, '..', 'pages')\n this.cacheLifeConfig = options.cacheLifeConfig\n this.distDirAbsolutePath = path.join(this.dir, this.distDir)\n }\n\n getRelativePathFromAppTypesDir(moduleRelativePathToAppDir: string) {\n const moduleAbsolutePath = path.join(\n this.appDir,\n moduleRelativePathToAppDir\n )\n\n const moduleInAppTypesAbsolutePath = path.join(\n this.distDirAbsolutePath,\n appTypesBasePath,\n moduleRelativePathToAppDir\n )\n\n return path.relative(\n moduleInAppTypesAbsolutePath + '/..',\n moduleAbsolutePath\n )\n }\n\n collectPage(filePath: string) {\n const isApp = filePath.startsWith(this.appDir + path.sep)\n const isPages = !isApp && filePath.startsWith(this.pagesDir + path.sep)\n\n if (!isApp && !isPages) {\n return\n }\n\n // Filter out non-page and non-route files in app dir\n if (isApp && !/[/\\\\](?:page|route)\\.[^.]+$/.test(filePath)) {\n return\n }\n\n // Filter out non-page files in pages dir\n if (\n isPages &&\n /[/\\\\](?:_app|_document|_error|404|500)\\.[^.]+$/.test(filePath)\n ) {\n return\n }\n\n let route = (isApp ? normalizeAppPath : denormalizePagePath)(\n ensureLeadingSlash(\n getPageFromPath(\n path.relative(isApp ? this.appDir : this.pagesDir, filePath),\n this.pageExtensions\n )\n )\n )\n\n const { isDynamic, routeType } = formatRouteToRouteType(route)\n\n pluginState.routeTypes[this.isEdgeServer ? 'edge' : 'node'][\n isDynamic ? 'dynamic' : 'static'\n ].push(routeType)\n }\n\n apply(compiler: webpack.Compiler) {\n // From asset root to dist root\n const assetDirRelative = this.dev\n ? '..'\n : this.isEdgeServer\n ? '..'\n : '../..'\n\n const handleModule = async (\n mod: webpack.NormalModule,\n compilation: webpack.Compilation\n ) => {\n if (!mod.resource) return\n\n const pageExtensionsRegex = new RegExp(\n `\\\\.(${this.pageExtensions.join('|')})$`\n )\n\n if (!pageExtensionsRegex.test(mod.resource)) return\n\n if (!mod.resource.startsWith(this.appDir + path.sep)) {\n if (!this.dev) {\n if (mod.resource.startsWith(this.pagesDir + path.sep)) {\n this.collectPage(mod.resource)\n }\n }\n return\n }\n if (mod.layer !== WEBPACK_LAYERS.reactServerComponents) return\n\n // skip for /app/_private dir convention\n // matches <app-dir>/**/_*\n const IS_PRIVATE = /(?:\\/[^/]+)*\\/_.*$/.test(\n mod.resource.replace(this.appDir, '')\n )\n if (IS_PRIVATE) return\n\n const IS_LAYOUT = /[/\\\\]layout\\.[^./\\\\]+$/.test(mod.resource)\n const IS_PAGE = !IS_LAYOUT && /[/\\\\]page\\.[^.]+$/.test(mod.resource)\n const IS_ROUTE = !IS_PAGE && /[/\\\\]route\\.[^.]+$/.test(mod.resource)\n const IS_IMPORTABLE = /\\.(js|jsx|ts|tsx|mjs|cjs)$/.test(mod.resource)\n const relativePathToApp = path.relative(this.appDir, mod.resource)\n\n if (!this.dev) {\n if (IS_PAGE || IS_ROUTE) {\n this.collectPage(mod.resource)\n }\n }\n\n const typePath = path.join(\n appTypesBasePath,\n relativePathToApp.replace(pageExtensionsRegex, '.ts')\n )\n const relativeImportPath = normalizePathSep(\n path\n .join(this.getRelativePathFromAppTypesDir(relativePathToApp))\n .replace(pageExtensionsRegex, '')\n )\n\n const assetPath = path.join(assetDirRelative, typePath)\n\n // Typescript won’t allow relative-importing (for example) a .mdx file using the .js extension\n // so for now we only generate “type guard files” for files that typescript can transform\n if (!IS_IMPORTABLE) return\n\n if (IS_LAYOUT) {\n const rootLayoutPath = normalizeAppPath(\n ensureLeadingSlash(\n getPageFromPath(\n path.relative(this.appDir, mod.resource),\n this.pageExtensions\n )\n )\n )\n\n const foundParams = Array.from(\n rootLayoutPath.matchAll(/\\[(.*?)\\]/g),\n (match) => match[1]\n )\n\n pluginState.collectedRootParams[rootLayoutPath] = foundParams\n\n const slots = await collectNamedSlots(mod.resource)\n compilation.emitAsset(\n assetPath,\n new sources.RawSource(\n createTypeGuardFile(mod.resource, relativeImportPath, {\n type: 'layout',\n slots,\n })\n ) as unknown as webpack.sources.RawSource\n )\n } else if (IS_PAGE) {\n compilation.emitAsset(\n assetPath,\n new sources.RawSource(\n createTypeGuardFile(mod.resource, relativeImportPath, {\n type: 'page',\n })\n ) as unknown as webpack.sources.RawSource\n )\n } else if (IS_ROUTE) {\n compilation.emitAsset(\n assetPath,\n new sources.RawSource(\n createTypeGuardFile(mod.resource, relativeImportPath, {\n type: 'route',\n })\n ) as unknown as webpack.sources.RawSource\n )\n }\n }\n\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {\n compilation.hooks.processAssets.tapAsync(\n {\n name: PLUGIN_NAME,\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH,\n },\n async (_, callback) => {\n const promises: Promise<any>[] = []\n\n // Clear routes\n if (this.isEdgeServer) {\n pluginState.routeTypes.edge.dynamic = []\n pluginState.routeTypes.edge.static = []\n } else {\n pluginState.routeTypes.node.dynamic = []\n pluginState.routeTypes.node.static = []\n }\n\n compilation.chunkGroups.forEach((chunkGroup) => {\n chunkGroup.chunks.forEach((chunk) => {\n if (!chunk.name) return\n\n // Here we only track page and route chunks.\n if (\n !chunk.name.startsWith('pages/') &&\n !(\n chunk.name.startsWith('app/') &&\n (chunk.name.endsWith('/page') ||\n chunk.name.endsWith('/route'))\n )\n ) {\n return\n }\n\n const chunkModules =\n compilation.chunkGraph.getChunkModulesIterable(\n chunk\n ) as Iterable<webpack.NormalModule>\n for (const mod of chunkModules) {\n promises.push(handleModule(mod, compilation))\n\n // If this is a concatenation, register each child to the parent ID.\n const anyModule = mod as unknown as {\n modules: webpack.NormalModule[]\n }\n if (anyModule.modules) {\n anyModule.modules.forEach((concatenatedMod) => {\n promises.push(handleModule(concatenatedMod, compilation))\n })\n }\n }\n })\n })\n\n await Promise.all(promises)\n\n const rootParams = getRootParamsFromLayouts(\n pluginState.collectedRootParams\n )\n // If we discovered rootParams, we'll override the `next/server` types\n // since we're able to determine the root params at build time.\n if (rootParams.length > 0) {\n const serverTypesPath = path.join(\n assetDirRelative,\n 'types/server.d.ts'\n )\n\n compilation.emitAsset(\n serverTypesPath,\n new sources.RawSource(\n createServerDefinitions(rootParams)\n ) as unknown as webpack.sources.RawSource\n )\n }\n\n // Support `\"moduleResolution\": \"Node16\" | \"NodeNext\"` with `\"type\": \"module\"`\n\n const packageJsonAssetPath = path.join(\n assetDirRelative,\n 'types/package.json'\n )\n\n compilation.emitAsset(\n packageJsonAssetPath,\n new sources.RawSource(\n '{\"type\": \"module\"}'\n ) as unknown as webpack.sources.RawSource\n )\n\n if (this.cacheLifeConfig) {\n const cacheLifeAssetPath = path.join(\n assetDirRelative,\n 'types/cache-life.d.ts'\n )\n\n compilation.emitAsset(\n cacheLifeAssetPath,\n new sources.RawSource(\n createCustomCacheLifeDefinitions(this.cacheLifeConfig)\n ) as unknown as webpack.sources.RawSource\n )\n }\n\n callback()\n }\n )\n })\n }\n}\n"],"names":["fs","webpack","sources","path","WEBPACK_LAYERS","PKG_NAME","require","name","denormalizePagePath","ensureLeadingSlash","normalizePathSep","HTTP_METHODS","isDynamicRoute","normalizeAppPath","getPageFromPath","getProxiedPluginState","PLUGIN_NAME","createTypeGuardFile","fullPath","relativePath","options","type","map","method","join","slots","slot","collectNamedSlots","layoutPath","layoutDir","dirname","items","readdir","withFileTypes","item","isDirectory","startsWith","push","slice","pluginState","collectedRootParams","routeTypes","edge","static","dynamic","node","extra","formatRouteToRouteType","route","isDynamic","split","part","endsWith","routeType","formatTimespan","seconds","formatTimespanWithSeconds","undefined","text","descriptive","getRootParamsFromLayouts","layouts","sortedLayouts","Object","entries","sort","a","b","length","rootLayout","rootParams","Set","isMultipleRootLayouts","params","allSegmentsAreDynamic","every","segment","test","isSubpath","param","add","result","Array","from","optional","parentLayoutPath","potentialChildLayoutPath","parentSegments","childSegments","childSegment","index","createServerDefinitions","includes","createCustomCacheLifeDefinitions","cacheLife","overloads","profileNames","keys","i","profileName","profile","description","stale","revalidate","expire","JSON","stringify","appTypesBasePath","NextTypesPlugin","constructor","dir","distDir","appDir","dev","isEdgeServer","pageExtensions","pagesDir","cacheLifeConfig","distDirAbsolutePath","getRelativePathFromAppTypesDir","moduleRelativePathToAppDir","moduleAbsolutePath","moduleInAppTypesAbsolutePath","relative","collectPage","filePath","isApp","sep","isPages","apply","compiler","assetDirRelative","handleModule","mod","compilation","resource","pageExtensionsRegex","RegExp","layer","reactServerComponents","IS_PRIVATE","replace","IS_LAYOUT","IS_PAGE","IS_ROUTE","IS_IMPORTABLE","relativePathToApp","typePath","relativeImportPath","assetPath","rootLayoutPath","foundParams","matchAll","match","emitAsset","RawSource","hooks","tap","processAssets","tapAsync","stage","Compilation","PROCESS_ASSETS_STAGE_OPTIMIZE_HASH","_","callback","promises","chunkGroups","forEach","chunkGroup","chunks","chunk","chunkModules","chunkGraph","getChunkModulesIterable","anyModule","modules","concatenatedMod","Promise","all","serverTypesPath","packageJsonAssetPath","cacheLifeAssetPath"],"mappings":"AAEA,OAAOA,QAAQ,cAAa;AAC5B,SAASC,OAAO,EAAEC,OAAO,QAAQ,qCAAoC;AACrE,OAAOC,UAAU,OAAM;AAEvB,SAASC,cAAc,QAAQ,4BAA2B;AAE1D,2DAA2D;AAC3D,MAAMC,WAAWC,QAAQ,+BAA+BC,IAAI;AAC5D,SAASC,mBAAmB,QAAQ,y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FG,YAAYoB,SAAS,CACnB0B,sBACA,IAAIlL,QAAQyJ,SAAS,CACnB;gBAIJ,IAAI,IAAI,CAACtC,eAAe,EAAE;oBACxB,MAAMgE,qBAAqBlL,KAAKqB,IAAI,CAClC2G,kBACA;oBAGFG,YAAYoB,SAAS,CACnB2B,oBACA,IAAInL,QAAQyJ,SAAS,CACnB9D,iCAAiC,IAAI,CAACwB,eAAe;gBAG3D;gBAEA+C;YACF;QAEJ;IACF;AACF","ignoreList":[0]}
|
|
@@ -1575,7 +1575,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
|
1575
1575
|
isClient && new CopyFilePlugin({
|
|
1576
1576
|
// file path to build output of `@next/polyfill-nomodule`
|
|
1577
1577
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
|
1578
|
-
cacheKey: "15.6.0-bun.
|
|
1578
|
+
cacheKey: "15.6.0-bun.28",
|
|
1579
1579
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
|
1580
1580
|
minimize: false,
|
|
1581
1581
|
info: {
|
|
@@ -1756,7 +1756,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
|
1756
1756
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
|
1757
1757
|
// - Next.js version
|
|
1758
1758
|
// - next.config.js keys that affect compilation
|
|
1759
|
-
version: `${__dirname}|${"15.6.0-bun.
|
|
1759
|
+
version: `${__dirname}|${"15.6.0-bun.28"}|${configVars}`,
|
|
1760
1760
|
cacheDirectory: path.join(distDir, 'cache', 'webpack'),
|
|
1761
1761
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
|
1762
1762
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - next/script with `beforeInteractive` strategy
|
|
6
6
|
*/ import { getAssetPrefix } from './asset-prefix';
|
|
7
7
|
import { setAttributesFromProps } from './set-attributes-from-props';
|
|
8
|
-
const version = "15.6.0-bun.
|
|
8
|
+
const version = "15.6.0-bun.28";
|
|
9
9
|
window.next = {
|
|
10
10
|
version,
|
|
11
11
|
appDir: true
|
package/dist/esm/client/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import { SearchParamsContext, PathParamsContext } from '../shared/lib/hooks-clie
|
|
|
26
26
|
import { onRecoverableError } from './react-client-callbacks/on-recoverable-error';
|
|
27
27
|
import tracer from './tracing/tracer';
|
|
28
28
|
import { isNextRouterError } from './components/is-next-router-error';
|
|
29
|
-
export const version = "15.6.0-bun.
|
|
29
|
+
export const version = "15.6.0-bun.28";
|
|
30
30
|
export let router;
|
|
31
31
|
export const emitter = mitt();
|
|
32
32
|
const looseToArray = (input)=>[].slice.call(input);
|
|
@@ -158,7 +158,7 @@ export default class HotReloaderWebpack {
|
|
|
158
158
|
this.previewProps = previewProps;
|
|
159
159
|
this.rewrites = rewrites;
|
|
160
160
|
this.hotReloaderSpan = trace('hot-reloader', undefined, {
|
|
161
|
-
version: "15.6.0-bun.
|
|
161
|
+
version: "15.6.0-bun.28"
|
|
162
162
|
});
|
|
163
163
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
164
164
|
// of the current `next dev` invocation.
|
|
@@ -14,7 +14,7 @@ export function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures
|
|
|
14
14
|
bundlerSuffix = ' (webpack)';
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.6.0-bun.
|
|
17
|
+
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.6.0-bun.28"}`))}${bundlerSuffix}`);
|
|
18
18
|
if (appUrl) {
|
|
19
19
|
Log.bootstrap(`- Local: ${appUrl}`);
|
|
20
20
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { isDynamicRoute } from '../../../shared/lib/router/utils/is-dynamic';
|
|
2
|
+
// Read package name dynamically to support forked packages
|
|
3
|
+
const PKG_NAME = require('../../../../../package.json').name;
|
|
2
4
|
function generateRouteTypes(routesManifest) {
|
|
3
5
|
const appRoutes = Object.keys(routesManifest.appRoutes).sort();
|
|
4
6
|
const pageRoutes = Object.keys(routesManifest.pageRoutes).sort();
|
|
@@ -224,18 +226,18 @@ declare namespace __next_route_internal_types__ {
|
|
|
224
226
|
`}
|
|
225
227
|
}
|
|
226
228
|
|
|
227
|
-
declare module '
|
|
228
|
-
export { default } from '
|
|
229
|
-
export * from '
|
|
229
|
+
declare module '${PKG_NAME}' {
|
|
230
|
+
export { default } from '${PKG_NAME}/types.js'
|
|
231
|
+
export * from '${PKG_NAME}/types.js'
|
|
230
232
|
|
|
231
233
|
export type Route<T extends string = string> =
|
|
232
234
|
__next_route_internal_types__.RouteImpl<T>
|
|
233
235
|
}
|
|
234
236
|
|
|
235
|
-
declare module '
|
|
236
|
-
export { useLinkStatus } from '
|
|
237
|
+
declare module '${PKG_NAME}/link' {
|
|
238
|
+
export { useLinkStatus } from '${PKG_NAME}/dist/client/link.js'
|
|
237
239
|
|
|
238
|
-
import type { LinkProps as OriginalLinkProps } from '
|
|
240
|
+
import type { LinkProps as OriginalLinkProps } from '${PKG_NAME}/dist/client/link.js'
|
|
239
241
|
import type { AnchorHTMLAttributes, DetailedHTMLProps } from 'react'
|
|
240
242
|
import type { UrlObject } from 'url'
|
|
241
243
|
|
|
@@ -262,11 +264,11 @@ declare module 'next/link' {
|
|
|
262
264
|
export default function Link<RouteType>(props: LinkProps<RouteType>): JSX.Element
|
|
263
265
|
}
|
|
264
266
|
|
|
265
|
-
declare module '
|
|
266
|
-
export * from '
|
|
267
|
+
declare module '${PKG_NAME}/navigation' {
|
|
268
|
+
export * from '${PKG_NAME}/dist/client/components/navigation.js'
|
|
267
269
|
|
|
268
|
-
import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from '
|
|
269
|
-
import type { RedirectType } from '
|
|
270
|
+
import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from '${PKG_NAME}/dist/shared/lib/app-router-context.shared-runtime.js'
|
|
271
|
+
import type { RedirectType } from '${PKG_NAME}/dist/client/components/redirect-error.js'
|
|
270
272
|
|
|
271
273
|
interface AppRouterInstance extends OriginalAppRouterInstance {
|
|
272
274
|
/**
|
|
@@ -323,8 +325,8 @@ declare module 'next/navigation' {
|
|
|
323
325
|
): never;
|
|
324
326
|
}
|
|
325
327
|
|
|
326
|
-
declare module '
|
|
327
|
-
import type { FormProps as OriginalFormProps } from '
|
|
328
|
+
declare module '${PKG_NAME}/form' {
|
|
329
|
+
import type { FormProps as OriginalFormProps } from '${PKG_NAME}/dist/client/form.js'
|
|
328
330
|
|
|
329
331
|
type FormRestProps = Omit<OriginalFormProps, 'action'>
|
|
330
332
|
|
|
@@ -476,7 +478,7 @@ export function generateValidatorFile(routesManifest) {
|
|
|
476
478
|
routeImports.push('AppRouteHandlerRoutes');
|
|
477
479
|
}
|
|
478
480
|
const routeImportStatement = routeImports.length > 0 ? `import type { ${routeImports.join(', ')} } from "./routes.js"` : '';
|
|
479
|
-
const nextRequestImport = hasAppRouteHandlers ?
|
|
481
|
+
const nextRequestImport = hasAppRouteHandlers ? `import type { NextRequest } from '${PKG_NAME}/server.js'\n` : '';
|
|
480
482
|
// Conditionally import types from next/types, merged into a single statement
|
|
481
483
|
const nextTypes = [];
|
|
482
484
|
if (pagesApiRouteValidations) {
|
|
@@ -485,7 +487,7 @@ export function generateValidatorFile(routesManifest) {
|
|
|
485
487
|
if (appPageValidations || layoutValidations) {
|
|
486
488
|
nextTypes.push('ResolvingMetadata', 'ResolvingViewport');
|
|
487
489
|
}
|
|
488
|
-
const nextTypesImport = nextTypes.length > 0 ? `import type { ${nextTypes.join(', ')} } from "
|
|
490
|
+
const nextTypesImport = nextTypes.length > 0 ? `import type { ${nextTypes.join(', ')} } from "${PKG_NAME}/types.js"\n` : '';
|
|
489
491
|
return `// This file is generated automatically by Next.js
|
|
490
492
|
// Do not edit this file manually
|
|
491
493
|
// This file validates that all pages and layouts export the correct types
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/server/lib/router-utils/typegen.ts"],"sourcesContent":["import type { RouteTypesManifest } from './route-types-utils'\nimport { isDynamicRoute } from '../../../shared/lib/router/utils/is-dynamic'\n\nfunction generateRouteTypes(routesManifest: RouteTypesManifest): string {\n const appRoutes = Object.keys(routesManifest.appRoutes).sort()\n const pageRoutes = Object.keys(routesManifest.pageRoutes).sort()\n const layoutRoutes = Object.keys(routesManifest.layoutRoutes).sort()\n const redirectRoutes = Object.keys(routesManifest.redirectRoutes).sort()\n const rewriteRoutes = Object.keys(routesManifest.rewriteRoutes).sort()\n\n let result = ''\n\n // Generate AppRoutes union type (pages only)\n if (appRoutes.length > 0) {\n result += `type AppRoutes = ${appRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type AppRoutes = never\\n'\n }\n\n // Generate AppRouteHandlerRoutes union type for route handlers\n const appRouteHandlerRoutes = Object.keys(\n routesManifest.appRouteHandlerRoutes\n ).sort()\n\n const hasAppRouteHandlers = appRouteHandlerRoutes.length > 0\n\n if (hasAppRouteHandlers) {\n result += `type AppRouteHandlerRoutes = ${appRouteHandlerRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n }\n\n // Generate PageRoutes union type\n if (pageRoutes.length > 0) {\n result += `type PageRoutes = ${pageRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type PageRoutes = never\\n'\n }\n\n // Generate LayoutRoutes union type\n if (layoutRoutes.length > 0) {\n result += `type LayoutRoutes = ${layoutRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type LayoutRoutes = never\\n'\n }\n\n // Generate RedirectRoutes union type\n if (redirectRoutes.length > 0) {\n result += `type RedirectRoutes = ${redirectRoutes\n .map((route) => JSON.stringify(route))\n .join(' | ')}\\n`\n } else {\n result += 'type RedirectRoutes = never\\n'\n }\n\n // Generate RewriteRoutes union type\n if (rewriteRoutes.length > 0) {\n result += `type RewriteRoutes = ${rewriteRoutes\n .map((route) => JSON.stringify(route))\n .join(' | ')}\\n`\n } else {\n result += 'type RewriteRoutes = never\\n'\n }\n\n // Only include AppRouteHandlerRoutes in Routes union if there are actual route handlers\n const routeUnionParts = [\n 'AppRoutes',\n 'PageRoutes',\n 'LayoutRoutes',\n 'RedirectRoutes',\n 'RewriteRoutes',\n ]\n if (hasAppRouteHandlers) {\n routeUnionParts.push('AppRouteHandlerRoutes')\n }\n\n result += `type Routes = ${routeUnionParts.join(' | ')}\\n`\n\n return result\n}\n\nfunction generateParamTypes(routesManifest: RouteTypesManifest): string {\n const allRoutes = {\n ...routesManifest.appRoutes,\n ...routesManifest.appRouteHandlerRoutes,\n ...routesManifest.pageRoutes,\n ...routesManifest.layoutRoutes,\n ...routesManifest.redirectRoutes,\n ...routesManifest.rewriteRoutes,\n }\n\n let paramTypes = 'interface ParamMap {\\n'\n\n // Sort routes deterministically for consistent output\n const sortedRoutes = Object.entries(allRoutes).sort(([a], [b]) =>\n a.localeCompare(b)\n )\n\n for (const [route, routeInfo] of sortedRoutes) {\n const { groups } = routeInfo\n\n // For static routes (no dynamic segments), we can produce an empty parameter map.\n if (!isDynamicRoute(route) || Object.keys(groups ?? {}).length === 0) {\n paramTypes += ` ${JSON.stringify(route)}: {}\\n`\n continue\n }\n\n let paramType = '{'\n\n // Process each group based on its properties\n for (const [key, group] of Object.entries(groups)) {\n const escapedKey = JSON.stringify(key)\n if (group.repeat) {\n // Catch-all parameters\n if (group.optional) {\n paramType += ` ${escapedKey}?: string[];`\n } else {\n paramType += ` ${escapedKey}: string[];`\n }\n } else {\n // Regular parameters\n if (group.optional) {\n paramType += ` ${escapedKey}?: string;`\n } else {\n paramType += ` ${escapedKey}: string;`\n }\n }\n }\n\n paramType += ' }'\n\n paramTypes += ` ${JSON.stringify(route)}: ${paramType}\\n`\n }\n\n paramTypes += '}\\n'\n return paramTypes\n}\n\nfunction generateLayoutSlotMap(routesManifest: RouteTypesManifest): string {\n let slotMap = 'interface LayoutSlotMap {\\n'\n\n // Sort routes deterministically for consistent output\n const sortedLayoutRoutes = Object.entries(routesManifest.layoutRoutes).sort(\n ([a], [b]) => a.localeCompare(b)\n )\n\n for (const [route, routeInfo] of sortedLayoutRoutes) {\n if ('slots' in routeInfo) {\n const slots = routeInfo.slots.sort()\n if (slots.length > 0) {\n slotMap += ` ${JSON.stringify(route)}: ${slots.map((slot) => JSON.stringify(slot)).join(' | ')}\\n`\n } else {\n slotMap += ` ${JSON.stringify(route)}: never\\n`\n }\n } else {\n slotMap += ` ${JSON.stringify(route)}: never\\n`\n }\n }\n\n slotMap += '}\\n'\n return slotMap\n}\n\n// Helper function to format routes to route types (matches the plugin logic exactly)\nfunction formatRouteToRouteType(route: string) {\n const isDynamic = isDynamicRoute(route)\n if (isDynamic) {\n route = route\n .split('/')\n .map((part) => {\n if (part.startsWith('[') && part.endsWith(']')) {\n if (part.startsWith('[...')) {\n // /[...slug]\n return `\\${CatchAllSlug<T>}`\n } else if (part.startsWith('[[...') && part.endsWith(']]')) {\n // /[[...slug]]\n return `\\${OptionalCatchAllSlug<T>}`\n }\n // /[slug]\n return `\\${SafeSlug<T>}`\n }\n return part\n })\n .join('/')\n }\n\n return {\n isDynamic,\n routeType: route,\n }\n}\n\n// Helper function to serialize route types (matches the plugin logic exactly)\nfunction serializeRouteTypes(routeTypes: string[]) {\n // route collection is not deterministic, this makes the output of the file deterministic\n return routeTypes\n .sort()\n .map((route) => `\\n | \\`${route}\\``)\n .join('')\n}\n\nexport function generateLinkTypesFile(\n routesManifest: RouteTypesManifest\n): string {\n // Generate serialized static and dynamic routes for the internal namespace\n // Build a unified set of routes across app/pages/redirect/rewrite as well as\n // app route handlers and Pages Router API routes.\n const allRoutesSet = new Set<string>([\n ...Object.keys(routesManifest.appRoutes),\n ...Object.keys(routesManifest.pageRoutes),\n ...Object.keys(routesManifest.redirectRoutes),\n ...Object.keys(routesManifest.rewriteRoutes),\n // Allow linking to App Route Handlers (e.g. `/logout/route.ts`)\n ...Object.keys(routesManifest.appRouteHandlerRoutes),\n // Allow linking to Pages Router API routes (e.g. `/api/*`)\n ...Array.from(routesManifest.pageApiRoutes),\n ])\n\n const staticRouteTypes: string[] = []\n const dynamicRouteTypes: string[] = []\n\n // Process each route using the same logic as the plugin\n for (const route of allRoutesSet) {\n const { isDynamic, routeType } = formatRouteToRouteType(route)\n if (isDynamic) {\n dynamicRouteTypes.push(routeType)\n } else {\n staticRouteTypes.push(routeType)\n }\n }\n\n const serializedStaticRouteTypes = serializeRouteTypes(staticRouteTypes)\n const serializedDynamicRouteTypes = serializeRouteTypes(dynamicRouteTypes)\n\n // If both StaticRoutes and DynamicRoutes are empty, fallback to type 'string & {}'.\n const routeTypesFallback =\n !serializedStaticRouteTypes && !serializedDynamicRouteTypes\n ? 'string & {}'\n : ''\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n\n// Type definitions for Next.js routes\n\n/**\n * Internal types used by the Next.js router and Link component.\n * These types are not meant to be used directly.\n * @internal\n */\ndeclare namespace __next_route_internal_types__ {\n type SearchOrHash = \\`?\\${string}\\` | \\`#\\${string}\\`\n type WithProtocol = \\`\\${string}:\\${string}\\`\n\n type Suffix = '' | SearchOrHash\n\n type SafeSlug<S extends string> = S extends \\`\\${string}/\\${string}\\`\n ? never\n : S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S\n\n type CatchAllSlug<S extends string> = S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S\n\n type OptionalCatchAllSlug<S extends string> =\n S extends \\`\\${string}\\${SearchOrHash}\\` ? never : S\n\n type StaticRoutes = ${serializedStaticRouteTypes || 'never'}\n type DynamicRoutes<T extends string = string> = ${\n serializedDynamicRouteTypes || 'never'\n }\n\n type RouteImpl<T> = ${\n routeTypesFallback ||\n `\n ${\n // This keeps autocompletion working for static routes.\n '| StaticRoutes'\n }\n | SearchOrHash\n | WithProtocol\n | \\`\\${StaticRoutes}\\${SearchOrHash}\\`\n | (T extends \\`\\${DynamicRoutes<infer _>}\\${Suffix}\\` ? T : never)\n `\n }\n}\n\ndeclare module 'next' {\n export { default } from 'next/types.js'\n export * from 'next/types.js'\n\n export type Route<T extends string = string> =\n __next_route_internal_types__.RouteImpl<T>\n}\n\ndeclare module 'next/link' {\n export { useLinkStatus } from 'next/dist/client/link.js'\n\n import type { LinkProps as OriginalLinkProps } from 'next/dist/client/link.js'\n import type { AnchorHTMLAttributes, DetailedHTMLProps } from 'react'\n import type { UrlObject } from 'url'\n\n type LinkRestProps = Omit<\n Omit<\n DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n >,\n keyof OriginalLinkProps\n > &\n OriginalLinkProps,\n 'href'\n >\n\n export type LinkProps<RouteInferType> = LinkRestProps & {\n /**\n * The path or URL to navigate to. This is the only required prop. It can also be an object.\n * @see https://nextjs.org/docs/api-reference/next/link\n */\n href: __next_route_internal_types__.RouteImpl<RouteInferType> | UrlObject\n }\n\n export default function Link<RouteType>(props: LinkProps<RouteType>): JSX.Element\n}\n\ndeclare module 'next/navigation' {\n export * from 'next/dist/client/components/navigation.js'\n\n import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime.js'\n import type { RedirectType } from 'next/dist/client/components/redirect-error.js'\n \n interface AppRouterInstance extends OriginalAppRouterInstance {\n /**\n * Navigate to the provided href.\n * Pushes a new history entry.\n */\n push<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>, options?: NavigateOptions): void\n /**\n * Navigate to the provided href.\n * Replaces the current history entry.\n */\n replace<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>, options?: NavigateOptions): void\n /**\n * Prefetch the provided href.\n */\n prefetch<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>): void\n }\n\n export function useRouter(): AppRouterInstance;\n \n /**\n * This function allows you to redirect the user to another URL. It can be used in\n * [Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components),\n * [Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers), and\n * [Server Actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations).\n *\n * - In a Server Component, this will insert a meta tag to redirect the user to the target page.\n * - In a Route Handler or Server Action, it will serve a 307/303 to the caller.\n * - In a Server Action, type defaults to 'push' and 'replace' elsewhere.\n *\n * Read more: [Next.js Docs: redirect](https://nextjs.org/docs/app/api-reference/functions/redirect)\n */\n export function redirect<RouteType>(\n /** The URL to redirect to */\n url: __next_route_internal_types__.RouteImpl<RouteType>,\n type?: RedirectType\n ): never;\n \n /**\n * This function allows you to redirect the user to another URL. It can be used in\n * [Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components),\n * [Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers), and\n * [Server Actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations).\n *\n * - In a Server Component, this will insert a meta tag to redirect the user to the target page.\n * - In a Route Handler or Server Action, it will serve a 308/303 to the caller.\n *\n * Read more: [Next.js Docs: redirect](https://nextjs.org/docs/app/api-reference/functions/redirect)\n */\n export function permanentRedirect<RouteType>(\n /** The URL to redirect to */\n url: __next_route_internal_types__.RouteImpl<RouteType>,\n type?: RedirectType\n ): never;\n}\n\ndeclare module 'next/form' {\n import type { FormProps as OriginalFormProps } from 'next/dist/client/form.js'\n\n type FormRestProps = Omit<OriginalFormProps, 'action'>\n\n export type FormProps<RouteInferType> = {\n /**\n * \\`action\\` can be either a \\`string\\` or a function.\n * - If \\`action\\` is a string, it will be interpreted as a path or URL to navigate to when the form is submitted.\n * The path will be prefetched when the form becomes visible.\n * - If \\`action\\` is a function, it will be called when the form is submitted. See the [React docs](https://react.dev/reference/react-dom/components/form#props) for more.\n */\n action: __next_route_internal_types__.RouteImpl<RouteInferType> | ((formData: FormData) => void)\n } & FormRestProps\n\n export default function Form<RouteType>(props: FormProps<RouteType>): JSX.Element\n}\n`\n}\n\nexport function generateValidatorFile(\n routesManifest: RouteTypesManifest\n): string {\n const generateValidations = (\n paths: string[],\n type:\n | 'AppPageConfig'\n | 'PagesPageConfig'\n | 'LayoutConfig'\n | 'RouteHandlerConfig'\n | 'ApiRouteConfig',\n pathToRouteMap?: Map<string, string>\n ) =>\n paths\n .sort()\n // Only validate TypeScript files - JavaScript files have too many type inference limitations\n .filter(\n (filePath) => filePath.endsWith('.ts') || filePath.endsWith('.tsx')\n )\n .filter(\n // Don't include metadata routes or pages\n // (e.g. /manifest.webmanifest)\n (filePath) =>\n type !== 'AppPageConfig' ||\n filePath.endsWith('page.ts') ||\n filePath.endsWith('page.tsx')\n )\n .map((filePath) => {\n // Keep the file extension for TypeScript imports to support node16 module resolution\n const importPath = filePath\n const route = pathToRouteMap?.get(filePath)\n const typeWithRoute =\n route &&\n (type === 'AppPageConfig' ||\n type === 'LayoutConfig' ||\n type === 'RouteHandlerConfig')\n ? `${type}<${JSON.stringify(route)}>`\n : type\n\n // NOTE: we previously used `satisfies` here, but it's not supported by TypeScript 4.8 and below.\n // If we ever raise the TS minimum version, we can switch back.\n\n return `// Validate ${filePath}\n{\n type __IsExpected<Specific extends ${typeWithRoute}> = Specific\n const handler = {} as typeof import(${JSON.stringify(\n importPath.replace(/\\.tsx?$/, '.js')\n )})\n type __Check = __IsExpected<typeof handler>\n // @ts-ignore\n type __Unused = __Check\n}`\n })\n .join('\\n\\n')\n\n // Use direct mappings from the manifest\n\n // Generate validations for different route types\n const appPageValidations = generateValidations(\n Array.from(routesManifest.appPagePaths).sort(),\n 'AppPageConfig',\n routesManifest.filePathToRoute\n )\n const appRouteHandlerValidations = generateValidations(\n Array.from(routesManifest.appRouteHandlers).sort(),\n 'RouteHandlerConfig',\n routesManifest.filePathToRoute\n )\n const pagesRouterPageValidations = generateValidations(\n Array.from(routesManifest.pagesRouterPagePaths).sort(),\n 'PagesPageConfig'\n )\n const pagesApiRouteValidations = generateValidations(\n Array.from(routesManifest.pageApiRoutes).sort(),\n 'ApiRouteConfig'\n )\n const layoutValidations = generateValidations(\n Array.from(routesManifest.layoutPaths).sort(),\n 'LayoutConfig',\n routesManifest.filePathToRoute\n )\n\n const hasAppRouteHandlers =\n Object.keys(routesManifest.appRouteHandlerRoutes).length > 0\n\n // Build type definitions based on what's actually used\n let typeDefinitions = ''\n\n if (appPageValidations) {\n typeDefinitions += `type AppPageConfig<Route extends AppRoutes = AppRoutes> = {\n default: React.ComponentType<{ params: Promise<ParamMap[Route]> } & any> | ((props: { params: Promise<ParamMap[Route]> } & any) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)\n generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise<any[]> | any[]\n generateMetadata?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingMetadata\n ) => Promise<any> | any\n generateViewport?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingViewport\n ) => Promise<any> | any\n metadata?: any\n viewport?: any\n}\n\n`\n }\n\n if (pagesRouterPageValidations) {\n typeDefinitions += `type PagesPageConfig = {\n default: React.ComponentType<any> | ((props: any) => React.ReactNode | Promise<React.ReactNode> | never | void)\n getStaticProps?: (context: any) => Promise<any> | any\n getStaticPaths?: (context: any) => Promise<any> | any\n getServerSideProps?: (context: any) => Promise<any> | any\n getInitialProps?: (context: any) => Promise<any> | any\n /**\n * Segment configuration for legacy Pages Router pages.\n * Validated at build-time by parsePagesSegmentConfig.\n */\n config?: {\n amp?: boolean | 'hybrid' | string // necessary for JS\n maxDuration?: number\n runtime?: 'edge' | 'experimental-edge' | 'nodejs' | string // necessary unless config is exported as const\n regions?: string[]\n }\n}\n\n`\n }\n\n if (layoutValidations) {\n typeDefinitions += `type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {\n default: React.ComponentType<LayoutProps<Route>> | ((props: LayoutProps<Route>) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)\n generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise<any[]> | any[]\n generateMetadata?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingMetadata\n ) => Promise<any> | any\n generateViewport?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingViewport\n ) => Promise<any> | any\n metadata?: any\n viewport?: any\n}\n\n`\n }\n\n if (appRouteHandlerValidations) {\n typeDefinitions += `type RouteHandlerConfig<Route extends AppRouteHandlerRoutes = AppRouteHandlerRoutes> = {\n GET?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n POST?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n PUT?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n PATCH?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n DELETE?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n HEAD?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n OPTIONS?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n}\n\n`\n }\n\n if (pagesApiRouteValidations) {\n typeDefinitions += `type ApiRouteConfig = {\n default: (req: any, res: any) => ReturnType<NextApiHandler>\n config?: {\n api?: {\n bodyParser?: boolean | { sizeLimit?: string }\n responseLimit?: string | number | boolean\n externalResolver?: boolean\n }\n runtime?: 'edge' | 'experimental-edge' | 'nodejs' | string // necessary unless config is exported as const\n maxDuration?: number\n }\n}\n\n`\n }\n\n // Build import statement based on what's actually needed\n const routeImports = []\n\n // Only import AppRoutes if there are app pages\n if (appPageValidations) {\n routeImports.push('AppRoutes')\n }\n\n // Only import LayoutRoutes if there are layouts\n if (layoutValidations) {\n routeImports.push('LayoutRoutes')\n }\n\n // Only import ParamMap if there are routes that use it\n if (appPageValidations || layoutValidations || appRouteHandlerValidations) {\n routeImports.push('ParamMap')\n }\n\n if (hasAppRouteHandlers) {\n routeImports.push('AppRouteHandlerRoutes')\n }\n\n const routeImportStatement =\n routeImports.length > 0\n ? `import type { ${routeImports.join(', ')} } from \"./routes.js\"`\n : ''\n\n const nextRequestImport = hasAppRouteHandlers\n ? \"import type { NextRequest } from 'next/server.js'\\n\"\n : ''\n\n // Conditionally import types from next/types, merged into a single statement\n const nextTypes: string[] = []\n if (pagesApiRouteValidations) {\n nextTypes.push('NextApiHandler')\n }\n if (appPageValidations || layoutValidations) {\n nextTypes.push('ResolvingMetadata', 'ResolvingViewport')\n }\n const nextTypesImport =\n nextTypes.length > 0\n ? `import type { ${nextTypes.join(', ')} } from \"next/types.js\"\\n`\n : ''\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n// This file validates that all pages and layouts export the correct types\n\n${routeImportStatement}\n${nextTypesImport}${nextRequestImport}\n${typeDefinitions}\n${appPageValidations}\n\n${appRouteHandlerValidations}\n\n${pagesRouterPageValidations}\n\n${pagesApiRouteValidations}\n\n${layoutValidations}\n`\n}\n\nexport function generateRouteTypesFile(\n routesManifest: RouteTypesManifest\n): string {\n const routeTypes = generateRouteTypes(routesManifest)\n const paramTypes = generateParamTypes(routesManifest)\n const layoutSlotMap = generateLayoutSlotMap(routesManifest)\n\n const hasAppRouteHandlers =\n Object.keys(routesManifest.appRouteHandlerRoutes).length > 0\n\n // Build export statement based on what's actually generated\n const routeExports = [\n 'AppRoutes',\n 'PageRoutes',\n 'LayoutRoutes',\n 'RedirectRoutes',\n 'RewriteRoutes',\n 'ParamMap',\n ]\n if (hasAppRouteHandlers) {\n routeExports.push('AppRouteHandlerRoutes')\n }\n\n const exportStatement = `export type { ${routeExports.join(', ')} }`\n\n const routeContextInterface = hasAppRouteHandlers\n ? `\n\n /**\n * Context for Next.js App Router route handlers\n * @example\n * \\`\\`\\`tsx\n * export async function GET(request: NextRequest, context: RouteContext<'/api/users/[id]'>) {\n * const { id } = await context.params\n * return Response.json({ id })\n * }\n * \\`\\`\\`\n */\n interface RouteContext<AppRouteHandlerRoute extends AppRouteHandlerRoutes> {\n params: Promise<ParamMap[AppRouteHandlerRoute]>\n }`\n : ''\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n\n${routeTypes}\n\n${paramTypes}\n\nexport type ParamsOf<Route extends Routes> = ParamMap[Route]\n\n${layoutSlotMap}\n\n${exportStatement}\n\ndeclare global {\n /**\n * Props for Next.js App Router page components\n * @example\n * \\`\\`\\`tsx\n * export default function Page(props: PageProps<'/blog/[slug]'>) {\n * const { slug } = await props.params\n * return <div>Blog post: {slug}</div>\n * }\n * \\`\\`\\`\n */\n interface PageProps<AppRoute extends AppRoutes> {\n params: Promise<ParamMap[AppRoute]>\n searchParams: Promise<Record<string, string | string[] | undefined>>\n }\n\n /**\n * Props for Next.js App Router layout components\n * @example\n * \\`\\`\\`tsx\n * export default function Layout(props: LayoutProps<'/dashboard'>) {\n * return <div>{props.children}</div>\n * }\n * \\`\\`\\`\n */\n type LayoutProps<LayoutRoute extends LayoutRoutes> = {\n params: Promise<ParamMap[LayoutRoute]>\n children: React.ReactNode\n } & {\n [K in LayoutSlotMap[LayoutRoute]]: React.ReactNode\n }${routeContextInterface}\n}\n`\n}\n"],"names":["isDynamicRoute","generateRouteTypes","routesManifest","appRoutes","Object","keys","sort","pageRoutes","layoutRoutes","redirectRoutes","rewriteRoutes","result","length","map","route","JSON","stringify","join","appRouteHandlerRoutes","hasAppRouteHandlers","routeUnionParts","push","generateParamTypes","allRoutes","paramTypes","sortedRoutes","entries","a","b","localeCompare","routeInfo","groups","paramType","key","group","escapedKey","repeat","optional","generateLayoutSlotMap","slotMap","sortedLayoutRoutes","slots","slot","formatRouteToRouteType","isDynamic","split","part","startsWith","endsWith","routeType","serializeRouteTypes","routeTypes","generateLinkTypesFile","allRoutesSet","Set","Array","from","pageApiRoutes","staticRouteTypes","dynamicRouteTypes","serializedStaticRouteTypes","serializedDynamicRouteTypes","routeTypesFallback","generateValidatorFile","generateValidations","paths","type","pathToRouteMap","filter","filePath","importPath","get","typeWithRoute","replace","appPageValidations","appPagePaths","filePathToRoute","appRouteHandlerValidations","appRouteHandlers","pagesRouterPageValidations","pagesRouterPagePaths","pagesApiRouteValidations","layoutValidations","layoutPaths","typeDefinitions","routeImports","routeImportStatement","nextRequestImport","nextTypes","nextTypesImport","generateRouteTypesFile","layoutSlotMap","routeExports","exportStatement","routeContextInterface"],"mappings":"AACA,SAASA,cAAc,QAAQ,8CAA6C;AAE5E,SAASC,mBAAmBC,cAAkC;IAC5D,MAAMC,YAAYC,OAAOC,IAAI,CAACH,eAAeC,SAAS,EAAEG,IAAI;IAC5D,MAAMC,aAAaH,OAAOC,IAAI,CAACH,eAAeK,UAAU,EAAED,IAAI;IAC9D,MAAME,eAAeJ,OAAOC,IAAI,CAACH,eAAeM,YAAY,EAAEF,IAAI;IAClE,MAAMG,iBAAiBL,OAAOC,IAAI,CAACH,eAAeO,cAAc,EAAEH,IAAI;IACtE,MAAMI,gBAAgBN,OAAOC,IAAI,CAACH,eAAeQ,aAAa,EAAEJ,IAAI;IAEpE,IAAIK,SAAS;IAEb,6CAA6C;IAC7C,IAAIR,UAAUS,MAAM,GAAG,GAAG;QACxBD,UAAU,CAAC,iBAAiB,EAAER,UAAUU,GAAG,CAAC,CAACC,QAAUC,KAAKC,SAAS,CAACF,QAAQG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC/F,OAAO;QACLN,UAAU;IACZ;IAEA,+DAA+D;IAC/D,MAAMO,wBAAwBd,OAAOC,IAAI,CACvCH,eAAegB,qBAAqB,EACpCZ,IAAI;IAEN,MAAMa,sBAAsBD,sBAAsBN,MAAM,GAAG;IAE3D,IAAIO,qBAAqB;QACvBR,UAAU,CAAC,6BAA6B,EAAEO,sBAAsBL,GAAG,CAAC,CAACC,QAAUC,KAAKC,SAAS,CAACF,QAAQG,IAAI,CAAC,OAAO,EAAE,CA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
|
|
1
|
+
{"version":3,"sources":["../../../../src/server/lib/router-utils/typegen.ts"],"sourcesContent":["import type { RouteTypesManifest } from './route-types-utils'\nimport { isDynamicRoute } from '../../../shared/lib/router/utils/is-dynamic'\n\n// Read package name dynamically to support forked packages\nconst PKG_NAME = require('../../../../../package.json').name\n\nfunction generateRouteTypes(routesManifest: RouteTypesManifest): string {\n const appRoutes = Object.keys(routesManifest.appRoutes).sort()\n const pageRoutes = Object.keys(routesManifest.pageRoutes).sort()\n const layoutRoutes = Object.keys(routesManifest.layoutRoutes).sort()\n const redirectRoutes = Object.keys(routesManifest.redirectRoutes).sort()\n const rewriteRoutes = Object.keys(routesManifest.rewriteRoutes).sort()\n\n let result = ''\n\n // Generate AppRoutes union type (pages only)\n if (appRoutes.length > 0) {\n result += `type AppRoutes = ${appRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type AppRoutes = never\\n'\n }\n\n // Generate AppRouteHandlerRoutes union type for route handlers\n const appRouteHandlerRoutes = Object.keys(\n routesManifest.appRouteHandlerRoutes\n ).sort()\n\n const hasAppRouteHandlers = appRouteHandlerRoutes.length > 0\n\n if (hasAppRouteHandlers) {\n result += `type AppRouteHandlerRoutes = ${appRouteHandlerRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n }\n\n // Generate PageRoutes union type\n if (pageRoutes.length > 0) {\n result += `type PageRoutes = ${pageRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type PageRoutes = never\\n'\n }\n\n // Generate LayoutRoutes union type\n if (layoutRoutes.length > 0) {\n result += `type LayoutRoutes = ${layoutRoutes.map((route) => JSON.stringify(route)).join(' | ')}\\n`\n } else {\n result += 'type LayoutRoutes = never\\n'\n }\n\n // Generate RedirectRoutes union type\n if (redirectRoutes.length > 0) {\n result += `type RedirectRoutes = ${redirectRoutes\n .map((route) => JSON.stringify(route))\n .join(' | ')}\\n`\n } else {\n result += 'type RedirectRoutes = never\\n'\n }\n\n // Generate RewriteRoutes union type\n if (rewriteRoutes.length > 0) {\n result += `type RewriteRoutes = ${rewriteRoutes\n .map((route) => JSON.stringify(route))\n .join(' | ')}\\n`\n } else {\n result += 'type RewriteRoutes = never\\n'\n }\n\n // Only include AppRouteHandlerRoutes in Routes union if there are actual route handlers\n const routeUnionParts = [\n 'AppRoutes',\n 'PageRoutes',\n 'LayoutRoutes',\n 'RedirectRoutes',\n 'RewriteRoutes',\n ]\n if (hasAppRouteHandlers) {\n routeUnionParts.push('AppRouteHandlerRoutes')\n }\n\n result += `type Routes = ${routeUnionParts.join(' | ')}\\n`\n\n return result\n}\n\nfunction generateParamTypes(routesManifest: RouteTypesManifest): string {\n const allRoutes = {\n ...routesManifest.appRoutes,\n ...routesManifest.appRouteHandlerRoutes,\n ...routesManifest.pageRoutes,\n ...routesManifest.layoutRoutes,\n ...routesManifest.redirectRoutes,\n ...routesManifest.rewriteRoutes,\n }\n\n let paramTypes = 'interface ParamMap {\\n'\n\n // Sort routes deterministically for consistent output\n const sortedRoutes = Object.entries(allRoutes).sort(([a], [b]) =>\n a.localeCompare(b)\n )\n\n for (const [route, routeInfo] of sortedRoutes) {\n const { groups } = routeInfo\n\n // For static routes (no dynamic segments), we can produce an empty parameter map.\n if (!isDynamicRoute(route) || Object.keys(groups ?? {}).length === 0) {\n paramTypes += ` ${JSON.stringify(route)}: {}\\n`\n continue\n }\n\n let paramType = '{'\n\n // Process each group based on its properties\n for (const [key, group] of Object.entries(groups)) {\n const escapedKey = JSON.stringify(key)\n if (group.repeat) {\n // Catch-all parameters\n if (group.optional) {\n paramType += ` ${escapedKey}?: string[];`\n } else {\n paramType += ` ${escapedKey}: string[];`\n }\n } else {\n // Regular parameters\n if (group.optional) {\n paramType += ` ${escapedKey}?: string;`\n } else {\n paramType += ` ${escapedKey}: string;`\n }\n }\n }\n\n paramType += ' }'\n\n paramTypes += ` ${JSON.stringify(route)}: ${paramType}\\n`\n }\n\n paramTypes += '}\\n'\n return paramTypes\n}\n\nfunction generateLayoutSlotMap(routesManifest: RouteTypesManifest): string {\n let slotMap = 'interface LayoutSlotMap {\\n'\n\n // Sort routes deterministically for consistent output\n const sortedLayoutRoutes = Object.entries(routesManifest.layoutRoutes).sort(\n ([a], [b]) => a.localeCompare(b)\n )\n\n for (const [route, routeInfo] of sortedLayoutRoutes) {\n if ('slots' in routeInfo) {\n const slots = routeInfo.slots.sort()\n if (slots.length > 0) {\n slotMap += ` ${JSON.stringify(route)}: ${slots.map((slot) => JSON.stringify(slot)).join(' | ')}\\n`\n } else {\n slotMap += ` ${JSON.stringify(route)}: never\\n`\n }\n } else {\n slotMap += ` ${JSON.stringify(route)}: never\\n`\n }\n }\n\n slotMap += '}\\n'\n return slotMap\n}\n\n// Helper function to format routes to route types (matches the plugin logic exactly)\nfunction formatRouteToRouteType(route: string) {\n const isDynamic = isDynamicRoute(route)\n if (isDynamic) {\n route = route\n .split('/')\n .map((part) => {\n if (part.startsWith('[') && part.endsWith(']')) {\n if (part.startsWith('[...')) {\n // /[...slug]\n return `\\${CatchAllSlug<T>}`\n } else if (part.startsWith('[[...') && part.endsWith(']]')) {\n // /[[...slug]]\n return `\\${OptionalCatchAllSlug<T>}`\n }\n // /[slug]\n return `\\${SafeSlug<T>}`\n }\n return part\n })\n .join('/')\n }\n\n return {\n isDynamic,\n routeType: route,\n }\n}\n\n// Helper function to serialize route types (matches the plugin logic exactly)\nfunction serializeRouteTypes(routeTypes: string[]) {\n // route collection is not deterministic, this makes the output of the file deterministic\n return routeTypes\n .sort()\n .map((route) => `\\n | \\`${route}\\``)\n .join('')\n}\n\nexport function generateLinkTypesFile(\n routesManifest: RouteTypesManifest\n): string {\n // Generate serialized static and dynamic routes for the internal namespace\n // Build a unified set of routes across app/pages/redirect/rewrite as well as\n // app route handlers and Pages Router API routes.\n const allRoutesSet = new Set<string>([\n ...Object.keys(routesManifest.appRoutes),\n ...Object.keys(routesManifest.pageRoutes),\n ...Object.keys(routesManifest.redirectRoutes),\n ...Object.keys(routesManifest.rewriteRoutes),\n // Allow linking to App Route Handlers (e.g. `/logout/route.ts`)\n ...Object.keys(routesManifest.appRouteHandlerRoutes),\n // Allow linking to Pages Router API routes (e.g. `/api/*`)\n ...Array.from(routesManifest.pageApiRoutes),\n ])\n\n const staticRouteTypes: string[] = []\n const dynamicRouteTypes: string[] = []\n\n // Process each route using the same logic as the plugin\n for (const route of allRoutesSet) {\n const { isDynamic, routeType } = formatRouteToRouteType(route)\n if (isDynamic) {\n dynamicRouteTypes.push(routeType)\n } else {\n staticRouteTypes.push(routeType)\n }\n }\n\n const serializedStaticRouteTypes = serializeRouteTypes(staticRouteTypes)\n const serializedDynamicRouteTypes = serializeRouteTypes(dynamicRouteTypes)\n\n // If both StaticRoutes and DynamicRoutes are empty, fallback to type 'string & {}'.\n const routeTypesFallback =\n !serializedStaticRouteTypes && !serializedDynamicRouteTypes\n ? 'string & {}'\n : ''\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n\n// Type definitions for Next.js routes\n\n/**\n * Internal types used by the Next.js router and Link component.\n * These types are not meant to be used directly.\n * @internal\n */\ndeclare namespace __next_route_internal_types__ {\n type SearchOrHash = \\`?\\${string}\\` | \\`#\\${string}\\`\n type WithProtocol = \\`\\${string}:\\${string}\\`\n\n type Suffix = '' | SearchOrHash\n\n type SafeSlug<S extends string> = S extends \\`\\${string}/\\${string}\\`\n ? never\n : S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S\n\n type CatchAllSlug<S extends string> = S extends \\`\\${string}\\${SearchOrHash}\\`\n ? never\n : S extends ''\n ? never\n : S\n\n type OptionalCatchAllSlug<S extends string> =\n S extends \\`\\${string}\\${SearchOrHash}\\` ? never : S\n\n type StaticRoutes = ${serializedStaticRouteTypes || 'never'}\n type DynamicRoutes<T extends string = string> = ${\n serializedDynamicRouteTypes || 'never'\n }\n\n type RouteImpl<T> = ${\n routeTypesFallback ||\n `\n ${\n // This keeps autocompletion working for static routes.\n '| StaticRoutes'\n }\n | SearchOrHash\n | WithProtocol\n | \\`\\${StaticRoutes}\\${SearchOrHash}\\`\n | (T extends \\`\\${DynamicRoutes<infer _>}\\${Suffix}\\` ? T : never)\n `\n }\n}\n\ndeclare module '${PKG_NAME}' {\n export { default } from '${PKG_NAME}/types.js'\n export * from '${PKG_NAME}/types.js'\n\n export type Route<T extends string = string> =\n __next_route_internal_types__.RouteImpl<T>\n}\n\ndeclare module '${PKG_NAME}/link' {\n export { useLinkStatus } from '${PKG_NAME}/dist/client/link.js'\n\n import type { LinkProps as OriginalLinkProps } from '${PKG_NAME}/dist/client/link.js'\n import type { AnchorHTMLAttributes, DetailedHTMLProps } from 'react'\n import type { UrlObject } from 'url'\n\n type LinkRestProps = Omit<\n Omit<\n DetailedHTMLProps<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n HTMLAnchorElement\n >,\n keyof OriginalLinkProps\n > &\n OriginalLinkProps,\n 'href'\n >\n\n export type LinkProps<RouteInferType> = LinkRestProps & {\n /**\n * The path or URL to navigate to. This is the only required prop. It can also be an object.\n * @see https://nextjs.org/docs/api-reference/next/link\n */\n href: __next_route_internal_types__.RouteImpl<RouteInferType> | UrlObject\n }\n\n export default function Link<RouteType>(props: LinkProps<RouteType>): JSX.Element\n}\n\ndeclare module '${PKG_NAME}/navigation' {\n export * from '${PKG_NAME}/dist/client/components/navigation.js'\n\n import type { NavigateOptions, AppRouterInstance as OriginalAppRouterInstance } from '${PKG_NAME}/dist/shared/lib/app-router-context.shared-runtime.js'\n import type { RedirectType } from '${PKG_NAME}/dist/client/components/redirect-error.js'\n \n interface AppRouterInstance extends OriginalAppRouterInstance {\n /**\n * Navigate to the provided href.\n * Pushes a new history entry.\n */\n push<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>, options?: NavigateOptions): void\n /**\n * Navigate to the provided href.\n * Replaces the current history entry.\n */\n replace<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>, options?: NavigateOptions): void\n /**\n * Prefetch the provided href.\n */\n prefetch<RouteType>(href: __next_route_internal_types__.RouteImpl<RouteType>): void\n }\n\n export function useRouter(): AppRouterInstance;\n \n /**\n * This function allows you to redirect the user to another URL. It can be used in\n * [Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components),\n * [Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers), and\n * [Server Actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations).\n *\n * - In a Server Component, this will insert a meta tag to redirect the user to the target page.\n * - In a Route Handler or Server Action, it will serve a 307/303 to the caller.\n * - In a Server Action, type defaults to 'push' and 'replace' elsewhere.\n *\n * Read more: [Next.js Docs: redirect](https://nextjs.org/docs/app/api-reference/functions/redirect)\n */\n export function redirect<RouteType>(\n /** The URL to redirect to */\n url: __next_route_internal_types__.RouteImpl<RouteType>,\n type?: RedirectType\n ): never;\n \n /**\n * This function allows you to redirect the user to another URL. It can be used in\n * [Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components),\n * [Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers), and\n * [Server Actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations).\n *\n * - In a Server Component, this will insert a meta tag to redirect the user to the target page.\n * - In a Route Handler or Server Action, it will serve a 308/303 to the caller.\n *\n * Read more: [Next.js Docs: redirect](https://nextjs.org/docs/app/api-reference/functions/redirect)\n */\n export function permanentRedirect<RouteType>(\n /** The URL to redirect to */\n url: __next_route_internal_types__.RouteImpl<RouteType>,\n type?: RedirectType\n ): never;\n}\n\ndeclare module '${PKG_NAME}/form' {\n import type { FormProps as OriginalFormProps } from '${PKG_NAME}/dist/client/form.js'\n\n type FormRestProps = Omit<OriginalFormProps, 'action'>\n\n export type FormProps<RouteInferType> = {\n /**\n * \\`action\\` can be either a \\`string\\` or a function.\n * - If \\`action\\` is a string, it will be interpreted as a path or URL to navigate to when the form is submitted.\n * The path will be prefetched when the form becomes visible.\n * - If \\`action\\` is a function, it will be called when the form is submitted. See the [React docs](https://react.dev/reference/react-dom/components/form#props) for more.\n */\n action: __next_route_internal_types__.RouteImpl<RouteInferType> | ((formData: FormData) => void)\n } & FormRestProps\n\n export default function Form<RouteType>(props: FormProps<RouteType>): JSX.Element\n}\n`\n}\n\nexport function generateValidatorFile(\n routesManifest: RouteTypesManifest\n): string {\n const generateValidations = (\n paths: string[],\n type:\n | 'AppPageConfig'\n | 'PagesPageConfig'\n | 'LayoutConfig'\n | 'RouteHandlerConfig'\n | 'ApiRouteConfig',\n pathToRouteMap?: Map<string, string>\n ) =>\n paths\n .sort()\n // Only validate TypeScript files - JavaScript files have too many type inference limitations\n .filter(\n (filePath) => filePath.endsWith('.ts') || filePath.endsWith('.tsx')\n )\n .filter(\n // Don't include metadata routes or pages\n // (e.g. /manifest.webmanifest)\n (filePath) =>\n type !== 'AppPageConfig' ||\n filePath.endsWith('page.ts') ||\n filePath.endsWith('page.tsx')\n )\n .map((filePath) => {\n // Keep the file extension for TypeScript imports to support node16 module resolution\n const importPath = filePath\n const route = pathToRouteMap?.get(filePath)\n const typeWithRoute =\n route &&\n (type === 'AppPageConfig' ||\n type === 'LayoutConfig' ||\n type === 'RouteHandlerConfig')\n ? `${type}<${JSON.stringify(route)}>`\n : type\n\n // NOTE: we previously used `satisfies` here, but it's not supported by TypeScript 4.8 and below.\n // If we ever raise the TS minimum version, we can switch back.\n\n return `// Validate ${filePath}\n{\n type __IsExpected<Specific extends ${typeWithRoute}> = Specific\n const handler = {} as typeof import(${JSON.stringify(\n importPath.replace(/\\.tsx?$/, '.js')\n )})\n type __Check = __IsExpected<typeof handler>\n // @ts-ignore\n type __Unused = __Check\n}`\n })\n .join('\\n\\n')\n\n // Use direct mappings from the manifest\n\n // Generate validations for different route types\n const appPageValidations = generateValidations(\n Array.from(routesManifest.appPagePaths).sort(),\n 'AppPageConfig',\n routesManifest.filePathToRoute\n )\n const appRouteHandlerValidations = generateValidations(\n Array.from(routesManifest.appRouteHandlers).sort(),\n 'RouteHandlerConfig',\n routesManifest.filePathToRoute\n )\n const pagesRouterPageValidations = generateValidations(\n Array.from(routesManifest.pagesRouterPagePaths).sort(),\n 'PagesPageConfig'\n )\n const pagesApiRouteValidations = generateValidations(\n Array.from(routesManifest.pageApiRoutes).sort(),\n 'ApiRouteConfig'\n )\n const layoutValidations = generateValidations(\n Array.from(routesManifest.layoutPaths).sort(),\n 'LayoutConfig',\n routesManifest.filePathToRoute\n )\n\n const hasAppRouteHandlers =\n Object.keys(routesManifest.appRouteHandlerRoutes).length > 0\n\n // Build type definitions based on what's actually used\n let typeDefinitions = ''\n\n if (appPageValidations) {\n typeDefinitions += `type AppPageConfig<Route extends AppRoutes = AppRoutes> = {\n default: React.ComponentType<{ params: Promise<ParamMap[Route]> } & any> | ((props: { params: Promise<ParamMap[Route]> } & any) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)\n generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise<any[]> | any[]\n generateMetadata?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingMetadata\n ) => Promise<any> | any\n generateViewport?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingViewport\n ) => Promise<any> | any\n metadata?: any\n viewport?: any\n}\n\n`\n }\n\n if (pagesRouterPageValidations) {\n typeDefinitions += `type PagesPageConfig = {\n default: React.ComponentType<any> | ((props: any) => React.ReactNode | Promise<React.ReactNode> | never | void)\n getStaticProps?: (context: any) => Promise<any> | any\n getStaticPaths?: (context: any) => Promise<any> | any\n getServerSideProps?: (context: any) => Promise<any> | any\n getInitialProps?: (context: any) => Promise<any> | any\n /**\n * Segment configuration for legacy Pages Router pages.\n * Validated at build-time by parsePagesSegmentConfig.\n */\n config?: {\n amp?: boolean | 'hybrid' | string // necessary for JS\n maxDuration?: number\n runtime?: 'edge' | 'experimental-edge' | 'nodejs' | string // necessary unless config is exported as const\n regions?: string[]\n }\n}\n\n`\n }\n\n if (layoutValidations) {\n typeDefinitions += `type LayoutConfig<Route extends LayoutRoutes = LayoutRoutes> = {\n default: React.ComponentType<LayoutProps<Route>> | ((props: LayoutProps<Route>) => React.ReactNode | Promise<React.ReactNode> | never | void | Promise<void>)\n generateStaticParams?: (props: { params: ParamMap[Route] }) => Promise<any[]> | any[]\n generateMetadata?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingMetadata\n ) => Promise<any> | any\n generateViewport?: (\n props: { params: Promise<ParamMap[Route]> } & any,\n parent: ResolvingViewport\n ) => Promise<any> | any\n metadata?: any\n viewport?: any\n}\n\n`\n }\n\n if (appRouteHandlerValidations) {\n typeDefinitions += `type RouteHandlerConfig<Route extends AppRouteHandlerRoutes = AppRouteHandlerRoutes> = {\n GET?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n POST?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n PUT?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n PATCH?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n DELETE?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n HEAD?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n OPTIONS?: (request: NextRequest, context: { params: Promise<ParamMap[Route]> }) => Promise<Response | void> | Response | void\n}\n\n`\n }\n\n if (pagesApiRouteValidations) {\n typeDefinitions += `type ApiRouteConfig = {\n default: (req: any, res: any) => ReturnType<NextApiHandler>\n config?: {\n api?: {\n bodyParser?: boolean | { sizeLimit?: string }\n responseLimit?: string | number | boolean\n externalResolver?: boolean\n }\n runtime?: 'edge' | 'experimental-edge' | 'nodejs' | string // necessary unless config is exported as const\n maxDuration?: number\n }\n}\n\n`\n }\n\n // Build import statement based on what's actually needed\n const routeImports = []\n\n // Only import AppRoutes if there are app pages\n if (appPageValidations) {\n routeImports.push('AppRoutes')\n }\n\n // Only import LayoutRoutes if there are layouts\n if (layoutValidations) {\n routeImports.push('LayoutRoutes')\n }\n\n // Only import ParamMap if there are routes that use it\n if (appPageValidations || layoutValidations || appRouteHandlerValidations) {\n routeImports.push('ParamMap')\n }\n\n if (hasAppRouteHandlers) {\n routeImports.push('AppRouteHandlerRoutes')\n }\n\n const routeImportStatement =\n routeImports.length > 0\n ? `import type { ${routeImports.join(', ')} } from \"./routes.js\"`\n : ''\n\n const nextRequestImport = hasAppRouteHandlers\n ? `import type { NextRequest } from '${PKG_NAME}/server.js'\\n`\n : ''\n\n // Conditionally import types from next/types, merged into a single statement\n const nextTypes: string[] = []\n if (pagesApiRouteValidations) {\n nextTypes.push('NextApiHandler')\n }\n if (appPageValidations || layoutValidations) {\n nextTypes.push('ResolvingMetadata', 'ResolvingViewport')\n }\n const nextTypesImport =\n nextTypes.length > 0\n ? `import type { ${nextTypes.join(', ')} } from \"${PKG_NAME}/types.js\"\\n`\n : ''\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n// This file validates that all pages and layouts export the correct types\n\n${routeImportStatement}\n${nextTypesImport}${nextRequestImport}\n${typeDefinitions}\n${appPageValidations}\n\n${appRouteHandlerValidations}\n\n${pagesRouterPageValidations}\n\n${pagesApiRouteValidations}\n\n${layoutValidations}\n`\n}\n\nexport function generateRouteTypesFile(\n routesManifest: RouteTypesManifest\n): string {\n const routeTypes = generateRouteTypes(routesManifest)\n const paramTypes = generateParamTypes(routesManifest)\n const layoutSlotMap = generateLayoutSlotMap(routesManifest)\n\n const hasAppRouteHandlers =\n Object.keys(routesManifest.appRouteHandlerRoutes).length > 0\n\n // Build export statement based on what's actually generated\n const routeExports = [\n 'AppRoutes',\n 'PageRoutes',\n 'LayoutRoutes',\n 'RedirectRoutes',\n 'RewriteRoutes',\n 'ParamMap',\n ]\n if (hasAppRouteHandlers) {\n routeExports.push('AppRouteHandlerRoutes')\n }\n\n const exportStatement = `export type { ${routeExports.join(', ')} }`\n\n const routeContextInterface = hasAppRouteHandlers\n ? `\n\n /**\n * Context for Next.js App Router route handlers\n * @example\n * \\`\\`\\`tsx\n * export async function GET(request: NextRequest, context: RouteContext<'/api/users/[id]'>) {\n * const { id } = await context.params\n * return Response.json({ id })\n * }\n * \\`\\`\\`\n */\n interface RouteContext<AppRouteHandlerRoute extends AppRouteHandlerRoutes> {\n params: Promise<ParamMap[AppRouteHandlerRoute]>\n }`\n : ''\n\n return `// This file is generated automatically by Next.js\n// Do not edit this file manually\n\n${routeTypes}\n\n${paramTypes}\n\nexport type ParamsOf<Route extends Routes> = ParamMap[Route]\n\n${layoutSlotMap}\n\n${exportStatement}\n\ndeclare global {\n /**\n * Props for Next.js App Router page components\n * @example\n * \\`\\`\\`tsx\n * export default function Page(props: PageProps<'/blog/[slug]'>) {\n * const { slug } = await props.params\n * return <div>Blog post: {slug}</div>\n * }\n * \\`\\`\\`\n */\n interface PageProps<AppRoute extends AppRoutes> {\n params: Promise<ParamMap[AppRoute]>\n searchParams: Promise<Record<string, string | string[] | undefined>>\n }\n\n /**\n * Props for Next.js App Router layout components\n * @example\n * \\`\\`\\`tsx\n * export default function Layout(props: LayoutProps<'/dashboard'>) {\n * return <div>{props.children}</div>\n * }\n * \\`\\`\\`\n */\n type LayoutProps<LayoutRoute extends LayoutRoutes> = {\n params: Promise<ParamMap[LayoutRoute]>\n children: React.ReactNode\n } & {\n [K in LayoutSlotMap[LayoutRoute]]: React.ReactNode\n }${routeContextInterface}\n}\n`\n}\n"],"names":["isDynamicRoute","PKG_NAME","require","name","generateRouteTypes","routesManifest","appRoutes","Object","keys","sort","pageRoutes","layoutRoutes","redirectRoutes","rewriteRoutes","result","length","map","route","JSON","stringify","join","appRouteHandlerRoutes","hasAppRouteHandlers","routeUnionParts","push","generateParamTypes","allRoutes","paramTypes","sortedRoutes","entries","a","b","localeCompare","routeInfo","groups","paramType","key","group","escapedKey","repeat","optional","generateLayoutSlotMap","slotMap","sortedLayoutRoutes","slots","slot","formatRouteToRouteType","isDynamic","split","part","startsWith","endsWith","routeType","serializeRouteTypes","routeTypes","generateLinkTypesFile","allRoutesSet","Set","Array","from","pageApiRoutes","staticRouteTypes","dynamicRouteTypes","serializedStaticRouteTypes","serializedDynamicRouteTypes","routeTypesFallback","generateValidatorFile","generateValidations","paths","type","pathToRouteMap","filter","filePath","importPath","get","typeWithRoute","replace","appPageValidations","appPagePaths","filePathToRoute","appRouteHandlerValidations","appRouteHandlers","pagesRouterPageValidations","pagesRouterPagePaths","pagesApiRouteValidations","layoutValidations","layoutPaths","typeDefinitions","routeImports","routeImportStatement","nextRequestImport","nextTypes","nextTypesImport","generateRouteTypesFile","layoutSlotMap","routeExports","exportStatement","routeContextInterface"],"mappings":"AACA,SAASA,cAAc,QAAQ,8CAA6C;AAE5E,2DAA2D;AAC3D,MAAMC,WAAWC,QAAQ,+BAA+BC,IAAI;AAE5D,SAASC,mBAAmBC,cAAkC;IAC5D,MAAMC,YAAYC,OAAOC,IAAI,CAACH,eAAeC,SAAS,EAAEG,IAAI;IAC5D,MAAMC,aAAaH,OAAOC,IAAI,CAACH,eAAeK,UAAU,EAAED,IAAI;IAC9D,MAAME,eAAeJ,OAAOC,IAAI,CAACH,eAAeM,YAAY,EAAEF,IAAI;IAClE,MAAMG,iBAAiBL,OAAOC,IAAI,CAACH,eAAeO,cAAc,EAAEH,IAAI;IACtE,MAAMI,gBAAgBN,OAAOC,IAAI,CAACH,eAAeQ,aAAa,EAAEJ,IAAI;IAEpE,IAAIK,SAAS;IAEb,6CAA6C;IAC7C,IAAIR,UAAUS,MAAM,GAAG,GAAG;QACxBD,UAAU,CAAC,iBAAiB,EAAER,UAAUU,GAAG,CAAC,CAACC,QAAUC,KAAKC,SAAS,CAACF,QAAQG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC/F,OAAO;QACLN,UAAU;IACZ;IAEA,+DAA+D;IAC/D,MAAMO,wBAAwBd,OAAOC,IAAI,CACvCH,eAAegB,qBAAqB,EACpCZ,IAAI;IAEN,MAAMa,sBAAsBD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4D;IAC5D,MAAMgF,eAAe;QACnB;QACA;QACA;QACA;QACA;QACA;KACD;IACD,IAAIzE,qBAAqB;QACvByE,aAAavE,IAAI,CAAC;IACpB;IAEA,MAAMwE,kBAAkB,CAAC,cAAc,EAAED,aAAa3E,IAAI,CAAC,MAAM,EAAE,CAAC;IAEpE,MAAM6E,wBAAwB3E,sBAC1B,CAAC;;;;;;;;;;;;;;GAcJ,CAAC,GACE;IAEJ,OAAO,CAAC;;;AAGV,EAAEgC,WAAW;;AAEb,EAAE3B,WAAW;;;;AAIb,EAAEmE,cAAc;;AAEhB,EAAEE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCf,EAAEC,sBAAsB;;AAE3B,CAAC;AACD","ignoreList":[0]}
|
|
@@ -87,7 +87,7 @@ export async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup,
|
|
|
87
87
|
export async function startServer(serverOptions) {
|
|
88
88
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
|
89
89
|
let { port } = serverOptions;
|
|
90
|
-
process.title = `next-server (v${"15.6.0-bun.
|
|
90
|
+
process.title = `next-server (v${"15.6.0-bun.28"})`;
|
|
91
91
|
let handlersReady = ()=>{};
|
|
92
92
|
let handlersError = ()=>{};
|
|
93
93
|
let handlersPromise = new Promise((resolve, reject)=>{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function isStableBuild() {
|
|
2
2
|
var _process_env___NEXT_VERSION;
|
|
3
|
-
return !((_process_env___NEXT_VERSION = "15.6.0-bun.
|
|
3
|
+
return !((_process_env___NEXT_VERSION = "15.6.0-bun.28") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
|
|
4
4
|
}
|
|
5
5
|
export class CanaryOnlyError extends Error {
|
|
6
6
|
constructor(arg){
|
|
@@ -226,7 +226,7 @@ class HotReloaderWebpack {
|
|
|
226
226
|
this.previewProps = previewProps;
|
|
227
227
|
this.rewrites = rewrites;
|
|
228
228
|
this.hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
|
229
|
-
version: "15.6.0-bun.
|
|
229
|
+
version: "15.6.0-bun.28"
|
|
230
230
|
});
|
|
231
231
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
232
232
|
// of the current `next dev` invocation.
|
|
@@ -82,7 +82,7 @@ function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures, logBu
|
|
|
82
82
|
bundlerSuffix = ' (webpack)';
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.6.0-bun.
|
|
85
|
+
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.6.0-bun.28"}`))}${bundlerSuffix}`);
|
|
86
86
|
if (appUrl) {
|
|
87
87
|
_log.bootstrap(`- Local: ${appUrl}`);
|
|
88
88
|
}
|