@teyik0/furin 0.1.0-alpha.10

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.
Files changed (87) hide show
  1. package/dist/adapter/bun.d.ts +3 -0
  2. package/dist/adapter/static.d.ts +3 -0
  3. package/dist/build/client.d.ts +25 -0
  4. package/dist/build/compile-entry.d.ts +35 -0
  5. package/dist/build/entry-template.d.ts +26 -0
  6. package/dist/build/hydrate.d.ts +24 -0
  7. package/dist/build/index.d.ts +7 -0
  8. package/dist/build/index.js +4716 -0
  9. package/dist/build/route-types.d.ts +21 -0
  10. package/dist/build/scan-server.d.ts +8 -0
  11. package/dist/build/server-routes-entry.d.ts +35 -0
  12. package/dist/build/shared.d.ts +11 -0
  13. package/dist/build/types.d.ts +76 -0
  14. package/dist/cli/config.d.ts +9 -0
  15. package/dist/cli/index.d.ts +2 -0
  16. package/dist/cli/index.js +4751 -0
  17. package/dist/client.d.ts +195 -0
  18. package/dist/client.js +20 -0
  19. package/dist/config.d.ts +50 -0
  20. package/dist/config.js +28 -0
  21. package/dist/context-logger.d.ts +28 -0
  22. package/dist/dev-page-plugin.d.ts +109 -0
  23. package/dist/error.d.ts +23 -0
  24. package/dist/furin.d.ts +52 -0
  25. package/dist/furin.js +3948 -0
  26. package/dist/internal.d.ts +33 -0
  27. package/dist/link.d.ts +454 -0
  28. package/dist/link.js +1790 -0
  29. package/dist/not-found.d.ts +19 -0
  30. package/dist/plugin/index.d.ts +20 -0
  31. package/dist/plugin/index.js +1408 -0
  32. package/dist/plugin/transform-client.d.ts +9 -0
  33. package/dist/render/assemble.d.ts +15 -0
  34. package/dist/render/boundaries.d.ts +79 -0
  35. package/dist/render/cache.d.ts +96 -0
  36. package/dist/render/default-screens.d.ts +11 -0
  37. package/dist/render/digest.d.ts +16 -0
  38. package/dist/render/element.d.ts +8 -0
  39. package/dist/render/index.d.ts +53 -0
  40. package/dist/render/loaders.d.ts +21 -0
  41. package/dist/render/shell.d.ts +29 -0
  42. package/dist/render/template.d.ts +6 -0
  43. package/dist/router.d.ts +96 -0
  44. package/dist/router.js +2693 -0
  45. package/dist/runtime-env.d.ts +3 -0
  46. package/dist/utils.d.ts +6 -0
  47. package/package.json +77 -0
  48. package/src/adapter/README.md +13 -0
  49. package/src/adapter/bun.ts +239 -0
  50. package/src/adapter/static.ts +341 -0
  51. package/src/build/client.ts +153 -0
  52. package/src/build/compile-entry.ts +129 -0
  53. package/src/build/entry-template.ts +126 -0
  54. package/src/build/hydrate.ts +250 -0
  55. package/src/build/index.ts +151 -0
  56. package/src/build/route-types.ts +89 -0
  57. package/src/build/scan-server.ts +110 -0
  58. package/src/build/server-routes-entry.ts +55 -0
  59. package/src/build/shared.ts +78 -0
  60. package/src/build/types.ts +85 -0
  61. package/src/cli/config.ts +68 -0
  62. package/src/cli/index.ts +115 -0
  63. package/src/client.ts +278 -0
  64. package/src/config.ts +66 -0
  65. package/src/context-logger.ts +74 -0
  66. package/src/dev-page-plugin.ts +434 -0
  67. package/src/env.d.ts +49 -0
  68. package/src/error.ts +32 -0
  69. package/src/furin.ts +383 -0
  70. package/src/internal.ts +51 -0
  71. package/src/link.tsx +1578 -0
  72. package/src/not-found.ts +40 -0
  73. package/src/plugin/index.ts +80 -0
  74. package/src/plugin/transform-client.ts +372 -0
  75. package/src/render/assemble.ts +66 -0
  76. package/src/render/boundaries.tsx +176 -0
  77. package/src/render/cache.ts +251 -0
  78. package/src/render/default-screens.tsx +299 -0
  79. package/src/render/digest.ts +71 -0
  80. package/src/render/element.tsx +119 -0
  81. package/src/render/index.ts +867 -0
  82. package/src/render/loaders.ts +127 -0
  83. package/src/render/shell.ts +187 -0
  84. package/src/render/template.ts +55 -0
  85. package/src/router.ts +779 -0
  86. package/src/runtime-env.ts +6 -0
  87. package/src/utils.ts +68 -0
