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

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 (67) hide show
  1. package/dist/adapter/bun.d.ts +17 -1
  2. package/dist/adapter/package.d.ts +26 -0
  3. package/dist/build/client.d.ts +1 -1
  4. package/dist/build/compile-entry.d.ts +3 -3
  5. package/dist/build/compile-entry.ts +88 -83
  6. package/dist/build/entry-template.d.ts +35 -9
  7. package/dist/build/entry-template.ts +106 -56
  8. package/dist/build/hydrate.d.ts +1 -1
  9. package/dist/build/index.js +643 -247
  10. package/dist/build/scan-server.d.ts +10 -4
  11. package/dist/build/server-routes-entry.d.ts +3 -3
  12. package/dist/build/server-routes-entry.ts +5 -11
  13. package/dist/build/ssg-cache.d.ts +1 -1
  14. package/dist/build/types.d.ts +36 -1
  15. package/dist/cli/config.d.ts +6 -1
  16. package/dist/cli/index.js +662 -260
  17. package/dist/config.d.ts +11 -2
  18. package/dist/config.js +5 -1
  19. package/dist/furin.d.ts +36 -18
  20. package/dist/furin.js +630 -310
  21. package/dist/server/auto-invalidate/registry.d.ts +8 -1
  22. package/dist/server/cache/dev-loader.d.ts +3 -2
  23. package/dist/server/cache/invalidation.d.ts +19 -0
  24. package/dist/server/cache/isr.d.ts +6 -2
  25. package/dist/server/cache/registry.d.ts +3 -3
  26. package/dist/server/cache/ssg.d.ts +6 -2
  27. package/dist/server/cache/store-view.d.ts +11 -0
  28. package/dist/server/instance.d.ts +86 -0
  29. package/dist/server/internal.d.ts +16 -1
  30. package/dist/server/internal.js +72 -5
  31. package/dist/server/render/template.d.ts +3 -2
  32. package/dist/server/sync/config.d.ts +11 -0
  33. package/dist/server/sync/stream.d.ts +8 -1
  34. package/dist/shared/prefix.d.ts +15 -0
  35. package/package.json +6 -1
  36. package/src/adapter/bun.ts +113 -50
  37. package/src/adapter/package.ts +206 -0
  38. package/src/build/client.ts +9 -3
  39. package/src/build/compile-entry.ts +88 -83
  40. package/src/build/entry-template.ts +106 -56
  41. package/src/build/hydrate.ts +4 -2
  42. package/src/build/index.ts +99 -28
  43. package/src/build/scan-server.ts +23 -7
  44. package/src/build/server-routes-entry.ts +5 -11
  45. package/src/build/ssg-cache.ts +6 -2
  46. package/src/build/types.ts +37 -1
  47. package/src/cli/config.ts +9 -3
  48. package/src/cli/index.ts +21 -3
  49. package/src/config.ts +14 -1
  50. package/src/furin.ts +297 -143
  51. package/src/server/auto-invalidate/registry.ts +23 -1
  52. package/src/server/auto-invalidate/runtime.ts +29 -4
  53. package/src/server/cache/dev-loader.ts +77 -38
  54. package/src/server/cache/invalidation.ts +71 -30
  55. package/src/server/cache/isr.ts +20 -5
  56. package/src/server/cache/registry.ts +17 -20
  57. package/src/server/cache/ssg.ts +19 -4
  58. package/src/server/cache/store-view.ts +30 -0
  59. package/src/server/instance.ts +252 -0
  60. package/src/server/internal.ts +100 -5
  61. package/src/server/render/not-found.ts +9 -3
  62. package/src/server/render/ssr.ts +16 -4
  63. package/src/server/render/template.ts +57 -24
  64. package/src/server/sync/config.ts +32 -1
  65. package/src/server/sync/plugin.ts +4 -5
  66. package/src/server/sync/stream.ts +19 -9
  67. package/src/shared/prefix.ts +38 -0
@@ -1,8 +1,14 @@
1
+ export interface ScannedFurinInstance {
2
+ pagesDir: string;
3
+ /** Normalized mount prefix (`""` when absent). */
4
+ prefix: string;
5
+ }
1
6
  /**
2
- * Statically scans a server entry file and returns all `pagesDir` string
3
- * literal values found inside `furin({ pagesDir: "..." })` call expressions.
7
+ * Statically scans a server entry file and returns the `pagesDir` (and
8
+ * optional `prefix`) string literals found inside `furin({ pagesDir: "..." })`
9
+ * call expressions.
4
10
  *
5
- * Dynamic paths (template literals, variables) are silently ignored.
11
+ * Dynamic values (template literals, variables) are silently ignored.
6
12
  * Returns an empty array when nothing is detected.
7
13
  */
8
- export declare function scanFurinInstances(serverEntryPath: string): string[];
14
+ export declare function scanFurinInstances(serverEntryPath: string): ScannedFurinInstance[];
@@ -3,9 +3,9 @@ import { type BuildEntryOptions } from "./entry-template";
3
3
  * Generates `server.ts` — an intermediate entry used to produce `server.js`.
4
4
  *
5
5
  * Equivalent to `_compile-entry.ts` but for disk (non-binary) production builds:
6
- * 1. Statically imports every page module so Bun bundles them into server.js
7
- * 2. Sets production mode and registers everything in a single CompileContext
8
- * 3. Imports server.ts to boot the app
6
+ * 1. Statically imports every page module of every app so Bun bundles them
7
+ * 2. Sets production mode and registers one CompileContext PER APP
8
+ * 3. Imports server.ts to boot the composed app
9
9
  *
