@teyik0/furin 0.3.0-alpha.1 → 0.4.0-alpha.1
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/adapter/bun.d.ts +1 -1
- package/dist/build/client.d.ts +2 -2
- package/dist/build/entry-template.d.ts +4 -0
- package/dist/build/entry-template.ts +17 -3
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +8288 -6629
- package/dist/build/route-types.d.ts +2 -22
- package/dist/build/shared.d.ts +1 -1
- package/dist/build/ssg-cache.d.ts +1 -1
- package/dist/build/types.d.ts +1 -1
- package/dist/cli/index.js +7862 -6168
- package/dist/client/boundaries.d.ts +2 -0
- package/dist/client/define-route.d.ts +35 -0
- package/dist/client/document.d.ts +26 -0
- package/dist/client/hmr.d.ts +10 -0
- package/dist/client/internal/runtime-types.d.ts +3 -1
- package/dist/client/link.js +1177 -894
- package/dist/client/router/index.d.ts +1 -1
- package/dist/client/router/link-utils.d.ts +9 -0
- package/dist/client/router/search/index.d.ts +3 -7
- package/dist/client/router/types.d.ts +32 -24
- package/dist/client.d.ts +4 -159
- package/dist/client.js +183 -21
- package/dist/config.d.ts +8 -8
- package/dist/config.js +8 -8
- package/dist/define-route.d.ts +1355 -0
- package/dist/furin.d.ts +17 -33
- package/dist/furin.js +13444 -10301
- package/dist/plugin/index.js +953 -244
- package/dist/plugin/route-config-autofix.d.ts +31 -0
- package/dist/plugin/routes.d.ts +27 -0
- package/dist/routes.d.ts +6 -0
- package/dist/routes.js +1 -0
- package/dist/rsc/build/index.d.ts +1 -1
- package/dist/rsc.js +3 -3
- package/dist/server/dev-page-plugin.d.ts +7 -5
- package/dist/server/devtools/instrumentation.d.ts +2 -2
- package/dist/server/devtools/instrumentation.production.d.ts +2 -2
- package/dist/server/devtools/plugin.d.ts +2 -2
- package/dist/server/internal.d.ts +3 -0
- package/dist/server/logger.d.ts +4 -0
- package/dist/server/render/assemble.d.ts +0 -9
- package/dist/server/render/document.d.ts +4 -0
- package/dist/server/render/element.d.ts +2 -1
- package/dist/server/render/index.d.ts +1 -1
- package/dist/server/render/index.ts +0 -1
- package/dist/server/render/isr.d.ts +1 -1
- package/dist/server/render/loaders.d.ts +1 -1
- package/dist/server/render/not-found.d.ts +1 -1
- package/dist/server/render/ppr-route.d.ts +1 -1
- package/dist/server/render/ssg.d.ts +1 -1
- package/dist/server/render/ssr.d.ts +7 -6
- package/dist/server/render/template.d.ts +4 -0
- package/dist/server/router/defined-route.d.ts +24 -0
- package/dist/server/router/hmr.d.ts +16 -8
- package/dist/server/router/patterns.d.ts +6 -0
- package/dist/server/router/plugin.d.ts +4 -3
- package/dist/server/router/schema-merge.d.ts +2 -2
- package/dist/server/router/schemas.d.ts +5 -5
- package/dist/server/router/source-version.d.ts +2 -0
- package/dist/server/router/types.d.ts +1 -0
- package/dist/server/sync/index.js +961 -806
- package/dist/server/sync/postgres/migrate.js +3 -2
- package/dist/shared/await.d.ts +6 -7
- package/dist/shared/elysia-contract.d.ts +41 -0
- package/dist/shared/route-map.d.ts +5 -0
- package/dist/shared/utils/index.d.ts +1 -3
- package/package.json +44 -41
- package/src/adapter/bun.ts +42 -22
- package/src/adapter/package.ts +20 -14
- package/src/adapter/static.ts +4 -3
- package/src/build/client.ts +20 -3
- package/src/build/entry-template.ts +17 -3
- package/src/build/hydrate.ts +98 -28
- package/src/build/index.ts +2 -2
- package/src/build/route-types.ts +19 -114
- package/src/build/shared.ts +1 -1
- package/src/build/ssg-cache.ts +2 -5
- package/src/build/types.ts +1 -1
- package/src/cli/config.ts +3 -3
- package/src/cli/index.ts +7 -7
- package/src/client/boundaries.tsx +9 -1
- package/src/client/define-route.ts +48 -0
- package/src/client/document.tsx +165 -0
- package/src/client/hmr.ts +40 -0
- package/src/client/internal/runtime-types.ts +3 -1
- package/src/client/link.tsx +21 -6
- package/src/client/router/index.ts +1 -0
- package/src/client/router/link-utils.ts +26 -0
- package/src/client/router/provider.tsx +25 -2
- package/src/client/router/search/index.ts +4 -12
- package/src/client/router/types.ts +50 -24
- package/src/client.ts +14 -316
- package/src/config.ts +10 -10
- package/src/define-route.ts +959 -0
- package/src/devtools/devtools-element.js +11 -10
- package/src/furin.ts +303 -53
- package/src/plugin/route-config-autofix.ts +1140 -0
- package/src/plugin/routes.ts +891 -0
- package/src/plugin/transform-client.ts +132 -266
- package/src/plugin/transform-isomorphic.ts +1 -1
- package/src/routes.ts +6 -0
- package/src/rsc/build/index.ts +1 -1
- package/src/server/auto-invalidate/registry.ts +2 -2
- package/src/server/dev-page-plugin.ts +31 -12
- package/src/server/devtools/instrumentation.production.ts +2 -2
- package/src/server/devtools/instrumentation.ts +2 -2
- package/src/server/devtools/plugin.ts +5 -3
- package/src/server/instance.ts +3 -3
- package/src/server/internal.ts +3 -0
- package/src/server/logger.ts +21 -0
- package/src/server/render/assemble.ts +0 -41
- package/src/server/render/document.tsx +25 -0
- package/src/server/render/element.tsx +13 -1
- package/src/server/render/index.ts +0 -1
- package/src/server/render/isr.ts +31 -10
- package/src/server/render/loaders.ts +31 -6
- package/src/server/render/not-found.ts +51 -27
- package/src/server/render/ppr-route.ts +1 -1
- package/src/server/render/ssg.ts +1 -1
- package/src/server/render/ssr.ts +271 -113
- package/src/server/render/template.ts +91 -1
- package/src/server/router/defined-route.ts +110 -0
- package/src/server/router/discovery.ts +129 -29
- package/src/server/router/hmr.ts +111 -40
- package/src/server/router/patterns.ts +40 -12
- package/src/server/router/plugin.ts +63 -46
- package/src/server/router/schema-merge.ts +4 -14
- package/src/server/router/schemas.ts +11 -8
- package/src/server/router/source-version.ts +16 -0
- package/src/server/router/types.ts +2 -0
- package/src/server/sync/postgres/migrate.ts +3 -2
- package/src/server/sync/response.ts +14 -10
- package/src/shared/await.tsx +6 -7
- package/src/shared/elysia-contract.ts +63 -0
- package/src/shared/route-map.ts +37 -0
- package/src/shared/utils/index.ts +2 -20
- package/dist/build/server-routes-entry.d.ts +0 -13
- package/dist/build/server-routes-entry.ts +0 -30
- package/dist/server/router/index.d.ts +0 -7
- package/dist/server/router/index.js +0 -27
- package/dist/server/router/index.ts +0 -28
- package/src/build/server-routes-entry.ts +0 -30
- package/src/server/router/index.ts +0 -28
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface ExpectedLayout {
|
|
2
|
+
/** Preferred local binding, e.g. "rootRoute". */
|
|
3
|
+
identifier: string;
|
|
4
|
+
/** Import specifier relative from the route file, e.g. "../root". */
|
|
5
|
+
importPath: string;
|
|
6
|
+
}
|
|
7
|
+
export type LayoutProbe = (path: string) => boolean;
|
|
8
|
+
/** Deterministic binding for a layout file: `root.tsx` → `rootRoute`, `board/_route.tsx` → `boardRoute`. */
|
|
9
|
+
export declare function layoutIdentifierFor(layoutPath: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* The layout a route file should reference: the nearest `_route.ts(x)` walking
|
|
12
|
+
* up from its own directory (a `_route` file looks at its PARENT directory),
|
|
13
|
+
* falling back to the `root.tsx` convention at the pages root. Returns null
|
|
14
|
+
* for the root layout itself — nothing above it exists.
|
|
15
|
+
*/
|
|
16
|
+
export declare function expectedLayoutFor(filePath: string, pagesDir: string, probe?: LayoutProbe): ExpectedLayout | null;
|
|
17
|
+
/** Dynamic param names derived from the file path segments (`[id]` → id, `[...all]` → "*"). */
|
|
18
|
+
export declare function dynamicParamsFor(filePath: string, pagesDir: string): string[];
|
|
19
|
+
/**
|
|
20
|
+
* Rewrites `defineRoute()` chains so every route file declares a full
|
|
21
|
+
* `config({ layout, mode, ... })`:
|
|
22
|
+
* - chain without `config()` → inserts `.config({ layout, mode })`
|
|
23
|
+
* - `config()` without `layout` → injects the expected ancestor layout
|
|
24
|
+
* - `config()` with a WRONG layout → repoints the reference (and its import)
|
|
25
|
+
* - `config()` without `mode` → infers the mode using the runtime cascade
|
|
26
|
+
* - layout file without `layout()` → appends an identity layout terminal
|
|
27
|
+
* The root layout (`pages/root.tsx`, built with `defineRootRoute()`) never
|
|
28
|
+
* receives a parent `layout` config entry. Returns the new source, or null when unchanged
|
|
29
|
+
* (idempotent — running the fix twice returns null on the second pass).
|
|
30
|
+
*/
|
|
31
|
+
export declare function fixRouteConfigLayout(source: string, filePath: string, pagesDir: string, probe?: LayoutProbe): string | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface RouteInstanceSpec {
|
|
2
|
+
pagesDir: string;
|
|
3
|
+
prefix: string;
|
|
4
|
+
}
|
|
5
|
+
export interface CreateRoutesPluginOptions {
|
|
6
|
+
instances: RouteInstanceSpec[];
|
|
7
|
+
target: "client" | "server";
|
|
8
|
+
}
|
|
9
|
+
export interface DevRouteTopologyWatcher {
|
|
10
|
+
close: () => void;
|
|
11
|
+
}
|
|
12
|
+
export interface DevRouteTopologyWatcherOptions {
|
|
13
|
+
instance: RouteInstanceSpec;
|
|
14
|
+
onRouteFilesTouched?: () => Promise<void> | void;
|
|
15
|
+
onTopologyChange: () => Promise<void> | void;
|
|
16
|
+
pollIntervalMs: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function routeModuleSpecifier(instance: RouteInstanceSpec): string;
|
|
19
|
+
export declare function routeSourcePaths(instance: RouteInstanceSpec): string[];
|
|
20
|
+
export declare function registerDevRouteTopologyWatcher(options: DevRouteTopologyWatcherOptions): DevRouteTopologyWatcher;
|
|
21
|
+
export declare function validateRouteParams(path: string, schemas: {
|
|
22
|
+
params?: {
|
|
23
|
+
properties?: object;
|
|
24
|
+
};
|
|
25
|
+
} | undefined): void;
|
|
26
|
+
export declare function registerDevRoutesPlugin(instances: RouteInstanceSpec[]): void;
|
|
27
|
+
export declare function createRoutesPlugin(options: CreateRoutesPluginOptions): Bun.BunPlugin;
|
package/dist/routes.d.ts
ADDED
package/dist/routes.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
package/dist/rsc.js
CHANGED
|
@@ -135,9 +135,9 @@ async function drainFlight(session, operation) {
|
|
|
135
135
|
try {
|
|
136
136
|
bytes = await readFlightBytes(session.stream);
|
|
137
137
|
} catch (streamError) {
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
140
|
-
throw createFurinRscRenderError(
|
|
138
|
+
const renderError = session.getRenderError();
|
|
139
|
+
if (renderError.reported) {
|
|
140
|
+
throw createFurinRscRenderError(renderError.error, operation);
|
|
141
141
|
}
|
|
142
142
|
throw streamError;
|
|
143
143
|
}
|
|
@@ -16,16 +16,18 @@
|
|
|
16
16
|
* stale module while the client received fresh HMR code, causing a React
|
|
17
17
|
* hydration mismatch.
|
|
18
18
|
*
|
|
19
|
-
* Solution: the caller appends `?furin-server&t=<
|
|
20
|
-
* specifier
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* Solution: the caller appends `?furin-server&t=<source-version>` to the import
|
|
20
|
+
* specifier. `onResolve` preserves the `?t=...` fragment in the resolved path,
|
|
21
|
+
* so Bun calls `onLoad` again after an edit without allocating a new permanent
|
|
22
|
+
* ESM registry entry for every request.
|
|
23
23
|
*
|
|
24
24
|
* ## Relative import rewriting
|
|
25
25
|
*
|
|
26
26
|
* Modules in a virtual namespace cannot resolve relative specifiers on their
|
|
27
27
|
* own (there is no real directory context). We rewrite every `./` / `../`
|
|
28
|
-
* path to an absolute one before returning the source.
|
|
28
|
+
* path to an absolute one before returning the source. Local JS/TS dependencies
|
|
29
|
+
* use the same source-version rule as routes, so refreshing a route does not
|
|
30
|
+
* retain an old helper module. Shared dependencies keep one identity per version.
|
|
29
31
|
*
|
|
30
32
|
* ## Bare specifier rewriting
|
|
31
33
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AnyElysia } from "elysia";
|
|
2
2
|
import type { DevtoolsServerEventInput } from "../../devtools/protocol.ts";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ResolvedRoutesSource } from "../router/types.ts";
|
|
4
4
|
import { type DevtoolsRequestContext } from "./request-context.ts";
|
|
5
5
|
type EventInput<T extends DevtoolsServerEventInput["type"]> = Omit<Extract<DevtoolsServerEventInput, {
|
|
6
6
|
type: T;
|
|
@@ -17,6 +17,6 @@ export declare function currentInstrumentationRequest(): DevtoolsRequestContext
|
|
|
17
17
|
export declare function runWithRequestInstrumentation<T>(request: Request, fn: () => T): T;
|
|
18
18
|
export declare function shouldInstrumentRequest(pathname: string, prefix: string): boolean;
|
|
19
19
|
export declare function instrumentationLoggerExclusions(prefix: string): string[];
|
|
20
|
-
export declare function createInstrumentationPlugin(routes:
|
|
20
|
+
export declare function createInstrumentationPlugin(routes: ResolvedRoutesSource, syncStreamPath: string | undefined): AnyElysia;
|
|
21
21
|
export declare function injectInstrumentationClient(html: string, prefix: string): string;
|
|
22
22
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AnyElysia } from "elysia";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ResolvedRoutesSource } from "../router/types.ts";
|
|
3
3
|
interface CacheAccessInput {
|
|
4
4
|
cache: "isr-loader" | "ssg-loader";
|
|
5
5
|
operationId: string | null;
|
|
@@ -39,6 +39,6 @@ export declare function currentInstrumentationRequest(): void;
|
|
|
39
39
|
export declare function runWithRequestInstrumentation<T>(_request: Request, fn: () => T): T;
|
|
40
40
|
export declare function shouldInstrumentRequest(_pathname: string, _prefix: string): boolean;
|
|
41
41
|
export declare function instrumentationLoggerExclusions(_prefix: string): string[];
|
|
42
|
-
export declare function createInstrumentationPlugin(_routes:
|
|
42
|
+
export declare function createInstrumentationPlugin(_routes: ResolvedRoutesSource, _syncStreamPath: string | undefined): AnyElysia;
|
|
43
43
|
export declare function injectInstrumentationClient(html: string, _prefix: string): string;
|
|
44
44
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type AnyElysia } from "elysia";
|
|
2
|
-
import type {
|
|
3
|
-
export declare function createDevtoolsPlugin(
|
|
2
|
+
import type { ResolvedRoutesSource } from "../router/types.ts";
|
|
3
|
+
export declare function createDevtoolsPlugin(routesSource: ResolvedRoutesSource, syncStreamPath: string | undefined): AnyElysia;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AnyElysia } from "elysia";
|
|
1
2
|
import type { SsgCacheEntry } from "./cache/index.ts";
|
|
2
3
|
export interface EmbeddedAppData {
|
|
3
4
|
assets: Record<string, string>;
|
|
@@ -14,6 +15,8 @@ export interface CompileContext {
|
|
|
14
15
|
clientLogging?: boolean;
|
|
15
16
|
embedded?: EmbeddedAppData;
|
|
16
17
|
modules: Record<string, unknown>;
|
|
18
|
+
/** Elysia-native route tree generated for this mounted app. */
|
|
19
|
+
nativeRoutes?: AnyElysia;
|
|
17
20
|
/** Mount prefix this app was built for (`""` = root). */
|
|
18
21
|
prefix?: string;
|
|
19
22
|
/** Root-level conventions discovered at compile time. */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { toCrossJSON } from "seroval";
|
|
2
|
-
import type { buildHeadInjection } from "./shell";
|
|
3
2
|
/**
|
|
4
3
|
* Single source of truth for the global registry name used by the SSR
|
|
5
4
|
* streaming script, the client hydration entry, and any test helper. Keeping
|
|
@@ -37,17 +36,9 @@ export interface LoaderContext {
|
|
|
37
36
|
}
|
|
38
37
|
export declare function resolvePath(pattern: string, params: Record<string, string>): string;
|
|
39
38
|
export declare function streamToString(stream: ReadableStream): Promise<string>;
|
|
40
|
-
interface SplitTemplate {
|
|
41
|
-
bodyPost: string;
|
|
42
|
-
bodyPre: string;
|
|
43
|
-
headPre: string;
|
|
44
|
-
}
|
|
45
|
-
export declare function splitTemplate(template: string): SplitTemplate;
|
|
46
|
-
export declare function assembleHTML(template: string, headData: ReturnType<typeof buildHeadInjection>, reactHtml: string, data: Record<string, unknown> | undefined): string;
|
|
47
39
|
export declare function buildRouteFrameTemplate(payload: string): string;
|
|
48
40
|
export declare function buildRouteFrameStreamScript(): string;
|
|
49
41
|
export declare function buildRouteFramePushScript(payload: string): string;
|
|
50
42
|
export declare function buildRouteFrameCloseScript(): string;
|
|
51
43
|
export declare function buildSyncRuntimeScript(): string;
|
|
52
44
|
export declare function injectSyncRuntimeScript(html: string): string;
|
|
53
|
-
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type DocumentAssets } from "../../client/document.tsx";
|
|
3
|
+
import type { HeadOptions } from "../../client.ts";
|
|
4
|
+
export declare function withDocumentState(element: ReactNode, assets: DocumentAssets, head: HeadOptions | undefined, data: object | undefined): ReactNode;
|
|
@@ -2,8 +2,9 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import type { RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
3
3
|
import type { ErrorComponent } from "../../shared/error.ts";
|
|
4
4
|
import type { FurinNotFoundError, NotFoundComponent } from "../../shared/not-found.ts";
|
|
5
|
-
import type { ResolvedRoute } from "../router/
|
|
5
|
+
import type { ResolvedRoute } from "../router/types.ts";
|
|
6
6
|
export declare function buildElement(route: ResolvedRoute, data: Record<string, unknown>, rootLayout: RuntimeRoute): ReactNode;
|
|
7
|
+
export declare function wrapRootLayout(element: ReactNode, data: Record<string, unknown>, rootLayout: RuntimeRoute): ReactNode;
|
|
7
8
|
export declare function buildNotFoundElement(component: NotFoundComponent | undefined, error: FurinNotFoundError): ReactNode;
|
|
8
9
|
/**
|
|
9
10
|
* Builds the error element rendered when a loader (or the SSR shell) fails.
|
|
@@ -4,4 +4,4 @@ export { handleISR } from "./isr.ts";
|
|
|
4
4
|
export { hasRequestLoader, type LoaderResult, runLoaders, serializeDeferredRejection, } from "./loaders.ts";
|
|
5
5
|
export { renderRootNotFound } from "./not-found.ts";
|
|
6
6
|
export { prerenderSSG, warmSSGCache } from "./ssg.ts";
|
|
7
|
-
export { assertDeferredModeAllowed, type PreparedRender, prepareRender, type RenderResult, renderForPath, renderSSR, renderToHTML, serializeLoaderDataNdjson,
|
|
7
|
+
export { assertDeferredModeAllowed, type PreparedRender, prepareRender, type RenderResult, renderForPath, renderSSR, renderToHTML, serializeLoaderDataNdjson, withSSRRouterContext, } from "./ssr.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Context } from "elysia";
|
|
2
2
|
import type { SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
3
|
-
import type { ResolvedRoute, RootLayout } from "../router/
|
|
3
|
+
import type { ResolvedRoute, RootLayout } from "../router/types.ts";
|
|
4
4
|
export declare function handleISR(route: ResolvedRoute, ctx: Context, root: RootLayout, buildId: string | undefined, searchRoutes?: SearchRouteMetadata[]): Promise<string | Response | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from "elysia";
|
|
2
2
|
import { type FurinNotFoundError } from "../../shared/not-found.ts";
|
|
3
|
-
import type { ResolvedRoute } from "../router/
|
|
3
|
+
import type { ResolvedRoute } from "../router/types.ts";
|
|
4
4
|
export type LoaderResult = {
|
|
5
5
|
type: "data";
|
|
6
6
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RootLayout } from "../router/
|
|
1
|
+
import type { RootLayout } from "../router/types.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Renders the root-level not-found component into a complete 404 HTML Response.
|
|
4
4
|
* Used by the Elysia `.onError` catch-all when no route matches the request URL.
|
|
@@ -2,7 +2,7 @@ import type { Context } from "elysia";
|
|
|
2
2
|
import type { SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
3
3
|
import { type RevalidateType } from "../cache/route-cache.ts";
|
|
4
4
|
import { type FurinInstance } from "../instance.ts";
|
|
5
|
-
import type { ResolvedRoute, RootLayout } from "../router/
|
|
5
|
+
import type { ResolvedRoute, RootLayout } from "../router/types.ts";
|
|
6
6
|
export declare function renderPprRoute(route: ResolvedRoute, ctx: Context, root: RootLayout, _buildId: string, searchRoutes: SearchRouteMetadata[] | undefined): Promise<Response>;
|
|
7
7
|
export declare function clearPprRouteCache(instance?: FurinInstance): void;
|
|
8
8
|
export declare function invalidatePprRoute(path: string, type: RevalidateType): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
2
2
|
import type { SsgCacheEntry } from "../cache/isr-ssg.ts";
|
|
3
|
-
import type { ResolvedRoute, RootLayout } from "../router/
|
|
3
|
+
import type { ResolvedRoute, RootLayout } from "../router/types.ts";
|
|
4
4
|
export declare function prerenderSSG(route: ResolvedRoute, params: Record<string, string>, root: RootLayout, origin: string, basePath?: string, searchRoutes?: SearchRouteMetadata[]): Promise<SsgCacheEntry | Response>;
|
|
5
5
|
/**
|
|
6
6
|
* Pre-renders all SSG routes that declare `staticParams` and populates the
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { Context } from "elysia";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import { renderToReadableStream } from "react-dom/server";
|
|
4
|
+
import { type DocumentAssets } from "../../client/document.tsx";
|
|
4
5
|
import type { RouterContextValue } from "../../client/router/types.ts";
|
|
6
|
+
import type { HeadOptions } from "../../client.ts";
|
|
5
7
|
import type { SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
6
|
-
import type { ResolvedRoute, RootLayout } from "../router/
|
|
8
|
+
import type { ResolvedRoute, RootLayout } from "../router/types.ts";
|
|
7
9
|
import { buildErrorElement } from "./element.tsx";
|
|
8
10
|
import { type LoaderResult } from "./loaders.ts";
|
|
9
11
|
export type { LoaderContext } from "./assemble.ts";
|
|
@@ -21,6 +23,7 @@ export interface RenderResult {
|
|
|
21
23
|
status: number;
|
|
22
24
|
}
|
|
23
25
|
export interface PreparedRender {
|
|
26
|
+
assets: DocumentAssets;
|
|
24
27
|
/**
|
|
25
28
|
* All props passed to the React component tree. For deferred renders this
|
|
26
29
|
* includes the Promise objects (for `<Await resolve={promise}>`) alongside
|
|
@@ -36,7 +39,7 @@ export interface PreparedRender {
|
|
|
36
39
|
element: ReactNode;
|
|
37
40
|
/** Set when the prepared element is an error UI. */
|
|
38
41
|
errorDigest?: string;
|
|
39
|
-
headData:
|
|
42
|
+
headData: HeadOptions | undefined;
|
|
40
43
|
headers: Record<string, string>;
|
|
41
44
|
loader_ms: number;
|
|
42
45
|
/**
|
|
@@ -55,7 +58,6 @@ export interface PreparedRender {
|
|
|
55
58
|
* excludes the Promise fields (those are streamed separately).
|
|
56
59
|
*/
|
|
57
60
|
syncData: Record<string, unknown>;
|
|
58
|
-
template: string;
|
|
59
61
|
}
|
|
60
62
|
export declare function withSSRRouterContext(element: ReactNode, contextValue: RouterContextValue): ReactNode;
|
|
61
63
|
interface ShellFallbackResult {
|
|
@@ -79,7 +81,7 @@ interface ShellFallbackResult {
|
|
|
79
81
|
* to a string) — both start from this same React stream and only diverge in how
|
|
80
82
|
* they consume it and which fields they log.
|
|
81
83
|
*/
|
|
82
|
-
export declare function renderElementWithShellFallback(element: ReactNode, errorComponent: Parameters<typeof buildErrorElement>[0], ssrContext: RouterContextValue): Promise<ShellFallbackResult>;
|
|
84
|
+
export declare function renderElementWithShellFallback(element: ReactNode, errorComponent: Parameters<typeof buildErrorElement>[0], ssrContext: RouterContextValue, wrapFallbackDocument: (element: ReactNode, digest: string) => ReactNode): Promise<ShellFallbackResult>;
|
|
83
85
|
/**
|
|
84
86
|
* defer() streams data progressively — it only makes sense in SSR. In SSG/ISR
|
|
85
87
|
* the HTML is pre-rendered and cached, so the deferred fields would be absent
|
|
@@ -89,7 +91,7 @@ export declare function renderElementWithShellFallback(element: ReactNode, error
|
|
|
89
91
|
export declare function assertDeferredModeAllowed(route: ResolvedRoute, deferredPromises: Record<string, Promise<unknown>> | undefined): void;
|
|
90
92
|
/**
|
|
91
93
|
* Shared pipeline steps used by both `renderToHTML` (buffered) and `renderSSR`
|
|
92
|
-
* (streaming). Runs loaders, builds props, head
|
|
94
|
+
* (streaming). Runs loaders, builds props, head data, resolves assets,
|
|
93
95
|
* and creates the React element.
|
|
94
96
|
*
|
|
95
97
|
* Returns the redirect Response directly when a loader redirects, so callers
|
|
@@ -104,4 +106,3 @@ export declare function renderForPath(route: ResolvedRoute, params: Record<strin
|
|
|
104
106
|
export declare function serializeLoaderDataNdjson(syncData: Record<string, unknown>, deferredPromises: Record<string, Promise<unknown>> | undefined): Promise<string>;
|
|
105
107
|
export declare function renderToHTML(route: ResolvedRoute, ctx: Context, root: RootLayout, searchRoutes?: SearchRouteMetadata[]): Promise<RenderResult>;
|
|
106
108
|
export declare function renderSSR(route: ResolvedRoute, ctx: Context, root: RootLayout, precomputedLoaderResult: LoaderResult | undefined, searchRoutes?: SearchRouteMetadata[]): Promise<Response>;
|
|
107
|
-
export declare function splitBeforeBodyClose(bodyPost: string): [string, string];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { DocumentAssets } from "../../client/document.tsx";
|
|
1
2
|
import { type FurinInstance } from "../instance.ts";
|
|
3
|
+
export declare function documentAssetsFromTemplate(template: string): DocumentAssets;
|
|
2
4
|
export declare function getDevTemplate(origin: string): Promise<string>;
|
|
5
|
+
export declare function getDevDocumentAssets(origin: string): Promise<DocumentAssets>;
|
|
3
6
|
export declare function setProductionTemplatePath(path: string | null, instance?: FurinInstance): void;
|
|
4
7
|
export declare function setProductionTemplateContent(content: string, instance?: FurinInstance): void;
|
|
8
|
+
export declare function getProductionDocumentAssets(): DocumentAssets | null;
|
|
5
9
|
export declare function getProductionTemplate(): string | null;
|
|
6
10
|
/** @internal test-only — resets all template state */
|
|
7
11
|
export declare function __resetTemplateState(): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RuntimePage, RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
2
|
+
import type { HeadOptions, RenderingMode } from "../../client.ts";
|
|
3
|
+
interface DefinedRouteTerminal {
|
|
4
|
+
__type: "FURIN_ROUTE";
|
|
5
|
+
component: (...args: never[]) => React.ReactNode;
|
|
6
|
+
elysia: object;
|
|
7
|
+
head?: (...args: never[]) => HeadOptions;
|
|
8
|
+
layout?: (...args: never[]) => React.ReactNode;
|
|
9
|
+
loader?: (...args: never[]) => unknown;
|
|
10
|
+
mode?: RenderingMode;
|
|
11
|
+
page?: (...args: never[]) => React.ReactNode;
|
|
12
|
+
requestLoader?: (...args: never[]) => unknown;
|
|
13
|
+
revalidate?: number;
|
|
14
|
+
schemas?: {
|
|
15
|
+
params?: unknown;
|
|
16
|
+
query?: unknown;
|
|
17
|
+
};
|
|
18
|
+
staticParams?: () => Promise<readonly unknown[]> | readonly unknown[];
|
|
19
|
+
tags?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export declare function isDefinedRouteTerminal(value: unknown): value is DefinedRouteTerminal;
|
|
22
|
+
export declare function adaptDefinedLayout(route: DefinedRouteTerminal, parent: RuntimeRoute | undefined, sourcePath?: string): RuntimeRoute;
|
|
23
|
+
export declare function adaptDefinedPage(route: DefinedRouteTerminal, parent: RuntimeRoute): RuntimePage;
|
|
24
|
+
export {};
|
|
@@ -4,12 +4,20 @@ import type { SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
|
4
4
|
import { type CompileContext } from "../internal.ts";
|
|
5
5
|
import type { ResolvedRoute, RootLayout } from "./types.ts";
|
|
6
6
|
type RouteModuleImport = (specifier: string) => Promise<Record<string, unknown>>;
|
|
7
|
-
export declare function importFreshRouteModuleCandidate(layoutPath: string, timestamp: number, resolveImport: RouteModuleImport, ctx: CompileContext | null): Promise<Record<string, unknown> | undefined>;
|
|
8
7
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* Reuses one virtual ESM module per source version. A timestamp generated on
|
|
9
|
+
* every request leaks module-registry entries because Bun cannot release old
|
|
10
|
+
* module identities; the source stamp preserves HMR freshness without
|
|
11
|
+
* request-proportional growth. Promise caching also deduplicates concurrent
|
|
12
|
+
* requests for the same edited version.
|
|
13
|
+
*/
|
|
14
|
+
export declare function importStampedRouteModule(path: string, resolveImport: RouteModuleImport): Promise<Record<string, unknown>>;
|
|
15
|
+
export declare function invalidateStampedRouteModules(): void;
|
|
16
|
+
export declare function importFreshRouteModuleCandidate(layoutPath: string, resolveImport: RouteModuleImport, ctx: CompileContext | null): Promise<Record<string, unknown> | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* Re-imports edited intermediate layout _route.tsx files with a versioned
|
|
19
|
+
* module identity, then patches the layout/loader references on the existing
|
|
20
|
+
* route-chain objects.
|
|
13
21
|
*
|
|
14
22
|
* The optional `importFn` parameter exists only for unit testing. In production
|
|
15
23
|
* it defaults to the real `import()`.
|
|
@@ -20,8 +28,8 @@ export declare function refreshLayoutChain(chain: RuntimeRoute[], pagePath: stri
|
|
|
20
28
|
* `mode` reflects the CURRENT contents of the page module — not the value
|
|
21
29
|
* captured at scan time.
|
|
22
30
|
*
|
|
23
|
-
* In dev, `handleDevRequest`
|
|
24
|
-
*
|
|
31
|
+
* In dev, `handleDevRequest` resolves the current versioned page module on
|
|
32
|
+
* every request. Without this
|
|
25
33
|
* function the spread `{ ...route, page, chain }` would carry over the stale
|
|
26
34
|
* `route.mode` resolved at startup, so toggling `revalidate` or removing a
|
|
27
35
|
* loader in source would not retake effect until a server restart.
|
|
@@ -31,7 +39,7 @@ export declare function refreshLayoutChain(chain: RuntimeRoute[], pagePath: stri
|
|
|
31
39
|
* `notFound`) are scan-time invariants in dev and are preserved as-is.
|
|
32
40
|
*/
|
|
33
41
|
export declare function rebuildDevRoute(base: ResolvedRoute, page: RuntimePage, chain: RuntimeRoute[]): ResolvedRoute;
|
|
34
|
-
/** @internal Handles a request in dev mode
|
|
42
|
+
/** @internal Handles a request in dev mode using the current source-version modules. */
|
|
35
43
|
export declare function handleDevRequest(route: ResolvedRoute, ctx: Context, root: RootLayout, searchRoutes?: SearchRouteMetadata[]): Promise<unknown>;
|
|
36
44
|
/**
|
|
37
45
|
* @internal Dev "Live ISR" — caches loader output, not assembled HTML. On a
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { RuntimePage, RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
2
2
|
export declare function collectIntermediateLayoutDirs(pagePath: string, rootPath: string): string[];
|
|
3
3
|
export declare function resolveMode(page: RuntimePage, routeChain: RuntimeRoute[]): "ssr" | "ssg" | "isr";
|
|
4
|
+
export interface DynamicRouteSegment {
|
|
5
|
+
catchAll: boolean;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function parseDynamicRouteSegment(segment: string, sourcePath: string | undefined): DynamicRouteSegment | undefined;
|
|
9
|
+
export declare function routeSegmentToPattern(segment: string): string;
|
|
4
10
|
export declare function filePathToPattern(path: string): string;
|
|
5
11
|
export declare function escapeRegExpChar(ch: string): string;
|
|
6
12
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type AnyElysia } from "elysia";
|
|
1
|
+
import { type AnyElysia, type Context } from "elysia";
|
|
2
2
|
import type { SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
3
|
-
import type { ResolvedRoute, RootLayout } from "./types.ts";
|
|
3
|
+
import type { ResolvedRoute, ResolvedRoutesSource, RootLayout } from "./types.ts";
|
|
4
4
|
export declare function createRoutePlugin(route: ResolvedRoute, root: RootLayout, buildId?: string, searchRoutes?: SearchRouteMetadata[]): AnyElysia;
|
|
5
|
+
export declare function renderResolvedRoute(route: ResolvedRoute, ctx: Context, root: RootLayout, buildId: string, searchRoutes: SearchRouteMetadata[] | undefined): unknown;
|
|
5
6
|
/**
|
|
6
7
|
* Elysia plugin that handles `GET /_furin/data?path=<logicalHref>`.
|
|
7
8
|
*
|
|
@@ -15,4 +16,4 @@ export declare function createRoutePlugin(route: ResolvedRoute, root: RootLayout
|
|
|
15
16
|
* - `__furinNotFound` — not-found payload
|
|
16
17
|
* - `__furinRedirect` — logical path after a server-side redirect
|
|
17
18
|
*/
|
|
18
|
-
export declare function createDataEndpoint(
|
|
19
|
+
export declare function createDataEndpoint(routesSource: ResolvedRoutesSource): AnyElysia;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AnySchema } from "elysia/types";
|
|
2
1
|
import type { RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
3
|
-
|
|
2
|
+
import { type FurinSchema } from "../../shared/elysia-contract.ts";
|
|
3
|
+
export declare function mergeRouteSchemas(routeChain: RuntimeRoute[], key: "params" | "query"): FurinSchema | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnySchema } from "elysia/types";
|
|
2
1
|
import type { RuntimeRoute } from "../../client/internal/runtime-types.ts";
|
|
2
|
+
import { type FurinSchema } from "../../shared/elysia-contract.ts";
|
|
3
3
|
import { type SearchParamsInput, type SearchRouteMetadata } from "../../shared/search-params.ts";
|
|
4
4
|
interface UnknownObject {
|
|
5
5
|
[key: string]: unknown;
|
|
@@ -42,15 +42,15 @@ export type ParseRouteParamsResult = {
|
|
|
42
42
|
*
|
|
43
43
|
* @internal Exported for unit testing.
|
|
44
44
|
*/
|
|
45
|
-
export declare function parseRouteQuery(url: URL, schema:
|
|
45
|
+
export declare function parseRouteQuery(url: URL, schema: FurinSchema | undefined): Promise<ParseRouteQueryResult>;
|
|
46
46
|
/**
|
|
47
47
|
* Validates and coerces path params for the synthetic `/_furin/data` request
|
|
48
|
-
* path. This mirrors the
|
|
49
|
-
*
|
|
48
|
+
* path. This mirrors the composed Elysia route schema so SPA loaders receive
|
|
49
|
+
* the same values as full SSR loaders.
|
|
50
50
|
*
|
|
51
51
|
* @internal Exported for unit testing.
|
|
52
52
|
*/
|
|
53
|
-
export declare function parseRouteParams(params: UnknownObject, schema:
|
|
53
|
+
export declare function parseRouteParams(params: UnknownObject, schema: FurinSchema | undefined): Promise<ParseRouteParamsResult>;
|
|
54
54
|
export declare function createSearchRouteMetadata(routes: Array<{
|
|
55
55
|
pattern: string;
|
|
56
56
|
routeChain: RuntimeRoute[];
|