@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/internal.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface EmbeddedAppData {
|
|
2
|
-
assets: Record<string, string>;
|
|
3
|
-
template: string;
|
|
4
|
-
}
|
|
5
|
-
export interface CompileContextRoute {
|
|
6
|
-
mode: "ssr" | "ssg" | "isr";
|
|
7
|
-
path: string;
|
|
8
|
-
pattern: string;
|
|
9
|
-
}
|
|
10
|
-
export interface CompileContext {
|
|
11
|
-
buildId?: string;
|
|
12
|
-
embedded?: EmbeddedAppData;
|
|
13
|
-
modules: Record<string, unknown>;
|
|
14
|
-
rootPath: string;
|
|
15
|
-
routes: CompileContextRoute[];
|
|
16
|
-
}
|
|
17
|
-
export declare function __setCompileContext(ctx: CompileContext): void;
|
|
18
|
-
export declare function getCompileContext(): CompileContext | null;
|
|
19
|
-
export declare function __resetCompileContext(): void;
|
package/dist/link.d.ts
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import type React from "react";
|
|
2
|
-
import type { RuntimeRoute } from "./client";
|
|
3
|
-
/**
|
|
4
|
-
* Augment this interface via declaration merging in furin-env.d.ts
|
|
5
|
-
* to get type-safe `to` autocompletion and per-route `search` types on <Link>.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* // furin-env.d.ts (auto-generated by Furin at project root)
|
|
9
|
-
* import "@teyik0/furin/link";
|
|
10
|
-
* declare module "@teyik0/furin/link" {
|
|
11
|
-
* interface RouteManifest {
|
|
12
|
-
* "/blog": { search?: { page?: number; tag?: string } };
|
|
13
|
-
* "/": { search?: never };
|
|
14
|
-
* [key: `/blog/${string}`]: { search?: never };
|
|
15
|
-
* }
|
|
16
|
-
* }
|
|
17
|
-
*/
|
|
18
|
-
export interface RouteManifest {
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The valid `to` pathname union derived from the augmented RouteManifest.
|
|
22
|
-
* Falls back to `string` when furin-env.d.ts has not been generated yet.
|
|
23
|
-
* When augmented, also includes `https://` and `http://` for external links.
|
|
24
|
-
*/
|
|
25
|
-
export type RouteTo = keyof RouteManifest extends never ? string : keyof RouteManifest | `https://${string}` | `http://${string}`;
|
|
26
|
-
/**
|
|
27
|
-
* The typed search params for a given `to` pathname.
|
|
28
|
-
* Falls back to a permissive record when RouteManifest is not augmented.
|
|
29
|
-
*/
|
|
30
|
-
export type RouteSearch<To extends RouteTo> = keyof RouteManifest extends never ? Record<string, string | number | boolean | null | undefined> : To extends keyof RouteManifest ? RouteManifest[To] extends {
|
|
31
|
-
search?: infer S;
|
|
32
|
-
} ? S : undefined : undefined;
|
|
33
|
-
export type PreloadStrategy = false | "intent" | "viewport" | "render";
|
|
34
|
-
export interface LinkProps<To extends RouteTo = RouteTo> extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href" | "children"> {
|
|
35
|
-
/**
|
|
36
|
-
* Extra props merged onto the anchor when the link is active.
|
|
37
|
-
* `isActive` is also passed so one function can handle both states.
|
|
38
|
-
* Styles and classNames from `activeProps` win over the static props.
|
|
39
|
-
*/
|
|
40
|
-
activeProps?: (opts: {
|
|
41
|
-
isActive: boolean;
|
|
42
|
-
}) => React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
43
|
-
/** Static children or a render function receiving active state. */
|
|
44
|
-
children?: React.ReactNode | ((state: {
|
|
45
|
-
isActive: boolean;
|
|
46
|
-
}) => React.ReactNode);
|
|
47
|
-
/** Prevents navigation and prefetch; adds aria-disabled="true". The href stays intact for right-click. */
|
|
48
|
-
disabled?: boolean;
|
|
49
|
-
/** Optional URL fragment (without the #). */
|
|
50
|
-
hash?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Extra props merged onto the anchor when the link is NOT active.
|
|
53
|
-
* Styles and classNames from `inactiveProps` win over the static props.
|
|
54
|
-
*/
|
|
55
|
-
inactiveProps?: () => React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
56
|
-
/** Preload strategy. Default: "intent" (preload on hover/focus). */
|
|
57
|
-
preload?: PreloadStrategy;
|
|
58
|
-
/** Delay in ms before intent preload triggers. Default: 50. */
|
|
59
|
-
preloadDelay?: number;
|
|
60
|
-
/** How long a preloaded entry stays fresh (ms). Default: 30_000. */
|
|
61
|
-
preloadStaleTime?: number;
|
|
62
|
-
/** If true, uses history.replaceState instead of pushState (no new history entry). */
|
|
63
|
-
replace?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Whether to scroll after SPA navigation. Default: true.
|
|
66
|
-
* - If the destination href has a `#hash`, scrolls to that element.
|
|
67
|
-
* - Otherwise scrolls to the top of the page.
|
|
68
|
-
* Set to `false` to suppress all scroll behaviour (e.g. tab/drawer navigation).
|
|
69
|
-
*/
|
|
70
|
-
resetScroll?: boolean;
|
|
71
|
-
/** Typed search params for this route. Auto-completed from the route's query schema. */
|
|
72
|
-
search?: RouteSearch<To>;
|
|
73
|
-
to: To;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Builds a full href string from a pathname, optional search params, and optional hash.
|
|
77
|
-
* Null/undefined search values are omitted.
|
|
78
|
-
*
|
|
79
|
-
* @internal Exported for unit testing only.
|
|
80
|
-
*/
|
|
81
|
-
export declare function buildHref(to: string, search?: Record<string, unknown> | null, hash?: string): string;
|
|
82
|
-
/**
|
|
83
|
-
* Parses the `X-Furin-Revalidate` response header and calls `invalidate` for
|
|
84
|
-
* each path entry. Header format: `"/path1,/path2:layout,/path3"`
|
|
85
|
-
*
|
|
86
|
-
* Intended to be called from a `window.fetch` interceptor or SPA navigation
|
|
87
|
-
* handler so that client-side prefetch caches are busted automatically whenever
|
|
88
|
-
* a server-side `revalidatePath()` call is made within the same request.
|
|
89
|
-
*
|
|
90
|
-
* @example
|
|
91
|
-
* ```ts
|
|
92
|
-
* const res = await fetch("/api/publish");
|
|
93
|
-
* applyRevalidateHeader(res.headers, (path, type) => {
|
|
94
|
-
* console.log("invalidate", path, type);
|
|
95
|
-
* });
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export declare function applyRevalidateHeader(headers: Headers, invalidate: (path: string, type?: "page" | "layout") => void): void;
|
|
99
|
-
/**
|
|
100
|
-
* Returns `true` when `currentPath` is targeted by at least one invalidation entry,
|
|
101
|
-
* using the same matching rules as `invalidatePrefetch`:
|
|
102
|
-
* - `type: 'page'` — exact pathname match (query string stripped)
|
|
103
|
-
* - `type: 'layout'` — prefix match: the path itself OR any descendant
|
|
104
|
-
*
|
|
105
|
-
* @internal Exported for unit testing only.
|
|
106
|
-
*/
|
|
107
|
-
export declare function shouldAutoRefreshPath(currentPath: string, invalidations: ReadonlyArray<{
|
|
108
|
-
path: string;
|
|
109
|
-
type: "page" | "layout";
|
|
110
|
-
}>): boolean;
|
|
111
|
-
export interface RouterContextValue {
|
|
112
|
-
/**
|
|
113
|
-
* Sub-path prefix for static deployments (e.g. "/furin").
|
|
114
|
-
* Empty string when the site is served from root.
|
|
115
|
-
* Used by `Link` to build correct physical hrefs for the `<a>` element.
|
|
116
|
-
*/
|
|
117
|
-
basePath: string;
|
|
118
|
-
/** Current **logical** pathname + search (basePath stripped). Used by Link for active-state detection. */
|
|
119
|
-
currentHref: string;
|
|
120
|
-
defaultPreload: PreloadStrategy;
|
|
121
|
-
defaultPreloadDelay: number;
|
|
122
|
-
defaultPreloadStaleTime: number;
|
|
123
|
-
/**
|
|
124
|
-
* Evicts one or more prefetch cache entries, mirroring a `revalidatePath()` call
|
|
125
|
-
* made on the server. Called automatically by the `window.fetch` interceptor when
|
|
126
|
-
* the server emits `X-Furin-Revalidate` headers.
|
|
127
|
-
*
|
|
128
|
-
* - `type: 'page'` (default) — exact URL match
|
|
129
|
-
* - `type: 'layout'` — prefix match (path + all nested children)
|
|
130
|
-
*/
|
|
131
|
-
invalidatePrefetch: (path: string, type?: "page" | "layout") => void;
|
|
132
|
-
isNavigating: boolean;
|
|
133
|
-
navigate: (href: string, opts?: {
|
|
134
|
-
replace?: boolean;
|
|
135
|
-
resetScroll?: boolean;
|
|
136
|
-
}) => Promise<void>;
|
|
137
|
-
prefetch: (href: string, opts?: {
|
|
138
|
-
staleTime?: number;
|
|
139
|
-
}) => void;
|
|
140
|
-
/**
|
|
141
|
-
* Re-fetches the current page in-place: busts the prefetch cache entry, re-runs
|
|
142
|
-
* loaders, and updates the rendered tree — without adding a history entry or
|
|
143
|
-
* resetting scroll (unless `resetScroll: true` is passed).
|
|
144
|
-
*
|
|
145
|
-
* Prefer this over `navigate(window.location.pathname)` after a mutation.
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```tsx
|
|
149
|
-
* const { refresh } = useRouter();
|
|
150
|
-
* await apiClient.api.boards.post({ name });
|
|
151
|
-
* await refresh();
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
|
-
refresh: (opts?: {
|
|
155
|
-
resetScroll?: boolean;
|
|
156
|
-
}) => Promise<void>;
|
|
157
|
-
}
|
|
158
|
-
export declare const RouterContext: React.Context<RouterContextValue | null>;
|
|
159
|
-
/**
|
|
160
|
-
* Returns the current router context.
|
|
161
|
-
* Provides a graceful fallback (full-page navigation) when used outside RouterProvider.
|
|
162
|
-
*/
|
|
163
|
-
export declare function useRouter(): RouterContextValue;
|
|
164
|
-
export interface ClientRoute {
|
|
165
|
-
component?: React.ComponentType<Record<string, unknown>>;
|
|
166
|
-
load: () => Promise<{
|
|
167
|
-
default: {
|
|
168
|
-
component: React.ComponentType<Record<string, unknown>>;
|
|
169
|
-
_route: RuntimeRoute;
|
|
170
|
-
};
|
|
171
|
-
}>;
|
|
172
|
-
pageRoute?: RuntimeRoute;
|
|
173
|
-
pattern: string;
|
|
174
|
-
regex: RegExp;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* A ClientRoute that has been loaded — component and pageRoute are guaranteed defined.
|
|
178
|
-
* The initial route is eagerly loaded in the hydrate entry; subsequent routes are loaded
|
|
179
|
-
* on navigation via fetchPageState.
|
|
180
|
-
*/
|
|
181
|
-
export type LoadedClientRoute = ClientRoute & {
|
|
182
|
-
component: React.ComponentType<Record<string, unknown>>;
|
|
183
|
-
pageRoute: RuntimeRoute;
|
|
184
|
-
};
|
|
185
|
-
export interface RouterProviderProps {
|
|
186
|
-
/**
|
|
187
|
-
* When `true` (default), the router automatically re-fetches the current page
|
|
188
|
-
* whenever a server `revalidatePath()` call targets it. The signal is the
|
|
189
|
-
* `X-Furin-Revalidate` header detected on any `window.fetch` response.
|
|
190
|
-
*
|
|
191
|
-
* Set to `false` to opt out and call `router.refresh()` manually instead.
|
|
192
|
-
*/
|
|
193
|
-
autoRefresh?: boolean;
|
|
194
|
-
/**
|
|
195
|
-
* Sub-path prefix for static deployments (e.g. "/furin").
|
|
196
|
-
* Must start with "/" and have no trailing slash.
|
|
197
|
-
* Default: "" (site served from root).
|
|
198
|
-
*
|
|
199
|
-
* When set:
|
|
200
|
-
* - `currentHref` stores **logical** paths (prefix stripped) for correct active-state detection.
|
|
201
|
-
* - `navigate(logicalHref)` pushes `basePath + logicalHref` to browser history.
|
|
202
|
-
* - `fetch` calls use the physical path `basePath + logicalHref`.
|
|
203
|
-
*/
|
|
204
|
-
basePath?: string;
|
|
205
|
-
defaultPreload?: PreloadStrategy;
|
|
206
|
-
defaultPreloadDelay?: number;
|
|
207
|
-
defaultPreloadStaleTime?: number;
|
|
208
|
-
initialData: Record<string, unknown>;
|
|
209
|
-
initialMatch: LoadedClientRoute;
|
|
210
|
-
/** Maximum number of prefetch cache entries. Oldest entry is evicted when exceeded. Default: 50. */
|
|
211
|
-
prefetchCacheSize?: number;
|
|
212
|
-
root: RuntimeRoute | null;
|
|
213
|
-
routes: ClientRoute[];
|
|
214
|
-
}
|
|
215
|
-
interface RouterState {
|
|
216
|
-
data: Record<string, unknown>;
|
|
217
|
-
/** The canonical href after server-side redirects (e.g. query-default redirect). */
|
|
218
|
-
finalHref?: string;
|
|
219
|
-
match: LoadedClientRoute;
|
|
220
|
-
title?: string;
|
|
221
|
-
}
|
|
222
|
-
/** @internal */
|
|
223
|
-
export interface CacheEntry {
|
|
224
|
-
createdAt: number;
|
|
225
|
-
promise: Promise<RouterState | null>;
|
|
226
|
-
staleTime: number;
|
|
227
|
-
}
|
|
228
|
-
/** @internal Exported for unit testing only. */
|
|
229
|
-
export declare function shouldRefetch(entry: CacheEntry): boolean;
|
|
230
|
-
/** @internal Exported for unit testing only. */
|
|
231
|
-
export declare function buildPageElement(match: LoadedClientRoute, root: RuntimeRoute | null, data: Record<string, unknown>): React.ReactNode;
|
|
232
|
-
export declare function RouterProvider({ routes, root, initialMatch, initialData, autoRefresh, basePath, defaultPreload, defaultPreloadDelay, defaultPreloadStaleTime, prefetchCacheSize, }: RouterProviderProps): React.ReactElement;
|
|
233
|
-
/**
|
|
234
|
-
* SSR-aware Link component.
|
|
235
|
-
*
|
|
236
|
-
* - **Server (SSR):** uses `RouterContext.Consumer` (a render-prop, not a hook)
|
|
237
|
-
* to read basePath / currentHref from any enclosing RouterProvider, then
|
|
238
|
-
* falls back to `SSR_FALLBACK_ROUTER` when no provider is present.
|
|
239
|
-
* `Context.Consumer` bypasses `ReactCurrentDispatcher` entirely, so it is
|
|
240
|
-
* safe even when two React instances coexist in the module graph (Bun HMR).
|
|
241
|
-
* - **Client:** delegates to `LinkInteractive` which adds preloading, SPA
|
|
242
|
-
* navigation, active-state tracking and all other interactive features.
|
|
243
|
-
*/
|
|
244
|
-
export declare function Link<To extends RouteTo>(props: LinkProps<To>): React.ReactElement;
|
|
245
|
-
export {};
|