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

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 (132) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +33 -33
  3. package/dist/adapter/bun.d.ts +3 -0
  4. package/dist/adapter/static.d.ts +3 -0
  5. package/dist/build/client.d.ts +25 -0
  6. package/dist/build/compile-entry.d.ts +9 -0
  7. package/dist/build/compile-entry.ts +109 -0
  8. package/dist/build/entry-template.d.ts +38 -0
  9. package/dist/build/entry-template.ts +156 -0
  10. package/dist/build/hydrate.d.ts +24 -0
  11. package/dist/build/index.d.ts +8 -0
  12. package/dist/build/index.js +8106 -0
  13. package/dist/build/route-types.d.ts +23 -0
  14. package/dist/build/scan-server.d.ts +8 -0
  15. package/dist/build/server-routes-entry.d.ts +13 -0
  16. package/dist/build/server-routes-entry.ts +36 -0
  17. package/dist/build/shared.d.ts +12 -0
  18. package/dist/build/ssg-cache.d.ts +4 -0
  19. package/dist/build/types.d.ts +80 -0
  20. package/dist/cli/config.d.ts +9 -0
  21. package/dist/cli/index.d.ts +2 -0
  22. package/dist/cli/index.js +8097 -0
  23. package/dist/client/boundaries.d.ts +117 -0
  24. package/dist/client/default-screens.d.ts +17 -0
  25. package/dist/client/link.d.ts +22 -0
  26. package/dist/client/link.js +4244 -0
  27. package/dist/client/router/boundary-tree.d.ts +26 -0
  28. package/dist/client/router/context.d.ts +8 -0
  29. package/dist/client/router/history.d.ts +9 -0
  30. package/dist/client/router/index.d.ts +11 -0
  31. package/dist/client/router/link-utils.d.ts +53 -0
  32. package/dist/client/router/navigation.d.ts +10 -0
  33. package/dist/client/router/provider.d.ts +4 -0
  34. package/dist/client/router/search/index.d.ts +18 -0
  35. package/dist/client/router/search-store.d.ts +21 -0
  36. package/dist/client/router/spa-response.d.ts +58 -0
  37. package/dist/client/router/types.d.ts +292 -0
  38. package/dist/client/server-error.d.ts +12 -0
  39. package/dist/client/sync.d.ts +25 -0
  40. package/dist/client.d.ts +243 -0
  41. package/dist/client.js +140 -0
  42. package/dist/config.d.ts +57 -0
  43. package/dist/config.js +29 -0
  44. package/dist/env.d.ts +50 -0
  45. package/dist/furin.d.ts +77 -0
  46. package/dist/furin.js +8693 -0
  47. package/dist/plugin/index.d.ts +20 -0
  48. package/dist/plugin/index.js +1500 -0
  49. package/dist/plugin/transform-client.d.ts +10 -0
  50. package/dist/server/auto-invalidate/index.d.ts +4 -0
  51. package/dist/server/auto-invalidate/plugin.d.ts +38 -0
  52. package/dist/server/auto-invalidate/registry.d.ts +9 -0
  53. package/dist/server/auto-invalidate/runtime.d.ts +9 -0
  54. package/dist/server/auto-invalidate/types.d.ts +12 -0
  55. package/dist/server/cache/dev-loader.d.ts +28 -0
  56. package/dist/server/cache/index.d.ts +10 -0
  57. package/dist/server/cache/invalidation.d.ts +12 -0
  58. package/dist/server/cache/isr-ssg.d.ts +26 -0
  59. package/dist/server/cache/isr.d.ts +6 -0
  60. package/dist/server/cache/registry.d.ts +5 -0
  61. package/dist/server/cache/route-cache.d.ts +26 -0
  62. package/dist/server/cache/ssg.d.ts +5 -0
  63. package/dist/server/context-logger.d.ts +28 -0
  64. package/dist/server/dev-inspector.d.ts +89 -0
  65. package/dist/server/dev-page-plugin.d.ts +112 -0
  66. package/dist/server/internal.d.ts +35 -0
  67. package/dist/server/internal.js +17 -0
  68. package/dist/server/lang-detect.d.ts +5 -0
  69. package/dist/server/render/assemble.d.ts +49 -0
  70. package/dist/server/render/element.d.ts +24 -0
  71. package/dist/server/render/index.d.ts +7 -0
  72. package/dist/server/render/index.ts +22 -0
  73. package/dist/server/render/isr.d.ts +4 -0
  74. package/dist/server/render/loaders.d.ts +64 -0
  75. package/dist/server/render/not-found.d.ts +6 -0
  76. package/dist/server/render/shell.d.ts +39 -0
  77. package/dist/server/render/shell.ts +202 -0
  78. package/dist/server/render/ssg.d.ts +9 -0
  79. package/dist/server/render/ssr.d.ts +108 -0
  80. package/dist/server/render/template.d.ts +6 -0
  81. package/dist/server/router/discovery.d.ts +16 -0
  82. package/dist/server/router/hmr.d.ts +65 -0
  83. package/dist/server/router/index.d.ts +6 -0
  84. package/dist/server/router/index.js +27 -0
  85. package/dist/server/router/index.ts +28 -0
  86. package/dist/server/router/patterns.d.ts +40 -0
  87. package/dist/server/router/plugin.d.ts +21 -0
  88. package/dist/server/router/schemas.d.ts +59 -0
  89. package/dist/server/router/types.d.ts +60 -0
  90. package/dist/server/runtime-env.d.ts +3 -0
  91. package/dist/server/runtime-env.js +10 -0
  92. package/dist/server/sync/config.d.ts +6 -0
  93. package/dist/server/sync/index.d.ts +4 -0
  94. package/dist/server/sync/plugin.d.ts +369 -0
  95. package/dist/server/sync/stream.d.ts +47 -0
  96. package/dist/shared/await.d.ts +67 -0
  97. package/dist/shared/deferred-ndjson.d.ts +32 -0
  98. package/dist/shared/digest.d.ts +16 -0
  99. package/dist/shared/error.d.ts +37 -0
  100. package/dist/shared/not-found.d.ts +19 -0
  101. package/dist/shared/search-params.d.ts +17 -0
  102. package/dist/shared/utils/ast-walk.d.ts +18 -0
  103. package/dist/shared/utils/index.d.ts +13 -0
  104. package/package.json +5 -5
  105. package/src/adapter/README.md +13 -13
  106. package/src/build/client.ts +152 -152
  107. package/src/build/compile-entry.ts +109 -109
  108. package/src/build/entry-template.ts +156 -156
  109. package/src/build/hydrate.ts +340 -337
  110. package/src/build/index.ts +152 -152
  111. package/src/build/route-types.ts +145 -145
  112. package/src/build/scan-server.ts +95 -95
  113. package/src/build/server-routes-entry.ts +36 -36
  114. package/src/build/shared.ts +80 -79
  115. package/src/build/ssg-cache.ts +32 -32
  116. package/src/build/types.ts +89 -89
  117. package/src/client/router/link-utils.ts +184 -177
  118. package/src/client/router/provider.tsx +804 -759
  119. package/src/client/router/types.ts +276 -271
  120. package/src/client/sync.ts +98 -0
  121. package/src/client.ts +369 -355
  122. package/src/furin.ts +465 -444
  123. package/src/server/auto-invalidate/runtime.ts +134 -133
  124. package/src/server/dev-page-plugin.ts +454 -449
  125. package/src/server/render/assemble.ts +160 -133
  126. package/src/server/render/isr.ts +323 -317
  127. package/src/server/render/ssr.ts +585 -583
  128. package/src/server/router/plugin.ts +384 -384
  129. package/src/server/sync/config.ts +29 -0
  130. package/src/server/sync/index.ts +14 -0
  131. package/src/server/sync/plugin.ts +108 -0
  132. package/src/server/sync/stream.ts +144 -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,79 +1,80 @@
