@teyik0/furin 0.1.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 (71) hide show
  1. package/dist/adapter/bun.d.ts +3 -0
  2. package/dist/build/client.d.ts +14 -0
  3. package/dist/build/compile-entry.d.ts +22 -0
  4. package/dist/build/entry-template.d.ts +13 -0
  5. package/dist/build/hydrate.d.ts +20 -0
  6. package/dist/build/index.d.ts +7 -0
  7. package/dist/build/index.js +2212 -0
  8. package/dist/build/route-types.d.ts +20 -0
  9. package/dist/build/scan-server.d.ts +8 -0
  10. package/dist/build/server-routes-entry.d.ts +22 -0
  11. package/dist/build/shared.d.ts +12 -0
  12. package/dist/build/types.d.ts +53 -0
  13. package/dist/cli/config.d.ts +9 -0
  14. package/dist/cli/index.d.ts +1 -0
  15. package/dist/cli/index.js +2240 -0
  16. package/dist/client.d.ts +158 -0
  17. package/dist/client.js +20 -0
  18. package/dist/config.d.ts +16 -0
  19. package/dist/config.js +23 -0
  20. package/dist/furin.d.ts +45 -0
  21. package/dist/furin.js +937 -0
  22. package/dist/internal.d.ts +18 -0
  23. package/dist/link.d.ts +119 -0
  24. package/dist/link.js +281 -0
  25. package/dist/plugin/index.d.ts +20 -0
  26. package/dist/plugin/index.js +1408 -0
  27. package/dist/plugin/transform-client.d.ts +9 -0
  28. package/dist/render/assemble.d.ts +13 -0
  29. package/dist/render/cache.d.ts +7 -0
  30. package/dist/render/element.d.ts +4 -0
  31. package/dist/render/index.d.ts +26 -0
  32. package/dist/render/loaders.d.ts +12 -0
  33. package/dist/render/shell.d.ts +17 -0
  34. package/dist/render/template.d.ts +4 -0
  35. package/dist/router.d.ts +32 -0
  36. package/dist/router.js +575 -0
  37. package/dist/runtime-env.d.ts +3 -0
  38. package/dist/tsconfig.dts.tsbuildinfo +1 -0
  39. package/dist/utils.d.ts +6 -0
  40. package/package.json +74 -0
  41. package/src/adapter/README.md +13 -0
  42. package/src/adapter/bun.ts +119 -0
  43. package/src/build/client.ts +110 -0
  44. package/src/build/compile-entry.ts +99 -0
  45. package/src/build/entry-template.ts +62 -0
  46. package/src/build/hydrate.ts +106 -0
  47. package/src/build/index.ts +120 -0
  48. package/src/build/route-types.ts +88 -0
  49. package/src/build/scan-server.ts +88 -0
  50. package/src/build/server-routes-entry.ts +38 -0
  51. package/src/build/shared.ts +80 -0
  52. package/src/build/types.ts +60 -0
  53. package/src/cli/config.ts +68 -0
  54. package/src/cli/index.ts +106 -0
  55. package/src/client.ts +237 -0
  56. package/src/config.ts +31 -0
  57. package/src/furin.ts +251 -0
  58. package/src/internal.ts +36 -0
  59. package/src/link.tsx +480 -0
  60. package/src/plugin/index.ts +80 -0
  61. package/src/plugin/transform-client.ts +372 -0
  62. package/src/render/assemble.ts +57 -0
  63. package/src/render/cache.ts +9 -0
  64. package/src/render/element.tsx +28 -0
  65. package/src/render/index.ts +312 -0
  66. package/src/render/loaders.ts +67 -0
  67. package/src/render/shell.ts +128 -0
  68. package/src/render/template.ts +54 -0
  69. package/src/router.ts +234 -0
  70. package/src/runtime-env.ts +6 -0
  71. package/src/utils.ts +68 -0
