@teyik0/furin 0.9.0-alpha.1 → 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/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/index.js +594 -422
- 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 +3 -3
- 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 +766 -614
- 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 +57 -76
- package/dist/server/registrations.d.ts +4 -2
- 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 +88 -120
- package/dist/server/sync/drizzle/index.d.ts +8 -10
- package/dist/shared/route-specificity.d.ts +10 -1
- package/package.json +3 -6
- 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/index.ts +30 -14
- package/src/client/define-route.ts +29 -4
- package/src/client/internal/runtime-types.ts +8 -0
- package/src/client/router/link-utils.ts +16 -8
- 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/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/route-specificity.ts +34 -2
- package/src/shared/utils/index.ts +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EntryAppContext } from "../build/entry-template.ts";
|
|
2
2
|
import { type BuildRoot, type BuildRouteInput } from "../build/route-metadata.ts";
|
|
3
3
|
import type { BuildAppOptions } from "../build/types.ts";
|
|
4
|
+
import type { RouteInstanceSpec } from "../plugin/route-manifest.ts";
|
|
4
5
|
import type { RouteRegistrySnapshot } from "../plugin/route-registry.ts";
|
|
5
6
|
import type { RootLayout } from "../server/router/types.ts";
|
|
6
7
|
/**
|
|
@@ -20,20 +21,23 @@ export declare function buildCompileMetadata(root: BuildRoot | RootLayout, route
|
|
|
20
21
|
notFoundPath: string | undefined;
|
|
21
22
|
} | undefined;
|
|
22
23
|
routeMetadata: Record<string, {
|
|
24
|
+
layouts: Array<{
|
|
25
|
+
path: string;
|
|
26
|
+
pattern: string;
|
|
27
|
+
}>;
|
|
23
28
|
requestKeys?: string[];
|
|
24
29
|
requestKeysByLoader?: string[][];
|
|
25
30
|
segmentBoundaries: Array<{
|
|
26
31
|
depth: number;
|
|
27
32
|
path: string;
|
|
28
33
|
errorPath?: string;
|
|
34
|
+
fromRoute?: true;
|
|
29
35
|
notFoundPath?: string;
|
|
30
36
|
}>;
|
|
31
37
|
}>;
|
|
32
38
|
};
|
|
33
39
|
/** One mounted app's build input (root + routes scanned from its pagesDir). */
|
|
34
|
-
export interface RuntimeTargetApp {
|
|
35
|
-
pagesDir: string;
|
|
36
|
-
prefix: string;
|
|
40
|
+
export interface RuntimeTargetApp extends RouteInstanceSpec {
|
|
37
41
|
root: BuildRoot | RootLayout;
|
|
38
42
|
routeRegistry?: RouteRegistrySnapshot;
|
|
39
43
|
routes: BuildRouteInput[];
|
package/dist/adapter/vercel.js
CHANGED
|
@@ -29,7 +29,7 @@ function segmentSpecificity(segment) {
|
|
|
29
29
|
}
|
|
30
30
|
return segment.startsWith(":") ? 2 : 3;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function compareConcreteSpecificity(a, b) {
|
|
33
33
|
const aSegments = a.split("/").filter(Boolean);
|
|
34
34
|
const bSegments = b.split("/").filter(Boolean);
|
|
35
35
|
const length = Math.max(aSegments.length, bSegments.length);
|
|
@@ -49,6 +49,24 @@ function compareRouteSpecificity(a, b) {
|
|
|
49
49
|
}
|
|
50
50
|
return 0;
|
|
51
51
|
}
|
|
52
|
+
function expandOptionalSegments(pattern) {
|
|
53
|
+
let variants = [[]];
|
|
54
|
+
for (const segment of pattern.split("/").filter(Boolean)) {
|
|
55
|
+
if (segment.startsWith(":") && segment.endsWith("?")) {
|
|
56
|
+
const required = segment.slice(0, -1);
|
|
57
|
+
variants = variants.flatMap((variant) => [variant, [...variant, required]]);
|
|
58
|
+
} else {
|
|
59
|
+
variants = variants.map((variant) => [...variant, segment]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return variants.map((variant) => `/${variant.join("/")}`);
|
|
63
|
+
}
|
|
64
|
+
function mostSpecificVariant(pattern) {
|
|
65
|
+
return expandOptionalSegments(pattern).reduce((best, variant) => compareConcreteSpecificity(variant, best) > 0 ? variant : best);
|
|
66
|
+
}
|
|
67
|
+
function compareRouteSpecificity(a, b) {
|
|
68
|
+
return compareConcreteSpecificity(mostSpecificVariant(a), mostSpecificVariant(b));
|
|
69
|
+
}
|
|
52
70
|
|
|
53
71
|
// src/shared/prefix.ts
|
|
54
72
|
function physicalPath(prefix, path) {
|
|
@@ -58,6 +76,7 @@ function physicalPath(prefix, path) {
|
|
|
58
76
|
return path === "/" ? prefix : `${prefix}${path}`;
|
|
59
77
|
}
|
|
60
78
|
// src/server/router/patterns.ts
|
|
79
|
+
var SPLAT_PARAM = "_splat";
|
|
61
80
|
var REGEX_META_CHARS_RE = /[.*+?^${}()|[\]\\]/g;
|
|
62
81
|
function escapeRegExp(value) {
|
|
63
82
|
return value.replace(REGEX_META_CHARS_RE, "\\$&");
|
|
@@ -73,11 +92,17 @@ function routePatternRegexSource(pattern, sources) {
|
|
|
73
92
|
while (i < pattern.length && pattern[i] !== "/") {
|
|
74
93
|
i += 1;
|
|
75
94
|
}
|
|
76
|
-
|
|
77
|
-
|
|
95
|
+
const name = pattern.slice(start, i);
|
|
96
|
+
if (name.endsWith("?") && source.endsWith("/")) {
|
|
97
|
+
paramNames.push(name.slice(0, -1));
|
|
98
|
+
source = `${source.slice(0, -1)}(?:/${sources.param})?`;
|
|
99
|
+
} else {
|
|
100
|
+
paramNames.push(name);
|
|
101
|
+
source += sources.param;
|
|
102
|
+
}
|
|
78
103
|
} else if (pattern[i] === "*") {
|
|
79
|
-
paramNames.push(
|
|
80
|
-
source
|
|
104
|
+
paramNames.push(SPLAT_PARAM);
|
|
105
|
+
source = source.endsWith("/") ? `${source.slice(0, -1)}(?:/${sources.catchAll})?` : source + sources.catchAll;
|
|
81
106
|
i += 1;
|
|
82
107
|
} else {
|
|
83
108
|
const ch = pattern[i];
|
|
@@ -213,7 +238,7 @@ function functionNameForPath(path, mode, names) {
|
|
|
213
238
|
return "[...splat]";
|
|
214
239
|
}
|
|
215
240
|
if (segment.startsWith(":")) {
|
|
216
|
-
return `[${segment.slice(1)}]`;
|
|
241
|
+
return segment.endsWith("?") ? `[[${segment.slice(1, -1)}]]` : `[${segment.slice(1)}]`;
|
|
217
242
|
}
|
|
218
243
|
const sanitized = segment.replace(UNSAFE_FUNCTION_PATH_RE, "-");
|
|
219
244
|
if (sanitized === segment && segment !== "." && segment !== "..") {
|
package/dist/build/client.d.ts
CHANGED
|
@@ -25,4 +25,4 @@ export interface BuildClientResult {
|
|
|
25
25
|
* it as an SSR template, injects the pre-rendered React HTML into
|
|
26
26
|
* <!--ssr-outlet-->, and sends the complete page.
|
|
27
27
|
*/
|
|
28
|
-
export declare function buildClient(routes: BuildRouteInput[], { outDir, rootLayout, plugins, preloadRouteChunks, publicPath, basePath, clientLogging, clientDirName, metafilePath, optimizeImports, reactCompiler,
|
|
28
|
+
export declare function buildClient(routes: BuildRouteInput[], { outDir, rootLayout, plugins, preloadRouteChunks, publicPath, basePath, clientLogging, clientDirName, metafilePath, optimizeImports, reactCompiler, pages, routeRegistry, }: BuildClientOptions): Promise<BuildClientResult>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompileContextAdapter } from "../server/internal.ts";
|
|
1
|
+
import type { CompileContext, CompileContextAdapter } from "../server/internal.ts";
|
|
2
2
|
import type { ClientPreloadManifest } from "./preload-manifest.ts";
|
|
3
3
|
/** Sidecar holding the SSG documents the production bundle rendered at build time. */
|
|
4
4
|
export declare const PRERENDER_SNAPSHOT_FILE = "furin-prerender.json";
|
|
@@ -11,7 +11,7 @@ export interface EntryAppContext {
|
|
|
11
11
|
clientLogging?: boolean;
|
|
12
12
|
/** Extra lines injected inside this app's `__setCompileContext({...})` call. */
|
|
13
13
|
extraContext?: string[];
|
|
14
|
-
/** Additional route modules such as filesystem-derived
|
|
14
|
+
/** Additional route modules such as filesystem-derived layouts. */
|
|
15
15
|
modulePaths?: string[];
|
|
16
16
|
/** Virtual module specifier exporting this app's composed Elysia route tree. */
|
|
17
17
|
nativeRoutes?: string;
|
|
@@ -24,16 +24,7 @@ export interface EntryAppContext {
|
|
|
24
24
|
notFoundPath?: string;
|
|
25
25
|
};
|
|
26
26
|
rootPath: string;
|
|
27
|
-
routeMetadata?:
|
|
28
|
-
requestKeys?: string[];
|
|
29
|
-
requestKeysByLoader?: string[][];
|
|
30
|
-
segmentBoundaries: Array<{
|
|
31
|
-
depth: number;
|
|
32
|
-
path: string;
|
|
33
|
-
errorPath?: string;
|
|
34
|
-
notFoundPath?: string;
|
|
35
|
-
}>;
|
|
36
|
-
}>;
|
|
27
|
+
routeMetadata?: CompileContext["routeMetadata"];
|
|
37
28
|
routes: Array<{
|
|
38
29
|
mode: "ssr" | "ssg" | "isr";
|
|
39
30
|
path: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import type { CompileContextAdapter } from "../server/internal.ts";
|
|
4
|
+
import type { CompileContext, CompileContextAdapter } from "../server/internal.ts";
|
|
5
5
|
import type { ClientPreloadManifest } from "./preload-manifest.ts";
|
|
6
6
|
|
|
7
7
|
// import.meta.resolve() runs at runtime (not inlined at bundle time), resolves
|
|
@@ -31,7 +31,7 @@ export interface EntryAppContext {
|
|
|
31
31
|
clientLogging?: boolean;
|
|
32
32
|
/** Extra lines injected inside this app's `__setCompileContext({...})` call. */
|
|
33
33
|
extraContext?: string[];
|
|
34
|
-
/** Additional route modules such as filesystem-derived
|
|
34
|
+
/** Additional route modules such as filesystem-derived layouts. */
|
|
35
35
|
modulePaths?: string[];
|
|
36
36
|
/** Virtual module specifier exporting this app's composed Elysia route tree. */
|
|
37
37
|
nativeRoutes?: string;
|
|
@@ -41,19 +41,7 @@ export interface EntryAppContext {
|
|
|
41
41
|
preloadManifest?: ClientPreloadManifest;
|
|
42
42
|
rootConventions?: { errorPath?: string; notFoundPath?: string };
|
|
43
43
|
rootPath: string;
|
|
44
|
-
routeMetadata?:
|
|
45
|
-
string,
|
|
46
|
-
{
|
|
47
|
-
requestKeys?: string[];
|
|
48
|
-
requestKeysByLoader?: string[][];
|
|
49
|
-
segmentBoundaries: Array<{
|
|
50
|
-
depth: number;
|
|
51
|
-
path: string;
|
|
52
|
-
errorPath?: string;
|
|
53
|
-
notFoundPath?: string;
|
|
54
|
-
}>;
|
|
55
|
-
}
|
|
56
|
-
>;
|
|
44
|
+
routeMetadata?: CompileContext["routeMetadata"];
|
|
57
45
|
routes: Array<{ mode: "ssr" | "ssg" | "isr"; path: string; pattern: string }>;
|
|
58
46
|
/** In-memory production document template for filesystem-free runtimes. */
|
|
59
47
|
templateHtml?: string;
|
package/dist/build/hydrate.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RouteStyle } from "../plugin/route-manifest.ts";
|
|
1
2
|
import type { ResolvedRoute } from "../server/router/types.ts";
|
|
2
3
|
import { type BuildRouteInput } from "./route-metadata.ts";
|
|
3
4
|
import type { ClientBoundary } from "../rsc/build/discover.ts";
|
|
@@ -33,6 +34,10 @@ export declare function releaseDevRouteTypes(projectRoot: string, prefix: string
|
|
|
33
34
|
* Only rewrites a file when its content has actually changed so Bun's --hot
|
|
34
35
|
* watcher does not trigger a spurious reload on every server restart.
|
|
35
36
|
*/
|
|
36
|
-
export declare function writeDevFiles(routes: ResolvedRoute[], { outDir, rootLayout, basePath, clientLogging, clientBoundaries, prefix, }: BuildClientOptions & {
|
|
37
|
+
export declare function writeDevFiles(routes: ResolvedRoute[], { outDir, rootLayout, basePath, clientLogging, clientBoundaries, pages, prefix, }: BuildClientOptions & {
|
|
38
|
+
pages: {
|
|
39
|
+
pagesDir: string;
|
|
40
|
+
style: RouteStyle;
|
|
41
|
+
};
|
|
37
42
|
prefix: string;
|
|
38
43
|
}, projectRoot: string, serverSourceVersion?: string): void;
|
package/dist/build/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { buildClient } from "./client";
|
|
|
3
3
|
export { writeRouteTypes } from "./route-types";
|
|
4
4
|
export type { BuildAppOptions, BuildAppResult, BuildClientOptions, BuildManifest, BuildRouteManifestEntry, TargetBuildManifest, VercelTargetBuildManifest, } from "./types";
|
|
5
5
|
/** Options for `generateRouteTypes()`, a subset of the build options. */
|
|
6
|
-
export type RouteTypegenOptions = Pick<BuildAppOptions, "apps" | "
|
|
6
|
+
export type RouteTypegenOptions = Pick<BuildAppOptions, "apps" | "plugins" | "rootDir" | "serverEntry">;
|
|
7
7
|
/**
|
|
8
8
|
* Writes `furin-env.d.ts` for every mounted app without building, e.g.
|
|
9
9
|
* before `tsc` in CI.
|