Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/vinext/src/build/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export { readPrerenderSecret } from "./server-manifest.js";

// ─── Public Types ─────────────────────────────────────────────────────────────

export interface PrerenderResult {
export type PrerenderResult = {
/** One entry per route (including skipped/error routes). */
routes: PrerenderRouteResult[];
}
};

export type PrerenderRouteResult =
| {
Expand Down Expand Up @@ -77,7 +77,7 @@ export type PrerenderProgressCallback = (update: {
status: PrerenderRouteResult["status"];
}) => void;

export interface PrerenderOptions {
export type PrerenderOptions = {
/**
* 'default' — prerender static/ISR routes; skip SSR routes
* 'export' — same as default but SSR routes are errors
Expand Down Expand Up @@ -110,9 +110,9 @@ export interface PrerenderOptions {
* multiple phases and write a single unified manifest itself.
*/
skipManifest?: boolean;
}
};

export interface PrerenderPagesOptions extends PrerenderOptions {
export type PrerenderPagesOptions = {
/** Discovered page routes (non-API). */
routes: Route[];
/** Discovered API routes. */
Expand All @@ -127,16 +127,16 @@ export interface PrerenderPagesOptions extends PrerenderOptions {
* `runPrerender` passes a shared `_prodServer` instead.
*/
pagesBundlePath?: string;
}
} & PrerenderOptions;

export interface PrerenderAppOptions extends PrerenderOptions {
export type PrerenderAppOptions = {
/** Discovered app routes. */
routes: AppRoute[];
/**
* Absolute path to the pre-built RSC handler bundle (e.g. `dist/server/index.js`).
*/
rscBundlePath: string;
}
} & PrerenderOptions;

// ─── Internal option extensions ───────────────────────────────────────────────
// These types extend the public option interfaces with an internal `_prodServer`
Expand Down
4 changes: 2 additions & 2 deletions packages/vinext/src/build/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type { PrerenderResult } from "./prerender.js";

export type RouteType = "static" | "isr" | "ssr" | "unknown" | "api";

export interface RouteRow {
export type RouteRow = {
pattern: string;
type: RouteType;
/** Only set for `isr` routes. */
Expand All @@ -40,7 +40,7 @@ export interface RouteRow {
* Used by `formatBuildReport` to add a note in the legend.
*/
prerendered?: boolean;
}
};

// ─── Regex-based export detection ────────────────────────────────────────────

Expand Down
4 changes: 2 additions & 2 deletions packages/vinext/src/build/run-prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class PrerenderProgress {

// ─── Shared runner ────────────────────────────────────────────────────────────

export interface RunPrerenderOptions {
export type RunPrerenderOptions = {
/** Project root directory. */
root: string;
/**
Expand All @@ -93,7 +93,7 @@ export interface RunPrerenderOptions {
* Intended for tests that build to a custom outDir.
*/
rscBundlePath?: string;
}
};

/**
* Run the prerender phase using pre-built production bundles.
Expand Down
12 changes: 6 additions & 6 deletions packages/vinext/src/build/static-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type { AppRoute } from "../routing/app-router.js";
import type { ResolvedNextConfig } from "../config/next-config.js";
import { prerenderPages, prerenderApp, type PrerenderRouteResult } from "./prerender.js";

export interface StaticExportOptions {
export type StaticExportOptions = {
/**
* Absolute path to the pre-built Pages Router server bundle
* (e.g. `dist/server/entry.js`).
Expand All @@ -38,9 +38,9 @@ export interface StaticExportOptions {
outDir: string;
/** Resolved next.config.js */
config: ResolvedNextConfig;
}
};

export interface StaticExportResult {
export type StaticExportResult = {
/** Number of HTML files generated */
pageCount: number;
/** Generated file paths (relative to outDir) */
Expand All @@ -49,7 +49,7 @@ export interface StaticExportResult {
warnings: string[];
/** Errors encountered (non-fatal, specific pages) */
errors: Array<{ route: string; error: string }>;
}
};

/**
* Convert a `PrerenderResult` into the legacy `StaticExportResult` shape.
Expand Down Expand Up @@ -103,7 +103,7 @@ export async function staticExportPages(options: StaticExportOptions): Promise<S
return toStaticExportResult(result.routes);
}

export interface AppStaticExportOptions {
export type AppStaticExportOptions = {
/** Discovered app routes */
routes: AppRoute[];
/**
Expand All @@ -115,7 +115,7 @@ export interface AppStaticExportOptions {
outDir: string;
/** Resolved next.config.js */
config: ResolvedNextConfig;
}
};

/**
* Run static export for App Router.
Expand Down
8 changes: 4 additions & 4 deletions packages/vinext/src/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import path from "node:path";

type Status = "supported" | "partial" | "unsupported";

interface CheckItem {
type CheckItem = {
name: string;
status: Status;
detail?: string;
files?: string[];
}
};

export interface CheckResult {
export type CheckResult = {
imports: CheckItem[];
config: CheckItem[];
libraries: CheckItem[];
Expand All @@ -32,7 +32,7 @@ export interface CheckResult {
total: number;
score: number;
};
}
};

// ── Import support map ─────────────────────────────────────────────────────

Expand Down
8 changes: 4 additions & 4 deletions packages/vinext/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ import { loadNextConfig, resolveNextConfig } from "./config/next-config.js";
// To fix this, we resolve Vite dynamically from `process.cwd()` at runtime
// using `createRequire`. This ensures we always use the project's Vite.

interface ViteModule {
type ViteModule = {
createServer: typeof import("vite").createServer;
build: typeof import("vite").build;
createBuilder: typeof import("vite").createBuilder;
createLogger: typeof import("vite").createLogger;
loadConfigFromFile: typeof import("vite").loadConfigFromFile;
version: string;
}
};

let _viteModule: ViteModule | null = null;

Expand Down Expand Up @@ -90,15 +90,15 @@ const VERSION = JSON.parse(fs.readFileSync(new URL("../package.json", import.met
const command = process.argv[2];
const rawArgs = process.argv.slice(3);

interface ParsedArgs {
type ParsedArgs = {
port?: number;
hostname?: string;
help?: boolean;
verbose?: boolean;
turbopack?: boolean; // accepted for compat, always ignored
experimental?: boolean; // accepted for compat, always ignored
prerenderAll?: boolean;
}
};

function parseArgs(args: string[]): ParsedArgs {
const result: ParsedArgs = {};
Expand Down
4 changes: 2 additions & 2 deletions packages/vinext/src/client/instrumentation-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
setClientInstrumentationHooks,
} from "./instrumentation-client-state.js";

export interface ClientInstrumentationHooks {
export type ClientInstrumentationHooks = {
onRouterTransitionStart?: (href: string, navigationType: "push" | "replace" | "traverse") => void;
}
};

export const clientInstrumentationHooks = setClientInstrumentationHooks(
normalizeClientInstrumentationHooks(instrumentationClientHooks as ClientInstrumentationHooks),
Expand Down
4 changes: 2 additions & 2 deletions packages/vinext/src/client/vinext-next-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
import type { NEXT_DATA } from "../shims/internal/utils.js";

export interface VinextNextData extends NEXT_DATA {
export type VinextNextData = {
/** vinext-specific additions (not part of Next.js upstream). */
__vinext?: {
/** Absolute URL of the page module for dynamic import. */
Expand All @@ -19,4 +19,4 @@ export interface VinextNextData extends NEXT_DATA {
__pageModule?: string;
/** Serialised `_app` module path (legacy — used by `client/entry.ts`). */
__appModule?: string;
}
} & NEXT_DATA;
8 changes: 4 additions & 4 deletions packages/vinext/src/cloudflare/kv-cache-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type SerializedIncrementalCacheValue =
| SerializedCachedImageValue;

// Cloudflare KV namespace interface (matches Workers types)
interface KVNamespace {
type KVNamespace = {
get(key: string, options?: { type?: string }): Promise<string | null>;
get(key: string, options: { type: "arrayBuffer" }): Promise<ArrayBuffer | null>;
put(
Expand All @@ -77,16 +77,16 @@ interface KVNamespace {
list_complete: boolean;
cursor?: string;
}>;
}
};

/** Shape stored in KV for each cache entry. */
interface KVCacheEntry {
type KVCacheEntry = {
value: SerializedIncrementalCacheValue | null;
tags: string[];
lastModified: number;
/** Absolute timestamp (ms) after which the entry is "stale" (but still served). */
revalidateAt: number | null;
}
};

/** Key prefix for tag invalidation timestamps. */
const TAG_PREFIX = "__tag:";
Expand Down
24 changes: 12 additions & 12 deletions packages/vinext/src/cloudflare/tpr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { spawn, type ChildProcess } from "node:child_process";

// ─── Types ───────────────────────────────────────────────────────────────────

export interface TPROptions {
export type TPROptions = {
/** Project root directory. */
root: string;
/** Traffic coverage percentage (0–100). Default: 90. */
Expand All @@ -35,9 +35,9 @@ export interface TPROptions {
limit: number;
/** Analytics lookback window in hours. Default: 24. */
window: number;
}
};

export interface TPRResult {
export type TPRResult = {
/** Total unique page paths found in analytics. */
totalPaths: number;
/** Number of pages successfully pre-rendered and uploaded. */
Expand All @@ -48,31 +48,31 @@ export interface TPRResult {
durationMs: number;
/** If TPR was skipped, the reason. */
skipped?: string;
}
};

interface TrafficEntry {
type TrafficEntry = {
path: string;
requests: number;
}
};

interface SelectedRoutes {
type SelectedRoutes = {
routes: TrafficEntry[];
totalRequests: number;
coveredRequests: number;
coveragePercent: number;
}
};

interface PrerenderResult {
type PrerenderResult = {
html: string;
status: number;
headers: Record<string, string>;
}
};

interface WranglerConfig {
type WranglerConfig = {
accountId?: string;
kvNamespaceId?: string;
customDomain?: string;
}
};

// ─── Wrangler Config Parsing ─────────────────────────────────────────────────

Expand Down
4 changes: 2 additions & 2 deletions packages/vinext/src/config/config-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,12 @@ export function escapeHeaderSource(source: string): string {
* Request context needed for evaluating has/missing conditions.
* Callers extract the relevant parts from the incoming Request.
*/
export interface RequestContext {
export type RequestContext = {
headers: Headers;
cookies: Record<string, string>;
query: URLSearchParams;
host: string;
}
};

/**
* Parse a Cookie header string into a key-value record.
Expand Down
8 changes: 4 additions & 4 deletions packages/vinext/src/config/dotenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import { parseEnv } from "node:util";

export type VinextEnvMode = "development" | "production" | "test";

export interface LoadDotenvOptions {
export type LoadDotenvOptions = {
root: string;
mode: VinextEnvMode;
processEnv?: NodeJS.ProcessEnv;
}
};

export interface LoadDotenvResult {
export type LoadDotenvResult = {
mode: VinextEnvMode;
loadedFiles: string[];
loadedEnv: Record<string, string>;
}
};

/**
* Next.js-compatible dotenv lookup order (highest priority first).
Expand Down
Loading
Loading