@teyik0/furin 0.9.0-alpha.0 → 0.9.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/README.md +1 -1
- package/dist/adapter/runtime-build.d.ts +7 -3
- package/dist/adapter/vercel.js +31 -6
- package/dist/build/client.d.ts +1 -1
- package/dist/build/entry-template.d.ts +3 -12
- package/dist/build/entry-template.ts +3 -15
- package/dist/build/hydrate.d.ts +6 -1
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +565 -401
- package/dist/build/route-metadata.d.ts +2 -2
- package/dist/build/route-types.d.ts +1 -1
- package/dist/build/types.d.ts +10 -4
- package/dist/cli/dev-worker.ts +10 -4
- package/dist/cli/index.js +624 -445
- package/dist/client/chunks/{client-xy6g38kx.js → client-a7spxfnn.js} +24 -5
- package/dist/client/chunks/{client-rjhxgt64.js → client-d9v49jwz.js} +1 -1
- package/dist/client/chunks/{client-k29262a4.js → client-rdxyrw11.js} +1 -1
- package/dist/client/define-route.d.ts +14 -0
- package/dist/client/internal/runtime-types.d.ts +8 -0
- package/dist/client/link.js +20 -17
- package/dist/client/router/link-utils.d.ts +3 -2
- package/dist/client/router/search/index.js +2 -2
- package/dist/client/router/types.d.ts +9 -3
- package/dist/client.js +22 -6
- package/dist/config.d.ts +4 -0
- package/dist/config.js +4 -1
- package/dist/define-route.d.ts +53 -12
- package/dist/furin.d.ts +13 -3
- package/dist/furin.js +815 -661
- package/dist/plugin/route-config.d.ts +3 -3
- package/dist/plugin/route-manifest.d.ts +46 -0
- package/dist/plugin/route-tree.d.ts +13 -29
- package/dist/routes.d.ts +2 -2
- package/dist/server/dev/runtime.d.ts +2 -1
- package/dist/server/internal.d.ts +6 -0
- package/dist/server/internal.js +97 -114
- package/dist/server/registrations.d.ts +4 -2
- package/dist/server/render/index.d.ts +0 -1
- package/dist/server/render/index.ts +0 -1
- package/dist/server/render/shell.d.ts +1 -13
- package/dist/server/render/shell.ts +1 -90
- package/dist/server/router/defined-route.d.ts +4 -0
- package/dist/server/router/discovery.d.ts +14 -4
- package/dist/server/router/hmr.d.ts +12 -12
- package/dist/server/router/patterns.d.ts +4 -12
- package/dist/server/router/types.d.ts +16 -1
- package/dist/server/static-export.js +128 -158
- package/dist/server/sync/drizzle/index.d.ts +8 -10
- package/dist/shared/not-found.d.ts +1 -1
- package/dist/shared/route-specificity.d.ts +10 -1
- package/package.json +8 -11
- package/src/adapter/package.ts +11 -37
- package/src/adapter/runtime-build.ts +5 -4
- package/src/adapter/static.ts +1 -1
- package/src/adapter/vercel.ts +2 -1
- package/src/build/client.ts +3 -3
- package/src/build/discover-pages-process.ts +1 -1
- package/src/build/elysia-aot.ts +2 -2
- package/src/build/entry-template.ts +3 -15
- package/src/build/hydrate.ts +12 -6
- package/src/build/index.ts +19 -9
- package/src/build/route-metadata.ts +15 -8
- package/src/build/route-types.ts +18 -43
- package/src/build/types.ts +12 -5
- package/src/cli/config.ts +6 -0
- package/src/cli/dev-worker.ts +10 -4
- package/src/cli/dev.ts +41 -26
- package/src/cli/index.ts +30 -14
- package/src/client/define-route.ts +29 -4
- package/src/client/internal/runtime-types.ts +8 -0
- package/src/client/link.tsx +21 -22
- package/src/client/router/context.ts +8 -7
- package/src/client/router/link-utils.ts +16 -8
- package/src/client/router/provider.tsx +5 -0
- package/src/client/router/types.ts +40 -14
- package/src/config.ts +5 -0
- package/src/define-route.ts +85 -16
- package/src/furin.ts +31 -7
- package/src/plugin/dev-routes.ts +8 -17
- package/src/plugin/route-config.ts +77 -62
- package/src/plugin/route-manifest.ts +437 -0
- package/src/plugin/route-modules.ts +6 -1
- package/src/plugin/route-registry.ts +7 -21
- package/src/plugin/route-tree.ts +71 -181
- package/src/routes.ts +2 -2
- package/src/server/dev/runtime.ts +16 -22
- package/src/server/internal.ts +4 -1
- package/src/server/registrations.ts +5 -2
- package/src/server/render/index.ts +0 -1
- package/src/server/render/shell.ts +1 -90
- package/src/server/render/static-params.ts +2 -10
- package/src/server/router/defined-route.ts +8 -0
- package/src/server/router/discovery.ts +237 -196
- package/src/server/router/hmr.ts +45 -63
- package/src/server/router/patterns.ts +41 -117
- package/src/server/router/types.ts +17 -1
- package/src/server/sync/drizzle/index.ts +18 -19
- package/src/shared/not-found.ts +1 -1
- package/src/shared/route-specificity.ts +34 -2
- package/src/shared/utils/index.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DevDiagnosticStore } from "../server/dev/diagnostics.ts";
|
|
2
|
-
import { type RouteInstanceSpec } from "./route-
|
|
2
|
+
import { type RouteInstanceSpec } from "./route-manifest.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Static route-config checks shared by the dev server and `furin build`.
|
|
5
5
|
* Furin never rewrites route sources: it reports what TypeScript cannot see
|
|
@@ -12,7 +12,7 @@ export interface RouteConfigIssue {
|
|
|
12
12
|
line: number;
|
|
13
13
|
message: string;
|
|
14
14
|
}
|
|
15
|
-
export declare function validateRouteConfig(
|
|
15
|
+
export declare function validateRouteConfig(spec: RouteInstanceSpec): RouteConfigIssue[];
|
|
16
16
|
export declare function formatRouteConfigIssue(issue: RouteConfigIssue): string;
|
|
17
17
|
/** Build and typegen: fails before route modules are imported. */
|
|
18
18
|
export declare function assertValidRouteConfig(instance: RouteInstanceSpec): void;
|
|
@@ -25,4 +25,4 @@ export declare function createRouteConfigReporter(instance: RouteInstanceSpec, s
|
|
|
25
25
|
* Writes a starter route, keyed by the file's id, into route files that are
|
|
26
26
|
* empty or whitespace-only, the only case where Furin writes to a source file.
|
|
27
27
|
*/
|
|
28
|
-
export declare function scaffoldEmptyRoutes(
|
|
28
|
+
export declare function scaffoldEmptyRoutes(spec: RouteInstanceSpec): string[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-routing convention of one `furin()` app. Both styles produce the same
|
|
3
|
+
* manifest, keyed by TanStack Start ids, so switching style only renames files.
|
|
4
|
+
*/
|
|
5
|
+
export type RouteStyle = "nextjs" | "tanstack";
|
|
6
|
+
export interface RouteInstanceSpec {
|
|
7
|
+
pagesDir: string;
|
|
8
|
+
prefix: string;
|
|
9
|
+
style: RouteStyle;
|
|
10
|
+
}
|
|
11
|
+
export interface RouteParam {
|
|
12
|
+
/** `_splat` for a catch-all segment. */
|
|
13
|
+
name: string;
|
|
14
|
+
optional: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ManifestRoute {
|
|
17
|
+
/** `defineRoute(id)`: the app prefix, then the TanStack id (`/board/$boardId/` for an index). */
|
|
18
|
+
id: string;
|
|
19
|
+
kind: "layout" | "page";
|
|
20
|
+
/** Path params of the route and its layouts, shallow → deep. */
|
|
21
|
+
params: RouteParam[];
|
|
22
|
+
/** Source of the parent layout; `undefined` when the root layout is the parent. */
|
|
23
|
+
parentPath: string | undefined;
|
|
24
|
+
/** URL pattern under the app prefix: `/board/:boardId`, `/docs/*`, `/:lang?/about`. */
|
|
25
|
+
pattern: string;
|
|
26
|
+
sourcePath: string;
|
|
27
|
+
}
|
|
28
|
+
/** A Next.js-style `error` / `not-found` pair declared in one directory. */
|
|
29
|
+
export interface ManifestBoundary {
|
|
30
|
+
directory: string;
|
|
31
|
+
errorPath: string | undefined;
|
|
32
|
+
notFoundPath: string | undefined;
|
|
33
|
+
}
|
|
34
|
+
export interface RouteManifest {
|
|
35
|
+
/** Directory boundaries, shallow → deep. Always empty in the TanStack style. */
|
|
36
|
+
boundaries: ManifestBoundary[];
|
|
37
|
+
/** Root layout module (`__root.tsx`, or `layout.tsx` at the top of a Next.js app). */
|
|
38
|
+
rootPath: string;
|
|
39
|
+
/** Layouts and pages in deterministic depth-first order. */
|
|
40
|
+
routes: ManifestRoute[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The single filesystem walk behind every route consumer (route tree,
|
|
44
|
+
* discovery, typegen, route-config checks, dev topology).
|
|
45
|
+
*/
|
|
46
|
+
export declare function scanRouteManifest({ pagesDir, prefix, style }: RouteInstanceSpec): RouteManifest;
|
|
@@ -1,43 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
prefix: string;
|
|
4
|
-
}
|
|
1
|
+
import { type RouteInstanceSpec } from "./route-manifest.ts";
|
|
2
|
+
export type { RouteInstanceSpec } from "./route-manifest.ts";
|
|
5
3
|
export declare function instanceKey(instance: RouteInstanceSpec): string;
|
|
6
4
|
export declare function routeModuleSpecifier(instance: RouteInstanceSpec): string;
|
|
7
5
|
export interface RouteFile {
|
|
8
6
|
id: string;
|
|
7
|
+
/** URL pattern of a page; `""` for a layout. */
|
|
9
8
|
path: string;
|
|
9
|
+
/** Mount prefix relative to the enclosing layout. */
|
|
10
|
+
prefix: string;
|
|
11
|
+
/** Native absolute path, as route modules are loaded and cached by it. */
|
|
10
12
|
sourcePath: string;
|
|
11
13
|
}
|
|
14
|
+
/** A layout and everything it wraps, following the manifest's parent links. */
|
|
12
15
|
export interface RouteTreeNode {
|
|
13
16
|
children: RouteTreeNode[];
|
|
14
|
-
|
|
15
|
-
indexRoute: RouteFile | undefined;
|
|
17
|
+
/** `undefined` for the root node: the root layout's Elysia is never mounted. */
|
|
16
18
|
layout: RouteFile | undefined;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* Id of `defineRoute(id)`: the app's prefix, then the file's path under
|
|
21
|
-
* `pagesDir` with brackets and groups, `/index` dropped
|
|
22
|
-
* (`board/[boardId]/index.tsx` → `/board/[boardId]`, `board/_route.tsx` →
|
|
23
|
-
* `/board/_route`; `users.tsx` under the `/admin` prefix → `/admin/users`).
|
|
24
|
-
*/
|
|
25
|
-
export declare function fileRouteId({ pagesDir, prefix }: RouteInstanceSpec, sourcePath: string): string;
|
|
26
|
-
export declare function segmentPath(segment: string): string;
|
|
27
|
-
export interface RouteManifestFile {
|
|
28
|
-
base: string;
|
|
29
|
-
directorySegments: string[];
|
|
30
|
-
/** URL pattern of a page; `undefined` for a `_route` layout. */
|
|
31
|
-
pattern: string | undefined;
|
|
32
|
-
sourcePath: string;
|
|
19
|
+
pages: RouteFile[];
|
|
20
|
+
/** Mount prefix relative to the parent node. */
|
|
21
|
+
prefix: string;
|
|
33
22
|
}
|
|
34
|
-
|
|
35
|
-
* The single filesystem walk behind every route consumer (native route tree,
|
|
36
|
-
* `scanPages`, typegen, adapters): files in deterministic depth-first order,
|
|
37
|
-
* dynamic segments validated and duplicate URL patterns rejected.
|
|
38
|
-
*/
|
|
39
|
-
export declare function scanRouteManifest(pagesDir: string): RouteManifestFile[];
|
|
40
|
-
export declare function buildRouteTree(pagesDir: string, instanceId: string): RouteTreeNode;
|
|
23
|
+
export declare function buildRouteTree(instance: RouteInstanceSpec, instanceId: string): RouteTreeNode;
|
|
41
24
|
export declare function collectRouteFiles(root: RouteTreeNode): RouteFile[];
|
|
42
25
|
export declare function routeSourcePaths(instance: RouteInstanceSpec): string[];
|
|
26
|
+
/** Every file whose presence shapes the app: root, routes and boundary files. */
|
|
43
27
|
export declare function routeSnapshotSourcePaths(instance: RouteInstanceSpec): string[];
|
package/dist/routes.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export interface RouteMap {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Typecheck fallback for `defineRoute(id)`. The generated
|
|
11
|
-
* furin-env.d.ts augments it with one entry per route file, keyed by its
|
|
12
|
-
* id (`"/board/
|
|
11
|
+
* furin-env.d.ts augments it with one entry per route file, keyed by its
|
|
12
|
+
* TanStack Start id (`"/board/$boardId/"`, `"/board"`): kind, URL pattern, parent
|
|
13
13
|
* layout and path params, read from the pages tree without importing modules.
|
|
14
14
|
*/
|
|
15
15
|
export interface FileRoutes {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { RouteStyle } from "../../plugin/route-manifest.ts";
|
|
1
2
|
import { type FurinInstance } from "../instance.ts";
|
|
2
3
|
import type { ModeOptions, ModeRuntime } from "../mode.ts";
|
|
3
4
|
/** Serves a runtime from its page sources with Bun native HMR. */
|
|
4
|
-
export declare function createDevRuntime(instance: FurinInstance, resolvedPagesDir: string, options: ModeOptions): Promise<ModeRuntime>;
|
|
5
|
+
export declare function createDevRuntime(instance: FurinInstance, resolvedPagesDir: string, style: RouteStyle, options: ModeOptions): Promise<ModeRuntime>;
|
|
@@ -75,12 +75,18 @@ export interface CompileContext {
|
|
|
75
75
|
rootPath: string;
|
|
76
76
|
/** Per-route metadata including pre-computed segment boundaries. */
|
|
77
77
|
routeMetadata?: Record<string, {
|
|
78
|
+
/** Layouts wrapping the page, shallow → deep, from the route manifest. */
|
|
79
|
+
layouts: Array<{
|
|
80
|
+
path: string;
|
|
81
|
+
pattern: string;
|
|
82
|
+
}>;
|
|
78
83
|
requestKeys?: string[];
|
|
79
84
|
requestKeysByLoader?: string[][];
|
|
80
85
|
segmentBoundaries: Array<{
|
|
81
86
|
depth: number;
|
|
82
87
|
path: string;
|
|
83
88
|
errorPath?: string;
|
|
89
|
+
fromRoute?: true;
|
|
84
90
|
notFoundPath?: string;
|
|
85
91
|
}>;
|
|
86
92
|
}>;
|
package/dist/server/internal.js
CHANGED
|
@@ -151,7 +151,7 @@ function segmentSpecificity(segment) {
|
|
|
151
151
|
}
|
|
152
152
|
return segment.startsWith(":") ? 2 : 3;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function compareConcreteSpecificity(a, b) {
|
|
155
155
|
const aSegments = a.split("/").filter(Boolean);
|
|
156
156
|
const bSegments = b.split("/").filter(Boolean);
|
|
157
157
|
const length = Math.max(aSegments.length, bSegments.length);
|
|
@@ -171,6 +171,24 @@ function compareRouteSpecificity(a, b) {
|
|
|
171
171
|
}
|
|
172
172
|
return 0;
|
|
173
173
|
}
|
|
174
|
+
function expandOptionalSegments(pattern) {
|
|
175
|
+
let variants = [[]];
|
|
176
|
+
for (const segment of pattern.split("/").filter(Boolean)) {
|
|
177
|
+
if (segment.startsWith(":") && segment.endsWith("?")) {
|
|
178
|
+
const required = segment.slice(0, -1);
|
|
179
|
+
variants = variants.flatMap((variant) => [variant, [...variant, required]]);
|
|
180
|
+
} else {
|
|
181
|
+
variants = variants.map((variant) => [...variant, segment]);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return variants.map((variant) => `/${variant.join("/")}`);
|
|
185
|
+
}
|
|
186
|
+
function mostSpecificVariant(pattern) {
|
|
187
|
+
return expandOptionalSegments(pattern).reduce((best, variant) => compareConcreteSpecificity(variant, best) > 0 ? variant : best);
|
|
188
|
+
}
|
|
189
|
+
function compareRouteSpecificity(a, b) {
|
|
190
|
+
return compareConcreteSpecificity(mostSpecificVariant(a), mostSpecificVariant(b));
|
|
191
|
+
}
|
|
174
192
|
|
|
175
193
|
// src/shared/search-params.ts
|
|
176
194
|
function isObject(value) {
|
|
@@ -3178,11 +3196,12 @@ function navigationHrefPolicy(href, currentOrigin) {
|
|
|
3178
3196
|
return url.origin === currentOrigin ? "internal" : "external";
|
|
3179
3197
|
}
|
|
3180
3198
|
function applyLinkParams(to, params) {
|
|
3181
|
-
|
|
3182
|
-
|
|
3199
|
+
const values = params ?? {};
|
|
3200
|
+
let url = to.replaceAll(/\/:([a-zA-Z0-9_]+)\?(?=\/|$)/g, (_match, name) => values[name] === undefined || values[name] === "" ? "" : `/${encodeURIComponent(String(values[name]))}`).replaceAll(/:([a-zA-Z0-9_]+)/g, (match, name) => (name in values) ? encodeURIComponent(String(values[name])) : match);
|
|
3201
|
+
if (url === "") {
|
|
3202
|
+
url = "/";
|
|
3183
3203
|
}
|
|
3184
|
-
|
|
3185
|
-
const wildcard = params["*"];
|
|
3204
|
+
const wildcard = values._splat;
|
|
3186
3205
|
if (wildcard !== undefined && url.includes("/*")) {
|
|
3187
3206
|
const encodedWildcard = String(wildcard).split("/").map(encodeURIComponent).join("/");
|
|
3188
3207
|
url = url.replace("/*", () => `/${encodedWildcard}`);
|
|
@@ -3662,7 +3681,6 @@ var init_graph = __esm(() => {
|
|
|
3662
3681
|
});
|
|
3663
3682
|
|
|
3664
3683
|
// src/server/router/patterns.ts
|
|
3665
|
-
import { parse } from "path";
|
|
3666
3684
|
function resolveRouteRevalidate(page) {
|
|
3667
3685
|
return page.revalidate ?? page._route.revalidate;
|
|
3668
3686
|
}
|
|
@@ -3672,47 +3690,6 @@ function resolveDocumentMode(route) {
|
|
|
3672
3690
|
}
|
|
3673
3691
|
return route.mode === "isr" || route.routeChain.some((entry) => entry.mode === "isr" && entry.loader !== undefined) ? "isr" : "ssg";
|
|
3674
3692
|
}
|
|
3675
|
-
function parseDynamicRouteSegment(segment, sourcePath) {
|
|
3676
|
-
if (!(segment.startsWith("[") && segment.endsWith("]"))) {
|
|
3677
|
-
return;
|
|
3678
|
-
}
|
|
3679
|
-
const inner = segment.slice(1, -1);
|
|
3680
|
-
const catchAll = inner.startsWith("...");
|
|
3681
|
-
const name = catchAll ? inner.slice(3) : inner;
|
|
3682
|
-
if (!DYNAMIC_PARAMETER_NAME_RE.test(name)) {
|
|
3683
|
-
throw new Error(`[furin] Invalid dynamic parameter ${JSON.stringify(name)} in ${JSON.stringify(sourcePath ?? segment)}. Parameter names must match ${DYNAMIC_PARAMETER_NAME_RE}.`);
|
|
3684
|
-
}
|
|
3685
|
-
return { catchAll, name };
|
|
3686
|
-
}
|
|
3687
|
-
function isRouteGroup(segment) {
|
|
3688
|
-
return ROUTE_GROUP_RE.test(segment);
|
|
3689
|
-
}
|
|
3690
|
-
function filePathToPattern(path) {
|
|
3691
|
-
const parts = path.replaceAll("\\", "/").split("/");
|
|
3692
|
-
const segments = [];
|
|
3693
|
-
const lastIndex = parts.length - 1;
|
|
3694
|
-
for (let idx = 0;idx < parts.length; idx += 1) {
|
|
3695
|
-
const part = parts[idx];
|
|
3696
|
-
if (part === undefined || part.length === 0) {
|
|
3697
|
-
continue;
|
|
3698
|
-
}
|
|
3699
|
-
const isFile = idx === lastIndex;
|
|
3700
|
-
const name = isFile ? parse(part).name : part;
|
|
3701
|
-
if (!isFile && isRouteGroup(name)) {
|
|
3702
|
-
continue;
|
|
3703
|
-
}
|
|
3704
|
-
if (isFile && name === "index") {
|
|
3705
|
-
continue;
|
|
3706
|
-
}
|
|
3707
|
-
const dynamic = parseDynamicRouteSegment(name, path);
|
|
3708
|
-
if (dynamic) {
|
|
3709
|
-
segments.push(dynamic.catchAll ? "*" : `:${dynamic.name}`);
|
|
3710
|
-
} else {
|
|
3711
|
-
segments.push(name);
|
|
3712
|
-
}
|
|
3713
|
-
}
|
|
3714
|
-
return `/${segments.join("/")}`;
|
|
3715
|
-
}
|
|
3716
3693
|
function escapeRegExp(value) {
|
|
3717
3694
|
return value.replace(REGEX_META_CHARS_RE, "\\$&");
|
|
3718
3695
|
}
|
|
@@ -3727,11 +3704,17 @@ function routePatternRegexSource(pattern, sources) {
|
|
|
3727
3704
|
while (i < pattern.length && pattern[i] !== "/") {
|
|
3728
3705
|
i += 1;
|
|
3729
3706
|
}
|
|
3730
|
-
|
|
3731
|
-
|
|
3707
|
+
const name = pattern.slice(start, i);
|
|
3708
|
+
if (name.endsWith("?") && source.endsWith("/")) {
|
|
3709
|
+
paramNames.push(name.slice(0, -1));
|
|
3710
|
+
source = `${source.slice(0, -1)}(?:/${sources.param})?`;
|
|
3711
|
+
} else {
|
|
3712
|
+
paramNames.push(name);
|
|
3713
|
+
source += sources.param;
|
|
3714
|
+
}
|
|
3732
3715
|
} else if (pattern[i] === "*") {
|
|
3733
|
-
paramNames.push(
|
|
3734
|
-
source
|
|
3716
|
+
paramNames.push(SPLAT_PARAM);
|
|
3717
|
+
source = source.endsWith("/") ? `${source.slice(0, -1)}(?:/${sources.catchAll})?` : source + sources.catchAll;
|
|
3735
3718
|
i += 1;
|
|
3736
3719
|
} else {
|
|
3737
3720
|
const ch = pattern[i];
|
|
@@ -3753,6 +3736,25 @@ function buildRouteRegex(pattern) {
|
|
|
3753
3736
|
regex: new RegExp(`^${source}${pattern === "/" || pattern.endsWith("/") ? "" : "/?"}$`)
|
|
3754
3737
|
};
|
|
3755
3738
|
}
|
|
3739
|
+
function decodeParam(value) {
|
|
3740
|
+
try {
|
|
3741
|
+
return decodeURIComponent(value);
|
|
3742
|
+
} catch {
|
|
3743
|
+
return value;
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
function matchedParams(paramNames, match) {
|
|
3747
|
+
const params = {};
|
|
3748
|
+
for (const [index, name] of paramNames.entries()) {
|
|
3749
|
+
const value = match[index + 1];
|
|
3750
|
+
if (value !== undefined) {
|
|
3751
|
+
params[name] = decodeParam(value);
|
|
3752
|
+
} else if (name === SPLAT_PARAM) {
|
|
3753
|
+
params[name] = "";
|
|
3754
|
+
}
|
|
3755
|
+
}
|
|
3756
|
+
return params;
|
|
3757
|
+
}
|
|
3756
3758
|
function buildRouteMatcher(routes) {
|
|
3757
3759
|
const compiled = routes.map((route) => {
|
|
3758
3760
|
const { regex, paramNames } = buildRouteRegex(route.pattern);
|
|
@@ -3764,26 +3766,13 @@ function buildRouteMatcher(routes) {
|
|
|
3764
3766
|
if (!match) {
|
|
3765
3767
|
continue;
|
|
3766
3768
|
}
|
|
3767
|
-
|
|
3768
|
-
for (let i = 0;i < candidate.paramNames.length; i += 1) {
|
|
3769
|
-
const name = candidate.paramNames[i];
|
|
3770
|
-
if (name !== undefined) {
|
|
3771
|
-
try {
|
|
3772
|
-
params[name] = decodeURIComponent(match[i + 1] ?? "");
|
|
3773
|
-
} catch {
|
|
3774
|
-
params[name] = match[i + 1] ?? "";
|
|
3775
|
-
}
|
|
3776
|
-
}
|
|
3777
|
-
}
|
|
3778
|
-
return { params, route: candidate.route };
|
|
3769
|
+
return { params: matchedParams(candidate.paramNames, match), route: candidate.route };
|
|
3779
3770
|
}
|
|
3780
3771
|
return null;
|
|
3781
3772
|
};
|
|
3782
3773
|
}
|
|
3783
|
-
var
|
|
3774
|
+
var SPLAT_PARAM = "_splat", REGEX_META_CHARS_RE;
|
|
3784
3775
|
var init_patterns = __esm(() => {
|
|
3785
|
-
DYNAMIC_PARAMETER_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
3786
|
-
ROUTE_GROUP_RE = /^\([^()]+\)$/;
|
|
3787
3776
|
REGEX_META_CHARS_RE = /[.*+?^${}()|[\]\\]/g;
|
|
3788
3777
|
});
|
|
3789
3778
|
|
|
@@ -8912,6 +8901,7 @@ var FALLBACK_SEARCH_STORE = createSearchStore({
|
|
|
8912
8901
|
});
|
|
8913
8902
|
var SearchStoreContext = createContext5(null);
|
|
8914
8903
|
// src/client/link.tsx
|
|
8904
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
8915
8905
|
"use client";
|
|
8916
8906
|
function resolveLinkHref({ to, params, search, hash }, router2) {
|
|
8917
8907
|
const resolvedTo = applyLinkParams(to, params);
|
|
@@ -8980,12 +8970,12 @@ function LinkInteractive({
|
|
|
8980
8970
|
if (target !== null) {
|
|
8981
8971
|
prefetch(target, { staleTime: effectiveStaleTime });
|
|
8982
8972
|
}
|
|
8983
|
-
}, [prefetch,
|
|
8973
|
+
}, [prefetch, effectiveStaleTime, router2.basePath]);
|
|
8984
8974
|
useEffect2(() => {
|
|
8985
8975
|
if (effectivePreload === "render") {
|
|
8986
8976
|
triggerPrefetch();
|
|
8987
8977
|
}
|
|
8988
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
8978
|
+
}, [effectivePreload, triggerPrefetch, logicalHref]);
|
|
8989
8979
|
useEffect2(() => {
|
|
8990
8980
|
if (effectivePreload !== "viewport" || !anchorRef.current) {
|
|
8991
8981
|
return;
|
|
@@ -8998,7 +8988,7 @@ function LinkInteractive({
|
|
|
8998
8988
|
}, { rootMargin: "200px" });
|
|
8999
8989
|
observer.observe(anchorRef.current);
|
|
9000
8990
|
return () => observer.disconnect();
|
|
9001
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
8991
|
+
}, [effectivePreload, triggerPrefetch, logicalHref]);
|
|
9002
8992
|
useEffect2(() => () => {
|
|
9003
8993
|
if (intentTimerRef.current !== null) {
|
|
9004
8994
|
clearTimeout(intentTimerRef.current);
|
|
@@ -9027,7 +9017,7 @@ function LinkInteractive({
|
|
|
9027
9017
|
}
|
|
9028
9018
|
e.preventDefault();
|
|
9029
9019
|
if (typeof window !== "undefined" && router2.navigate === CLIENT_FALLBACK_ROUTER.navigate) {
|
|
9030
|
-
window.location.href
|
|
9020
|
+
window.location.assign(href);
|
|
9031
9021
|
return;
|
|
9032
9022
|
}
|
|
9033
9023
|
router2.navigate(target, { replace, resetScroll: resetScroll ?? true });
|
|
@@ -9051,7 +9041,7 @@ function LinkInteractive({
|
|
|
9051
9041
|
triggerPrefetch();
|
|
9052
9042
|
}
|
|
9053
9043
|
};
|
|
9054
|
-
return
|
|
9044
|
+
return /* @__PURE__ */ jsxDEV3("a", {
|
|
9055
9045
|
"data-furin-link": true,
|
|
9056
9046
|
href,
|
|
9057
9047
|
onClick: handleClick,
|
|
@@ -9062,8 +9052,9 @@ function LinkInteractive({
|
|
|
9062
9052
|
...isActive ? { "data-status": "active" } : {},
|
|
9063
9053
|
...anchorProps,
|
|
9064
9054
|
...extraProps,
|
|
9065
|
-
...disabled ? { "aria-disabled": true } : {}
|
|
9066
|
-
|
|
9055
|
+
...disabled ? { "aria-disabled": true } : {},
|
|
9056
|
+
children: resolvedChildren
|
|
9057
|
+
}, undefined, false, undefined, this);
|
|
9067
9058
|
}
|
|
9068
9059
|
var SSR_FALLBACK_ROUTER = {
|
|
9069
9060
|
basePath: "",
|
|
@@ -9123,7 +9114,7 @@ function Link(props) {
|
|
|
9123
9114
|
}
|
|
9124
9115
|
|
|
9125
9116
|
// src/client/default-screens.tsx
|
|
9126
|
-
import { jsxDEV as
|
|
9117
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
9127
9118
|
var FONT_SANS = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
|
|
9128
9119
|
var FONT_MONO = 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace';
|
|
9129
9120
|
var COLOR_BG = "#000000";
|
|
@@ -9174,7 +9165,7 @@ function CornerBracket({ corner }) {
|
|
|
9174
9165
|
[`border${top ? "Top" : "Bottom"}`]: `2px solid ${COLOR_BRACKET}`,
|
|
9175
9166
|
[`border${left ? "Left" : "Right"}`]: `2px solid ${COLOR_BRACKET}`
|
|
9176
9167
|
};
|
|
9177
|
-
return /* @__PURE__ */
|
|
9168
|
+
return /* @__PURE__ */ jsxDEV4("span", {
|
|
9178
9169
|
"aria-hidden": "true",
|
|
9179
9170
|
style
|
|
9180
9171
|
}, undefined, false, undefined, this);
|
|
@@ -9280,32 +9271,32 @@ html, body {
|
|
|
9280
9271
|
}
|
|
9281
9272
|
`;
|
|
9282
9273
|
function ScreenFrame({ badge, children }) {
|
|
9283
|
-
return /* @__PURE__ */
|
|
9274
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
9284
9275
|
style: PAGE_STYLE,
|
|
9285
9276
|
children: [
|
|
9286
|
-
/* @__PURE__ */
|
|
9277
|
+
/* @__PURE__ */ jsxDEV4("style", {
|
|
9287
9278
|
children: RESET_CSS
|
|
9288
9279
|
}, undefined, false, undefined, this),
|
|
9289
|
-
/* @__PURE__ */
|
|
9280
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
9290
9281
|
style: FRAME_STYLE,
|
|
9291
9282
|
children: [
|
|
9292
|
-
/* @__PURE__ */
|
|
9283
|
+
/* @__PURE__ */ jsxDEV4(CornerBracket, {
|
|
9293
9284
|
corner: "tl"
|
|
9294
9285
|
}, undefined, false, undefined, this),
|
|
9295
|
-
/* @__PURE__ */
|
|
9286
|
+
/* @__PURE__ */ jsxDEV4(CornerBracket, {
|
|
9296
9287
|
corner: "tr"
|
|
9297
9288
|
}, undefined, false, undefined, this),
|
|
9298
|
-
/* @__PURE__ */
|
|
9289
|
+
/* @__PURE__ */ jsxDEV4(CornerBracket, {
|
|
9299
9290
|
corner: "bl"
|
|
9300
9291
|
}, undefined, false, undefined, this),
|
|
9301
|
-
/* @__PURE__ */
|
|
9292
|
+
/* @__PURE__ */ jsxDEV4(CornerBracket, {
|
|
9302
9293
|
corner: "br"
|
|
9303
9294
|
}, undefined, false, undefined, this),
|
|
9304
|
-
/* @__PURE__ */
|
|
9295
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
9305
9296
|
style: CARD_STYLE,
|
|
9306
9297
|
children: [
|
|
9307
9298
|
badge,
|
|
9308
|
-
/* @__PURE__ */
|
|
9299
|
+
/* @__PURE__ */ jsxDEV4("hr", {
|
|
9309
9300
|
style: DIVIDER_STYLE
|
|
9310
9301
|
}, undefined, false, undefined, this),
|
|
9311
9302
|
children
|
|
@@ -9317,41 +9308,41 @@ function ScreenFrame({ badge, children }) {
|
|
|
9317
9308
|
}, undefined, true, undefined, this);
|
|
9318
9309
|
}
|
|
9319
9310
|
function DefaultErrorScreen({ message, digest, reset }) {
|
|
9320
|
-
return /* @__PURE__ */
|
|
9321
|
-
badge: /* @__PURE__ */
|
|
9311
|
+
return /* @__PURE__ */ jsxDEV4(ScreenFrame, {
|
|
9312
|
+
badge: /* @__PURE__ */ jsxDEV4("div", {
|
|
9322
9313
|
style: BADGE_STYLE,
|
|
9323
9314
|
children: "500 \u2014 ERROR"
|
|
9324
9315
|
}, undefined, false, undefined, this),
|
|
9325
9316
|
children: [
|
|
9326
|
-
/* @__PURE__ */
|
|
9317
|
+
/* @__PURE__ */ jsxDEV4("h1", {
|
|
9327
9318
|
style: HEADING_STYLE,
|
|
9328
9319
|
children: "Something went wrong"
|
|
9329
9320
|
}, undefined, false, undefined, this),
|
|
9330
|
-
/* @__PURE__ */
|
|
9321
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
9331
9322
|
style: CODE_BOX_STYLE,
|
|
9332
9323
|
children: [
|
|
9333
|
-
/* @__PURE__ */
|
|
9324
|
+
/* @__PURE__ */ jsxDEV4("span", {
|
|
9334
9325
|
style: CODE_LABEL_STYLE,
|
|
9335
9326
|
children: "CODE:"
|
|
9336
9327
|
}, undefined, false, undefined, this),
|
|
9337
|
-
/* @__PURE__ */
|
|
9328
|
+
/* @__PURE__ */ jsxDEV4("span", {
|
|
9338
9329
|
children: digest
|
|
9339
9330
|
}, undefined, false, undefined, this)
|
|
9340
9331
|
]
|
|
9341
9332
|
}, undefined, true, undefined, this),
|
|
9342
|
-
/* @__PURE__ */
|
|
9333
|
+
/* @__PURE__ */ jsxDEV4("p", {
|
|
9343
9334
|
style: DESCRIPTION_WRAPPER_STYLE,
|
|
9344
9335
|
children: message ? message : "We encountered an unexpected error. Please try again or return to the home page."
|
|
9345
9336
|
}, undefined, false, undefined, this),
|
|
9346
|
-
/* @__PURE__ */
|
|
9337
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
9347
9338
|
style: ACTIONS_STYLE,
|
|
9348
9339
|
children: [
|
|
9349
|
-
/* @__PURE__ */
|
|
9340
|
+
/* @__PURE__ */ jsxDEV4(Link, {
|
|
9350
9341
|
style: BUTTON_PRIMARY,
|
|
9351
9342
|
to: "/",
|
|
9352
9343
|
children: "Go Home"
|
|
9353
9344
|
}, undefined, false, undefined, this),
|
|
9354
|
-
/* @__PURE__ */
|
|
9345
|
+
/* @__PURE__ */ jsxDEV4("button", {
|
|
9355
9346
|
onClick: reset,
|
|
9356
9347
|
style: BUTTON_SECONDARY,
|
|
9357
9348
|
type: "button",
|
|
@@ -9363,23 +9354,23 @@ function DefaultErrorScreen({ message, digest, reset }) {
|
|
|
9363
9354
|
}, undefined, true, undefined, this);
|
|
9364
9355
|
}
|
|
9365
9356
|
function DefaultNotFoundScreen({ message }) {
|
|
9366
|
-
return /* @__PURE__ */
|
|
9367
|
-
badge: /* @__PURE__ */
|
|
9357
|
+
return /* @__PURE__ */ jsxDEV4(ScreenFrame, {
|
|
9358
|
+
badge: /* @__PURE__ */ jsxDEV4("div", {
|
|
9368
9359
|
style: BADGE_STYLE,
|
|
9369
9360
|
children: "404 \u2014 NOT FOUND"
|
|
9370
9361
|
}, undefined, false, undefined, this),
|
|
9371
9362
|
children: [
|
|
9372
|
-
/* @__PURE__ */
|
|
9363
|
+
/* @__PURE__ */ jsxDEV4("h1", {
|
|
9373
9364
|
style: HEADING_STYLE,
|
|
9374
9365
|
children: "This page does not exist"
|
|
9375
9366
|
}, undefined, false, undefined, this),
|
|
9376
|
-
/* @__PURE__ */
|
|
9367
|
+
/* @__PURE__ */ jsxDEV4("p", {
|
|
9377
9368
|
style: DESCRIPTION_WRAPPER_STYLE,
|
|
9378
9369
|
children: message ? message : "The page you are looking for could not be found. It may have been moved or removed."
|
|
9379
9370
|
}, undefined, false, undefined, this),
|
|
9380
|
-
/* @__PURE__ */
|
|
9371
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
9381
9372
|
style: ACTIONS_STYLE,
|
|
9382
|
-
children: /* @__PURE__ */
|
|
9373
|
+
children: /* @__PURE__ */ jsxDEV4(Link, {
|
|
9383
9374
|
style: BUTTON_PRIMARY,
|
|
9384
9375
|
to: "/",
|
|
9385
9376
|
children: "Go Home"
|
|
@@ -9388,18 +9379,18 @@ function DefaultNotFoundScreen({ message }) {
|
|
|
9388
9379
|
]
|
|
9389
9380
|
}, undefined, true, undefined, this);
|
|
9390
9381
|
}
|
|
9391
|
-
var DefaultErrorFallback = ({ error, reset }) => /* @__PURE__ */
|
|
9382
|
+
var DefaultErrorFallback = ({ error, reset }) => /* @__PURE__ */ jsxDEV4(DefaultErrorScreen, {
|
|
9392
9383
|
digest: error.digest,
|
|
9393
9384
|
message: error.message,
|
|
9394
9385
|
reset
|
|
9395
9386
|
}, undefined, false, undefined, this);
|
|
9396
|
-
var DefaultNotFoundFallback = ({ error }) => /* @__PURE__ */
|
|
9387
|
+
var DefaultNotFoundFallback = ({ error }) => /* @__PURE__ */ jsxDEV4(DefaultNotFoundScreen, {
|
|
9397
9388
|
message: error.message
|
|
9398
9389
|
}, undefined, false, undefined, this);
|
|
9399
9390
|
|
|
9400
9391
|
// src/server/render/element.tsx
|
|
9401
9392
|
init_instance();
|
|
9402
|
-
import { jsxDEV as
|
|
9393
|
+
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
9403
9394
|
function errorMessageOf(err) {
|
|
9404
9395
|
if (err instanceof Error) {
|
|
9405
9396
|
return err.message;
|
|
@@ -9427,7 +9418,7 @@ function errorMessageForRender(component, error, messageOverride) {
|
|
|
9427
9418
|
function buildErrorElement(component, error, digest, messageOverride, status) {
|
|
9428
9419
|
const ErrorView = component ?? DefaultErrorFallback;
|
|
9429
9420
|
const message = errorMessageForRender(component, error, messageOverride);
|
|
9430
|
-
return /* @__PURE__ */
|
|
9421
|
+
return /* @__PURE__ */ jsxDEV5(ErrorView, {
|
|
9431
9422
|
error: { digest, message, status },
|
|
9432
9423
|
reset: SERVER_RESET_NOOP2
|
|
9433
9424
|
}, undefined, false, undefined, this);
|
|
@@ -10530,8 +10521,6 @@ function renderForPath(route, params, root, origin, mode, basePath, searchRoutes
|
|
|
10530
10521
|
}
|
|
10531
10522
|
|
|
10532
10523
|
// src/server/render/static-params.ts
|
|
10533
|
-
import { dirname as dirname2, relative } from "path";
|
|
10534
|
-
init_patterns();
|
|
10535
10524
|
var STATIC_PARAMS_CONCURRENCY = 4;
|
|
10536
10525
|
var DYNAMIC_SEGMENT_RE = /\/:[^/]+|\/\*/;
|
|
10537
10526
|
function collectStaticParamsStages(route) {
|
|
@@ -10547,17 +10536,11 @@ function collectStaticParamsStages(route) {
|
|
|
10547
10536
|
return stages;
|
|
10548
10537
|
}
|
|
10549
10538
|
function ancestorPattern(route, ancestors) {
|
|
10550
|
-
const rootSourcePath = route.routeChain[0]?.sourcePath;
|
|
10551
10539
|
const ancestorSourcePath = ancestors.at(-1)?.sourcePath;
|
|
10552
|
-
if (
|
|
10553
|
-
return route.pattern;
|
|
10554
|
-
}
|
|
10555
|
-
const pagesDir = dirname2(rootSourcePath);
|
|
10556
|
-
const ancestorDir = dirname2(ancestorSourcePath);
|
|
10557
|
-
if (ancestorDir === pagesDir) {
|
|
10540
|
+
if (ancestors.length <= 1) {
|
|
10558
10541
|
return "/";
|
|
10559
10542
|
}
|
|
10560
|
-
return
|
|
10543
|
+
return route.layouts.find(({ path }) => path === ancestorSourcePath)?.pattern ?? route.pattern;
|
|
10561
10544
|
}
|
|
10562
10545
|
function createBuildContext(pattern, params, origin) {
|
|
10563
10546
|
const path = resolvePath(pattern, params);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { RouteStyle } from "../plugin/route-manifest.ts";
|
|
2
|
+
/** A `furin({ pagesDir, prefix, style })` call, as declared by the application. */
|
|
2
3
|
export interface FurinRegistration {
|
|
3
|
-
/** pagesDir as declared (
|
|
4
|
+
/** pagesDir as declared (the style's default when omitted); relative to the project root. */
|
|
4
5
|
readonly pagesDir: string;
|
|
5
6
|
/** Normalized mount prefix (`""` for root). */
|
|
6
7
|
readonly prefix: string;
|
|
8
|
+
readonly style: RouteStyle;
|
|
7
9
|
}
|
|
8
10
|
/** Starts recording `furin()` calls in this process. */
|
|
9
11
|
export declare function collectFurinRegistrations(discover: boolean): FurinRegistration[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// biome-ignore-all lint/performance/noBarrelFile: intentional barrel for public API
|
|
2
2
|
|
|
3
|
-
export { streamToString } from "./assemble.ts";
|
|
4
3
|
export { renderToHTML } from "./buffered-render.ts";
|
|
5
4
|
export { buildErrorElement } from "./element.tsx";
|
|
6
5
|
export { handleISR } from "./isr.ts";
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MetaDescriptor } from "../../client.ts";
|
|
2
2
|
export declare function extractTitle(meta?: MetaDescriptor[]): string | undefined;
|
|
3
|
-
export declare function isMetaTag(entry: MetaDescriptor): boolean;
|
|
4
3
|
export declare function escapeHtml(str: string): string;
|
|
5
4
|
export declare function safeJson(value: unknown): string;
|
|
6
|
-
export declare function renderAttrs(obj: Record<string, string | undefined>): string;
|
|
7
|
-
export declare function buildMetaParts(meta: MetaDescriptor[]): string[];
|
|
8
|
-
export declare function buildLinkParts(links: NonNullable<HeadOptions["links"]>): string[];
|
|
9
|
-
export declare function buildScriptParts(scripts: NonNullable<HeadOptions["scripts"]>): string[];
|
|
10
|
-
export declare function buildStyleParts(styles: NonNullable<HeadOptions["styles"]>): string[];
|
|
11
|
-
/**
|
|
12
|
-
* Builds the string to inject into the <!--ssr-head--> placeholder.
|
|
13
|
-
* Handles title, meta tags, links, inline scripts, and inline styles from
|
|
14
|
-
* the page's `head()` function. CSS is handled by Bun (imported in user files).
|
|
15
|
-
*/
|
|
16
|
-
export declare function buildHeadInjection(headData: HeadOptions | undefined): string;
|
|
17
5
|
export declare function generateIndexHtml(): string;
|
|
18
6
|
/**
|
|
19
7
|
* Generates the production SSR template (index.html) with hashed asset paths.
|