@@ -0,0 +1,9 @@
1
+ import MagicString from "magic-string";
2
+ interface TransformResult {
3
+ code: string;
4
+ map: ReturnType<MagicString["generateMap"]> | null;
5
+ removedServerCode: boolean;
6
+ }
7
+ export declare function deadCodeElimination(s: MagicString): MagicString;
8
+ export declare function transformForClient(code: string, filename: string): TransformResult;
9
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { RouteContext } from "../client";
2
+ import type { buildHeadInjection } from "./shell";
3
+ export type LoaderContext = RouteContext<Record<string, string>, Record<string, string>>;
4
+ export declare function resolvePath(pattern: string, params: Record<string, string>): string;
5
+ export declare function streamToString(stream: ReadableStream): Promise<string>;
6
+ interface SplitTemplate {
7
+ bodyPost: string;
8
+ bodyPre: string;
9
+ headPre: string;
10
+ }
11
+ export declare function splitTemplate(template: string): SplitTemplate;
12
+ export declare function assembleHTML(template: string, headData: ReturnType<typeof buildHeadInjection>, reactHtml: string, data: Record<string, unknown> | undefined): string;
13
+ export {};
@@ -0,0 +1,7 @@
1
+ export interface ISRCacheEntry {
2
+ generatedAt: number;
3
+ html: string;
4
+ revalidate: number;
5
+ }
6
+ export declare const isrCache: Map<string, ISRCacheEntry>;
7
+ export declare const ssgCache: Map<string, string>;
@@ -0,0 +1,4 @@
1
+ import type { ReactNode } from "react";
2
+ import type { RuntimeRoute } from "../client";
3
+ import type { ResolvedRoute } from "../router";
4
+ export declare function buildElement(route: ResolvedRoute, data: Record<string, unknown>, rootLayout: RuntimeRoute): ReactNode;
@@ -0,0 +1,26 @@
1
+ import type { RootLayout } from "../router.ts";
2
+ export { type LoaderContext, streamToString } from "./assemble.ts";
3
+ export { buildElement } from "./element.tsx";
4
+ export { type LoaderResult, runLoaders } from "./loaders.ts";
5
+ import type { Context } from "elysia";
6
+ import type { ResolvedRoute } from "../router.ts";
7
+ interface RenderResult {
8
+ headers: Record<string, string>;
9
+ html: string;
10
+ }
11
+ export declare function renderToHTML(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<RenderResult>;
12
+ export declare function renderToStream(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<ReadableStream | Response>;
13
+ export declare function prerenderSSG(route: ResolvedRoute, params: Record<string, string>, root: RootLayout, origin?: string): Promise<string>;
14
+ export declare function renderSSR(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<Response>;
15
+ export declare function handleISR(route: ResolvedRoute, ctx: Context, root: RootLayout): Promise<string | Response>;
16
+ /**
17
+ * Pre-renders all SSG routes that declare `staticParams` and populates the
18
+ * in-memory cache before the first real request arrives.
19
+ * Should be called from the Elysia `onStart` hook (production only).
20
+ *
21
+ * Uses a bounded worker pool (SSG_WARM_CONCURRENCY slots) so large sites
22
+ * with many routes × param sets cannot exhaust memory or CPU during startup.
23
+ * Failures are isolated per (route, params) pair and logged without aborting
24
+ * the rest of the warm-up.
25
+ */
26
+ export declare function warmSSGCache(routes: ResolvedRoute[], root: RootLayout, origin: string): Promise<void>;
@@ -0,0 +1,12 @@
1
+ import type { Context } from "elysia";
2
+ import type { RuntimeRoute } from "../client";
3
+ import type { ResolvedRoute } from "../router";
4
+ export type LoaderResult = {
5
+ type: "data";
6
+ data: Record<string, unknown>;
7
+ headers: Record<string, string>;
8
+ } | {
9
+ type: "redirect";
10
+ response: Response;
11
+ };
12
+ export declare function runLoaders(route: ResolvedRoute, ctx: Context, rootLayout: RuntimeRoute): Promise<LoaderResult>;
@@ -0,0 +1,17 @@
1
+ import type { HeadOptions, MetaDescriptor } from "../client.ts";
2
+ export declare function extractTitle(meta?: MetaDescriptor[]): string | undefined;
3
+ export declare function isMetaTag(entry: MetaDescriptor): boolean;
4
+ export declare function escapeHtml(str: string): string;
5
+ export declare function safeJson(value: unknown): string;
6
+ export declare function renderAttrs(obj: Record<string, string | undefined>): string;
7
+ export declare function buildMetaParts(meta: MetaDescriptor[]): string[];
8
+ export declare function buildLinkParts(links: NonNullable<HeadOptions["links"]>): string[];
9
+ export declare function buildScriptParts(scripts: NonNullable<HeadOptions["scripts"]>): string[];
10
+ export declare function buildStyleParts(styles: NonNullable<HeadOptions["styles"]>): string[];
11
+ /**
12
+ * Builds the string to inject into the <!--ssr-head--> placeholder.
13
+ * Handles title, meta tags, links, inline scripts, and inline styles from
14
+ * the page's `head()` function. CSS is handled by Bun (imported in user files).
15
+ */
16
+ export declare function buildHeadInjection(headData: HeadOptions | undefined): string;
17
+ export declare function generateIndexHtml(): string;
@@ -0,0 +1,4 @@
1
+ export declare function getDevTemplate(origin: string): Promise<string>;
2
+ export declare function setProductionTemplatePath(path: string | null): void;
3
+ export declare function setProductionTemplateContent(content: string): void;
4
+ export declare function getProductionTemplate(): string | null;
@@ -0,0 +1,32 @@
1
+ import { type AnyElysia } from "elysia";
2
+ import type { RuntimePage, RuntimeRoute } from "./client.ts";
3
+ import { type CompileContext } from "./internal.ts";
4
+ export interface ResolvedRoute {
5
+ isrCache?: {
6
+ html: string;
7
+ generatedAt: number;
8
+ revalidate: number;
9
+ };
10
+ mode: "ssr" | "ssg" | "isr";
11
+ page: RuntimePage;
12
+ path: string;
13
+ pattern: string;
14
+ routeChain: RuntimeRoute[];
15
+ ssgHtml?: string;
16
+ }
17
+ export interface RootLayout {
18
+ path: string;
19
+ route: RuntimeRoute;
20
+ }
21
+ export declare function createRoutePlugin(route: ResolvedRoute, root: RootLayout): AnyElysia;
22
+ export declare function scanRootLayout(pagesDir: string): Promise<RootLayout>;
23
+ export declare function scanPages(pagesDir: string): Promise<{
24
+ root: RootLayout;
25
+ routes: ResolvedRoute[];
26
+ }>;
27
+ export declare function loadProdRoutes(ctx: CompileContext): {
28
+ root: RootLayout;
29
+ routes: ResolvedRoute[];
30
+ };
31
+ export declare function resolveMode(page: RuntimePage, routeChain: RuntimeRoute[]): "ssr" | "ssg" | "isr";
32
+ export declare function filePathToPattern(path: string): string;