@teyik0/furin 0.2.0-alpha.1 → 0.2.0-alpha.2
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/package.json +8 -3
- package/src/adapter/static.ts +23 -6
- package/src/build/client.ts +5 -2
- package/src/build/hydrate.ts +7 -1
- package/src/build/route-types.ts +37 -7
- package/src/build/shared.ts +1 -0
- package/src/build/ssg-cache.ts +3 -2
- package/src/client/link.tsx +13 -4
- package/src/client/router/context.ts +2 -0
- package/src/client/router/index.ts +9 -0
- package/src/client/router/link-utils.ts +5 -8
- package/src/client/router/navigation.ts +61 -0
- package/src/client/router/provider.tsx +59 -23
- package/src/client/router/search/index.ts +99 -0
- package/src/client/router/search-store.ts +86 -0
- package/src/client/router/types.ts +12 -4
- package/src/furin.ts +11 -4
- package/src/server/render/isr.ts +29 -7
- package/src/server/render/not-found.ts +2 -0
- package/src/server/render/ssg.ts +15 -4
- package/src/server/render/ssr.ts +47 -9
- package/src/server/router/hmr.ts +14 -10
- package/src/server/router/index.ts +1 -2
- package/src/server/router/patterns.ts +5 -0
- package/src/server/router/plugin.ts +28 -45
- package/src/server/router/schemas.ts +172 -57
- package/src/shared/search-params.ts +182 -0
- package/dist/adapter/bun.d.ts +0 -3
- package/dist/adapter/static.d.ts +0 -3
- package/dist/build/client.d.ts +0 -25
- package/dist/build/compile-entry.d.ts +0 -9
- package/dist/build/compile-entry.ts +0 -109
- package/dist/build/entry-template.d.ts +0 -38
- package/dist/build/entry-template.ts +0 -156
- package/dist/build/hydrate.d.ts +0 -24
- package/dist/build/index.d.ts +0 -8
- package/dist/build/index.js +0 -7069
- package/dist/build/route-types.d.ts +0 -21
- package/dist/build/scan-server.d.ts +0 -8
- package/dist/build/server-routes-entry.d.ts +0 -13
- package/dist/build/server-routes-entry.ts +0 -36
- package/dist/build/shared.d.ts +0 -11
- package/dist/build/ssg-cache.d.ts +0 -4
- package/dist/build/types.d.ts +0 -80
- package/dist/cli/config.d.ts +0 -9
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -7082
- package/dist/client/boundaries.d.ts +0 -117
- package/dist/client/default-screens.d.ts +0 -17
- package/dist/client/link.d.ts +0 -22
- package/dist/client/link.js +0 -3450
- package/dist/client/router/boundary-tree.d.ts +0 -26
- package/dist/client/router/context.d.ts +0 -8
- package/dist/client/router/history.d.ts +0 -9
- package/dist/client/router/index.d.ts +0 -7
- package/dist/client/router/link-utils.d.ts +0 -51
- package/dist/client/router/provider.d.ts +0 -4
- package/dist/client/router/spa-response.d.ts +0 -58
- package/dist/client/router/types.d.ts +0 -279
- package/dist/client/server-error.d.ts +0 -12
- package/dist/client.d.ts +0 -242
- package/dist/client.js +0 -96
- package/dist/config.d.ts +0 -57
- package/dist/config.js +0 -29
- package/dist/env.d.ts +0 -50
- package/dist/furin.d.ts +0 -69
- package/dist/furin.js +0 -7373
- package/dist/plugin/index.d.ts +0 -20
- package/dist/plugin/index.js +0 -1500
- package/dist/plugin/transform-client.d.ts +0 -10
- package/dist/server/auto-invalidate/index.d.ts +0 -4
- package/dist/server/auto-invalidate/plugin.d.ts +0 -38
- package/dist/server/auto-invalidate/registry.d.ts +0 -9
- package/dist/server/auto-invalidate/runtime.d.ts +0 -9
- package/dist/server/auto-invalidate/types.d.ts +0 -12
- package/dist/server/cache/dev-loader.d.ts +0 -28
- package/dist/server/cache/index.d.ts +0 -10
- package/dist/server/cache/invalidation.d.ts +0 -12
- package/dist/server/cache/isr-ssg.d.ts +0 -26
- package/dist/server/cache/isr.d.ts +0 -6
- package/dist/server/cache/registry.d.ts +0 -5
- package/dist/server/cache/route-cache.d.ts +0 -26
- package/dist/server/cache/ssg.d.ts +0 -5
- package/dist/server/context-logger.d.ts +0 -28
- package/dist/server/dev-inspector.d.ts +0 -89
- package/dist/server/dev-page-plugin.d.ts +0 -109
- package/dist/server/internal.d.ts +0 -35
- package/dist/server/internal.js +0 -17
- package/dist/server/lang-detect.d.ts +0 -5
- package/dist/server/render/assemble.d.ts +0 -47
- package/dist/server/render/element.d.ts +0 -24
- package/dist/server/render/index.d.ts +0 -7
- package/dist/server/render/index.ts +0 -22
- package/dist/server/render/isr.d.ts +0 -3
- package/dist/server/render/loaders.d.ts +0 -64
- package/dist/server/render/not-found.d.ts +0 -6
- package/dist/server/render/shell.d.ts +0 -39
- package/dist/server/render/shell.ts +0 -202
- package/dist/server/render/ssg.d.ts +0 -8
- package/dist/server/render/ssr.d.ts +0 -107
- package/dist/server/render/template.d.ts +0 -6
- package/dist/server/router/discovery.d.ts +0 -16
- package/dist/server/router/hmr.d.ts +0 -64
- package/dist/server/router/index.d.ts +0 -6
- package/dist/server/router/index.js +0 -28
- package/dist/server/router/index.ts +0 -29
- package/dist/server/router/patterns.d.ts +0 -40
- package/dist/server/router/plugin.d.ts +0 -20
- package/dist/server/router/schemas.d.ts +0 -51
- package/dist/server/router/types.d.ts +0 -60
- package/dist/server/runtime-env.d.ts +0 -3
- package/dist/server/runtime-env.js +0 -10
- package/dist/shared/await.d.ts +0 -67
- package/dist/shared/deferred-ndjson.d.ts +0 -32
- package/dist/shared/digest.d.ts +0 -16
- package/dist/shared/error.d.ts +0 -37
- package/dist/shared/not-found.d.ts +0 -19
- package/dist/shared/utils/ast-walk.d.ts +0 -18
- package/dist/shared/utils/index.d.ts +0 -13
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import MagicString from "magic-string";
|
|
2
|
-
import { type SourceLang } from "yuku-parser";
|
|
3
|
-
interface TransformResult {
|
|
4
|
-
code: string;
|
|
5
|
-
map: ReturnType<MagicString["generateMap"]> | null;
|
|
6
|
-
removedServerCode: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function deadCodeElimination(s: MagicString, lang: SourceLang): MagicString;
|
|
9
|
-
export declare function transformForClient(code: string, filename: string): TransformResult;
|
|
10
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { furinInvalidate } from "./plugin.ts";
|
|
2
|
-
export { AutoInvalidateRegistry, autoInvalidateRegistry } from "./registry.ts";
|
|
3
|
-
export { appendPendingInvalidationHeader, isSuccessfulMutationResponse, revalidateTag, runInvalidationRules, } from "./runtime.ts";
|
|
4
|
-
export type { InvalidationInput, InvalidationRule } from "./types.ts";
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type AfterHandler, Elysia } from "elysia";
|
|
2
|
-
import type { InvalidationInput } from "./types.ts";
|
|
3
|
-
type AnyAfterHandleContext = Parameters<AfterHandler>[0];
|
|
4
|
-
export declare function furinInvalidate(): Elysia<"", {
|
|
5
|
-
decorator: {};
|
|
6
|
-
store: {};
|
|
7
|
-
derive: {};
|
|
8
|
-
resolve: {};
|
|
9
|
-
}, {
|
|
10
|
-
typebox: {};
|
|
11
|
-
error: {};
|
|
12
|
-
}, {
|
|
13
|
-
schema: {};
|
|
14
|
-
standaloneSchema: {};
|
|
15
|
-
macro: Partial<{
|
|
16
|
-
readonly invalidate: InvalidationInput;
|
|
17
|
-
}>;
|
|
18
|
-
macroFn: {
|
|
19
|
-
readonly invalidate: (rules: InvalidationInput) => {
|
|
20
|
-
readonly afterHandle: (ctx: AnyAfterHandleContext) => void;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
parser: {};
|
|
24
|
-
response: {};
|
|
25
|
-
}, {}, {
|
|
26
|
-
derive: {};
|
|
27
|
-
resolve: {};
|
|
28
|
-
schema: {};
|
|
29
|
-
standaloneSchema: {};
|
|
30
|
-
response: {};
|
|
31
|
-
}, {
|
|
32
|
-
derive: {};
|
|
33
|
-
resolve: {};
|
|
34
|
-
schema: {};
|
|
35
|
-
standaloneSchema: {};
|
|
36
|
-
response: {};
|
|
37
|
-
}>;
|
|
38
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare class AutoInvalidateRegistry {
|
|
2
|
-
private readonly pathToTags;
|
|
3
|
-
private readonly tagToPaths;
|
|
4
|
-
registerLoaderTags(urlPath: string, tags: readonly string[] | undefined): void;
|
|
5
|
-
pathsForTags(tags: readonly string[]): string[];
|
|
6
|
-
unregisterPath(urlPath: string): void;
|
|
7
|
-
reset(): void;
|
|
8
|
-
}
|
|
9
|
-
export declare const autoInvalidateRegistry: AutoInvalidateRegistry;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Context } from "elysia";
|
|
2
|
-
import type { InvalidationInput } from "./types.ts";
|
|
3
|
-
export declare function isSuccessfulMutationResponse(ctx: Pick<Context, "set"> & {
|
|
4
|
-
responseValue?: unknown;
|
|
5
|
-
response?: unknown;
|
|
6
|
-
}): boolean;
|
|
7
|
-
export declare function appendPendingInvalidationHeader(set: Context["set"]): void;
|
|
8
|
-
export declare function revalidateTag(tags: string | readonly string[]): boolean;
|
|
9
|
-
export declare function runInvalidationRules(input: InvalidationInput): boolean;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { CacheTag } from "../../furin.ts";
|
|
2
|
-
import type { RevalidateType } from "../cache/route-cache.ts";
|
|
3
|
-
export type InvalidationRule = {
|
|
4
|
-
path: string;
|
|
5
|
-
tags?: readonly CacheTag[];
|
|
6
|
-
type: RevalidateType;
|
|
7
|
-
} | {
|
|
8
|
-
path?: never;
|
|
9
|
-
tags: readonly CacheTag[];
|
|
10
|
-
type?: never;
|
|
11
|
-
};
|
|
12
|
-
export type InvalidationInput = InvalidationRule | readonly InvalidationRule[];
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type RevalidateType } from "./route-cache";
|
|
2
|
-
export interface DevLoaderCacheEntry {
|
|
3
|
-
dependencies: string[];
|
|
4
|
-
generatedAt: number;
|
|
5
|
-
headers: Record<string, string>;
|
|
6
|
-
loaderData: Record<string, unknown>;
|
|
7
|
-
mode: "isr" | "ssg";
|
|
8
|
-
revalidate: number;
|
|
9
|
-
}
|
|
10
|
-
export interface InvalidateOutcome {
|
|
11
|
-
cleared: string[];
|
|
12
|
-
isr: number;
|
|
13
|
-
ssg: number;
|
|
14
|
-
}
|
|
15
|
-
export declare const devISRLoaderCache: import("./route-cache").Cache<DevLoaderCacheEntry>;
|
|
16
|
-
export declare const devSSGLoaderCache: import("./route-cache").Cache<DevLoaderCacheEntry>;
|
|
17
|
-
export declare function getDevISRLoaderCache(key: string): DevLoaderCacheEntry | undefined;
|
|
18
|
-
export declare function setDevISRLoaderCache(key: string, entry: DevLoaderCacheEntry): void;
|
|
19
|
-
export declare function getDevSSGLoaderCache(key: string): DevLoaderCacheEntry | undefined;
|
|
20
|
-
export declare function setDevSSGLoaderCache(key: string, entry: DevLoaderCacheEntry): void;
|
|
21
|
-
export declare function urlPathFromCacheKey(key: string): string | null;
|
|
22
|
-
export declare function invalidateDevLoaderCacheByPath(path: string, type: RevalidateType): InvalidateOutcome;
|
|
23
|
-
export declare function invalidateDevLoaderCacheBySource(filePath: string): InvalidateOutcome;
|
|
24
|
-
export declare function isDevLoaderCacheFresh(entry: DevLoaderCacheEntry): boolean;
|
|
25
|
-
export declare function isDevLoaderCacheValid(entry: DevLoaderCacheEntry): boolean;
|
|
26
|
-
export declare function getAllDevISRLoaderEntries(): [string, DevLoaderCacheEntry][];
|
|
27
|
-
export declare function getAllDevSSGLoaderEntries(): [string, DevLoaderCacheEntry][];
|
|
28
|
-
export declare function __resetDevLoaderCacheState(): void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type { DevLoaderCacheEntry, InvalidateOutcome } from "./dev-loader";
|
|
2
|
-
export { __resetDevLoaderCacheState, getAllDevISRLoaderEntries, getAllDevSSGLoaderEntries, getDevISRLoaderCache, getDevSSGLoaderCache, invalidateDevLoaderCacheByPath, invalidateDevLoaderCacheBySource, isDevLoaderCacheFresh, isDevLoaderCacheValid, setDevISRLoaderCache, setDevSSGLoaderCache, urlPathFromCacheKey, } from "./dev-loader";
|
|
3
|
-
export { __resetCacheState, _runWithRequestInvalidationScope, callCachePurger, consumePendingInvalidations, getBuildId, revalidatePath, setBuildId, setCachePurger, } from "./invalidation";
|
|
4
|
-
export { deleteISRCache, getISRCache, isrCache, setISRCache } from "./isr";
|
|
5
|
-
export type { ISRCacheEntry, SsgCacheEntry } from "./isr-ssg";
|
|
6
|
-
export type { CacheInvalidator } from "./registry";
|
|
7
|
-
export { registerCacheInvalidator } from "./registry";
|
|
8
|
-
export type { Cache, CacheInvalidationResult, RevalidateType } from "./route-cache";
|
|
9
|
-
export { createRouteCache } from "./route-cache";
|
|
10
|
-
export { getSSGCache, setSSGCache, ssgCache } from "./ssg";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { RevalidateType } from "./route-cache";
|
|
2
|
-
export declare function setBuildId(id: string): void;
|
|
3
|
-
export declare function getBuildId(): string;
|
|
4
|
-
export declare function _runWithRequestInvalidationScope<T>(fn: () => T): T;
|
|
5
|
-
export declare function consumePendingInvalidations(): string[];
|
|
6
|
-
type CachePurger = (paths: string[]) => Promise<void>;
|
|
7
|
-
export declare function setCachePurger(fn: CachePurger): void;
|
|
8
|
-
export declare function callCachePurger(paths: string[]): void;
|
|
9
|
-
export declare function revalidatePath(path: string, type: RevalidateType): boolean;
|
|
10
|
-
/** @internal — resets all module state between tests */
|
|
11
|
-
export declare function __resetCacheState(): void;
|
|
12
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type Cache } from "./route-cache";
|
|
2
|
-
export interface ISRCacheEntry {
|
|
3
|
-
generatedAt: number;
|
|
4
|
-
html: string;
|
|
5
|
-
revalidate: number;
|
|
6
|
-
}
|
|
7
|
-
export interface SsgCacheEntry {
|
|
8
|
-
cachedAt: number;
|
|
9
|
-
html: string;
|
|
10
|
-
/**
|
|
11
|
-
* NDJSON payload identical in shape to what the live `/_furin/data` endpoint
|
|
12
|
-
* emits. Persisted alongside the HTML by the static adapter so SPA navigation
|
|
13
|
-
* on a static-hosted deployment can fetch loader data without going through
|
|
14
|
-
* a runtime endpoint that does not exist on a file server.
|
|
15
|
-
*/
|
|
16
|
-
ndjson: string;
|
|
17
|
-
status: number;
|
|
18
|
-
tags?: string[];
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Builds the LRU cache backing one render mode's pre-rendered HTML. ISR and SSG
|
|
22
|
-
* share the same eviction bound and the same `onDelete` hook — which keeps the
|
|
23
|
-
* auto-invalidate path registry in sync — and differ only in entry shape and
|
|
24
|
-
* the diagnostic `name`.
|
|
25
|
-
*/
|
|
26
|
-
export declare function createHtmlRouteCache<Entry>(mode: "isr" | "ssg"): Cache<Entry>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type ISRCacheEntry } from "./isr-ssg";
|
|
2
|
-
export declare const isrRouteCache: import("./route-cache").Cache<ISRCacheEntry>;
|
|
3
|
-
export declare const isrCache: Map<string, ISRCacheEntry>;
|
|
4
|
-
export declare function getISRCache(key: string): ISRCacheEntry | undefined;
|
|
5
|
-
export declare function deleteISRCache(key: string): boolean;
|
|
6
|
-
export declare function setISRCache(key: string, entry: ISRCacheEntry): void;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Cache } from "./route-cache";
|
|
2
|
-
export type CacheInvalidator = Pick<Cache<unknown>, "invalidatePath" | "name">;
|
|
3
|
-
export declare function registerCacheInvalidator(invalidator: CacheInvalidator): () => void;
|
|
4
|
-
export declare function getCacheInvalidators(): IterableIterator<CacheInvalidator>;
|
|
5
|
-
export declare function clearCacheInvalidators(): void;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type RevalidateType = "page" | "layout";
|
|
2
|
-
export interface CacheInvalidationResult {
|
|
3
|
-
deleted: boolean;
|
|
4
|
-
purgedPaths: string[];
|
|
5
|
-
}
|
|
6
|
-
export interface Cache<Entry> {
|
|
7
|
-
clear(): void;
|
|
8
|
-
delete(key: string): boolean;
|
|
9
|
-
entries(): IterableIterator<[string, Entry]>;
|
|
10
|
-
get(key: string): Entry | undefined;
|
|
11
|
-
has(key: string): boolean;
|
|
12
|
-
invalidatePath(path: string, type: RevalidateType): CacheInvalidationResult;
|
|
13
|
-
keys(): IterableIterator<string>;
|
|
14
|
-
readonly name: string;
|
|
15
|
-
set(key: string, entry: Entry): void;
|
|
16
|
-
get size(): number;
|
|
17
|
-
readonly store: Map<string, Entry>;
|
|
18
|
-
}
|
|
19
|
-
export interface RouteCacheOptions<Entry> {
|
|
20
|
-
maxSize?: number;
|
|
21
|
-
name: string;
|
|
22
|
-
onDelete?: (key: string, entry: Entry) => void;
|
|
23
|
-
onSet?: (key: string, entry: Entry, previous: Entry | undefined) => void;
|
|
24
|
-
pathFromKey?: (key: string) => string | null;
|
|
25
|
-
}
|
|
26
|
-
export declare function createRouteCache<Entry>(options: RouteCacheOptions<Entry>): Cache<Entry>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type SsgCacheEntry } from "./isr-ssg";
|
|
2
|
-
export declare const ssgRouteCache: import("./route-cache").Cache<SsgCacheEntry>;
|
|
3
|
-
export declare const ssgCache: Map<string, SsgCacheEntry>;
|
|
4
|
-
export declare function getSSGCache(key: string): SsgCacheEntry | undefined;
|
|
5
|
-
export declare function setSSGCache(key: string, entry: SsgCacheEntry): void;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { RequestLogger } from "evlog";
|
|
2
|
-
import { createLogger } from "evlog";
|
|
3
|
-
export { createLogger };
|
|
4
|
-
/**
|
|
5
|
-
* Returns the current request-scoped logger.
|
|
6
|
-
*
|
|
7
|
-
* Priority:
|
|
8
|
-
* 1. Live Elysia request handled by the evlog() plugin → full request-scoped wide event
|
|
9
|
-
* 2. Synthetic render scope (ISR revalidation, SSG pre-render) → detached createLogger()
|
|
10
|
-
* that still drains to the configured adapter (Datadog, Axiom, etc.)
|
|
11
|
-
* 3. Completely outside any context → no-op
|
|
12
|
-
*
|
|
13
|
-
* Import from `@teyik0/furin` instead of `evlog/elysia` so this fallback chain
|
|
14
|
-
* applies in all rendering contexts.
|
|
15
|
-
*/
|
|
16
|
-
export declare function useLogger(): RequestLogger;
|
|
17
|
-
/**
|
|
18
|
-
* Runs `fn` inside a synthetic render scope.
|
|
19
|
-
*
|
|
20
|
-
* Creates a detached `createLogger()` instance for the duration of `fn`.
|
|
21
|
-
* `useLogger()` calls inside `fn` (including user loaders) return this logger
|
|
22
|
-
* instead of throwing. On completion, the accumulated wide event is emitted to
|
|
23
|
-
* the global drain with the provided initial context (e.g. route pattern).
|
|
24
|
-
*
|
|
25
|
-
* Used by renderForPath() which drives both ISR background revalidation and
|
|
26
|
-
* SSG pre-renders — neither has a live Elysia request context.
|
|
27
|
-
*/
|
|
28
|
-
export declare function runInSyntheticRenderScope<T>(fn: () => Promise<T> | T, initialContext: Record<string, unknown>): Promise<T>;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { Elysia } from "elysia";
|
|
2
|
-
/**
|
|
3
|
-
* Dev "Live ISR" inspector.
|
|
4
|
-
*
|
|
5
|
-
* Mounts read-only JSON endpoints that surface the active entries of the
|
|
6
|
-
* dev-mode loader caches. Designed to back a future browser DevTools panel:
|
|
7
|
-
* the JSON shape is stable and carries enough information for a UI to render
|
|
8
|
-
* a freshness-aware entry list with dependencies and a data preview.
|
|
9
|
-
*
|
|
10
|
-
* The plugin always registers the routes — caller is responsible for gating
|
|
11
|
-
* on `IS_DEV` to keep them out of production builds.
|
|
12
|
-
*/
|
|
13
|
-
/** Public response shape — keep stable for downstream UI consumers. */
|
|
14
|
-
export interface InspectorEntry {
|
|
15
|
-
/** Per-entry preview of the cached loader output. */
|
|
16
|
-
dataPreview: Record<string, unknown>;
|
|
17
|
-
/** Source files whose change drops this entry. */
|
|
18
|
-
dependencies: string[];
|
|
19
|
-
/** ms timestamp at which the entry was written. */
|
|
20
|
-
generatedAt: number;
|
|
21
|
-
/** True iff the entry is still within its `revalidate` window. */
|
|
22
|
-
isFresh: boolean;
|
|
23
|
-
/** Resolved cache key (the same path used by `revalidatePath`). */
|
|
24
|
-
key: string;
|
|
25
|
-
/** Cache origin — surfaced verbatim so a UI can group by mode. */
|
|
26
|
-
mode: "isr" | "ssg";
|
|
27
|
-
/** Revalidate window in seconds. SSG entries report `-1` for "indefinite". */
|
|
28
|
-
revalidate: number;
|
|
29
|
-
}
|
|
30
|
-
export declare function createDevInspectorPlugin(): Elysia<"", {
|
|
31
|
-
decorator: {};
|
|
32
|
-
store: {};
|
|
33
|
-
derive: {};
|
|
34
|
-
resolve: {};
|
|
35
|
-
}, {
|
|
36
|
-
typebox: {};
|
|
37
|
-
error: {};
|
|
38
|
-
}, {
|
|
39
|
-
schema: {};
|
|
40
|
-
standaloneSchema: {};
|
|
41
|
-
macro: {};
|
|
42
|
-
macroFn: {};
|
|
43
|
-
parser: {};
|
|
44
|
-
response: {};
|
|
45
|
-
}, {
|
|
46
|
-
__furin: {
|
|
47
|
-
_inspect: {
|
|
48
|
-
isr: {
|
|
49
|
-
get: {
|
|
50
|
-
body: unknown;
|
|
51
|
-
params: {};
|
|
52
|
-
query: unknown;
|
|
53
|
-
headers: unknown;
|
|
54
|
-
response: {
|
|
55
|
-
200: InspectorEntry[];
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
} & {
|
|
62
|
-
__furin: {
|
|
63
|
-
_inspect: {
|
|
64
|
-
ssg: {
|
|
65
|
-
get: {
|
|
66
|
-
body: unknown;
|
|
67
|
-
params: {};
|
|
68
|
-
query: unknown;
|
|
69
|
-
headers: unknown;
|
|
70
|
-
response: {
|
|
71
|
-
200: InspectorEntry[];
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
}, {
|
|
78
|
-
derive: {};
|
|
79
|
-
resolve: {};
|
|
80
|
-
schema: {};
|
|
81
|
-
standaloneSchema: {};
|
|
82
|
-
response: {};
|
|
83
|
-
}, {
|
|
84
|
-
derive: {};
|
|
85
|
-
resolve: {};
|
|
86
|
-
schema: {};
|
|
87
|
-
standaloneSchema: {};
|
|
88
|
-
response: {};
|
|
89
|
-
}>;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bun.plugin that loads page modules into a virtual namespace so they stay
|
|
3
|
-
* out of `--hot`'s file watcher.
|
|
4
|
-
*
|
|
5
|
-
* `--hot` re-evaluates every real source file in the module graph when any
|
|
6
|
-
* tracked file changes. By resolving page imports to a virtual namespace
|
|
7
|
-
* (`furin-dev-page`), the actual `.tsx` files are never registered as
|
|
8
|
-
* watched sources — edits trigger only the client-side dev bundler (React
|
|
9
|
-
* Fast Refresh) without a full server restart.
|
|
10
|
-
*
|
|
11
|
-
* ## Cache-busting (prevents hydration mismatches)
|
|
12
|
-
*
|
|
13
|
-
* Bun caches every resolved module by its `(namespace, path)` identity.
|
|
14
|
-
* Without cache-busting, the first import of `pages/index.tsx` would be
|
|
15
|
-
* permanently frozen: after a file edit the server would keep returning the
|
|
16
|
-
* stale module while the client received fresh HMR code, causing a React
|
|
17
|
-
* hydration mismatch.
|
|
18
|
-
*
|
|
19
|
-
* Solution: the caller appends `?furin-server&t=<timestamp>` to the import
|
|
20
|
-
* specifier (a new timestamp on every request). `onResolve` preserves the
|
|
21
|
-
* `?t=...` fragment in the resolved path so each request gets a unique
|
|
22
|
-
* `(namespace, path)` key and Bun always calls `onLoad` fresh.
|
|
23
|
-
*
|
|
24
|
-
* ## Relative import rewriting
|
|
25
|
-
*
|
|
26
|
-
* Modules in a virtual namespace cannot resolve relative specifiers on their
|
|
27
|
-
* own (there is no real directory context). We rewrite every `./` / `../`
|
|
28
|
-
* path to an absolute one before returning the source.
|
|
29
|
-
*
|
|
30
|
-
* ## Bare specifier rewriting
|
|
31
|
-
*
|
|
32
|
-
* When `onLoad` returns `loader: "js"`, Bun resolves bare specifiers
|
|
33
|
-
* (e.g. `@teyik0/furin/link`, `shiki`) from the process CWD — not from the
|
|
34
|
-
* page file's directory. On a cold start the CWD and the file's directory
|
|
35
|
-
* often agree, but after `bun --hot` re-evaluates the server the module
|
|
36
|
-
* cache for project-local packages (like `packages/core/src/link.tsx`) may
|
|
37
|
-
* be cleared and re-loaded with a fresh React instance that diverges from the
|
|
38
|
-
* one already cached by `react-dom/server`. The result is the classic
|
|
39
|
-
* "two React copies" crash: `dispatcher.useState === null`.
|
|
40
|
-
*
|
|
41
|
-
* Fix: after transpilation, resolve every bare specifier from the page
|
|
42
|
-
* file's directory via `Bun.resolveSync` and replace it with the
|
|
43
|
-
* canonical on-disk path. This pins each import to exactly the same
|
|
44
|
-
* file-system location that Bun's native module resolver would choose,
|
|
45
|
-
* guaranteeing a single shared React instance regardless of CWD or
|
|
46
|
-
* hot-reload state.
|
|
47
|
-
*
|
|
48
|
-
* All import/re-export occurrences of each quoted specifier are replaced using
|
|
49
|
-
* a context-aware regex (requires a preceding `from` or `import` keyword) so
|
|
50
|
-
* that modules which both import and re-export from the same package are fully
|
|
51
|
-
* rewritten while string literals in non-import positions are left untouched.
|
|
52
|
-
*/
|
|
53
|
-
/**
|
|
54
|
-
* Rewrites bare React/react-dom singleton imports in source text to their
|
|
55
|
-
* absolute resolved paths. Handles explicit static import / re-export forms:
|
|
56
|
-
*
|
|
57
|
-
* import { useState } from "react" → import { useState } from "/abs/…"
|
|
58
|
-
* import type { FC } from "react"
|
|
59
|
-
* export { x } from "react"
|
|
60
|
-
* import "react/jsx-dev-runtime"
|
|
61
|
-
*
|
|
62
|
-
* Does NOT touch dynamic `import("react")` or `require("react")`.
|
|
63
|
-
*
|
|
64
|
-
* @internal exported for testing
|
|
65
|
-
*/
|
|
66
|
-
export declare function rewriteSingletonImports(source: string): string;
|
|
67
|
-
/**
|
|
68
|
-
* `Bun.Transpiler.transformSync` converts JSX syntax to function calls using
|
|
69
|
-
* mangled helper names (e.g. `jsxDEV_7x81h0kn`, `Fragment_8vg9x3sq`) but does
|
|
70
|
-
* NOT emit the corresponding import statement — it expects Bun's full bundler
|
|
71
|
-
* pipeline to inject it later.
|
|
72
|
-
*
|
|
73
|
-
* When we return pre-transpiled JS from `onLoad`, that pipeline step never
|
|
74
|
-
* runs, leaving the helpers as undefined free variables. This function scans
|
|
75
|
-
* the transpiled source, detects which mangled helper names are used, and
|
|
76
|
-
* prepends the correct import statements using absolute on-disk paths from
|
|
77
|
-
* `SINGLETON_PATHS`.
|
|
78
|
-
*
|
|
79
|
-
* Helper → package mapping:
|
|
80
|
-
* jsxDEV_* → `{ jsxDEV as … }` from react/jsx-dev-runtime
|
|
81
|
-
* Fragment_* → `{ Fragment as … }` from react/jsx-dev-runtime
|
|
82
|
-
* jsx_* → `{ jsx as … }` from react/jsx-runtime (prod only)
|
|
83
|
-
* jsxs_* → `{ jsxs as … }` from react/jsx-runtime (prod only)
|
|
84
|
-
*
|
|
85
|
-
* @internal exported for testing
|
|
86
|
-
*/
|
|
87
|
-
export declare function injectJsxHelperImports(transpiled: string): string;
|
|
88
|
-
/** @internal exported for testing */
|
|
89
|
-
export declare function rewriteRelativeImports(source: string, dir: string): string;
|
|
90
|
-
/**
|
|
91
|
-
* Rewrites all remaining bare specifiers in the transpiled JS to absolute
|
|
92
|
-
* on-disk paths resolved from `dir` (the page file's directory).
|
|
93
|
-
*
|
|
94
|
-
* Uses `Bun.Transpiler.scan()` on the original source to get the authoritative
|
|
95
|
-
* list of *actual* import specifiers (parsing correctly handles template
|
|
96
|
-
* literals, comments, etc.). For each bare specifier that is not already
|
|
97
|
-
* handled by `rewriteSingletonImports`, it calls `Bun.resolveSync` and
|
|
98
|
-
* replaces **every** import/re-export occurrence of the quoted specifier using
|
|
99
|
-
* a context-aware regex with the `g` flag — mirroring the approach used by
|
|
100
|
-
* `rewriteSingletonImports`. This correctly handles modules that both import
|
|
101
|
-
* and re-export from the same package without leaving any bare specifier
|
|
102
|
-
* behind. String literals that happen to contain the same text (inside
|
|
103
|
-
* template literals, JSX props, etc.) are not touched because the regex
|
|
104
|
-
* requires a preceding `from` or `import` keyword.
|
|
105
|
-
*
|
|
106
|
-
* @internal exported for testing
|
|
107
|
-
*/
|
|
108
|
-
export declare function rewriteBareImports(source: string, transpiled: string, dir: string): string;
|
|
109
|
-
export declare function registerDevPagePlugin(): void;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { SsgCacheEntry } from "./cache/index.ts";
|
|
2
|
-
export interface EmbeddedAppData {
|
|
3
|
-
assets: Record<string, string>;
|
|
4
|
-
template: string;
|
|
5
|
-
}
|
|
6
|
-
export interface CompileContextRoute {
|
|
7
|
-
mode: "ssr" | "ssg" | "isr";
|
|
8
|
-
path: string;
|
|
9
|
-
pattern: string;
|
|
10
|
-
}
|
|
11
|
-
export interface CompileContext {
|
|
12
|
-
buildId?: string;
|
|
13
|
-
embedded?: EmbeddedAppData;
|
|
14
|
-
modules: Record<string, unknown>;
|
|
15
|
-
/** Root-level conventions discovered at compile time. */
|
|
16
|
-
rootConventions?: {
|
|
17
|
-
errorPath?: string;
|
|
18
|
-
notFoundPath?: string;
|
|
19
|
-
};
|
|
20
|
-
rootPath: string;
|
|
21
|
-
/** Per-route metadata including pre-computed segment boundaries. */
|
|
22
|
-
routeMetadata?: Record<string, {
|
|
23
|
-
segmentBoundaries: Array<{
|
|
24
|
-
depth: number;
|
|
25
|
-
path: string;
|
|
26
|
-
errorPath?: string;
|
|
27
|
-
notFoundPath?: string;
|
|
28
|
-
}>;
|
|
29
|
-
}>;
|
|
30
|
-
routes: CompileContextRoute[];
|
|
31
|
-
ssgCache?: Record<string, SsgCacheEntry>;
|
|
32
|
-
}
|
|
33
|
-
export declare function __setCompileContext(ctx: CompileContext): void;
|
|
34
|
-
export declare function getCompileContext(): CompileContext | null;
|
|
35
|
-
export declare function __resetCompileContext(): void;
|
package/dist/server/internal.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// src/server/internal.ts
|
|
3
|
-
var _compileCtx = null;
|
|
4
|
-
function __setCompileContext(ctx) {
|
|
5
|
-
_compileCtx = ctx;
|
|
6
|
-
}
|
|
7
|
-
function getCompileContext() {
|
|
8
|
-
return _compileCtx;
|
|
9
|
-
}
|
|
10
|
-
function __resetCompileContext() {
|
|
11
|
-
_compileCtx = null;
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
getCompileContext,
|
|
15
|
-
__setCompileContext,
|
|
16
|
-
__resetCompileContext
|
|
17
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { toCrossJSON } from "seroval";
|
|
2
|
-
import type { buildHeadInjection } from "./shell";
|
|
3
|
-
/**
|
|
4
|
-
* Single source of truth for the global registry name used by the SSR
|
|
5
|
-
* streaming script, the client hydration entry, and any test helper. Keeping
|
|
6
|
-
* it centralised here avoids `<script>`/JS source drift if the name is ever
|
|
7
|
-
* renamed.
|
|
8
|
-
*/
|
|
9
|
-
export declare const FURIN_DEFERRED_GLOBAL = "__FURIN_DEFERRED__";
|
|
10
|
-
/**
|
|
11
|
-
* Generates the `window.__FURIN_DEFERRED__` registry script that is injected
|
|
12
|
-
* BEFORE the React stream starts. It sets up the resolve/reject/getPromise API
|
|
13
|
-
* for late chunks.
|
|
14
|
-
*
|
|
15
|
-
* Client-side `<Await>` components call `getPromise(key)` to obtain a Promise
|
|
16
|
-
* they can pass to React 19's `use()`. The late resolution scripts call
|
|
17
|
-
* `resolve(key, chunk)` / `reject(key, chunk)` to settle those Promises.
|
|
18
|
-
*
|
|
19
|
-
* Synchronous loader data is NOT carried here — it lives exclusively in the
|
|
20
|
-
* `__FURIN_DATA__` JSON script that the hydrate entry reads.
|
|
21
|
-
*
|
|
22
|
-
* CSP note: this is an inline `<script>` — nonce support is a v2 concern.
|
|
23
|
-
*/
|
|
24
|
-
export declare function buildDeferredScript(deferredKeys: string[]): string;
|
|
25
|
-
/**
|
|
26
|
-
* Generates a late `<script>` that settles one deferred Promise on the client.
|
|
27
|
-
* The `chunk` must be a seroval CrossJSON value produced by `toCrossJSON(value)`.
|
|
28
|
-
*
|
|
29
|
-
* @param key - The Promise key (matches what `getPromise(key)` was called with)
|
|
30
|
-
* @param chunk - The already-serialised CrossJSON value
|
|
31
|
-
* @param action - "resolve" or "reject"
|
|
32
|
-
*/
|
|
33
|
-
export declare function buildDeferredResolution(key: string, chunk: ReturnType<typeof toCrossJSON>, action: "resolve" | "reject"): string;
|
|
34
|
-
/** Minimal context passed to background / synthetic render helpers — only `request` is needed. */
|
|
35
|
-
export interface LoaderContext {
|
|
36
|
-
request: Request;
|
|
37
|
-
}
|
|
38
|
-
export declare function resolvePath(pattern: string, params: Record<string, string>): string;
|
|
39
|
-
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
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import type { RuntimeRoute } from "../../client.ts";
|
|
3
|
-
import type { ErrorComponent } from "../../shared/error.ts";
|
|
4
|
-
import type { FurinNotFoundError, NotFoundComponent } from "../../shared/not-found.ts";
|
|
5
|
-
import type { ResolvedRoute } from "../router/index.ts";
|
|
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
|
-
/**
|
|
9
|
-
* Builds the error element rendered when a loader (or the SSR shell) fails.
|
|
10
|
-
*
|
|
11
|
-
* @param component - User-declared `error.tsx` component, or `undefined` to
|
|
12
|
-
* fall back to the built-in `DefaultErrorScreen` with a generic message.
|
|
13
|
-
* @param error - The original thrown value. Kept for `errorMessageOf` lookup
|
|
14
|
-
* when no explicit `messageOverride` is provided (e.g. shell-render errors).
|
|
15
|
-
* @param digest - 10-hex-char digest correlating with server logs.
|
|
16
|
-
* @param messageOverride - Pre-extracted public message. Set by the loader
|
|
17
|
-
* pipeline when the thrown value is a `Response` (whose body has already
|
|
18
|
-
* been consumed in `runLoaders`); pass `undefined` to derive the message
|
|
19
|
-
* from `error` via `errorMessageOf`.
|
|
20
|
-
* @param status - HTTP status to surface in `ErrorProps.error.status`. The
|
|
21
|
-
* loader pipeline passes the thrown `Response.status` (default 500); the
|
|
22
|
-
* shell-error recovery path always passes 500.
|
|
23
|
-
*/
|
|
24
|
-
export declare function buildErrorElement(component: ErrorComponent | undefined, error: unknown, digest: string, messageOverride: string | undefined, status: number): ReactNode;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { type LoaderContext, streamToString } from "./assemble.ts";
|
|
2
|
-
export { buildElement, buildErrorElement } from "./element.tsx";
|
|
3
|
-
export { handleISR } from "./isr.ts";
|
|
4
|
-
export { type LoaderResult, runLoaders, serializeDeferredRejection } from "./loaders.ts";
|
|
5
|
-
export { renderRootNotFound } from "./not-found.ts";
|
|
6
|
-
export { prerenderSSG, warmSSGCache } from "./ssg.ts";
|
|
7
|
-
export { assertDeferredModeAllowed, type PreparedRender, prepareRender, type RenderResult, renderForPath, renderSSR, renderToHTML, renderToStream, serializeLoaderDataNdjson, splitBeforeBodyClose, withSSRRouterContext, } from "./ssr.ts";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// biome-ignore-all lint/performance/noBarrelFile: intentional barrel for public API
|
|
2
|
-
|
|
3
|
-
export { type LoaderContext, streamToString } from "./assemble.ts";
|
|
4
|
-
export { buildElement, buildErrorElement } from "./element.tsx";
|
|
5
|
-
export { handleISR } from "./isr.ts";
|
|
6
|
-
export { type LoaderResult, runLoaders, serializeDeferredRejection } from "./loaders.ts";
|
|
7
|
-
export { renderRootNotFound } from "./not-found.ts";
|
|
8
|
-
|
|
9
|
-
export { prerenderSSG, warmSSGCache } from "./ssg.ts";
|
|
10
|
-
export {
|
|
11
|
-
assertDeferredModeAllowed,
|
|
12
|
-
type PreparedRender,
|
|
13
|
-
prepareRender,
|
|
14
|
-
type RenderResult,
|
|
15
|
-
renderForPath,
|
|
16
|
-
renderSSR,
|
|
17
|
-
renderToHTML,
|
|
18
|
-
renderToStream,
|
|
19
|
-
serializeLoaderDataNdjson,
|
|
20
|
-
splitBeforeBodyClose,
|
|
21
|
-
withSSRRouterContext,
|
|
22
|
-
} from "./ssr.ts";
|