1
- import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
2
- import { join, relative } from "node:path";
3
- import type { BuildTarget } from "../config";
4
- import type { ResolvedRoute } from "../server/router/index.ts";
5
- import type { BuildRouteManifestEntry, TargetBuildManifest } from "./types";
6
-
7
- // import.meta.dir/path/url are inlined at bundle time to the OUTPUT file's
8
- // location — so relative paths break when bundled. import.meta.resolve() is a
9
- // function call (not inlined), runs at runtime, and resolves through package
10
- // exports. This is the Web-standard approach (Bun, Node 20.6+, browsers).
11
- export const CLIENT_MODULE_PATH = new URL(import.meta.resolve("@teyik0/furin/client")).pathname;
12
- export const LINK_MODULE_PATH = new URL(import.meta.resolve("@teyik0/furin/link")).pathname;
13
- export const SEARCH_MODULE_PATH = new URL(import.meta.resolve("@teyik0/furin/search")).pathname;
14
-
15
- export function ensureDir(path: string): void {
16
- if (!existsSync(path)) {
17
- mkdirSync(path, { recursive: true });
18
- }
19
- }
20
-
21
- export function toPosixPath(path: string): string {
22
- return path.replace(/\\/g, "/");
23
- }
24
-
25
- export function collectFilesRecursive(dir: string): string[] {
26
- const files: string[] = [];
27
- const entries = readdirSync(dir, { withFileTypes: true });
28
-
29
- for (const entry of entries) {
30
- const absolutePath = join(dir, entry.name);
31
- if (entry.isDirectory()) {
32
- files.push(...collectFilesRecursive(absolutePath));
33
- continue;
34
- }
35
- if (entry.isFile()) {
36
- files.push(absolutePath);
37
- }
38
- }
39
-
40
- return files.sort();
41
- }
42
-
43
- export function copyDirRecursive(sourceDir: string, targetDir: string): void {
44
- rmSync(targetDir, { force: true, recursive: true });
45
- cpSync(sourceDir, targetDir, { recursive: true });
46
- }
47
-
48
- export function toBuildRouteManifestEntry(
49
- route: ResolvedRoute,
50
- rootDir: string
51
- ): BuildRouteManifestEntry {
52
- return {
53
- pattern: route.pattern,
54
- mode: route.mode,
55
- pagePath: toPosixPath(relative(rootDir, route.path)),
56
- hasLayout: route.routeChain.some((entry) => !!entry.layout),
57
- hasStaticParams: !!route.page?.staticParams,
58
- revalidate: route.page?._route.revalidate ?? null,
59
- };
60
- }
61
-
62
- export function buildTargetManifest(
63
- rootDir: string,
64
- buildRoot: string,
65
- target: BuildTarget,
66
- serverEntry: string | null
67
- ): TargetBuildManifest {
68
- const targetDir = join(buildRoot, target);
69
-
70
- return {
71
- buildId: "", // populated by adapter after buildClient() completes
72
- generatedAt: new Date().toISOString(),
73
- targetDir: toPosixPath(relative(rootDir, targetDir)),
74
- clientDir: toPosixPath(relative(rootDir, join(targetDir, "client"))),
75
- templatePath: toPosixPath(relative(rootDir, join(targetDir, "client", "index.html"))),
76
- serverPath: null,
77
- serverEntry: serverEntry ? toPosixPath(relative(rootDir, serverEntry)) : null,
78
- };
79
- }
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
+ }