@teyik0/furin 0.2.0-alpha.3 → 0.2.0-alpha.4

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.
Files changed (54) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +37 -33
  3. package/dist/build/compile-entry.ts +109 -109
  4. package/dist/build/entry-template.ts +156 -156
  5. package/dist/build/server-routes-entry.ts +36 -36
  6. package/dist/cli/index.js +0 -0
  7. package/dist/client/link.js +163 -16
  8. package/dist/client/router/abort.d.ts +1 -0
  9. package/dist/client/router/sync-catch-up.d.ts +29 -0
  10. package/dist/furin.d.ts +1 -1
  11. package/dist/furin.js +499 -215
  12. package/dist/server/sync/adapter.d.ts +62 -0
  13. package/dist/server/sync/fingerprint.d.ts +6 -0
  14. package/dist/server/sync/index.d.ts +2 -2
  15. package/dist/server/sync/memory-adapter.d.ts +17 -0
  16. package/dist/server/sync/plugin.d.ts +12 -195
  17. package/dist/server/sync/response.d.ts +4 -0
  18. package/dist/server/sync/stream.d.ts +16 -4
  19. package/package.json +1 -1
  20. package/src/adapter/README.md +13 -13
  21. package/src/build/client.ts +152 -152
  22. package/src/build/compile-entry.ts +109 -109
  23. package/src/build/entry-template.ts +156 -156
  24. package/src/build/hydrate.ts +340 -340
  25. package/src/build/index.ts +152 -152
  26. package/src/build/route-types.ts +145 -145
  27. package/src/build/scan-server.ts +95 -95
  28. package/src/build/server-routes-entry.ts +36 -36
  29. package/src/build/shared.ts +80 -80
  30. package/src/build/ssg-cache.ts +32 -32
  31. package/src/build/types.ts +89 -89
  32. package/src/client/router/abort.ts +5 -0
  33. package/src/client/router/link-utils.ts +184 -184
  34. package/src/client/router/provider.tsx +883 -804
  35. package/src/client/router/sync-catch-up.ts +113 -0
  36. package/src/client/router/types.ts +276 -276
  37. package/src/client/sync.ts +98 -98
  38. package/src/client.ts +369 -369
  39. package/src/furin.ts +465 -465
  40. package/src/server/auto-invalidate/runtime.ts +134 -134
  41. package/src/server/dev-page-plugin.ts +454 -454
  42. package/src/server/render/assemble.ts +160 -160
  43. package/src/server/render/isr.ts +323 -323
  44. package/src/server/render/ssr.ts +591 -585
  45. package/src/server/router/plugin.ts +384 -384
  46. package/src/server/sync/adapter.ts +65 -0
  47. package/src/server/sync/config.ts +29 -29
  48. package/src/server/sync/fingerprint.ts +44 -0
  49. package/src/server/sync/index.ts +15 -14
  50. package/src/server/sync/memory-adapter.ts +196 -0
  51. package/src/server/sync/plugin.ts +200 -108
  52. package/src/server/sync/response.ts +77 -0
  53. package/src/server/sync/stream.ts +152 -144
  54. package/src/shared/deferred-ndjson.ts +7 -0
