@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
package/dist/config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { BunPlugin } from "bun";
2
- export declare const BUILD_TARGETS: readonly ["bun", "node", "vercel", "cloudflare", "static"];
2
+ export declare const BUILD_TARGETS: readonly ["bun", "node", "vercel", "cloudflare", "static", "package"];
3
3
  export type BuildTarget = (typeof BUILD_TARGETS)[number];
4
4
  /**
5
5
  * Configuration for the `static` build target.
@@ -29,6 +29,15 @@ export interface StaticExportConfig {
29
29
  export declare const configSchema: import("@sinclair/typebox").TObject<{
30
30
  rootDir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
31
31
  pagesDir: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
32
+ /**
33
+ * Multi-instance builds: one entry per mounted furin app. Overrides
34
+ * `pagesDir` and server-entry auto-detection. `prefix` must match the
35
+ * `furin({ prefix })` the app is mounted with (`""`/absent = root).
36
+ */
37
+ apps: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
38
+ pagesDir: import("@sinclair/typebox").TString;
39
+ prefix: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
40
+ }>>>;
32
41
  serverEntry: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
33
42
  /**
34
43
  * Initialize the browser HTTP log drain in the hydration entry. Off by
@@ -37,7 +46,7 @@ export declare const configSchema: import("@sinclair/typebox").TObject<{
37
46
  * via the `furin({ logger })` plugin option).
38
47
  */
39
48
  clientLogging: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
40
- targets: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"bun" | "node" | "vercel" | "cloudflare" | "static">[]>>>;
49
+ targets: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"bun" | "node" | "vercel" | "cloudflare" | "static" | "package">[]>>>;
41
50
  bun: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
42
51
  compile: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"server">, import("@sinclair/typebox").TLiteral<"embed">]>>;
43
52
  }>>;
package/dist/config.js CHANGED
@@ -1,12 +1,16 @@
1
1
  // @bun
2
2
  // src/config.ts
3
3
  import { t } from "elysia";
4
- var BUILD_TARGETS = ["bun", "node", "vercel", "cloudflare", "static"];
4
+ var BUILD_TARGETS = ["bun", "node", "vercel", "cloudflare", "static", "package"];
5
5
  var buildTargetSchema = t.Union(BUILD_TARGETS.map((v) => t.Literal(v)));
6
6
  var compileTargetSchema = t.Union([t.Literal("server"), t.Literal("embed")]);
7
7
  var configSchema = t.Object({
8
8
  rootDir: t.Optional(t.String()),
9
9
  pagesDir: t.Optional(t.String()),
10
+ apps: t.Optional(t.Array(t.Object({
11
+ pagesDir: t.String(),
12
+ prefix: t.Optional(t.String())
13
+ }))),
10
14
  serverEntry: t.Optional(t.String()),
11
15
  clientLogging: t.Optional(t.Boolean()),
12
16
  targets: t.Optional(t.Array(buildTargetSchema)),
package/dist/furin.d.ts CHANGED
@@ -4,23 +4,16 @@ import { type FurinSyncOption } from "./server/sync/index.ts";
4
4
  export interface FurinCacheTags {
5
5
  }
6
6
  export type CacheTag = keyof FurinCacheTags extends never ? string : keyof FurinCacheTags;
7
- /**
8
- * Main Furin plugin.
9
- *
10
- * Returns a standalone Elysia instance (async function) so that routes are
11
- * properly registered in Elysia's router for SPA navigation to work.
12
- *
13
- * ## Usage
14
- *
15
- * ```ts
16
- * new Elysia()
17
- * .use(await furin({ ... }))
18
- * .listen(3000)
19
- * ```
20
- */
21
- export declare function furin({ pagesDir, logger, clientLogging, sync, }: {
22
- pagesDir?: string;
23
- logger?: EvlogElysiaOptions;
7
+ export { clientDirNameForPrefix } from "./shared/prefix.ts";
8
+ /** Options for the {@link furin} plugin. */
9
+ export interface FurinOptions {
10
+ /**
11
+ * Production only: explicit directory holding this app's built client
12
+ * assets (chunks + index.html template). Packaged furin apps pass their own
13
+ * `dist/furin/client` here; when omitted the directory is auto-resolved
14
+ * next to the server artifact.
15
+ */
16
+ clientDir?: string;
24
17
  /**
25
18
  * Initialize the browser HTTP log drain in the hydration entry. Off by
26
19
  * default — enabling it adds `evlog/http` drain setup and points browser
@@ -28,13 +21,38 @@ export declare function furin({ pagesDir, logger, clientLogging, sync, }: {
28
21
  * and unaffected.
29
22
  */
30
23
  clientLogging?: boolean;
24
+ logger?: EvlogElysiaOptions;
25
+ pagesDir?: string;
26
+ /**
27
+ * Mount prefix for this app, e.g. `"/admin"`. All pages, framework
28
+ * endpoints (`/_furin/*`) and client assets (`/_client/*`) are served under
29
+ * it, and the client bundle is built with the matching basePath. Defaults
30
+ * to `""` (root). Mounting two furin instances on the same prefix throws.
31
+ */
32
+ prefix?: string;
31
33
  /**
32
34
  * Enables Furin's built-in sync event stream. The opinionated default mounts
33
35
  * Server-Sent Events at `/_furin/sync`; pass an object only for constrained
34
36
  * reverse-proxy deployments that need a custom internal path.
35
37
  */
36
38
  sync?: FurinSyncOption;
37
- }): Promise<Elysia<"", {
39
+ }
40
+ /**
41
+ * Main Furin plugin.
42
+ *
43
+ * Returns a standalone Elysia instance (async function) so that routes are
44
+ * properly registered in Elysia's router for SPA navigation to work.
45
+ *
46
+ * ## Usage
47
+ *
48
+ * ```ts
49
+ * new Elysia()
50
+ * .use(await furin({ pagesDir: "./src/pages" }))
51
+ * .use(await furin({ pagesDir: "./src/admin", prefix: "/admin" }))
52
+ * .listen(3000)
53
+ * ```
54
+ */
55
+ export declare function furin({ pagesDir, prefix: rawPrefix, clientDir: explicitClientDir, logger, clientLogging, sync, }?: FurinOptions): Promise<Elysia<"", {
38
56
  decorator: {};
39
57
  store: {};
40
58
  derive: {};