@@ -0,0 +1,9 @@
1
+ import MagicString from "magic-string";
2
+ interface TransformResult {
3
+ code: string;
4
+ map: ReturnType<MagicString["generateMap"]> | null;
5
+ removedServerCode: boolean;
6
+ }
7
+ export declare function deadCodeElimination(s: MagicString): MagicString;
8
+ export declare function transformForClient(code: string, filename: string): TransformResult;
9
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { buildHeadInjection } from "./shell";
2
+ /** Minimal context passed to background / synthetic render helpers — only `request` is needed. */
3
+ export interface LoaderContext {
4
+ request: Request;
5
+ }
6
+ export declare function resolvePath(pattern: string, params: Record<string, string>): string;
7
+ export declare function streamToString(stream: ReadableStream): Promise<string>;
8
+ interface SplitTemplate {
9
+ bodyPost: string;
10
+ bodyPre: string;
11
+ headPre: string;
12
+ }
13
+ export declare function splitTemplate(template: string): SplitTemplate;
14
+ export declare function assembleHTML(template: string, headData: ReturnType<typeof buildHeadInjection>, reactHtml: string, data: Record<string, unknown> | undefined): string;
15
+ export {};
@@ -0,0 +1,79 @@
1
+ import { Component, type ReactNode } from "react";
2
+ import { type ErrorComponent } from "../error.ts";
3
+ import { type NotFoundComponent } from "../not-found.ts";
4
+ interface ErrorBoundaryProps {
5
+ children: ReactNode;
6
+ /**
7
+ * Server-provided digest for an error rendered server-side. Honoured only
8
+ * for the FIRST error this boundary surfaces post-hydration — i.e. when the
9
+ * latched error is plausibly the same one the server already logged. After
10
+ * any reset, or when subsequent client-side errors are caught, the boundary
11
+ * computes a fresh digest from the actual caught error so distinct failures
12
+ * keep distinct IDs.
13
+ */
14
+ digest?: string;
15
+ /** Component rendered when an error is caught. Omit to use the built-in default. */
16
+ fallback?: ErrorComponent;
17
+ /**
18
+ * Invoked AFTER the boundary has cleared its local error state. Slice 7
19
+ * wires this to `router.navigate(currentHref, { force: true })` so the
20
+ * loader re-runs.
21
+ */
22
+ onReset?: () => void;
23
+ /**
24
+ * When this value changes the boundary clears its error state, effectively
25
+ * retrying the render of `children`. Slice 7 drives this from router
26
+ * navigation success.
27
+ */
28
+ resetKey?: string | number;
29
+ }
30
+ interface ErrorBoundaryState {
31
+ /**
32
+ * Digest computed at the moment the error was latched. Stored in state so
33
+ * each distinct caught error gets its own ID, instead of all of them
34
+ * inheriting the server-provided `digest` prop.
35
+ */
36
+ digest: string | null;
37
+ /** Unmount/remount counter — bumped on reset to force React to discard
38
+ * the previous subtree (including any broken state). */
39
+ epoch: number;
40
+ error: Error | null;
41
+ }
42
+ /**
43
+ * Catches generic errors thrown during render of `children`. Lets
44
+ * `FurinNotFoundError` bubble past so a sibling `<FurinNotFoundBoundary>`
45
+ * can handle it.
46
+ *
47
+ * Must be a class: React error catching (`getDerivedStateFromError`,
48
+ * `componentDidCatch`) has no function-component equivalent.
49
+ */
50
+ export declare class FurinErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
51
+ state: ErrorBoundaryState;
52
+ static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
53
+ componentDidUpdate(prevProps: ErrorBoundaryProps): void;
54
+ reset: () => void;
55
+ render(): ReactNode;
56
+ }
57
+ interface NotFoundBoundaryProps {
58
+ children: ReactNode;
59
+ fallback?: NotFoundComponent;
60
+ resetKey?: string | number;
61
+ }
62
+ interface NotFoundBoundaryState {
63
+ epoch: number;
64
+ error: Error | null;
65
+ }
66
+ /**
67
+ * Catches `FurinNotFoundError` (thrown by `notFound()`) and renders the
68
+ * nearest not-found UI. Generic errors are re-thrown from render() so a
69
+ * parent `<FurinErrorBoundary>` can handle them.
70
+ *
71
+ * Must be a class: React error catching has no function-component equivalent.
72
+ */
73
+ export declare class FurinNotFoundBoundary extends Component<NotFoundBoundaryProps, NotFoundBoundaryState> {
74
+ state: NotFoundBoundaryState;
75
+ static getDerivedStateFromError(error: Error): Partial<NotFoundBoundaryState>;
76
+ componentDidUpdate(prevProps: NotFoundBoundaryProps): void;
77
+ render(): ReactNode;
78
+ }
79
+ export {};
@@ -0,0 +1,96 @@
1
+ export interface ISRCacheEntry {
2
+ generatedAt: number;
3
+ html: string;
4
+ revalidate: number;
5
+ }
6
+ export interface SsgCacheEntry {
7
+ cachedAt: number;
8
+ html: string;
9
+ status: number;
10
+ }
11
+ export declare const isrCache: Map<string, ISRCacheEntry>;
12
+ export declare const ssgCache: Map<string, SsgCacheEntry>;
13
+ /**
14
+ * Gets an ISR cache entry and refreshes its recency so it is treated as
15
+ * recently used by the LRU eviction policy. Without this, a hot entry that
16
+ * was written early would be evicted before a cold entry written later.
17
+ */
18
+ export declare function getISRCache(key: string): ISRCacheEntry | undefined;
19
+ /**
20
+ * Gets an SSG cache entry and refreshes its recency so it is treated as
21
+ * recently used by the LRU eviction policy.
22
+ */
23
+ export declare function getSSGCache(key: string): SsgCacheEntry | undefined;
24
+ /** Sets an ISR cache entry with LRU eviction. */
25
+ export declare function setISRCache(key: string, entry: ISRCacheEntry): void;
26
+ /** Sets an SSG cache entry with LRU eviction. */
27
+ export declare function setSSGCache(key: string, entry: SsgCacheEntry): void;
28
+ /** Set once at server startup from the CompileContext. */
29
+ export declare function setBuildId(id: string): void;
30
+ /** Returns the current deployment build ID, or empty string in dev / before set. */
31
+ export declare function getBuildId(): string;
32
+ /**
33
+ * Wraps `fn` in a fresh per-request invalidation scope.
34
+ * Call this around the entire Elysia request handle so that all lifecycle
35
+ * hooks share an isolated invalidation Set.
36
+ * @internal
37
+ */
38
+ export declare function _runWithRequestInvalidationScope<T>(fn: () => T): T;
39
+ /**
40
+ * Consume and clear all pending invalidation paths for the current request.
41
+ * Called by the Elysia `onAfterHandle` hook to populate `X-Furin-Revalidate`.
42
+ * @internal
43
+ */
44
+ export declare function consumePendingInvalidations(): string[];
45
+ type CachePurger = (paths: string[]) => Promise<void>;
46
+ /**
47
+ * Register a CDN cache purger that will be called whenever `revalidatePath()`
48
+ * is invoked. Intended for use by platform adapters (Vercel, Cloudflare, etc.).
49
+ *
50
+ * The purger is called fire-and-forget — errors are logged but do not affect
51
+ * the HTTP response.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * // In a Vercel adapter:
56
+ * import { setCachePurger } from "@teyik0/furin";
57
+ * setCachePurger(async (paths) => {
58
+ * await fetch("https://api.vercel.com/v1/edge-cache/purge", {
59
+ * method: "POST",
60
+ * headers: { Authorization: `Bearer ${process.env.VERCEL_TOKEN}` },
61
+ * body: JSON.stringify({ urls: paths }),
62
+ * });
63
+ * });
64
+ * ```
65
+ */
66
+ export declare function setCachePurger(fn: CachePurger): void;
67
+ /** @internal */
68
+ export declare function callCachePurger(paths: string[]): void;
69
+ /**
70
+ * Programmatically invalidate the server-side cache for a given path.
71
+ *
72
+ * - `type: 'page'` (default): exact URL match.
73
+ * - `type: 'layout'`: the path itself plus all nested children (prefix match).
74
+ *
75
+ * Works for ISR and SSG routes. SSR routes are always fresh (no server-side
76
+ * cache), but calling this still queues a client-side prefetch invalidation
77
+ * via the `X-Furin-Revalidate` response header.
78
+ *
79
+ * If a CDN purger has been registered via `setCachePurger()`, it will also be
80
+ * called asynchronously to purge the CDN edge cache.
81
+ *
82
+ * @returns `true` if at least one server-side cache entry was removed.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * // In an API route or webhook handler:
87
+ * import { revalidatePath } from "@teyik0/furin";
88
+ *
89
+ * revalidatePath("/blog/my-post"); // invalidate a single page
90
+ * revalidatePath("/blog", "layout"); // invalidate /blog + all children
91
+ * ```
92
+ */
93
+ export declare function revalidatePath(path: string, type?: "page" | "layout"): boolean;
94
+ /** @internal — resets all module state between tests */
95
+ export declare function __resetCacheState(): void;
96
+ export {};
@@ -0,0 +1,11 @@
1
+ interface DefaultErrorScreenProps {
2
+ digest: string;
3
+ message: string;
4
+ reset: () => void;
5
+ }
6
+ export declare function DefaultErrorScreen({ message, digest, reset }: DefaultErrorScreenProps): import("react/jsx-runtime").JSX.Element;
7
+ interface DefaultNotFoundScreenProps {
8
+ message: string | undefined;
9
+ }
10
+ export declare function DefaultNotFoundScreen({ message }: DefaultNotFoundScreenProps): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Computes a deterministic, opaque 10-hex-character digest for an error.
3
+ *
4
+ * Purpose: render this digest in client-facing error UIs (e.g. `Error ID:
5
+ * a3f2b9c1d8`) and log the same digest alongside the full stack on the server,
6
+ * so support can correlate user reports with server logs without leaking stack
7
+ * traces or sensitive message content to the browser.
8
+ *
9
+ * Deterministic: identical error message + stack ⇒ identical digest across
10
+ * restarts, processes, and environments (server + client).
11
+ *
12
+ * Uses a pure-JS 53-bit hash so the function works identically in Bun and in
13
+ * the browser — `computeErrorDigest` is called from `FurinErrorBoundary`, which
14
+ * runs on both sides.
15
+ */
16
+ export declare function computeErrorDigest(err: unknown): string;
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from "react";
2
+ import type { RuntimeRoute } from "../client";
3
+ import type { ErrorComponent } from "../error";
4
+ import type { FurinNotFoundError, NotFoundComponent } from "../not-found";
5
+ import type { ResolvedRoute } from "../router";
6
+ export declare function buildElement(route: ResolvedRoute, data: Record<string, unknown>, rootLayout: RuntimeRoute): ReactNode;
7
+ export declare function buildNotFoundElement(component: NotFoundComponent | undefined, error: FurinNotFoundError): ReactNode;
8
+ export declare function buildErrorElement(component: ErrorComponent | undefined, error: unknown, digest: string): ReactNode;
@@ -0,0 +1,53 @@
1
+ import type { RootLayout } from "../router.ts";
2
+ import { type SsgCacheEntry } from "./cache.ts";
3
+ export { type LoaderContext, streamToString } from "./assemble.ts";
4
+ export { buildElement } from "./element.tsx";
5
+ export { type LoaderResult, runLoaders } from "./loaders.ts";
6
+ import type { Context } from "elysia";
7
+ import type { ResolvedRoute } from "../router.ts";
8
+ interface RenderResult {
9
+ headers: Record<string, string>;
10
+ html: string;
11
+ status: number;
12
+ }
13
+ export declare function renderToHTML(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<RenderResult>;
14
+ export declare function renderToStream(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<ReadableStream | Response>;
15
+ export declare function prerenderSSG(route: ResolvedRoute, params: Record<string, string>, root: RootLayout, origin: string, basePath: string | undefined): Promise<SsgCacheEntry | Response>;
16
+ export declare function renderSSR(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<Response>;
17
+ /**
18
+ * Renders the root-level not-found component into a complete 404 HTML Response.
19
+ * Used by the Elysia `.onError` catch-all when no route matches the request URL.
20
+ *
21
+ * Template resolution mirrors the main render path:
22
+ * prod template (if pre-rendered / compiled server)
23
+ * → dev template from Bun's HTML bundler (in dev, for the rewritten script tag)
24
+ * → static `generateIndexHtml()` (last-resort fallback; test harness, SSR with no request).
25
+ *
26
+ * The dev-template branch is critical: Bun's HTML bundler rewrites
27
+ * `./_hydrate.tsx` to the hashed client chunk URL (e.g. `/_bun/client/index-*.js`).
28
+ * If we served the raw `generateIndexHtml()` output, the browser would try to
29
+ * load `./_hydrate.tsx` relative to the current URL (e.g. `/foo/_hydrate.tsx`),
30
+ * 404, and the page would be left static — so clicking any in-page link would
31
+ * trigger a full document load instead of SPA navigation.
32
+ *
33
+ * If the user's not-found.tsx itself throws, falls back to the built-in
34
+ * DefaultNotFoundComponent to break recursion.
35
+ *
36
+ * @param root - Resolved root layout (carries the user's `not-found.tsx` ref).
37
+ * @param request - The incoming request. Required in dev to resolve the HMR
38
+ * entry origin. Pass `undefined` in contexts where no request is available
39
+ * (tests, SSG warmup) — the function will fall through to the static shell.
40
+ */
41
+ export declare function renderRootNotFound(root: RootLayout, request: Request | undefined): Promise<Response>;
42
+ export declare function handleISR(route: ResolvedRoute, ctx: Context, root: RootLayout, buildId?: string): Promise<string | Response | undefined>;
43
+ /**
44
+ * Pre-renders all SSG routes that declare `staticParams` and populates the
45
+ * in-memory cache before the first real request arrives.
46
+ * Should be called from the Elysia `onStart` hook (production only).
47
+ *
48
+ * Uses a bounded worker pool (SSG_WARM_CONCURRENCY slots) so large sites
49
+ * with many routes × param sets cannot exhaust memory or CPU during startup.
50
+ * Failures are isolated per (route, params) pair and logged without aborting
51
+ * the rest of the warm-up.
52
+ */
53
+ export declare function warmSSGCache(routes: ResolvedRoute[], root: RootLayout, origin: string): Promise<void>;
@@ -0,0 +1,21 @@
1
+ import type { Context } from "elysia";
2
+ import type { RuntimeRoute } from "../client";
3
+ import { type FurinNotFoundError } from "../not-found.ts";
4
+ import type { ResolvedRoute } from "../router";
5
+ export type LoaderResult = {
6
+ type: "data";
7
+ data: Record<string, unknown>;
8
+ headers: Record<string, string>;
9
+ } | {
10
+ type: "redirect";
11
+ response: Response;
12
+ } | {
13
+ type: "not-found";
14
+ error: FurinNotFoundError;
15
+ headers: Record<string, string>;
16
+ } | {
17
+ type: "error";
18
+ error: unknown;
19
+ headers: Record<string, string>;
20
+ };
21
+ export declare function runLoaders(route: ResolvedRoute, ctx: Context, _rootLayout: RuntimeRoute): Promise<LoaderResult>;
@@ -0,0 +1,29 @@
1
+ import type { HeadOptions, MetaDescriptor } from "../client.ts";
2
+ export declare function extractTitle(meta?: MetaDescriptor[]): string | undefined;
3
+ export declare function isMetaTag(entry: MetaDescriptor): boolean;
4
+ export declare function escapeHtml(str: string): string;
5
+ export declare function safeJson(value: unknown): string;
6
+ export declare function renderAttrs(obj: Record<string, string | undefined>): string;
7
+ export declare function buildMetaParts(meta: MetaDescriptor[]): string[];
8
+ export declare function buildLinkParts(links: NonNullable<HeadOptions["links"]>): string[];
9
+ export declare function buildScriptParts(scripts: NonNullable<HeadOptions["scripts"]>): string[];
10
+ export declare function buildStyleParts(styles: NonNullable<HeadOptions["styles"]>): string[];
11
+ /**
12
+ * Builds the string to inject into the <!--ssr-head--> placeholder.
13
+ * Handles title, meta tags, links, inline scripts, and inline styles from
14
+ * the page's `head()` function. CSS is handled by Bun (imported in user files).
15
+ */
16
+ export declare function buildHeadInjection(headData: HeadOptions | undefined): string;
17
+ export declare function generateIndexHtml(): string;
18
+ /**
19
+ * Generates the production SSR template (index.html) with hashed asset paths.
20
+ * Called after Bun.build() completes so we can inject the correct entry chunk
21
+ * and CSS paths derived from result.outputs.
22
+ *
23
+ * @param buildId - Short hash identifying this specific build. Injected as a
24
+ * `<meta name="furin-build-id">` tag so the client can detect stale deploys.
25
+ * @param faviconHref - Absolute href for the favicon (e.g. "/furin/favicon.ico").
26
+ * When provided, a `<link rel="icon">` tag is injected so browsers can locate
27
+ * the favicon even when the site is served from a sub-path.
28
+ */
29
+ export declare function generateProdIndexHtml(entryChunk: string, cssChunks: string[], buildId?: string, faviconHref?: string): string;
@@ -0,0 +1,6 @@
1
+ export declare function getDevTemplate(origin: string): Promise<string>;
2
+ export declare function setProductionTemplatePath(path: string | null): void;
3
+ export declare function setProductionTemplateContent(content: string): void;
4
+ export declare function getProductionTemplate(): string | null;
5
+ /** @internal test-only — resets all template state */
6
+ export declare function __resetTemplateState(): void;
@@ -0,0 +1,96 @@
1
+ import { type AnyElysia, type Context } from "elysia";
2
+ import type { AnySchema } from "elysia/types";
3
+ import type { RuntimePage, RuntimeRoute } from "./client.ts";
4
+ import type { ErrorComponent } from "./error.ts";
5
+ import { type CompileContext } from "./internal.ts";
6
+ import type { NotFoundComponent } from "./not-found.ts";
7
+ /**
8
+ * A single directory-scoped boundary declaration.
9
+ *
10
+ * Each entry represents ONE directory on the path from `pagesDir` to the page
11
+ * file. `error` / `notFound` hold the components defined IN THAT DIRECTORY
12
+ * only — never inherited from a parent. This 1:1 tie between directory and
13
+ * entry is what lets the render layer insert React error boundaries at the
14
+ * exact nesting level where the user authored them (Next.js app-router model).
15
+ */
16
+ export interface SegmentBoundary {
17
+ /** 0 = `pagesDir`; increments with each nested subdirectory. */
18
+ depth: number;
19
+ error?: ErrorComponent;
20
+ /**
21
+ * Absolute path to the `error.tsx` module, when present. Carried alongside
22
+ * the component so the client hydrate entry can emit a static `import`
23
+ * statement for each unique convention file — a component reference alone
24
+ * can't survive the server→client boundary.
25
+ */
26
+ errorPath?: string;
27
+ notFound?: NotFoundComponent;
28
+ /** Absolute path to the `not-found.tsx` module, when present. */
29
+ notFoundPath?: string;
30
+ /** Absolute directory path. */
31
+ path: string;
32
+ }
33
+ export interface ResolvedRoute {
34
+ error?: ErrorComponent;
35
+ isrCache?: {
36
+ html: string;
37
+ generatedAt: number;
38
+ revalidate: number;
39
+ };
40
+ mode: "ssr" | "ssg" | "isr";
41
+ notFound?: NotFoundComponent;
42
+ page: RuntimePage;
43
+ path: string;
44
+ pattern: string;
45
+ routeChain: RuntimeRoute[];
46
+ /**
47
+ * Per-directory boundary chain, ordered shallow → deep. Only directories
48
+ * that DECLARE at least one of `error.tsx` / `not-found.tsx` are included;
49
+ * directories without conventions are skipped. Empty when no conventions
50
+ * exist anywhere in the path.
51
+ */
52
+ segmentBoundaries: SegmentBoundary[];
53
+ ssgHtml?: string;
54
+ }
55
+ export interface RootLayout {
56
+ error?: ErrorComponent;
57
+ errorPath?: string;
58
+ notFound?: NotFoundComponent;
59
+ notFoundPath?: string;
60
+ path: string;
61
+ route: RuntimeRoute;
62
+ }
63
+ export declare function loadProdRoutes(ctx: CompileContext): {
64
+ root: RootLayout;
65
+ routes: ResolvedRoute[];
66
+ };
67
+ export declare function scanPages(pagesDir: string): Promise<{
68
+ root: RootLayout;
69
+ routes: ResolvedRoute[];
70
+ }>;
71
+ export declare function scanRootLayout(pagesDir: string): Promise<RootLayout>;
72
+ /** @internal Exported for unit testing. */
73
+ export declare function queryDefaultRedirectHook({ request, query, status, set }: Context): import("elysia").ElysiaCustomStatusResponse<"Found", "Found", 302> | undefined;
74
+ /**
75
+ * Re-imports intermediate layout _route.tsx files with cache-busting so that
76
+ * server-side renders reflect the latest code after an HMR edit. Bun's ESM
77
+ * cache keeps the original module alive, so we import via ?furin-server and
78
+ * patch the layout/loader references on the existing route-chain objects.
79
+ *
80
+ * The optional `importFn` parameter exists only for unit testing. In production
81
+ * it defaults to the real `import()`.
82
+ */
83
+ export declare function refreshLayoutChain(chain: RuntimeRoute[], pagePath: string, rootPath: string, importFn: ((specifier: string) => Promise<Record<string, unknown>>) | undefined): Promise<void>;
84
+ /**
85
+ * Merges TObject schemas from all routeChain entries for a given key.
86
+ * Properties are spread left-to-right (leaf wins on key conflict).
87
+ * Object-level options (additionalProperties, $id, description, …) are also
88
+ * merged with the same leaf-wins semantics so they are not silently dropped.
89
+ * Returns undefined when no entry in the chain defines the key.
90
+ *
91
+ * @internal Exported for unit testing.
92
+ */
93
+ export declare function mergeRouteSchemas(routeChain: RuntimeRoute[], key: "params" | "query"): AnySchema | undefined;
94
+ export declare function createRoutePlugin(route: ResolvedRoute, root: RootLayout, buildId?: string): AnyElysia;
95
+ export declare function resolveMode(page: RuntimePage, routeChain: RuntimeRoute[]): "ssr" | "ssg" | "isr";
96
+ export declare function filePathToPattern(path: string): string;