10
10
  * This file is intermediate: `adapter/bun.ts` runs `Bun.build()` on it to produce
11
11
  * the self-contained `server.js` bundle, then deletes this file.
@@ -7,26 +7,20 @@ import { ensureDir } from "./shared";
7
7
  * Generates `server.ts` — an intermediate entry used to produce `server.js`.
8
8
  *
9
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
10
+ * 1. Statically imports every page module of every app so Bun bundles them
11
+ * 2. Sets production mode and registers one CompileContext PER APP
12
+ * 3. Imports server.ts to boot the composed app
13
13
  *
14
14
  * This file is intermediate: `adapter/bun.ts` runs `Bun.build()` on it to produce
15
15
  * the self-contained `server.js` bundle, then deletes this file.
16
16
  */
17
17
  export function generateServerRoutesEntry(options: BuildEntryOptions): string {
18
- const { buildId, outDir, rootPath, routes, serverEntry, rootConventions, routeMetadata, ssgCache } =
19
- options;
18
+ const { apps, outDir, serverEntry } = options;
20
19
  ensureDir(outDir);
21
20
  const source = buildEntrySource({
22
- buildId,
21
+ apps: apps.map(({ embed: _embed, ...context }) => context),
23
22
  headerComment: "// Auto-generated by furin build — do not edit",
24
- rootPath,
25
- routes,
26
23
  serverEntry,
27
- rootConventions,
28
- routeMetadata,
29
- ssgCache,
30
24
  });
31
25
 
32
26
  // Named "server.ts" so Bun.build() outputs "server.js"
@@ -1,4 +1,4 @@
1
1
  import type { SsgCacheEntry } from "../server/cache/index.ts";
2
2
  import { type ResolvedRoute, type RootLayout } from "../server/router/index.ts";
3
3
  export type SSGCacheSnapshot = Record<string, SsgCacheEntry>;
4
- export declare function buildSSGCacheSnapshot(routes: ResolvedRoute[], root: RootLayout, origin: string): Promise<SSGCacheSnapshot>;
4
+ export declare function buildSSGCacheSnapshot(routes: ResolvedRoute[], root: RootLayout, origin: string, basePath?: string): Promise<SSGCacheSnapshot>;
@@ -7,6 +7,11 @@ export interface BuildClientOptions {
7
7
  * correct physical URLs. Pass "" for root deployments.
8
8
  */
9
9
  basePath: string;
10
+ /**
11
+ * On-disk client dir name under outDir (default "client"). Multi-instance
12
+ * builds pass "client-<slug>" per mounted app.
13
+ */
14
+ clientDirName?: string;
10
15
  /** Inject the evlog client logger into the hydrate entry. Off by default. */
11
16
  clientLogging: boolean;
12
17
  outDir: string;
@@ -19,6 +24,12 @@ export interface BuildClientOptions {
19
24
  */
20
25
  publicPath: string;
21
26
  rootLayout: string;
27
+ /**
28
+ * Skip furin-env.d.ts generation. Set for non-root instances in
29
+ * multi-instance dev — the file lives at the project root and only the root
30
+ * app owns it.
31
+ */
32
+ skipRouteTypes?: boolean;
22
33
  }
23
34
  export interface BuildRouteManifestEntry {
24
35
  hasLayout: boolean;
@@ -37,8 +48,27 @@ export interface TargetBuildManifest {
37
48
  targetDir: string;
38
49
  templatePath: string | null;
39
50
  }
40
- export type AnyTargetManifest = TargetBuildManifest | StaticTargetBuildManifest;
51
+ /** Build manifest entry produced by the `package` adapter. */
52
+ export interface PackageTargetBuildManifest {
53
+ buildId: string;
54
+ generatedAt: string;
55
+ prefix: string;
56
+ targetDir: string;
57
+ }
58
+ export type AnyTargetManifest = TargetBuildManifest | StaticTargetBuildManifest | PackageTargetBuildManifest;
59
+ /** One mounted app in a multi-instance build. */
60
+ export interface BuildAppSpec {
61
+ pagesDir: string;
62
+ /** Mount prefix (`""` or absent = root). */
63
+ prefix?: string;
64
+ }
41
65
  export interface BuildManifest {
66
+ /** Every mounted app built into this artifact (multi-instance). */
67
+ apps?: Array<{
68
+ pagesDir: string;
69
+ prefix: string;
70
+ routes: BuildRouteManifestEntry[];
71
+ }>;
42
72
  generatedAt: string;
43
73
  pagesDir: string;
44
74
  rootDir: string;
@@ -49,6 +79,11 @@ export interface BuildManifest {
49
79
  version: 1;
50
80
  }
51
81
  export interface BuildAppOptions {
82
+ /**
83
+ * Explicit multi-app build (furin.config.ts `apps`). Overrides `pagesDir`
84
+ * and server-entry auto-detection.
85
+ */
86
+ apps?: BuildAppSpec[];
52
87
  /** Inject the evlog client logger into the hydrate entry. Defaults to false. */
53
88
  clientLogging?: boolean;
54
89
  compile?: "server" | "embed";
@@ -1,7 +1,12 @@
1
1
  import { type FurinConfig } from "../config.ts";
2
2
  interface ResolvedCliConfig extends FurinConfig {
3
3
  configPath: string | null;
4
- pagesDir: string;
4
+ /**
5
+ * Only set when the config file declares one — leaving it undefined lets
6
+ * buildApp fall back to scanning server.ts for `furin({ pagesDir, prefix })`
7
+ * calls (multi-instance detection).
8
+ */
9
+ pagesDir?: string;
5
10
  plugins?: Bun.BunPlugin[];
6
11
  rootDir: string;
7
12
  }