@@ -1,95 +1,95 @@
1
- import { readFileSync } from "node:fs";
2
- import { parse, type CallExpression, type ObjectExpression, type ObjectProperty } from "yuku-parser";
3
- import { detectLangFromPath, unwrapTSExpression } from "../server/lang-detect.ts";
4
- import { walkAST } from "../shared/utils/ast-walk.ts";
5
-
6
- /**
7
- * Statically scans a server entry file and returns all `pagesDir` string
8
- * literal values found inside `furin({ pagesDir: "..." })` call expressions.
9
- *
10
- * Dynamic paths (template literals, variables) are silently ignored.
11
- * Returns an empty array when nothing is detected.
12
- */
13
- export function scanFurinInstances(serverEntryPath: string): string[] {
14
- const code = readFileSync(serverEntryPath, "utf8");
15
- const lang = detectLangFromPath(serverEntryPath);
16
-
17
- // Declaration files contain no runtime code — skip parsing.
18
- if (lang === "dts") {
19
- return [];
20
- }
21
-
22
- const { program, diagnostics } = parse(code, { sourceType: "module", lang });
23
- const firstError = diagnostics.find((d) => d.severity === "error");
24
- if (firstError) {
25
- console.error("[furin] scan-server: parse error:", firstError.message, "in", serverEntryPath);
26
- return [];
27
- }
28
-
29
- const results: string[] = [];
30
- walkAST(program, (node) => {
31
- if (node.type === "CallExpression") {
32
- checkFurinCall(node as unknown as CallExpression, results);
33
- }
34
- });
35
- return results;
36
- }
37
-
38
- /** Checks whether `node` is a `furin({ pagesDir: "..." })` call and, if so, pushes the value. */
39
- function checkFurinCall(node: CallExpression, out: string[]): void {
40
- const isFurinCall = node.callee.type === "Identifier" && node.callee.name === "furin";
41
-
42
- if (!isFurinCall || node.arguments.length === 0) {
43
- return;
44
- }
45
-
46
- // Unwrap TS expression wrappers like `furin({...} as Config)` or
47
- // `furin({...} satisfies Options)` so we still see the ObjectExpression.
48
- const firstArgNode = node.arguments[0];
49
- if (!firstArgNode) {
50
- return;
51
- }
52
- const firstArg = unwrapTSExpression(firstArgNode);
53
- if (!isObjectExpressionNode(firstArg)) {
54
- return;
55
- }
56
-
57
- const pagesDir = extractStringProperty(firstArg, "pagesDir");
58
- if (pagesDir !== null) {
59
- out.push(pagesDir);
60
- }
61
- }
62
-
63
- function isObjectExpressionNode(node: { type: string }): node is ObjectExpression {
64
- return node.type === "ObjectExpression";
65
- }
66
-
67
- function extractStringProperty(obj: ObjectExpression, propName: string): string | null {
68
- for (const prop of obj.properties) {
69
- if (prop.type !== "Property") {
70
- continue;
71
- }
72
- const value = getStringPropertyValue(prop, propName);
73
-
74
- if (value !== undefined) {
75
- return value;
76
- }
77
- }
78
- return null;
79
- }
80
-
81
- function getStringPropertyValue(prop: ObjectProperty, propName: string): string | null | undefined {
82
- const keyMatches =
83
- (prop.key.type === "Identifier" && prop.key.name === propName) ||
84
- (prop.key.type === "Literal" && prop.key.value === propName);
85
-
86
- if (!keyMatches) {
87
- return undefined;
88
- }
89
-
90
- // Only accept string literals — ignore template literals, identifiers, etc.
91
- if (prop.value.type === "Literal" && typeof prop.value.value === "string") {
92
- return prop.value.value;
93
- }
94
- return null; // dynamic path — silently skip
95
- }
1
+ import { readFileSync } from "node:fs";
2
+ import { parse, type CallExpression, type ObjectExpression, type ObjectProperty } from "yuku-parser";
3
+ import { detectLangFromPath, unwrapTSExpression } from "../server/lang-detect.ts";
4
+ import { walkAST } from "../shared/utils/ast-walk.ts";
5
+
6
+ /**
7
+ * Statically scans a server entry file and returns all `pagesDir` string
8
+ * literal values found inside `furin({ pagesDir: "..." })` call expressions.
9
+ *
10
+ * Dynamic paths (template literals, variables) are silently ignored.
11
+ * Returns an empty array when nothing is detected.
12
+ */
13
+ export function scanFurinInstances(serverEntryPath: string): string[] {
14
+ const code = readFileSync(serverEntryPath, "utf8");
15
+ const lang = detectLangFromPath(serverEntryPath);
16
+
17
+ // Declaration files contain no runtime code — skip parsing.
18
+ if (lang === "dts") {
19
+ return [];
20
+ }
21
+
22
+ const { program, diagnostics } = parse(code, { sourceType: "module", lang });
23
+ const firstError = diagnostics.find((d) => d.severity === "error");
24
+ if (firstError) {
25
+ console.error("[furin] scan-server: parse error:", firstError.message, "in", serverEntryPath);
26
+ return [];
27
+ }
28
+
29
+ const results: string[] = [];
30
+ walkAST(program, (node) => {
31
+ if (node.type === "CallExpression") {
32
+ checkFurinCall(node as unknown as CallExpression, results);
33
+ }
34
+ });
35
+ return results;
36
+ }
37
+
38
+ /** Checks whether `node` is a `furin({ pagesDir: "..." })` call and, if so, pushes the value. */
39
+ function checkFurinCall(node: CallExpression, out: string[]): void {
40
+ const isFurinCall = node.callee.type === "Identifier" && node.callee.name === "furin";
41
+
42
+ if (!isFurinCall || node.arguments.length === 0) {
43
+ return;
44
+ }
45
+
46
+ // Unwrap TS expression wrappers like `furin({...} as Config)` or
47
+ // `furin({...} satisfies Options)` so we still see the ObjectExpression.
48
+ const firstArgNode = node.arguments[0];
49
+ if (!firstArgNode) {
50
+ return;
51
+ }
52
+ const firstArg = unwrapTSExpression(firstArgNode);
53
+ if (!isObjectExpressionNode(firstArg)) {
54
+ return;
55
+ }
56
+
57
+ const pagesDir = extractStringProperty(firstArg, "pagesDir");
58
+ if (pagesDir !== null) {
59
+ out.push(pagesDir);
60
+ }
61
+ }
62
+
63
+ function isObjectExpressionNode(node: { type: string }): node is ObjectExpression {
64
+ return node.type === "ObjectExpression";
65
+ }
66
+
67
+ function extractStringProperty(obj: ObjectExpression, propName: string): string | null {
68
+ for (const prop of obj.properties) {
69
+ if (prop.type !== "Property") {
70
+ continue;
71
+ }
72
+ const value = getStringPropertyValue(prop, propName);
73
+
74
+ if (value !== undefined) {
75
+ return value;
76
+ }
77
+ }
78
+ return null;
79
+ }
80
+
81
+ function getStringPropertyValue(prop: ObjectProperty, propName: string): string | null | undefined {
82
+ const keyMatches =
83
+ (prop.key.type === "Identifier" && prop.key.name === propName) ||
84
+ (prop.key.type === "Literal" && prop.key.value === propName);
85
+
86
+ if (!keyMatches) {
87
+ return undefined;
88
+ }
89
+
90
+ // Only accept string literals — ignore template literals, identifiers, etc.
91
+ if (prop.value.type === "Literal" && typeof prop.value.value === "string") {
92
+ return prop.value.value;
93
+ }
94
+ return null; // dynamic path — silently skip
95
+ }
@@ -1,36 +1,36 @@
1
- import { writeFileSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { buildEntrySource, type BuildEntryOptions } from "./entry-template";
4
- import { ensureDir } from "./shared";
5
-
6
- /**
7
- * Generates `server.ts` — an intermediate entry used to produce `server.js`.
8
- *
9
- * Equivalent to `_compile-entry.ts` but for disk (non-binary) production builds:
10
- * 1. Statically imports every page module so Bun bundles them into server.js
11
- * 2. Sets production mode and registers everything in a single CompileContext
12
- * 3. Imports server.ts to boot the app
13
- *
14
- * This file is intermediate: `adapter/bun.ts` runs `Bun.build()` on it to produce
15
- * the self-contained `server.js` bundle, then deletes this file.
16
- */
17
- export function generateServerRoutesEntry(options: BuildEntryOptions): string {
18
- const { buildId, outDir, rootPath, routes, serverEntry, rootConventions, routeMetadata, ssgCache } =
19
- options;
20
- ensureDir(outDir);
21
- const source = buildEntrySource({
22
- buildId,
23
- headerComment: "// Auto-generated by furin build — do not edit",
24
- rootPath,
25
- routes,
26
- serverEntry,
27
- rootConventions,
28
- routeMetadata,
29
- ssgCache,
30
- });
31
-
32
- // Named "server.ts" so Bun.build() outputs "server.js"
33
- const entryPath = join(outDir, "server.ts");
34
- writeFileSync(entryPath, source);
35
- return entryPath;
36
- }
1
+ import { writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { buildEntrySource, type BuildEntryOptions } from "./entry-template";
4
+ import { ensureDir } from "./shared";
5
+
6
+ /**
7
+ * Generates `server.ts` — an intermediate entry used to produce `server.js`.
8
+ *
9
+ * Equivalent to `_compile-entry.ts` but for disk (non-binary) production builds:
10
+ * 1. Statically imports every page module so Bun bundles them into server.js
11
+ * 2. Sets production mode and registers everything in a single CompileContext
12
+ * 3. Imports server.ts to boot the app
13
+ *
14
+ * This file is intermediate: `adapter/bun.ts` runs `Bun.build()` on it to produce
15
+ * the self-contained `server.js` bundle, then deletes this file.
16
+ */
17
+ export function generateServerRoutesEntry(options: BuildEntryOptions): string {
18
+ const { buildId, outDir, rootPath, routes, serverEntry, rootConventions, routeMetadata, ssgCache } =
19
+ options;
20
+ ensureDir(outDir);
21
+ const source = buildEntrySource({
22
+ buildId,
23
+ headerComment: "// Auto-generated by furin build — do not edit",
24
+ rootPath,
25
+ routes,
26
+ serverEntry,
27
+ rootConventions,
28
+ routeMetadata,
29
+ ssgCache,
30
+ });
31
+
32
+ // Named "server.ts" so Bun.build() outputs "server.js"
33
+ const entryPath = join(outDir, "server.ts");
34
+ writeFileSync(entryPath, source);
35
+ return entryPath;
36
+ }
@@ -1,80 +1,80 @@
1
- import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
2
- import { join, relative } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import type { BuildTarget } from "../config";
5
- import type { ResolvedRoute } from "../server/router/index.ts";
6
- import type { BuildRouteManifestEntry, TargetBuildManifest } from "./types";
7
-
8
- // import.meta.dir/path/url are inlined at bundle time to the OUTPUT file's
9
- // location — so relative paths break when bundled. import.meta.resolve() is a
10
- // function call (not inlined), runs at runtime, and resolves through package
11
- // exports. This is the Web-standard approach (Bun, Node 20.6+, browsers).
12
- export const CLIENT_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/client"));
13
- export const LINK_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/link"));
14
- export const SEARCH_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/search"));
15
-
16
- export function ensureDir(path: string): void {
17
- if (!existsSync(path)) {
18
- mkdirSync(path, { recursive: true });
19
- }
20
- }
21
-
22
- export function toPosixPath(path: string): string {
23
- return path.replace(/\\/g, "/");
24
- }
25
-
26
- export function collectFilesRecursive(dir: string): string[] {
27
- const files: string[] = [];
28
- const entries = readdirSync(dir, { withFileTypes: true });
29
-
30
- for (const entry of entries) {
31
- const absolutePath = join(dir, entry.name);
32
- if (entry.isDirectory()) {
33
- files.push(...collectFilesRecursive(absolutePath));
34
- continue;
35
- }
36
- if (entry.isFile()) {
37
- files.push(absolutePath);
38
- }
39
- }
40
-
41
- return files.sort();
42
- }
43
-
44
- export function copyDirRecursive(sourceDir: string, targetDir: string): void {
45
- rmSync(targetDir, { force: true, recursive: true });
46
- cpSync(sourceDir, targetDir, { recursive: true });
47
- }
48
-
49
- export function toBuildRouteManifestEntry(
50
- route: ResolvedRoute,
51
- rootDir: string
52
- ): BuildRouteManifestEntry {
53
- return {
54
- pattern: route.pattern,
55
- mode: route.mode,
56
- pagePath: toPosixPath(relative(rootDir, route.path)),
57
- hasLayout: route.routeChain.some((entry) => !!entry.layout),
58
- hasStaticParams: !!route.page?.staticParams,
59
- revalidate: route.page?._route.revalidate ?? null,
60
- };
61
- }
62
-
63
- export function buildTargetManifest(
64
- rootDir: string,
65
- buildRoot: string,
66
- target: BuildTarget,
67
- serverEntry: string | null
68
- ): TargetBuildManifest {
69
- const targetDir = join(buildRoot, target);
70
-
71
- return {
72
- buildId: "", // populated by adapter after buildClient() completes
73
- generatedAt: new Date().toISOString(),
74
- targetDir: toPosixPath(relative(rootDir, targetDir)),
75
- clientDir: toPosixPath(relative(rootDir, join(targetDir, "client"))),
76
- templatePath: toPosixPath(relative(rootDir, join(targetDir, "client", "index.html"))),
77
- serverPath: null,
78
- serverEntry: serverEntry ? toPosixPath(relative(rootDir, serverEntry)) : null,
79
- };
80
- }
1
+ import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
2
+ import { join, relative } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import type { BuildTarget } from "../config";
5
+ import type { ResolvedRoute } from "../server/router/index.ts";
6
+ import type { BuildRouteManifestEntry, TargetBuildManifest } from "./types";
7
+
8
+ // import.meta.dir/path/url are inlined at bundle time to the OUTPUT file's
9
+ // location — so relative paths break when bundled. import.meta.resolve() is a
10
+ // function call (not inlined), runs at runtime, and resolves through package
11
+ // exports. This is the Web-standard approach (Bun, Node 20.6+, browsers).
12
+ export const CLIENT_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/client"));
13
+ export const LINK_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/link"));
14
+ export const SEARCH_MODULE_PATH = fileURLToPath(import.meta.resolve("@teyik0/furin/search"));
15
+
16
+ export function ensureDir(path: string): void {
17
+ if (!existsSync(path)) {
18
+ mkdirSync(path, { recursive: true });
19
+ }
20
+ }
21
+
22
+ export function toPosixPath(path: string): string {
23
+ return path.replace(/\\/g, "/");
24
+ }
25
+
26
+ export function collectFilesRecursive(dir: string): string[] {
27
+ const files: string[] = [];
28
+ const entries = readdirSync(dir, { withFileTypes: true });
29
+
30
+ for (const entry of entries) {
31
+ const absolutePath = join(dir, entry.name);
32
+ if (entry.isDirectory()) {
33
+ files.push(...collectFilesRecursive(absolutePath));
34
+ continue;
35
+ }
36
+ if (entry.isFile()) {
37
+ files.push(absolutePath);
38
+ }
39
+ }
40
+
41
+ return files.sort();
42
+ }
43
+
44
+ export function copyDirRecursive(sourceDir: string, targetDir: string): void {
45
+ rmSync(targetDir, { force: true, recursive: true });
46
+ cpSync(sourceDir, targetDir, { recursive: true });
47
+ }
48
+
49
+ export function toBuildRouteManifestEntry(
50
+ route: ResolvedRoute,
51
+ rootDir: string
52
+ ): BuildRouteManifestEntry {
53
+ return {
54
+ pattern: route.pattern,
55
+ mode: route.mode,
56
+ pagePath: toPosixPath(relative(rootDir, route.path)),
57
+ hasLayout: route.routeChain.some((entry) => !!entry.layout),
58
+ hasStaticParams: !!route.page?.staticParams,
59
+ revalidate: route.page?._route.revalidate ?? null,
60
+ };
61
+ }
62
+
63
+ export function buildTargetManifest(
64
+ rootDir: string,
65
+ buildRoot: string,
66
+ target: BuildTarget,
67
+ serverEntry: string | null
68
+ ): TargetBuildManifest {
69
+ const targetDir = join(buildRoot, target);
70
+
71
+ return {
72
+ buildId: "", // populated by adapter after buildClient() completes
73
+ generatedAt: new Date().toISOString(),
74
+ targetDir: toPosixPath(relative(rootDir, targetDir)),
75
+ clientDir: toPosixPath(relative(rootDir, join(targetDir, "client"))),
76
+ templatePath: toPosixPath(relative(rootDir, join(targetDir, "client", "index.html"))),
77
+ serverPath: null,
78
+ serverEntry: serverEntry ? toPosixPath(relative(rootDir, serverEntry)) : null,
79
+ };
80
+ }
@@ -1,32 +1,32 @@
1
- import type { SsgCacheEntry } from "../server/cache/index.ts";
2
- import { prerenderSSG } from "../server/render/index.ts";
3
- import { createSearchRouteMetadata, type ResolvedRoute, type RootLayout } from "../server/router/index.ts";
4
- import { resolvePath } from "../server/render/assemble.ts";
5
-
6
- export type SSGCacheSnapshot = Record<string, SsgCacheEntry>;
7
-
8
- export async function buildSSGCacheSnapshot(
9
- routes: ResolvedRoute[],
10
- root: RootLayout,
11
- origin: string
12
- ): Promise<SSGCacheSnapshot> {
13
- const snapshot: SSGCacheSnapshot = {};
14
- const searchRoutes = createSearchRouteMetadata(routes);
15
-
16
- for (const route of routes) {
17
- if (route.mode !== "ssg" || !route.page.staticParams) {
18
- continue;
19
- }
20
-
21
- const paramSets = await route.page.staticParams();
22
- for (const params of paramSets) {
23
- const entry = await prerenderSSG(route, params, root, origin, undefined, searchRoutes);
24
- if (entry instanceof Response) {
25
- continue;
26
- }
27
- snapshot[resolvePath(route.pattern, params)] = entry;
28
- }
29
- }
30
-
31
- return snapshot;
32
- }
1
+ import type { SsgCacheEntry } from "../server/cache/index.ts";
2
+ import { prerenderSSG } from "../server/render/index.ts";
3
+ import { createSearchRouteMetadata, type ResolvedRoute, type RootLayout } from "../server/router/index.ts";
4
+ import { resolvePath } from "../server/render/assemble.ts";
5
+
6
+ export type SSGCacheSnapshot = Record<string, SsgCacheEntry>;
7
+
8
+ export async function buildSSGCacheSnapshot(
9
+ routes: ResolvedRoute[],
10
+ root: RootLayout,
11
+ origin: string
12
+ ): Promise<SSGCacheSnapshot> {
13
+ const snapshot: SSGCacheSnapshot = {};
14
+ const searchRoutes = createSearchRouteMetadata(routes);
15
+
16
+ for (const route of routes) {
17
+ if (route.mode !== "ssg" || !route.page.staticParams) {
18
+ continue;
19
+ }
20
+
21
+ const paramSets = await route.page.staticParams();
22
+ for (const params of paramSets) {
23
+ const entry = await prerenderSSG(route, params, root, origin, undefined, searchRoutes);
24
+ if (entry instanceof Response) {
25
+ continue;
26
+ }
27
+ snapshot[resolvePath(route.pattern, params)] = entry;
28
+ }
29
+ }
30
+
31
+ return snapshot;
32
+ }
@@ -1,89 +1,89 @@
1
- import type { BuildTarget, StaticExportConfig } from "../config";
2
- import type { ResolvedRoute } from "../server/router/index.ts";
3
-
4
- export interface BuildClientOptions {
5
- /**
6
- * Sub-path prefix for the deployment (e.g. "/furin" for GitHub Pages).
7
- * Passed through to the generated hydrate entry so SPA navigation uses
8
- * correct physical URLs. Pass "" for root deployments.
9
- */
10
- basePath: string;
11
- /** Inject the evlog client logger into the hydrate entry. Off by default. */
12
- clientLogging: boolean;
13
- outDir: string;
14
- pagesDir?: string;
15
- plugins?: Bun.BunPlugin[];
16
- /**
17
- * Public path prefix for all emitted JS/CSS chunks.
18
- * Pass "/_client/" for root deployments; override for basePath deployments,
19
- * e.g. "/furin/_client/".
20
- */
21
- publicPath: string;
22
- rootLayout: string;
23
- }
24
-
25
- export interface BuildRouteManifestEntry {
26
- hasLayout: boolean;
27
- hasStaticParams: boolean;
28
- mode: ResolvedRoute["mode"];
29
- pagePath: string;
30
- pattern: string;
31
- revalidate: number | null;
32
- }
33
-
34
- export interface TargetBuildManifest {
35
- buildId: string;
36
- clientDir: string | null;
37
- generatedAt: string;
38
- serverEntry: string | null;
39
- serverPath: string | null;
40
- targetDir: string;
41
- templatePath: string | null;
42
- }
43
-
44
- export type AnyTargetManifest = TargetBuildManifest | StaticTargetBuildManifest;
45
-
46
- export interface BuildManifest {
47
- generatedAt: string;
48
- pagesDir: string;
49
- rootDir: string;
50
- rootPath: string;
51
- routes: BuildRouteManifestEntry[];
52
- serverEntry: string | null;
53
- targets: Partial<Record<BuildTarget, AnyTargetManifest>>;
54
- version: 1;
55
- }
56
-
57
- export interface BuildAppOptions {
58
- /** Inject the evlog client logger into the hydrate entry. Defaults to false. */
59
- clientLogging?: boolean;
60
- compile?: "server" | "embed";
61
- pagesDir?: string;
62
- plugins?: Bun.BunPlugin[];
63
- rootDir?: string;
64
- serverEntry?: string;
65
- /** Configuration for the `static` build target. */
66
- staticConfig?: StaticExportConfig;
67
- target: BuildTarget | "all";
68
- }
69
-
70
- /** Build manifest entry produced by the `static` adapter. */
71
- export interface StaticTargetBuildManifest {
72
- basePath: string;
73
- generatedAt: string;
74
- outDir: string;
75
- renderedRoutes: string[];
76
- skippedRoutes: string[];
77
- }
78
-
79
- export interface BuildAppResult {
80
- manifest: BuildManifest;
81
- targets: Partial<Record<BuildTarget, AnyTargetManifest>>;
82
- }
83
-
84
- export type BunBuildAliasConfig = Bun.BuildConfig & {
85
- alias?: Record<string, string>;
86
- outfile?: string;
87
- packages?: "bundle" | "external";
88
- write?: boolean;
89
- };
1
+ import type { BuildTarget, StaticExportConfig } from "../config";
2
+ import type { ResolvedRoute } from "../server/router/index.ts";
3
+
4
+ export interface BuildClientOptions {
5
+ /**
6
+ * Sub-path prefix for the deployment (e.g. "/furin" for GitHub Pages).
7
+ * Passed through to the generated hydrate entry so SPA navigation uses
8
+ * correct physical URLs. Pass "" for root deployments.
9
+ */
10
+ basePath: string;
11
+ /** Inject the evlog client logger into the hydrate entry. Off by default. */
12
+ clientLogging: boolean;
13
+ outDir: string;
14
+ pagesDir?: string;
15
+ plugins?: Bun.BunPlugin[];
16
+ /**
17
+ * Public path prefix for all emitted JS/CSS chunks.
18
+ * Pass "/_client/" for root deployments; override for basePath deployments,
19
+ * e.g. "/furin/_client/".
20
+ */
21
+ publicPath: string;
22
+ rootLayout: string;
23
+ }
24
+
25
+ export interface BuildRouteManifestEntry {
26
+ hasLayout: boolean;
27
+ hasStaticParams: boolean;
28
+ mode: ResolvedRoute["mode"];
29
+ pagePath: string;
30
+ pattern: string;
31
+ revalidate: number | null;
32
+ }
33
+
34
+ export interface TargetBuildManifest {
35
+ buildId: string;
36
+ clientDir: string | null;
37
+ generatedAt: string;
38
+ serverEntry: string | null;
39
+ serverPath: string | null;
40
+ targetDir: string;
41
+ templatePath: string | null;
42
+ }
43
+
44
+ export type AnyTargetManifest = TargetBuildManifest | StaticTargetBuildManifest;
45
+
46
+ export interface BuildManifest {
47
+ generatedAt: string;
48
+ pagesDir: string;
49
+ rootDir: string;
50
+ rootPath: string;
51
+ routes: BuildRouteManifestEntry[];
52
+ serverEntry: string | null;
53
+ targets: Partial<Record<BuildTarget, AnyTargetManifest>>;
54
+ version: 1;
55
+ }
56
+
57
+ export interface BuildAppOptions {
58
+ /** Inject the evlog client logger into the hydrate entry. Defaults to false. */
59
+ clientLogging?: boolean;
60
+ compile?: "server" | "embed";
61
+ pagesDir?: string;
62
+ plugins?: Bun.BunPlugin[];
63
+ rootDir?: string;
64
+ serverEntry?: string;
65
+ /** Configuration for the `static` build target. */
66
+ staticConfig?: StaticExportConfig;
67
+ target: BuildTarget | "all";
68
+ }
69
+
70
+ /** Build manifest entry produced by the `static` adapter. */
71
+ export interface StaticTargetBuildManifest {
72
+ basePath: string;
73
+ generatedAt: string;
74
+ outDir: string;
75
+ renderedRoutes: string[];
76
+ skippedRoutes: string[];
77
+ }
78
+
79
+ export interface BuildAppResult {
80
+ manifest: BuildManifest;
81
+ targets: Partial<Record<BuildTarget, AnyTargetManifest>>;
82
+ }
83
+
84
+ export type BunBuildAliasConfig = Bun.BuildConfig & {
85
+ alias?: Record<string, string>;
86
+ outfile?: string;
87
+ packages?: "bundle" | "external";
88
+ write?: boolean;
89
+ };