@teyik0/furin 0.1.0-alpha.9 → 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/LICENSE +21 -0
- package/README.md +33 -0
- package/package.json +61 -25
- package/src/adapter/bun.ts +90 -41
- package/src/adapter/static.ts +100 -40
- package/src/build/client.ts +13 -14
- package/src/build/compile-entry.ts +20 -14
- package/src/build/entry-template.ts +90 -8
- package/src/build/hydrate.ts +219 -36
- package/src/build/index.ts +10 -9
- package/src/build/route-types.ts +65 -9
- package/src/build/scan-server.ts +52 -67
- package/src/build/server-routes-entry.ts +7 -11
- package/src/build/shared.ts +2 -1
- package/src/build/ssg-cache.ts +32 -0
- package/src/build/types.ts +5 -1
- package/src/cli/index.ts +1 -0
- package/src/client/boundaries.tsx +259 -0
- package/src/client/default-screens.tsx +304 -0
- package/src/client/link.tsx +347 -0
- package/src/client/router/boundary-tree.tsx +116 -0
- package/src/client/router/context.ts +40 -0
- package/src/client/router/history.ts +41 -0
- package/src/client/router/index.ts +56 -0
- package/src/client/router/link-utils.ts +177 -0
- package/src/client/router/navigation.ts +61 -0
- package/src/client/router/provider.tsx +759 -0
- package/src/client/router/search/index.ts +99 -0
- package/src/client/router/search-store.ts +86 -0
- package/src/client/router/spa-response.ts +143 -0
- package/src/client/router/types.ts +271 -0
- package/src/client/server-error.ts +47 -0
- package/src/client.ts +80 -3
- package/src/config.ts +11 -3
- package/src/env.d.ts +1 -0
- package/src/furin.ts +114 -29
- package/src/plugin/index.ts +7 -8
- package/src/plugin/transform-client.ts +146 -120
- package/src/server/auto-invalidate/index.ts +10 -0
- package/src/server/auto-invalidate/plugin.ts +25 -0
- package/src/server/auto-invalidate/registry.ts +60 -0
- package/src/server/auto-invalidate/runtime.ts +133 -0
- package/src/server/auto-invalidate/types.ts +16 -0
- package/src/server/cache/dev-loader.ts +211 -0
- package/src/server/cache/index.ts +34 -0
- package/src/server/cache/invalidation.ts +111 -0
- package/src/server/cache/isr-ssg.ts +41 -0
- package/src/server/cache/isr.ts +17 -0
- package/src/server/cache/registry.ts +35 -0
- package/src/server/cache/route-cache.ts +124 -0
- package/src/server/cache/ssg.ts +15 -0
- package/src/{context-logger.ts → server/context-logger.ts} +5 -0
- package/src/server/dev-inspector.ts +60 -0
- package/src/{dev-page-plugin.ts → server/dev-page-plugin.ts} +15 -0
- package/src/{internal.ts → server/internal.ts} +17 -0
- package/src/server/lang-detect.ts +46 -0
- package/src/server/render/assemble.ts +133 -0
- package/src/server/render/element.tsx +113 -0
- package/src/server/render/index.ts +22 -0
- package/src/server/render/isr.ts +317 -0
- package/src/server/render/loaders.ts +328 -0
- package/src/server/render/not-found.ts +98 -0
- package/src/{render → server/render}/shell.ts +28 -13
- package/src/server/render/ssg.ts +148 -0
- package/src/server/render/ssr.ts +583 -0
- package/src/server/router/discovery.ts +474 -0
- package/src/server/router/hmr.ts +376 -0
- package/src/server/router/index.ts +28 -0
- package/src/server/router/patterns.ts +219 -0
- package/src/server/router/plugin.ts +384 -0
- package/src/server/router/schemas.ts +278 -0
- package/src/server/router/types.ts +59 -0
- package/src/shared/await.tsx +192 -0
- package/src/shared/deferred-ndjson.ts +244 -0
- package/src/shared/digest.ts +71 -0
- package/src/shared/error.ts +49 -0
- package/src/shared/not-found.ts +40 -0
- package/src/shared/search-params.ts +182 -0
- package/src/shared/utils/ast-walk.ts +51 -0
- package/src/{utils.ts → shared/utils/index.ts} +32 -1
- 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 -23
- package/dist/build/entry-template.d.ts +0 -14
- package/dist/build/hydrate.d.ts +0 -24
- package/dist/build/index.d.ts +0 -7
- package/dist/build/index.js +0 -3727
- 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 -23
- package/dist/build/shared.d.ts +0 -11
- package/dist/build/types.d.ts +0 -76
- package/dist/cli/config.d.ts +0 -9
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -3762
- package/dist/client.d.ts +0 -195
- package/dist/client.js +0 -20
- package/dist/config.d.ts +0 -47
- package/dist/config.js +0 -28
- package/dist/context-logger.d.ts +0 -26
- package/dist/dev-page-plugin.d.ts +0 -109
- package/dist/furin.d.ts +0 -34
- package/dist/furin.js +0 -2744
- package/dist/internal.d.ts +0 -19
- package/dist/link.d.ts +0 -245
- package/dist/link.js +0 -1232
- package/dist/plugin/index.d.ts +0 -20
- package/dist/plugin/index.js +0 -1408
- package/dist/plugin/transform-client.d.ts +0 -9
- package/dist/render/assemble.d.ts +0 -15
- package/dist/render/cache.d.ts +0 -95
- package/dist/render/element.d.ts +0 -4
- package/dist/render/index.d.ts +0 -27
- package/dist/render/loaders.d.ts +0 -12
- package/dist/render/shell.d.ts +0 -29
- package/dist/render/template.d.ts +0 -6
- package/dist/router.d.ts +0 -45
- package/dist/router.js +0 -1671
- package/dist/runtime-env.d.ts +0 -3
- package/dist/utils.d.ts +0 -6
- package/src/link.tsx +0 -1120
- package/src/render/assemble.ts +0 -66
- package/src/render/cache.ts +0 -241
- package/src/render/element.tsx +0 -28
- package/src/render/index.ts +0 -483
- package/src/render/loaders.ts +0 -117
- package/src/router.ts +0 -439
- /package/src/{render → server/render}/template.ts +0 -0
- /package/src/{runtime-env.ts → server/runtime-env.ts} +0 -0
package/dist/client.d.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import type { Cookie, StatusMap } from "elysia";
|
|
2
|
-
import type { AnySchema, HTTPHeaders, UnwrapSchema } from "elysia/types";
|
|
3
|
-
import type { RequestLogger } from "evlog";
|
|
4
|
-
declare const UNSET: unique symbol;
|
|
5
|
-
type Unset = typeof UNSET;
|
|
6
|
-
type ToRecord<T> = {
|
|
7
|
-
[K in keyof T]: T[K];
|
|
8
|
-
};
|
|
9
|
-
type ResolvedSchema<T> = [T] extends [Unset] ? Unset : T extends AnySchema ? UnwrapSchema<T> : Unset;
|
|
10
|
-
type MergeSchema<TParent, TOwn> = [TParent] extends [Unset] ? TOwn : [TOwn] extends [Unset] ? TParent : TParent & TOwn;
|
|
11
|
-
type NormalizeUnset<T> = [T] extends [Unset] ? {} : T;
|
|
12
|
-
/**
|
|
13
|
-
* Transforms each key of a parent-data record into an individual `Promise<T>`.
|
|
14
|
-
* This is what child loaders see for inherited fields — direct values from
|
|
15
|
-
* `RouteContext` (request, params, set, …) remain unchanged.
|
|
16
|
-
*/
|
|
17
|
-
type PromisifyData<T extends Record<string, unknown>> = {
|
|
18
|
-
[K in keyof T]: Promise<T[K]>;
|
|
19
|
-
};
|
|
20
|
-
export interface RouteContext<TParams = {}, TQuery = {}> {
|
|
21
|
-
cookie: Record<string, Cookie<unknown>>;
|
|
22
|
-
headers: Record<string, string | undefined>;
|
|
23
|
-
/** Request-scoped logger. Call `log.set({})` to attach fields to the wide event for this render. */
|
|
24
|
-
log: RequestLogger;
|
|
25
|
-
params: NormalizeUnset<TParams>;
|
|
26
|
-
path: string;
|
|
27
|
-
query: NormalizeUnset<TQuery>;
|
|
28
|
-
redirect: (url: string, status?: 301 | 302 | 303 | 307 | 308) => Response;
|
|
29
|
-
request: Request;
|
|
30
|
-
set: {
|
|
31
|
-
headers: HTTPHeaders;
|
|
32
|
-
status?: number | keyof StatusMap;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export interface ComponentProps<TParams = {}, TQuery = {}> {
|
|
36
|
-
params: NormalizeUnset<TParams>;
|
|
37
|
-
path: string;
|
|
38
|
-
query: NormalizeUnset<TQuery>;
|
|
39
|
-
}
|
|
40
|
-
type ResolveParent<T> = T extends RouteRef<infer D, infer P, infer Q> ? {
|
|
41
|
-
data: D;
|
|
42
|
-
params: P;
|
|
43
|
-
query: Q;
|
|
44
|
-
} : {
|
|
45
|
-
data: {};
|
|
46
|
-
params: Unset;
|
|
47
|
-
query: Unset;
|
|
48
|
-
};
|
|
49
|
-
interface Resolved<TParentRef, TLoaderData, TParamsSchema = Unset, TQuerySchema = Unset> {
|
|
50
|
-
data: ToRecord<ResolveParent<TParentRef>["data"] & TLoaderData>;
|
|
51
|
-
params: MergeSchema<ResolveParent<TParentRef>["params"], ResolvedSchema<TParamsSchema>>;
|
|
52
|
-
query: MergeSchema<ResolveParent<TParentRef>["query"], ResolvedSchema<TQuerySchema>>;
|
|
53
|
-
}
|
|
54
|
-
export type MetaDescriptor = {
|
|
55
|
-
charSet: "utf-8";
|
|
56
|
-
} | {
|
|
57
|
-
title: string;
|
|
58
|
-
} | {
|
|
59
|
-
name: string;
|
|
60
|
-
content: string;
|
|
61
|
-
} | {
|
|
62
|
-
property: string;
|
|
63
|
-
content: string;
|
|
64
|
-
} | {
|
|
65
|
-
httpEquiv: string;
|
|
66
|
-
content: string;
|
|
67
|
-
} | {
|
|
68
|
-
"script:ld+json": object;
|
|
69
|
-
} | {
|
|
70
|
-
tagName: "meta" | "link";
|
|
71
|
-
[name: string]: string | undefined;
|
|
72
|
-
};
|
|
73
|
-
export interface HeadOptions {
|
|
74
|
-
links?: Array<{
|
|
75
|
-
rel: string;
|
|
76
|
-
href: string;
|
|
77
|
-
[key: string]: string;
|
|
78
|
-
}>;
|
|
79
|
-
meta?: MetaDescriptor[];
|
|
80
|
-
/**
|
|
81
|
-
* Inline scripts injected into `<head>`.
|
|
82
|
-
*
|
|
83
|
-
* **Security warning:** `children` is injected as raw HTML — never pass
|
|
84
|
-
* user-controlled or loader-derived data here without sanitisation.
|
|
85
|
-
*/
|
|
86
|
-
scripts?: Array<{
|
|
87
|
-
src?: string;
|
|
88
|
-
type?: string;
|
|
89
|
-
children?: string;
|
|
90
|
-
[key: string]: string | undefined;
|
|
91
|
-
}>;
|
|
92
|
-
/**
|
|
93
|
-
* Inline styles injected into `<head>`.
|
|
94
|
-
*
|
|
95
|
-
* **Security warning:** `children` is injected as raw HTML — never pass
|
|
96
|
-
* user-controlled or loader-derived data here without sanitisation.
|
|
97
|
-
*/
|
|
98
|
-
styles?: Array<{
|
|
99
|
-
type?: string;
|
|
100
|
-
children: string;
|
|
101
|
-
}>;
|
|
102
|
-
}
|
|
103
|
-
type ExtractLoaderReturn<TLoader> = TLoader extends (...args: never[]) => unknown ? Awaited<ReturnType<TLoader>> extends object ? ToRecord<Awaited<ReturnType<TLoader>>> : {} : {};
|
|
104
|
-
export interface PageConfig<TParentData extends Record<string, unknown>, TParams, TQuery, TPageLoaderData extends object = {}> {
|
|
105
|
-
component: React.FC<TParentData & TPageLoaderData & ComponentProps<TParams, TQuery>>;
|
|
106
|
-
head?: (ctx: ComponentProps<TParams, TQuery> & TParentData & TPageLoaderData) => HeadOptions;
|
|
107
|
-
loader?: (ctx: RouteContext<TParams, TQuery> & PromisifyData<TParentData>) => Promise<TPageLoaderData> | TPageLoaderData;
|
|
108
|
-
staticParams?: () => Promise<NormalizeUnset<TParams>[]> | NormalizeUnset<TParams>[];
|
|
109
|
-
}
|
|
110
|
-
export interface RuntimeRoute {
|
|
111
|
-
__type: "FURIN_ROUTE";
|
|
112
|
-
layout?: React.FC<Record<string, unknown> & {
|
|
113
|
-
children: React.ReactNode;
|
|
114
|
-
}>;
|
|
115
|
-
loader?(ctx: Record<string, unknown>): Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
116
|
-
mode?: "ssr" | "ssg" | "isr";
|
|
117
|
-
params?: unknown;
|
|
118
|
-
parent?: RuntimeRoute;
|
|
119
|
-
query?: unknown;
|
|
120
|
-
revalidate?: number;
|
|
121
|
-
}
|
|
122
|
-
export interface RuntimePage {
|
|
123
|
-
__type: "FURIN_PAGE";
|
|
124
|
-
_route: RuntimeRoute;
|
|
125
|
-
component: React.FC<Record<string, unknown>>;
|
|
126
|
-
head?(ctx: Record<string, unknown>): HeadOptions;
|
|
127
|
-
loader?(ctx: Record<string, unknown>): Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
128
|
-
staticParams?(): Promise<Record<string, string>[]> | Record<string, string>[];
|
|
129
|
-
}
|
|
130
|
-
export interface RouteRef<TData extends Record<string, unknown> = Record<string, unknown>, TParams = unknown, TQuery = unknown> {
|
|
131
|
-
readonly __brand: "FURIN_ROUTE_REF";
|
|
132
|
-
readonly __phantom: {
|
|
133
|
-
data: TData;
|
|
134
|
-
params: TParams;
|
|
135
|
-
query: TQuery;
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
interface PageResult<TData extends Record<string, unknown>, TParams, TQuery, TPageLoaderData extends object> {
|
|
139
|
-
__type: "FURIN_PAGE";
|
|
140
|
-
_route: Route<TData, TParams, TQuery>;
|
|
141
|
-
component: React.FC<TData & TPageLoaderData & ComponentProps<TParams, TQuery>>;
|
|
142
|
-
head?: (ctx: ComponentProps<TParams, TQuery> & TData & TPageLoaderData) => HeadOptions;
|
|
143
|
-
loader?: (ctx: RouteContext<TParams, TQuery> & PromisifyData<TData>) => Promise<TPageLoaderData> | TPageLoaderData;
|
|
144
|
-
}
|
|
145
|
-
export interface Route<TParentData extends Record<string, unknown>, TParams, TQuery> {
|
|
146
|
-
__type: "FURIN_ROUTE";
|
|
147
|
-
layout?: React.FC<TParentData & {
|
|
148
|
-
children: React.ReactNode;
|
|
149
|
-
} & ComponentProps<TParams, TQuery>>;
|
|
150
|
-
loader?(ctx: RouteContext<TParams, TQuery> & PromisifyData<TParentData>): Promise<TParentData> | TParentData;
|
|
151
|
-
mode?: "ssr" | "ssg" | "isr";
|
|
152
|
-
page<TLoader extends (ctx: RouteContext<TParams, TQuery> & PromisifyData<TParentData>) => unknown, TPageLoaderData extends object = ExtractLoaderReturn<TLoader>>(config: {
|
|
153
|
-
loader: TLoader;
|
|
154
|
-
mode?: "ssr" | "ssg" | "isr";
|
|
155
|
-
revalidate?: number;
|
|
156
|
-
staticParams?: () => Promise<NormalizeUnset<TParams>[]> | NormalizeUnset<TParams>[];
|
|
157
|
-
component: React.FC<NoInfer<TParentData & TPageLoaderData & ComponentProps<TParams, TQuery>>>;
|
|
158
|
-
head?: (ctx: NoInfer<ComponentProps<TParams, TQuery> & TParentData & TPageLoaderData>) => HeadOptions;
|
|
159
|
-
}): PageResult<TParentData, TParams, TQuery, TPageLoaderData>;
|
|
160
|
-
page(config: {
|
|
161
|
-
mode?: "ssr" | "ssg" | "isr";
|
|
162
|
-
revalidate?: number;
|
|
163
|
-
staticParams?: () => Promise<NormalizeUnset<TParams>[]> | NormalizeUnset<TParams>[];
|
|
164
|
-
component: React.FC<TParentData & ComponentProps<TParams, TQuery>>;
|
|
165
|
-
head?: (ctx: ComponentProps<TParams, TQuery> & TParentData) => HeadOptions;
|
|
166
|
-
}): PageResult<TParentData, TParams, TQuery, {}>;
|
|
167
|
-
params?: unknown;
|
|
168
|
-
parent?: RuntimeRoute;
|
|
169
|
-
query?: unknown;
|
|
170
|
-
/** Branded ref for type inference when used as a parent. */
|
|
171
|
-
ref: RouteRef<TParentData, TParams, TQuery>;
|
|
172
|
-
revalidate?: number;
|
|
173
|
-
}
|
|
174
|
-
export declare function createRoute<TParentRef extends RouteRef | undefined = undefined, TParamsSchema extends AnySchema | Unset = Unset, TQuerySchema extends AnySchema | Unset = Unset, TLoaderData extends object = {}>(config?: {
|
|
175
|
-
parent?: {
|
|
176
|
-
ref: TParentRef;
|
|
177
|
-
} & {
|
|
178
|
-
__type: "FURIN_ROUTE";
|
|
179
|
-
};
|
|
180
|
-
mode?: "ssr" | "ssg" | "isr";
|
|
181
|
-
revalidate?: number;
|
|
182
|
-
params?: TParamsSchema;
|
|
183
|
-
query?: TQuerySchema;
|
|
184
|
-
loader?: (ctx: RouteContext<Resolved<TParentRef, TLoaderData, TParamsSchema, TQuerySchema>["params"], Resolved<TParentRef, TLoaderData, TParamsSchema, TQuerySchema>["query"]> & PromisifyData<ResolveParent<TParentRef>["data"]>) => Promise<TLoaderData> | TLoaderData;
|
|
185
|
-
layout?: React.FC<Resolved<TParentRef, TLoaderData, TParamsSchema, TQuerySchema>["data"] & {
|
|
186
|
-
children: React.ReactNode;
|
|
187
|
-
} & ComponentProps<Resolved<TParentRef, TLoaderData, TParamsSchema, TQuerySchema>["params"], Resolved<TParentRef, TLoaderData, TParamsSchema, TQuerySchema>["query"]>>;
|
|
188
|
-
}): Route<Resolved<TParentRef, TLoaderData, TParamsSchema, TQuerySchema>["data"], Resolved<TParentRef, TLoaderData, TParamsSchema, TQuerySchema>["params"], Resolved<TParentRef, TLoaderData, TParamsSchema, TQuerySchema>["query"]>;
|
|
189
|
-
export type InferProps<T> = T extends {
|
|
190
|
-
__type: "FURIN_PAGE";
|
|
191
|
-
component: React.FC<infer P>;
|
|
192
|
-
} ? P : T extends Route<infer D, infer P, infer Q> ? D & {
|
|
193
|
-
children: React.ReactNode;
|
|
194
|
-
} & ComponentProps<P, Q> : never;
|
|
195
|
-
export {};
|
package/dist/client.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// src/client.ts
|
|
3
|
-
function createRoute(config) {
|
|
4
|
-
const route = {
|
|
5
|
-
...config,
|
|
6
|
-
__type: "FURIN_ROUTE",
|
|
7
|
-
ref: {},
|
|
8
|
-
page(pageConfig) {
|
|
9
|
-
return {
|
|
10
|
-
...pageConfig,
|
|
11
|
-
__type: "FURIN_PAGE",
|
|
12
|
-
_route: route
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
return route;
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
createRoute
|
|
20
|
-
};
|
package/dist/config.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export type { BunPlugin } from "bun";
|
|
2
|
-
export declare const BUILD_TARGETS: readonly ["bun", "node", "vercel", "cloudflare", "static"];
|
|
3
|
-
export type BuildTarget = (typeof BUILD_TARGETS)[number];
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for the `static` build target.
|
|
6
|
-
* Produces a fully pre-rendered directory deployable to any static host
|
|
7
|
-
* (GitHub Pages, Netlify, Surge.sh, …).
|
|
8
|
-
*/
|
|
9
|
-
export interface StaticExportConfig {
|
|
10
|
-
/**
|
|
11
|
-
* Sub-path prefix for GitHub Pages sub-path deployments.
|
|
12
|
-
* e.g. "/furin" when the site is served at `https://user.github.io/furin/`.
|
|
13
|
-
* Must start with "/" and have no trailing slash.
|
|
14
|
-
* Default: "" (site served at root).
|
|
15
|
-
*/
|
|
16
|
-
basePath?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Behaviour when SSR or ISR routes are encountered during a static build.
|
|
19
|
-
* - "error" (default): throw at build time with the list of incompatible routes.
|
|
20
|
-
* - "skip": emit a warning and omit those routes from the output.
|
|
21
|
-
*/
|
|
22
|
-
onSSR?: "error" | "skip";
|
|
23
|
-
/**
|
|
24
|
-
* Output directory for the static export.
|
|
25
|
-
* Default: "dist".
|
|
26
|
-
*/
|
|
27
|
-
outDir?: string;
|
|
28
|
-
}
|
|
29
|
-
export declare const configSchema: import("@sinclair/typebox").TObject<{
|
|
30
|
-
rootDir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
31
|
-
pagesDir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
32
|
-
serverEntry: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
33
|
-
targets: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"bun" | "node" | "vercel" | "cloudflare" | "static">[]>>>;
|
|
34
|
-
bun: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
35
|
-
compile: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"server">, import("@sinclair/typebox").TLiteral<"embed">]>>;
|
|
36
|
-
}>>;
|
|
37
|
-
static: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
38
|
-
basePath: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
39
|
-
outDir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
40
|
-
onSSR: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"error">, import("@sinclair/typebox").TLiteral<"skip">]>>;
|
|
41
|
-
}>>;
|
|
42
|
-
}>;
|
|
43
|
-
export type FurinConfig = (typeof configSchema)["static"] & {
|
|
44
|
-
plugins?: Bun.BunPlugin[];
|
|
45
|
-
static?: StaticExportConfig;
|
|
46
|
-
};
|
|
47
|
-
export declare function defineConfig(config: FurinConfig): FurinConfig;
|
package/dist/config.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// src/config.ts
|
|
3
|
-
import { t } from "elysia";
|
|
4
|
-
var BUILD_TARGETS = ["bun", "node", "vercel", "cloudflare", "static"];
|
|
5
|
-
var buildTargetSchema = t.Union(BUILD_TARGETS.map((v) => t.Literal(v)));
|
|
6
|
-
var compileTargetSchema = t.Union([t.Literal("server"), t.Literal("embed")]);
|
|
7
|
-
var configSchema = t.Object({
|
|
8
|
-
rootDir: t.Optional(t.String()),
|
|
9
|
-
pagesDir: t.Optional(t.String()),
|
|
10
|
-
serverEntry: t.Optional(t.String()),
|
|
11
|
-
targets: t.Optional(t.Array(buildTargetSchema)),
|
|
12
|
-
bun: t.Optional(t.Object({
|
|
13
|
-
compile: t.Optional(compileTargetSchema)
|
|
14
|
-
})),
|
|
15
|
-
static: t.Optional(t.Object({
|
|
16
|
-
basePath: t.Optional(t.String()),
|
|
17
|
-
outDir: t.Optional(t.String()),
|
|
18
|
-
onSSR: t.Optional(t.Union([t.Literal("error"), t.Literal("skip")]))
|
|
19
|
-
}))
|
|
20
|
-
});
|
|
21
|
-
function defineConfig(config) {
|
|
22
|
-
return config;
|
|
23
|
-
}
|
|
24
|
-
export {
|
|
25
|
-
defineConfig,
|
|
26
|
-
configSchema,
|
|
27
|
-
BUILD_TARGETS
|
|
28
|
-
};
|
package/dist/context-logger.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { RequestLogger } from "evlog";
|
|
2
|
-
/**
|
|
3
|
-
* Returns the current request-scoped logger.
|
|
4
|
-
*
|
|
5
|
-
* Priority:
|
|
6
|
-
* 1. Live Elysia request handled by the evlog() plugin → full request-scoped wide event
|
|
7
|
-
* 2. Synthetic render scope (ISR revalidation, SSG pre-render) → detached createLogger()
|
|
8
|
-
* that still drains to the configured adapter (Datadog, Axiom, etc.)
|
|
9
|
-
* 3. Completely outside any context → no-op
|
|
10
|
-
*
|
|
11
|
-
* Import from `@teyik0/furin` instead of `evlog/elysia` so this fallback chain
|
|
12
|
-
* applies in all rendering contexts.
|
|
13
|
-
*/
|
|
14
|
-
export declare function useLogger(): RequestLogger;
|
|
15
|
-
/**
|
|
16
|
-
* Runs `fn` inside a synthetic render scope.
|
|
17
|
-
*
|
|
18
|
-
* Creates a detached `createLogger()` instance for the duration of `fn`.
|
|
19
|
-
* `useLogger()` calls inside `fn` (including user loaders) return this logger
|
|
20
|
-
* instead of throwing. On completion, the accumulated wide event is emitted to
|
|
21
|
-
* the global drain with the provided initial context (e.g. route pattern).
|
|
22
|
-
*
|
|
23
|
-
* Used by renderForPath() which drives both ISR background revalidation and
|
|
24
|
-
* SSG pre-renders — neither has a live Elysia request context.
|
|
25
|
-
*/
|
|
26
|
-
export declare function runInSyntheticRenderScope<T>(fn: () => Promise<T> | T, initialContext: Record<string, unknown>): Promise<T>;
|
|
@@ -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;
|
package/dist/furin.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Elysia } from "elysia";
|
|
2
|
-
import { type EvlogElysiaOptions } from "evlog/elysia";
|
|
3
|
-
export declare function furin({ pagesDir, logger, }: {
|
|
4
|
-
pagesDir?: string;
|
|
5
|
-
logger?: EvlogElysiaOptions;
|
|
6
|
-
}): Promise<Elysia<"", {
|
|
7
|
-
decorator: {};
|
|
8
|
-
store: {};
|
|
9
|
-
derive: {};
|
|
10
|
-
resolve: {};
|
|
11
|
-
}, {
|
|
12
|
-
typebox: {};
|
|
13
|
-
error: {};
|
|
14
|
-
}, {
|
|
15
|
-
schema: {};
|
|
16
|
-
standaloneSchema: {};
|
|
17
|
-
macro: {};
|
|
18
|
-
macroFn: {};
|
|
19
|
-
parser: {};
|
|
20
|
-
response: {};
|
|
21
|
-
}, {}, {
|
|
22
|
-
derive: {};
|
|
23
|
-
resolve: {};
|
|
24
|
-
schema: {};
|
|
25
|
-
standaloneSchema: {};
|
|
26
|
-
response: {};
|
|
27
|
-
}, {
|
|
28
|
-
derive: {};
|
|
29
|
-
resolve: {};
|
|
30
|
-
schema: {};
|
|
31
|
-
standaloneSchema: {};
|
|
32
|
-
response: {};
|
|
33
|
-
}>>;
|
|
34
|
-
export { revalidatePath, setCachePurger } from "./render/cache.ts";
|